コード例 #1
0
 function show()
 {
     global $USER, $LNG, $reslist;
     $db = Database::get();
     $sql = "SELECT elementID, level, userID, username\n\t\tFROM %%USERS%%\n\t\tINNER JOIN %%RECORDS%% ON userID = id\n\t\tWHERE universe = :universe;";
     $recordResult = $db->select($sql, array(':universe' => Universe::current()));
     $defenseList = array_fill_keys($reslist['defense'], array());
     $fleetList = array_fill_keys($reslist['fleet'], array());
     $researchList = array_fill_keys($reslist['tech'], array());
     $buildList = array_fill_keys($reslist['build'], array());
     foreach ($recordResult as $recordRow) {
         if (in_array($recordRow['elementID'], $reslist['defense'])) {
             $defenseList[$recordRow['elementID']][] = $recordRow;
         } elseif (in_array($recordRow['elementID'], $reslist['fleet'])) {
             $fleetList[$recordRow['elementID']][] = $recordRow;
         } elseif (in_array($recordRow['elementID'], $reslist['tech'])) {
             $researchList[$recordRow['elementID']][] = $recordRow;
         } elseif (in_array($recordRow['elementID'], $reslist['build'])) {
             $buildList[$recordRow['elementID']][] = $recordRow;
         }
     }
     require_once 'includes/classes/Cronjob.class.php';
     $this->assign(array('defenseList' => $defenseList, 'fleetList' => $fleetList, 'researchList' => $researchList, 'buildList' => $buildList, 'update' => _date($LNG['php_tdformat'], Cronjob::getLastExecutionTime('statistic'), $USER['timezone'])));
     $this->display('page.records.default.tpl');
 }
コード例 #2
0
ファイル: card.php プロジェクト: ADDAdev/Dolibarr
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
// librairie jobs
require_once DOL_DOCUMENT_ROOT . "/cron/class/cronjob.class.php";
require_once DOL_DOCUMENT_ROOT . "/core/class/html.formcron.class.php";
require_once DOL_DOCUMENT_ROOT . '/core/lib/cron.lib.php';
$langs->load("admin");
$langs->load("cron");
if (!$user->rights->cron->create) {
    accessforbidden();
}
$id = GETPOST('id', 'int');
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$cancel = GETPOST('cancel');
$object = new Cronjob($db);
if (!empty($id)) {
    $result = $object->fetch($id);
    if ($result < 0) {
        setEventMessage($object->error, 'errors');
    }
}
if (!empty($cancel)) {
    if (!empty($id)) {
        $action = '';
    } else {
        Header("Location: " . DOL_URL_ROOT . '/cron/list.php?status=1');
        exit;
    }
}
// Delete jobs
コード例 #3
0
ファイル: cronjob.php プロジェクト: joancefet/Beta7
<?php

