예제 #1
0
 public function albumAdd(OW_Event $e)
 {
     $params = $e->getParams();
     $data = $e->getData();
     if (empty($params['name'])) {
         return false;
     }
     $albumName = trim($params['name']);
     $userId = !empty($params['userId']) ? (int) $params['userId'] : null;
     $entityId = !empty($params['entityId']) ? (int) $params['entityId'] : $userId;
     $entityType = !empty($params['entityType']) ? (int) $params['entityType'] : 'user';
     $album = $this->albumService->findEntityAlbumByName($albumName, $entityId, $entityType);
     if (empty($album) && $entityType == "user" && !empty($userId)) {
         $album = $this->albumService->findAlbumByName($albumName, $userId);
     }
     if (!empty($album)) {
         $data['albumId'] = $album->id;
         $e->setData($data);
         return $data;
     }
     $album = new PHOTO_BOL_PhotoAlbum();
     $album->name = $albumName;
     $album->userId = $userId;
     $album->entityId = $entityId;
     $album->entityType = $entityType;
     $album->createDatetime = time();
     $albumId = $this->albumService->addAlbum($album);
     $data['albumId'] = $albumId;
     $e->setData($data);
     return $data;
 }