コード例 #1
0
ファイル: LikeService.php プロジェクト: DBezemer/server
 /**
  * @action like
  * Action for current kuser to mark the entry as "liked".
  * @param string $entryId
  * @throws KalturaLikeErrors::USER_LIKE_FOR_ENTRY_ALREADY_EXISTS
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  * @return bool
  */
 public function likeAction($entryId)
 {
     if (!$entryId) {
         throw new KalturaAPIException(KalturaErrors::MISSING_MANDATORY_PARAMETER, "entryId");
     }
     //Check if a kvote for current entryId and kuser already exists. If it does - throw exception
     $existingKVote = kvotePeer::doSelectByEntryIdAndPuserId($entryId, $this->getPartnerId(), kCurrentContext::$ks_uid);
     if ($existingKVote) {
         throw new KalturaAPIException(KalturaLikeErrors::USER_LIKE_FOR_ENTRY_ALREADY_EXISTS);
     }
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     if (kvotePeer::enableExistingKVote($entryId, $this->getPartnerId(), kCurrentContext::$ks_uid)) {
         return true;
     }
     kvotePeer::createKvote($entryId, $this->getPartnerId(), kCurrentContext::$ks_uid, self::KVOTE_LIKE_RANK_VALUE, KVoteType::LIKE);
     return true;
 }