aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2005-04-30 14:36:57 +0000
committerplegall <plg@piwigo.org>2005-04-30 14:36:57 +0000
commit9cfba96167a8d6e67d6e3a257e87e27483c478ec (patch)
treed09a6d441b18e3e561dbce61ddb1c9295816c820
parent5293402be5299d3c7b6b0f55b4130223ece04dd6 (diff)
- user list updated : ability to filter list on status. Function get_enums
comes back to retrieve the list of possible status in the database. git-svn-id: http://piwigo.org/svn/trunk@777 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--admin/user_list.php38
-rw-r--r--doc/ChangeLog6
-rw-r--r--include/functions.inc.php30
-rw-r--r--template/default/admin/user_list.tpl7
4 files changed, 81 insertions, 0 deletions
diff --git a/admin/user_list.php b/admin/user_list.php
index 9bfbacd33..615ecdf58 100644
--- a/admin/user_list.php
+++ b/admin/user_list.php
@@ -155,6 +155,29 @@ while ($row = mysql_fetch_array($result))
));
}
+$blockname = 'status_option';
+
+$template->assign_block_vars(
+ $blockname,
+ array(
+ 'VALUE'=> -1,
+ 'CONTENT' => '------------',
+ 'SELECTED' => ''
+ ));
+
+foreach (get_enums(USERS_TABLE, 'status') as $status)
+{
+ $selected = (isset($_GET['status']) and $_GET['status'] == $status) ?
+ 'selected="selected"' : '';
+ $template->assign_block_vars(
+ $blockname,
+ array(
+ 'VALUE' => $status,
+ 'CONTENT' => $lang['user_status_'.$status],
+ 'SELECTED' => $selected
+ ));
+}
+
// +-----------------------------------------------------------------------+
// | filter |
// +-----------------------------------------------------------------------+
@@ -186,6 +209,11 @@ if (isset($_GET['group'])
$filter['group'] = $_GET['group'];
}
+if (isset($_GET['status'])
+ and in_array($_GET['status'], get_enums(USERS_TABLE, 'status')))
+{
+ $filter['status'] = $_GET['status'];
+}
// +-----------------------------------------------------------------------+
// | navigation bar |
@@ -205,6 +233,11 @@ if (isset($filter['group']))
$query.= '
AND group_id = '.$filter['group'];
}
+if (isset($filter['status']))
+{
+ $query.= '
+ AND status = \''.$filter['status']."'";
+}
$query.= '
;';
list($counter) = mysql_fetch_row(pwg_query($query));
@@ -258,6 +291,11 @@ if (isset($filter['group']))
$query.= '
AND group_id = '.$filter['group'];
}
+if (isset($filter['status']))
+{
+ $query.= '
+ AND status = \''.$filter['status']."'";
+}
$query.= '
ORDER BY '.$order_by.' '.$direction.'
LIMIT '.$start.', '.$conf['users_page'].'
diff --git a/doc/ChangeLog b/doc/ChangeLog
index b3e45227c..cff4f3ff0 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,9 @@
+2005-04-30 Pierrick LE GALL
+
+ * user list updated : ability to filter list on status. Function
+ get_enums comes back to retrieve the list of possible status in
+ the database.
+
2005-04-28 Pierrick LE GALL
* user list updated : ability to filter list on group
diff --git a/include/functions.inc.php b/include/functions.inc.php
index a9c48f33b..ce64148a7 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -34,6 +34,36 @@ include_once( PHPWG_ROOT_PATH .'include/functions_html.inc.php' );
//----------------------------------------------------------- generic functions
+/**
+ * returns an array containing the possible values of an enum field
+ *
+ * @param string tablename
+ * @param string fieldname
+ */
+function get_enums($table, $field)
+{
+ // retrieving the properties of the table. Each line represents a field :
+ // columns are 'Field', 'Type'
+ $result = pwg_query('desc '.$table);
+ while ($row = mysql_fetch_array($result))
+ {
+ // we are only interested in the the field given in parameter for the
+ // function
+ if ($row['Field'] == $field)
+ {
+ // retrieving possible values of the enum field
+ // enum('blue','green','black')
+ $options = explode(',', substr($row['Type'], 5, -1));
+ foreach ($options as $i => $option)
+ {
+ $options[$i] = str_replace("'", '',$option);
+ }
+ }
+ }
+ mysql_free_result($result);
+ return $options;
+}
+
// get_boolean transforms a string to a boolean value. If the string is
// "false" (case insensitive), then the boolean value false is returned. In
// any other case, true is returned.
diff --git a/template/default/admin/user_list.tpl b/template/default/admin/user_list.tpl
index 5aa108298..215564879 100644
--- a/template/default/admin/user_list.tpl
+++ b/template/default/admin/user_list.tpl
@@ -22,6 +22,13 @@
username <input type="text" name="username" value="{F_USERNAME}" />
+ status
+ <select name="status">
+ <!-- BEGIN status_option -->
+ <option value="{status_option.VALUE}" {status_option.SELECTED} > {status_option.CONTENT}</option>
+ <!-- END status_option -->
+ </select>
+
group
<select name="group">
<!-- BEGIN group_option -->