/**
  * Gives a system applicative snapsot
  */
 public function execute()
 {
     myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3;
     $this->forceSystemAuthentication();
     $partner_id = $this->getRequestParameter('partner_id', -1);
     if ($partner_id >= 0) {
         myPartnerUtils::applyPartnerFilters($partner_id);
     }
     $this->partner_id = $partner_id;
     $limit = $this->getRequestParameter('limit', '30');
     if ($limit > 300) {
         $limit = 300;
     }
     $bands_only = $this->getRequestParameter("bands", false) != null;
     $modified_only = $this->getRequestParameter("modified", false) != null;
     $this->bands_only = $bands_only;
     $this->modified_only = $modified_only;
     $this->kshows_with_new_entries = $modified_only ? dashboardUtils::getUpdatedKshows() : null;
     $yesterday = mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"));
     $lastweek = mktime(0, 0, 0, date("m"), date("d") - 7, date("Y"));
     $query_esterday = date('Y-m-d', $yesterday);
     $query_lastweek = date('Y-m-d', $lastweek);
     $modified_band_ids = $modified_only ? array_keys($this->kshows_with_new_entries) : null;
     if ($modified_only) {
         // TODO - this chunk was copied from the code bellow with minor changes - generalize !
         $c = new Criteria();
         // 			$c->add ( kshowPeer::ID , $modified_band_ids , Criteria::IN ); // search only the given IDs
         $this->bandsOnly($bands_only, $modified_band_ids, $c, kshowPeer::PARTNER_ID);
         $this->kshow_count = kshowPeer::doCount($c);
         $criterion = $c->getNewCriterion(kshowPeer::CREATED_AT, $query_esterday, Criteria::GREATER_EQUAL);
         $c->add($criterion);
         $this->kshow_count1 = kshowPeer::doCount($c);
         $criterion = $c->getNewCriterion(kshowPeer::CREATED_AT, $query_lastweek, Criteria::GREATER_EQUAL);
         $c->add($criterion);
         $this->kshow_count7 = kshowPeer::doCount($c);
         $c->setLimit($limit);
         //$c->hints = array(kshowPeer::TABLE_NAME => "created_at_index");
         $c->addDescendingOrderByColumn(kshowPeer::CREATED_AT);
         $c->remove(kshowPeer::CREATED_AT);
         $c->addJoin(kshowPeer::PRODUCER_ID, kuserPeer::ID, Criteria::LEFT_JOIN);
         $this->kshows = kshowPeer::doSelectJoinkuser($c);
         $this->bands_only = $bands_only;
         $this->entry_count = 0;
         $this->entry_count1 = 0;
         $this->entry_count7 = 0;
         $this->entries = array();
         $this->kuser_count = 0;
         $this->kuser_count1 = 0;
         $this->kuser_count7 = 0;
         $this->kusers = array();
         dashboardUtils::updateKshowsRoughcutCount($this->kshows);
         return sfView::SUCCESS;
     }
     $c = new Criteria();
     $this->bandsOnly($bands_only, $modified_band_ids, $c, kshowPeer::PARTNER_ID);
     $this->kshow_count = kshowPeer::doCount($c);
     $d = new Criteria();
     $this->bandsOnly($bands_only, $modified_band_ids, $d, kshowPeer::PARTNER_ID);
     $criterion = $c->getNewCriterion(kshowPeer::CREATED_AT, $query_esterday, Criteria::GREATER_EQUAL);
     $d->add($criterion);
     $this->kshow_count1 = kshowPeer::doCount($d);
     $e = new Criteria();
     $this->bandsOnly($bands_only, $modified_band_ids, $e, kshowPeer::PARTNER_ID);
     $criterion = $c->getNewCriterion(kshowPeer::CREATED_AT, $query_lastweek, Criteria::GREATER_EQUAL);
     $e->add($criterion);
     $this->kshow_count7 = kshowPeer::doCount($e);
     //$this->kshow_count = kshowPeer::doCount( $c );
     $c->setLimit($limit);
     //$c->hints = array(kshowPeer::TABLE_NAME => "created_at_index");
     $c->addDescendingOrderByColumn(kshowPeer::CREATED_AT);
     $c->addJoin(kshowPeer::PRODUCER_ID, kuserPeer::ID, Criteria::LEFT_JOIN);
     $this->kshows = kshowPeer::doSelectJoinkuser($c);
     $c = new Criteria();
     $this->bandsOnly($bands_only, $modified_band_ids, $c, entryPeer::PARTNER_ID);
     $this->entry_count = entryPeer::doCount($c);
     $d = new Criteria();
     $this->bandsOnly($bands_only, $modified_band_ids, $d, entryPeer::PARTNER_ID);
     $criterion = $c->getNewCriterion(entryPeer::CREATED_AT, $query_esterday, Criteria::GREATER_EQUAL);
     $d->add($criterion);
     $this->entry_count1 = entryPeer::doCount($d);
     $e = new Criteria();
     $this->bandsOnly($bands_only, $modified_band_ids, $e, entryPeer::PARTNER_ID);
     $criterion = $c->getNewCriterion(entryPeer::CREATED_AT, $query_lastweek, Criteria::GREATER_EQUAL);
     $e->add($criterion);
     $this->entry_count7 = entryPeer::doCount($e);
     $c->setLimit($limit);
     //$c->hints = array(entryPeer::TABLE_NAME => "created_at_index");
     $c->addDescendingOrderByColumn(entryPeer::CREATED_AT);
     $c->add(entryPeer::TYPE, entryType::MEDIA_CLIP);
     // we don't want entries that
     //		$c->addJoin(entryPeer::KUSER_ID, kuserPeer::ID, Criteria::INNER_JOIN);
     //	    $c->addJoin(entryPeer::KSHOW_ID, kshowPeer::ID, Criteria::INNER_JOIN);
     $this->entries = entryPeer::doSelectJoinAll($c);
     $c = new Criteria();
     $this->bandsOnly($bands_only, $modified_band_ids, $c, kuserPeer::PARTNER_ID);
     $d = new Criteria();
     $this->bandsOnly($bands_only, $modified_band_ids, $d, kuserPeer::PARTNER_ID);
     $criterion = $c->getNewCriterion(kuserPeer::CREATED_AT, $query_esterday, Criteria::GREATER_EQUAL);
     $d->add($criterion);
     $this->kuser_count1 = kuserPeer::doCount($d);
     $e = new Criteria();
     $this->bandsOnly($bands_only, $modified_band_ids, $e, kuserPeer::PARTNER_ID);
     $criterion = $c->getNewCriterion(kuserPeer::CREATED_AT, $query_lastweek, Criteria::GREATER_EQUAL);
     $e->add($criterion);
     $this->kuser_count7 = kuserPeer::doCount($e);
     $this->kuser_count = kuserPeer::doCount($c);
     $c->setLimit($limit);
     $c->addDescendingOrderByColumn(kuserPeer::CREATED_AT);
     $this->kusers = kuserPeer::doSelect($c);
     dashboardUtils::updateKusersRoughcutCount($this->kusers);
     dashboardUtils::updateKshowsRoughcutCount($this->kshows);
     return sfView::SUCCESS;
 }
