Beispiel #1
0
 public function run()
 {
     Logger::debug('main', 'ServerStatusChangedTask::run');
     $needs_cleanup = false;
     $data = get_from_cache('events', 'ServerStatusChanged');
     if ($data == NULL) {
         $data[$this->ev->fqdn] = $this->ev->status;
         if ($this->ev->status != ServerStatusChanged::$ONLINE) {
             $needs_cleanup = true;
         }
     } else {
         if ($this->ev->status != ServerStatusChanged::$ONLINE) {
             $needs_cleanup = true;
         }
     }
     if ($needs_cleanup) {
         Logger::debug('main', 'ServerStatusChangedTask::run cleanup task for ' . $this->ev->fqdn);
         set_cache($data, 'events', 'ServerStatusChanged');
         $tm = new Tasks_Manager();
         $tm->load_from_server($this->ev->fqdn);
         foreach ($tm->tasks as $a_task) {
             $tm->remove($a_task->id);
         }
     }
     return true;
 }
function do_create_task($fqdn_)
{
    $server = Abstract_Server::load($fqdn_);
    if (!is_object($server)) {
        Logger::error('main', '(ajax/installable_applications) Server ' . $fqdn_ . ' not found');
        header('Content-Type: text/xml; charset=utf-8');
        $dom = new DomDocument('1.0', 'utf-8');
        $node = $dom->createElement('usage');
        $node->setAttribute('status', 'server not found');
        $dom->appendChild($node);
        die($dom->saveXML());
    }
    $task = new Task_available_applications('', $fqdn_);
    $manager = new Tasks_Manager();
    $manager->add($task);
    header('Content-Type: text/xml; charset=utf-8');
    $dom = new DomDocument('1.0', 'utf-8');
    $node = $dom->createElement('task');
    $node->setAttribute('id', $task->id);
    $dom->appendChild($node);
    die($dom->saveXML());
}
Beispiel #3
0
                if (count($to_install) > 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');
Beispiel #4
0
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 **/
require_once dirname(__FILE__) . '/includes/core.inc.php';
require_once dirname(__FILE__) . '/includes/page_template.php';
if (!checkAuthorization('viewServers')) {
    redirect();
}
$tm = new Tasks_Manager();
$tm->load_all();
$tm->refresh_all();
if (isset($_REQUEST['action'])) {
    if ($_REQUEST['action'] == 'manage') {
        if (isset($_REQUEST['id'])) {
            show_manage($_REQUEST['id'], $tm);
        }
    }
}
show_default($tm);
function show_manage($id, $tm)
{
    $task = false;
    foreach ($tm->tasks as $t) {
        if ($t->id == $id) {
Beispiel #5
0
 public function application_info($id_)
 {
     $this->check_authorized('viewApplications');
     $applicationDB = ApplicationDB::getInstance();
     $applicationsGroupDB = ApplicationsGroupDB::getInstance();
     $application = $applicationDB->import($id_);
     if (!is_object($application)) {
         return null;
     }
     $a = self::generate_application_array($application);
     $liaisons = Abstract_Liaison::load('ApplicationServer', $application->getAttribute('id'), NULL);
     if (count($liaisons) > 0) {
         $a['servers'] = array();
         foreach ($liaisons as $liaison) {
             $server = Abstract_Server::load($liaison->group);
             if (!$server) {
                 continue;
             }
             $a['servers'][$server->id] = $server->getDisplayName();
         }
     }
     $liaisons = Abstract_Liaison::load('AppsGroup', $application->getAttribute('id'), NULL);
     if (count($liaisons) > 0) {
         $a['groups'] = array();
         foreach ($liaisons as $liaison) {
             $group = $applicationsGroupDB->import($liaison->group);
             if (!is_object($group)) {
                 continue;
             }
             $a['groups'][$group->id] = $group->name;
         }
     }
     $mimes = $application->getMimeTypes();
     if (count($mimes) > 0) {
         $a['mimetypes'] = $mimes;
     }
     $tm = new Tasks_Manager();
     $tm->load_from_application($id_);
     if (count($tm->tasks) > 0) {
         $a['tasks'] = array();
         foreach ($tm->tasks as $task) {
             $t = self::generate_task_array($task);
             $a['tasks'][$t['id']] = $t;
         }
     }
     return $a;
 }
 public static function removeRole($fqdn_, $role_)
 {
     Logger::debug('main', "Starting Abstract_Server::removeRole for '{$fqdn_}' removing '{$role_}'");
     if (substr($fqdn_, -1) == '.') {
         $fqdn_ = substr($fqdn_, 0, strlen($fqdn_) - 1);
     }
     $a_server = Abstract_Server::load($fqdn_);
     if (is_object($a_server) == false) {
         Logger::error('main', "Starting Abstract_Server::removeRole error failed to load server '{$fqdn_}'");
         return false;
     }
     $roles = $a_server->getAttribute('roles');
     if (is_array($roles) == false) {
         return false;
     }
     if (in_array($role_, $roles) == false) {
         return false;
     }
     switch ($role_) {
         case Server::SERVER_ROLE_APS:
             $prefs = Preferences::getInstance();
             if (!$prefs) {
                 die_error('get Preferences failed', __FILE__, __LINE__);
             }
             $slave_server_settings = $prefs->get('general', 'slave_server_settings');
             $remove_orphan = (bool) $slave_server_settings['remove_orphan'];
             Abstract_Liaison::delete('ApplicationServer', NULL, $fqdn_);
             if ($remove_orphan) {
                 $apps = $a_server->getApplications();
                 $applicationDB = ApplicationDB::getInstance();
                 // remove the orphan applications
                 if (is_array($apps)) {
                     foreach ($apps as $an_application) {
                         if ($an_application->isOrphan()) {
                             Logger::debug('main', "Abstract_Server::delete {$an_application} is orphan");
                             $applicationDB->remove($an_application);
                         }
                     }
                 }
             }
             $tm = new Tasks_Manager();
             $tm->load_from_server($fqdn_);
             foreach ($tm->tasks as $a_task) {
                 $tm->remove($a_task->id);
             }
             break;
         case Server::SERVER_ROLE_FS:
             if (Preferences::moduleIsEnabled('ProfileDB')) {
                 $profiledb = ProfileDB::getInstance();
                 $folders = $profiledb->importFromServer($fqdn_);
                 foreach ($folders as $a_folder) {
                     $profiledb->remove($a_folder->id);
                 }
             }
             if (Preferences::moduleIsEnabled('SharedFolderDB')) {
                 $sharedfolderdb = SharedFolderDB::getInstance();
                 $folders = $sharedfolderdb->importFromServer($fqdn_);
                 foreach ($folders as $a_folder) {
                     $profiledb->remove($a_folder->id);
                 }
             }
             break;
             // 			case Server::SERVER_ROLE_GATEWAY:
             // 			break;
     }
     return true;
 }
Beispiel #7
0
function show_manage($id, $applicationDB)
{
    $applicationsGroupDB = ApplicationsGroupDB::getInstance();
    $app = $applicationDB->import($id);
    if (!is_object($app)) {
        return false;
    }
    //     die_error('Unable to import application "'.$id.'"',__FILE__,__LINE__);
    if ($app->getAttribute('static')) {
        redirect('applications_static.php?action=manage&id=' . $app->getAttribute('id'));
    }
    $is_rw = $applicationDB->isWriteable();
    if ($app->getAttribute('published')) {
        $status = '<span class="msg_ok">' . _('Available') . '</span>';
        $status_change = _('Block');
        $status_change_value = 0;
    } else {
        $status = '<span class="msg_error">' . _('Blocked') . '</span>';
        $status_change = _('Unblock');
        $status_change_value = 1;
    }
    // Tasks
    $tm = new Tasks_Manager();
    $tm->load_from_application($id);
    $tm->refresh_all();
    $servers_in_install = array();
    $servers_in_remove = array();
    $tasks = array();
    foreach ($tm->tasks as $task) {
        if ($task->succeed()) {
            continue;
        }
        if ($task->failed()) {
            continue;
        }
        $tasks[] = $task;
        if (get_class($task) == 'Task_install') {
            if (!in_array($task->server, $servers_in_install)) {
                $servers_in_install[] = $task->server;
            }
        }
        if (get_class($task) == 'Task_remove') {
            if (!in_array($task->server, $servers_in_remove)) {
                $servers_in_remove[] = $task->server;
            }
        }
    }
    // Servers
    if ($app->getAttribute('static')) {
        $servers_all = array();
    } else {
        $servers_all = Abstract_Server::load_all();
    }
    $liaisons = Abstract_Liaison::load('ApplicationServer', $app->getAttribute('id'), NULL);
    $servers_id = array();
    foreach ($liaisons as $liaison) {
        $servers_id[] = $liaison->group;
    }
    $servers = array();
    $servers_available = array();
    foreach ($servers_all as $server) {
        if (in_array($server->fqdn, $servers_id)) {
            $servers[] = $server;
        } elseif (in_array($server->fqdn, $servers_in_install)) {
            continue;
        } elseif (!$server->isOnline()) {
            continue;
        } elseif ($server->type != $app->getAttribute('type')) {
            continue;
        } elseif (is_array($server->roles) && array_key_exists(Server::SERVER_ROLE_APS, $server->roles)) {
            $servers_available[] = $server;
        }
    }
    // App groups
    $appgroups = $applicationsGroupDB->getList(true);
    $groups_id = array();
    $liaisons = Abstract_Liaison::load('AppsGroup', $app->getAttribute('id'), NULL);
    foreach ($liaisons as $liaison) {
        $groups_id[] = $liaison->group;
    }
    $groups = array();
    $groups_available = array();
    foreach ($appgroups as $group) {
        if (in_array($group->id, $groups_id)) {
            $groups[] = $group;
        } else {
            $groups_available[] = $group;
        }
    }
    $can_manage_server = isAuthorized('manageServers');
    $can_manage_applicationsgroups = isAuthorized('manageApplicationsGroups');
    page_header();
    echo '<div>';
    echo '<h1><img src="media/image/cache.php?id=' . $app->getAttribute('id') . '" alt="" title="" /> ' . $app->getAttribute('name') . '</h1>';
    echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="3">';
    echo '<tr class="title">';
    echo '<th>' . _('Package') . '</th>';
    echo '<th>' . _('Type') . '</th>';
    //   echo '<th>'._('Status').'</th>';
    echo '<th>' . _('Description') . '</th>';
    echo '<th>' . _('Executable') . '</th>';
    echo '</tr>';
    echo '<tr class="content1">';
    echo '<td>' . $app->getAttribute('package') . '</td>';
    echo '<td style="text-align: center;"><img src="media/image/server-' . $app->getAttribute('type') . '.png" alt="' . $app->getAttribute('type') . '" title="' . $app->getAttribute('type') . '" /><br />' . $app->getAttribute('type') . '</td>';
    //   echo '<td>'.$status.'</td>';
    echo '<td>' . $app->getAttribute('description') . '</td>';
    echo '<td>' . $app->getAttribute('executable_path') . '</td>';
    echo '</tr>';
    echo '</table>';
    echo '<br />';
    echo '<table border="0" cellspacing="0" cellpadding="0">';
    echo '<tr><td>';
    echo '<form action="applications.php" method="get"">';
    echo '<input type="hidden" name="action" value="icon" />';
    echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />';
    echo '<input type="submit" value="' . _('Set custom icon') . '"/>';
    echo '</form>';
    echo '</td><td style="width: 10px;"></td><td>';
    echo '<form action="actions.php" method="post"">';
    echo '<input type="hidden" name="name" value="Application" />';
    echo '<input type="hidden" name="action" value="clone" />';
    echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />';
    echo '<input type="submit" value="' . _('Clone to static application') . '"/>';
    echo '</form>';
    echo '</td></tr>';
    echo '</table>';
    echo '<br />';
    // orphan part
    if ($app->isOrphan() && !$app->getAttribute('static')) {
        echo '<br />';
        echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to remove this application?') . '\');">';
        echo '<input type="hidden" name="action" value="del" />';
        echo '<input type="hidden" name="name" value="Application" />';
        echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />';
        echo _('This application is orphan') . ' <input type="submit" value="' . _('Remove this application') . '"/>';
        echo '</form>';
        echo '<br />';
    }
    //   if ($is_rw) {
    //     echo '<h2>'._('Settings').'</h2>';
    //
    //     echo '<form action="" method="post">';
    //     echo '<input type="hidden" name="action" value="modify" />';
    //     echo '<input type="hidden" name="id" value="'.$app->getAttribute('id').'" />';
    //     echo '<input type="hidden" name="published" value="'.$status_change_value.'" />';
    //     echo '<input type="submit" value="'.$status_change.'"/>';
    //     echo '</form>';
    //   }
    // Server part
    if (count($servers) + count($servers_in_install) + count($servers_available) > 0) {
        echo '<div>';
        echo '<h2>' . _('Servers with this application') . '</h2>';
        echo '<table border="0" cellspacing="1" cellpadding="3">';
        foreach ($servers as $server) {
            $remove_in_progress = in_array($server->fqdn, $servers_in_remove);
            echo '<tr><td>';
            echo '<a href="servers.php?action=manage&fqdn=' . $server->fqdn . '">' . $server->fqdn . '</a>';
            echo '</td>';
            echo '<td>';
            if ($remove_in_progress) {
                echo 'remove in progress';
            } elseif ($server->isOnline() and $can_manage_server and $app->getAttribute('type') == 'linux' and $app->hasAttribute('package') and $app->getAttribute('package') !== '') {
                echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to remove this application from this server?') . '\');">';
                echo '<input type="hidden" name="action" value="del" />';
                echo '<input type="hidden" name="name" value="Application_Server" />';
                echo '<input type="hidden" name="application" value="' . $id . '" />';
                echo '<input type="hidden" name="server" value="' . $server->fqdn . '" />';
                echo '<input type="submit" value="' . _('Remove from this server') . '"/>';
                echo '</form>';
            }
            echo '</td>';
            echo '</tr>';
        }
        foreach ($servers_in_install as $server) {
            echo '<tr><td>';
            echo '<a href="servers.php?action=manage&fqdn=' . $server . '">' . $server . '</a>';
            echo '</td>';
            echo '<td>install in progress</td>';
            echo '</tr>';
        }
        if (count($servers_available) > 0 and $can_manage_server and $app->getAttribute('type') == 'linux' and $app->hasAttribute('package') and $app->getAttribute('package') !== '') {
            $display_list = false;
            foreach ($servers_available as $server) {
                if ($server->hasAttribute('ulteo_system') && $server->getAttribute('ulteo_system') == 1) {
                    $display_list = true;
                    break;
                }
            }
            if ($display_list) {
                echo '<tr>';
                echo '<form action="actions.php" method="post"><td>';
                echo '<input type="hidden" name="name" value="Application_Server" />';
                echo '<input type="hidden" name="action" value="add" />';
                echo '<input type="hidden" name="application" value="' . $id . '" />';
                echo '<select name="server">';
                foreach ($servers_available as $server) {
                    if ($server->hasAttribute('ulteo_system') && $server->getAttribute('ulteo_system') == 1) {
                        echo '<option value="' . $server->fqdn . '">' . $server->fqdn . '</option>';
                    }
                }
                echo '</select>';
                echo '</td><td><input type="submit" value="' . _('Install on this server') . '" /></td>';
                echo '</form>';
                echo '</tr>';
            }
        }
        echo '</table>';
        echo "<div>\n";
    }
    if (count($tasks) > 0) {
        echo '<h2>' . _('Active tasks on this application') . '</h1>';
        echo '<table border="0" cellspacing="1" cellpadding="3">';
        echo '<tr class="title">';
        echo '<th>' . _('ID') . '</th>';
        echo '<th>' . _('Type') . '</th>';
        echo '<th>' . _('Status') . '</th>';
        echo '<th>' . _('Details') . '</th>';
        echo '</tr>';
        $count = 0;
        foreach ($tasks as $task) {
            $content = 'content' . ($count++ % 2 == 0 ? 1 : 2);
            if ($task->failed()) {
                $status = '<span class="msg_error">' . _('Error') . '</span>';
            } else {
                $status = '<span class="msg_ok">' . $task->status . '</span>';
            }
            echo '<tr class="' . $content . '">';
            echo '<td><a href="tasks.php?action=manage&id=' . $task->id . '">' . $task->id . '</a></td>';
            echo '<td>' . get_class($task) . '</td>';
            echo '<td>' . $status . '</td>';
            echo '<td>' . $task->server . ', ' . $task->getRequest() . ', ' . $task->status_code . '</td>';
            echo '</tr>';
        }
        echo '</table>';
        echo "<div>\n";
    }
    if (count($appgroups) > 0) {
        echo '<div>';
        echo '<h2>' . _('Groups with this application') . '</h2>';
        echo '<table border="0" cellspacing="1" cellpadding="3">';
        foreach ($groups as $group) {
            echo '<tr>';
            echo '<td>';
            echo '<a href="appsgroup.php?action=manage&id=' . $group->id . '">' . $group->name . '</a>';
            echo '</td>';
            if ($can_manage_applicationsgroups) {
                echo '<td><form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this application from this group?') . '\');">';
                echo '<input type="hidden" name="name" value="Application_ApplicationGroup" />';
                echo '<input type="hidden" name="action" value="del" />';
                echo '<input type="hidden" name="element" value="' . $id . '" />';
                echo '<input type="hidden" name="group" value="' . $group->id . '" />';
                echo '<input type="submit" value="' . _('Delete from this group') . '" />';
                echo '</form></td>';
            }
            echo '</tr>';
        }
        if (count($groups_available) > 0 and $can_manage_applicationsgroups) {
            echo '<tr>';
            echo '<form action="actions.php" method="post"><td>';
            echo '<input type="hidden" name="name" value="Application_ApplicationGroup" />';
            echo '<input type="hidden" name="action" value="add" />';
            echo '<input type="hidden" name="element" value="' . $id . '" />';
            echo '<select name="group">';
            foreach ($groups_available as $group) {
                echo '<option value="' . $group->id . '">' . $group->name . '</option>';
            }
            echo '</select>';
            echo '</td><td><input type="submit" value="' . _('Add to this group') . '" /></td>';
            echo '</form>';
            echo '</tr>';
        }
        echo '</table>';
        echo "<div>\n";
    }
    // Mime-Type part
    echo '<div>';
    echo '<h2>' . _('Mime-Types') . '</h2>';
    echo '<div>';
    if (count($app->getMimeTypes()) == 0) {
        echo _('No available mimes-type') . '<br />';
    } else {
        echo '<table border="0" cellspacing="1" cellpadding="3">';
        foreach ($app->getMimeTypes() as $mime) {
            echo '<tr><td>';
            echo '<a href="mimetypes.php?action=manage&id=' . urlencode($mime) . '">' . $mime . '</a>';
            echo '</td></tr>';
        }
        echo '</table>';
    }
    echo '</div>';
    echo '</div>';
    // mime div
    echo '</div>';
    echo '</div>';
    echo '</div>';
    echo '</div>';
    echo '</div>';
    echo '</div>';
    page_footer();
    die;
}
Beispiel #8
0
function server_display_role_preparation_aps($server)
{
    $ret = array();
    $server_online = $server->isOnline();
    if ($server_online) {
        $buf = $server->updateApplications();
        if (!$buf) {
            popup_error(_('Cannot list available applications'));
        }
    }
    $applicationDB = ApplicationDB::getInstance();
    $applications_all = $applicationDB->getList(true);
    $applications = $server->getApplications();
    if (!is_array($applications)) {
        $applications = array();
    }
    usort($applications, 'application_cmp');
    $applications_available = array();
    $static_applications_available = array();
    if (!$server_online && count($applications) == 0) {
        $applications_all = array();
    }
    $servers_all = Abstract_Server::load_by_status(Server::SERVER_STATUS_ONLINE);
    foreach ($servers_all as $k => $v) {
        if ($v->fqdn == $server->fqdn) {
            unset($servers_all[$k]);
        }
    }
    $servers_replication = Abstract_Server::load_by_status(Server::SERVER_STATUS_ONLINE);
    foreach ($servers_replication as $k => $v) {
        if ($v->fqdn == $server->fqdn) {
            unset($servers_replication[$k]);
        }
        if ($v->type != $server->getAttribute('type')) {
            unset($servers_replication[$k]);
        }
        if (!array_key_exists('aps', $v->roles) || $v->roles['aps'] !== true) {
            unset($servers_replication[$k]);
        }
        if ($server->hasAttribute('ulteo_system') == false || $server->getAttribute('ulteo_system') == 0) {
            unset($servers_replication[$k]);
        }
    }
    $sessions = array();
    $total = Abstract_Session::countByServer($_GET['fqdn']);
    if ($total > 0) {
        $has_sessions = true;
        $prefs = Preferences::getInstance();
        if (!$prefs) {
            die_error('get Preferences failed', __FILE__, __LINE__);
        }
        if ($total > $prefs->get('general', 'max_items_per_page')) {
            if (!isset($_GET['start']) || (!is_numeric($_GET['start']) || $_GET['start'] >= $total)) {
                $start = 0;
            } else {
                $start = $_GET['start'];
            }
            $pagechanger = get_pagechanger('servers.php?action=manage&fqdn=' . $_GET['fqdn'] . '&', $prefs->get('general', 'max_items_per_page'), $total);
            $sessions = Abstract_Session::getByServer($_GET['fqdn'], $prefs->get('general', 'max_items_per_page'), $start);
        } else {
            $sessions = Abstract_Session::getByServer($_GET['fqdn']);
        }
    } else {
        $has_sessions = false;
    }
    $external_name_checklist = array('localhost', '127.0.0.1');
    if (in_array($server->fqdn, $external_name_checklist) && in_array($server->getAttribute('external_name'), $external_name_checklist)) {
        popup_error(sprintf(_('Server "%s": redirection name may be invalid!'), $server->fqdn));
    }
    if ($server->getAttribute('external_name') == '') {
        popup_error(sprintf(_('Server "%s": redirection name cannot be empty!'), $server->fqdn));
    }
    if ($server_online) {
        //FIX ME ?
        $tm = new Tasks_Manager();
        $tm->load_from_server($server->fqdn);
        $tm->refresh_all();
        $apps_in_remove = array();
        $apps_in_install = array();
        $tasks = array();
        if ($server_online) {
            foreach ($tm->tasks as $task) {
                if (!$task->succeed()) {
                    $tasks[] = $task;
                }
            }
            foreach ($tasks as $task) {
                if (get_class($task) == 'Task_install') {
                    foreach ($task->applications as $app) {
                        if (!in_array($app, $apps_in_install)) {
                            $apps_in_install[] = $app;
                        }
                    }
                }
                if (get_class($task) == 'Task_remove') {
                    foreach ($task->applications as $app) {
                        if (!in_array($app, $apps_in_remove)) {
                            $apps_in_remove[] = $app;
                        }
                    }
                }
            }
            foreach ($applications_all as $app) {
                if (in_array($app, $applications)) {
                    continue;
                }
                if (in_array($app, $apps_in_install)) {
                    continue;
                }
                if ($app->getAttribute('type') != $server->getAttribute('type')) {
                    continue;
                }
                $applications_available[] = $app;
            }
        }
        $ret['tasks'] = $tasks;
        $ret['apps_in_install'] = $apps_in_install;
        $ret['apps_in_remove'] = $apps_in_remove;
    }
    $ret['can_do_action'] = isAuthorized('manageServers');
    $ret['web_port'] = $server->getAttribute('web_port');
    $ret['can_use_apt'] = isset($server->ulteo_system) && $server->ulteo_system == 1 ? true : false;
    $ret['server_online'] = $server_online;
    $ret['sessions'] = $sessions;
    $ret['has_sessions'] = $has_sessions;
    $ret['total_sessions'] = $total;
    if (isset($pagechanger)) {
        $ret['pagechanger'] = $pagechanger;
    }
    $ret['applications'] = $applications;
    $ret['applications_available'] = $applications_available;
    $ret['applications_all'] = $applications_all;
    $ret['servers_all'] = $servers_all;
    $ret['servers_replication'] = $servers_replication;
    return $ret;
}