コード例 #1
0
 /**
  * Delete all notifications for this user and this survey
  * @param int|null $surveyId
  * @return void
  */
 public function clearAllNotifications($surveyId = null)
 {
     Notification::model()->deleteAll('entity = \'user\' AND entity_id = ' . Yii::app()->user->id);
     if (is_int($surveyId)) {
         Notification::model()->deleteAll('entity = \'survey\' AND entity_id = ' . $surveyId);
     }
 }
コード例 #2
0
 /**
  * Remove notification after member had approved/declined the invite
  *
  * @param type $userId
  * @param type $room
  */
 public static function remove($userId, $room)
 {
     $notifications = Notification::model()->findAllByAttributes(array('class' => 'RoomInviteNotification', 'target_object_model' => 'Room', 'target_object_id' => $room->id, 'user_id' => $userId));
     foreach ($notifications as $notification) {
         $notification->delete();
     }
 }
コード例 #3
0
ファイル: TController.php プロジェクト: paranoidxc/iwebhost
 public function actionIndex()
 {
     if (is_numeric($_GET['id'])) {
         $article = Article::model()->findByPk($_GET['id']);
     } else {
         $article = Article::model()->findByAttributes(array('ident_label' => $_GET['id']));
     }
     if ($article === null) {
         throw new CHttpException(404, 'The requested Topic does not exist.');
     }
     // page view plus expcet the owner of the article
     if ($article->user_id != Yii::app()->user->id) {
         $article->pv = $article->pv + 1;
         $article->save();
     }
     //article auther read the reply
     if ($article->user_id == Yii::app()->user->id) {
         Notification::model()->article_auther_readed_notices($article->id, Yii::app()->user->id);
     }
     $model = new Post();
     //		$model->content = "<p></p>";
     $model->article_id = $article->id;
     $this->_pageTitle = CHtml::encode($article->title) . API::lchart() . $article->leaf->name . API::lchart();
     // 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));
 }
コード例 #4
0
 /**
  * Remove notification after member was approved/declined or canceled the
  * request.
  *
  * @param type $userId
  * @param type $workspace
  */
 public static function remove($userId, $workspace)
 {
     $notifications = Notification::model()->findAllByAttributes(array('class' => 'SpaceApprovalRequestNotification', 'target_object_model' => 'Space', 'target_object_id' => $workspace->id, 'source_object_model' => 'User', 'source_object_id' => $userId));
     foreach ($notifications as $notification) {
         $notification->delete();
     }
 }
コード例 #5
0
ファイル: Notification.php プロジェクト: jjsub/samesub
 /**
  * Do some things before save
  * 
  */
 public function beforeSave()
 {
     if ($this->fixed == 1) {
         Notification::model()->updateAll(array('fixed' => 0), 'notification_type_id=:notification_type_id', array(':notification_type_id' => $this->notification_type_id));
     }
     return true;
 }
コード例 #6
0
 public function checkAccess()
 {
     // Save users last action on this space
     $membership = $this->space->getMembership(Yii::app()->user->id);
     if ($membership != null) {
         $membership->updateLastVisit();
     } else {
         // Super Admin can always enter
         if (!Yii::app()->user->isAdmin()) {
             // Space invisible?
             if ($this->space->visibility == Space::VISIBILITY_NONE) {
                 // Not Space Member
                 throw new CHttpException(404, Yii::t('SpaceModule.behaviors_SpaceControllerBehavior', 'Space is invisible!'));
             }
         }
     }
     // Delete all pending notifications for this space
     $notifications = Notification::model()->findAllByAttributes(array('space_id' => $this->space->id, 'user_id' => Yii::app()->user->id), 'seen != 1');
     foreach ($notifications as $n) {
         // Ignore Approval Notifications
         if ($n->class == "SpaceApprovalRequestNotification" || $n->class == "SpaceInviteNotification") {
             continue;
         }
         $n->seen = 1;
         $n->save();
     }
 }
