aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2004-11-15 21:42:55 +0000
committerplegall <plg@piwigo.org>2004-11-15 21:42:55 +0000
commitb138e8aa0731b7e8f7a40f6af5024948bde40c52 (patch)
tree0bb5f77ce0fc6bdadb995ce1ad7eff1e22d5564e
parent2d0f0f03ba9d467c314f7ef7f06b5cb52f88c3d2 (diff)
- admin/cat_options page really added this time : manage options for the
whole categories tree : uploadable, commentable, status and visible git-svn-id: http://piwigo.org/svn/trunk@604 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/cat_options.php333
-rw-r--r--language/en_UK.iso-8859-1/admin.lang.php6
-rw-r--r--template/default/admin/cat_options.tpl61
3 files changed, 400 insertions, 0 deletions
diff --git a/admin/cat_options.php b/admin/cat_options.php
new file mode 100644
index 000000000..cb518f7db
--- /dev/null
+++ b/admin/cat_options.php
@@ -0,0 +1,333 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2004 PhpWebGallery Team - 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');
+// +-----------------------------------------------------------------------+
+// | modification registration |
+// +-----------------------------------------------------------------------+
+// print '<pre>';
+// print_r($_POST);
+// print '</pre>';
+if (isset($_POST['submit']) and count($_POST['cat']) > 0)
+{
+ switch ($_GET['section'])
+ {
+ case 'upload' :
+ {
+ $query = '
+UPDATE '.CATEGORIES_TABLE.'
+ SET uploadable = \''.$_POST['option'].'\'
+ WHERE id IN ('.implode(',', $_POST['cat']).')
+;';
+ pwg_query($query);
+ break;
+ }
+ case 'comments' :
+ {
+ $query = '
+UPDATE '.CATEGORIES_TABLE.'
+ SET commentable = \''.$_POST['option'].'\'
+ WHERE id IN ('.implode(',', $_POST['cat']).')
+;';
+ pwg_query($query);
+ break;
+ }
+ case 'visible' :
+ {
+ // locking a category => all its child categories become locked
+ if ($_POST['option'] == 'false')
+ {
+ $subcats = get_subcat_ids($_POST['cat']);
+ $query = '
+UPDATE '.CATEGORIES_TABLE.'
+ SET visible = \'false\'
+ WHERE id IN ('.implode(',', $subcats).')
+;';
+ pwg_query($query);
+ }
+ // unlocking a category => all its parent categories become unlocked
+ if ($_POST['option'] == 'true')
+ {
+ $uppercats = array();
+ $query = '
+SELECT uppercats
+ FROM '.CATEGORIES_TABLE.'
+ WHERE id IN ('.implode(',', $_POST['cat']).')
+;';
+ $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);
+ }
+ break;
+ }
+ case 'status' :
+ {
+ // make a category private => all its child categories become private
+ if ($_POST['option'] == 'false')
+ {
+ $subcats = get_subcat_ids($_POST['cat']);
+ $query = '
+UPDATE '.CATEGORIES_TABLE.'
+ SET status = \'private\'
+ WHERE id IN ('.implode(',', $subcats).')
+;';
+ pwg_query($query);
+ }
+ // make public a category => all its parent categories become public
+ if ($_POST['option'] == 'true')
+ {
+ $uppercats = array();
+ $query = '
+SELECT uppercats
+ FROM '.CATEGORIES_TABLE.'
+ WHERE id IN ('.implode(',', $_POST['cat']).')
+;';
+ $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);
+ }
+ break;
+ }
+ }
+}
+// +-----------------------------------------------------------------------+
+// | template init |
+// +-----------------------------------------------------------------------+
+$template->set_filenames(array('cat_options'=>'admin/cat_options.tpl'));
+
+if (!isset($_GET['section']))
+{
+ $page['section'] = 'upload';
+}
+else
+{
+ $page['section'] = $_GET['section'];
+}
+
+$base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_options&amp;section=';
+$template->assign_vars(
+ array(
+ 'L_SUBMIT'=>$lang['submit'],
+ 'L_RESET'=>$lang['reset'],
+ 'L_CAT_OPTIONS_MENU_UPLOAD'=>$lang['cat_options_menu_upload'],
+ 'L_CAT_OPTIONS_MENU_VISIBLE'=>$lang['cat_options_menu_visible'],
+ 'L_CAT_OPTIONS_MENU_COMMENTS'=>$lang['cat_options_menu_comments'],
+ 'L_CAT_OPTIONS_MENU_STATUS'=>$lang['cat_options_menu_status'],
+ 'L_CAT_OPTIONS_UPLOAD_INFO'=>$lang['cat_options_upload_info'],
+ 'L_CAT_OPTIONS_UPLOAD_TRUE'=>$lang['cat_options_upload_true'],
+ 'L_CAT_OPTIONS_UPLOAD_FALSE'=>$lang['cat_options_upload_false'],
+ 'L_CAT_OPTIONS_COMMENTS_INFO'=>$lang['cat_options_comments_info'],
+ 'L_CAT_OPTIONS_COMMENTS_TRUE'=>$lang['cat_options_comments_true'],
+ 'L_CAT_OPTIONS_COMMENTS_FALSE'=>$lang['cat_options_comments_false'],
+ 'L_CAT_OPTIONS_VISIBLE_INFO'=>$lang['cat_options_visible_info'],
+ 'L_CAT_OPTIONS_VISIBLE_TRUE'=>$lang['cat_options_visible_true'],
+ 'L_CAT_OPTIONS_VISIBLE_FALSE'=>$lang['cat_options_visible_false'],
+ 'L_CAT_OPTIONS_STATUS_INFO'=>$lang['cat_options_status_info'],
+ 'L_CAT_OPTIONS_STATUS_TRUE'=>$lang['cat_options_status_true'],
+ 'L_CAT_OPTIONS_STATUS_FALSE'=>$lang['cat_options_status_false'],
+
+ 'U_UPLOAD'=>add_session_id($base_url.'upload'),
+ 'U_VISIBLE'=>add_session_id($base_url.'visible'),
+ 'U_COMMENTS'=>add_session_id($base_url.'comments'),
+ 'U_STATUS'=>add_session_id($base_url.'status'),
+
+ 'F_ACTION'=>add_session_id($base_url.$page['section'])
+ )
+ );
+
+$template->assign_vars(array(strtoupper($page['section']).'_CLASS'=>'opened'));
+// +-----------------------------------------------------------------------+
+// | form display |
+// +-----------------------------------------------------------------------+
+
+// for each section, categories in the multiselect field can be :
+//
+// - true : uploadable for upload section
+// - false : un-uploadable for upload section
+// - NA : (not applicable) for virtual categories
+//
+// for true and false status, we associates an array of category ids,
+// function display_select_categories will use the given CSS class for each
+// option
+$cats_true = array();
+$cats_false = array();
+switch ($page['section'])
+{
+ case 'upload' :
+ {
+ $query = '
+SELECT id
+ FROM '.CATEGORIES_TABLE.'
+ WHERE uploadable = \'true\'
+ AND dir IS NOT NULL
+ AND site_id = 1
+;';
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ array_push($cats_true, $row['id']);
+ }
+ $query = '
+SELECT id
+ FROM '.CATEGORIES_TABLE.'
+ WHERE uploadable = \'false\'
+ AND dir IS NOT NULL
+ AND site_id = 1
+;';
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ array_push($cats_false, $row['id']);
+ }
+
+ $template->assign_block_vars('upload', array());
+
+ break;
+ }
+ case 'comments' :
+ {
+ $query = '
+SELECT id
+ FROM '.CATEGORIES_TABLE.'
+ WHERE commentable = \'true\'
+;';
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ array_push($cats_true, $row['id']);
+ }
+ $query = '
+SELECT id
+ FROM '.CATEGORIES_TABLE.'
+ WHERE commentable = \'false\'
+;';
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ array_push($cats_false, $row['id']);
+ }
+
+ $template->assign_block_vars('comments', array());
+
+ break;
+ }
+ case 'visible' :
+ {
+ $query = '
+SELECT id
+ FROM '.CATEGORIES_TABLE.'
+ WHERE visible = \'true\'
+;';
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ array_push($cats_true, $row['id']);
+ }
+ $query = '
+SELECT id
+ FROM '.CATEGORIES_TABLE.'
+ WHERE visible = \'false\'
+;';
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ array_push($cats_false, $row['id']);
+ }
+
+ $template->assign_block_vars('visible', array());
+
+ break;
+ }
+ case 'status' :
+ {
+ $query = '
+SELECT id
+ FROM '.CATEGORIES_TABLE.'
+ WHERE status = \'public\'
+;';
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ array_push($cats_true, $row['id']);
+ }
+ $query = '
+SELECT id
+ FROM '.CATEGORIES_TABLE.'
+ WHERE status = \'private\'
+;';
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ array_push($cats_false, $row['id']);
+ }
+
+ $template->assign_block_vars('status', array());
+
+ break;
+ }
+}
+$CSS_classes = array('optionTrue'=>$cats_true,
+ 'optionFalse'=>$cats_false);
+
+$user['expand'] = true;
+$structure = create_user_structure('');
+display_select_categories($structure,
+ '&nbsp;',
+ array(),
+ 'category_option',
+ $CSS_classes);
+// +-----------------------------------------------------------------------+
+// | sending html code |
+// +-----------------------------------------------------------------------+
+$template->assign_var_from_handle('ADMIN_CONTENT', 'cat_options');
+?> \ No newline at end of file
diff --git a/language/en_UK.iso-8859-1/admin.lang.php b/language/en_UK.iso-8859-1/admin.lang.php
index 8b5419b39..3da806042 100644
--- a/language/en_UK.iso-8859-1/admin.lang.php
+++ b/language/en_UK.iso-8859-1/admin.lang.php
@@ -334,4 +334,10 @@ $lang['cat_options_upload_info'] = '(multi)select categories to make them upload
$lang['cat_options_comments_true'] = 'authorize comments';
$lang['cat_options_comments_false'] = 'forbid comments';
$lang['cat_options_comments_info'] = '(multi)select categories to make them commentable or not. By inheritance, an element is commentable if it belongs at least to one commentable category.';
+$lang['cat_options_visible_true'] = 'unlock';
+$lang['cat_options_visible_false'] = 'lock temporary';
+$lang['cat_options_visible_info'] = '(multi)select categories to lock or unlock them. If you lock category, all its child categories becomes locked. It you unlock a category, all its parent categories becomes unlocked';
+$lang['cat_options_status_true'] = 'public';
+$lang['cat_options_status_false'] = 'private';
+$lang['cat_options_status_info'] = '(multi)select categories to make them public or private. If you make a category private, all its child categories becomes private. It you make a category public, all its parent categories becomes public';
?> \ No newline at end of file
diff --git a/template/default/admin/cat_options.tpl b/template/default/admin/cat_options.tpl
new file mode 100644
index 000000000..148f72e0b
--- /dev/null
+++ b/template/default/admin/cat_options.tpl
@@ -0,0 +1,61 @@
+<p class="confMenu">
+ <a class="{UPLOAD_CLASS}" href="{U_UPLOAD}">{L_CAT_OPTIONS_MENU_UPLOAD}</a>
+ <a class="{COMMENTS_CLASS}" href="{U_COMMENTS}">{L_CAT_OPTIONS_MENU_COMMENTS}</a>
+ <a class="{VISIBLE_CLASS}" href="{U_VISIBLE}">{L_CAT_OPTIONS_MENU_VISIBLE}</a>
+ <a class="{STATUS_CLASS}" href="{U_STATUS}">{L_CAT_OPTIONS_MENU_STATUS}</a>
+</p>
+
+<form action="{F_ACTION}" method="post">
+
+ <select style="width:500px" multiple="multiple" name="cat[]" size="20">
+ <!-- BEGIN category_option -->
+ <option class="{category_option.CLASS}" {category_option.SELECTED} value="{category_option.VALUE}">{category_option.OPTION}</option>
+ <!-- END category_option -->
+ </select>
+
+ <!-- BEGIN upload -->
+ <p>{L_CAT_OPTIONS_UPLOAD_INFO}</p>
+ <p>
+ <input type="radio" name="option" value="true"/> <span class="optionTrue">{L_CAT_OPTIONS_UPLOAD_TRUE}</span>
+ </p>
+ <p>
+ <input type="radio" name="option" value="false"/> <span class="optionFalse">{L_CAT_OPTIONS_UPLOAD_FALSE}</span>
+ </p>
+ <!-- END upload -->
+
+ <!-- BEGIN comments -->
+ <p>{L_CAT_OPTIONS_COMMENTS_INFO}</p>
+ <p>
+ <input type="radio" name="option" value="true"/> <span class="optionTrue">{L_CAT_OPTIONS_COMMENTS_TRUE}</span>
+ </p>
+ <p>
+ <input type="radio" name="option" value="false"/> <span class="optionFalse">{L_CAT_OPTIONS_COMMENTS_FALSE}</span>
+ </p>
+ <!-- END comments -->
+
+ <!-- BEGIN visible -->
+ <p>{L_CAT_OPTIONS_VISIBLE_INFO}</p>
+ <p>
+ <input type="radio" name="option" value="true"/> <span class="optionTrue">{L_CAT_OPTIONS_VISIBLE_TRUE}</span>
+ </p>
+ <p>
+ <input type="radio" name="option" value="false"/> <span class="optionFalse">{L_CAT_OPTIONS_VISIBLE_FALSE}</span>
+ </p>
+ <!-- END visible -->
+
+ <!-- BEGIN status -->
+ <p>{L_CAT_OPTIONS_STATUS_INFO}</p>
+ <p>
+ <input type="radio" name="option" value="true"/> <span class="optionTrue">{L_CAT_OPTIONS_STATUS_TRUE}</span>
+ </p>
+ <p>
+ <input type="radio" name="option" value="false"/> <span class="optionFalse">{L_CAT_OPTIONS_STATUS_FALSE}</span>
+ </p>
+ <!-- END status -->
+
+ <p style="text-align:center;">
+ <input type="submit" value="{L_SUBMIT}" name="submit" class="bouton" />
+ <input type="reset" name="reset" value="{L_RESET}" class="bouton" />
+ </p>
+
+</form>