Пример #1
0
 public static function createKvote($entryId, $partnerId, $puserId, $rank, $type = KVoteType::RANK)
 {
     $kvote = new kvote();
     $kvote->setEntryId($entryId);
     $kvote->setStatus(KVoteStatus::VOTED);
     $kvote->setPartnerId($partnerId);
     $kvote->setKvoteType($type);
     $kuser = self::getKuserFromPuserAndPartner($puserId, $partnerId);
     if (!$kuser) {
         $kuser = new kuser();
         $kuser->setPuserId($puserId);
         $kuser->setStatus(KuserStatus::ACTIVE);
         $kuser->save();
     }
     $kvote->setPuserId($puserId);
     $kvote->setKuserId($kuser->getId());
     $kvote->setRank($rank);
     $kvote->save();
 }
Пример #2
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $kshow_id = $this->getPM("kshow_id");
     $rank = $this->getPM("rank");
     $kshow = kshowPeer::retrieveByPK($kshow_id);
     if (!$kshow) {
         $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id);
         return;
     }
     if ($rank > entry::MAX_NORMALIZED_RANK || $rank < 0 || !is_numeric($rank)) {
         $this->addError(APIErrors::INVALID_RANK, $rank);
         return;
     }
     $kuser_id = $puser_kuser->getKuserId();
     $entry_id = $kshow->getShowEntryId();
     $partner = PartnerPeer::retrieveByPK($partner_id);
     if (!$partner->getAllowAnonymousRanking()) {
         // prevent duplicate votes
         $c = new Criteria();
         $c->add(kvotePeer::KUSER_ID, $kuser_id);
         $c->add(kvotePeer::ENTRY_ID, $entry_id);
         $c->add(kvotePeer::KSHOW_ID, $kshow_id);
         $kvote = kvotePeer::doSelectOne($c);
         if ($kvote != NULL) {
             $this->addError(APIErrors::USER_ALREADY_RANKED_KSHOW, $puser_id, $kshow_id);
             return;
         }
     }
     $kvote = new kvote();
     $kvote->setKshowId($kshow_id);
     $kvote->setEntryId($entry_id);
     $kvote->setKuserId($kuser_id);
     $kvote->setRank($rank);
     $kvote->save();
     $statistics_results = $kvote->getStatisticsResults();
     $updated_kshow = @$statistics_results["kshow"];
     if ($updated_kshow) {
         myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_KSHOW_RANK, $updated_kshow);
         $data = array("kshow_id" => $kshow_id, "uid" => $puser_id, "rank" => $updated_kshow->getRank(), "votes" => $updated_kshow->getVotes());
         //$this->addMsg ( "kshow" , objectWrapperBase::getWrapperClass( $updated_kshow , objectWrapperBase::DETAIL_LEVEL_DETAILED) );
         $this->addMsg("rank", $data);
     }
 }
Пример #3
0
 protected function anonymousRankEntry($entryId, $entryType = null, $rank)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry || $entryType !== null && $dbEntry->getType() != $entryType) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     if ($rank <= 0 || $rank > 5) {
         throw new KalturaAPIException(KalturaErrors::INVALID_RANK_VALUE);
     }
     $kvote = new kvote();
     $kvote->setEntryId($entryId);
     $kvote->setKuserId($this->getKuser()->getId());
     $kvote->setRank($rank);
     $kvote->save();
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      kvote $value A kvote object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(kvote $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Пример #5
0
 public static function modifyEntryVotesBykVote(kvote $kvote)
 {
     $entry = $kvote->getEntry();
     $res = self::modifyEntryVotes($entry, $kvote->getRank(), $kvote->getStatus());
     return $res;
 }
Пример #6
0
 public static function addKvote(kvote $kvote, $delta_rank)
 {
     $entry = $kvote->getEntry();
     $res = self::incEntryVotes($entry, $delta_rank);
     return $res;
 }
Пример #7
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      kvote $value A kvote object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(kvote $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) {
             self::$instances[$key] = $obj;
             kMemoryManager::registerPeer('kvotePeer');
         }
     }
 }