From f226f71efd8dff89b9fc3c2339ef7b8cce740ac4 Mon Sep 17 00:00:00 2001 From: Peter Rotich Date: Thu, 14 Feb 2013 17:18:17 -0500 Subject: [PATCH] Add setting to enable cron service (external) at API key level Remove piping setting option - it's now part of ticket create service (which include XML & JSON) --- include/class.api.php | 11 ++++++----- include/class.config.php | 5 ----- include/staff/apikey.inc.php | 16 +++++++++++++--- include/staff/settings-emails.inc.php | 10 ++-------- include/upgrader/sql/c0fd16f4-959a00e.patch.sql | 17 +++++++++++++++++ main.inc.php | 2 +- setup/inc/sql/osTicket-mysql.sql | 2 +- setup/inc/sql/osTicket-mysql.sql.md5 | 2 +- 8 files changed, 41 insertions(+), 24 deletions(-) create mode 100644 include/upgrader/sql/c0fd16f4-959a00e.patch.sql diff --git a/include/class.api.php b/include/class.api.php index 48e968df..f5d2ef5c 100644 --- a/include/class.api.php +++ b/include/class.api.php @@ -72,7 +72,7 @@ function canCreateTickets() { } function canExecuteCronjob() { - return true; + return ($this->ht['can_exec_cron']); } function update($vars, &$errors) { @@ -129,6 +129,7 @@ function save($id, $vars, &$errors) { $sql=' updated=NOW() ' .',isactive='.db_input($vars['isactive']) .',can_create_tickets='.db_input($vars['can_create_tickets']) + .',can_exec_cron='.db_input($vars['can_exec_cron']) .',notes='.db_input($vars['notes']); if($id) { @@ -265,11 +266,11 @@ function exerr($code, $error='') { if($error && is_array($error)) $error = Format::array_implode(": ", "\n", $error); - //Include api key - if available. + //Log the error as a warning - include api key if available. + $msg = $error; if($_SERVER['HTTP_X_API_KEY']) - $error.="\n\n*[".$_SERVER['HTTP_X_API_KEY']."]*\n"; - - $ost->logWarning("API Error ($code)", $error, false); + $msg.="\n*[".$_SERVER['HTTP_X_API_KEY']."]*\n"; + $ost->logWarning("API Error ($code)", $msg, false); $this->response($code, $error); //Responder should exit... return false; diff --git a/include/class.config.php b/include/class.config.php index c7e96697..50a3174c 100644 --- a/include/class.config.php +++ b/include/class.config.php @@ -336,10 +336,6 @@ function isEmailPollingEnabled() { return ($this->config['enable_mail_polling']); } - function isEmailPipingEnabled() { - return ($this->config['enable_email_piping']); - } - function allowPriorityChange() { return ($this->config['allow_priority_change']); } @@ -723,7 +719,6 @@ function updateEmailsSettings($vars, &$errors) { .',admin_email='.db_input($vars['admin_email']) .',enable_auto_cron='.db_input(isset($vars['enable_auto_cron'])?1:0) .',enable_mail_polling='.db_input(isset($vars['enable_mail_polling'])?1:0) - .',enable_email_piping='.db_input(isset($vars['enable_email_piping'])?1:0) .',strip_quoted_reply='.db_input(isset($vars['strip_quoted_reply'])?1:0) .',reply_separator='.db_input($vars['reply_separator']) .' WHERE id='.db_input($this->getId()); diff --git a/include/staff/apikey.inc.php b/include/staff/apikey.inc.php index 6e2ffe6e..507753aa 100644 --- a/include/staff/apikey.inc.php +++ b/include/staff/apikey.inc.php @@ -71,13 +71,23 @@ - Enabled Services:: Check applicable API services. All active keys can make cron call. + Services:: Check applicable API services enabled for the key. - > - Can Create Tickets. (XML/JSON/PIPE) + + + + + + diff --git a/include/staff/settings-emails.inc.php b/include/staff/settings-emails.inc.php index f8674095..b7175a06 100644 --- a/include/staff/settings-emails.inc.php +++ b/include/staff/settings-emails.inc.php @@ -61,19 +61,13 @@   (System administrator's email) - Incoming Emails: For mail fetcher (polling) to work you must set an external cron job or enable auto-cron + Incoming Emails: For mail fetcher (polling) to work you must set an external cron job or enable auto-cron polling Email Polling: > Enable POP/IMAP polling    > - Enable Auto-Cron (Poll based on staff activity - NOT recommended) - - - - Email Piping: - > Enable email piping -   (You pipe we accept policy) + Poll on auto-cron (Poll based on staff activity - NOT recommended) diff --git a/include/upgrader/sql/c0fd16f4-959a00e.patch.sql b/include/upgrader/sql/c0fd16f4-959a00e.patch.sql new file mode 100644 index 00000000..186dfc5b --- /dev/null +++ b/include/upgrader/sql/c0fd16f4-959a00e.patch.sql @@ -0,0 +1,17 @@ +/** + * @version v1.7 + * + * @schema d959a00e55c75e0c903b9e37324fd25d + */ + +-- Add cron exec service +ALTER TABLE `%TABLE_PREFIX%api_key` + ADD `can_exec_cron` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1' AFTER `can_create_tickets`; + +-- Drop email piping settings from config table. +ALTER TABLE `%TABLE_PREFIX%config` + DROP `enable_email_piping`; + +-- update schema signature +UPDATE `%TABLE_PREFIX%config` + SET `schema_signature`='d959a00e55c75e0c903b9e37324fd25d'; diff --git a/main.inc.php b/main.inc.php index 2dc651c9..2e7691f2 100644 --- a/main.inc.php +++ b/main.inc.php @@ -63,7 +63,7 @@ #Current version && schema signature (Changes from version to version) define('THIS_VERSION','1.7-RC4+'); //Shown on admin panel - define('SCHEMA_SIGNATURE', 'c0fd16f4eaf99b920be9f7fc6ebead32'); //MD5 signature of the db schema. (used to trigger upgrades) + define('SCHEMA_SIGNATURE', 'd959a00e55c75e0c903b9e37324fd25d'); //MD5 signature of the db schema. (used to trigger upgrades) #load config info $configfile=''; if(file_exists(ROOT_DIR.'ostconfig.php')) //Old installs prior to v 1.6 RC5 diff --git a/setup/inc/sql/osTicket-mysql.sql b/setup/inc/sql/osTicket-mysql.sql index ba980b87..3d14f86d 100644 --- a/setup/inc/sql/osTicket-mysql.sql +++ b/setup/inc/sql/osTicket-mysql.sql @@ -6,6 +6,7 @@ CREATE TABLE `%TABLE_PREFIX%api_key` ( `ipaddr` varchar(64) NOT NULL, `apikey` varchar(255) NOT NULL, `can_create_tickets` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1', + `can_exec_cron` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1', `notes` text, `updated` datetime NOT NULL, `created` datetime NOT NULL, @@ -97,7 +98,6 @@ CREATE TABLE `%TABLE_PREFIX%config` ( `enable_captcha` tinyint(1) unsigned NOT NULL default '0', `enable_auto_cron` tinyint(1) unsigned NOT NULL default '0', `enable_mail_polling` tinyint(1) unsigned NOT NULL default '0', - `enable_email_piping` tinyint(1) unsigned NOT NULL default '0', `send_sys_errors` tinyint(1) unsigned NOT NULL default '1', `send_sql_errors` tinyint(1) unsigned NOT NULL default '1', `send_mailparse_errors` tinyint(1) unsigned NOT NULL default '1', diff --git a/setup/inc/sql/osTicket-mysql.sql.md5 b/setup/inc/sql/osTicket-mysql.sql.md5 index db25b456..d14b842c 100644 --- a/setup/inc/sql/osTicket-mysql.sql.md5 +++ b/setup/inc/sql/osTicket-mysql.sql.md5 @@ -1 +1 @@ -c0fd16f4eaf99b920be9f7fc6ebead32 +d959a00e55c75e0c903b9e37324fd25d