コード例 #1
0
ファイル: event_handler.php プロジェクト: hardikamutech/loov
 public function onBeforePhotoMove(OW_Event $event)
 {
     $params = $event->getParams();
     if (empty($params['fromAlbum']) || empty($params['photoIdList'])) {
         return;
     }
     $fromAlbum = $this->albumService->findAlbumById($params['fromAlbum']);
     $fromAlbumLastPhoto = PHOTO_BOL_PhotoDao::getInstance()->getLastPhoto($params['fromAlbum']);
     $toAlbum = $this->albumService->findAlbumById($params['toAlbum']);
     $toAlbumLastPhoto = PHOTO_BOL_PhotoDao::getInstance()->getLastPhoto($params['toAlbum']);
     if ($fromAlbumLastPhoto) {
         $this->photoService->feedDeleteItem('photo_comments', $fromAlbumLastPhoto->id);
         $this->photoService->feedDeleteItem('multiple_photo_upload', $fromAlbumLastPhoto->uploadKey);
     }
     if ($toAlbumLastPhoto) {
         $this->photoService->feedDeleteItem('photo_comments', $toAlbumLastPhoto->id);
         $this->photoService->feedDeleteItem('multiple_photo_upload', $toAlbumLastPhoto->uploadKey);
     }
     if (empty($params['toAlbum'])) {
         $photoIdList = PHOTO_BOL_PhotoDao::getInstance()->findPhotoIdListByAlbumId($fromAlbum->id);
         $count = count($photoIdList);
         $user = BOL_UserService::getInstance()->findUserById($fromAlbum->userId);
         $albumUrl = OW::getRouter()->urlForRoute('photo.user_photos', array('user' => $user->username));
         $event = new OW_Event('feed.action', array('pluginKey' => 'photo', 'entityType' => $count === 1 ? 'photo_comments' : 'multiple_photo_upload', 'entityId' => $fromAlbumLastPhoto->uploadKey, 'userId' => $user->id), array('photoIdList' => $photoIdList, 'string' => array('key' => 'photo+feed_move_photo_descriptions', 'vars' => array('number' => $count, 'albumUrl' => $albumUrl)), 'features' => array('likes'), 'content' => '', 'view' => array('iconClass' => 'ow_ic_picture')));
         OW::getEventManager()->trigger($event);
     } else {
         $fromPhotoIdList = PHOTO_BOL_PhotoDao::getInstance()->findPhotoIdListByAlbumId($fromAlbum->id, $params['photoIdList']);
         if (empty($fromPhotoIdList)) {
             $photo = $this->photoService->findPhotoById($params['photoIdList'][0]);
             $this->photoService->feedDeleteItem('photo_comments', $photo->id);
             $this->photoService->feedDeleteItem('photo_comments', $photo->uploadKey);
             $this->photoService->feedDeleteItem('multiple_photo_upload', $photo->uploadKey);
         } else {
             $fromCount = count($fromPhotoIdList);
             $fromEntityType = $fromCount === 1 ? 'photo_comments' : 'multiple_photo_upload';
             $fromAlbumUrl = OW::getRouter()->urlForRoute('photo_user_album', array('user' => BOL_UserService::getInstance()->getUserName($fromAlbum->userId), 'album' => $fromAlbum->id));
             $event = new OW_Event('feed.action', array('pluginKey' => 'photo', 'entityType' => $fromEntityType, 'entityId' => $fromAlbumLastPhoto->uploadKey, 'userId' => $fromAlbum->userId), array('photoIdList' => $fromPhotoIdList, 'string' => array('key' => 'photo+feed_multiple_descriptions', 'vars' => array('number' => $fromCount, 'albumUrl' => $fromAlbumUrl, 'albumName' => $fromAlbum->name)), 'features' => array('likes'), 'content' => '', 'view' => array('iconClass' => 'ow_ic_picture')));
             OW::getEventManager()->trigger($event);
         }
         if ($toAlbumLastPhoto) {
             $toPhotoIdList = array_merge(PHOTO_BOL_PhotoDao::getInstance()->findPhotoIdListByAlbumId($toAlbum->id), $params['photoIdList']);
             $toAlbumUrl = OW::getRouter()->urlForRoute('photo_user_album', array('user' => BOL_UserService::getInstance()->getUserName($toAlbum->userId), 'album' => $toAlbum->id));
             $event = new OW_Event('feed.action', array('pluginKey' => 'photo', 'entityType' => 'multiple_photo_upload', 'entityId' => $toAlbumLastPhoto->uploadKey, 'userId' => $toAlbum->userId), array('photoIdList' => $toPhotoIdList, 'string' => array('key' => 'photo+feed_multiple_descriptions', 'vars' => array('number' => count($toPhotoIdList), 'albumUrl' => $toAlbumUrl, 'albumName' => $toAlbum->name)), 'features' => array('likes'), 'content' => '', 'view' => array('iconClass' => 'ow_ic_picture')));
             OW::getEventManager()->trigger($event);
         }
     }
 }