Changeset 632


Ignore:
Timestamp:
Dec 4, 2004, 1:10:17 PM (19 years ago)
Author:
plg
Message:
  • change "->" in a beautiful arrow :-) for categories level in admin
  • single category management screen updated : commentable and uploadable properties added, full directory displayed, status and visibility properties update uses inheritance, user favorite elements check moved to somewhere else : would be too long to calculate here for too many users
  • new admin functions set_cat_visible and set_cat_status : visibility and status updates can be done in cat_options and cat_modify
  • language : differentiate "locked" (state) and "lock" (action)
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_list.php

    r628 r632  
    133133if (isset($_GET['parent_id']))
    134134{
    135   $separator = ' -> ';
     135  $separator = ' <span style="font-size:15px">&rarr;</span> ';
    136136  $base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_list';
    137137 
  • trunk/admin/cat_modify.php

    r623 r632  
    2626// +-----------------------------------------------------------------------+
    2727
    28 if( !defined("PHPWG_ROOT_PATH") )
     28if (!defined('PHPWG_ROOT_PATH'))
    2929{
    30         die ("Hacking attempt!");
     30  die('Hacking attempt!');
    3131}
    32 include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
    33 
     32include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
    3433//---------------------------------------------------------------- verification
    3534if ( !isset( $_GET['cat_id'] ) || !is_numeric( $_GET['cat_id'] ) )
     
    4342if ( isset( $_POST['submit'] ) )
    4443{
    45   // if new status is different from previous one, deletion of all related
    46   // links for access rights
    4744  $query = 'SELECT status';
    4845  $query.= ' FROM '.CATEGORIES_TABLE;
     
    6461    $query.= "'".htmlentities( $_POST['comment'], ENT_QUOTES )."'";
    6562
    66   $query.= ", status = '".$_POST['status']."'";
    67   $query.= ", visible = '".$_POST['visible']."'";
    6863  if ( isset( $_POST['uploadable'] ) )
    6964    $query.= ", uploadable = '".$_POST['uploadable']."'";
     
    8176  pwg_query( $query );
    8277
    83   if ( $_POST['status'] != $row['status'] )
    84   {
    85     // deletion of all access for groups concerning this category
    86     $query = 'DELETE';
    87     $query.= ' FROM '.GROUP_ACCESS_TABLE;
    88     $query.= ' WHERE cat_id = '.$_GET['cat_id'];
    89     pwg_query( $query );
    90     // deletion of all access for users concerning this category
    91     $query = 'DELETE';
    92     $query.= ' FROM '.USER_ACCESS_TABLE;
    93     $query.= ' WHERE cat_id = '.$_GET['cat_id'];
    94     pwg_query( $query );
    95   }
     78  set_cat_visible(array($_GET['cat_id']), $_POST['visible']);
     79  set_cat_status(array($_GET['cat_id']), $_POST['status']);
    9680
    97   // checking users favorites
    98   $query = 'SELECT id';
    99   $query.= ' FROM '.USERS_TABLE;
    100   $query.= ';';
    101   $result = pwg_query( $query );
    102   while ( $row = mysql_fetch_array( $result ) )
    103   {
    104     check_favorites( $row['id'] );
    105   }
    10681  $template->assign_block_vars('confirmation' ,array());
    10782}
    10883
    109 $query = 'SELECT a.*, b.*';
    110 $query.= ' FROM '.CATEGORIES_TABLE.' as a, '.SITES_TABLE.' as b';
    111 $query.= ' WHERE a.id = '.$_GET['cat_id'];
    112 $query.= ' AND a.site_id = b.id';
    113 $query.= ';';
     84$query = '
     85SELECT *
     86  FROM '.CATEGORIES_TABLE.'
     87  WHERE id = '.$_GET['cat_id'].'
     88;';
    11489$category = mysql_fetch_array( pwg_query( $query ) );
    11590// nullable fields
    116 foreach (array('comment','dir') as $nullable)
     91foreach (array('comment','dir','site_id') as $nullable)
    11792{
    11893  if (!isset($category[$nullable]))
     
    126101$url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&amp;parent_id=';
    127102$navigation = '<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.'admin.php?page=cat_list').'">';
    128 $navigation.= $lang['home'].'</a>-&gt;';
    129 $navigation.= get_cat_display_name($current_category['name'], '-&gt;', $url);
     103$navigation.= $lang['home'].'</a> <span style="font-size:15px">&rarr;</span>';
     104$navigation.= get_cat_display_name(
     105  $current_category['name'],
     106  ' <span style="font-size:15px">&rarr;</span>',
     107  $url);
    130108
    131109$form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id='.$_GET['cat_id'];
    132 $access = ($category['status']=='public')?'ACCESS_FREE':'ACCESS_RESTRICTED';
     110$status = ($category['status']=='public')?'STATUS_PUBLIC':'STATUS_PRIVATE';
    133111$lock = ($category['visible']=='true')?'UNLOCKED':'LOCKED';
     112
     113if ($category['commentable'] == 'true')
     114{
     115  $commentable = 'COMMENTABLE_TRUE';
     116}
     117else
     118{
     119  $commentable = 'COMMENTABLE_FALSE';
     120}
     121if ($category['uploadable'] == 'true')
     122{
     123  $uploadable = 'UPLOADABLE_TRUE';
     124}
     125else
     126{
     127  $uploadable = 'UPLOADABLE_FALSE';
     128}
    134129
    135130//----------------------------------------------------- template initialization
     
    138133  'CAT_NAME'=>$category['name'],
    139134  'CAT_COMMENT'=>$category['comment'],
    140   'CATEGORY_DIR'=>$category['dir'],
    141   'SITE_URL'=>$category['galleries_url'],
     135  'CATEGORY_DIR'=>preg_replace('/\/$/', '', get_complete_dir($category['id'])),
    142136 
    143   $access=>'checked="checked"',
     137  $status=>'checked="checked"',
    144138  $lock=>'checked="checked"',
     139  $commentable=>'checked="checked"',
     140  $uploadable=>'checked="checked"',
    145141 
    146142  'L_EDIT_CONFIRM'=>$lang['editcat_confirm'],
    147143  'L_EDIT_NAME'=>$lang['description'],
    148144  'L_STORAGE'=>$lang['storage'],
     145  'L_REMOTE_SITE'=>$lang['remote_site'],
    149146  'L_EDIT_COMMENT'=>$lang['comment'],
    150147  'L_EDIT_STATUS'=>$lang['conf_access'],
    151148  'L_EDIT_STATUS_INFO'=>$lang['cat_access_info'],
    152   'L_ACCESS_FREE'=>$lang['free'],
    153   'L_ACCESS_RESTRICTED'=>$lang['restricted'],
     149  'L_STATUS_PUBLIC'=>$lang['public'],
     150  'L_STATUS_PRIVATE'=>$lang['private'],
    154151  'L_EDIT_LOCK'=>$lang['lock'],
    155   'L_EDIT_LOCK_INFO'=>$lang['cat_lock_info'],
     152  'L_EDIT_LOCK_INFO'=>$lang['editcat_visible_info'],
     153  'L_EDIT_UPLOADABLE'=>$lang['editcat_uploadable'],
     154  'L_EDIT_UPLOADABLE_INFO'=>$lang['editcat_uploadable_info'],
     155  'L_EDIT_COMMENTABLE'=>$lang['editcat_commentable'],
     156  'L_EDIT_COMMENTABLE_INFO'=>$lang['editcat_commentable_info'],
    156157  'L_YES'=>$lang['yes'],
    157158  'L_NO'=>$lang['no'],
     
    161162  ));
    162163 
    163 if ( !empty($category['dir']))
     164if (!empty($category['dir']))
    164165{
    165166  $template->assign_block_vars('storage' ,array());
     167  $template->assign_block_vars('upload' ,array());
    166168}
    167169
    168 if ( $category['site_id'] != 1 )
     170if (is_numeric($category['site_id']) and $category['site_id'] != 1)
    169171{
    170   $template->assign_block_vars('storage' ,array());
     172  $query = '
     173SELECT galleries_url
     174  FROM '.SITES_TABLE.'
     175  WHERE id = '.$category['site_id'].'
     176;';
     177  list($galleries_url) = mysql_fetch_array(pwg_query($query));
     178  $template->assign_block_vars('server', array('SITE_URL' => $galleries_url));
    171179}
    172180
  • trunk/admin/cat_options.php

    r627 r632  
    6565    case 'visible' :
    6666    {
    67       // locking a category   => all its child categories become locked
    68       $subcats = get_subcat_ids($_POST['cat_true']);
    69       $query = '
    70 UPDATE '.CATEGORIES_TABLE.'
    71   SET visible = \'false\'
    72   WHERE id IN ('.implode(',', $subcats).')
    73 ;';
    74       pwg_query($query);
     67      set_cat_visible($_POST['cat_true'], 'false');
    7568      break;
    7669    }
    7770    case 'status' :
    7871    {
    79       // make a category private => all its child categories become private
    80       $subcats = get_subcat_ids($_POST['cat_true']);
    81       $query = '
    82 UPDATE '.CATEGORIES_TABLE.'
    83   SET status = \'private\'
    84   WHERE id IN ('.implode(',', $subcats).')
    85 ;';
    86       pwg_query($query);
     72      set_cat_status($_POST['cat_true'], 'private');
    8773      break;
    8874    }
     
    117103    case 'visible' :
    118104    {
    119       // unlocking a category => all its parent categories become unlocked
    120       $uppercats = array();
    121       $query = '
    122 SELECT uppercats
    123   FROM '.CATEGORIES_TABLE.'
    124   WHERE id IN ('.implode(',', $_POST['cat_false']).')
    125 ;';
    126       $result = pwg_query($query);
    127       while ($row = mysql_fetch_array($result))
    128       {
    129         $uppercats = array_merge($uppercats,
    130                                  explode(',', $row['uppercats']));
    131       }
    132       $uppercats = array_unique($uppercats);
    133      
    134       $query = '
    135 UPDATE '.CATEGORIES_TABLE.'
    136   SET visible = \'true\'
    137   WHERE id IN ('.implode(',', $uppercats).')
    138 ;';
    139       pwg_query($query);
     105      set_cat_visible($_POST['cat_false'], 'true');
    140106      break;
    141107    }
    142108    case 'status' :
    143109    {
    144       // make public a category => all its parent categories become public
    145       $uppercats = array();
    146       $query = '
    147 SELECT uppercats
    148   FROM '.CATEGORIES_TABLE.'
    149   WHERE id IN ('.implode(',', $_POST['cat_false']).')
    150 ;';
    151       $result = pwg_query($query);
    152       while ($row = mysql_fetch_array($result))
    153       {
    154         $uppercats = array_merge($uppercats,
    155                                  explode(',', $row['uppercats']));
    156       }
    157       $uppercats = array_unique($uppercats);
    158      
    159       $query = '
    160 UPDATE '.CATEGORIES_TABLE.'
    161   SET status = \'public\'
    162   WHERE id IN ('.implode(',', $uppercats).')
    163 ;';
    164       pwg_query($query);
     110      set_cat_status($_POST['cat_false'], 'public');
    165111      break;
    166112    }
     
    274220      array(
    275221        'L_CAT_TITLE' => $lang['cat_lock_title'],
    276         'L_CAT_OPTIONS_TRUE' => $lang['lock'],
    277         'L_CAT_OPTIONS_FALSE' => $lang['unlock'],
     222        'L_CAT_OPTIONS_TRUE' => $lang['unlocked'],
     223        'L_CAT_OPTIONS_FALSE' => $lang['locked'],
    278224        'L_CAT_OPTIONS_INFO' => $lang['cat_lock_info'],
    279225        )
  • trunk/admin/include/functions.php

    r630 r632  
    991991  mass_updates(CATEGORIES_TABLE, $fields, $datas);
    992992}
     993
     994/**
     995 * change the visible property on a set of categories
     996 *
     997 * @param array categories
     998 * @param string value
     999 * @return void
     1000 */
     1001function set_cat_visible($categories, $value)
     1002{
     1003  if (!in_array($value, array('true', 'false')))
     1004  {
     1005    return false;
     1006  }
     1007
     1008  // unlocking a category => all its parent categories become unlocked
     1009  if ($value == 'true')
     1010  {
     1011    $uppercats = array();
     1012    $query = '
     1013SELECT uppercats
     1014  FROM '.CATEGORIES_TABLE.'
     1015  WHERE id IN ('.implode(',', $categories).')
     1016;';
     1017    $result = pwg_query($query);
     1018    while ($row = mysql_fetch_array($result))
     1019    {
     1020      $uppercats = array_merge($uppercats,
     1021                               explode(',', $row['uppercats']));
     1022    }
     1023    $uppercats = array_unique($uppercats);
     1024     
     1025    $query = '
     1026UPDATE '.CATEGORIES_TABLE.'
     1027  SET visible = \'true\'
     1028  WHERE id IN ('.implode(',', $uppercats).')
     1029;';
     1030    pwg_query($query);
     1031  }
     1032  // locking a category   => all its child categories become locked
     1033  if ($value == 'false')
     1034  {
     1035    $subcats = get_subcat_ids($categories);
     1036    $query = '
     1037UPDATE '.CATEGORIES_TABLE.'
     1038  SET visible = \'false\'
     1039  WHERE id IN ('.implode(',', $subcats).')
     1040;';
     1041    pwg_query($query);
     1042  }
     1043}
     1044
     1045/**
     1046 * change the status property on a set of categories : private or public
     1047 *
     1048 * @param array categories
     1049 * @param string value
     1050 * @return void
     1051 */
     1052function set_cat_status($categories, $value)
     1053{
     1054  if (!in_array($value, array('public', 'private')))
     1055  {
     1056    return false;
     1057  }
     1058
     1059  // make public a category => all its parent categories become public
     1060  if ($value == 'public')
     1061  {
     1062    $uppercats = array();
     1063    $query = '
     1064SELECT uppercats
     1065  FROM '.CATEGORIES_TABLE.'
     1066  WHERE id IN ('.implode(',', $categories).')
     1067;';
     1068    $result = pwg_query($query);
     1069    while ($row = mysql_fetch_array($result))
     1070    {
     1071      $uppercats = array_merge($uppercats,
     1072                               explode(',', $row['uppercats']));
     1073    }
     1074    $uppercats = array_unique($uppercats);
     1075     
     1076    $query = '
     1077UPDATE '.CATEGORIES_TABLE.'
     1078  SET status = \'public\'
     1079  WHERE id IN ('.implode(',', $uppercats).')
     1080;';
     1081    pwg_query($query);
     1082  }
     1083  // make a category private => all its child categories become private
     1084  if ($value == 'private')
     1085  {
     1086    $subcats = get_subcat_ids($categories);
     1087    $query = '
     1088UPDATE '.CATEGORIES_TABLE.'
     1089  SET status = \'private\'
     1090  WHERE id IN ('.implode(',', $subcats).')
     1091;';
     1092    pwg_query($query);
     1093  }
     1094}
    9931095?>
  • trunk/language/en_UK.iso-8859-1/admin.lang.php

    r631 r632  
    4444$lang['free'] = 'Free';
    4545$lang['restricted'] = 'Restricted';
     46$lang['public'] = 'public';
     47$lang['private'] = 'private';
    4648$lang['metadata']='Metadata';
    4749$lang['visitors'] = 'Visitors';
     50$lang['locked'] = 'Locked';
     51$lang['unlocked'] = 'Unlocked';
    4852$lang['lock'] = 'Lock';
    4953$lang['unlock'] = 'Unlock';
     
    9094$lang['editcat_confirm'] = 'Category informations updated successfully.';
    9195$lang['editcat_perm'] = 'To set permissions for this category, click';
    92 $lang['cat_access_info'] = 'Permission management.';
     96$lang['editcat_uploadable'] = 'Authorize upload';
     97$lang['editcat_uploadable_info'] = 'Authorize users to upload files';
     98$lang['editcat_commentable'] = 'Users comments';
     99$lang['editcat_commentable_info'] = 'Authorize users to comment elements of this category';
     100$lang['cat_access_info'] = 'Permission management. If you make a category private, all its child categories becomes private. If you make a category public, all its parent categories becomes public';
     101$lang['editcat_visible_info'] = 'Lock temporary for maintenance. If you lock a category, all its child categories become locked. If you unlock a category, all its parent categories become unlocked.';
    93102$lang['cat_virtual_added'] = 'Virtual category added';
    94103$lang['cat_virtual_deleted'] = 'Virtual category deleted';
     
    96105$lang['cat_upload_info'] = 'Only non virtual and non remote categories are shown.';
    97106$lang['cat_lock_title'] = 'Lock categories';
    98 $lang['cat_lock_info'] = 'Selected categories will temporary been disabled for maintenance.';
     107$lang['cat_lock_info'] = 'Selected categories will temporary been disabled for maintenance.
     108<br />If you lock a category, all its child categories become locked.
     109<br />If you unlock a category, all its parent categories become unlocked.';
    99110$lang['cat_comments_title'] = 'Authorize users to add comments on selected categories';
    100111$lang['cat_comments_info'] = 'By inheritance, an element is commentable if it belongs at least to one commentable category.';
     
    102113$lang['cat_status_info'] = 'Selected categories are private : you will need to authorize users and/or groups to access to them.
    103114<br />If you make a category private, all its child categories becomes private.
    104 <br />It you make a category public, all its parent categories becomes public';
     115<br />If you make a category public, all its parent categories becomes public';
    105116
    106117// Titles
  • trunk/template/default/admin/cat_modify.tpl

    r403 r632  
    88    <!-- BEGIN server -->
    99    <tr>
    10       <td style="width:50%;">{L_REMOTE_SITE}</td>
    11       <td class="row1">{SITE_URL}</td>
     10      <td style="width:50%;"><strong>{L_REMOTE_SITE}</strong></td>
     11      <td class="row1">{server.SITE_URL}</td>
    1212    </tr>
    1313    <!-- END server -->
     
    3333      <td><strong>{L_EDIT_STATUS}&nbsp;:</strong><br /><span class="small">{L_EDIT_STATUS_INFO}</span></td>
    3434      <td class="row1">
    35           <input type="radio" class="radio" name="status" value="public" {ACCESS_FREE} />{L_ACCESS_FREE}&nbsp;&nbsp;
    36           <input type="radio" class="radio" name="status" value="private" {ACCESS_RESTRICTED} />{L_ACCESS_RESTRICTED}
     35          <input type="radio" class="radio" name="status" value="public" {STATUS_PUBLIC} />{L_STATUS_PUBLIC}&nbsp;&nbsp;
     36          <input type="radio" class="radio" name="status" value="private" {STATUS_PRIVATE} />{L_STATUS_PRIVATE}
    3737      </td>
    3838    </tr>
    39         <tr>
     39    <tr>
    4040      <td><strong>{L_EDIT_LOCK}&nbsp;:</strong><br /><span class="small">{L_EDIT_LOCK_INFO}</span></td>
    4141      <td class="row1">
     
    4444      </td>
    4545    </tr>
     46    <tr>
     47      <td><strong>{L_EDIT_COMMENTABLE}&nbsp;:</strong><br /><span class="small">{L_EDIT_COMMENTABLE_INFO}</span></td>
     48      <td class="row1">
     49          <input type="radio" class="radio" name="commentable" value="false" {COMMENTABLE_TRUE} />{L_YES}&nbsp;&nbsp;
     50          <input type="radio" class="radio" name="commentable" value="true" {COMMENTABLE_FALSE} />{L_NO}
     51      </td>
     52    </tr>
     53    <!-- BEGIN upload -->
     54    <tr>
     55      <td><strong>{L_EDIT_UPLOADABLE}&nbsp;:</strong><br /><span class="small">{L_EDIT_UPLOADABLE_INFO}</span></td>
     56      <td class="row1">
     57          <input type="radio" class="radio" name="uploadable" value="true" {UPLOADABLE_TRUE} />{L_YES}&nbsp;&nbsp;
     58          <input type="radio" class="radio" name="uploadable" value="false" {UPLOADABLE_FALSE} />{L_NO}
     59      </td>
     60    </tr>
     61    <!-- END upload -->
    4662    <!-- BEGIN parent -->
    4763    <tr>
Note: See TracChangeset for help on using the changeset viewer.