コード例 #1
0
ファイル: kvotePeer.php プロジェクト: kubrickfr/server
 public static function setDefaultCriteriaFilter()
 {
     if (self::$s_criteria_filter == null) {
         self::$s_criteria_filter = new criteriaFilter();
     }
     $c = new myCriteria();
     $c->add(kvotePeer::STATUS, KVoteStatus::REVOKED, Criteria::NOT_EQUAL);
     self::$s_criteria_filter->setFilter($c);
 }
コード例 #2
0
ファイル: KalturaLikeFilter.php プロジェクト: GElkayam/server
 public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null)
 {
     myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2;
     $c = new Criteria();
     $c->add(kvotePeer::PARTNER_ID, kCurrentContext::$ks_partner_id);
     if ($this->entryIdEqual) {
         $c->add(kvotePeer::ENTRY_ID, $this->entryIdEqual);
     }
     if ($this->userIdEqual) {
         $c->add(kvotePeer::PUSER_ID, $this->userIdEqual);
     }
     $pager->attachToCriteria($c);
     $list = kvotePeer::doSelect($c);
     $response = new KalturaLikeListResponse();
     $response->objects = KalturaLikeArray::fromDbArray($list, $responseProfile);
     $response->totalCount = count($list);
     return $response;
 }
コード例 #3
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);
     }
 }
コード例 #4
0
ファイル: Basekshow.php プロジェクト: wzur/server
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this kshow is new, it will return
  * an empty collection; or if this kshow has previously
  * been saved, it will retrieve related kvotesRelatedByKuserId from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in kshow.
  */
 public function getkvotesRelatedByKuserIdJoinentry($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     if ($criteria === null) {
         $criteria = new Criteria(kshowPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collkvotesRelatedByKuserId === null) {
         if ($this->isNew()) {
             $this->collkvotesRelatedByKuserId = array();
         } else {
             $criteria->add(kvotePeer::KUSER_ID, $this->id);
             $this->collkvotesRelatedByKuserId = kvotePeer::doSelectJoinentry($criteria, $con, $join_behavior);
         }
     } else {
         // the following code is to determine if a new query is
         // called for.  If the criteria is the same as the last
         // one, just return the collection.
         $criteria->add(kvotePeer::KUSER_ID, $this->id);
         if (!isset($this->lastkvoteRelatedByKuserIdCriteria) || !$this->lastkvoteRelatedByKuserIdCriteria->equals($criteria)) {
             $this->collkvotesRelatedByKuserId = kvotePeer::doSelectJoinentry($criteria, $con, $join_behavior);
         }
     }
     $this->lastkvoteRelatedByKuserIdCriteria = $criteria;
     return $this->collkvotesRelatedByKuserId;
 }
コード例 #5
0
ファイル: LikeFilter.class.php プロジェクト: DBezemer/server
 public function getFieldNameFromPeer($field_name)
 {
     $res = kvotePeer::translateFieldName($field_name, $this->field_name_translation_type, BasePeer::TYPE_COLNAME);
     return $res;
 }
コード例 #6
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(kvotePeer::DATABASE_NAME);
         $criteria->add(kvotePeer::ID, $pks, Criteria::IN);
         $objs = kvotePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
コード例 #7
0
ファイル: Basekvote.php プロジェクト: kubrickfr/server
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = kvotePeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setKshowId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setEntryId($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setKuserId($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setPartnerId($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setRank($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setStatus($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setKvoteType($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setCreatedAt($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setCustomData($arr[$keys[9]]);
     }
 }
コード例 #8
0
ファイル: LikeService.php プロジェクト: DBezemer/server
 /**
  * @action checkLikeExists
  * Action to check whether a user likes a specific entry
  * @param string $entryId
  * @param string $userId
  * @return bool
  */
 public function checkLikeExistsAction($entryId, $userId = null)
 {
     if (!$entryId) {
         throw new KalturaAPIException(KalturaErrors::MISSING_MANDATORY_PARAMETER, "entryId");
     }
     if (!$userId) {
         $userId = kCurrentContext::$ks_uid;
     }
     $existingKVote = kvotePeer::doSelectByEntryIdAndPuserId($entryId, $this->getPartnerId(), $userId);
     if (!$existingKVote || !count($existingKVote)) {
         return false;
     }
     return true;
 }
<?php

const LIMIT = 500;
const INITIAL_CREATED_AT_VALUE = '2000-01-01 00:00:00';
require_once __DIR__ . "/../../../alpha/scripts/bootstrap.php";
$c = new Criteria();
$c->addAscendingOrderByColumn(kvotePeer::CREATED_AT);
$c->setLimit(LIMIT);
$createdAtValue = INITIAL_CREATED_AT_VALUE;
$kVotes = array(1);
while (!empty($kVotes)) {
    $c->add(kvotePeer::CREATED_AT, $createdAtValue, Criteria::GREATER_THAN);
    kvotePeer::setUseCriteriaFilter(false);
    $kVotes = kvotePeer::doSelect($c);
    kvotePeer::setUseCriteriaFilter(true);
    foreach ($kVotes as $kVote) {
        $kuserId = $kVote->getKuserId();
        kuserPeer::setUseCriteriaFilter(false);
        $kuser = kuserPeer::retrieveByPKNoFilter($kuserId);
        kuserPeer::setUseCriteriaFilter(true);
        if (!$kuser) {
            KalturaLog::err("no user found with id {$kuserId}");
            continue;
        }
        $puserId = $kuser->getPuserId();
        $kVote->setPuserId($puserId);
        $kVote->save();
    }
    KalturaLog::debug("created is - " . $kVote->getCreatedAt());
    $createdAtValue = $kVote->getCreatedAt();
}