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 require_once('include/formbase.php');
40 $focus = new Scheduler();
41 $focus = populateFromPost('', $focus);
43 ///////////////////////////////////////////////////////////////////////////////
45 if(!isset($_REQUEST['adv_interval']) || $_REQUEST['adv_interval'] == 'false' || $_REQUEST['adv_interval'] == '0') {
47 $xtDays = array(1 => 'mon',
55 if( (isset($_REQUEST['mon']) && $_REQUEST['mon'] == 'true') &&
56 (isset($_REQUEST['tue']) && $_REQUEST['tue'] == 'true') &&
57 (isset($_REQUEST['wed']) && $_REQUEST['wed'] == 'true') &&
58 (isset($_REQUEST['thu']) && $_REQUEST['thu'] == 'true') &&
59 (isset($_REQUEST['fri']) && $_REQUEST['fri'] == 'true') &&
60 (isset($_REQUEST['sat']) && $_REQUEST['sat'] == 'true') &&
61 (isset($_REQUEST['sun']) && $_REQUEST['sun'] == 'true') ) {
62 $_REQUEST['day_of_week'] = '*';
65 foreach($xtDays as $k => $day) {
66 if(isset($_REQUEST[$day]) && $_REQUEST[$day] == 'true') {
67 if($day_string != '') {
73 $_REQUEST['day_of_week'] = $day_string;
77 if($_REQUEST['basic_period'] == 'min') {
78 $_REQUEST['mins'] = '*/'.$_REQUEST['basic_interval'];
79 $_REQUEST['hours'] = '*';
81 // Bug # 44933 - hours cannot be greater than 23
82 if ($_REQUEST['basic_interval'] < 24) {
83 $_REQUEST['hours'] = '*/'.$_REQUEST['basic_interval'];
85 $_REQUEST['hours'] = '0'; // setting it to run midnight every 24 hours
87 $_REQUEST['mins'] = '0'; // on top of the hours
91 //// END USE_ADV override
92 ///////////////////////////////////////////////////////////////////////////////
93 $focus->job_interval = $_REQUEST['mins']."::".$_REQUEST['hours']."::".$_REQUEST['day_of_month']."::".$_REQUEST['months']."::".$_REQUEST['day_of_week'];
94 // deal with job types
96 if ( ($_REQUEST['job_function'] == 'url::') && ($_REQUEST['job_url'] == '' || $_REQUEST['job_url'] == 'http://') ) {
97 $GLOBALS['log']->fatal('Scheduler save did not get a job_url or job_function');
98 } elseif ( ($_REQUEST['job_function'] != 'url::') && ($_REQUEST['job_url'] != '' && $_REQUEST['job_url'] != 'http://') ) {
99 $GLOBALS['log']->fatal('Scheduler got both a job_url and job_function');
102 if ( ($_REQUEST['job_function'] != 'url::')) {
103 $focus->job = $_REQUEST['job_function'];
104 } elseif ( $_REQUEST['job_url'] != '' && $_REQUEST['job_url'] != 'http://') { // url
105 $focus->job = 'url::'.$_REQUEST['job_url'];
106 } // url wins if both passed
108 // save should refresh ALL jobs
110 $return_id = $focus->id;
113 if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") $return_module = $_REQUEST['return_module'];
114 else $return_module = "Schedulers";
115 if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") $return_action = $_REQUEST['return_action'];
116 else $return_action = "DetailView";
117 if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") $return_id = $_REQUEST['return_id'];
118 if(!empty($_REQUEST['edit'])) {
123 $GLOBALS['log']->debug("Saved record with id of ".$return_id);
125 header("Location: index.php?action=$return_action&module=$return_module&record=$return_id&$edit");