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


PHP manager::queue_adhoc_task方法代码示例

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


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

示例1: test_get_next_adhoc_task

 public function test_get_next_adhoc_task()
 {
     $this->resetAfterTest(true);
     // Create an adhoc task.
     $task = new \core\task\adhoc_test_task();
     // Queue it.
     $task = \core\task\manager::queue_adhoc_task($task);
     $now = time();
     // Get it from the scheduler.
     $task = \core\task\manager::get_next_adhoc_task($now);
     $this->assertNotNull($task);
     $task->execute();
     \core\task\manager::adhoc_task_failed($task);
     // Should not get any task.
     $task = \core\task\manager::get_next_adhoc_task($now);
     $this->assertNull($task);
     // Should get the adhoc task (retry after delay).
     $task = \core\task\manager::get_next_adhoc_task($now + 120);
     $this->assertNotNull($task);
     $task->execute();
     \core\task\manager::adhoc_task_complete($task);
     // Should not get any task.
     $task = \core\task\manager::get_next_adhoc_task($now);
     $this->assertNull($task);
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:25,代码来源:adhoc_task_test.php

示例2: write_setting

 /**
  * Store new setting
  *
  * @param mixed $data string or array, must not be NULL
  * @return string empty string if ok, string error message otherwise
  */
 public function write_setting($data)
 {
     $oldvalue = get_config($this->plugin, $this->name);
     if ($oldvalue == $data && !empty($data)) {
         return '';
     }
     if (!empty($data)) {
         $this->config_write($this->name, $data);
         $this->config_write('sharepoint_initialized', '0');
         $sharepointinit = new \local_o365\task\sharepointinit();
         \core\task\manager::queue_adhoc_task($sharepointinit);
     } else {
         // Support default value so it doesn't prompt for setting on install.
         $this->config_write($this->name, '');
     }
     return '';
 }
开发者ID:jamesmcq,项目名称:o365-moodle,代码行数:23,代码来源:sharepointlink.php

示例3: process_buffer

 /**
  * This method process all events stored in the buffer.
  *
  * This is a multi purpose api. It does the following:-
  * 1. Write event data to tool_monitor_events
  * 2. Find out users that need to be notified about rule completion and schedule a task to send them messages.
  */
 public function process_buffer()
 {
     global $DB;
     $events = $this->flush();
     // Flush data.
     $select = "SELECT COUNT(id) FROM {tool_monitor_events} ";
     $now = time();
     $messagestosend = array();
     $allsubids = array();
     // Let us now process the events and check for subscriptions.
     foreach ($events as $eventobj) {
         $subscriptions = subscription_manager::get_subscriptions_by_event($eventobj);
         $idstosend = array();
         foreach ($subscriptions as $subscription) {
             $starttime = $now - $subscription->timewindow;
             $starttime = $starttime > $subscription->lastnotificationsent ? $starttime : $subscription->lastnotificationsent;
             if ($subscription->courseid == 0) {
                 // Site level subscription. Count all events.
                 $where = "eventname = :eventname AND timecreated >  :starttime";
                 $params = array('eventname' => $eventobj->eventname, 'starttime' => $starttime);
             } else {
                 // Course level subscription.
                 if ($subscription->cmid == 0) {
                     // All modules.
                     $where = "eventname = :eventname AND courseid = :courseid AND timecreated > :starttime";
                     $params = array('eventname' => $eventobj->eventname, 'courseid' => $eventobj->courseid, 'starttime' => $starttime);
                 } else {
                     // Specific module.
                     $where = "eventname = :eventname AND courseid = :courseid AND contextinstanceid = :cmid\n                                AND timecreated > :starttime";
                     $params = array('eventname' => $eventobj->eventname, 'courseid' => $eventobj->courseid, 'cmid' => $eventobj->contextinstanceid, 'starttime' => $starttime);
                 }
             }
             $sql = $select . "WHERE " . $where;
             $count = $DB->count_records_sql($sql, $params);
             if (!empty($count) && $count >= $subscription->frequency) {
                 $idstosend[] = $subscription->id;
                 // Trigger a subscription_criteria_met event.
                 // It's possible that the course has been deleted since the criteria was met, so in that case use
                 // the system context. Set it here and change later if needed.
                 $context = \context_system::instance();
                 // We can't perform if (!empty($subscription->courseid)) below as it uses the magic method
                 // __get to return the variable, which will always result in being empty.
                 $courseid = $subscription->courseid;
                 if (!empty($courseid)) {
                     if ($coursecontext = \context_course::instance($courseid, IGNORE_MISSING)) {
                         $context = $coursecontext;
                     }
                 }
                 $params = array('userid' => $subscription->userid, 'courseid' => $subscription->courseid, 'context' => $context, 'other' => array('subscriptionid' => $subscription->id));
                 $event = \tool_monitor\event\subscription_criteria_met::create($params);
                 $event->trigger();
             }
         }
         if (!empty($idstosend)) {
             $messagestosend[] = array('subscriptionids' => $idstosend, 'event' => $eventobj);
             $allsubids = array_merge($allsubids, $idstosend);
         }
     }
     if (!empty($allsubids)) {
         // Update the last trigger flag.
         list($sql, $params) = $DB->get_in_or_equal($allsubids, SQL_PARAMS_NAMED);
         $params['now'] = $now;
         $sql = "UPDATE {tool_monitor_subscriptions} SET lastnotificationsent = :now WHERE id {$sql}";
         $DB->execute($sql, $params);
     }
     // Schedule a task to send notification.
     if (!empty($messagestosend)) {
         $adhocktask = new notification_task();
         $adhocktask->set_custom_data($messagestosend);
         $adhocktask->set_component('tool_monitor');
         \core\task\manager::queue_adhoc_task($adhocktask);
     }
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:80,代码来源:eventobservers.php

示例4: handle_role_deleted

 /**
  * Handle role_deleted event
  *
  * Does the following:
  *     - Unfortunately the role has already been deleted when we hear about it here, and have no way to determine the affected
  *     users. Therefore, we have to do a global sync.
  *
  * @param \core\event\role_deleted $event The triggered event.
  * @return bool Success/Failure.
  */
 public static function handle_role_deleted(\core\event\role_deleted $event)
 {
     if (\local_o365\utils::is_configured() !== true) {
         return false;
     }
     $roleid = $event->objectid;
     // Role deletions can be heavy - run in cron.
     $spaccesssync = new \local_o365\task\sharepointaccesssync();
     $spaccesssync->set_custom_data(['roleid' => '*', 'userid' => '*', 'contextid' => null]);
     \core\task\manager::queue_adhoc_task($spaccesssync);
     return true;
 }
开发者ID:eugeneventer,项目名称:o365-moodle,代码行数:22,代码来源:observers.php

示例5: convert_with_ffmpeg_bg

function convert_with_ffmpeg_bg($filerecord, $tempdir, $tempfilename, $convfilenamebase, $convext)
{
    global $CFG;
    //init our fs object
    $fs = get_file_storage();
    $convfilename = $convfilenamebase . $convext;
    $placeholderfilename = "convertingmessage" . $convext;
    $filerecord->filename = $convfilename;
    $stored_file = $fs->create_file_from_pathname($filerecord, $CFG->dirroot . '/filter/poodll/' . $placeholderfilename);
    //we need this id later, to find the old draft file and remove it, in ad hoc task
    $filerecord->id = $stored_file->get_id();
    // set up task and add custom data
    $conv_task = new \filter_poodll\task\adhoc_convert_media();
    $qdata = array('filerecord' => $filerecord, 'filename' => $convfilename, 'tempdir' => $tempdir, 'tempfilename' => $tempfilename, 'convfilenamebase' => $convfilenamebase, 'convext' => $convext);
    $conv_task->set_custom_data($qdata);
    // queue it
    \core\task\manager::queue_adhoc_task($conv_task);
    //error_log('queeued:' . $convfilename);
    //error_log(print_r($qdata,true));
    return $stored_file;
}
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:21,代码来源:poodllfilelib.php

示例6: roledeleted

 /**
  * Called when an role has been removed.
  */
 public static function roledeleted(\core\event\role_unassigned $event)
 {
     global $CFG;
     if (\panopto_data::get_panopto_course_id($event->courseid) === false || $CFG->version < $requiredVersion) {
         return;
     }
     $task = new \block_panopto\task\update_user();
     $task->set_custom_data(array('courseid' => $event->courseid, 'relateduserid' => $event->relateduserid, 'contextid' => $event->contextid, 'eventtype' => "role"));
     if ($CFG->block_panopto_async_tasks) {
         \core\task\manager::queue_adhoc_task($task);
     } else {
         $task->execute();
     }
 }
开发者ID:edwinp-catalyst-eu,项目名称:Moodle-2.0-plugin-for-Panopto,代码行数:17,代码来源:rollingsync.php

示例7: handle_calendar_unsubscribed

 /**
  * Handle calendar_unsubscribed event - queue calendar sync jobs for cron.
  *
  * @param \local_o365\event\calendar_unsubscribed $event The triggered event.
  * @return bool Success/Failure.
  */
 public static function handle_calendar_unsubscribed(\local_o365\event\calendar_unsubscribed $event)
 {
     $eventdata = $event->get_data();
     $calunsubscribe = new \local_o365\feature\calsync\task\syncoldevents();
     $calunsubscribe->set_custom_data(['caltype' => $eventdata['other']['caltype'], 'caltypeid' => isset($eventdata['other']['caltypeid']) ? $eventdata['other']['caltypeid'] : 0, 'userid' => $eventdata['userid'], 'timecreated' => time()]);
     \core\task\manager::queue_adhoc_task($calunsubscribe);
     return true;
 }
开发者ID:jamesmcq,项目名称:o365-moodle,代码行数:14,代码来源:observers.php

示例8: course_delete_section_async

/**
 * Course section deletion, using an adhoc task for deletion of the modules it contains.
 * 1. Schedule all modules within the section for adhoc removal.
 * 2. Move all modules to course section 0.
 * 3. Delete the resulting empty section.
 *
 * @param \stdClass $section the section to schedule for deletion.
 * @param bool $forcedeleteifnotempty whether to force section deletion if it contains modules.
 * @return bool true if the section was scheduled for deletion, false otherwise.
 */
function course_delete_section_async($section, $forcedeleteifnotempty = true)
{
    global $DB, $USER;
    // Objects only, and only valid ones.
    if (!is_object($section) || empty($section->id)) {
        return false;
    }
    // Does the object currently exist in the DB for removal (check for stale objects).
    $section = $DB->get_record('course_sections', array('id' => $section->id));
    if (!$section || !$section->section) {
        // No section exists, or the section is 0. Can't proceed.
        return false;
    }
    // Check whether the section can be removed.
    if (!$forcedeleteifnotempty && (!empty($section->sequence) || !empty($section->summary))) {
        return false;
    }
    $format = course_get_format($section->course);
    $sectionname = $format->get_section_name($section);
    // Flag those modules having no existing deletion flag. Some modules may have been scheduled for deletion manually, and we don't
    // want to create additional adhoc deletion tasks for these. Moving them to section 0 will suffice.
    $affectedmods = $DB->get_records_select('course_modules', 'course = ? AND section = ? AND deletioninprogress <> ?', [$section->course, $section->id, 1], '', 'id');
    $DB->set_field('course_modules', 'deletioninprogress', '1', ['course' => $section->course, 'section' => $section->id]);
    // Move all modules to section 0.
    $modules = $DB->get_records('course_modules', ['section' => $section->id], '');
    $sectionzero = $DB->get_record('course_sections', ['course' => $section->course, 'section' => '0']);
    foreach ($modules as $mod) {
        moveto_module($mod, $sectionzero);
    }
    // Create and queue an adhoc task for the deletion of the modules.
    $removaltask = new \core_course\task\course_delete_modules();
    $data = array('cms' => $affectedmods, 'userid' => $USER->id, 'realuserid' => \core\session\manager::get_realuser()->id);
    $removaltask->set_custom_data($data);
    \core\task\manager::queue_adhoc_task($removaltask);
    // Delete the now empty section, passing in only the section number, which forces the function to fetch a new object.
    // The refresh is needed because the section->sequence is now stale.
    $result = $format->delete_section($section->section, $forcedeleteifnotempty);
    // Trigger an event for course section deletion.
    if ($result) {
        $context = \context_course::instance($section->course);
        $event = \core\event\course_section_deleted::create(array('objectid' => $section->id, 'courseid' => $section->course, 'context' => $context, 'other' => array('sectionnum' => $section->section, 'sectionname' => $sectionname)));
        $event->add_record_snapshot('course_sections', $section);
        $event->trigger();
    }
    rebuild_course_cache($section->course, true);
    return $result;
}
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:57,代码来源:lib.php

示例9: test_get_next_adhoc_task_future

 /**
  * Test future adhoc task execution.
  */
 public function test_get_next_adhoc_task_future()
 {
     $this->resetAfterTest(true);
     $now = time();
     // Create an adhoc task in future.
     $task = new \core\task\adhoc_test_task();
     $task->set_next_run_time($now + 1000);
     \core\task\manager::queue_adhoc_task($task);
     // Fetching the next task should not return anything.
     $this->assertNull(\core\task\manager::get_next_adhoc_task($now));
     // Fetching in the future should return the task.
     $task = \core\task\manager::get_next_adhoc_task($now + 1020);
     $this->assertInstanceOf('\\core\\task\\adhoc_test_task', $task);
     $task->execute();
     \core\task\manager::adhoc_task_complete($task);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:19,代码来源:adhoc_task_test.php

示例10: process_publish_allocations

 private function process_publish_allocations()
 {
     $now = time();
     if ($this->ratingallocate->accesstimestop < $now) {
         global $USER, $OUTPUT;
         $this->origdbrecord->{this_db\ratingallocate::PUBLISHED} = true;
         $this->origdbrecord->{this_db\ratingallocate::PUBLISHDATE} = time();
         $this->origdbrecord->{this_db\ratingallocate::NOTIFICATIONSEND} = -1;
         $this->ratingallocate = new ratingallocate_db_wrapper($this->origdbrecord);
         $this->db->update_record(this_db\ratingallocate::TABLE, $this->origdbrecord);
         // create the instance
         $domination = new mod_ratingallocate\task\send_distribution_notification();
         // set blocking if required (it probably isn't)
         // $domination->set_blocking(true);
         // add custom data
         $domination->set_component('mod_ratingallocate');
         $domination->set_custom_data(array('userid' => $USER->id, 'ratingallocateid' => $this->ratingallocateid));
         // queue it
         \core\task\manager::queue_adhoc_task($domination);
         //Logging
         $event = \mod_ratingallocate\event\allocation_published::create_simple(context_course::instance($this->course->id), $this->ratingallocateid);
         $event->trigger();
         /* @var $renderer mod_ratingallocate_renderer */
         $renderer = $this->get_renderer();
         $renderer->add_notification(get_string('distribution_published', ratingallocate_MOD_NAME), self::NOTIFY_SUCCESS);
         return $this->process_default();
     }
 }
开发者ID:Kathrin84,项目名称:moodle-mod_ratingallocate,代码行数:28,代码来源:locallib.php

示例11: array

         $_SESSION["notice"]["message"] = $doupload["message"];
         $_SESSION["notice"]["type"] = "error";
         $do = "submitpaper";
     }
 } else {
     if ($post['submissiontype'] == 2) {
         $turnitintooltwosubmission->prepare_text_submission($cm, $post);
     }
 }
 if ($do == "submission_success") {
     // Kent - New method.
     // Delete any old status.
     $DB->delete_records('turnitintooltwo_sub_status', array('submissionid' => $turnitintooltwosubmission->id));
     $task = new \mod_turnitintooltwo\task\submit_assignment();
     $task->set_custom_data(array('userid' => $USER->id, 'tiiid' => $turnitintooltwoassignment->turnitintooltwo->id, 'submissionid' => $turnitintooltwosubmission->id, 'submissionpart' => $post['submissionpart'], 'subtime' => time()));
     \core\task\manager::queue_adhoc_task($task, null, 10);
     turnitintooltwo_add_to_log($turnitintooltwoassignment->turnitintooltwo->course, "queue submission", 'view.php?id=' . $cm->id, "Queued turnitin submission: " . " '" . $post['submissiontitle'] . "'", $cm->id, $post['studentsname'], array('submissionid' => $turnitintooltwosubmission->id));
     redirect(new moodle_url('/mod/turnitintooltwo/view.php', array('id' => $id, 'do' => 'submission_queued', 'submissionid' => $turnitintooltwosubmission->id, 'view_context' => $viewcontext)));
     exit;
     // Kent - New method.
     // Log successful submission to Moodle.
     turnitintooltwo_add_to_log($turnitintooltwoassignment->turnitintooltwo->course, "add submission", 'view.php?id=' . $cm->id, get_string('addsubmissiondesc', 'turnitintooltwo') . " '" . $post['submissiontitle'] . "'", $cm->id, $post['studentsname']);
     $tiisubmission = $turnitintooltwosubmission->do_tii_submission($cm, $turnitintooltwoassignment);
     $_SESSION["digital_receipt"] = $tiisubmission;
     $_SESSION["digital_receipt"]["is_manual"] = 0;
     if ($tiisubmission['success'] == true) {
         $lockedassignment = new stdClass();
         $lockedassignment->id = $turnitintooltwoassignment->turnitintooltwo->id;
         $lockedassignment->submitted = 1;
         $DB->update_record('turnitintooltwo', $lockedassignment);
         $lockedpart = new stdClass();
开发者ID:SkylarKelty,项目名称:moodle-mod_turnitintooltwo,代码行数:31,代码来源:view.php


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