*
* @return boolean Whether or not the credentials are valid.
*/
- function authenticate($userID = null, $credentials = array(),
- $login = false)
+ public function authenticate($userID = null, $credentials = array(),
+ $login = false)
{
return parent::authenticate($userID, $credentials, $login && ($this->getProvider() == 'imp'));
}
*
* @return boolean Whether or not the credentials are valid.
*/
- function _authenticate($userID, $credentials)
+ protected function _authenticate($userID, $credentials)
{
- global $imp_imap;
-
// Check for valid IMAP Client object.
- if (!$imp_imap->loadImapObject()) {
+ if (!$GLOBALS['imp_imap']->loadImapObject()) {
// Attempt to create IMAP Client object
$key = isset($credentials['server']) ? $credentials['server'] : IMP_Session::getAutoLoginServer();
if (is_null($key) ||
!isset($credentials['password']) ||
- !$imp_imap->createImapObject($userID, $credentials['password'], $key)) {
+ !$GLOBALS['imp_imap']->createImapObject($userID, $credentials['password'], $key)) {
IMP::loginLogMessage('failed', __FILE__, __LINE__);
$this->_setAuthError(AUTH_REASON_FAILED);
return false;
}
try {
- $imp_imap->ob->login();
+ $GLOBALS['imp_imap']->ob->login();
return true;
} catch (Horde_Imap_Client_Exception $e) {
- IMP::loginLogMessage('failed', __FILE__, __LINE__);
+ IMP::loginLogMessage($e->getMessage(), __FILE__, __LINE__);
$this->_setAuthError(AUTH_REASON_BADLOGIN);
return false;
}
* @author Chuck Hagenbuch <chuck@horde.org>
* @package Horde_Identity
*/
-class Identity_imp extends Identity {
-
+class Identity_imp extends Identity
+{
/**
* Cached alias list.
*
* @var array
*/
- var $_aliases = array();
+ protected $_aliases = array();
/**
* Cached from address list.
*
* @var array
*/
- var $_fromList = array();
+ protected $_fromList = array();
/**
* Cached names list.
*
* @var array
*/
- var $_names = array();
+ protected $_names = array();
/**
* Cached signature list.
*
* @var array
*/
- var $_signatures = array();
+ protected $_signatures = array();
/**
* Reads all the user's identities from the prefs object or builds
* a new identity from the standard values given in prefs.php.
*/
- function Identity_imp()
+ function __construct()
{
parent::Identity();
$this->_properties = array_merge(
$this->_properties,
array('replyto_addr', 'alias_addr', 'tieto_addr', 'bcc_addr',
'signature', 'sig_first', 'sig_dashes', 'save_sent_mail',
- 'sent_mail_folder'));
+ 'sent_mail_folder')
+ );
}
/**
* @return boolean|object True if the properties are valid or a PEAR_Error
* with an error description otherwise.
*/
- function verify($identity = null)
+ public function verify($identity = null)
{
if (is_a($result = parent::verify($identity), 'PEAR_Error')) {
return $result;
* @return string A full From: header in the format
* 'Fullname <user@example.com>'.
*/
- function getFromLine($ident = null, $from_address = '')
+ public function getFromLine($ident = null, $from_address = '')
{
static $froms = array();
*
* @return array The From: headers from all identities
*/
- function getAllFromLines()
+ public function getAllFromLines()
{
foreach (array_keys($this->_identities) as $ident) {
$list[$ident] = $this->getFromAddress($ident);
*
* @return array The array with the necessary strings
*/
- function getSelectList()
+ public function getSelectList()
{
$ids = $this->getAll('id');
foreach ($ids as $key => $id) {
*
* @return boolean True if the address was found.
*/
- function hasAddress($address)
+ public function hasAddress($address)
{
static $list;
*
* @return string A valid from address.
*/
- function getFromAddress($ident = null)
+ public function getFromAddress($ident = null)
{
if (!empty($this->_fromList[$ident])) {
return $this->_fromList[$ident];
*
* @return array Aliases for the identity.
*/
- function getAliasAddress($ident)
+ public function getAliasAddress($ident)
{
if (empty($this->_aliases[$ident])) {
$this->_aliases[$ident] = @array_merge($this->getValue('alias_addr', $ident),
* KEY - address
* VAL - identity number
*/
- function getAllFromAddresses($alias = false)
+ public function getAllFromAddresses($alias = false)
{
$list = array();
* KEY - address
* VAL - identity number
*/
- function getAllTieAddresses()
+ public function getAllTieAddresses()
{
$list = array();
* Returns the list of identities with the default identity positioned
* last.
*
- * @access private
- *
* @return array The identities list with the default identity last.
*/
- function _identitiesWithDefaultLast()
+ protected function _identitiesWithDefaultLast()
{
$ids = $this->_identities;
$default = $this->getDefault();
*
* @return array The array of objects (IMAP addresses).
*/
- function getBccAddresses($ident = null)
+ public function getBccAddresses($ident = null)
{
$bcc = $this->getValue('bcc_addr', $ident);
if (empty($bcc)) {
* addresses match (one of) the passed addresses or
* null if none matches.
*/
- function getMatchingIdentity($addresses, $search_ties = true)
+ public function getMatchingIdentity($addresses, $search_ties = true)
{
static $tie_addresses, $own_addresses;
*
* @return string The user's full name.
*/
- function getFullname($ident = null)
+ public function getFullname($ident = null)
{
if (isset($this->_names[$ident])) {
return $this->_names[$ident];
*
* @return string The full signature.
*/
- function getSignature($ident = null)
+ public function getSignature($ident = null)
{
if (isset($this->_signatures[$ident])) {
return $this->_signatures[$ident];
*
* @return array The array with all the signatures.
*/
- function getAllSignatures()
+ public function getAllSignatures()
{
static $list;
/**
* @see Identity::getValue()
*/
- function getValue($key, $identity = null)
+ public function getValue($key, $identity = null)
{
if ($key == 'sent_mail_folder') {
$folder = parent::getValue('sent_mail_folder', $identity);
*
* @return array The array with the folder names.
*/
- function getAllSentmailFolders()
+ public function getAllSentmailFolders()
{
$list = array();
foreach ($this->_identities as $key => $identity) {
*
* @return boolean True if the sent mail should be saved.
*/
- function saveSentmail($ident = null)
+ public function saveSentmail($ident = null)
{
if (!$GLOBALS['conf']['user']['allow_folders']) {
return false;
<?php
/**
+ * TODO
+ *
* Copyright 2005-2008 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* @author Michael Slusarz <slusarz@horde.org>
* @package IMP
*/
-class Imple {
-
+class Imple
+{
/**
* Parameters needed by the subclasses.
*
* @var array
*/
- var $_params = array();
+ protected $_params = array();
/**
* Attempts to return a concrete Imple instance based on $imple.
* @return mixed The newly created concrete Imple instance, or false on
* error.
*/
- function factory($imple, $params = array())
+ static public function factory($imple, $params = array())
{
$imple = basename($imple);
if (!$imple) {
*
* @param array $params Any parameters needed by the class.
*/
- function Imple($params)
+ function __construct($params)
{
$this->_params = $params;
$this->attach();
/**
* Attach the Imple object to a javascript event.
*/
- function attach()
+ public function attach()
{
Horde::addScriptFile('prototype.js', 'horde', true);
Horde::addScriptFile('effects.js', 'horde', true);
*
* @param TODO
*/
- function handle($args)
+ public function handle($args)
{
}
*
* @return string The HTML code.
*/
- function html()
+ public function html()
{
}
/**
* Generate a random ID string.
*
- * @access private
- *
* @return string The random ID string.
*/
- function _randomid()
+ protected function _randomid()
{
return 'imple_' . uniqid(mt_rand());
}
* @author Michael Slusarz <slusarz@horde.org>
* @package IMP
*/
-class Imple_ContactAutoCompleter extends Imple {
-
+class Imple_ContactAutoCompleter extends Imple
+{
/**
* The URL to use in attach().
*
* @var string
*/
- var $_url;
+ protected $_url;
/**
* Constructor.
* 'resultsId' => TODO (optional)
* </pre>
*/
- function Imple_ContactAutoCompleter($params)
+ function __construct($params)
{
if (empty($params['triggerId'])) {
$params['triggerId'] = $this->_randomid();
$params['resultsId'] = $params['triggerId'] . '_results';
}
- parent::Imple($params);
+ parent::__construct($params);
}
/**
* Attach the Imple object to a javascript event.
*/
- function attach()
+ public function attach()
{
static $list_output = false;
if (!isset($_SESSION['imp']['cache']['ac_ajax'])) {
$success = $use_ajax = true;
- require_once IMP_BASE . '/lib/Compose.php';
$sparams = IMP_Compose::getAddressSearchParams();
foreach ($sparams['fields'] as $val) {
array_map('strtolower', $val);
} else {
if (!$list_output) {
if (!isset($addrlist)) {
- require_once IMP_BASE . '/lib/Compose.php';
$addrlist = IMP_Compose::getAddressList();
}
- require_once 'Horde/Serialize.php';
IMP::addInlineScript('if (!IMP) { var IMP = {}; } IMP.ac_list = '. Horde_Serialize::serialize(array_map('htmlspecialchars', $addrlist), SERIALIZE_JSON, NLS::getCharset()));
$list_output = true;
}
*
* @return array The data to send to the autocompleter JS code.
*/
- function handle($args)
+ public function handle($args)
{
// Avoid errors if 'input' isn't set and short-circuit empty searches.
if (empty($args['input']) ||
return array();
}
- require_once IMP_BASE . '/lib/Compose.php';
return array_map('htmlspecialchars', IMP_Compose::expandAddresses($input));
}
* @author Michael Slusarz <slusarz@horde.org>
* @package IMP
*/
-class Imple_SpellChecker extends Imple {
-
+class Imple_SpellChecker extends Imple
+{
/**
* Constructor.
*
* 'triggerId' => TODO (optional)
* </pre>
*/
- function Imple_SpellChecker($params = array())
+ function __construct($params = array())
{
- require_once 'Horde/Serialize.php';
if (empty($params['id'])) {
$params['id'] = $this->_randomid();
}
asort($params['locales'], SORT_LOCALE_STRING);
$params['locales'] = Horde_Serialize::serialize($params['locales'], SERIALIZE_JSON, NLS::getCharset());
- parent::Imple($params);
+ parent::__construct($params);
}
/**
*/
- function attach()
+ public function attach()
{
parent::attach();
Horde::addScriptFile('KeyNavList.js', 'imp', true);
/**
*/
- function handle($args)
+ public function handle($args)
{
$spellArgs = array();
$spellArgs['html'] = true;
}
- require_once 'Horde/SpellChecker.php';
$speller = Horde_SpellChecker::factory(
$GLOBALS['conf']['spell']['driver'], $spellArgs);
if ($speller === false) {
* @author Jan Schneider <jan@horde.org>
* @package IMP
*/
-class IMP_Sentmail {
+class IMP_Sentmail
+{
+ /**
+ * Attempts to return a concrete IMP_Sentmail instance based on $driver.
+ *
+ * @param string $driver The type of the concrete IMP_Sentmail subclass
+ * to return. The class name is based on the
+ * storage driver ($driver). The code is
+ * dynamically included.
+ *
+ * @param array $params A hash containing any additional configuration
+ * or connection parameters a subclass might need.
+ *
+ * @return IMP_Sentmail The newly created concrete IMP_Sentmail instance.
+ */
+ static public function factory($driver = null, $params = null)
+ {
+ if (is_null($driver)) {
+ $driver = $GLOBALS['conf']['sentmail']['driver'];
+ }
+
+ if (is_null($params)) {
+ $params = Horde::getDriverConfig('sentmail', $driver);
+ }
+
+ $driver = basename($driver);
+ $class = 'IMP_Sentmail_' . $driver;
+ if (!class_exists($class)) {
+ @include dirname(__FILE__) . '/Sentmail/' . $driver . '.php';
+ }
+
+ if (class_exists($class)) {
+ $sentmail = new $class($params);
+ $result = $sentmail->initialize();
+ if (!is_a($result, 'PEAR_Error')) {
+ return $sentmail;
+ }
+ }
+
+ return new IMP_Sentmail();
+ }
/**
* Logs an attempt to send a message.
* @param string|array $recipients The list of message recipients.
* @param boolean $success Whether the attempt was successful.
*/
- function log($action, $message_id, $recipients, $success = true)
+ public function log($action, $message_id, $recipients, $success = true)
{
if (!is_array($recipients)) {
$recipients = array($recipients);
}
+
foreach ($recipients as $addresses) {
$addresses = Horde_Mime_Address::bareAddress($addresses, $_SESSION['imp']['maildomain'], true);
foreach ($addresses as $recipient) {
$this->_log($action, $message_id, $recipient, $success);
}
}
+
$this->gc();
}
* @param string $recipients A message recipient.
* @param boolean $success Whether the attempt was successful.
*/
- function _log($action, $message_id, $recipient, $success)
+ protected function _log($action, $message_id, $recipient, $success)
{
}
/**
- * Returns the most favourite recipients.
+ * Returns the favourite recipients.
*
* @param integer $limit Return this number of recipients.
* @param array $filter A list of messages types that should be returned.
*
* @return array A list with the $limit most favourite recipients.
*/
- function favouriteRecipients($limit, $filter = array('new', 'forward', 'reply', 'redirect'))
+ public function favouriteRecipients($limit,
+ $filter = array('new', 'forward', 'reply', 'redirect'))
{
return array();
}
*
* @return integer The number of recipients in the given time period.
*/
- function numberOfRecipients($hours, $user = false)
+ public function numberOfRecipients($hours, $user = false)
{
return 0;
}
/**
* Garbage collect log entries with a probability of 1%.
*/
- function gc()
+ public function gc()
{
/* A 1% chance we will run garbage collection during a call. */
if (rand(0, 99) == 0) {
* @param integer $before Unix timestamp before that all log entries
* should be deleted.
*/
- function _deleteOldEntries($before)
- {
- }
-
- /**
- * Attempts to return a concrete IMP_Sentmail instance based on $driver.
- *
- * @param string $driver The type of the concrete IMP_Sentmail subclass
- * to return. The class name is based on the
- * storage driver ($driver). The code is
- * dynamically included.
- *
- * @param array $params A hash containing any additional configuration
- * or connection parameters a subclass might need.
- *
- * @return mixed The newly created concrete IMP_Sentmail instance, or
- * false on an error.
- */
- function factory($driver = null, $params = null)
+ protected function _deleteOldEntries($before)
{
- if ($driver === null) {
- $driver = $GLOBALS['conf']['sentmail']['driver'];
- }
- if ($params === null) {
- $params = Horde::getDriverConfig('sentmail', $driver);
- }
-
- $driver = basename($driver);
- $class = 'IMP_Sentmail_' . $driver;
- if (!class_exists($class)) {
- @include dirname(__FILE__) . '/Sentmail/' . $driver . '.php';
- }
- if (class_exists($class)) {
- $sentmail = new $class($params);
- $result = $sentmail->initialize();
- if (!is_a($result, 'PEAR_Error')) {
- return $sentmail;
- }
- }
-
- return new IMP_Sentmail();
}
}
* @author Jan Schneider <jan@horde.org>
* @package IMP
*/
-class IMP_Sentmail_sql extends IMP_Sentmail {
-
+class IMP_Sentmail_sql extends IMP_Sentmail
+{
/**
* Hash containing connection parameters.
*
* @var array
*/
- var $_params = array();
+ protected $_params = array();
/**
* Handle for the current database connection.
*
* @var DB
*/
- var $_db;
+ protected $_db;
/**
* Constructor.
*
* @param array $params A hash containing connection parameters.
*/
- function IMP_Sentmail_sql($params = array())
+ function __construct($params = array())
{
$this->_params = $params;
}
* @param string $recipients A message recipient.
* @param boolean $success Whether the attempt was successful.
*/
- function _log($action, $message_id, $recipient, $success)
+ protected function _log($action, $message_id, $recipient, $success)
{
/* Build the SQL query. */
$query = sprintf('INSERT INTO %s (sentmail_id, sentmail_who, sentmail_ts, sentmail_messageid, sentmail_action, sentmail_recipient, sentmail_success) VALUES (?, ?, ?, ?, ?, ?, ?)',
*
* @return array A list with the $limit most favourite recipients.
*/
- function favouriteRecipients($limit, $filter = array('new', 'forward', 'reply', 'redirect'))
+ public function favouriteRecipients($limit,
+ $filter = array('new', 'forward', 'reply', 'redirect'))
{
/* Build the SQL query. */
$where = '';
*
* @return integer The number of recipients in the given time period.
*/
- function numberOfRecipients($hours, $user = false)
+ public function numberOfRecipients($hours, $user = false)
{
/* Build the SQL query. */
$query = sprintf('SELECT COUNT(*) FROM %s WHERE sentmail_ts > ?',
* @param integer $before Unix timestamp before that all log entries
* should be deleted.
*/
- function _deleteOldEntries($before)
+ protected function _deleteOldEntries($before)
{
/* Build the SQL query. */
$query = sprintf('DELETE FROM %s WHERE sentmail_ts < ?',
*
* @return boolean True on success, PEAR_Error on failure.
*/
- function initialize()
+ public function initialize()
{
Horde::assertDriverConfig($this->_params, 'storage',
array('phptype', 'table'));