diff --git a/apps/api/modules/like/actions/actions.class.php b/apps/api/modules/like/actions/actions.class.php index 85b9198..8c654a3 100644 --- a/apps/api/modules/like/actions/actions.class.php +++ b/apps/api/modules/like/actions/actions.class.php @@ -55,31 +55,30 @@ public function executePost(sfWebRequest $request) $this->forward400If($alreadyLike, 'It has already been registered'); $fromMember = $this->getUser()->getMember(); - $baseUrl = $request->getRelativeUrlRoot(); switch ($foreignTable) { case 'A': $this->forward400Unless($activity = Doctrine::getTable('ActivityData')->find($foreignId)); $timelineId = $activity->in_reply_to_activity_id ? $activity->in_reply_to_activity_id : $activity->id; - $url = $baseUrl.'/timeline/show/id/'.$timelineId; + $url = '/timeline/show/id/'.$timelineId; break; case 'D': - $url = $baseUrl.'/diary/'.$foreignId; + $url = '/diary/'.$foreignId; break; case 'd': $diaryComment = Doctrine::getTable('DiaryComment')->findOneById($foreignId); $this->forward400Unless($diaryComment, 'diary comment does not exist.'); - $url = $baseUrl.'/diary/'.$diaryComment->getDiaryId(); + $url = '/diary/'.$diaryComment->getDiaryId(); break; case 'e': $eventComment = Doctrine::getTable('CommunityEventComment')->findOneById($foreignId); $this->forward400Unless($eventComment, 'event comment does not exist.'); - $url = $baseUrl.'/communityEvent/'.$eventComment->getCommunityEventId(); + $url = '/communityEvent/'.$eventComment->getCommunityEventId(); break; case 't': $topicComment = Doctrine::getTable('CommunityTopicComment')->findOneById($foreignId); $this->forward400Unless($topicComment, 'topic comment does not exist.'); - $url = $baseUrl.'/communityTopic/'.$topicComment->getCommunityTopicId(); + $url = '/communityTopic/'.$topicComment->getCommunityTopicId(); break; default : $url = '#'; diff --git a/data/fixtures/000_revision.yml b/data/fixtures/000_revision.yml index 1b108c6..e0c27ff 100644 --- a/data/fixtures/000_revision.yml +++ b/data/fixtures/000_revision.yml @@ -1,4 +1,4 @@ SnsConfig: op_like_plugin_current_revision: name: "opLikePlugin_revision" - value: 3 + value: 4 diff --git a/data/migrations/004_change_notification_url.php b/data/migrations/004_change_notification_url.php new file mode 100644 index 0000000..39fb242 --- /dev/null +++ b/data/migrations/004_change_notification_url.php @@ -0,0 +1,48 @@ + + */ +class opLikePluginMigrationVersion4 extends opMigration +{ + /* + * 下記の条件に一致する通知URLを一括で変更: + * * url に '/timeline/', '/diary/', '/communityEvent/', '/communityTopic/' が含まれ、 + * 且つ、これらの前に'/'で始まる何らかの文字列が含まれているもの + */ + public function postUp() + { + $notificationObject = Doctrine::getTable('MemberConfig') + ->findByName('notification_center'); + + if ($notificationObject) + { + foreach ($notificationObject as $object) + { + $notifications = unserialize($object->getValue()); + + $newNotifications = array(); + foreach ($notifications as $notificationItem) + { + $url = $notificationItem['url']; + if ($url) + { + if (preg_match('/(\/timeline\/show\/id|\/diary|\/communityEvent|\/communityTopic)\/[0-9]+/', $url, $m)) + { + $url = $m[0]; + $notificationItem['url'] = $url; + } + } + array_push($newNotifications, $notificationItem); + } + + $object->setValue(serialize($newNotifications)); + $object->save(); + $object->free(true); + } + } + + } +}