template for plugins in AMS

This commit is contained in:
shubham_meena 2014-06-02 01:05:37 +05:30
parent 6af763206e
commit 079989ee5c
5 changed files with 421 additions and 0 deletions

View file

@ -0,0 +1,262 @@
<?php
/**
* contains the getters and setters for plugins
* this file is for demo purpose
**/
class Plugincache{
private $id;
private $plugin_name;
private $plugin_version;
private $plugin_permission;
private $plugin_isactive;
/**
* A constructor.
* 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']);
}
/**
* loads the object's attributes.
*/
public function load_With_SID( ) {
$dbl = new DBLayer("lib");
$statement = $dbl->executeWithoutParams("SELECT * FROM plugins");
$row = $statement->fetch();
$this->set($row);
}
/**
* updates the entry.
*/
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(){
return $this->Id;
}
/**
* get plugin permission attribute of the object.
*/
public function getPluginPermission(){
return $this->plugin_permission;
}
/**
* get plugin version attribute of the object.
*/
public function getPluginVersion(){
return $this->plugin_version;
}
/**
* get plugin is active attribute of the object.
*/
public function getIsActive(){
return $this->plugin_isactive;
}
/**
* get plugin name attribute of the object.
*/
public function getPluginName(){
return $this->plugin_name;
}
/**
* set plugin id attribute of the object.
* @param $s integer id
*/
public function setId($s){
$this->Id = $s;
}
/**
* set plugin permission attribute of the object.
* @param $t type of the query, set permission
*/
public function setPluginPermission($t){
$this->plugin_permission = $t;
}
/**
* set plugin version attribute of the object.
* @param $q string to set plugin version
*/
public function setPluginVersion($q){
$this->plugin_version= $q;
}
/**
* set plugin is active attribute of the object.
* @param $d tinyint to set plugin is active or not .
*/
public function setIsActive($d){
$this->plugin_isactive= $d;
}
/**
* 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;
}
}

View file

@ -53,6 +53,16 @@ name = "Name"
email = "Email"
action = "Action"
[plugins]
plugin_title = "Plugin List"
plugin_info = "Here you can see the entire list of plugins . You can easily remove plugins ,activate them and add permissions"
plugins= "Plugins"
plugin_id = "ID"
plugin_name = "Name"
plugin_version= "Version"
plugin_permission= "Owner/Access Permission"
plugin_is_active= "On/Off"
[show_ticket]
t_title = "Ticket"
title = "Title"

View file

@ -0,0 +1,45 @@
<?php
/**
* File with function plugins to get
* plugins from the Database using pagination object
* @author shubham meena mentored by Mathew Lagoe
*/
function plugins()
{
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");
$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['links'] = $pagination->getLinks(5);
$pageResult['lastPage'] = $pagination->getLast();
$pageResult['currentPage'] = $pagination->getCurrent();
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";
}
return( $pageResult);
}else{
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
}
}

View file

@ -154,6 +154,21 @@
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `" . $cfg['db']['lib']['name'] ."`.`plugins`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`plugins` ;
CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`plugins` (
`PluginId` INT(10) NOT NULL AUTO_INCREMENT,
`PluginName` VARCHAR(11) NOT NULL,
`PluginPermission` VARCHAR(5) NOT NULL,
`PluginVersion` INT(11) NOT NULL,
`IsActive` TINYINT(1) NOT NULL,
PRIMARY KEY (`PluginId`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `" . $cfg['db']['lib']['name'] ."`.`ticket`
-- -----------------------------------------------------

View file

@ -0,0 +1,89 @@
{block name=content}
<div class="row-fluid">
<div class="box span12">
<div class="box-header well" data-original-title>
<h2><i class="icon-user"></i> {$plugin_title}</h2>
<div class="box-icon">
<a href="#" class="btn btn-setting btn-round"><i class="icon-cog"></i></a>
<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
<a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
</div>
</div>
<div class="box-content">
<center><p>{$plugin_info}</p></center>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>{$plugin_id}</th>
<th>{$plugin_permission}</th>
<th>{$plugin_name}</th>
<th>{$plugin_version}</th>
<th>{$plugin_is_active}</th>
</tr>
</thead>
<tbody>
{foreach from=$plug item=element}
<tr>
<td>{$element.id}</td>
<td class="center">{$element.plugin_permission}</td>
<td class="center">{$element.plugin_name}</td>
<td class="center">{$element.plugin_version}</td>
<td class="center">{$element.plugin_isactive}</td>
</tr>
{/foreach}
</tbody>
</table>
<div style="width: 300px; margin:0px auto;">
<ul class="pagination">
<li><a href="index.php?page=plugins&pagenum=1">&laquo;</a></li>
{foreach from=$links item=link}
<li {if $link == $currentPage}class="active"{/if}><a href="index.php?page=plugins&pagenum={$link}">{$link}</a></li>
{/foreach}
<li><a href="index.php?page=plugins&pagenum={$lastPage}">&raquo;</a></li>
</ul>
</div>
</div>
</div><!--/span-->
<div class="box span3">
<div class="box-header well" data-original-title="">
<h2><i class="icon-th"></i>Actions</h2>
<div class="box-icon">
<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
<a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
</div>
</div>
<div class="box-content">
<div class="row-fluid">
<div class="btn-group">
<button class="btn btn-primary btn-large dropdown-toggle" data-toggle="dropdown">Actions<span class="caret"></span></button>
<ul class="dropdown-menu">
<li class="divider"></li>
<li><a href="">Edit Plugins</a></li>
<li><a href="">Add Plugin</a></li>
<li class="divider"></li>
{if isset($isAdmin) and $isAdmin eq 'TRUE' and $target_id neq 1}
{if $userPermission eq 1}
<li><a href="index.php?page=change_permission&user_id={$target_id}&value=2">Make Moderator</a></li>
<li><a href="index.php?page=change_permission&user_id={$target_id}&value=3">Make Admin</a></li>
{else if $userPermission eq 2 }
<li><a href="index.php?page=change_permission&user_id={$target_id}&value=1">Demote to User</a></li>
<li><a href="index.php?page=change_permission&user_id={$target_id}&value=3">Make Admin</a></li>
{else if $userPermission eq 3 }
<li><a href="index.php?page=change_permission&user_id={$target_id}&value=1">Demote to User</a></li>
<li><a href="index.php?page=change_permission&user_id={$target_id}&value=2">Demote to Moderator</a></li>
{/if}
<li class="divider"></li>
{/if}
</ul>
</div>
</div>
</div>
</div><!--/span-->
</div><!--/row-->
{/block}