Changeset 25674


Ignore:
Timestamp:
Nov 24, 2013, 2:48:30 PM (7 years ago)
Author:
mistic100
Message:

fixc empty share key field after addition
fix javascript errors

Location:
extensions/UserCollections
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserCollections/include/UserCollection.class.php

    r24421 r25674  
    327327   * @return: array errors
    328328   */
    329   function addShare($share, $abord_on_duplicate=true)
     329  function addShare(&$share, $abord_on_duplicate=true)
    330330  {
    331331    global $conf, $page;
     
    342342    else
    343343    {
    344       $share['share_key'] = $this->data['id'].'-'.str2url($share['share_key']);
     344      $share['share_key'] = str2url($share['share_key']);
     345      $share_key = $this->data['id'].'-'.$share['share_key'];
    345346     
    346347      $query = '
    347348SELECT id FROM '.COLLECTION_SHARES_TABLE.'
    348349  WHERE col_id = '.$this->data['id'].'
    349   AND share_key = "'.$share['share_key'].'"
     350  AND share_key = "'.$share_key.'"
    350351;';
    351352      $result = pwg_query($query);
     
    358359        else
    359360        {
    360           return USER_COLLEC_PUBLIC . 'view/' . $share['share_key'];
     361          return USER_COLLEC_PUBLIC . 'view/' . $share_key;
    361362        }
    362363      }
     
    373374    if (!empty($share['password']))
    374375    {
    375       $share['password'] = sha1($conf['secret_key'].$share['password'].$share['share_key']);
     376      $share['password'] = sha1($conf['secret_key'].$share['password'].$share_key);
    376377    }
    377378   
     
    392393  VALUES(
    393394    '.$this->data['id'].',
    394     "'.$share['share_key'].'",
     395    "'.$share_key.'",
    395396    "'.pwg_db_real_escape_string($params).'",
    396397    "'.date('Y-m-d H:i:s').'"
     
    399400      pwg_query($query);
    400401     
    401       return USER_COLLEC_PUBLIC . 'view/' . $share['share_key'];
     402      return USER_COLLEC_PUBLIC . 'view/' . $share_key;
    402403    }
    403404   
  • extensions/UserCollections/include/collections.inc.php

    r24421 r25674  
    124124    if ($conf['user_collections']['allow_public'])
    125125    {
    126       $share = array(
    127         'share_key' => get_random_key(16),
    128         'password' => null,
    129         'deadline' => null,
    130         );
    131      
    132126      if (isset($_POST['add_share']))
    133127      {
     
    165159        $share['open'] = true;
    166160      }
    167      
     161
     162      if (!isset($share['share_key']))
     163      {
     164        $share['share_key'] = get_random_key(16);
     165        $share['password'] = null;
     166        $share['deadline'] = null;
     167      }
     168
    168169      $template->assign('share', $share);
    169170    }
  • extensions/UserCollections/include/install.inc.php

    r24421 r25674  
    9393   
    9494    mass_inserts($prefixeTable.'collection_shares',
    95       array('col_id','share_key','add_date'),
     95      array('col_id','share_key','params','add_date'),
    9696      $inserts
    9797      );
  • extensions/UserCollections/template/collection_edit.tpl

    r24421 r25674  
    1818
    1919
    20 <script>
    2120{footer_script require='jquery,jquery.ui.timepicker'}
     21var bg_color = $('#the_page #content').css('background-color');
     22if (!bg_color || bg_color=='transparent') {ldelim}
     23  bg_color = $('body').css('background-color');
     24}
     25
    2226{if isset($U_SHARE)}
    2327{literal}
     
    6771  $share_form.find('.set_share_key').on('click', function() {
    6872      if ($share_form.find('input[name="share_key"]').val().length < 8) {
    69           alert("{/literal}{'The key must be at least 8 characters long'|@translate}{literal}");
     73          alert("{/literal}{'The key must be at least 8 characters long'|@translate|escape:javascript}{literal}");
    7074      }
    7175      else {
     
    107111    return false;
    108112  });
    109   jQuery("#share_form").css('background-color', jQuery("#the_page #content").css('background-color'));
     113  jQuery("#share_form").css('background-color', bg_color);
    110114{/literal}
    111115{/if}
     
    121125    return false;
    122126  });
    123   jQuery("#mail_form").css('background-color', jQuery("#the_page #content").css('background-color'));
     127 
     128 
     129  jQuery("#mail_form").css('background-color', bg_color);
    124130{/literal}
    125131{/if}
     
    138144{/literal}
    139145{/footer_script}
    140 </script>
    141146
    142147
  • extensions/UserCollections/template/thumbnails_colorbox.tpl

    r24421 r25674  
    1010  title: function() {ldelim}
    1111    var title = $(this).children("img.thumbnail").attr("alt");
    12     {if $F_ACTION} title+= ' · <a class="addCollection" data-id="'+ $(this).data('id') +'" rel="nofollow">{'Remove from collection'|@translate}</a>';{/if}
    13     title+= ' · <a href="'+ $(this).attr('href') +'" target="_blank">{'jump to photo'|@translate} →</a>';
     12    {if $F_ACTION} title+= ' · <a class="addCollection" data-id="'+ $(this).data('id') +'" rel="nofollow">{'Remove from collection'|@translate|escape:javascript}</a>';{/if}
     13    title+= ' · <a href="'+ $(this).attr('href') +'" target="_blank">{'jump to photo'|@translate|escape:javascript} →</a>';
    1414    return  title;
    1515  }
  • extensions/UserCollections/template/thumbnails_css_js.tpl

    r24421 r25674  
    2323  // ENTER or ESC pressed
    2424  "keyup": function(event) {ldelim}
    25     if (event.which == 27) {
     25    if (event.which == 27) {ldelim}
    2626      jQuery(this).val('').hide().prev().show();
    2727      return;
     
    161161  <div class="switchBoxFooter">
    162162  <span>&#10010;</span> <a class="new">{'Create a new collection'|@translate}</a>
    163   <input class="new" placeholder="{'Name'|@translate}" size="25"/>
     163  <input type="text" class="new" placeholder="{'Name'|@translate}" size="25"/>
    164164  </div>
    165165</div>
Note: See TracChangeset for help on using the changeset viewer.