plugin interaction files

This commit is contained in:
shubham_meena 2014-06-11 11:52:57 +05:30
parent 6511b6192b
commit 10afd1a3e8
2 changed files with 151 additions and 269 deletions

View file

@ -1,262 +1,150 @@
<?php <?php
/** /**
* API for loading and interacting with plugins
* contains getters and setters
*
* @author shubham meena mentored by Matthew Lagoe
*/
* contains the getters and setters for plugins class Plugincache {
* this file is for demo purpose
**/
class Plugincache{
private $id; private $id;
private $plugin_name;
private $plugin_name; private $plugin_type;
private $plugin_permission;
private $plugin_version; private $plugin_status;
private $plugin_info = array();
private $plugin_permission;
private $plugin_isactive;
/** /**
* A constructor.
* Empty constructor
*/
* A constructor. public function __construct() {
}
* Empty constructor
*/
public function __construct() {
}
public function set($values) {
$this->setId($values['PluginId']);
$this->setPluginName($values['PluginName']);
$this->setPluginVersion($values['PluginVersion']);
$this->setPluginPermission($values['PluginPermission']);
$this->setIsActive($values['IsActive']);
}
public function set( $values ) {
$this -> setId( $values['Id'] );
$this -> setPluginName( $values['Name'] );
$this -> setPluginType( $values['Type'] );
$this -> setPluginPermission( $values['Permission'] );
$this -> setPluginStatus( $values['Status'] );
$this -> setPluginInfo( $values['Info'] );
}
/** /**
* loads the object's attributes.
* loads the object's attributes. */
public function load_With_SID() {
*/ $dbl = new DBLayer( "lib" );
$statement = $dbl -> executeWithoutParams( "SELECT * FROM plugins" );
public function load_With_SID( ) { $row = $statement -> fetch();
$this -> set( $row );
$dbl = new DBLayer("lib"); }
$statement = $dbl->executeWithoutParams("SELECT * FROM plugins");
$row = $statement->fetch();
$this->set($row);
}
/** /**
* get plugin id attribute of the object.
* updates the entry. *
* @return integer id
*/ */
public function getId() {
public function update(){ return $this -> Id;
}
$dbl = new DBLayer("lib");
$query = "UPDATE plugins SET PluginPermission= :t, PluginVersion = :q, IsActive = :d WHERE PluginName=:p_n";
$values = Array('p_n' => $this->getPluginName(), 't' => $this->getPluginPermission(), 'q' => $this->getPluginVersion(), 'd' => $this->getIsActive());
$statement = $dbl->execute($query, $values);
}
public function getId(){
return $this->Id;
}
/** /**
* get plugin permission attribute of the object.
* get plugin permission attribute of the object. */
public function getPluginPermission() {
*/ return $this -> plugin_permission;
}
public function getPluginPermission(){
return $this->plugin_permission;
}
/** /**
* get plugin Type attribute of the object.
* get plugin version attribute of the object. */
public function getPluginType() {
*/ return $this -> plugin_version;
}
public function getPluginVersion(){
return $this->plugin_version;
}
/** /**
* get plugin status attribute of the object.
* get plugin is active attribute of the object. */
public function getPluginStatus() {
*/ return $this -> plugin_status;
}
public function getIsActive(){
return $this->plugin_isactive;
}
/** /**
* get plugin name attribute of the object.
* get plugin name attribute of the object. */
public function getPluginName() {
*/ return $this -> plugin_name;
}
public function getPluginName(){
return $this->plugin_name;
}
/** /**
* get plugin info array attribute of the object.
* set plugin id attribute of the object. */
public function getPluginInfo() {
* @param $s integer id return $this -> plugin_info;
}
*/
public function setId($s){
$this->Id = $s;
}
/** /**
* set plugin id attribute of the object.
* set plugin permission attribute of the object. *
* @param $s integer id
* @param $t type of the query, set permission */
public function setId( $s ) {
*/ $this -> Id = $s;
}
public function setPluginPermission($t){
$this->plugin_permission = $t;
}
/** /**
* set plugin permission attribute of the object.
* set plugin version attribute of the object. *
* @param $t type of the query, set permission
* @param $q string to set plugin version */
public function setPluginPermission( $t ) {
*/ $this -> plugin_permission = $t;
}
public function setPluginVersion($q){
$this->plugin_version= $q;
}
/** /**
* set plugin version attribute of the object.
* set plugin is active attribute of the object. *
* @param $q string to set plugin version
* @param $d tinyint to set plugin is active or not . */
public function setPluginType( $q ) {
*/ $this -> plugin_version = $q;
}
public function setIsActive($d){
$this->plugin_isactive= $d;
}
/** /**
* set plugin status attribute of the object.
*
* @param $d status code type int
*/
public function setPluginStatus( $d ) {
$this -> plugin_status = $d;
}
* set plugin name attribute of the object. /**
* get plugin name attribute of the object.
*/
public function getPluginName() {
return $this -> plugin_name;
}
* @param $p_n string to set plugin name. /**
* set plugin name attribute of the object.
*
* @param $p_n string to set plugin name.
*/
public function setPluginName( $p_n ) {
$this -> plugin_name = $p_n;
}
*/ /**
* set plugin info attribute array of the object.
public function setPluginName($p_n){ *
* @param $p_n array
$this->plugin_name= $p_n; */
public function setPluginInfo( $p_n ) {
$this -> plugin_info = $p_n;
}
} }
}