define('MODE', 'CRON');
define('ROOT_PATH', str_replace('\\', '/', dirname(__FILE__)) . '/');
set_include_path(ROOT_PATH);
require 'includes/common.php';
// Output transparent gif
HTTP::sendHeader('Cache-Control', 'no-cache');
HTTP::sendHeader('Content-Type', 'image/gif');
HTTP::sendHeader('Expires', '0');
$isSessionActive = $SESSION->isActiveSession();
echo "GIF89a€!ù,D;";
if (!$isSessionActive) {
    exit;
}
$cronjobID = HTTP::_GP('cronjobID', 0);
if (empty($cronjobID)) {
    exit;
}
require 'includes/classes/Cronjob.class.php';
$cronjobsTodo = Cronjob::getNeedTodoExecutedJobs();
if (!in_array($cronjobID, $cronjobsTodo)) {
    exit;
}
Cronjob::execute($cronjobID);
コード例 #4
0
function ClearCache()
{
    $DIRS = array('cache/', 'cache/templates/');
    foreach ($DIRS as $DIR) {
        $FILES = array_diff(scandir($DIR), array('..', '.', '.htaccess'));
        foreach ($FILES as $FILE) {
            if (is_dir(ROOT_PATH . $DIR . $FILE)) {
                continue;
            }
            unlink(ROOT_PATH . $DIR . $FILE);
        }
    }
    require_once 'includes/classes/Cronjob.class.php';
    Cronjob::reCalculateCronjobs();
    $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " SET eco_hash = '';");
    clearstatcache();
}
コード例 #5
0
ファイル: cronjobs.ctrl.php プロジェクト: Ariflaw/b2evolution
         $edited_Cronjob->start_timestamp = $localtimenow;
     }
     break;
 case 'create':
     // Check that this action request is not a CSRF hacked request:
     $Session->assert_received_crumb('crontask');
     // Check that we have permission to edit options:
     $current_User->check_perm('options', 'edit', true, NULL);
     if (!empty($edited_Cronjob)) {
         // It is a copy action, we should save the fields "key" & "params"
         $ctsk_key = $edited_Cronjob->get('key');
         $ctsk_params = $edited_Cronjob->get('params');
     }
     // CREATE OBJECT:
     load_class('/cron/model/_cronjob.class.php', 'Cronjob');
     $edited_Cronjob = new Cronjob();
     if ($edited_Cronjob->load_from_Request()) {
         // We could load data from form without errors:
         if (!empty($ctsk_key)) {
             // Save controller field from copied object
             $edited_Cronjob->set('key', $ctsk_key);
         }
         if (!empty($ctsk_params)) {
             // Save params field from copied object
             $edited_Cronjob->set('params', $ctsk_params);
         }
         // Save to DB:
         $edited_Cronjob->dbinsert();
         $Messages->add(T_('New job has been scheduled.'), 'success');
         // Redirect so that a reload doesn't write to the DB twice:
         header_redirect('?ctrl=crontab', 303);
コード例 #6
0
 protected function getCronjobsTodo()
 {
     require_once 'includes/classes/Cronjob.class.php';
     $this->assign(array('cronjobs' => Cronjob::getNeedTodoExecutedJobs()));
 }
コード例 #7
0
 function CronApplicationJob($entryScript, $commandName, $parameters = array(), $min = NULL, $hour = NULL, $day = NULL, $month = NULL, $dayofweek = NULL)
 {
     $this->entryScript = $entryScript;
     $this->commandName = $commandName;
     $this->parameters = $parameters;
     $command = $this->getCommand();
     parent::Cronjob($command, $min, $hour, $day, $month, $dayofweek);
     return $this;
 }
コード例 #8
0
ファイル: cronjobs.ctrl.php プロジェクト: ldanielz/uesp.blog
         $edited_Cronjob->start_timestamp = $localtimenow;
     }
     break;
 case 'create':
     // Check that this action request is not a CSRF hacked request:
     $Session->assert_received_crumb('crontask');
     // Check that we have permission to edit options:
     $current_User->check_perm('options', 'edit', true, NULL);
     if (!empty($edited_Cronjob)) {
         // It is a copy action, we should save the fields "controller" & "params"
         $ctsk_controller = $edited_Cronjob->get('controller');
         $ctsk_params = $edited_Cronjob->get('params');
     }
     // CREATE OBJECT:
     load_class('/cron/model/_cronjob.class.php', 'Cronjob');
     $edited_Cronjob = new Cronjob();
     if ($edited_Cronjob->load_from_Request($cron_job_names, $cron_job_params)) {
         // We could load data from form without errors:
         if (!empty($ctsk_controller)) {
             // Save controller field from copied object
             $edited_Cronjob->set('controller', $ctsk_controller);
         }
         if (!empty($ctsk_params)) {
             // Save params field from copied object
             $edited_Cronjob->set('params', $ctsk_params);
         }
         // Save to DB:
         $edited_Cronjob->dbinsert();
         $Messages->add(T_('New job has been scheduled.'), 'success');
         // Redirect so that a reload doesn't write to the DB twice:
         header_redirect('?ctrl=crontab', 303);
コード例 #9
0
ファイル: _item.class.php プロジェクト: Ariflaw/b2evolution
 /**
  * Execute or schedule post(=after) processing tasks
  *
  * Includes notifications & pings
  *
  * @param boolean a new post was just created or it was called after an update
  * @param boolean give more info messages (we want to avoid that when we save & continue editing)
  */
 function handle_post_processing($just_created, $verbose = true)
 {
     global $Settings, $Messages, $localtimenow, $posttypes_nopermanentURL;
     if ($just_created) {
         // we must try to send moderation notifications for the newly created posts
         $already_notified = $this->send_moderation_emails();
     } else {
         // Moderation notifications were not sent, so there are no already notified users
         $already_notified = NULL;
     }
     $notifications_mode = $Settings->get('outbound_notifications_mode');
     if ($notifications_mode == 'off') {
         // Exit silently
         return false;
     }
     if ($this->notifications_status == 'finished') {
         // pings have been done before
         if ($verbose) {
             $Messages->add(T_('Post had already pinged: skipping notifications...'), 'note');
         }
         return false;
     }
     if ($this->notifications_status != 'noreq') {
         // pings have been done before
         // TODO: Check if issue_date has changed and reschedule
         if ($verbose) {
             $Messages->add(T_('Post processing already pending...'), 'note');
         }
         return false;
     }
     if ($this->status != 'published') {
         // TODO: discard any notification that may be pending!
         if ($verbose) {
             $Messages->add(T_('Post not publicly published: skipping notifications...'), 'note');
         }
         return false;
     }
     if (in_array($this->ityp_ID, $posttypes_nopermanentURL)) {
         // TODO: discard any notification that may be pending!
         if ($verbose) {
             $Messages->add(T_('This post type doesn\'t need notifications...'), 'note');
         }
         return false;
     }
     if ($notifications_mode == 'immediate' && strtotime($this->issue_date) <= $localtimenow) {
         // We want to do the post processing immediately:
         // send outbound pings:
         $this->send_outbound_pings($verbose);
         // Send email notifications now!
         $this->send_email_notifications(false, $already_notified);
         // Record that processing has been done:
         $this->set('notifications_status', 'finished');
     } else {
         // We want asynchronous post processing. This applies to posts with date in future too.
         $Messages->add(sprintf(T_('You just published a post in the future. You must set your notifications to <a %s>Asynchronous</a> so that b2evolution can send out notification when this post goes live.'), 'href="http://b2evolution.net/man/after-each-post-settings"'), 'warning');
         // CREATE OBJECT:
         load_class('/cron/model/_cronjob.class.php', 'Cronjob');
         $edited_Cronjob = new Cronjob();
         // start datetime. We do not want to ping before the post is effectively published:
         $edited_Cronjob->set('start_datetime', $this->issue_date);
         // no repeat.
         // key:
         $edited_Cronjob->set('key', 'send-post-notifications');
         // params: specify which post this job is supposed to send notifications for:
         $edited_Cronjob->set('params', array('item_ID' => $this->ID));
         // Save cronjob to DB:
         $edited_Cronjob->dbinsert();
         // Memorize the cron job ID which is going to handle this post:
         $this->set('notifications_ctsk_ID', $edited_Cronjob->ID);
         // Record that processing has been scheduled:
         $this->set('notifications_status', 'todo');
     }
     // Save the new processing status to DB, but do not update last edited by user, slug or post excerpt
     $this->dbupdate(false, false, false);
     return true;
 }
コード例 #10
0
ファイル: index.php プロジェクト: OwlManAtt/imageforum-ys
* =========================
* (Red, if you're still out there, I hope 
* you irlol'd hard when you see this. GCv3 is
* dedicated to you.)
*
* Ghettocron is the name of crontab emulation
* from (I *think!*) the original OPG sourcecode 
* (I could be mistaken).
*
* Entries in the cron_tab table will be run if
* it is their due time. Obviously, ghettocron is
* less accurate then proper cron, but I am designing
* for the largest possible market, and everyone may
* not have/know how to use cron.
*/
foreach (Cronjob::listPendingJobs($db) as $job) {
    $job->run();
}
// end cronjob loop
// Display page.
if (is_a($jump_page, 'JumpPage') == false) {
    header("HTTP/1.1 404 Not Found");
    $renderer->display('http/404.tpl');
    die;
} else {
    $SELF = array('page' => $jump_page, 'php_self' => $_SERVER['PHP_SELF'], 'slug' => $jump_page->getPageSlug());
    $renderer->assign('self', $SELF);
    $renderer->assign('fat', 'fade-808080');
    $renderer->assign('page_title', $jump_page->getPageTitle());
    $renderer->assign('page_html_title', $jump_page->getPageHtmlTitle());
    $message_count = '';
コード例 #11
0
 /**
  * Fetch a list of pending cronjobs. 
  *
  * @param $db PEAR::DB connector 
  * @return array An array of Cronjob objects
  **/
 public static function listPendingJobs($db)
 {
     $jobs = new Cronjob($db);
     return $jobs->findBy(array('enabled' => 'Y', array('table' => 'cron_tab', 'column' => 'unixtime_next_run', 'value' => time(), 'search_type' => '<=')));
 }
コード例 #12
0
ファイル: GeneralFunctions.php プロジェクト: Hetachi/2Moons
function ClearCache()
{
    $DIRS = array('cache/', 'cache/templates/');
    foreach ($DIRS as $DIR) {
        $FILES = array_diff(scandir($DIR), array('..', '.', '.htaccess'));
        foreach ($FILES as $FILE) {
            if (is_dir(ROOT_PATH . $DIR . $FILE)) {
                continue;
            }
            unlink(ROOT_PATH . $DIR . $FILE);
        }
    }
    require_once 'includes/classes/Cronjob.class.php';
    Cronjob::reCalculateCronjobs();
    $sql = 'UPDATE %%PLANETS%% SET eco_hash = :ecoHash;';
    Database::get()->update($sql, array(':ecoHash' => ''));
    clearstatcache();
    // Find currently Revision
    $config = Config::get();
    $version = explode('.', $config->VERSION);
    $REV = 0;
    $iterator = new RecursiveDirectoryIterator(ROOT_PATH);
    foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file) {
        if (false == $file->isDir()) {
            $CONTENT = file_get_contents($file->getPathname());
            preg_match('!\\$' . 'Id: [^ ]+ ([0-9]+)!', $CONTENT, $match);
            if (isset($match[1]) && is_numeric($match[1])) {
                $REV = max($REV, $match[1]);
            }
        }
    }
    $config->VERSION = $version[0] . '.' . $version[1] . '.' . $REV;
    $config->save();
}
コード例 #13
0
ファイル: info.php プロジェクト: ADDAdev/Dolibarr
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
/**
 *  \file       	htdocs/cron/info.php
 *  \brief      	Page of info of a cron job
 */
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . "/cron/class/cronjob.class.php";
require_once DOL_DOCUMENT_ROOT . '/core/lib/cron.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
// Security check
if (!$user->rights->cron->read) {
    accessforbidden();
}
$id = GETPOST('id', 'int');
$mesg = '';
/*
 * View
*/
llxHeader('', $langs->trans("CronInfo"));
$object = new Cronjob($db);
$object->fetch($id);
$object->info($id);
$head = cron_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("CronTask"), 0, 'cron');
print '<table width="100%"><tr><td>';
dol_print_object_info($object);
print '</td></tr></table>';
print '</div>';
$db->close();
llxFooter();
コード例 #14
0
ファイル: CronjobRepo.php プロジェクト: exfriend/overseer
 public function getAllActive()
 {
     return Cronjob::where('active', '=', '1')->get();
 }
