launch() public static method

Launch the need cron tasks
public static launch ( $mode, $max = 1, $name = '' ) : the
$mode (internal/external, <0 to force)
$max number of task to launch (default 1)
$name of task to run (default '')
return the name of last task launched
コード例 #1
0
ファイル: cron.php プロジェクト: geldarr/hack-space
    header("Cache-Control: no-cache,no-store");
    header("Pragma: no-cache");
    header("Connection: close");
    echo $image;
    flush();
    CronTask::launch(CronTask::MODE_INTERNAL);
} else {
    if (isset($_SERVER['argc']) && $_SERVER['argc'] > 1) {
        // Parse command line options
        $mode = CronTask::MODE_EXTERNAL;
        // when taskname given, will allow --force
        for ($i = 1; $i < $_SERVER['argc']; $i++) {
            if ($_SERVER['argv'][$i] == '--force') {
                $mode = -CronTask::MODE_EXTERNAL;
            } else {
                if (is_numeric($_SERVER['argv'][$i])) {
                    // Number of tasks
                    CronTask::launch(CronTask::MODE_EXTERNAL, intval($_SERVER['argv'][$i]));
                    // Only check first parameter when numeric is passed
                    break;
                } else {
                    // Task name
                    CronTask::launch($mode, $CFG_GLPI['cron_limit'], $_SERVER['argv'][$i]);
                }
            }
        }
    } else {
        // Default from configuration
        CronTask::launch(CronTask::MODE_EXTERNAL, $CFG_GLPI['cron_limit']);
    }
}
コード例 #2
0
ファイル: crontask.form.php プロジェクト: jose-martins/glpi
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief Form to edit Cron Task
*/
include '../inc/includes.php';
Session::checkRight("config", UPDATE);
$crontask = new CronTask();
if (isset($_POST['execute'])) {
    if (is_numeric($_POST['execute'])) {
        // Execute button from list.
        $name = CronTask::launch(CronTask::MODE_INTERNAL, intval($_POST['execute']));
    } else {
        // Execute button from Task form (force)
        $name = CronTask::launch(-CronTask::MODE_INTERNAL, 1, $_POST['execute']);
    }
    if ($name) {
        //TRANS: %s is a task name
        Session::addMessageAfterRedirect(sprintf(__('Task %s executed'), $name));
    }
    Html::back();
} else {
    if (isset($_POST["update"])) {
        Session::checkRight('config', UPDATE);
        $crontask->update($_POST);
        Html::back();
    } else {
        if (isset($_POST['resetdate']) && isset($_POST["id"])) {
            Session::checkRight('config', UPDATE);
            if ($crontask->getFromDB($_POST["id"])) {