OEModule\PatientTicketing\controllers\DefaultController::setTicketState PHP Method

setTicketState() public method

Abstraction of managing session tracking of expanded tickets.
public setTicketState ( $ticket, $expand, boolean $unique = false )
$ticket
$expand
$unique boolean
    public function setTicketState($ticket, $expand, $unique = false)
    {
        if ($unique) {
            Yii::app()->session['patientticket_ticket_ids'] = array($ticket->id);
            return;
        }
        // add to the ticket list if it's not in there for expanding
        // remove from current list for collapsing
        $curr = Yii::app()->session['patientticket_ticket_ids'];
        if (!$curr) {
            $curr = array();
        }
        if ($expand) {
            $curr[] = $ticket->id;
        } else {
            $k = array_search($ticket->id, $curr);
            if ($k !== false) {
                unset($curr[$k]);
            }
        }
        // ensure that tickets are only referenced once, and that the list is zero indexed.
        Yii::app()->session['patientticket_ticket_ids'] = array_values(array_unique($curr));
    }