]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - service/v2_1/SugarWebServiceImplv2_1.php
Release 6.4.0
[Github/sugarcrm.git] / service / v2_1 / SugarWebServiceImplv2_1.php
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-2011 SugarCRM Inc.
6  * 
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Affero General Public License version 3 as published by the
9  * Free Software Foundation with the addition of the following permission added
10  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13  * 
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
17  * details.
18  * 
19  * You should have received a copy of the GNU Affero General Public License along with
20  * this program; if not, see http://www.gnu.org/licenses or write to the Free
21  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  * 02110-1301 USA.
23  * 
24  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26  * 
27  * The interactive user interfaces in modified source and object code versions
28  * of this program must display Appropriate Legal Notices, as required under
29  * Section 5 of the GNU Affero General Public License version 3.
30  * 
31  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32  * these Appropriate Legal Notices must retain the display of the "Powered by
33  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34  * technical reasons, the Appropriate Legal Notices must display the words
35  * "Powered by SugarCRM".
36  ********************************************************************************/
37
38
39 /**
40  * This class is an implemenatation class for all the rest services
41  */
42 require_once('service/core/SugarWebServiceImpl.php');
43
44 class SugarWebServiceImplv2_1 extends SugarWebServiceImpl
45 {
46         /**
47          * Retrieve a list of beans.  This is the primary method for getting list of SugarBeans from Sugar using the SOAP API.
48          *
49          * @param String $session -- Session ID returned by a previous call to login.
50          * @param String $module_name -- The name of the module to return records 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)..
51          * @param String $query -- SQL where clause without the word 'where'
52          * @param String $order_by -- SQL order by clause without the phrase 'order by'
53          * @param integer $offset -- The record offset to start from.
54          * @param Array  $select_fields -- A list of the fields to be included in the results. This optional parameter allows for only needed fields to be retrieved.
55          * @param Array $link_name_to_fields_array -- A list of link_names and for each link_name, what fields value to be returned. For ex.'link_name_to_fields_array' => array(array('name' =>  'email_addresses', 'value' => array('id', 'email_address', 'opt_out', 'primary_address')))
56          * @param integer $max_results -- The maximum number of records to return.  The default is the sugar configuration value for 'list_max_entries_per_page'
57          * @param integer $deleted -- false if deleted records should not be include, true if deleted records should be included.
58          * @return Array 'result_count' -- integer - The number of records returned
59          *               'next_offset' -- integer - The start of the next page (This will always be the previous offset plus the number of rows returned.  It does not indicate if there is additional data unless you calculate that the next_offset happens to be closer than it should be.
60          *               'entry_list' -- Array - The records that were retrieved
61          *                       'relationship_list' -- Array - The records link field data. The example is if asked about accounts 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] => hr.kid.qa@example.com ) [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] => kid.hr@example.name ) [2] => Array ( [name] => opt_out [value] => 0 ) [3] => Array ( [name] => primary_address [value] => 0 ) ) ) ) )
62          * @exception 'SoapFault' -- The SOAP error, if any
63          */
64         public function get_entry_list($session, $module_name, $query, $order_by,$offset, $select_fields, $link_name_to_fields_array, $max_results, $deleted )
65         {
66                 $result = parent::get_entry_list($session, $module_name, $query, $order_by,$offset, $select_fields, $link_name_to_fields_array, $max_results, $deleted );
67                 if(empty($result)) {
68                     return null;
69                 }
70                 $relationshipList = $result['relationship_list'];
71                 $returnRelationshipList = array();
72                 foreach($relationshipList as $rel){
73                         $link_output = array();
74                         foreach($rel as $row){
75                                 $rowArray = array();
76                                 foreach($row['records'] as $record){
77                                         $rowArray[]['link_value'] = $record;
78                                 }
79                                 $link_output[] = array('name' => $row['name'], 'records' => $rowArray);
80                         }
81                         $returnRelationshipList[]['link_list'] = $link_output;
82                 }
83                 $result['relationship_list'] = $returnRelationshipList;
84                 return $result;
85         } // fn
86 }