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


PHP notification::send_notification方法代码示例

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


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

示例1: class_notcompleted_handler

 /**
  * Function to handle class not completed events.
  *
  * @param   student  $student  The class enrolment / student object who is "not completed"
  * @uses    $CFG
  * @uses    $DB
  * @return  boolean            TRUE is successful, otherwise FALSE
  */
 public static function class_notcompleted_handler($student)
 {
     global $CFG, $DB;
     require_once elispm::lib('notifications.php');
     /// Does the user receive a notification?
     $sendtouser = elis::$config->local_elisprogram->notify_classnotcompleted_user;
     $sendtorole = elis::$config->local_elisprogram->notify_classnotcompleted_role;
     $sendtosupervisor = elis::$config->local_elisprogram->notify_classnotcompleted_supervisor;
     /// If nobody receives a notification, we're done.
     if (!$sendtouser && !$sendtorole && !$sendtosupervisor) {
         return true;
     }
     if (!empty($student->moodlecourseid)) {
         if (!($context = context_course::instance($student->moodlecourseid))) {
             if (in_cron()) {
                 mtrace(get_string('invalidcontext'));
             } else {
                 debugging(get_string('invalidcontext'));
             }
             return true;
         }
     } else {
         $context = context_system::instance();
     }
     $message = new notification();
     /// Set up the text of the message
     $text = empty(elis::$config->local_elisprogram->notify_classnotcompleted_message) ? get_string('notifyclassnotcompletedmessagedef', self::LANG_FILE) : elis::$config->local_elisprogram->notify_classnotcompleted_message;
     $search = array('%%userenrolname%%', '%%classname%%', '%%coursename%%');
     $user = new user($student->userid);
     if (!$user) {
         if (in_cron()) {
             mtrace(get_string('nouser', 'local_elisprogram'));
         } else {
             debugging(get_string('nouser', 'local_elisprogram'));
         }
         return true;
     }
     $user->load();
     // Get course info
     $pmcourse = $DB->get_record(course::TABLE, array('id' => $student->courseid));
     $pmclass = $DB->get_record(pmclass::TABLE, array('id' => $student->classid));
     $replace = array($user->moodle_fullname(), $pmclass->idnumber, $pmcourse->name);
     $text = str_replace($search, $replace, $text);
     $eventlog = new Object();
     $eventlog->event = 'class_notcompleted';
     $eventlog->instance = $student->classid;
     $eventlog->fromuserid = $user->id;
     if ($sendtouser) {
         $message->send_notification($text, $user, null, $eventlog);
     }
     $users = array();
     if ($sendtorole) {
         /// Get all users with the notify_classnotcomplete capability.
         if ($roleusers = get_users_by_capability($context, 'local/elisprogram:notify_classnotcomplete')) {
             $users = $users + $roleusers;
         }
     }
     if ($sendtosupervisor) {
         /// Get parent-context users.
         if ($supervisors = pm_get_users_by_capability('user', $user->id, 'local/elisprogram:notify_classnotcomplete')) {
             $users = $users + $supervisors;
         }
     }
     // Send notifications to any users who need to receive them.
     foreach ($users as $touser) {
         $message->send_notification($text, $touser, $user, $eventlog);
     }
     return true;
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:77,代码来源:student.class.php

示例2: course_recurrence_handler

 /**
  * Function to handle course recurrence events.
  *
  * @param   user      $user  CM user object representing the user in the course
  *
  * @return  boolean          TRUE is successful, otherwise FALSE
  */
 public static function course_recurrence_handler($user)
 {
     global $CFG, $CURMAN;
     require_once $CFG->dirroot . '/curriculum/lib/notifications.php';
     /// Does the user receive a notification?
     $sendtouser = $CURMAN->config->notify_courserecurrence_user;
     $sendtorole = $CURMAN->config->notify_courserecurrence_role;
     $sendtosupervisor = $CURMAN->config->notify_courserecurrence_supervisor;
     /// If nobody receives a notification, we're done.
     if (!$sendtouser && !$sendtorole && !$sendtosupervisor) {
         return true;
     }
     $context = get_system_context();
     /// Make sure this is a valid user.
     $enroluser = new user($user->id);
     if (empty($enroluser->id)) {
         print_error('nouser', 'block_curr_admin');
         return true;
     }
     $message = new notification();
     /// Set up the text of the message
     $text = empty($CURMAN->config->notify_courserecurrence_message) ? get_string('notifycourserecurrencemessagedef', 'block_curr_admin') : $CURMAN->config->notify_courserecurrence_message;
     $search = array('%%userenrolname%%', '%%coursename%%');
     $replace = array(fullname($user), $user->coursename);
     $text = str_replace($search, $replace, $text);
     $eventlog = new Object();
     $eventlog->event = 'course_recurrence';
     $eventlog->instance = $user->enrolmentid;
     $eventlog->fromuserid = $user->id;
     if ($sendtouser) {
         $message->send_notification($text, $user, null, $eventlog);
     }
     $users = array();
     if ($sendtorole) {
         /// Get all users with the notify_courserecurrence capability.
         if ($roleusers = get_users_by_capability($context, 'block/curr_admin:notify_courserecurrence')) {
             $users = $users + $roleusers;
         }
     }
     if ($sendtosupervisor) {
         /// Get parent-context users.
         if ($supervisors = cm_get_users_by_capability('user', $user->id, 'block/curr_admin:notify_courserecurrence')) {
             $users = $users + $supervisors;
         }
     }
     foreach ($users as $u) {
         $message->send_notification($text, $u, $enroluser, $eventlog);
     }
     return true;
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:57,代码来源:course.class.php

示例3: curriculum_notcompleted_handler

 /**
  * Function to handle curriculum not completed events.
  *
  */
 public static function curriculum_notcompleted_handler($curstudent)
 {
     global $CFG, $DB;
     require_once elispm::lib('notifications.php');
     /// Does the user receive a notification?
     $sendtouser = elis::$config->local_elisprogram->notify_curriculumnotcompleted_user;
     $sendtorole = elis::$config->local_elisprogram->notify_curriculumnotcompleted_role;
     $sendtosupervisor = elis::$config->local_elisprogram->notify_curriculumnotcompleted_supervisor;
     /// If nobody receives a notification, we're done.
     if (!$sendtouser && !$sendtorole && !$sendtosupervisor) {
         return true;
     }
     $context = context_system::instance();
     // Send notifications
     $message = new notification();
     /// Set up the text of the message
     $text = empty(elis::$config->local_elisprogram->notify_curriculumnotcompleted_message) ? get_string('notifycurriculumnotcompletedmessagedef', 'local_elisprogram') : elis::$config->local_elisprogram->notify_curriculumnotcompleted_message;
     $user = new user($curstudent->userid);
     if (!$user) {
         return true;
     }
     $user->load();
     // Get course info
     $program = $DB->get_record(curriculum::TABLE, array('id' => $curstudent->curriculumid));
     $search = array('%%userenrolname%%', '%%programname%%');
     $replace = array($user->moodle_fullname(), $program->name);
     $text = str_replace($search, $replace, $text);
     $eventlog = new Object();
     $eventlog->event = 'curriculum_notcompleted';
     $eventlog->instance = $curstudent->id;
     /// Store the assignment id.
     $eventlog->fromuserid = $user->id;
     if ($sendtouser) {
         $message->send_notification($text, $user, null, $eventlog);
     }
     $users = array();
     if ($sendtorole) {
         /// Get all users with the notify_curriculumnotcomplete capability.
         if ($roleusers = get_users_by_capability($context, 'local/elisprogram:notify_programnotcomplete')) {
             $users = $users + $roleusers;
         }
     }
     if ($sendtosupervisor) {
         /// Get parent-context users.
         if ($supervisors = pm_get_users_by_capability('user', $user->id, 'local/elisprogram:notify_programnotcomplete')) {
             $users = $users + $supervisors;
         }
     }
     foreach ($users as $u) {
         $message->send_notification($text, $u, $user, $eventlog);
     }
     return true;
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:57,代码来源:curriculumstudent.class.php

示例4: notify

 public static function notify($text = '', $userto = null, $userfrom = null)
 {
     $message = new notification();
     $message->send_notification($text, $userto, $userfrom);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:5,代码来源:notifications.php

示例5: course_recurrence_handler

 /**
  * Function to handle course recurrence events.
  *
  * @param   user      $user  CM user object representing the user in the course
  *
  * @return  boolean          TRUE is successful, otherwise FALSE
  */
 public static function course_recurrence_handler($user)
 {
     global $DB;
     require_once elispm::lib('notifications.php');
     /// Does the user receive a notification?
     $sendtouser = elis::$config->local_elisprogram->notify_courserecurrence_user;
     $sendtorole = elis::$config->local_elisprogram->notify_courserecurrence_role;
     $sendtosupervisor = elis::$config->local_elisprogram->notify_courserecurrence_supervisor;
     /// If nobody receives a notification, we're done.
     if (!$sendtouser && !$sendtorole && !$sendtosupervisor) {
         return true;
     }
     $context = context_system::instance();
     /// Make sure this is a valid user.
     $enroluser = new user($user->userid);
     if (!$enroluser) {
         if (in_cron()) {
             mtrace(get_string('nouser', 'local_elisprogram'));
         } else {
             print_error('nouser', 'local_elisprogram');
         }
         return true;
     }
     // Due to lazy loading, we need to pre-load this object
     $enroluser->load();
     if (empty($enroluser->id)) {
         if (in_cron()) {
             mtrace(get_string('nouser', 'local_elisprogram'));
         } else {
             print_error('nouser', 'local_elisprogram');
         }
         return true;
     }
     /// Set up the text of the message
     $message = new notification();
     $text = empty(elis::$config->local_elisprogram->notify_courserecurrence_message) ? get_string('notifycourserecurrencemessagedef', 'local_elisprogram') : elis::$config->local_elisprogram->notify_courserecurrence_message;
     $search = array('%%userenrolname%%', '%%coursename%%');
     $replace = array($enroluser->moodle_fullname(), $user->coursename);
     $text = str_replace($search, $replace, $text);
     $eventlog = new Object();
     $eventlog->event = 'course_recurrence';
     $eventlog->instance = $user->enrolmentid;
     $eventlog->fromuserid = $enroluser->id;
     if ($sendtouser) {
         $message->send_notification($text, $enroluser, null, $eventlog);
     }
     $users = array();
     if ($sendtorole) {
         /// Get all users with the notify_courserecurrence capability.
         if ($roleusers = get_users_by_capability($context, 'local/elisprogram:notify_courserecurrence')) {
             $users = $users + $roleusers;
         }
     }
     if ($sendtosupervisor) {
         /// Get parent-context users.
         if ($supervisors = pm_get_users_by_capability('user', $enroluser->id, 'local/elisprogram:notify_courserecurrence')) {
             $users = $users + $supervisors;
         }
     }
     foreach ($users as $u) {
         $message->send_notification($text, $u, $enroluser, $eventlog);
     }
     return true;
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:71,代码来源:course.class.php

示例6: where

 function sent_notice($comment_id)
 {
     //data o knize
     $sql = sql_query("select id, name, orig_name from books\n                          where (id = '" . $this->item . "')");
     $data = sql_fetch_object($sql);
     $url = "kniha";
     $url_param = "-" . make_url($data->id . " " . $data->name . " " . $data->orig_name);
     $url_param .= "#" . $comment_id;
     $type = "new_book_comment";
     $type_param = $data->name;
     $sql = sql_query("select user from follow\n                          where (book = '" . $this->item . "')");
     while ($data = sql_fetch_object($sql)) {
         if ($data->user != $this->uid) {
             $n = new notification($data->user);
             $n->send_notification($type, $type_param, $url, $url_param);
         }
     }
 }
开发者ID:janda2,项目名称:Fitness-shop,代码行数:18,代码来源:comment.php

示例7: clear

 function add_rating()
 {
     $add_rating = clear("add_rating");
     if ($add_rating == 'yes' && $this->uid != $this->id) {
         //zjisteni jestli ma uzivatel alespon 10 komentaru, jinak nejde bodovat
         $s = sql_query("select id from comments\n                            where (user = '" . $this->id . "' and type='book')");
         $num = sql_num_rows($s);
         if ($num < 10) {
             $this->msg->set_text($this->l->t("min_comments"), "error");
         }
         //zjisteni jestli jsem jiz bodoval uzivatele
         $s = sql_query("select id from users_rating\n                            where (user = '" . $this->uid . "' and rated_user = '" . $this->id . "')");
         $d = sql_fetch_object($s);
         if (!$d->id && $this->msg->is_empty()) {
             $s = sql_query("insert into users_rating\n                                (user, rated_user)\n                                values\n                                ('" . $this->uid . "', '" . $this->id . "')");
             if ($s) {
                 $this->rating++;
                 recount("user_rating", $this->id);
                 //zasleme uzivateli info
                 $sql = sql_query("select id, nick from users\n\t\t\t\t\t\t\t\t                      where (id = '" . $this->uid . "')");
                 $data = sql_fetch_object($sql);
                 $url = "uzivatel";
                 $url_param = "-" . make_url($data->id . " " . $data->nick);
                 $type = "user_add_rating";
                 $type_param = $data->nick;
                 $n = new notification($this->id);
                 $n->send_notification($type, $type_param, $url, $url_param);
             }
         }
     }
 }
开发者ID:janda2,项目名称:Fitness-shop,代码行数:31,代码来源:class_user.php


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