Users can specify if they want to receive or dont want to receive tickt updates!
This commit is contained in:
parent
a6c5b1bab1
commit
747e1deaea
7 changed files with 152 additions and 31 deletions
|
@ -21,22 +21,32 @@ class Mail_Handler{
|
|||
//if it is not forwarded (==public == which returns 0) then make it NULL which is needed to be placed in the DB.
|
||||
$sendingGroupId = NULL;
|
||||
}
|
||||
if($type == "REPLY"){
|
||||
$txt = "---------- Ticket #". $ticketObj->getTId() . " ----------\n You received a new reply on your ticket: " . $ticketObj->getTitle() .
|
||||
"\n --------------------\n\n";
|
||||
$subject = "New reply on [Ticket #" . $ticketObj->getTId() ."]";
|
||||
$endTxt = "\n\n----------\nYou can reply on this message to answer directly on the ticket!";
|
||||
$txt = $txt . $content . $endTxt;
|
||||
self::send_mail($ticketObj->getAuthor(),$subject,$txt, $ticketObj->getTId(),$sendingGroupId);
|
||||
}else if($type == "NEW"){
|
||||
$txt = "---------- Ticket #". $ticketObj->getTId() . " ----------\n Your ticket: " . $ticketObj->getTitle() . " is newly created";
|
||||
$txt = $txt . "\n --------------------\n\n";
|
||||
$subject = "New ticket created [Ticket #" . $ticketObj->getTId() ."]";
|
||||
$endTxt = "\n\n----------\nYou can reply on this message to answer directly on the ticket!";
|
||||
$txt = $txt . $content . $endTxt;
|
||||
self::send_mail($ticketObj->getAuthor(),$subject,$txt, $ticketObj->getTId(), $sendingGroupId);
|
||||
}
|
||||
$author = $ticketObj->getAuthor();
|
||||
$webUser = new WebUsers($author);
|
||||
|
||||
//if the author of the ticket wants to receive mail, then send it!
|
||||
if($webUser->getReceiveMail()){
|
||||
|
||||
switch($type){
|
||||
case "REPLY":
|
||||
$txt = "---------- Ticket #". $ticketObj->getTId() . " ----------\n You received a new reply on your ticket: " . $ticketObj->getTitle() .
|
||||
"\n --------------------\n\n";
|
||||
$subject = "New reply on [Ticket #" . $ticketObj->getTId() ."]";
|
||||
$endTxt = "\n\n----------\nYou can reply on this message to answer directly on the ticket!";
|
||||
$txt = $txt . $content . $endTxt;
|
||||
self::send_mail($author,$subject,$txt, $ticketObj->getTId(),$sendingGroupId);
|
||||
break;
|
||||
|
||||
case "NEW":
|
||||
$txt = "---------- Ticket #". $ticketObj->getTId() . " ----------\n Your ticket: " . $ticketObj->getTitle() . " is newly created";
|
||||
$txt = $txt . "\n --------------------\n\n";
|
||||
$subject = "New ticket created [Ticket #" . $ticketObj->getTId() ."]";
|
||||
$endTxt = "\n\n----------\nYou can reply on this message to answer directly on the ticket!";
|
||||
$txt = $txt . $content . $endTxt;
|
||||
self::send_mail($author,$subject,$txt, $ticketObj->getTId(), $sendingGroupId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,11 @@ $cfg['mail']['default_username'] = 'amsryzom@gmail.com';
|
|||
$cfg['mail']['default_password'] = 'lol123bol';
|
||||
$cfg['mail']['host'] = "ryzomcore.com";
|
||||
|
||||
//Defines mailing related stuff
|
||||
$SUPPORT_GROUP_IMAP_CRYPTKEY = "azerty";
|
||||
$TICKET_MAILING_SUPPORT = true;
|
||||
$MAIL_DIR = "/tmp";
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// If true= the server will add automatically unknown user in the database
|
||||
// (in nel.user= nel.permission= ring.ring_user and ring.characters
|
||||
|
@ -73,7 +78,4 @@ $TIME_FORMAT = "m-d-Y H:i:s";
|
|||
//defines which ingame layout template should be used
|
||||
$INGAME_LAYOUT = "basic";
|
||||
|
||||
//Defines mailing related stuff
|
||||
$SUPPORT_GROUP_IMAP_CRYPTKEY = "azerty";
|
||||
$TICKET_MAILING_SUPPORT = true;
|
||||
$MAIL_DIR = "/tmp";
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ class WebUsers extends Users{
|
|||
private $lastname;
|
||||
private $gender;
|
||||
private $country;
|
||||
private $receiveMail;
|
||||
|
||||
function __construct($UId = 0) {
|
||||
$this->uId = $UId;
|
||||
|
@ -22,6 +23,7 @@ class WebUsers extends Users{
|
|||
$this->lastname = $values['LastName'];
|
||||
$this->gender = $values['Gender'];
|
||||
$this->country = $values['Country'];
|
||||
$this->receiveMail = $values['ReceiveMail'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,16 +116,26 @@ class WebUsers extends Users{
|
|||
|
||||
public function getInfo(){
|
||||
$dbw = new DBLayer("web");
|
||||
if(! (isset($this->firstname) && isset($this->lastname) && isset($this->gender) && isset($this->country) ) ||
|
||||
$this->firstname == "" || $this->lastname == "" || $this->gender == "" || $this->country == ""){
|
||||
if(! (isset($this->firstname) && isset($this->lastname) && isset($this->gender) && isset($this->country) && isset($this->receiveMail) ) ||
|
||||
$this->firstname == "" || $this->lastname == "" || $this->gender == "" || $this->country == "" || $this->receiveMail == ""){
|
||||
$statement = $dbw->execute("SELECT * FROM ams_user WHERE UId=:id", array('id' => $this->uId));
|
||||
$row = $statement->fetch();
|
||||
$this->set($row);
|
||||
}
|
||||
$result = Array('FirstName' => $this->firstname, 'LastName' => $this->lastname, 'Gender' => $this->gender, 'Country' => $this->country);
|
||||
$result = Array('FirstName' => $this->firstname, 'LastName' => $this->lastname, 'Gender' => $this->gender, 'Country' => $this->country, 'ReceiveMail' => $this->receiveMail);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getReceiveMail(){
|
||||
$dbw = new DBLayer("web");
|
||||
if(! isset($this->receiveMail) || $this->receiveMail == ""){
|
||||
$statement = $dbw->execute("SELECT * FROM ams_user WHERE UId=:id", array('id' => $this->uId));
|
||||
$row = $statement->fetch();
|
||||
$this->set($row);
|
||||
}
|
||||
return $this->receiveMail;
|
||||
}
|
||||
|
||||
public function isLoggedIn(){
|
||||
if(isset($_SESSION['user'])){
|
||||
return true;
|
||||
|
@ -159,6 +171,18 @@ class WebUsers extends Users{
|
|||
return $reply;
|
||||
}
|
||||
|
||||
public static function setReceiveMail($user, $receivemail){
|
||||
$values = Array('user' => $user, 'receivemail' => $receivemail);
|
||||
try {
|
||||
//make connection with and put into shard db
|
||||
$dbw = new DBLayer("web");
|
||||
$dbw->execute("UPDATE ams_user SET ReceiveMail = :receivemail WHERE UId = :user ",$values);
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
//ERROR: the web DB is offline
|
||||
}
|
||||
}
|
||||
|
||||
public function getUsers(){
|
||||
$dbl = new DBLayer("web");
|
||||
$data = $dbl->executeWithoutParams("SELECT * FROM ams_user");
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
function change_receivemail(){
|
||||
|
||||
try{
|
||||
//if logged in
|
||||
if(WebUsers::isLoggedIn()){
|
||||
|
||||
if(isset($_POST['target_id'])){
|
||||
|
||||
|
||||
if( ( ($_POST['target_id'] == $_SESSION['id']) || Ticket_User::isMod($_SESSION['ticket_user'])) && isset($_POST['ReceiveMail']) ){
|
||||
$user_id = filter_var($_POST['target_id'], FILTER_SANITIZE_NUMBER_INT);
|
||||
$receiveMail = filter_var($_POST['ReceiveMail'], FILTER_SANITIZE_NUMBER_INT);
|
||||
if($receiveMail == 0 || $receiveMail == 1){
|
||||
WebUsers::setReceiveMail($user_id, $receiveMail);
|
||||
}
|
||||
header("Location: index.php?page=settings&id=".$user_id);
|
||||
exit;
|
||||
|
||||
}else{
|
||||
//ERROR: permission denied!
|
||||
$_SESSION['error_code'] = "403";
|
||||
header("Location: index.php?page=error");
|
||||
exit;
|
||||
}
|
||||
|
||||
}else{
|
||||
//ERROR: The form was not filled in correclty
|
||||
header("Location: index.php?page=settings");
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
//ERROR: user is not logged in
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
}catch (PDOException $e) {
|
||||
//go to error page or something, because can't access website db
|
||||
print_r($e);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -24,14 +24,15 @@ function settings(){
|
|||
$result['target_id'] = $_SESSION['id'];
|
||||
$result['current_mail'] = $webUser->getEmail();
|
||||
|
||||
//Sanitize Data
|
||||
$result['current_mail'] = filter_var($result['current_mail'], FILTER_SANITIZE_EMAIL);
|
||||
//$result['Login'] = filter_var($result['Login'], FILTER_SANITIZE_STRING);
|
||||
$result['FirstName'] = filter_var($result['FirstName'], FILTER_SANITIZE_STRING);
|
||||
$result['LastName'] = filter_var($result['LastName'], FILTER_SANITIZE_STRING);
|
||||
$result['Country'] = filter_var($result['Country'], FILTER_SANITIZE_STRING);
|
||||
$result['Gender'] = filter_var($result['Gender'], FILTER_SANITIZE_NUMBER_INT);
|
||||
}
|
||||
//Sanitize Data
|
||||
$result['current_mail'] = filter_var($result['current_mail'], FILTER_SANITIZE_EMAIL);
|
||||
//$result['Login'] = filter_var($result['Login'], FILTER_SANITIZE_STRING);
|
||||
$result['FirstName'] = filter_var($result['FirstName'], FILTER_SANITIZE_STRING);
|
||||
$result['LastName'] = filter_var($result['LastName'], FILTER_SANITIZE_STRING);
|
||||
$result['Country'] = filter_var($result['Country'], FILTER_SANITIZE_STRING);
|
||||
$result['Gender'] = filter_var($result['Gender'], FILTER_SANITIZE_NUMBER_INT);
|
||||
$result['ReceiveMail'] = filter_var($result['ReceiveMail'], FILTER_SANITIZE_NUMBER_INT);
|
||||
$result['country_array'] = getCountryArray();
|
||||
return $result;
|
||||
}else{
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
`LastName` varchar(255) NOT NULL DEFAULT '',
|
||||
`Gender` tinyint(1) unsigned NOT NULL DEFAULT '0',
|
||||
`Country` char(2) NOT NULL DEFAULT '',
|
||||
`ReceiveMail` int(1) NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY (`UId`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='contains all users information for ryzom_ams';
|
||||
|
||||
|
|
|
@ -101,6 +101,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{if isset($SUCCESS_MAIL) and $SUCCESS_MAIL eq "OK"}
|
||||
<div class="alert alert-success">
|
||||
The email has been changed!
|
||||
|
@ -124,6 +125,40 @@
|
|||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-header well" data-original-title="">
|
||||
<h2><i class="icon-envelope"></i> Ticket updates</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="changeReceiveMail" class="form-vertical" method="post" action="index.php?page=settings&id={$target_id}">
|
||||
<legend>Ticket-Update Mail Settings</legend>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">Receive ticket updates</label>
|
||||
<div class="controls">
|
||||
<select name="ReceiveMail">
|
||||
<option value="1" {if isset($ReceiveMail) and $ReceiveMail eq 1}selected="selected"{/if}>Yes</option>
|
||||
<option value="0" {if isset($ReceiveMail) and $ReceiveMail eq 0}selected="selected"{/if}>No</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="function" value="change_receivemail">
|
||||
<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" style="margin-left:5px; margin-top:10px;">Change Updates</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div><!--/span-->
|
||||
|
||||
<div class="box span4">
|
||||
|
|
Loading…
Reference in a new issue