$app = $applicationDB->import($_REQUEST['id']); if (!is_object($app)) { die_error(sprintf(_("Unable to import application '%s'"), $_REQUEST['id']), __FILE__, __LINE__); } $attr_list = $app->getAttributesList(); foreach ($data as $k => $v) { if (in_array($k, $attr_list)) { $app->setAttribute($k, $v); } } $app->setAttribute('revision', $app->getAttribute('revision') + 1); $ret = $applicationDB->update($app); if (!$ret) { popup_error(sprintf(_("Failed to modify application '%s'"), $app->getAttribute('name'))); } $servers = Abstract_Server::load_available_by_type($app->getAttribute('type'), true); foreach ($servers as $server) { $server->syncStaticApplications(); } popup_info(sprintf(_("Application '%s' successfully modified"), $app->getAttribute('name'))); if (array_key_exists('file_icon', $_FILES)) { $upload = $_FILES['file_icon']; $have_file = true; if ($upload['error']) { switch ($upload['error']) { case 1: // UPLOAD_ERR_INI_SIZE popup_error(_('Oversized file for server rules')); redirect(); break; case 3:
public function application_static_modify($id_, $name_, $description_, $command_) { $this->check_authorized('manageApplications'); $applicationDB = ApplicationDB::getInstance(); if (!$applicationDB->isWriteable()) { Logger::error('api', 'ApplicationDB is not writable'); return false; } $app = $applicationDB->import($id_); if (!is_object($app)) { Logger::error('api', 'Unknown application "' . $id_ . '"'); return false; } $modify = false; $changes = array(); if ($name_ != null && $name_ != $app->getAttribute('name')) { $changes['name'] = array('old' => $app->getAttribute('name'), 'new' => $name_); $app->setAttribute('name', $name_); $modify = true; } if ($description_ != null && $description_ != $app->getAttribute('description')) { $changes['description'] = array('old' => $app->getAttribute('description'), 'new' => $description_); $app->setAttribute('description', $description_); $modify = true; } if ($command_ != null && $command_ != $app->getAttribute('executable_path')) { $changes['command'] = array('old' => $app->getAttribute('executable_path'), 'new' => $command_); $app->setAttribute('executable_path', $command_); $modify = true; } if (!$modify) { return true; } $app->setAttribute('revision', $app->getAttribute('revision') + 1); $ret = $applicationDB->update($app); if (!$ret) { Logger::error('api', 'Failed to modify application "' . $app->getAttribute('name') . '"'); return false; } $servers = Abstract_Server::load_available_by_type($app->getAttribute('type'), true); foreach ($servers as $server) { $server->syncStaticApplications(); } $this->log_action('application_static_modify', array_merge($changes, array('id' => $app->getAttribute('id'), 'name' => $app->getAttribute('name')))); return true; }