public function triggerNewsfeedEventOnSinglePhotoAdd(PHOTO_BOL_PhotoAlbum $album, PHOTO_BOL_Photo $photo, $isAdd = TRUE) { $lastPhoto = $this->photoDao->getLastPhoto($album->id, array($photo->id)); if ($isAdd && $lastPhoto && time() - $lastPhoto->addDatetime < 60 * 15 && $lastPhoto->uploadKey) { $this->feedDeleteItem('photo_comments', $lastPhoto->id); $this->feedDeleteItem('multiple_photo_upload', $lastPhoto->uploadKey); $photoIdList = $this->photoDao->findPhotoIdListByUploadKey($lastPhoto->uploadKey); sort($photoIdList, SORT_NUMERIC); $count = count($photoIdList); $albumUrl = OW::getRouter()->urlForRoute('photo_user_album', array('user' => BOL_UserService::getInstance()->getUserName($album->userId), 'album' => $album->id)); if ($count === 1) { $entityType = 'photo_comments'; $entityId = $photoIdList[0]; $key = 'photo+feed_single_description'; } else { $entityType = 'multiple_photo_upload'; $entityId = $lastPhoto->uploadKey; $key = 'photo+feed_multiple_descriptions'; } $event = new OW_Event('feed.action', array('pluginKey' => 'photo', 'entityType' => $entityType, 'entityId' => $entityId, 'userId' => $album->userId), array('photoIdList' => array_reverse($photoIdList), 'string' => array('key' => $key, 'vars' => array('number' => $count, 'albumUrl' => $albumUrl, 'albumName' => $album->name)), 'features' => array('likes'), 'content' => '', 'view' => array('iconClass' => 'ow_ic_picture'))); OW::getEventManager()->trigger($event); } else { $this->feedDeleteItem('photo_comments', $photo->id); $this->feedDeleteItem('multiple_photo_upload', $photo->uploadKey); $albumUrl = OW::getRouter()->urlForRoute('photo_user_album', array('user' => BOL_UserService::getInstance()->getUserName($album->userId), 'album' => $album->id)); $data = array('photoIdList' => array($photo->id), 'string' => array('key' => 'photo+feed_single_description', 'vars' => array('number' => 1, 'albumUrl' => $albumUrl, 'albumName' => $album->name))); if (!empty($photo->description)) { $data['status'] = $photo->description; } $event = new OW_Event('feed.action', array('pluginKey' => 'photo', 'entityType' => 'photo_comments', 'entityId' => $photo->id, 'userId' => $album->userId, 'time' => $photo->addDatetime), $data); OW::getEventManager()->trigger($event); } return TRUE; }