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


PHP Notification::find方法代码示例

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


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

示例1: uninstall

 /**
  * Remove mreporting notifications from GLPI.
  * 
  * @return array 'success' => true on success
  */
 static function uninstall()
 {
     global $DB;
     $queries = array();
     // Remove NotificationTargets and Notifications
     $notification = new Notification();
     $result = $notification->find("itemtype = 'PluginMreportingNotification'");
     foreach ($result as $row) {
         $notification_id = $row['id'];
         $queries[] = "DELETE FROM glpi_notificationtargets \n                        WHERE notifications_id = " . $notification_id;
         $queries[] = "DELETE FROM glpi_notifications \n                        WHERE id = " . $notification_id;
     }
     // Remove NotificationTemplateTranslations and NotificationTemplates
     $template = new NotificationTemplate();
     $result = $template->find("itemtype = 'PluginMreportingNotification'");
     foreach ($result as $row) {
         $template_id = $row['id'];
         $queries[] = "DELETE FROM glpi_notificationtemplatetranslations \n                        WHERE notificationtemplates_id = " . $template_id;
         $queries[] = "DELETE FROM glpi_notificationtemplates \n                        WHERE id = " . $template_id;
     }
     foreach ($queries as $query) {
         $DB->query($query);
     }
     return array('success' => true);
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:30,代码来源:notification.class.php

示例2: add

 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;
         }
     }
 }
开发者ID:ph7pal,项目名称:mei,代码行数:26,代码来源:Notification.php

示例3: action

 public function action($app, $id, $action)
 {
     if (!$app->user->isLoggedIn()) {
         $app->output->redirect('/');
     }
     if (!in_array($action, ['read', 'unread', 'delete'])) {
         $app->output->redirect('/');
     }
     try {
         $id_dec = $app->hashids->decrypt($id);
         $notification = Notification::find('first', ['conditions' => ['id = ? AND receiver_id = ? AND deleted = ?', $id_dec, $app->user->id, 0], 'include' => ['user']]);
         if (!$notification) {
             $app->logger->log('No such Notification found', 'ERROR', array('object' => 'Notification', 'id' => $id, 'id_decrypted' => $id_dec, 'pathway' => 'notifications_action'), 'user');
             $app->output->notFound();
         }
         if ($action == 'read' or $action == 'unread') {
             $notification->seen = $action == 'read' ? 1 : 0;
         }
         if ($action == 'delete') {
             $notification->deleted = 1;
         }
         $notification->save();
         $app->output->redirect('/notifications');
     } catch (Hashids_Invalid $e) {
         $app->logger->log('Notification ID given was invalid', 'ERROR', array('object' => 'Notification', 'id' => $id, 'pathway' => 'notifications_action'), 'user');
         $app->output->notFound();
     }
 }
开发者ID:puttyplayer,项目名称:CSGOShop,代码行数:28,代码来源:NotificationController.php

