plugin interaction files

--HG--
branch : Gsoc14-ryzomAppImprovements
hg/feature/cdb-packed
shubham_meena 11 years ago
parent 2f023e0bdc
commit c558b92bf5

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

@ -1,23 +1,18 @@
<?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");
$plugin=new plugin();
$plugin->init();
print_r(plugin::$plugins);**/
$pagination = new Pagination( "SELECT * FROM plugins", "lib", 5, "Plugincache" ); $pagination = new Pagination( "SELECT * FROM plugins", "lib", 5, "Plugincache" );
$pageResult['plug']= Gui_Elements::make_table($pagination->getElements() , Array ("getId","getPluginName","getPluginVersion","getPluginPermission","getIsActive"), Array("id","plugin_name","plugin_version","plugin_permission","plugin_isactive")); $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['links'] = $pagination -> getLinks( 5 );
$pageResult['lastPage'] = $pagination -> getLast(); $pageResult['lastPage'] = $pagination -> getLast();
$pageResult['currentPage'] = $pagination -> getCurrent(); $pageResult['currentPage'] = $pagination -> getCurrent();
@ -29,7 +24,8 @@ function plugins()
try { try {
$dbs = new DBLayer( "shard" ); $dbs = new DBLayer( "shard" );
$pageResult['shard'] = "online"; $pageResult['shard'] = "online";
}catch(PDOException $e){ }
catch( PDOException $e ) {
$pageResult['shard'] = "offline"; $pageResult['shard'] = "offline";
} }
return( $pageResult ); return( $pageResult );
@ -41,5 +37,3 @@ function plugins()
} }
} }

Loading…
Cancel
Save