ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

public

Returns
integer The reference id of the mail object

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

References $DIC, $res, $row, and array.

Referenced by FormMailCodesGUI\__construct(), ilMainMenuGUI\__construct(), ilMailUserActionProvider\checkUserMailAccess(), ilPersonalSettingsGUI\executeCommand(), ilUsersOnlineBlockGUI\fillRow(), ilUsersOnlineBlockGUI\getListRowData(), ilMailLoginOrEmailAddressAddressType\isValid(), ilContactGUI\mailToUsers(), ilMailRoleAddressType\maySendToGlobalRole(), and ilMail\readMailObjectReferenceId().

53  {
54  global $DIC;
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  return self::$global_mail_services_cache[self::CACHE_TYPE_REF_ID];
59  }
60 
61  // mail settings id is set by a constant in ilias.ini. Keep the select for some time until everyone has updated his ilias.ini
62  if (!MAIL_SETTINGS_ID) {
63  $res = $DIC->database()->queryF(
64  '
65  SELECT object_reference.ref_id FROM object_reference, tree, object_data
66  WHERE tree.parent = %s
67  AND object_data.type = %s
68  AND object_reference.ref_id = tree.child
69  AND object_reference.obj_id = object_data.obj_id',
70  array('integer', 'text'),
71  array(SYSTEM_FOLDER_ID, 'mail')
72  );
73 
74  while ($row = $DIC->database()->fetchAssoc($res)) {
75  self::$global_mail_services_cache[self::CACHE_TYPE_REF_ID] = $row['ref_id'];
76  }
77  } else {
78  self::$global_mail_services_cache[self::CACHE_TYPE_REF_ID] = MAIL_SETTINGS_ID;
79  }
80 
81  return self::$global_mail_services_cache[self::CACHE_TYPE_REF_ID];
82  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
+ 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.

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 94 of file class.ilMailGlobalServices.php.

References $DIC, $res, $row, and array.

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

95  {
96  global $DIC;
97 
98  if (!$usr_id) {
99  return 0;
100  }
101 
102  if (
103  isset(self::$global_mail_services_cache[self::CACHE_TYPE_NEW_MAILS][$usr_id]) &&
104  null !== self::$global_mail_services_cache[self::CACHE_TYPE_NEW_MAILS][$usr_id]) {
105  return self::$global_mail_services_cache[self::CACHE_TYPE_NEW_MAILS][$usr_id];
106  }
107 
108  $res = $DIC->database()->queryF(
109  '
110  SELECT COUNT(mail_id) cnt FROM mail
111  WHERE folder_id = %s
112  AND user_id = %s
113  AND m_status = %s',
114  array('integer', 'integer', 'text'),
115  array('0', $usr_id, 'unread')
116  );
117 
118  $row = $DIC->database()->fetchAssoc($res);
119 
120  $res = $DIC->database()->queryF(
121  '
122  SELECT COUNT(mail_id) cnt FROM mail m,mail_obj_data mo
123  WHERE m.user_id = mo.user_id
124  AND m.folder_id = mo.obj_id
125  AND mo.m_type = %s
126  AND m.user_id = %s
127  AND m.m_status = %s',
128  array('text', 'integer', 'text'),
129  array('inbox', $usr_id, 'unread')
130  );
131 
132  $row2 = $DIC->database()->fetchAssoc($res);
133 
134  self::$global_mail_services_cache[self::CACHE_TYPE_NEW_MAILS][$usr_id] = $row['cnt'] + $row2['cnt'];
135  return self::$global_mail_services_cache[self::CACHE_TYPE_NEW_MAILS][$usr_id];
136  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
+ 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.

◆ CACHE_TYPE_REF_ID

const ilMailGlobalServices::CACHE_TYPE_REF_ID = 0

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


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