public function update($fields)
 {
     $fields['template_title'] = trim($fields['template_title']);
     if (!empty($fields['template_title'])) {
         $this->load->helper('url');
         $fields['template_file_name'] = strtolower(url_title($fields['template_title']));
     }
     // options: Create JSON string from post array
     if (!empty($fields['template_options']) && is_array($fields['template_options'])) {
         $fields['template_options'] = json_encode($fields['template_options']);
     }
     $update_item = parent::update($fields);
     // Clear page cache for linked pages
     // Update child sort if method changed
     if (!empty($fields['orig_sort_method']) && !empty($fields['template_options']['child_sort_method']) && $fields['orig_sort_method'] != $fields['template_options']['child_sort_method']) {
         $this->load->model('page_model');
         $pages = CI()->page_model->get(array($this->id_field => $update_item[$this->id_field]));
         foreach ($pages as $page) {
             if ($page['type'] != 'section') {
                 continue;
             }
             CI()->page_model->_updateSort(array('parent_id' => $page['page_id']));
         }
     }
     return $update_item;
 }
 public function update($fields)
 {
     if (!empty($fields['value']) && is_array($fields['value'])) {
         $fields['value'] = json_encode($fields['value']);
     }
     return parent::update($fields);
 }
 public function update($fields)
 {
     $update_item = parent::update($fields);
     // Everytime you update a value, let's publish it.
     CI()->load->model('publish_queue_model');
     CI()->publish_queue_model->publish($this->table, $update_item[$this->id_field], $update_item);
     return $update_item;
 }
 public function update($fields)
 {
     $fields['group_key'] = strtolower(preg_replace("/[^a-z\\-_\\d]/i", "", underscore($fields['group_title'])));
     $update_item = parent::update($fields);
     // Everytime you update a group, let's publish it.
     CI()->load->model('publish_queue_model');
     CI()->publish_queue_model->publish($this->table, $update_item[$this->id_field], $update_item);
     return $update_item;
 }
 public function update($fields)
 {
     $fields['editor_id'] = $this->authentication->get('user_id');
     $fields['old_path'] = $this->cleanPath($fields['old_path']);
     $fields['new_path'] = $this->cleanPath($fields['new_path']);
     // Do update (through application model)
     $update_item = parent::update($fields);
     // Always publish these immediately
     CI()->load->model('publish_queue_model');
     CI()->publish_queue_model->publish($this->table, $update_item[$this->id_field], $update_item);
     return $update_item;
 }
 public function update($fields)
 {
     if (!empty($fields['value']) && is_array($fields['value'])) {
         $fields['value'] = json_encode($fields['value']);
     }
     $update_fields = parent::update($fields);
     if ($this->ADMIN_CONF['publish']['publish_method'] != 'local_table') {
         // Queue template for publish
         CI()->load->model('publish_queue_model');
         CI()->publish_queue_model->publish($this->table, $update_fields[$this->id_field], $update_fields);
     }
     return $update_fields;
 }
 public function update($fields)
 {
     if (empty($fields['all_day'])) {
         $fields['all_day'] = '0';
         $fields['ignore_end'] = '0';
     } else {
         $fields['start_time'] = '';
         $fields['end_time'] = '';
     }
     if (empty($fields['ignore_end'])) {
         $fields['ignore_end'] = '0';
     }
     if (!empty($fields['start_time']) && is_array($fields['start_time'])) {
         $fields['start_time'] = timeFromArray($fields['start_time']);
     }
     if (!empty($fields['end_time']) && is_array($fields['end_time'])) {
         $fields['end_time'] = timeFromArray($fields['end_time']);
     }
     return parent::update($fields);
 }
 public function update($fields = array())
 {
     if (!count($fields)) {
         show_error('Invalid update parameters.');
     }
     if (!empty($fields['permission_group']) && $fields['permission_group'] == 'administrator' && $this->authentication->get('permission_group') != 'administrator') {
         show_error('You are not allowed to edit or create Administrator users. If you feel you have reached this page in error please contact the website administrator.');
     }
     if (!empty($fields['password_new']) && !empty($fields['password_confirm'])) {
         // Passwords Match?
         if ($fields['password_new'] != $fields['password_confirm']) {
             show_error('New password does not match confirmation.');
         }
         // New Password Length
         if (strlen($fields['password_new']) < $this->ADMIN_CONF['login']['req_password_len']) {
             show_error('Password must be ' . $this->ADMIN_CONF['login']['req_password_len'] . ' characters or longer.');
         }
         $fields['password'] = encryptString($fields['password_new']);
         $fields['password_options'] = $this->_setPasswordOptions($fields);
     }
     return parent::update($fields);
 }
 public function update($fields)
 {
     $fields['template_title'] = trim($fields['template_title']);
     if (!empty($fields['template_title'])) {
         $this->load->helper('url');
         $fields['template_file_name'] = strtolower(url_title($fields['template_title']));
     }
     if (empty($fields['template_attributes'])) {
         $fields['template_attributes'] = array();
     }
     if (!empty($fields['template_attributes_new'])) {
         // Get list of all attribuge groups for dropdown
         $all_attributegroups = CI()->page_attributegroup_model->getAllGroupsForDropdown(array());
         foreach ($fields['template_attributes_new'] as $group_id) {
             if (!empty($group_id)) {
                 $fields['template_attributes'][$group_id] = array('title' => $all_attributegroups[$group_id], 'multi' => 'no', 'can_add' => 'yes', 'attribute_group_id' => $group_id);
             }
         }
     }
     $update_item = parent::update($fields);
     // Clear page cache for linked pages
     // Update child sort if method changed
     if (!empty($fields['orig_sort_method']) && !empty($fields['template_options']['child_sort_method']) && $fields['orig_sort_method'] != $fields['template_options']['child_sort_method']) {
         $this->load->model('page_model');
         $pages = CI()->page_model->get(array($this->id_field => $update_item[$this->id_field]));
         foreach ($pages as $page) {
             if ($page['type'] != 'section') {
                 continue;
             }
             CI()->page_model->_updateSort(array('parent_id' => $page['page_id']));
         }
     }
     // Queue template for publish
     CI()->load->model('publish_queue_model');
     CI()->publish_queue_model->publish($this->table, $update_item[$this->id_field], $update_item);
     return $update_item;
 }
 public function update($fields = array())
 {
     $exists = $this->db->select($this->id_field)->where($this->id_field, $fields[$this->id_field])->get($this->table)->row_array();
     if (count($exists)) {
         parent::update($fields);
     } else {
         // This is an almost mirror of parent::insert, but we don't strip id_field
         // Transform array fields into json
         if (count($this->json_fields)) {
             foreach ($this->json_fields as $_field) {
                 if (isset($fields[$_field])) {
                     $fields[$_field] = json_encode($fields[$_field]);
                 }
             }
         }
         // Get fields, this needs to happen after any field transformations
         $this->_getMatchingFields($fields);
         // Create query	 & run
         $this->_addQueryValues();
         $this->_addQueryDateValue('update');
         $this->_addQueryDateValue('insert');
         $this->db->insert($this->table);
     }
 }
 public function update($fields)
 {
     // Before we insert, clean up old/expired records
     if (!empty($fields['id'])) {
         $this->clear($fields['page_id']);
     }
     parent::update($fields);
 }
