Craig Brass Systems Forum: Adding Change Department to updateTicketProperties() - Craig Brass Systems Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Adding Change Department to updateTicketProperties()

#1
User is offline   sean89 

  • Member
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 05-March 09
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.
0

#2
User is offline   sean89 

  • Member
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 05-March 09
Just got done adding this into the method but it seems that the ticket counts in Staff CP are wrong. Any ideas?
0

#3
User is offline   sean89 

  • Member
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 05-March 09
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

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;
    }


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));
}

0

#4
User is offline   Craig Brass 

  • Staff - Managing Director and Chief Software Architect
  • PipPipPip
  • Group: Management
  • Posts: 349
  • Joined: 17-January 07
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
0

#5
User is offline   sean89 

  • Member
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 05-March 09
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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users