Beispiel #2
0
 public static function doCountOnPeer(Criteria $c)
 {
     return kuserPeer::doCount($c);
 }
Beispiel #3
0
 /**
  * Tests user->add with adminLoginUsersQuota partner parameter
  */
 public function testAdminLoginUsersQuota()
 {
     // check test prerequisites
     $c = new Criteria();
     $c->addAnd(kuserPeer::PARTNER_ID, $this->dummyPartner->getId());
     $c->addAnd(kuserPeer::LOGIN_DATA_ID, NULL, Criteria::NOT_EQUAL);
     $loginUsersNum = kuserPeer::doCount($c);
     if ($loginUsersNum != 1) {
         $this->fail('Partner [' . $this->dummyPartner->getId() . '] does not have only 1 user - test cannot proceed');
         return;
     }
     $this->startSession(KalturaSessionType::ADMIN, null);
     $newUser = $this->createUser(true, false, __FUNCTION__);
     $newUser2 = $this->createUser(true, true, __FUNCTION__);
     $newUser3 = $this->createUser(true, false, __FUNCTION__);
     $newUser4 = $this->createUser(true, true, __FUNCTION__);
     $newUser5 = $this->createUser(true, true, __FUNCTION__);
     // check that a negative number means no new users possible
     $this->dummyPartner->setAdminLoginUsersQuota(rand(-30, -2));
     $this->dummyPartner->save();
     $exceptionThrown = false;
     try {
         $this->addUser($newUser2);
     } catch (Exception $e) {
         $exceptionThrown = $e;
     }
     $this->checkException($exceptionThrown, 'ADMIN_LOGIN_USERS_QUOTA_EXCEEDED');
     // check that null means no new users possible
     $this->dummyPartner->setAdminLoginUsersQuota(null);
     $this->dummyPartner->save();
     $exceptionThrown = false;
     try {
         $this->addUser($newUser2);
     } catch (Exception $e) {
         $exceptionThrown = $e;
     }
     $this->checkException($exceptionThrown, 'ADMIN_LOGIN_USERS_QUOTA_EXCEEDED');
     // try to add more users than the partner's quota
     $this->dummyPartner->setAdminLoginUsersQuota(3);
     $this->dummyPartner->save();
     $this->assertType('KalturaUser', $this->addUser($newUser));
     $this->assertType('KalturaUser', $this->addUser($newUser2));
     $this->assertType('KalturaUser', $this->addUser($newUser5));
     $exceptionThrown = false;
     try {
         $this->addUser($newUser4);
     } catch (Exception $e) {
         $exceptionThrown = $e;
     }
     $this->checkException($exceptionThrown, 'ADMIN_LOGIN_USERS_QUOTA_EXCEEDED');
     $this->assertType('KalturaUser', $this->addUser($newUser3));
     $this->dummyPartner->setAdminLoginUsersQuota(4);
     $this->dummyPartner->save();
     $this->assertType('KalturaUser', $this->addUser($newUser4));
 }
