2010-11-19 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_extensions.php: added functions
	"get_disabled_extensions" and "getExtensionInfo".

	* operation/extensions.php: erased the delete extension option.

	* images/dot_green.disabled.png, images/dot_red.disabled.png: added files
	for the table of features extension.
	
	* godmode/extensions.php: show a table of extension with features and
	action to disable and delete.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3606 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2010-11-19 12:08:18 +00:00
parent 569f86e096
commit d0834c18bc
6 changed files with 383 additions and 35 deletions

View File

@ -1,3 +1,16 @@
2010-11-19 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_extensions.php: added functions
"get_disabled_extensions" and "getExtensionInfo".
* operation/extensions.php: erased the delete extension option.
* images/dot_green.disabled.png, images/dot_red.disabled.png: added files
for the table of features extension.
* godmode/extensions.php: show a table of extension with features and
action to disable and delete.
2010-11-17 Miguel de Dios <miguel.dedios@artica.es>
* extensions/vnc_view.php: added first version of extension of to VNC view

View File

@ -13,7 +13,6 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
check_login ();
if (! give_acl ($config['id_user'], 0, "PM")) {
@ -31,37 +30,233 @@ if (sizeof ($config['extensions']) == 0) {
// Header
print_page_header (__('Extensions'). " &raquo; ". __('Defined extensions'), "images/extensions.png", false, "", true, "" );
$enterprise = (bool)get_parameter('enterprise', 0);
$delete = get_parameter ("delete", "");
$name = get_parameter ("name", "");
$enabled = get_parameter("enabled", "");
$disabled = get_parameter("disabled", "");
if ($delete != ""){
if (!file_exists($config["homedir"]."/extensions/ext_backup"))
mkdir($config["homedir"]."/extensions/ext_backup");
$source = $config["homedir"]."/$delete.php";
rename ($source, $config["homedir"]."/extensions/ext_backup/$name.php");
}
$table->width = '500px';
$table->head = array ();
$table->head[0] = __('Name');
$table->head[1] = __('Delete');
$table->align[1] = "center";
$table->data = array ();
foreach ($config['extensions'] as $extension) {
if ($extension['godmode_function'] == '')
continue;
if ($extension['godmode_menu'] == null)
continue;
if ($enterprise) {
if (!file_exists($config["homedir"]."/enterprise/extensions/ext_backup"))
{
mkdir($config["homedir"]."/enterprise/extensions/ext_backup");
}
}
else {
if (!file_exists($config["homedir"]."/extensions/ext_backup"))
{
mkdir($config["homedir"]."/extensions/ext_backup");
}
}
if ($enterprise) {
$source = $config["homedir"]."/enterprise/extensions/" . $delete;
$endFile = $config["homedir"]."/enterprise/extensions/ext_backup/" . $delete;
}
else {
$source = $config["homedir"]."/extensions/" . $delete;
$endFile = $config["homedir"]."/extensions/ext_backup/" . $delete;
}
$data = array ();
$data[0] = '<a href="index.php?sec=gextensions&sec2='.$extension['godmode_menu']['sec2'].'" class="mn">'.$extension['godmode_menu']['name'].'</a>';
$data[1] = '<a href="index.php?sec=gextensions&amp;sec2=godmode/extensions&delete='.$extension['godmode_menu']['sec2'].'&name='.$extension['godmode_menu']['name'].'" class="mn"><img src="images/cross.png"></a>';
array_push ($table->data, $data);
rename($source, $endFile);
?>
<script type="text/javascript">
$(document).ready(function() {
var href = location.href.replace(/&enterprise=(0|1)&delete=.*/g, "");
location = href;
}
);
</script>
<?php
}
if ($enabled != '') {
if ($enterprise) {
$endFile = $config["homedir"]."/enterprise/extensions/" . $enabled;
$source= $config["homedir"]."/enterprise/extensions/disabled/" . $enabled;
}
else {
$endFile = $config["homedir"]."/extensions/" . $enabled;
$source = $config["homedir"]."/extensions/disabled/" . $enabled;
}
rename($source, $endFile);
?>
<script type="text/javascript">
$(document).ready(function() {
var href = location.href.replace(/&enterprise=(0|1)&enabled=.*/g, "");
location = href;
}
);
</script>
<?php
}
if ($disabled != '') {
if ($enterprise) {
if (!file_exists($config["homedir"]."/enterprise/extensions/disabled"))
{
mkdir($config["homedir"]."/enterprise/extensions/disabled");
}
}
else {
if (!file_exists($config["homedir"]."/extensions/disabled"))
{
mkdir($config["homedir"]."/extensions/disabled");
}
}
if ($enterprise) {
$source = $config["homedir"]."/enterprise/extensions/" . $disabled;
$endFile = $config["homedir"]."/enterprise/extensions/disabled/" . $disabled;
}
else {
$source = $config["homedir"]."/extensions/" . $disabled;
$endFile = $config["homedir"]."/extensions/disabled/" . $disabled;
}
rename($source, $endFile);
?>
<script type="text/javascript">
$(document).ready(function() {
var href = location.href
href = href.replace(/&enterprise=(0|1)&disabled=.*/g, "");
console.log(href);
location = href;
}
);
</script>
<?php
}
$extensions = getExtensionInfo();
$table->width = '95%';
$table->head = array();
$table->head[] = __('File');
$table->head[] = "<span title='" . __("Enterprise") . "'>" . __('E.') . "</span>";
$table->head[] = "<span title='" . __("Godmode Function") . "'>" . __('G.F.') . "</span>";
$table->head[] = "<span title='" . __("Godmode Menu") . "'>" . __('G.M.') . "</span>";
$table->head[] = "<span title='" . __("Operation Menu") . "'>" . __('O.M.') . "</span>";
$table->head[] = "<span title='" . __("Operation Function") . "'>" . __('O.F.') . "</span>";
$table->head[] = "<span title='" . __("Login Function") . "'>" . __('L.F.') . "</span>";
$table->head[] = "<span title='" . __("Agent operation tab") . "'>" . __('A.O.T.') . "</span>";
$table->head[] = "<span title='" . __("Agent godmode tab") . "'>" . __('A.G.T.') . "</span>";
$table->head[] = "<span title='" . __("Operation") . "'>" . __('O.') . "</span>";
$table->width = array();
$table->width[] = '30%';
$table->width[] = '22px';
$table->width[] = '44px';
$table->width[] = '44px';
$table->width[] = '44px';
$table->width[] = '44px';
$table->width[] = '66px';
$table->width[] = '66px';
$table->width[] = '44px';
$table->align = array();
$table->align[] = 'left';
$table->align[] = 'center';
$table->align[] = 'center';
$table->align[] = 'center';
$table->align[] = 'center';
$table->align[] = 'center';
$table->align[] = 'center';
$table->align[] = 'center';
$table->align[] = 'center';
$table->align[] = 'center';
$table->data = array();
foreach ($extensions as $file => $extension) {
$data = array();
$on = '<img src="images/dot_green.png" />';
$off = '<img src="images/dot_red.png" />';
if (!$extension['enabled']) {
$on = '<img src="images/dot_green.disabled.png" />';
$off = '<img src="images/dot_red.disabled.png" />';
$data[] = '<i style="color: grey;">' . $file . '</i>';
}
else {
$data[] = $file;
}
if ($extension['enterprise']) {
$data[] = $on;
}
else {
$data[] = $off;
}
if ($extension['godmode_function']) {
$data[] = $on;
}
else {
$data[] = $off;
}
if ($extension['godmode_menu']) {
$data[] = $on;
}
else {
$data[] = $off;
}
if ($extension['operation_menu']) {
$data[] = $on;
}
else {
$data[] = $off;
}
if ($extension['operation_function']) {
$data[] = $on;
}
else {
$data[] = $off;
}
if ($extension['login_function']) {
$data[] = $on;
}
else {
$data[] = $off;
}
if ($extension['extension_ope_tab']) {
$data[] = $on;
}
else {
$data[] = $off;
}
if ($extension['extension_god_tab']) {
$data[] = $on;
}
else {
$data[] = $off;
}
if (!$extension['enabled']) {
$data[] = '<a title="' . __('Delete') . '" href="index.php?sec=gextensions&amp;sec2=godmode/extensions&enterprise=' . (int)$extension['enterprise'] . '&delete='.$file.'" class="mn"><img src="images/cross.disabled.png"></a>' .
' <a title="' . __('Enable') . '" href="index.php?sec=gextensions&amp;sec2=godmode/extensions&enterprise=' . (int)$extension['enterprise'] . '&enabled='.$file.'" class="mn"><img src="images/lightbulb_off.png"></a>';
}
else {
$data[] = '<a title="' . __('Delete') . '" href="index.php?sec=gextensions&amp;sec2=godmode/extensions&enterprise=' . (int)$extension['enterprise'] . '&delete='.$file.'" class="mn"><img src="images/cross.png"></a>' .
' <a title="' . __('Disable') . '" href="index.php?sec=gextensions&amp;sec2=godmode/extensions&enterprise=' . (int)$extension['enterprise'] . '&disabled='.$file.'" class="mn"><img src="images/lightbulb.png"></a>';
}
$table->data[] = $data;
}
print_table ($table);
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

View File

@ -128,6 +128,146 @@ function get_extensions ($enterprise = false) {
return $extensions;
}
function get_disabled_extensions() {
global $config;
$extensions = array ();
$dirs = array('open' => EXTENSIONS_DIR . '/disabled', 'enterprise' => ENTERPRISE_DIR . '/' . EXTENSIONS_DIR . '/disabled');
foreach ($dirs as $type => $dir) {
$handle = false;
if (file_exists ($dir))
$handle = @opendir ($dir);
if (empty ($handle))
continue;
$ignores = array ('.', '..');
$file = readdir ($handle);
while ($file !== false) {
if (in_array ($file, $ignores)) {
$file = readdir ($handle);
continue;
}
$filepath = realpath ($dir."/".$file);
if (! is_readable ($filepath) || is_dir ($filepath) || ! preg_match ("/.*\.php$/", $filepath)) {
$file = readdir ($handle);
continue;
}
//$content = file_get_contents($filepath);
$content = '';
$data = array();
$data['operation_menu'] = false;
if (preg_match("/<?php(\n|.)*add_operation_menu_option(\n|.)*?>/", $content)) {
$data['operation_menu'] = true;
}
$data['godmode_menu'] = false;
if (preg_match('/<\?php(\n|.)*add_godmode_menu_option(\n|.)*\?>/', $content)) {
$data['godmode_menu'] = true;
}
$data['operation_function'] = false;
if (preg_match('/<\?php(\n|.)*add_extension_main_function(\n|.)*\?>/', $content)) {
$data['operation_function'] = true;
}
$data['login_function'] = false;
if (preg_match('/<\?php(\n|.)*add_extension_login_function(\n|.)*\?>/', $content)) {
$data['login_function'] = true;
}
$data['extension_ope_tab'] = false;
if (preg_match('/<\?php(\n|.)*add_extension_opemode_tab_agent(\n|.)*\?>/', $content)) {
$data['extension_ope_tab'] = true;
}
$data['extension_god_tab'] = false;
if (preg_match('/<\?php(\n|.)*add_extension_godmode_tab_agent(\n|.)*\?>/', $content)) {
$data['extension_god_tab'] = true;
}
$data['godmode_function'] = false;
if (preg_match('/<\?php(\n|.)*add_extension_godmode_function(\n|.)*\?>/', $content)) {
$data['godmode_function'] = true;
}
$data['enterprise'] = false;
if ($type == 'enterprise') {
$data['enterprise'] = true;
}
$data['enabled'] = false;
$extensions[$file] = $data;
$file = readdir ($handle);
}
}
return $extensions;
}
function getExtensionInfo() {
global $config;
$return = array ();
foreach($config['extensions'] as $extension) {
$data = array();
$data['godmode_function'] = false;
if (!empty($extension['godmode_function'])) {
$data['godmode_function'] = true;
}
$data['godmode_menu'] = false;
if (!empty($extension['godmode_menu'])) {
$data['godmode_menu'] = true;
}
$data['operation_function'] = false;
if (!empty($extension['main_function'])) {
$data['operation_function'] = true;
}
$data['operation_menu'] = false;
if (!empty($extension['operation_menu'])) {
$data['operation_menu'] = true;
}
$data['login_function'] = false;
if (!empty($extension['login_function'])) {
$data['login_function'] = true;
}
$data['extension_ope_tab'] = false;
if (!empty($extension['extension_ope_tab'])) {
$data['extension_ope_tab'] = true;
}
$data['extension_god_tab'] = false;
if (!empty($extension['extension_god_tab'])) {
$data['extension_god_tab'] = true;
}
$data['enterprise'] = (bool)$extension['enterprise'];
$data['enabled'] = true;
$return[$extension['file']] = $data;
}
$return = $return + get_disabled_extensions();
return $return;
}
/**
* TODO: Document extensions
*
@ -230,7 +370,7 @@ function add_extension_opemode_tab_agent($tabId, $tabName, $tabIcon, $tabFunctio
}
/**
* TODO: Document extensions
* Add the function to call in OPERATION
*
* @param string $function_name
*/

View File

@ -44,10 +44,10 @@ if ($delete != ""){
$table->width = '500px';
$table->head = array ();
$table->head[0] = __('Name');
if (give_acl ($config['id_user'], 0, "PM")){
$table->head[1] = __('Delete');
$table->align[1] = "center";
}
//if (give_acl ($config['id_user'], 0, "PM")){
// $table->head[1] = __('Delete');
// $table->align[1] = "center";
//}
$table->data = array ();
foreach ($config['extensions'] as $extension) {
@ -59,9 +59,9 @@ foreach ($config['extensions'] as $extension) {
$data = array ();
$data[0] = '<a href="index.php?sec=extensions&amp;sec2='.$extension['operation_menu']['sec2'].'" class="mn">'.$extension['operation_menu']['name'];
if (give_acl ($config['id_user'], 0, "PM")) {
$data[1] = '<a href="index.php?sec=extensions&amp;sec2=operation/extensions&delete='.$extension['operation_menu']['sec2'].'&name='.$extension['operation_menu']['name'].'" class="mn"><img src="images/cross.png"></a>';
}
// if (give_acl ($config['id_user'], 0, "PM")) {
// $data[1] = '<a href="index.php?sec=extensions&amp;sec2=operation/extensions&delete='.$extension['operation_menu']['sec2'].'&name='.$extension['operation_menu']['name'].'" class="mn"><img src="images/cross.png"></a>';
// }
array_push ($table->data, $data);
}