Exemplo n.º 1
0
 /**
  * Cron Controller Class
  * Index Action - "http://SERVER/Cron"
  * calls the modle to select the requests to Transfer and 
  * opens process for each one of the requests   
  * 
  * @package ApplicationController
  * @subpackage CronController
  */
 public function indexAction()
 {
     $disabled_output = $this->getRequest()->getParam('no-output');
     $forceAll = $this->getRequest()->getParam('force-all');
     if (!isset($disabled_output) || !$disabled_output) {
         $this->view->output_enabled = true;
     } else {
         $this->view->output_enabled = false;
     }
     // we make 3 process at different iteraion
     // we order the check publish before publish for scenario of force all (all on one time)
     // we don't use else in case we force all
     $this->view->transfer = array();
     $this->view->publish_check = array();
     $this->view->publish = array();
     $minute = date('i');
     if ($minute % 2 === 0 || $forceAll) {
         //first execute
         $this->view->transfer = Application_Model_Cron::makeChangeProvider();
     }
     $publish_verification_iteration = Application_Model_General::getSettings('publish-verification-iteration', 20);
     $hour = date('G');
     // 24-hour format of an hour without leading zeros
     $dayofweek = date('w');
     // Numeric representation of the day of the week, 0 (for Sunday) through 6 (for Saturday)
     $working_days = (bool) ($dayofweek >= 0 && $dayofweek <= 4 && $hour >= 8 && $hour < 23);
     $friday = (bool) ($dayofweek == 5 && $hour >= 8 && $hour < 15);
     if ($minute % $publish_verification_iteration == 0 && ($working_days || $friday) || $forceAll) {
         // verify all requests return publish
         $this->view->publish_check = Application_Model_Cron::checkPublishResponseFromProviders();
     }
     if ($minute % 2 === 1 || $forceAll) {
         // publish
         $this->view->publish = Application_Model_Cron::publishChangeProvider();
     }
 }