コード例 #7
0
 public function loadModel($id)
 {
     $model = Notification::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #8
0
ファイル: UsersController.php プロジェクト: ph7pal/wedding
 /**
  * 用户提醒列表
  */
 public function actionNotice()
 {
     $sql = "SELECT * FROM {{notification}} WHERE uid='{$this->uid}' ORDER BY cTime DESC";
     Posts::getAll(array('sql' => $sql), $pages, $comLists);
     Notification::model()->updateAll(array('new' => 0), 'uid=:uid', array(':uid' => $this->uid));
     $data = array('posts' => $comLists, 'pages' => $pages);
     $this->pageTitle = $this->userInfo['truename'] . '的提醒 - ' . zmf::config('sitename');
     $this->render('notice', $data);
 }
コード例 #9
0
 public function loadNotification($notificationId)
 {
     $notification = Notification::model()->findByPk($notificationId);
     if ($notification === null || $notification->user_id !== Yii::app()->getUser()->getModel()->id) {
         throw new CHttpException(404, Yii::t('application', 'The requested page does not exist.'));
     } else {
         return $notification;
     }
 }
コード例 #10
0
ファイル: NController.php プロジェクト: paranoidxc/iwebhost
 public function actionDel()
 {
     $u =& $this->iuser;
     $n = Notification::model()->findByPk($_GET['id']);
     if ($n === null) {
         throw new CHttpException(404, 'The requested Node does not exist.');
     }
     if ($n->user_id == user()->id) {
         $n->delete();
     }
     $this->redirect(array('n/index'));
 }
コード例 #11
0
ファイル: Notification.php プロジェクト: ph7pal/momo
 public function getNum()
 {
     $uid = zmf::uid();
     if (!$uid) {
         return '0';
     }
     $num = Notification::model()->count('new=1 AND uid=:uid', array(':uid' => $uid));
     if ($num > 0) {
         return $num;
     } else {
         return '0';
     }
 }
コード例 #12
0
ファイル: ListController.php プロジェクト: alefernie/intranet
 public function actionMarkAsSeen()
 {
     // build query
     $criteria = new CDbCriteria();
     $criteria->condition = 'seen=0';
     // load all unseen notification for this user
     $notifications = Notification::model()->findAllByAttributes(array('user_id' => Yii::app()->user->id), $criteria);
     foreach ($notifications as $notification) {
         // mark all unseen notification as seen
         $notification->markAsSeen();
     }
     // compete action
     Yii::app()->end();
 }
コード例 #13
0
 public function actionFriendnotification()
 {
     $this->layout = 'layout_user';
     $type = 'friend';
     $notification = Notification::model()->findAll("user_id=:uid AND type = '{$type}'", array(':uid' => Yii::app()->user->userId));
     foreach ($notification as $n) {
         $n->is_read = 1;
         $n->save();
     }
     $friend = UserFriend::model()->findAll('friend_id=:uid AND is_read=0', array(':uid' => Yii::app()->user->userId));
     foreach ($friend as $n) {
         $n->is_read = 1;
         $n->save();
     }
     $this->render('shownotification', array('notification' => $notification));
 }
コード例 #14
0
 /**
  * Returns a List of all Comments belong to this Model
  */
 public function actionIndex()
 {
     $notificationId = (int) Yii::app()->request->getParam('id');
     $notification = Notification::model()->findByAttributes(array('user_id' => Yii::app()->user->id, 'id' => $notificationId));
     if ($notification == null) {
         throw new CHttpException(500, 'Invalid notification id!');
     }
     if ($notification->class != "SpaceApprovalRequestNotification" && $notification->class != "SpaceInviteNotification") {
         $notification->seen = 1;
         $notification->save();
         // Mark similar notification as read
         $notifications = Notification::model()->findAllByAttributes(array('target_object_model' => $notification->target_object_model, 'target_object_id' => $notification->target_object_id, 'user_id' => Yii::app()->user->id), 'seen != 1');
         foreach ($notifications as $n) {
             $n->markAsSeen();
         }
     }
     $notification->redirectToTarget();
 }
コード例 #15
0
ファイル: AjaxController.php プロジェクト: ph7pal/wedding
 public function actionNotices()
 {
     self::checkLogin();
     $uid = zmf::uid();
     $items = Notification::model()->findAll('new=1 AND uid=:uid ORDER BY cTime DESC', array(':uid' => $uid));
     if (!empty($items)) {
         $longstr = '<ul>';
         foreach ($items as $item) {
             $longstr .= '<li>';
             $longstr .= $item['content'];
             $longstr .= '</li>';
         }
         $longstr .= '</ul>';
         //Notification::model()->updateAll(array('new' => 0), 'uid=:uid', array(':uid' => $uid));
         $this->jsonOutPut(1, $longstr);
     } else {
         $this->jsonOutPut(1, '<div class="suggitem"><span>暂无提醒</span></div>');
     }
 }
コード例 #16
0
ファイル: HUpdateCommand.php プロジェクト: skapl/design
 public function actionIndex($args, $interactive = null)
 {
     if ($interactive != null) {
         $this->interactive = $interactive;
     }
     print "*** Begin Migrations ***\n\n";
     $this->runMigrations();
     $this->printLine();
     print "\n*** Checking Modules ***\n\n";
     $this->runModuleCheck();
     print "\n\n\n";
     $this->printLine();
     if (!$this->hasErrors) {
         print "Finished succesfully without errors!";
     } else {
         print "Finished with ERRORS!";
     }
     $this->printLine();
     print "\n";
     Notification::model()->deleteAllByAttributes(array('class' => 'HumHubUpdateNotification'));
 }
コード例 #17
0
ファイル: AdminModuleEvents.php プロジェクト: skapl/design
 /**
  * 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();
             }
         }
     }
 }
コード例 #18
0
 public function actionScheduleInterview()
 {
     $original_string = "qwertyuiopasdfghjklzxcvbnm123456789";
     $lastid = VideoInterview::model()->find(array('order' => 'id DESC'));
     if ($lastid != null) {
         $key = $lastid->id + 1 . "VJFID" . rand(1, 10000000);
     } else {
         $key = 1 . "VJFID" . rand(1, 10000000);
     }
     $refid = Notification::model()->find(array('order' => 'id DESC'));
     $username = Yii::app()->user->name;
     $sender_id = User::model()->find("username=:username", array(':username' => $username))->id;
     $student = $_POST['user_name'];
     $receiver = User::model()->find("username=:username", array(':username' => $student));
     $link = $username;
     $model = new VideoInterview();
     $model->attributes = $_POST['VideoInterview'];
     $model->FK_employer = $sender_id;
     $model->FK_student = $receiver->id;
     $model->session_key = $key;
     $model->notification_id = $refid->id + 2;
     $model->save(false);
     $message = $username . " scheduled a video interview with you on: {$model->date} at: {$model->time} Good Luck!";
     User::sendSchedualNotificationAlart($sender_id, $receiver->id, $message, $link);
     //print "<pre>"; print_r($receiver_id);print "</pre>";return;
     //SAVE TO VIDEO INTERVIEW TABLE
     $message2 = "You scheduled an interview with " . $student . " at " . $model->time . " on " . $model->date . " Click here to go to the interview page.";
     User::sendSchedualNotificationAlart($receiver->id, $sender_id, $message2, $student);
     $message3 = "Hi {$receiver->username}, {$username} will like to interview you on:<br/>Date: {$model->date}<br/>Time: {$model->time}";
     User::sendEmail($receiver->email, "Virtual Job Fair", "Scheduled Interview", $message3);
     //User::sendEmailNotificationAlart($receiver->email, $receiver->username, $username, $message3);
     $link = CHtml::link('here', 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/home/studenthome');
     $message4 = "{$username} scheduled an interview with you on:<br/>Date: {$model->date}<br/>Time: {$model->time}<br/>{$link}" . " Click {$link} to go to the interview page";
     //$html = User::replaceMessage($student, $message4);
     User::sendEmail($receiver->email, "Virtual Job Fair", "Scheduled Interview", $message4);
     //User::sendEmailNotificationAlart($receiver->email, $receiver->username, $username, $message4);
     $this->redirect("/JobFair/index.php/profile/student/user/" . $student);
     //print "<pre>"; print_r($key);print "</pre>";return;
 }
コード例 #19
0
 /**
  * Sends an notifcation to everybody who is involved/following in this content
  * with notifications.
  * 
  * @param HActiveRecordContentAddon $comment
  */
 public static function fire($comment)
 {
     foreach ($comment->content->getUnderlyingObject()->getFollowers(null, true) as $user) {
         // Dont send a notification to the creator of this comment
         if ($user->id == $comment->created_by) {
             continue;
         }
         // Check there is also an mentioned notifications, so ignore this notification
         if (Notification::model()->findByAttributes(array('class' => 'MentionedNotification', 'source_object_model' => 'Comment', 'source_object_id' => $comment->id)) !== null) {
             continue;
         }
         $notification = new Notification();
         $notification->class = "NewCommentNotification";
         $notification->user_id = $user->id;
         // Optional
         $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();
     }
 }
コード例 #20
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = Notification::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
コード例 #21
0
ファイル: DefaultController.php プロジェクト: ruzuojun/shiqu
 public function actionTopic()
 {
     $id = $_GET["id"];
     if (isset($_GET["pk_id"])) {
         if (Notification::model()->findByPk($_GET["pk_id"])->remind_flag == 0) {
             Notification::model()->updateByPk($_GET["pk_id"], array("remind_flag" => 1));
         }
     }
     $criteria = new CDbCriteria();
     $topicModel = Topic::model()->findByPk($id);
     $criteria->addCondition("pk_id='" . $id . "'");
     $criteria->addCondition("model='topic'");
     $dataProvider = new CActiveDataProvider('Comment', array('criteria' => $criteria, 'sort' => array('defaultOrder' => 'create_time asc'), 'pagination' => array('pageVar' => 'page', 'pageSize' => 10)));
     $this->render('topic', array("dataProvider" => $dataProvider, 'topicModel' => $topicModel));
 }
コード例 #22
0
ファイル: main.php プロジェクト: paranoidxc/iwebhost
        ?>
              <span class='mail_not'><?php 
        echo $_t_unread_mail_count;
        ?>
</span>
              <?php 
    }
    ?>
            </li>
           <li>
            <a href="<?php 
    echo bu('notifications.html');
    ?>
