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; }
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; }