View file

@ -1,45 +1,39 @@
<?php <?php
/** /**
* File with function plugins to get * function plugins to get
* plugins from the Database using pagination object * plugins from the Database using pagination object
* @author shubham meena mentored by Mathew Lagoe *
* @author shubham meena mentored by Matthew Lagoe
*/ */
function plugins() function plugins()
{ {
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){ if ( Ticket_User :: isMod( unserialize( $_SESSION['ticket_user'] ) ) ) {
/**require("../../ams_lib/plugins/plugin.handler.php"); $pagination = new Pagination( "SELECT * FROM plugins", "lib", 5, "Plugincache" );
$pageResult['plug'] = Gui_Elements :: make_table( $pagination -> getElements(), Array( "getId", "getPluginName", "getPluginType", "getPluginPermission", "getPluginStatus", "getPluginInfo" ), Array( "id", "plugin_name", "plugin_type", "plugin_permission", "plugin_status", "plugin_info" ) );
$pageResult['links'] = $pagination -> getLinks( 5 );
$pageResult['lastPage'] = $pagination -> getLast();
$pageResult['currentPage'] = $pagination -> getCurrent();
$plugin=new plugin(); global $INGAME_WEBPATH;
$plugin->init(); $pageResult['ingame_webpath'] = $INGAME_WEBPATH;
print_r(plugin::$plugins);**/
$pagination = new Pagination("SELECT * FROM plugins","lib",5,"Plugincache"); // check if shard is online
$pageResult['plug']= Gui_Elements::make_table($pagination->getElements() , Array ("getId","getPluginName","getPluginVersion","getPluginPermission","getIsActive"), Array("id","plugin_name","plugin_version","plugin_permission","plugin_isactive")); try {
$pageResult['links'] = $pagination->getLinks(5); $dbs = new DBLayer( "shard" );
$pageResult['lastPage'] = $pagination->getLast(); $pageResult['shard'] = "online";
$pageResult['currentPage'] = $pagination->getCurrent(); }
catch( PDOException $e ) {
global $INGAME_WEBPATH;
$pageResult['ingame_webpath'] = $INGAME_WEBPATH;
//check if shard is online
try{
$dbs = new DBLayer("shard");
$pageResult['shard'] = "online";
}catch(PDOException $e){
$pageResult['shard'] = "offline"; $pageResult['shard'] = "offline";
} }
return( $pageResult); return( $pageResult );
}else{ } else {
//ERROR: No access! // ERROR: No access!
$_SESSION['error_code'] = "403"; $_SESSION['error_code'] = "403";
header("Location: index.php?page=error"); header( "Location: index.php?page=error" );
exit; exit;
}
} }
}