/** * Send a message to a log. If the deposit package is aware of a * a scheduled task, the message will be sent to the task's * log. Otherwise it will be sent to error_log(). * * @param $message string Locale-specific message to be logged */ function _logMessage($message) { if ($this->_task) { $this->_task->addExecutionLogEntry($message, SCHEDULED_TASK_MESSAGE_TYPE_NOTICE); } else { error_log($message); } }
/** * Constructor. * @param $args array script arguments */ function FileLoader($args) { parent::ScheduledTask($args); // Set an initial process id and load translations (required // for email notifications). AppLocale::requireComponents(LOCALE_COMPONENT_PKP_ADMIN); $this->_newProcessId(); // Canonicalize the base path. $basePath = rtrim($args[0], DIRECTORY_SEPARATOR); $basePathFolder = basename($basePath); // We assume that the parent folder of the base path // does already exist and can be canonicalized. $basePathParent = realpath(dirname($basePath)); if ($basePathParent === false) { $basePath = null; } else { $basePath = $basePathParent . DIRECTORY_SEPARATOR . $basePathFolder; } $this->_basePath = $basePath; // Configure paths. if (!is_null($basePath)) { $this->_stagePath = $basePath . DIRECTORY_SEPARATOR . FILE_LOADER_PATH_STAGING; $this->_archivePath = $basePath . DIRECTORY_SEPARATOR . FILE_LOADER_PATH_ARCHIVE; $this->_rejectPath = $basePath . DIRECTORY_SEPARATOR . FILE_LOADER_PATH_REJECT; $this->_processingPath = $basePath . DIRECTORY_SEPARATOR . FILE_LOADER_PATH_PROCESSING; } // Set admin email and name. $siteDao = DAORegistry::getDAO('SiteDAO'); /* @var $siteDao SiteDAO */ $site = $siteDao->getSite(); /* @var $site Site */ $this->_adminEmail = $site->getLocalizedContactEmail(); $this->_adminName = $site->getLocalizedContactName(); }
/** * Constructor. * @param $argv array task arguments */ function __construct($args) { PluginRegistry::loadCategory('importexport'); $plugin = PluginRegistry::getPlugin('importexport', 'MedraExportPlugin'); /* @var $plugin MedraExportPlugin */ $this->_plugin = $plugin; if (is_a($plugin, 'MedraExportPlugin')) { $plugin->addLocaleData(); } parent::__construct($args); }
/** * Constructor. * @param $argv array task arguments */ function MedraInfoSender($args) { PluginRegistry::loadCategory('importexport'); $plugin = PluginRegistry::getPlugin('importexport', 'MedraExportPlugin'); /* @var $plugin MedraExportPlugin */ $this->_plugin = $plugin; if (is_a($plugin, 'MedraExportPlugin')) { $plugin->addLocaleData(); } parent::ScheduledTask($args); }
/** * Constructor. * @param $argv array task arguments */ function DataciteInfoSender($args) { PluginRegistry::loadCategory('importexport'); $plugin =& PluginRegistry::getPlugin('importexport', 'DataciteExportPlugin'); /* @var $plugin CrossRefExportPlugin */ $this->_plugin =& $plugin; if (is_a($plugin, 'DataciteExportPlugin')) { $plugin->addLocaleData(); } parent::ScheduledTask($args); }
/** * Constructor. * @param $argv array task arguments */ function ArticleInfoSender($args) { PluginRegistry::loadCategory('generic'); $plugin =& PluginRegistry::getPlugin('generic', 'almplugin'); /* @var $plugin AlmPlugin */ $this->_plugin =& $plugin; if (is_a($plugin, 'AlmPlugin')) { $plugin->addLocaleData(); $this->_depositUrl = $plugin->getSetting(CONTEXT_ID_NONE, 'depositUrl'); } parent::ScheduledTask($args); }
protected function display() { if (Tools::isConnectedUser()) { $teamList = $this->session_user->getTeamList(); // only teamMembers & observers can access this page if (0 == $this->teamid || $this->session_user->isTeamCustomer($this->teamid)) { $this->smartyHelper->assign('accessDenied', TRUE); } else { $pageWidth = Tools::getSecurePOSTIntValue('width', Tools::getSecureGETIntValue('width', 0)); $this->smartyHelper->assign('width', $pageWidth); if (array_key_exists($this->teamid, $teamList)) { $this->smartyHelper->assign('consistencyErrors', $this->getConsistencyErrors($this->teamid)); $team = TeamCache::getInstance()->getTeam($this->teamid); $isManager = $this->session_user->isTeamManager($this->teamid); $isObserver = $this->session_user->isTeamObserver($this->teamid); $this->smartyHelper->assign('isManager', $isManager || $isObserver); // display backlog (unassigned tasks) $unassignedIssues = $team->getUnassignedTasks(); $unassigendSel = new IssueSelection("unassigned from team {$this->teamid}"); $unassigendSel->addIssueList($unassignedIssues); $this->smartyHelper->assign('unassigned_nbIssues', $unassigendSel->getNbIssues()); $this->smartyHelper->assign('unassigned_MEE', $unassigendSel->mgrEffortEstim); $this->smartyHelper->assign('unassigned_EE', $unassigendSel->effortEstim + $unassigendSel->effortAdd); // get planningOptions $keyvalue = Tools::getSecurePOSTStringValue('planningOptions', ''); if (!empty($keyvalue)) { $planningOptions = Tools::doubleExplode(':', ',', $keyvalue); $this->session_user->setPlanningOptions($this->teamid, $planningOptions); } $this->smartyHelper->assign('planningOptions', $this->getPlanningOptions()); $today = mktime(0, 0, 0, date("m"), date("d"), date("Y")); $graphSize = "undefined" != $pageWidth ? $pageWidth - 150 : 800; $allTasksLists = array(); $workloads = array(); $teamMembers = $team->getUsers(); $nbDaysToDisplay = 0; foreach ($teamMembers as $user) { $workload = 0; // show only developper's & manager's tasks if (!$user->isTeamDeveloper($this->teamid) && !$user->isTeamManager($this->teamid)) { if (self::$logger->isDebugEnabled()) { self::$logger->debug("user " . $user->getId() . " excluded from scheduled users on team {$this->teamid}"); } continue; } if (NULL != $user->getDepartureDate($this->teamid) && $user->getDepartureDate($this->teamid) < $today) { continue; } $scheduledTaskList = ScheduledTask::scheduleUser($user, $today, $this->teamid, TRUE); foreach ($scheduledTaskList as $scheduledTask) { $workload += $scheduledTask->getDuration(); } $nbDaysToDisplay = $nbDaysToDisplay < $workload ? $workload : $nbDaysToDisplay; $allTasksLists[$user->getName()] = $scheduledTaskList; $workloads[$user->getName()] = $workload; } $dayPixSize = 0 != $nbDaysToDisplay ? $graphSize / $nbDaysToDisplay : 0; $dayPixSize = round($dayPixSize); #echo "DEBUG dayPixSize = $dayPixSize<br/>\n"; $this->smartyHelper->assign('planning', $this->getPlanning($nbDaysToDisplay, $dayPixSize, $allTasksLists, $workloads, $this->teamid, $this->session_userid, $isManager)); $this->smartyHelper->assign('colors', array("green" => T_("onTime"), "red" => T_("NOT onTime"), "blue" => T_("no deadLine"), "grey" => T_("monitored"))); $this->smartyHelper->assign('dayPixSize', $dayPixSize - 1); } } } }
/** deploy_post() actually create the deployment task * @return void */ public function deploy_post() { $Data = $this->obj; $TaskType = new TaskType($_REQUEST['type']); $Snapin = $_REQUEST['snapin'] ? new Snapin($_REQUEST['snapin']) : -1; $enableShutdown = $_REQUEST['shutdown'] ? true : false; $enableSnapins = $TaskType->get('id') != '17' ? $Snapin instanceof Snapin && $Snapin->isValid() ? $Snapin->get('id') : $Snapin : false; $enableDebug = $_REQUEST['debug'] == 'true' || $_REQUEST['isDebugTask'] ? true : false; $scheduleDeployTime = $this->nice_date($_REQUEST['scheduleSingleTime']); $imagingTasks = in_array($TaskType->get('id'), array(1, 2, 8, 15, 16, 17, 24)); try { if (!$TaskType || !$TaskType->isValid()) { throw new Exception(_('Task type is not valid')); } $taskName = $TaskType->get('name') . ' Task'; if ($Data && $Data->isValid()) { // Error Checking if ($Data instanceof Host && $imagingTasks) { if (!$Data->getImage() || !$Data->getImage()->isValid()) { throw new Exception(_('You need to assign an image to the host')); } if ($TaskType->isUpload() && $Data->getImage()->get('protected')) { throw new Exception(_('You cannot upload to this image as it is currently protected')); } if (!$Data->checkIfExist($TaskType->get('id'))) { throw new Exception(_('You must first upload an image to create a download task')); } } else { if ($Data instanceof Group && $imagingTasks) { if ($TaskType->isMulticast() && !$Data->doMembersHaveUniformImages()) { throw new Exception(_('Hosts do not contain the same image assignments')); } unset($NoImage, $ImageExists, $Tasks); foreach ((array) $Data->get('hosts') as $Host) { if ($Host && $Host->isValid() && !$Host->get('pending')) { $NoImage[] = !$Host->getImage() || !$Host->getImage()->isValid(); } } if (in_array(true, $NoImage)) { throw new Exception(_('One or more hosts do not have an image set')); } foreach ((array) $Data->get('hosts') as $Host) { if ($Host && $Host->isValid() && !$Host->get('pending')) { $ImageExists[] = !$Host->checkIfExist($TaskType->get('id')); } } if (in_array(true, $ImageExists)) { throw new Exception(_('One or more hosts have an image that does not exist')); } foreach ((array) $Data->get('hosts') as $Host) { if ($Host && $Host->isValid() && $Host->get('task') && $Host->get('task')->isValid()) { $Tasks[] = $Host->get('task'); } } if (count($Tasks) > 0) { throw new Exception(_('One or more hosts are currently in a task')); } } } $passreset = trim($_REQUEST['account']); if ($TaskType->get('id') == 11 && empty($passreset)) { throw new Exception(_('Password reset requires a user account to reset')); } try { if ($_REQUEST['scheduleType'] == 'instant') { if ($Data instanceof Group) { foreach ((array) $Data->get('hosts') as $Host) { if ($Host && $Host->isValid() && !$Host->get('pending')) { if ($Host->createImagePackage($TaskType->get('id'), $taskName, $enableShutdown, $enableDebug, $enableSnapins, $Data instanceof Group, $_SESSION['FOG_USERNAME'], $passreset)) { $success[] = sprintf('<li>%s – %s</li>', $Host->get('name'), $Host->getImage()->get('name')); } } } } else { if ($Data instanceof Host) { if ($Data->createImagePackage($TaskType->get('id'), $taskName, $enableShutdown, $enableDebug, $enableSnapins, $Data instanceof Group, $_SESSION['FOG_USERNAME'], $passreset)) { $success[] = sprintf('<li>%s – %s</li>', $Data->get('name'), $Data->getImage()->get('name')); } } } } else { if ($_REQUEST['scheduleType'] == 'single') { if ($scheduleDeployTime < $this->nice_date()) { throw new Exception(sprintf('%s<br>%s: %s', _('Scheduled date is in the past'), _('Date'), $scheduleDeployTime->format('Y/d/m H:i'))); } $ScheduledTask = new ScheduledTask(array('taskType' => $TaskType->get('id'), 'name' => $taskName, 'hostID' => $Data->get('id'), 'shutdown' => $enableShutdown, 'other2' => $enableSnapins, 'isGroupTask' => $Data instanceof Group, 'type' => 'S', 'scheduleTime' => $scheduleDeployTime->getTimestamp(), 'other3' => $this->FOGUser->get('name'))); } else { if ($_REQUEST['scheduleType'] == 'cron') { $ScheduledTask = new ScheduledTask(array('taskType' => $TaskType->get('id'), 'name' => $taskName, 'hostID' => $Data->get('id'), 'shutdown' => $enableShutdown, 'other2' => $enableSnapins, 'isGroupTask' => $Data instanceof Group, 'type' => 'C', 'other3' => $this->FOGUser->get('name'), 'minute' => $_REQUEST['scheduleCronMin'], 'hour' => $_REQUEST['scheduleCronHour'], 'dayOfMonth' => $_REQUEST['scheduleCronDOM'], 'month' => $_REQUEST['scheduleCronMonth'], 'dayOfWeek' => $_REQUEST['scheduleCronDOW'])); } } } if ($ScheduledTask && $ScheduledTask->save()) { if ($Data instanceof Group) { foreach ((array) $Data->get('hosts') as $Host) { if ($Host && $Host->isValid() && !$Host->get('pending')) { $success[] = sprintf('<li>%s – %s</li>', $Host->get('name'), $Host->getImage()->get('name')); } } } else { if ($Data instanceof Host) { if ($Data && $Data->isValid() && !$Data->get('pending')) { $success[] = sprintf('<li>%s – %s</li>', $Data->get('name'), $Data->getImage()->get('name')); } } } } } catch (Exception $e) { $error[] = sprintf('%s: %s', $Data instanceof Group ? $Host->get('name') : $Data->get('name'), $e->getMessage()); } } // Failure if (count($error)) { throw new Exception('<ul><li>' . implode('</li><li>', $error) . '</li></ul>'); } } catch (Exception $e) { // Failure printf('<div class="task-start-failed"><p>%s</p><p>%s</p></div>', _('Failed to create deployment tasking for the following hosts'), $e->getMessage()); } // Success if (count($success)) { printf('<div class="task-start-ok"><p>%s</p><p>%s%s%s</p></div>', sprintf(_('Successfully created tasks for deployment to the following Hosts'), $Data instanceof Group ? $Host->getImage()->get('name') : $Data->getImage()->get('name')), $_REQUEST['scheduleType'] == 'cron' ? sprintf('%s: %s', _('Cron Schedule'), implode(' ', array($_REQUEST['scheduleCronMin'], $_REQUEST['scheduleCronHour'], $_REQUEST['scheduleCronDOM'], $_REQUEST['scheduleCronMonth'], $_REQUEST['scheduleCronDOW']))) : '', $_REQUEST['scheduleType'] == 'single' ? sprintf('%s: %s', _('Scheduled to start at'), $scheduleDeployTime->format('Y/m/d H:i')) : '', count($success) ? sprintf('<ul>%s</ul>', implode('', $success)) : ''); } }
/** * Constructor. */ function __construct() { parent::__construct(); }
/** * Initialize complex static variables * @static */ public static function staticInit() { self::$logger = Logger::getLogger(__CLASS__); }
/** * Constructor. */ function OpenAccessNotification() { parent::ScheduledTask(); }
/** * Constructor. */ function ReviewReminder() { parent::ScheduledTask(); }
public function scheduled_post() { if (isset($_REQUEST['rmid'])) { $this->HookManager->processEvent('TaskScheduledRemove'); $Task = new ScheduledTask($_REQUEST['rmid']); if ($Task->destroy()) { $this->HookManager->processEvent('TaskScheduledRemoveSuccess'); } else { $this->HookManager->processEvent('TaskScheduledRemoveFail'); } $this->FOGCore->redirect($this->formAction); } }
/** * Constructor. */ function BooksForReviewReminder() { parent::ScheduledTask(); }
public function getScheduledTimeForMethod($className, $methodName, $methodParameter = null) { $taskName = ScheduledTask::getTaskName($className, $methodName, $methodParameter); return $this->taskHasBeenScheduledOnce($taskName) ? $this->timetable[$taskName] : false; }
/** * Constructor. */ function ObjectsForReviewReminder() { parent::ScheduledTask(); }
/** stopScheduledTask($task) Stops the scheduled task. */ public function stopScheduledTask($task) { $ScheduledTask = new ScheduledTask($task->get('id')); return $ScheduledTask->set('isActive', 0)->save(); }
/** * Constructor. * @param $argv array task arguments */ function Depositor($args) { PluginRegistry::loadCategory('generic'); $this->_plugin =& PluginRegistry::getPlugin('generic', PLN_PLUGIN_NAME); parent::ScheduledTask($args); }
/** * Constructor. */ function SubscriptionExpiryReminder() { parent::ScheduledTask(); }