ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSystemNotification Class Reference

Wrapper classes for system notifications. More...

+ Inheritance diagram for ilSystemNotification:
+ Collaboration diagram for ilSystemNotification:

Public Member Functions

 setSubjectLangId ($a_lang_id)
 Set subject lang id. More...
 
 setIntroductionLangId ($a_lang_id)
 Set introduction lang id. More...
 
 setIntroductionDirect ($a_text)
 Set introduction text. More...
 
 setTaskLangId ($a_lang_id)
 Set task lang id. More...
 
 setReasonLangId ($a_lang_id)
 Set reason lang id. More...
 
 setGotoLangId ($a_lang_id)
 Set goto lang id. More...
 
 setChangedByUserId ($a_id)
 Set changed by user id. More...
 
 addAdditionalInfo ($a_lang_id, $a_value, $a_multiline=false)
 Add additional information. More...
 
 sendMail (array $a_user_ids, $a_goto_additional=null, $a_permission="read")
 Send notification(s) More...
 
 compose ($a_user_id, $a_goto_additional=null, $a_permission="read", $a_append_signature_direct=false)
 Compose notification to single recipient. More...
 
 composeAndGetMessage ($a_user_id, $a_goto_additional=null, $a_permission="read", $a_append_signature_direct=false)
 Compose notification to single recipient. More...
 
- Public Member Functions inherited from ilMailNotification
 __construct ($a_is_personal_workspace=false)
 Constructor. More...
 
 setType ($a_type)
 Set notification type. More...
 
 getType ()
 Get notification type. More...
 
 setSender ($a_usr_id)
 Set sender of mail. More...
 
 getSender ()
 get sender of mail More...
 
 setRecipients ($a_rcp)
 set mail recipients More...
 
 getRecipients ()
 get array of recipients More...
 
 setAttachments ($a_att)
 Set attachments. More...
 
 getAttachments ()
 Get attachments. More...
 
 setLangModules (array $a_modules)
 Set lang modules. More...
 
 getUserLanguage ($a_usr_id)
 Get user language. More...
 
 setRefId ($a_id)
 Set ref id. More...
 
 getRefId ()
 get reference id More...
 
 getObjId ()
 get object id More...
 
 setObjId ($a_obj_id)
 set obj id More...
 
 getObjType ()
 Get object type. More...
 
 setAdditionalInformation ($a_info)
 Additional information for creating notification mails. More...
 
 getAdditionalInformation ()
 Get additional information for generating notification mails. More...
 
 sendMail ($a_rcp, $a_type, $a_parse_recipients=true)
 Send Mail. More...
 
 getBlockBorder ()
 Get (ascii) block border. More...
 

Protected Member Functions

 composeAndSendMail ($a_user_id, $a_goto_additional=null, $a_permission="read")
 Send notification to single recipient. More...
 
- Protected Member Functions inherited from ilMailNotification
 setSubject ($a_subject)
 Set mail subject. More...
 
 getSubject ()
 Get mail subject. More...
 
 setBody ($a_body)
 Set mail body. More...
 
 appendBody ($a_body)
 Append body text. More...
 
 getBody ()
 Get body. More...
 
 initLanguage ($a_usr_id)
 Init language. More...
 
 initLanguageByIso2Code ($a_code='')
 Init language by ISO2 code. More...
 
 setLanguage ($a_language)
 A language. More...
 
 getLanguage ()
 get language object More...
 
 getLanguageText ($a_keyword)
 Replace new lines. More...
 
 getObjectTitle ($a_shorten=false)
 Get object title. More...
 
 initMail ()
 Init mail. More...
 
 getMail ()
 Get mail object. More...
 
 createPermanentLink ($a_params=array(), $a_append='')
 Create a permanent link for an object. More...
 
 userToString ($a_usr_id)
 Utility function. More...
 
 isRefIdAccessible ($a_user_id, $a_ref_id, $a_permission="read")
 Check if ref id is accessible for user. More...
 

Protected Attributes

 $subject_lang_id
 
 $introduction
 
 $introduction_direct
 
 $task
 
 $reason
 
 $additional
 
 $goto_caption
 
 $changed_by
 
 $all_ref_ids
 
- Protected Attributes inherited from ilMailNotification
 $type = null
 
 $sender = null
 
 $mail = null
 
 $subject = ''
 
 $body = ''
 
 $attachments = array()
 
 $language = null
 
 $lang_modules = array()
 
 $recipients = array()
 
 $ref_id = null
 
 $obj_id = null
 
 $obj_type = null
 
 $additional_info = array()
 
 $is_in_wsp
 
 $wsp_tree
 
 $wsp_access_handler
 

