diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/plugincache.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/plugincache.php index 1b0dc873d..bba6e3fb1 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/plugincache.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/plugincache.php @@ -2,7 +2,7 @@ /** * API for loading and interacting with plugins - * contains getters and setters + * contains getters and setters * * @author shubham meena mentored by Matthew Lagoe */ @@ -29,7 +29,7 @@ class Plugincache { $this -> setPluginType( $values['Type'] ); $this -> setPluginPermission( $values['Permission'] ); $this -> setPluginStatus( $values['Status'] ); - $this -> setPluginInfo( $values['Info'] ); + $this -> setPluginInfo( json_decode( $values['Info'] ) ); } /** @@ -122,13 +122,6 @@ class Plugincache { $this -> plugin_status = $d; } - /** - * get plugin name attribute of the object. - */ - public function getPluginName() { - return $this -> plugin_name; - } - /** * set plugin name attribute of the object. * @@ -147,4 +140,4 @@ class Plugincache { $this -> plugin_info = $p_n; } - } + } diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini index 0d1b9cfb6..0164abbee 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini @@ -56,12 +56,21 @@ action = "Action" [plugins] plugin_title = "Plugin List" plugin_info = "Here you can see the entire list of plugins . You can easily remove plugins ,activate them and add permissions" -plugins= "Plugins" -plugin_id = "ID" +plugins = "Plugins" plugin_name = "Name" -plugin_version= "Version" -plugin_permission= "Owner/Access Permission" -plugin_is_active= "On/Off" +plugin_version = "Version" +plugin_description = "Description" +plugin_type = "Type" +plugin_permission = "Access Permission" +plugin_status = "Status" +ip_success = "Plugin added succesfully." + +[install_plugin] +ip_title = "Install a new Plugin" +ip_message = "For example: name.zip from your local computer" +ip_support = "Upload the plugin archieve to install.
The following file extension is supported: zip." +ip_error = "Please select the format with zip extension" +ip_info_nfound = "Info file not found in the Plugin.Please recheck" [show_ticket] t_title = "Ticket" @@ -252,4 +261,4 @@ email_body_forgot_password_header = "A request to reset your account's password email_body_forgot_password_footer = " ---------- If you didn't make this request, please ignore this message." -;=========================================================================== \ No newline at end of file +;=========================================================================== diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/install_plugin.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/install_plugin.php new file mode 100644 index 000000000..64cb66a30 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/install_plugin.php @@ -0,0 +1,94 @@ + 0 ) && ( $_FILES["file"]["type"] == 'application/zip' ) ) + { + $fileName = $_FILES["file"]["name"]; //the files name takes from the HTML form + $fileTmpLoc = $_FILES["file"]["tmp_name"]; //file in the PHP tmp folder + $dir = trim( $_FILES["file"]["name"], ".zip" ); + $target_path = "../../ams_lib/plugins/$dir"; //path in which the zip extraction is to be done + $destination = "../../ams_lib/plugins/"; + + if ( move_uploaded_file( $fileTmpLoc, $destination . $fileName ) ) { + // zip object to handle zip archieves + $zip = new ZipArchive(); + $x = $zip -> open( $destination . $fileName ); + if ( $x === true ) { + $zip -> extractTo( $destination ); // change this to the correct site path + $zip -> close(); + + // removing the uploaded zip file + unlink( $destination . $fileName ); + + // check for the info file + if ( file_exists( $target_path . "/.info" ) ) + { + // read the details of the plugin through the info file + $file_handle = fopen( $target_path . "/.info", "r" ); + $result = array(); + while ( !feof( $file_handle ) ) { + + $line_of_text = fgets( $file_handle ); + $parts = array_map( 'trim', explode( '=', $line_of_text, 2 ) ); + @$result[$parts[0]] = $parts[1]; + + } + + fclose( $file_handle ); + + // sending all info to the database + $install_result = array(); + $install_result['FileName'] = $target_path; + $install_result['Name'] = $result['PluginName']; + $install_result['Type'] = $result['type']; + + if ( Ticket_User :: isMod( unserialize( $_SESSION['ticket_user'] ) ) ) + { + $install_result['Permission'] = 'admin'; + } + else + { + $install_result['Permission'] = 'user'; + } + + $install_result['Info'] = json_encode( $result ); + + // connection with the database + $dbr = new DBLayer( "lib" ); + $dbr -> insert( "plugins", $install_result ); + + header( "Location: index.php?page=plugins&result=1" ); + exit; + + } + else + { + rmdir( $target_path ); + header( "Location: index.php?page=install_plugin&result=2" ); + exit; + + } + + } + } + + header( "Location: index.php?page=plugins" ); + exit; + } + else + { + header( "Location: index.php?page=install_plugin&result=1" ); + exit; + } + } + } diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/index.php b/code/ryzom/tools/server/ryzom_ams/www/html/index.php index faf3488c6..f01eab3e4 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/index.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/index.php @@ -1,126 +1,130 @@ getPermission(); -}else{ - //default permission - $return['permission'] = 0; -} -//hide sidebar + topbar in case of login/register -if($page == 'login' || $page == 'register' || $page == 'logout' || $page == 'forgot_password' || $page == 'reset_password'){ - $return['no_visible_elements'] = 'TRUE'; -}else{ +// Set permission +if ( isset( $_SESSION['ticket_user'] ) ) { + $return['permission'] = unserialize( $_SESSION['ticket_user'] ) -> getPermission(); + } else { + // default permission + $return['permission'] = 0; + } + + +// hide sidebar + topbar in case of login/register +if ( $page == 'login' || $page == 'register' || $page == 'logout' || $page == 'forgot_password' || $page == 'reset_password' ) { + $return['no_visible_elements'] = 'TRUE'; + } else { + $return['no_visible_elements'] = 'FALSE'; + } + +// handle error page +if ( $page == 'error' ) { + $return['permission'] = 0; $return['no_visible_elements'] = 'FALSE'; -} + } -//handle error page -if($page == 'error'){ - $return['permission'] = 0; - $return['no_visible_elements'] = 'FALSE'; -} - -//load the template with the variables in the $return array +// load the template with the variables in the $return array helpers :: loadTemplate( $page , $return ); diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/installer/libsetup.php b/code/ryzom/tools/server/ryzom_ams/www/html/installer/libsetup.php index 43b262b74..a590e6d7d 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/installer/libsetup.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/installer/libsetup.php @@ -160,15 +160,15 @@ DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`plugins` ; CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`plugins` ( - `Id` INT(10) NOT NULL AUTO_INCREMENT, - `FileName VARCHAR(255) NOT NULL, + `Id` INT(10) NOT NULL AUTO_INCREMENT, + `FileName VARCHAR(255) NOT NULL, `Name` VARCHAR(11) NOT NULL, `Type` VARCHAR(12) NOT NULL, `Owner` VARCHAR(25) NOT NULL, `Permission` VARCHAR(5) NOT NULL, `Status` INT(11) NOT NULL DEFAULT 0, `Weight` INT(11) NOT NULL DEFAULT 0, - `Info` BLOB NULL DEFAULT NULL, + `Info` TEXT NULL DEFAULT NULL, PRIMARY KEY (`Id`) ) ENGINE = InnoDB; diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/install_plugin.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/install_plugin.tpl new file mode 100644 index 000000000..52fdb3820 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/install_plugin.tpl @@ -0,0 +1,34 @@ +{block name=content} + +
+
+
+

{$ip_title}

+
+ + + + +
+
+
+
+

{$ip_support}

+
+
+    +
+ {if isset($smarty.get.result) and $smarty.get.result eq "1"}

{$ip_error}

{/if} + {if isset($smarty.get.result) and $smarty.get.result eq "2"}

{$ip_info_nfound}

{/if} +
+
+ {$ip_message} +
+
+
+
+
+ + + +{/block} diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/plugins.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/plugins.tpl index 4d4703875..99f382c5c 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/plugins.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/plugins.tpl @@ -1,4 +1,3 @@ - {block name=content}
@@ -10,27 +9,35 @@
+ {if isset($smarty.get.result) and $smarty.get.result eq "1"}

{$ip_success}

{/if}

{$plugin_info}

- +
+ + + + +
- - - + + - + + + {foreach from=$plug item=element} - - + - - + + + + {/foreach} @@ -48,42 +55,6 @@ -
-
-

Actions

-
- - -
-
-
-
-
- - -
-
-
-
- -{/block} \ No newline at end of file +{/block} +
{$plugin_id}{$plugin_permission}{$plugin_name}{$plugin_status}{$plugin_name} {$plugin_version}{$plugin_is_active}{$plugin_description}{$plugin_type}{$plugin_permission}
{$element.id}{$element.plugin_permission} {$element.plugin_name}{$element.plugin_version}{$element.plugin_isactive}{$element.plugin_info->Version}{$element.plugin_info->Description}{$element.plugin_type}{$element.plugin_permission}