本文整理汇总了PHP中ArtefactTypeComment::get_watchlist_users方法的典型用法代码示例。如果您正苦于以下问题:PHP ArtefactTypeComment::get_watchlist_users方法的具体用法?PHP ArtefactTypeComment::get_watchlist_users怎么用?PHP ArtefactTypeComment::get_watchlist_users使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArtefactTypeComment
的用法示例。
在下文中一共展示了ArtefactTypeComment::get_watchlist_users方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param array $data Parameters:
* - viewid (int)
* - commentid (int)
*/
public function __construct($data, $cron = false)
{
parent::__construct($data, $cron);
$comment = new ArtefactTypeComment($this->commentid);
$this->overridemessagecontents = true;
if ($onartefact = $comment->get('onartefact')) {
// feedback on artefact
$userid = null;
require_once get_config('docroot') . 'artefact/lib.php';
$artefactinstance = artefact_instance_from_id($onartefact);
if ($artefactinstance->feedback_notify_owner()) {
$userid = $artefactinstance->get('owner');
$groupid = $artefactinstance->get('group');
$institutionid = $artefactinstance->get('institution');
}
if (empty($this->url)) {
$this->url = 'artefact/artefact.php?artefact=' . $onartefact . '&view=' . $this->viewid;
}
} else {
// feedback on view.
$onview = $comment->get('onview');
if (!($viewrecord = get_record('view', 'id', $onview))) {
throw new ViewNotFoundException(get_string('viewnotfound', 'error', $onview));
}
$userid = $viewrecord->owner;
$groupid = $viewrecord->group;
$institutionid = $viewrecord->institution;
if (empty($this->url)) {
$this->url = 'view/view.php?id=' . $onview;
}
}
// Now fetch the users that will need to get notified about this event
// depending on whether the page has an owner, group, or institution id set.
$this->users = array();
if (!empty($userid)) {
$this->users = activity_get_users($this->get_id(), array($userid));
} else {
if (!empty($groupid)) {
require_once get_config('docroot') . 'lib/group.php';
$this->users = get_records_sql_assoc("SELECT u.id, u.username, u.firstname, u.lastname, u.preferredname, u.email\n from {usr} u, {group_member} m, {group} g\n WHERE g.id = m.group AND m.member = u.id AND m.group = ?\n AND (g.feedbacknotify = " . GROUP_ROLES_ALL . "\n OR (g.feedbacknotify = " . GROUP_ROLES_NONMEMBER . " AND (m.role = 'tutor' OR m.role = 'admin'))\n OR (g.feedbacknotify = " . GROUP_ROLES_ADMIN . " AND m.role = 'admin')\n )", array($groupid));
} else {
if (!empty($institutionid)) {
require_once get_config('libroot') . 'institution.php';
$institution = new Institution($institutionid);
$admins = $institution->institution_and_site_admins();
$this->users = get_records_sql_assoc("SELECT u.id, u.username, u.firstname, u.lastname, u.preferredname, u.email FROM {usr} u WHERE id IN (" . implode(',', $admins) . ")", array());
}
}
}
// Fetch the users who will be notified because this page is on their watchlist
if (!$comment->get('private')) {
$watchlistusers = $comment->get_watchlist_users($comment->get('author'));
$this->users = $this->users + $watchlistusers;
}
// If this comment is a reply, send a notification to the author of the parent comment
if ($comment->get('parent')) {
$parentauthorid = get_field('artefact', 'author', 'id', $comment->get('parent'));
if ($parentauthorid && !array_key_exists($parentauthorid, $this->users)) {
$parentauthor = get_record('usr', 'id', $parentauthorid, null, null, null, null, 'id, username, firstname, lastname, preferredname, email');
$this->users[$parentauthorid] = $parentauthor;
}
}
if (empty($this->users)) {
// no one to notify - possibe if group 'feedbacknotify' is set to 0
return;
}
$title = $onartefact ? $artefactinstance->get('title') : $viewrecord->title;
$this->urltext = $title;
$body = $comment->get('description');
$posttime = strftime(get_string('strftimedaydatetime'), $comment->get('ctime'));
// Internal
$this->message = strip_tags(str_shorten_html($body, 200, true));
// Seeing as things like emaildigest base the message on $this->message
// we need to set the language for the $removedbyline here based on first user.
$user = reset($this->users);
$lang = empty($user->lang) || $user->lang == 'default' ? get_config('lang') : $user->lang;
// Comment deleted notification
if ($deletedby = $comment->get('deletedby')) {
$this->strings = (object) array('subject' => (object) array('key' => 'commentdeletednotificationsubject', 'section' => 'artefact.comment', 'args' => array($title)));
$deletedmessage = ArtefactTypeComment::deleted_messages();
$removedbyline = get_string_from_language($lang, $deletedmessage[$deletedby], 'artefact.comment');
$this->message = $removedbyline . ":\n" . $this->message;
foreach ($this->users as $key => $user) {
if (empty($user->lang) || $user->lang == 'default') {
// check to see if we need to show institution language
$instlang = get_user_institution_language($user->id);
$lang = empty($instlang) || $instlang == 'default' ? get_config('lang') : $instlang;
} else {
$lang = $user->lang;
}
// For email we can send the message in the user's preferred language
$removedbyline = get_string_from_language($lang, $deletedmessage[$deletedby], 'artefact.comment');
$this->users[$key]->htmlmessage = get_string_from_language($lang, 'feedbackdeletedhtml', 'artefact.comment', hsc($title), $removedbyline, clean_html($body), get_config('wwwroot') . $this->url, hsc($title));
$this->users[$key]->emailmessage = get_string_from_language($lang, 'feedbackdeletedtext', 'artefact.comment', $title, $removedbyline, trim(html2text($body)), $title, get_config('wwwroot') . $this->url);
}
//.........这里部分代码省略.........