[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] api/class.prefs.php, 1.1.1.1.2.13
From: |
nomail |
Subject: |
[Phpgroupware-cvs] api/class.prefs.php, 1.1.1.1.2.13 |
Date: |
Thu, 20 May 2004 18:50:36 -0000 |
Update of /api
Modified Files:
Branch: proposal-branch
class.prefs.php
date: 2004/04/23 06:58:46; author: jengo; state: Exp; lines: +85 -19
Log Message:
- Restored preferences to a working state
- Added _display_account_fullname(), which will display accounts in the users
preference format
=====================================================================
No syntax errors detected in -
=====================================================================
Index: api/class.prefs.php
diff -u api/class.prefs.php:1.1.1.1.2.12 api/class.prefs.php:1.1.1.1.2.13
--- api/class.prefs.php:1.1.1.1.2.12 Fri Apr 16 20:59:48 2004
+++ api/class.prefs.php Fri Apr 23 06:58:46 2004
@@ -39,8 +39,11 @@
$this->account_id = $args['account_id'];
/* all required defaults can be set here */
- $this->data['phpgw_default']['api.skin'] = 'default';
- $this->data['phpgw_default']['api.lang'] = 'en';
+ $this->data['phpgw_default']['api.skin'] =
'default';
+ $this->data['phpgw_default']['api.lang'] =
'en';
+ // FIXME: This should be added to setup defaults
+ // This isn't a required value ... but its a nice
default
+ $this->data['phpgw_default']['api.account_display'] =
'all';
}
function __sleep()
@@ -59,15 +62,17 @@
$args->set('value', '##UNSET##', 'any');
$args->set('account_id', $this->account_id, 'any');
$args = $args->get(func_get_args());
+
$tmp = explode('.', $args['pref']);
$args['app'] = $tmp[0];
$args['name'] = $tmp[1];
- if($GLOBALS['phpgw']->acl->check('api.prefs.save', 1))
+
+ if ($GLOBALS['phpgw']->acl->check('api.prefs.save', 1))
{
return $this->save($args);
}
- if($args['value'] == '##UNSET##')
+ if ($args['value'] == '##UNSET##')
{
unset($this->data[$args['account_id']][$args['name']]);
}
@@ -94,11 +99,11 @@
. ' AND
pref_name='.$GLOBALS['phpgw']->db->qstr($args['name'])
. ' AND
pref_account='.$GLOBALS['phpgw']->db->qstr($args['account_id']);
- if($args['value'] == '##UNSET##')
+ if ($args['value'] == '##UNSET##')
{
$sql = 'DELETE FROM phpgw_prefs'
. $where;
- if (!is_object($rs =
$GLOBALS['phpgw']->db->query($sql)))
+ if (! is_object($rs =
$GLOBALS['phpgw']->db->query($sql)))
{
return false;
}
@@ -108,12 +113,13 @@
{
$sql = 'SELECT * FROM phpgw_prefs'
. $where;
- if (!is_object($rs =
$GLOBALS['phpgw']->db->query($sql)))
+ if (! is_object($rs =
$GLOBALS['phpgw']->db->query($sql)))
{
return false;
}
- $values = array(
+ $values = array
+ (
'pref_app' => $args['app'],
'pref_name' => $args['name'],
'pref_value' => $args['value'],
@@ -147,7 +153,7 @@
$args->set('app', NOTSET, 'any');
$args = $args->get(func_get_args());
- if (!isset($args['app']))
+ if (! isset($args['app']))
{
list($args['app']) =
explode('.',$GLOBALS['phpgw_data']['api']['op'],2);
}
@@ -161,12 +167,12 @@
. ' WHERE
pref_app='.$GLOBALS['phpgw']->db->qstr($args['app'])
. ' AND
pref_name='.$GLOBALS['phpgw']->db->qstr($args['name'])
. ' AND
pref_account='.$GLOBALS['phpgw']->db->qstr($args['account_id']);
- if (!is_object($rs =
$GLOBALS['phpgw']->db->query($sql)))
+ if (! is_object($rs =
$GLOBALS['phpgw']->db->query($sql)))
{
return false;
}
- if (!$rs->EOF)
+ if (! $rs->EOF)
{
$this->data[$args['account_id']][$args['app'].'.'.$args['name']] =
$GLOBALS['phpgw']->db->f('pref_value');
}
@@ -179,7 +185,8 @@
$args->set('account_id', $this->account_id, 'any');
$args->set('app', NOTSET, 'any');
$args = $args->get(func_get_args());
- if(!isset($args['app']) || empty($args['app']) ||
$args['app'] == 'api')
+
+ if (! isset($args['app']) || empty($args['app']) ||
$args['app'] == 'api')
{
$args['app'] = 'api';
$this->loaded_api = true;
@@ -190,16 +197,17 @@
$sql = 'SELECT * FROM phpgw_prefs'
. ' WHERE pref_app =
'.$GLOBALS['phpgw']->db->qstr($args['app'])
. ' AND pref_account
IN('.$GLOBALS['phpgw']->db->qstr($args['account_id']).',\'phpgw_default\',\'phpgw_forced\')';
- if(!is_object($rs =
$GLOBALS['phpgw']->db->Execute($sql)))
+ if (!is_object($rs =
$GLOBALS['phpgw']->db->Execute($sql)))
{
return false;
}
//}
-
+
while ($row = $rs->FetchRow())
{
-
$this->data[$row['pref_account']][$row['pref_app'].'.'.$row['pref_account']] =
$row['pref_value'];
+
$this->data[$row['pref_account']][$row['pref_app'] . '.' . $row['pref_name']] =
$row['pref_value'];
}
+
return true;
}
@@ -213,16 +221,74 @@
$args = new safe_args();
$args->set('app', NOTSET, 'any');
$args = $args->get(func_get_args());
- if(!isset($args['app']))
+
+ if(! isset($args['app']))
{
list($args['app']) =
explode('.',$GLOBALS['phpgw_data']['api']['op'],2);
}
- if(!$this->loaded_api)
+ if(! $this->loaded_api)
{
$this->load('api');
}
+
$this->load(array('app'=>$args['app']));
$GLOBALS['phpgw_data']['prefs'] = $this->merge_prefs();
}
+
+ function _display_account_fullname()
+ {
+ $args = new safe_args();
+ $args->set('loginid',NOVAR);
+ $args->set('firstname',NOVAR);
+ $args->set('lastname',NOVAR);
+ extract($args->get(func_get_args()));
+
+ if (loginid == NOVAR && $firstname == NOVAR &&
$lastname == NOVAR)
+ {
+ $loginid =
$GLOBALS['phpgw_data']['user']['loginid'];
+ $firstname =
$GLOBALS['phpgw_data']['user']['firstname'];
+ $lastname =
$GLOBALS['phpgw_data']['user']['lastname'];
+ }
+
+ if (! $firstname && ! $lastname ||
$GLOBALS['phpgw_data']['prefs']['api.account_display'] == 'username')
+ {
+ return $loginid;
+ }
+
+ if ($lastname)
+ {
+ $a[] = $lastname;
+ }
+
+ if ($firstname)
+ {
+ $a[] = $firstname;
+ }
+
+ switch
($GLOBALS['phpgw_data']['prefs']['api.account_display'])
+ {
+ case 'all':
+ if ($loginid)
+ {
+ $name = '[' . $loginid . '] ';
+ }
+ // fall-through
+ case 'lastname':
+ $name .= implode(', ',$a);
+ break;
+ case 'firstall':
+ if ($loginid)
+ {
+ $name = ' [' . $loginid . ']';
+ }
+ // fall-through
+ case 'firstname':
+ default:
+ $name = $firstname . ' ' . $lastname .
$name;
+ }
+
+ return $name;
+ }
+
}
- [Phpgroupware-cvs] api/class.prefs.php, 1.1.1.1.2.13,
nomail <=