} ?> <!-- share button --> <?php if (conf('site.common.shareButton.isEnabled', 'page') && check_public_flag($album_image->public_flag)) { echo render('_parts/services/share', array('text' => $album_image->name ?: $album_image->album->name)); } ?> </div><!-- .comment_info --> <div id="comment_list"> <?php echo render('_parts/comment/list', array('parent' => $album_image, 'list' => $comments, 'next_id' => $comment_next_id, 'delete_uri' => 'album/image/comment/api/delete.json', 'counter_selector' => '#comment_count_' . $album_image->id, 'list_more_box_attrs' => array('data-uri' => 'album/image/comment/api/list/' . $album_image->id . '.json', 'data-template' => '#comment-template'), 'like_api_uri_prefix' => 'album/image/comment', 'liked_ids' => $liked_ids)); ?> </div> <?php if (Auth::check()) { echo render('_parts/comment/post', array('id' => $album_image->id, 'size' => 'M', 'textarea_attrs' => array('id' => 'textarea_comment_' . $album_image->id), 'button_attrs' => array('data-post_uri' => 'album/image/comment/api/create/' . $album_image->id . '.json', 'data-get_uri' => 'album/image/comment/api/list/' . $album_image->id . '.json', 'data-list' => '#comment_list', 'data-template' => '#comment-template', 'data-counter' => '#comment_count_' . $album_image->id))); } ?> <?php if (is_enabled_map('image/detail', 'album')) { echo render('_parts/map/detail', array('auther_member_id' => $album_image->album->member_id, 'locations' => $locations, 'save_uri' => \Album\Site_Util::get_save_location_api_uri($album_image->id), 'markers' => $locations ? Site_Util::get_map_markers($locations) : array(), 'marker_template' => '#map-marker-image-template', 'marker_images' => array('uri' => img_uri($album_image->get_image(), 'M'), 'alt' => $album_image->name))); } ?>
public static function _init() { static::$_properties['member_id'] = Util_Orm::get_relational_numeric_key_prop(); static::$_properties['profile_id'] = Util_Orm::get_relational_numeric_key_prop(); static::$_properties['profile_option_id'] = Util_Orm::get_relational_numeric_key_prop(false); static::$_properties['public_flag']['validation']['in_array'][] = Site_Util::get_public_flags(); }
public static function _init() { static::$_properties['name']['label'] = term('member.name'); static::$_properties['name']['validation']['min_length'][] = conf('member.name.validation.length.min'); static::$_properties['name']['validation']['max_length'][] = conf('member.name.validation.length.max'); if (is_enabled('notice') && conf('mention.isEnabled', 'notice')) { static::$_properties['name']['validation']['match_pattern'][] = sprintf('/^(%s)$/u', conf('member.name.validation.match_patterns.register')); $method = conf('member.name.validation.blacklist.method'); if (is_callable($method)) { static::$_properties['name']['validation']['not_in_array'][] = call_user_func($method); } } static::$_properties['register_type']['validation']['in_array'][] = Site_Member::get_accept_member_register_types(); $sex_options = Site_Form::get_form_options4config('term.member.sex.options'); static::$_properties['sex']['label'] = term('member.sex.label'); static::$_properties['sex']['form']['options'] = $sex_options; static::$_properties['sex']['validation']['in_array'][] = array_keys($sex_options); $options_public_flag = Site_Util::get_public_flags(); static::$_properties['sex_public_flag']['label'] = sprintf('%sの%s', term('member.sex.label'), term('public_flag.label')); static::$_properties['sex_public_flag']['form'] = Site_Form::get_public_flag_configs(); static::$_properties['sex_public_flag']['validation']['in_array'][] = $options_public_flag; static::$_properties['birthyear']['label'] = term('member.birthyear'); $options = Form_Util::get_year_options(conf('member.profile.birthday.year_from'), conf('member.profile.birthday.year_to')); static::$_properties['birthyear']['form']['options'] = $options; static::$_properties['birthyear']['validation']['in_array'][] = array_keys($options); static::$_properties['birthyear_public_flag']['label'] = sprintf('%sの%s', term('member.birthyear'), term('public_flag.label')); static::$_properties['birthyear_public_flag']['form'] = Site_Form::get_public_flag_configs(); static::$_properties['birthyear_public_flag']['validation']['in_array'][] = $options_public_flag; static::$_properties['birthday']['label'] = term('member.birthday'); static::$_properties['birthday_public_flag']['label'] = sprintf('%sの%s', term('member.birthday'), term('public_flag.label')); static::$_properties['birthday_public_flag']['form'] = Site_Form::get_public_flag_configs(); static::$_properties['birthday_public_flag']['validation']['in_array'][] = $options_public_flag; static::$_properties['invite_member_id'] = Util_Orm::get_relational_numeric_key_prop(false); }
/** * Update watch status * * @access public * @param string $foreign_table target related table * @param int $foreign_id target related table id * @return Response (json) * @throws Exception in Controller_Base::controller_common_api * @see Controller_Base::controller_common_api */ public function post_update_watch_status($foreign_table = null, $foreign_id = null) { $this->controller_common_api(function () use($foreign_table, $foreign_id) { if (!is_enabled('notice')) { throw new \HttpNotFoundException(); } if (\Input::post('foreign_table')) { $foreign_table = \Input::post('foreign_table'); } $foreign_id = intval(\Input::post('foreign_id') ?: $foreign_id); if (!$foreign_table || !$foreign_id) { throw new \HttpNotFoundException(); } if (!in_array($foreign_table, Site_Util::get_accept_foreign_tables())) { throw new \HttpNotFoundException(); } $this->response_body['errors']['message_default'] = term('form.watch') . '状態の変更に失敗しました。'; $model = \Site_Model::get_model_name($foreign_table); $foreign_obj = $model::check_authority($foreign_id); $member_id = $foreign_table == 'album_image' ? $foreign_obj->album->member_id : $foreign_obj->member_id; $this->check_browse_authority($foreign_obj->public_flag, $member_id); if ($member_id == $this->u->id) { throw new \HttpBadRequestException(); } \DB::start_transaction(); $is_registerd = (bool) Model_MemberWatchContent::change_registered_status4unique_key(array('foreign_table' => $foreign_table, 'foreign_id' => $foreign_id, 'member_id' => $this->u->id)); \DB::commit_transaction(); $data = array('result' => $is_registerd, 'message' => $is_registerd ? term('form.watch') . '対象に追加しました。' : term('form.watch') . 'を解除しました。', 'html' => icon_label($is_registerd ? 'form.do_unwatch' : 'form.do_watch', 'both', false)); $this->set_response_body_api($data); }); }
public static function get_validation_notice($member_id) { $val = \Validation::forge('member_config_notice'); $name = self::get_name('comment'); $value = self::get_value($member_id, $name, parent::get_default_value($name, 1)); $label = sprintf('自分の%sに%sされた時', term('form.post'), term('form.comment')); $options = self::get_options_recieve(); $val->add($name, $label, array('type' => 'radio', 'options' => $options, 'value' => $value))->add_rule('valid_string', 'numeric', 'required')->add_rule('required')->add_rule('in_array', array_keys($options)); $name = self::get_name('like'); $value = self::get_value($member_id, $name, parent::get_default_value($name, 1)); $label = sprintf('自分の%sに%sされた時', term('form.post'), term('form.like')); $options = self::get_options_recieve(); $val->add($name, $label, array('type' => 'radio', 'options' => $options, 'value' => $value))->add_rule('valid_string', 'numeric', 'required')->add_rule('required')->add_rule('in_array', array_keys($options)); $name = Site_Util::get_member_config_name_for_watch_content('comment'); $value = self::get_value($member_id, $name, parent::get_default_value($name, 1)); $label = sprintf('自分が%sした%s', term('form.comment'), term('form.post')); $options = self::get_options_watch(); $val->add($name, $label, array('type' => 'radio', 'options' => $options, 'value' => $value))->add_rule('valid_string', 'numeric', 'required')->add_rule('required')->add_rule('in_array', array_keys($options)); $name = Site_Util::get_member_config_name_for_watch_content('like'); $value = self::get_value($member_id, $name, parent::get_default_value($name, 1)); $label = sprintf('自分が%sした%s', term('form.like'), term('form.post')); $options = self::get_options_watch(); $val->add($name, $label, array('type' => 'radio', 'options' => $options, 'value' => $value))->add_rule('valid_string', 'numeric', 'required')->add_rule('required')->add_rule('in_array', array_keys($options)); return $val; }
public static function delete_timeline4id($timeline_id) { $delete_target_notice_cache_member_ids = array(); $writable_connection = \MyOrm\Model::connection(true); \DBUtil::set_connection($writable_connection); \DB::start_transaction(); if (is_enabled('notice')) { \Notice\Site_NoOrmModel::delete_member_watch_content_multiple4foreign_data('timeline', $timeline_id); $notice_ids = \Notice\Site_NoOrmModel::get_notice_ids4foreign_data('timeline', $timeline_id); $delete_target_notice_cache_member_ids = \Notice\Site_NoOrmModel::get_notice_status_member_ids4notice_ids($notice_ids); \Notice\Site_NoOrmModel::delete_notice_multiple4ids($notice_ids); } if (!\DB::delete('timeline')->where('id', $timeline_id)->execute()) { throw new \FuelException('Failed to delete timeline. id:' . $timeline_id); } \DB::commit_transaction(); \DBUtil::set_connection(null); // delete caches if ($delete_target_notice_cache_member_ids) { foreach ($delete_target_notice_cache_member_ids as $member_id) { \Notice\Site_Util::delete_unread_count_cache($member_id); } } Site_Util::delete_cache($timeline_id); }
protected function url2link_callback($matches) { $url = str_replace('&', '&', $matches[0]); $items = parse_url($url); $length = $this->options['url2link_truncate_width']; $truncated_marker = $this->options['url2link_trimmarker']; if (!$this->url2link_site_summary_url) { $this->url2link_site_summary_url = $url; } if (strlen($url) > $length) { $length -= strlen($truncated_marker); $urlstr = substr($url, 0, $length) . $truncated_marker; } else { $urlstr = $url; } $attr = array(); if (Site_Util::check_ext_uri($url)) { $attr['target'] = '_blank'; } else { //TODO: add album image view. } $url = Security::htmlentities($url); $urlstr = Security::htmlentities($urlstr); return Html::anchor($url, $urlstr, $attr); }
/** * Creates a url with the given uri, including the base url * * @param string $uri The uri to create the URL for * @param array $variables Some variables for the URL * @param array $get_variables Any GET urls to append via a query string * @param bool $secure If false, force http. If true, force https * @return string */ public static function create($uri = null, $variables = array(), $get_variables = array(), $secure = null) { if (is_null($secure) && FBD_SSL_MODE) { $secure = Site_Util::check_ssl_required_uri($uri, FBD_SSL_MODE == 'ALL'); } return parent::create($uri, $variables, $get_variables, $secure); }
/** * Creates an html image tag * * Sets the alt atribute to filename of it is not supplied. * DocumentRoot 以下の絶対パスを返すように改修 * * @param string the source * @param array the attributes array * @return string the image tag */ public static function img($src, $attr = array(), $is_absolute_url = false) { if (!preg_match('#^(\\w+://)# i', $src)) { $src = Site_Util::get_media_uri($src, $is_absolute_url); } $attr['src'] = $src; $attr['alt'] = isset($attr['alt']) ? $attr['alt'] : pathinfo($src, PATHINFO_FILENAME); return html_tag('img', $attr); }
protected function setUp() { self::$like_count = \Util_Orm::get_count_all('\\Timeline\\Model_TimelineCommentLike', array('timeline_comment_id' => self::$timeline_comment->id)); // timeline view cache 作成 if (self::$is_check_view_cache) { Site_Util::get_article_main_view(self::$timeline->id); self::$view_cache_before = \Cache::get(Site_Util::get_cache_key(self::$timeline->id), \Config::get('timeline.articles.cache.expir')); } }
/** * Action detail * * @access public * @params integer * @return Response */ public function action_detail($slug = null) { $content_page = Model_ContentPage::check_authority4unique_key('slug', $slug); $this->check_browse_authority(\Site_Util::convert_is_secure2public_flag($content_page->is_secure)); $this->set_title_and_breadcrumbs($content_page->title); $this->template->content = \View::forge('page/detail', array('content_page' => $content_page)); if (Site_Util::check_editor_enabled()) { $this->template->content->set_safe('html_body', $content_page->body); } }
public function update_public_flag($public_flag, $is_skip_check_album_disabled_to_update = false) { if (!$is_skip_check_album_disabled_to_update && ($result = Site_Util::check_album_disabled_to_update($this->album->foreign_table))) { throw new \DisableToUpdateException($result['message']); } $this->public_flag = $public_flag; $result = $this->save(); if (\Module::loaded('timeline')) { \Timeline\Model_Timeline::check_and_update_public_flag4child_data($public_flag, 'album_image', $this->id); } return $result; }
public static function create_instantly($user_id) { $obj = self::forge(); $obj->slug = Site_Util::get_slug(); $obj->title = date(conf('default.dateFormat')) . 'の' . term('news.view'); $obj->users_id = $user_id; $obj->token = \Security::generate_token(); $obj->is_published = 0; $obj->format = conf('form.formats.default', 'news'); $obj->save(); return $obj; }
public static function _init() { static::$_properties['public_flag']['form'] = \Site_Form::get_public_flag_configs(); static::$_properties['public_flag']['validation']['in_array'][] = \Site_Util::get_public_flags(); if (is_enabled('notice')) { static::$_observers['MyOrm\\Observer_DeleteNotice'] = array('events' => array('before_delete'), 'conditions' => array('foreign_table' => array('note' => 'value'), 'foreign_id' => array('id' => 'property'))); } if (is_enabled('timeline')) { $type_note = \Config::get('timeline.types.note'); // 更新時に timeline の sort_datetime, comment_count を更新 static::$_observers['MyOrm\\Observer_UpdateRelationalTables'] = array('events' => array('after_update'), 'relations' => array('model_to' => '\\Timeline\\Model_Timeline', 'conditions' => array('foreign_table' => array('note' => 'value'), 'foreign_id' => array('id' => 'property'), 'type' => array($type_note => 'value')), 'check_changed' => array('check_properties' => array('title', 'body', 'public_flag', 'sort_datetime', 'comment_count', 'like_count')), 'update_properties' => array('public_flag', 'sort_datetime', 'comment_count', 'like_count', 'updated_at'))); } }
public static function _init() { static::$_properties['default_public_flag']['form'] = Site_Form::get_public_flag_configs(); static::$_properties['default_public_flag']['validation']['in_array'][] = Site_Util::get_public_flags(); $option_keys = array('form_type', 'display_type', 'value_type', 'is_edit_public_flag', 'is_unique', 'is_disp_regist' => 'get_is_disp_options', 'is_disp_config' => 'get_is_disp_options', 'is_disp_search' => 'get_is_disp_options'); foreach ($option_keys as $option_key => $method) { if (is_int($option_key)) { $option_key = $method; $method = sprintf('get_%s_options', $option_key); } self::set_properties_options($option_key, $method); } }
private static function validate_posted_value($name, $curret_value = null) { switch ($name) { case 'timeline_public_flag': $value = Site_Util::validate_posted_public_flag($curret_value); break; case 'timeline_viewType': $value = \Timeline\Site_Model::validate_timeline_viewType(\Input::post('value')); break; default: break; } return $value; }
/** * Timeline detail * * @access public * @params integer * @return Response */ public function action_detail($id = null) { $timeline = Model_Timeline::check_authority($id); $this->check_browse_authority($timeline->public_flag, $timeline->member_id); // 既読処理 if (\Auth::check()) { $this->change_notice_status2read($this->u->id, 'timeline', $id); } $liked_timeline_ids = conf('like.isEnabled') && \Auth::check() ? \Site_Model::get_liked_ids('timeline', $this->u->id, array($timeline)) : array(); list($ogp_title, $ogp_description) = Site_Util::get_timeline_ogp_contents($timeline->type, $timeline->body); $this->set_title_and_breadcrumbs(term('timeline', 'site.detail'), null, $timeline->member, 'timeline', null, false, true, array('title' => $ogp_title, 'description' => $ogp_description, 'image' => Site_Util::get_timeline_ogp_image_uri($timeline->type, $timeline->foreign_id, $timeline->id, true))); $this->template->post_footer = \View::forge('_parts/load_timelines'); $this->template->content = \View::forge('_parts/article', array('timeline_id' => $timeline->id, 'type' => $timeline->type, 'member_id' => $timeline->member_id, 'self_member_id' => \Auth::check() ? $this->u->id : 0, 'liked_timeline_ids' => $liked_timeline_ids)); }
public static function get_mentioned_member_ids4body($body) { if (!preg_match_all(Site_Util::get_match_pattern2mention(), $body, $matches, PREG_SET_ORDER)) { return array(); } $member_names = array(); foreach ($matches as $match) { $member_names[] = $match[2]; } if (!($members = \Model_Member::query()->where('name', 'in', $member_names)->get())) { array(); } return \Util_Orm::conv_col2array($members, 'id'); }
/** * Mmeber home * * @access public * @return Response */ public function action_home($id = null) { $id = (int) $id; list($is_mypage, $member, $access_from) = $this->check_auth_and_is_mypage($id); $member_profiles = Model_MemberProfile::get4member_id($member->id, true); $data = array('member' => $member, 'member_profiles' => $member_profiles, 'is_mypage' => $is_mypage, 'access_from' => $access_from, 'display_type' => 'summary'); if (is_enabled('timeline')) { $data['timeline'] = \Timeline\Site_Util::get_list4view(\Auth::check() ? $this->u->id : 0, $member->id, false, null, $this->common_get_list_params(array('desc' => 1, 'latest' => 1, 'limit' => conf('articles.limit', 'timeline')), conf('articles.limit_max', 'timeline'), true)); $data['timeline']['member'] = $member; $this->template->post_footer = \View::forge('timeline::_parts/load_timelines'); } $this->set_title_and_breadcrumbs($member->name . ' さんのページ', array('member/list' => term('member.view', 'site.list')), null, null, array(), false, false, array('title' => $member->name . ' さんのページ', 'image' => Site_Util::get_image_uri4file_name($member->get_image(), 'P_L', 'profile'))); $this->template->content = \View::forge('member/home', $data); }
public static function get_public_flag_options($key = null, $type = 'default', $with_no_change_option = false) { $options = array(); if ($with_no_change_option) { $options[99] = '変更しない'; } $public_flags = Site_Util::get_public_flags($type); foreach ($public_flags as $public_flag) { $options[$public_flag] = term('public_flag.options.' . $public_flag); } if (isset($key)) { return $options[$key]; } return $options; }
/** * Get note list * * @access public * @return Response (html) * @throws Exception in Controller_Base::controller_common_api * @see Controller_Base::controller_common_api */ public function get_list() { $this->api_accept_formats = 'html'; $this->controller_common_api(function () { $category_name = \Input::get('category'); $news_category = $category_name ? Model_NewsCategory::get4name($category_name) : null; $tag_string = \Input::get('tag'); $tags = \Site_Util::validate_tags($tag_string); $ids = $tags ? Model_NewsTag::get_news_ids4tags($tags) : array(); list($limit, $page) = $this->common_get_pager_list_params(); $data = Site_Model::get_list($limit, $page, \Auth::check(), $news_category ? $news_category->id : 0, $ids); $data['category_name'] = $category_name; $data['tag_string'] = implode(', ', $tags); $this->set_response_body_api($data, '_parts/list', array('html_bodys' => Site_Model::convert_raw_bodys($data['list']))); }); }
public static function check_and_create($foreign_table, $foreign_id, $type) { $since_datetime = \Date::forge(strtotime('-' . \Config::get('notice.periode_to_update.default')))->format('mysql'); if (!($obj = self::get_last4foreign_data($foreign_table, $foreign_id, $type, $since_datetime))) { $obj = self::forge(array('foreign_table' => $foreign_table, 'foreign_id' => $foreign_id, 'type' => $type, 'body' => Site_Util::get_notice_body($foreign_table, $type))); if (!in_array($foreign_table, Site_Util::get_accept_parent_tables()) && ($parent_table = \Site_Model::get_parent_table($foreign_table))) { $obj->parent_table = $parent_table; $foreign_obj_name = \Site_Model::get_model_name($foreign_table); $foreign_obj = $foreign_obj_name::find($foreign_id); $parent_id_prop = $parent_table . '_id'; $obj->parent_id = $foreign_obj->{$parent_id_prop}; } $obj->save(); } return $obj; }
public static function get_public_flag_range_max4timeline_id($timeline_id) { if (!($objs = self::get4timeline_id($timeline_id))) { return false; } $public_flag_range_max = false; foreach ($objs as $obj) { // 暫定的に album_image 限定 if ($obj->foreign_table != 'album_image') { continue; } $child_obj = \Album\Model_AlbumImage::check_authority($obj->foreign_id); if ($public_flag_range_max === false || \Site_Util::check_is_expanded_public_flag_range($public_flag_range_max, $child_obj->public_flag)) { $public_flag_range_max = $child_obj->public_flag; } } return $public_flag_range_max; }
function strim($string, $width = 0, $trimmarker = null, $is_html = true, $is_remove_line_feed = false) { if (!$width) { return $string; } if (is_null($trimmarker)) { $trimmarker = '...'; } if ($is_remove_line_feed) { $string = str_replace(array("\r", "\n"), '', $string); } $original_width = mb_strlen($string); if ($is_html) { $string = Site_Util::html_entity_decode($string); } $string = mb_strimwidth($string, 0, $width, $trimmarker); if ($is_html) { $string = Security::htmlentities($string); } return $string; }
public static function check_exists_accessible_uri($paths) { if (!is_array($paths)) { if (!$paths) { return true; } if ($paths == '/') { return true; } return \Auth::has_access(\Site_Util::get_acl_path($paths) . '.GET'); } foreach ($paths as $name => $path) { if (is_array($path)) { if (isset($path['href']) && isset($path['method']) && \Auth::has_access(\Site_Util::get_acl_path($path['href']) . '.' . $path['method'])) { return true; } } else { if (\Auth::has_access(\Site_Util::get_acl_path($path) . '.GET')) { return true; } } } return false; }
private function form_setting_email() { $add_fields = array('email' => \Form_Util::get_model_field('admin_user', 'email', sprintf('新しい%s', term('site.email'))), 'email_confirm' => array('label' => sprintf('新しい%s(確認用)', term('site.email')), 'attributes' => array('type' => 'email', 'class' => 'input-xlarge form-control'), 'rules' => array('required', array('match_field', 'email')))); $add_fields['email']['attributes']['class'] .= ' input-xlarge'; return \Site_Util::get_form_instance('setting_email', null, true, $add_fields, array('value' => term('form.do_update'))); }
<div id="btn_menu"> <?php if ($is_mypage) { echo btn(term('album', 'form.create'), 'album/create', 'mr', true, null, null, null, 'plus', null, null, false); } $name = $is_mypage ? '自分' : member_name($member) . 'さん'; $controller = Site_Util::get_controller_name(); if ($controller == 'album') { echo btn(sprintf('%sの%sを全て見る', $name, term('album_image')), sprintf('album/member/%d/images', $member->id), 'mr', true, null, null, null, 'picture', null, null, false); } elseif ($controller == 'image') { echo btn(sprintf('%sの%sを全て見る', $name, term('album')), sprintf('album/member/%d', $member->id), 'mr', true, null, null, null, 'picture', null, null, false); } ?> </div>
/** * News delete * * @access public * @params integer * @return Response */ public function action_delete($id = null) { $id = (int) $id; \Util_security::check_method('POST'); \Util_security::check_csrf(); $error_message = ''; $is_transaction_rollback = false; try { $member = \Model_Member::check_authority($id); $message = \Site_Member::remove($member); \Session::set_flash('message', $message); } catch (\EmailValidationFailedException $e) { \Util_Toolkit::log_error('send mail error: ' . __METHOD__ . ' validation error'); $error_message = 'メール送信エラー'; } catch (\EmailSendingFailedException $e) { \Util_Toolkit::log_error('send mail error: ' . __METHOD__ . ' sending error'); $error_message = 'メール送信エラー'; } catch (\Auth\SimpleUserUpdateException $e) { $is_transaction_rollback = true; $error_message = term('member.view') . 'が存在しません。'; } catch (\Database_Exception $e) { $is_transaction_rollback = true; $error_message = \Site_Controller::get_error_message($e, true); } catch (\FuelException $e) { $is_transaction_rollback = true; if (!($error_message = $e->getMessage())) { $error_message = term('site.left') . 'に失敗しました。'; } } if ($error_message) { if ($is_transaction_rollback && \DB::in_transaction()) { \DB::rollback_transaction(); } \Session::set_flash('error', $error_message); } \Response::redirect(\Site_Util::get_redirect_uri('admin/member')); }
/** * Admin account delete * * @access public * @params integer * @return Response */ public function action_delete($id = null) { \Util_security::check_method('POST'); \Util_security::check_csrf(); if (check_original_user($id, true)) { throw new \HttpForbiddenException(); } $user = Model_AdminUser::check_authority($id); try { $auth = \Auth::instance(); \DB::start_transaction(); $auth->delete_user($user->username); \DB::commit_transaction(); \Session::set_flash('message', term('admin.user.view') . 'を削除しました。'); } catch (\FuelException $e) { if (\DB::in_transaction()) { \DB::rollback_transaction(); } \Session::set_flash('error', $e->getMessage()); } \Response::redirect(\Site_Util::get_redirect_uri('admin/account')); }
/** * News delete * * @access public * @params integer * @return Response */ public function action_delete($id = null) { \Util_security::check_method('POST'); \Util_security::check_csrf(); $content_page = \Content\Model_ContentPage::check_authority($id); $error_message = ''; try { \DB::start_transaction(); $content_page->delete(); \DB::commit_transaction(); \Session::set_flash('message', term('content.page') . 'を削除しました。'); } catch (\Database_Exception $e) { $error_message = \Site_Controller::get_error_message($e, true); } catch (\FuelException $e) { $error_message = $e->getMessage(); } if ($error_message) { if (\DB::in_transaction()) { \DB::rollback_transaction(); } \Session::set_flash('error', $error_message); } \Response::redirect(\Site_Util::get_redirect_uri('admin/content/page')); }