ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilMailForm Class Reference
+ Collaboration diagram for ilMailForm:

Public Member Functions

 __construct ()
 Constructor.
 getRecipientAsync ($a_search, $a_native_search)
 Called by class ilMailFormGUI.

Private Member Functions

 addResult ($login, $firstname, $lastname, $type)
 Adds a result for mail recipient auto complete.

Private Attributes

 $allow_smtp = null
 $user_id = null
 $setMap = array()
 $result
 $max_entries = 20

Detailed Description

Author
Nadia Krzywon
Version
$Id$

Definition at line 8 of file class.ilMailForm.php.

Constructor & Destructor Documentation

ilMailForm::__construct ( )

Constructor.

public

Definition at line 23 of file class.ilMailForm.php.

{
global $ilUser, $rbacsystem;
$this->allow_smtp = $rbacsystem->checkAccess('smtp_mail', MAIL_SETTINGS_ID);
$this->user_id = $ilUser->getId();
$this->result = new stdClass();
$this->result->response = new stdClass();
$this->result->response->results = array();
}

Member Function Documentation

ilMailForm::addResult (   $login,
  $firstname,
  $lastname,
  $type 
)
private

Adds a result for mail recipient auto complete.

private

Exceptions
ilException

Definition at line 43 of file class.ilMailForm.php.

References $login.

Referenced by getRecipientAsync().

{
if(count($this->result->response->results) > $this->max_entries)
{
throw new ilException('exceeded_max_entries');
}
if (isset($this->setMap[$login]))
return;
$tmp = new stdClass();
$tmp->login = $login;
$tmp->firstname = $firstname;
$tmp->lastname = $lastname;
$this->result->response->results[] = $tmp;
$this->setMap[$login] = 1;
}

+ Here is the caller graph for this function:

ilMailForm::getRecipientAsync (   $a_search,
  $a_native_search 
)

Called by class ilMailFormGUI.

Parameters
stringsearch string surrounded with wildcards
stringnative search string
Returns
stdClass search result as an object of type stdClass public

Definition at line 73 of file class.ilMailForm.php.

References $ilDB, $query, $result, $row, $type, addResult(), ilStr\strPos(), and ilStr\strToLower().

{
global $ilDB;
"SELECT DISTINCT
abook.login login,
abook.firstname firstname,
abook.lastname lastname,
'addressbook' type
FROM addressbook abook
WHERE abook.user_id = ".$ilDB->quote($this->user_id,'integer')."
AND abook.login IS NOT NULL
AND (". $ilDB->like('abook.login', 'text', $a_search)."
OR ".$ilDB->like('abook.firstname', 'text', $a_search)."
OR ".$ilDB->like('abook.lastname', 'text', $a_search)."
)";
$union_query_1 = "SELECT DISTINCT
abook.email login,
abook.firstname firstname,
abook.lastname lastname,
'addressbook' type
FROM addressbook abook
WHERE abook.user_id = ".$ilDB->quote($this->user_id,'integer')."
AND abook.login IS NULL
AND (".$ilDB->like('abook.email', 'text', $a_search)."
OR ".$ilDB->like('abook.firstname', 'text', $a_search)."
OR ".$ilDB->like('abook.lastname', 'text', $a_search)."
)";
$union_query_2 = "SELECT DISTINCT
mail.rcp_to login,
'' firstname,
'' lastname,
'mail' type
FROM mail
WHERE ".$ilDB->like('mail.rcp_to', 'text', $a_search)."
AND sender_id = ".$ilDB->quote($this->user_id,'integer')."
AND mail.sender_id = mail.user_id";
$queries = array(
'addressbook_1' => $query,
'mail' => $union_query_2
);
if($this->allow_smtp == 1)
$queries['addressbook_2'] = $union_query_1;
include_once 'Services/Utilities/classes/class.ilStr.php';
try
{
// MySql: Join the array values for mysql to one select statement
if($ilDB->getDbType() != 'oracle')
$queries['all'] = implode(' UNION ', $queries);
foreach($queries as $type => $query)
{
// Oracle: Distincts do no work with clobs
if('mail' == $type && $ilDB->getDbType() == 'oracle')
{
$query = str_replace('DISTINCT', '', $query);
}
$ilDB->setLimit(0,20);
$query_res = $ilDB->query( $query );
while($row = $ilDB->fetchObject($query_res))
{
if($row->type == 'mail')
{
if(strpos($row->login, ',') || strpos($row->login, ';'))
{
$parts = preg_split("/[ ]*[;,][ ]*/", trim($row->login));
foreach($parts as $part)
{
if(ilStr::strPos(ilStr::strToLower($part), ilStr::strToLower($a_native_search)) !== false)
{
$this->addResult($part, '', '', 'mail');
}
}
}
else
{
$this->addResult($row->login, '', '', 'mail');
}
}
else
{
$this->addResult($row->login, $row->firstname, $row->lastname, 'addressbook');
}
}
}
} catch(ilException $e) {}
$result->response->total = count($this->result->response->results);
return $result;
}

+ Here is the call graph for this function:

Field Documentation

ilMailForm::$allow_smtp = null
private

Definition at line 10 of file class.ilMailForm.php.

ilMailForm::$max_entries = 20
private

Definition at line 14 of file class.ilMailForm.php.

ilMailForm::$result
private

Definition at line 13 of file class.ilMailForm.php.

Referenced by getRecipientAsync().

ilMailForm::$setMap = array()
private

Definition at line 12 of file class.ilMailForm.php.

ilMailForm::$user_id = null
private

Definition at line 11 of file class.ilMailForm.php.


The documentation for this class was generated from the following file: