ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilLearningModuleNotification Class Reference

Class ilLearningModuleNotification class. More...

+ Collaboration diagram for ilLearningModuleNotification:

Public Member Functions

 __construct (string $a_action, int $a_type, ilObjLearningModule $a_learning_module, int $a_page_id, string $a_comment="")
 
 send ()
 

Data Fields

const ACTION_COMMENT = "comment"
 
const ACTION_UPDATE = "update"
 

Protected Member Functions

 getLink ()
 
 getPageTitle ()
 
 getMailSubject (ilLanguage $ulng)
 
 getMailBody (ilLanguage $a_ulng, int $a_user_id)
 
 getPreviewText (ilLanguage $a_ulng)
 

Protected Attributes

ilObjUser $ilUser
 
ilAccessHandler $ilAccess
 
ilLanguage $lng
 
ilSetting $lm_set
 
string $action
 
int $type
 
ilObjLearningModule $learning_module
 
int $page_id
 
string $comment
 
string $link
 
int $lm_ref_id
 
string $pg_title
 

Detailed Description

Class ilLearningModuleNotification class.

//TODO create an interface for notifications contract.(ilnotification?).Similar code in ilwikipage, ilblogposting

Author
Jesús López lopez.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 28 of file class.ilLearningModuleNotification.php.

Constructor & Destructor Documentation

◆ __construct()

ilLearningModuleNotification::__construct ( string  $a_action,
int  $a_type,
ilObjLearningModule  $a_learning_module,
int  $a_page_id,
string  $a_comment = "" 
)
Parameters
int$a_typeNotification type e.g. ilNotification::TYPE_LM_PAGE

Definition at line 49 of file class.ilLearningModuleNotification.php.

