/** * Process answer */ function processAnswer() { global $ilUser, $ilDB, $lng, $ilPluginAdmin, $ilLog; parent::processAnswer(); // // Send notifications to authors that want to be informed on blocked users // $parent_id = ilPageObject::lookupParentId((int) $_GET["page_id"], "lm"); // is restriction mode set? include_once "./Modules/LearningModule/classes/class.ilObjContentObject.php"; if (ilObjContentObject::_lookupRestrictForwardNavigation($parent_id)) { // check if user is blocked $id = ilUtil::stripSlashes($_POST["id"]); include_once "./Services/COPage/classes/class.ilPageQuestionProcessor.php"; $as = ilPageQuestionProcessor::getAnswerStatus($id, $ilUser->getId()); // get question information include_once "./Modules/TestQuestionPool/classes/class.ilAssQuestionList.php"; $qlist = new ilAssQuestionList($ilDB, $lng, $ilPluginAdmin); $qlist->setParentObjId(0); $qlist->addFieldFilter("question_id", array($id)); $qlist->load(); $qdata = $qlist->getQuestionDataArray(); // has the user been blocked? if ($as["try"] >= $qdata[$as["qst_id"]]["nr_of_tries"] && $qdata[$as["qst_id"]]["nr_of_tries"] > 0 && !$as["passed"]) { include_once "./Services/Notification/classes/class.ilNotification.php"; $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_LM_BLOCKED_USERS, $parent_id); if (count($users) > 0) { include_once "./Modules/LearningModule/classes/class.ilLMMailNotification.php"; $not = new ilLMMailNotification(); $not->setType(ilLMMailNotification::TYPE_USER_BLOCKED); $not->setQuestionId($id); $not->setRefId((int) $_GET["ref_id"]); $not->setRecipients($users); $not->send(); } } } }
/** * Send submission notifications * @param int $assignment_id */ protected function sendNotifications($assignment_id) { include_once "./Services/Notification/classes/class.ilNotification.php"; $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_EXERCISE_SUBMISSION, $this->object->getId()); include_once "./Modules/Exercise/classes/class.ilExerciseMailNotification.php"; $not = new ilExerciseMailNotification(); $not->setType(ilExerciseMailNotification::TYPE_SUBMISSION_UPLOAD); $not->setAssignmentId($assignment_id); $not->setRefId($this->ref_id); $not->setRecipients($users); $not->send(); }
static function sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, $a_comment = null) { global $ilUser, $ilObjDataCache, $ilAccess; include_once "./Services/Notification/classes/class.ilNotification.php"; include_once "./Modules/Wiki/classes/class.ilObjWiki.php"; include_once "./Modules/Wiki/classes/class.ilWikiPage.php"; $wiki_id = $ilObjDataCache->lookupObjId($a_wiki_ref_id); $wiki = new ilObjWiki($a_wiki_ref_id, true); $page = new ilWikiPage($a_page_id); // #11138 $ignore_threshold = $a_action == "comment"; // 1st update will be converted to new - see below if ($a_action == "new") { return; } if ($a_type == ilNotification::TYPE_WIKI_PAGE) { $users = ilNotification::getNotificationsForObject($a_type, $a_page_id, null, $ignore_threshold); $wiki_users = ilNotification::getNotificationsForObject(ilNotification::TYPE_WIKI, $wiki_id, $a_page_id, $ignore_threshold); $users = array_merge($users, $wiki_users); if (!sizeof($users)) { return; } ilNotification::updateNotificationTime(ilNotification::TYPE_WIKI_PAGE, $a_page_id, $users); } else { $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_WIKI, $wiki_id, $a_page_id, $ignore_threshold); if (!sizeof($users)) { return; } } ilNotification::updateNotificationTime(ilNotification::TYPE_WIKI, $wiki_id, $users, $a_page_id); // #15192 - should always be present if ($a_page_id) { include_once "./Modules/Wiki/classes/class.ilObjWikiGUI.php"; $link = ILIAS_HTTP_PATH . "/" . ilObjWikiGui::getGotoLink($a_wiki_ref_id, $page->getTitle()); } else { include_once "./Services/Link/classes/class.ilLink.php"; $link = ilLink::_getLink($a_wiki_ref_id); } include_once "./Services/Mail/classes/class.ilMail.php"; include_once "./Services/User/classes/class.ilObjUser.php"; include_once "./Services/Language/classes/class.ilLanguageFactory.php"; include_once "./Services/User/classes/class.ilUserUtil.php"; // see ilBlogPostingGUI::getSnippet() // see ilBlogPosting::getNotificationAbstract() include_once "Modules/Wiki/classes/class.ilWikiPageGUI.php"; $pgui = new ilWikiPageGUI($page->getId()); $pgui->setRawPageContent(true); $pgui->setAbstractOnly(true); $pgui->setFileDownloadLink("."); $pgui->setFullscreenLink("."); $pgui->setSourcecodeDownloadScript("."); $snippet = $pgui->showPage(); $snippet = ilPageObject::truncateHTML($snippet, 500, "..."); // making things more readable $snippet = str_replace('<br/>', "\n", $snippet); $snippet = str_replace('<br />', "\n", $snippet); $snippet = str_replace('</p>', "\n", $snippet); $snippet = str_replace('</div>', "\n", $snippet); $snippet = trim(strip_tags($snippet)); // "fake" new (to enable snippet - if any) $current_version = array_shift($page->getHistoryEntries()); $current_version = $current_version["nr"]; if (!$current_version) { $a_type = ilNotification::TYPE_WIKI; $a_action = "new"; } foreach (array_unique($users) as $idx => $user_id) { if ($user_id != $ilUser->getId() && $ilAccess->checkAccessOfUser($user_id, 'read', '', $a_wiki_ref_id)) { // use language of recipient to compose message $ulng = ilLanguageFactory::_getLanguageOfUser($user_id); $ulng->loadLanguageModule('wiki'); $subject = sprintf($ulng->txt('wiki_change_notification_subject'), $wiki->getTitle(), $page->getTitle()); $message = sprintf($ulng->txt('wiki_change_notification_salutation'), ilObjUser::_lookupFullname($user_id)) . "\n\n"; if ($a_type == ilNotification::TYPE_WIKI_PAGE) { // update/delete $message .= $ulng->txt('wiki_change_notification_page_body_' . $a_action) . ":\n\n"; $message .= $ulng->txt('wiki') . ": " . $wiki->getTitle() . "\n"; $message .= $ulng->txt('page') . ": " . $page->getTitle() . "\n"; $message .= $ulng->txt('wiki_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n"; if ($snippet) { $message .= "\n" . $ulng->txt('content') . "\n" . "----------------------------------------\n" . $snippet . "\n" . "----------------------------------------\n"; } // include comment/note text if ($a_comment) { $message .= "\n" . $ulng->txt('comment') . ":\n\"" . trim($a_comment) . "\"\n"; } $message .= "\n" . $ulng->txt('wiki_change_notification_page_link') . ": " . $link; } else { // new $message .= $ulng->txt('wiki_change_notification_body_' . $a_action) . ":\n\n"; $message .= $ulng->txt('wiki') . ": " . $wiki->getTitle() . "\n"; $message .= $ulng->txt('page') . ": " . $page->getTitle() . "\n"; $message .= $ulng->txt('wiki_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n\n"; if ($snippet) { $message .= $ulng->txt('content') . "\n" . "----------------------------------------\n" . $snippet . "\n" . "----------------------------------------\n\n"; } $message .= $ulng->txt('wiki_change_notification_link') . ": " . $link; } $mail_obj = new ilMail(ANONYMOUS_USER_ID); $mail_obj->appendInstallationSignature(true); $mail_obj->sendMail(ilObjUser::_lookupLogin($user_id), "", "", $subject, $message, array(), array("system")); } else { unset($users[$idx]); } } }
protected function sendNotifications() { global $ilUser; // recipients include_once "./Services/Notification/classes/class.ilNotification.php"; $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_POLL, $this->object->getId(), null, true); if (!sizeof($users)) { return; } include_once "./Services/Notification/classes/class.ilSystemNotification.php"; $ntf = new ilSystemNotification(); $ntf->setLangModules(array("poll")); $ntf->setRefId($this->ref_id); if ($this->object->getNonAnonymous()) { $ntf->setChangedByUserId($ilUser->getId()); } $ntf->setSubjectLangId('poll_vote_notification_subject'); $ntf->setIntroductionLangId('poll_vote_notification_body'); $ntf->setGotoLangId('poll_vote_notification_link'); $ntf->setReasonLangId('poll_vote_notification_reason'); $notified = $ntf->sendMail($users, null, "read"); ilNotification::updateNotificationTime(ilNotification::TYPE_POLL, $this->object->getId(), $notified); }
/** * @param $a_action * @param $a_table_id * @param null $a_record_id */ public static function sendNotification($a_action, $a_table_id, $a_record_id = NULL) { global $ilUser, $ilAccess; // If coming from trash, never send notifications and don't load dcl Object if ($_GET['ref_id'] == SYSTEM_FOLDER_ID) { return; } $dclObj = new ilObjDataCollection($_GET['ref_id']); if ($dclObj->getNotification() != 1) { return; } $obj_table = ilDataCollectionCache::getTableCache($a_table_id); $obj_dcl = $obj_table->getCollectionObject(); // recipients require_once './Services/Notification/classes/class.ilNotification.php'; $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_DATA_COLLECTION, $obj_dcl->getId(), true); if (!sizeof($users)) { return; } ilNotification::updateNotificationTime(ilNotification::TYPE_DATA_COLLECTION, $obj_dcl->getId(), $users); //FIXME $_GET['ref_id] require_once './Services/Link/classes/class.ilLink.php'; $link = ilLink::_getLink($_GET['ref_id']); // prepare mail content // use language of recipient to compose message require_once './Services/Language/classes/class.ilLanguageFactory.php'; // send mails require_once './Services/Mail/classes/class.ilMail.php'; require_once './Services/User/classes/class.ilObjUser.php'; require_once './Services/Language/classes/class.ilLanguageFactory.php'; require_once './Services/User/classes/class.ilUserUtil.php'; require_once './Services/User/classes/class.ilUserUtil.php'; require_once './Modules/DataCollection/classes/class.ilDataCollectionTable.php'; foreach (array_unique($users) as $idx => $user_id) { // the user responsible for the action should not be notified // FIXME $_GET['ref_id] if ($user_id != $ilUser->getId() && $ilAccess->checkAccessOfUser($user_id, 'read', '', $_GET['ref_id'])) { // use language of recipient to compose message $ulng = ilLanguageFactory::_getLanguageOfUser($user_id); $ulng->loadLanguageModule('dcl'); $subject = sprintf($ulng->txt('dcl_change_notification_subject'), $obj_dcl->getTitle()); // update/delete $message = $ulng->txt("dcl_hello") . " " . ilObjUser::_lookupFullname($user_id) . ",\n\n"; $message .= $ulng->txt('dcl_change_notification_dcl_' . $a_action) . ":\n\n"; $message .= $ulng->txt('obj_dcl') . ": " . $obj_dcl->getTitle() . "\n\n"; $message .= $ulng->txt('dcl_table') . ": " . $obj_table->getTitle() . "\n\n"; $message .= $ulng->txt('dcl_record') . ":\n"; $message .= "------------------------------------\n"; if ($a_record_id) { $record = ilDataCollectionCache::getRecordCache($a_record_id); if (!$record->getTableId()) { $record->setTableId($a_table_id); } // $message .= $ulng->txt('dcl_record_id').": ".$a_record_id.":\n"; $t = ""; foreach ($record->getTable()->getVisibleFields() as $field) { if ($record->getRecordField($field->getId())) { $t .= $field->getTitle() . ": " . $record->getRecordField($field->getId())->getPlainText() . "\n"; } } $message .= $t . "\n"; } $message .= "------------------------------------\n"; $message .= $ulng->txt('dcl_changed_by') . ": " . $ilUser->getFullname() . " " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n\n"; $message .= $ulng->txt('dcl_change_notification_link') . ": " . $link . "\n\n"; $message .= $ulng->txt('dcl_change_why_you_receive_this_email'); $mail_obj = new ilMail(ANONYMOUS_USER_ID); $mail_obj->appendInstallationSignature(true); $mail_obj->sendMail(ilObjUser::_lookupLogin($user_id), "", "", $subject, $message, array(), array("system")); } else { unset($users[$idx]); } } }
static function sendNotification($a_action, $a_in_wsp, $a_blog_node_id, $a_posting_id, $a_comment = null) { global $ilUser, $ilAccess; // get blog object id (repository or workspace) if ($a_in_wsp) { include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php"; include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php"; $tree = new ilWorkspaceTree($ilUser->getId()); // owner of tree is irrelevant $blog_obj_id = $tree->lookupObjectId($a_blog_node_id); $access_handler = new ilWorkspaceAccessHandler($tree); $link = ilWorkspaceAccessHandler::getGotoLink($a_blog_node_id, $blog_obj_id, "_" . $a_posting_id); } else { $blog_obj_id = ilObject::_lookupObjId($a_blog_node_id); $access_handler = null; include_once "Services/Link/classes/class.ilLink.php"; $link = ilLink::_getStaticLink($a_blog_node_id, "blog", true, "_" . $a_posting_id); } if (!$blog_obj_id) { return; } include_once "./Modules/Blog/classes/class.ilBlogPosting.php"; $posting = new ilBlogPosting($a_posting_id); // #11138 $ignore_threshold = $a_action == "comment"; // approval handling $admin_only = false; if (!$posting->isApproved()) { $blog = new self($blog_obj_id, false); if ($blog->hasApproval()) { switch ($a_action) { case "update": // un-approved posting was updated - no notifications return; case "new": // un-approved posting was activated - admin-only notification $admin_only = true; $ignore_threshold = true; break; } } } // recipients include_once "./Services/Notification/classes/class.ilNotification.php"; $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_BLOG, $blog_obj_id, $a_posting_id, $ignore_threshold); if (!sizeof($users)) { return; } // send mails include_once "./Services/Mail/classes/class.ilMail.php"; include_once "./Services/User/classes/class.ilObjUser.php"; include_once "./Services/Language/classes/class.ilLanguageFactory.php"; include_once "./Services/User/classes/class.ilUserUtil.php"; $posting_title = $posting->getTitle(); $blog_title = ilObject::_lookupTitle($blog_obj_id); $author = $posting->getAuthor(); $notified = array(); foreach (array_unique($users) as $idx => $user_id) { // the user responsible for the action should not be notified if ($user_id == $ilUser->getId()) { continue; } // workspace if ($access_handler) { if ($admin_only && !$access_handler->checkAccessOfUser($tree, $user_id, 'write', '', $a_blog_node_id)) { continue; } if (!$access_handler->checkAccessOfUser($tree, $user_id, 'read', '', $a_blog_node_id)) { continue; } } else { if ($admin_only && !$ilAccess->checkAccessOfUser($user_id, 'write', '', $a_blog_node_id)) { continue; } if (!$ilAccess->checkAccessOfUser($user_id, 'read', '', $a_blog_node_id)) { continue; } } // use language of recipient to compose message $ulng = ilLanguageFactory::_getLanguageOfUser($user_id); $ulng->loadLanguageModule('blog'); $subject = sprintf($ulng->txt('blog_change_notification_subject'), $blog_title); $message = sprintf($ulng->txt('blog_change_notification_salutation'), ilObjUser::_lookupFullname($user_id)) . "\n\n"; $message .= $ulng->txt('blog_change_notification_body_' . $a_action) . ":\n\n"; $message .= $ulng->txt('obj_blog') . ": " . $blog_title . "\n"; $message .= $ulng->txt('blog_posting') . ": " . $posting_title . "\n"; $message .= $ulng->txt('blog_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n"; if ($a_comment) { $message .= "\n" . $ulng->txt('comment') . ":\n\"" . trim($a_comment) . "\"\n"; } $message .= "\n" . $ulng->txt('blog_change_notification_link') . ": " . $link; $mail_obj = new ilMail(ANONYMOUS_USER_ID); $mail_obj->appendInstallationSignature(true); $mail_obj->sendMail(ilObjUser::_lookupLogin($user_id), "", "", $subject, $message, array(), array("system")); $notified[] = $user_id; } if (sizeof($notified)) { ilNotification::updateNotificationTime(ilNotification::TYPE_BLOG, $blog_obj_id, $notified); } }
static function sendNotification($a_action, $a_in_wsp, $a_blog_node_id, $a_posting_id, $a_comment = null) { global $ilUser; // get blog object id (repository or workspace) if ($a_in_wsp) { include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php"; include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php"; $tree = new ilWorkspaceTree($ilUser->getId()); // owner of tree is irrelevant $blog_obj_id = $tree->lookupObjectId($a_blog_node_id); $access_handler = new ilWorkspaceAccessHandler($tree); } else { $blog_obj_id = ilObject::_lookupObjId($a_blog_node_id); $access_handler = null; } if (!$blog_obj_id) { return; } include_once "./Modules/Blog/classes/class.ilBlogPosting.php"; $posting = new ilBlogPosting($a_posting_id); // #11138 $ignore_threshold = $a_action == "comment"; // approval handling $admin_only = false; if (!$posting->isApproved()) { $blog = new self($blog_obj_id, false); if ($blog->hasApproval()) { switch ($a_action) { case "update": // un-approved posting was updated - no notifications return; case "new": // un-approved posting was activated - admin-only notification $admin_only = true; $ignore_threshold = true; break; } } } // recipients include_once "./Services/Notification/classes/class.ilNotification.php"; $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_BLOG, $blog_obj_id, $a_posting_id, $ignore_threshold); if (!sizeof($users)) { return; } include_once "./Services/Notification/classes/class.ilSystemNotification.php"; $ntf = new ilSystemNotification($a_in_wsp); $ntf->setLangModules(array("blog")); $ntf->setRefId($a_blog_node_id); $ntf->setChangedByUserId($ilUser->getId()); $ntf->setSubjectLangId('blog_change_notification_subject'); $ntf->setIntroductionLangId('blog_change_notification_body_' . $a_action); $ntf->addAdditionalInfo('blog_posting', $posting->getTitle()); if ($a_comment) { $ntf->addAdditionalInfo('comment', $a_comment, true); } $ntf->setGotoLangId('blog_change_notification_link'); $ntf->setReasonLangId('blog_change_notification_reason'); $notified = $ntf->sendMail($users, "_" . $a_posting_id, $admin_only ? "write" : "read"); ilNotification::updateNotificationTime(ilNotification::TYPE_BLOG, $blog_obj_id, $notified); }
static function sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, $a_comment = null) { global $ilUser, $ilObjDataCache, $ilAccess; include_once "./Services/Notification/classes/class.ilNotification.php"; include_once "./Modules/Wiki/classes/class.ilObjWiki.php"; include_once "./Modules/Wiki/classes/class.ilWikiPage.php"; $wiki_id = $ilObjDataCache->lookupObjId($a_wiki_ref_id); $wiki = new ilObjWiki($a_wiki_ref_id, true); $page = new ilWikiPage($a_page_id); // #11138 $ignore_threshold = $a_action == "comment"; if ($a_type == ilNotification::TYPE_WIKI_PAGE) { $users = ilNotification::getNotificationsForObject($a_type, $a_page_id, null, $ignore_threshold); $wiki_users = ilNotification::getNotificationsForObject(ilNotification::TYPE_WIKI, $wiki_id, $a_page_id, $ignore_threshold); $users = array_merge($users, $wiki_users); if (!sizeof($users)) { return; } include_once "./Modules/Wiki/classes/class.ilObjWikiGUI.php"; $link = ILIAS_HTTP_PATH . "/" . ilObjWikiGui::getGotoLink($a_wiki_ref_id, $page->getTitle()); ilNotification::updateNotificationTime(ilNotification::TYPE_WIKI_PAGE, $a_page_id, $users); } else { $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_WIKI, $wiki_id, $a_page_id, $ignore_threshold); if (!sizeof($users)) { return; } include_once "./Services/Link/classes/class.ilLink.php"; $link = ilLink::_getLink($a_wiki_ref_id); } ilNotification::updateNotificationTime(ilNotification::TYPE_WIKI, $wiki_id, $users, $a_page_id); include_once "./Services/Mail/classes/class.ilMail.php"; include_once "./Services/User/classes/class.ilObjUser.php"; include_once "./Services/Language/classes/class.ilLanguageFactory.php"; include_once "./Services/User/classes/class.ilUserUtil.php"; foreach (array_unique($users) as $idx => $user_id) { if ($user_id != $ilUser->getId() && $ilAccess->checkAccessOfUser($user_id, 'read', '', $a_wiki_ref_id)) { // use language of recipient to compose message $ulng = ilLanguageFactory::_getLanguageOfUser($user_id); $ulng->loadLanguageModule('wiki'); $subject = sprintf($ulng->txt('wiki_change_notification_subject'), $wiki->getTitle()); $message = sprintf($ulng->txt('wiki_change_notification_salutation'), ilObjUser::_lookupFullname($user_id)) . "\n\n"; if ($a_type == ilNotification::TYPE_WIKI_PAGE) { // update/delete $message .= $ulng->txt('wiki_change_notification_page_body_' . $a_action) . ":\n\n"; $message .= $ulng->txt('wiki') . ": " . $wiki->getTitle() . "\n"; $message .= $ulng->txt('page') . ": " . $page->getTitle() . "\n"; $message .= $ulng->txt('wiki_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n"; // include comment/note text if ($a_comment) { $message .= "\n" . $ulng->txt('comment') . ":\n\"" . trim($a_comment) . "\"\n"; } $message .= "\n" . $ulng->txt('wiki_change_notification_page_link') . ": " . $link; } else { // new $message .= $ulng->txt('wiki_change_notification_body_' . $a_action) . ":\n\n"; $message .= $ulng->txt('wiki') . ": " . $wiki->getTitle() . "\n"; $message .= $ulng->txt('page') . ": " . $page->getTitle() . "\n"; $message .= $ulng->txt('wiki_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n\n"; $message .= $ulng->txt('wiki_change_notification_link') . ": " . $link; } $mail_obj = new ilMail(ANONYMOUS_USER_ID); $mail_obj->appendInstallationSignature(true); $mail_obj->sendMail(ilObjUser::_lookupLogin($user_id), "", "", $subject, $message, array(), array("system")); } else { unset($users[$idx]); } } }