]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/SugarDependentDropdown/metadata/dependentDropdown.php
Release 6.5.0
[Github/sugarcrm.git] / include / SugarDependentDropdown / metadata / dependentDropdown.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-2012 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  * Description:
41  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
42  * Reserved. Contributor(s): ______________________________________..
43  *********************************************************************************/
44 global $app_strings; // coming from an include in a method call
45 global $current_user;
46
47
48 require_once("include/SugarRouting/SugarRouting.php");
49
50 $ie = new InboundEmail();
51 $rules = new SugarRouting($ie, $current_user);
52 $actions = $rules->getActionsDOM();
53
54 $strings = array();
55 foreach($app_strings as $k => $v) {
56         if(strpos($k, "LBL_ROUTING_") !== false) {
57                 $strings[$k] = $v;
58         }
59 }
60
61
62 $sugarDependentDropdown = array(
63         /*
64          * Turn on heavy logging and report errors
65          */
66         'debugMode' => false,
67
68         /**
69          * This is the actions' dependent dropdown metadata for Email 2.0's Rules
70          * Wizard
71          */
72         'actions' => array(
73                 /*
74                  * The array values below will be merged into all elements and handlers.
75                  * This is a good way to set a global that is overridable at the
76                  * individual element level.
77                  */
78                 'always_merge' => array(
79                         /*
80                          * This flag tells the render engine to display all elements when
81                          * called.  If set to 'false', the engine will allow 'onchange' calls to
82                          * render subsequent elements.
83                          */
84                         'force_render' => false,
85                         /*
86                          * Used by Email 2.0 - this helps zero in on the DD-type when we
87                          * merge it with a saved Rule.
88                          */
89                         'actionType'    => 'actions',
90                         /*
91                          * User defined function to call when an element's value is changed
92                          * (select type only)
93                          */
94                         'onchange'      => '',
95                 ),
96                 /*
97                  * This array will contain as many elements as there are dependencies.  It
98                  * will be iterated through.  The key is used for ordering; the SDD class
99                  * will ksort() this array
100                  */
101                 'elements' => array(
102                         /*
103                          * Initial dropdown. Define the necessaries.
104                          */
105                         'element0'      => array(
106                                 /*
107                                  * 'name' will be prepended by the 'grouping' value and a delimiter "::".  It then will be prepended by
108                                  * a numeric index in increments of 100. If the user inserts actions inbetween retrieved action rows,
109                                  * the index will be 1/2 of the delta (i. e., "50" if inserted between index 0 and index 100).
110                                  * 
111                                  * This element will have the following as it's name in the form:
112                                  *              "actionGroup::0::action0"
113                                  * Subsequent elements will have the following: 
114                                  *              "actionGroup::100::action0"
115                                  */
116                                 'name'          => 'action0',   // name of form element
117                                 /*
118                                  * The above applies to "id" in addition to:
119                                  * "id" will further be appended by ":::" and a numeric index in increments of 1 (0, 1, 2, 3, etc).  This is
120                                  * to allow us to identify which element is currently being acted upon.
121                                  * 
122                                  * The example below will ultimately have the id "actionGroup::0::action0" in the DOM.
123                                  */
124                                 'id'            => 'action0',   // id of form element - an internal index will be appended to this value 0, 100, 200, etc.
125                                 /*
126                                  * 'type' denotes what kind of form element you wish to display.  Of course "select" (drop-down) is the
127                                  * default.
128                                  * Valid values are "select" | "input" (text) | "checkbox" | "none".
129                                  */
130                                 'type'          => 'select',
131                                 /*
132                                  * If using multiple dependent-dropdowns on a single page, you
133                                  * must differentiate them via this flag.  This value is
134                                  * arbitrary, but must be different from other sets of DDs.
135                                  */
136                                 'grouping'      => 'actionGroup',
137                                 /*
138                                  * In the interests of keeping this simple, you can pass an associative array as the argument for values.
139                                  * However, you may also pass a string which will be eval()'d in JS.  You can write a custom function to
140                                  * return a Javascript object as an associative array which will be iterated over and rendered as options
141                                  * for a dropdown.  The return must be a JS object.
142                                  */
143                                 'values'        => $actions,    // assoc array of dropdown values, if a STRING, it will be eval'd to lazy load the values
144                                 /*
145                                  * The 'selected' value must match one of the keys in the above array.  If lazy-loading through a JS
146                                  * call, there is a chance race-condition that may result in the selected value not being defaulted.  In
147                                  * this case, preload the values into local memory and retrieve via a non-async JS call.
148                                  */
149                                 'selected'      => '',                  // initially selected value (key value)
150                                 /*
151                                  * This attribute should map to a JS method/function that is loaded and available.  It will be called on
152                                  * initialization and can cascade the results to this element's children (this is how Email 2.0 Rules
153                                  * Wizard works).  If force_render is set to true, this call will still be made.
154                                  */
155                                 'onchange'      => 'SUGAR.routing.handleDependentDropdown(this, \'actions\');', // javascript onchange() call
156                                 /*
157                                  * The text that can accompany this element.  Any string value is valid.  Simple HTML formatting will be
158                                  * honored (<B>, <I>, <EM>, etc.).
159                                  */
160                                 'label'         => '&nbsp;',
161                                 /*
162                                  * This attribute dictates where the above text will display relative to this element.  Valid values are
163                                  * "top" | "bottom" | "left" | "right"
164                                  */
165                                 'label_pos'     => 'left',
166                         ),
167         
168                         /*
169                          * Subsequent dropdown/form elements must contain an array keyed to dropdown1's selected value.
170                          * I.e.:
171                          * if 'values' is
172                          *              array(
173                          *                      'option1' => 'This is option one',
174                          *                      'option2' => 'This is option two',
175                          *              );
176                          * dropdown2 must contain an array 'handlers' keyed by "option1" and "option2"
177                          */
178                         'element1'      => array(
179                                 'name'          => 'action1',   // name of form element
180                                 'id'            => 'action1',   // id of form element - an internal index will be appended to this value 0, 100, 200, etc.
181                                 'label'         => '',                  // label to be displayed next/above dropdown
182                                 'label_pos'     => 'none',              // default 'left'
183                                 'grouping'      => 'actionGroup',
184                                 /*
185                                  * Correspond to the values in the preceding element for dependencies
186                                  * - will be merged with parent's values (minus 'handlers' values)
187                                  * - keys will override parent values
188                                  */
189                                 'handlers'      => array(
190                                         /*
191                                          * If the selected value is all that you are interested in,
192                                          * create blank arrays like below. In this particular case
193                                          * the form element "action1" will hold the value
194                                          * "mark_read" which will be passed when the form is
195                                          * submitted.
196                                          */
197                                         'mark_read'             => array(),
198                                         'mark_unread'   => array(),
199                                         'mark_flagged'  => array(),
200                                         /*
201                                          * If further processing is required (like more dropdowns
202                                          * or input fields), create handlers that have "onchange"
203                                          * handlers to further process subsequent elements.
204                                          * 
205                                          * See SUGAR.routing.handleDependentDropdown() found in
206                                          * "include/SugarDependentDropdown/javascript/SugarDependentDropdown.
207                                          * js" for an example of how to continue cascading the
208                                          * dropdowns.
209                                          */
210                                         'move_mail'             => array(
211                                                 //'name'                => 'move_email_select',
212                                                 'type'          => 'select', // create a 2nd order dropdown
213                                                 'values'        => 'SUGAR.routing.ui.getElementValues("move_mail");',
214                                                 'label'         => $strings['LBL_ROUTING_TO'],  // label to be displayed next/above dropdown
215                                                 'label_pos'     => 'left',      // show "to" before this dropdown the dropdown
216                                                 //'onchange'    => '', // override to prevent double-triggering of setup cascade calls
217                                         ),
218                                         'copy_mail'             => array(
219                                                 'type'          => 'select', // create a 2nd order dropdown
220                                                 'values'        => 'SUGAR.routing.ui.getElementValues("move_mail");',
221                                                 'label'         => $strings['LBL_ROUTING_TO'],  // label to be displayed next/above dropdown
222                                                 'label_pos'     => 'left',      // show "to" before this dropdown the dropdown
223                                         ),
224                                         
225                                         'forward' =>    array(
226                                                 'type'          => 'input',
227                                                 'label'         => $strings['LBL_ROUTING_TO_ADDRESS'],
228                                                 'label_pos'     => 'left',
229                                         ),
230                                         'reply' =>              array(
231                                                 'type'          => 'select',
232                                                 'label'         => $strings['LBL_ROUTING_WITH_TEMPLATE'],
233                                                 'label_pos'     => 'left',
234                                                 'values'        => 'SUGAR.routing.ui.getElementValues("email_templates");',
235                                         ),
236                                         
237                                         'delete_mail'   => array(
238                                                 'onchange'      => 'SUGAR.routing.handleDependentDropdown(this, \'actions\');', // javascript onchange() call
239                                                 'type'          => 'none',
240                                         ),
241                                         
242                                         
243                                         /* not implemented yet
244                                         'delete_bean'   => array(
245                                                 'onchange'      => 'SUGAR.routing.handleDependentDropdown(this, \'actions\');', // javascript onchange() call
246                                         ),
247                                         'delete_file'   => array(
248                                                 'onchange'      => 'SUGAR.routing.handleDependentDropdown(this, \'actions\');', // javascript onchange() call
249                                         ),*/
250                                 ),
251                         ),
252                 ),      
253         ),
254         /**
255          * This is the criteria dependent dropdown metadata for Email 2.0's Rules
256          * Wizard
257          */
258         'criteria' => array(
259                 'always_merge' => array(
260                         'force_render' => false,
261                         'grouping'      => 'criteriaGroup',
262                         'onchange'      => 'SUGAR.routing.handleDependentDropdown(this, \'criteria\');',        // javascript onchange() call
263                         'label'         => '&nbsp;',
264                         'label_pos'     => 'left',
265                         'actionType'    => 'criteria',
266                 ),
267                 'elements' => array(
268                         'element0'      => array(
269                                 'name'          => 'crit0',     // name of form element
270                                 'id'            => 'crit0id',   // id of form element - an internal index will be appended to this value 0, 100, 200, etc.
271                                 'type'          => 'select',
272                                 'values'        => 'SUGAR.routing.matchDom;',   // assoc array of dropdown values, if a STRING, it will be eval'd to lazy load the values
273                                 'selected'      => '',                  // initially selected value (key value)
274                         ),
275                         'element1' => array(
276                                 'name'          => 'crit1',
277                                 'id'            => 'crit1id',
278                                 'type'          => 'select',
279                                 'values'        => 'SUGAR.routing.matchTypeDom;',
280                                 'handlers'      => array(
281                                         'from_addr' => array(),
282                                         'to_addr' => array(),
283                                         'cc_addr' => array(),
284                                         'name' => array(),
285                                         'description' => array(),
286                                         'priority_high' => array(
287                                                 'type' => 'none',
288                                                 'label' => $app_strings['LBL_ROUTING_FLAGGED'],
289                                         ),
290                                         'priority_normal' => array(
291                                                 'type' => 'none',
292                                                 'label' => $app_strings['LBL_ROUTING_FLAGGED'],
293                                         ),
294                                         'priority_low' => array(
295                                                 'type' => 'none',
296                                                 'label' => $app_strings['LBL_ROUTING_FLAGGED'],
297                                         ),
298                                 ),
299                         ),
300                         'element2' => array(
301                                 'name'          => 'crit2',
302                                 'id'            => 'crit2id',
303                                 'type'          => 'input',
304                                 'values'        => '',
305                         ),
306                 ),
307         ),
308         /**
309          * This is the "simple" (non-cascasding, force-rendered) version of the
310          * above.  It has since been deprecated, but is useful to demonstrate
311          * how to make relatively static dependent dropdown.
312          */
313         'criteriaSimple' => array(
314                 'always_merge' => array(
315                         'force_render' => true,
316                         'grouping'      => 'criteriaGroup',
317                         'onchange'      => '',  // javascript onchange() call
318                         'label'         => '&nbsp;',
319                         'label_pos'     => 'left',
320                 ),
321                 'elements' => array(
322                         'element0'      => array(
323                                 'name'          => 'crit0',     // name of form element
324                                 'id'            => 'crit0id',   // id of form element - an internal index will be appended to this value 0, 100, 200, etc.
325                                 'type'          => 'select',
326                                 'values'        => 'SUGAR.routing.matchDom;',   // assoc array of dropdown values, if a STRING, it will be eval'd to lazy load the values
327                                 'selected'      => '',                  // initially selected value (key value)
328                         ),
329                         'element1' => array(
330                                 'name'          => 'crit1',
331                                 'id'            => 'crit1id',
332                                 'type'          => 'select',
333                                 'values'        => 'SUGAR.routing.matchTypeDom;',
334                         ),
335                         'element2' => array(
336                                 'name'          => 'crit2',
337                                 'id'            => 'crit2id',
338                                 'type'          => 'input',
339                                 'values'        => '',
340                         ),
341                 ),
342         ),
343 );