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


PHP Notifications::model方法代码示例

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


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

示例1: add

 public function add($user_follow, $user_followed, $type)
 {
     $check = Relationship::model()->findAllByAttributes(array('user_id_1' => $user_follow, 'user_id_2' => $user_followed));
     $check_2 = Relationship::model()->findAllByAttributes(array('user_id_2' => $user_follow, 'user_id_1' => $user_followed));
     $check_3 = Follow::model()->findByAttributes(array('user_follow' => $user_follow, 'user_followed' => $user_followed));
     if ($check || $check_2 || $check_3 || $user_followed == Yii::app()->session['user_id']) {
         return FALSE;
     }
     $model = new Follow();
     $model->user_follow = $user_follow;
     $model->user_followed = $user_followed;
     $model->created_at = time();
     $model->update_at = time();
     $model->type = $type;
     $user_follow_data = User::model()->findByPk($user_follow);
     $user_followed_data = User::model()->findByPk($user_followed);
     if ($user_follow != Yii::app()->session['user_id']) {
         $arr_noti = array('user_id' => $user_follow, 'content' => "{$user_follow_data->username} vừa theo dõi bạn", 'type' => 'follow', 'recipient_id' => $user_followed_data->id, 'url' => Yii::app()->createAbsoulteUrl('user/profile', array('user_id' => $user_follow_data->id, 'ref' => 'noti')));
         Notifications::model()->add($arr_noti);
     }
     if ($model->save(FALSE)) {
         return TRUE;
     }
     return FALSE;
 }
开发者ID:huynt57,项目名称:fashion,代码行数:25,代码来源:Follow.php

示例2: getNotification

 public function getNotification($user_id, $limit, $offset)
 {
     $criteria = new CDbCriteria();
     $criteria->limit = $limit;
     $criteria->offset = $offset;
     $criteria->condition = "user_id = {$user_id}";
     return $data = Notifications::model()->findAll($criteria);
 }
开发者ID:huynt57,项目名称:image_chooser,代码行数:8,代码来源:Notifications.php

示例3: loadModel

 /**
  * 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.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Notifications::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('site', '404_Error'));
     }
     return $model;
 }
开发者ID:lanzelotik,项目名称:celestic-community,代码行数:13,代码来源:NotificationsController.php

示例4: afterDelete

 public function afterDelete()
 {
     parent::afterDelete();
     $shared = Shared::model()->findAllByAttributes(array('cam_id' => $this->id));
     foreach ($shared as $s) {
         Notifications::model()->deleteAllByAttributes(array('shared_id' => $s->id, 'status' => 1));
         $s->delete();
     }
     Sessions::model()->deleteAllByAttributes(array('real_id' => $this->id));
     Sessions::model()->deleteAllByAttributes(array('real_id' => $this->id . '_low'));
     return true;
 }
开发者ID:mrtos,项目名称:OpenNVR,代码行数:12,代码来源:Cams.php

示例5: markAllNotificationAsSeen

 public function markAllNotificationAsSeen()
 {
     $flag = TRUE;
     $notis = Notifications::model()->findAllByAttributes(array('is_read' => 0));
     foreach ($notis as $noti) {
         $noti->is_read = 2;
         if (!$noti->save(FALSE)) {
             $flag = FALSE;
         }
     }
     return $flag;
 }
开发者ID:huynt57,项目名称:fashion,代码行数:12,代码来源:Notifications.php

示例6: addComment

 public function addComment($user_id, $post_id, $content)
 {
     $model = new Comments();
     $model->post_id = $post_id;
     $model->created_by = $user_id;
     $model->updated_at = time();
     $model->comment_content = $content;
     $model->status = 1;
     $model->created_at = time();
     $model->updated_at = time();
     $model->save(FALSE);
     $post = Posts::model()->findByPk($post_id);
     $post->post_comment_count++;
     $user = User::model()->findByPk($model->created_by);
     $user_commented = User::model()->findByPk($post->user_id);
     if ($user_commented) {
         if ($user->id != $post->user_id) {
             $users_have_commented = $this->getListUserCommentedOnPost($post_id);
             if ($users_have_commented) {
                 foreach ($users_have_commented as $item) {
                     if ($user_id != $item->created_by && $post->user_id != $item->created_by) {
                         $arr_noti_others = array('user_id' => $user->id, 'content' => "{$user->username} cũng đã bình luận bài viết của {$user_commented->username}", 'type' => 'comment_also', 'recipient_id' => $item->created_by, 'url' => Yii::app()->createAbsoluteUrl('post/viewPost', array('post_id' => $post_id, array('ref' => 'noti'))));
                         Notifications::model()->add($arr_noti_others);
                     }
                 }
             }
             $arr_noti = array('user_id' => $user->id, 'content' => "{$user->username} vừa bình luận bài viết của bạn", 'type' => 'comment', 'recipient_id' => $user_commented->id, 'url' => Yii::app()->createAbsoluteUrl('post/viewPost', array('post_id' => $post_id, array('ref' => 'noti'))));
             Notifications::model()->add($arr_noti);
         } else {
             $users_have_commented = $this->getListUserCommentedOnPost($post_id);
             if ($users_have_commented) {
                 foreach ($users_have_commented as $item) {
                     if ($user_id != $item->created_by) {
                         $arr_noti_others = array('user_id' => $user->id, 'content' => "{$user->username} cũng đã bình luận bài viết của họ", 'type' => 'comment_also', 'recipient_id' => $item->created_by, 'url' => Yii::app()->createAbsoluteUrl('post/viewPost', array('post_id' => $post_id, array('ref' => 'noti'))));
                         Notifications::model()->add($arr_noti_others);
                     }
                 }
             }
         }
     }
     if ($model->save(FALSE) && $post->save(FALSE)) {
         $returnArr = array();
         $returnArr['created_by'] = $model->created_by;
         $returnArr['username'] = $user->username;
         $returnArr['photo'] = StringHelper::generateUrlImage($user->photo);
         $returnArr['created_at'] = Util::time_elapsed_string($model->created_at);
         $returnArr['comment_content'] = $model->comment_content;
         return $returnArr;
     }
     return FALSE;
 }
开发者ID:huynt57,项目名称:fashion,代码行数:51,代码来源:Comments.php

示例7: loadModel

 /**
  * Load model of a Notification.
  *
  * @author Kuldeep Dangi <kuldeep.dangi@yiifrmae.com>
  */
 public function loadModel($id)
 {
     $model = Notifications::model()->findByPk($id);
     return $model;
 }
