当前位置: 首页>>代码示例>>PHP>>正文


PHP Notifications::addNotification方法代码示例

本文整理汇总了PHP中Notifications::addNotification方法的典型用法代码示例。如果您正苦于以下问题:PHP Notifications::addNotification方法的具体用法?PHP Notifications::addNotification怎么用?PHP Notifications::addNotification使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Notifications的用法示例。


在下文中一共展示了Notifications::addNotification方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionFollowUser

 /**
  * Add a user to follower list of other and send notifcation
  *
  * @author Kuldeep Dangi <kuldeep.dangi@yiifrmae.com>
  */
 public function actionFollowUser($userId, $followerId)
 {
     $model = new UserFollow();
     $userFollowingObj = Users::model()->findByPk($userId);
     $userObj = Users::model()->findByPk($followerId);
     if ($userFollowingObj && $userObj) {
         $isRecrodExist = $model->findByAttributes(array('id_follower' => $followerId, 'id_following' => $userId));
         if ($isRecrodExist) {
             $this->result['success'] = true;
         } else {
             $model->attributes = array('id_follower' => $followerId, 'id_following' => $userId);
             if ($model->validate() && $model->save()) {
                 $notificationObj = new Notifications();
                 $notificationObj->addNotification(array('byUserId' => $userId, 'user_id' => $followerId, 'type' => 'FOLLOW'));
                 $notificationObj->sendPushNotification(array('deviceToken' => $userObj->deviceToken, 'deviceType' => $userObj->deviceType, 'message' => $userFollowingObj->username . ' has started following you.'));
                 $this->result['success'] = true;
                 $this->getUserInformation($userId);
                 $this->result['message'] = 'Record saved successfuly.';
             } else {
                 $this->result['message'] = 'Invalid Data.';
             }
         }
     } else {
         $this->result['message'] = 'Invalid data.';
     }
     $this->sendResponse($this->result);
 }
开发者ID:kuldeepro,项目名称:notesgen,代码行数:32,代码来源:UsersController.php

示例2: actionAddFile

 /**
  * Add a file in response of a wishlist request.
  *
  * @author Kuldeep Dangi <kuldeep.dangi@yiifrmae.com>
  */
 public function actionAddFile()
 {
     $model = new Extensions();
     $modelUserFeed = new UserFeed();
     if (!empty($_POST['user_id']) && !empty($_POST['reply_to_feed'])) {
         $model->attributes = $_POST;
         $uploadedFiles = CUploadedFile::getInstancesByName('images');
         if ($uploadedFiles && count($uploadedFiles) > 0) {
             $allUploadedFiles = array();
             foreach ($uploadedFiles as $uploadedFile) {
                 $fileName = strtotime($this->getCurrentDateTime()) . '-' . $uploadedFile;
                 $uploadedFile->saveAs(Yii::app()->basePath . '/../../' . Extensions::FILE_UPLOAD_PATH . $fileName);
                 $allUploadedFiles[] = $fileName;
             }
             $savedFileNames = $model->getPdfFromImages($allUploadedFiles);
             $model->pdf = Extensions::FILE_CONVERT_PATH . $savedFileNames['pdf'];
             $model->imagepdf = $savedFileNames['imagepdf'];
             $model->image = Extensions::FILE_IMAGE_PATH . $savedFileNames['image'];
             if ($model->save()) {
                 $modelUserFeed->user_id = $_POST['user_id'];
                 $modelUserFeed->reply_to_feed = $_POST['reply_to_feed'];
                 $modelUserFeed->comment = Extensions::FILE_CONVERT_PATH . $savedFileNames['pdf'];
                 $modelUserFeed->is_file = 1;
                 $modelUserFeed->date_add = time();
                 $modelUserFeed->save();
                 $feedData = $this->loadModel($_POST['reply_to_feed']);
                 $notificationObj = new Notifications();
                 $notificationObj->addNotification(array('byUserId' => $_GET['user_id'], 'user_id' => $feedData->user_id, 'notify_comment' => $feedData->user_feed_id, 'type' => 'WISHLISTUPLOAD'));
                 $userObj = Users::model()->findByPk($feedData->user_id);
                 if ($userObj && !empty($userObj->deviceToken)) {
                     $notificationObj->sendPushNotification(array('deviceToken' => $userObj->deviceToken, 'deviceType' => $userObj->deviceType, 'message' => 6));
                 }
                 $this->result['success'] = true;
             }
         }
     } else {
         $this->result['message'] = 'Invalid Data.';
     }
     $this->sendResponse($this->result);
 }
开发者ID:kuldeepro,项目名称:notesgen,代码行数:45,代码来源:WishlistController.php


注:本文中的Notifications::addNotification方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。