Пример #1
0
 /**
  * Browse all jobs.
  *
  * @param null $action
  *
  * @return void
  */
 public function browse($action = NULL)
 {
     $qm = new CRM_Queryrunner_QueryManager();
     // using Export action for Execute. Doh.
     if ($this->_action & CRM_Core_Action::EXPORT) {
         $qm->execute($this->_id, TRUE);
         $name = $qm->getNameFromId($this->_id);
         CRM_Core_Session::setStatus(ts("The {$name} query has been executed."), ts("Executed"), "success");
     }
     $freqs = CRM_Queryrunner_Query::getQueryFrequency();
     $rows = array();
     foreach ($qm->queries as $query) {
         $action = array_sum(array_keys($this->links()));
         if ($query->is_active) {
             $action -= CRM_Core_Action::ENABLE;
         } else {
             $action -= CRM_Core_Action::DISABLE;
         }
         $query->action = CRM_Core_Action::formLink(self::links(), $action, array('id' => $query->id), ts('more'), FALSE, 'query.manage.action', 'Query', $query->id);
         $query->last_run = $query->last_run ? date('M j, Y, g:ia', $query->last_run) : 'never';
         $query->scheduled_run = $query->scheduled_run ? date('M j, Y, g:ia', $query->scheduled_run) : '';
         $query->run_frequency = $freqs[$query->run_frequency];
         $query = get_object_vars($query);
         $rows[] = $query;
         if ($query['id'] == $this->_id) {
             $this->assign('query', $query);
         }
     }
     $this->assign('rows', $rows);
     if ($this->_action & CRM_Core_Action::PREVIEW) {
         $this->assign('server', isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''));
         $this->assign('doc_root', $_SERVER['DOCUMENT_ROOT']);
     }
 }
Пример #2
0
 /**
  * Build the form object.
  *
  * @param bool $check
  *
  * @return void
  */
 public function buildQuickForm($check = FALSE)
 {
     parent::buildQuickForm();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $attributes = CRM_Core_DAO::getAttribute('CRM_Queryrunner_DAO_Query');
     $this->add('text', 'name', ts('Name'), $attributes['name'], TRUE);
     $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Queryrunner_DAO_Query', $this->_id));
     $this->add('text', 'description', ts('Description'), $attributes['description']);
     $this->add('textarea', 'query', ts('Query'), "cols=80 rows=10", true);
     $this->add('select', 'run_frequency', ts('Run Frequency'), CRM_Queryrunner_Query::getQueryFrequency(), true);
     $this->addDateTime('scheduled_run_date', ts('Scheduled Run Date'), FALSE, array('formatType' => 'activityDateTime'));
     $this->add('checkbox', 'is_active', ts('Is this Query active?'));
 }