Was wondering if there was a specific reason why the changing of departments is not provisioned into updateTicketProperties. If there was, please let me know as I am doing it now and will take that into mind.
Page 1 of 1
Adding Change Department to updateTicketProperties()
#2
Posted 10 June 2009 - 01:57 PM
Just got done adding this into the method but it seems that the ticket counts in Staff CP are wrong. Any ideas?
#3
Posted 10 June 2009 - 02:55 PM
Looks like its working. Here is the code. I have not added any validation as that is not part of my project guidelines. Please let me know if there are any bugs or if you elaborate on the code adding validation etc so I can update mine as well. I have to move on to the next piece of this API development. Hope you find this useful!
api.class.php
wsdl.php
api.class.php
CODE
public static function updateTicketProperties($user, $password, $email, $ticketId, $newStatus=0, $newPriority=0, $newDepartment=0) {
global $_SWIFT, $dbCore, $CONF;
require_once 'modules/tickets/functions_ticketmain.php';
require_once 'modules/tickets/functions_ticketcore.php';
//First we check the fields
if (!self::isApiUserValid($user, $password))
return self::ERR_INCORRECT_API_USER_CREDENTIALS;
if (!isValidEmail($email))
return self::ERR_INVALID_EMAIL;
$ticketId = (int) $ticketId;
if (($userId = getUserEmail($email)) === false)
return self::ERR_NON_EXISTENT_USER;
if ($newPriority == 0 && $newStatus == 0 && $newDepartment == 0)
return self::ERR_STATUS_AND_PRIORITY_BOTH_EMPTY;
$ticketObj = new TicketMain($ticketId, false);
if (empty($ticketObj->ticket['ticketid']))
return self::ERR_NON_EXISTENT_TICKET;
$ticket = $ticketObj->ticket;
$userArr = fetchUser($ticket['userid']);
if ($userArr['userid'] != $userId)
return self::ERR_TICKET_REQUESTED_FOR_INCORRECT_USER;
if ($newPriority != 0) {
$prioritylist = self::getPriorityList($user, $password);
$ispresent = false;
foreach ($prioritylist as $priority) {
if ($newPriority == $priority['id']) {
$ispresent = true;
break;
}
}
if (!$ispresent)
return self::ERR_NON_EXISTENT_PRIORITY;
}
if ($newStatus != 0) {
$statuslist = self::getStatusList($user, $password);
$ispresent = false;
foreach ($statuslist as $status) {
if ($newStatus == $status['id']) {
$ispresent = true;
break;
}
}
if (!$ispresent)
return self::ERR_NON_EXISTENT_STATUS;
}
if ($newPriority) $ticketObj->changePriority($newPriority);
if ($newStatus) $ticketObj->changeStatus($newStatus);
if ($newDepartment != 0) $ticketObj->moveTicket($newDepartment);
//Refresh the department count
$myDepartmentList = self::getDepartmentList($user, $password);
foreach ($myDepartmentList as $department){
$departmentList[] = $department['id'];
}
$_SWIFT["recountdep"] = $departmentList;
recountTicketDepartments();
return true;
}
global $_SWIFT, $dbCore, $CONF;
require_once 'modules/tickets/functions_ticketmain.php';
require_once 'modules/tickets/functions_ticketcore.php';
//First we check the fields
if (!self::isApiUserValid($user, $password))
return self::ERR_INCORRECT_API_USER_CREDENTIALS;
if (!isValidEmail($email))
return self::ERR_INVALID_EMAIL;
$ticketId = (int) $ticketId;
if (($userId = getUserEmail($email)) === false)
return self::ERR_NON_EXISTENT_USER;
if ($newPriority == 0 && $newStatus == 0 && $newDepartment == 0)
return self::ERR_STATUS_AND_PRIORITY_BOTH_EMPTY;
$ticketObj = new TicketMain($ticketId, false);
if (empty($ticketObj->ticket['ticketid']))
return self::ERR_NON_EXISTENT_TICKET;
$ticket = $ticketObj->ticket;
$userArr = fetchUser($ticket['userid']);
if ($userArr['userid'] != $userId)
return self::ERR_TICKET_REQUESTED_FOR_INCORRECT_USER;
if ($newPriority != 0) {
$prioritylist = self::getPriorityList($user, $password);
$ispresent = false;
foreach ($prioritylist as $priority) {
if ($newPriority == $priority['id']) {
$ispresent = true;
break;
}
}
if (!$ispresent)
return self::ERR_NON_EXISTENT_PRIORITY;
}
if ($newStatus != 0) {
$statuslist = self::getStatusList($user, $password);
$ispresent = false;
foreach ($statuslist as $status) {
if ($newStatus == $status['id']) {
$ispresent = true;
break;
}
}
if (!$ispresent)
return self::ERR_NON_EXISTENT_STATUS;
}
if ($newPriority) $ticketObj->changePriority($newPriority);
if ($newStatus) $ticketObj->changeStatus($newStatus);
if ($newDepartment != 0) $ticketObj->moveTicket($newDepartment);
//Refresh the department count
$myDepartmentList = self::getDepartmentList($user, $password);
foreach ($myDepartmentList as $department){
$departmentList[] = $department['id'];
}
$_SWIFT["recountdep"] = $departmentList;
recountTicketDepartments();
return true;
}
wsdl.php
CODE
$soapMethods['updateTicketProperties'] = array(
'input' => array( 'email' => 'xsd:string',
'ticketId' => 'xsd:int',
'newStatus' => 'xsd:int',
'newPriority'=>'xsd:int',
'newDepartment'=>'xsd:int'
),
'output' => array( 'successful' => 'xsd:boolean' ),
'desc' => 'Updates the status and/or priority of the specified ticket, returning true if successful'
);
function updateTicketProperties($user, $password, $email, $ticketId, $newStatus, $newPriority, $newDepartment) {
return processSoapResult(CBS_KayakoAPI::updateTicketProperties($user, $password, $email, $ticketId, $newStatus, $newPriority, $newDepartment));
}
'input' => array( 'email' => 'xsd:string',
'ticketId' => 'xsd:int',
'newStatus' => 'xsd:int',
'newPriority'=>'xsd:int',
'newDepartment'=>'xsd:int'
),
'output' => array( 'successful' => 'xsd:boolean' ),
'desc' => 'Updates the status and/or priority of the specified ticket, returning true if successful'
);
function updateTicketProperties($user, $password, $email, $ticketId, $newStatus, $newPriority, $newDepartment) {
return processSoapResult(CBS_KayakoAPI::updateTicketProperties($user, $password, $email, $ticketId, $newStatus, $newPriority, $newDepartment));
}
#4
Posted 10 June 2009 - 02:56 PM
This is due to the fact changing department isn't a client side function on the official user interface. We just added everything in to allow recreation of customer side functions.
Craig Brass
Managing Director and Chief Software Architect - Craig Brass Systems
Managing Director and Chief Software Architect - Craig Brass Systems
#5
Posted 10 June 2009 - 02:58 PM
QUOTE (Craig Brass @ Jun 10 2009, 10:56 AM) <{POST_SNAPBACK}>
This is due to the fact changing department isn't a client side function on the official user interface. We just added everything in to allow recreation of customer side functions.
Oh ok gotcha. We need this piece on our API as our software is what will decide who has permissions to do what.
Share this topic:
Page 1 of 1
Sign In »
Register Now!
Help

Back to top








