diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/autoload/webusers.php b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/autoload/webusers.php index 158eb3b29..2beb75c1b 100644 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/autoload/webusers.php +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/autoload/webusers.php @@ -17,15 +17,15 @@ class WebUsers extends Users{ } public function set($values){ - $this->uId = $values['UId']; - $this->login = $values['Login']; - $this->email = $values['Email']; - $this->firstname = $values['FirstName']; - $this->lastname = $values['LastName']; - $this->gender = $values['Gender']; - $this->country = $values['Country']; - $this->receiveMail = $values['ReceiveMail']; - $this->language = $values['Language']; + $this->uId = $values['uid']; + $this->login = $values['name']; + $this->email = $values['mail']; + //$this->firstname = $values['FirstName']; + //$this->lastname = $values['LastName']; + //$this->gender = $values['Gender']; + //$this->country = $values['Country']; + //$this->receiveMail = $values['ReceiveMail']; + //$this->language = $values['Language']; } /** @@ -72,8 +72,8 @@ class WebUsers extends Users{ //returns te id for a given username public static function getId($username){ - $row = db_query("SELECT * FROM {users} WHERE name = :name", array(':name' => $username))->fetchField(); - return $row['UId']; + $row = db_query("SELECT * FROM {users} WHERE name = :name", array(':name' => $username))->fetchAssoc(); + return $row['uid']; } //returns te id for a given username @@ -93,20 +93,17 @@ class WebUsers extends Users{ } public function getUsername(){ - $dbw = new DBLayer("web"); + if(! isset($this->login) || $this->login == ""){ - $statement = $dbw->execute("SELECT * FROM ams_user WHERE UId=:id", array('id' => $this->uId)); - $row = $statement->fetch(); - $this->set($row); + $row = db_query("SELECT * FROM {users} WHERE uid = :id", array(':id' => $this->uId))->fetchAssoc(); + $this->set($row); } return $this->login; } public function getEmail(){ - $dbw = new DBLayer("web"); if(! isset($this->email) || $this->email == ""){ - $statement = $dbw->execute("SELECT * FROM ams_user WHERE UId=:id", array('id' => $this->uId)); - $row = $statement->fetch(); + $row = db_query("SELECT * FROM {users} WHERE uid = :id", array(':id' => $this->uId))->fetchAssoc(); $this->set($row); } return $this->email; diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/func/create_ticket.php b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/func/create_ticket.php new file mode 100644 index 000000000..764bd6931 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/func/create_ticket.php @@ -0,0 +1,52 @@ +getTUserId(); + }else{ + $author= Ticket_User::constr_ExternId($_POST['target_id'])->getTUserId(); + } + $ticket_id = Ticket::create_Ticket($title, $content, $category, $author, unserialize($_SESSION['ticket_user'])->getTUserId(),0, $_POST); + header("Location: index.php?page=show_ticket&id=".$ticket_id); + exit; + + }catch (PDOException $e) { + //ERROR: LIB DB is not online! + print_r($e); + exit; + header("Location: index.php"); + 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=create_ticket"); + exit; + } + }else{ + //ERROR: user is not logged in + header("Location: index.php"); + exit; + } + +} + diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/func/reply_on_ticket.php b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/func/reply_on_ticket.php new file mode 100644 index 000000000..36fa3abeb --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/func/reply_on_ticket.php @@ -0,0 +1,54 @@ +load_With_TId($ticket_id); + + if(($target_ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId()) || Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) ){ + + try{ + $author = unserialize($_SESSION['ticket_user'])->getTUserId(); + if(isset($_POST['Content'])){ + $content = $_POST['Content']; + }else{ + $content=""; + } + $hidden = 0; + if(isset($_POST['hidden']) && Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){ + $hidden = 1; + } + Ticket::createReply($content, $author, $ticket_id, $hidden); + + if(isset($_POST['ChangeStatus']) && isset($_POST['ChangePriority']) && Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){ + $newStatus = filter_var($_POST['ChangeStatus'], FILTER_SANITIZE_NUMBER_INT); + $newPriority = filter_var($_POST['ChangePriority'], FILTER_SANITIZE_NUMBER_INT); + Ticket::updateTicketStatusAndPriority($ticket_id,$newStatus, $newPriority, $author); + } + header("Location: ams?page=show_ticket&id=".$ticket_id); + exit; + + }catch (PDOException $e) { + //ERROR: LIB DB is not online! + print_r($e); + //header("Location: index.php"); + 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; + } + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/createticket.php b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/createticket.php new file mode 100644 index 000000000..49e2263cf --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/createticket.php @@ -0,0 +1,46 @@ +getTUserId(); + $result['ticket_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT); + $target_ticket = new Ticket(); + $target_ticket->load_With_TId($result['ticket_id']); + + if(Ticket_User::isMod(unserialize($_SESSION['ticket_user'] ))){ + if(isset($_POST['action'])){ + switch($_POST['action']){ + case "forward": + $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); + $group_id = filter_var($_POST['group'], FILTER_SANITIZE_NUMBER_INT); + $result['ACTION_RESULT'] = Ticket::forwardTicket($result['user_id'], $ticket_id, $group_id); + break; + case "assignTicket": + $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); + $result['ACTION_RESULT'] = Ticket::assignTicket($result['user_id'] , $ticket_id); + break; + case "unAssignTicket": + $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); + $result['ACTION_RESULT'] = Ticket::unAssignTicket($result['user_id'], $ticket_id); + break; + + } + } + } + + if(($target_ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId()) || Ticket_User::isMod(unserialize($_SESSION['ticket_user']) )){ + + $show_as_admin = false; + if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){ + $show_as_admin = true; + } + + $entire_ticket = Ticket::getEntireTicket( $result['ticket_id'],$show_as_admin); + Ticket_Log::createLogEntry($result['ticket_id'],unserialize($_SESSION['ticket_user'])->getTUserId(), 3); + $result['ticket_tId'] = $entire_ticket['ticket_obj']->getTId(); + $result['ticket_forwardedGroupName'] = $entire_ticket['ticket_obj']->getForwardedGroupName(); + $result['ticket_forwardedGroupId'] = $entire_ticket['ticket_obj']->getForwardedGroupId(); + $result['ticket_title'] = $entire_ticket['ticket_obj']->getTitle(); + $result['ticket_timestamp'] = $entire_ticket['ticket_obj']->getTimestamp(); + $result['ticket_status'] = $entire_ticket['ticket_obj']->getStatus(); + $result['ticket_author'] = $entire_ticket['ticket_obj']->getAuthor(); + $result['ticket_prioritytext'] = $entire_ticket['ticket_obj']->getPriorityText(); + $result['ticket_priorities'] = Ticket::getPriorityArray(); + $result['ticket_priority'] = $entire_ticket['ticket_obj']->getPriority(); + $result['ticket_statustext'] = $entire_ticket['ticket_obj']->getStatusText(); + $result['ticket_lastupdate'] = Gui_Elements::time_elapsed_string(Ticket::getLatestReply($result['ticket_id'])->getTimestamp()); + $result['ticket_category'] = $entire_ticket['ticket_obj']->getCategoryName(); + $webUser = new WebUsers(Assigned::getUserAssignedToTicket($result['ticket_tId'])); + $result['ticket_assignedToText'] = $webUser->getUsername(); + $result['ticket_assignedTo'] = Assigned::getUserAssignedToTicket($result['ticket_tId']); + $result['ticket_replies'] = Gui_Elements::make_table($entire_ticket['reply_array'], Array("getTReplyId","getContent()->getContent","getTimestamp","getAuthor()->getExternId","getAuthor()->getPermission","getHidden"), Array("tReplyId","replyContent","timestamp","authorExtern","permission","hidden")); + $i = 0; + foreach( $result['ticket_replies'] as $reply){ + $webReplyUser = new WebUsers($reply['authorExtern']); + $result['ticket_replies'][$i]['author'] = $webReplyUser->getUsername(); + $i++; + } + if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){ + $result['isMod'] = "TRUE"; + $result['statusList'] = Ticket::getStatusArray(); + $result['sGroups'] = Gui_Elements::make_table_with_key_is_id(Support_Group::getAllSupportGroups(), Array("getName"), "getSGroupId" ); + } + $result['hasInfo'] = $target_ticket->hasInfo(); + 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; + } +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/show_user.php b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/show_user.php new file mode 100644 index 000000000..3a4b2acee --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/inc/show_user.php @@ -0,0 +1,44 @@ +getUsername(); + $result['mail'] = $webUser->getEmail(); + //$info = $webUser->getInfo(); + //$result['firstName'] = $info['FirstName']; + //$result['lastName'] = $info['LastName']; + //$result['country'] = $info['Country']; + //$result['gender'] = $info['Gender']; + + $ticket_user = Ticket_User::constr_ExternId($result['target_id']); + $result['userPermission'] = $ticket_user->getPermission(); + if(Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){ + $result['isAdmin'] = "TRUE"; + } + $ticketlist = Ticket::getTicketsOf($ticket_user->getTUserId()); + + $result['ticketlist'] = Gui_Elements::make_table($ticketlist, Array("getTId","getTimestamp","getTitle","getStatus","getStatusText","getStatusText","getCategoryName"), Array("tId","timestamp","title","status","statustext","statusText","category")); + 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; + } +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.module b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.module index e935828fd..dbba16531 100644 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.module +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ryzommanage.module @@ -248,6 +248,8 @@ function ryzommanage_block_view($delta = '') } + + function _ams_handler() { @@ -547,7 +549,20 @@ function top_bar() $userId = $user->uid; if (user_is_logged_in()) { // Logged in user - return "
"; + //check permission, if user + if(ticket_user::isMod(unserialize($_SESSION['ticket_user']))){ + return " "; + + }else{ + return " "; + } + } else { return drupal_get_form('login_form'); // Not logged in @@ -1001,4 +1016,60 @@ function ryzommanage_help($path, $arg) { return '' . t("A module that handles account registration and a ticketing service regarding ryzomcore.") . '
'; break; } -} \ No newline at end of file +} + +function ryzommanage_enable() { + // Check if our field is not already created. + if (!field_info_field('firstname')) { + $field = array( + 'field_name' => 'firstname', + 'type' => 'text', + ); + field_create_field($field); + + // Create the instance on the bundle. + $instance = array( + 'field_name' => 'firstname', + 'entity_type' => 'user', + 'label' => 'First Name', + 'bundle' => 'user', + // If you don't set the "required" property then the field wont be required by default. + 'required' => FALSE, + 'settings' => array( + // Here you inform either or not you want this field showing up on the registration form. + + ), + 'widget' => array( + 'type' => 'textfield', + 'weight' => '1', + ), + ); + field_create_instance($instance); + } + + if (!field_info_field('secondname')) { + $field = array( + 'field_name' => 'secondname', + 'type' => 'text', + ); + field_create_field($field); + + // Create the instance on the bundle. + $instance = array( + 'field_name' => 'secondname', + 'entity_type' => 'user', + 'label' => 'Second Name', + 'bundle' => 'user', + // If you don't set the "required" property then the field wont be required by default. + 'required' => FALSE, + 'settings' => array( + // Here you inform either or not you want this field showing up on the registration form. + ), + 'widget' => array( + 'type' => 'textfield', + 'weight' => '1', + ), + ); + field_create_instance($instance); + } +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/createticket.tpl b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/createticket.tpl new file mode 100644 index 000000000..c1ca81e07 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/templates/createticket.tpl @@ -0,0 +1,38 @@ +{block name=content} + ++ Ticket Assigning: + {if $ticket_assignedTo eq 0} + + {else if $ticket_assignedTo eq $user_id} + + {/if} + | ++ Forward to Group: + + | + {/if} + {if isset($isMod) and $isMod eq "TRUE"}Show Ticket Log | {/if} + +Send Other Ticket | + {if $hasInfo}Show ticket Info | {/if} + +
{$success_assigned}
+ + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_UNASSIGNED"} + +{$success_unassigned}
+ + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "TICKET_NOT_EXISTING"} + +{$ticket_not_existing}
+ + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "ALREADY_ASSIGNED"} + +{$ticket_already_assigned}
+ + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "NOT_ASSIGNED"} + +{$ticket_not_assigned}
+ + {/if} + + {if isset($ACTION_RESULT) and $ACTION_RESULT eq "INVALID_SGROUP"} + +{$invalid_sgroup}
+ + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "TICKET_NOT_EXISTING"} + +{$ticket_not_existing}
+ + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_FORWARDED"} + +{$success_forwarded}
+ + {/if} + +