function getPartners($lastPartner, $partnerLimitEachLoop)
{
    PartnerPeer::clearInstancePool();
    $c = new Criteria();
    $c->add(PartnerPeer::ID, $lastPartner, Criteria::GREATER_THAN);
    $c->addAscendingOrderByColumn(PartnerPeer::ID);
    $c->setLimit($partnerLimitEachLoop);
    PartnerPeer::setUseCriteriaFilter(false);
    $partners = PartnerPeer::doSelect($c);
    PartnerPeer::setUseCriteriaFilter(true);
    return $partners;
}
 private function getPartnersArray($partnerIds)
 {
     $allowed = array();
     $c = new Criteria();
     $c->addAnd(PartnerPeer::ID, $partnerIds, Criteria::IN);
     $c->addAnd(PartnerPeer::STATUS, Partner::PARTNER_STATUS_ACTIVE, Criteria::EQUAL);
     PartnerPeer::setUseCriteriaFilter(false);
     $partners = PartnerPeer::doSelect($c);
     PartnerPeer::setUseCriteriaFilter(true);
     foreach ($partners as $partner) {
         if (!in_array($partner->getId(), array(PartnerPeer::GLOBAL_PARTNER, Partner::ADMIN_CONSOLE_PARTNER_ID, Partner::BATCH_PARTNER_ID))) {
             $allowed[] = array('id' => $partner->getId(), 'name' => $partner->getName());
         }
     }
     return $allowed;
 }
 public static function getPartnersArray(array $partnerIds, Criteria $c = null)
 {
     $ret = array();
     if (!$c) {
         $c = new Criteria();
     }
     $c->addAnd(PartnerPeer::ID, $partnerIds, Criteria::IN);
     $c->addAnd(PartnerPeer::STATUS, Partner::PARTNER_STATUS_ACTIVE, Criteria::EQUAL);
     PartnerPeer::setUseCriteriaFilter(false);
     $partners = PartnerPeer::doSelect($c);
     PartnerPeer::setUseCriteriaFilter(true);
     foreach ($partners as $partner) {
         if (!in_array($partner->getId(), array(PartnerPeer::GLOBAL_PARTNER, Partner::ADMIN_CONSOLE_PARTNER_ID, Partner::BATCH_PARTNER_ID))) {
             $ret[] = $partner;
         }
     }
     return $ret;
 }
 /**
  * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
  *
  * This will only work if the object has been saved and has a valid primary key set.
  *
  * @param      boolean $deep (optional) Whether to also de-associated any related objects.
  * @param      PropelPDO $con (optional) The PropelPDO connection to use.
  * @return     void
  * @throws     PropelException - if this object is deleted, unsaved or doesn't have pk match in db
  */
 public function reload($deep = false, PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("Cannot reload a deleted object.");
     }
     if ($this->isNew()) {
         throw new PropelException("Cannot reload an unsaved object.");
     }
     if ($con === null) {
         $con = Propel::getConnection(PartnerPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     // We don't need to alter the object instance pool; we're just modifying this instance
     // already in the pool.
     PartnerPeer::setUseCriteriaFilter(false);
     $stmt = PartnerPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
     PartnerPeer::setUseCriteriaFilter(true);
     $row = $stmt->fetch(PDO::FETCH_NUM);
     $stmt->closeCursor();
     if (!$row) {
         throw new PropelException('Cannot find matching row in the database to reload object values.');
     }
     $this->hydrate($row, 0, true);
     // rehydrate
     if ($deep) {
         // also de-associate any related objects?
         $this->akuser = null;
         $this->colladminKusers = null;
         $this->lastadminKuserCriteria = null;
     }
     // if (deep)
 }
Exemple #5
0
 protected static function init()
 {
     kEventsManager::enableDeferredEvents(false);
     MetadataProfilePeer::setUseCriteriaFilter(false);
     MetadataPeer::setUseCriteriaFilter(false);
     entryPeer::setUseCriteriaFilter(false);
     uiConfPeer::setUseCriteriaFilter(false);
     assetPeer::setUseCriteriaFilter(false);
     PartnerPeer::setUseCriteriaFilter(false);
     FileSyncPeer::setUseCriteriaFilter(false);
     $options = getopt('hrl:p:o:b:e:', array('real-run', 'error-objects', 'old-versions', 'blocked-partners', 'files'));
     if (isset($options['h'])) {
         self::failWrongInputs();
     }
     if (isset($options['blocked-partners'])) {
         self::$deleteDeletedPartnersFileSyncs = true;
     }
     if (isset($options['error-objects'])) {
         self::$deleteErrorObjects = true;
     }
     if (isset($options['old-versions'])) {
         self::$deleteOldVersions = true;
     }
     if (isset($options['files'])) {
         self::$purgeDeletedFileSyncs = true;
     }
     if (isset($options['r']) || isset($options['real-run'])) {
         self::$dryRun = false;
     }
     KalturaStatement::setDryRun(self::$dryRun);
     $cacheFilePath = kConf::get('cache_root_path') . '/scripts/deleteOldContent.cache';
     if (file_exists($cacheFilePath)) {
         $cache = unserialize(file_get_contents($cacheFilePath));
         if (isset($cache['oldVersionsStartUpdatedAt'])) {
             self::$oldVersionsStartUpdatedAt = $cache['oldVersionsStartUpdatedAt'];
         }
         if (isset($cache['purgeStartUpdatedAt'])) {
             self::$purgeStartUpdatedAt = $cache['purgeStartUpdatedAt'];
         }
     }
     if (!self::$purgeStartUpdatedAt) {
         $criteria = new Criteria();
         $criteria->add(FileSyncPeer::UPDATED_AT, 0, Criteria::GREATER_THAN);
         $criteria->add(FileSyncPeer::DC, kDataCenterMgr::getCurrentDcId());
         $criteria->add(FileSyncPeer::STATUS, FileSync::FILE_SYNC_STATUS_DELETED);
         $criteria->addSelectColumn('UNIX_TIMESTAMP(MIN(' . FileSyncPeer::UPDATED_AT . '))');
         $stmt = FileSyncPeer::doSelectStmt($criteria);
         $mins = $stmt->fetchAll(PDO::FETCH_COLUMN);
         if (count($mins)) {
             self::$purgeStartUpdatedAt = reset($mins);
         }
     }
     if (is_null(self::$purgeStartUpdatedAt)) {
         self::$purgeStartUpdatedAt = 0;
     }
     self::$purgeNextStartUpdatedAt = self::$purgeStartUpdatedAt;
     $oldVersionsUpdatedAtPeriod = 30;
     // days
     if (isset($options['o'])) {
         if (!is_numeric($options['o']) || $options['o'] < 0) {
             self::failWrongInputs("Period of old versions to delete must be positive numeric of days");
         }
         $oldVersionsUpdatedAtPeriod = $options['o'];
     }
     foreach (self::$oldVersionsStartUpdatedAt as $objectType => $oldVersionsStartUpdatedAt) {
         self::$oldVersionsEndUpdatedAt[$objectType] = $oldVersionsStartUpdatedAt + $oldVersionsUpdatedAtPeriod * 60 * 60 * 24;
     }
     // days
     $purgeUpdatedAtPeriod = 30;
     // days
     if (isset($options['p'])) {
         if (!is_numeric($options['p']) || $options['p'] < 0) {
             self::failWrongInputs("Period of purge must be positive numeric of days");
         }
         $purgeUpdatedAtPeriod = $options['p'];
     }
     self::$purgeEndUpdatedAt = self::$purgeStartUpdatedAt + $purgeUpdatedAtPeriod * 60 * 60 * 24;
     // days
     $oldPartnersUpdatedAtPeriod = 24;
     // months
     if (isset($options['b'])) {
         if (!is_numeric($options['b']) || $options['b'] < 0) {
             self::failWrongInputs("Period of blocked partners to delete must be positive numeric of months");
         }
         $oldPartnersUpdatedAtPeriod = $options['b'];
     }
     self::$oldPartnersUpdatedAt = time() - $oldPartnersUpdatedAtPeriod * 60 * 60 * 24 * 30;
     // months
     $errObjectsUpdatedAtPeriod = 24;
     // months
     if (isset($options['e'])) {
         if (!is_numeric($options['e']) || $options['e'] < 0) {
             self::failWrongInputs("Period of error objects to delete must be positive numeric of months");
         }
         $errObjectsUpdatedAtPeriod = $options['e'];
     }
     self::$errObjectsUpdatedAt = time() - $errObjectsUpdatedAtPeriod * 60 * 60 * 24 * 30;
     // months
     if (isset($options['l'])) {
         if (!is_numeric($options['l']) || $options['l'] < 0) {
             self::failWrongInputs("Limit querymust be positive numeric value");
         }
         self::$queryLimit = $options['l'];
     }
 }
Exemple #6
0
 /**
  * Code to be run after inserting to database
  * @param PropelPDO $con 
  */
 public function postInsert(PropelPDO $con = null)
 {
     PartnerPeer::setUseCriteriaFilter(false);
     $this->reload();
     PartnerPeer::setUseCriteriaFilter(true);
     kEventsManager::raiseEvent(new kObjectCreatedEvent($this));
     if ($this->copiedFrom) {
         kEventsManager::raiseEvent(new kObjectCopiedEvent($this->copiedFrom, $this));
     }
 }
function getLoginPartners()
{
    PartnerPeer::clearInstancePool();
    $c = new Criteria();
    $c1 = $c->getNewCriterion(PartnerPeer::SERVICE_CONFIG_ID, 'services-paramount-mobile.ct');
    $c2 = $c->getNewCriterion(PartnerPeer::SERVICE_CONFIG_ID, 'services-disney-mediabowl.ct');
    $c1->addOr($c2);
    $c->add($c1);
    PartnerPeer::setUseCriteriaFilter(false);
    $partners = PartnerPeer::doSelect($c);
    PartnerPeer::setUseCriteriaFilter(true);
    $ids = array();
    foreach ($partners as $par) {
        $ids[] = $par->getId();
    }
    return $ids;
}