public static function withPermissions() { $query = "\n\t\t\t\tSELECT\n\t\t\t\t\tServices.*\n\t\t\t\tFROM\n\t\t\t\t\tservices Services\n\t\t\t\tWHERE\n\t\t\t\t\tServices.status = " . static::STATUS_ACTIVE . "\n\t\t\t\tORDER BY sort ASC\n\t\t\t"; $services = array(); $result = static::execute($query)->group(); if ($result) { foreach ($result as $serviceId => $service) { $services[$serviceId] = array_merge($service[0], array('id' => $serviceId)); } } $permissions = ServicesPermissionsModel::all(array('conditions' => array('service_id' => array_keys($services), 'status' => ServicesPermissionsModel::STATUS_ACTIVE), 'order' => array('sort' => 'ASC')))->toArray(); if ($permissions) { foreach ($permissions as $permission) { if (isset($services[$permission['service_id']])) { $services[$permission['service_id']]['permissions'][] = $permission; } } } $actions = ServicesActionsModel::all(array('conditions' => array('service_id' => array_keys($services), 'status' => ServicesActionsModel::STATUS_ACTIVE), 'order' => array('sort' => 'ASC')))->toArray(); if ($actions) { foreach ($actions as $action) { if (isset($services[$action['service_id']])) { $services[$action['service_id']]['actions'][] = $action; } } } return $services; }
public static function start() { // Create task $task = TasksModel::create(); $task->user_id = $_SESSION['current']['username']['id']; $task->user_affected_id = $_SESSION['current']['username']['id']; $task->group_id = $_SESSION['current']['username']['group']; $task->type = TasksModel::TYPE_BACKUP; $task->title = 'Backup Data'; $task->created_at = date(DATE_TIME); $task->estimate = 10 * 60; $task->status = TasksModel::STATUS_PROGRESS; $task->save(); // Add services if ($_POST['services']) { foreach ($_POST['services'] as $serviceId) { $serviceId = (int) $serviceId; $taskService = TasksServicesModel::create(array('task_id' => $task->id, 'service_id' => $serviceId))->save(); } $task->contains = json_encode(ServicesActionsModel::getActions($_POST['services'])); $task->save(); } \Util::notice(array('type' => 'success', 'text' => 'The backup process has started. Check the list below to review it\'s status.')); $task = new PushTask('/queue/backup/' . $task->id); $task->add(); }
public static function start() { // Create task $task = TasksModel::create(); $task->user_id = $_SESSION['wizard']['source']['username']['id']; $task->user_affected_id = $_SESSION['wizard']['destination']['username']['id']; $task->group_id = $_SESSION['current']['username']['group']; $task->type = \Util::action(false, $_SESSION['wizard']['action']); $task->title = ucfirst(\Util::action()) . ' Data'; $task->created_at = date(DATE_TIME); $task->estimate = 10 * 60; $task->save(); // Add services if ($_SESSION['wizard']['services']) { foreach ($_SESSION['wizard']['services'] as $serviceId => $service) { $serviceId = (int) $serviceId; TasksServicesModel::create(array('task_id' => $task->id, 'service_id' => $serviceId))->save(); } $task->contains = json_encode(ServicesActionsModel::getActions($_POST['services'])); $task->save(); } // Reset wizard unset($_SESSION['wizard']); $task = new PushTask('/queue/add/' . $task->id); $task->add(); // Notification \Util::notice(array('type' => 'success', 'text' => 'Your ' . \Util::action('termination') . ' process has started. Check the list below to see it\'s status.')); }