/** * get_modified_relationships * * Get a list of the relationship records that have a date_modified value set within a specified date range. This is used to * help facilitate sync operations. The module_name should be "Users" and the related_module one of "Meetings", "Calls" and * "Contacts". * * @param xsd:string $session String of the session id * @param xsd:string $module_name String value of the primary module to retrieve relationship against * @param xsd:string $related_module String value of the related module to retrieve records off of * @param xsd:string $from_date String value in YYYY-MM-DD HH:MM:SS format of date_start range (required) * @param xsd:string $to_date String value in YYYY-MM-DD HH:MM:SS format of ending date_start range (required) * @param xsd:int $offset Integer value of the offset to begin returning records from * @param xsd:int $max_results Integer value of the max_results to return; -99 for unlimited * @param xsd:int $deleted Integer value indicating deleted column value search (defaults to 0). Set to 1 to find deleted records * @param xsd:string $module_user_id String value of the user id (optional, but defaults to SOAP session user id anyway) The module_user_id value * here ought to be the user id of the user initiating the SOAP session * @param tns:select_fields $select_fields Array value of fields to select and return as name/value pairs * @param xsd:string $relationship_name String value of the relationship name to search on * @param xsd:string $deletion_date String value in YYYY-MM-DD HH:MM:SS format for filtering on deleted records whose date_modified falls within range * this allows deleted records to be returned as well * * @return Array records that match search criteria */ function get_modified_relationships($session, $module_name, $related_module, $from_date, $to_date, $offset, $max_results, $deleted = 0, $module_user_id = '', $select_fields = array(), $relationship_name = '', $deletion_date = '') { global $beanList, $beanFiles, $current_user; $error = new SoapError(); $output_list = array(); if (empty($from_date)) { $error->set_error('invalid_call_error, missing from_date'); return array('result_count' => 0, 'next_offset' => 0, 'field_list' => $select_fields, 'entry_list' => array(), 'error' => $error->get_soap_array()); } if (empty($to_date)) { $error->set_error('invalid_call_error, missing to_date'); return array('result_count' => 0, 'next_offset' => 0, 'field_list' => $select_fields, 'entry_list' => array(), 'error' => $error->get_soap_array()); } self::$helperObject = new SugarWebServiceUtilv4_1(); if (!self::$helperObject->checkSessionAndModuleAccess($session, 'invalid_session', $module_name, 'read', 'no_access', $error)) { Log::info('End: SugarWebServiceImpl->get_modified_relationships'); return; } // if if (empty($beanList[$module_name]) || empty($beanList[$related_module])) { $error->set_error('no_module'); return array('result_count' => 0, 'next_offset' => 0, 'field_list' => $select_fields, 'entry_list' => array(), 'error' => $error->get_soap_array()); } global $current_user; if (!self::$helperObject->check_modules_access($current_user, $module_name, 'read') || !self::$helperObject->check_modules_access($current_user, $related_module, 'read')) { $error->set_error('no_access'); return array('result_count' => 0, 'next_offset' => 0, 'field_list' => $select_fields, 'entry_list' => array(), 'error' => $error->get_soap_array()); } if ($max_results > 0 || $max_results == '-99') { global $sugar_config; $sugar_config['list_max_entries_per_page'] = $max_results; } // Cast to integer $deleted = (int) $deleted; $query = "(m1.date_modified > " . db_convert("'" . $GLOBALS['db']->quote($from_date) . "'", 'datetime') . " AND m1.date_modified <= " . db_convert("'" . $GLOBALS['db']->quote($to_date) . "'", 'datetime') . " AND {0}.deleted = {$deleted})"; if (isset($deletion_date) && !empty($deletion_date)) { $query .= " OR ({0}.date_modified > " . db_convert("'" . $GLOBALS['db']->quote($deletion_date) . "'", 'datetime') . " AND {0}.date_modified <= " . db_convert("'" . $GLOBALS['db']->quote($to_date) . "'", 'datetime') . " AND {0}.deleted = 1)"; } if (!empty($current_user->id)) { $query .= " AND m2.id = '" . $GLOBALS['db']->quote($current_user->id) . "'"; } //if($related_module == 'Meetings' || $related_module == 'Calls' || $related_module = 'Contacts'){ $query = string_format($query, array('m1')); //} require_once 'soap/SoapRelationshipHelper.php'; $results = retrieve_modified_relationships($module_name, $related_module, $query, $deleted, $offset, $max_results, $select_fields, $relationship_name); $list = $results['result']; foreach ($list as $value) { $output_list[] = self::$helperObject->array_get_return_value($value, $results['table_name']); } $next_offset = $offset + count($output_list); return array('result_count' => count($output_list), 'next_offset' => $next_offset, 'entry_list' => $output_list, 'error' => $error->get_soap_array()); }
/** * get_entries_count doesn't work with custom fields * * @group 43339 */ public function testGetEntriesCountForCustomField() { $api = new SugarWebServiceImplv4_1(); $auth = $api->login(array('user_name' => self::$_user->user_name, 'password' => self::$_user->user_hash, 'version' => '.01'), 'SoapTest', array()); $assert = $api->get_entries_count($auth['id'], $this->_moduleName, $this->_customFieldName . ' LIKE \'\'', 0); $api->logout($auth['id']); $this->assertNotEquals(NULL, $assert['result_count']); }