public function execute()
 {
     $this->forceSystemAuthentication();
     myDbHelper::$use_alternative_con = null;
     $partnerId = $this->getRequestParameter("partnerId", null);
     $uiConfId = $this->getRequestParameter("uiConfId", null);
     $page = $this->getRequestParameter("page", 1);
     if ($partnerId !== null && $partnerId !== "") {
         $pageSize = 50;
         $c = new Criteria();
         $c->add(widgetPeer::PARTNER_ID, $partnerId);
         if ($uiConfId) {
             $c->add(widgetPeer::UI_CONF_ID, $uiConfId);
         }
         $c->addDescendingOrderByColumn(widgetPeer::CREATED_AT);
         $total = widgetPeer::doCount($c);
         $lastPage = ceil($total / $pageSize);
         $c->setOffset(($page - 1) * $pageSize);
         $c->setLimit($pageSize);
         $widgets = widgetPeer::doSelect($c);
     } else {
         $total = 0;
         $lastPage = 0;
         $widgets = array();
     }
     $this->uiConfId = $uiConfId;
     $this->page = $page;
     $this->lastPage = $lastPage;
     $this->widgets = $widgets;
     $this->partner = PartnerPeer::retrieveByPK($partnerId);
     $this->partnerId = $partnerId;
 }
