protected function update_sort_order() { if (!($ids = \Util_Array::cast_values(explode(',', \Input::post('ids')), 'int', true))) { throw new \HttpInvalidInputException('Invalid input data.'); } return \Site_Model::update_sort_order($ids, \News\Model_NewsCategory::forge()); }
public static function get_file_tmps_uploaded($member_id = null, $check_selected = false, $type = 'img', $check_file_exists = true, $is_delete_not_exists_file = false) { $file_tmps = array(); $post_key = $type == 'img' ? 'image_tmp' : 'file_tmp'; if (!($file_tmps_posted = Input::post($post_key))) { if ($check_selected) { throw new HttpInvalidInputException('File not selected.'); } return array(); } if (!($file_tmp_ids = Util_Array::cast_values(array_keys($file_tmps_posted), 'int', true))) { throw new HttpInvalidInputException('Invalid input data.'); } if (!($file_tmps = Model_FileTmp::get4ids($file_tmp_ids))) { throw new FuelException('ファイルが選択されていません。'); } foreach ($file_tmps as $key => $file_tmp) { if ($member_id && $file_tmp->member_id != $member_id) { throw new HttpForbiddenException(); } if ($file_tmps_posted[$file_tmp->id] != $file_tmp->name) { throw new HttpInvalidInputException('Invalid input data.'); } $file_tmps_description_posted = Input::post($post_key . '_description'); if (isset($file_tmps_description_posted[$file_tmp->id])) { $file_tmps[$key]->description = trim($file_tmps_description_posted[$file_tmp->id]); } $file_tmp_path = Site_Upload::get_uploaded_file_path($file_tmp->name, 'raw', 'img', true); if (conf('upload.storageType') == 'normal' && !file_exists($file_tmp_path)) { if ($check_file_exists) { throw new HttpInvalidInputException('File not exists.'); } if ($is_delete_not_exists_file) { $file_tmp->delete(); } unset($file_tmps[$file_tmp->id]); } } return $file_tmps; }
public static function get4ids($ids, $limit = 0, $sort = array('id' => 'asc'), $relateds = array()) { if (!is_array($ids)) { $ids = (array) $ids; } if (!($ids = \Util_Array::cast_values($ids, 'int', true))) { throw new \InvalidArgumentException('First parameter is invalid.'); } $query = self::query()->where('id', 'in', $ids); if ($relateds) { $query->related($relateds); } if ($sort) { foreach ($sort as $column => $order) { $query->order_by($column, $order); } } if ($limit) { $query->rows_limit($limit); } return $query->get(); }