mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-24 18:08:44 +00:00
support group class added + list of support groups added!
This commit is contained in:
parent
77ef51b759
commit
4cb1b633a2
10 changed files with 335 additions and 4 deletions
|
@ -0,0 +1,148 @@
|
|||
<?php
|
||||
|
||||
class Support_Group{
|
||||
|
||||
private $sGroupId;
|
||||
private $name;
|
||||
private $tag;
|
||||
|
||||
////////////////////////////////////////////Functions////////////////////////////////////////////////////
|
||||
|
||||
//return all groups
|
||||
public static function getGroups() {
|
||||
$dbl = new DBLayer("lib");
|
||||
$statement = $dbl->executeWithoutParams("SELECT * FROM support_group ORDER BY Name ASC");
|
||||
$rows = $statement->fetchAll();
|
||||
$result = Array();
|
||||
foreach($rows as $group){
|
||||
|
||||
$instanceGroup = new self();
|
||||
$instanceGroup->set($group);
|
||||
$result[] = $instanceGroup;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
//wrapper for creating a support group
|
||||
public static function createSupportGroup( $name, $tag) {
|
||||
|
||||
if(strlen($name) < 21 && strlen($name) > 4 &&strlen($tag) < 8 && strlen($tag) > 1 ){
|
||||
$notExists = self::supportGroup_NotExists($name, $tag);
|
||||
if ( $notExists == "SUCCESS" ){
|
||||
$sGroup = new self();
|
||||
$sGroup->setName($name);
|
||||
$sGroup->setTag($tag);
|
||||
$sGroup->create();
|
||||
return "SUCCESS";
|
||||
}else{
|
||||
//return NAME_TAKEN or TAG_TAKEN
|
||||
return $notExists;
|
||||
}
|
||||
}else{
|
||||
//RETURN ERROR that indicates SIZE
|
||||
return "SIZE_ERROR";
|
||||
}
|
||||
}
|
||||
|
||||
//check if group exists
|
||||
public static function supportGroup_NotExists( $name, $tag) {
|
||||
$dbl = new DBLayer("lib");
|
||||
//check if name is already used
|
||||
if( $dbl->execute("SELECT * FROM support_group WHERE Name = :name",array('name' => $name))->rowCount() ){
|
||||
return "NAME_TAKEN";
|
||||
}
|
||||
else if( $dbl->execute("SELECT * FROM support_group WHERE Tag = :tag",array('tag' => $tag))->rowCount() ){
|
||||
return "TAG_TAKEN";
|
||||
}else{
|
||||
return "SUCCESS";
|
||||
}
|
||||
}
|
||||
|
||||
//return constructed element based on SGroupId
|
||||
public static function constr_SGroupId( $id) {
|
||||
$instance = new self();
|
||||
$instance->setSGroup($id);
|
||||
return $instance;
|
||||
}
|
||||
|
||||
//returns list of all users that are enlisted to a support group
|
||||
public static function getAllUsersOfSupportGroup($id) {
|
||||
$dbl = new DBLayer("lib");
|
||||
$statement = $dbl->execute("SELECT * FROM ticket_log INNER JOIN ticket_user ON ticket_log.Author = ticket_user.TUserId and ticket_log.Ticket=:id", array('id' => $ticket_id));
|
||||
$row = $statement->fetchAll();
|
||||
$result = Array();
|
||||
foreach($row as $log){
|
||||
$instance = new self();
|
||||
$instance->set($log);
|
||||
$result[] = $instance;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////Methods////////////////////////////////////////////////////
|
||||
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
//set values
|
||||
public function set($values) {
|
||||
$this->setSGroupId($values['SGroupId']);
|
||||
$this->setName($values['Name']);
|
||||
$this->setTag($values['Tag']);
|
||||
}
|
||||
|
||||
public function create() {
|
||||
$dbl = new DBLayer("lib");
|
||||
$query = "INSERT INTO support_group (Name, Tag) VALUES (:name, :tag)";
|
||||
$values = Array('name' => $this->name, 'tag' => $this->tag);
|
||||
$dbl->execute($query, $values);
|
||||
}
|
||||
|
||||
//Load with sGroupId
|
||||
public function load_With_SGroupId( $id) {
|
||||
$dbl = new DBLayer("lib");
|
||||
$statement = $dbl->execute("SELECT * FROM ticket_log WHERE TLogId=:id", array('id' => $id));
|
||||
$row = $statement->fetch();
|
||||
$this->set($row);
|
||||
}
|
||||
|
||||
|
||||
//update private data to DB.
|
||||
public function update(){
|
||||
$dbl = new DBLayer("lib");
|
||||
$query = "UPDATE ticket_log SET Timestamp = :timestamp, Query = :query, Author = :author, Ticket = :ticket WHERE TLogId=:id";
|
||||
$values = Array('id' => $this->getTLogId(), 'timestamp' => $this->getTimestamp(), 'query' => $this->getQuery(), 'author' => $this->getAuthor(), 'ticket' => $this->getTicket() );
|
||||
$statement = $dbl->execute($query, $values);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////Getters////////////////////////////////////////////////////
|
||||
|
||||
public function getSGroupId(){
|
||||
return $this->sGroupId;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getTag(){
|
||||
return $this->tag;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////Setters////////////////////////////////////////////////////
|
||||
|
||||
public function setSGroupId($id){
|
||||
$this->sGroupId = $id;
|
||||
}
|
||||
|
||||
public function setName($n){
|
||||
$this->name = $n;
|
||||
}
|
||||
|
||||
public function setTag($t){
|
||||
$this->tag = $t;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -31,6 +31,12 @@ t_send = "Send reply"
|
|||
|
||||
[show_queue]
|
||||
|
||||
[sgroup_list]
|
||||
group_success = "The group has been created!"
|
||||
group_name_taken = "The groupname was already used!"
|
||||
group_tag_taken = "The tag was already used!"
|
||||
group_size_error = "The name has to be between 4-20 chars and the tag between 2-4!"
|
||||
|
||||
[createticket]
|
||||
|
||||
[show_ticket_log]
|
||||
|
|
|
@ -31,6 +31,12 @@ t_send = "Envoyer la reponse"
|
|||
|
||||
[show_queue]
|
||||
|
||||
[sgroup_list]
|
||||
group_success = "le group est cree!"
|
||||
group_name_taken = "le nom pour le group est deja utilise!"
|
||||
group_tag_taken = "le tag pour le group est deja utilise!"
|
||||
group_size_error = "le nom doit etre 4-20 chars et le tag 2-4!"
|
||||
|
||||
[createticket]
|
||||
|
||||
[show_reply]
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
function add_sgroup(){
|
||||
|
||||
if(WebUsers::isLoggedIn()){
|
||||
|
||||
if( WebUsers::isAdmin()){
|
||||
$name = filter_var($_POST['Name'],FILTER_SANITIZE_STRING);
|
||||
$inner_tag = filter_var($_POST['Tag'], FILTER_SANITIZE_STRING);
|
||||
$tag = "[" . $inner_tag . "]";
|
||||
|
||||
$result['RESULT_OF_ADDING'] = Support_Group::createSupportGroup($name, $tag);
|
||||
$result['permission'] = $_SESSION['permission'];
|
||||
$result['no_visible_elements'] = 'FALSE';
|
||||
$result['username'] = $_SESSION['user'];
|
||||
global $SITEBASE;
|
||||
require_once($SITEBASE . 'inc/sgroup_list.php');
|
||||
$result= array_merge($result, sgroup_list());
|
||||
helpers :: loadtemplate( 'sgroup_list', $result);
|
||||
exit;
|
||||
|
||||
}else{
|
||||
//ERROR: No access!
|
||||
$_SESSION['error_code'] = "403";
|
||||
header("Location: index.php?page=error");
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
//ERROR: not logged in!
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
function sgroup_list(){
|
||||
//if logged in & queue id is given
|
||||
if(WebUsers::isLoggedIn()){
|
||||
if( WebUsers::isAdmin()){
|
||||
|
||||
$result['grouplist'] = Gui_Elements::make_table(Support_Group::getGroups(), Array("getSGroupId","getName","getTag"), Array("sGroupId","name","tag"));
|
||||
return $result;
|
||||
|
||||
}else{
|
||||
//ERROR: No access!
|
||||
$_SESSION['error_code'] = "403";
|
||||
header("Location: index.php?page=error");
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
//ERROR: not logged in!
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 124 KiB |
|
@ -281,8 +281,11 @@
|
|||
|
||||
CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`support_group` (
|
||||
`SGroupId` INT(10) NOT NULL AUTO_INCREMENT ,
|
||||
`Name` VARCHAR(45) NOT NULL ,
|
||||
PRIMARY KEY (`SGroupId`) )
|
||||
`Name` VARCHAR(22) NOT NULL ,
|
||||
`Tag` VARCHAR(7) NOT NULL ,
|
||||
PRIMARY KEY (`SGroupId`) ,
|
||||
UNIQUE INDEX `Name_UNIQUE` (`Name` ASC) ,
|
||||
UNIQUE INDEX `Tag_UNIQUE` (`Tag` ASC) )
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
|
|
|
@ -238,8 +238,11 @@ DROP TABLE IF EXISTS `mydb`.`support_group` ;
|
|||
|
||||
CREATE TABLE IF NOT EXISTS `mydb`.`support_group` (
|
||||
`SGroupId` INT(10) NOT NULL AUTO_INCREMENT ,
|
||||
`Name` VARCHAR(45) NOT NULL ,
|
||||
PRIMARY KEY (`SGroupId`) )
|
||||
`Name` VARCHAR(22) NOT NULL ,
|
||||
`Tag` VARCHAR(7) NOT NULL ,
|
||||
PRIMARY KEY (`SGroupId`) ,
|
||||
UNIQUE INDEX `Name_UNIQUE` (`Name` ASC) ,
|
||||
UNIQUE INDEX `Tag_UNIQUE` (`Tag` ASC) )
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,108 @@
|
|||
{block name=content}
|
||||
<div class="row-fluid sortable ui-sortable">
|
||||
<div class="box span12">
|
||||
<div class="box-header well" data-original-title="">
|
||||
<h2><i class="icon-plus-sign"></i> Add</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">
|
||||
|
||||
<form id="addSGroup" class="form-vertical" method="post" action="index.php">
|
||||
|
||||
<legend>Add a support group</legend>
|
||||
|
||||
<div class="control-group" style="display: inline-block; ">
|
||||
<label class="control-label">Group name</label>
|
||||
<div class="controls">
|
||||
<div class="input-prepend">
|
||||
<input type="text" maxlength="20" id="Name" name="Name">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group" style="display: inline-block; margin-left:10px;">
|
||||
<label class="control-label">Group Tag</label>
|
||||
<div class="controls">
|
||||
<div class="input-prepend">
|
||||
<input type="text" maxlength="4" id="Tag" name="Tag">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="function" value="add_sgroup">
|
||||
<input type="hidden" name="target_id" value="{$target_id}">
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label"></label>
|
||||
<div class="controls">
|
||||
<button type="submit" class="btn btn-primary" >Add</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SUCCESS"}
|
||||
<div class="alert alert-success">
|
||||
{$group_success}
|
||||
</div>
|
||||
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "NAME_TAKEN"}
|
||||
<div class="alert alert-warning">
|
||||
{$group_name_taken}
|
||||
</div>
|
||||
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "TAG_TAKEN"}
|
||||
<div class="alert alert-warning">
|
||||
{$group_tag_taken}
|
||||
</div>
|
||||
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SIZE_ERROR"}
|
||||
<div class="alert alert-warning">
|
||||
{$group_size_error}
|
||||
</div>
|
||||
{/if}
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
|
||||
<div class="row-fluid sortable ui-sortable">
|
||||
<div class="box span12">
|
||||
<div class="box-header well" data-original-title="">
|
||||
<h2><i class="icon-list"></i> List</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">
|
||||
<legend>All support groups</legend>
|
||||
<table class="table table-striped table-bordered bootstrap-datatable datatable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Tag</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$grouplist item=group}
|
||||
<tr>
|
||||
<td>{$group.sGroupId}</td>
|
||||
<td><a href ="index.php?page=show_group&id={$group.sGroupId}">{$group.name}</a></td>
|
||||
<td class="center"><span class="label label-important" >{$group.tag}</span></td>
|
||||
<td class="center"><a class="btn btn-danger" href="#"><i class="icon-trash icon-white"></i> Delete</a></td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
{/block}
|
||||
|
Loading…
Reference in a new issue