Skip to content

Commit

Permalink
Add setting to enable cron service (external) at API key level
Browse files Browse the repository at this point in the history
Remove piping setting option - it's now part of ticket create service (which include XML & JSON)
  • Loading branch information
protich committed Feb 14, 2013
1 parent 38a1d20 commit f226f71
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 24 deletions.
11 changes: 6 additions & 5 deletions include/class.api.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function canCreateTickets() {
}

function canExecuteCronjob() {
return true;
return ($this->ht['can_exec_cron']);
}

function update($vars, &$errors) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions include/class.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
Expand Down Expand Up @@ -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());
Expand Down
16 changes: 13 additions & 3 deletions include/staff/apikey.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,23 @@
<?php } ?>
<tr>
<th colspan="2">
<em><strong>Enabled Services:</strong>: Check applicable API services. All active keys can make cron call.</em>
<em><strong>Services:</strong>: Check applicable API services enabled for the key.</em>
</th>
</tr>
<tr>
<td colspan=2 style="padding-left:5px">
<input type="checkbox" name="can_create_tickets" value="1" <?php echo $info['can_create_tickets']?'checked="checked"':''; ?> >
Can Create Tickets. <em>(XML/JSON/PIPE)</em>
<label>
<input type="checkbox" name="can_create_tickets" value="1" <?php echo $info['can_create_tickets']?'checked="checked"':''; ?> >
Can Create Tickets <em>(XML/JSON/EMAIL)</em>
</label>
</td>
</tr>
<tr>
<td colspan=2 style="padding-left:5px">
<label>
<input type="checkbox" name="can_exec_cron" value="1" <?php echo $info['can_exec_cron']?'checked="checked"':''; ?> >
Can Execute Cron
</label>
</td>
</tr>
<tr>
Expand Down
10 changes: 2 additions & 8 deletions include/staff/settings-emails.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,13 @@
&nbsp;&nbsp;<em>(System administrator's email)</em>
</td>
</tr>
<tr><th colspan=2><em><strong>Incoming Emails</strong>: For mail fetcher (polling) to work you must set an external cron job or enable auto-cron</em></th>
<tr><th colspan=2><em><strong>Incoming Emails</strong>: For mail fetcher (polling) to work you must set an external cron job or enable auto-cron polling</em></th>
<tr>
<td width="180">Email Polling:</td>
<td><input type="checkbox" name="enable_mail_polling" value=1 <?php echo $config['enable_mail_polling']? 'checked="checked"': ''; ?> > Enable POP/IMAP polling
&nbsp;&nbsp;
<input type="checkbox" name="enable_auto_cron" <?php echo $config['enable_auto_cron']?'checked="checked"':''; ?>>
Enable Auto-Cron <em>(Poll based on staff activity - NOT recommended)</em>
</td>
</tr>
<tr>
<td width="180">Email Piping:</td>
<td><input type="checkbox" name="enable_email_piping" value=1 <?php echo $config['enable_email_piping']? 'checked="checked"': ''; ?>> Enable email piping
&nbsp;&nbsp;<em>(You pipe we accept policy)</em>
Poll on auto-cron <em>(Poll based on staff activity - NOT recommended)</em>
</td>
</tr>
<tr>
Expand Down
17 changes: 17 additions & 0 deletions include/upgrader/sql/c0fd16f4-959a00e.patch.sql
Original file line number Diff line number Diff line change
@@ -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';
2 changes: 1 addition & 1 deletion main.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup/inc/sql/osTicket-mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion setup/inc/sql/osTicket-mysql.sql.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c0fd16f4eaf99b920be9f7fc6ebead32
d959a00e55c75e0c903b9e37324fd25d

0 comments on commit f226f71

Please sign in to comment.