55 {
56 global $DIC;
57
58 $this->ilUser = $DIC->user();
59 $this->ilAccess = $DIC->access();
60 $this->lng = $DIC->language();
61 $this->lng->loadLanguageModule("content");
62 $this->lm_set = new ilSetting("lm");
63 $this->action = $a_action;
64 $this->type = $a_type;
65 $this->learning_module = $a_learning_module;
66 $this->page_id = $a_page_id;
67 $this->comment = $a_comment;
68 $this->lm_ref_id = $this->learning_module->getRefId();
69 $this->link = $this->getLink();
70 $this->pg_title = $this->getPageTitle();
71 }
Checks access for ILIAS objects.
ILIAS Setting Class.
link(string $caption, string $href, bool $new_viewport=false)
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\UI\examples\Symbol\Glyph\Comment\comment(), getLink(), getPageTitle(), ILIAS\Repository\link(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ getLink()

ilLearningModuleNotification::getLink ( )
protected

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

120 : string
121 {
122 // #15192 - should always be present
123 if ($this->page_id) {
124 // #18804 - see ilWikiPageGUI::preview()
125 return ilLink::_getLink(null, "pg", [], $this->page_id . "_" . $this->lm_ref_id);
126 }
127
128 return ilLink::_getLink($this->lm_ref_id);
129 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ getMailBody()

ilLearningModuleNotification::getMailBody ( ilLanguage  $a_ulng,
int  $a_user_id 
)
protected

Definition at line 153 of file class.ilLearningModuleNotification.php.

153 : string
154 {
155 $message = sprintf($a_ulng->txt('cont_change_notification_salutation'), ilObjUser::_lookupFullname($a_user_id)) . "\n\n";
156 $message .= $a_ulng->txt('cont_notification_' . $this->action . "_lm") . ":\n\n";
157 $message .= $a_ulng->txt('learning module') . ": " . $this->learning_module->getTitle() . "\n";
158 $message .= $a_ulng->txt('page') . ": " . $this->pg_title . "\n";
159 if ($this->action == self::ACTION_COMMENT) {
160 // include comment/note text
161 $message .= $a_ulng->txt('cont_commented_by') . ": " . ilUserUtil::getNamePresentation($this->ilUser->getId()) . "\n";
162 $message .= "\n" . $a_ulng->txt('comment') . ":\n\"" . trim($this->comment) . "\"\n";
163 } else {
164 $message .= $this->getPreviewText($a_ulng);
165 }
166
167 $message .= "\n" . $a_ulng->txt('url') . ": " . $this->link;
168
169 return $message;
170 }
txt(string|LanguageIdentifier $a_topic, ?int $n=null)
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _lookupFullname(int $a_user_id)
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:

References $link, $message, ilObjUser\_lookupFullname(), ILIAS\UI\examples\Symbol\Glyph\Comment\comment(), ilUserUtil\getNamePresentation(), getPreviewText(), and ilLanguage\txt().

Referenced by send().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMailSubject()

ilLearningModuleNotification::getMailSubject ( ilLanguage  $ulng)
protected

Definition at line 144 of file class.ilLearningModuleNotification.php.

144 : string
145 {
146 if ($this->action == self::ACTION_COMMENT) {
147 return sprintf($ulng->txt('cont_notification_comment_subject_lm'), $this->learning_module->getTitle(), $this->pg_title);
148 }
149
150 return sprintf($ulng->txt('cont_change_notification_subject_lm'), $this->learning_module->getTitle(), $this->pg_title);
151 }

References ilLanguage\txt().

Referenced by send().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPageTitle()

ilLearningModuleNotification::getPageTitle ( )
protected

Definition at line 131 of file class.ilLearningModuleNotification.php.

131 : string
132 {
134 $this->page_id,
135 $this->learning_module->getPageHeader(),
136 $this->learning_module->isActiveNumbering(),
137 (bool) $this->lm_set->get("time_scheduled_page_activation"),
138 false,
139 0,
140 $this->lng->getLangKey()
141 );
142 }
static _getPresentationTitle(int $a_pg_id, string $a_mode=self::CHAPTER_TITLE, bool $a_include_numbers=false, bool $a_time_scheduled_activation=false, bool $a_force_content=false, int $a_lm_id=0, string $a_lang="-", bool $a_include_short=false)
presentation title doesn't have to be page title, it may be chapter title + page title or chapter tit...

References ilLMPageObject\_getPresentationTitle().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPreviewText()

ilLearningModuleNotification::getPreviewText ( ilLanguage  $a_ulng)
protected

Definition at line 172 of file class.ilLearningModuleNotification.php.

172 : string
173 {
174 $page = new ilLMPageGUI($this->page_id);
175 $page->setRawPageContent(true);
176 $page->setAbstractOnly(true);
177 $page->setFileDownloadLink(".");
178 $page->setFullscreenLink(".");
179 $page->setSourcecodeDownloadScript(".");
180 $str = $page->showPage();
181 $str = ilPageObject::truncateHTML($str, 500, "...");
182 // making things more readable
183 $str = str_replace('<br/>', "\n", $str);
184 $str = str_replace('<br />', "\n", $str);
185 $str = str_replace('</p>', "\n", $str);
186 $str = str_replace('</div>', "\n", $str);
187 $str = trim(strip_tags($str));
188
189 $content = "\n" . $a_ulng->txt('content') . "\n" .
190 "----------------------------------------\n" .
191 $str . "\n" .
192 "----------------------------------------\n";
193
194 return $content;
195 }
Extension of ilPageObjectGUI for learning modules.
static truncateHTML(string $a_text, int $a_length=100, string $a_ending='...', bool $a_exact=false, bool $a_consider_html=true)
Truncate (html) string.

References $page, ilPageObject\truncateHTML(), and ilLanguage\txt().

Referenced by getMailBody().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send()

ilLearningModuleNotification::send ( )

Definition at line 74 of file class.ilLearningModuleNotification.php.

74 : void
75 {
76 $lm_id = $this->learning_module->getId();
77
78 // #11138 //only comment implemented so always true.
79 $ignore_threshold = ($this->action == self::ACTION_COMMENT);
80
81 $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_LM, $lm_id, null, $ignore_threshold);
82
83 if ($this->type == ilNotification::TYPE_LM_PAGE) {
84 $page_users = ilNotification::getNotificationsForObject($this->type, $this->page_id, null, $ignore_threshold);
85 $users = array_merge($users, $page_users);
87 }
88
89 if (!sizeof($users)) {
90 return;
91 }
92
94
95
96 foreach (array_unique($users) as $idx => $user_id) {
97 if ($user_id != $this->ilUser->getId() &&
98 $this->ilAccess->checkAccessOfUser($user_id, 'read', '', $this->lm_ref_id)) {
99 // use language of recipient to compose message
101 $ulng->loadLanguageModule('content');
102
103 $subject = $this->getMailSubject($ulng);
104 $message = $this->getMailBody($ulng, $user_id);
105
106 $mail_obj = new ilMail(ANONYMOUS_USER_ID);
107 $mail_obj->appendInstallationSignature(true);
108 $mail_obj->enqueue(
110 "",
111 "",
112 $subject,
113 $message,
114 MailAttachments::empty()
115 );
116 }
117 }
118 }
static _getLanguageOfUser(int $a_usr_id)
Get language object of user.
getMailBody(ilLanguage $a_ulng, int $a_user_id)
static updateNotificationTime(int $type, int $id, array $user_ids, ?int $page_id=null, bool $activate_new_entries=true)
Update the last mail timestamp for given object and users.
static getNotificationsForObject(int $type, int $id, ?int $page_id=null, bool $ignore_threshold=false)
Get all users/recipients for given object.
static _lookupLogin(int $a_user_id)
const ANONYMOUS_USER_ID
Definition: constants.php:27

