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.
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.
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
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
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.
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.
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 ********************************************************************************/
38 /*********************************************************************************
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
48 require_once("include/SugarRouting/SugarRouting.php");
50 $ie = new InboundEmail();
51 $rules = new SugarRouting($ie, $current_user);
52 $actions = $rules->getActionsDOM();
55 foreach($app_strings as $k => $v) {
56 if(strpos($k, "LBL_ROUTING_") !== false) {
62 $sugarDependentDropdown = array(
64 * Turn on heavy logging and report errors
69 * This is the actions' dependent dropdown metadata for Email 2.0's Rules
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.
78 'always_merge' => array(
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.
84 'force_render' => false,
86 * Used by Email 2.0 - this helps zero in on the DD-type when we
87 * merge it with a saved Rule.
89 'actionType' => 'actions',
91 * User defined function to call when an element's value is changed
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
103 * Initial dropdown. Define the necessaries.
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).
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"
116 'name' => 'action0', // name of form element
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.
122 * The example below will ultimately have the id "actionGroup::0::action0" in the DOM.
124 'id' => 'action0', // id of form element - an internal index will be appended to this value 0, 100, 200, etc.
126 * 'type' denotes what kind of form element you wish to display. Of course "select" (drop-down) is the
128 * Valid values are "select" | "input" (text) | "checkbox" | "none".
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.
136 'grouping' => 'actionGroup',
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.
143 'values' => $actions, // assoc array of dropdown values, if a STRING, it will be eval'd to lazy load the values
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.
149 'selected' => '', // initially selected value (key value)
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.
155 'onchange' => 'SUGAR.routing.handleDependentDropdown(this, \'actions\');', // javascript onchange() call
157 * The text that can accompany this element. Any string value is valid. Simple HTML formatting will be
158 * honored (<B>, <I>, <EM>, etc.).
162 * This attribute dictates where the above text will display relative to this element. Valid values are
163 * "top" | "bottom" | "left" | "right"
165 'label_pos' => 'left',
169 * Subsequent dropdown/form elements must contain an array keyed to dropdown1's selected value.
173 * 'option1' => 'This is option one',
174 * 'option2' => 'This is option two',
176 * dropdown2 must contain an array 'handlers' keyed by "option1" and "option2"
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',
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
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
197 'mark_read' => array(),
198 'mark_unread' => array(),
199 'mark_flagged' => array(),
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.
205 * See SUGAR.routing.handleDependentDropdown() found in
206 * "include/SugarDependentDropdown/javascript/SugarDependentDropdown.
207 * js" for an example of how to continue cascading the
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
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
227 'label' => $strings['LBL_ROUTING_TO_ADDRESS'],
228 'label_pos' => 'left',
232 'label' => $strings['LBL_ROUTING_WITH_TEMPLATE'],
233 'label_pos' => 'left',
234 'values' => 'SUGAR.routing.ui.getElementValues("email_templates");',
237 'delete_mail' => array(
238 'onchange' => 'SUGAR.routing.handleDependentDropdown(this, \'actions\');', // javascript onchange() call
243 /* not implemented yet
244 'delete_bean' => array(
245 'onchange' => 'SUGAR.routing.handleDependentDropdown(this, \'actions\');', // javascript onchange() call
247 'delete_file' => array(
248 'onchange' => 'SUGAR.routing.handleDependentDropdown(this, \'actions\');', // javascript onchange() call
255 * This is the criteria dependent dropdown metadata for Email 2.0's Rules
259 'always_merge' => array(
260 'force_render' => false,
261 'grouping' => 'criteriaGroup',
262 'onchange' => 'SUGAR.routing.handleDependentDropdown(this, \'criteria\');', // javascript onchange() call
264 'label_pos' => 'left',
265 'actionType' => 'criteria',
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.
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)
279 'values' => 'SUGAR.routing.matchTypeDom;',
281 'from_addr' => array(),
282 'to_addr' => array(),
283 'cc_addr' => array(),
285 'description' => array(),
286 'priority_high' => array(
288 'label' => $app_strings['LBL_ROUTING_FLAGGED'],
290 'priority_normal' => array(
292 'label' => $app_strings['LBL_ROUTING_FLAGGED'],
294 'priority_low' => array(
296 'label' => $app_strings['LBL_ROUTING_FLAGGED'],
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.
313 'criteriaSimple' => array(
314 'always_merge' => array(
315 'force_render' => true,
316 'grouping' => 'criteriaGroup',
317 'onchange' => '', // javascript onchange() call
319 'label_pos' => 'left',
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.
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)
333 'values' => 'SUGAR.routing.matchTypeDom;',