function to install update in the plugin

--HG--
branch : Gsoc14-ryzomAppImprovements
This commit is contained in:
shubham_meena 2014-06-23 14:36:29 +05:30
parent ae7503df36
commit e7e4b88747
3 changed files with 37 additions and 0 deletions

View file

@ -75,6 +75,7 @@ ac_error = "Plugin facing some error in activating. Please try again later."
dc_success = "Plugin de-Activated successfuly."
dc_error = "Plugin facing some error in de-activating. Please try again later."
up_success = "Update added successfully. Go to Updates page for installing updates."
up_install_success = "Update installed successfully."
[install_plugin]
ip_title = "Install a new Plugin"

View file

@ -0,0 +1,35 @@
<?php
/**
* This function is used in installing updates for plugins.
*
* @author Shubham Meena, mentored by Matthew Lagoe
*/
function update_plugin() {
// if logged in
if ( WebUsers :: isLoggedIn() ) {
if ( isset( $_GET['id'] ) )
{
// id of plugin to delete
$id = filter_var( $_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$db = new DBLayer( 'lib' );
$sth = $db -> executeWithoutParams( "SELECT * FROM plugins INNER JOIN updates ON plugins.Id=updates.PluginId Where plugins.Id=$id" );
$row = $sth -> fetch();
print_r( $row );
// replacing update in the database
Plugincache :: rrmdir( $row['FileName'] );
Plugincache :: zipExtraction( $row['UpdatePath'], rtrim( $row['FileName'], strtolower( $row['Name'] ) ) );
$db -> update( "plugins", array( 'Info' => $row['UpdateInfo'] ), "Id=$row[Id]" );
// deleting the previous update
$db -> delete( "updates", array( 'id' => $row['s.no'] ), "s.no=:id" );
header( "Location: index.php?page=plugins&result=8" );
exit;
}
}
}

View file

@ -17,6 +17,7 @@
{if isset($smarty.get.result) and $smarty.get.result eq "5"}<div class="alert alert-error"><p>{$dc_success}</p></div>{/if}
{if isset($smarty.get.result) and $smarty.get.result eq "6"}<div class="alert alert-error"><p>{$dc_error}</p></div>{/if}
{if isset($smarty.get.result) and $smarty.get.result eq "7"}<div class="alert alert-error"><p>{$up_success}</p></div>{/if}
{if isset($smarty.get.result) and $smarty.get.result eq "8"}<div class="alert alert-error"><p>{$up_install_success}</p></div>{/if}
<div class="box-content">
<center><p>{$plugin_info}</p></center>
<center>