コード例 #15
0
 function show()
 {
     global $USER, $LNG;
     $who = HTTP::_GP('who', 1);
     $type = HTTP::_GP('type', 1);
     $range = HTTP::_GP('range', 1);
     switch ($type) {
         case 2:
             $Order = "fleet_rank";
             $Points = "fleet_points";
             $Rank = "fleet_rank";
             $OldRank = "fleet_old_rank";
             break;
         case 3:
             $Order = "tech_rank";
             $Points = "tech_points";
             $Rank = "tech_rank";
             $OldRank = "tech_old_rank";
             break;
         case 4:
             $Order = "build_rank";
             $Points = "build_points";
             $Rank = "build_rank";
             $OldRank = "build_old_rank";
             break;
         case 5:
             $Order = "defs_rank";
             $Points = "defs_points";
             $Rank = "defs_rank";
             $OldRank = "defs_old_rank";
             break;
         default:
             $Order = "total_rank";
             $Points = "total_points";
             $Rank = "total_rank";
             $OldRank = "total_old_rank";
             break;
     }
     $RangeList = array();
     $db = Database::get();
     $config = Config::get();
     switch ($who) {
         case 1:
             $MaxUsers = $config->users_amount;
             $range = min($range, $MaxUsers);
             $LastPage = max(1, ceil($MaxUsers / 100));
             for ($Page = 0; $Page < $LastPage; $Page++) {
                 $PageValue = $Page * 100 + 1;
                 $PageRange = $PageValue + 99;
                 $Selector['range'][$PageValue] = $PageValue . "-" . $PageRange;
             }
             $start = max(floor(($range - 1) / 100) * 100, 0);
             if ($config->stat == 2) {
                 $sql = "SELECT DISTINCT s.*, u.id, u.username, u.ally_id, a.ally_name FROM %%STATPOINTS%% as s\n\t\t\t\t\tINNER JOIN %%USERS%% as u ON u.id = s.id_owner\n\t\t\t\t\tLEFT JOIN %%ALLIANCE%% as a ON a.id = s.id_ally\n\t\t\t\t\tWHERE s.universe = :universe AND s.stat_type = 1 AND u.authlevel < :authLevel\n\t\t\t\t\tORDER BY " . $Order . " ASC LIMIT :offset, :limit;";
                 $query = $db->select($sql, array(':universe' => Universe::current(), ':authLevel' => $config->stat_level, ':offset' => $start, ':limit' => 100));
             } else {
                 $sql = "SELECT DISTINCT s.*, u.id, u.username, u.ally_id, a.ally_name FROM %%STATPOINTS%% as s\n\t\t\t\t\tINNER JOIN %%USERS%% as u ON u.id = s.id_owner\n\t\t\t\t\tLEFT JOIN %%ALLIANCE%% as a ON a.id = s.id_ally\n\t\t\t\t\tWHERE s.universe = :universe AND s.stat_type = 1\n\t\t\t\t\tORDER BY " . $Order . " ASC LIMIT :offset, :limit;";
                 $query = $db->select($sql, array(':universe' => Universe::current(), ':offset' => $start, ':limit' => 100));
             }
             $RangeList = array();
             foreach ($query as $StatRow) {
                 $RangeList[] = array('id' => $StatRow['id'], 'name' => $StatRow['username'], 'points' => pretty_number($StatRow[$Points]), 'allyid' => $StatRow['ally_id'], 'rank' => $StatRow[$Rank], 'allyname' => $StatRow['ally_name'], 'ranking' => $StatRow[$OldRank] - $StatRow[$Rank]);
             }
             break;
         case 2:
             $sql = "SELECT COUNT(*) as state FROM %%ALLIANCE%% WHERE `ally_universe` = :universe;";
             $MaxAllys = $db->selectSingle($sql, array(':universe' => Universe::current()), 'state');
             $range = min($range, $MaxAllys);
             $LastPage = max(1, ceil($MaxAllys / 100));
             for ($Page = 0; $Page < $LastPage; $Page++) {
                 $PageValue = $Page * 100 + 1;
                 $PageRange = $PageValue + 99;
                 $Selector['range'][$PageValue] = $PageValue . "-" . $PageRange;
             }
             $start = max(floor(($range - 1) / 100) * 100, 0);
             $sql = 'SELECT DISTINCT s.*, a.id, a.ally_members, a.ally_name FROM %%STATPOINTS%% as s
             INNER JOIN %%ALLIANCE%% as a ON a.id = s.id_owner
             WHERE universe = :universe AND stat_type = 2
             ORDER BY ' . $Order . ' ASC LIMIT :offset, :limit;';
             $query = $db->select($sql, array(':universe' => Universe::current(), ':offset' => $start, ':limit' => 100));
             foreach ($query as $StatRow) {
                 $RangeList[] = array('id' => $StatRow['id'], 'name' => $StatRow['ally_name'], 'members' => $StatRow['ally_members'], 'rank' => $StatRow[$Rank], 'mppoints' => pretty_number(floor($StatRow[$Points] / $StatRow['ally_members'])), 'points' => pretty_number($StatRow[$Points]), 'ranking' => $StatRow[$OldRank] - $StatRow[$Rank]);
             }
             break;
     }
     $Selector['who'] = array(1 => $LNG['st_player'], 2 => $LNG['st_alliance']);
     $Selector['type'] = array(1 => $LNG['st_points'], 2 => $LNG['st_fleets'], 3 => $LNG['st_researh'], 4 => $LNG['st_buildings'], 5 => $LNG['st_defenses']);
     require_once 'includes/classes/Cronjob.class.php';
     $this->assign(array('Selectors' => $Selector, 'who' => $who, 'type' => $type, 'range' => floor(($range - 1) / 100) * 100 + 1, 'RangeList' => $RangeList, 'CUser_ally' => $USER['ally_id'], 'CUser_id' => $USER['id'], 'stat_date' => _date($LNG['php_tdformat'], Cronjob::getLastExecutionTime('statistic'), $USER['timezone'])));
     $this->display('page.statistics.default.tpl');
 }