Beispiel #4
0
 public function getAdminLoginUsersNumber()
 {
     $c = new Criteria();
     $c->addAnd(kuserPeer::PARTNER_ID, $this->getId());
     $c->addAnd(kuserPeer::LOGIN_DATA_ID, NULL, Criteria::NOT_EQUAL);
     $c->addAnd(kuserPeer::IS_ADMIN, true);
     $c->addAnd(kuserPeer::STATUS, KuserStatus::DELETED, Criteria::NOT_EQUAL);
     return kuserPeer::doCount($c);
 }
 protected function doCountOnPeer(Criteria $c)
 {
     return kuserPeer::doCount($c);
 }
Beispiel #6
0
 public static function notifyOneLessUser($loginDataId)
 {
     if (!$loginDataId) {
         return;
     }
     kuserPeer::setUseCriteriaFilter(false);
     $c = new Criteria();
     $c->addAnd(kuserPeer::PARTNER_ID, null, Criteria::NOT_EQUAL);
     $c->addAnd(kuserPeer::LOGIN_DATA_ID, $loginDataId);
     $c->addAnd(kuserPeer::STATUS, KuserStatus::DELETED, Criteria::NOT_EQUAL);
     $countUsers = kuserPeer::doCount($c);
     kuserPeer::setUseCriteriaFilter(true);
     if ($countUsers <= 0) {
         $loginData = self::retrieveByPK($loginDataId);
         $loginData->delete();
     }
 }
