Exemplo n.º 1
0
 /**
  * post-trigger of task
  */
 public function complete()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $task_id = (int) $this->request->post['task_id'];
     if ($task_id) {
         $tm = new ATaskManager();
         $tm->deleteTask($task_id);
         $install_upgrade_history = new ADataset('install_upgrade_history', 'admin');
         $backup_name = $this->request->get_or_post('backup_name');
         $backup_name = !$backup_name ? 'manual_backup' : $backup_name;
         $display_name = '';
         if (is_file(DIR_BACKUP . $backup_name . '.tar.gz')) {
             $display_name = $backup_name . '.tar.gz';
             $result_text = $this->html->convertLinks($this->language->get('backup_complete_text_file'));
         } elseif (is_dir(DIR_BACKUP . $backup_name)) {
             $display_name = $backup_name . '/...';
             $result_text = sprintf($this->language->get('backup_complete_text_dir'), DIR_BACKUP . $backup_name);
         }
         $install_upgrade_history->addRows(array('date_added' => date("Y-m-d H:i:s", time()), 'name' => 'Manual Backup', 'version' => VERSION, 'backup_file' => $display_name, 'backup_date' => date("Y-m-d H:i:s", time()), 'type' => 'backup', 'user' => $this->user->getUsername()));
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->load->library('json');
     $this->response->addJSONHeader();
     $this->response->setOutput(AJson::encode(array('result' => true, 'result_text' => $result_text)));
 }
Exemplo n.º 2
0
 public function delete()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $id = (int) $this->request->get_or_post('task_id');
     if ($id) {
         $tm = new ATaskManager();
         $tm->deleteTask($id);
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     $this->redirect($this->html->getSecureURL('tool/task'));
 }
Exemplo n.º 3
0
 public function incompleted()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadModel('user/user');
     $this->data = $this->language->getASet('sale/contact');
     $tm = new ATaskManager();
     $incompleted = $tm->getTasks(array('filter' => array('name' => 'send_now')));
     $k = 0;
     foreach ($incompleted as $incm_task) {
         //show all incompleted tasks for Top Administrator user group
         if ($this->user->getUserGroupId() != 1) {
             if ($incm_task['starter'] != $this->user->getId()) {
                 continue;
             }
         }
         //define incompleted tasks by last time run
         $max_exec_time = (int) $incm_task['max_execution_time'];
         if (!$max_exec_time) {
             //if no limitations for execution time for task - think it's 2 hours
             //$max_exec_time = 7200;
             $max_exec_time = 7200;
         }
         if (time() - dateISO2Int($incm_task['last_time_run']) > $max_exec_time) {
             //get some info about task, for ex message-text and subject
             $steps = $tm->getTaskSteps($incm_task['task_id']);
             if (!$steps) {
                 $tm->deleteTask($incm_task['task_id']);
             }
             $user_info = $this->model_user_user->getUser($incm_task['starter']);
             $incm_task['starter_name'] = $user_info['username'] . ' ' . $user_info['firstname'] . ' ' . $user_info['lastname'];
             $step = current($steps);
             $step_settings = $step['settings'];
             if ($step_settings['subject']) {
                 $incm_task['subject'] = $step_settings['subject'];
             }
             $incm_task['message'] = mb_substr($step_settings['message'], 0, 300);
             $incm_task['date_added'] = dateISO2Display($incm_task['date_added'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format'));
             $incm_task['last_time_run'] = dateISO2Display($incm_task['last_time_run'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format'));
             $incm_task['was_sent'] = sprintf($this->language->get('text_was_sent'), $incm_task['settings']['sent'], $incm_task['settings']['recipients_count']);
             $this->data['tasks'][$k] = $incm_task;
         }
         $k++;
     }
     $this->data['restart_task_url'] = $this->html->getSecureURL('r/sale/contact/restartTask');
     $this->data['complete_task_url'] = $this->html->getSecureURL('r/sale/contact/complete');
     $this->data['abort_task_url'] = $this->html->getSecureURL('r/sale/contact/abort');
     $this->view->batchAssign($this->data);
     $this->processTemplate('responses/sale/contact_incompleted.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }