Changeset 403 for trunk/admin


Ignore:
Timestamp:
Mar 31, 2004, 7:26:31 PM (20 years ago)
Author:
gweltas
Message:
  • Category upload admin control panel
Location:
trunk/admin
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/admin_phpinfo.php

    r394 r403  
    6868    $output = preg_replace('#border="0" cellpadding="3" width="600"#', 'border="0" cellspacing="1" cellpadding="4" width="95%"', $output);
    6969    $output = preg_replace('#<tr class="v"><td>(.*?<a .*?</a>)(.*?)</td></tr>#s', '<tr class="throw"><td><table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td>\2</td><td>\1</td></tr></table></td></tr>', $output);
    70     $output = preg_replace('#<td>#', '<td style="{background-color: #9999cc;}">', $output);
     70    $output = preg_replace('#<td>#', '<td style="background-color: #444444;text-align:center;">', $output);
    7171        $output = preg_replace('#<th>#', '<th class="throw">', $output);
    7272    $output = preg_replace('#class="e"#', 'class="row1" nowrap="nowrap"', $output);
  • trunk/admin/cat_list.php

    r394 r403  
    221221{
    222222
    223   if ($category['status'] == 'private')
     223  if ($category['visible'] == 'false')
    224224  {
    225225    $category_image = '<img src="'.PHPWG_ROOT_PATH.'template/'.$user['template'].'/admin/images/icon_folder_lock.gif"
     
    256256        'U_MOVE_UP'=>add_session_id( $url.'up='.$category['id'] ),
    257257        'U_MOVE_DOWN'=>add_session_id( $url.'down='.$category['id'] ),
    258         'U_CAT_EDIT'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id='.$row['id'] ),
     258        'U_CAT_EDIT'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id='.$category['id'] ),
    259259        'U_CAT_DELETE'=>add_session_id( $url.'delete='.$category['id'] ),
    260         'U_INFO_IMG'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=infos_images&amp;cat_id='.$row['id'] ),
    261         'U_CAT_UPDATE'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=update&amp;update='.$row['id'] )
     260        'U_INFO_IMG'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=infos_images&amp;cat_id='.$category['id'] ),
     261        'U_CAT_UPDATE'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=update&amp;update='.$category['id'] )
    262262        ));
    263263       
     
    270270        $template->assign_block_vars('category.virtual' ,array());
    271271  }
    272   $url = add_session_id( './admin.php?page=cat_modify&amp;cat='.$row['id'] );
     272  $url = add_session_id( PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat='.$row['id'] );
    273273  if ( $category['nb_images'] > 0 )
    274274  {
  • trunk/admin/cat_modify.php

    r394 r403  
    2626// +-----------------------------------------------------------------------+
    2727
    28 include_once( './admin/include/isadmin.inc.php' );
    29 //----------------------------------------------------- template initialization
    30 $sub = $vtp->Open( './template/'.$user['template'].'/admin/cat_modify.vtp' );
    31 $tpl = array( 'remote_site','editcat_confirm','editcat_back','editcat_title1',
    32               'editcat_name','editcat_comment','editcat_status',
    33               'editcat_visible','editcat_visible_info', 'submit',
    34               'editcat_uploadable','cat_virtual','cat_parent' );
    35 templatize_array( $tpl, 'lang', $sub );
     28if( !defined("PHPWG_ROOT_PATH") )
     29{
     30        die ("Hacking attempt!");
     31}
     32include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
     33
    3634//---------------------------------------------------------------- verification
    37 if ( !is_numeric( $_GET['cat'] ) )
    38 {
    39   $_GET['cat'] = '-1';
    40 }
     35if ( !isset( $_GET['cat_id'] ) || !is_numeric( $_GET['cat_id'] ) )
     36{
     37  $_GET['cat_id'] = '-1';
     38}
     39
     40$template->set_filenames( array('categories'=>'admin/cat_modify.tpl') );
     41
    4142//--------------------------------------------------------- form criteria check
    4243if ( isset( $_POST['submit'] ) )
     
    4546  // links for access rights
    4647  $query = 'SELECT status';
    47   $query.= ' FROM '.PREFIX_TABLE.'categories';
    48   $query.= ' WHERE id = '.$_GET['cat'];
     48  $query.= ' FROM '.CATEGORIES_TABLE;
     49  $query.= ' WHERE id = '.$_GET['cat_id'];
    4950  $query.= ';';
    5051  $row = mysql_fetch_array( mysql_query( $query ) );
    5152 
    52   $query = 'UPDATE '.PREFIX_TABLE.'categories';
    53 
     53  $query = 'UPDATE '.CATEGORIES_TABLE;
    5454  $query.= ' SET name = ';
    55   if ( $_POST['name'] == '' )
     55  if ( empty($_POST['name']))
    5656    $query.= 'NULL';
    5757  else
     
    5959
    6060  $query.= ', comment = ';
    61   if ( $_POST['comment'] == '' )
     61  if ( empty($_POST['comment']))
    6262    $query.= 'NULL';
    6363  else
     
    6666  $query.= ", status = '".$_POST['status']."'";
    6767  $query.= ", visible = '".$_POST['visible']."'";
    68 
    6968  if ( isset( $_POST['uploadable'] ) )
    7069    $query.= ", uploadable = '".$_POST['uploadable']."'";
     
    7877      $query.= $_POST['associate'];
    7978  }
    80   $query.= ' WHERE id = '.$_GET['cat'];
     79  $query.= ' WHERE id = '.$_GET['cat_id'];
    8180  $query.= ';';
    8281  mysql_query( $query );
     
    8685    // deletion of all access for groups concerning this category
    8786    $query = 'DELETE';
    88     $query.= ' FROM '.PREFIX_TABLE.'group_access';
    89     $query.= ' WHERE cat_id = '.$_GET['cat'];
     87    $query.= ' FROM '.GROUP_ACCESS_TABLE;
     88    $query.= ' WHERE cat_id = '.$_GET['cat_id'];
    9089    mysql_query( $query );
    9190    // deletion of all access for users concerning this category
    9291    $query = 'DELETE';
    93     $query.= ' FROM '.PREFIX_TABLE.'user_access';
    94     $query.= ' WHERE cat_id = '.$_GET['cat'];
     92    $query.= ' FROM '.USER_ACCESS_TABLE;
     93    $query.= ' WHERE cat_id = '.$_GET['cat_id'];
    9594    mysql_query( $query );
    9695    // resynchronize all users
     
    107106    check_favorites( $row['id'] );
    108107  }
    109 
    110   $vtp->addSession( $sub, 'confirmation' );
    111   $url = add_session_id( './admin.php?page=cat_list' );
    112   $vtp->setVar( $sub, 'confirmation.back_url', $url );
    113   $vtp->closeSession( $sub, 'confirmation' );
    114 }
    115 //------------------------------------------------------------------------ form
    116 $form_action = './admin.php?page=cat_modify&amp;cat='.$_GET['cat'];
    117 $vtp->setVar( $sub, 'form_action', add_session_id( $form_action ) );
    118 
    119 $query = 'SELECT a.id,name,dir,status,comment,uploadable';
    120 $query.= ',id_uppercat,site_id,galleries_url,visible';
    121 $query.= ' FROM '.PREFIX_TABLE.'categories as a, '.PREFIX_TABLE.'sites as b';
    122 $query.= ' WHERE a.id = '.$_GET['cat'];
     108  $template->assign_block_vars('confirmation' ,array());
     109}
     110
     111$query = 'SELECT a.*, b.*';
     112$query.= ' FROM '.CATEGORIES_TABLE.' as a, '.SITES_TABLE.' as b';
     113$query.= ' WHERE a.id = '.$_GET['cat_id'];
    123114$query.= ' AND a.site_id = b.id';
    124115$query.= ';';
    125 $row = mysql_fetch_array( mysql_query( $query ) );
    126 
    127 if ( !isset( $row['dir'] ) ) $row['dir'] = '';
    128 if ( !isset( $row['id_uppercat'] ) ) $row['id_uppercat'] = '';
    129 
    130 $result = get_cat_info( $row['id'] );
    131 // cat name
    132 $cat_name = get_cat_display_name( $result['name'], ' - ' );
    133 $vtp->setVar( $sub, 'cat:name', $cat_name );
    134 // cat dir
    135 if ( $row['dir'] != '' )
    136 {
    137   $vtp->addSession( $sub, 'storage' );
    138   $vtp->setVar( $sub, 'storage.dir', $row['dir'] );
    139   $vtp->closeSession( $sub, 'storage' );
    140 }
    141 else
    142 {
    143   $vtp->addSession( $sub, 'virtual' );
    144   $vtp->closeSession( $sub, 'virtual' );
    145 }
    146 // remote site ?
    147 if ( $row['site_id'] != 1 )
    148 {
    149   $vtp->addSession( $sub, 'server' );
    150   $vtp->setVar( $sub, 'server.url', $row['galleries_url'] );
    151   $vtp->closeSession( $sub, 'server' );
    152 }
    153 $vtp->setVar( $sub, 'name',    $row['name'] );
    154 if ( !isset( $row['comment'] ) ) $row['comment'] = '';
    155 $vtp->setVar( $sub, 'comment', $row['comment'] );
    156 // status : public, private...
    157 $options = get_enums( PREFIX_TABLE.'categories', 'status' );
    158 foreach ( $options as $option  ) {
    159   $vtp->addSession( $sub, 'status_option' );
    160   $vtp->setVar( $sub, 'status_option.option', $lang[$option] );
    161   $vtp->setVar( $sub, 'status_option.value', $option );
    162   if ( $option == $row['status'] )
    163   {
    164     $vtp->setVar( $sub, 'status_option.checked', ' checked="checked"' ); 
    165   }
    166   $vtp->closeSession( $sub, 'status_option' );
    167 }
    168 // visible : true or false
    169 $vtp->addSession( $sub, 'visible_option' );
    170 $vtp->setVar( $sub, 'visible_option.value', 'true' );
    171 $vtp->setVar( $sub, 'visible_option.option', $lang['yes'] );
    172 $checked = '';
    173 if ( $row['visible'] == 'true' )
    174 {
    175   $checked = ' checked="checked"';
    176 }
    177 $vtp->setVar( $sub, 'visible_option.checked', $checked );
    178 $vtp->closeSession( $sub, 'visible_option' );
    179 $vtp->addSession( $sub, 'visible_option' );
    180 $vtp->setVar( $sub, 'visible_option.value', 'false' );
    181 $vtp->setVar( $sub, 'visible_option.option', $lang['no'] );
    182 $checked = '';
    183 if ( $row['visible'] == 'false' )
    184 {
    185   $checked = ' checked="checked"';
    186 }
    187 $vtp->setVar( $sub, 'visible_option.checked', $checked );
    188 $vtp->closeSession( $sub, 'visible_option' );
    189 // uploadable : true or false
    190 // a category can be uploadable if :
    191 //  1. upload is authorized
    192 //  2. category is not virtual
    193 //  3. category is on the main site
    194 if ( $conf['upload_available'] and $row['dir'] != '' and $row['site_id'] == 1 )
    195 {
    196   $vtp->addSession( $sub, 'uploadable' );
    197   $vtp->addSession( $sub, 'uploadable_option' );
    198   $vtp->setVar( $sub, 'uploadable_option.value', 'true' );
    199   $vtp->setVar( $sub, 'uploadable_option.option', $lang['yes'] );
    200   $checked = '';
    201   if ( $row['uploadable'] == 'true' )
    202   {
    203     $checked = ' checked="checked"';
    204   }
    205   $vtp->setVar( $sub, 'uploadable_option.checked', $checked );
    206   $vtp->closeSession( $sub, 'uploadable_option' );
    207   $vtp->addSession( $sub, 'uploadable_option' );
    208   $vtp->setVar( $sub, 'uploadable_option.value', 'false' );
    209   $vtp->setVar( $sub, 'uploadable_option.option', $lang['no'] );
    210   $checked = '';
    211   if ( $row['uploadable'] == 'false' )
    212   {
    213     $checked = ' checked="checked"';
    214   }
    215   $vtp->setVar( $sub, 'uploadable_option.checked', $checked );
    216   $vtp->closeSession( $sub, 'uploadable_option' );
    217   $vtp->closeSession( $sub, 'uploadable' );
    218 }
     116$category = mysql_fetch_array( mysql_query( $query ) );
     117
     118// Navigation path
     119$current_category = get_cat_info($_GET['cat_id']);
     120$url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&amp;parent_id=';
     121$navigation = '<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.'admin.php?page=cat_list').'">';
     122$navigation.= $lang['gallery_index'].'</a>-&gt;';
     123$navigation.= get_cat_display_name($current_category['name'], '-&gt;', $url);
     124
     125$form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id='.$_GET['cat_id'];
     126$access = ($category['status']=='public')?'ACCESS_FREE':'ACCESS_RESTRICTED';
     127$lock = ($category['visible']=='true')?'UNLOCKED':'LOCKED';
     128
     129//----------------------------------------------------- template initialization
     130
     131$template->assign_vars(array(
     132  'CATEGORIES_NAV'=>$navigation,
     133  'CAT_NAME'=>$category['name'],
     134  'CAT_COMMENT'=>$category['comment'],
     135  'CATEGORY_DIR'=>$category['dir'],
     136  'SITE_URL'=>$category['galleries_url'],
     137 
     138  $access=>'checked="checked"',
     139  $lock=>'checked="checked"',
     140 
     141  'L_EDIT_CONFIRM'=>$lang['editcat_confirm'],
     142  'L_EDIT_NAME'=>$lang['description'],
     143  'L_STORAGE'=>$lang['storage'],
     144  'L_EDIT_COMMENT'=>$lang['comment'],
     145  'L_EDIT_STATUS'=>$lang['conf_general_access'],
     146  'L_EDIT_STATUS_INFO'=>$lang['cat_access_info'],
     147  'L_ACCESS_FREE'=>$lang['conf_general_access_1'],
     148  'L_ACCESS_RESTRICTED'=>$lang['conf_general_access_2'],
     149  'L_EDIT_LOCK'=>$lang['cat_lock'],
     150  'L_EDIT_LOCK_INFO'=>$lang['cat_lock_info'],
     151  'L_YES'=>$lang['yes'],
     152  'L_NO'=>$lang['no'],
     153  'L_SUBMIT'=>$lang['submit'],
     154   
     155  'F_ACTION'=>add_session_id($form_action)
     156  ));
     157 
     158if ( !empty($category['dir']))
     159{
     160  $template->assign_block_vars('storage' ,array());
     161}
     162
     163if ( $category['site_id'] != 1 )
     164{
     165  $template->assign_block_vars('storage' ,array());
     166}
     167
     168/*
    219169// can the parent category be changed ? (is the category virtual ?)
    220170if ( $row['dir'] == '' )
     
    224174  // $conf['max_LOV_categories']
    225175  $query = 'SELECT COUNT(id) AS nb_total_categories';
    226   $query.= ' FROM '.PREFIX_TABLE.'categories';
     176  $query.= ' FROM '.CATEGORIES_TABLE;
    227177  $query.= ';';
    228178  $countrow = mysql_fetch_array( mysql_query( $query ) );
     
    249199  $vtp->closeSession( $sub, 'parent' );
    250200}
     201*/
    251202//----------------------------------------------------------- sending html code
    252 $vtp->Parse( $handle , 'sub', $sub );
     203$template->assign_var_from_handle('ADMIN_CONTENT', 'categories');
    253204?>
Note: See TracChangeset for help on using the changeset viewer.