Beispiel #1
0
 /**
  * Executes the command cron:list.
  *
  * Prints a list of ready and unready cron jobs.
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return null
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $tasks = $this->cron_manager->get_tasks();
     if (empty($tasks)) {
         $output->writeln($this->user->lang('CRON_NO_TASKS'));
         return;
     }
     $ready_tasks = array();
     $not_ready_tasks = array();
     foreach ($tasks as $task) {
         if ($task->is_ready()) {
             $ready_tasks[] = $task;
         } else {
             $not_ready_tasks[] = $task;
         }
     }
     if (!empty($ready_tasks)) {
         $output->writeln('<info>' . $this->user->lang('TASKS_READY') . '</info>');
         $this->print_tasks_names($ready_tasks, $output);
     }
     if (!empty($ready_tasks) && !empty($not_ready_tasks)) {
         $output->writeln('');
     }
     if (!empty($not_ready_tasks)) {
         $output->writeln('<info>' . $this->user->lang('TASKS_NOT_READY') . '</info>');
         $this->print_tasks_names($not_ready_tasks, $output);
     }
 }
 /**
  * Runs the cron job after the response was sent
  *
  * @param PostResponseEvent	$event	The event
  */
 public function on_kernel_terminate(PostResponseEvent $event)
 {
     $request = $event->getRequest();
     $controller_name = $request->get('_route');
     if ($controller_name !== 'phpbb_cron_run') {
         return;
     }
     $cron_type = $request->get('cron_type');
     if ($this->cron_lock->acquire()) {
         $task = $this->cron_manager->find_task($cron_type);
         if ($task) {
             if ($task->is_parametrized()) {
                 $task->parse_parameters($this->request);
             }
             if ($task->is_ready()) {
                 $task->run();
             }
             $this->cron_lock->release();
         }
     }
 }
Beispiel #3
0
 /**
  * Executes a given cron task, if it is ready.
  *
  * If there is a task whose name matches $task_name, it is run and 0 is returned.
  *		and if verbose mode is set, print an info message with the name of the task.
  * If there is no task matching $task_name, the function prints an error message
  *		and returns with status 2.
  *
  * @see execute
  * @param string $task_name The name of the task that should be run.
  * @param InputInterface $input The input stream used to get the argument and verbose option.
  * @param OutputInterface $output The output stream, used for printing verbose-mode and error information.
  * @return int 0 if all is well, 2 if no task matches $task_name.
  */
 protected function run_one(InputInterface $input, OutputInterface $output, $task_name)
 {
     $task = $this->cron_manager->find_task($task_name);
     if ($task) {
         if ($input->getOption('verbose')) {
             $output->writeln('<info>' . $this->user->lang('RUNNING_TASK', $task_name) . '</info>');
         }
         $task->run();
         return 0;
     } else {
         throw new runtime_exception('CRON_NO_SUCH_TASK', array($task_name), null, 2);
     }
 }
 /**
  * Display cat or subcat
  *
  * @return	null
  */
 public function display()
 {
     $cat_rows = $subcats = array();
     $parent_id = $visible_cats = 0;
     $sql_array = array('SELECT' => 'cat_id, left_id, right_id, parent_id, cat_name, cat_desc, display_subcat_list, cat_desc_uid, cat_desc_bitfield, cat_desc_options, cat_links, cat_icon, cat_count_all', 'FROM' => array(DIR_CAT_TABLE => ''));
     if (empty($this->data)) {
         $root_data = array('cat_id' => 0);
         $sql_where = '';
     } else {
         $root_data = $this->data;
         $sql_where = 'left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id'];
     }
     $sql = $this->db->sql_build_query('SELECT', array('SELECT' => $sql_array['SELECT'], 'FROM' => $sql_array['FROM'], 'WHERE' => $sql_where, 'ORDER_BY' => 'left_id'));
     $result = $this->db->sql_query($sql);
     $branch_root_id = $root_data['cat_id'];
     while ($row = $this->db->sql_fetchrow($result)) {
         $dir_cat_id = $row['cat_id'];
         if ($row['parent_id'] == $root_data['cat_id'] || $row['parent_id'] == $branch_root_id) {
             // Direct child of current branch
             $parent_id = $dir_cat_id;
             $cat_rows[$dir_cat_id] = $row;
         } else {
             $subcats[$parent_id][$dir_cat_id]['display'] = $row['display_subcat_list'] ? true : false;
             $subcats[$parent_id][$dir_cat_id]['name'] = $row['cat_name'];
             $subcats[$parent_id][$dir_cat_id]['links'] = $row['cat_links'];
             $subcats[$parent_id][$dir_cat_id]['parent_id'] = $row['parent_id'];
         }
     }
     $this->db->sql_freeresult($result);
     foreach ($cat_rows as $row) {
         $visible_cats++;
         $dir_cat_id = $row['cat_id'];
         $subcats_list = array();
         // Generate list of subcats if we need to
         if (isset($subcats[$dir_cat_id])) {
             foreach ($subcats[$dir_cat_id] as $subcat_id => $subcat_row) {
                 $row['cat_links'] = $row['cat_count_all'] ? $row['cat_links'] + $subcat_row['links'] : $row['cat_links'];
                 if ($subcat_row['display'] && $subcat_row['parent_id'] == $dir_cat_id) {
                     $subcats_list[] = array('link' => $this->helper->route('ernadoo_phpbbdirectory_page_controller', array('cat_id' => (int) $subcat_id)), 'name' => $subcat_row['name'], 'links' => $subcat_row['links']);
                 } else {
                     unset($subcats[$dir_cat_id][$subcat_id]);
                 }
             }
         }
         $this->template->assign_block_vars('cat', array('CAT_NAME' => $row['cat_name'], 'CAT_DESC' => generate_text_for_display($row['cat_desc'], $row['cat_desc_uid'], $row['cat_desc_bitfield'], $row['cat_desc_options']), 'CAT_LINKS' => $row['cat_links'], 'CAT_IMG' => $this->dir_helper->get_img_path('icons', $row['cat_icon']), 'U_CAT' => $this->helper->route('ernadoo_phpbbdirectory_page_controller', array('cat_id' => (int) $row['cat_id']))));
         // Assign subcats loop for style authors
         foreach ($subcats_list as $subcat) {
             $this->template->assign_block_vars('cat.subcat', array('U_CAT' => $subcat['link'], 'CAT_NAME' => $subcat['name'], 'CAT_LINKS' => $subcat['links']));
         }
     }
     $this->template->assign_vars(array('S_AUTH_ADD' => $this->auth->acl_get('u_submit_dir'), 'S_AUTH_SEARCH' => $this->auth->acl_get('u_search_dir'), 'S_HAS_SUBCAT' => $visible_cats ? true : false, 'S_ROOT' => empty($this->data), 'U_MAKE_SEARCH' => $this->helper->route('ernadoo_phpbbdirectory_search_controller')));
     // Do the categorie Prune thang - cron type job ...
     if (!$this->config['use_system_cron']) {
         $task = $this->cron->find_task('ernadoo.phpbbdirectory.cron.task.core.prune_categorie');
         $task->set_categorie_data($this->data);
         if ($task->is_ready()) {
             $url = $task->get_url();
             $this->template->assign_var('RUN_CRON_TASK', '<img src="' . $url . '" width="1" height="1" alt="" />');
         }
     }
 }