コード例 #16
0
/*
 * View
 */
$form = new Form($db);
$pagetitle = $langs->trans("CronList");
llxHeader('', $pagetitle);
print_fiche_titre($pagetitle, '', 'setup');
print $langs->trans('CronInfo');
if ($action == 'delete') {
    print $form->formconfirm($_SERVER['PHP_SELF'] . "?id=" . $id . '&status=' . $status, $langs->trans("CronDelete"), $langs->trans("CronConfirmDelete"), "confirm_delete", '', '', 1);
}
if ($action == 'execute') {
    print $form->formconfirm($_SERVER['PHP_SELF'] . "?id=" . $id . '&status=' . $status, $langs->trans("CronExecute"), $langs->trans("CronConfirmExecute"), "confirm_execute", '', '', 1);
}
// liste des jobs creer
$object = new Cronjob($db);
$result = $object->fetch_all($sortorder, $sortfield, $limit, $offset, $status, $filter);
if ($result < 0) {
    setEventMessage($object->error, 'errors');
}
print "<br><br>";
print '<form method="GET" action="' . $url_form . '" name="search_form">' . "\n";
print '<input type="hidden" name="status" value="' . $status . '" >';
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
$arg_url = '&page=' . $page . '&status=' . $status . '&search_label=' . $search_label;
print_liste_field_titre($langs->trans("CronLabel"), $_SERVEUR['PHP_SELF'], "t.label", "", $arg_url, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("CronTask"), '', '', "", $arg_url, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("CronDtStart"), $_SERVEUR['PHP_SELF'], "t.datestart", "", $arg_url, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("CronDtEnd"), $_SERVEUR['PHP_SELF'], "t.dateend", "", $arg_url, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("CronDtLastLaunch"), $_SERVEUR['PHP_SELF'], "t.datelastrun", "", $arg_url, '', $sortfield, $sortorder);
コード例 #17
0
 /**
  *		Function called when module is enabled.
  *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  *		It also creates data directories
  *
  *      @param      string	$options    Options when enabling module ('', 'noboxes')
  *      @return     int             	1 if OK, 0 if KO
  */
 function init($options = '')
 {
     global $user;
     $sql = array();
     define('INC_FROM_DOLIBARR', true);
     dol_include_once('/recurrence/config.php');
     dol_include_once('/recurrence/script/create-maj-base.php');
     $TValues = array('label' => 'Mise à jour récurrence', 'jobtype' => 'method', 'frequency' => 86400, 'unitfrequency' => 86400, 'status' => 1, 'module_name' => 'recurrence', 'classesname' => 'cronrecurrence.class.php', 'objectname' => 'TCronRecurrence', 'methodename' => 'run', 'params' => '', 'datestart' => time());
     $req = "\n\t\t\tSELECT rowid\n\t\t\tFROM " . MAIN_DB_PREFIX . "cronjob\n\t\t\tWHERE classesname = '" . $TValues['classesname'] . "'\n\t\t\tAND module_name = '" . $TValues['module_name'] . "'\n\t\t\tAND objectname = '" . $TValues['objectname'] . "'\n\t\t\tAND methodename = '" . $TValues['methodename'] . "'\n\t\t";
     $res = $this->db->query($req);
     $job = $this->db->fetch_object($res);
     if (empty($job->rowid)) {
         $cronTask = new Cronjob($this->db);
         foreach ($TValues as $key => $value) {
             $cronTask->{$key} = $value;
         }
         $cronTask->create($user);
     }
     return $this->_init($sql, $options);
 }
