adamjakab /
SuiteCRM
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | if (!defined('sugarEntry')) define('sugarEntry', true); |
||
| 3 | /********************************************************************************* |
||
| 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
||
| 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
||
| 6 | |||
| 7 | * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd. |
||
| 8 | * Copyright (C) 2011 - 2014 Salesagility Ltd. |
||
| 9 | * |
||
| 10 | * This program is free software; you can redistribute it and/or modify it under |
||
| 11 | * the terms of the GNU Affero General Public License version 3 as published by the |
||
| 12 | * Free Software Foundation with the addition of the following permission added |
||
| 13 | * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK |
||
| 14 | * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY |
||
| 15 | * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. |
||
| 16 | * |
||
| 17 | * This program is distributed in the hope that it will be useful, but WITHOUT |
||
| 18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
||
| 19 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
||
| 20 | * details. |
||
| 21 | * |
||
| 22 | * You should have received a copy of the GNU Affero General Public License along with |
||
| 23 | * this program; if not, see http://www.gnu.org/licenses or write to the Free |
||
| 24 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
||
| 25 | * 02110-1301 USA. |
||
| 26 | * |
||
| 27 | * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, |
||
| 28 | * SW2-130, Cupertino, CA 95014, USA. or at email address [email protected]. |
||
| 29 | * |
||
| 30 | * The interactive user interfaces in modified source and object code versions |
||
| 31 | * of this program must display Appropriate Legal Notices, as required under |
||
| 32 | * Section 5 of the GNU Affero General Public License version 3. |
||
| 33 | * |
||
| 34 | * In accordance with Section 7(b) of the GNU Affero General Public License version 3, |
||
| 35 | * these Appropriate Legal Notices must retain the display of the "Powered by |
||
| 36 | * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not |
||
| 37 | * reasonably feasible for technical reasons, the Appropriate Legal Notices must |
||
| 38 | * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
||
| 39 | ********************************************************************************/ |
||
| 40 | |||
| 41 | |||
| 42 | /** |
||
| 43 | * SugarWebServiceImplv4_1.php |
||
| 44 | * |
||
| 45 | * This class is an implementation class for all the web services. Version 4_1 adds limit/off support to the |
||
| 46 | * get_relationships function. We also added the sync_get_modified_relationships function call from version |
||
| 47 | * one to facilitate querying for related meetings/calls contacts/users records. |
||
| 48 | * |
||
| 49 | */ |
||
| 50 | require_once('service/v4/SugarWebServiceImplv4.php'); |
||
| 51 | require_once('service/v4_1/SugarWebServiceUtilv4_1.php'); |
||
| 52 | |||
| 53 | class SugarWebServiceImplv4_1 extends SugarWebServiceImplv4 |
||
| 54 | { |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Class Constructor Object |
||
| 58 | * |
||
| 59 | */ |
||
| 60 | public function __construct() |
||
| 61 | { |
||
| 62 | self::$helperObject = new SugarWebServiceUtilv4_1(); |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Retrieve a collection of beans that are related to the specified bean and optionally return relationship data for those related beans. |
||
| 67 | * So in this API you can get contacts info for an account and also return all those contact's email address or an opportunity info also. |
||
| 68 | * |
||
| 69 | * @param String $session -- Session ID returned by a previous call to login. |
||
| 70 | * @param String $module_name -- The name of the module that the primary record is from. This name should be the name the module was developed under (changing a tab name is studio does not affect the name that should be passed into this method).. |
||
| 71 | * @param String $module_id -- The ID of the bean in the specified module |
||
| 72 | * @param String $link_field_name -- The name of the lnk field to return records from. This name should be the name the relationship. |
||
| 73 | * @param String $related_module_query -- A portion of the where clause of the SQL statement to find the related items. The SQL query will already be filtered to only include the beans that are related to the specified bean. |
||
| 74 | * @param Array $related_fields - Array of related bean fields to be returned. |
||
| 75 | * @param Array $related_module_link_name_to_fields_array - For every related bean returrned, specify link fields name to fields info for that bean to be returned. For ex.'link_name_to_fields_array' => array(array('name' => 'email_addresses', 'value' => array('id', 'email_address', 'opt_out', 'primary_address'))). |
||
| 76 | * @param Number $deleted -- false if deleted records should not be include, true if deleted records should be included. |
||
| 77 | * @param String $order_by -- field to order the result sets by |
||
| 78 | * @param Number $offset -- where to start in the return |
||
| 79 | * @param Number $limit -- number of results to return (defaults to all) |
||
| 80 | * @return Array 'entry_list' -- Array - The records that were retrieved |
||
| 81 | * 'relationship_list' -- Array - The records link field data. The example is if asked about accounts contacts email address then return data would look like Array ( [0] => Array ( [name] => email_addresses [records] => Array ( [0] => Array ( [0] => Array ( [name] => id [value] => 3fb16797-8d90-0a94-ac12-490b63a6be67 ) [1] => Array ( [name] => email_address [value] => [email protected] ) [2] => Array ( [name] => opt_out [value] => 0 ) [3] => Array ( [name] => primary_address [value] => 1 ) ) [1] => Array ( [0] => Array ( [name] => id [value] => 403f8da1-214b-6a88-9cef-490b63d43566 ) [1] => Array ( [name] => email_address [value] => [email protected] ) [2] => Array ( [name] => opt_out [value] => 0 ) [3] => Array ( [name] => primary_address [value] => 0 ) ) ) ) ) |
||
| 82 | * @exception 'SoapFault' -- The SOAP error, if any |
||
| 83 | */ |
||
| 84 | function get_relationships($session, $module_name, $module_id, $link_field_name, $related_module_query, $related_fields, $related_module_link_name_to_fields_array, $deleted, $order_by = '', $offset = 0, $limit = false) |
||
| 85 | { |
||
| 86 | $GLOBALS['log']->info('Begin: SugarWebServiceImpl->get_relationships'); |
||
| 87 | self::$helperObject = new SugarWebServiceUtilv4_1(); |
||
| 88 | global $beanList, $beanFiles; |
||
| 89 | $error = new SoapError(); |
||
| 90 | |||
| 91 | if (!self::$helperObject->checkSessionAndModuleAccess($session, 'invalid_session', $module_name, 'read', 'no_access', $error)) { |
||
| 92 | $GLOBALS['log']->info('End: SugarWebServiceImpl->get_relationships'); |
||
| 93 | return; |
||
| 94 | } // if |
||
| 95 | |||
| 96 | $mod = BeanFactory::getBean($module_name, $module_id); |
||
| 97 | |||
| 98 | if (!self::$helperObject->checkQuery($error, $related_module_query, $order_by)) { |
||
| 99 | $GLOBALS['log']->info('End: SugarWebServiceImpl->get_relationships'); |
||
| 100 | return; |
||
| 101 | } // if |
||
| 102 | |||
| 103 | if (!self::$helperObject->checkACLAccess($mod, 'DetailView', $error, 'no_access')) { |
||
| 104 | $GLOBALS['log']->info('End: SugarWebServiceImpl->get_relationships'); |
||
| 105 | return; |
||
| 106 | } // if |
||
| 107 | |||
| 108 | $output_list = array(); |
||
| 109 | $linkoutput_list = array(); |
||
| 110 | |||
| 111 | // get all the related modules data. |
||
| 112 | $result = self::$helperObject->getRelationshipResults($mod, $link_field_name, $related_fields, $related_module_query, $order_by, $offset, $limit); |
||
|
0 ignored issues
–
show
|
|||
| 113 | |||
| 114 | if (self::$helperObject->isLogLevelDebug()) { |
||
| 115 | $GLOBALS['log']->debug('SoapHelperWebServices->get_relationships - return data for getRelationshipResults is ' . var_export($result, true)); |
||
| 116 | } // if |
||
| 117 | if ($result) { |
||
| 118 | |||
| 119 | $list = $result['rows']; |
||
| 120 | $filterFields = $result['fields_set_on_rows']; |
||
| 121 | |||
| 122 | if (sizeof($list) > 0) { |
||
| 123 | // get the related module name and instantiate a bean for that |
||
| 124 | $submodulename = $mod->$link_field_name->getRelatedModuleName(); |
||
| 125 | $submoduletemp = BeanFactory::getBean($submodulename); |
||
| 126 | |||
| 127 | foreach($list as $row) { |
||
| 128 | $submoduleobject = @clone($submoduletemp); |
||
| 129 | // set all the database data to this object |
||
| 130 | foreach ($filterFields as $field) { |
||
| 131 | $submoduleobject->$field = $row[$field]; |
||
| 132 | } // foreach |
||
| 133 | if (isset($row['id'])) { |
||
| 134 | $submoduleobject->id = $row['id']; |
||
| 135 | } |
||
| 136 | $output_list[] = self::$helperObject->get_return_value_for_fields($submoduleobject, $submodulename, $filterFields); |
||
| 137 | if (!empty($related_module_link_name_to_fields_array)) { |
||
| 138 | $linkoutput_list[] = self::$helperObject->get_return_value_for_link_fields($submoduleobject, $submodulename, $related_module_link_name_to_fields_array); |
||
| 139 | } // if |
||
| 140 | |||
| 141 | } // foreach |
||
| 142 | } |
||
| 143 | |||
| 144 | } // if |
||
| 145 | |||
| 146 | $GLOBALS['log']->info('End: SugarWebServiceImpl->get_relationships'); |
||
| 147 | return array('entry_list'=>$output_list, 'relationship_list' => $linkoutput_list); |
||
| 148 | } |
||
| 149 | |||
| 150 | |||
| 151 | /** |
||
| 152 | * get_modified_relationships |
||
| 153 | * |
||
| 154 | * Get a list of the relationship records that have a date_modified value set within a specified date range. This is used to |
||
| 155 | * help facilitate sync operations. The module_name should be "Users" and the related_module one of "Meetings", "Calls" and |
||
| 156 | * "Contacts". |
||
| 157 | * |
||
| 158 | * @param xsd:string $session String of the session id |
||
|
0 ignored issues
–
show
The doc-type
xsd:string could not be parsed: Unknown type name "xsd:string" at position 0. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. Loading history...
|
|||
| 159 | * @param xsd:string $module_name String value of the primary module to retrieve relationship against |
||
|
0 ignored issues
–
show
The doc-type
xsd:string could not be parsed: Unknown type name "xsd:string" at position 0. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. Loading history...
|
|||
| 160 | * @param xsd:string $related_module String value of the related module to retrieve records off of |
||
|
0 ignored issues
–
show
The doc-type
xsd:string could not be parsed: Unknown type name "xsd:string" at position 0. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. Loading history...
|
|||
| 161 | * @param xsd:string $from_date String value in YYYY-MM-DD HH:MM:SS format of date_start range (required) |
||
|
0 ignored issues
–
show
The doc-type
xsd:string could not be parsed: Unknown type name "xsd:string" at position 0. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. Loading history...
|
|||
| 162 | * @param xsd:string $to_date String value in YYYY-MM-DD HH:MM:SS format of ending date_start range (required) |
||
|
0 ignored issues
–
show
The doc-type
xsd:string could not be parsed: Unknown type name "xsd:string" at position 0. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. Loading history...
|
|||
| 163 | * @param xsd:int $offset Integer value of the offset to begin returning records from |
||
|
0 ignored issues
–
show
The doc-type
xsd:int could not be parsed: Unknown type name "xsd:int" at position 0. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. Loading history...
|
|||
| 164 | * @param xsd:int $max_results Integer value of the max_results to return; -99 for unlimited |
||
|
0 ignored issues
–
show
The doc-type
xsd:int could not be parsed: Unknown type name "xsd:int" at position 0. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. Loading history...
|
|||
| 165 | * @param xsd:int $deleted Integer value indicating deleted column value search (defaults to 0). Set to 1 to find deleted records |
||
|
0 ignored issues
–
show
The doc-type
xsd:int could not be parsed: Unknown type name "xsd:int" at position 0. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. Loading history...
|
|||
| 166 | * @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 |
||
|
0 ignored issues
–
show
The doc-type
xsd:string could not be parsed: Unknown type name "xsd:string" at position 0. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. Loading history...
|
|||
| 167 | * here ought to be the user id of the user initiating the SOAP session |
||
| 168 | * @param tns:select_fields $select_fields Array value of fields to select and return as name/value pairs |
||
|
0 ignored issues
–
show
The doc-type
tns:select_fields could not be parsed: Unknown type name "tns:select_fields" at position 0. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. Loading history...
|
|||
| 169 | * @param xsd:string $relationship_name String value of the relationship name to search on |
||
|
0 ignored issues
–
show
The doc-type
xsd:string could not be parsed: Unknown type name "xsd:string" at position 0. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. Loading history...
|
|||
| 170 | * @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 |
||
|
0 ignored issues
–
show
The doc-type
xsd:string could not be parsed: Unknown type name "xsd:string" at position 0. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. Loading history...
|
|||
| 171 | * this allows deleted records to be returned as well |
||
| 172 | * |
||
| 173 | * @return Array records that match search criteria |
||
| 174 | */ |
||
| 175 | 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 = ''){ |
||
| 176 | global $beanList, $beanFiles, $current_user; |
||
| 177 | $error = new SoapError(); |
||
| 178 | $output_list = array(); |
||
| 179 | |||
| 180 | if(empty($from_date)) |
||
| 181 | { |
||
| 182 | $error->set_error('invalid_call_error, missing from_date'); |
||
| 183 | return array('result_count'=>0, 'next_offset'=>0, 'field_list'=>$select_fields, 'entry_list'=>array(), 'error'=>$error->get_soap_array()); |
||
| 184 | } |
||
| 185 | |||
| 186 | if(empty($to_date)) |
||
| 187 | { |
||
| 188 | $error->set_error('invalid_call_error, missing to_date'); |
||
| 189 | return array('result_count'=>0, 'next_offset'=>0, 'field_list'=>$select_fields, 'entry_list'=>array(), 'error'=>$error->get_soap_array()); |
||
| 190 | } |
||
| 191 | |||
| 192 | self::$helperObject = new SugarWebServiceUtilv4_1(); |
||
| 193 | if (!self::$helperObject->checkSessionAndModuleAccess($session, 'invalid_session', $module_name, 'read', 'no_access', $error)) |
||
| 194 | { |
||
| 195 | $GLOBALS['log']->info('End: SugarWebServiceImpl->get_modified_relationships'); |
||
| 196 | return; |
||
| 197 | } // if |
||
| 198 | |||
| 199 | if(empty($beanList[$module_name]) || empty($beanList[$related_module])) |
||
| 200 | { |
||
| 201 | $error->set_error('no_module'); |
||
| 202 | return array('result_count'=>0, 'next_offset'=>0, 'field_list'=>$select_fields, 'entry_list'=>array(), 'error'=>$error->get_soap_array()); |
||
| 203 | } |
||
| 204 | |||
| 205 | global $current_user; |
||
| 206 | if(!self::$helperObject->check_modules_access($current_user, $module_name, 'read') || !self::$helperObject->check_modules_access($current_user, $related_module, 'read')){ |
||
| 207 | $error->set_error('no_access'); |
||
| 208 | return array('result_count'=>0, 'next_offset'=>0, 'field_list'=>$select_fields, 'entry_list'=>array(), 'error'=>$error->get_soap_array()); |
||
| 209 | } |
||
| 210 | |||
| 211 | if($max_results > 0 || $max_results == '-99'){ |
||
| 212 | global $sugar_config; |
||
| 213 | $sugar_config['list_max_entries_per_page'] = $max_results; |
||
| 214 | } |
||
| 215 | |||
| 216 | // Cast to integer |
||
| 217 | $deleted = (int)$deleted; |
||
| 218 | $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)"; |
||
|
0 ignored issues
–
show
The function
db_convert() has been deprecated with message: use DBManager::convert() instead.
This function has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead. Loading history...
|
|||
| 219 | if(isset($deletion_date) && !empty($deletion_date)){ |
||
| 220 | $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)"; |
||
|
0 ignored issues
–
show
The function
db_convert() has been deprecated with message: use DBManager::convert() instead.
This function has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead. Loading history...
|
|||
| 221 | } |
||
| 222 | |||
| 223 | if(!empty($current_user->id)) |
||
| 224 | { |
||
| 225 | $query .= " AND m2.id = '".$GLOBALS['db']->quote($current_user->id)."'"; |
||
| 226 | } |
||
| 227 | |||
| 228 | //if($related_module == 'Meetings' || $related_module == 'Calls' || $related_module = 'Contacts'){ |
||
| 229 | $query = string_format($query, array('m1')); |
||
| 230 | //} |
||
| 231 | |||
| 232 | require_once('soap/SoapRelationshipHelper.php'); |
||
| 233 | $results = retrieve_modified_relationships($module_name, $related_module, $query, $deleted, $offset, $max_results, $select_fields, $relationship_name); |
||
| 234 | |||
| 235 | $list = $results['result']; |
||
| 236 | |||
| 237 | foreach($list as $value) |
||
| 238 | { |
||
| 239 | $output_list[] = self::$helperObject->array_get_return_value($value, $results['table_name']); |
||
| 240 | } |
||
| 241 | |||
| 242 | $next_offset = $offset + count($output_list); |
||
| 243 | |||
| 244 | return array( |
||
| 245 | 'result_count'=> count($output_list), |
||
| 246 | 'next_offset' => $next_offset, |
||
| 247 | 'entry_list' => $output_list, |
||
| 248 | 'error' => $error->get_soap_array() |
||
| 249 | ); |
||
| 250 | } |
||
| 251 | |||
| 252 | } |
||
| 253 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.