diff --git a/include/ajax.config.php b/include/ajax.config.php index 74ee115f08c1082fbb2013cafd0fb2d2c7ddd84b..1cff41842b82d4d8c7c08fde9a4222561810c7e2 100644 --- a/include/ajax.config.php +++ b/include/ajax.config.php @@ -27,10 +27,8 @@ class ConfigAjaxAPI extends AjaxController { $config=array( 'lock_time' => ($cfg->getLockTime()*3600), - 'max_file_uploads'=> (int) $cfg->getStaffMaxFileUploads(), 'html_thread' => (bool) $cfg->isHtmlThreadEnabled(), 'date_format' => ($cfg->getDateFormat()), - 'allow_attachments' => (bool) $cfg->allowAttachments(), 'lang' => $lang, 'short_lang' => $sl, ); @@ -44,10 +42,6 @@ class ConfigAjaxAPI extends AjaxController { list($sl, $locale) = explode('_', $lang); $config=array( - 'allow_attachments' => (bool) $cfg->allowOnlineAttachments(), - 'file_types' => $cfg->getAllowedFileTypes(), - 'max_file_size' => (int) $cfg->getMaxFileSize(), - 'max_file_uploads'=> (int) $cfg->getClientMaxFileUploads(), 'html_thread' => (bool) $cfg->isHtmlThreadEnabled(), 'lang' => $lang, 'short_lang' => $sl, diff --git a/include/class.config.php b/include/class.config.php index 78284e49daa52abb910a4dbb5d94b73522c74ed5..8a7d5eebdb6d53a6d23d5667d543ded34ad8b5ca 100644 --- a/include/class.config.php +++ b/include/class.config.php @@ -152,9 +152,6 @@ class OsticketConfig extends Config { 'pw_reset_window' => 30, 'enable_html_thread' => true, 'allow_attachments' => true, - 'allow_email_attachments' => true, - 'allow_online_attachments' => true, - 'allow_online_attachments_onlogin' => false, 'name_format' => 'full', # First Last 'auto_claim_tickets'=> true, 'system_language' => 'en_US', @@ -809,28 +806,10 @@ class OsticketConfig extends Config { return ($this->get('allow_attachments')); } - function allowOnlineAttachments() { - return ($this->allowAttachments() && $this->get('allow_online_attachments')); - } - - function allowAttachmentsOnlogin() { - return ($this->allowOnlineAttachments() && $this->get('allow_online_attachments_onlogin')); - } - - function allowEmailAttachments() { - return ($this->allowAttachments() && $this->get('allow_email_attachments')); - } - function getSystemLanguage() { return $this->get('system_language'); } - //TODO: change db field to allow_api_attachments - which will include email/json/xml attachments - // terminology changed on the UI - function allowAPIAttachments() { - return $this->allowEmailAttachments(); - } - /* Needed by upgrader on 1.6 and older releases upgrade - not not remove */ function getUploadDir() { return $this->get('upload_dir'); @@ -959,27 +938,6 @@ class OsticketConfig extends Config { $errors['enable_captcha']=__('PNG support is required for Image Captcha'); } - if($vars['allow_attachments']) { - - if(!ini_get('file_uploads')) - $errors['err']=__('The "file_uploads" directive is disabled in php.ini'); - - if(!is_numeric($vars['max_file_size'])) - $errors['max_file_size']=__('Maximum file size required'); - - if(!$vars['allowed_filetypes']) - $errors['allowed_filetypes']=__('Allowed file extentions required'); - - if(!($maxfileuploads=ini_get('max_file_uploads'))) - $maxfileuploads=DEFAULT_MAX_FILE_UPLOADS; - - if(!$vars['max_user_file_uploads'] || $vars['max_user_file_uploads']>$maxfileuploads) - $errors['max_user_file_uploads']=sprintf(__('Invalid selection. Must be less than %d'),$maxfileuploads); - - if(!$vars['max_staff_file_uploads'] || $vars['max_staff_file_uploads']>$maxfileuploads) - $errors['max_staff_file_uploads']=sprintf(__('Invalid selection. Must be less than %d'),$maxfileuploads); - } - if ($vars['default_help_topic'] && ($T = Topic::lookup($vars['default_help_topic'])) && !$T->isActive()) { @@ -1012,15 +970,8 @@ class OsticketConfig extends Config { 'hide_staff_name'=>isset($vars['hide_staff_name'])?1:0, 'enable_html_thread'=>isset($vars['enable_html_thread'])?1:0, 'allow_client_updates'=>isset($vars['allow_client_updates'])?1:0, - 'allow_attachments'=>isset($vars['allow_attachments'])?1:0, - 'allowed_filetypes'=>strtolower(preg_replace("/\n\r|\r\n|\n|\r/", '',trim($vars['allowed_filetypes']))), 'max_file_size'=>$vars['max_file_size'], - 'max_user_file_uploads'=>$vars['max_user_file_uploads'], - 'max_staff_file_uploads'=>$vars['max_staff_file_uploads'], 'email_attachments'=>isset($vars['email_attachments'])?1:0, - 'allow_email_attachments'=>isset($vars['allow_email_attachments'])?1:0, - 'allow_online_attachments'=>isset($vars['allow_online_attachments'])?1:0, - 'allow_online_attachments_onlogin'=>isset($vars['allow_online_attachments_onlogin'])?1:0, )); } diff --git a/include/class.forms.php b/include/class.forms.php index b994c738faa1b7b3989e0c0fccd800542823da53..68175ed43d2cf98ac47865a74a793d5db7c465d3 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -995,10 +995,14 @@ class ThreadEntryField extends FormField { return array( 'attachments' => new BooleanField(array( 'label'=>__('Enable Attachments'), - 'default'=>$cfg->allowOnlineAttachments(), + 'default'=>$cfg->allowAttachments(), 'configuration'=>array( 'desc'=>__('Enables attachments on tickets, regardless of channel'), ), + 'validators' => function($self, $value) { + if (!ini_get('file_uploads')) + $self->addError(__('The "file_uploads" directive is disabled in php.ini')); + } )), ) + $attachments->getConfigurationOptions(); diff --git a/include/class.mailparse.php b/include/class.mailparse.php index efcff356c753a89672f6d2937dedac59a60ce6d6..c2d0cac78cd13567695111233879c60f9c2da6f2 100644 --- a/include/class.mailparse.php +++ b/include/class.mailparse.php @@ -672,8 +672,7 @@ class EmailDataParser { $data['reply-to-name'] = trim($replyto->personal, " \t\n\r\0\x0B\x22"); } - if($cfg && $cfg->allowEmailAttachments()) - $data['attachments'] = $parser->getAttachments(); + $data['attachments'] = $parser->getAttachments(); return $data; } diff --git a/include/client/view.inc.php b/include/client/view.inc.php index cc7a2f84e83055434ebd95b5992b8f40990b2bcf..3d81f7900c24cc55189aca35ee75970c194f6b73 100644 --- a/include/client/view.inc.php +++ b/include/client/view.inc.php @@ -184,11 +184,11 @@ if($ticket->getThreadCount() && ($thread=$ticket->getClientThread())) { </td> </tr> <?php - if($cfg->allowOnlineAttachments()) { ?> + if ($messageField->isAttachmentsEnabled()) { ?> <tr> <td colspan="2"> <?php - print $response_form->getField('attachments')->render(true); + print $attachments->render(true); ?> </td> </tr> diff --git a/include/staff/settings-tickets.inc.php b/include/staff/settings-tickets.inc.php index 9f4b306735d14061a8dc1cfde5848a3da98047fa..a9ede1b5d164c9149f81a7d5f9ebeae37bc00979 100644 --- a/include/staff/settings-tickets.inc.php +++ b/include/staff/settings-tickets.inc.php @@ -214,61 +214,20 @@ if(!($maxfileuploads=ini_get('max_file_uploads'))) </th> </tr> <tr> - <td width="180"><?php echo __('Allow Attachments');?>:</td> + <td width="180"><?php echo __('Ticket Attachment Settings');?>:</td> <td> - <input type="checkbox" name="allow_attachments" <?php echo - $config['allow_attachments']?'checked="checked"':''; ?>> <b><?php echo __('Allow Attachments'); ?></b> - <em>(<?php echo __('Global Setting'); ?>)</em> - <font class="error"> <?php echo $errors['allow_attachments']; ?></font> - </td> - </tr> - <tr> - <td width="180"><?php echo __('Emailed/API Attachments');?>:</td> - <td> - <input type="checkbox" name="allow_email_attachments" <?php echo $config['allow_email_attachments']?'checked="checked"':''; ?>> <?php echo __('Accept emailed files');?> - <font class="error"> <?php echo $errors['allow_email_attachments']; ?></font> - </td> - </tr> - <tr> - <td width="180"><?php echo __('Online/Web Attachments');?>:</td> - <td> - <input type="checkbox" name="allow_online_attachments" <?php echo $config['allow_online_attachments']?'checked="checked"':''; ?> > - <?php echo __('Allow web upload');?> - <input type="checkbox" name="allow_online_attachments_onlogin" <?php echo $config['allow_online_attachments_onlogin'] ?'checked="checked"':''; ?> > - <?php echo __('Limit to authenticated users only. <em>(User must be logged in to upload files)</em>');?> - <font class="error"> <?php echo $errors['allow_online_attachments']; ?></font> - </td> - </tr> - <tr> - <td><?php echo __('Maximum User File Uploads');?>:</td> - <td> - <select name="max_user_file_uploads"> - <?php - for($i = 1; $i <=$maxfileuploads; $i++) { - ?> - <option <?php echo $config['max_user_file_uploads']==$i?'selected="selected"':''; ?> value="<?php echo $i; ?>"> - <?php echo sprintf(_N('%d file', '%d files', $i), $i); ?></option> - <?php - } ?> - </select> - <em><?php echo __('(Number of files the user is allowed to upload simultaneously)');?></em> - <font class="error"> <?php echo $errors['max_user_file_uploads']; ?></font> - </td> - </tr> - <tr> - <td><?php echo __('Maximum Agent File Uploads');?>:</td> - <td> - <select name="max_staff_file_uploads"> - <?php - for($i = 1; $i <=$maxfileuploads; $i++) { - ?> - <option <?php echo $config['max_staff_file_uploads']==$i?'selected="selected"':''; ?> value="<?php echo $i; ?>"> - <?php echo sprintf(_N('%d file', '%d files', $i), $i); ?></option> - <?php - } ?> - </select> - <em><?php echo __('(Number of files an agent is allowed to upload simultaneously)');?></em> - <font class="error"> <?php echo $errors['max_staff_file_uploads']; ?></font> +<?php + $tform = TicketForm::objects()->one()->getForm(); + $f = $tform->getField('message'); +?> + <a class="action-button field-config" style="float:none;overflow:inherit" + href="#ajax.php/form/field-config/<?php + echo $f->get('id'); ?>" + onclick="javascript: + $.dialog($(this).attr('href').substr(1), [201]); + return false; + "><i class="icon-edit"></i> <?php echo __('Config'); ?></a> + <i class="help-tip icon-question-sign" href="#attachment_settings"></i> </td> </tr> <tr> @@ -330,18 +289,6 @@ if(!($maxfileuploads=ini_get('max_file_uploads'))) </td> </tr> <?php } ?> - <tr> - <th colspan="2"> - <em><strong><?php echo __('Accepted File Types');?></strong>: <?php echo __('Limit the type of files users are allowed to submit.');?> - <font class="error"> <?php echo $errors['allowed_filetypes']; ?></font></em> - </th> - </tr> - <tr> - <td colspan="2"> - <em><?php echo __('Enter allowed file extensions separated by a comma. e.g .doc, .pdf. To accept all files enter wildcard <b><i>.*</i></b> i.e dotStar (NOT Recommended).');?></em><br> - <textarea name="allowed_filetypes" cols="21" rows="4" style="width: 65%;" wrap="hard" ><?php echo $config['allowed_filetypes']; ?></textarea> - </td> - </tr> </tbody> </table> <p style="padding-left:250px;"> diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php index ea43caa960819162413f1b07f7d1d7c3a3cfaa62..138d7c6c2ee8c4067c41d6b00da319eb8e9ddf80 100644 --- a/include/staff/ticket-open.inc.php +++ b/include/staff/ticket-open.inc.php @@ -302,15 +302,11 @@ if ($_POST) placeholder="<?php echo __('Initial response for the ticket'); ?>" name="response" id="response" cols="21" rows="8" style="width:80%;"><?php echo $info['response']; ?></textarea> - <?php - if($cfg->allowAttachments()) { ?> <div class="attachments"> <?php print $response_form->getField('attachments')->render(); ?> </div> - <?php - } ?> <table border="0" cellspacing="0" cellpadding="2" width="100%"> <tr> diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index 0c66a9859201d2f40c7fdd3ef4fb597b138c9092..5da914258ea548bf4d18a46372bb06db13786b18 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -577,15 +577,11 @@ $tcount+= $ticket->getNumNotes(); rows="9" wrap="soft" class="richtext ifhtml draft draft-delete"><?php echo $info['response']; ?></textarea> - <?php - if($cfg->allowAttachments()) { ?> <div id="reply_form_attachments" class="attachments"> <?php print $response_form->getField('attachments')->render(); ?> </div> - <?php - }?> </td> </tr> <tr> @@ -686,8 +682,6 @@ print $response_form->getField('attachments')->render(); <span class="error"><?php echo $errors['note']; ?></span> </td> </tr> - <?php - if($cfg->allowAttachments()) { ?> <tr> <td width="120"> <label for="attachment"><?php echo __('Attachments');?>:</label> @@ -698,9 +692,6 @@ print $note_form->getField('attachments')->render(); ?> </td> </tr> - <?php - } - ?> <tr><td colspan="2"> </td></tr> <tr> <td width="120"> diff --git a/open.php b/open.php index 93d74c2629e7940970e8f74e7b79873e81959d89..2311bc2bc57759bbcd812cdb75ace610fc504439 100644 --- a/open.php +++ b/open.php @@ -29,9 +29,10 @@ if ($_POST) { $errors['captcha']=__('Invalid - try again!'); } - $tform = TicketForm::objects()->one()->getForm($create_vars); - $attachments = $tform->getField('message')->getWidget()->getAttachments(); - if (!$errors && $cfg->allowOnlineAttachments()) + $tform = TicketForm::objects()->one()->getForm($vars); + $messageField = $tform->getField('message'); + $attachments = $messageField->getWidget()->getAttachments(); + if (!$errors && $messageField->isAttachmentsEnabled()) $vars['cannedattachments'] = $attachments->getClean(); // Drop the draft.. If there are validation errors, the content diff --git a/tickets.php b/tickets.php index 593c337f313ca43e16e2471343868181f1ea374c..7adb4029fd86c40bd62da6405f089bf24d08239d 100644 --- a/tickets.php +++ b/tickets.php @@ -35,9 +35,9 @@ if($_REQUEST['id']) { if (!$ticket && $thisclient->isGuest()) Http::redirect('view.php'); -$response_form = new Form(array( - 'attachments' => new FileUploadField(array('id'=>'attach')) -)); +$tform = TicketForm::objects()->one(); +$messageField = $tform->getField('message'); +$attachments = $messageField->getWidget()->getAttachments(); //Process post...depends on $ticket object above. if($_POST && is_object($ticket) && $ticket->getId()):