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(\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();
         }
     }
 }
Example #3
0
 private function execute($obj)
 {
     list($foreign_table, $foreign_id, $member_id_to, $member_id_from, $type_key) = self::get_variables($obj);
     if (self::check_already_executed($foreign_table, $foreign_id, $member_id_to, $member_id_from, $type_key)) {
         return;
     }
     if (!\Model_Member::check_is_active($member_id_to)) {
         $member_id_to = null;
     }
     // watch content
     if ($member_id_to && $member_id_from != $member_id_to) {
         \Notice\Site_Util::regiser_watch_content($member_id_from, $foreign_table, $foreign_id, $type_key);
     }
     // get mention targets
     $mentioned_member_ids = array();
     if (conf('mention.isEnabled', 'notice') && \Notice\Site_Util::check_mention_target($foreign_table, $type_key)) {
         $body_porp = !empty($this->_update_properties['body_prop_name']) ? $this->_update_properties['body_prop_name'] : 'body';
         $mentioned_member_ids = \Notice\Site_Model::get_mentioned_member_ids4body($obj->{$body_porp});
         $mentioned_member_ids = \Util_Array::delete_in_array($mentioned_member_ids, array($member_id_from));
         // 自分宛の mention は無効
     }
     // get notice targets
     $notice_member_ids = \Notice\Site_Util::get_notice_target_member_ids($member_id_to, $member_id_from, $foreign_table, $foreign_id, $type_key);
     // 重複通知防止
     $notice_member_ids = \Util_Array::delete_in_array($notice_member_ids, $mentioned_member_ids);
     if (!$notice_member_ids && !$mentioned_member_ids) {
         return;
     }
     // notice 実行
     if ($notice_member_ids) {
         \Notice\Site_Model::execut_notice($foreign_table, $foreign_id, $type_key, $member_id_from, $notice_member_ids);
     }
     // mention 実行
     if ($mentioned_member_ids) {
         $mention_type_key = $type_key == 'comment' ? 'comment_mention' : 'parent_mention';
         \Notice\Site_Model::execut_notice($foreign_table, $foreign_id, $mention_type_key, $member_id_from, $mentioned_member_ids);
     }
 }