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


PHP SMS::notify方法代码示例

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


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

示例1: cron

 function cron()
 {
     global $CFG;
     echo "\n\n****** moodle_notifications :: begin ******";
     $User = new User();
     // clean deleted users data
     $User->collect_garbage();
     $Course = new Course();
     // clean deleted courses data
     $Course->collect_garbage();
     // get the list of courses that are using this block
     $courses = $Course->get_all_courses_using_moodle_notifications_block();
     // if no courses are using this block exit
     if (!is_array($courses) or count($courses) < 1) {
         echo "\n--> None course is using moodle_notifications plugin.";
         echo "\n****** moodle_notifications :: end ******\n\n";
         return;
     }
     foreach ($courses as $course) {
         // if course is not visible then skip
         if ($course->visible == 0) {
             continue;
         }
         // if the course has not been registered so far then register
         echo "\n--> Processing course: {$course->fullname}";
         if (!$Course->is_registered($course->id)) {
             $Course->register($course->id, time());
         }
         // check notification frequency for this course
         $course_registration = $Course->get_registration($course->id);
         // initialize user preferences and check for new enrolled users in this course
         $enrolled_users = $User->get_all_users_enrolled_in_the_course($course->id);
         foreach ($enrolled_users as $user) {
             // check if the user has preferences
             $user_preferences = $User->get_preferences($user->id, $course->id);
             // if the user has not preferences than set the default
             if (is_null($user_preferences)) {
                 $user_preferences = new Object();
                 $user_preferences->user_id = $user->id;
                 $user_preferences->course_id = $course->id;
                 $user_preferences->notify_by_email = $course_registration->email_notification_preset;
                 $user_preferences->notify_by_sms = $course_registration->sms_notification_preset;
                 $User->initialize_preferences($user_preferences->user_id, $user_preferences->course_id, $user_preferences->notify_by_email, $user_preferences->notify_by_sms);
             }
         }
         // if course log entry does not exist
         // or the last notification time is older than two days
         // then reinitialize course log
         if (!$Course->log_exists($course->id) or $course_registration->last_notification_time + 48 * 3600 < time()) {
             $Course->initialize_log($course);
         }
         // check notification frequency for the course and skip to next cron cycle if neccessary
         if ($course_registration->last_notification_time + $course_registration->notification_frequency > time()) {
             echo " - Skipping to next cron cycle.";
             continue;
         }
         $Course->update_log($course);
         // check if the course has something new or not
         $changelist = $Course->get_recent_activities($course->id);
         // update the last notification time
         $Course->update_last_notification_time($course->id, time());
         if (empty($changelist)) {
             continue;
         }
         // check the next course. No new items in this one.
         foreach ($enrolled_users as $user) {
             // get user preferences
             $user_preferences = $User->get_preferences($user->id, $course->id);
             // if the email notification is enabled in the course
             // and if the user has set the emailing notification in preferences
             // then send a notification by email
             if ($CFG->block_moodle_notifications_email_channel == 1 and $course_registration->notify_by_email == 1 and $user_preferences->notify_by_email == 1) {
                 $eMail = new eMail();
                 $eMail->notify($changelist, $user, $course);
             }
             // if the sms notification is enabled in the course
             // and if the user has set the sms notification in preferences
             // and if the user has set the mobile phone number
             // then send a notification by sms
             if (class_exists('SMS') and $CFG->block_moodle_notifications_sms_channel == 1 and $course_registration->notify_by_sms == 1 and $user_preferences->notify_by_sms == 1 and !empty($user->phone2)) {
                 $sms = new SMS();
                 $sms->notify($changelist, $user, $course);
             }
         }
     }
     echo "\n****** moodle_notifications :: end ******\n\n";
     return;
 }
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:88,代码来源:block_moodle_notifications.php


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