2014-06-15 04:15:00 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* This function is used in deactivating plugins.
|
2014-08-18 01:43:15 +00:00
|
|
|
* This can be done by providing id using $_GET global variable of the plugin which
|
|
|
|
* we want to activate. After getting id we update the respective plugin with status
|
|
|
|
* deactivate which here means '0'.
|
2014-09-03 05:06:43 +00:00
|
|
|
*
|
|
|
|
* @author Shubham Meena, mentored by Matthew Lagoe
|
2014-06-15 04:15:00 +00:00
|
|
|
*/
|
|
|
|
function deactivate_plugin() {
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2014-06-15 04:15:00 +00:00
|
|
|
// if logged in
|
|
|
|
if ( WebUsers :: isLoggedIn() ) {
|
2014-09-03 05:06:43 +00:00
|
|
|
|
|
|
|
|
2014-06-15 04:15:00 +00:00
|
|
|
if ( isset( $_GET['id'] ) )
|
|
|
|
{
|
2014-08-18 01:43:15 +00:00
|
|
|
// id of plugin to deactivate
|
2014-06-15 04:15:00 +00:00
|
|
|
$id = filter_var( $_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS );
|
|
|
|
$db = new DBLayer( 'lib' );
|
|
|
|
$result = $db -> update( "plugins", array( 'Status' => '0' ), "Id = $id" );
|
|
|
|
if ( $result )
|
2014-09-03 05:06:43 +00:00
|
|
|
{
|
|
|
|
// if result is successfull it redirects and shows success message
|
2014-06-15 04:15:00 +00:00
|
|
|
header( "Location: index.php?page=plugins&result=5" );
|
2014-09-03 05:06:43 +00:00
|
|
|
die();
|
|
|
|
}
|
2014-06-15 04:15:00 +00:00
|
|
|
else
|
|
|
|
{
|
2014-09-03 05:06:43 +00:00
|
|
|
// if result is unsuccessfull it redirects and shows success message
|
2014-06-15 04:15:00 +00:00
|
|
|
header( "Location: index.php?page=plugins&result=6" );
|
2014-09-03 05:06:43 +00:00
|
|
|
die();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2014-06-15 04:15:00 +00:00
|
|
|
else
|
|
|
|
{
|
2014-09-03 05:06:43 +00:00
|
|
|
//if $_GET variable is not set it redirects and shows error
|
2014-06-15 04:15:00 +00:00
|
|
|
header( "Location: index.php?page=plugins&result=6" );
|
2014-09-03 05:06:43 +00:00
|
|
|
die();
|
|
|
|
}
|
|
|
|
}
|
2014-06-15 04:15:00 +00:00
|
|
|
}
|