aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorgweltas <gweltas@piwigo.org>2004-03-31 17:26:31 +0000
committergweltas <gweltas@piwigo.org>2004-03-31 17:26:31 +0000
commitb531871f125265596ee9a7c550fdd3f4bfd0d19e (patch)
tree08150726aff1c31a32b5bb92f8a4d0df15c14a56 /admin
parentd90e90dd4a98c8bb70c83e5d0a351b27c0e2283b (diff)
- Category upload admin control panel
git-svn-id: http://piwigo.org/svn/trunk@403 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin.php3
-rw-r--r--admin/admin_phpinfo.php2
-rw-r--r--admin/admin_upload.php93
-rw-r--r--admin/cat_list.php10
-rw-r--r--admin/cat_modify.php201
5 files changed, 178 insertions, 131 deletions
diff --git a/admin.php b/admin.php
index 0076d1fb3..83714c0d6 100644
--- a/admin.php
+++ b/admin.php
@@ -111,6 +111,8 @@ switch ( $_GET['page'] )
$title = $lang['title_categories']; $page_valide = true; break;
case 'cat_modify':
$title = $lang['title_edit_cat']; $page_valide = true; break;
+ case 'admin_upload':
+ $title = $lang['upload']; $page_valide = true; break;
case 'infos_images':
$title = $lang['title_info_images']; $page_valide = true; break;
case 'waiting':
@@ -202,6 +204,7 @@ $template->assign_vars(array(
'U_USERS'=>add_session_id($link_start.'user_search' ),
'U_GROUPS'=>add_session_id($link_start.'group_list' ),
'U_CATEGORIES'=>add_session_id($link_start.'cat_list' ),
+ 'U_UPLOAD'=>add_session_id($link_start.'admin_upload' ),
'U_WAITING'=>add_session_id($link_start.'waiting' ),
'U_COMMENTS'=>add_session_id($link_start.'comments' ),
'U_CAT_UPDATE'=>add_session_id($link_start.'update&amp;update=cats' ),
diff --git a/admin/admin_phpinfo.php b/admin/admin_phpinfo.php
index db0b52bb6..ebae7ab52 100644
--- a/admin/admin_phpinfo.php
+++ b/admin/admin_phpinfo.php
@@ -67,7 +67,7 @@ switch ($layout)
$output = preg_replace('#(\w),(\w)#', '\1, \2', $output);
$output = preg_replace('#border="0" cellpadding="3" width="600"#', 'border="0" cellspacing="1" cellpadding="4" width="95%"', $output);
$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);
- $output = preg_replace('#<td>#', '<td style="{background-color: #9999cc;}">', $output);
+ $output = preg_replace('#<td>#', '<td style="background-color: #444444;text-align:center;">', $output);
$output = preg_replace('#<th>#', '<th class="throw">', $output);
$output = preg_replace('#class="e"#', 'class="row1" nowrap="nowrap"', $output);
$output = preg_replace('#class="v"#', 'class="row2"', $output);
diff --git a/admin/admin_upload.php b/admin/admin_upload.php
new file mode 100644
index 000000000..28f210989
--- /dev/null
+++ b/admin/admin_upload.php
@@ -0,0 +1,93 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | admin_upload.php |
+// +-----------------------------------------------------------------------+
+// | application : PhpWebGallery <http://phpwebgallery.net> |
+// | branch : BSF (Best So Far) |
+// +-----------------------------------------------------------------------+
+// | file : $RCSfile$
+// | last update : $Date$
+// | last modifier : $Author$
+// | revision : $Revision$
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify |
+// | it under the terms of the GNU General Public License as published by |
+// | the Free Software Foundation |
+// | |
+// | This program is distributed in the hope that it will be useful, but |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+// | General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
+
+if( !defined("PHPWG_ROOT_PATH") )
+{
+ die ("Hacking attempt!");
+}
+
+include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
+$uploadable = '';
+$categories = '';
+
+if (isset($_POST['submit']) || isset($_POST['delete']))
+{
+ $query = 'UPDATE '.CATEGORIES_TABLE;
+ $query.= ' SET uploadable = ';
+ if (isset($_POST['submit']))
+ $query.="'true'";
+ else
+ $query.="'false'";
+ $query.= ' WHERE id IN (';
+ $nb=count($cat_data);
+ foreach($cat_data as $i=>$id)
+ {
+ $query.= $id;
+ if ($i+1<$nb) $query.=',';
+ }
+ $query.=');';
+ mysql_query ($query);
+}
+
+// Cache management
+$query = 'SELECT id, name, uploadable FROM '.CATEGORIES_TABLE;
+$query.= ' WHERE dir IS NOT NULL';
+$query.= ' ORDER BY name ASC';
+$query.= ';';
+$result = mysql_query( $query );
+while ( $row = mysql_fetch_assoc( $result ) )
+{
+ if ($row['uploadable'] == 'false')
+ {
+ $categories.='<option value="'.$row['id'].'">'.$row['name'].'</option>';
+ }
+ else
+ {
+ $uploadable.='<option value="'.$row['id'].'">'.$row['name'].'</option>';
+ }
+}
+
+//----------------------------------------------------- template initialization
+$template->set_filenames( array('upload'=>'admin/admin_upload.tpl') );
+
+$template->assign_vars(array(
+ 'PRIVATE_CATEGORIES'=>$categories,
+ 'UPLOADABLE_CATEGORIES'=>$uploadable,
+
+ 'L_UPLOAD_TITLE'=>$lang['cat_upload'],
+ 'L_SUBMIT'=>$lang['submit'],
+ 'L_DELETE'=>$lang['delete'],
+ 'L_RESET'=>$lang['reset'],
+ 'L_UPLOAD_INFO'=>$lang['cat_upload_info'],
+ 'L_AUTHORIZED'=>$lang['authorized'],
+ 'L_FORBIDDEN'=>$lang['forbidden']
+ ));
+
+//----------------------------------------------------------- sending html code
+$template->assign_var_from_handle('ADMIN_CONTENT', 'upload');
+
+?> \ No newline at end of file
diff --git a/admin/cat_list.php b/admin/cat_list.php
index 1f021bf0c..08446cf74 100644
--- a/admin/cat_list.php
+++ b/admin/cat_list.php
@@ -220,7 +220,7 @@ if ( sizeof( $errors ) != 0 )
while (list ($id,$category) = each($categories))
{
- if ($category['status'] == 'private')
+ if ($category['visible'] == 'false')
{
$category_image = '<img src="'.PHPWG_ROOT_PATH.'template/'.$user['template'].'/admin/images/icon_folder_lock.gif"
width="46" height="25" alt="'.$lang['cat_private'].'" title="'.$lang['cat_private'].'"/>';
@@ -255,10 +255,10 @@ while (list ($id,$category) = each($categories))
'U_CATEGORY'=>add_session_id( $simple_url.'parent_id='.$category['id']),
'U_MOVE_UP'=>add_session_id( $url.'up='.$category['id'] ),
'U_MOVE_DOWN'=>add_session_id( $url.'down='.$category['id'] ),
- 'U_CAT_EDIT'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id='.$row['id'] ),
+ 'U_CAT_EDIT'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id='.$category['id'] ),
'U_CAT_DELETE'=>add_session_id( $url.'delete='.$category['id'] ),
- 'U_INFO_IMG'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=infos_images&amp;cat_id='.$row['id'] ),
- 'U_CAT_UPDATE'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=update&amp;update='.$row['id'] )
+ 'U_INFO_IMG'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=infos_images&amp;cat_id='.$category['id'] ),
+ 'U_CAT_UPDATE'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=update&amp;update='.$category['id'] )
));
if ( !empty($category['dir']))
@@ -269,7 +269,7 @@ while (list ($id,$category) = each($categories))
{
$template->assign_block_vars('category.virtual' ,array());
}
- $url = add_session_id( './admin.php?page=cat_modify&amp;cat='.$row['id'] );
+ $url = add_session_id( PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat='.$row['id'] );
if ( $category['nb_images'] > 0 )
{
$template->assign_block_vars('category.image_info' ,array());
diff --git a/admin/cat_modify.php b/admin/cat_modify.php
index ba1cd7d9d..ea33f20f4 100644
--- a/admin/cat_modify.php
+++ b/admin/cat_modify.php
@@ -25,47 +25,46 @@
// | USA. |
// +-----------------------------------------------------------------------+
-include_once( './admin/include/isadmin.inc.php' );
-//----------------------------------------------------- template initialization
-$sub = $vtp->Open( './template/'.$user['template'].'/admin/cat_modify.vtp' );
-$tpl = array( 'remote_site','editcat_confirm','editcat_back','editcat_title1',
- 'editcat_name','editcat_comment','editcat_status',
- 'editcat_visible','editcat_visible_info', 'submit',
- 'editcat_uploadable','cat_virtual','cat_parent' );
-templatize_array( $tpl, 'lang', $sub );
+if( !defined("PHPWG_ROOT_PATH") )
+{
+ die ("Hacking attempt!");
+}
+include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
+
//---------------------------------------------------------------- verification
-if ( !is_numeric( $_GET['cat'] ) )
+if ( !isset( $_GET['cat_id'] ) || !is_numeric( $_GET['cat_id'] ) )
{
- $_GET['cat'] = '-1';
+ $_GET['cat_id'] = '-1';
}
+
+$template->set_filenames( array('categories'=>'admin/cat_modify.tpl') );
+
//--------------------------------------------------------- form criteria check
if ( isset( $_POST['submit'] ) )
{
// if new status is different from previous one, deletion of all related
// links for access rights
$query = 'SELECT status';
- $query.= ' FROM '.PREFIX_TABLE.'categories';
- $query.= ' WHERE id = '.$_GET['cat'];
+ $query.= ' FROM '.CATEGORIES_TABLE;
+ $query.= ' WHERE id = '.$_GET['cat_id'];
$query.= ';';
$row = mysql_fetch_array( mysql_query( $query ) );
- $query = 'UPDATE '.PREFIX_TABLE.'categories';
-
+ $query = 'UPDATE '.CATEGORIES_TABLE;
$query.= ' SET name = ';
- if ( $_POST['name'] == '' )
+ if ( empty($_POST['name']))
$query.= 'NULL';
else
$query.= "'".htmlentities( $_POST['name'], ENT_QUOTES)."'";
$query.= ', comment = ';
- if ( $_POST['comment'] == '' )
+ if ( empty($_POST['comment']))
$query.= 'NULL';
else
$query.= "'".htmlentities( $_POST['comment'], ENT_QUOTES )."'";
$query.= ", status = '".$_POST['status']."'";
$query.= ", visible = '".$_POST['visible']."'";
-
if ( isset( $_POST['uploadable'] ) )
$query.= ", uploadable = '".$_POST['uploadable']."'";
@@ -77,7 +76,7 @@ if ( isset( $_POST['submit'] ) )
else
$query.= $_POST['associate'];
}
- $query.= ' WHERE id = '.$_GET['cat'];
+ $query.= ' WHERE id = '.$_GET['cat_id'];
$query.= ';';
mysql_query( $query );
@@ -85,13 +84,13 @@ if ( isset( $_POST['submit'] ) )
{
// deletion of all access for groups concerning this category
$query = 'DELETE';
- $query.= ' FROM '.PREFIX_TABLE.'group_access';
- $query.= ' WHERE cat_id = '.$_GET['cat'];
+ $query.= ' FROM '.GROUP_ACCESS_TABLE;
+ $query.= ' WHERE cat_id = '.$_GET['cat_id'];
mysql_query( $query );
// deletion of all access for users concerning this category
$query = 'DELETE';
- $query.= ' FROM '.PREFIX_TABLE.'user_access';
- $query.= ' WHERE cat_id = '.$_GET['cat'];
+ $query.= ' FROM '.USER_ACCESS_TABLE;
+ $query.= ' WHERE cat_id = '.$_GET['cat_id'];
mysql_query( $query );
// resynchronize all users
synchronize_all_users();
@@ -106,116 +105,67 @@ if ( isset( $_POST['submit'] ) )
{
check_favorites( $row['id'] );
}
-
- $vtp->addSession( $sub, 'confirmation' );
- $url = add_session_id( './admin.php?page=cat_list' );
- $vtp->setVar( $sub, 'confirmation.back_url', $url );
- $vtp->closeSession( $sub, 'confirmation' );
+ $template->assign_block_vars('confirmation' ,array());
}
-//------------------------------------------------------------------------ form
-$form_action = './admin.php?page=cat_modify&amp;cat='.$_GET['cat'];
-$vtp->setVar( $sub, 'form_action', add_session_id( $form_action ) );
-
-$query = 'SELECT a.id,name,dir,status,comment,uploadable';
-$query.= ',id_uppercat,site_id,galleries_url,visible';
-$query.= ' FROM '.PREFIX_TABLE.'categories as a, '.PREFIX_TABLE.'sites as b';
-$query.= ' WHERE a.id = '.$_GET['cat'];
+
+$query = 'SELECT a.*, b.*';
+$query.= ' FROM '.CATEGORIES_TABLE.' as a, '.SITES_TABLE.' as b';
+$query.= ' WHERE a.id = '.$_GET['cat_id'];
$query.= ' AND a.site_id = b.id';
$query.= ';';
-$row = mysql_fetch_array( mysql_query( $query ) );
+$category = mysql_fetch_array( mysql_query( $query ) );
-if ( !isset( $row['dir'] ) ) $row['dir'] = '';
-if ( !isset( $row['id_uppercat'] ) ) $row['id_uppercat'] = '';
+// Navigation path
+$current_category = get_cat_info($_GET['cat_id']);
+$url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&amp;parent_id=';
+$navigation = '<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.'admin.php?page=cat_list').'">';
+$navigation.= $lang['gallery_index'].'</a>-&gt;';
+$navigation.= get_cat_display_name($current_category['name'], '-&gt;', $url);
-$result = get_cat_info( $row['id'] );
-// cat name
-$cat_name = get_cat_display_name( $result['name'], ' - ' );
-$vtp->setVar( $sub, 'cat:name', $cat_name );
-// cat dir
-if ( $row['dir'] != '' )
-{
- $vtp->addSession( $sub, 'storage' );
- $vtp->setVar( $sub, 'storage.dir', $row['dir'] );
- $vtp->closeSession( $sub, 'storage' );
-}
-else
-{
- $vtp->addSession( $sub, 'virtual' );
- $vtp->closeSession( $sub, 'virtual' );
-}
-// remote site ?
-if ( $row['site_id'] != 1 )
-{
- $vtp->addSession( $sub, 'server' );
- $vtp->setVar( $sub, 'server.url', $row['galleries_url'] );
- $vtp->closeSession( $sub, 'server' );
-}
-$vtp->setVar( $sub, 'name', $row['name'] );
-if ( !isset( $row['comment'] ) ) $row['comment'] = '';
-$vtp->setVar( $sub, 'comment', $row['comment'] );
-// status : public, private...
-$options = get_enums( PREFIX_TABLE.'categories', 'status' );
-foreach ( $options as $option ) {
- $vtp->addSession( $sub, 'status_option' );
- $vtp->setVar( $sub, 'status_option.option', $lang[$option] );
- $vtp->setVar( $sub, 'status_option.value', $option );
- if ( $option == $row['status'] )
- {
- $vtp->setVar( $sub, 'status_option.checked', ' checked="checked"' );
- }
- $vtp->closeSession( $sub, 'status_option' );
-}
-// visible : true or false
-$vtp->addSession( $sub, 'visible_option' );
-$vtp->setVar( $sub, 'visible_option.value', 'true' );
-$vtp->setVar( $sub, 'visible_option.option', $lang['yes'] );
-$checked = '';
-if ( $row['visible'] == 'true' )
-{
- $checked = ' checked="checked"';
-}
-$vtp->setVar( $sub, 'visible_option.checked', $checked );
-$vtp->closeSession( $sub, 'visible_option' );
-$vtp->addSession( $sub, 'visible_option' );
-$vtp->setVar( $sub, 'visible_option.value', 'false' );
-$vtp->setVar( $sub, 'visible_option.option', $lang['no'] );
-$checked = '';
-if ( $row['visible'] == 'false' )
+$form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id='.$_GET['cat_id'];
+$access = ($category['status']=='public')?'ACCESS_FREE':'ACCESS_RESTRICTED';
+$lock = ($category['visible']=='true')?'UNLOCKED':'LOCKED';
+
+//----------------------------------------------------- template initialization
+
+$template->assign_vars(array(
+ 'CATEGORIES_NAV'=>$navigation,
+ 'CAT_NAME'=>$category['name'],
+ 'CAT_COMMENT'=>$category['comment'],
+ 'CATEGORY_DIR'=>$category['dir'],
+ 'SITE_URL'=>$category['galleries_url'],
+
+ $access=>'checked="checked"',
+ $lock=>'checked="checked"',
+
+ 'L_EDIT_CONFIRM'=>$lang['editcat_confirm'],
+ 'L_EDIT_NAME'=>$lang['description'],
+ 'L_STORAGE'=>$lang['storage'],
+ 'L_EDIT_COMMENT'=>$lang['comment'],
+ 'L_EDIT_STATUS'=>$lang['conf_general_access'],
+ 'L_EDIT_STATUS_INFO'=>$lang['cat_access_info'],
+ 'L_ACCESS_FREE'=>$lang['conf_general_access_1'],
+ 'L_ACCESS_RESTRICTED'=>$lang['conf_general_access_2'],
+ 'L_EDIT_LOCK'=>$lang['cat_lock'],
+ 'L_EDIT_LOCK_INFO'=>$lang['cat_lock_info'],
+ 'L_YES'=>$lang['yes'],
+ 'L_NO'=>$lang['no'],
+ 'L_SUBMIT'=>$lang['submit'],
+
+ 'F_ACTION'=>add_session_id($form_action)
+ ));
+
+if ( !empty($category['dir']))
{
- $checked = ' checked="checked"';
+ $template->assign_block_vars('storage' ,array());
}
-$vtp->setVar( $sub, 'visible_option.checked', $checked );
-$vtp->closeSession( $sub, 'visible_option' );
-// uploadable : true or false
-// a category can be uploadable if :
-// 1. upload is authorized
-// 2. category is not virtual
-// 3. category is on the main site
-if ( $conf['upload_available'] and $row['dir'] != '' and $row['site_id'] == 1 )
+
+if ( $category['site_id'] != 1 )
{
- $vtp->addSession( $sub, 'uploadable' );
- $vtp->addSession( $sub, 'uploadable_option' );
- $vtp->setVar( $sub, 'uploadable_option.value', 'true' );
- $vtp->setVar( $sub, 'uploadable_option.option', $lang['yes'] );
- $checked = '';
- if ( $row['uploadable'] == 'true' )
- {
- $checked = ' checked="checked"';
- }
- $vtp->setVar( $sub, 'uploadable_option.checked', $checked );
- $vtp->closeSession( $sub, 'uploadable_option' );
- $vtp->addSession( $sub, 'uploadable_option' );
- $vtp->setVar( $sub, 'uploadable_option.value', 'false' );
- $vtp->setVar( $sub, 'uploadable_option.option', $lang['no'] );
- $checked = '';
- if ( $row['uploadable'] == 'false' )
- {
- $checked = ' checked="checked"';
- }
- $vtp->setVar( $sub, 'uploadable_option.checked', $checked );
- $vtp->closeSession( $sub, 'uploadable_option' );
- $vtp->closeSession( $sub, 'uploadable' );
+ $template->assign_block_vars('storage' ,array());
}
+
+/*
// can the parent category be changed ? (is the category virtual ?)
if ( $row['dir'] == '' )
{
@@ -223,7 +173,7 @@ if ( $row['dir'] == '' )
// We only show a List Of Values if the number of categories is less than
// $conf['max_LOV_categories']
$query = 'SELECT COUNT(id) AS nb_total_categories';
- $query.= ' FROM '.PREFIX_TABLE.'categories';
+ $query.= ' FROM '.CATEGORIES_TABLE;
$query.= ';';
$countrow = mysql_fetch_array( mysql_query( $query ) );
if ( $countrow['nb_total_categories'] < $conf['max_LOV_categories'] )
@@ -248,6 +198,7 @@ if ( $row['dir'] == '' )
}
$vtp->closeSession( $sub, 'parent' );
}
+*/
//----------------------------------------------------------- sending html code
-$vtp->Parse( $handle , 'sub', $sub );
+$template->assign_var_from_handle('ADMIN_CONTENT', 'categories');
?>