public function outdate($active_score = -10) { $option = array('outdate' => 0, 'active_score <=' => -10); echo "SET OUTDATE :"; $query = $this->db->get_where('page', $option); if ($query->num_rows() > 0) { $page = new Page_model(); foreach ($query->result() as $row) { echo $row->id . ','; $page->init($row->id); $page->outdate = 1; $page->update(); } unset($page); } }
public function update($fields, $publish_mothod = 'draft') { // Additional updates which need to be made to event items only if (in_array($fields['type'], array('page_calendar_event', 'mirror_calendar_event_source'))) { $date_fields = array('content_start_date', 'content_end_date'); foreach ($date_fields as $date_field) { if (!empty($fields[$date_field . '_day'])) { $content_date = $fields[$date_field . '_day']; if (!empty($fields[$date_field . '_time'])) { $hour = $fields[$date_field . '_time'][0]; $mins = !empty($fields[$date_field . '_time'][1]) ? $fields[$date_field . '_time'][1] : '00'; if ($fields[$date_field . '_time'][2] == 'pm') { $hour = $hour + 12; } $content_date .= ' ' . $hour . ':' . $mins . ':00'; } else { $content_date .= ' 00:00:00'; } $fields[$date_field] = $content_date; } } $fields['file_title'] = $fields['title']; $fields['file_name'] = strtolower(preg_replace("/[^a-z\\-_\\d]/i", "", underscore($fields['file_title']))); } // Do update (through page model) $update_item = parent::update($fields, $publish_mothod); // When you update a mirror source let's see if a destination should be automatically set up. // TODO: This should be moved to the create method after CHW implementation. if (!empty($update_item['parent_id']) && !empty($update_item['type']) && $update_item['type'] == 'mirror_calendar_event_source') { $parent = CI()->page_model->getById($update_item['parent_id'], 'navigation'); // We only do this if this is inside a source. Parent source must always be set up manually. if ($parent[0]['type'] == 'mirror_calendar_source') { $mirror_parent = CI()->page_model->get(array('source_id' => $parent[0]['page_id']), 'navigation'); foreach ($mirror_parent as $mp) { // Is there a copy of this already in there? $mirror_item = CI()->page_model->get(array('parent_id' => $mp['page_id'], 'source_id' => $update_item['page_id']), 'navigation'); if (!count($mirror_item)) { // Create it $mirror_create = array('title' => $update_item['title'], 'module' => 'page_calendar', 'type' => 'mirror_calendar_event', 'parent_path' => $mp['path'], 'parent_id' => $mp['page_id'], 'source_id' => $update_item['page_id'], 'template_id' => $update_item['template_id'], 'page_id' => -1); CI()->page_calendar_model->update($mirror_create); } } } } return $update_item; }
/** * @param int $id_page */ protected function _remove_link($id_page) { $context = array('link_type' => '', 'link_id' => '', 'link' => ''); // Save the context $this->page_model->update(array('id_page' => $id_page), $context); }