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); }
public function save_with_relations($member_id, $values) { if (!empty($this->member_id) && $this->member_id != $member_id) { throw new \InvalidArgumentException('Parameter member_id is invalid.'); } $is_new = $this->_is_new; $this->member_id = $member_id; if (isset($values['title'])) { $this->title = $values['title']; } if (isset($values['body'])) { $this->body = $values['body']; } if (isset($values['public_flag'])) { $this->public_flag = $values['public_flag']; } $is_changed_public_flag = $this->is_changed('public_flag'); $is_changed = $this->is_changed(); if ($is_changed) { $this->save(); } if (is_enabled('timeline')) { if (!$is_new && $is_changed_public_flag) { // timeline の public_flag の更新 \Timeline\Model_Timeline::update_public_flag4foreign_table_and_foreign_id($this->public_flag, 'thread', $this->id, \Config::get('timeline.types.thread')); } else { // timeline 投稿 \Timeline\Site_Model::save_timeline($member_id, $this->public_flag, 'thread', $this->id, $this->updated_at); } } return $is_changed; }
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); }
public function before_delete(\Orm\Model $obj) { // カバー写真の確認 & 削除 if (!($album = \Album\Model_Album::find($obj->album_id))) { throw new \FuelException('Invalid album id.'); } if ($album->cover_album_image_id == $obj->id) { $album->cover_album_image_id = null; $album->save(); } // プロフィール写真の確認 & 削除 if ($album->foreign_table == 'member') { if ($album->member->file_name == $obj->file_name) { $album->member->file_name = null; $album->member->save(); } // timeline 投稿の削除 if (is_enabled('timeline')) { \Timeline\Model_Timeline::delete4foreign_table_and_foreign_ids('album_image', $obj->id); } } if (is_enabled('timeline')) { // timeline_child_data の削除 \Timeline\Model_TimelineChildData::delete4foreign_table_and_foreign_ids('album_image', $obj->id); // timeline view cache の削除 if (is_enabled('note') && \Config::get('timeline.articles.cache.is_use') && $obj->album->foreign_table == 'note') { \Timeline\Site_Model::delete_note_view_cache4album_image_id($obj->id); } } // file 削除 if ($file = \Model_File::get4name($obj->file_name)) { $file->delete(); } }
/** * Site index * * @access public * @return Response */ public function action_index() { $data = array(); if (Config::get('page.site.index.timeline.isEnabled') && is_enabled('timeline')) { $data['timelines'] = \Timeline\Site_Util::get_list4view(\Auth::check() ? $this->u->id : 0, 0, false, null, $this->common_get_list_params(array('desc' => 1, 'latest' => 1, 'limit' => Config::get('page.site.index.timeline.list.limit')), Config::get('page.site.index.timeline.list.limit_max'), true)); $data['timelines']['see_more_link'] = array('uri' => 'timeline'); //$this->template->post_footer = \View::forge('timeline::_parts/load_timelines'); } if (Config::get('page.site.index.news.isEnabled') && is_enabled('news')) { list($limit, $page) = $this->common_get_pager_list_params(\Config::get('page.site.index.news.list.limit'), \Config::get('page.site.index.news.list.limit_max')); $data['news_list'] = \News\Site_Model::get_list($limit, $page, \Auth::check()); $data['news_list']['see_more_link'] = array('uri' => 'news'); } if (Config::get('page.site.index.albumImage.isEnabled') && is_enabled('album')) { list($limit, $page) = $this->common_get_pager_list_params(\Config::get('page.site.index.albumImage.list.limit'), \Config::get('page.site.index.albumImage.list.limit_max')); $data['album_images'] = \Album\Model_AlbumImage::get_pager_list(array('related' => array('album'), 'where' => \Site_Model::get_where_params4list(0, \Auth::check() ? $this->u->id : 0), 'order_by' => array('id' => 'desc'), 'limit' => $limit), $page); $data['album_images']['liked_album_image_ids'] = conf('like.isEnabled') && \Auth::check() ? \Site_Model::get_liked_ids('album_image', $this->u->id, $data['album_images']['list']) : array(); $data['album_images']['column_count'] = \Config::get('page.site.index.albumImage.list.column_count'); //$this->template->post_footer = \View::forge('image/_parts/list_footer'); } $this->template->post_footer = \View::forge('site/_parts/index_footer'); if (conf('site.index.slide.isEnabled', 'page')) { if (conf('site.index.slide.recentAlbumImage.isEnabled', 'page')) { $images = \Album\Site_Util::get_top_slide_image_uris(); } else { $images = Config::get('page.site.index.slide.images'); } $this->template->post_header_content = View::forge('site/_parts/slide', array('image_uris' => $images)); } $this->set_title_and_breadcrumbs('', null, null, null, null, true, true); $this->template->content = View::forge('site/index', $data); if (!empty($data['news_list']['list'])) { $this->template->content->set_safe('html_bodys', \News\Site_Model::convert_raw_bodys($data['news_list']['list'])); } }
public static function _init() { if (is_enabled('notice')) { static::$_observers['MyOrm\\Observer_InsertNotice'] = array('events' => array('after_insert'), 'update_properties' => array('foreign_table' => array('thread_comment' => 'value'), 'foreign_id' => array('thread_comment_id' => 'property'), 'type_key' => array('like' => 'value'), 'member_id_from' => array('member_id' => 'property'), 'member_id_to' => array('related' => array('thread_comment' => 'member_id')))); $type = \Notice\Site_Util::get_notice_type('like'); static::$_observers['MyOrm\\Observer_DeleteNotice'] = array('events' => array('before_delete'), 'conditions' => array('foreign_table' => array('thread_comment' => 'value'), 'foreign_id' => array('thread_comment_id' => 'property'), 'type' => array($type => 'value'))); } }
/** * @dataProvider like_notice_provider */ public function test_like_notice($member_id_to, $mc_notice_like, $member_id_from, $is_test_after_read, $is_cahce_deleted_exp, $countup_num, $countup_num_all) { if (!is_enabled('notice')) { \Util_Develop::output_test_info(__FILE__, __LINE__); $this->markTestSkipped('notice module is disabled.'); } // 事前準備 \Model_MemberConfig::set_value($member_id_to, \Notice\Form_MemberConfig::get_name('like'), $mc_notice_like); $is_new = false; if (!self::$commented_member_id_before || $member_id_to != self::$commented_member_id_before) { self::$timeline = Site_Test::setup_timeline(self::$member_id); self::$timeline_comment = \Site_Test::save_comment('timeline', self::$timeline->id, $member_id_to); $is_new = true; } self::$commented_member_id_before = $member_id_to; if ($is_test_after_read) { $read_count = \Notice\Site_Util::change_status2read($member_id_to, self::$foreign_table, self::$timeline_comment->id, self::$type_key); } $notice_count_all_before = \Notice\Model_Notice::get_count(); // set cache $notice_count_before = \Notice\Site_Util::get_unread_count($member_id_to); if (self::$is_check_notice_cache) { $this->assertFalse(\Notice\Site_Test::check_no_cache4notice_unread($member_id_to)); } // cache が生成されていることを確認 // like save $is_liked = (bool) Model_TimelineCommentLike::change_registered_status4unique_key(array('timeline_comment_id' => self::$timeline_comment->id, 'member_id' => $member_id_from)); if (self::$is_check_notice_cache) { if ($is_cahce_deleted_exp) { $this->assertTrue(\Notice\Site_Test::check_no_cache4notice_unread($member_id_to)); } else { $this->assertFalse(\Notice\Site_Test::check_no_cache4notice_unread($member_id_to)); } } // notice count 取得 $notice_count = \Notice\Site_Util::get_unread_count($member_id_to); if (self::$is_check_notice_cache) { $this->assertFalse(\Notice\Site_Test::check_no_cache4notice_unread($member_id_to)); } // cache が生成されていることを確認 // execute test $this->assertEquals($notice_count_before + $countup_num, $notice_count); // count up を確認 // Model_Notice // 件数 $notice_count_all = \Notice\Model_Notice::get_count(); $this->assertEquals($notice_count_all_before + $countup_num_all, $notice_count_all); // record if ($notice = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, self::$timeline_comment->id, \Notice\Site_Util::get_notice_type(self::$type_key))) { $notice_status = \Notice\Model_NoticeStatus::get4member_id_and_notice_id($member_id_to, $notice->id); $notice_member_from = \Notice\Model_NoticeMemberFrom::get_last(); if ($mc_notice_like !== 0 && $member_id_to != $member_id_from) { $this->assertEquals($member_id_from, $notice_member_from->member_id); } $this->assertEquals($notice_member_from->created_at, $notice_status->sort_datetime); } }
public static function _init() { if (\Module::loaded('timeline')) { static::$_observers['MyOrm\\Observer_InsertMemberFollowTimeline'] = array('events' => array('after_insert'), 'timeline_relations' => array('foreign_table' => array('album_image' => 'value'), 'foreign_id' => array('album_image_id' => 'property')), 'property_from_member_id' => 'member_id'); } if (is_enabled('notice')) { static::$_observers['MyOrm\\Observer_InsertNotice'] = array('events' => array('after_insert'), 'update_properties' => array('foreign_table' => array('album_image' => 'value'), 'foreign_id' => array('album_image_id' => 'property'), 'type_key' => array('like' => 'value'), 'member_id_from' => array('member_id' => 'property'), 'member_id_to' => array('related' => array('album_image' => array('album' => 'member_id'))))); $type = \Notice\Site_Util::get_notice_type('like'); static::$_observers['MyOrm\\Observer_DeleteNotice'] = array('events' => array('before_delete'), 'conditions' => array('foreign_table' => array('album_image' => 'value'), 'foreign_id' => array('album_image_id' => 'property'), 'type' => array($type => 'value'))); } }
public function after_insert(\Notice\Model_MemberWatchContent $obj) { if (is_enabled('timeline')) { if (!($timelines = \Notice\Site_Model::get_timelines4foreign_table_and_id($obj->foreign_table, $obj->foreign_id))) { return false; } foreach ($timelines as $timeline) { $member_follow_timeline = \Timeline\Model_MemberFollowTimeline::check_and_create($timeline->id, $obj->member_id); } } }
public function before_delete(\Orm\Model $obj) { // Delete album_image file. $album_images = \Album\Model_AlbumImage::get4album_id($obj->id); foreach ($album_images as $album_image) { $album_image->delete(); } // delete timeline if (is_enabled('timeline')) { \Timeline\Model_Timeline::delete4foreign_table_and_foreign_ids('album', $obj->id); } }
function get_enabled_modules_str($target_modules, $delimitter = '|') { foreach ($target_modules as $key => $module) { if (!is_enabled($module)) { unset($target_modules[$key]); } } if (!$target_modules) { return ''; } return implode($delimitter, $target_modules); }
public static function delete_with_timeline($name) { if (!($obj = self::get4name($name))) { return false; } if (is_enabled('timeline')) { \Timeline\Model_Timeline::delete4foreign_table_and_foreign_ids('file', $obj->id); } $deleted_filesize = $obj->filesize; $obj->delete(); return $deleted_filesize; }
public function before_delete(\Notice\Model_MemberWatchContent $obj) { if (is_enabled('timeline')) { if (!($timelines = \Notice\Site_Model::get_timelines4foreign_table_and_id($obj->foreign_table, $obj->foreign_id))) { return false; } foreach ($timelines as $timeline) { $member_follow_timeline = \Timeline\Model_MemberFollowTimeline::get4timeline_id_and_member_id($timeline->id, $obj->member_id); $member_follow_timeline->delete(); } } }
/** * Mmeber_Profile_Image index * * @access public * @return Response */ public function action_index($member_id = null) { list($is_mypage, $member, $access_from) = $this->check_auth_and_is_mypage($member_id); $member_profiles = Model_MemberProfile::get4member_id($member->id, true); $title = term('profile', 'site.picture', $is_mypage ? 'site.setting' : ''); $this->set_title_and_breadcrumbs($title, array('/member/' . $member_id => sprintf('%sさんの%s', $member->name, term('site.page.kana'))), $member); $images = array(); if (is_enabled('album') && conf('upload.types.img.types.m.save_as_album_image')) { $album_id = \Album\Model_Album::get_id_for_foreign_table($member->id, 'member'); $images = \Album\Model_AlbumImage::query()->related('album')->where('album_id', $album_id)->order_by('id', 'desc')->get(); $this->template->post_footer = \View::forge('_parts/load_masonry'); } $this->template->content = View::forge('member/profile/image/index', array('is_mypage' => $is_mypage, 'member' => $member, 'access_from' => $access_from, 'images' => $images, 'member_profiles' => $member_profiles)); }
/** * 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 _init() { static::$_properties['name']['label'] = term('album') . '名'; static::$_properties['public_flag']['form'] = \Site_Form::get_public_flag_configs(); static::$_properties['public_flag']['validation']['in_array'][] = \Site_Util::get_public_flags(); static::$_properties['foreign_table']['validation']['in_array'][] = Site_Util::get_album_foreign_tables(); if (is_enabled('notice')) { static::$_observers['MyOrm\\Observer_DeleteNotice'] = array('events' => array('before_delete'), 'conditions' => array('foreign_table' => array('album' => 'value'), 'foreign_id' => array('id' => 'property'))); } if (\Module::loaded('timeline')) { // 更新時に timeline の sort_datetime を更新 $observer_key = \Config::get('timeline.types.album'); static::$_observers['MyOrm\\Observer_UpdateRelationalTables'] = array('events' => array('after_update'), 'relations' => array('model_to' => '\\Timeline\\Model_Timeline', 'conditions' => array('foreign_table' => array('album' => 'value'), 'foreign_id' => array('id' => 'property'), 'type' => array($observer_key => 'value')), 'check_changed' => array('check_properties' => array('name', 'body', 'public_flag')), 'update_properties' => array('sort_datetime' => array('updated_at' => 'property')))); if (\Config::get('timeline.articles.cache.is_use')) { static::$_observers['MyOrm\\Observer_ExecuteToRelations'] = array('events' => array('after_update'), 'relations' => array('model_to' => '\\Timeline\\Model_Timeline', 'execute_func' => array('method' => '\\Timeline\\Site_Util::delete_cache', 'params' => array('id' => 'property')), 'conditions' => array('foreign_table' => array('album' => 'value'), 'foreign_id' => array('id' => 'property')))); } } }
public static function delete_album_image_multiple4ids($album_image_ids = array(), $with_delete_timeline = false) { if (!is_array($album_image_ids)) { $album_image_ids = (array) $album_image_ids; } $delete_target_notice_cache_member_ids = array(); $delete_target_timeline_ids = array(); $writable_connection = \MyOrm\Model::connection(true); \DBUtil::set_connection($writable_connection); \DB::start_transaction(); foreach ($album_image_ids as $album_image_id) { if (is_enabled('notice')) { \Notice\Site_NoOrmModel::delete_member_watch_content_multiple4foreign_data('album_image', $album_image_id); $notice_ids = \Notice\Site_NoOrmModel::get_notice_ids4foreign_data('album_image', $album_image_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 (is_enabled('timeline') && $with_delete_timeline) { $delete_target_timeline_ids += \timeline\site_noormmodel::delete_timeline_multiple4foreign_data('album_image', $album_image_id); } } $file_names = \Util_Orm::conv_col2array(Model_AlbumImage::get4ids($album_image_ids), 'file_name'); \DB::delete('album_image')->where('id', 'in', $album_image_ids)->execute(); \DB::commit_transaction(); \DBUtil::set_connection(null); \DB::start_transaction(); if ($files = \Model_File::get4names($file_names)) { foreach ($files as $file) { $file->delete(); } } \DB::commit_transaction(); // 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); } } if ($delete_target_timeline_ids) { foreach ($delete_target_timeline_ids as $timeline_id) { \Timeline\Site_Util::delete_cache($timeline_id); } } }
public static function _init() { static::$_properties['type']['validation']['in_array'][] = \Config::get('timeline.types'); static::$_properties['foreign_table']['validation']['in_array'][] = Site_Util::get_accept_timeline_foreign_tables(); 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_InsertNotice'] = array('events' => array('after_insert'), 'update_properties' => array('foreign_table' => array('timeline' => 'value'), 'foreign_id' => array('id' => 'property'), 'type_key' => array('create' => 'value'), 'member_id_from' => array('member_id' => 'property'))); static::$_observers['MyOrm\\Observer_DeleteNotice'] = array('events' => array('before_delete'), 'conditions' => array('foreign_table' => array('timeline' => 'value'), 'foreign_id' => array('id' => 'property'))); } if (\Config::get('timeline.articles.cache.is_use')) { // 更新・削除時に timeline の cache を削除 static::$_observers['MyOrm\\Observer_UpdateTimeline'] = array('events' => array('after_update'), 'check_changed' => array('check_properties' => array('body', 'source', 'source_uri', 'public_flag', 'sort_datetime' => array('ignore_property' => 'comment_count')))); static::$_observers['MyOrm\\Observer_DeleteTimeline'] = array('events' => array('before_delete')); } if (\Config::get('timeline.importanceLevel.isEnabled')) { // 更新時に timeline の importance_level を更新 static::$_observers['MyOrm\\Observer_UpdateTimelineImportanceLevel'] = array('events' => array('before_update')); } }
/** * Perform preflight checks for Mercator * * Checks that we can actually run SSO, then attaches the relevant actions * and filters to make it useful. */ function run_preflight() { if (!is_enabled()) { return; } // Check for COOKIE_DOMAIN definition // // Note that this can't be an admin notice, as you'd never be able to log in // to see it. if (defined('COOKIE_DOMAIN')) { status_header(500); header('X-Mercator: COOKIE_DOMAIN'); wp_die('The constant <code>COOKIE_DOMAIN</code> is defined (probably in <code>wp-config.php</code>). Please remove or comment out that <code>define()</code> line.'); } // E: There's no reason to become alarmed, and we hope you'll enjoy the // rest of your flight. // // E: By the way, is there anyone on board who knows how to fly a plane? bootstrap(); }
public static function _init() { static::$_properties['name']['label'] = term('site.picture', 'site.title'); static::$_properties['public_flag']['form'] = \Site_Form::get_public_flag_configs(); static::$_properties['public_flag']['validation']['in_array'][] = \Site_Util::get_public_flags(); if (conf('albumImageLoction.saveFromExif', 'album')) { static::$_observers['MyOrm\\Observer_SaveAlbumImageLocation'] = array('events' => array('after_insert')); } if (is_enabled('notice')) { static::$_observers['MyOrm\\Observer_InsertNotice'] = array('events' => array('after_insert'), 'update_properties' => array('foreign_table' => array('album' => 'value'), 'foreign_id' => array('album_id' => 'property'), 'type_key' => array('child_data' => 'value'), 'member_id_from' => array('related' => array('album' => 'member_id')))); static::$_observers['MyOrm\\Observer_DeleteNotice'] = array('events' => array('before_delete'), 'conditions' => array('foreign_table' => array('album_image' => 'value'), 'foreign_id' => array('id' => 'property'))); } if (\Module::loaded('timeline')) { $type_album_image_profile = \Config::get('timeline.types.album_image_profile'); // 更新時に 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('album_image' => 'value'), 'foreign_id' => array('id' => 'property'), 'type' => array($type_album_image_profile => 'value')), 'check_changed' => array('check_properties' => array('public_flag', 'sort_datetime', 'comment_count', 'like_count')), 'update_properties' => array('public_flag', 'sort_datetime', 'updated_at', 'comment_count', 'like_count'))); if (\Config::get('timeline.articles.cache.is_use')) { static::$_observers['MyOrm\\Observer_ExecuteToRelations'] = array('events' => array('after_update'), 'relations' => array('model_to' => '\\Timeline\\Model_TimelineChildData', 'conditions' => array('foreign_table' => array('album_image' => 'value'), 'foreign_id' => array('id' => 'property')), 'check_changed' => array('check_properties' => array('name', 'public_flag')), 'execute_func' => array('method' => '\\Timeline\\Site_Util::delete_cache', 'params' => array('timeline_id' => 'property')))); } } }
<div class="btn-group notice pull-right"> <?php /* <button class="btn btn-default navbar-inverse" type="button"> <?php echo icon('group', 'fa fa-', 'i', array('class' => 'icon')); ?> <span class="badge">99</span> </button> <button class="btn btn-default navbar-inverse" type="button"> <?php echo icon('comments', 'fa fa-', 'i', array('class' => 'icon')); ?> <span class="badge">99</span> </button> */ if (is_enabled('notice')) { $notice_btn_attr = array('class' => 'btn btn-default navbar-inverse js-modal', 'type' => 'button', 'data-uri' => 'notice/api/list.json', 'data-get_data' => array('limit' => Config::get('notice.modalArticles.limit')), 'data-target' => '#modal_notice_navbar', 'data-tmpl' => '#notices-template', 'data-is_list' => 1, 'id' => 'btn_notice_navbar'); if (!empty($notification_counts['notice'])) { $notice_btn_attr['class'] .= ' notified'; } ?> <button <?php echo Util_Array::conv_array2attr_string($notice_btn_attr); ?> > <?php echo icon('info-circle', 'fa fa-', 'i', array('class' => 'icon')); if (!empty($notification_counts['notice'])) { ?> <span class="badge" id="badge_notice"><?php echo $notification_counts['notice']; ?> </span> <?php
public function update_public_flag_with_relations($public_flag) { $this->public_flag = $public_flag; if (!$this->is_changed('public_flag')) { return; } $this->save(); // album_image の public_flag の更新 if ($this->is_published && is_enabled('album') && ($album_images = Model_NoteAlbumImage::get_album_image4note_id($this->id))) { foreach ($album_images as $album_image) { $album_image->update_public_flag($public_flag, true); } } }
/** * module の load 状態による設定値の修正 * * @access public * @return null */ public static function regulate_configs_for_module_loaded() { if (Config::get('site.upload.types.img.types.m.save_as_album_image') && !is_enabled('album')) { Config::set('site.upload.types.img.types.m.save_as_album_image', false); } }
private function set_count() { self::$album_count = \Util_Orm::get_count_all('\\Album\\Model_Album'); if (is_enabled('timeline')) { self::$timeline_count = \Util_Orm::get_count_all('\\Timeline\\Model_Timeline'); self::$timeline_cache_count = \Util_Orm::get_count_all('\\Timeline\\Model_TimelineCache'); } }
<?php echo render('_parts/member_profile', array('is_mypage' => $is_mypage, 'member' => $member, 'member_profiles' => $member_profiles, 'access_from' => $access_from, 'display_type' => !empty($display_type) ? $display_type : 'summary', 'link_uri' => $is_mypage ? 'member/profile' : 'member/profile/' . $member->id, 'is_hide_fallow_btn' => isset($is_hide_fallow_btn) ? $is_hide_fallow_btn : false)); ?> <?php if (is_enabled('timeline') && !empty($timeline)) { ?> <h3><?php echo sprintf('%sさんの%s', member_name($member), term('timeline')); ?> </h3> <?php echo render('timeline::_parts/list', $timeline); }
public static function delete($member_id) { if (!($member = Model_Member::query()->related('member_auth')->where('id', $member_id)->get_one())) { throw new FuelException('Member not exists.'); } $name = $member->name; $email = !empty($member->member_auth->email) ? $member->member_auth->email : ''; if (is_enabled('timeline')) { \Timeline\Site_NoOrmModel::delete_timeline4member_id($member_id); } if (is_enabled('album')) { \Album\Site_NoOrmModel::delete_album4member_id($member_id); } if (is_enabled('note')) { \Note\Site_NoOrmModel::delete_note4member_id($member_id); } static::delete_file_all4member_id($member_id); static::delete_file_all4member_id($member_id, true); DB::start_transaction(); if (!$member->delete()) { throw new FuelException('Delete user error. user_id:' . $member_id); } DB::commit_transaction(); if ($name && $email) { $mail = new Site_Mail('memberLeave'); $mail->send($email, array('to_name' => $name)); } }
/** * Note edit * * @access public * @params integer * @return Response */ public function action_edit($id = null) { $note = Model_Note::check_authority($id, $this->u->id); $val = self::get_validation_object($note, true); $album_images = array(); if (is_enabled('album')) { $album_id = \Album\Model_Album::get_id_for_foreign_table($this->u->id, 'note'); $album_images = Model_NoteAlbumImage::get_album_image4note_id($note->id); } $files = is_enabled('album') ? \Site_Upload::get_file_objects($album_images, $album_id, false, $this->u->id) : array(); $file_tmps = array(); if (\Input::method() == 'POST') { \Util_security::check_csrf(); $moved_files = array(); try { if (is_enabled('album')) { $file_tmps = \Site_FileTmp::get_file_tmps_and_check_filesize($this->u->id, $this->u->filesize_total); } if (!$val->run()) { throw new \FuelException($val->show_errors()); } $post = $val->validated(); \DB::start_transaction(); list($is_changed, $is_published, $moved_files) = $note->save_with_relations($this->u->id, $post, $file_tmps, $album_images, $files); \DB::commit_transaction(); // thumbnail 作成 & tmp_file thumbnail 削除 \Site_FileTmp::make_and_remove_thumbnails($moved_files, 'note'); $message = sprintf('%sを%sしました。', term('note'), $is_published ? term('form.publish') : term('form.edit')); \Session::set_flash('message', $message); \Response::redirect('note/detail/' . $note->id); } catch (\FuelException $e) { if (\DB::in_transaction()) { \DB::rollback_transaction(); } if ($moved_files) { \Site_FileTmp::move_files_to_tmp_dir($moved_files); } $file_tmps = \Site_FileTmp::get_file_objects($file_tmps, $this->u->id); \Session::set_flash('error', $e->getMessage()); } } $files = array_merge($files, $file_tmps); $this->set_title_and_breadcrumbs(sprintf('%sを%s', term('note'), term('form.do_edit')), array('/note/' . $id => $note->title), $note->member, 'note'); $this->template->post_header = \View::forge('_parts/form_header'); $this->template->post_footer = \View::forge('_parts/form_footer'); $this->template->content = \View::forge('_parts/form', array('val' => $val, 'note' => $note, 'is_edit' => true, 'files' => $files)); }
/** * @dataProvider like_watch_provider */ public function test_like_watch($member_id_to, $member_id_from, $mc_notice_comment, $mc_watch_liked, $member_id_add_comment, $is_countup_watch_exp, $is_created_watch_exp, $notice_countup_num_exp) { if (!is_enabled('notice')) { \Util_Develop::output_test_info(__FILE__, __LINE__); $this->markTestSkipped('notice module is disabled.'); } // 事前準備 \Model_MemberConfig::set_value($member_id_from, \Notice\Form_MemberConfig::get_name('comment'), $mc_notice_comment); \Model_MemberConfig::set_value($member_id_from, \Notice\Site_Util::get_member_config_name_for_watch_content(self::$type_key), $mc_watch_liked); $is_new = false; if ($member_id_to != self::$member_id) { self::$member_id = $member_id_to; self::set_note(); $is_new = true; } $note_id = self::$note_id; $foreign_id = self::$note_id; $watch_count_all_before = \Notice\Model_MemberWatchContent::get_count(); // 既読処理 $read_count = \Notice\Site_Util::change_status2read($member_id_from, self::$foreign_table, $note_id, self::$type_key); // like save $like_id = Model_NoteLike::change_registered_status4unique_key(array('note_id' => $note_id, 'member_id' => $member_id_from)); self::$liked_member_id_before = $member_id_from; // Model_Notice $member_watch_content = \Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $foreign_id, $member_id_from); if ($is_created_watch_exp) { $this->assertNotNull($member_watch_content); } else { $this->assertNull($member_watch_content); } // 件数 $watch_count_all = \Notice\Model_MemberWatchContent::get_count(); $watch_count_all_countup_num = $is_countup_watch_exp ? 1 : 0; $this->assertEquals($watch_count_all_before + $watch_count_all_countup_num, $watch_count_all); // set cache $notice_count_before = \Notice\Site_Util::get_unread_count($member_id_from); // note_comment save $note_comment_added = self::save_comment($member_id_add_comment); // notice count を取得 $notice_count = \Notice\Site_Util::get_unread_count($member_id_from); // execute test $this->assertEquals($notice_count_before + $notice_countup_num_exp, $notice_count); // count up を確認 }
protected function set_notification_count() { if (is_enabled('notice') && Auth::check()) { $this->notification_counts['notice'] = \Notice\Site_Util::get_unread_count($this->u->id); } View::set_global('notification_counts', $this->notification_counts); }
if (!$u->check_registered_oauth(true)) { ?> <?php echo form_text(!empty($u->member_auth->password) ? sprintf('<span class="text-muted">%s</span>', term('site.set_already')) : sprintf('<span class="text-danger">%s</span>', term('site.unset')), term('site.password'), $label_col_size, true, array('uri' => 'member/setting/password', 'text' => icon('cog') . ' ' . term('form.edit'), 'is_safe_text' => true)); } ?> <?php if (is_enabled('notice')) { ?> <?php echo form_text(sprintf('<span class="text-muted">%sを%sを%sします</span>', term('notice'), term('form.recieve', 'site.item'), term('site.setting')), term('notice', 'site.setting'), $label_col_size, true, array('uri' => 'member/setting/notice', 'text' => icon('cog') . ' ' . term('form.edit'), 'is_safe_text' => true)); } ?> <?php if (is_enabled('timeline')) { ?> <?php echo form_text(\Timeline\Form_MemberConfig::get_viewType_options($member_config->timeline_viewType), term('timeline', 'site.display', 'site.setting'), $label_col_size, true, array('uri' => 'member/setting/timeline/viewtype', 'text' => icon('cog') . ' ' . term('form.edit'), 'is_safe_text' => true)); } ?> </div> <div class="list-group"> <?php echo Html::anchor($this->u->check_registered_oauth() ? 'member/leave/confirm' : 'member/leave', term('site.leave'), array('class' => 'list-group-item list-group-item-danger')); ?> </div>