コード例 #18
0
ファイル: _comment.class.php プロジェクト: ldanielz/uesp.blog
 /**
  * Handle comment email notifications
  *
  * Should be called only when a new comment was posted or when a comment status was changed to published
  * 
  * @param boolean set true if the comment was posted just now, false otherwise
  * @param integer the user ID who executed the action which will be notified, or NULL if it was executed by an anonymous user
  */
 function handle_notifications($just_posted = false, $executed_by_userid = NULL)
 {
     global $Settings;
     if ($just_posted) {
         // send email notification to moderators
         $this->send_email_notifications(true, false, $executed_by_userid);
     }
     if ($this->status != 'published') {
         // don't send notificaitons about non published comments
         return;
     }
     $notifications_mode = $Settings->get('outbound_notifications_mode');
     if ($notifications_mode == 'off') {
         // don't send notification
         return false;
     }
     if ($this->get('notif_status') != 'noreq') {
         // notification have been done before, or is in progress
         return false;
     }
     $edited_Item =& $this->get_Item();
     if ($notifications_mode == 'immediate') {
         // Send email notifications now!
         $this->send_email_notifications(false, $just_posted, $executed_by_userid);
         // Record that processing has been done:
         $this->set('notif_status', 'finished');
     } else {
         // Create scheduled job to send notifications
         // CREATE OBJECT:
         load_class('/cron/model/_cronjob.class.php', 'Cronjob');
         $edited_Cronjob = new Cronjob();
         // start datetime. We do not want to ping before the post is effectively published:
         $edited_Cronjob->set('start_datetime', $this->date);
         // name:
         $edited_Cronjob->set('name', sprintf(T_('Send notifications about new comment on &laquo;%s&raquo;'), strip_tags($edited_Item->get('title'))));
         // controller:
         $edited_Cronjob->set('controller', 'cron/jobs/_comment_notifications.job.php');
         // params: specify which post this job is supposed to send notifications for:
         $edited_Cronjob->set('params', array('comment_ID' => $this->ID, 'except_moderators' => $just_posted, 'executed_by_userid' => $executed_by_userid));
         // Save cronjob to DB:
         $edited_Cronjob->dbinsert();
         // Memorize the cron job ID which is going to handle this post:
         $this->set('notif_ctsk_ID', $edited_Cronjob->ID);
         // Record that processing has been scheduled:
         $this->set('notif_status', 'todo');
     }
     // update comment notification params
     $this->dbupdate();
 }
