public function actionRunAjaxJob($type, $timeLimit = 500, $messageLoggerClassName = 'MessageLogger')
 {
     Yii::app()->getClientScript()->setToAjaxMode();
     $template = '<li>{message}</li>';
     $isJobInProgress = false;
     try {
         JobsManagerUtil::runFromJobManagerCommandOrBrowser($type, (int) $timeLimit, $messageLoggerClassName, $isJobInProgress, true, $template);
     } catch (Exception $e) {
         echo Zurmo::t('JobsManagerModule', 'There was an error. Please check logs for more details');
     }
     Yii::app()->end(0, false);
 }
 /**
  * Execute the action.  Changes max run time to 5 minutes, pass the optional parameter
  * @param array command line parameters specific for this command
  */
 public function run($args)
 {
     if (!isset($args[0])) {
         $this->usageError('A username must be specified.');
     }
     if (!isset($args[1])) {
         $this->usageError('A job type must be specified.');
     }
     try {
         Yii::app()->user->userModel = User::getByUsername($args[0]);
         $group = Group::getByName(Group::SUPER_ADMINISTRATORS_GROUP_NAME);
         if (!$group->users->contains(Yii::app()->user->userModel)) {
             $this->usageError('The username specified must be for a super administrator.');
         }
     } catch (NotFoundException $e) {
         $this->usageError('The specified username does not exist.');
     }
     if (!is_string($args[1])) {
         $this->usageError('The specified job type to run is invalid.');
     } else {
         $jobClassName = $args[1] . 'Job';
         if (!@class_exists($jobClassName)) {
             $this->usageError('The specified job type to run does not exist.');
         }
     }
     if (isset($args[2])) {
         $timeLimit = (int) $args[2];
     } else {
         $timeLimit = 300;
     }
     if (isset($args[3])) {
         $messageLoggerClassName = $args[3];
     } else {
         $messageLoggerClassName = 'MessageLogger';
     }
     echo "\n";
     $isJobInProgress = false;
     JobsManagerUtil::runFromJobManagerCommandOrBrowser($args[1], $timeLimit, $messageLoggerClassName, $isJobInProgress, false);
 }
예제 #3
0
 public function actionRunJob($type, $timeLimit = 500, $messageLoggerClassName = 'MessageLogger')
 {
     if (!Group::isUserASuperAdministrator(Yii::app()->user->userModel)) {
         echo Zurmo::t('JobsManagerModule', 'Only super administrators can run jobs from the browser');
         Yii::app()->end(0, false);
     }
     $breadCrumbLinks = array(Zurmo::t('JobsManagerModule', 'JobsManagerModuleSingularLabel', LabelUtil::getTranslationParamsForAllModules()) => array('/jobsManager/default'), Zurmo::t('JobsManagerModule', 'Run Job'));
     $runJobView = new RunJobView($this->getId(), $this->getModule()->getId(), $type, (int) $timeLimit);
     $view = new JobsManagerPageView(ZurmoDefaultAdminViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $runJobView, $breadCrumbLinks, 'SettingsBreadCrumbView'));
     echo $view->render();
     $template = ZurmoHtml::script("\$('#logging-table ol').append('<li>{message}</li>');");
     $isJobInProgress = false;
     JobsManagerUtil::runFromJobManagerCommandOrBrowser($type, (int) $timeLimit, $messageLoggerClassName, $isJobInProgress, true, $template);
     echo ZurmoHtml::script('$("#progress-table").hide(); $("#complete-table").show();');
 }