/**
  * The general "do the jobs" action
  */
 public function indexAction()
 {
     $this->initHtml();
     if ($this->util->getMaintenanceLock()->isLocked()) {
         $this->addMessage($this->_('Cannot run cron job in maintenance mode.'));
     } elseif ($this->util->getCronJobLock()->isLocked()) {
         $this->addMessage($this->_('Cron jobs turned off.'));
     } else {
         $this->commJob();
     }
     $this->util->getMonitor()->startCronMailMonitor();
 }
Пример #2
0
 /**
  * Start the cron mail monitor
  *
  * @return boolean True when the job was started
  */
 public function reverseMaintenanceMonitor()
 {
     $job = new MonitorJob($this->project->getName() . ' maintenance mode');
     $lock = $this->util->getMaintenanceLock();
     if ($lock->isLocked()) {
         $job->stop();
         $lock->unlock();
         return false;
     }
     $lock->lock();
     $roles = $this->util->getDbLookup()->getRolesByPrivilege('pr.maintenance.maintenance-mode');
     if ($roles) {
         $where = 'gsf_id_primary_group IN (SELECT ggp_id_group FROM gems__groups WHERE ggp_role IN (' . implode(', ', array_map(array($this->db, 'quote'), array_keys($roles))) . '))';
     } else {
         $where = null;
     }
     $to = $this->_getMailTo('maintenancemode', $where);
     if (!$to) {
         return true;
     }
     switch ($this->project->getLocaleDefault()) {
         case 'nl':
             $initSubject = "{name} is aangezet";
             $initBbText = "L.S.,\n\nDe [b]{name}[/b] is op {setTime} aangezet.\n\nZolang dit aan blijft staan kan u regelmatig waarschuwingen krijgen.\n\nDit is een automatisch bericht.";
             $subject = "{name} staat al meer dan {periodHours} uur aan";
             $messageBbText = "L.S.,\n\nDe [b]{name}[/b] is op {setTime} aangezet en staat nog steeds aan.\n\nDit is waarschuwing nummer [b]{mailCount}[/b]. Controleer s.v.p. of de onderhouds modus nog steeds nodig is.\n\nDit is een automatische waarschuwing.";
             break;
         default:
             $initSubject = "{name} has been turned on";
             $initBbText = "L.S.,\n\nThe [b]{name}[/b] was activated at {setTime}.\n\nAs long as maintenance mode is active the system may send you warning messages.\n\nThis messages was send automatically.";
             $subject = "{name} has been active for over {periodHours} hours";
             $messageBbText = "L.S.,\n\nThe [b]{name}[/b] was activated at {setTime} and is still active.\n\nThis is notice number {mailCount}. Please check whether the maintenance mode is still required.\n\nThis messages was send automatically.";
             break;
     }
     $job->setFrom($this->project->getMonitorFrom('maintenancemode'))->setMessage($messageBbText)->setPeriod($this->project->getMonitorPeriod('maintenancemode'))->setSubject($subject)->setTo($to);
     if ($job->start()) {
         $job->sendOtherMail($initSubject, $initBbText);
     }
     return true;
 }