示例4: getNot

 public function getNot($id)
 {
     $u_id = Input::get('u_id', 0);
     $token = Input::get('token', '');
     try {
         $user = User::chkUserByToken($token, $u_id);
         $not = Notification::find($id);
         if (empty($not)) {
             throw new Exception("没有找到请求的数据", 2001);
         }
         $data = $not->showDetail();
         $read = NotificationRead::where('u_id', '=', $u_id)->where('n_id', '=', $id)->first();
         if (empty($read)) {
             $read = new NotificationRead();
             $read->n_id = $id;
             $read->u_id = $u_id;
             $read->is_read = 1;
             $read->is_del = 0;
         } else {
             $read->is_read = 1;
         }
         $read->save();
         $re = Tools::reTrue('获取消息成功', $data);
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '获取消息失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:28,代码来源:MeNotificationController.php

示例5: deleteNotify

 public function deleteNotify($id)
 {
     if (Notification::where('user_id', Auth::user()->id)->where('id', $id)->exists()) {
         $noty = Notification::find($id);
         $noty->delete();
     }
 }
开发者ID:Acikteknoloji,项目名称:acikteknoloji,代码行数:7,代码来源:HomeController.php

示例6: banned

 public function banned($app)
 {
     $app->output->addBreadcrumb('', 'CSGOShop');
     $app->output->addBreadcrumb('/banned', 'Banned Notice');
     $notification = Notification::find('first', array('conditions' => array('receiver_id = ? AND title = "BAN"', $app->user->id)));
     if (!empty($notification)) {
         $app->output->alert($notification->body, 'danger');
     }
     $app->output->setTitle('Banned');
     $app->output->render('about.banned');
 }
开发者ID:puttyplayer,项目名称:CSGOShop,代码行数:11,代码来源:AboutController.php

示例7: install

 public static function install()
 {
     $notifications = array('plugin_formcreator_form_created' => array('name' => __('A form has been created', 'formcreator'), 'subject' => __('Your request have been saved', 'formcreator'), 'content' => __('Hi,\\nYour request from GLPI have been successfully saved with number ##formcreator.request_id## and transmetted to the helpdesk team.\\nYou can see your answers onto the following link:\\n##formcreator.validation_link##', 'formcreator'), 'notified' => self::AUTHOR), 'plugin_formcreator_need_validation' => array('name' => __('A form need to be validate', 'formcreator'), 'subject' => __('A form from GLPI need to be validate', 'formcreator'), 'content' => __('Hi,\\nA form from GLPI need to be validate and you have been choosen as the validator.\\nYou can access it by clicking onto this link:\\n##formcreator.validation_link##', 'formcreator'), 'notified' => self::APPROVER), 'plugin_formcreator_refused' => array('name' => __('The form is refused', 'formcreator'), 'subject' => __('Your form have been refused by the validator', 'formcreator'), 'content' => __('Hi,\\nWe are sorry to inform you that your form have been refused by the validator for the reason below:\\n##formcreator.validation_comment##\\n\\nYou can still modify and resubmit it by clicking onto this link:\\n##formcreator.validation_link##', 'formcreator'), 'notified' => self::AUTHOR), 'plugin_formcreator_accepted' => array('name' => __('The form is accepted', 'formcreator'), 'subject' => __('Your form have been accepted by the validator', 'formcreator'), 'content' => __('Hi,\\nWe are pleased to inform you that your form have been accepted by the validator.\\nYour request will be considered soon.', 'formcreator'), 'notified' => self::AUTHOR), 'plugin_formcreator_deleted' => array('name' => __('The form is deleted', 'formcreator'), 'subject' => __('Your form have been deleted by an administrator', 'formcreator'), 'content' => __('Hi,\\nWe are sorry to inform you that your request cannot be considered and have been deleted by an administrator.', 'formcreator'), 'notified' => self::AUTHOR));
     // Create the notification template
     $notification = new Notification();
     $notification_target = new NotificationTarget();
     $template = new NotificationTemplate();
     $translation = new NotificationTemplateTranslation();
     foreach ($notifications as $event => $datas) {
         // Check if notification allready exists
         $exists = $notification->find("itemtype = 'PluginFormcreatorFormanswer' AND event = '{$event}'");
         // If it doesn't exists, create it
         if (count($exists) == 0) {
             $template_id = $template->add(array('name' => addslashes($datas['name']), 'comment' => '', 'itemtype' => 'PluginFormcreatorFormanswer'));
             // Add a default translation for the template
             $translation->add(array('notificationtemplates_id' => $template_id, 'language' => '', 'subject' => addslashes($datas['subject']), 'content_text' => addslashes($datas['content']), 'content_html' => '<p>' . str_replace('\\n', '<br />', $datas['content']) . '</p>'));
             // Create the notification
             $notification_id = $notification->add(array('name' => addslashes($datas['name']), 'comment' => '', 'entities_id' => 0, 'is_recursive' => 1, 'is_active' => 1, 'itemtype' => 'PluginFormcreatorFormanswer', 'notificationtemplates_id' => $template_id, 'event' => $event, 'mode' => 'mail'));
             // Add default notification targets
             $notification_target->add(array("items_id" => $datas['notified'], "type" => Notification::USER_TYPE, "notifications_id" => $notification_id));
         }
     }
 }
开发者ID:ChristopheG77,项目名称:formcreator,代码行数:23,代码来源:notificationtargetformanswer.class.php

示例8: Exception

<?php

include '../../inc/init.inc';
if (isset($notification)) {
    $notification = Notification::find($notification);
    if (isset($type) && $type == "updateStatus") {
        if ($notification->to_user_id != $res->user->id) {
            throw new Exception("user is not autorized", 504, $res->user->id);
        }
        $notification->status = 1;
        $notification->save();
    }
}
isset($redirect) ? $res->load($notification->action) : "";
开发者ID:Osin,项目名称:Intranet,代码行数:14,代码来源:action.notification.php

示例9: fechar

 /**
  * CLOSE NOTIFICATION (no destroy)
  *
  * @param  int  $id
  * @return Response
  */
 public static function fechar($id)
 {
     if (!isset($id)) {
         return Response::json(array('error' => 'ID não informado'));
     }
     if ($notification = Notification::find($id)) {
         if ($notification->status) {
             $notification->status = 0;
             $notification->save();
             $alert[] = ['class' => 'alert-success', 'message' => '<strong><i class="fa fa-check"></i></strong> Notificação marcada como não lida!'];
             Session::flash('alerts', $alert);
             return Redirect::to(URL::previous());
         }
         $notification->close();
     }
     return Response::json(array('success' => true));
 }
开发者ID:waldenylson,项目名称:alfredapp,代码行数:23,代码来源:NotificationsController.php

示例10: viewNotification

 public function viewNotification($id)
 {
     try {
         $notification = Notification::find($id);
         if ($notification) {
             $notification->seen = 2;
             if ($notification->type == 1) {
                 $notification->like = Like::wherePostId($notification->post_id)->get()->count();
                 $notification->dislike = Dislike::wherePostId($notification->post_id)->get()->count();
             } elseif ($notification->type == 2) {
                 $notification->comment = Comment::wherePostId($notification->post_id)->get()->count();
                 //$notification->save();
             }
             $notification->save();
             return Redirect::to('/singlepost/' . $notification->post_id);
         }
         return "Unauthorized Access Of Notification";
     } catch (Exception $e) {
     }
     return "Unauthorized Access Of Notification";
 }
开发者ID:nayeemjoy,项目名称:maskcamp,代码行数:21,代码来源:UsersController.php

示例11: action_mark_as_read

        $view = View::make('notifications.index');
        $view->notifications = Auth::user()->notifications_received()->order_by('created_at', 'desc')->paginate(10);
        $this->layout->content = $view;
    }
    public function action_mark_as_read()
    {
        $notification = Config::get('notification');
        if (Input::get('action') == '1') {
            $notification->mark_as_read();
        } else {
            $notification->mark_as_unread();
        }
        return Response::json(array("status" => "success", "unread_count" => Auth::user()->unread_notification_count(), "html" => View::make('notifications.partials.notification')->with('notification', $notification)->render()));
    }
    public function action_json()
    {
        $return_array = array();
        foreach (Auth::user()->notifications_received()->order_by('read')->order_by('created_at', 'desc')->take(3)->get() as $notification) {
            $return_array[] = array('object' => $notification->to_array(), 'parsed' => NotificationParser::parse($notification));
        }
        return Response::json(array('status' => 'success', 'results' => $return_array, 'count' => Auth::user()->notifications_received()->count()));
    }
}
Route::filter('i_am_notification_target', function () {
    $id = Request::$route->parameters[0];
    $notification = Notification::find($id);
    if (!Auth::user() || Auth::user()->id != $notification->target_id) {
        return Redirect::to('/');
    }
    Config::set('notification', $notification);
});
开发者ID:ajb,项目名称:rfpez,代码行数:31,代码来源:notifications.php