Additional Inherited Members

- Data Fields inherited from ilMailNotification
const SUBJECT_TITLE_LENGTH = 60
 

Detailed Description

Wrapper classes for system notifications.

See also
FeatureWiki/Guidelines/System Notification Guideline
Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Id
class.ilObjExerciseGUI.php 24003 2010-05-26 14:35:42Z akill

Definition at line 16 of file class.ilSystemNotification.php.

Member Function Documentation

◆ addAdditionalInfo()

ilSystemNotification::addAdditionalInfo (   $a_lang_id,
  $a_value,
  $a_multiline = false 
)

Add additional information.

Parameters
string$a_lang_id
mixed$a_value
bool$a_multiline

Definition at line 107 of file class.ilSystemNotification.php.

108  {
109  $this->additional[$a_lang_id] = array(trim($a_value), (bool)$a_multiline);
110  }

◆ compose()

ilSystemNotification::compose (   $a_user_id,
  $a_goto_additional = null,
  $a_permission = "read",
  $a_append_signature_direct = false 
)

Compose notification to single recipient.

Parameters
mixed$a_rcp
string$a_goto_additional
string$a_permission
bool$a_append_signature_direct
Returns
bool

Definition at line 182 of file class.ilSystemNotification.php.

References ilMailNotification\$ref_id, ilMail\_getAutoGeneratedMessageString(), ilMail\_getInstallationSignature(), ilMailNotification\appendBody(), ilMailNotification\createPermanentLink(), ilMailNotification\getBlockBorder(), ilMailNotification\getLanguage(), ilMailNotification\getLanguageText(), ilMailNotification\getMail(), ilUserUtil\getNamePresentation(), ilMailNotification\getObjectTitle(), ilMailNotification\getObjId(), ilMailNotification\getObjType(), ilMailNotification\getRefId(), ilMail\getSalutation(), ilMailNotification\initLanguage(), ilMailNotification\initMail(), ilMailNotification\isRefIdAccessible(), ilMailNotification\setBody(), and ilMailNotification\setSubject().

Referenced by composeAndGetMessage(), and composeAndSendMail().

