khanat-opennel-code/code/web/public_php/ams/func/activate_plugin.php

45 lines
1.5 KiB
PHP
Raw Normal View History

2014-08-18 23:57:20 +00:00
<?php
/**
* This function is used in activating plugins.
* 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
* activate which here means '1' .
2014-09-03 18:27:01 +00:00
*
* @author Shubham Meena, mentored by Matthew Lagoe
2014-08-18 23:57:20 +00:00
*/
function activate_plugin() {
2014-09-03 18:27:01 +00:00
2014-08-18 23:57:20 +00:00
// if logged in
if ( WebUsers :: isLoggedIn() ) {
2014-09-03 18:27:01 +00:00
2014-08-18 23:57:20 +00:00
if ( isset( $_GET['id'] ) )
{
// id of plugin to activate
$id = filter_var( $_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$db = new DBLayer( 'lib' );
$result = $db -> update( "plugins", array( 'Status' => '1' ), "Id = $id" );
if ( $result )
{
// if result is successfull it redirects and shows success message
2014-09-03 18:27:01 +00:00
header("Cache-Control: max-age=1");
2014-08-18 23:57:20 +00:00
header( "Location: index.php?page=plugins&result=3" );
2014-09-03 18:27:01 +00:00
throw new SystemExit();
}
2014-08-18 23:57:20 +00:00
else
{
2014-09-03 18:27:01 +00:00
//if result is unsuccessfull it redirects and throws error
header("Cache-Control: max-age=1");
2014-08-18 23:57:20 +00:00
header( "Location: index.php?page=plugins&result=4" );
2014-09-03 18:27:01 +00:00
throw new SystemExit();
}
}
2014-08-18 23:57:20 +00:00
else
{
//if $_GET variable is not set it redirects and shows error
2014-09-03 18:27:01 +00:00
header("Cache-Control: max-age=1");
2014-08-18 23:57:20 +00:00
header( "Location: index.php?page=plugins&result=4" );
2014-09-03 18:27:01 +00:00
throw new SystemExit();
}
}
2014-08-18 23:57:20 +00:00
}