" >提醒</a>
            <?php 
    if (($_t_notices_count = Notification::model()->notices_count()->count()) > 0) {
        ?>
            <span class="mail_not"><?php 
        echo $_t_notices_count;
        ?>
</span>
            <?php 
    }
    ?>
           </li>
            <li id='signin_user_wrap'>
              <a id='signin_user_link' href="<?php 
    echo url('m/you');
    ?>
">Hi,<?php 
    echo user()->name;
コード例 #23
0
ファイル: EMailing.php プロジェクト: ahdail/humhub
 /**
  * Returns notification content by given user.
  *
  * The output will generated on current mode.
  *
  * @param type $user
  * @return string email output
  */
 private function getNotificationContent($user)
 {
     $receive_email_notifications = $user->getSetting("receive_email_notifications", 'core', HSetting::Get('receive_email_notifications', 'mailing'));
     // Never receive notifications
     if ($receive_email_notifications == User::RECEIVE_EMAIL_NEVER) {
         return "";
     }
     // We are in hourly mode and user wants daily
     if ($this->mode == 'hourly' && $receive_email_notifications == User::RECEIVE_EMAIL_DAILY_SUMMARY) {
         return "";
     }
     // We are in daily mode and user dont wants daily reports
     if ($this->mode == 'daily' && $receive_email_notifications != User::RECEIVE_EMAIL_DAILY_SUMMARY) {
         return "";
     }
     // User wants only when offline and is online
     if ($this->mode == 'hourly') {
         $isOnline = count($user->httpSessions) > 0;
         if ($receive_email_notifications == User::RECEIVE_EMAIL_WHEN_OFFLINE && $isOnline) {
             return "";
         }
     }
     // Get not seen notifcation, order by created_at
     $criteria = new CDbCriteria();
     $criteria->order = 'created_at DESC';
     $notifications = Notification::model()->findAllByAttributes(array('user_id' => $user->id, 'seen' => 0, 'emailed' => 0), $criteria);
     // Nothin new
     if (count($notifications) == 0) {
         return "";
     }
     // Generate notification output
     $output = "";
     foreach ($notifications as $notification) {
         $output .= $notification->getMailOut();
         $notification->emailed = 1;
         $notification->save();
     }
     return $output;
 }
