Changeset 16597


Ignore:
Timestamp:
Jul 10, 2012, 5:37:33 PM (8 years ago)
Author:
mistic100
Message:

-menu always displayed if user has unactive collections
-better user status checks
-localizations

Location:
extensions/UserCollections
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserCollections/include/collections.inc.php

    r16591 r16597  
    88switch ($page['sub_section'])
    99{
     10  /* list */
    1011  case 'list':
    1112  {
     13    if (is_a_guest()) access_denied();
     14   
    1215    $template->set_filename('index', dirname(__FILE__) . '/../template/list.tpl');
    1316   
     
    125128    {
    126129      $col['date_creation'] = format_date($col['date_creation'], true);
    127       $col['U_VIEW'] = USER_COLLEC_PUBLIC.'view/'.$col['id'];
    128130      $col['U_EDIT'] = USER_COLLEC_PUBLIC.'edit/'.$col['id'];
    129131      $col['U_ACTIVE'] = USER_COLLEC_PUBLIC.'&action=set_active&col_id='.$col['id'];
     
    133135      {
    134136        $col['name'] = 'temp #'.$col['id'];
     137        $col['U_VIEW'] = $col['U_EDIT'];
    135138        $col['U_SAVE'] = USER_COLLEC_PUBLIC.'&action=save&col_id='.$col['id'];
    136139        $template->append('temp_col', $col);
     
    138141      else
    139142      {
     143        $col['U_VIEW'] = USER_COLLEC_PUBLIC.'view/'.$col['id'];
    140144        $template->append('collections', $col);
    141145      }
     
    145149    break;
    146150  }
    147    
     151 
     152  /* edit */
    148153  case 'edit':
    149154  {
     
    165170    try {
    166171      $UserCollection = new UserCollection($page['col_id']);
     172     
     173      if (!is_admin() and $UserCollection->getParam('user_id') != $user['id'])
     174      {
     175        access_denied();
     176      }
    167177     
    168178      // save properties
     
    199209     
    200210      include(PHPWG_ROOT_PATH . 'include/category_default.inc.php');
     211     
     212      $template->concat('TITLE', $conf['level_separator'].$UserCollection->getParam('name'));
    201213    }
    202214    catch (Exception $e)
     
    208220  }
    209221 
     222  /* view */
    210223  case 'view':
    211224  {
     
    234247     
    235248      $template->assign('collection', $UserCollection->getCollectionInfo());
    236      
    237       include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
    238       $template->assign('OWNER', get_username($UserCollection->getParam('user_id')));
    239249     
    240250      $page['start'] = isset($_GET['start']) ? $_GET['start'] : 0;
     
    254264     
    255265      include(PHPWG_ROOT_PATH . 'include/category_default.inc.php');
     266     
     267      include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     268      $template->concat('TITLE',
     269        $conf['level_separator'].$UserCollection->getParam('name').
     270        ' ('.sprintf(l10n('by %s'), get_username($UserCollection->getParam('user_id'))).')'
     271        );
    256272    }
    257273    catch (Exception $e)
    258274    {
    259       array_push($page['errors'], $e->getMessage());
     275      access_denied();
    260276    }
    261277   
    262278    break;
    263279  }
    264    
    265   // case 'send':
    266   // {
    267    
    268     // break;
    269   // }
    270280}
    271281
  • extensions/UserCollections/include/events.inc.php

    r16591 r16597  
    77function user_collections_init()
    88{
    9   global $conf;
    10  
    11   // $conf['user_collections'] = unserialize($conf['user_collections']);
    129  load_language('plugin.lang', USER_COLLEC_PATH);
    1310}
     
    2421    $page['title'] = '<a href="'.USER_COLLEC_PUBLIC.'">'.l10n('Collections').'</a>';
    2522   
    26     switch (@$tokens[1])
    27     {
    28       case 'edit':
    29         $page['sub_section'] = 'edit';
    30         $page['title'].= $conf['level_separator'].' '.l10n('Edit');
    31         break;
    32       case 'view':
    33         $page['sub_section'] = 'view';
    34         $page['title'].= $conf['level_separator'].' '.l10n('View');
    35         break;
    36       // case 'send':
    37         // $page['sub_section'] = 'send';
    38         // $page['title'].= $conf['level_separator'].' '.l10n('Send');
    39         // break;
    40       default:
    41         $page['sub_section'] = 'list';
     23    if (in_array(@$tokens[1], array('edit','view','list')))
     24    {
     25       $page['sub_section'] = $tokens[1];
     26    }
     27    else
     28    {
     29      $page['sub_section'] = 'list';
    4230    }
    4331   
     
    6452function user_collections_index_actions()
    6553{
     54  if (is_a_guest()) return;
     55 
    6656  global $page, $UserCollection;
    6757     
     
    8070function user_collections_thumbnails_list($tpl_thumbnails_var, $pictures)
    8171{
     72  if (is_a_guest()) return $tpl_thumbnails_var;
     73 
    8274  global $page, $template, $UserCollection;
    8375 
     
    9991    $collection = array();
    10092  }
    101  
    10293 
    10394 
     
    142133function user_collections_picture_page()
    143134{
     135  if (is_a_guest()) return;
     136 
    144137  global $template, $picture, $UserCollection;
    145138 
     
    186179function user_collections_add_menublock($menu_ref_arr)
    187180{
     181  if (is_a_guest()) return;
     182 
     183  global $user;
     184 
    188185  $menu = &$menu_ref_arr[0];
    189186  if ($menu->get_id() != 'menubar') return;
    190187 
    191   if (get_current_collection_id(false) === false) return;
    192  
    193   $menu->register_block(new RegisteredBlock('mbUserCollection', l10n('Download Basket'), 'UserCollection'));
     188  $query = '
     189SELECT id
     190  FROM '.COLLECTIONS_TABLE.'
     191  WHERE user_id = '.$user['id'].'
     192  LIMIT 1
     193;';
     194  $result = pwg_query($query);
     195 
     196  if (!pwg_db_num_rows($result)) return;
     197 
     198  $menu->register_block(new RegisteredBlock('mbUserCollection', l10n('Collections'), 'UserCollection'));
    194199}
    195200
     
    201206  if (($block = $menu->get_block('mbUserCollection')) != null)
    202207  {
    203     if (empty($UserCollection))
    204     {
    205       $UserCollection = new UserCollection(get_current_collection_id());
    206     }
    207    
    208     $data = array(
    209       'U_LIST' => USER_COLLEC_PUBLIC,
    210       'current' => array(
    211         'NAME' => $UserCollection->getParam('name'),
    212         'NB_IMAGES' => $UserCollection->getParam('nb_images'),
    213         ),
    214       'links' => array(),
    215       );
    216      
    217     if ($data['current']['NB_IMAGES'] > 0)
    218     {
    219       $data['links'] = array(
    220         array(
    221           'URL' => USER_COLLEC_PUBLIC.'view/'.$UserCollection->getParam('col_id'),
    222           'NAME' => l10n('View'),
     208    if (($col_id = get_current_collection_id(false)) !== false)
     209    {
     210      if (empty($UserCollection))
     211      {
     212        $UserCollection = new UserCollection($col_id);
     213      }
     214   
     215      $data = array(
     216        'current' => array(
     217          'NAME' => $UserCollection->getParam('name'),
     218          'NB_IMAGES' => $UserCollection->getParam('nb_images'),
    223219          ),
    224         array(
    225           'URL' => USER_COLLEC_PUBLIC.'&amp;action=clear&amp;col_id='.$UserCollection->getParam('col_id'),
    226           'NAME' => l10n('Clear'),
    227           ),
     220        'links' => array(),
    228221        );
    229     }
     222       
     223      if ($data['current']['NB_IMAGES'] > 0)
     224      {
     225        $data['links'] = array(
     226          array(
     227            'URL' => USER_COLLEC_PUBLIC.'edit/'.$UserCollection->getParam('col_id'),
     228            'NAME' => l10n('Display collection'),
     229            ),
     230          array(
     231            'URL' => USER_COLLEC_PUBLIC.'&amp;action=clear&amp;col_id='.$UserCollection->getParam('col_id'),
     232            'NAME' => l10n('Clear collection'),
     233            ),
     234          );
     235      }
     236    }
     237   
     238    $data['U_LIST'] = USER_COLLEC_PUBLIC;
    230239     
    231240    $template->set_template_dir(USER_COLLEC_PATH . 'template/');
  • extensions/UserCollections/language/en_UK/description.txt

    r16591 r16597  
     1Registered users can select pictures from the gallery and save them into collections, like advanced favorites.
  • extensions/UserCollections/language/en_UK/plugin.lang.php

    r16591 r16597  
    11<?php
    22
    3 
     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 collections list';
     7$lang['This collection is empty'] = 'This collection is empty';
     8$lang['Collection name:'] = 'Collection name:';
     9$lang['Create a new collection'] = 'Create a new collection';
     10$lang['Unsaved collections'] = 'Unsaved collections';
     11$lang['save'] = 'save';
     12$lang['set active'] = 'set active';
     13$lang['Saved collections'] = 'Saved collections';
     14$lang['Current collection:'] = 'Current collection:';
     15$lang['See all my collections'] = 'See all my collections';
     16$lang['Please give a name'] = 'Please give a name';
     17$lang['Invalid collection'] = 'Invalid collection';
     18$lang['by %s'] = 'by %s';
     19$lang['Collections'] = 'Collections';
     20$lang['Remove from collection'] = 'Remove from collection';
     21$lang['Add to collection'] = 'Add to collection';
     22$lang['Display collection'] = 'Display';
     23$lang['Clear collection'] = 'Clear';
    424
    525?>
  • extensions/UserCollections/language/fr_FR/description.txt

    r16591 r16597  
     1Les utilisateurs inscrits peuvent sélectionner des photos et es sauvegarder dans des collections, comme des favoris avancés.
  • extensions/UserCollections/language/fr_FR/plugin.lang.php

    r16591 r16597  
    11<?php
    22
    3 
     3$lang['Copied'] = 'Copié';
     4$lang['Public collection'] = 'Publique';
     5$lang['Copy to clipboard'] = 'Copier dans le press-papier';
     6$lang['Return to collections list'] = 'Retourner à la liste des collections';
     7$lang['This collection is empty'] = 'Cette collection est vide';
     8$lang['Collection name:'] = 'Nom de la collection:';
     9$lang['Create a new collection'] = 'Créer une nouvelle collection';
     10$lang['Unsaved collections'] = 'Collections temporaires';
     11$lang['save'] = 'sauvegarder';
     12$lang['set active'] = 'choisir comme collection active';
     13$lang['Saved collections'] = 'Collections sauvegardées';
     14$lang['Current collection:'] = 'Collection actuelle:';
     15$lang['See all my collections'] = 'Voir toutes mes collections';
     16$lang['Please give a name'] = 'Veuillez donner un nom';
     17$lang['Invalid collection'] = 'Collection invalide';
     18$lang['by %s'] = 'par %s';
     19$lang['Collections'] = 'Collections';
     20$lang['Remove from collection'] = 'Supprimer de la collection';
     21$lang['Add to collection'] = 'Ajouter à la collection';
     22$lang['Display collection'] = 'Afficher';
     23$lang['Clear collection'] = 'Vider';
    424
    525?>
  • extensions/UserCollections/main.inc.php

    r16591 r16597  
    33Plugin Name: User Collections
    44Version: auto
    5 Description: Registered users can select pictures from the gallery and save them into collections, kind of advanced favorites.
    6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=
     5Description: Registered users can select pictures from the gallery and save them into collections, like advanced favorites.
     6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=615
    77Author: Mistic
    88Author URI: http://www.strangeplanet.fr
     
    1313global $conf, $prefixeTable;
    1414
    15 define('USER_COLLEC_PATH',      PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
    16 define('COLLECTIONS_TABLE',     $prefixeTable.'collections');
     15define('USER_COLLEC_PATH',       PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
     16define('COLLECTIONS_TABLE',      $prefixeTable.'collections');
    1717define('COLLECTION_IMAGES_TABLE',$prefixeTable.'collection_images');
    18 define('USER_COLLEC_ADMIN',     get_root_url() . 'admin.php?page=plugin-' . basename(dirname(__FILE__)));
    19 define('USER_COLLEC_PUBLIC',    make_index_url(array('section' => 'collections')) . '/');
     18define('USER_COLLEC_ADMIN',      get_root_url() . 'admin.php?page=plugin-' . basename(dirname(__FILE__)));
     19define('USER_COLLEC_PUBLIC',     make_index_url(array('section' => 'collections')) . '/');
    2020
    2121
  • extensions/UserCollections/template/edit.tpl

    r16591 r16597  
    2929
    3030<div id="content" class="content{if isset($MENUBAR)} contentWithMenu{/if}">
    31 <div class="titrePage{if isset($chronology.TITLE)} calendarTitleBar{/if}">
     31<div class="titrePage">
    3232  <ul class="categoryActions">
    3333  {if !empty($COLLECTION_ACTIONS)}{$COLLECTION_ACTIONS}{/if}
     
    4747  <p class="title"><label for="name">{'Name'|@translate}</label></p>
    4848  <p><input type="text" name="name" id="name" value="{$collection.NAME}" size="60"></p>
    49   <p class="title">{'Public'|@translate}</p>
     49  <p class="title">{'Public collection'|@translate}</p>
    5050  <p>
    5151    <label><input type="radio" name="public" value="0" {if not $collection.PUBLIC}checked="checked"{/if}> {'No'|@translate}</label>
    5252    <label><input type="radio" name="public" value="1" {if $collection.PUBLIC}checked="checked"{/if}> {'Yes'|@translate}</label>
    53     <span id="publicURL" {if not $collection.PUBLIC}style="display:none;"{/if}><span class="button" title="{'Copy to clipborad'|@translate}">&nbsp;</span><span class="url">{$collection.U_PUBLIC}</span></span>
     53    <span id="publicURL" {if not $collection.PUBLIC}style="display:none;"{/if}><span class="button" title="{'Copy to clipboard'|@translate}">&nbsp;</span><span class="url">{$collection.U_PUBLIC}</span></span>
    5454  </p>
    5555  <p>
  • extensions/UserCollections/template/list.tpl

    r16591 r16597  
    44jQuery(".save_col").click(function() {ldelim}
    55  var name = prompt("{'Collection name:'|@translate}");
    6   $(this).attr("href",  $(this).attr("href") +"&name="+ name);
    7   return true;
     6  if (name != null) {ldelim}
     7    $(this).attr("href",  $(this).attr("href") +"&name="+ name);
     8    return true;
     9  } else {ldelim}
     10    return false;
     11  }
    812});
    913{/footer_script}
  • extensions/UserCollections/template/menublock.tpl

    r16591 r16597  
    11<dt>{$block->get_title()}</dt>
    22<dd>
     3{if $block->data.current}
    34  {'Current collection:'|@translate} <b>{$block->data.current.NAME}</b>, {'%d images'|@translate|@sprintf:$block->data.current.NB_IMAGES}
    45        <ul>{strip}
     
    78                {/foreach}
    89        {/strip}</ul>
     10{/if}
    911  <a href="{$block->data.U_LIST}" rel="nofollow">{'See all my collections'|@translate}</a>
    1012</dd>
  • extensions/UserCollections/template/view.tpl

    r16591 r16597  
    44
    55<div id="content" class="content{if isset($MENUBAR)} contentWithMenu{/if}">
    6 <div class="titrePage{if isset($chronology.TITLE)} calendarTitleBar{/if}">
     6<div class="titrePage">
    77  <ul class="categoryActions">
    88  {if !empty($COLLECTION_ACTIONS)}{$COLLECTION_ACTIONS}{/if}
     
    1414{include file='infos_errors.tpl'}
    1515{/if}
    16 
    17 {if $collection}
    18 <fieldset id="colProperties">
    19   <legend>{'Properties'|@translate}</legend>
    20  
    21   <p class="title">{'Name'|@translate}</p>
    22   <p>{$collection.NAME}</p>
    23   <p class="title">{'Owner'|@translate}</p>
    24   <p>{$OWNER}</p>
    25   <p class="title">{'Creation date'|@translate}</p>
    26   <p>{$collection.DATE_CREATION}</p>
    27 </fieldset>
    28 </form>
    29 {/if}
    30 
    3116
    3217{if !empty($THUMBNAILS)}
Note: See TracChangeset for help on using the changeset viewer.