]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/QuickSearchDefaults.php
Fixed config.php files that aren't the main config.php from being included.
[Github/sugarcrm.git] / include / QuickSearchDefaults.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
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  * QuickSearchDefaults class, outputs default values for setting up quicksearch
41  *
42  * @copyright  2004-2007 SugarCRM Inc.
43  * @license    http://www.sugarcrm.com/crm/products/sugar-professional-eula.html  SugarCRM Professional End User License
44  * @since      Class available since Release 4.0
45  */
46
47 class QuickSearchDefaults {
48
49         var $form_name = 'EditView';
50         
51         function setFormName($name = 'EditView') {
52                 $this->form_name = $name;
53         }
54         
55     function getQSParent($parent = 'Accounts') {
56         global $app_strings;
57
58         $qsParent = array(
59                     'form' => $this->form_name,
60                     'method' => 'query',
61                     'modules' => array($parent),
62                     'group' => 'or',
63                     'field_list' => array('name', 'id'),
64                     'populate_list' => array('parent_name', 'parent_id'),
65                     'required_list' => array('parent_id'),
66                     'conditions' => array(array('name'=>'name','op'=>'like_custom','end'=>'%','value'=>'')),
67                     'order' => 'name',
68                     'limit' => '30',
69                     'no_match_text' => $app_strings['ERR_SQS_NO_MATCH']
70                     );
71
72         return $qsParent;
73     }
74
75     function getQSAccount($nameKey, $idKey, $billingKey = null, $shippingKey = null, $additionalFields = null) {
76
77         global $app_strings;
78
79
80         $field_list = array('name', 'id');
81         $populate_list = array($nameKey, $idKey);
82         if($billingKey != null) {
83             $field_list = array_merge($field_list, array('billing_address_street', 'billing_address_city',
84                                                            'billing_address_state', 'billing_address_postalcode', 'billing_address_country'));
85
86             $populate_list = array_merge($populate_list, array($billingKey . "_address_street", $billingKey . "_address_city",
87                                                                 $billingKey . "_address_state", $billingKey . "_address_postalcode", $billingKey . "_address_country"));
88         } //if
89
90         if($shippingKey != null) {
91             $field_list = array_merge($field_list, array('shipping_address_street', 'shipping_address_city',
92                                                            'shipping_address_state', 'shipping_address_postalcode', 'shipping_address_country'));
93
94             $populate_list = array_merge($populate_list, array($shippingKey . "_address_street", $shippingKey . "_address_city",
95                                                                 $shippingKey . "_address_state", $shippingKey . "_address_postalcode", $shippingKey . "_address_country"));
96         }
97
98         if(!empty($additionalFields) && is_array($additionalFields)) {
99            $field_list = array_merge($field_list, array_keys($additionalFields));
100            $populate_list = array_merge($populate_list, array_values($additionalFields));
101         }
102
103         $qsParent = array(
104                                         'form' => $this->form_name,
105                     'method' => 'query',
106                     'modules' => array('Accounts'),
107                     'group' => 'or',
108                     'field_list' => $field_list,
109                     'populate_list' => $populate_list,
110                     'conditions' => array(array('name'=>'name','op'=>'like_custom','end'=>'%','value'=>'')),
111                     'required_list' => array($idKey),
112                     'order' => 'name',
113                     'limit' => '30',
114                     'no_match_text' => $app_strings['ERR_SQS_NO_MATCH']
115                     );
116
117         return $qsParent;
118     }
119
120     /**
121      * getQSContact
122      * This is a customized method to handle returning in JSON notation the QuickSearch formats
123      * for searching the Contacts module for a contact name.  The method takes into account
124      * the locale settings (s = salutation, f = first name, l = last name) that are permissible.
125      * It should be noted though that any other characters present in the formatting will render
126      * this widget non-functional.
127      * @return The JSON format of a QuickSearch definition for the Contacts module
128      */
129     function getQSContact($name, $idName) {
130         global $app_strings, $locale;
131
132         $qsContact = array('form' => $this->form_name,
133                                            'method'=>'get_contact_array',
134                            'modules'=>array('Contacts'),
135                            'field_list' => array('salutation', 'first_name', 'last_name', 'id'),
136                            'populate_list' => array($name, $idName, $idName, $idName),
137                            'required_list' => array($idName),
138                            'group' => 'or',
139                            'conditions' => array(
140                                                  array('name'=>'first_name', 'op'=>'like_custom','end'=>'%','value'=>''),
141                                                  array('name'=>'last_name', 'op'=>'like_custom','end'=>'%','value'=>'')
142                                            ),
143                            'order'=>'last_name',
144                            'limit'=>'30',
145                            'no_match_text'=> $app_strings['ERR_SQS_NO_MATCH']);
146         return $qsContact;
147     }    
148     
149     function getQSUser($p_name = 'assigned_user_name', $p_id ='assigned_user_id') {
150         global $app_strings;
151
152         $qsUser = array('form' => $this->form_name,
153                                         'method' => 'get_user_array', // special method
154                         'field_list' => array('user_name', 'id'),
155                         'populate_list' => array($p_name, $p_id),
156                         'required_list' => array($p_id),
157                         'conditions' => array(array('name'=>'user_name','op'=>'like_custom','end'=>'%','value'=>'')),
158                         'limit' => '30','no_match_text' => $app_strings['ERR_SQS_NO_MATCH']);
159         return $qsUser;
160     }
161     function getQSCampaigns($c_name = 'campaign_name', $c_id = 'campaign_id') {
162         global $app_strings;
163
164         $qsCampaign = array('form' => $this->form_name,
165                                                 'method' => 'query',
166                             'modules'=> array('Campaigns'),
167                             'group' => 'or',
168                             'field_list' => array('name', 'id'),
169                             'populate_list' => array($c_name, $c_id),
170                             'conditions' => array(array('name'=>'name','op'=>'like_custom','end'=>'%','value'=>'')),
171                             'required_list' => array('campaign_id'),
172                             'order' => 'name',
173                             'limit' => '30',
174                             'no_match_text' => $app_strings['ERR_SQS_NO_MATCH']);
175         return $qsCampaign;
176     }
177
178     
179     /**
180      * Loads Quick Search Object for any object (if suitable method is defined)
181      *
182      * @param string $module the given module we want to load the vardefs for
183      * @param string $object the given object we wish to load the vardefs for
184      * @param string $relationName the name of the relation between entities
185      * @param type $nameField the name of the field to populate
186      * @param type $idField the id of the field to populate
187      */
188     function loadQSObject($module, $object, $relationName, $nameField, $idField)
189     {
190         $result = array();
191         VardefManager::loadVardef($module, $object);
192         if (isset($GLOBALS['dictionary'][$object]['relationships']) && array_key_exists($relationName, $GLOBALS['dictionary'][$object]['relationships']))
193         {
194             if (method_exists($this, 'getQS' . $module))
195             {
196                 $result = $this->{'getQS' . $module};
197             } elseif (method_exists($this, 'getQS' . $object))
198             {
199                 $result = $this->{'getQS' . $object};
200             }
201         } else
202         {
203             if (method_exists($this, 'getQS' . $module))
204             {
205                 $result = $this->{'getQS' . $module}($nameField, $idField);
206             } elseif (method_exists($this, 'getQS' . $object))
207             {
208                 $result = $this->{'getQS' . $object}($nameField, $idField);
209             }
210         }
211         return $result;
212     }
213
214     // BEGIN QuickSearch functions for 4.5.x backwards compatibility support
215     function getQSScripts() {
216                 global $sugar_version, $sugar_config, $theme;
217                 $qsScripts = '<script type="text/javascript">sqsWaitGif = "' . SugarThemeRegistry::current()->getImageURL('sqsWait.gif') . '";</script>
218                 <script type="text/javascript" src="'. getJSPath('include/javascript/quicksearch.js') . '"></script>';
219                 return $qsScripts;
220         }
221
222         function getQSScriptsNoServer() {
223                 return $this->getQSScripts();
224         }
225
226         function getQSScriptsJSONAlreadyDefined() {
227                 global $sugar_version, $sugar_config, $theme;
228                 $qsScriptsJSONAlreadyDefined = '<script type="text/javascript">sqsWaitGif = "' . SugarThemeRegistry::current()->getImageURL('sqsWait.gif') . '";</script><script type="text/javascript" src="' . getJSPath('include/javascript/quicksearch.js') . '"></script>';
229                 return $qsScriptsJSONAlreadyDefined;
230         }
231     // END QuickSearch functions for 4.5.x backwards compatibility support
232 }
233
234 ?>