ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilMailGlobalServices Class Reference

Class for global mail information (e.g. More...

+ Collaboration diagram for ilMailGlobalServices:

Static Public Member Functions

static getMailObjectRefId ()
 Determines the reference id of the mail object and stores this information in a local cache variable. More...
 
static getNumberOfNewMailsByUserId ($usr_id)
 Determines the number of new mails for the passed user id and stores this information in a local cache variable. More...
 

Data Fields

const CACHE_TYPE_REF_ID = 0
 
const CACHE_TYPE_NEW_MAILS = 1
 

Static Protected Attributes

static $global_mail_services_cache = array()
 

Detailed Description

Class for global mail information (e.g.

in main menu). This class should only contain methods for fetching data which is necessary in global parts of ILIAS, e.g. the main menu. We should keep this class as small as possible. Maybe we duplicate some code which already exists in class ilMail, but we need an efficient class.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de

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

Member Function Documentation

◆ getMailObjectRefId()

static ilMailGlobalServices::getMailObjectRefId ( )
static

Determines the reference id of the mail object and stores this information in a local cache variable.

@access public

Returns
integer The reference id of the mail object

Definition at line 52 of file class.ilMailGlobalServices.php.

53 {
54 global $ilDB;
55
56 if(isset(self::$global_mail_services_cache[self::CACHE_TYPE_REF_ID]) &&
57 null !== self::$global_mail_services_cache[self::CACHE_TYPE_REF_ID])
58 {
59 return self::$global_mail_services_cache[self::CACHE_TYPE_REF_ID];
60 }
61
62 // mail settings id is set by a constant in ilias.ini. Keep the select for some time until everyone has updated his ilias.ini
63 if(!MAIL_SETTINGS_ID)
64 {
65 $res = $ilDB->queryf('
66 SELECT object_reference.ref_id FROM object_reference, tree, object_data
67 WHERE tree.parent = %s
68 AND object_data.type = %s
69 AND object_reference.ref_id = tree.child
70 AND object_reference.obj_id = object_data.obj_id',
71 array('integer', 'text'),
72 array(SYSTEM_FOLDER_ID, 'mail'));
73
74 while($row = $ilDB->fetchAssoc($res))
75 {
76 self::$global_mail_services_cache[self::CACHE_TYPE_REF_ID] = $row['ref_id'];
77 }
78 }
79 else
80 {
81 self::$global_mail_services_cache[self::CACHE_TYPE_REF_ID] = MAIL_SETTINGS_ID;
82 }
83
84 return self::$global_mail_services_cache[self::CACHE_TYPE_REF_ID];
85 }
global $ilDB

References $ilDB, $res, $row, and CACHE_TYPE_REF_ID.

Referenced by ilAwarenessMailFeatureProvider\checkUserMailAccess(), ilUsersOnlineBlockGUI\fillRow(), ilUsersOnlineBlockGUI\getListRowData(), ilMainMenuGUI\ilMainMenuGUI(), and ilMail\readMailObjectReferenceId().

+ Here is the caller graph for this function:

◆ getNumberOfNewMailsByUserId()

static ilMailGlobalServices::getNumberOfNewMailsByUserId (   $usr_id)
static

Determines the number of new mails for the passed user id and stores this information in a local cache variable.

@access public

Returns
integer The number on unread mails (system messages + inbox mails) for the passed user id
Parameters
integerA user id of an ILIAS user account

Definition at line 97 of file class.ilMailGlobalServices.php.

98 {
99 global $ilDB;
100
101 if(!$usr_id)
102 {
103 return 0;
104 }
105
106 if(isset(self::$global_mail_services_cache[self::CACHE_TYPE_NEW_MAILS][$usr_id]) &&
107 null !== self::$global_mail_services_cache[self::CACHE_TYPE_NEW_MAILS][$usr_id])
108 {
109 return self::$global_mail_services_cache[self::CACHE_TYPE_NEW_MAILS][$usr_id];
110 }
111
112 // Read system mails
113 $res = $ilDB->queryf('
114 SELECT COUNT(mail_id) cnt FROM mail
115 WHERE folder_id = %s
116 AND user_id = %s
117 AND m_status = %s',
118 array('integer', 'integer', 'text'),
119 array('0', $usr_id, 'unread'));
120
121 $row = $ilDB->fetchAssoc($res);
122
123 $res = $ilDB->queryf('
124 SELECT COUNT(mail_id) cnt FROM mail m,mail_obj_data mo
125 WHERE m.user_id = mo.user_id
126 AND m.folder_id = mo.obj_id
127 AND mo.m_type = %s
128 AND m.user_id = %s
129 AND m.m_status = %s',
130 array('text', 'integer', 'text'),
131 array('inbox', $usr_id, 'unread'));
132
133
134 $row2 = $ilDB->fetchAssoc($res);
135
136 self::$global_mail_services_cache[self::CACHE_TYPE_NEW_MAILS][$usr_id] = $row['cnt'] + $row2['cnt'];
137
138 return self::$global_mail_services_cache[self::CACHE_TYPE_NEW_MAILS][$usr_id];
139 }

References $ilDB, $res, $row, and CACHE_TYPE_NEW_MAILS.

Referenced by ilSoapUserAdministration\hasNewMail(), and ilMainMenuGUI\renderStatusBox().

+ Here is the caller graph for this function:

Field Documentation

◆ $global_mail_services_cache

ilMailGlobalServices::$global_mail_services_cache = array()
staticprotected

Definition at line 41 of file class.ilMailGlobalServices.php.

◆ CACHE_TYPE_NEW_MAILS

const ilMailGlobalServices::CACHE_TYPE_NEW_MAILS = 1

Definition at line 30 of file class.ilMailGlobalServices.php.

Referenced by getNumberOfNewMailsByUserId().

◆ CACHE_TYPE_REF_ID

const ilMailGlobalServices::CACHE_TYPE_REF_ID = 0

Definition at line 21 of file class.ilMailGlobalServices.php.

Referenced by getMailObjectRefId().


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