示例12: sendEmail

 function sendEmail($toEmail, $notification_title, $data = null)
 {
     $sent = false;
     if (!empty($toEmail)) {
         $config = $this->getConfiguration();
         $this->Email->from = $config['domain_name'] . '<' . $config['donotreplay_email'] . '>';
         $this->Email->to = $toEmail;
         $this->Email->sendAs = 'html';
         App::import('Model', 'Notification');
         $objNotification = new Notification();
         $options = array('conditions' => array('title' => $notification_title));
         $notification = $objNotification->find('first', $options);
         if (!empty($notification)) {
             $this->Email->subject = $notification['Notification']['subject'];
             $this->Email->cc = $notification['Notification']['cc'];
             $this->Email->bcc = $notification['Notification']['bcc'];
             $message = $this->_getMessage($notification, $data);
             $sent = $this->Email->send($message);
         }
         return $sent;
     }
 }
开发者ID:shashin62,项目名称:abc_audit,代码行数:22,代码来源:app_controller.php

示例13: preRenderSetup

 private function preRenderSetup()
 {
     $app =& $this->app;
     $page = ['alerts' => $this->alerts, 'title' => $this->title, 'activeTab' => $this->activeTab, 'breadcrumbs' => $this->breadcrumbs];
     if ($app->user->isSiteDeveloper()) {
         $page['profiler'] = $app->profiler->fetch();
     }
     $this->twig->addGlobal('page', $page);
     $this->twig->addFunction(new Twig_SimpleFunction('config', function ($key) use(&$app) {
         return $app->config->get($key);
     }));
     $this->twig->addFunction(new Twig_SimpleFunction('relative_time', function ($time = false, $limit = 86400, $format = 'g:i A M jS') {
         if (is_object($time)) {
             $time = $time->format('db');
         }
         if (is_string($time)) {
             $time = strtotime($time);
         }
         $now = time();
         $relative = '';
         if ($time === $now) {
             $relative = 'now';
         } elseif ($time > $now) {
             //$relative = 'in the future';
             $diff = $time - $now;
             if ($diff >= $limit) {
                 $relative = date($format, $time);
             } elseif ($diff < 60) {
                 $relative = 'less than one minute';
             } elseif (($minutes = ceil($diff / 60)) < 60) {
                 $relative = $minutes . ' minute' . ((int) $minutes === 1 ? '' : 's');
             } else {
                 $hours = ceil($diff / 3600);
                 $relative = 'about ' . $hours . ' hour' . ((int) $hours === 1 ? '' : 's');
             }
         } else {
             $diff = $now - $time;
             if ($diff >= $limit) {
                 $relative = date($format, $time);
             } elseif ($diff < 60) {
                 $relative = 'less than one minute ago';
             } elseif (($minutes = ceil($diff / 60)) < 60) {
                 $relative = $minutes . ' minute' . ((int) $minutes === 1 ? '' : 's') . ' ago';
             } else {
                 $hours = ceil($diff / 3600);
                 $relative = 'about ' . $hours . ' hour' . ((int) $hours === 1 ? '' : 's') . ' ago';
             }
         }
         return $relative;
     }));
     $this->twig->addFunction(new Twig_SimpleFunction('markdown', function ($data) {
         return $this->markdown->text($data);
     }));
     $this->twig->addFunction(new Twig_SimpleFunction('hashid', function ($id) use(&$app) {
         return $app->hashids->encrypt($id);
     }));
     $this->twig->addFunction(new Twig_SimpleFunction('truncate', function ($text, $limit = 40) {
         if (strlen($text) < $limit) {
             return $text;
         }
         $text = $text . " ";
         $text = substr($text, 0, $limit);
         $text = substr($text, 0, strrpos($text, ' '));
         $text = $text . "...";
         return $text;
     }));
     $this->twig->addFunction(new Twig_SimpleFunction('money_format', function ($amount) {
         if (!function_exists('money_format')) {
             sprintf('$%.2f', $amount);
         }
         // require_once('./libs/utils/money_format.php');
         return money_format('$%.2n', $amount);
     }));
     $this->twig->addFunction(new Twig_SimpleFunction('imgur_thumb', function ($link, $type = 'm') {
         return preg_replace('/(\\.gif|\\.jpg|\\.png)/', $type . '$1', $link);
     }));
     $this->twig->addGlobal('user', $app->user);
     $this->twig->addGlobal('total_users', count(User::find('all')));
     $this->twig->addGlobal('total_stock', count(Listing::find('all', array('conditions' => array('stage = ?', Listing::STAGE_LIST)))));
     $this->twig->addGlobal('total_ordered', count(Listing::find('all', array('conditions' => array('stage IN (?)', array(Listing::STAGE_COMPLETE, Listing::STAGE_ARCHIVE))))));
     if ($app->user->isLoggedIn()) {
         $notification_count = count(Notification::find('all', ['conditions' => ['receiver_id = ? AND seen = ? AND deleted = ?', $app->user->id, 0, 0]]));
         $this->twig->addGlobal('notification_count', $notification_count);
     }
     if (!empty($_SESSION['cart'])) {
         $cart_count = array_reduce(array_merge($_SESSION['cart']['listings'], $_SESSION['cart']['bulk']), function ($carry, $item) {
             $carry += $item['qty'];
             return $carry;
         }) ?: 0;
     } else {
         $cart_count = 0;
     }
     $this->twig->addGlobal('cart_count', $cart_count);
 }
开发者ID:puttyplayer,项目名称:CSGOShop,代码行数:94,代码来源:Output.class.php


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