Ejemplo n.º 1
0
 /**
  * Returns the number of related UploadToken objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related UploadToken objects.
  * @throws     PropelException
  */
 public function countUploadTokens(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(kuserPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collUploadTokens === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(UploadTokenPeer::KUSER_ID, $this->id);
             $count = UploadTokenPeer::doCount($criteria, false, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // 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 count of the collection.
             $criteria->add(UploadTokenPeer::KUSER_ID, $this->id);
             if (!isset($this->lastUploadTokenCriteria) || !$this->lastUploadTokenCriteria->equals($criteria)) {
                 $count = UploadTokenPeer::doCount($criteria, false, $con);
             } else {
                 $count = count($this->collUploadTokens);
             }
         } else {
             $count = count($this->collUploadTokens);
         }
     }
     return $count;
 }
 /**
  * List upload token by filter with pager support. 
  * When using a user session the service will be restricted to users objects only.
  * 
  * @action list
  * @param KalturaUploadTokenFilter $filter
  * @param KalturaFilterPager $pager
  * @return KalturaUploadTokenListResponse
  */
 function listAction(KalturaUploadTokenFilter $filter = null, KalturaFilterPager $pager = null)
 {
     if (!$filter) {
         $filter = new KalturaUploadTokenFilter();
     }
     if (!$pager) {
         $pager = new KalturaFilterPager();
     }
     $this->restrictPeerToCurrentUser();
     // translate the user id (puser id) to kuser id
     if ($filter->userIdEqual !== null) {
         $kuser = kuserPeer::getKuserByPartnerAndUid($this->getPartnerId(), $filter->userIdEqual);
         if ($kuser) {
             $filter->userIdEqual = $kuser->getId();
         } else {
             $filter->userIdEqual = -1;
         }
         // no result will be returned when the user is missing
     }
     // create the filter
     $uploadTokenFilter = new UploadTokenFilter();
     $filter->toObject($uploadTokenFilter);
     $c = new Criteria();
     $uploadTokenFilter->attachToCriteria($c);
     $totalCount = UploadTokenPeer::doCount($c);
     $pager->attachToCriteria($c);
     $list = UploadTokenPeer::doSelect($c);
     // create the response object
     $newList = KalturaUploadTokenArray::fromUploadTokenArray($list);
     $response = new KalturaUploadTokenListResponse();
     $response->objects = $newList;
     $response->totalCount = $totalCount;
     return $response;
 }