member listing now includes a form to search amoung domains rather than logins

This commit is contained in:
Fran��ois Serman 2013-09-23 10:11:59 +00:00
parent 4f603deb80
commit 14bb794dd0
2 changed files with 47 additions and 22 deletions

View File

@ -39,6 +39,7 @@ $fields = array (
"creator" => array("request", "integer", 0), "creator" => array("request", "integer", 0),
"short" => array("request", "integer", -1), "short" => array("request", "integer", -1),
"pattern" => array("request", "string", FALSE), "pattern" => array("request", "string", FALSE),
"pattern_type" => array("request", "string", FALSE),
); );
getFields($fields); getFields($fields);
@ -57,13 +58,12 @@ if ($show=="all" && !$subadmin==1 && $cuid != 2000) {
exit(); exit();
} }
if ($pattern && $pattern_type) {
if ($pattern) $r=$admin->get_list($show == 'all' ? 1 : 0, $creator, $pattern, $pattern_type);
$r=$admin->get_list($show == 'all' ? 1 : 0, $creator, $pattern); }
else else
$r = FALSE; $r = FALSE;
?> ?>
<h3><?php __("AlternC account list"); ?></h3> <h3><?php __("AlternC account list"); ?></h3>
<hr id="topbar"/> <hr id="topbar"/>
<br /> <br />
@ -73,7 +73,10 @@ else
<p> <p>
<form method="get"> <form method="get">
<label for="pattern"><?php __("Login pattern"); ?></label>&nbsp; <span><?php __("Pattern"); ?></span>
<label for="pattern_type_login">Login</label><input type="radio" name="pattern_type" value="login" id="pattern_type_login" <?php if ($pattern_type === 'login') echo ' checked="checked" '; ?>/>&nbsp;
<label for="pattern_type_domain">Domaine</label><input type="radio" name="pattern_type" value="domaine" id="pattern_type_domain" <?php if ($pattern_type === 'domaine') echo ' checked="checked" '; ?>/>
<!-- <label for="pattern"><?php __("Login pattern"); ?></label>&nbsp; -->
<input type="text" id="pattern" name="pattern" value="<?php echo $pattern ? $pattern : '*'; ?>"/> <input type="submit" class="inb" value="<?php __("submit"); ?>" /> <input type="text" id="pattern" name="pattern" value="<?php echo $pattern ? $pattern : '*'; ?>"/> <input type="submit" class="inb" value="<?php __("submit"); ?>" />
</form> </form>

View File

@ -281,7 +281,7 @@ class m_admin {
* table <code>membres</code> and <code>local</code> of all the accounts. * table <code>membres</code> and <code>local</code> of all the accounts.
* Returns FALSE if an error occurs. * Returns FALSE if an error occurs.
*/ */
function get_list($all=0,$creator=0,$pattern=FALSE) { function get_list($all=0,$creator=0,$pattern=FALSE,$pattern_type=FALSE) {
global $err,$mem,$cuid; global $err,$mem,$cuid;
$err->log("admin","get_list"); $err->log("admin","get_list");
if (!$this->enabled) { if (!$this->enabled) {
@ -290,28 +290,50 @@ class m_admin {
} }
$db=new DB_System(); $db=new DB_System();
$request = 'SELECT uid FROM membres WHERE 1';
if ($pattern && preg_match('/[a-zA-Z0-9]+/', $pattern)) if ($pattern) {
$request .= sprintf(' AND login LIKE "%%%s%%"', $pattern);
if ($creator) if ($pattern_type === 'domaine') {
$request .= sprintf(' AND creator = "%s"', $creator);
if ($mem->user['uid']!=2000 && !$all)
$request .= sprintf(' AND creator = "%s"', $cuid);
$request .= ' ORDER BY login;'; $request = 'SELECT compte AS uid FROM domaines WHERE 1';
if ($pattern && preg_match('/[.a-zA-Z0-9]+/', $pattern))
$request .= sprintf(' AND domaine LIKE "%%%s%%"', $pattern);
} elseif ($pattern_type === 'login') {
$request = 'SELECT uid FROM membres WHERE 1';
if ($pattern && preg_match('/[a-zA-Z0-9]+/', $pattern))
$request .= sprintf(' AND login LIKE "%%%s%%"', $pattern);
if ($creator)
$request .= sprintf(' AND creator = "%s"', $creator);
if ($mem->user['uid']!=2000 && !$all)
$request .= sprintf(' AND creator = "%s"', $cuid);
$request .= ' ORDER BY login;';
} else {
$err->raise("admin", _("Invalid pattern type provided. Are you even performing a legitimate action?"));
return FALSE;
}
/* if ($creator)
{
// Limit listing to a specific reseller
$db->query("SELECT uid FROM membres WHERE creator='".$creator."' ORDER BY login;");
} elseif ($mem->user['uid']==2000 || $all) {
$db->query("SELECT uid FROM membres ORDER BY login;");
} else { } else {
$db->query("SELECT uid FROM membres WHERE creator='".$cuid."' ORDER BY login;");
if ($creator)
{
// Limit listing to a specific reseller
$request = "SELECT uid FROM membres WHERE creator='".$creator."' ORDER BY login;";
} elseif ($mem->user['uid']==2000 || $all) {
$request = "SELECT uid FROM membres ORDER BY login;";
} else {
$request = "SELECT uid FROM membres WHERE creator='".$cuid."' ORDER BY login;";
}
} }
*/
$db->query($request); $db->query($request);