Beispiel #7
0
 /**
  * List users (When not set in the filter, blocked and deleted users will be returned too)
  * 
  * @action list
  * @param KalturaUserFilter $filter
  * @param KalturaFilterPager $pager
  * @return KalturaUserListResponse
  */
 public function listAction(KalturaUserFilter $filter = null, KalturaFilterPager $pager = null)
 {
     if (!$filter) {
         $filter = new KalturaUserFilter();
     }
     if (!$pager) {
         $pager = new KalturaFilterPager();
     }
     $userFilter = new kuserFilter();
     $filter->toObject($userFilter);
     $c = new Criteria();
     $c->addAnd(kuserPeer::PUSER_ID, NULL, Criteria::ISNOTNULL);
     $userFilter->attachToCriteria($c);
     $totalCount = kuserPeer::doCount($c);
     $pager->attachToCriteria($c);
     $list = kuserPeer::doSelect($c);
     $newList = KalturaUserArray::fromUserArray($list);
     $response = new KalturaUserListResponse();
     $response->objects = $newList;
     $response->totalCount = $totalCount;
     return $response;
 }
 /**
 	 * 
 select kshow.id,concat('http://www.kaltura.com/index.php/browse/bands?band_id=',indexed_custom_data_1),concat('http://profile.myspace.com/index.cfm?fuseaction=user.viewpr
 ofile&friendID=',indexed_custom_data_1) ,  kuser.screen_name , indexed_custom_data_1  from kshow ,kuser where kshow.partner_id=5 AND kuser.id=kshow.producer_id AND kshow.
 id>=10815  order by kshow.id ;
 ~
 */
 public function execute()
 {
     $this->forceSystemAuthentication();
     $kshow_id = $this->getRequestParameter("kshow_id", null);
     $band_id = $this->getRequestParameter("band_id", null);
     $kuser_name = $this->getRequestParameter("kuser_name", null);
     $this->other_kshows_by_producer = null;
     $error = "";
     $kshow = null;
     $kuser = null;
     $entries = null;
     $this->kuser_count = 0;
     $should_delete = $this->getRequestParameter("deleteme", "false") == "true";
     if ($kuser_name) {
         $c = new Criteria();
         $c->add(kuserPeer::SCREEN_NAME, "%" . $kuser_name . "%", Criteria::LIKE);
         $this->kuser_count = kuserPeer::doCount($c);
         $kuser = kuserPeer::doSelectOne($c);
         if ($kuser) {
             $this->other_kshows_by_producer = $this->getKshowsForKuser($kuser, null);
         } else {
             $error .= "Cannot find kuser with name [{$kuser_name}]<br>";
         }
         $other_kshow_count = count($this->other_kshows_by_producer);
         if ($other_kshow_count < 1) {
             // kuser has no kshow - delete him !
             if ($should_delete) {
                 $kuser->delete();
             }
         } else {
             if ($other_kshow_count == 1) {
                 $kshow_id = $this->other_kshows_by_producer[0]->getId();
             } else {
                 // kuser has more than one kshow - let user choose
                 $error .= "[{$kuser_name}] has ({$other_kshow_count}) shows.<br>";
             }
         }
     }
     if ($band_id) {
         $c = new Criteria();
         $c->add(kshowPeer::INDEXED_CUSTOM_DATA_1, $band_id);
         $c->add(kshowPeer::PARTNER_ID, 5);
         $kshow = kshowPeer::doSelectOne($c);
     } else {
         if ($kshow_id) {
             $kshow = kshowPeer::retrieveByPK($kshow_id);
         }
     }
     if ($kshow) {
         if (!$kuser) {
             $kuser = kuserPeer::retrieveByPK($kshow->getProducerId());
         }
         if ($kuser) {
             $this->other_kshows_by_producer = $this->getKshowsForKuser($kuser, $kshow);
             if ($should_delete) {
                 if (count($this->other_kshows_by_producer) == 0) {
                     $kuser->delete();
                 }
             }
         }
         $entries = $kshow->getEntrys();
         if ($should_delete) {
             $id_list = array();
             foreach ($entries as $entry) {
                 $id_list[] = $entry->getId();
             }
             if ($id_list) {
                 $d = new Criteria();
                 $d->add(entryPeer::ID, $id_list, Criteria::IN);
                 entryPeer::doDelete($d);
             }
         }
         if ($should_delete) {
             $kshow->delete();
         }
     } else {
         $error .= "Cannot find kshow [{$kshow_id}]<br>";
     }
     $this->kshow_id = $kshow_id;
     $this->kuser_name = $kuser_name;
     $this->kshow = $kshow;
     $this->kuser = $kuser;
     $this->entries = $entries;
     $this->should_delete = $should_delete;
     $this->error = $error;
 }