/**
  * CheckBeforeLoadingPageHook for Siebel
  */
 private function checkBeforeLoadingPageHookForSiebel()
 {
     $url = $_SERVER['REQUEST_URI'];
     if (Text::beginsWith($url, '/app/account/questions/detail/i_id')) {
         // check if i_id in URL is valid
         $incidentID = Url::getParameter('i_id');
         if (!$incidentID || !is_numeric($incidentID)) {
             $this->log->error('Invalid i_id#{$incidentID}', __METHOD__, array(null, $this->contact));
             Url::redirectToErrorPage(9);
         }
         // check if the linked SR has been closed
         if ($incident = RNCPHP\Incident::fetch(intval($incidentID))) {
             if ($incident->StatusWithType->Status->ID === 2) {
                 // solved
                 return;
             }
             if ($srID = $incident->CustomFields->Accelerator->siebel_sr_id) {
                 $srDetail = $this->checkServiceRequest($srID);
                 // if the status is closed, redirect to the read only page
                 if ($srDetail['STATUS'] === 'Closed' && Url::getParameter('readonly') !== "1") {
                     $this->log->debug("Redirect to read-only page", __METHOD__, array(null, $this->contact));
                     header("Location: /app/account/questions/detail/i_id/{$incidentID}/readonly/1" . Url::sessionParameter());
                     exit;
                 }
             }
         }
         return;
     }
     // sr detail page
     if (Text::beginsWith($url, '/app/account/questions/detail/sr_id') === true) {
         $srID = Url::getParameter('sr_id');
         // check SR
         $srDetail = $this->checkServiceRequest($srID);
         // check if SR has already been associated with an Incident in RN.
         // if so, redirect to the corresponding Incident detail page
         $integrationID = $srDetail['INTEGRATIONID'];
         $integrationID = explode(',', $integrationID);
         $incidentID = $integrationID[0];
         if ($incidentID) {
             $this->log->debug('Redirect to incident#{$incidentID} page', __METHOD__, array(null, $this->contact));
             header("Location: /app/account/questions/detail/i_id/{$incidentID}" . Url::sessionParameter());
             exit;
         }
         // if the status is closed, redirect to the read only page
         if ($srDetail['STATUS'] === 'Closed' && Url::getParameter('readonly') !== "1") {
             $this->log->debug("Redirect to read-only page", __METHOD__, array(null, $this->contact));
             header("Location: /app/account/questions/detail/sr_id/{$srID}/readonly/1" . Url::sessionParameter());
             exit;
         }
     }
 }
 /**
  * Execute the following check before loading page
  * - SR doesn't exist
  * - user doesn't have the right to access the SR
  * - SR has been closed
  */
 private function checkBeforeLoadingPageHookForEbs()
 {
     $url = $_SERVER['REQUEST_URI'];
     // incident detail page
     if (Text::beginsWith($url, '/app/account/questions/detail/i_id')) {
         // check if the i_id is valid
         $incidentID = Url::getParameter('i_id');
         if (!$incidentID || !is_numeric($incidentID)) {
             $this->log->error("Invalid i_id#{$incidentID}", __METHOD__, array(null, $this->contact));
             Url::redirectToErrorPage(9);
         }
         // check if the linked SR has been closed
         if ($incident = RNCPHP\Incident::fetch(intval($incidentID))) {
             if ($incident->StatusWithType->Status->ID === 2) {
                 // solved
                 return;
             }
             if ($srID = $incident->CustomFields->Accelerator->ebs_sr_id) {
                 $srDetail = $this->checkServiceRequest($srID);
                 // if the status is closed, redirect to the read only page
                 if ($srDetail['INCIDENT_STATUS'] === 'Closed' && Url::getParameter('readonly') !== "1") {
                     $this->log->debug("Redirect to read-only page", __METHOD__, array(null, $this->contact));
                     header("Location: /app/account/questions/detail/i_id/{$incidentID}/readonly/1" . Url::sessionParameter());
                     exit;
                 }
             }
         }
         return;
     }
     // sr detail page
     if (Text::beginsWith($url, '/app/account/questions/detail/sr_id')) {
         $srID = Url::getParameter('sr_id');
         // check SR
         $srDetail = $this->checkServiceRequest($srID);
         // redirect to the incident detail page if the SR has already associated with an incident
         $incidentID = $srDetail['EXTATTRIBUTE15'];
         if ($incidentID) {
             $this->log->debug("Redirect to incident#{$incidentID} page", __METHOD__, array(null, $this->contact));
             header("Location: /app/account/questions/detail/i_id/{$incidentID}" . Url::sessionParameter());
             exit;
         }
         // if the status is closed, redirect to the read only page
         if ($srDetail['INCIDENT_STATUS'] === 'Closed' && Url::getParameter('readonly') !== "1") {
             $this->log->debug("Redirect to read-only page", __METHOD__, array(null, $this->contact));
             header("Location: /app/account/questions/detail/sr_id/{$srID}/readonly/1" . Url::sessionParameter());
             exit;
         }
     }
 }
 /**
  * Get the endpoint, username and password of the current site from custom 
  * Config Verb CUSTOM_CFG_EBS_Web_Service_Endpoint.
  * @return null
  */
 function checkExtIntegrationConfigVerb()
 {
     $url = $_SERVER['REQUEST_URI'];
     if (Text::beginsWith($url, '/app/error/')) {
         return;
     }
     // check if CUSTOM_CFG_EBS_Web_Service_Endpoint is defined in the current site
     if (IS_DEVELOPMENT === true && !defined('CUSTOM_CFG_Accel_Ext_Integrations')) {
         $this->log->error('CUSTOM_CFG_' . 'Accel_Ext_Integrations is not set', __METHOD__, array(null, $this->contact));
         Url::redirectToErrorPage(13);
     }
     // get the value of config verb CUSTOM_CFG_Accel_Ext_Integrations
     $config = RNCPHP\Configuration::fetch(CUSTOM_CFG_Accel_Ext_Integrations);
     $configVerb = json_decode($config->Value, true);
     if (is_null($configVerb)) {
         $this->log->error('Unable to get the value of CUSTOM_CFG_' . 'Accel_Ext_Integrations', __METHOD__, array(null, $this->contact), $config);
         Url::redirectToErrorPage(13);
     }
     // check if current site is defined in the config rnt_host
     $server = \RightNow\Utils\Config::getConfig(OE_WEB_SERVER);
     $hosts = $configVerb['hosts'];
     if (is_null($hosts)) {
         $this->log->error('Unable to find hosts inside CUSTOM_CFG_' . 'Accel_Ext_Integrations', __METHOD__, array(null, $this->contact), var_export($configVerb, true));
         Url::redirectToErrorPage(8);
     }
     foreach ($hosts as $host) {
         if ($server === $host['rnt_host']) {
             $this->extConfigVerb = $host;
             $this->extServerType = $host['integration']['server_type'];
             $this->rntHost = $host['rnt_host'];
             $this->ebsDefaultSROwnerID = $host['integration']['ebs_default_sr_owner_id'];
             return;
         }
     }
     // if no config verb match the current host
     $this->log->error("CUSTOM_CFG_Accel_Ext_Integrations :: host name isn't included in hosts", __METHOD__, array(null, $this->contact));
     Url::redirectToErrorPage(8);
 }
