本文整理汇总了PHP中CUserHelper::parseTaggedUserNotification方法的典型用法代码示例。如果您正苦于以下问题:PHP CUserHelper::parseTaggedUserNotification方法的具体用法?PHP CUserHelper::parseTaggedUserNotification怎么用?PHP CUserHelper::parseTaggedUserNotification使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUserHelper
的用法示例。
在下文中一共展示了CUserHelper::parseTaggedUserNotification方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ajaxSaveWall
/**
* Ajax function to save a new wall entry
*
* @param message A message that is submitted by the user
* @param uniqueId The unique id for this group
*
* */
public function ajaxSaveWall($message, $uniqueId, $appId = null, $photoId = 0)
{
$filter = JFilterInput::getInstance();
$message = $filter->clean($message, 'string');
$uniqueId = $filter->clean($uniqueId, 'int');
$appId = $filter->clean($appId, 'int');
$photoId = $filter->clean($photoId, 'int');
if (!COwnerHelper::isRegisteredUser()) {
return $this->ajaxBlockUnregister();
}
$json = array();
$my = CFactory::getUser();
$config = CFactory::getConfig();
$message = strip_tags($message);
$photo = JTable::getInstance('Photo', 'CTable');
$photo->load($uniqueId);
$album = JTable::getInstance('Album', 'CTable');
$album->load($photo->albumid);
$handler = $this->_getHandler($album);
if (!$handler->isWallsAllowed($photo->id)) {
echo JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_POST_COMMENT');
return;
}
// If the content is false, the message might be empty.
if (empty($message) && $photoId == 0) {
$json['error'] = JText::_('COM_COMMUNITY_WALL_EMPTY_MESSAGE');
} else {
// @rule: Spam checks
if ($config->get('antispam_akismet_walls')) {
$filter = CSpamFilter::getFilter();
$filter->setAuthor($my->getDisplayName());
$filter->setMessage($message);
$filter->setEmail($my->email);
$filter->setURL(CRoute::_('index.php?option=com_community&view=photos&task=photo&albumid=' . $photo->albumid) . '&photoid=' . $photo->id);
$filter->setType('message');
$filter->setIP($_SERVER['REMOTE_ADDR']);
if ($filter->isSpam()) {
$json['error'] = JText::_('COM_COMMUNITY_WALLS_MARKED_SPAM');
die(json_encode($json));
}
}
$wall = CWallLibrary::saveWall($uniqueId, $message, 'photos', $my, $my->id == $photo->creator, 'photos,photo', 'wall/content', 0, $photoId);
$url = $photo->getRawPhotoURI();
$param = new CParameter('');
$param->set('photoid', $uniqueId);
$param->set('action', 'wall');
$param->set('wallid', $wall->id);
$param->set('url', $url);
// Get the album type
$app = $album->type;
// Add activity logging based on app's type
$permission = $this->_getAppPremission($app, $album);
/**
* We don't need to check for permission to create activity
* Activity will follow album privacy
* @since 3.2
*/
if ($app == 'user' || $app == 'group') {
$group = JTable::getInstance('Group', 'CTable');
$group->load($album->groupid);
$event = null;
$this->_addActivity('photos.wall.create', $my->id, 0, '', $message, 'photos.comment', $uniqueId, $group, $event, $param->toString(), $permission);
}
// Add notification
$params = new CParameter('');
$params->set('url', $photo->getRawPhotoURI());
$params->set('message', CUserHelper::replaceAliasURL($message));
$params->set('photo', JText::_('COM_COMMUNITY_SINGULAR_PHOTO'));
$params->set('photo_url', $url);
// @rule: Send notification to the photo owner.
if ($my->id !== $photo->creator) {
CNotificationLibrary::add('photos_submit_wall', $my->id, $photo->creator, JText::sprintf('COM_COMMUNITY_PHOTO_WALL_EMAIL_SUBJECT'), '', 'photos.wall', $params);
} else {
//for activity reply action
//get relevent users in the activity
$wallModel = CFactory::getModel('wall');
$users = $wallModel->getAllPostUsers('photos', $photo->id, $photo->creator);
if (!empty($users)) {
CNotificationLibrary::add('photos_reply_wall', $my->id, $users, JText::sprintf('COM_COMMUNITY_PHOTO_WALLREPLY_EMAIL_SUBJECT'), '', 'photos.wallreply', $params);
}
}
//email and add notification if user are tagged
$info = array('type' => 'image-comment', 'album_id' => $album->id, 'image_id' => $photo->id);
CUserHelper::parseTaggedUserNotification($message, CFactory::getUser($photo->creator), $wall, $info);
// Add user points
CUserPoints::assignPoint('photos.wall.create');
// Log user engagement
CEngagement::log('photo.comment', $my->id);
$json['success'] = true;
$json['html'] = $wall->content;
}
$this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES));
die(json_encode($json));
//.........这里部分代码省略.........
示例2: ajaxSaveWall
/**
* @param $message A message that is submitted by the user
* @param $uniqueId The unique id for this group
* @param int $photoId
*/
public function ajaxSaveWall($message, $uniqueId, $photoId = 0)
{
$filter = JFilterInput::getInstance();
$uniqueId = $filter->clean($uniqueId, 'int');
$photoId = $filter->clean($photoId, 'int');
if (!COwnerHelper::isRegisteredUser()) {
return $this->ajaxBlockUnregister();
}
$response = new JAXResponse();
$json = array();
$my = CFactory::getUser();
$video = JTable::getInstance('Video', 'CTable');
$video->load($uniqueId);
// If the content is false, the message might be empty.
if (empty($message) && $photoId == 0) {
$json['error'] = JText::_('COM_COMMUNITY_WALL_EMPTY_MESSAGE');
} else {
$config = CFactory::getConfig();
// @rule: Spam checks
if ($config->get('antispam_akismet_walls')) {
//CFactory::load( 'libraries' , 'spamfilter' );
$filter = CSpamFilter::getFilter();
$filter->setAuthor($my->getDisplayName());
$filter->setMessage($message);
$filter->setEmail($my->email);
$filter->setURL(CRoute::_('index.php?option=com_community&view=videos&task=video&videoid=' . $uniqueId));
$filter->setType('message');
$filter->setIP($_SERVER['REMOTE_ADDR']);
if ($filter->isSpam()) {
$json['error'] = JText::_('COM_COMMUNITY_WALLS_MARKED_SPAM');
die(json_encode($json));
}
}
//CFactory::load( 'libraries' , 'wall' );
$wall = CWallLibrary::saveWall($uniqueId, $message, 'videos', $my, $my->id == $video->creator, 'videos,video', 'wall/content', 0, $photoId);
// Add activity logging
$url = $video->getViewUri(false);
$params = new CParameter('');
$params->set('videoid', $uniqueId);
$params->set('action', 'wall');
$params->set('wallid', $wall->id);
$params->set('video_url', $url);
$act = new stdClass();
$act->cmd = 'videos.wall.create';
$act->actor = $my->id;
$act->access = $video->permissions;
$act->target = 0;
$act->title = JText::sprintf('COM_COMMUNITY_VIDEOS_ACTIVITIES_WALL_POST_VIDEO', '{video_url}', $video->title);
$act->app = 'videos.comment';
$act->cid = $uniqueId;
$act->params = $params->toString();
$act->groupid = $video->groupid;
$act->eventid = $video->eventid;
CActivityStream::add($act);
// Add notification
//CFactory::load( 'libraries' , 'notification' );
$params = new CParameter('');
$params->set('url', $url);
$params->set('message', CUserHelper::replaceAliasURL($message));
$params->set('video', $video->title);
$params->set('video_url', $url);
if ($my->id !== $video->creator) {
CNotificationLibrary::add('videos_submit_wall', $my->id, $video->creator, JText::sprintf('COM_COMMUNITY_VIDEO_WALL_EMAIL_SUBJECT'), '', 'videos.wall', $params);
} else {
//for activity reply action
//get relevent users in the activity
$wallModel = CFactory::getModel('wall');
$users = $wallModel->getAllPostUsers('videos', $video->id, $video->creator);
if (!empty($users)) {
CNotificationLibrary::add('videos_reply_wall', $my->id, $users, JText::sprintf('COM_COMMUNITY_VIDEO_WALLREPLY_EMAIL_SUBJECT'), '', 'videos.wallreply', $params);
}
}
//email and add notification if user are tagged
$info = array('type' => 'video-comment', 'video_id' => $video->id);
CUserHelper::parseTaggedUserNotification($message, CFactory::getUser($video->creator), $wall, $info);
// Add user points
CUserPoints::assignPoint('videos.comment');
//@since 4.1 we dump the info into photo stats
$statsModel = CFactory::getModel('stats');
$statsModel->addVideoStats($video->id, 'comment');
// Log user engagement
CEngagement::log('video.comment', $my->id);
$json['html'] = $wall->content;
$json['success'] = true;
}
$this->cacheClean(array(COMMUNITY_CACHE_TAG_ACTIVITIES));
die(json_encode($json));
}
示例3: ajaxStreamAddComment
//.........这里部分代码省略.........
$params->set('actor_url', CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id));
$params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
$params->set('stream_url', $url);
if ($my->id != $act->actor) {
$command = 'profile_activity_add_comment';
/* Notifications to all poster in this activity except myself */
$users = $wallModel->getAllPostUsers($act->comment_type, $act->id, $my->id);
if (!empty($users)) {
if (!in_array($act->actor, $users)) {
array_push($users, $act->actor);
}
$commenters = array_diff($users, array($act->actor));
// this will sent notification to the participant only
CNotificationLibrary::add('profile_activity_add_comment', $my->id, $commenters, JText::sprintf('COM_COMMUNITY_ACTIVITY_WALL_PARTICIPANT_EMAIL_SUBJECT'), '', 'profile.activityreply', $params);
// this will sent a notification to the poster, reason is that the title should be different
CNotificationLibrary::add('profile_activity_add_comment', $my->id, $act->actor, JText::sprintf('COM_COMMUNITY_ACITIVY_WALL_EMAIL_SUBJECT'), '', 'profile.activityreply', $params);
} else {
CNotificationLibrary::add('profile_activity_add_comment', $my->id, $act->actor, JText::sprintf('COM_COMMUNITY_ACITIVY_WALL_EMAIL_SUBJECT'), '', 'profile.activitycomment', $params);
}
} else {
//for activity reply action
//get relevent users in the activity
$users = $wallModel->getAllPostUsers($act->comment_type, $act->id, $act->actor);
if (!empty($users)) {
CNotificationLibrary::add('profile_activity_reply_comment', $my->id, $users, JText::sprintf('COM_COMMUNITY_ACITIVY_WALL_USER_REPLY_EMAIL_SUBJECT'), '', 'profile.activityreply', $params);
}
}
} elseif ($act->groupid != 0 && $act->eventid == 0) {
/* Group activity */
$params = new CParameter('');
$params->set('message', $table->comment);
$url = 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $act->groupid . '&actid=' . $actid;
$params->set('url', $url);
$params->set('actor', $my->getDisplayName());
$params->set('actor_url', CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id));
$params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
$params->set('stream_url', $url);
if ($my->id != $act->actor) {
/**
* Adds notification data into the mailq table
* @uses Make sure your provide body parameter or email content will be empty
* @param type $command
* @param null $actorId
* @param type $recipients
* @param type $subject
* @param type $body
* @param type $templateFile
* @param type $mailParams
* @param type $sendEmail
* @param type $favicon
* @param type $altSubject
* @return type
*/
CNotificationLibrary::add('groups_activity_add_comment', $my->id, $act->actor, JText::sprintf('COM_COMMUNITY_ACITIVY_WALL_GROUP_EMAIL_SUBJECT'), $table->comment, 'group.activitycomment', $params);
$users = $wallModel->getAllPostUsers($act->comment_type, $act->id, $act->actor);
} else {
//for activity reply action
//get relevent users in the activity
$users = $wallModel->getAllPostUsers($act->comment_type, $act->id, $act->actor);
if (!empty($users)) {
CNotificationLibrary::add('groups_activity_add_comment', $my->id, $users, JText::sprintf('COM_COMMUNITY_ACITIVY_WALL_USER_REPLY_EMAIL_SUBJECT'), $table->comment, 'group.activityreply', $params);
}
}
} elseif ($act->eventid != 0) {
$event = JTable::getInstance('Event', 'CTable');
$event->load($act->eventid);
$params = new CParameter('');
$params->set('message', $table->comment);
$url = 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $act->eventid . '&actid=' . $actid;
$params->set('url', $url);
$params->set('actor', $my->getDisplayName());
$params->set('actor_url', CRoute::_('index.php?option=com_community&view=profile&userid=' . $my->id));
$params->set('stream', JText::_('COM_COMMUNITY_SINGULAR_STREAM'));
$params->set('stream_url', $url);
$params->set('event', $event->title);
if ($my->id != $act->actor) {
CNotificationLibrary::add('events_submit_wall_comment', $my->id, $act->actor, JText::sprintf('COM_COMMUNITY_ACITIVY_WALL_EVENT_EMAIL_SUBJECT'), '', 'events.wallcomment', $params);
} else {
//for activity reply action
//get relevent users in the activity
$users = $wallModel->getAllPostUsers($act->comment_type, $act->id, $act->actor);
if (!empty($users)) {
CNotificationLibrary::add('events_activity_reply_comment', $my->id, $users, JText::sprintf('COM_COMMUNITY_ACITIVY_WALL_USER_REPLY_EMAIL_SUBJECT'), '', 'event.activityreply', $params);
}
}
}
//notifications
CUserHelper::parseTaggedUserNotification($rawComment, $my, $act, array('type' => 'post-comment'));
//Add tag
CTags::add($table);
// Log user engagement
CEngagement::log($act->app . '.comment', $my->id);
} else {
$json['error'] = 'Permission denied.';
}
if (!isset($json['error'])) {
$json['success'] = true;
}
die(json_encode($json));
}
示例4: ajaxSaveDiscussionWall
/**
* Ajax function to save a new wall entry
*
* @param message A message that is submitted by the user
* @param uniqueId The unique id for this group
*
* */
public function ajaxSaveDiscussionWall($message, $uniqueId, $photoId = 0)
{
$filter = JFilterInput::getInstance();
//$message = $filter->clean($message, 'string');
$uniqueId = $filter->clean($uniqueId, 'int');
if (!COwnerHelper::isRegisteredUser()) {
return $this->ajaxBlockUnregister();
}
$response = new JAXResponse();
$json = array();
$my = CFactory::getUser();
// Load models
$group = JTable::getInstance('Group', 'CTable');
$discussionModel = CFactory::getModel('Discussions');
$discussion = JTable::getInstance('Discussion', 'CTable');
//$message = strip_tags( $message );
$discussion->load($uniqueId);
$group->load($discussion->groupid);
// If the content is false, the message might be empty.
if (empty($message) && $photoId == 0) {
$json['error'] = JText::_('COM_COMMUNITY_EMPTY_MESSAGE');
die(json_encode($json));
}
$config = CFactory::getConfig();
// @rule: Spam checks
if ($config->get('antispam_akismet_walls')) {
//CFactory::load( 'libraries' , 'spamfilter' );
$filter = CSpamFilter::getFilter();
$filter->setAuthor($my->getDisplayName());
$filter->setMessage($message);
$filter->setEmail($my->email);
$filter->setURL(CRoute::_('index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $discussion->groupid . '&topicid=' . $discussion->id));
$filter->setType('message');
$filter->setIP($_SERVER['REMOTE_ADDR']);
if ($filter->isSpam()) {
$json['error'] = JText::_('COM_COMMUNITY_WALLS_MARKED_SPAM');
die(json_encode($json));
}
}
// Save the wall content
$wall = CWallLibrary::saveWall($uniqueId, $message, 'discussions', $my, $my->id == $discussion->creator, 'groups,discussion', 'wall/content', 0, $photoId);
$date = JFactory::getDate();
$discussion->lastreplied = $date->toSql();
$discussion->store();
// @rule: only add the activities of the wall if the group is not private.
//if( $group->approvals == COMMUNITY_PUBLIC_GROUP ) {
// Build the URL
$discussURL = CUrl::build('groups', 'viewdiscussion', array('groupid' => $discussion->groupid, 'topicid' => $discussion->id), true);
$act = new stdClass();
$act->cmd = 'group.discussion.reply';
$act->actor = $my->id;
$act->target = 0;
$act->title = '';
$act->content = $message;
$act->app = 'groups.discussion.reply';
$act->cid = $discussion->id;
$act->groupid = $group->id;
$act->group_access = $group->approvals;
$act->like_id = $wall->id;
$act->like_type = 'groups.discussion.reply';
$params = new CParameter('');
$params->set('action', 'group.discussion.reply');
$params->set('wallid', $wall->id);
$params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
$params->set('group_name', $group->name);
$params->set('discuss_url', 'index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $discussion->groupid . '&topicid=' . $discussion->id);
// Add activity log
CActivityStream::add($act, $params->toString());
// Get repliers for this discussion and notify the discussion creator too
$users = $discussionModel->getRepliers($discussion->id, $group->id);
$users[] = $discussion->creator;
// Make sure that each person gets only 1 email
$users = array_unique($users);
// The person who post this, should not be getting notification email
$key = array_search($my->id, $users);
if ($key !== false && isset($users[$key])) {
unset($users[$key]);
}
// Add notification
$params = new CParameter('');
$params->set('url', 'index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $discussion->groupid . '&topicid=' . $discussion->id);
$params->set('message', $message);
$params->set('title', $discussion->title);
$params->set('discussion', $discussion->title);
$params->set('discussion_url', 'index.php?option=com_community&view=groups&task=viewdiscussion&groupid=' . $discussion->groupid . '&topicid=' . $discussion->id);
CNotificationLibrary::add('groups_discussion_reply', $my->id, $users, JText::_('COM_COMMUNITY_GROUP_NEW_DISCUSSION_REPLY_SUBJECT'), '', 'groups.discussion.reply', $params);
//email and add notification if user are tagged
CUserHelper::parseTaggedUserNotification($message, $my, null, array('type' => 'discussion-comment', 'group_id' => $group->id, 'discussion_id' => $discussion->id));
//add user points
//CFactory::load( 'libraries' , 'userpoints' );
CUserPoints::assignPoint('group.discussion.reply');
$config = CFactory::getConfig();
$order = $config->get('group_discuss_order');
//.........这里部分代码省略.........