/** * Get the definition of a report by its name * * @param $reportName * @param api_session $sess * @throws Exception * @return simpleXmlElement */ public static function readReportDefinition($reportName, api_session $sess) { $runXml = new SimpleXMLElement('<readReport/>'); $runXml->addAttribute('returnDef', 'true'); $runXml->addChild('report', $reportName); $response = api_post::post(api_util::xmlElementToSnippet($runXml), $sess); $responseXml = new simpleXmlElement($response); if ($responseXml === false) { throw new Exception('Invalid XML response in readReportDefinition.'); } $reportDefXml = $responseXml->operation->result->data->report_definition; return $reportDefXml; }
/** * Get the effective list of permissions for a user, whether the company is configured for user-specific permissions * or role-based permissions * * @param string $userId The User ID * @param api_session $sess Connected api_session object * * @throws Exception * @return api_userPermissions */ public static function getUserPermissions($userId, api_session $sess) { $runXml = "<getUserPermissions><userId>{$userId}</userId></getUserPermissions>"; $response = api_post::post($runXml, $sess, "2.1"); $respElem = new simpleXmlElement($response); if ($respElem === false) { throw new Exception("Invalid XML response in getUserPermissions."); } $permsElem = $respElem->operation->result->data; return new api_userPermissions($permsElem); }