Started working on getting the admin account sections to work again

This commit is contained in:
jengo 2001-02-20 14:06:32 +00:00
parent cdd1abffb1
commit 385a94f09e
4 changed files with 109 additions and 93 deletions

View File

@ -68,10 +68,29 @@
}
function get_list($_type='both')
function get_list($_type='both',$start = '',$sort = '', $order = '', $query = '')
{
global $phpgw, $phpgw_info;
if ($start)
{
$limitclause = $phpgw->db->limit($start);
}
if (! $sort)
{
$sort = "desc";
}
if ($order)
{
$orderclause = "order by $order $sort";
}
else
{
$orderclause = "order by account_lid,account_lastname,account_firstname asc";
}
switch($_type)
{
case 'accounts':
@ -84,7 +103,27 @@
$whereclause = "";
}
$sql = "select * from phpgw_accounts $whereclause";
if ($query)
{
if ($whereclause)
{
$whereclause .= ' and ( ';
}
else
{
$whereclause .= ' where ';
}
$whereclause .= " account_firstname like '%$query%' OR account_lastname like "
. "'%$query%' OR account_lid like '%$query%' ";
if ($whereclause)
{
$whereclause .= ' ) ';
}
}
$sql = "select * from phpgw_accounts $whereclause $orderclause $limitclause";
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record()) {
$accounts[] = Array(
@ -138,24 +177,29 @@
}
}
function exists($account_id)
{
global $phpgw, $phpgw_info;
if (gettype($account_id) == "string") {
$account_id = $this->name2id($account_id);
}
$sql = "SELECT account_id FROM phpgw_accounts WHERE account_id='".$account_id."'";
$this->db->query($sql,__LINE__,__FILE__);
if ($this->db->num_rows()) {
return True;
} else {
return False;
}
}
function exists($account_lid)
{
$this->db->query("SELECT count(*) FROM phpgw_accounts WHERE account_lid='" . $account_lid
. "'",__LINE__,__FILE__);
$this->db->next_record();
return $this->db->f(0);
}
function create($account_type, $account_lid, $account_pwd, $account_firstname, $account_lastname, $account_status)
{
$this->db->query("insert into phpgw_accounts (account_lid, account_type, account_pwd, "
. "account_firstname, account_lastname, account_status) values ('" . $account_lid
. "','" . $account_type . "','" . md5($account_pwd) . "', '" . $account_firstname
. "','" . $account_lastname . "','" . $account_status . "')",__LINE__,__FILE__);
}
function auto_add($accountname, $passwd, $default_prefs = False, $default_acls = False)
{
global $phpgw, $phpgw_info;
// Why on earth is this a random number ?!
// This should also use the above function (jengo)
$accountid = mt_rand (100, 600000);
if ($default_prefs == False) {
$default_prefs = 'a:5:{s:6:"common";a:1:{s:0:"";s:2:"en";}s:11:"addressbook";a:1:{s:0:"";s:4:"True";}i:8;a:1:{s:0:"";s:13:"workdaystarts";}i:15;a:1:{s:0:"";s:11:"workdayends";}s:6:"Monday";a:1:{s:0:"";s:13:"weekdaystarts";}}';

View File

@ -294,10 +294,12 @@ It should use the values in the $this->data
* These are the generic functions. Not specific to $this->account_id *
\**************************************************************************/
function add_repository($app, $location, $account_id, $rights){
function add_repository($app, $location, $account_id, $account_type, $rights)
{
$this->delete_repository($app, $location, $account_id);
$sql = 'insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights)';
$sql .= " values('".$app."', '".$location."', ".$account_id.', '.$rights.')';
$sql = 'insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)';
$sql .= " values ('" . $app . "','" . $location . "','" . $account_id . "','" . $account_type
. "','" . $rights . "')";
$this->db->query($sql ,__LINE__,__FILE__);
return True;
}

View File

@ -101,7 +101,7 @@
reset($this->data);
while($app = each($this->data)) {
if(!$this->is_system_enabled($app[0])) { continue; }
$phpgw->acl->add_repository($app[0],'run',$this->account_id,1);
$phpgw->acl->add_repository($app[0],'run',$this->account_id,'u',1);
}
reset($this->data);
return $this->data;

View File

@ -284,82 +284,52 @@ class nextmatchs
return $str;
} /* right() */
function alternate_row_color($currentcolor = "")
{
global $phpgw_info;
if (! $currentcolor) {
global $tr_color;
$currentcolor = $tr_color;
}
function alternate_row_color($currentcolor = '')
{
global $phpgw_info;
if (! $currentcolor)
{
global $tr_color;
$currentcolor = $tr_color;
}
if ($currentcolor == $phpgw_info["theme"]["row_on"]) {
$tr_color = $phpgw_info["theme"]["row_off"];
} else {
$tr_color = $phpgw_info["theme"]["row_on"];
}
return $tr_color;
}
if ($currentcolor == $phpgw_info['theme']['row_on'])
{
$tr_color = $phpgw_info['theme']['row_off'];
}
else
{
$tr_color = $phpgw_info['theme']['row_on'];
}
// If you are using the common bgcolor="{tr_color}"
// This function is a little cleanier approch
function template_alternate_row_color(&$tpl)
{
$tpl->set_var("tr_color",$this->alternate_row_color());
}
return $tr_color;
}
function show_sort_order($sort,$var,$order,$program,$text,$extra="")
{
global $phpgw, $filter, $qfield, $start, $query;
if (($order == $var) && ($sort == "ASC"))
$sort = "DESC";
else if (($order == $var) && ($sort == "DESC"))
$sort = "ASC";
else
$sort = "ASC";
// If you are using the common bgcolor="{tr_color}"
// This function is a little cleanier approch
function template_alternate_row_color(&$tpl)
{
$tpl->set_var('tr_color',$this->alternate_row_color());
}
return "<a href=\"".$phpgw->link($program,"order=$var&sort=$sort"
. "&filter=$filter&qfield=$qfield"
. "&start=$start&query=$query".$extra)."\">$text</a>";
}
function show_sort_order($sort,$var,$order,$program,$text,$extra='')
{
global $phpgw, $filter, $qfield, $start, $query;
if (($order == $var) && ($sort == "ASC"))
{
$sort = "DESC";
}
else if (($order == $var) && ($sort == "DESC"))
{
$sort = "ASC";
}
else
{
$sort = "ASC";
}
// Postgre and MySQL switch the vars in limit. This will make it easier
// if there are any other databases that pull this.
return '<a href="' . $phpgw->link($program,"order=$var&sort=$sort&filter=$filter&"
. "qfield=$qfield&start=$start&query=$query" . $extra) . '">' . $text . '</a>';
}
// NOTE!! This is is NO longer used. Use db->limit() instead.
// This is here for people to get there code up to date.
function sql_limit($start)
{
echo "<center><b>WARNING:</b> Do not use sql_limit() anymore. Use db->limit() from now on.</center>";
global $phpgw_info;
$max = $phpgw_info["user"]["preferences"]["common"]["maxmatchs"];
switch ($phpgw_info["server"]["db_type"]) {
case "pgsql":
if ($start == 0)
$l = $max;
else
$l = "$max,$start";
return $l;
break;
case "mysql":
if ($start == 0)
$l = $max;
else
$l = "$start,$max";
return $l;
break;
case "oracle":
if ($start == 0)
$l = "rownum < $max";
else
$l = "rownum >= $start AND rownum <= $max";
// if ($new_where)
// return "WHERE $l";
// else
// return "AND $l";
break;
}
}
}