function SaveField() { if (!$this->ValidateUser()) { return $this->noPermission(); } $ticketid = FSS_Input::getInt('ticketid'); $savefield = FSS_Input::getInt('savefield'); $model = $this->getModel(); $ticket = $model->getTicket($ticketid); $user = JFactory::getUser(); $userid = $user->get('id'); $uids = $model->getUIDS($userid); //print_r($uids); if (!array_key_exists($ticket['user_id'], $uids)) { $this->ticket = $ticket; $this->getCCInfo(); // doesnt have permission to view, check cc list if (!array_key_exists("cc", $ticket)) { return $this->noPermission(); } $found = false; foreach ($ticket['cc'] as &$user) { if ($user['id'] == $userid) { $found = true; } } if (!$found) { return $this->noPermission(); } } $this->GetTicketPerms($ticket); if (!$ticket['can_edit']) { return $this->noPermission(); } $this->fields = FSSCF::GetCustomFields($ticketid, $ticket['prod_id'], $ticket['ticket_dept_id']); list($old, $new) = FSSCF::StoreField($savefield, $ticketid, $ticket); if ($old != $new) { $field = FSSCF::GetField($savefield); if ($this->CanEditField($field)) { if ($field->type == 'checkbox') { if ($old == "") { $old = "No"; } if ($old == "on") { $old = "Yes"; } if ($new == "") { $new = "No"; } if ($new == "on") { $new = "Yes"; } } $this->AddTicketAuditNote($ticketid, "Custom field '" . $field->description . "' changed from '" . $old . "' to '" . $new . "'"); } } //FSSCF::StoreFields($this->fields, $ticketid); // forward with what= /*$mainframe = JFactory::getApplication(); $link = FSSRoute::_('&what=new_status=new_pri=',false); $mainframe->redirect($link); */ echo "<script>parent.window.location.reload();</script>"; exit; return true; }
function updateCustomField($fieldid, $value, $max_permission = 3) { // TODO: Dont like how this works, needs the field data to be stored in the class object! if (empty($this->fields)) { $this->fields = FSSCF::GetCustomFields($this->id, $this->prod_id, $this->ticket_dept_id, $max_permission); } list($old, $new) = FSSCF::StoreField($fieldid, $this->id, $this, $value); if ($old != $new) { $field = FSSCF::GetField($fieldid); if ($field->type == 'checkbox') { if ($old == "") { $old = "No"; } if ($old == "on") { $old = "Yes"; } if ($new == "") { $new = "No"; } if ($new == "on") { $new = "Yes"; } } $this->addAuditNote("Custom field '" . $field->description . "' changed from '" . $old . "' to '" . $new . "'"); $this->updateLastUpdated(); SupportActions::DoAction_Ticket("updateCustomField", $this, array('field_id' => $fieldid, 'old' => $old, 'new' => $new)); } }