aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--admin/cat_list.php2
-rw-r--r--admin/cat_modify.php104
-rw-r--r--admin/cat_options.php66
-rw-r--r--admin/include/functions.php102
4 files changed, 165 insertions, 109 deletions
diff --git a/admin/cat_list.php b/admin/cat_list.php
index 00bb4a5ac..2914901b5 100644
--- a/admin/cat_list.php
+++ b/admin/cat_list.php
@@ -132,7 +132,7 @@ while ($row = mysql_fetch_assoc($result))
// +-----------------------------------------------------------------------+
if (isset($_GET['parent_id']))
{
- $separator = ' -> ';
+ $separator = ' <span style="font-size:15px">&rarr;</span> ';
$base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_list';
$navigation = '<a class="" href="'.add_session_id($base_url).'">';
diff --git a/admin/cat_modify.php b/admin/cat_modify.php
index 98ea0b287..00f52abd4 100644
--- a/admin/cat_modify.php
+++ b/admin/cat_modify.php
@@ -25,12 +25,11 @@
// | USA. |
// +-----------------------------------------------------------------------+
-if( !defined("PHPWG_ROOT_PATH") )
+if (!defined('PHPWG_ROOT_PATH'))
{
- die ("Hacking attempt!");
+ die('Hacking attempt!');
}
-include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
-
+include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
//---------------------------------------------------------------- verification
if ( !isset( $_GET['cat_id'] ) || !is_numeric( $_GET['cat_id'] ) )
{
@@ -42,8 +41,6 @@ $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 '.CATEGORIES_TABLE;
$query.= ' WHERE id = '.$_GET['cat_id'];
@@ -63,8 +60,6 @@ if ( isset( $_POST['submit'] ) )
else
$query.= "'".htmlentities( $_POST['comment'], ENT_QUOTES )."'";
- $query.= ", status = '".$_POST['status']."'";
- $query.= ", visible = '".$_POST['visible']."'";
if ( isset( $_POST['uploadable'] ) )
$query.= ", uploadable = '".$_POST['uploadable']."'";
@@ -80,40 +75,20 @@ if ( isset( $_POST['submit'] ) )
$query.= ';';
pwg_query( $query );
- if ( $_POST['status'] != $row['status'] )
- {
- // deletion of all access for groups concerning this category
- $query = 'DELETE';
- $query.= ' FROM '.GROUP_ACCESS_TABLE;
- $query.= ' WHERE cat_id = '.$_GET['cat_id'];
- pwg_query( $query );
- // deletion of all access for users concerning this category
- $query = 'DELETE';
- $query.= ' FROM '.USER_ACCESS_TABLE;
- $query.= ' WHERE cat_id = '.$_GET['cat_id'];
- pwg_query( $query );
- }
+ set_cat_visible(array($_GET['cat_id']), $_POST['visible']);
+ set_cat_status(array($_GET['cat_id']), $_POST['status']);
- // checking users favorites
- $query = 'SELECT id';
- $query.= ' FROM '.USERS_TABLE;
- $query.= ';';
- $result = pwg_query( $query );
- while ( $row = mysql_fetch_array( $result ) )
- {
- check_favorites( $row['id'] );
- }
$template->assign_block_vars('confirmation' ,array());
}
-$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.= ';';
+$query = '
+SELECT *
+ FROM '.CATEGORIES_TABLE.'
+ WHERE id = '.$_GET['cat_id'].'
+;';
$category = mysql_fetch_array( pwg_query( $query ) );
// nullable fields
-foreach (array('comment','dir') as $nullable)
+foreach (array('comment','dir','site_id') as $nullable)
{
if (!isset($category[$nullable]))
{
@@ -125,34 +100,60 @@ foreach (array('comment','dir') as $nullable)
$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['home'].'</a>-&gt;';
-$navigation.= get_cat_display_name($current_category['name'], '-&gt;', $url);
+$navigation.= $lang['home'].'</a> <span style="font-size:15px">&rarr;</span>';
+$navigation.= get_cat_display_name(
+ $current_category['name'],
+ ' <span style="font-size:15px">&rarr;</span>',
+ $url);
$form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id='.$_GET['cat_id'];
-$access = ($category['status']=='public')?'ACCESS_FREE':'ACCESS_RESTRICTED';
+$status = ($category['status']=='public')?'STATUS_PUBLIC':'STATUS_PRIVATE';
$lock = ($category['visible']=='true')?'UNLOCKED':'LOCKED';
+if ($category['commentable'] == 'true')
+{
+ $commentable = 'COMMENTABLE_TRUE';
+}
+else
+{
+ $commentable = 'COMMENTABLE_FALSE';
+}
+if ($category['uploadable'] == 'true')
+{
+ $uploadable = 'UPLOADABLE_TRUE';
+}
+else
+{
+ $uploadable = 'UPLOADABLE_FALSE';
+}
+
//----------------------------------------------------- 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'],
+ 'CATEGORY_DIR'=>preg_replace('/\/$/', '', get_complete_dir($category['id'])),
- $access=>'checked="checked"',
+ $status=>'checked="checked"',
$lock=>'checked="checked"',
+ $commentable=>'checked="checked"',
+ $uploadable=>'checked="checked"',
'L_EDIT_CONFIRM'=>$lang['editcat_confirm'],
'L_EDIT_NAME'=>$lang['description'],
'L_STORAGE'=>$lang['storage'],
+ 'L_REMOTE_SITE'=>$lang['remote_site'],
'L_EDIT_COMMENT'=>$lang['comment'],
'L_EDIT_STATUS'=>$lang['conf_access'],
'L_EDIT_STATUS_INFO'=>$lang['cat_access_info'],
- 'L_ACCESS_FREE'=>$lang['free'],
- 'L_ACCESS_RESTRICTED'=>$lang['restricted'],
+ 'L_STATUS_PUBLIC'=>$lang['public'],
+ 'L_STATUS_PRIVATE'=>$lang['private'],
'L_EDIT_LOCK'=>$lang['lock'],
- 'L_EDIT_LOCK_INFO'=>$lang['cat_lock_info'],
+ 'L_EDIT_LOCK_INFO'=>$lang['editcat_visible_info'],
+ 'L_EDIT_UPLOADABLE'=>$lang['editcat_uploadable'],
+ 'L_EDIT_UPLOADABLE_INFO'=>$lang['editcat_uploadable_info'],
+ 'L_EDIT_COMMENTABLE'=>$lang['editcat_commentable'],
+ 'L_EDIT_COMMENTABLE_INFO'=>$lang['editcat_commentable_info'],
'L_YES'=>$lang['yes'],
'L_NO'=>$lang['no'],
'L_SUBMIT'=>$lang['submit'],
@@ -160,14 +161,21 @@ $template->assign_vars(array(
'F_ACTION'=>add_session_id($form_action)
));
-if ( !empty($category['dir']))
+if (!empty($category['dir']))
{
$template->assign_block_vars('storage' ,array());
+ $template->assign_block_vars('upload' ,array());
}
-if ( $category['site_id'] != 1 )
+if (is_numeric($category['site_id']) and $category['site_id'] != 1)
{
- $template->assign_block_vars('storage' ,array());
+ $query = '
+SELECT galleries_url
+ FROM '.SITES_TABLE.'
+ WHERE id = '.$category['site_id'].'
+;';
+ list($galleries_url) = mysql_fetch_array(pwg_query($query));
+ $template->assign_block_vars('server', array('SITE_URL' => $galleries_url));
}
//----------------------------------------------------------- sending html code
diff --git a/admin/cat_options.php b/admin/cat_options.php
index 29e583150..502539d71 100644
--- a/admin/cat_options.php
+++ b/admin/cat_options.php
@@ -64,26 +64,12 @@ UPDATE '.CATEGORIES_TABLE.'
}
case 'visible' :
{
- // locking a category => all its child categories become locked
- $subcats = get_subcat_ids($_POST['cat_true']);
- $query = '
-UPDATE '.CATEGORIES_TABLE.'
- SET visible = \'false\'
- WHERE id IN ('.implode(',', $subcats).')
-;';
- pwg_query($query);
+ set_cat_visible($_POST['cat_true'], 'false');
break;
}
case 'status' :
{
- // make a category private => all its child categories become private
- $subcats = get_subcat_ids($_POST['cat_true']);
- $query = '
-UPDATE '.CATEGORIES_TABLE.'
- SET status = \'private\'
- WHERE id IN ('.implode(',', $subcats).')
-;';
- pwg_query($query);
+ set_cat_status($_POST['cat_true'], 'private');
break;
}
}
@@ -116,52 +102,12 @@ UPDATE '.CATEGORIES_TABLE.'
}
case 'visible' :
{
- // unlocking a category => all its parent categories become unlocked
- $uppercats = array();
- $query = '
-SELECT uppercats
- FROM '.CATEGORIES_TABLE.'
- WHERE id IN ('.implode(',', $_POST['cat_false']).')
-;';
- $result = pwg_query($query);
- while ($row = mysql_fetch_array($result))
- {
- $uppercats = array_merge($uppercats,
- explode(',', $row['uppercats']));
- }
- $uppercats = array_unique($uppercats);
-
- $query = '
-UPDATE '.CATEGORIES_TABLE.'
- SET visible = \'true\'
- WHERE id IN ('.implode(',', $uppercats).')
-;';
- pwg_query($query);
+ set_cat_visible($_POST['cat_false'], 'true');
break;
}
case 'status' :
{
- // make public a category => all its parent categories become public
- $uppercats = array();
- $query = '
-SELECT uppercats
- FROM '.CATEGORIES_TABLE.'
- WHERE id IN ('.implode(',', $_POST['cat_false']).')
-;';
- $result = pwg_query($query);
- while ($row = mysql_fetch_array($result))
- {
- $uppercats = array_merge($uppercats,
- explode(',', $row['uppercats']));
- }
- $uppercats = array_unique($uppercats);
-
- $query = '
-UPDATE '.CATEGORIES_TABLE.'
- SET status = \'public\'
- WHERE id IN ('.implode(',', $uppercats).')
-;';
- pwg_query($query);
+ set_cat_status($_POST['cat_false'], 'public');
break;
}
}
@@ -273,8 +219,8 @@ SELECT id,name,uppercats,global_rank
$template->assign_vars(
array(
'L_CAT_TITLE' => $lang['cat_lock_title'],
- 'L_CAT_OPTIONS_TRUE' => $lang['lock'],
- 'L_CAT_OPTIONS_FALSE' => $lang['unlock'],
+ 'L_CAT_OPTIONS_TRUE' => $lang['unlocked'],
+ 'L_CAT_OPTIONS_FALSE' => $lang['locked'],
'L_CAT_OPTIONS_INFO' => $lang['cat_lock_info'],
)
);
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 5b113d9ce..7a12be755 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -990,4 +990,106 @@ SELECT id,uppercats
$fields = array('primary' => array('id'), 'update' => array('global_rank'));
mass_updates(CATEGORIES_TABLE, $fields, $datas);
}
+
+/**
+ * change the visible property on a set of categories
+ *
+ * @param array categories
+ * @param string value
+ * @return void
+ */
+function set_cat_visible($categories, $value)
+{
+ if (!in_array($value, array('true', 'false')))
+ {
+ return false;
+ }
+
+ // unlocking a category => all its parent categories become unlocked
+ if ($value == 'true')
+ {
+ $uppercats = array();
+ $query = '
+SELECT uppercats
+ FROM '.CATEGORIES_TABLE.'
+ WHERE id IN ('.implode(',', $categories).')
+;';
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ $uppercats = array_merge($uppercats,
+ explode(',', $row['uppercats']));
+ }
+ $uppercats = array_unique($uppercats);
+
+ $query = '
+UPDATE '.CATEGORIES_TABLE.'
+ SET visible = \'true\'
+ WHERE id IN ('.implode(',', $uppercats).')
+;';
+ pwg_query($query);
+ }
+ // locking a category => all its child categories become locked
+ if ($value == 'false')
+ {
+ $subcats = get_subcat_ids($categories);
+ $query = '
+UPDATE '.CATEGORIES_TABLE.'
+ SET visible = \'false\'
+ WHERE id IN ('.implode(',', $subcats).')
+;';
+ pwg_query($query);
+ }
+}
+
+/**
+ * change the status property on a set of categories : private or public
+ *
+ * @param array categories
+ * @param string value
+ * @return void
+ */
+function set_cat_status($categories, $value)
+{
+ if (!in_array($value, array('public', 'private')))
+ {
+ return false;
+ }
+
+ // make public a category => all its parent categories become public
+ if ($value == 'public')
+ {
+ $uppercats = array();
+ $query = '
+SELECT uppercats
+ FROM '.CATEGORIES_TABLE.'
+ WHERE id IN ('.implode(',', $categories).')
+;';
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ $uppercats = array_merge($uppercats,
+ explode(',', $row['uppercats']));
+ }
+ $uppercats = array_unique($uppercats);
+
+ $query = '
+UPDATE '.CATEGORIES_TABLE.'
+ SET status = \'public\'
+ WHERE id IN ('.implode(',', $uppercats).')
+;';
+ pwg_query($query);
+ }
+ // make a category private => all its child categories become private
+ if ($value == 'private')
+ {
+ $subcats = get_subcat_ids($categories);
+ $query = '
+UPDATE '.CATEGORIES_TABLE.'
+ SET status = \'private\'
+ WHERE id IN ('.implode(',', $subcats).')
+;';
+ pwg_query($query);
+ }
+}
?>