refactored to admin/mod + changed install file + added mod menu

This commit is contained in:
Quitta 2013-07-18 21:12:03 +02:00
parent 2f39522002
commit bbe74c8fba
20 changed files with 49 additions and 37 deletions

View file

@ -34,8 +34,10 @@ class Helpers{
foreach ( $variables[$template] as $key => $value ){
$smarty -> assign( $key, $value );
}
if( isset($vars['permission']) && $vars['permission'] == 2 ){
if( isset($vars['permission']) && $vars['permission'] == 3 ){
$inherited = "extends:layout_admin.tpl|";
}else if( isset($vars['permission']) && $vars['permission'] == 2){
$inherited = "extends:layout_mod.tpl|";
}else if( isset($vars['permission']) && $vars['permission'] == 1){
$inherited = "extends:layout_user.tpl|";
}else{

View file

@ -30,7 +30,6 @@ class Ticket_User{
return false;
}
//return constructed element based on TUserId
public static function constr_TUserId( $id) {
$instance = new self();

View file

@ -82,13 +82,6 @@ class WebUsers extends Users{
return false;
}
public function isAdmin(){
if(isset($_SESSION['permission']) && $_SESSION['permission'] == 2){
return true;
}
return false;
}
public function setPassword($user, $pass){
$reply = WebUsers::setAmsPassword($user, $pass);
$values = Array('user' => $user, 'pass' => $pass);
@ -122,4 +115,5 @@ class WebUsers extends Users{
$data = $dbl->executeWithoutParams("SELECT * FROM ams_user");
return $data;
}
}

View file

@ -10,7 +10,7 @@ function add_sgroup(){
$tag = "[" . $inner_tag . "]";
$result['RESULT_OF_ADDING'] = Support_Group::createSupportGroup($name, $tag);
$result['permission'] = $_SESSION['permission'];
$result['permission'] = $_SESSION['ticket_user']->getPermission();
$result['no_visible_elements'] = 'FALSE';
$result['username'] = $_SESSION['user'];
global $SITEBASE;

View file

@ -13,7 +13,7 @@ function add_user_to_sgroup(){
}else{
$result['RESULT_OF_ADDING'] = "USER_NOT_EXISTING";
}
$result['permission'] = $_SESSION['permission'];
$result['permission'] = $_SESSION['ticket_user']->getPermission();
$result['no_visible_elements'] = 'FALSE';
$result['username'] = $_SESSION['user'];
global $SITEBASE;

View file

@ -81,7 +81,7 @@ function change_info(){
if($updated){
$result['info_updated'] = "OK";
}
$result['permission'] = $_SESSION['permission'];
$result['permission'] = $_SESSION['ticket_user']->getPermission();
$result['username'] = $_SESSION['user'];
$result['no_visible_elements'] = 'FALSE';
$result['target_id'] = $_POST['target_id'];

View file

@ -37,13 +37,13 @@ function change_mail(){
}else if($status == 'shardoffline'){
$result['SUCCESS_MAIL'] = "SHARDOFF";
}
$result['permission'] = $_SESSION['permission'];
$result['permission'] = $_SESSION['ticket_user']->getPermission();
$result['no_visible_elements'] = 'FALSE';
$result['username'] = $_SESSION['user'];
$result['target_id'] = $_POST['target_id'];
if(isset($_GET['id'])){
if(Ticket_User::isMod($_SESSION['ticket_user']) && ($_POST['target_id'] != $_SESSION['id'])){
$result['isAdmin'] = "TRUE";
$result['isMod'] = "TRUE";
}
}
helpers :: loadtemplate( 'settings', $result);
@ -51,13 +51,13 @@ function change_mail(){
}else{
$result['EMAIL'] = $reply;
$result['permission'] = $_SESSION['permission'];
$result['permission'] = $_SESSION['ticket_user']->getPermission();
$result['no_visible_elements'] = 'FALSE';
$result['username'] = $_SESSION['user'];
$result['target_id'] = $_POST['target_id'];
if(isset($_GET['id'])){
if(Ticket_User::isMod($_SESSION['ticket_user']) && ($_POST['target_id'] != $_SESSION['id'])){
$result['isAdmin'] = "TRUE";
$result['isMod'] = "TRUE";
}
}
helpers :: loadtemplate( 'settings', $result);

View file

@ -34,7 +34,7 @@ function change_password(){
}else if($status == 'shardoffline'){
$succresult['SUCCESS_PASS'] = "SHARDOFF";
}
$succresult['permission'] = $_SESSION['permission'];
$succresult['permission'] = $_SESSION['ticket_user']->getPermission();
$succresult['no_visible_elements'] = 'FALSE';
$succresult['username'] = $_SESSION['user'];
$succresult['target_id'] = $_POST['target_id'];
@ -46,7 +46,7 @@ function change_password(){
$result['prevCurrentPass'] = filter_var($_POST["CurrentPass"], FILTER_SANITIZE_STRING);
$result['prevNewPass'] = filter_var($_POST["NewPass"], FILTER_SANITIZE_STRING);
$result['prevConfirmNewPass'] = filter_var($_POST["ConfirmNewPass"], FILTER_SANITIZE_STRING);
$result['permission'] = $_SESSION['permission'];
$result['permission'] = $_SESSION['ticket_user']->getPermission();
$result['no_visible_elements'] = 'FALSE';
$result['username'] = $_SESSION['user'];
$result['target_id'] = $_POST['target_id'];

View file

@ -3,11 +3,12 @@
function login(){
try{
$result = WebUsers::checkLoginMatch($_POST["Username"],$_POST["Password"]);
$username = filter_var($_POST['Username'],FILTER_SANITIZE_STRING);
$password = filter_var($_POST['Password'],FILTER_SANITIZE_STRING);
$result = WebUsers::checkLoginMatch($username, $password);
if( $result != "fail"){
//handle successful login
$_SESSION['user'] = $_POST["Username"];
$_SESSION['permission'] = $result['Permission'];
$_SESSION['user'] = $username;
$_SESSION['id'] = $result['UId'];
$_SESSION['ticket_user'] = Ticket_User::constr_ExternId($result['UId']);

View file

@ -12,7 +12,7 @@ function settings(){
}else{
$result = WebUsers::getInfo($_GET['id']);
if(Ticket_User::isMod($_SESSION['ticket_user']) && ($_GET['id']!= $_SESSION['id'])){
$result['isAdmin'] = "TRUE";
$result['changesOther'] = "TRUE";
}
$result['target_id'] = $_GET['id'];
$result['current_mail'] = WebUsers::getEmail($_GET['id']);

View file

@ -17,7 +17,7 @@ function show_queue(){
$i++;
}
if(Ticket_User::isMod($_SESSION['ticket_user'])){
$result['isAdmin'] = "TRUE";
$result['isMod'] = "TRUE";
}
return $result;
}else{

View file

@ -26,7 +26,7 @@ function show_reply(){
$result['author'] = $author->getExternId();
$result['authorName'] = WebUsers::getUsername($author->getExternId());
if(Ticket_User::isMod($_SESSION['ticket_user'])){
$result['isAdmin'] = "TRUE";
$result['isMod'] = "TRUE";
}
return $result;

View file

@ -29,7 +29,7 @@ function show_ticket(){
$i++;
}
if(Ticket_User::isMod($_SESSION['ticket_user'])){
$result['isAdmin'] = "TRUE";
$result['isMod'] = "TRUE";
$result['statusList'] = Ticket::getStatusArray();
}
return $result;

View file

@ -34,7 +34,7 @@ function show_ticket_log(){
$i++;
}
if(Ticket_User::isMod($_SESSION['ticket_user'])){
$result['isAdmin'] = "TRUE";
$result['isMod'] = "TRUE";
}
return $result;

View file

@ -36,8 +36,8 @@ if(isset($_SESSION['user'])){
//Set permission
if(isset($_SESSION['permission'])){
$return['permission'] = $_SESSION['permission'];
if(isset($_SESSION['ticket_user'])){
$return['permission'] = $_SESSION['ticket_user']->getPermission();
}else{
//default permission
$return['permission'] = 0;

View file

@ -323,12 +323,14 @@
'name' => "admin",
'pass' => $hashpass,
'mail' => "admin@admin.com",
'permission' => 3
);
Users::createUser($params, 1);
try{
$params['permission'] = 2;
$dbw = new DBLayer("web");
$dbw->execute("INSERT INTO ams_user (Login, Password, Email, Permission) VALUES (:name, :pass, :mail, :permission)",$params);
$user_id = $dbw->executeReturnId("INSERT INTO ams_user (Login, Password, Email, Permission) VALUES (:name, :pass, :mail, :permission)",$params);
Users::createUser($params, $user_id);
$dbl = new DBLayer("lib");
$dbl->execute("UPDATE ticket_user SET Permission = 3 WHERE TUserId = :user_id",array('user_id' => $user_id));
print "The admin account is created, you can login with id: admin, pass: admin!";
}catch (PDOException $e){
print "There was an error while creating the admin account! ";

View file

@ -0,0 +1,14 @@
{extends file="layout.tpl"}
{block name=menu}
<li class="nav-header hidden-tablet">Main</li>
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php"><i class="icon-home"></i><span class="hidden-tablet"> Dashboard</span></a></li>
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=show_user"><i class="icon-user"></i><span class="hidden-tablet"> Profile</span></a></li>
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=settings"><i class="icon-cog"></i><span class="hidden-tablet"> Settings</span></a></li>
<li class="nav-header hidden-tablet">Admin</li>
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=userlist"><i class="icon-th-list"></i><span class="hidden-tablet"> Users</span></a></li>
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=show_queue&get=all_open"><i class="icon-th-list"></i><span class="hidden-tablet"> Queues</span></a></li>
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=sgroup_list"><i class="icon-briefcase"></i><span class="hidden-tablet"> Support Groups</span></a></li>
<li class="nav-header hidden-tablet">Actions</li>
<li style="margin-left: -2px;"><a href="?page=logout"><i class="icon-off"></i><span class="hidden-tablet"> Logout </span></a></li>
{/block}

View file

@ -13,7 +13,7 @@
<form id="changePassword" class="form-vertical" method="post" action="index.php?page=settings&id={$target_id}">
<legend>Change Password</legend>
{if !isset($isAdmin) or $isAdmin eq "FALSE"}
{if !isset($changesOther) or $changesOther eq "FALSE"}
<div class="control-group {if isset($MATCH_ERROR) and $MATCH_ERROR eq "TRUE"}error{else if
isset($match_error_message) and $match_error_message neq "fail"}success{else}{/if}">
<label class="control-label">Current Password</label>

View file

@ -20,7 +20,7 @@
{else if $author_permission eq '2'}
<span class="label label-important"><strong><i class="icon-star icon-white"></i>[CSR]</strong></span>
{/if}
<span class="label label-warning"><strong><i class="icon-user icon-white"></i>{if isset($isAdmin) and $isAdmin eq "TRUE"} <a href="index.php?page=show_user&id={$author}"><font color="white">{$authorName}</font>{else}{$authorName} {/if}</a></strong></span></p>
<span class="label label-warning"><strong><i class="icon-user icon-white"></i>{if isset($isMod) and $isMod eq "TRUE"} <a href="index.php?page=show_user&id={$author}"><font color="white">{$authorName}</font>{else}{$authorName} {/if}</a></strong></span></p>
<p><pre{if $author_permission eq '2'} style="background-color:rgb(248, 200, 200);"{/if}>{$reply_content}</pre></p>
</td>

View file

@ -39,7 +39,7 @@
{else if $reply.permission gt '1'}
<span class="label label-important"><strong><i class="icon-star icon-white"></i>[CSR]</strong></span>
{/if}
<span class="label label-warning"><strong><i class="icon-user icon-white"></i>{if isset($isAdmin) and $isAdmin eq "TRUE"} <a href="index.php?page=show_user&id={$reply.authorExtern}"><font color="white">{$reply.author}</font>{else}{$reply.author} {/if}</a></strong></span></p>
<span class="label label-warning"><strong><i class="icon-user icon-white"></i>{if isset($isMod) and $isMod eq "TRUE"} <a href="index.php?page=show_user&id={$reply.authorExtern}"><font color="white">{$reply.author}</font>{else}{$reply.author} {/if}</a></strong></span></p>
<p><pre{if $reply.permission gt '1'} style="background-color:rgb(248, 200, 200);"{/if}>{$reply.replyContent}</pre></p>
</td>
@ -68,7 +68,7 @@
</div>
</div>
{/if}
{if isset($isAdmin) and $isAdmin eq "TRUE"}
{if isset($isMod) and $isMod eq "TRUE"}
<div class="control-group" style="display: inline-block;">
<label class="control-label">Change status to</label>
<div class="controls">
@ -181,7 +181,7 @@
<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>
{if isset($isAdmin) and $isAdmin eq "TRUE"}<li><a href="index.php?page=show_ticket_log&id={$ticket_tId}">Show Ticket Log</a></li>{/if}
{if isset($isMod) and $isMod eq "TRUE"}<li><a href="index.php?page=show_ticket_log&id={$ticket_tId}">Show Ticket Log</a></li>{/if}
<li><a href="index.php?page=createticket&user_id={$target_id}">Send Other Ticket</a></li>
<li class="divider"></li>
</ul>