开发者ID:kuldeepro,项目名称:notesgen,代码行数:10,代码来源:NotificationsController.php

示例8: send

    /**
     * @inheritdoc
     */
    public function send($message, $category = null, $object_pk = null, $subject_pk = null, $notification = null)
    {
        

        $by_email = false; $notifications = null;

        $subscriptions = NfyDbSubscription::model()->current()->withQueue($this->id)->matchingCategory($category)->findAll();

        if($message == null && !empty($notification)){
            
            $notifications = Notifications::model()->findByPk($notification);

            if($notifications){
                $message = $notifications->body;
            }

            if(empty($message)){
                $success = false;
            } else {
                $queueMessage = $this->createNotification($message, $notifications->id, $object_pk, $subject_pk);
                
            }

            
        } else {
            $queueMessage = $this->createMessage($message, $object_pk, $subject_pk);
        }

        if ($this->beforeSend($queueMessage) !== true) {
            Yii::log(Yii::t('NfyModule.app', "Not sending message '{msg}' to queue {queue_label}.", array('{msg}' => $queueMessage->body, '{queue_label}' => $this->label)), CLogger::LEVEL_INFO, 'nfy');
            return;
        }

        $success = true;

        

        $trx = $queueMessage->getDbConnection()->getCurrentTransaction() !== null ? null : $queueMessage->getDbConnection()->beginTransaction();

       
        if (!$queueMessage->save()) {
            Yii::log(Yii::t('NfyModule.app', "Failed to save message '{msg}' in queue {queue_label}.", array('{msg}' => $queueMessage->body, '{queue_label}' => $this->label)), CLogger::LEVEL_ERROR, 'nfy');
            return false;
        }
        
        if(!empty($subscriptions)){
            foreach ($subscriptions as $subscription) {
                $simple = true;
                $subscriptionMessage = clone $queueMessage;
                $subscriptionMessage->subscription_id = $subscription->id;
                $subscriptionMessage->message_id = $queueMessage->id;
                if ($this->beforeSendSubscription($subscriptionMessage, $subscription->subscriber_id) !== true) {
                    continue;
                }
                if($notifications){
                    $user_notification = UserNotification::model()->find('user_id=:user_id and notification_id=:notification_id',array(':user_id'=>$subscription->subscriber_id,':notification_id'=>$notification));
                
                    if($user_notification && $user_notification->by_email == true){
                        if(!$this->sendMessageByEmail($queueMessage, $subscription)) {
                           Yii::log(Yii::t('NfyModule.app', "Failed to send message '{msg}' by email in queue {queue_label} for the subscription {subscription_id}.", array(
                                '{msg}' => $queueMessage->body,
                                '{queue_label}' => $this->label,
                                '{subscription_id}' => $subscription->id,
                            )), CLogger::LEVEL_ERROR, 'nfy');
                            $success = false;  
                        }
                    }

                    if($notifications->available == false){ // not send simple notification
                        $simple = false;
                    }
                    
                } 
                if ($simple == false) {
                    continue;
                }
                
                if (!$subscriptionMessage->save()) {
                    Yii::log(Yii::t('NfyModule.app', "Failed to save message '{msg}' in queue {queue_label} for the subscription {subscription_id}.", array(
                        '{msg}' => $queueMessage->body,
                        '{queue_label}' => $this->label,
                        '{subscription_id}' => $subscription->id,
                    )), CLogger::LEVEL_ERROR, 'nfy');
                    $success = false;
                }

                $this->afterSendSubscription($subscriptionMessage, $subscription->subscriber_id);
            }
        }

        $this->afterSend($queueMessage);

        if ($trx !== null) {
            $trx->commit();
        }

        Yii::log(Yii::t('NfyModule.app', "Sent message '{msg}' to queue {queue_label}.", array('{msg}' => $queueMessage->body, '{queue_label}' => $this->label)), CLogger::LEVEL_INFO, 'nfy');
//.........这里部分代码省略.........
开发者ID:Aplay,项目名称:Fastreview_site,代码行数:101,代码来源:NfyDbQueue.php

示例9: loadModel

 /**
  * 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.
  * @param string $id the identifier of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Notifications::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('http_status', 404));
     }
     return $model;
 }
开发者ID:Gnafu,项目名称:wiz,代码行数:13,代码来源:NotificationsController.php

示例10: if

							    	if ($("#form-changepassword").valid()) { return true } else { return false }
				        		}', 'success' => "function(html) {\n\t\t\t\t\t\t\t\t     if (html.indexOf('{')==0) {\n\t\t\t\t\t\t\t\t     \tvar obj = jQuery.parseJSON(html);\n\t\t\t\t\t\t\t\t     \tvar mes = '';\n\t\t\t\t\t\t\t\t     \tif(obj.UserChangePassword_oldPassword)\n\t\t\t\t\t\t\t\t     \t\tmes = mes + obj.UserChangePassword_oldPassword + '<br>';\n\t\t\t\t\t\t\t\t     \tif(obj.UserChangePassword_password)\n\t\t\t\t\t\t\t\t     \t\tmes = mes + obj.UserChangePassword_password + '<br>';\n\t\t\t\t\t\t\t\t     \tif(obj.UserChangePassword_verifyPassword)\n\t\t\t\t\t\t\t\t     \t\tmes = mes + obj.UserChangePassword_verifyPassword + '<br>';\n\t\t\t\t\t\t\t\t        \$.growl.error({ message: mes});\n\t\t\t\t\t\t\t\t     }\n\t\t\t\t\t\t\t\t     else {\n\t\t\t\t\t\t\t\t     \t \$.growl.notice({ message: '" . Yii::t('site', 'Password saved successfully') . "' });\n\t\t\t\t\t\t\t\t     }\n\t\t\t\t\t\t\t\t}", 'error' => "function(jqXHR, textStatus, errorThrown) {\n\t\t\t\t\t\t\t\t     \$.growl.error({ message: textStatus +'  '+errorThrown});\n\t\t\t\t\t\t\t\t}"), array('encode' => false, 'class' => 'btn btn-primary pull-right'));
?>
				</div>
				</div>
				<?php 
$this->endWidget();
?>
			</div>
			<div class="panel-footer">
				<div class="form-group no-margin tab-content-padding">
				<?php 
// echo CHtml::link(Yii::t('site', 'Delete account'),Yii::app()->createUrl('/users/admin/default/delete',array('id'=>$user->id)), array('class'=>'pull-left', 'title'=>Yii::t('site', 'Delete account'), 'confirm' => Yii::t('site','Do you really want to delete account? Recovery will not be available.')));
?>
				</div>
			</div>
	</div>
</div>
</div>
<?php 
$src = $themeUrl . '/img/avatars/male.png';
$availableNotifications = CHtml::listData(Notifications::model()->findAll(array('condition' => 'available_email=:available', 'params' => array(':available' => true), 'order' => 'id')), 'id', 'form_title');
$availableNotificationsArray = array();
if (!empty($availableNotifications)) {
    foreach ($availableNotifications as $key => $value) {
        $availableNotificationsArray[] = array('value' => $key, 'text' => $value);
    }
}
$setArray = CJSON::encode($availableNotificationsArray);
$scriptDd = "\n\$(document).ready(function(){\n\n\n\nvar dropzone = new Dropzone('#profileAvatarAdd', {\n\t    // Prevents Dropzone from uploading dropped files immediately\n\t\tautoProcessQueue: true,\n\t\turl: '" . Yii::app()->createUrl('/users/admin/default/addavatar', array('id' => $user->id)) . "',\n\t\tmaxFilesize: 5,\n\t\tparamName: 'qqfile',\n\t\tthumbnailWidth: 160,\n        thumbnailHeight: 160,\n\t\tparams: {\n          '" . $csrfTokenName . "': '" . $csrfToken . "'\n        },\n        previewsContainer : '#profilePreviewAvatar',\n}).on('addedfile', function(file) {\n                \n}).on('success', function(file) {\n\t\tvar src = \$('#profilePreviewAvatar .dz-preview:last .dz-details img').attr('src');\n\t//\t\$('.page-settings .profile-photo').css('width','auto');\n\t\t\$('.my-avatar').attr('src', src);\n\t//\tvar url = src.replace(/^data:image\\/[^;]/, 'data:application/octet-stream');\n    //\t\tlocation.href = url;\n\t\t\n});\n\$('#profileAvatarDelete').on('click', function(e){\n\te.preventDefault();\n    \$.ajax({\n\t\t\t\ttype: 'POST',\n\t\t\t\turl: '" . Yii::app()->createUrl('/users/admin/default/unlink', array('id' => $user->id)) . "',\n\t\t\t\tdata: { '" . $csrfTokenName . "': '" . $csrfToken . "'},\n\t\t}).done(function(data){\n\t\t\t\t\n\t\t\t\t\$('.my-avatar').attr('src', '" . $src . "');\n\t\t\t\tdropzone.removeAllFiles();\n\t\t});\n})\n\$('#bs-x-editable-notifications').editable({\n\t\t//limit: 3,\n\t\ttype:'checklist',\n\t\tsource: " . $setArray . ",\n\t\temptytext: '" . Yii::t('site', 'None') . "',\n\t\tdisplay: function(value, sourceData) {\n\t\t    //display checklist as comma-separated values\n\t\t    var html = [],\n\t\t    checked = \$.fn.editableutils.itemsByValue(value, sourceData);\n\t\t    if(checked.length) {\n\t\t    \t\$.each(checked, function(i, v) { \n\t\t    \t\thtml.push('<span class=\"selNotifsEmail\">'+\$.fn.editableutils.escape(v.text)+ '</span>'); \n\t\t    \t});\n\t\t    \t\$(this).html(html.join(', '));\n\t\n\t\t    } else {\n\t\t    \t\$(this).empty();\n\t\t    }\n\t\t },\n\t\t\n\t    params: function(params) {\n\t\t    //originally params contain pk, name and value\n\t\t    params." . $csrfTokenName . " = '" . $csrfToken . "';\n\t\t    return params;\n\t\t    },\n\t\t'url': '" . Yii::app()->createUrl('/users/admin/default/updateEmailNotification', array('id' => $user->id)) . "'\n\t});\n});\n";
Yii::app()->clientScript->registerScript("selScript", $scriptDd, CClientScript::POS_END);
开发者ID:Aplay,项目名称:myhistorypark_site,代码行数:31,代码来源:view.php

示例11: actionLogs

 public function actionLogs($type)
 {
     if ($type == 'system') {
         $logs = Notifications::model()->findAllByAttributes(array('creator_id' => 0), array('order' => 'time DESC'));
     } else {
         $logs = Notifications::model()->findAll(array('condition' => 'creator_id > 0', 'order' => 'time DESC'));
     }
     $this->render('logs/index', array('type' => $type, 'logs' => $logs));
 }
开发者ID:mrtos,项目名称:OpenNVR,代码行数:9,代码来源:AdminController.php

示例12: addLikeNotification

 public function addLikeNotification($from, $post_id, $to)
 {
     $user_from = User::model()->findByPk($from);
     //  $user_to = User::model()->findByPk($to);
     if ($from != Yii::app()->session['user_id']) {
         $arr_noti = array('user_id' => $from, 'content' => "{$user_from->username} vừa thích bài post của bạn", 'type' => 'like', 'recipient_id' => $to, 'url' => Yii::app()->createAbsoluteUrl('post/viewPost', array('post_id' => $post_id, array('ref' => 'noti'))));
         Notifications::model()->add($arr_noti);
         //  var_dump($res); die;
     }
 }
开发者ID:huynt57,项目名称:fashion,代码行数:10,代码来源:Posts.php

示例13: actionMarkSeen

 public function actionMarkSeen()
 {
     $request = Yii::app()->request;
     try {
         $noti_id = StringHelper::filterString($request->getPost('noti_id'));
         $data = Notifications::model()->markSeen($noti_id);
         ResponseHelper::JsonReturnSuccess($data, "Success");
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
开发者ID:huynt57,项目名称:fashion,代码行数:11,代码来源:NotificationController.php


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