public function Edit() { // Check the token if (!Kit::CheckToken()) { trigger_error('Token does not match', E_USER_ERROR); } $response = new ResponseManager(); // Create a form out of the config object. $displayProfile = new DisplayProfile(); $displayProfile->displayProfileId = Kit::GetParam('displayprofileid', _POST, _INT); if (!$displayProfile->Load()) { trigger_error($displayProfile->GetErrorMessage(), E_USER_ERROR); } if ($this->user->usertypeid != 1 && $this->user->userid != $displayProfile->userId) { trigger_error(__('You do not have permission to edit this profile'), E_USER_ERROR); } if (empty($displayProfile->type)) { trigger_error(__('Unknown Client Type'), E_USER_ERROR); } $displayProfile->name = Kit::GetParam('name', _POST, _STRING); $displayProfile->isDefault = Kit::GetParam('isdefault', _POST, _CHECKBOX); // Capture and validate the posted form parameters in accordance with the display config object. include 'config/client.config.php'; if (!isset($CLIENT_CONFIG[$displayProfile->type])) { trigger_error(__('CMS Config not supported for ' . $displayProfile->type . ' displays.'), E_USER_ERROR); } $combined = array(); foreach ($CLIENT_CONFIG[$displayProfile->type]['settings'] as $setting) { // Validate the parameter $value = Kit::GetParam($setting['name'], _POST, $setting['type'], $setting['type'] == 'checkbox' ? NULL : $setting['default']); // If we are a time picker, then process the received time if ($setting['fieldType'] == 'timePicker') { $value = $value == '00:00' ? '0' : DateManager::getTimestampFromTimeString($value) * 1000; } // Add to the combined array $combined[] = array('name' => $setting['name'], 'value' => $value, 'type' => $setting['type']); } // Recursively merge the arrays and update $displayProfile->config = $combined; if (!$displayProfile->Save()) { trigger_error($displayProfile->GetErrorMessage(), E_USER_ERROR); } $response->SetFormSubmitResponse(__('Display Configuration Saved.')); $response->Respond(); }