array( 'currentapp' => 'login', 'noheader' => True, 'disable_Template_class' => True ) ); include_once('../../header.inc.php'); $this->expressoVersion = substr($GLOBALS['phpgw_info']['server']['versions']['phpgwapi'],0,3); } protected function setRequest($request){ $this->request = $request; } public function getRequest(){ return $this->request; } protected function setResult($result){ $this->result = $result; } public function getResult(){ return $this->result; } protected function setId($id){ $this->id = $id; } public function getId(){ return $this->id; } protected function setParams($params){ $this->params = $params; } public function getParams(){ return $this->params; } public function getParam($param){ return $this->params->$param; } public function setError($error) { $this-> error = $error; } protected function getError() { return $this-> error; } public function post($request){ $this->setRequest($request); parse_str($request->data, &$array); $data = (object)$array; if($data){ if($data->params){ $this->setParams(json_decode($data->params)); } if($data->id) $this->setId($data->id); } } public function get($request){ $response = new Response($request); $response->code = Response::OK; $response->addHeader('content-type', 'text/html'); $response->body = "

Metodo GET nao permitido para este recurso.

"; return $response; } public function getResponse(){ $response = new Response($this->getRequest()); $response->code = Response::OK; $response->addHeader('content-type', 'application/json'); if($this->getId()) $body['id'] = $this->getId(); if($this->getResult()) $body['result'] = $this->getResult(); else throw new ResponseException("",Errors::E_UNKNOWN_ERROR); $response->body = json_encode($body); return $response; } protected function getUserProfile(){ $user_id = $GLOBALS['phpgw_info']['user']['account_id']['acl']; $acl = CreateObject('phpgwapi.acl'); $apps = $acl->get_user_applications($user_id); $contactApps = array(); foreach($apps as $app => $isEnabled){ if($isEnabled) $contactApps[] = $app; } return array( 'contactID' => $GLOBALS['phpgw_info']['user']['account_dn'], 'contactMails' => array($GLOBALS['phpgw_info']['user']['email']), 'contactPhones' => array($GLOBALS['phpgw_info']['user']['telephonenumber']), 'contactFullName' => $GLOBALS['phpgw_info']['user']['fullname'], 'contactApps' => $contactApps ); } protected function getLdapCatalog(){ if(!$this->ldapCatalog) { $catalog_config = CreateObject("contactcenter.bo_ldap_manager"); $_SESSION['phpgw_info']['expressomail']['ldap_server'] = $catalog_config ? $catalog_config->srcs[1] : null; $this->ldapCatalog = CreateObject("expressoMail1_2.ldap_functions"); } return $this->ldapCatalog; } protected function getDb(){ return $GLOBALS['phpgw']->db; } protected function isLoggedIn(){ if($this->getParam('auth') != null) { list($sessionid, $kp3) = explode(":", $this->getParam('auth')); if($GLOBALS['phpgw']->session->verify($sessionid, $kp3)){ return $sessionid; } else{ throw new ResponseException("",Errors::LOGIN_AUTH_INVALID); } } else{ throw new ResponseException("",Errors::LOGIN_NOT_LOGGED_IN); } } }