Beispiel #12
0
 public function update($fields = array())
 {
     $row = parent::update($fields);
     if (empty($row['ext'])) {
         $sub = $this->getById($row[$this->id_field]);
         $row = $sub[0];
     }
     $var_length = (int) $this->FILE_CONF['file_dir_depth'] * 3;
     $path_array = str_split(str_pad($row[$this->id_field], $var_length, '0', STR_PAD_LEFT), 3);
     $upload_path = implode('/', $path_array);
     // Add file paths
     $row['server_path'] = DOCROOT . zonepath($this->FILE_CONF['file_directory'], 'local') . '/' . $upload_path . $row['ext'];
     $row['app_path'] = $upload_path . $row['ext'];
     // Queue file for publish
     //CI()->load->model('publish_queue_model');
     //CI()->publish_queue_model->publish($this->table, $row[$this->id_field], $row);
     return $row;
 }
 public function delete($module = null, $module_id = null)
 {
     $publish_fields = array('queue_date' => EMPTY_DATE, 'queue_type' => 'delete', 'module' => $module, 'module_id' => $module_id);
     parent::update($publish_fields);
     return TRUE;
 }
Beispiel #14
0
 public function delete($id)
 {
     // We do not actually delete items in this model. Just change their status to deleted.
     if (!($id > 1)) {
         show_error(__METHOD__ . ' Invalid id: ' . $id);
     }
     $fields = array();
     $fields[$this->id_field] = $id;
     $fields['status'] = 99;
     parent::update($fields);
     if ($this->ADMIN_CONF['publish']['publish_method'] == 'local_table') {
         // Delete from local table
         CI()->load->model('page_published_model');
         CI()->page_published_model->delete($id);
     } else {
         // Queue page for delete on remote
         CI()->load->model('publish_queue_model');
         CI()->publish_queue_model->delete($this->table, $id, $fields);
     }
     log_message('debug', 'Deleted ' . $this->id_field . ' #' . $id);
     $children = $this->selectSet('basic')->get(array('parent_id' => $id));
     if (count($children)) {
         foreach ($children as $child) {
             $this->delete($child[$this->id_field]);
         }
     }
     return true;
 }
Beispiel #15
0
 public function update($fields = array())
 {
     if (!empty($fields['file_name'])) {
         $fields['file_name'] = strtolower(preg_replace("/[^a-z\\-_\\d]/i", "", underscore($fields['file_name'])));
     }
     $row = parent::update($fields);
     if (empty($row['ext'])) {
         $sub = $this->getById($row[$this->id_field]);
         $row = $sub[0];
     }
     $var_length = (int) $this->FILE_CONF['file_dir_depth'] * 3;
     $path_array = str_split(str_pad($row[$this->id_field], $var_length, '0', STR_PAD_LEFT), 3);
     $upload_path = implode('/', $path_array);
     // Add file paths
     $row['server_path'] = DOCROOT . zonepath($this->FILE_CONF['file_directory'], 'local') . '/' . $upload_path . $row['ext'];
     $row['app_path'] = $upload_path . $row['ext'];
     if ($this->ADMIN_CONF['publish']['publish_method'] != 'local_table') {
         // Queue file for publish
         CI()->load->model('publish_queue_model');
         CI()->publish_queue_model->publish($this->table, $row[$this->id_field], $row);
     }
     return $row;
 }