function getData() { $this->data['js']['dqaWidgetType'] = WIDGET_TYPE_CCL; $this->data['js']['dqaInsertType'] = DQA_WIDGET_STATS; $this->data['js']['avail_type'] = PROACTIVE_CHAT_AVAIL_TYPE_SESSIONS; list($this->data['js']['prod'], $this->data['js']['cat']) = $this->getProductCategoryValues(); $this->data['js']['interface_id'] = \RightNow\Api::intf_id(); $profile = $this->CI->session->getProfile(true); if ($profile !== null) { $contactID = $profile->contactID; if ($contactID > 0) { $this->data['js']['c_id'] = $contactID; $organizationID = $profile->orgID; if ($organizationID > 0) { $this->data['js']['org_id'] = $organizationID; } $this->data['js']['contact_email'] = $profile->email; $this->data['js']['contact_fname'] = $profile->firstName; $this->data['js']['contact_lname'] = $profile->lastName; } } $linkUrl = $this->data['attrs']['chat_login_page']; if (!$this->data['attrs']['initiate_by_event'] && $this->data['attrs']['enable_availability_check']) { $this->processDataFromCheckChatQueue($linkUrl); } if ($this->data['attrs']['auto_detect_incident'] && ($incidentID = Url::getParameter('i_id'))) { $linkUrl .= "/i_id/{$incidentID}"; } $linkUrl .= '/request_source/' . CHATS_REQUEST_SOURCE_CCL; $this->data['js']['link_url'] = $linkUrl; $this->CI->model('Clickstream')->insertWidgetStats($this->data['js']['dqaInsertType'], (object) array('w' => (string) $this->data['js']['dqaWidgetType'], 'hit' => 1)); }
public function sendForm($formData, $listOfUpdateIDs = array(), $smartAssistant = false) { if ($tokenError = $this->verifyFormToken()) { return $tokenError; } $actions = array(); $processActions = function ($type, $action, $response) { return array($type => $response->result ?: $response->errors, "{$type}{$action}" => $response->errors ? false : true); }; $formData = $this->processFields($formData, $presentFields); if (!$formData || !array_intersect(array_keys($presentFields), array_keys(Connect::getSupportedObjects(), 'read,write'))) { Api::phpoutlog("The form did not contain any fields with names of the Connect objects for which we have read and write support. Fields present: " . var_export($presentFields, true)); return $this->getResponseObject(null, null, Config::getMessage(ERROR_REQUEST_ACTION_COMPLETED_MSG)); } if ($presentFields['Contact']) { //Contact update if (Framework::isLoggedIn()) { $result = $this->CI->model('Contact')->update($this->CI->session->getProfileData('contactID'), $formData); $action = 'Updated'; } else { if ($formData['Contact.Emails.PRIMARY.Address'] && $formData['Contact.Emails.PRIMARY.Address']->value && $presentFields['Incident']) { $existingContact = $this->CI->model('Contact')->lookupContactByEmail($formData['Contact.Emails.PRIMARY.Address']->value, $formData['Contact.Name.First'] ? $formData['Contact.Name.First']->value : null, $formData['Contact.Name.Last'] ? $formData['Contact.Name.Last']->value : null)->result; if ($existingContact) { $formData['Incident.PrimaryContact'] = $existingContact; } else { $result = $this->CI->model('Contact')->create($formData, true); if ($result->result && $result->result->ID) { $formData['Incident.PrimaryContact'] = $result->result; } $action = 'Created'; } } else { $result = $this->CI->model('Contact')->create($formData, true); $action = 'Created'; } } if ($action) { $actions += $processActions('contact', $action, $result); } } if ($presentFields['Incident']) { if ($incidentIDToUpdate = $listOfUpdateIDs['i_id']) { $result = $this->CI->model('Incident')->update($incidentIDToUpdate, $formData); $action = 'Updated'; } else { $result = $this->CI->model('Incident')->create($formData, $smartAssistant); $action = 'Created'; } $actions += $processActions('incident', $action, $result); } if ($presentFields['Asset']) { $productID = $listOfUpdateIDs['product_id']; $serialNumber = $listOfUpdateIDs['serial_no']; if ($assetIDToUpdate = $listOfUpdateIDs['asset_id']) { if ($serialNumber !== null) { $serialNumber = urldecode($serialNumber); } $result = $this->CI->model('custom/AssetExtn')->create($productID, $formData, $serialNumber); $action = 'Updated'; } else { $result = $this->CI->model('custom/AssetExtn')->create($productID, $formData, $serialNumber); $action = 'Created'; } $actions += $processActions('asset', $action, $result); } return $this->getStatus($actions); }