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


PHP notification::notify方法代码示例

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


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

示例1: add

 /**
  * Perform all necessary tasks to add a student enrolment to the system.
  *
  * @param array $checks what checks to perform before adding enrolling the
  * user.  e.g. array('prereq' => 1, 'waitlist' => 1) will check that
  * prerequisites are satisfied, and that the class is not full
  * @param boolean $notify whether or not notifications should be sent if a
  * check fails
  */
 function add($checks = array(), $notify = false)
 {
     global $CURMAN, $CFG, $USER;
     $status = true;
     if ($CURMAN->db->record_exists(STUTABLE, 'userid', $this->userid, 'classid', $this->classid)) {
         // already enrolled -- pretend we succeeded
         return true;
     }
     // check that the student can be enrolled first
     if (!empty($checks['prereq'])) {
         // check prerequisites
         $cmclass = new cmclass($this->classid);
         // get all the curricula that the user is in
         $curricula = curriculumstudent::get_curricula($this->userid);
         foreach ($curricula as $curriculum) {
             $curcrs = new curriculumcourse();
             $curcrs->courseid = $cmclass->courseid;
             $curcrs->curriculumid = $curriculum->curid;
             if (!$curcrs->prerequisites_satisfied($this->userid)) {
                 // prerequisites not satisfied
                 if ($notify) {
                     $data = new stdClass();
                     $data->userid = $this->userid;
                     $data->classid = $this->classid;
                     //$data->trackid = $trackid;
                     events_trigger('crlm_prereq_unsatisfied', $data);
                 }
                 $status = new Object();
                 $status->message = get_string('unsatisfiedprereqs', 'block_curr_admin');
                 $status->code = 'unsatisfiedprereqs';
                 return $status;
             }
         }
     }
     if (!empty($checks['waitlist'])) {
         // check class enrolment limit
         $cmclass = new cmclass($this->classid);
         $limit = $cmclass->maxstudents;
         if (!empty($limit) && $limit <= student::count_enroled($this->classid)) {
             // class is full
             // put student on wait list
             $wait_list = new waitlist($this);
             $wait_list->timecreated = time();
             $wait_list->position = 0;
             $wait_list->add();
             if ($notify) {
                 $subject = get_string('user_waitlisted', 'block_curr_admin');
                 $a = new object();
                 $a->user = $this->user->idnumber;
                 $a->cmclass = $cmclass->idnumber;
                 $message = get_string('user_waitlisted_msg', 'block_curr_admin', $a);
                 $from = $user = get_admin();
                 notification::notify($message, $user, $from);
                 email_to_user($user, $from, $subject, $message);
             }
             $status = new Object();
             $status->message = get_string('user_waitlisted', 'block_curr_admin');
             $status->code = 'user_waitlisted';
             return $status;
         }
     }
     //set end time based on class duration
     $studentclass = new cmclass($this->classid);
     if (empty($this->endtime)) {
         if (isset($studentclass->duration) && $studentclass->duration) {
             $this->endtime = $this->enrolmenttime + $studentclass->duration;
         } else {
             // no class duration -> no end time
             $this->endtime = 0;
         }
     }
     $status = $this->data_insert_record();
     // TBD: we should check this!
     /// Get the Moodle user ID or create a new account for this user.
     if (!($muserid = cm_get_moodleuserid($this->userid))) {
         $user = new user($this->userid);
         if (!($muserid = $user->synchronize_moodle_user(true, true))) {
             $status = new Object();
             $status->message = get_string('errorsynchronizeuser', 'block_curr_admin');
             $muserid = false;
         }
     }
     /// Enrol them into the Moodle class.
     if ($moodlecourseid = moodle_get_course($this->classid)) {
         if ($mcourse = get_record('course', 'id', $moodlecourseid)) {
             $enrol = $mcourse->enrol;
             if (!$enrol) {
                 $enrol = $CFG->enrol;
             }
             if ($CURMAN->config->restrict_to_elis_enrolment_plugin && $enrol != 'elis') {
                 $status = new Object();
//.........这里部分代码省略.........
开发者ID:remotelearner,项目名称:elis.cm,代码行数:101,代码来源:student.class.php

示例2: pm_update_student_enrolment

/**
 * Notifies that students have not passed their classes via the notifications where applicable,
 * setting enrolment status to failed where applicable
 *
 * @param int $pmuserid  optional userid to update, default(0) updates all users
 */
function pm_update_student_enrolment($pmuserid = 0)
{
    global $DB;
    require_once elispm::lib('data/student.class.php');
    require_once elispm::lib('notifications.php');
    //look for all enrolments where status is incomplete / in progress and end time has passed
    $select = 'completestatusid = :status AND endtime > 0 AND endtime < :time';
    $params = array('status' => STUSTATUS_NOTCOMPLETE, 'time' => time());
    if ($pmuserid) {
        $select .= ' AND userid = :userid';
        $params['userid'] = $pmuserid;
    }
    $students = $DB->get_recordset_select(student::TABLE, $select, $params);
    if (!empty($students)) {
        foreach ($students as $s) {
            // Send notification, if enabled.
            $sendnotification = !empty(elis::$config->local_elisprogram->notify_incompletecourse_user) ? true : false;
            if ($sendnotification === true) {
                $a = $DB->get_field(pmclass::TABLE, 'idnumber', array('id' => $s->classid));
                $message = get_string('incomplete_course_message', 'local_elisprogram', $a);
                $cuser = new user($s->userid);
                $from = get_admin();
                notification::notify($message, $cuser, $from);
            }
            //set status to failed
            $s->completetime = time();
            $s->completestatusid = STUSTATUS_FAILED;
            $stu = new student($s->id);
            $stu->set_from_data($s);
            $stu->update();
        }
    }
    return true;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:40,代码来源:lib.php

示例3: save

 /**
  *
  */
 public function save()
 {
     $new = false;
     try {
         validation_helper::is_unique_userid_classid($this);
     } catch (Exception $e) {
         // already on waitlist
         return true;
     }
     if (!isset($this->id)) {
         $new = true;
         if (empty($this->position)) {
             $max = $this->_db->get_field(waitlist::TABLE, 'MAX(position)', array('classid' => $this->classid));
             $this->position = $max + 1;
         }
     }
     parent::save();
     $sendnotification = !empty(elis::$config->local_elisprogram->notify_addedtowaitlist_user) ? true : false;
     if ($new && $sendnotification === true) {
         $subject = get_string('waitlist', self::LANG_FILE);
         $pmclass = new pmclass($this->classid);
         $sparam = new stdClass();
         $sparam->idnumber = $pmclass->idnumber;
         $message = get_string('added_to_waitlist_message', self::LANG_FILE, $sparam);
         $cuser = new user($this->userid);
         $cuser->load();
         $from = get_admin();
         notification::notify($message, $cuser, $from);
         //email_to_user($user, $from, $subject, $message); // *TBD*
     }
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:34,代码来源:waitlist.class.php

示例4: add

 /**
  *
  * @global <type> $CURMAN
  */
 public function add()
 {
     global $CURMAN;
     if (empty($this->position)) {
         //SELECT MIN(userid) FROM eli_crlm_wait_list WHERE 1
         $sql = 'SELECT ' . sql_max('position') . ' as max 
                 FROM ' . $CURMAN->db->prefix_table(WATLSTTABLE) . ' as wl
                 WHERE wl.classid = ' . $this->classid;
         $max_record = get_record_sql($sql);
         $max = $max_record->max;
         $this->position = $max + 1;
     }
     $subject = get_string('waitlist', 'block_curr_admin');
     $cmclass = new cmclass($this->classid);
     $message = get_string('added_to_waitlist_message', 'block_curr_admin', $cmclass->idnumber);
     $user = cm_get_moodleuser($this->userid);
     $from = get_admin();
     // Send a notification and e-mail only if the Moodle user exists
     if ($user != null) {
         notification::notify($message, $user, $from);
         email_to_user($user, $from, $subject, $message);
     }
     parent::add();
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:28,代码来源:waitlist.class.php

示例5: cm_update_student_enrolment

/**
 *
 */
function cm_update_student_enrolment()
{
    global $CURMAN;
    //for every student
    $select = 'completestatusid = ' . STUSTATUS_NOTCOMPLETE . ' AND endtime > 0 AND endtime < ' . time();
    $students = $CURMAN->db->get_records_select(STUTABLE, $select);
    if (!empty($students)) {
        foreach ($students as $s) {
            $a = $CURMAN->db->get_field('crlm_class', 'idnumber', 'id', $s->classid);
            $subject = get_string('incomplete_course_subject', 'block_curr_admin');
            $message = get_string('incomplete_course_message', 'block_curr_admin', $a);
            $user = cm_get_moodleuser($s->userid);
            $from = get_admin();
            notification::notify($message, $user, $from);
            email_to_user($user, $from, $subject, $message);
            $s->completetime = 0;
            $s->completestatusid = STUSTATUS_FAILED;
            $CURMAN->db->update_record(STUTABLE, $s);
        }
    }
    return true;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:25,代码来源:lib.php

示例6: approve_request

 /**
  * Helper method for performing actions specific to the back-end approval process
  *
  * @param  object  $request   the request record
  * @param  object  $formdata  the submitted form data
  * @uses   $DB
  * @uses   $USER
  */
 function approve_request($request, $formdata)
 {
     global $DB, $USER;
     // process course-specific actions
     $courseid = $this->approve_request_course_actions($request, $formdata);
     // process class-specific actions
     $this->approve_request_class_actions($request, $formdata, $courseid);
     // update the request with additional information
     $request->requeststatus = 'approved';
     $request->statusnote = $formdata->comments;
     $DB->update_record('block_courserequest', $request);
     // TBV: addslashes_recursive() not required in Moodle 2 ?
     // notify the user of the request status
     $statusnote = null;
     if (!empty($request->statusnote)) {
         $statusnote = $request->statusnote;
     }
     $request->newcourseid = $courseid;
     $notice = block_courserequest_get_approval_message($request, $statusnote);
     $requser = $DB->get_record('user', array('id' => $request->userid));
     $requser->firstname = $formdata->first;
     $requser->lastname = $formdata->last;
     $requser->email = $formdata->email;
     notification::notify($notice, $requser, $USER);
     // redirect back to the listing page
     redirect($this->url, get_string('requestapproved', 'block_courserequest'), 3);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:35,代码来源:approvepage.class.php

示例7: display_create


//.........这里部分代码省略.........
                 if (!($request = $DB->get_record('block_courserequest', array('id' => $requestid)))) {
                     $target = str_replace($CFG->wwwroot, '', $this->url);
                     print_error('errorinvalidrequestid', 'block_courserequest', $target, $requestid);
                 }
                 $target = $this->get_new_page(array('action' => 'approveconfirm'));
                 $approveform = new pending_request_approve_form($target->url, $request);
                 $request->request = $request->id;
                 $approveform->set_data($request);
                 // We're not actually approving the request, redirect back to the approval table.
                 if ($approveform->is_cancelled()) {
                     redirect($this->url, '', 0);
                 }
                 // Do we have to create a brand new course?
                 if (empty($request->courseid)) {
                     $crsdata = array('name' => $request->title, 'idnumber' => $data->crsidnumber, 'syllabus' => '');
                     $newcourse = new course($crsdata);
                     if (!empty($config->use_course_fields)) {
                         // course fields are enabled, so add the relevant data
                         $this->add_custom_fields($request->id, 'course', $newcourse);
                     }
                     $newcourse->save();
                     // ->add()
                     // do the course role assignment, if applicable
                     if (!empty($config->course_role)) {
                         if ($context = \local_elisprogram\context\course::instance($newcourse->id)) {
                             // TBD: role_assign() now throws exceptions!
                             $result = role_assign($config->course_role, $request->userid, $context->id, ECR_CD_ROLE_COMPONENT);
                         }
                     }
                     $courseid = $newcourse->id;
                 } else {
                     $courseid = $request->courseid;
                     // TBV: addslashes()
                 }
                 // Create the new class if we are using an existing course, or if
                 // create_class_with_course is on.
                 if (!empty($request->courseid) || !empty($config->create_class_with_course)) {
                     require_once $CFG->dirroot . '/local/elisprogram/lib/data/pmclass.class.php';
                     $clsdata = array('name' => $request->title, 'courseid' => $courseid, 'idnumber' => $data->clsidnumber, 'starttimehour' => 25, 'starttimeminute' => 61, 'endtimehour' => 25, 'endtimeminute' => 61);
                     $newclass = new pmclass($clsdata);
                     $newclass->autocreate = false;
                     if (!empty($config->use_class_fields)) {
                         // class fields are enabled, so add the relevant data
                         $this->add_custom_fields($request->id, 'class', $newclass);
                     }
                     $newclass->save();
                     // ->add()
                 }
                 // Update the request record to mark it as being approved.
                 $request->requeststatus = 'approved';
                 $request->statusnote = '';
                 $DB->update_record('block_courserequest', $request);
                 // TBV: addslashes_object()
                 // assign role to requester in the newly created class
                 if (!empty($newclass->id)) {
                     if (!empty($config->class_role)) {
                         $context = \local_elisprogram\context\pmclass::instance($newclass->id);
                         // TBD: role_assign() now throws exceptions!
                         role_assign($config->class_role, $request->userid, $context->id, ECR_CI_ROLE_COMPONENT);
                     }
                 }
                 // create a new Moodle course from the course template if applicable
                 if (!empty($data->usecoursetemplate) && !empty($newclass->id)) {
                     moodle_attach_class($newclass->id, 0, '', true, true, true);
                     // copy role over into Moodle course
                     if (!empty($config->class_role)) {
                         require_once $CFG->dirroot . '/local/elisprogram/lib/data/classmoodlecourse.class.php';
                         if ($class_moodle_record = $DB->get_record(classmoodlecourse::TABLE, array('classid' => $newclass->id))) {
                             $context = context_course::instance($class_moodle_record->moodlecourseid);
                             // TBD: role_assign() now throws exceptions!
                             role_assign($config->class_role, $request->userid, $context->id, ECR_MC_ROLE_COMPONENT);
                         }
                     }
                 }
                 // Send a notification to the requesting user that their course / class is ready.
                 // set additional course / class information for use in the message
                 if (isset($newclass->idnumber) && isset($newclass->id)) {
                     $request->classidnumber = $newclass->idnumber;
                     $request->classid = $newclass->id;
                 }
                 $request->newcourseid = $courseid;
                 // calculate the actual message
                 $notice = block_courserequest_get_approval_message($request);
                 // send it to the requester
                 notification::notify($notice, $DB->get_record('user', array('id' => $request->userid)));
                 print_string('request_submitted_and_auto_approved', 'block_courserequest');
             } else {
                 // find users with approve capabilities in the system context
                 $admin = get_users_by_capability($syscontext, 'block/courserequest:approve');
                 foreach ($admin as $userto) {
                     notification::notify(get_string('new_request_notification', 'block_courserequest', $data), $userto);
                 }
                 print_string('request_submitted', 'block_courserequest');
             }
             redirect($this->url);
             return;
         }
     }
     $form->display();
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:101,代码来源:requestpage.php


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