コード例 #24
0
 /**
  * On run of the cron, do some cleanup stuff.
  * We delete all notifications which are older than 2 month and are seen.
  *
  * @param type $event
  */
 public static function onCronDailyRun($event)
 {
     $cron = $event->sender;
     /**
      * Delete seen notifications which are older than 2 months
      */
     $deleteTime = time() - 60 * 60 * 24 * 31 * 2;
     // Notifcations which are older as ~ 2 Months
     foreach (Notification::model()->findAllByAttributes(array('seen' => 1), 'created_at < :date', array(':date' => date('Y-m-d', $deleteTime))) as $notification) {
         $notification->delete();
     }
 }
コード例 #25
0
ファイル: Notification.php プロジェクト: alefernie/intranet
 public static function remove($model, $id)
 {
     $notifications = Notification::model()->findAllByAttributes(array('target_object_model' => $model, 'target_object_id' => $id));
     foreach ($notifications as $notification) {
         $notification->delete();
     }
     $notifications = Notification::model()->findAllByAttributes(array('source_object_model' => $model, 'source_object_id' => $id));
     foreach ($notifications as $notification) {
         $notification->delete();
     }
 }
コード例 #26
0
ファイル: AjaxController.php プロジェクト: ph7pal/naodong
 /**
  * 删除内容
  */
 public function actionDelPost()
 {
     $logid = zmf::filterInput($_POST['logid']);
     $type = zmf::filterInput($_POST['type'], 't', 1);
     $admin = false;
     if (empty($logid) or !is_numeric($logid)) {
         $this->jsonOutPut(0, Yii::t('default', 'unkownerror'));
     }
     if (!Yii::app()->request->isAjaxRequest) {
         //Forbidden::updateTimes();
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (Yii::app()->user->isGuest) {
         $this->jsonOutPut(0, Yii::t('default', 'loginfirst'));
     }
     if (!in_array($type, array('naodong', 'comment', 'notice'))) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if ($type == 'naodong') {
         $tinfo = Naodong::model()->findByPk($logid);
         if (!$tinfo) {
             $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
         } elseif ($tinfo['uid'] != zmf::uid()) {
             //                $admin = Users::checkPower('delpost', false, true);
             //                if (!$admin) {
             //                    $this->jsonOutPut(0, '请勿越权操作');
             //                }
         }
         $status = Posts::STATUS_DELED;
         $attr = array('status' => Posts::STATUS_DELED);
         if (Naodong::model()->updateByPk($logid, $attr)) {
             $this->jsonOutPut(1, '操作成功!');
         } else {
             $this->jsonOutPut(1, '操作失败!');
         }
     } elseif ($type == 'comment') {
         $cinfo = Comments::model()->findByPk($logid);
         if (!$cinfo) {
             $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
         } elseif ($cinfo['uid'] != zmf::uid()) {
             //                $admin = Users::checkPower('delcomment', false, true);
             //                if (!$admin) {
             //                    $this->jsonOutPut(0, '请勿越权操作');
             //                }
         }
         $status = Posts::STATUS_DELED;
         $attr = array('status' => $status);
         if (Comments::model()->updateByPk($logid, $attr)) {
             if (strtolower($cinfo['classify']) == 'naodong') {
                 Posts::updateCount($cinfo['logid'], 'Naodong', -1, 'comments');
             }
             $this->jsonOutPut(1, '操作成功!');
         } else {
             $this->jsonOutPut(1, '操作失败!');
         }
     } elseif ($type == 'notice') {
         $cinfo = Notification::model()->findByPk($logid);
         if (!$cinfo) {
             $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
         } elseif ($cinfo['uid'] != zmf::uid()) {
             $this->jsonOutPut(0, '请勿越权操作');
         }
         if (Notification::model()->deleteByPk($logid)) {
             $this->jsonOutPut(1, '操作成功!');
         } else {
             $this->jsonOutPut(0, '操作失败');
         }
     }
 }
コード例 #27
0
ファイル: Notification.php プロジェクト: erick305/testing
 public static function markHasBeenRead($id)
 {
     $notification = Notification::model()->findByPk($id);
     $notification->been_read = 1;
     $notification->save(false);
 }
コード例 #28
0
ファイル: _notifications.php プロジェクト: mjrouser/cityapi
<?php

/*
    _notifications.php

    Copyright Stefan Fisk 2012
*/
/* var $userId int */
/* var $onlyUnviewed bool */
if (!isset($onlyUnviewed)) {
    $onlyUnviewed = false;
}
$this->beginWidget('application.widgets.OuterBoxWidget', array('class' => 'notifications feed', 'title' => CHtml::link(Yii::t('app', 'Notifications'), array('notifications'))));
$notifications = $onlyUnviewed ? Notification::model()->findAllUnviewed($userId) : Notification::model()->findAllByAttributes(array('user_id' => $userId));
if (0 !== count($notifications)) {
    ?>
        <ul class="notifications">
            <?php 
    foreach ($notifications as $notification) {
        ?>
                <?php 
        if (RecordOperationLog::INSERT !== $notification->log->action) {
            Yii::log('Unknown notification log action. $notification = ' . $notification->id, 'error', 'app.user._notifications');
            $notification->viewed = true;
            $notification->save();
            continue;
        }
        ?>
                <?php 
        if ('Message' === $notification->log->model) {
            ?>
コード例 #29
0
ファイル: ListController.php プロジェクト: skapl/design
 /**
  * Returns a JSON which contains 
  * - Number of new / unread notification
  * - Notification Output for new HTML5 Notifications
  * 
  * @return string JSON String
  */
 public static function getUpdateJson()
 {
     $user = Yii::app()->user->getModel();
     $criteria = new CDbCriteria();
     $criteria->condition = 'user_id = :user_id';
     $criteria->addCondition('seen != 1');
     $criteria->params = array('user_id' => $user->id);
     $json['newNotifications'] = Notification::model()->count($criteria);
     $json['notifications'] = array();
     $criteria->addCondition('desktop_notified = 0');
     $notifications = Notification::model()->findAll($criteria);
     foreach ($notifications as $notification) {
         if ($user->getSetting("enable_html5_desktop_notifications", 'core', HSetting::Get('enable_html5_desktop_notifications', 'notification'))) {
             $json['notifications'][] = $notification->getTextOut();
         }
         $notification->desktop_notified = 1;
         $notification->update();
     }
     return CJSON::encode($json);
 }
コード例 #30
0
ファイル: Notification.php プロジェクト: ph7pal/mei
 public function getNum($uid = '')
 {
     if (Yii::app()->user->isGuest) {
         return '0';
     }
     if ($uid == '') {
         $uid = Yii::app()->user->id;
     }
     if (!$uid) {
         return '0';
     }
     $num = Notification::model()->count('new=1 AND uid=:uid', array(':uid' => $uid));
     if ($num > 0) {
         return $num;
     } else {
         return '0';
     }
 }