diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php index 3f53acd180bb79283d90de1c7766e674ec20c55b..2d5ed570088cc5c710e15a3b4091d66fddbe55fc 100644 --- a/include/ajax.tickets.php +++ b/include/ajax.tickets.php @@ -523,6 +523,10 @@ function refer($tid, $target=null) { __($field->getLabel()) ) ); + + $impl = $field->getImpl(); + if ($impl instanceof FileUploadField) + $field->save(); Http::response(201, $field->getClean()); } $form->addErrors($errors); diff --git a/include/class.ticket.php b/include/class.ticket.php index a6ed0915df61141e13fd89f210f7a69805cf785e..7da02a0afa0d259900ddb2d3aa14a9bfeebe28ee 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -1022,16 +1022,22 @@ implements RestrictedAccess, Threadable, Searchable { } } - static function getMissingRequiredFields($ticket) { + //if ids passed, function returns only the ids of fields disabled by help topic + static function getMissingRequiredFields($ticket, $ids=false) { // Check for fields disabled by Help Topic $disabled = array(); - foreach ($ticket->entries as $entry) { - $extra = JsonDataParser::decode($entry->extra); + foreach (($ticket->getTopic() ? $ticket->getTopic()->forms : $ticket->entries) as $f) { + $extra = JsonDataParser::decode($f->extra); + if (!empty($extra['disable'])) $disabled[] = $extra['disable']; } + $disabled = !empty($disabled) ? call_user_func_array('array_merge', $disabled) : NULL; + if ($ids) + return $disabled; + $criteria = array( 'answers__field__flags__hasbit' => DynamicFormField::FLAG_ENABLED, 'answers__field__flags__hasbit' => DynamicFormField::FLAG_CLOSE_REQUIRED, @@ -1042,7 +1048,7 @@ implements RestrictedAccess, Threadable, Searchable { if ($disabled) array_push($criteria, Q::not(array('answers__field__id__in' => $disabled))); - return $ticket->getDynamicFields($criteria, $ticket); + return $ticket->getDynamicFields($criteria); } function getMissingRequiredField() { @@ -1603,7 +1609,6 @@ implements RestrictedAccess, Threadable, Searchable { if(get_class($recipient) == 'Collaborator') { if ($recipient->isCc()) { $collabsCc[] = $recipient->getEmail()->address; - $cnotice = $this->replaceVars($msg, array('recipient.name.first' => __('Collaborator'), 'recipient' => $recipient)); } else $collabsBcc[] = $recipient; @@ -1614,11 +1619,14 @@ implements RestrictedAccess, Threadable, Searchable { } } - foreach ($collabsBcc as $recipient) { - $notice = $this->replaceVars($msg, array('recipient' => $recipient)); - if ($posterEmail != $recipient->getEmail()->address) - $email->send($recipient, $notice['subj'], $notice['body'], $attachments, - $options); + //send bcc messages seperately for privacy + if ($collabsBcc) { + foreach ($collabsBcc as $recipient) { + $notice = $this->replaceVars($msg, array('recipient' => $recipient)); + if ($posterEmail != $recipient->getEmail()->address) + $email->send($recipient, $notice['subj'], $notice['body'], $attachments, + $options); + } } foreach ($collabsCc as $cc) { @@ -1628,14 +1636,25 @@ implements RestrictedAccess, Threadable, Searchable { $collaborators[] = $cc; } + //the ticket user is a recipient if ($owner->getEmail()->address != $poster->getEmail()->address && !in_array($owner->getEmail()->address, $skip)) - $collaborators[] = $owner->getEmail()->address; + $owner_recip = $owner->getEmail()->address; $collaborators['cc'] = $collaborators; //collaborator email sent out - $email->send('', $cnotice['subj'], $cnotice['body'], $attachments, - $options, $collaborators); + if ($collaborators['cc']) { + //say dear collaborator if the ticket user is not a recipient + if (!$owner_recip) + $cnotice = $this->replaceVars($msg, array('recipient.name.first' => __('Collaborator'), 'recipient' => $recipient)); + //otherwise address email to ticket user + else + $cnotice = $this->replaceVars($msg, array('recipient' => $owner)); + + //if the ticket user is a recipient, put them in to address otherwise, cc all recipients + $email->send($owner_recip ? $owner_recip : '', $cnotice['subj'], $cnotice['body'], $attachments, + $options, $collaborators); + } } function onMessage($message, $autorespond=true, $reopen=true) { diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index f5d7ae5f7ba3bf740000ed119c2e1429b2e3324e..6b8fe9791cebb9efdd20ca6d53654ea0806374cd 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -695,15 +695,15 @@ if ($errors['err'] && isset($_POST['a'])) { <?php }?> <tbody id="to_sec"> + <?php + # XXX: Add user-to-name and user-to-email HTML ID#s + if ($addresses = Email::getAddresses(array('smtp' => true))){ + ?> <tr> <td width="120"> <label><strong><?php echo __('From'); ?>:</strong></label> </td> <td> - <?php - # XXX: Add user-to-name and user-to-email HTML ID#s - $addresses = Email::getAddresses(); - ?> <select id="from_name" name="from_name"> <?php $sql=' SELECT email_id, email, name, smtp_host ' @@ -719,6 +719,7 @@ if ($errors['err'] && isset($_POST['a'])) { </select> </td> </tr> + <?php } ?> <tr> <td width="120"> <label><strong><?php echo __('To'); ?>:</strong></label> diff --git a/scp/emailtest.php b/scp/emailtest.php index ae8d68579d88768ee3034c856d89ace84c5b6283..8228de5c3507906057c6d7a5f1a7ac70b067edd2 100644 --- a/scp/emailtest.php +++ b/scp/emailtest.php @@ -16,8 +16,6 @@ require('admin.inc.php'); include_once(INCLUDE_DIR.'class.email.php'); include_once(INCLUDE_DIR.'class.csrf.php'); -$info=array(); -$info['subj']='osTicket test email'; if($_POST){ $errors=array(); @@ -53,6 +51,8 @@ $ost->addExtraHeader('<meta name="tip-namespace" content="emails.diagnostic" />' "$('#content').data('tipNamespace', '".$tip_namespace."');"); require(STAFFINC_DIR.'header.inc.php'); +$info=array(); +$info['subj']='osTicket test email'; $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); ?> <form action="emailtest.php" method="post" class="save">