Back to PhocacartUser class

Method defineUser

public static
defineUser
(mixed &$user, mixed &$vendor, mixed &$ticket, mixed &$unit, mixed &$section, mixed $forcePos = 0)

Method defineUser - Source code

public static function defineUser(&$user, &$vendor, &$ticket, &$unit, &$section, $forcePos = 0)
{
    $pos = PhocacartPos::isPos($forcePos);
    $user = Factory::getUser();
    $vendor = array();
    $vendor = new stdClass();
    $vendor->id = 0;
    $ticket = array();
    $ticket = new stdClass();
    $ticket->id = 0;
    $unit = array();
    $unit = new stdClass();
    $unit->id = 0;
    $section = array();
    $section = new stdClass();
    $section->id = 0;
    if ($pos == 1) {
        // Is logged in user a vendor?
        if (!empty($user) && (int) $user->id > 0) {
            $vendor = clone $user;
            $isVendor = PhocacartVendor::isVendor($vendor);
            if ($isVendor) {
                //unset($user); cannot unset $user as we lost it for reference
                $user = array();
                $user = new stdClass();
                $ticketA = PhocacartTicket::getTicket($vendor->id);
                $ticket->id = $ticketA['ticketid'];
                $unit->id = $ticketA['unitid'];
                $section->id = $ticketA['sectionid'];
                $userId = PhocacartPos::getUserIdByVendorAndTicket($vendor->id, $ticket->id, $unit->id, $section->id);
                $user = Factory::getUser($userId);
                return true;
            } else {
                $vendor = array();
                $vendor = new stdClass();
                $vendor->id = 0;
                return false;
            }
            return false;
        }
        return false;
    }
    return false;
}