/** * This function is called by the javascript (System Settings) everytime there is an event (drag, sort, submit) * It updates the config file for the specific object and returns the updated html to the javascript which * replaces the old content with the new one * * @access private * @param * @return string * @example * @see * * @author Damiano Venturin * @copyright 2V S.r.l. * @license GPL * @link http://www.squadrainformatica.com/en/development#mcbsb MCB-SB official page * @since Feb 6, 2012 * */ public function update_settings() { $output = ''; $data = array(); $split = preg_split('/_/', $this->input->post('action')); if (isset($split['0'])) { $objName = $split['0']; } if (isset($split['1'])) { $action = $split['1']; } switch ($objName) { case 'person': $obj = new Mdl_Person(); break; case 'organization': $obj = new Mdl_Organization(); break; case 'location': $obj = new Mdl_Location(); break; default: return false; break; } $obj->getProperties(); $obj->prepareShow(); $tpl = null; switch ($action) { case 'addToVisible': if ($attribute = $this->getAjaxItem()) { $this->toVisible($obj, 'add', $attribute); } break; case 'removeFromVisible': if ($attribute = $this->getAjaxItem()) { $this->toVisible($obj, 'remove', $attribute); } break; case 'sort': //show_fields is the ordered array of fields coming from the accordion $show_fields = $this->input->post(ucfirst(strtolower($objName)) . 'VisibleAttributes'); if (is_array($show_fields)) { if (is_array($obj->show_fields)) { //let's check if the given array (show_fields) is not fake if (count(array_diff($obj->show_fields, $show_fields)) == 0) { //there are no differences so I can assume that the POST wasn't manipulated $obj->show_fields = $show_fields; $this->update_config($obj, $obj->objName); } } } $tpl = 'order'; break; case 'aliases': if ($this->input->post('save')) { if (is_array($this->input->post('form'))) { $aliases = array(); $form = $this->input->post('form'); foreach ($form as $key => $item) { if (!empty($item['value']) and $item['type'] == 'TEXT') { $aliases[$item['field']] = strtolower(only_chars_nums_underscore($item['value'])); } } $obj->aliases = $aliases; $this->update_config($obj, $obj->objName); } } $tpl = 'aliases'; break; } echo $this->display_object_settings($obj, $tpl); }