References $message, $user_id, ilLanguageFactory\_getLanguageOfUser(), ilObjUser\_lookupLogin(), ACTION_COMMENT, ANONYMOUS_USER_ID, getMailBody(), getMailSubject(), ilNotification\getNotificationsForObject(), ilNotification\TYPE_LM, ilNotification\TYPE_LM_PAGE, and ilNotification\updateNotificationTime().

+ Here is the call graph for this function:

Field Documentation

◆ $action

string ilLearningModuleNotification::$action
protected

Definition at line 37 of file class.ilLearningModuleNotification.php.

◆ $comment

string ilLearningModuleNotification::$comment
protected

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

◆ $ilAccess

ilAccessHandler ilLearningModuleNotification::$ilAccess
protected

Definition at line 34 of file class.ilLearningModuleNotification.php.

◆ $ilUser

ilObjUser ilLearningModuleNotification::$ilUser
protected

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

◆ $learning_module

ilObjLearningModule ilLearningModuleNotification::$learning_module
protected

Definition at line 39 of file class.ilLearningModuleNotification.php.

◆ $link

string ilLearningModuleNotification::$link
protected

Definition at line 42 of file class.ilLearningModuleNotification.php.

Referenced by getMailBody().

◆ $lm_ref_id

int ilLearningModuleNotification::$lm_ref_id
protected

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

◆ $lm_set

ilSetting ilLearningModuleNotification::$lm_set
protected

Definition at line 36 of file class.ilLearningModuleNotification.php.

◆ $lng

ilLanguage ilLearningModuleNotification::$lng
protected

Definition at line 35 of file class.ilLearningModuleNotification.php.

◆ $page_id

int ilLearningModuleNotification::$page_id
protected

Definition at line 40 of file class.ilLearningModuleNotification.php.

◆ $pg_title

string ilLearningModuleNotification::$pg_title
protected

Definition at line 44 of file class.ilLearningModuleNotification.php.

◆ $type

int ilLearningModuleNotification::$type
protected

Definition at line 38 of file class.ilLearningModuleNotification.php.

◆ ACTION_COMMENT

const ilLearningModuleNotification::ACTION_COMMENT = "comment"

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

Referenced by send().

◆ ACTION_UPDATE

const ilLearningModuleNotification::ACTION_UPDATE = "update"

Definition at line 31 of file class.ilLearningModuleNotification.php.

Referenced by ilLMPage\afterUpdate().


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