public function execute()
 {
     die;
     $this->forceSystemAuthentication();
     $order = $this->getRequestParameter('sort', 'id');
     $page = $this->getRequestParameter('page', 1);
     $referer = $this->getRequestParameter('referer', "");
     $c = new Criteria();
     if ($referer) {
         $c->add(WidgetLogPeer::REFERER, "%{$referer}%", Criteria::LIKE);
     }
     $c->addAnd(WidgetLogPeer::REFERER, "%diff=%", Criteria::NOT_LIKE);
     $c->addAnd(WidgetLogPeer::REFERER, "%kaltura:%", Criteria::NOT_LIKE);
     $partner_id = $this->getRequestParameter('partner_id', -1);
     if ($partner_id >= 0) {
         $c->add(WidgetLogPeer::PARTNER_ID, $partner_id);
         //fixme: replace with myPartnerUtils::applyPartnerFilters( $partner_id );
     }
     $this->partner_id = $partner_id;
     $pager = WidgetLogPeer::getWidgetOrderedPager($order, 100, $page, $c);
     $widget_log_list = $pager->getResults();
     // following variables will be used by the view
     $this->firstTime = $this->getRequestParameter('first', 1) == 1;
     $this->order = $order;
     $this->page = $page;
     $this->lastPage = $pager->getLastPage();
     $this->numResults = $pager->getNbResults();
     $this->widget_log_list = $widget_log_list;
     $this->referer = $referer;
     // allow the action buttons to show only for entires the user on their own pages
     $this->allowactions = true;
 }
Esempio n. 2
0
 public function execute()
 {
     $this->forceSystemAuthentication();
     $start = microtime(true);
     $partner_id = $this->getP("partner_id");
     $limit = $this->getP("limit", 20);
     $c = new Criteria();
     $c->add(WidgetLogPeer::PARTNER_ID, $partner_id);
     $c->addAnd(WidgetLogPeer::REFERER, null, Criteria::ISNOTNULL);
     $c->addAnd(WidgetLogPeer::REFERER, "", Criteria::NOT_EQUAL);
     $c->addAnd(WidgetLogPeer::REFERER, "%kaltura:%", Criteria::NOT_LIKE);
     $c->addAnd(WidgetLogPeer::REFERER, "%localhost%", Criteria::NOT_LIKE);
     $c->addDescendingOrderByColumn(WidgetLogPeer::CREATED_AT);
     $c->setLimit(min($limit, 50));
     $this->widget_list = WidgetLogPeer::doSelect($c);
     $this->partner_id = $partner_id;
 }
 /**
  * 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(WidgetLogPeer::DATABASE_NAME);
         $criteria->add(WidgetLogPeer::ID, $pks, Criteria::IN);
         $objs = WidgetLogPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Esempio n. 4
0
 /**
  * Returns the number of related WidgetLog objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related WidgetLog objects.
  * @throws     PropelException
  */
 public function countWidgetLogs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(entryPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collWidgetLogs === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(WidgetLogPeer::ENTRY_ID, $this->id);
             $count = WidgetLogPeer::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(WidgetLogPeer::ENTRY_ID, $this->id);
             if (!isset($this->lastWidgetLogCriteria) || !$this->lastWidgetLogCriteria->equals($criteria)) {
                 $count = WidgetLogPeer::doCount($criteria, false, $con);
             } else {
                 $count = count($this->collWidgetLogs);
             }
         } else {
             $count = count($this->collWidgetLogs);
         }
     }
     return $count;
 }
Esempio n. 5
0
 /**
  * Builds a Criteria object containing the primary key for this object.
  *
  * Unlike buildCriteria() this method includes the primary key values regardless
  * of whether or not they have been modified.
  *
  * @return     Criteria The Criteria object containing value(s) for primary key(s).
  */
 public function buildPkeyCriteria()
 {
     $criteria = new Criteria(WidgetLogPeer::DATABASE_NAME);
     $criteria->add(WidgetLogPeer::ID, $this->id);
     if ($this->alreadyInSave && count($this->modifiedColumns) == 2 && $this->isColumnModified(WidgetLogPeer::UPDATED_AT)) {
         $theModifiedColumn = null;
         foreach ($this->modifiedColumns as $modifiedColumn) {
             if ($modifiedColumn != WidgetLogPeer::UPDATED_AT) {
                 $theModifiedColumn = $modifiedColumn;
             }
         }
         $atomicColumns = WidgetLogPeer::getAtomicColumns();
         if (in_array($theModifiedColumn, $atomicColumns)) {
             $criteria->add($theModifiedColumn, $this->getByName($theModifiedColumn, BasePeer::TYPE_COLNAME), Criteria::NOT_EQUAL);
         }
     }
     return $criteria;
 }
}
$c = new Criteria();
$c->add(kshowPeer::ID, $kshow_ids, Criteria::IN);
$kshows = kshowPeer::doSelect($c);
$kshows_data = array();
foreach ($kshows as $kshow) {
    $kshows_data[$kshow->getId()] = $kshow;
}
// fetch sum of plays per entry_id
$c = new Criteria();
$c->addSelectColumn(WidgetLogPeer::ENTRY_ID);
$c->addSelectColumn("SUM(" . WidgetLogPeer::PLAYS . ")");
$c->addSelectColumn("SUM(" . WidgetLogPeer::VIEWS . ")");
$c->add(WidgetLogPeer::ENTRY_ID, $entry_ids, Criteria::IN);
$c->addGroupByColumn(WidgetLogPeer::ENTRY_ID);
$rs = WidgetLogPeer::doSelectStmt($c);
$entries_data = array();
$res = $rs->fetchAll();
foreach ($res as $record) {
    $entry_id = $record[0];
    $plays = $record[1];
    $views = $record[2];
    $entries_data[$entry_id] = array("plays" => $plays, "views" => $views);
}
//old code from doSelectRs
//while($rs->next())
//{
//	$entry_id = $rs->getInt(1);
//	$plays= $rs->getInt(2);
//	$views = $rs->getInt(3);
//	$entries_data[$entry_id] = array("plays" => $plays, "views" => $views);
Esempio n. 7
0
 public static function incPlaysIfExists($kshow_id, $entry_id)
 {
     $entry_id = self::getKshowEntryId($kshow_id, $entry_id);
     $c = new Criteria();
     $c->add(WidgetLogPeer::ENTRY_ID, $entry_id);
     $c->add(WidgetLogPeer::KSHOW_ID, $kshow_id);
     $c->addAscendingOrderByColumn(WidgetLogPeer::ID);
     // the first found will always stay the first found
     $widget_log = WidgetLogPeer::doSelectOne($c);
     // update the statistics of the first existing widget_log
     if ($widget_log) {
         $widget_log->setPlays($widget_log->getPlays() + 1);
         $widget_log->save();
     } else {
         // if does not exist - do nothing.
         // there is no use incrementing the plays if the widget was never created
     }
 }
Esempio n. 8
0
 /**
  * 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 = WidgetLogPeer::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->setKmediaType($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setWidgetType($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setReferer($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setViews($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setIp1($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setIp1Count($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setIp2($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setIp2Count($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setCreatedAt($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setUpdatedAt($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setPlays($arr[$keys[13]]);
     }
     if (array_key_exists($keys[14], $arr)) {
         $this->setPartnerId($arr[$keys[14]]);
     }
     if (array_key_exists($keys[15], $arr)) {
         $this->setSubpId($arr[$keys[15]]);
     }
 }