public static function add($params = array()) { $uid = zmf::uid(); $data = array('uid' => $params['uid'], 'authorid' => $uid, 'content' => $params['content'], 'new' => 1, 'type' => $params['type'], 'cTime' => zmf::now(), 'from_id' => $params['from_id'], 'from_idtype' => $params['from_idtype'], 'from_num' => 1); if ($uid == $params['uid']) { return false; } $model = new Notification(); $info = $model->find("uid=:uid AND authorid=:authorid AND from_id=:from AND type=:type", array(':uid' => $params['uid'], ':authorid' => $uid, ':from' => $params['from_id'], ':type' => $params['type'])); if ($info) { //存在则更新最新操作时间 if ($model->updateByPk($info['id'], array('cTime' => time(), 'new' => 1, 'from_num' => $info['from_num'] + 1))) { return true; } else { return false; } } else { //不存在则新增 $model->attributes = $data; if ($model->save()) { return true; } else { return false; } } }
/** * Fires this notification * * @param type $like */ public static function fire($like) { // Determine Space Id if exists $spaceId = ""; if ($like->content->container instanceof Space) { $spaceId = $like->content->container->id; } // Determine who created the liked content / content addon $createdBy = ""; if ($like->source instanceof HActiveRecordContent) { $createdBy = $like->source->content->created_by; } elseif ($like->source instanceof HActiveRecordContentAddon) { $createdBy = $like->source->created_by; } if ($createdBy != "" && $createdBy != $like->created_by) { // Send Notification to owner $notification = new Notification(); $notification->class = "NewLikeNotification"; $notification->user_id = $createdBy; $notification->space_id = $spaceId; $notification->source_object_model = "Like"; $notification->source_object_id = $like->id; $notification->target_object_model = $like->object_model; $notification->target_object_id = $like->object_id; $notification->save(); } }
public function execute(&$params) { $options =& $this->config['options']; $notif = new Notification(); $notif->user = $this->parseOption('user', $params); $notif->createdBy = 'API'; $notif->createDate = time(); // file_put_contents('triggerLog.txt',"\n".$notif->user,FILE_APPEND); // if($this->parseOption('type',$params) == 'auto') { // if(!isset($params['model'])) // return false; // $notif->modelType = get_class($params['model']); // $notif->modelId = $params['model']->id; // $notif->type = $this->getNotifType(); // } else { $notif->type = 'custom'; $notif->text = $this->parseOption('text', $params); // } if ($notif->save()) { return array(true, ""); } else { $errors = $notif->getErrors(); return array(false, array_shift($errors)); } }
/** * Fire this notification on given comment object * * @param type $comment */ public static function fire($comment) { $targetCreatorId = $comment->content->user_id; // gets also an new comment notification // Get Users which are also commented this model $userIds = array(); $otherComments = Comment::model()->findAllByAttributes(array('object_model' => $comment->object_model, 'object_id' => $comment->object_id)); foreach ($otherComments as $otherComment) { if ($comment->created_by != $otherComment->created_by && $otherComment->created_by != $targetCreatorId) { $userIds[] = $otherComment->created_by; } } $userIds = array_unique($userIds); // Write new Notification for them foreach ($userIds as $userId) { $notification = new Notification(); $notification->class = "AlsoCommentedNotification"; $notification->user_id = $userId; $notification->space_id = $comment->space_id; $notification->source_object_model = "Comment"; $notification->source_object_id = $comment->id; $notification->target_object_model = $comment->object_model; $notification->target_object_id = $comment->object_id; $notification->save(); } }
public function save() { $message = "NEW " . strtolower(get_parent_class($this)) . " saved!"; $type = parent::__get('resource_type'); $notification = new Notification($message, $type); return $notification->save(); }
public static function createForUserRecord(User $user, PathRecord $record) { $notify = new Notification(); $notify->user_id = $user->id; $notify->path_record_id = $record->id; $notify->save(); return $notify; }
public function unfollow($id) { $sql = 'delete from followers where user_id = ' . (int) $id . ' and follower_id = ' . $this->id; $query = $this->db->query($sql); $notification = new Notification(); $notification->text = 'Používateľ ' . $this->nick . ' vás prestal sledovať!'; $notification->user_id = (int) $id; $notification->link = 'uzivatel/' . $this->id; $notification->save(); }
public static function fire($user_follow) { $notification = new Notification(); $notification->class = "FollowNotification"; $notification->user_id = $user_follow->object_id; $notification->source_object_model = "UserFollow"; $notification->source_object_id = $user_follow->id; $notification->target_object_model = $user_follow->object_model; $notification->target_object_id = $user_follow->user_id; $notification->save(); }
public static function add($params = array()) { $data = array('uid' => $params['uid'], 'authorid' => $params['authorid'], 'content' => $params['content'], 'new' => 1, 'type' => $params['type'], 'cTime' => zmf::now(), 'from_id' => $params['from_id'], 'from_idtype' => $params['from_idtype'], 'from_num' => 1); if ($params['uid'] == $params['authorid']) { return false; } $model = new Notification(); //2016修改为不计条数 $model->attributes = $data; return $model->save(); }
function save_notification($fields, $is_new = true) { $notification = new Notification(); $notification->id = $fields['id']; $notification->message = $fields['message']; $notification->category = $fields['category']; $notification->display_type = $fields['type']; $notification->read = $fields['read']; $notification->is_new = $is_new; $result = $notification->save(); return $this->status($result); }
public static function fire($invitorUserId, $invitedUser, $space) { // Send Notification to owner $notification = new Notification(); $notification->class = "SpaceInviteAcceptedNotification"; $notification->user_id = $invitorUserId; $notification->space_id = $space->id; $notification->source_object_model = "User"; $notification->source_object_id = $invitedUser->id; $notification->target_object_model = "Space"; $notification->target_object_id = $space->id; $notification->save(); }
public static function fire($approverUserId, $requestor, $room) { // Send Notification to owner $notification = new Notification(); $notification->class = "RoomApprovalRequestAcceptedNotification"; $notification->user_id = $requestor->id; $notification->space_id = $room->id; $notification->source_object_model = "User"; $notification->source_object_id = $approverUserId; $notification->target_object_model = "Room"; $notification->target_object_id = $room->id; $notification->save(); }
public static function fire($approverUserId, $requestor, $workspace) { // Send Notification to owner $notification = new Notification(); $notification->class = "SpaceApprovalRequestDeclinedNotification"; $notification->user_id = $requestor->id; $notification->space_id = $workspace->id; $notification->source_object_model = "User"; $notification->source_object_id = $approverUserId; $notification->target_object_model = "Space"; $notification->target_object_id = $workspace->id; $notification->save(); }
public static function fire($invitorUserId, $invitedUser, $room) { // Send Notification to owner $notification = new Notification(); $notification->class = "RoomInviteDeclinedNotification"; $notification->user_id = $invitorUserId; $notification->space_id = $room->id; $notification->source_object_model = "User"; $notification->source_object_id = $invitedUser->id; $notification->target_object_model = "Room"; $notification->target_object_id = $room->id; $notification->save(); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $input = Input::get(); $input['userId'] = Auth::id(); $followed = $this->execute(FollowUserCommand::class, $input); $notification = new Notification(); $notification->notification_type = 'following'; $notification->notified_id = Input::get('userIdToFollow'); $notification->notifier_id = Auth::id(); $notification->save(); Flash::success("You are now following this user."); return Redirect::back(); }
/** * Fires this notification * * @param Album $like */ public static function fire($album) { foreach ($album->owner->getFollowers(null, true) as $user) { $notification = new Notification(); $notification->class = "AlbumNotification"; $notification->user_id = $user->id; $notification->source_object_model = "Album"; $notification->source_object_id = $album->id; $notification->target_object_model = 'Album'; $notification->target_object_id = $album->id; $notification->save(); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Notification(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Notification'])) { $model->attributes = $_POST['Notification']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public static function fire($originatorUserId, $userId, $room) { $user = User::model()->findByPk($userId); $originator = User::model()->findByPk($originatorUserId); // Send Notification to owner $notification = new Notification(); $notification->class = "SpaceInviteNotification"; $notification->user_id = $user->id; $notification->room_id = $room->id; $notification->source_object_model = "User"; $notification->source_object_id = $originator->id; $notification->target_object_model = "Room"; $notification->target_object_id = $room->id; $notification->save(); }
public static function createNotificationByContentAndTypeForOwner($content, $owner, $type = 'Simple') { //And Billy can create a notification for super $notification = new Notification(); $notification->type = $type; $notification->owner = $owner; $saved = $notification->save(); assert('$saved'); //Same with a message. $message = new NotificationMessage(); $message->textContent = 'text' . $content; $message->htmlContent = 'html' . $content; $saved = $message->save(); assert('$saved'); }
public static function fire($invitorUserId, $invitedUser, $room) { // Send Notification to owner $notification = new Notification(); $notification->class = "RoomInviteAcceptedNotification"; $notification->user_id = $invitorUserId; $notification->room_id = $room->id; $notification->source_object_model = "User"; $notification->source_object_id = $invitedUser->id; $notification->target_object_model = "Room"; $notification->target_object_id = $room->id; if (!isset(Yii::app()->user->id)) { $notification->created_by = $invitedUser->id; } $notification->save(); }
public static function fire($comment) { // Get Comment Root $createdByUserId = $comment->content->created_by; if ($createdByUserId != $comment->created_by) { // Send Notification to owner $notification = new Notification(); $notification->class = "NewCommentNotification"; $notification->user_id = $createdByUserId; $notification->space_id = $comment->space_id; $notification->source_object_model = "Comment"; $notification->source_object_id = $comment->id; $notification->target_object_model = $comment->object_model; $notification->target_object_id = $comment->object_id; $notification->save(); } }
/** * Fires this notification * * @param type $like */ public static function fire($like) { foreach ($like->content->getUnderlyingObject()->getFollowers(null, true) as $user) { if ($user->id == $like->created_by) { continue; } $notification = new Notification(); $notification->class = "NewLikeNotification"; $notification->user_id = $user->id; if ($like->content->container instanceof Space) { $notification->space_id = $like->content->space_id; } $notification->source_object_model = "Like"; $notification->source_object_id = $like->id; $notification->target_object_model = $like->object_model; $notification->target_object_id = $like->object_id; $notification->save(); } }
static function notifyUser($action, $target_guid, $sender_guid, $recipient_guid) { $target = getEntity($target_guid); $target_type = $target->type; $sender = getEntity($sender_guid); if (is_a($sender, "SocialApparatus\\User")) { $sender_full_name = $sender->full_name; } else { $sender_full_name = NULL; } $notification = new Notification(); $notification->action = $action; $notification->target_guid = $target_guid; $notification->sender_guid = $sender_guid; $notification->recipient_guid = $recipient_guid; $notification->target_type = $target_type; $notification->sender_full_name = $sender_full_name; $notification->save(); }
public static function fire($userId, $room) { // Get Approval Users $admins = $room->getAdmins(); $user = User::model()->findByPk($userId); // Send them a notification foreach ($admins as $admin) { // Send Notification to owner $notification = new Notification(); $notification->class = "RoomApprovalRequestNotification"; $notification->user_id = $admin->id; $notification->space_id = $room->id; $notification->source_object_model = "User"; $notification->source_object_id = $user->id; $notification->target_object_model = "Room"; $notification->target_object_id = $room->id; $notification->save(); } }
public function actionReply() { $model = new Post(); $now = date("Y-m-d H:i:s"); if (isset($_POST['Post']) && !Yii::app()->user->isGuest) { $model->attributes = $_POST['Post']; $model->c_time = $now; $model->user_id = Yii::app()->user->id; $article = Article::model()->findByPk($model->article_id); /* if( strlen($article->content) > 0 ){ $model->content = str_replace('<div><br /></div>','<div> </div>',$model->content); } */ if ($model->save()) { $article->reply_count++; $article->reply_time = $now; $article->save(); // add Notification except the auther of the article if ($article->user_id != Yii::app()->user->id) { $n = new Notification(); $n->attributes = array('user_id' => $article->user_id, 'article_id' => $article->id, 'post_id' => $model->id, 'c_time' => $now); $n->save(); } $this->redirect(array('t/index', 'id' => $model->article_id)); } if ($model->content == '') { // $model->content = "<p></p>"; } // only show the author reply if ($_GET['s']) { $criteria = new CDbCriteria(); $criteria->condition = "t.user_id = {$article->user_id} AND t.article_id = {$article->id}"; $criteria->order = 't.c_time ASC '; $posts = Post::model()->findAll($criteria); } else { $posts = $article->posts; } $this->render('index', array('inst' => $article, 'model' => $model, 'posts' => $posts)); } else { throw new CHttpException(404, 'The requested does not allow.'); } }
/** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ private function createNotification() { $transaction = Yii::app()->db->beginTransaction(); try { $ntf = new Notification(); $ntf->customSetAttributes($this->arguments); if ($ntf->save()) { $transaction->commit(); Response::ok(CJSON::encode(array("result" => Constants::RESULTADO_OPERACION_EXITO, "message" => "notificacion con id = {$ntf->id} ingresada con exito"))); } else { $transaction->rollback(); Response::ok(CJSON::encode(array("result" => Constants::RESULTADO_OPERACION_FALLA, "message" => $ntf->getErrors()))); } } catch (\Exception $e) { $transaction->rollback(); Yii::log($e->getMessage(), DBLog::LOG_LEVEL_ERROR); Response::error(CJSON::encode(array("result" => Constants::RESULTADO_OPERACION_FALLA, "message" => Yii::app()->params["httpErrorCode500Message"]))); } }
/** * Send notification through websocket server * * @param $type string * @param $dest array array of notification's recipients (visiteur:<guid> ,visite:<guid>, exposition:<guid>, parcours:<guid>) * @param $options array array of notification's parameters * @param $model array -> array('model' => '', 'model_id' => '') */ public function sendNotification($type, $dest, $options, $model = null) { // This is our new stuff $context = new \ZMQContext(); $socket = $context->getSocket(\ZMQ::SOCKET_PUSH, 'ServerVip pusher'); $socket->connect($this->uri); $vars = array(); $explode1 = explode(",", $dest); foreach ($explode1 as $values) { $data = explode(":", $values); $key = trim($data[0]); $value = trim($data[1]); $vars[$key] = $value; } if (isset($vars['visiteur']) && trim($vars['visiteur']) != '') { $visiteur_id = $vars['visiteur']; } else { throw new sfException('You must specify visiteur.'); $visiteur_id = 'NULL'; } if (isset($vars['visite'])) { $visite_id = $vars['visite']; } else { $visite_id = 'NULL'; } if ($visiteur_id && strpos($option, 'stdClass') === false) { $notif = new Notification(); $notif->setGuid(Guid::generate()); $notif->setLibelle($options['title']); $notif->setVisiteurId($visiteur_id); $notif->setVisiteId($visite_id); if (isset($model['model'])) { $notif->setFromModel($model['model']); } if (isset($model['model_id'])) { $notif->setFromModelId($model['model_id']); } $notif->setParameter(json_encode((array) $options)); $notif->save(); } $socket->send(json_encode(array('command' => 'notification.send', 'data' => array('dest' => $dest, 'type' => $type, 'options' => $options, 'model' => $model)))); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $input = Input::all(); $validation = Validator::make($input, Comment::$rules); if ($validation->passes()) { $last_comment = Comment::where('user_id', '=', Auth::user()->id)->orderBy('created_at', 'desc')->first(); $current_date = new DateTime(date("Y-m-d H:i:s")); if (empty($last_comment)) { $interval = 5; } else { $interval = $current_date->diff($last_comment->created_at); $interval = intval($interval->format('%i')); } /*if($interval >= 3){*/ $this->add_daily_comment_points(); $comment = new Comment(); $comment->media_id = $input['media_id']; $comment->comment = htmlspecialchars($input['comment']); $comment->user_id = Auth::user()->id; //echo $comment; if ($comment->save()) { $notification = new Notification(); $media = Media::find($comment->media_id); $notification->user_id = $media->user_id; $user_comment = $comment->user()->username; $notification->url_comment = URL::to('media') . '/' . $media->slug; if ($media->user_id == Auth::user()->id) { $notification->is_read = 1; } else { $notification->is_read = 0; $notification->content = $user_comment . " comments in " . '" ' . $comment->media()->title . ' " your'; } $notification->save(); } echo $comment; /*} else { echo 0; }*/ } else { echo 0; } }
/** * Check if there is a new Humhub Version available * * @param type $event */ public static function onCronDailyRun($event) { Yii::import('application.modules_core.admin.libs.*'); $cron = $event->sender; if (!Yii::app()->getModule('admin')->marketplaceEnabled) { return; } $onlineModuleManager = new OnlineModuleManager(); $latestVersion = $onlineModuleManager->getLatestHumHubVersion(); if ($latestVersion != "" && version_compare($latestVersion, HVersion::VERSION, ">")) { foreach (User::model()->findAllByAttributes(array('super_admin' => 1)) as $user) { $notification = Notification::model()->findByAttributes(array('class' => 'HumHubUpdateNotification', 'user_id' => $user->id)); if ($notification === null) { $notification = new Notification(); $notification->class = "HumHubUpdateNotification"; $notification->user_id = $user->id; $notification->save(); } } } }
public function afterSave($event) { $log = new RecordOperationLog(); $log->user_id = Yii::app()->user->id; $log->model = get_class($this->Owner); $log->model_id = $this->Owner->getPrimaryKey(); $log->action = $this->Owner->isNewRecord ? RecordOperationLog::INSERT : RecordOperationLog::UPDATE; $log->save(); if (RecordOperationLog::INSERT !== $log->action) { return; } $notificationRecipientIds = array(); if ($this->Owner instanceof Message) { $notificationRecipientIds[] = $this->Owner->recipient_id; } else { if ($this->Owner instanceof Post) { foreach ($this->Owner->feed->followers as $follower) { $notificationRecipientIds[] = $follower->id; } } else { if ($this->Owner instanceof Comment) { $notificationRecipientIds[] = $this->Owner->post->user_id; foreach ($this->Owner->post->comments as $comment) { $notificationRecipientIds[] = $comment->user_id; } foreach ($this->Owner->post->feed->followers as $follower) { $notificationRecipientIds[] = $follower->id; } } } } $notificationRecipientIds = array_diff(array_unique($notificationRecipientIds), array($log->user_id)); foreach ($notificationRecipientIds as $recipientId) { $notification = new Notification(); $notification->record_operation_log_id = $log->id; $notification->user_id = $recipientId; $notification->save(); } }