Example #4
0
 private function processFields(array $fields, &$presentFields = array())
 {
     $return = array();
     foreach ($fields as $field) {
         $fieldName = $field->name;
         if (!is_string($fieldName) || $fieldName === '') {
             continue;
         }
         unset($field->name);
         $return[$fieldName] = $field;
         if ($objectName = Text::getSubstringBefore($fieldName, '.')) {
             $presentFields[$objectName] = true;
         }
     }
     return $return;
 }
Example #5
0
 public function create($productID, array $formData, $serialNumber)
 {
     if (!Framework::isValidID($productID)) {
         return $this->getResponseObject(null, null, Config::getMessage(INVALID_ID_SALES_PRODUCT_COLON_LBL));
     }
     //$resultSet = Connect\ROQL::queryObject(sprintf("SELECT SalesProduct FROM SalesProduct WHERE ID = %d And Disabled != 1 And Attributes.IsServiceProduct = 1 And Attributes.HasSerialNumber != 1 And AdminVisibleInterfaces.ID = curInterface()", $productID))->next();
     $resultSet = Connect\ROQL::queryObject(sprintf("SELECT SalesProduct FROM SalesProduct WHERE ID = %d And Disabled != 1 And Attributes.IsServiceProduct = 1 And AdminVisibleInterfaces.ID = curInterface()", $productID))->next();
     if (!($salesProduct = $resultSet->next())) {
         return $this->getResponseObject(null, null, Config::getMessage(INVALID_ID_SALES_PRODUCT_COLON_LBL));
     }
     $asset = $this->getBlank()->result;
     if ($contact = $this->getContact()) {
         $asset->Contact = $contact->ID;
     } else {
         return $this->getResponseObject(null, null, Config::getMessage(CONTACT_IS_NOT_LOGGED_IN_MSG));
     }
     if ($asset->Contact->Organization) {
         $asset->Organization = $asset->Contact->Organization->ID;
     }
     $errors = $warnings = array();
     foreach ($formData as $name => $field) {
         if (!\RightNow\Utils\Text::beginsWith($name, 'Asset')) {
             continue;
         }
         $fieldName = explode('.', $name);
         try {
             //Get the metadata about the field we're trying to set. In order to do that we have to
             //populate some of the sub-objects on the record. We don't want to touch the existing
             //record at all, so instead we'll just pass in a dummy instance.
             list(, $fieldMetaData) = ConnectUtil::getObjectField($fieldName, $this->getBlank()->result);
         } catch (\Exception $e) {
             $warnings[] = $e->getMessage();
             continue;
         }
         if (\RightNow\Utils\Validation::validate($field, $name, $fieldMetaData, $errors)) {
             $field->value = ConnectUtil::castValue($field->value, $fieldMetaData);
             if ($setFieldError = $this->setFieldValue($asset, $name, $field->value)) {
                 $errors[] = $setFieldError;
             }
         }
     }
     if ($productID !== null && ($setFieldError = $this->setFieldValue($asset, "Asset.Product", $productID))) {
         $errors[] = $setFieldError;
     }
     if ($serialNumber !== null && ($setFieldError = $this->setFieldValue($asset, "Asset.SerialNumber", $serialNumber))) {
         $errors[] = $setFieldError;
     }
     if ($errors) {
         return $this->getResponseObject(null, null, $errors);
     }
     try {
         $asset = parent::createObject($asset, SRC2_EU_ASSET);
     } catch (\Exception $e) {
         $asset = $e->getMessage();
     }
     if (!is_object($asset)) {
         return $this->getResponseObject(null, null, $asset);
     }
     return $this->getResponseObject($asset, 'is_object', null, $warnings);
 }