function portal_get_entry_list_limited($session, $module_name, $where, $order_by, $select_fields, $row_offset, $limit) { global $beanList, $beanFiles, $portal_modules; $error = new SoapError(); if (!portal_validate_authenticated($session)) { $error->set_error('invalid_session'); return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array()); } if ($_SESSION['type'] == 'lead') { $error->set_error('no_access'); return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array()); } if (empty($beanList[$module_name])) { $error->set_error('no_module'); return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array()); } if ($module_name == 'Cases') { //if the related cases have not yet been loaded into the session object, //then call the methods that will load the cases related to the contact/accounts for this user if (!isset($_SESSION['viewable'][$module_name])) { //retrieve the contact/account id's for this user $c = get_contacts_in(); $a = get_accounts_in(); if (!empty($c)) { get_cases_in_contacts($c); } if (!empty($a)) { get_cases_in_accounts($a); } } $sugar = new aCase(); $list = array(); //if no Cases have been loaded into the session as viewable, then do not issue query, just return empty list //issuing a query with no cases loaded in session will return ALL the Cases, which is not a good thing if (!empty($_SESSION['viewable'][$module_name])) { $list = get_related_list(get_module_in($module_name), new aCase(), $where, $order_by, $row_offset, $limit); } } else { if ($module_name == 'Contacts') { $sugar = new Contact(); $list = get_related_list(get_module_in($module_name), new Contact(), $where, $order_by); } else { if ($module_name == 'Accounts') { $sugar = new Account(); $list = get_related_list(get_module_in($module_name), new Account(), $where, $order_by); } else { if ($module_name == 'Bugs') { //if the related bugs have not yet been loaded into the session object, //then call the methods that will load the bugs related to the contact/accounts for this user if (!isset($_SESSION['viewable'][$module_name])) { //retrieve the contact/account id's for this user $c = get_contacts_in(); $a = get_accounts_in(); if (!empty($c)) { get_bugs_in_contacts($c); } if (!empty($a)) { get_bugs_in_accounts($a); } } $list = array(); //if no Bugs have been loaded into the session as viewable, then do not issue query, just return empty list //issuing a query with no bugs loaded in session will return ALL the Bugs, which is not a good thing if (!empty($_SESSION['viewable'][$module_name])) { $list = get_related_list(get_module_in($module_name), new Bug(), $where, $order_by, $row_offset, $limit); } } else { if ($module_name == 'KBDocuments') { } else { if ($module_name == 'FAQ') { } else { $error->set_error('no_module_support'); return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array()); } } } } } } $output_list = array(); $field_list = array(); foreach ($list as $value) { //$loga->fatal("Adding another account to the list"); $output_list[] = get_return_value($value, $module_name); $_SESSION['viewable'][$module_name][$value->id] = $value->id; if (empty($field_list)) { $field_list = get_field_list($value); } } $output_list = filter_return_list($output_list, $select_fields, $module_name); $field_list = filter_field_list($field_list, $select_fields, $module_name); return array('result_count' => sizeof($output_list), 'next_offset' => 0, 'field_list' => $field_list, 'entry_list' => $output_list, 'error' => $error->get_soap_array()); }
function portal_set_newsletters($session, $subscribe_ids, $unsubscribe_ids) { global $beanList, $beanFiles; $error = new SoapError(); if (!portal_validate_authenticated($session)) { $error->set_error('invalid_session'); return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array()); } require_once 'modules/Campaigns/utils.php'; $contact = new Contact(); $contact->retrieve($_SESSION['user_id']); if (!empty($contact->id)) { foreach ($subscribe_ids as $campaign_id) { subscribe($campaign_id, null, $contact, true); } foreach ($unsubscribe_ids as $campaign_id) { unsubscribe($campaign_id, $contact); } } return $error->get_soap_array(); }
function portal_get_module_fields($session, $module_name) { global $beanList, $beanFiles, $portal_modules, $valid_modules_for_contact; $error = new SoapError(); $module_fields = array(); if (!portal_validate_authenticated($session)) { $error->set_error('invalid_session'); $error->description .= $session; return array('module_name' => $module_name, 'module_fields' => $module_fields, 'error' => $error->get_soap_array()); } if ($_SESSION['type'] == 'lead' && $module_name != 'Leads') { $error->set_error('no_access'); return array('module_name' => $module_name, 'module_fields' => $module_fields, 'error' => $error->get_soap_array()); } if (empty($beanList[$module_name])) { $error->set_error('no_module'); return array('module_name' => $module_name, 'module_fields' => $module_fields, 'error' => $error->get_soap_array()); } if (($_SESSION['type'] == 'portal' || $_SESSION['type'] == 'contact') && !key_exists($module_name, $valid_modules_for_contact)) { $error->set_error('no_module'); return array('module_name' => $module_name, 'module_fields' => $module_fields, 'error' => $error->get_soap_array()); } $class_name = $beanList[$module_name]; require_once $beanFiles[$class_name]; $seed = new $class_name(); $seed->fill_in_additional_detail_fields(); return get_return_module_fields($seed, $module_name, $error->get_soap_array()); }
function portal_get_entry_list_limited($session, $module_name, $where, $order_by, $select_fields, $row_offset, $limit) { global $beanList, $beanFiles, $portal_modules; $error = new SoapError(); if (!portal_validate_authenticated($session)) { $error->set_error('invalid_session'); return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array()); } if ($_SESSION['type'] == 'lead') { $error->set_error('no_access'); return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array()); } if (empty($beanList[$module_name])) { $error->set_error('no_module'); return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array()); } if ($module_name == 'Cases') { //if the related cases have not yet been loaded into the session object, //then call the methods that will load the cases related to the contact/accounts for this user if (!isset($_SESSION['viewable'][$module_name])) { //retrieve the contact/account id's for this user $c = get_contacts_in(); $a = get_accounts_in(); if (!empty($c)) { get_cases_in_contacts($c); } if (!empty($a)) { get_cases_in_accounts($a); } } $sugar = BeanFactory::getBean('Cases'); $list = array(); //if no Cases have been loaded into the session as viewable, then do not issue query, just return empty list //issuing a query with no cases loaded in session will return ALL the Cases, which is not a good thing if (!empty($_SESSION['viewable'][$module_name])) { $list = get_related_list(get_module_in($module_name), BeanFactory::getBean('Cases'), $where, $order_by, $row_offset, $limit); } } else { if ($module_name == 'Contacts') { $sugar = BeanFactory::getBean('Contacts'); $list = get_related_list(get_module_in($module_name), BeanFactory::getBean('Contacts'), $where, $order_by); } else { if ($module_name == 'Accounts') { $sugar = BeanFactory::getBean('Accounts'); $list = get_related_list(get_module_in($module_name), BeanFactory::getBean('Accounts'), $where, $order_by); } else { if ($module_name == 'Bugs') { //if the related bugs have not yet been loaded into the session object, //then call the methods that will load the bugs related to the contact/accounts for this user if (!isset($_SESSION['viewable'][$module_name])) { //retrieve the contact/account id's for this user $c = get_contacts_in(); $a = get_accounts_in(); if (!empty($c)) { get_bugs_in_contacts($c); } if (!empty($a)) { get_bugs_in_accounts($a); } } $list = array(); //if no Bugs have been loaded into the session as viewable, then do not issue query, just return empty list //issuing a query with no bugs loaded in session will return ALL the Bugs, which is not a good thing if (!empty($_SESSION['viewable'][$module_name])) { $list = get_related_list(get_module_in($module_name), BeanFactory::getBean('Bugs'), $where, $order_by, $row_offset, $limit); } } else { if ($module_name == 'KBDocuments') { $sugar = BeanFactory::getBean('KBDocuments'); $sugar->disable_row_level_security = true; $keywords = array(); //Check if there was a LIKE or = clause built. If so, the key/value pairs $where = str_replace("\\'", "<##@comma@##>", $where); if (preg_match_all("/kbdocuments[\\.]([^\\s]*?)[\\s]+(LIKE|=)[\\s]+[\\'](.*?)[%][\\']/si", $where, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $value = str_replace("<##@comma@##>", "\\'", $match[3]); $keywords[$match[1]] = $value; } } $where = ""; $result = create_portal_list_query($sugar, $order_by, $where, $keywords, $row_offset, $limit); $list = array(); while ($row = $sugar->db->fetchByAssoc($result)) { $id = $row['id']; //$list[] = $id; $record = BeanFactory::getBean('KBDocuments', $id, array("disable_row_level_security" => true)); $record->fill_in_additional_list_fields(); $list[] = $record; } } else { if ($module_name == 'FAQ') { $sugar = BeanFactory::getBean('KBDocuments'); preg_match("/kbdocuments.tags[\\s]=[\\s]+[(][\\'](.*?)[\\'][)]/si", $where, $matches); //Use KBDocuments/SearchUtils.php //ToDo: Set Global ID for FAQ somewhere, can't assume it's faq1 $list = get_faq_list($matches[1], $sugar); } else { $error->set_error('no_module_support'); return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array()); } } } } } } $output_list = array(); $field_list = array(); foreach ($list as $value) { $output_list[] = get_return_value($value, $module_name); $_SESSION['viewable'][$module_name][$value->id] = $value->id; if (empty($field_list)) { $field_list = get_field_list($value); } } $output_list = filter_return_list($output_list, $select_fields, $module_name); $field_list = filter_field_list($field_list, $select_fields, $module_name); return array('result_count' => sizeof($output_list), 'next_offset' => 0, 'field_list' => $field_list, 'entry_list' => $output_list, 'error' => $error->get_soap_array()); }
function portal_get_kbdocument_attachment($session, $id) { $error = new SoapError(); if (!portal_validate_authenticated($session)) { $error->set_error('invalid_session'); return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array()); } require_once 'modules/KBDocuments/KBDocumentSoap.php'; $ns = new KBDocumentSoap($id); $file = $ns->retrieveFile($id); if ($file == -1) { $error->set_error('no_file'); $file = ''; } return array('note_attachment' => array('id' => $id, 'filename' => $ns->retrieveFileName($id), 'file' => $file), 'error' => $error->get_soap_array()); }
function portal_get_entry_list_limited($session, $module_name, $where, $order_by, $select_fields, $row_offset, $limit) { global $beanList, $beanFiles, $portal_modules; $error = new SoapError(); if (!portal_validate_authenticated($session)) { $error->set_error('invalid_session'); return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array()); } if ($_SESSION['type'] == 'lead') { $error->set_error('no_access'); return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array()); } if (empty($beanList[$module_name])) { $error->set_error('no_module'); return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array()); } if ($module_name == 'Cases') { if (!isset($_SESSION['viewable'][$module_name])) { get_cases_in_contacts(get_contacts_in()); get_cases_in_accounts(get_accounts_in()); } $sugar = new aCase(); $list = get_related_list(get_module_in($module_name), new aCase(), $where, $order_by, $row_offset, $limit); } else { if ($module_name == 'Contacts') { $sugar = new Contact(); $list = get_related_list(get_module_in($module_name), new Contact(), $where, $order_by); } else { if ($module_name == 'Accounts') { $sugar = new Account(); $list = get_related_list(get_module_in($module_name), new Account(), $where, $order_by); } else { if ($module_name == 'Bugs') { if (!isset($_SESSION['viewable'][$module_name])) { get_bugs_in_contacts(get_contacts_in()); get_bugs_in_accounts(get_accounts_in()); } $list = get_related_list(get_module_in($module_name), new Bug(), $where, $order_by, $row_offset, $limit); } else { if ($module_name == 'KBDocuments') { } else { if ($module_name == 'FAQ') { } else { $error->set_error('no_module_support'); return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array()); } } } } } } $output_list = array(); $field_list = array(); foreach ($list as $value) { //$loga->fatal("Adding another account to the list"); $output_list[] = get_return_value($value, $module_name); $_SESSION['viewable'][$module_name][$value->id] = $value->id; if (empty($field_list)) { $field_list = get_field_list($value); } } $output_list = filter_return_list($output_list, $select_fields, $module_name); $field_list = filter_field_list($field_list, $select_fields, $module_name); return array('result_count' => sizeof($output_list), 'next_offset' => 0, 'field_list' => $field_list, 'entry_list' => $output_list, 'error' => $error->get_soap_array()); }