Example #1
0
                    $t = new Task_install(0, $server_fqdn, $to_install);
                    $tm->add($t);
                    popup_info(_('Task successfully added'));
                }
            }
            redirect();
        }
    }
}
if ($_REQUEST['name'] == 'Task') {
    // it is the rigth place ? (see similar block on name=server action=install_line
    if (!checkAuthorization('manageServers')) {
        redirect();
    }
    $tm = new Tasks_Manager();
    $tm->load_all();
    $tm->refresh_all();
    if ($_REQUEST['action'] == 'add') {
        if (isset($_POST['type'])) {
            $type_task = 'Task_' . $_POST['type'];
            try {
                $task = new $type_task(0, $_POST['server'], $_POST['request']);
                $tm->add($task);
                popup_info(_("Task successfully added"));
            } catch (Exception $e) {
                Logger::error('main', 'tasks.php error create task (type=\'' . $type_task . '\')');
                popup_error("error create task (type='{$type_task}')");
            }
        }
        redirect('tasks.php');
    }
Example #2
0
 public function task_debian_upgrade($server_id_)
 {
     $this->check_authorized('manageServers');
     $server = Abstract_Server::load($server_id_);
     if (!is_object($server)) {
         Logger::error('api', sprintf('Unknown server "%s"', $server_id_));
         return null;
     }
     $tm = new Tasks_Manager();
     $tm->load_all();
     $tm->refresh_all();
     $t = new Task_upgrade(0, $server_id_);
     $tm->add($t);
     $this->log_action('task_debian_upgrade', array('server_id' => $server->id, 'server_name' => $server->getDisplayName()));
     return $t->id;
 }