183  {
184  $this->initLanguage($a_user_id);
185  $this->initMail();
186 
187  $this->setSubject(
188  sprintf($this->getLanguageText($this->subject_lang_id), $this->getObjectTitle(true))
189  );
190 
191  $this->setBody(ilMail::getSalutation($a_user_id, $this->getLanguage()));
192  $this->appendBody("\n\n");
193 
194  if($this->introduction)
195  {
196  $this->appendBody($this->getLanguageText($this->introduction));
197  $this->appendBody("\n\n");
198  }
199 
200  if($this->introduction_direct)
201  {
202  $this->appendBody($this->introduction_direct);
203  $this->appendBody("\n\n");
204  }
205 
206  if($this->task)
207  {
208  $this->appendBody($this->getLanguageText($this->task));
209  $this->appendBody("\n\n");
210  }
211 
212  // details table
213  if($this->getObjId())
214  {
215  $this->appendBody($this->getLanguageText("obj_".$this->getObjType()).": ".
216  $this->getObjectTitle()."\n");
217  }
218  if(sizeof($this->additional))
219  {
220  foreach($this->additional as $lang_id => $item)
221  {
222  if(!$item[1])
223  {
224  $this->appendBody($this->getLanguageText($lang_id).": ".
225  $item[0]."\n");
226  }
227  else
228  {
229  $this->appendBody("\n".$this->getLanguageText($lang_id)."\n".
230  $this->getBlockBorder().
231  $item[0]."\n".
232  $this->getBlockBorder()."\n");
233  }
234  }
235  }
236  $this->body = trim($this->body);
237  $this->appendBody("\n\n");
238 
239  if($this->changed_by)
240  {
241  $this->appendBody($this->getLanguageText("system_notification_installation_changed_by").": ".
242  ilUserUtil::getNamePresentation($this->changed_by));
243  $this->appendBody("\n\n");
244  }
245 
246  if($this->getObjId())
247  {
248  // try to find accessible ref_id
249  if(!$this->getRefId() && $this->all_ref_ids)
250  {
251  $find_ref_id = true;
252  foreach($this->all_ref_ids as $ref_id)
253  {
254  if($this->isRefIdAccessible($a_user_id, $ref_id, $a_permission))
255  {
256  $this->ref_id = $ref_id;
257  break;
258  }
259  }
260  }
261 
262  // check if initially given ref_id is accessible for current recipient
263  if($this->getRefId() &&
264  !$find_ref_id &&
265  !$this->isRefIdAccessible($a_user_id, $this->getRefId(), $a_permission))
266  {
267  return false;
268  }
269 
270  $goto = $this->createPermanentLink(array(), $a_goto_additional);
271  if($goto)
272  {
273  $this->appendBody($this->getLanguageText($this->goto_caption).": ".
274  $goto);
275  $this->appendBody("\n\n");
276  }
277 
278  if($find_ref_id)
279  {
280  $this->ref_id = null;
281  }
282  }
283 
284  if($this->reason)
285  {
286  $this->appendBody($this->getLanguageText($this->reason));
287  $this->appendBody("\n\n");
288  }
289 
290  $this->appendBody(ilMail::_getAutoGeneratedMessageString($this->language));
291 
292  // signature will append new lines
293  $this->body = trim($this->body);
294 
295  if(!$a_append_signature_direct)
296  {
297  $this->getMail()->appendInstallationSignature(true);
298  }
299  else
300  {
302  }
303 
304  return true;
305  }
getLanguage()
get language object
setBody($a_body)
Set mail body.
getLanguageText($a_keyword)
Replace new lines.
initLanguage($a_usr_id)
Init language.
isRefIdAccessible($a_user_id, $a_ref_id, $a_permission="read")
Check if ref id is accessible for user.
setSubject($a_subject)
Set mail subject.
static getNamePresentation($a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true)
Default behaviour is:
getObjectTitle($a_shorten=false)
Get object title.
static getSalutation($a_usr_id, $a_language=null)
Get salutation.
getObjType()
Get object type.
getBlockBorder()
Get (ascii) block border.
createPermanentLink($a_params=array(), $a_append='')
Create a permanent link for an object.
appendBody($a_body)
Append body text.
static _getAutoGeneratedMessageString($lang=null)
get auto generated info string
static _getInstallationSignature()
Static getter for the installation signature.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ composeAndGetMessage()

ilSystemNotification::composeAndGetMessage (   $a_user_id,
  $a_goto_additional = null,
  $a_permission = "read",
  $a_append_signature_direct = false 
)

Compose notification to single recipient.

Parameters
mixed$a_user_id
string$a_goto_additional
string$a_permission
bool$a_append_signature_direct
Returns
string

Definition at line 334 of file class.ilSystemNotification.php.

References ilMailNotification\$body, and compose().

335  {
336  if($this->compose($a_user_id, $a_goto_additional, $a_permission, $a_append_signature_direct))
337  {
338  return $this->body;
339  }
340  }
compose($a_user_id, $a_goto_additional=null, $a_permission="read", $a_append_signature_direct=false)
Compose notification to single recipient.
+ Here is the call graph for this function:

◆ composeAndSendMail()

ilSystemNotification::composeAndSendMail (   $a_user_id,
  $a_goto_additional = null,
  $a_permission = "read" 
)
protected

Send notification to single recipient.

Parameters
mixed$a_rcp
string$a_goto_additional
string$a_permission
Returns
bool

Definition at line 315 of file class.ilSystemNotification.php.

References compose().

Referenced by sendMail().

316  {
317  if($this->compose($a_user_id, $a_goto_additional, $a_permission))
318  {
319  parent::sendMail(array($a_user_id), array('system'), is_numeric($a_user_id));
320  return true;
321  }
322  return false;
323  }
compose($a_user_id, $a_goto_additional=null, $a_permission="read", $a_append_signature_direct=false)
Compose notification to single recipient.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendMail()

ilSystemNotification::sendMail ( array  $a_user_ids,
  $a_goto_additional = null,
  $a_permission = "read" 
)

Send notification(s)

Parameters
array$a_user_ids
string$a_goto_additional
string$a_permission
Returns
array recipient ids

Definition at line 120 of file class.ilSystemNotification.php.

References ilObject\_getAllReferences(), composeAndSendMail(), ilMailNotification\getObjId(), and ilMailNotification\getRefId().

