use language ini files to select correct log thing

This commit is contained in:
Quitta 2013-07-13 16:41:52 +02:00
parent 80c846050d
commit 66cec1fb7a
6 changed files with 73 additions and 64 deletions

View file

@ -76,12 +76,12 @@ class Ticket{
$ticket->create(); $ticket->create();
$ticket_id = $ticket->getTId(); $ticket_id = $ticket->getTId();
Ticket_Reply::createReply($content, $author, $ticket_id);
if ( $author == $real_author){ if ( $author == $real_author){
Ticket_Log::createLogEntry( $ticket_id, $author, 1); Ticket_Log::createLogEntry( $ticket_id, $author, 1);
}else{ }else{
Ticket_Log::createLogEntry( $ticket_id, $real_author, 2, $author); Ticket_Log::createLogEntry( $ticket_id, $real_author, 2, $author);
} }
Ticket_Reply::createReply($content, $author, $ticket_id);
return $ticket_id; return $ticket_id;
} }

View file

@ -142,6 +142,40 @@ class Ticket_Log{
return $decodedQuery[1]; return $decodedQuery[1];
} }
public function getActionTextArray(){
global $DEFAULT_LANGUAGE;
global $AMS_TRANS;
//if language get param is given = set cookie
//else if no get param is given and a cookie is set, use that language, else use default.
if ( isset( $_GET['language'] ) ) {
//check if the language is supported
if ( file_exists( $AMS_TRANS . '/' . $_GET['language'] . '.ini' ) ){
//if it's supported, set cookie!
setcookie( 'language',$_GET['language'], time() + 60*60*24*30 );
$language = $_GET['language'];
}else{
//the language is not supported, use the default.
$language = $DEFAULT_LANGUAGE;
}
}else{
//if no get param is given, check if a cookie value for language is set
if ( isset( $_COOKIE['language'] ) ) {
$language = $_COOKIE['language'];
}
//else use the default
else{
$language = $DEFAULT_LANGUAGE;
}
}
$variables = parse_ini_file( $AMS_TRANS . '/' . $language . '.ini', true );
$result = array();
foreach ( $variables['ticket_log'] as $key => $value ){
$result[$key] = $value;
}
return $result;
}
////////////////////////////////////////////Setters//////////////////////////////////////////////////// ////////////////////////////////////////////Setters////////////////////////////////////////////////////
public function setTLogId($id){ public function setTLogId($id){

View file

@ -33,6 +33,14 @@ t_send = "Send reply"
[show_ticket_log] [show_ticket_log]
[ticket_log]
1 = "created the ticket"
2 = "created the ticket for"
3 = "read the ticket"
4 = "added reply"
5 = "changed the status to"
6 = "changed the priority to"
[error] [error]
title404 = "Not<br/>Found!" title404 = "Not<br/>Found!"
title403 = "Forbidden!" title403 = "Forbidden!"

View file

@ -13,10 +13,25 @@ function show_ticket_log(){
$result['ticket_title'] = $target_ticket->getTitle(); $result['ticket_title'] = $target_ticket->getTitle();
$ticket_logs = Ticket_Log::getLogsOfTicket( $result['ticket_id']); $ticket_logs = Ticket_Log::getLogsOfTicket( $result['ticket_id']);
$log_action_array = Ticket_Log::getActionTextArray();
$result['ticket_logs'] = Gui_Elements::make_table($ticket_logs, Array("getTLogId","getTimestamp","getAuthor()->getExternId","getAction","getArgument()"), Array("tLogId","timestamp","authorExtern","action","argument")); $result['ticket_logs'] = Gui_Elements::make_table($ticket_logs, Array("getTLogId","getTimestamp","getAuthor()->getExternId","getAction","getArgument()"), Array("tLogId","timestamp","authorExtern","action","argument"));
$i = 0; $i = 0;
foreach( $result['ticket_logs'] as $log){ foreach( $result['ticket_logs'] as $log){
$result['ticket_logs'][$i]['author'] = WebUsers::getUsername($log['authorExtern']); $author = WebUsers::getUsername($log['authorExtern']);
$result['ticket_logs'][$i]['author'] = $author;
$query_backpart = "";
if($log['action'] == 2){
$query_backpart = WebUsers::getUsername($log['argument']);
}else if($log['action'] == 4){
$query_backpart = "<a href='index.php?page=show_reply&id=" . $log['argument'] . "'>" . $log['argument'] . "</a>";
}else if($log['action'] == 5){
$statusArray = Ticket::getStatusArray();
$query_backpart = $statusArray[$log['argument'] ];
}else if($log['action'] == 6){
$priorityArray = Ticket::getPriorityArray();
$query_backpart = $priorityArray[$log['argument'] ];
}
$result['ticket_logs'][$i]['query'] = $author . " " . $log_action_array[$log['action']] . " " . $query_backpart;
$i++; $i++;
} }
if(WebUsers::isAdmin()){ if(WebUsers::isAdmin()){

View file

@ -109,7 +109,7 @@
<div class="box span3"> <div class="box span3">
<div class="box-header well" data-original-title=""> <div class="box-header well" data-original-title="">
<h2><i class="icon-th"></i>Tags</h2> <h2><i class="icon-th"></i>Actions</h2>
<div class="box-icon"> <div class="box-icon">
<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></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> <a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
@ -117,6 +117,7 @@
</div> </div>
<div class="box-content"> <div class="box-content">
<div class="row-fluid"> <div class="row-fluid">
<form id="addTag" class="form-vertical" method="post" action="index.php"> <form id="addTag" class="form-vertical" method="post" action="index.php">
<legend>Tags</legend> <legend>Tags</legend>
@ -146,61 +147,7 @@
</div> </div>
</div> </div>
</form> </form>
</div>
</div>
</div>
<div class="box span3">
<div class="box-header well" data-original-title="">
<h2><i class="icon-th"></i>Groups</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="addTag" class="form-vertical" method="post" action="index.php">
<legend>Groups</legend>
<div class="control-group">
<label class="control-label">Current Groups</label>
<div class="controls">
<div class="input-prepend">
<div id="checkbox1" class="checker"><span class="checked"><input style="opacity: 0;" id="inlineCheckbox2" value="option2" checked="checked" type="checkbox"></span></div> Hacked accounts
</div>
</div>
</div>
<div class="control-group">
<label class="control-label">New Group</label>
<div class="controls">
<div class="input-prepend">
<input type="text" class="span8" id="newTag" name="newTag">
</div>
</div>
</div>
<div class="control-group">
<label class="control-label"></label>
<div class="controls">
<button type="submit" class="btn btn-primary" >Update</button>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="box span3">
<div class="box-header well" data-original-title="">
<h2><i class="icon-th"></i>Associations</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="addTag" class="form-vertical" method="post" action="index.php"> <form id="addTag" class="form-vertical" method="post" action="index.php">
<legend>Associations</legend> <legend>Associations</legend>
@ -227,6 +174,16 @@
</div> </div>
</div> </div>
</form> </form>
<legend>Actions</legend>
<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="index.php?page=show_ticket_log&id={$ticket_tId}">Show Ticket Log</a></li>
<li><a href="index.php?page=createticket&user_id={$target_id}">Send Other Ticket</a></li>
<li class="divider"></li>
</ul>
</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -16,9 +16,7 @@
<tr> <tr>
<th>ID</th> <th>ID</th>
<th>Timestamp</th> <th>Timestamp</th>
<th>User</th> <th>Query</th>
<th>Action</th>
<th>Argument</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -26,10 +24,7 @@
<tr> <tr>
<td>{$log.tLogId}</td> <td>{$log.tLogId}</td>
<td>{$log.timestamp}</td> <td>{$log.timestamp}</td>
<td>{$log.author}</td> <td>{$log.query}</td>
<td>{$log.action}</td>
<td>{$log.argument}</td>
</tr> </tr>
{/foreach} {/foreach}