コード例 #19
0
ファイル: DailyCronjob.class.php プロジェクト: bergi9/2Moons
 function reCalculateCronjobs()
 {
     Cronjob::reCalculateCronjobs();
 }
コード例 #20
0
ファイル: cron_run_jobs.php プロジェクト: Samara94/dolibarr
    dol_syslog("cron_run_jobs.php fetch Error" . $cronjob->error, LOG_WARNING);
    exit;
}
// current date
$now = dol_now();
$nbofjobs = count($object->lines);
$nbofjobslaunchedok = 0;
$nbofjobslaunchedko = 0;
if (is_array($object->lines) && count($object->lines) > 0) {
    // Loop over job
    foreach ($object->lines as $line) {
        dol_syslog("cron_run_jobs.php fetch cronjobid: " . $line->id, LOG_WARNING);
        //If date_next_jobs is less of current dat, execute the program, and store the execution time of the next execution in database
        if ($line->datenextrun <= $now && $line->dateend < $now || empty($line->datenextrun) && empty($line->dateend)) {
            dol_syslog("cron_run_jobs.php:: torun line->datenextrun:" . dol_print_date($line->datenextrun, 'dayhourtext') . " line->dateend:" . dol_print_date($line->dateend, 'dayhourtext') . " now:" . dol_print_date($now, 'dayhourtext'));
            $cronjob = new Cronjob($db);
            $result = $cronjob->fetch($line->id);
            if ($result < 0) {
                echo "Error:" . $cronjob->error;
                dol_syslog("cron_run_jobs.php:: fetch Error" . $cronjob->error, LOG_ERR);
                exit;
            }
            // Execut job
            $result = $cronjob->run_jobs($userlogin);
            if ($result < 0) {
                echo "Error:" . $cronjob->error;
                dol_syslog("cron_run_jobs.php:: run_jobs Error" . $cronjob->error, LOG_ERR);
                $nbofjobslaunchedko++;
            } else {
                $nbofjobslaunchedok++;
            }
コード例 #21
0
 /**
  *	Load an object from its id and create a new one in database
  *
  *	@param	int		$fromid     Id of object to clone
  * 	@return	int					New id of clone
  */
 function createFromClone($fromid)
 {
     global $user, $langs;
     $error = 0;
     $object = new Cronjob($this->db);
     $object->context['createfromclone'] = 'createfromclone';
     $this->db->begin();
     // Load source object
     $object->fetch($fromid);
     $object->id = 0;
     $object->statut = 0;
     // Clear fields
     // ...
     // Create clone
     $result = $object->create($user);
     // Other options
     if ($result < 0) {
         $this->error = $object->error;
         $error++;
     }
     if (!$error) {
     }
     unset($this->context['createfromclone']);
     // End
     if (!$error) {
         $this->db->commit();
         return $object->id;
     } else {
         $this->db->rollback();
         return -1;
     }
 }
コード例 #22
0
 /**
  * Handle comment email notifications
  *
  * Should be called only when a new comment was posted or when a comment status was changed to published
  *
  * @param boolean set true if the comment was posted just now, false otherwise
  * @param integer the user ID who executed the action which will be notified, or NULL if it was executed by an anonymous user
  */
 function handle_notifications($just_posted = false, $executed_by_userid = NULL)
 {
     global $Settings;
     if ($just_posted) {
         // send email notification to moderators or to users with "meta comments" notification
         $this->send_email_notifications(true, false, $executed_by_userid);
         if ($this->is_meta()) {
             // Record that processing has been done in case of this meta comment
             $this->set('notif_status', 'finished');
             $this->dbupdate();
         }
     }
     if ($this->is_meta()) {
         // Meta comments were already notified when they were posted.
         return;
     }
     if ($this->status != 'published') {
         // don't send notificaitons about non published comments
         return;
     }
     $notifications_mode = $Settings->get('outbound_notifications_mode');
     if ($notifications_mode == 'off') {
         // don't send notification
         return false;
     }
     if ($this->get('notif_status') != 'noreq') {
         // notification have been done before, or is in progress
         return false;
     }
     $edited_Item =& $this->get_Item();
     if ($notifications_mode == 'immediate') {
         // Send email notifications now!
         $this->send_email_notifications(false, $just_posted, $executed_by_userid);
         // Record that processing has been done:
         $this->set('notif_status', 'finished');
     } else {
         // Create scheduled job to send notifications
         // CREATE OBJECT:
         load_class('/cron/model/_cronjob.class.php', 'Cronjob');
         $edited_Cronjob = new Cronjob();
         // start datetime. We do not want to ping before the post is effectively published:
         $edited_Cronjob->set('start_datetime', $this->date);
         // key:
         $edited_Cronjob->set('key', 'send-comment-notifications');
         // params: specify which post this job is supposed to send notifications for:
         $edited_Cronjob->set('params', array('comment_ID' => $this->ID, 'except_moderators' => $just_posted, 'executed_by_userid' => $executed_by_userid));
         // Save cronjob to DB:
         $edited_Cronjob->dbinsert();
         // Memorize the cron job ID which is going to handle this post:
         $this->set('notif_ctsk_ID', $edited_Cronjob->ID);
         // Record that processing has been scheduled:
         $this->set('notif_status', 'todo');
     }
     // update comment notification params
     $this->dbupdate();
 }
コード例 #23
0
ファイル: _item.class.php プロジェクト: ldanielz/uesp.blog
 /**
  * Execute or schedule post(=after) processing tasks
  *
  * Includes notifications & pings
  *
  * @param boolean a new post was just created or it was called after an update
  * @param boolean give more info messages (we want to avoid that when we save & continue editing)
  */
 function handle_post_processing($just_created, $verbose = true)
 {
     global $Settings, $Messages, $localtimenow, $posttypes_nopermanentURL;
     if ($just_created) {
         // we must try to send moderation notifications for the newly created posts
         $already_notified = $this->send_moderation_emails();
     } else {
         // Moderation notifications were not sent, so there are no already notified users
         $already_notified = NULL;
     }
     $notifications_mode = $Settings->get('outbound_notifications_mode');
     if ($notifications_mode == 'off') {
         // Exit silently
         return false;
     }
     if ($this->notifications_status == 'finished') {
         // pings have been done before
         if ($verbose) {
             $Messages->add(T_('Post had already pinged: skipping notifications...'), 'note');
         }
         return false;
     }
     if ($this->notifications_status != 'noreq') {
         // pings have been done before
         // TODO: Check if issue_date has changed and reschedule
         if ($verbose) {
             $Messages->add(T_('Post processing already pending...'), 'note');
         }
         return false;
     }
     if ($this->status != 'published') {
         // TODO: discard any notification that may be pending!
         if ($verbose) {
             $Messages->add(T_('Post not publicly published: skipping notifications...'), 'note');
         }
         return false;
     }
     if (in_array($this->ptyp_ID, $posttypes_nopermanentURL)) {
         // TODO: discard any notification that may be pending!
         if ($verbose) {
             $Messages->add(T_('This post type doesn\'t need notifications...'), 'note');
         }
         return false;
     }
     if ($notifications_mode == 'immediate' && strtotime($this->issue_date) <= $localtimenow) {
         // We want to do the post processing immediately:
         // send outbound pings:
         $this->send_outbound_pings($verbose);
         // Send email notifications now!
         $this->send_email_notifications(false, $already_notified);
         // Record that processing has been done:
         $this->set('notifications_status', 'finished');
     } else {
         // We want asynchronous post processing. This applies to posts with date in future too.
         $Messages->add(T_('Scheduling asynchronous notifications...'), 'note');
         // CREATE OBJECT:
         load_class('/cron/model/_cronjob.class.php', 'Cronjob');
         $edited_Cronjob = new Cronjob();
         // start datetime. We do not want to ping before the post is effectively published:
         $edited_Cronjob->set('start_datetime', $this->issue_date);
         // no repeat.
         // name:
         $edited_Cronjob->set('name', sprintf(T_('Send notifications for &laquo;%s&raquo;'), strip_tags($this->title)));
         // controller:
         $edited_Cronjob->set('controller', 'cron/jobs/_post_notifications.job.php');
         // params: specify which post this job is supposed to send notifications for:
         $edited_Cronjob->set('params', array('item_ID' => $this->ID));
         // Save cronjob to DB:
         $edited_Cronjob->dbinsert();
         // Memorize the cron job ID which is going to handle this post:
         $this->set('notifications_ctsk_ID', $edited_Cronjob->ID);
         // Record that processing has been scheduled:
         $this->set('notifications_status', 'todo');
     }
     // Save the new processing status to DB
     $this->dbupdate();
     return true;
 }