本文整理汇总了PHP中notify_user函数的典型用法代码示例。如果您正苦于以下问题:PHP notify_user函数的具体用法?PHP notify_user怎么用?PHP notify_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了notify_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: daily
/**
* Add menu items to the filter menu
*
* @param string $hook 'cron'
* @param string $type 'daily'
* @param string $return_value optional output
* @param array $params supplied params
*
* @return void
*/
public static function daily($hook, $type, $return_value, $params)
{
if (!static_out_of_date_enabled()) {
return;
}
$time = elgg_extract('time', $params, time());
$days = (int) elgg_get_plugin_setting('out_of_date_days', 'static');
$site = elgg_get_site_entity();
$options = ['type' => 'object', 'subtype' => \StaticPage::SUBTYPE, 'limit' => false, 'modified_time_upper' => $time - $days * 24 * 60 * 60, 'modified_time_lower' => $time - ($days + 1) * 24 * 60 * 60, 'order_by' => 'e.time_updated DESC'];
// ignore access
$ia = elgg_set_ignore_access(true);
$batch = new \ElggBatch('elgg_get_entities', $options);
$users = [];
foreach ($batch as $entity) {
$last_editors = $entity->getAnnotations(['annotation_name' => 'static_revision', 'limit' => 1, 'order_by' => 'n_table.time_created DESC']);
if (empty($last_editors)) {
continue;
}
$users[$last_editors[0]->getOwnerGUID()] = $last_editors[0]->getOwnerEntity();
}
// restore access
elgg_set_ignore_access($ia);
if (empty($users)) {
return;
}
foreach ($users as $user) {
$subject = elgg_echo('static:out_of_date:notification:subject');
$message = elgg_echo('static:out_of_date:notification:message', [$user->name, elgg_normalize_url('static/out_of_date/' . $user->username)]);
notify_user($user->getGUID(), $site->getGUID(), $subject, $message, [], 'email');
}
}
示例2: triggerMentionNotificationEvent
/**
* This functions performs actions when a wire post is created
*
* @param string $event 'create'
* @param string $type 'object'
* @param \ElggObject $object the ElggObject created
*
* @return void
*/
public static function triggerMentionNotificationEvent($event, $type, \ElggObject $object)
{
if (!elgg_instanceof($object, 'object', 'thewire')) {
return;
}
// @todo replace with decent Elgg 2.0 notification event handling
//send out notification to users mentioned in a wire post
$usernames = [];
preg_match_all("/\\@([A-Za-z0-9\\_\\.\\-]+)/i", $object->description, $usernames);
if (empty($usernames)) {
return;
}
$usernames = array_unique($usernames[0]);
$params = ['object' => $object, 'action' => 'mention'];
foreach ($usernames as $username) {
$username = str_ireplace('@', '', $username);
$user = get_user_by_username($username);
if (empty($user) || $user->getGUID() == $object->getOwnerGUID()) {
continue;
}
$setting = thewire_tools_get_notification_settings($user->getGUID());
if (empty($setting)) {
continue;
}
$subject = elgg_echo('thewire_tools:notify:mention:subject');
$message = elgg_echo('thewire_tools:notify:mention:message', [$user->name, $object->getOwnerEntity()->name, elgg_normalize_url("thewire/search/@{$user->username}")]);
notify_user($user->getGUID(), $object->getOwnerGUID(), $subject, $message, $params, $setting);
}
}
示例3: post
/**
* {@inheritdoc}
*/
public function post(ParameterBag $params)
{
$user = elgg_get_logged_in_user_entity();
$object = get_entity($params->guid);
if (!$object || !$object->canWriteToContainer(0, 'object', 'comment')) {
throw new GraphException("You are not allowed to comment on this object", 403);
}
$comment_text = $params->comment;
$comment = new ElggComment();
$comment->owner_guid = $user->guid;
$comment->container_guid = $object->guid;
$comment->description = $comment_text;
$comment->access_id = $object->access_id;
if (!$comment->save()) {
throw new GraphException(elgg_echo("generic_comment:failure"));
}
// Notify if poster wasn't owner
if ($object->owner_guid != $user->guid) {
$owner = $object->getOwnerEntity();
notify_user($owner->guid, $user->guid, elgg_echo('generic_comment:email:subject', array(), $owner->language), elgg_echo('generic_comment:email:body', array($object->title, $user->name, $comment->description, $comment->getURL(), $user->name, $user->getURL()), $owner->language), array('object' => $comment, 'action' => 'create'));
}
$return = array('nodes' => array('comment' => $comment));
// Add to river
$river_id = elgg_create_river_item(array('view' => 'river/object/comment/create', 'action_type' => 'comment', 'subject_guid' => $user->guid, 'object_guid' => $comment->guid, 'target_guid' => $object->guid));
if ($river_id) {
$river = elgg_get_river(array('ids' => $river_id));
$return['nodes']['activity'] = $river ? $river[0] : $river_id;
}
return $return;
}
示例4: deleteRequest
/**
* Listen to the delete of a membership request
*
* @param stirng $event the name of the event
* @param stirng $type the type of the event
* @param \ElggRelationship $relationship the relationship
*
* @return void
*/
public static function deleteRequest($event, $type, $relationship)
{
if (!$relationship instanceof \ElggRelationship) {
return;
}
if ($relationship->relationship !== 'membership_request') {
// not a membership request
return;
}
$action_pattern = '/action\\/groups\\/killrequest/i';
if (!preg_match($action_pattern, current_page_url())) {
// not in the action, so do nothing
return;
}
$group = get_entity($relationship->guid_two);
$user = get_user($relationship->guid_one);
if (empty($user) || !$group instanceof \ElggGroup) {
return;
}
if ($user->getGUID() === elgg_get_logged_in_user_guid()) {
// user kills own request
return;
}
$reason = get_input('reason');
if (empty($reason)) {
$body = elgg_echo('group_tools:notify:membership:declined:message', array($user->name, $group->name, $group->getURL()));
} else {
$body = elgg_echo('group_tools:notify:membership:declined:message:reason', array($user->name, $group->name, $reason, $group->getURL()));
}
$subject = elgg_echo('group_tools:notify:membership:declined:subject', array($group->name));
$params = array('object' => $group, 'action' => 'delete');
notify_user($user->getGUID(), $group->getGUID(), $subject, $body, $params);
}
示例5: au_landing_page_update
function au_landing_page_update($event, $type, $object)
{
if (!elgg_instanceof($object, 'page') && elgg_instanceof($object, 'page_top')) {
return true;
}
// only process this event once
if (elgg_get_config('page_update_notify_sent_' . $object->guid)) {
return true;
}
elgg_set_config('page_update_notify_sent_' . $object->guid, true);
// get revision history for the page
$revisions = $object->getAnnotations(array('annotation_name' => 'page', 'limit' => false));
// create an array of unique users to notify, excluding the current user
// and the object owner (as core notifies them)
$users = array();
foreach ($revisions as $revision) {
if ($revision->owner_guid != $object->owner_guid && $revision->owner_guid != elgg_get_logged_in_user_guid()) {
$users[] = $revision->owner_guid;
}
}
$users = array_unique($users);
// notify the users
if (count($users)) {
notify_user($users, elgg_get_logged_in_user_guid(), elgg_echo('au_landing:page:update:subject', array($object->title)), elgg_echo('au_landing:page:update:message', array($object->title, elgg_get_logged_in_user_entity()->name, $object->getURL())));
}
}
示例6: hj_forum_notify_subscribed_users
/**
* Notify subscribed users
* @param int $guid
*/
function hj_forum_notify_subscribed_users($guid)
{
$entity = get_entity($guid);
//$parentEntity = get_entity($entity->container_guid);
$subscribers = $entity->getSubscribedUsers();
$to = array();
foreach ($subscribers as $subscribed) {
$to[] = $subscribed->guid;
}
$subtype = $entity->getSubtype();
$from = elgg_get_site_entity()->guid;
$subject = elgg_echo("hj:forum:new:{$subtype}");
$subject_link = elgg_view('framework/bootstrap/user/elements/name', array('entity' => $entity->getOwnerEntity()));
$object_link = elgg_view('framework/bootstrap/object/elements/title', array('entity' => $entity));
$breadcrumbs = elgg_view('framework/bootstrap/object/elements/breadcrumbs', array('entity' => $entity));
if (!empty($breadcrumbs)) {
$breadcrumbs_link = elgg_echo('river:in:forum', array($breadcrumbs));
}
$key = "river:create:object:{$subtype}";
$summary = elgg_echo($key, array($subject_link, $object_link)) . $breadcrumbs_link;
$body = elgg_view('framework/bootstrap/object/elements/description', array('entity' => $entity));
$link = elgg_view('output/url', array('text' => elgg_echo('hj:framework:notification:link'), 'href' => $entity->getURL(), 'is_trusted' => true));
$footer = elgg_echo('hj:framework:notification:full_link', array($link));
$message = "<p>{$summary}</p><p>{$body}</p><p>{$footer}</p>";
notify_user($to, $from, $subject, $message);
}
示例7: post
/**
* {@inheritdoc}
*/
public function post(ParameterBag $params)
{
$user = elgg_get_logged_in_user_entity();
$group = get_entity($params->guid);
// join or request
$join = false;
if ($group->isPublicMembership() || $group->canEdit($user->guid)) {
// anyone can join public groups and admins can join any group
$join = true;
} else {
if (check_entity_relationship($group->guid, 'invited', $user->guid)) {
// user has invite to closed group
$join = true;
}
}
if ($join) {
if (groups_join_group($group, $user)) {
$msg = elgg_echo("groups:joined");
} else {
throw new GraphException(elgg_echo("groups:cantjoin"));
}
} else {
if (!add_entity_relationship($user->guid, 'membership_request', $group->guid)) {
throw new GraphException(elgg_echo("groups:joinrequestnotmade"));
}
$owner = $group->getOwnerEntity();
$url = elgg_normalize_url("groups/requests/{$group->guid}");
$subject = elgg_echo('groups:request:subject', array($user->name, $group->name), $owner->language);
$body = elgg_echo('groups:request:body', array($group->getOwnerEntity()->name, $user->name, $group->name, $user->getURL(), $url), $owner->language);
// Notify group owner
notify_user($owner->guid, $user->getGUID(), $subject, $body);
$msg = elgg_echo("groups:joinrequestmade");
}
return array('nodes' => array('member' => check_entity_relationship($user->guid, 'member', $group->guid), 'invited' => check_entity_relationship($group->guid, 'invited', $user->guid), 'membership_request' => check_entity_relationship($user->guid, 'membership_request', $group->guid)));
}
示例8: thewire_tools_create_object_event_handler
/**
* This functions performs actions when a wire post is created
*
* @param string $event 'create'
* @param string $type 'object'
* @param ElggObject $object the ElggObject created
*
* @return void
*/
function thewire_tools_create_object_event_handler($event, $type, ElggObject $object)
{
if (empty($object) || !elgg_instanceof($object, "object", "thewire")) {
return;
}
//send out notification to users mentioned in a wire post
$usernames = array();
preg_match_all("/\\@([A-Za-z0-9\\_\\.\\-]+)/i", $object->description, $usernames);
if (empty($usernames)) {
return;
}
$usernames = array_unique($usernames[0]);
$params = array("object" => $object, "action" => "mention");
foreach ($usernames as $username) {
$username = str_ireplace("@", "", $username);
$user = get_user_by_username($username);
if (empty($user) || $user->getGUID() == $object->getOwnerGUID()) {
continue;
}
$setting = thewire_tools_get_notification_settings($user->getGUID());
if (empty($setting)) {
continue;
}
$subject = elgg_echo("thewire_tools:notify:mention:subject");
$message = elgg_echo("thewire_tools:notify:mention:message", array($user->name, $object->getOwnerEntity()->name, elgg_normalize_url("thewire/search/@" . $user->username)));
notify_user($user->getGUID(), $object->getOwnerGUID(), $subject, $message, $params, $setting);
}
}
示例9: security_tools_usersettings_save_handler
/**
* Listen to the usersettings save hook for some notifications to the user
*
* @param string $hook usersettings:save
* @param string $type user
* @param bool $return_value not supplied for this hook
* @param null $params not supplied for this hook
*
* @return void
*/
function security_tools_usersettings_save_handler($hook, $type, $return_value, $params)
{
$user_guid = (int) get_input("guid");
if (empty($user_guid)) {
$user_guid = elgg_get_logged_in_user_guid();
}
if (empty($user_guid)) {
return $return_value;
}
$user = get_user($user_guid);
if (empty($user) || !$user->canEdit()) {
return $return_value;
}
// passwords are different
if (_elgg_set_user_password() === true) {
// do we need to notify the user about a password change
$setting = elgg_get_plugin_setting("mails_password_change", "security_tools");
if ($setting != "no") {
$site = elgg_get_site_entity();
$subject = elgg_echo("security_tools:notify_user:password:subject");
$message = elgg_echo("security_tools:notify_user:password:message", array($user->name, $site->name, $site->url));
notify_user($user->getGUID(), $site->getGUID(), $subject, $message, null, "email");
}
}
// email are also different
$setting = elgg_get_plugin_setting("mails_verify_email_change", "security_tools");
if ($setting != "no" && $user->getGUID() == elgg_get_logged_in_user_guid()) {
// verify new email address
security_tools_prepare_email_change();
} else {
// old way, or admin changes your email
_elgg_set_user_email();
}
}
示例10: membershipRequest
/**
* Notify the group admins about a membership request
*
* @param string $event create
* @param string $type membership_request
* @param \ElggRelationship $relationship the created membership request relation
*
* @return void
*/
public static function membershipRequest($event, $type, $relationship)
{
if (!$relationship instanceof \ElggRelationship) {
return;
}
if ($relationship->relationship !== 'membership_request') {
return;
}
// only send a message if group admins are allowed
if (!group_tools_multiple_admin_enabled()) {
return;
}
$user = get_user($relationship->guid_one);
$group = get_entity($relationship->guid_two);
if (empty($user) || !$group instanceof \ElggGroup) {
return;
}
// Notify group admins
$options = ['relationship' => 'group_admin', 'relationship_guid' => $group->getGUID(), 'inverse_relationship' => true, 'type' => 'user', 'limit' => false, 'wheres' => ["e.guid <> {$group->getOwnerGUID()}"]];
$url = elgg_normalize_url("groups/requests/{$group->getGUID()}");
$subject = elgg_echo('groups:request:subject', [$user->name, $group->name]);
$admins = new \ElggBatch('elgg_get_entities_from_relationship', $options);
foreach ($admins as $a) {
$body = elgg_echo('groups:request:body', [$a->name, $user->name, $group->name, $user->getURL(), $url]);
notify_user($a->getGUID(), $user->getGUID(), $subject, $body);
}
}
示例11: notifyLastEditor
/**
* Make sure the last editor of a static page gets notified about a comment
*
* @param string $event 'create'
* @param string $type 'object'
* @param \ElggObject $object the object that was just created
*
* @return void
*/
public static function notifyLastEditor($event, $type, \ElggObject $object)
{
// check of this is a comment
if (empty($object) || !elgg_instanceof($object, 'object', 'comment')) {
return;
}
// is it a comment on a static page
$container = $object->getContainerEntity();
if (empty($container) || !elgg_instanceof($container, 'object', 'static')) {
return;
}
$comment_owner = $object->getOwnerEntity();
// get last revisor
$ia = elgg_set_ignore_access(true);
$revisions = $container->getAnnotations(['annotation_name' => 'static_revision', 'limit' => 1, 'reverse_order_by' => true]);
$static_owner = $revisions[0]->getOwnerEntity();
elgg_set_ignore_access($ia);
// don't notify yourself
if ($static_owner->getGUID() == $comment_owner->getGUID()) {
return;
}
// @see actions/comment/save
$subject = elgg_echo('generic_comment:email:subject');
$message = elgg_echo('generic_comment:email:body', [$container->title, $comment_owner->name, $object->description, $container->getURL(), $comment_owner->name, $comment_owner->getURL()]);
$params = ['object' => $object, 'action' => 'create'];
notify_user($static_owner->getGUID(), $comment_owner->getGUID(), $subject, $message, $params);
}
示例12: sendUserNotifications
public function sendUserNotifications()
{
if (is_array($this->calloutUsers)) {
foreach ($this->calloutUsers as $calloutUserGuid) {
notify_user($calloutUserGuid, $this->fromUser->guid, $this->fromUser->name . " mentioned you in " . $this->context, "You have been mentioned in " . $this->context . ". View it here: " . $this->url);
}
} else {
notify_user($this->calloutUsers, $this->fromUser->guid, $this->fromUser->name . " mentioned you in " . $this->context, "You have been mentioned in " . $this->context . ". View it here: " . $this->url);
}
}
示例13: friend_collection_message_shutdown_tasks
/**
* send the message in the vroom shutdown stage
*/
function friend_collection_message_shutdown_tasks()
{
$id = elgg_get_config('friend_collection_message_id');
$recipients = elgg_get_config('friend_collection_message_recipients');
$subject = elgg_get_config('friend_collection_message_subject');
$message = elgg_get_config('friend_collection_message_message');
$members = get_members_of_access_collection($id, true);
$guids = array_intersect($recipients, $members);
notify_user($guids, elgg_get_logged_in_user_guid(), $subject, $message);
}
示例14: send_validation_reminder_mail
/**
* Send validation reminder to a specified user with
* some parameters.
*
* @param ElggUser $user User to send the reminder to
* @param int $enddate The end date in a unix timestamp
* @param int $pastdays The days we've passed since the validation
*/
function send_validation_reminder_mail($user, $enddate, $pastdays)
{
$daysleft = $enddate - $pastdays;
$site = elgg_get_site_entity();
$code = uservalidationbyemail_generate_code($user->getGUID(), $user->email);
$link = $site->url . 'uservalidationbyemail/confirm?u=' . $user->getGUID() . '&c=' . $code;
$subject = elgg_echo('validation_reminder:validate:token:subject', array($user->name, $site->name), $user->language);
$body = elgg_echo('validation_reminder:validate:token:body', array($user->name, $pastdays, $site->name, $user->token, $link, $daysleft, $site->name, $site->url), $user->language);
// Send validation email
notify_user($user->guid, $site->guid, $subject, $body, array(), 'email');
}
示例15: account_removal_send_thank_notification
/**
* Send a thank you notification after account removal
*
* @param string $type what kind of removal
* @param int $user_guid the user_guid to send the notification to
*
* @return bool
*/
function account_removal_send_thank_notification($type, $user_guid)
{
$result = false;
$site = elgg_get_site_entity();
if (!empty($user_guid) && ($user = get_user($user_guid)) && in_array($type, array("remove", "disable"))) {
$subject = elgg_echo("account_removal:message:thank_you:" . $type . ":subject", array($site->name));
$message = elgg_echo("account_removal:message:thank_you:" . $type . ":body", array($user->name, $site->name));
notify_user($user_guid, $site->getGUID(), $subject, $message, null, "email");
$result = true;
}
return $result;
}