Beispiel #2
0
 /**
  * Gets an array of widget objects which contain a foreign key that references this object.
  *
  * If this collection has already been initialized with an identical Criteria, it returns the collection.
  * Otherwise if this kshow has previously been saved, it will retrieve
  * related widgets from storage. If this kshow is new, it will return
  * an empty collection or the current collection, the criteria is ignored on a new object.
  *
  * @param      PropelPDO $con
  * @param      Criteria $criteria
  * @return     array widget[]
  * @throws     PropelException
  */
 public function getwidgets($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(kshowPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collwidgets === null) {
         if ($this->isNew()) {
             $this->collwidgets = array();
         } else {
             $criteria->add(widgetPeer::KSHOW_ID, $this->id);
             widgetPeer::addSelectColumns($criteria);
             $this->collwidgets = widgetPeer::doSelect($criteria, $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 the collection.
             $criteria->add(widgetPeer::KSHOW_ID, $this->id);
             widgetPeer::addSelectColumns($criteria);
             if (!isset($this->lastwidgetCriteria) || !$this->lastwidgetCriteria->equals($criteria)) {
                 $this->collwidgets = widgetPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastwidgetCriteria = $criteria;
     return $this->collwidgets;
 }
 public function execute()
 {
     $this->forceSystemAuthentication();
     myDbHelper::$use_alternative_con = null;
     //myDbHelper::DB_HELPER_CONN_PROPEL2
     $this->saved = false;
     $uiConfId = $this->getRequestParameter("id");
     if ($uiConfId) {
         $uiConf = uiConfPeer::retrieveByPK($uiConfId);
     } else {
         $uiConf = new uiConf();
     }
     if ($this->getRequest()->getMethodName() == "POST") {
         $uiConf->setPartnerId($this->getRequestParameter("partnerId"));
         $uiConf->setSubpId($uiConf->getPartnerId() * 100);
         $uiConf->setObjType($this->getRequestParameter("type"));
         $uiConf->setName($this->getRequestParameter("name"));
         $uiConf->setWidth($this->getRequestParameter("width"));
         $uiConf->setHeight($this->getRequestParameter("height"));
         $uiConf->setCreationMode($this->getRequestParameter("creationMode"));
         $uiConf->setSwfUrl($this->getRequestParameter("swfUrl"));
         $uiConf->setConfVars($this->getRequestParameter("confVars"));
         $useCdn = $this->getRequestParameter("useCdn");
         $uiConf->setUseCdn($useCdn === "1" ? true : false);
         $uiConf->setDisplayInSearch($this->getRequestParameter("displayInSearch"));
         $uiConf->setConfVars($this->getRequestParameter("confVars"));
         $uiConf->setTags($this->getRequestParameter("tags"));
         /* files: */
         if ($uiConf->getCreationMode() != uiConf::UI_CONF_CREATION_MODE_MANUAL) {
             $confFile = $this->getRequestParameter("uiconf_confFile");
             $confFileFeatures = $this->getRequestParameter("uiconf_confFileFeatures");
             if ($uiConf->getConfFile() != $confFile || $uiConf->getConfFileFeatures() != $confFileFeatures) {
                 $uiConf->setConfFile($confFile);
                 $uiConf->setConfFileFeatures($confFileFeatures);
             }
         }
         $uiConf->save();
         $this->saved = true;
     }
     // so script won't die when uiconf is missing
     if (!$uiConf) {
         $uiConf = new uiConf();
     }
     $partner = PartnerPeer::retrieveByPK($uiConf->getPartnerId());
     $types = $uiConf->getUiConfTypeMap();
     $c = new Criteria();
     $c->add(widgetPeer::UI_CONF_ID, $uiConf->getId());
     $c->setLimit(1000);
     $widgets = widgetPeer::doSelect($c);
     $widgetsPerPartner = array();
     $this->tooMuchWidgets = false;
     if (count($widgets) == 1000) {
         $this->tooMuchWidgets = true;
     } else {
         if ($widgets) {
             foreach ($widgets as $widget) {
                 if (!array_key_exists($widget->getPartnerId(), $widgetsPerPartner)) {
                     $widgetsPerPartner[$widget->getPartnerId()] = 0;
                 }
                 $widgetsPerPartner[$widget->getPartnerId()]++;
             }
         }
     }
     // find the FileSync
     $fileSyncs = array();
     $fileSyncs[] = array("key" => $uiConf->getSyncKey(uiConf::FILE_SYNC_UICONF_SUB_TYPE_DATA));
     $fileSyncs[] = array("key" => $uiConf->getSyncKey(uiConf::FILE_SYNC_UICONF_SUB_TYPE_FEATURES));
     foreach ($fileSyncs as &$fileSync) {
         $fileSync["fileSyncs"] = FileSyncPeer::retrieveAllByFileSyncKey($fileSync["key"]);
     }
     $this->fileSyncs = $fileSyncs;
     $this->widgetsPerPartner = $widgetsPerPartner;
     $this->directoryMap = $uiConf->getDirectoryMap();
     $this->swfNames = $uiConf->getSwfNames();
     $this->types = $types;
     $this->uiConf = $uiConf;
     $this->partner = $partner;
 }
Beispiel #4
0
 /**
  * Retrieve a list of available widget depends on the filter given
  * 
  * @action list
  * @param KalturaWidgetFilter $filter
  * @param KalturaFilterPager $pager
  * @return KalturaWidgetListResponse
  */
 function listAction(KalturaWidgetFilter $filter = null, KalturaFilterPager $pager = null)
 {
     if (!$filter) {
         $filter = new KalturaWidgetFilter();
     }
     $widgetFilter = new widgetFilter();
     $filter->toObject($widgetFilter);
     $c = new Criteria();
     $widgetFilter->attachToCriteria($c);
     $totalCount = widgetPeer::doCount($c);
     if ($pager) {
         $pager->attachToCriteria($c);
     }
     $list = widgetPeer::doSelect($c);
     $newList = KalturaWidgetArray::fromWidgetArray($list);
     $response = new KalturaWidgetListResponse();
     $response->objects = $newList;
     $response->totalCount = $totalCount;
     return $response;
 }
Beispiel #5
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(widgetPeer::DATABASE_NAME);
         $criteria->add(widgetPeer::ID, $pks, Criteria::IN);
         $objs = widgetPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
 /**
  * 
  */
 public function execute()
 {
     $this->forceSystemAuthentication();
     $kshow_ids = $this->getP("kshow_ids");
     $partner_id = $this->getP("partner_id");
     //		$subp_id = $this->getP ( "subp_id") ;
     $source_widget_id = $this->getP("source_widget_id", 201);
     $submitted = $this->getP("submitted");
     $method = $this->getP("method", "partner");
     $create = $this->getP("create");
     $limit = $this->getP("limit", 20);
     if ($limit > 300) {
         $limit = 300;
     }
     $this->kshow_ids = $kshow_ids;
     $this->partner_id = $partner_id;
     //		$this->subp_id = $subp_id;
     $this->source_widget_id = $source_widget_id;
     $this->method = $method;
     $this->create = $create;
     $this->limit = $limit;
     $errors = array();
     $res = array();
     $this->errors = $errors;
     if ($submitted) {
         // fetch all kshows that don't have widgets
         $c = new Criteria();
         $c->setLimit($limit);
         if ($method == "list") {
             $c->add(kshowPeer::ID, @explode(",", $kshow_ids), Criteria::IN);
         } else {
             $c->add(kshowPeer::PARTNER_ID, $partner_id);
             if ($create) {
                 // because we want to create - select those kshows that are not marked as "have widgets"
                 $c->add(kshowPeer::INDEXED_CUSTOM_DATA_3, NULL, Criteria::EQUAL);
             }
         }
         $c->addAscendingOrderByColumn(kshowPeer::CREATED_AT);
         // start at a specific int_id
         // TODO
         $kshows = kshowPeer::doSelect($c);
         $kshow_id_list = $this->getIdList($kshows, $partner_id, $errors);
         $fixed_kshows = array();
         //			$res [] = print_r ( $kshow_id_list ,true );
         $this->res = $res;
         //return;
         $this->errors = $errors;
         if ($kshow_id_list) {
             //	$kshow_id_list_copy = array_  $kshow_id_list ;
             $widget_c = new Criteria();
             $widget_c->add(widgetPeer::PARTNER_ID, $partner_id);
             $widget_c->add(widgetPeer::KSHOW_ID, $kshow_id_list, Criteria::IN);
             $widgets = widgetPeer::doSelect($widget_c);
             // - IMPORTANT - add the kshow->setIndexedCustomData3 ( $widget_id ) for wikis
             foreach ($widgets as $widget) {
                 $kshow_id = $widget->getKshowId();
                 if (in_array($kshow_id, $fixed_kshows)) {
                     continue;
                 }
                 // mark the kshow as one that has a widget
                 $kshow = $this->getKshow($kshows, $kshow_id);
                 $kshow->setIndexedCustomData3($widget->getId());
                 $kshow->save();
                 unset($kshow_id_list[$kshow_id]);
                 $fixed_kshows[$kshow_id] = $kshow_id;
                 //					print_r ( $kshow_id_list );
             }
             // create widgets for those who are still on the list === don't have a widget
             foreach ($kshow_id_list as $kshow_id) {
                 if (in_array($kshow_id, $fixed_kshows)) {
                     continue;
                 }
                 $kshow = $this->getKshow($kshows, $kshow_id);
                 $widget = widget::createWidget($kshow, null, $source_widget_id, null);
                 $kshow->setIndexedCustomData3($widget->getId());
                 $kshow->save();
                 $fixed_kshows[$kshow_id] = $kshow_id;
             }
         }
         // create a log file of the kaltura-widget tagss for wiki
         $partner = PartnerPeer::retrieveByPK($partner_id);
         if ($partner) {
             $secret = $partner->getSecret();
             foreach ($kshows as $kshow) {
                 $kshow_id = $kshow->getId();
                 $article_name = "Video {$kshow_id}";
                 $widget_id = $kshow->getIndexedCustomData3();
                 // by now this kshow should have the widget id
                 $subp_id = $kshow->getSubpId();
                 $md5 = md5($kshow_id . $partner_id . $subp_id . $article_name . $widget_id . $secret);
                 $hash = substr($md5, 1, 10);
                 $values = array($kshow_id, $partner_id, $subp_id, $article_name, $widget_id, $hash);
                 $str = implode("|", $values);
                 $base64_str = base64_encode($str);
                 $res[] = "kalturaid='{$kshow_id}'\tkwid='{$base64_str}'\t'{$str}'\n";
             }
         }
     }
     $this->res = $res;
 }