Changeset 24421


Ignore:
Timestamp:
Sep 11, 2013, 6:44:54 PM (11 years ago)
Author:
mistic100
Message:

new system for shares : password protection, link timeout, management popup + for mails
handle lightbox conflicts
menublock is visible by AMM

Location:
extensions/UserCollections
Files:
42 added
2 deleted
23 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserCollections/admin/config.php

    r23551 r24421  
    55{
    66  $conf['user_collections'] = array(
    7     'allow_mails'     => isset($_POST['allow_mails']),
    87    'allow_public'    => isset($_POST['allow_public']),
     8    'allow_mails'     => isset($_POST['allow_mails']) && isset($_POST['allow_public']),
    99    );
    1010 
  • extensions/UserCollections/admin/export.php

    r23551 r24421  
    33
    44try {
    5   $UserCollection = new UserCollection($_GET['col_id']);
     5  $collection = new UserCollection($_GET['col_id']);
    66 
    77  $template->assign('COL_ID', $_GET['col_id']);
     
    2020  pwg_set_session_var('uc_export_inactive_fields', $_POST['inactive']);
    2121 
    22   $content = $UserCollection->serialize($_POST['active']);
     22  $content = $collection->serialize($_POST['active']);
    2323  $filename = 'collection_'.$_GET['col_id'].'_'.date('Ymd-Hi').'.csv';
    2424 
  • extensions/UserCollections/admin/sets.php

    r23551 r24421  
    5050    'DATE_CREATION' => format_date($row['date_creation'], true),
    5151    'USERNAME' => $row['username'],
    52     'IS_PUBLIC' => (bool)$row['public'],
    53     'U_PUBLIC' => USER_COLLEC_PUBLIC . 'view/'.$row['public_id'],
    5452    'U_EDIT' => USER_COLLEC_PUBLIC . 'edit/'.$row['id'],
    5553    'U_EXPORT' => USER_COLLEC_ADMIN . '-export&col_id='.$row['id'],
  • extensions/UserCollections/admin/template/config.tpl

    r20090 r24421  
    11{combine_css path=$USER_COLLEC_PATH|@cat:"admin/template/style.css"}
     2
     3{footer_script}{literal}
     4$("input[name='allow_public']").on("change", function() {
     5    $("#allow_mails").toggle($(this).is(":checked"));
     6});
     7{/literal}{/footer_script}
    28
    39<div class="titrePage">
     
    1420      </label>
    1521    </li>
    16     <li>
     22    <li id="allow_mails" {if not $user_collections.allow_public}style="display:none;"{/if}>
    1723      <label>
    1824        <input type="checkbox" name="allow_mails" {if $user_collections.allow_mails}checked="checked"{/if}>
  • extensions/UserCollections/admin/template/sets.tpl

    r23551 r24421  
    3838      <td class="name">{'Name'|@translate}</td>
    3939      <td class="user">{'Username'|@translate}</td>
    40       <td class="status">{'Public'|@translate}</td>
    4140      <td class="date">{'Creation date'|@translate}</td>
    4241      <td class="images">{'Number of images'|@translate}</td>
     
    4847  <tr class="{if $smarty.foreach.sets_loop.index is odd}row1{else}row2{/if}">
    4948    <td>
    50       <a href="{$set.U_PUBLIC}">{$set.NAME}</a>
     49      <a href="{$set.U_EDIT}">{$set.NAME}</a>
    5150    </td>
    5251    <td>{$set.USERNAME}</td>
    53     <td style="text-align:center;">{if $set.IS_PUBLIC}{'Yes'|@translate}{else}{'No'|@translate}{/if}</td>
    5452    <td style="text-align:center;">{$set.DATE_CREATION}</td>
    5553    <td>{$set.NB_IMAGES}</td>
  • extensions/UserCollections/include/UserCollection.class.php

    r23552 r24421  
    1212   * @param: array images
    1313   */
    14   function __construct($col_id, $name=null, $comment=null, $public=false, $user_id=null)
     14  function __construct($col_id, $name=null, $comment=null, $user_id=null)
    1515  {
    1616    global $user;
    1717   
    18     if (empty($user_id)) {
     18    if (empty($user_id))
     19    {
    1920      $user_id = $user['id'];
    2021    }
     
    2728      'comment' => null,
    2829      'nb_images' => 0,
    29       'public' => 0,
    30       'public_id' => null,
    3130      );
    3231    $this->images = array();
    33    
    34     // access from public id (access permission is checked line 66)
    35     if ( strlen($col_id) == 10 and strpos($col_id, 'uc') === 0 )
    36     {
    37       $query = '
    38 SELECT id
    39   FROM '.COLLECTIONS_TABLE.'
    40   WHERE public_id = "'.$col_id.'"
    41 ;';
    42       $result = pwg_query($query);
    43      
    44       if (!pwg_db_num_rows($result))
    45       {
    46         $col_id = 0;
    47       }
    48       else
    49       {
    50         list($col_id) = pwg_db_fetch_row($result);
    51       }
    52     }
    5332   
    5433    // load specific collection
     
    5837SELECT *
    5938  FROM '.COLLECTIONS_TABLE.'
    60   WHERE
    61     id = '.$col_id.'
    62     '.(!is_admin() ? 'AND (user_id = '.$this->data['user_id'].' OR public = 1)' : null).'
     39  WHERE id = '.$col_id.'
    6340;';
    6441      $result = pwg_query($query);
     
    9269      else
    9370      {
    94         throw new Exception(l10n('Invalid collection'));
     71        throw new Exception(l10n('Invalid collection'), WS_ERR_INVALID_PARAM);
    9572      }
    9673    }
     
    10077      $this->data['name'] = $name;
    10178      $this->data['comment'] = $comment;
    102       $this->data['public'] = (int)$public;
    103       $this->data['public_id'] = 'uc'.hash('crc32', uniqid(serialize($this->data), true));
    10479     
    10580      $query = '
     
    10883    name,
    10984    date_creation,
    110     comment,
    111     public,
    112     public_id
     85    comment
    11386  )
    11487  VALUES(
     
    11689    "'.$this->data['name'].'",
    11790    NOW(),
    118     "'.$this->data['comment'].'",
    119     '.(int)$this->data['public'].',
    120     "'.$this->data['public_id'].'"
     91    "'.$this->data['comment'].'"
    12192  )
    12293;';
     
    130101    {
    131102      trigger_error('UserCollection::__construct, invalid input parameter', E_USER_ERROR);
     103    }
     104  }
     105 
     106  /**
     107   * check if current user is owner of the collection or admin
     108   */
     109  function checkUser()
     110  {
     111    global $user;
     112   
     113    if (!is_admin() && $user['id'] != $this->data['user_id'])
     114    {
     115      throw new Exception('Forbidden', 403);
    132116    }
    133117  }
     
    280264      'COMMENT' => $this->data['comment'],
    281265      'NB_IMAGES' => $this->data['nb_images'],
    282       'PUBLIC' => (bool)$this->data['public'],
    283266      'DATE_CREATION' => $this->data['date_creation'],
    284       'U_PUBLIC' => USER_COLLEC_PUBLIC . 'view/'.$this->data['public_id'],
    285267      );
    286268   
    287269    return $set;
     270  }
     271 
     272  /**
     273   * get share links
     274   */
     275  function getShares()
     276  {
     277    $query = '
     278SELECT * FROM '.COLLECTION_SHARES_TABLE.'
     279  WHERE col_id = '.$this->data['id'].'
     280  ORDER BY add_date DESC
     281;';
     282    $result = pwg_query($query);
     283   
     284    $shares = array();
     285    while ($row = pwg_db_fetch_assoc($result))
     286    {
     287      $row['expired'] = false;
     288     
     289      $row['params'] = unserialize($row['params']);
     290      if (!empty($row['params']['deadline']))
     291      {
     292        $row['expired'] = strtotime($row['params']['deadline']) < time();
     293        $row['params']['deadline_readable'] = format_date($row['params']['deadline'], true, false);
     294      }
     295     
     296      $row['url'] = USER_COLLEC_PUBLIC . 'view/' . $row['share_key'];
     297      $row['u_delete'] = USER_COLLEC_PUBLIC . 'edit/' . $this->data['id'] . '&amp;delete_share=' . $row['id'];
     298      $row['add_date_readable'] = format_date($row['add_date'], true, false);
     299     
     300      $shares[] = $row;
     301    }
     302   
     303    return $shares;
     304  }
     305 
     306  /**
     307   * delete a share
     308   */
     309  function deleteShare($id)
     310  {
     311    $query = '
     312DELETE FROM '.COLLECTION_SHARES_TABLE.'
     313  WHERE id = "'.pwg_db_real_escape_string($id).'"
     314  AND col_id = '.$this->data['id'].'
     315;';
     316    pwg_query($query);
     317   
     318    return pwg_db_changes() != 0;
     319  }
     320 
     321  /**
     322   * Add a share URL
     323   * @param: array
     324   *          - share_key
     325   *          - password
     326   *          - deadline
     327   * @return: array errors
     328   */
     329  function addShare($share, $abord_on_duplicate=true)
     330  {
     331    global $conf, $page;
     332   
     333    $errors = array();
     334   
     335    $share = array_map('stripslashes', $share);
     336   
     337    // check key
     338    if (empty($share['share_key']) || strlen($share['share_key']) < 8)
     339    {
     340      $errors[] = l10n('The key must be at least 8 characters long');
     341    }
     342    else
     343    {
     344      $share['share_key'] = $this->data['id'].'-'.str2url($share['share_key']);
     345     
     346      $query = '
     347SELECT id FROM '.COLLECTION_SHARES_TABLE.'
     348  WHERE col_id = '.$this->data['id'].'
     349  AND share_key = "'.$share['share_key'].'"
     350;';
     351      $result = pwg_query($query);
     352      if (pwg_db_num_rows($result))
     353      {
     354        if ($abord_on_duplicate)
     355        {
     356          $errors[] = l10n('This key is already used');
     357        }
     358        else
     359        {
     360          return USER_COLLEC_PUBLIC . 'view/' . $share['share_key'];
     361        }
     362      }
     363    }
     364   
     365    // filter date
     366    if (!empty($share['deadline']))
     367    {
     368      $date = DateTime::createFromFormat('Y-m-d H:i', $share['deadline']);
     369      $share['deadline'] = $date->format('Y-m-d H:i');
     370    }
     371   
     372    // hash password
     373    if (!empty($share['password']))
     374    {
     375      $share['password'] = sha1($conf['secret_key'].$share['password'].$share['share_key']);
     376    }
     377   
     378    if (empty($errors))
     379    {
     380      $params = serialize(array(
     381        'password' => @$share['password'],
     382        'deadline' => @$share['deadline'],
     383        ));
     384     
     385      $query = '
     386INSERT INTO '.COLLECTION_SHARES_TABLE.'(
     387    col_id,
     388    share_key,
     389    params,
     390    add_date
     391  )
     392  VALUES(
     393    '.$this->data['id'].',
     394    "'.$share['share_key'].'",
     395    "'.pwg_db_real_escape_string($params).'",
     396    "'.date('Y-m-d H:i:s').'"
     397  )
     398;';
     399      pwg_query($query);
     400     
     401      return USER_COLLEC_PUBLIC . 'view/' . $share['share_key'];
     402    }
     403   
     404    return $errors;
    288405  }
    289406 
     
    299416   * @return: array errors
    300417   */
    301   function sendEmail($comm, $key)
    302   {
    303     global $conf, $page, $template;
     418  function sendEmail($comm)
     419  {
     420    global $conf;
    304421   
    305422    $errors = array();
     
    308425
    309426    $comment_action='validate';
    310    
    311     // check key
    312     if (!verify_ephemeral_key(@$key))
    313     {
    314       array_push($errors, l10n('Invalid key'));
    315       $comment_action='reject';
    316     }
    317427
    318428    // check author
     
    393503      {
    394504        array_push($errors, l10n('Error while sending e-mail'));
     505      }
     506      else
     507      {
     508        return true;
    395509      }
    396510    }
     
    454568    $mail_css = file_get_contents(dirname(__FILE__).'/../template/mail.css');
    455569   
     570    $share_key = 'mail-' . substr(sha1($this->data['id'].$conf['secret_key']), 0, 11);
     571   
    456572    $template->assign(array(
    457573      'GALLERY_URL' => get_gallery_home_url(),
     
    459575      'UC_MAIL_CSS' => str_replace("\n", null, $mail_css),
    460576      'MAIL_TITLE' => $this->getParam('name').' ('.sprintf(l10n('by %s'), $params['sender_name']).')',
    461       'COL_URL' => USER_COLLEC_PUBLIC . 'view/'.$this->data['public_id'],
     577      'COL_URL' => $this->addShare(array('share_key'=>$share_key), false),
    462578      'PARAMS' => $params,
    463579      'derivative_params' => ImageStdParams::get_by_type(IMG_SQUARE),
     
    518634          {
    519635          case 'name':
    520             $element[] = render_element_name($row); break;
     636            $element[] = render_element_name($row);
     637            break;
    521638          case 'url':
    522             $element[] = make_picture_url(array('image_id'=>$row['id'], 'image_file'=>$row['file'])); break;
     639            $element[] = make_picture_url(array('image_id'=>$row['id'], 'image_file'=>$row['file']));
     640            break;
    523641          case 'path':
    524             $element[] = $root_url.ltrim($row['path'], './'); break;
     642            $element[] = $root_url.ltrim($row['path'], './');
     643            break;
    525644          default:
    526             $element[] = $row[$field]; break;
     645            $element[] = $row[$field];
     646            break;
    527647          }
    528648        }
  • extensions/UserCollections/include/collections.inc.php

    r23551 r24421  
    22defined('USER_COLLEC_PATH') or die('Hacking attempt!');
    33
    4 # this file is called on basket public page #
    5 
    6 global $page, $template, $conf, $user, $tokens, $pwg_loaded_plugins;
     4global $page, $template, $conf, $user;
    75
    86$template->assign(array(
     
    119  ));
    1210
     11
    1312switch ($page['sub_section'])
    1413{
    15   /* list */
    16   case 'list':
    17   {
    18     // security
    19     if (is_a_guest()) access_denied();
    20    
    21     $template->set_filename('index', realpath(USER_COLLEC_PATH.'template/collections_list.tpl'));
    22    
    23     // actions
    24     if ( isset($_GET['action']) and preg_match('#^([0-9]+)$#', $_GET['col_id']) )
    25     {
    26       switch ($_GET['action'])
    27       {
    28         // new
    29         case 'new':
    30         {
    31           if (empty($_GET['name']))
     14// +-----------------------------------------------------------------------+
     15// | Collections list                                                      |
     16// +-----------------------------------------------------------------------+
     17case 'list':
     18{
     19  if (is_a_guest())
     20  {
     21    access_denied();
     22  }
     23 
     24  $template->set_filename('index', realpath(USER_COLLEC_PATH.'template/collections_list.tpl'));
     25 
     26  // actions
     27  if ( isset($_GET['action']) and preg_match('#^([0-9]+)$#', $_GET['col_id']) )
     28  {
     29    switch ($_GET['action'])
     30    {
     31      ## new collection ##
     32      case 'new':
     33      {
     34        if (empty($_GET['name']))
     35        {
     36          $page['errors'][] = l10n('Please give a name');
     37        }
     38        else
     39        {
     40          $collection = new UserCollection('new', $_GET['name']);
     41         
     42          if (isset($_GET['redirect']))
    3243          {
    33             array_push($page['errors'], l10n('Please give a name'));
     44            $redirect = USER_COLLEC_PUBLIC . 'edit/' . $collection->getParam('id');
    3445          }
    3546          else
    3647          {
    37             $UserCollection = new UserCollection('new', $_GET['name']);
    38            
    39             if (isset($_GET['redirect']))
    40             {
    41               $redirect = USER_COLLEC_PUBLIC.'edit/'.$UserCollection->getParam('id');
    42             }
    43             else
    44             {
    45               $redirect = USER_COLLEC_PUBLIC;
    46             }
    47             redirect($redirect);
     48            $redirect = USER_COLLEC_PUBLIC;
    4849          }
    49           break;
    50         }
     50          redirect($redirect);
     51        }
     52        break;
     53      }
     54       
     55      ## delete collection ##
     56      case 'delete':
     57      {
     58        try {
     59          $collection = new UserCollection($_GET['col_id']);
     60          $collection->delete();
     61          redirect(USER_COLLEC_PUBLIC);
     62        }
     63        catch (Exception $e)
     64        {
     65          $page['errors'][] = $e->getMessage();
     66        }
     67        break;
     68      }
     69    }
     70  }
     71 
     72  $template->assign('U_CREATE',
     73    add_url_params(USER_COLLEC_PUBLIC, array('action'=>'new','col_id'=>'0'))
     74    );
     75 
     76  $template->set_prefilter('index_category_thumbnails', 'user_collections_categories_list');
     77 
     78  include(USER_COLLEC_PATH . '/include/display_collections.inc.php');
     79 
     80  break;
     81}
     82
     83// +-----------------------------------------------------------------------+
     84// | Edit collection                                                       |
     85// +-----------------------------------------------------------------------+
     86case 'edit':
     87{
     88  // security
     89  if (empty($page['col_id']))
     90  {
     91    $_SESSION['page_errors'][] = l10n('Invalid collection');
     92    redirect(USER_COLLEC_PUBLIC);
     93  }
     94 
     95  $template->set_filename('index', realpath(USER_COLLEC_PATH.'template/collection_edit.tpl'));
     96 
     97  $self_url = USER_COLLEC_PUBLIC . 'edit/' . $page['col_id'];
     98 
     99  $template->assign(array(
     100    'F_ACTION' => $self_url,
     101    'U_LIST' => USER_COLLEC_PUBLIC,
     102    'UC_IN_EDIT' => true,
     103    ));
     104 
     105  try {
     106    $collection = new UserCollection($page['col_id']);
     107    $collection->checkUser();
     108   
     109    // save properties
     110    if (isset($_POST['save_col']))
     111    {
     112      if (empty($_POST['name']))
     113      {
     114        $page['errors'][] = l10n('Please give a name');
     115      }
     116      else
     117      {
     118        $collection->updateParam('name', stripslashes($_POST['name']));
     119      }
     120      $collection->updateParam('comment', stripslashes($_POST['comment']));
     121    }
     122   
     123    // add key
     124    if ($conf['user_collections']['allow_public'])
     125    {
     126      $share = array(
     127        'share_key' => get_random_key(16),
     128        'password' => null,
     129        'deadline' => null,
     130        );
     131     
     132      if (isset($_POST['add_share']))
     133      {
     134        $share = array(
     135          'share_key' =>  trim($_POST['share_key']),
     136          'password' =>   isset($_POST['use_share_password']) ? trim($_POST['share_password']) : '',
     137          'deadline' =>   isset($_POST['use_share_deadline']) ? trim($_POST['share_deadline']) : '',
     138          );
    51139         
    52         // delete
    53         case 'delete':
    54         {
    55           try {
    56             $UserCollection = new UserCollection($_GET['col_id']);
    57             $UserCollection->delete();
    58             redirect(USER_COLLEC_PUBLIC);
    59           }
    60           catch (Exception $e)
    61           {
    62             $page['errors'][] = $e->getMessage();
    63           }
    64           break;
    65         }
    66       }
    67     }
    68    
    69     $template->assign('U_CREATE', add_url_params(USER_COLLEC_PUBLIC, array('action'=>'new','col_id'=>'0')));
    70    
    71     $template->set_prefilter('index_category_thumbnails', 'user_collections_categories_list');
    72    
    73     include(USER_COLLEC_PATH . '/include/display_collections.inc.php');
    74    
    75     break;
    76   }
    77  
    78   /* edit */
    79   case 'edit':
    80   {
    81     // security
    82     if (empty($page['col_id']))
    83     {
    84       $_SESSION['page_errors'][] = l10n('Invalid collection');
    85       redirect(USER_COLLEC_PUBLIC);
    86     }
    87    
    88     $template->set_filename('index', realpath(USER_COLLEC_PATH.'template/collection_edit.tpl'));
    89    
    90     $self_url = USER_COLLEC_PUBLIC . 'edit/'.$page['col_id'];
    91    
    92     $template->assign(array(
    93       'user_collections' => $conf['user_collections'],
    94       'F_ACTION' => $self_url,
    95       'U_LIST' => USER_COLLEC_PUBLIC,
    96       'UC_IN_EDIT' => true,
    97       ));
    98    
    99     try {
    100       $UserCollection = new UserCollection($page['col_id']);
    101      
    102       // save properties
    103       if (isset($_POST['save_col']))
    104       {
    105         if (empty($_POST['name']))
    106         {
    107           array_push($page['errors'], l10n('Please give a name'));
    108         }
    109         else
    110         {
    111           $UserCollection->updateParam('name', stripslashes($_POST['name']));
    112         }
    113         if (!$conf['user_collections']['allow_public'])
    114         {
    115           $_POST['public'] = '0';
    116         }
    117         $UserCollection->updateParam('public', $_POST['public']);
    118         $UserCollection->updateParam('comment', stripslashes($_POST['comment']));
    119       }
    120      
    121       // send mail
    122       if ( $conf['user_collections']['allow_public'] and $conf['user_collections']['allow_mails'] )
     140        if (!verify_ephemeral_key(@$_POST['key']))
     141        {
     142          $result = array(l10n('Invalid key'));
     143        }
     144        else
     145        {
     146          $result = $collection->addShare($share);
     147        }
     148        if (is_array($result))
     149        {
     150          $share['errors'] = $result;
     151        }
     152        else
     153        {
     154          $share = array();
     155          $share['infos'][] = sprintf(l10n('New share added: <a href="%s">%s</a>'), $result, $result);
     156        }
     157        $share['open'] = true;
     158      }
     159      else if (isset($_GET['delete_share']))
     160      {
     161        if ($collection->deleteShare($_GET['delete_share']))
     162        {
     163          $share['infos'][] = l10n('Share deleted');
     164        }
     165        $share['open'] = true;
     166      }
     167     
     168      $template->assign('share', $share);
     169    }
     170   
     171    // send mail
     172    if ( $conf['user_collections']['allow_mails'] && $conf['user_collections']['allow_public'] )
     173    {
     174      $contact = array(
     175        'sender_name' =>      $user['username'],
     176        'sender_email' =>     $user['email'],
     177        'recipient_name' =>   null,
     178        'recipient_email' =>  null,
     179        'nb_images' =>        4,
     180        'message' =>          null,
     181        );
     182         
     183      if (isset($_POST['send_mail']))
    123184      {
    124185        $contact = array(
    125             'sender_name' => $user['username'],
    126             'sender_email' => $user['email'],
    127             'recipient_name' => null,
    128             'recipient_email' => null,
    129             'nb_images' => 4,
    130             'message' => null,
    131             );
    132            
    133         if ( isset($_POST['send_mail']) and (bool)$UserCollection->getParam('public') )
    134         {
    135           $contact = array(
    136             'sender_email' => trim($_POST['sender_email']),
    137             'sender_name' => trim($_POST['sender_name']),
    138             'recipient_email' => trim($_POST['recipient_email']),
    139             'recipient_name' => trim($_POST['recipient_name']),
    140             'nb_images' => $_POST['nb_images'],
    141             'message' => $_POST['message'],
    142             );
    143            
    144           $errors = $UserCollection->sendEmail($contact, @$_POST['key']);
    145           if (count($errors))
    146           {
    147             $template->assign('uc_mail_errors', $errors);
    148           }
    149           else
    150           {
    151             array_push($page['infos'], l10n('E-mail sent successfully'));
    152           }
    153         }
     186          'sender_email' =>     trim($_POST['sender_email']),
     187          'sender_name' =>      trim($_POST['sender_name']),
     188          'recipient_email' =>  trim($_POST['recipient_email']),
     189          'recipient_name' =>   trim($_POST['recipient_name']),
     190          'nb_images' =>        $_POST['nb_images'],
     191          'message' =>          $_POST['message'],
     192          );
    154193       
    155         $contact['KEY'] = get_ephemeral_key(3);
    156         $template->assign('contact', $contact);
    157       }
    158      
    159       // clear
    160       if ( isset($_GET['action']) and $_GET['action'] == 'clear' )
    161       {
    162         $UserCollection->clearImages();
    163       }
    164      
    165      
    166       // add remove item links
    167       $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_button');
     194        if (!verify_ephemeral_key(@$_POST['key']))
     195        {
     196          $result = array(l10n('Invalid key'));
     197        }
     198        else
     199        {
     200          $result = $collection->sendEmail($contact);
     201        }
     202        if (is_array($result))
     203        {
     204          $contact['errors'] = $result;
     205          $contact['open'] = true;
     206        }
     207        else
     208        {
     209          $contact = array();
     210          $page['infos'] = l10n('E-mail sent successfully');
     211        }
     212      }
     213     
     214      $template->assign('contact', $contact);
     215    }
     216   
     217    // clear
     218    if ( isset($_GET['action']) and $_GET['action'] == 'clear' )
     219    {
     220      $collection->clearImages();
     221    }
     222   
     223   
     224    // add remove item links
     225    $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_button');
     226    $template->set_prefilter('index_thumbnails', 'user_collections_add_colorbox');
     227   
     228    // thumbnails
     229    include(USER_COLLEC_PATH . '/include/display_thumbnails.inc.php');
     230   
     231   
     232    // collection properties
     233    $infos = $collection->getCollectionInfo();
     234    $infos['DATE_CREATION'] = format_date($infos['DATE_CREATION'], true);
     235    $infos['SHARES'] = $collection->getShares();
     236    $template->assign('collection', $infos);
     237   
     238    // toolbar buttons
     239    if (!empty($page['items']))
     240    {
     241      $template->assign('U_CLEAR',
     242        add_url_params($self_url, array('action'=>'clear'))
     243        );
     244    }
     245    $template->assign('U_DELETE',
     246      add_url_params(USER_COLLEC_PUBLIC, array('action'=>'delete','col_id'=>$page['col_id']))
     247      );
     248     
     249    if ( $conf['user_collections']['allow_public'] && !empty($page['items']) )
     250    {
     251      $template->assign('U_SHARE', USER_COLLEC_PUBLIC . 'view/' . $page['col_id'] .'-');
     252    }
     253    if ( $conf['user_collections']['allow_mails'] && $conf['user_collections']['allow_public'] && !empty($page['items']) )
     254    {
     255      $template->assign('U_MAIL', true);
     256    }
     257    $template->assign('UC_TKEY', get_ephemeral_key(3));
     258   
     259    // modify page title
     260    $template->concat('TITLE',
     261      $conf['level_separator'] . trigger_event('render_category_name', $infos['NAME'])
     262      );
     263   
     264    // render description
     265    $template->assign('CONTENT_DESCRIPTION',
     266      trigger_event('render_category_description', nl2br($infos['COMMENT']))
     267      );
     268  }
     269  catch (Exception $e)
     270  {
     271    $page['errors'][] = $e->getMessage();
     272  }
     273 
     274  break;
     275}
     276
     277// +-----------------------------------------------------------------------+
     278// | View collection                                                       |
     279// +-----------------------------------------------------------------------+
     280case 'view':
     281{
     282  $page['col_key'] = $page['col_id'];
     283 
     284  if (!$conf['user_collections']['allow_public'])
     285  {
     286    page_forbidden('');
     287  }
     288  if (empty($page['col_key']))
     289  {
     290    bad_request('');
     291  }
     292 
     293  $query = '
     294SELECT col_id, params
     295  FROM '.COLLECTION_SHARES_TABLE.'
     296  WHERE share_key = "'.$page['col_key'].'"
     297;';
     298  $result = pwg_query($query);
     299  if (!pwg_db_num_rows($result))
     300  {
     301    page_not_found(l10n('Collection not found'));
     302  }
     303 
     304  list($page['col_id'], $share_params) = pwg_db_fetch_row($result);
     305  $share_params = unserialize($share_params);
     306 
     307  // deadline check
     308  if ( !empty($share_params['deadline']) && strtotime($share_params['deadline'])<time() )
     309  {
     310    page_not_found(l10n('This link expired'));
     311  }
     312 
     313  $self_url = USER_COLLEC_PUBLIC . 'view/' . $page['col_key'];
     314 
     315  $template->set_filename('index', realpath(USER_COLLEC_PATH.'template/collection_view.tpl'));
     316 
     317  try {
     318    $collection = new UserCollection($page['col_id']);
     319    $col = $collection->getCollectionInfo();
     320   
     321    $mode = 'view';
     322   
     323    // password check
     324    if (!empty($share_params['password']))
     325    {
     326      if (isset($_POST['uc_password']))
     327      {
     328        $hash = sha1($conf['secret_key'].$_POST['uc_password'].$page['col_key']);
     329        if ($hash == $share_params['password'])
     330        {
     331          pwg_set_session_var('uc_key_'.$page['col_key'], get_ephemeral_key(0, $share_params['password']));
     332        }
     333        else
     334        {
     335          $page['errors'][] = l10n('Invalid password!');
     336          $mode = 'password';
     337        }
     338      }
     339      else if (($var = pwg_get_session_var('uc_key_'.$page['col_key'])) !== null)
     340      {
     341        if (!verify_ephemeral_key($var, $share_params['password']))
     342        {
     343          pwg_unset_session_var('uc_key_'.$page['col_key']);
     344          $mode = 'password';
     345        }
     346      }
     347      else
     348      {
     349        $mode = 'password';
     350      }
     351    }
     352   
     353    if ($mode == 'view')
     354    {
    168355      $template->set_prefilter('index_thumbnails', 'user_collections_add_colorbox');
    169356     
     
    171358      include(USER_COLLEC_PATH . '/include/display_thumbnails.inc.php');
    172359     
    173      
    174       // collection properties
    175       $col = $UserCollection->getCollectionInfo();
    176       $col['DATE_CREATION'] = format_date($col['DATE_CREATION'], true);
    177       $template->assign('collection', $col);
    178      
    179       // toolbar buttons
    180       if (!empty($page['items']))
    181       {
    182         $template->assign('U_CLEAR',
    183           add_url_params($self_url, array('action'=>'clear') )
    184           );
    185       }
    186       $template->assign('U_DELETE',
    187         add_url_params(USER_COLLEC_PUBLIC, array('action'=>'delete','col_id'=>$page['col_id']))
     360      // render description
     361      $template->assign('CONTENT_DESCRIPTION',
     362        trigger_event('render_category_description', nl2br($col['COMMENT']))
    188363        );
    189       if ($conf['user_collections']['allow_public'] and $conf['user_collections']['allow_mails'] and !empty($page['items']))
    190       {
    191         $template->assign('U_MAIL', true);
    192       }
    193      
    194      
    195       $template->concat('TITLE',
    196         $conf['level_separator'].trigger_event('render_category_name', $col['NAME'])
    197         );
    198        
    199       $template->assign('CONTENT_DESCRIPTION', trigger_event('render_category_description', nl2br($col['COMMENT'])));
    200     }
    201     catch (Exception $e)
    202     {
    203       array_push($page['errors'], $e->getMessage());
    204     }
    205    
    206     break;
    207   }
    208  
    209   /* view */
    210   case 'view':
    211   {
    212     // security
    213     if ( empty($page['col_id']) or strlen($page['col_id']) != 10 or strpos($page['col_id'], 'uc') === false or !$conf['user_collections']['allow_public'] )
    214     {
    215       $_SESSION['page_errors'][] = l10n('Invalid collection');
    216       redirect('index.php');
    217     }
    218    
    219     $template->set_filename('index', realpath(USER_COLLEC_PATH.'template/collection_view.tpl'));
    220    
    221     $self_url = USER_COLLEC_PUBLIC . 'view/'.$page['col_id'];
    222    
    223     try {
    224       $UserCollection = new UserCollection($page['col_id']); // public id
    225       $page['col_id'] = $UserCollection->getParam('id'); // private id
    226       $col = $UserCollection->getCollectionInfo();
    227      
    228       $template->set_prefilter('index_thumbnails', 'user_collections_add_colorbox');
    229      
    230       // thumbnails
    231       include(USER_COLLEC_PATH . '/include/display_thumbnails.inc.php');
    232      
    233       // add username in title
    234       include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
    235       $template->concat('TITLE',
    236         $conf['level_separator'] . trigger_event('render_category_name', $col['NAME']) .
    237         ' (' . sprintf(l10n('by %s'), get_username($UserCollection->getParam('user_id'))) . ')'
    238         );
    239        
    240       $template->assign('CONTENT_DESCRIPTION', trigger_event('render_category_description', nl2br($col['COMMENT'])));
    241     }
    242     catch (Exception $e)
    243     {
    244       access_denied();
    245     }
    246    
    247     break;
    248   }
    249 }
     364    }
     365   
     366    // add username in title
     367    include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     368    $template->concat('TITLE',
     369      $conf['level_separator'] . trigger_event('render_category_name', $col['NAME']) .
     370      ' (' . sprintf(l10n('by %s'), get_username($collection->getParam('user_id'))) . ')'
     371      );
     372     
     373    $template->assign('UC_MODE', $mode);
     374  }
     375  catch (Exception $e)
     376  {
     377    access_denied();
     378  }
     379 
     380  break;
     381}
     382}
     383
    250384
    251385// modification on mainpage_categories.tpl
  • extensions/UserCollections/include/events.inc.php

    r23719 r24421  
    1515   
    1616    $page['section'] = 'collections';
    17     $page['section_title'] = '<a href="'.get_absolute_root_url().'">'.l10n('Home').'</a>'.$conf['level_separator'].'<a href="'.USER_COLLEC_PUBLIC.'">'.l10n('Collections').'</a>';
    1817    $page['title'] = l10n('Collections');
    1918   
     19    $page['section_title'] = '<a href="'.get_absolute_root_url().'">'.l10n('Home').'</a>'.$conf['level_separator'];
     20    if (is_a_guest()) $page['section_title'].= l10n('Collections');
     21    else $page['section_title'].= '<a href="'.USER_COLLEC_PUBLIC.'">'.l10n('Collections').'</a>';
     22   
    2023    if (in_array(@$tokens[1], array('edit','view','list')))
    2124    {
    2225      $page['sub_section'] = $tokens[1];
    23       if ($tokens[1]=='edit' and isset($conf['GThumb']) && is_array($conf['GThumb']))
     26      if ($tokens[1]=='edit' && isset($conf['GThumb']) && is_array($conf['GThumb']))
    2427      {
    2528        $conf['GThumb']['big_thumb'] = false; // big thumb is buggy with removes
     
    4245  global $page;
    4346  $page['body_id'] = 'theCollectionPage';
     47}
     48
     49function uc_anti_lightbox($tpl_thumbnails_var)
     50{
     51  global $template, $page;
     52 
     53  if ($page['section'] == 'collections' && !empty($template->css_by_priority[0]))
     54  {
     55    foreach ($template->css_by_priority[0] as $file)
     56    {
     57      if (strpos($file[0], 'colorbox.css') !== false)
     58      {
     59        $template->assign('UC_NO_LIGHTBOX', true);
     60        break;
     61      }
     62    }
     63  }
     64 
     65  return $tpl_thumbnails_var;
    4466}
    4567
  • extensions/UserCollections/include/functions.inc.php

    r23551 r24421  
    2020    return (bool)preg_match($regex, $mail_address);
    2121  }
     22}
     23
     24function get_random_key($length=32)
     25{
     26  $chars = '0123456789abcdefabcdef';
     27  for ($s=''; strlen($s)<$length; )
     28  {
     29    $s.= $chars[rand(0, strlen($chars) - 1)];
     30  }
     31  return $s;
    2232}
    2333
  • extensions/UserCollections/include/install.inc.php

    r23551 r24421  
    2626  `comment` text NULL,
    2727  `nb_images` mediumint(8) NOT NULL DEFAULT 0,
    28   `public` tinyint(1) DEFAULT 0,
    29   `public_id` varchar(10) NULL,
    3028  PRIMARY KEY (`id`)
    31 ) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1
     29) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1
    3230;';
    3331  pwg_query($query);
     
    3735  `col_id` mediumint(8) NOT NULL,
    3836  `image_id` mediumint(8) NOT NULL,
    39   `add_date` DATETIME NULL,
     37  `add_date` datetime NULL,
    4038  UNIQUE KEY `UNIQUE` (`col_id`,`image_id`)
    41 ) DEFAULT CHARSET=utf8
     39) ENGINE=MyISAM DEFAULT CHARSET=utf8
    4240;';
    4341  pwg_query($query);
    4442 
     43  // version 2.0.0
    4544  $result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'collection_images` LIKE "add_date";');
    4645  if (!pwg_db_num_rows($result))
    4746  {
    48     pwg_query('ALTER TABLE `'.$prefixeTable.'collection_images` ADD `add_date` DATETIME NULL;');
     47    pwg_query('ALTER TABLE `'.$prefixeTable.'collection_images` ADD `add_date` datetime NULL;');
    4948  }
    5049 
     
    5251  if (!pwg_db_num_rows($result))
    5352  {
    54     pwg_query('ALTER TABLE `'.$prefixeTable.'collections` ADD `comment` TEXT NULL;');
     53    pwg_query('ALTER TABLE `'.$prefixeTable.'collections` ADD `comment` text NULL;');
    5554    pwg_query('ALTER TABLE `'.$prefixeTable.'collections` DROP `active`;');
     55  }
     56 
     57  // version 2.1.0
     58  $query = '
     59CREATE TABLE IF NOT EXISTS `'.$prefixeTable.'collection_shares` (
     60  `id` mediumint(8) NOT NULL AUTO_INCREMENT,
     61  `col_id` mediumint(8) NOT NULL,
     62  `share_key` varchar(64) NOT NULL,
     63  `params` text NULL,
     64  `add_date` datetime NOT NULL,
     65  PRIMARY KEY (`id`),
     66  UNIQUE KEY `share_key` (`share_key`)
     67) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1
     68;';
     69  pwg_query($query);
     70 
     71  $result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'collections` LIKE "public";');
     72  if (pwg_db_num_rows($result))
     73  {
     74    $now = date('Y-m-d H:i:s');
     75   
     76    $query = '
     77SELECT id, public_id
     78  FROM `'.$prefixeTable.'collections`
     79  WHERE public = 1
     80;';
     81    $result = pwg_query($query);
     82   
     83    $inserts = array();
     84    while ($row = pwg_db_fetch_assoc($result))
     85    {
     86      $inserts[] = array(
     87        'col_id' => $row['id'],
     88        'share_key' => $row['public_id'],
     89        'params' => serialize(array('password'=>'','deadline'=>'')),
     90        'add_date' => $now,
     91        );
     92    }
     93   
     94    mass_inserts($prefixeTable.'collection_shares',
     95      array('col_id','share_key','add_date'),
     96      $inserts
     97      );
     98   
     99    pwg_query('ALTER TABLE `'.$prefixeTable.'collections` DROP `public`, DROP `public_id`;');
    56100  }
    57101}
  • extensions/UserCollections/include/ws_functions.inc.php

    r23719 r24421  
    1414      'comment' => array('default' => null),
    1515      'user_id' => array('default' => null, 'info'=>'Admin parameter, default is current user'),
    16       'public' => array('default' => 0),
    1716      ),
    1817    'Create a new User Collection.'
     
    3433      'user_id' => array('default' => null, 'info'=>'Admin parameter, default is current user'),
    3534      'name' => array('default' => null),
    36       'public' => array('default' => null),
    37       'per_page' => array('default'=>100, 'maxValue'=>ceil($conf['ws_max_images_per_page']/10)),
     35      'per_page' => array(
     36        'default'=>min(100,ceil($conf['ws_max_images_per_page']/10)),
     37        'maxValue'=>ceil($conf['ws_max_images_per_page']/10)
     38      ),
    3839      'page' => array('default'=>0),
    3940      'order' => array('default'=>'username ASC, name ASC'),
     
    6768    array(
    6869      'col_id' => array(),
    69       'per_page' => array('default'=>100, 'maxValue'=>$conf['ws_max_images_per_page']),
     70      'per_page' => array('default'=>min(100,$conf['ws_max_images_per_page']), 'maxValue'=>$conf['ws_max_images_per_page']),
    7071      'page' => array('default'=>0),
    7172      'order' => array('default'=>null),
     
    135136  }
    136137 
    137   // check public
    138   if ($params['public'] != 0 and $params['public'] != 1)
    139   {
    140     return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid "public" value, 0 or 1.');
    141   }
    142   if (!$conf['user_collections']['allow_public'])
    143   {
    144     $params['public'] = 0;
    145   }
    146  
    147   $UserCollection = new UserCollection('new', $params['name'], $params['comment'], $params['public'], $params['user_id']);
    148  
    149   return array_change_key_case($UserCollection->getCollectionInfo(), CASE_LOWER);
     138  $collection = new UserCollection('new', $params['name'], $params['comment'], $params['user_id']);
     139 
     140  return array_change_key_case($collection->getCollectionInfo(), CASE_LOWER);
    150141}
    151142
     
    163154  }
    164155 
    165   // check collection id
    166   if (!preg_match('#^[0-9]+$#', $params['col_id']))
    167   {
    168     return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid collection id');
    169   }
    170  
    171   $query = '
    172 SELECT user_id
    173   FROM '.COLLECTIONS_TABLE.'
    174   WHERE id = '.$params['col_id'].'
    175 ;';
    176   $result = pwg_query($query);
    177  
    178   if (!pwg_db_num_rows($result))
    179   {
    180     return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid collection id');
    181   }
    182   else
    183   {
    184     // check owner
    185     list($user_id) = pwg_db_fetch_row($result);
    186    
    187     if (!is_admin() and $user_id != $user['id'])
    188     {
    189       return new PwgError(403, 'Forbidden');
    190     }
    191    
    192     // delete
    193     $query = '
    194 DELETE ci, c
    195   FROM '.COLLECTION_IMAGES_TABLE.' AS ci
    196     RIGHT JOIN '.COLLECTIONS_TABLE.' AS c
    197     ON ci.col_id = c.id
    198   WHERE
    199     c.user_id = '.$user_id.'
    200     AND c.id = '.$params['col_id'].'
    201 ;';
    202     pwg_query($query);
     156  try {
     157    $collection = new UserCollection($params['col_id']);
     158    $collection->checkUser();
     159   
     160    $collection->delete();
     161  }
     162  catch (Exception $e)
     163  {
     164    return new PwgError($e->getCode(), $e->getMessage());
    203165  }
    204166}
     
    235197  }
    236198 
    237   // check public
    238   if ( !empty($params['public']) and $params['public'] != 0 and $params['public'] != 1 )
    239   {
    240     return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid "public" value, 0 or 1.');
    241   }
    242  
    243199  // search
    244200  $where_clauses = array('1=1');
     
    246202  {
    247203    $where_clauses[] = 'user_id = '.$params['user_id'];
    248   }
    249   if (!empty($params['public']))
    250   {
    251     $where_clauses[] = 'public = '.$params['public'];
    252204  }
    253205  if (!empty($params['name']))
     
    280232      'comment' => $row['comment'],
    281233      'nb_images' => $row['nb_images'],
    282       'public' => (bool)$row['public'],
    283234      'date_creation' => $row['date_creation'],
    284235      'is_temp' => $row['name'] == 'temp',
    285       'u_public' => USER_COLLEC_PUBLIC . 'view/'.$row['public_id'],
    286236      'user_id' => $row['user_id'],
    287237      'username' => $row['username'],
     
    316266    return new PwgError(403, 'Forbidden');
    317267  }
    318  
    319   // check collection id
    320   if (!preg_match('#^[0-9]+$#', $params['col_id']))
    321   {
    322     return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid collection id');
    323   }
    324 
    325   try {
    326     $UserCollection = new UserCollection($params['col_id']);
    327    
    328     $UserCollection->addImages($params['image_ids']);
    329    
    330     return array('nb_images' => $UserCollection->getParam('nb_images'));
    331   }
    332   catch (Exception $e)
    333   {
    334     return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid collection id');
     268
     269  try {
     270    $collection = new UserCollection($params['col_id']);
     271    $collection->checkUser();
     272   
     273    $collection->addImages($params['image_ids']);
     274   
     275    return array('nb_images' => $collection->getParam('nb_images'));
     276  }
     277  catch (Exception $e)
     278  {
     279    return new PwgError($e->getCode(), $e->getMessage());
    335280  }
    336281}
     
    349294  }
    350295 
    351   // check collection id
    352   if (!preg_match('#^[0-9]+$#', $params['col_id']))
    353   {
    354     return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid collection id');
    355   }
    356 
    357   try {
    358     $UserCollection = new UserCollection($params['col_id']);
    359    
    360     $UserCollection->removeImages($params['image_ids']);
    361    
    362     return array('nb_images' => $UserCollection->getParam('nb_images'));
    363   }
    364   catch (Exception $e)
    365   {
    366     return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid collection id');
     296  try {
     297    $collection = new UserCollection($params['col_id']);
     298    $collection->checkUser();
     299   
     300    $collection->removeImages($params['image_ids']);
     301   
     302    return array('nb_images' => $collection->getParam('nb_images'));
     303  }
     304  catch (Exception $e)
     305  {
     306    return new PwgError($e->getCode(), $e->getMessage());
    367307  }
    368308}
     
    380320    return new PwgError(403, 'Forbidden');
    381321  }
    382  
    383   // check collection id
    384   if (!preg_match('#^[0-9]+$#', $params['col_id']))
    385   {
    386     return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid collection id');
    387   }
    388 
    389   try {
    390     $UserCollection = new UserCollection($params['col_id']);
    391    
    392     $image_ids = $UserCollection->getImages();
     322
     323  try {
     324    $collection = new UserCollection($params['col_id']);
     325    $collection->checkUser();
     326   
     327    $image_ids = $collection->getImages();
    393328    $images = array();
    394329   
     
    451386  catch (Exception $e)
    452387  {
    453     return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid collection id');
     388    return new PwgError($e->getCode(), $e->getMessage());
    454389  }
    455390}
     
    467402    return new PwgError(403, 'Forbidden');
    468403  }
    469  
    470   // check collection id
    471   if (!preg_match('#^[0-9]+$#', $params['col_id']))
    472   {
    473     return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid collection id');
    474   }
    475 
    476   try {
    477     $UserCollection = new UserCollection($params['col_id']);
     404
     405  try {
     406    $collection = new UserCollection($params['col_id']);
     407    $collection->checkUser();
    478408   
    479409    // change encoder to plain text
     
    482412    $service->setEncoder('plain', $encoder);
    483413 
    484     return $UserCollection->serialize($params['content']);
    485   }
    486   catch (Exception $e)
    487   {
    488     return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid collection id');
     414    return $collection->serialize($params['content']);
     415  }
     416  catch (Exception $e)
     417  {
     418    return new PwgError($e->getCode(), $e->getMessage());
    489419  }
    490420}
     
    502432    return new PwgError(403, 'Forbidden');
    503433  }
    504  
    505   // check collection id
    506   if (!preg_match('#^[0-9]+$#', $params['col_id']))
    507   {
    508     return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid collection id');
    509   }
    510 
    511   try {
    512     $UserCollection = new UserCollection($params['col_id']);
    513  
    514     return array_change_key_case($UserCollection->getCollectionInfo(), CASE_LOWER);
    515   }
    516   catch (Exception $e)
    517   {
    518     return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid collection id');
     434
     435  try {
     436    $collection = new UserCollection($params['col_id']);
     437    $collection->checkUser();
     438 
     439    return array_change_key_case($collection->getCollectionInfo(), CASE_LOWER);
     440  }
     441  catch (Exception $e)
     442  {
     443    return new PwgError($e->getCode(), $e->getMessage());
    519444  }
    520445}
  • extensions/UserCollections/language/en_UK/plugin.lang.php

    r23551 r24421  
    11<?php
    22
    3 $lang['Copied'] = 'Copied';
    4 $lang['Public collection'] = 'Public';
    5 $lang['Copy to clipboard'] = 'Copy to clipboard';
    6 $lang['Return to collections list'] = 'Return to list';
    73$lang['This collection is empty'] = 'This collection is empty';
    84$lang['Collection name:'] = 'Collection name:';
    95$lang['Create a new collection'] = 'Create a new collection';
    10 $lang['See all my collections'] = 'See all my collections';
    116$lang['Please give a name'] = 'Please give a name';
    127$lang['Invalid collection'] = 'Invalid collection';
     
    2318$lang['%d more...'] = '%d more...';
    2419$lang['(remove)'] = '(remove)';
    25 
     20$lang['Collection not found'] = 'Collection not found';
     21$lang['Expiration date'] = 'Expiration date';
     22$lang['New share added: <a href="%s">%s</a>'] = 'New share added: <a href="%s">%s</a>';
     23$lang['Restricted access'] = 'Restricted access';
     24$lang['Share'] = 'Share';
     25$lang['Share deleted'] = 'Share deleted';
     26$lang['Share key'] = 'Share key';
     27$lang['Share this collection'] = 'Share this collection';
     28$lang['The key must be at least 8 characters long'] = 'The key must be at least 8 characters long';
     29$lang['This key is already used'] = 'This key is already used';
     30$lang['This link expired'] = 'This link expired';
    2631$lang['Allow users to set their collections as public'] = 'Allow users to set their collections as public';
    2732$lang['Allow users to send their public collections by mail'] = 'Allow users to send their public collections by mail';
     
    4449$lang['Error while sending e-mail'] = 'Error while sending e-mail';
    4550$lang['E-mail sent successfully'] = 'E-mail sent successfully';
    46 $lang['The collection must be public in order to send it'] = 'The collection must be public in order to send it';
    4751$lang['Your name'] = 'Your name';
    4852$lang['Your e-mail'] = 'Your e-mail';
  • extensions/UserCollections/language/fr_FR/plugin.lang.php

    r23551 r24421  
    11<?php
    22
    3 $lang['Copied'] = 'Copié';
    4 $lang['Public collection'] = 'Publique';
    5 $lang['Copy to clipboard'] = 'Copier dans le presse-papier';
    6 $lang['Return to collections list'] = 'Retourner à la liste des collections';
    73$lang['This collection is empty'] = 'Cette collection est vide';
    8 $lang['Collection name:'] = 'Nom de la collection:';
     4$lang['Collection name:'] = 'Nom de la collection :';
    95$lang['Create a new collection'] = 'Créer une nouvelle collection';
    10 $lang['See all my collections'] = 'Voir toutes mes collections';
    116$lang['Please give a name'] = 'Veuillez donner un nom';
    127$lang['Invalid collection'] = 'Collection invalide';
     
    2318$lang['%d more...'] = 'et %d autres...';
    2419$lang['(remove)'] = '(retirer)';
    25 
     20$lang['Collection not found'] = 'collection non trouvée';
     21$lang['Expiration date'] = 'Date d\'expiration';
     22$lang['New share added: <a href="%s">%s</a>'] = 'Nouveau partage ajouté : <a href="%s">%s</a>';
     23$lang['Restricted access'] = 'Accès restreint';
     24$lang['Share'] = 'Partager';
     25$lang['Share deleted'] = 'Partage supprimé';
     26$lang['Share key'] = 'Clé de partage';
     27$lang['Share this collection'] = 'Partager cette collection';
     28$lang['The key must be at least 8 characters long'] = 'La clé doit faire au moins 8 caractères';
     29$lang['This key is already used'] = 'Cette clé est déjà utilisée';
     30$lang['This link expired'] = 'Ce lien a expiré';
    2631$lang['Allow users to set their collections as public'] = 'Les utilisateurs peuvent rendre leurs collections publiques';
    2732$lang['Allow users to send their public collections by mail'] = 'Les utilisateurs peuvent envoyer leurs collections publiques par mail';
     
    4449$lang['Error while sending e-mail'] = 'Erreur lors de l\'envoi de l\'e-mail';
    4550$lang['E-mail sent successfully'] = 'E-mail envoyé avec succès';
    46 $lang['The collection must be public in order to send it'] = 'La collection doit être publique pour l\'envoyer';
    4751$lang['Your name'] = 'Votre nom';
    4852$lang['Your e-mail'] = 'Votre e-mail';
  • extensions/UserCollections/main.inc.php

    r23551 r24421  
    2222define('COLLECTIONS_TABLE',       $prefixeTable.'collections');
    2323define('COLLECTION_IMAGES_TABLE', $prefixeTable.'collection_images');
     24define('COLLECTION_SHARES_TABLE', $prefixeTable.'collection_shares');
    2425define('USER_COLLEC_ADMIN',       get_root_url() . 'admin.php?page=plugin-' . USER_COLLEC_ID);
    2526define('USER_COLLEC_PUBLIC',      get_absolute_root_url() . make_index_url(array('section' => 'collections')) . '/');
     
    4243  // thumbnails actions
    4344  add_event_handler('loc_end_index_thumbnails', 'user_collections_thumbnails_list', EVENT_HANDLER_PRIORITY_NEUTRAL-10, 2);
     45  add_event_handler('loc_end_index_thumbnails', 'uc_anti_lightbox', 41);
    4446
    4547  // picture action
    4648  add_event_handler('loc_end_picture', 'user_collections_picture_page');
    47 
    48   // menu
    49   add_event_handler('blockmanager_register_blocks', 'user_collections_add_menublock');
    50   add_event_handler('blockmanager_apply', 'user_collections_applymenu');
    5149}
    5250
    53 require(USER_COLLEC_PATH . 'include/ws_functions.inc.php');
    54 require(USER_COLLEC_PATH . 'include/functions.inc.php');
    55 require(USER_COLLEC_PATH . 'include/UserCollection.class.php');
    56 require(USER_COLLEC_PATH . 'include/events.inc.php');
     51// menu
     52add_event_handler('blockmanager_register_blocks', 'user_collections_add_menublock');
     53add_event_handler('blockmanager_apply', 'user_collections_applymenu');
     54
     55require_once(USER_COLLEC_PATH . 'include/ws_functions.inc.php');
     56require_once(USER_COLLEC_PATH . 'include/functions.inc.php');
     57require_once(USER_COLLEC_PATH . 'include/UserCollection.class.php');
     58require_once(USER_COLLEC_PATH . 'include/events.inc.php');
    5759
    5860
  • extensions/UserCollections/maintain.inc.php

    r23551 r24421  
    2222function plugin_uninstall()
    2323{
    24   global $prefixeTable;
     24  global $prefixeTable, $conf;
    2525 
    26   pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "user_collections" LIMIT 1;');
     26  pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "user_collections";');
    2727  pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'collections`;');
    2828  pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'collection_images`;');
     29  pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'collection_shares`;');
     30 
     31  unset($conf['user_collections']);
    2932}
    3033
  • extensions/UserCollections/template/collection_edit.tpl

    r23551 r24421  
    11{combine_css path=$USER_COLLEC_PATH|cat:'template/style_collections.css'}
    2 {combine_script id='ZeroClipboard' path=$USER_COLLEC_PATH|cat:'template/resources/ZeroClipboard.min.js'}
     2
    33{include file=$USER_COLLEC_ABS_PATH|cat:'template/thumbnails_colorbox.tpl'}
    44
    5 {footer_script require='jquery'}
    6 {if $user_collections.allow_public}
    7 ZeroClipboard.setDefaults( {ldelim} moviePath: "{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/ZeroClipboard.swf" } );
    8 var clip = new ZeroClipboard();
    9 
    10 clip.glue(jQuery("#publicURL .button").get());
    11 clip.addEventListener('onMouseOver', function() {ldelim}
    12   clip.setText(jQuery("#publicURL .url").val());
    13 });
    14 clip.addEventListener('complete', function() {ldelim}
    15   jQuery('.confirm').remove();
    16   jQuery("#publicURL .url").select();
    17   jQuery('<span class="confirm" style="display:none;">{'Copied'|@translate}</span>').appendTo("#publicURL")
    18     .fadeIn(400).delay(1000).fadeOut(400, function(){ldelim} jQuery(this).remove(); });
    19 });
    20 
    21 jQuery("#publicURL .url").click(function() {ldelim}
    22   jQuery(this).select();
    23 });
    24 
    25 jQuery("input[name='public']").change(function() {ldelim}
    26   jQuery("#publicURL").fadeToggle("fast");
    27 });
    28 {/if}
    29 
    30 {if $collection.PUBLIC && $user_collections.allow_mails}
    31   jQuery(window).load(function(){ldelim}
    32     jQuery(".mail_colorbox_open").colorbox({ldelim}
    33       {if isset($uc_mail_errors)}open: true, transition:"none",{/if}
    34       inline:true
    35     });
    36     jQuery(".mail_colorbox_close").click(function() {ldelim}
    37       jQuery(".mail_colorbox_open").colorbox.close();
     5{*<!-- datepicker and timepicker -->*}
     6{include file='include/datepicker.inc.tpl'}
     7{combine_script id='jquery.ui.timepicker' load='footer' require='jquery.ui.datepicker,jquery.ui.slider' path=$USER_COLLEC_PATH|cat:'template/resources/jquery-timepicker/jquery-ui-timepicker-addon.js'}
     8
     9{assign var="timepicker_language" value=$USER_COLLEC_PATH|cat:'template/resources/jquery-timepicker/i18n/jquery-ui-timepicker-'|cat:$lang_info.code|cat:'.js'}
     10{if "PHPWG_ROOT_PATH"|@constant|@cat:$timepicker_language|@file_exists}
     11{combine_script id="jquery.ui.timepicker-$lang_info.code" load='footer' require='jquery.ui.timepicker' path=$timepicker_language}
     12{/if}
     13
     14{combine_css path='themes/default/js/ui/theme/jquery.ui.core.css'}
     15{combine_css path='themes/default/js/ui/theme/jquery.ui.theme.css'}
     16{combine_css path='themes/default/js/ui/theme/jquery.ui.slider.css'}
     17{combine_css path=$USER_COLLEC_PATH|cat:'template/resources/jquery-timepicker/jquery-ui-timepicker-addon.css'}
     18
     19
     20<script>
     21{footer_script require='jquery,jquery.ui.timepicker'}
     22{if isset($U_SHARE)}
     23{literal}
     24  var $share_form = jQuery('#share_form');
     25 
     26  // functions
     27  jQuery.fn.extend({
     28      hideVis: function() {
     29          $(this).css('visibility', 'hidden');
     30          return this;
     31      },
     32      showVis: function() {
     33          $(this).css('visibility', 'visible');
     34          return this;
     35      },
     36      toggleVis: function(toggle) {
     37          if ($(this).css('visibility')=='hidden' || toggle === true){
     38              return $(this).showVis();
     39          } else {
     40              return $(this).hideVis();
     41          }
     42      }
     43  });
     44 
     45  function enterShareKeyEdit() {
     46      $share_form.find('.url-edit').show();
     47      $share_form.find('.url-normal').hide();
     48      jQuery(".share_colorbox_open").colorbox.resize({speed:0});
     49  }
     50  function exitShareKeyEdit() {
     51      $share_form.find('.url-edit').hide();
     52      $share_form.find('.url-normal').show();
     53      jQuery(".share_colorbox_open").colorbox.resize({speed:0});
     54  }
     55 
     56  // hide some inputs
     57  exitShareKeyEdit();
     58 
     59  // display key
     60  $share_form.find('.url-more').text($share_form.find('input[name="share_key"]').val());
     61 
     62  // url edition
     63  $share_form.find('.edit_share_key').on('click', function() {
     64      enterShareKeyEdit();
    3865      return false;
    39     })
     66  });
     67  $share_form.find('.set_share_key').on('click', function() {
     68      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}");
     70      }
     71      else {
     72          $share_form.find('.url-more').text($share_form.find('input[name="share_key"]').val());
     73          exitShareKeyEdit();
     74      }
     75      return false;
     76  });
     77  $share_form.find('.cancel_share_key').on('click', function() {
     78      $share_form.find('input[name="share_key"]').val($share_form.find('.url-more').text());
     79      exitShareKeyEdit();
     80      return false;
     81  });
     82  $share_form.find('.url-more').on('dblclick', function() {
     83      enterShareKeyEdit();
     84  });
     85 
     86  // optional inputs
     87  $share_form.find('.share-option').each(function() {
     88      $share_form.find('input[name="'+ $(this).data('for') +'"]').hideVis();
     89  }).on('change', function() {
     90      $share_form.find('input[name="'+ $(this).data('for') +'"]').toggleVis($(this).is(':checked'));
     91  });
     92 
     93  // datetime picker
     94  $share_form.find('input[name="share_deadline"]').datetimepicker({
     95      dateFormat: 'yy-mm-dd',
     96      minDate: new Date()
     97  });
     98 
     99 
     100  // popup
     101  jQuery(".share_colorbox_open").colorbox({
     102    {/literal}{if isset($share.open)}open: true, transition:"none",{/if}{literal}
     103    inline:true
     104  });
     105  jQuery(".share_colorbox_close").click(function() {
     106    jQuery(".share_colorbox_open").colorbox.close();
     107    return false;
     108  });
     109  jQuery("#share_form").css('background-color', jQuery("#the_page #content").css('background-color'));
     110{/literal}
     111{/if}
     112
     113{if isset($U_MAIL)}
     114{literal}
     115  jQuery(".mail_colorbox_open").colorbox({
     116    {/literal}{if isset($contact.open)}open: true, transition:"none",{/if}{literal}
     117    inline:true
     118  });
     119  jQuery(".mail_colorbox_close").click(function() {
     120    jQuery(".mail_colorbox_open").colorbox.close();
     121    return false;
    40122  });
    41123  jQuery("#mail_form").css('background-color', jQuery("#the_page #content").css('background-color'));
    42 {/if}
    43 
    44 jQuery("#edit_form_show").click(function() {ldelim}
     124{/literal}
     125{/if}
     126
     127{literal}
     128jQuery("#edit_form_show").click(function() {
    45129  jQuery("#edit_form_show").hide();
    46130  jQuery(".additional_info").hide();
    47131  jQuery("#edit_form").show();
    48132});
    49 jQuery("#edit_form_hide").click(function() {ldelim}
     133jQuery("#edit_form_hide").click(function() {
    50134  jQuery("#edit_form_show").show();
    51135  jQuery(".additional_info").show();
    52136  jQuery("#edit_form").hide();
    53137});
     138{/literal}
    54139{/footer_script}
     140</script>
    55141
    56142
     
    71157
    72158
     159{if isset($collection)}
     160
    73161{if !empty($CONTENT_DESCRIPTION)}
    74162<div class="additional_info">
     
    89177  <p class="title"><label for="comment">{'Description'|@translate}</label></p>
    90178  <p><textarea name="comment" id="comment" style="width:400px;height:100px;">{$collection.COMMENT}</textarea></p>
    91  
    92 {if $user_collections.allow_public}
    93   <p class="title">{'Public collection'|@translate}</p>
    94   <p>
    95     <label><input type="radio" name="public" value="0" {if not $collection.PUBLIC}checked="checked"{/if}> {'No'|@translate}</label>
    96     <label><input type="radio" name="public" value="1" {if $collection.PUBLIC}checked="checked"{/if}> {'Yes'|@translate}</label>
    97     <span id="publicURL" {if not $collection.PUBLIC}style="display:none;"{/if}><!--
    98     --><span class="button" title="{'Copy to clipboard'|@translate}">&nbsp;</span><!--
    99     --><input type="text" class="url" value="{$collection.U_PUBLIC}" size="{$collection.U_PUBLIC|strlen}"><!--
    100   --></span>
    101   </p>
    102 {/if}
    103179
    104180  <p>
     
    109185</form>
    110186
    111 
    112 {* <!-- send collection by mail -->*}
    113 {if $user_collections.allow_public && $user_collections.allow_mails}
     187{*<!-- create share links -->*}
     188{if isset($U_SHARE)}
    114189<div style="display:none;">
    115   <form id="mail_form" action="{$F_ACTION}" method="post">
    116   {if isset($uc_mail_errors)}
    117     {assign var=errors value=$uc_mail_errors}
    118     {include file='infos_errors.tpl'}
     190  <form id="share_form" class="uc_form" action="{$F_ACTION}" method="post">
     191    {include file='infos_errors.tpl' errors=$share.errors infos=$share.infos}
     192   
     193    <table>
     194      <tr>
     195        <td colspan="2" class="url-preview" style="white-space:nowrap;">
     196          <span class="url-base">{$U_SHARE}</span><span class="url-more url-normal"></span>
     197          <input type="text" name="share_key" class="url-edit" size="20" value="{$share.share_key}">
     198          <button class="url-normal edit_share_key">{'Edit'|@translate}</button>
     199          <button class="url-edit set_share_key">{'OK'|@translate}</button>
     200          <a href="#" class="url-edit cancel_share_key">{'Cancel'|@translate}</button>
     201        </td>
     202      </tr>
     203      <tr>
     204        <td class="title"><label>
     205          {'Password'|@translate}
     206          <input type="checkbox" name="use_share_password" data-for="share_password" class="share-option">
     207        </label></td>
     208        <td>
     209          <input type="text" name="share_password" size="25" maxlength="25" value="{$share.password}" placeholder="{'Password'|@translate}">
     210        </td>
     211      </tr>
     212      <tr>
     213        <td class="title"><label>
     214          {'Expiration date'|@translate}
     215          <input type="checkbox" name="use_share_deadline" data-for="share_deadline" class="share-option">
     216        </label></td>
     217        <td>
     218          <input type="text" name="share_deadline" size="25" value="{$share.deadline}" placeholder="{'Date'|@translate}">
     219        </td>
     220      </tr>
     221      <tr>
     222        <td class="title">&nbsp;</td>
     223        <td>
     224          <input class="submit" type="submit" name="add_share" value="{'Add'|@translate}">
     225          <a class="share_colorbox_close" href="#">{'Cancel'|@translate}</a>
     226          <input type="hidden" name="key" value="{$UC_TKEY}">
     227        </td>
     228      </tr>
     229    </table>
     230   
     231  {if not empty($collection.SHARES)}
     232    <table class="shares_list">
     233      <tr class="header">
     234        <th>{'Share key'|@translate}</th>
     235        <th>{'Creation date'|@translate}</th>
     236        <th>{'Password'|@translate}</th>
     237        <th>{'Expiration date'|@translate}</th>
     238        <th></th>
     239      </tr>
     240    {foreach from=$collection.SHARES item=share}
     241      <tr class="{cycle values='row2,row1'} {if $share.expired}expired{/if}">
     242        <td><a href="{$share.url}">{$share.share_key}</a></td>
     243        <td>{$share.add_date_readable}</td>
     244        <td>{if $share.params.password}{'Yes'|@translate}{else}{'No'|@translate}{/if}</td>
     245        <td>{if $share.params.deadline}{$share.params.deadline_readable}{else}{'No'|@translate}{/if}</td>
     246        <td><a href="{$share.u_delete}" onClick="return confirm('{'Are you sure?'|@translate}');">
     247          <img src="{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/delete.png" width=16 height=16></a>
     248        </td>
     249      </tr>
     250    {/foreach}
     251    </table>
    119252  {/if}
     253  </form>
     254</div>
     255{/if}
     256
     257{*<!-- send collection by mail -->*}
     258{if isset($U_MAIL)}
     259<div style="display:none;">
     260  <form id="mail_form" class="uc_form" action="{$F_ACTION}" method="post">
     261    {include file='infos_errors.tpl' errors=$contact.errors}
    120262
    121263    <table>
     
    163305          <input class="submit" type="submit" name="send_mail" value="{'Send'|@translate}">
    164306          <a class="mail_colorbox_close" href="#">{'Cancel'|@translate}</a>
    165           <input type="hidden" name="key" value="{$contact.KEY}" />
     307          <input type="hidden" name="key" value="{$UC_TKEY}">
    166308        </td>
    167309      </tr>
     
    183325{if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if}
    184326
     327{/if}
    185328
    186329{if isset($clear)}<div style="clear: both;"></div>
  • extensions/UserCollections/template/collection_view.tpl

    r23551 r24421  
    1818{/if}
    1919
     20{if $UC_MODE == 'password'}
     21<form action="{$F_LOGIN_ACTION}" method="post" name="login_form" class="properties">
     22  <fieldset>
     23    <legend>{'Restricted access'|@translate}</legend>
     24
     25    <ul>
     26      <li>
     27        <span class="property">
     28          <label for="uc_password">{'Password'|@translate}</label>
     29        </span>
     30        <input tabindex="1" class="login" type="password" name="uc_password" id="uc_password" size="25" maxlength="25">
     31      </li>
     32    </ul>
     33  </fieldset>
     34
     35  <p>
     36    <input tabindex="2" type="submit" value="{'Submit'|@translate}">
     37  </p>
     38</form>
     39
     40<script type="text/javascript"><!--
     41document.login_form.username.focus();
     42//--></script>
     43
     44{else}
    2045{if !empty($CONTENT_DESCRIPTION)}
    2146<div class="additional_info">
     
    3156
    3257{if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if}
     58{/if}
    3359
    3460{if isset($clear)}<div style="clear: both;"></div>
  • extensions/UserCollections/template/style_collections.css

    r23551 r24421  
    5757
    5858/* SEND BY MAIL */
    59 #mail_form {
     59.uc_form {
    6060  width:540px;
    6161  padding:10px;
    6262}
    63   #mail_form table td {
     63  .uc_form table td {
    6464    padding-bottom:5px;
    6565    text-align:left;
    6666  }
    67   #mail_form table td.title {
     67  .uc_form table td.title {
    6868    font-weight:bold;
    6969    text-align:right !important;
     
    7171    vertical-align:top;
    7272    width:120px;
     73    white-space:nowrap;
    7374  }
    74   #mail_form input[type="text"], #mail_form textarea, #mail_form select {
     75  .uc_form input[type="text"], .uc_form textarea, .uc_form select {
    7576    border-radius:2px;
    7677    padding:3px;
    7778  }
     79 
     80#share_form .url-base {
     81  font-size:0.9em;
     82}
     83#share_form .url-more {
     84  text-decoration:underline;
     85}
     86
     87.ui-datepicker-current { display:none; }
     88
     89.shares_list {
     90        border-left:1px solid #444;
     91        border-right:1px solid #444;
     92        margin:1em auto;
     93        padding:0;
     94  background-color:#222;
     95  border-spacing:0;
     96  text-align:left;
     97  color:#aaa;
     98}
     99
     100.shares_list td, .shares_list th {
     101        padding:5px 5px 2px 5px;
     102  vertical-align:center;
     103  border-top:1px solid #444;
     104  border-bottom:1px solid #111;
     105}
     106 
     107.shares_list tr.row2 td { background-color:#222; }
     108.shares_list tr.row1 td { background-color:#333; }
     109
     110.shares_list tr.expired td {
     111  text-decoration:line-through;
     112}
     113
     114.shares_list tr.header th
     115{
     116  height:30px;
     117}
     118.shares_list tr.header th {
     119  background:#333333;
     120  background:-moz-linear-gradient(top,  #333333 0%, #222222 100%);
     121  background:-webkit-gradient(linear, left top, left bottom, color-stop(0%,#333333), color-stop(100%,#222222));
     122  background:-webkit-linear-gradient(top,  #333333 0%,#222222 100%);
     123  background:-o-linear-gradient(top,  #333333 0%,#222222 100%);
     124  background:-ms-linear-gradient(top,  #333333 0%,#222222 100%);
     125  background:linear-gradient(top,  #333333 0%,#222222 100%);
     126  filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#333333', endColorstr='#222222',GradientType=0 );
     127}
  • extensions/UserCollections/template/themes/default.tpl

    r20093 r24421  
    6565  {/if}
    6666 
     67  {if $U_SHARE}
     68    <li><a href="#share_form" title="{'Share this collection'|@translate}" class="share_colorbox_open pwg-state-default pwg-button" rel="nofollow">
     69          <span class="pwg-icon user-collections-share-icon" style="background:url('{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/share.png') center center no-repeat;">&nbsp;</span><span class="pwg-button-text">{'Share'|@translate}</span>
     70    </a></li>
     71  {/if}
    6772  {if $U_MAIL}
    68     <li><a href="#mail_form" title="{'Send this collection my mail'|@translate}" class="mail_colorbox_open pwg-state-default pwg-button" rel="nofollow"
    69         {if not $collection.PUBLIC}onClick="alert('{'The collection must be public in order to send it'|@translate|escape:javascript}');return false;"{/if}>
     73    <li><a href="#mail_form" title="{'Send this collection my mail'|@translate}" class="mail_colorbox_open pwg-state-default pwg-button" rel="nofollow">
    7074          <span class="pwg-icon user-collections-mail-icon" style="background:url('{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/mail.png') center center no-repeat;">&nbsp;</span><span class="pwg-button-text">{'Send'|@translate}</span>
    7175    </a></li>
  • extensions/UserCollections/template/themes/simple.tpl

    r20093 r24421  
    44 
    55  <ul class="categoryActions">
     6  {if $U_SHARE}
     7    <li><a href="#share_form" title="{'Share this collection'|@translate}" class="share_colorbox_open pwg-state-default pwg-button" rel="nofollow">
     8          <span class="pwg-icon user-collections-share-icon" style="background:url('{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/share.png') center center no-repeat;">&nbsp;</span><span class="pwg-button-text">{'Share'|@translate}</span>
     9    </a></li>
     10  {/if}
    611  {if $U_MAIL}
    7     <li><a href="#mail_form" title="{'Send this collection my mail'|@translate}" class="mail_colorbox_open pwg-state-default pwg-button" rel="nofollow"
    8         {if not $collection.PUBLIC}onClick="alert('{'The collection must be public in order to send it'|@translate|escape:javascript}');return false;"{/if}>
     12    <li><a href="#mail_form" title="{'Send this collection my mail'|@translate}" class="mail_colorbox_open pwg-state-default pwg-button" rel="nofollow">
    913          <span class="pwg-icon user-collections-mail-icon" style="background:url('{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/mail.png') center center no-repeat;">&nbsp;</span><span class="pwg-button-text">{'Send'|@translate}</span>
    1014    </a></li>
  • extensions/UserCollections/template/themes/stripped.tpl

    r23551 r24421  
    1010      <li class="mainAction"><a href="{$U_CADDIE}" title="{'Add to caddie'|@translate}">{'Caddie'|@translate}</a></li>
    1111    {/if}
    12        
     12   
     13    {if $U_SHARE}
     14      <li><a href="#share_form" title="{'Share this collection'|@translate}" class="share_colorbox_open pwg-state-default pwg-button" rel="nofollow">
     15            <span class="pwg-icon user-collections-share-icon" style="background:url('{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/share.png') center center no-repeat;">&nbsp;</span><span class="pwg-button-text">{'Share'|@translate}</span>
     16      </a></li>
     17    {/if}
    1318    {if $U_MAIL}
    14       <li><a href="#mail_form" title="{'Send this collection my mail'|@translate}" class="mail_colorbox_open pwg-state-default pwg-button" rel="nofollow"
    15           {if not $collection.PUBLIC}onClick="alert('{'The collection must be public in order to send it'|@translate|escape:javascript}');return false;"{/if}>
     19      <li><a href="#mail_form" title="{'Send this collection my mail'|@translate}" class="mail_colorbox_open pwg-state-default pwg-button" rel="nofollow">
    1620            <span class="pwg-icon user-collections-mail-icon" style="background:url('{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/mail.png') center center no-repeat;">&nbsp;</span><span class="pwg-button-text">{'Send'|@translate}</span>
    1721      </a></li>
  • extensions/UserCollections/template/thumbnails_colorbox.tpl

    r23551 r24421  
     1{if not isset($UC_NO_LIGHTBOX)}
    12{combine_script id='jquery.colorbox' load='footer' require='jquery' path='themes/default/js/plugins/jquery.colorbox.min.js'}
    23{combine_css path='themes/default/js/plugins/colorbox/style2/colorbox.css'}
     4{/if}
    35
    46{footer_script}
  • extensions/UserCollections/template/thumbnails_css_js.tpl

    r23551 r24421  
    2121// events on "new collection" input
    2222$cdm.find("input.new").on({ldelim}
    23   // ENTER pressed
     23  // ENTER or ESC pressed
    2424  "keyup": function(event) {ldelim}
     25    if (event.which == 27) {
     26      jQuery(this).val('').hide().prev().show();
     27      return;
     28    }
     29   
    2530    if (event.which != 13) return;
    2631   
    2732    jQuery(this).hide().prev().show();
    2833    var name = jQuery(this).val();
    29     jQuery(this).val("{'Name'|@translate}");
     34    jQuery(this).val('');
    3035   
    3136    if (name == "" || name == null) return;
     
    5661      },
    5762      error: function() {ldelim}
    58         alert("{'Un unknown error occured'|@translate}");
     63        alert("{'An unknown error occured'|@translate}");
    5964      }
    6065    });
     
    6570  "click": function(event) {ldelim}
    6671    event.stopPropagation();
    67   },
    68   // remove help on focus
    69   "focus": function() {ldelim}
    70     if (jQuery(this).val() == "{'Name'|@translate}") jQuery(this).val("");
    71   },
    72   // restore help on blur
    73   "blur" : function() {ldelim}
    74     if (jQuery(this).val() == "") jQuery(this).val("{'Name'|@translate}");
    7572  }
    7673});
     
    111108    },
    112109    error: function() {ldelim}
    113       alert("{'Un unknown error occured'|@translate}");
     110      alert("{'An unknown error occured'|@translate}");
    114111    }
    115112  });
     
    164161  <div class="switchBoxFooter">
    165162  <span>&#10010;</span> <a class="new">{'Create a new collection'|@translate}</a>
    166   <input class="new" value="{'Name'|@translate}" size="25"/>
     163  <input class="new" placeholder="{'Name'|@translate}" size="25"/>
    167164  </div>
    168165</div>
     
    201198    },
    202199    error: function() {ldelim}
    203       alert("{'Un unknown error occured'|@translate}");
     200      alert("{'An unknown error occured'|@translate}");
    204201    }
    205202  });
Note: See TracChangeset for help on using the changeset viewer.