function action() { $msg = ''; $event = new event(); $server = new openqrm_server(); $plugin = new plugin(); $identifier = $this->response->html->request()->get($this->identifier_name); $available = $plugin->available(); if ($identifier !== '') { foreach ($identifier as $id) { if (in_array($id, $available)) { $error = false; // check dependencies $tmp = $plugin->get_dependencies($id); if ($tmp !== '' && isset($tmp['dependencies']) && $tmp['dependencies'] !== '') { $tmp = str_replace(' ', '', $tmp['dependencies']); $tmp = explode(',', $tmp); $enabled = $plugin->enabled(); $result = array_diff($tmp, $enabled); if (count($result) > 0) { $msg .= sprintf($this->lang['error_dependencies'], $id, implode(', ', $result)) . '<br>'; $error = true; } } // handle plugin type if ($error === false) { $tmp = $plugin->get_config($id); switch ($tmp['type']) { case 'storage': $storage = new storage(); $types = $storage->get_storage_types(); $deployment = new deployment(); $dep = $deployment->get_id_by_storagetype($id); foreach ($dep as $val) { if (in_array($val['value'], $types)) { $msg .= sprintf($this->lang['error_enabled'], $id) . '<br>'; $error = true; } } break; } } if ($error === false) { $return = $server->send_command("openqrm_server_plugin_command " . $id . " init " . $GLOBALS['OPENQRM_ADMIN']->name . ' ' . $GLOBALS['OPENQRM_ADMIN']->password); if ($return === true) { if ($this->__check($id)) { $msg .= sprintf($this->lang['msg'], $id) . '<br>'; } else { $msg .= sprintf($this->lang['error_timeout'], $id) . '<br>'; } } else { $msg .= sprintf($this->lang['error_enable'], $id) . '<br>'; } } } } } $this->response->redirect($this->response->get_url($this->actions_name, 'select', $this->message_param, $msg)); }
function __plugins() { /* $ha = array(); $net = array(); $mgmt = array(); $moni = array(); $misc = array(); $dep = array(); $enter = array(); */ $return = $this->response->html->div(); $plugin = new plugin(); $plugins = $plugin->available(); foreach ($plugins as $k => $v) { $p = $plugin->get_config($v); $link = ''; $hook = $this->openqrm->get('webdir') . "/plugins/" . $v . "/openqrm-" . $v . "-appliance-edit-hook.php"; if ($this->file->exists($hook)) { require_once $hook; $function = str_replace("-", "_", 'get_' . $v . '_appliance_edit'); if (function_exists($function)) { $id = $this->apliance_id; $link = $function($id, $this->openqrm, $this->response); if (is_object($link)) { $link->label = ucfirst($v); $link->handler = 'onclick="wait();"'; $link->css = "edit"; $link->title = preg_replace('~(.*?)<a.*>(.*?)</a>(.*?)~i', '$1$2$3', $p['description']); } } } if (isset($link) && $link !== '') { $return->add($link); } } return $return; /* if(isset($link) && $link !== '') { switch($p['type']) { case 'HA': $ha[] = $link; break; case 'monitoring': $moni[] = $link; break; case 'management': $mgmt[] = $link; break; case 'misc': $misc[] = $link; break; case 'network': $net[] = $link; break; case 'deployment': $dep[] = $link; break; case 'enterprise': $enter[] = $link; break; } } } if(count($ha) < 1) { $ha[] = $this->lang['no_plugin_available']; } if(count($net) < 1) { $net[] = $this->lang['no_plugin_available']; } if(count($mgmt) < 1) { $mgmt[] = $this->lang['no_plugin_available']; } if(count($moni) < 1) { $moni[] = $this->lang['no_plugin_available']; } if(count($misc) < 1) { $misc[] = $this->lang['no_plugin_available']; } if(count($dep) < 1) { $dep[] = $this->lang['no_plugin_available']; } if(count($enter) < 1) { $enter[] = $this->lang['no_plugin_available']; } return array( 'plugin_ha' => $ha, 'plugin_net' => $net, 'plugin_mgmt' => $mgmt, 'plugin_moni' => $moni, 'plugin_dep' => $dep, 'plugin_misc' => $misc, 'plugin_enter' => $enter ); */ }
function __get_navi($template, $mode) { $response = $this->response; if ($this->response->html->request()->get('plugin_name') !== '') { $plugin = new plugin(); $plugins = $plugin->available(); $key = array_keys($plugins, $this->response->html->request()->get('plugin_name')); $key = $key[0]; $param = 'plugin_name'; } if ($this->response->html->request()->get('base_name') !== '') { $plugins = array('aa_server', 'appliance', 'event', 'image', 'kernel', 'plugins', 'resource', 'storage'); $key = array_keys($plugins, $this->response->html->request()->get('base_name')); $key = $key[0]; $param = 'base_name'; } $prev = ' '; $next = ' '; if ($key === 0) { $next = $response->html->a(); $next->label = $plugins[1] . ' >>'; $next->href = $this->response->get_url($this->actions_name, $mode) . '&' . $param . '=' . $plugins[1]; $next->handler = 'onclick="wait();"'; } else { if ($key !== 0 && $key < count($plugins) - 1) { $prev = $response->html->a(); $prev->label = '<< ' . $plugins[$key - 1]; $prev->href = $this->response->get_url($this->actions_name, $mode) . '&' . $param . '=' . $plugins[$key - 1]; $prev->handler = 'onclick="wait();"'; $next = $response->html->a(); $next->label = $plugins[$key + 1] . ' >>'; $next->href = $this->response->get_url($this->actions_name, $mode) . '&' . $param . '=' . $plugins[$key + 1]; $next->handler = 'onclick="wait();"'; } else { if ($key === count($plugins) - 1) { $prev = $response->html->a(); $prev->label = '<< ' . $plugins[$key - 1]; $prev->href = $this->response->get_url($this->actions_name, $mode) . '&' . $param . '=' . $plugins[$key - 1]; $prev->style = "text-decoration: none;"; $prev->handler = 'onclick="wait();"'; } } } $switch = ''; if ($mode !== 'docblock') { $a = $response->html->a(); $a->label = 'docblock'; $a->href = $this->response->get_url($this->actions_name, 'docblock'); $a->handler = 'onclick="wait();"'; $switch .= $a->get_string(); } if ($mode !== 'lang') { $a = $response->html->a(); $a->label = 'lang'; $a->href = $this->response->get_url($this->actions_name, 'lang'); $a->handler = 'onclick="wait();"'; $switch .= $a->get_string(); } if ($mode !== 'rest') { $a = $response->html->a(); $a->label = 'rest'; $a->href = $this->response->get_url($this->actions_name, 'rest'); $a->handler = 'onclick="wait();"'; $switch .= $a->get_string(); } if ($mode !== 'api') { $a = $response->html->a(); $a->label = 'api'; $a->href = $this->response->get_url($this->actions_name, 'api'); $a->handler = 'onclick="wait();"'; $switch .= $a->get_string(); } if ($mode !== 'template') { $a = $response->html->a(); $a->label = 'templates'; $a->href = $this->response->get_url($this->actions_name, 'template'); $a->handler = 'onclick="wait();"'; $switch .= $a->get_string(); } if ($mode !== 'hooks') { $a = $response->html->a(); $a->label = 'hooks'; $a->href = $this->response->get_url($this->actions_name, 'hooks'); $a->handler = 'onclick="wait();"'; $switch .= $a->get_string(); } if ($mode !== 'js') { $a = $response->html->a(); $a->label = 'js'; $a->href = $this->response->get_url($this->actions_name, 'js'); $a->handler = 'onclick="wait();"'; $switch .= $a->get_string(); } if ($mode !== 'css') { $a = $response->html->a(); $a->label = 'css'; $a->href = $this->response->get_url($this->actions_name, 'css'); $a->handler = 'onclick="wait();"'; $switch .= $a->get_string(); } $template->add($switch, 'switch'); $template->add($prev, 'previous'); $template->add($next, 'next'); return $template; }
function select() { $icon_started = $this->lang['action_stop']; $icon_stopped = $this->lang['action_start']; $icon_enabled = $this->lang['action_disable']; $icon_disabled = $this->lang['action_enable']; $plugin = new plugin(); $plugins_available = $plugin->available(); $plugins_enabled = $plugin->enabled(); $plugins_started = $plugin->started(); $h = array(); $h['name']['title'] = $this->lang['table_name']; $h['type']['title'] = ' '; $h['type']['sortable'] = ' '; $h['type_n']['title'] = $this->lang['table_type']; $h['type_n']['hidden'] = true; $h['description']['title'] = $this->lang['table_description']; $h['description']['sortable'] = false; $h['configure']['title'] = " "; $h['configure']['sortable'] = false; $h['enabled']['title'] = " "; $h['enabled']['sortable'] = false; $h['enabled_n']['title'] = $this->lang['table_enabled']; $h['enabled_n']['hidden'] = true; $h['started']['title'] = " "; $h['started']['sortable'] = false; $h['started_n']['title'] = $this->lang['table_started']; $h['started_n']['hidden'] = true; $table = $this->response->html->tablebuilder('plugins', $this->response->get_array($this->actions_name, 'select')); $table->max = count($plugins_available); $table->sort = 'name'; $table->limit = 0; $table->order = 'ASC'; $table->init(); $tps = $table->get_params(); $tp = ''; foreach ($tps['plugins'] as $k => $v) { $tp .= '&plugins[' . $k . ']=' . $v; } $RootDir = $_SERVER["DOCUMENT_ROOT"] . '/openqrm/base/'; $thisfile = $this->response->html->thisfile; $b = array(); $plugtype = array(); $i = 0; $openqrm_version = $this->openqrm->get('config', 'SERVER_VERSION'); foreach ($plugins_available as $index => $plugin_name) { $tmp = $plugin->get_config($plugin_name); $plugin_description = $tmp['description']; $plugin_type = $tmp['type']; $plugtype[] = $plugin_type; $plugin_version = $tmp['version']; $plugin_major = substr($plugin_version, 0, strpos($plugin_version, '.')); $plugin_minor = substr($plugin_version, strpos($plugin_version, '.') + 1); $plugin_minor = substr($plugin_minor, 0, strpos($plugin_minor, '.')); $plugin_base_version = $plugin_major . "." . $plugin_minor; if (!strlen($this->response->html->request()->get('plugin_filter')) || strstr($this->response->html->request()->get('plugin_filter'), $plugin_type)) { // $b[$i] = array(); // plugin version mismatch if ($openqrm_version != $plugin_base_version) { $b[$i]['name'] = $plugin_name; $b[$i]['type'] = '<span class="pill ' . strtolower($plugin_type) . '">' . $plugin_type . '</span>'; $b[$i]['type_n'] = $plugin_type; $b[$i]['description'] = $plugin_description; $b[$i]['enabled'] = $this->lang['version_mismatch']; $b[$i]['enabled_n'] = 'b'; $b[$i]['started'] = ' '; $b[$i]['started_n'] = 'c'; $b[$i]['configure'] = ''; } else { // plugin not enabled! if (!in_array($plugin_name, $plugins_enabled)) { $a = $this->response->html->a(); $a->label = $icon_disabled; $a->href = $this->response->get_url($this->actions_name, "enable"); $a->href .= '&' . $this->identifier_name . '[]=' . $plugin_name; $a->href .= '&plugin_filter=' . $this->response->html->request()->get('plugin_filter'); $a->href .= $tp; $a->href .= '#' . $plugin_name; // anchor $a->name = $plugin_name; $a->handler = 'onclick="wait();"'; $a->css = 'enable'; $a->title = sprintf($this->lang['title_enable'], $plugin_name); $b[$i]['name'] = $plugin_name; $b[$i]['type'] = '<span class="pill ' . strtolower($plugin_type) . '">' . $plugin_type . '</span>'; $b[$i]['type_n'] = $plugin_type; $b[$i]['description'] = $plugin_description; $b[$i]['enabled'] = $a->get_string(); $b[$i]['enabled_n'] = 'b'; $b[$i]['started'] = ' '; $b[$i]['started_n'] = 'c'; } else { $plugin_icon_path = "{$RootDir}/plugins/{$plugin_name}/img/plugin.png"; $plugin_icon = "/openqrm/base/plugins/{$plugin_name}/img/plugin.png"; $plugin_icon_default = "/openqrm/base/plugins/aa_plugins/img/plugin.png"; if ($this->file->exists($plugin_icon_path)) { $plugin_icon_default = $plugin_icon; } $a = $this->response->html->a(); $a->label = $icon_enabled; $a->href = $this->response->get_url($this->actions_name, "disable"); $a->href .= '&' . $this->identifier_name . '[]=' . $plugin_name; $a->href .= '&plugin_filter=' . $this->response->html->request()->get('plugin_filter'); $a->href .= $tp; $a->href .= '#' . $plugin_name; // anchor $a->name = $plugin_name; $a->handler = 'onclick="wait();"'; $a->css = !in_array($plugin_name, $plugins_started) ? 'disable' : 'disable disabled'; $a->title = sprintf($this->lang['title_disable'], $plugin_name); $b[$i]['name'] = $plugin_name; $b[$i]['type'] = '<span class="pill ' . strtolower($plugin_type) . '">' . $plugin_type . '</span>'; $b[$i]['type_n'] = $plugin_type; $b[$i]['description'] = $plugin_description; $b[$i]['enabled'] = $a->get_string(); $b[$i]['enabled_n'] = 'a'; // started ? if (!in_array($plugin_name, $plugins_started)) { $a = $this->response->html->a(); $a->label = $icon_stopped; $a->href = $this->response->get_url($this->actions_name, "start"); $a->href .= '&' . $this->identifier_name . '[]=' . $plugin_name; $a->href .= '&plugin_filter=' . $this->response->html->request()->get('plugin_filter'); $a->href .= $tp; $a->href .= '#' . $plugin_name; $a->handler = 'onclick="wait();"'; $a->css = 'start'; $a->title = sprintf($this->lang['title_start'], $plugin_name); $b[$i]['started'] = $a->get_string(); $b[$i]['started_n'] = 'b'; } else { $a = $this->response->html->a(); $a->label = $icon_started; $a->href = $this->response->get_url($this->actions_name, "stop"); $a->href .= '&' . $this->identifier_name . '[]=' . $plugin_name; $a->href .= '&plugin_filter=' . $this->response->html->request()->get('plugin_filter'); $a->href .= $tp; $a->href .= '#' . $plugin_name; $a->handler = 'onclick="wait();"'; $a->css = 'stop'; $a->title = sprintf($this->lang['title_stop'], $plugin_name); $b[$i]['started'] = $a->get_string(); $b[$i]['started_n'] = 'a'; } } // configure button $b[$i]['configure'] = ''; if (isset($tmp['configurable'])) { $a = $this->response->html->a(); $a->label = $this->lang['action_configure']; $a->href = $this->response->get_url($this->actions_name, "configure"); $a->href .= '&' . $this->identifier_name . '=' . $plugin_name; $a->href .= '&plugin_filter=' . $this->response->html->request()->get('plugin_filter'); $a->href .= $tp; $a->handler = 'onclick="wait();"'; $a->css = 'manage'; $a->title = sprintf($this->lang['title_configure'], $plugin_name); $b[$i]['configure'] = $a->get_string(); } } $i++; } } $plugs = array(); $plugs[] = array('', ''); $plugtype = array_unique($plugtype); natcasesort($plugtype); foreach ($plugtype as $p) { $plugs[] = array($p, ucfirst($p)); } $select = $this->response->html->select(); $select->add($plugs, array(0, 1)); $select->name = 'plugin_filter'; $select->handler = 'onchange="wait();this.form.submit();return false;"'; $select->selected = array($this->response->html->request()->get('plugin_filter')); $box = $this->response->html->box(); $box->add($select); $box->id = 'plugins_filter'; $box->css = 'htmlobject_box'; $box->label = $this->lang['lang_filter']; $table->id = 'Tabelle'; $table->tr_handler = array(); $table->css = 'htmlobject_table'; $table->border = 1; $table->cellspacing = 0; $table->cellpadding = 3; $table->autosort = true; $table->sort_link = false; $table->add_headrow($box->get_string()); $table->head = $h; $table->body = $b; $table->max = count($b); $table->form_action = $this->response->html->thisfile; /* $table->actions_name = $this->actions_name; $table->actions = array( array('enable' => $this->lang['action_enable']), array('disable' => $this->lang['action_disable']), array('start' => $this->lang['action_start']), array('stop' => $this->lang['action_stop']) ); $table->identifier = 'name'; $table->identifier_name = $this->identifier_name; */ return $table; }
function select() { $response = $this->response; $h['plugin']['title'] = $this->lang['id']; $h['plugin']['sortable'] = true; $h['docblock']['title'] = ' '; $h['docblock']['sortable'] = false; $h['lang']['title'] = ' '; $h['lang']['sortable'] = false; $h['edit']['title'] = ' '; $h['edit']['sortable'] = false; $h['api']['title'] = ' '; $h['api']['sortable'] = false; $h['hooks']['title'] = ' '; $h['hooks']['sortable'] = false; $h['template']['title'] = ' '; $h['template']['sortable'] = false; $h['css']['title'] = ' '; $h['css']['sortable'] = false; $h['js']['title'] = ' '; $h['js']['sortable'] = false; // plugins $plugin = new plugin(); $result = $plugin->available(); $b = array(); if (is_array($result)) { foreach ($result as $v) { $tmp['plugin'] = $v; $tmp['docblock'] = ' '; $tmp['edit'] = ' '; $tmp['api'] = ' '; $tmp['lang'] = ' '; $tmp['template'] = ' '; $tmp['hooks'] = ' '; $path = $this->openqrm->get('basedir') . '/plugins/' . $v . '/web/class/'; $files = $this->file->get_files($path); $oop = false; foreach ($files as $file) { if (strripos($file['name'], 'controller') !== false && strripos($file['name'], 'about') === false) { $oop = true; break; } } if ($oop === true) { $a = $response->html->a(); $a->href = $response->get_url($this->actions_name, 'docblock') . '&plugin_name=' . $v; $a->label = $this->lang['action_docblock']; $a->title = $this->lang['action_docblock']; $a->handler = 'onclick="wait();"'; $tmp['docblock'] = $a->get_string(); $a = $response->html->a(); $a->href = $response->get_url($this->actions_name, 'lang') . '&plugin_name=' . $v; $a->label = $this->lang['action_lang']; $a->title = $this->lang['action_lang']; $a->handler = 'onclick="wait();"'; $tmp['lang'] = $a->get_string(); $a = $response->html->a(); $a->href = $response->get_url($this->actions_name, 'rest') . '&plugin_name=' . $v; $a->label = $this->lang['action_rest']; $a->title = $this->lang['action_rest']; $a->handler = 'onclick="wait();"'; $tmp['edit'] = $a->get_string(); $a = $response->html->a(); $a->href = $response->get_url($this->actions_name, 'api') . '&plugin_name=' . $v; $a->label = $this->lang['action_api']; $a->title = $this->lang['action_api']; $a->handler = 'onclick="wait();"'; $tmp['api'] = $a->get_string(); $a = $response->html->a(); $a->href = $response->get_url($this->actions_name, 'template') . '&plugin_name=' . $v; $a->label = $this->lang['action_template']; $a->title = $this->lang['action_template']; $a->handler = 'onclick="wait();"'; $tmp['template'] = $a->get_string(); $a = $response->html->a(); $a->href = $response->get_url($this->actions_name, 'hooks') . '&plugin_name=' . $v; $a->label = $this->lang['action_hooks']; $a->title = $this->lang['action_hooks']; $a->handler = 'onclick="wait();"'; $tmp['hooks'] = $a->get_string(); $a = $response->html->a(); $a->href = $response->get_url($this->actions_name, 'js') . '&plugin_name=' . $v; $a->label = $this->lang['action_js']; $a->title = $this->lang['action_js']; $a->handler = 'onclick="wait();"'; $tmp['js'] = $a->get_string(); $a = $response->html->a(); $a->href = $response->get_url($this->actions_name, 'css') . '&plugin_name=' . $v; $a->label = $this->lang['action_css']; $a->title = $this->lang['action_css']; $a->handler = 'onclick="wait();"'; $tmp['css'] = $a->get_string(); } $b[] = $tmp; } } $table = $this->response->html->tablebuilder('plugins', $this->response->get_array($this->actions_name, 'select')); $table->offset = 0; $table->sort = 'plugin'; $table->limit = 0; $table->order = 'ASC'; $table->max = count($b); $table->css = 'htmlobject_table'; $table->border = 0; $table->id = 'Tabelle_1'; $table->form_action = $this->response->html->thisfile; $table->head = $h; $table->body = $b; $table->sort_params = $response->get_string($this->actions_name, 'select'); $table->sort_form = false; $table->sort_link = false; $table->autosort = true; $response->table_plugins = $table; // base $result = array('aa_server', 'appliance', 'event', 'image', 'kernel', 'resource', 'storage', 'plugins'); $b = array(); if (is_array($result)) { foreach ($result as $v) { $tmp['plugin'] = $v; $tmp['docblock'] = ' '; $tmp['edit'] = ' '; $tmp['api'] = ' '; $tmp['lang'] = ' '; $tmp['template'] = ' '; $tmp['hooks'] = ' '; if ($v !== 'plugins') { $path = $this->openqrm->get('basedir') . '/web/base/server/' . $v . '/class/'; } elseif ($v === 'plugins') { $path = $this->openqrm->get('basedir') . '/web/base/plugins/aa_plugins/class/'; } $files = $this->file->get_files($path); $oop = false; foreach ($files as $file) { if (strripos($file['name'], 'controller') !== false && strripos($file['name'], 'about') === false) { $oop = true; break; } } if ($oop === true) { $a = $response->html->a(); $a->href = $response->get_url($this->actions_name, 'docblock') . '&base_name=' . $v; $a->label = $this->lang['action_docblock']; $a->title = $this->lang['action_docblock']; $a->handler = 'onclick="wait();"'; $tmp['docblock'] = $a->get_string(); $a = $response->html->a(); $a->href = $response->get_url($this->actions_name, 'lang') . '&base_name=' . $v; $a->label = $this->lang['action_lang']; $a->title = $this->lang['action_lang']; $a->handler = 'onclick="wait();"'; $tmp['lang'] = $a->get_string(); $a = $response->html->a(); $a->href = $response->get_url($this->actions_name, 'rest') . '&base_name=' . $v; $a->label = $this->lang['action_rest']; $a->title = $this->lang['action_rest']; $a->handler = 'onclick="wait();"'; $tmp['edit'] = $a->get_string(); $a = $response->html->a(); $a->href = $response->get_url($this->actions_name, 'api') . '&base_name=' . $v; $a->label = $this->lang['action_api']; $a->title = $this->lang['action_api']; $a->handler = 'onclick="wait();"'; $tmp['api'] = $a->get_string(); $a = $response->html->a(); $a->href = $response->get_url($this->actions_name, 'template') . '&base_name=' . $v; $a->label = $this->lang['action_template']; $a->title = $this->lang['action_template']; $a->handler = 'onclick="wait();"'; $tmp['template'] = $a->get_string(); $a = $response->html->a(); $a->href = $response->get_url($this->actions_name, 'hooks') . '&base_name=' . $v; $a->label = $this->lang['action_hooks']; $a->title = $this->lang['action_hooks']; $a->handler = 'onclick="wait();"'; $tmp['hooks'] = $a->get_string(); $a = $response->html->a(); $a->href = $response->get_url($this->actions_name, 'js') . '&base_name=' . $v; $a->label = $this->lang['action_js']; $a->title = $this->lang['action_js']; $a->handler = 'onclick="wait();"'; $tmp['js'] = $a->get_string(); $a = $response->html->a(); $a->href = $response->get_url($this->actions_name, 'css') . '&base_name=' . $v; $a->label = $this->lang['action_css']; $a->title = $this->lang['action_css']; $a->handler = 'onclick="wait();"'; $tmp['css'] = $a->get_string(); } $b[] = $tmp; } } $table = $this->response->html->tablebuilder('base', $this->response->get_array($this->actions_name, 'select')); $table->offset = 0; $table->sort = 'plugin'; $table->limit = 0; $table->order = 'ASC'; $table->max = count($b); $table->css = 'htmlobject_table'; $table->border = 0; $table->id = 'Tabelle_2'; $table->form_action = $this->response->html->thisfile; $table->head = $h; $table->body = $b; $table->sort_params = $response->get_string($this->actions_name, 'select'); $table->sort_form = false; $table->sort_link = false; $table->autosort = true; $response->table_base = $table; return $response; }