[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: phpgwapi/inc class.preferences.inc.php,1.49,1.50
From: |
Ralf Becker <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: phpgwapi/inc class.preferences.inc.php,1.49,1.50 |
Date: |
Thu, 01 May 2003 21:33:34 -0400 |
Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv15543
Modified Files:
class.preferences.inc.php
Log Message:
added notify-messages to prefs:
- notify messages contain vars to be substituted, eg. $$username$$
- the var-name gets translated for editing
- new function create_notify in preferences.php
- new function parse_notify to substitute / create the notify msg
Index: class.preferences.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.preferences.inc.php,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -r1.49 -r1.50
*** class.preferences.inc.php 1 May 2003 09:19:11 -0000 1.49
--- class.preferences.inc.php 2 May 2003 01:33:32 -0000 1.50
***************
*** 54,57 ****
--- 54,59 ----
//var $debug_init_prefs = 2;
//var $debug_init_prefs = 3;
+
+ var $values,$vars; // standard notify substitues, will be
set by standard_substitues()
/**************************************************************************\
***************
*** 74,77 ****
--- 76,189 ----
/*!
+ @function parse_notify
+ @abstract parses a notify and replaces the substitutes
+ @syntax parse_notify($msg,$values='',$use_standard_values=True)
+ @param $msg message to parse / substitute
+ @param $values extra vars to replace in addition to
$this->values, vars are in an array with \
+ $key => $value pairs, $key does not include the $'s and
is the *untranslated* name
+ @param $use_standard_values should the standard values are used
+ @returns the parsed notify-msg
+ */
+ function parse_notify($msg,$values='',$use_standard_values=True)
+ {
+ $vals = $values ? $values : array();
+
+ if ($use_standard_values && is_array($this->values))
+ {
+ $vals += $this->values;
+ }
+ foreach($vals as $key => $val)
+ {
+ $replace[] = '$$'.$key.'$$';
+ $with[] = $val;
+ }
+ return str_replace($replace,$with,$msg);
+ }
+
+ /*!
+ @function lang_notify
+ @abstract replaces the english key's with translated ones, or
if $un_lang the opposite
+ @syntax lang_notify($msg,$values='',$un_lang=False)
+ @param $msg message to translate
+ @param $values extra vars to replace in addition to
$this->values, vars are in an array with \
+ $key => $value pairs, $key does not include the $'s and
is the *untranslated* name
+ @param $un_lang if true translate back
+ @returns the result
+ */
+ function lang_notify($msg,$vals=array(),$un_lang=False)
+ {
+ foreach($vals as $key => $val)
+ {
+ $lname = ($lname = lang($key)) == $key.'*' ?
$key : $lname;
+ if ($un_lang)
+ {
+ $langs[$lname] = '$$'.$key.'$$';
+ }
+ else
+ {
+ $langs[$key] = '$$'.$lname.'$$';
+ }
+ }
+ return $this->parse_notify($msg,$langs,False);
+ }
+
+ /*!
+ @function standard_substitues
+ @abstract define some standard substitues-values and use them
on the prefs, if needed
+ */
+ function standard_substitutes()
+ {
+ if
(!is_array($GLOBALS['phpgw_info']['user']['preferences']))
+ {
+ $GLOBALS['phpgw_info']['user']['preferences'] =
$this->data; // else no lang()
+ }
+ // we cant use phpgw_info/user/fullname, as it's not
set when we run
+
$GLOBALS['phpgw']->accounts->get_account_name($this->account_id,$lid,$fname,$lname);
+
+ $this->values = array( // standard notify replacements
+ 'username' => $fname.' '.$lname,
+ 'firstname' => $fname,
+ 'lastname' => $lname,
+ 'maildomain'=>
$GLOBALS['phpgw_info']['server']['mail_suffix'],
+ 'email' =>
$this->email_address($this->account_id),
+ 'date' =>
$GLOBALS['phpgw']->common->show_date('',$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']),
+ );
+ $this->vars = array( // langs have to be in common
!!!
+ 'username' => lang('name of the user, eg.
"%1"',$this->values['username']),
+ 'firstname' => lang('first name of the user,
eg. "%1"',$this->values['firstname']),
+ 'lastname' => lang('last name of the user, eg.
"%1"',$this->values['lastname']),
+ 'maildomain'=> lang('mail domain, eg.
"%1"',$this->values['maildomain']),
+ 'email' => lang('email-address of the user,
eg. "%1"',$this->values['email']),
+ 'date' => lang('todays date, eg.
"%1"',$this->values['date']),
+ );
+ // do this first, as it might be already contain some
substitues
+ //
+ $this->values['email'] =
$this->parse_notify($this->values['email']);
+
+ // do the substituetion in the effective prefs (data)
+ //
+ foreach($this->data as $app => $data)
+ {
+ foreach($data as $key => $val)
+ {
+ if (!is_array($val) &&
strstr($val,'$$') !== False)
+ {
+ $this->data[$app][$key] =
$this->parse_notify($val);
+ }
+ elseif (is_array($val))
+ {
+ foreach($val as $k => $v)
+ {
+ if (!is_array($v) &&
strstr($val,'$$') !== False)
+ {
+
$this->data[$app][$key][$k] = $this->parse_notify($v);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /*!
@function unquote
@abstract unquote (stripslashes) recursivly the whole array
***************
*** 117,153 ****
if (!is_array($value))
{
! $value = array();
}
switch($this->db->f('preference_owner'))
{
case -1: // forced
! if (empty($app)) // db
not updated
! {
! $this->forced = $value;
! }
! else
! {
! $this->forced[$app] =
$value;
! }
break;
case -2: // default
! if (empty($app)) // db
not updated
! {
! $this->default = $value;
! }
! else
! {
! $this->default[$app] =
$value;
! }
break;
default: // user
! if (empty($app)) // db
not updated
! {
! $this->user = $value;
! }
! else
! {
! $this->user[$app] =
$value;
! }
break;
}
--- 229,244 ----
if (!is_array($value))
{
! continue;
}
switch($this->db->f('preference_owner'))
{
case -1: // forced
! $this->forced[$app] = $value;
break;
case -2: // default
! $this->default[$app] = $value;
break;
default: // user
! $this->user[$app] = $value;
break;
}
***************
*** 176,179 ****
--- 267,274 ----
}
}
+ // setup the standard substitues and substitues the
data in $this->data
+ //
+ $this->standard_substitutes();
+
// This is to supress warnings durring login
if (is_array($this->data))
***************
*** 610,615 ****
/*!
! @function sub_default_address
! @abstract Helper function for create_email_preferences, gets
default "From:" email address
@discussion This will generate the appropriate email address
used as the "From:"
email address when the user sends email, the address@hidden
part. The "personal"
--- 705,710 ----
/*!
! @function email_address
! @abstract returns the custom email-address (if set) or
generates a default one
@discussion This will generate the appropriate email address
used as the "From:"
email address when the user sends email, the address@hidden
part. The "personal"
***************
*** 617,626 ****
In the absence of a custom ['email']['address'], this function
should be used to set it.
@param $accountid - as determined in and/or passed to
"create_email_preferences"
! @access Private
*/
! function sub_default_address($account_id='')
{
! $prefs_email_address =
$GLOBALS['phpgw']->accounts->id2name($account_id)
! . '@' .
$GLOBALS['phpgw_info']['server']['mail_suffix'];
return $prefs_email_address;
}
--- 712,728 ----
In the absence of a custom ['email']['address'], this function
should be used to set it.
@param $accountid - as determined in and/or passed to
"create_email_preferences"
! @access Public now
*/
! function email_address($account_id='')
{
! if ($this->data['email']['address'])
! {
! return $this->data['email']['address'];
! }
! $prefs_email_address =
$GLOBALS['phpgw']->accounts->id2name($account_id);
! if (strstr($prefs_email_address,'@') === False)
! {
! $prefs_email_address .= '@' .
$GLOBALS['phpgw_info']['server']['mail_suffix'];
! }
return $prefs_email_address;
}
***************
*** 992,996 ****
if (!isset($prefs['email']['address']))
{
! $prefs['email']['address'] =
$this->sub_default_address($accountid);
}
// --- mail_server ---
--- 1094,1098 ----
if (!isset($prefs['email']['address']))
{
! $prefs['email']['address'] =
$this->email_address($accountid);
}
// --- mail_server ---
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: phpgwapi/inc class.preferences.inc.php,1.49,1.50,
Ralf Becker <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] CVS: preferences/setup phpgw_de.lang,1.6.2.7.2.4,1.6.2.7.2.5 phpgw_en.lang,1.7.2.9.2.4,1.7.2.9.2.5
- Next by Date:
[Phpgroupware-cvs] CVS: phpgwapi/setup phpgw_de.lang,1.34,1.35 phpgw_en.lang,1.56,1.57
- Previous by thread:
[Phpgroupware-cvs] CVS: preferences/setup phpgw_de.lang,1.6.2.7.2.4,1.6.2.7.2.5 phpgw_en.lang,1.7.2.9.2.4,1.7.2.9.2.5
- Next by thread:
[Phpgroupware-cvs] CVS: phpgwapi/setup phpgw_de.lang,1.34,1.35 phpgw_en.lang,1.56,1.57
- Index(es):