getPriority() != $priority) { continue; } $scheduledTime = $task->getScheduledTime(); $className = $task->getClassName(); $methodName = $task->getMethodName(); $fullyQualifiedMethodName = get_class($className) . '.' . $methodName; /* * Task has to be executed if : * - it is the first time, ie. rescheduledTime is not set * - that task has already been executed and the current system time is greater than the * rescheduled time. */ if ( !isset($timetable[$fullyQualifiedMethodName]) || (isset($timetable[$fullyQualifiedMethodName]) && time() >= $timetable[$fullyQualifiedMethodName]) || $forceScheduledTasks) { // Updates the rescheduled time $timetable[$fullyQualifiedMethodName] = $scheduledTime->getRescheduledTime(); Piwik_SetOption(self::TIMETABLE_OPTION_STRING, serialize($timetable)); self::$running = true; // Run the task try { $timer = new Piwik_Timer; call_user_func ( array($className,$methodName) ); $message = $timer->__toString(); } catch(Exception $e) { $message = 'ERROR: '.$e->getMessage(); } self::$running = false; $return[] = array('task' => $fullyQualifiedMethodName, 'output' => $message); } } } return $return; } static public function isTaskBeingExecuted() { return self::$running; } /** * return the timetable for a given task * @param string $className * @param string $methodName * @return mixed */ static public function getScheduledTimeForTask($className, $methodName) { // Gets the array where rescheduled timetables are stored $option = Piwik_GetOption(self::TIMETABLE_OPTION_STRING); $timetable = self::getTimetableFromOption($option); if($timetable === false) { return; } $taskName = $className . '.' . $methodName; if(isset($timetable[$taskName])) { return $timetable[$taskName]; } else { return false; } } static private function getTimetableFromOption($option = false) { if($option === false) { return array(); } elseif(!is_string($option)) { return false; } else { return unserialize($option); } } }