121  {
122  $this->all_ref_ids = null;
123 
124  // prepare object related info
125  if($this->getObjId())
126  {
127  if(!$this->getRefId())
128  {
129  // try to find ref_id(s)
130  if(!$this->is_in_wsp)
131  {
132  $ref_ids = ilObject::_getAllReferences($this->getObjId());
133  if(sizeof($ref_ids) == 1)
134  {
135  $this->ref_id = array_shift($ref_ids);
136  }
137  else
138  {
139  $this->all_ref_ids = $ref_ids;
140  }
141  }
142  }
143  else if($this->is_in_wsp) // #11680
144  {
145  $this->ref_id = $this->wsp_tree->lookupNodeId($this->getObjId());
146  }
147 
148  // default values
149  if(!$this->goto_caption)
150  {
151  $this->goto_caption = "url";
152  }
153  }
154 
155  $recipient_ids = array();
156  foreach(array_unique($a_user_ids) as $user_id)
157  {
158  // author of change should not get notification
159  if($this->changed_by == $user_id)
160  {
161  continue;
162  }
163 
164  if($this->composeAndSendMail($user_id, $a_goto_additional, $a_permission))
165  {
166  $recipient_ids[] = $user_id;
167  }
168  }
169 
170  return $recipient_ids;
171  }
static _getAllReferences($a_id)
get all reference ids of object
composeAndSendMail($a_user_id, $a_goto_additional=null, $a_permission="read")
Send notification to single recipient.
+ Here is the call graph for this function:

◆ setChangedByUserId()

ilSystemNotification::setChangedByUserId (   $a_id)

Set changed by user id.

Parameters
int$a_id

Definition at line 93 of file class.ilSystemNotification.php.

94  {
95  $this->changed_by = (int)$a_id;
96 
97  include_once "Services/User/classes/class.ilUserUtil.php";
98  }

◆ setGotoLangId()

ilSystemNotification::setGotoLangId (   $a_lang_id)

Set goto lang id.

Parameters
string$a_lang_id

Definition at line 83 of file class.ilSystemNotification.php.

84  {
85  $this->goto_caption = (string)$a_lang_id;
86  }

◆ setIntroductionDirect()

ilSystemNotification::setIntroductionDirect (   $a_text)

Set introduction text.

Parameters
string$a_text

Definition at line 53 of file class.ilSystemNotification.php.

54  {
55  $this->introduction_direct = trim($a_text);
56  }

◆ setIntroductionLangId()

ilSystemNotification::setIntroductionLangId (   $a_lang_id)

Set introduction lang id.

Parameters
string$a_lang_id

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

44  {
45  $this->introduction = (string)$a_lang_id;
46  }

◆ setReasonLangId()

ilSystemNotification::setReasonLangId (   $a_lang_id)

Set reason lang id.

Parameters
string$a_lang_id

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

74  {
75  $this->reason = (string)$a_lang_id;
76  }

◆ setSubjectLangId()

ilSystemNotification::setSubjectLangId (   $a_lang_id)

Set subject lang id.

Parameters
string$a_lang_id

Definition at line 33 of file class.ilSystemNotification.php.

34  {
35  $this->subject_lang_id = (string)$a_lang_id;
36  }

◆ setTaskLangId()

ilSystemNotification::setTaskLangId (   $a_lang_id)

Set task lang id.

Parameters
string$a_lang_id

Definition at line 63 of file class.ilSystemNotification.php.

64  {
65  $this->task = (string)$a_lang_id;
66  }

Field Documentation

◆ $additional

ilSystemNotification::$additional
protected

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

◆ $all_ref_ids

ilSystemNotification::$all_ref_ids
protected

Definition at line 26 of file class.ilSystemNotification.php.

◆ $changed_by

ilSystemNotification::$changed_by
protected

Definition at line 25 of file class.ilSystemNotification.php.

◆ $goto_caption

ilSystemNotification::$goto_caption
protected

Definition at line 24 of file class.ilSystemNotification.php.

◆ $introduction

ilSystemNotification::$introduction
protected

Definition at line 19 of file class.ilSystemNotification.php.

◆ $introduction_direct

ilSystemNotification::$introduction_direct
protected

Definition at line 20 of file class.ilSystemNotification.php.

◆ $reason

ilSystemNotification::$reason
protected

Definition at line 22 of file class.ilSystemNotification.php.

◆ $subject_lang_id

ilSystemNotification::$subject_lang_id
protected

Definition at line 18 of file class.ilSystemNotification.php.

◆ $task

ilSystemNotification::$task
protected

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


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