function handle($request) {
        $groupIdParamName = 'group';
        $groupId = Form::getField($request, $groupIdParamName);
        if (strlen($groupId) == 0) {
            die(IsatisText::getText("MissingParameter").": ".$groupIdParamName);
        }
        $g = SecurityGroup::getById($groupId);
        if ($g == NULL) {
            die(Text::getText("GroupNotFound").": '".$groupId."'");
        }
        $allPermissions = SecurityPermission::getAll();
        $allResources = SecurityResource::getAll();

        foreach ($allResources as $res) {
            foreach ($allPermissions as $perm) {
                $fieldName = "res".$res->getId()."_perm".$perm->getId();
                $value = Form::getField($request, $fieldName);
                if ($value == "on") {
                    if (!$g->hasPermission($res, $perm)) {
                        $g->addPermission($res, $perm);
                    }
                } else {
                    $g->removePermission($res, $perm);
                }
            }
        }
        return $g;
    }
Example #2
0
                 $msg = __('Ticket is NOW assigned to you!');
             } else {
                 $msg = sprintf(__('Ticket assigned successfully to %s'), $ticket->getAssigned());
                 TicketLock::removeStaffLocks($thisstaff->getId(), $ticket->getId());
                 $ticket = null;
             }
         } elseif (!$errors['assign']) {
             $errors['err'] = __('Unable to complete the ticket assignment');
             $errors['assign'] = __('Correct the error(s) below and try again!');
         }
     }
     break;
 case 'postnote':
     /* Post Internal Note */
     $vars = $_POST;
     $attachments = $note_form->getField('attachments')->getClean();
     $vars['cannedattachments'] = array_merge($vars['cannedattachments'] ?: array(), $attachments);
     $wasOpen = $ticket->isOpen();
     if ($note = $ticket->postNote($vars, $errors, $thisstaff)) {
         $msg = __('Internal note posted successfully');
         // Clear attachment list
         $note_form->setSource(array());
         $note_form->getField('attachments')->reset();
         if ($wasOpen && $ticket->isClosed()) {
             $ticket = null;
         } else {
             // Ticket is still open -- clear draft for the note
             Draft::deleteForNamespace('ticket.note.' . $ticket->getId(), $thisstaff->getId());
         }
     } else {
         if (!$errors['err']) {
        'configuration'=>array('extensions'=>false,
            'size'=>$cfg->getMaxFileSize())
   )),
));

if($_POST && $thisstaff->canManageCannedResponses()) {
    switch(strtolower($_POST['do'])) {
        case 'update':
            if(!$canned) {
                $errors['err']=sprintf(__('%s: Unknown or invalid'), __('canned response'));
            } elseif($canned->update($_POST, $errors)) {
                $msg=sprintf(__('Successfully updated %s'),
                    __('this canned response'));
                //Delete removed attachments.
                //XXX: files[] shouldn't be changed under any circumstances.
                $keepers = $canned_form->getField('attachments')->getClean();
                $attachments = $canned->attachments->getSeparates(); //current list of attachments.
                foreach($attachments as $k=>$file) {
                    if($file['id'] && !in_array($file['id'], $keepers)) {
                        $canned->attachments->delete($file['id']);
                    }
                }

                //Upload NEW attachments IF ANY - TODO: validate attachment types??
                if ($keepers)
                    $canned->attachments->upload($keepers);

                // Attach inline attachments from the editor
                if (isset($_POST['draft_id'])
                        && ($draft = Draft::lookup($_POST['draft_id']))) {
                    $canned->attachments->deleteInlines();
Example #4
0
    vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
require 'staff.inc.php';
require_once INCLUDE_DIR . 'class.faq.php';
$faq = $category = null;
if ($_REQUEST['id'] && !($faq = FAQ::lookup($_REQUEST['id']))) {
    $errors['err'] = sprintf(__('%s: Unknown or invalid'), __('FAQ article'));
}
if ($_REQUEST['cid'] && !$faq && !($category = Category::lookup($_REQUEST['cid']))) {
    $errors['err'] = sprintf(__('%s: Unknown or invalid'), __('FAQ category'));
}
$faq_form = new Form(array('attachments' => new FileUploadField(array('id' => 'attach', 'configuration' => array('extensions' => false, 'size' => $cfg->getMaxFileSize())))));
if ($_POST) {
    $errors = array();
    $_POST['files'] = $faq_form->getField('attachments')->getClean();
    switch (strtolower($_POST['do'])) {
        case 'create':
        case 'add':
            if ($faq = FAQ::add($_POST, $errors)) {
                $msg = sprintf(__('Successfully added %s'), Format::htmlchars($faq->getQuestion()));
                // Delete draft for this new faq
                Draft::deleteForNamespace('faq', $thisstaff->getId());
            } elseif (!$errors['err']) {
                $errors['err'] = sprintf(__('Unable to add %s. Correct error(s) below and try again.'), __('this FAQ article'));
            }
            break;
        case 'update':
        case 'edit':
            if (!$faq) {
                $errors['err'] = sprintf(__('%s: Invalid or unknown'), __('FAQ article'));