mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-20 12:58:46 +01:00
"using the global db object"
This commit is contained in:
parent
ec042e0f4d
commit
81a0b796d9
@ -1,30 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
/**************************************************************************\
|
/**
|
||||||
* eGroupWare API - Preferences *
|
* eGroupWare API - Preferences
|
||||||
* This file written by Joseph Engo <jengo@phpgroupware.org> *
|
*
|
||||||
* and Mark Peters <skeeter@phpgroupware.org> *
|
* @link http://www.egroupware.org
|
||||||
* Manages user preferences *
|
* @author Joseph Engo <jengo@phpgroupware.org>
|
||||||
* Copyright (C) 2000, 2001 Joseph Engo *
|
* @author Mark Peters <skeeter@phpgroupware.org>
|
||||||
* -------------------------------------------------------------------------*
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> merging prefs on runtime, session prefs and reworked the class
|
||||||
* This library is part of the eGroupWare API *
|
* Copyright (C) 2000, 2001 Joseph Engo
|
||||||
* http://www.egroupware.org/api *
|
* @license http://opensource.org/licenses/lgpl-license.php LGPL - GNU Lesser General Public License
|
||||||
* ------------------------------------------------------------------------ *
|
* @package api
|
||||||
* This library is free software; you can redistribute it and/or modify it *
|
* @version $Id$
|
||||||
* under the terms of the GNU Lesser General Public License as published by *
|
*/
|
||||||
* the Free Software Foundation; either version 2.1 of the License, *
|
|
||||||
* or any later version. *
|
|
||||||
* This library is distributed in the hope that it will be useful, but *
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
|
||||||
* See the GNU Lesser General Public License for more details. *
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License *
|
|
||||||
* along with this library; if not, write to the Free Software Foundation, *
|
|
||||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
|
||||||
\**************************************************************************/
|
|
||||||
|
|
||||||
/* $Id$ */
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* preferences class used for setting application preferences
|
* preferences class used for setting application preferences
|
||||||
*
|
*
|
||||||
* the prefs are read into 4 arrays:
|
* the prefs are read into 4 arrays:
|
||||||
@ -32,57 +20,56 @@
|
|||||||
* $user the stored user prefs, only used for manipulating and storeing the user prefs
|
* $user the stored user prefs, only used for manipulating and storeing the user prefs
|
||||||
* $default the default preferences, always used when the user has no own preference set
|
* $default the default preferences, always used when the user has no own preference set
|
||||||
* $forced forced preferences set by the admin, they take precedence over user or default prefs
|
* $forced forced preferences set by the admin, they take precedence over user or default prefs
|
||||||
*
|
|
||||||
* @package api
|
|
||||||
* @license LGPL
|
|
||||||
* @author Joseph Engo <jengo@phpgroupware.org>
|
|
||||||
* @author Mark Peters <skeeter@phpgroupware.org>
|
|
||||||
* @author Ralf Becker <RalfBecker@outdoor-training.de> merging prefs on runtime, session prefs and reworked the class
|
|
||||||
*/
|
*/
|
||||||
class preferences
|
class preferences
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var int $account_id account the class is instanciated for
|
* account the class is instanciated for
|
||||||
|
* @var int
|
||||||
*/
|
*/
|
||||||
var $account_id;
|
var $account_id;
|
||||||
/**
|
/**
|
||||||
* @var string $ccount_type u or g
|
* account-type u or g
|
||||||
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $account_type;
|
var $account_type;
|
||||||
/**
|
/**
|
||||||
* @var array $data effectiv user prefs, used by all apps
|
* effectiv user prefs, used by all apps
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $data = array();
|
var $data = array();
|
||||||
/**
|
/**
|
||||||
* @var array $user set user prefs for saveing (no defaults/forced prefs merged)
|
* set user prefs for saveing (no defaults/forced prefs merged)
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $user = array();
|
var $user = array();
|
||||||
/**
|
/**
|
||||||
* @var array $default default prefs
|
* default prefs
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $default = array();
|
var $default = array();
|
||||||
/**
|
/**
|
||||||
* @var array $forced forced prefs
|
* forced prefs
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $forced = array();
|
var $forced = array();
|
||||||
/**
|
/**
|
||||||
* @var array $session session / tempory prefs
|
* session / tempory prefs
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $session = array();
|
var $session = array();
|
||||||
/**
|
/**
|
||||||
* @var db
|
* @var egw_db
|
||||||
*/
|
*/
|
||||||
var $db;
|
var $db;
|
||||||
/**
|
/**
|
||||||
* @var string $table table-name
|
* table-name
|
||||||
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $table = 'egw_preferences';
|
var $table = 'egw_preferences';
|
||||||
|
|
||||||
var $values,$vars; // standard notify substitues, will be set by standard_substitues()
|
var $values,$vars; // standard notify substitues, will be set by standard_substitues()
|
||||||
|
|
||||||
/**************************************************************************\
|
|
||||||
* Standard constructor for setting $this->account_id *
|
|
||||||
\**************************************************************************/
|
|
||||||
/**
|
/**
|
||||||
* Standard constructor for setting $this->account_id
|
* Standard constructor for setting $this->account_id
|
||||||
*/
|
*/
|
||||||
@ -90,11 +77,11 @@
|
|||||||
{
|
{
|
||||||
if (is_object($GLOBALS['egw']->db))
|
if (is_object($GLOBALS['egw']->db))
|
||||||
{
|
{
|
||||||
$this->db = clone($GLOBALS['egw']->db);
|
$this->db = $GLOBALS['egw']->db;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->db = clone($GLOBALS['egw_setup']->db);
|
$this->db = $GLOBALS['egw_setup']->db;
|
||||||
$this->table = $GLOBALS['egw_setup']->prefs_table;
|
$this->table = $GLOBALS['egw_setup']->prefs_table;
|
||||||
}
|
}
|
||||||
$this->account_id = get_account_id($account_id);
|
$this->account_id = get_account_id($account_id);
|
||||||
@ -251,20 +238,19 @@
|
|||||||
{
|
{
|
||||||
$this->session = array();
|
$this->session = array();
|
||||||
}
|
}
|
||||||
$this->db->select($this->table,'*','preference_owner IN (-1,-2,'.(int) $this->account_id.')',__LINE__,__FILE__);
|
|
||||||
|
|
||||||
$this->forced = $this->default = $this->user = array();
|
$this->forced = $this->default = $this->user = array();
|
||||||
while($this->db->next_record())
|
foreach($this->db->select($this->table,'*','preference_owner IN (-1,-2,'.(int) $this->account_id.')',__LINE__,__FILE__) as $row)
|
||||||
|
|
||||||
{
|
{
|
||||||
// The following replacement is required for PostgreSQL to work
|
// The following replacement is required for PostgreSQL to work
|
||||||
$app = trim($this->db->f('preference_app'));
|
$app = trim($row['preference_app']);
|
||||||
$value = unserialize($this->db->f('preference_value'));
|
$value = unserialize($row['preference_value']);
|
||||||
$this->unquote($value);
|
$this->unquote($value);
|
||||||
if (!is_array($value))
|
if (!is_array($value))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
switch($this->db->f('preference_owner'))
|
switch($row['preference_owner'])
|
||||||
{
|
{
|
||||||
case -1: // forced
|
case -1: // forced
|
||||||
$this->forced[$app] = $value;
|
$this->forced[$app] = $value;
|
||||||
@ -1143,139 +1129,4 @@
|
|||||||
print_debug('class.preferences: create_email_preferences: LEAVING', 'messageonly','api');
|
print_debug('class.preferences: create_email_preferences: LEAVING', 'messageonly','api');
|
||||||
return $prefs;
|
return $prefs;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/*
|
|
||||||
// ==== DEPRECATED - ARCHIVAL CODE ====
|
|
||||||
// used to be part of function this->create_email_preferences()
|
|
||||||
// = = = = SIMPLER PREFS = = = =
|
|
||||||
// Default Preferences info that is:
|
|
||||||
// described in the email prefs array itself
|
|
||||||
|
|
||||||
$default_trash_folder = 'Trash';
|
|
||||||
$default_sent_folder = 'Sent';
|
|
||||||
|
|
||||||
// --- userid ---
|
|
||||||
if (!isset($prefs['email']['userid']))
|
|
||||||
{
|
|
||||||
$prefs['email']['userid'] = $this->sub_default_userid($accountid);
|
|
||||||
}
|
|
||||||
// --- address ---
|
|
||||||
if (!isset($prefs['email']['address']))
|
|
||||||
{
|
|
||||||
$prefs['email']['address'] = $this->email_address($accountid);
|
|
||||||
}
|
|
||||||
// --- mail_server ---
|
|
||||||
if (!isset($prefs['email']['mail_server']))
|
|
||||||
{
|
|
||||||
$prefs['email']['mail_server'] = $GLOBALS['egw_info']['server']['mail_server'];
|
|
||||||
}
|
|
||||||
// --- mail_server_type ---
|
|
||||||
if (!isset($prefs['email']['mail_server_type']))
|
|
||||||
{
|
|
||||||
$prefs['email']['mail_server_type'] = $GLOBALS['egw_info']['server']['mail_server_type'];
|
|
||||||
}
|
|
||||||
// --- imap_server_type ---
|
|
||||||
if (!isset($prefs['email']['imap_server_type']))
|
|
||||||
{
|
|
||||||
$prefs['email']['imap_server_type'] = $GLOBALS['egw_info']['server']['imap_server_type'];
|
|
||||||
}
|
|
||||||
// --- mail_folder ---
|
|
||||||
// because of the way this option works, an empty string IS ACTUALLY a valid value
|
|
||||||
// which represents the $HOME/* as the UWash mail files location
|
|
||||||
// THERFOR we must check the "Use_custom_setting" option to help us figure out what to do
|
|
||||||
if (!isset($prefs['email']['use_custom_settings']))
|
|
||||||
{
|
|
||||||
// we are NOT using custom settings so this MUST be the server default
|
|
||||||
$prefs['email']['mail_folder'] = $GLOBALS['egw_info']['server']['mail_folder'];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// we ARE using custom settings AND a BLANK STRING is a valid option, so...
|
|
||||||
if ((isset($prefs['email']['mail_folder']))
|
|
||||||
&& ($prefs['email']['mail_folder'] != ''))
|
|
||||||
{
|
|
||||||
// using custom AND a string exists, so "mail_folder" is that string stored in the custom prefs by the user
|
|
||||||
// DO NOTING - VALID OPTION VALUE for $prefs['email']['mail_folder']
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// using Custom Prefs BUT this text box was left empty by the user on submit, so no value stored
|
|
||||||
// BUT since we are using custom prefs, "mail_folder" MUST BE AN EMPTY STRING
|
|
||||||
// which is an acceptable, valid preference, overriding any value which
|
|
||||||
// may have been set in ["server"]["mail_folder"]
|
|
||||||
// This is one of the few instances in the preference class where an empty, unspecified value
|
|
||||||
// actually does NOT get deleted from the repository.
|
|
||||||
$prefs['email']['mail_folder'] = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- use_trash_folder ---
|
|
||||||
// --- trash_folder_name ---
|
|
||||||
// if the option to use the Trash folder is ON, make sure a proper name is specified
|
|
||||||
if (isset($prefs['email']['use_trash_folder']))
|
|
||||||
{
|
|
||||||
if ((!isset($prefs['email']['trash_folder_name']))
|
|
||||||
|| ($prefs['email']['trash_folder_name'] == ''))
|
|
||||||
{
|
|
||||||
$prefs['email']['trash_folder_name'] = $default_trash_folder;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- use_sent_folder ---
|
|
||||||
// --- sent_folder_name ---
|
|
||||||
// if the option to use the sent folder is ON, make sure a proper name is specified
|
|
||||||
if (isset($prefs['email']['use_sent_folder']))
|
|
||||||
{
|
|
||||||
if ((!isset($prefs['email']['sent_folder_name']))
|
|
||||||
|| ($prefs['email']['sent_folder_name'] == ''))
|
|
||||||
{
|
|
||||||
$prefs['email']['sent_folder_name'] = $default_sent_folder;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- layout ---
|
|
||||||
// Layout Template Preference
|
|
||||||
// layout 1 = default ; others are prefs
|
|
||||||
if (!isset($prefs['email']['layout']))
|
|
||||||
{
|
|
||||||
$prefs['email']['layout'] = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//// --- font_size_offset ---
|
|
||||||
//// Email Index Page Font Size Preference
|
|
||||||
//// layout 1 = default ; others are prefs
|
|
||||||
//if (!isset($prefs['email']['font_size_offset']))
|
|
||||||
//{
|
|
||||||
// $prefs['email']['font_size_offset'] = 'normal';
|
|
||||||
//}
|
|
||||||
|
|
||||||
// SANITY CHECK
|
|
||||||
// --- use_trash_folder ---
|
|
||||||
// --- use_sent_folder ---
|
|
||||||
// is it possible to use Trash and Sent folders - i.e. using IMAP server
|
|
||||||
// if not - force settings to false
|
|
||||||
if (stristr($prefs['email']['mail_server_type'], 'imap') == False)
|
|
||||||
{
|
|
||||||
if (isset($prefs['email']['use_trash_folder']))
|
|
||||||
{
|
|
||||||
unset($prefs['email']['use_trash_folder']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($prefs['email']['use_sent_folder']))
|
|
||||||
{
|
|
||||||
unset($prefs['email']['use_sent_folder']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DEBUG : force some settings to test stuff
|
|
||||||
//$prefs['email']['layout'] = 1;
|
|
||||||
//$prefs['email']['layout'] = 2;
|
|
||||||
//$prefs['email']['font_size_offset'] = (-1);
|
|
||||||
|
|
||||||
// DEBUG
|
|
||||||
//echo "<br>prefs['email']: <br>"
|
|
||||||
// .'<pre>'.serialize($prefs['email']) .'</pre><br>';
|
|
||||||
return $prefs;
|
|
||||||
*/
|
|
||||||
} /* end of preferences class */
|
|
||||||
?>
|
|
||||||
|
Loading…
Reference in New Issue
Block a user