/**
  * @return string Comma seperated string of role ids associated to the current user
  */
 public function getRoleIds()
 {
     if (is_null($this->roleIds)) {
         $this->roleIds = '';
         $c = new Criteria();
         $c->addAnd(KuserToUserRolePeer::KUSER_ID, $this->getId(), Criteria::EQUAL);
         $selectResults = KuserToUserRolePeer::doSelect($c);
         foreach ($selectResults as $selectResult) {
             if ($this->roleIds != '') {
                 $this->roleIds .= ',';
             }
             $this->roleIds .= $selectResult->getUserRoleId();
         }
     }
     return $this->roleIds;
 }
Esempio n. 2
0
 /**
  * Gets an array of KuserToUserRole 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 kuser has previously been saved, it will retrieve
  * related KuserToUserRoles from storage. If this kuser 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 KuserToUserRole[]
  * @throws     PropelException
  */
 public function getKuserToUserRoles($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(kuserPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collKuserToUserRoles === null) {
         if ($this->isNew()) {
             $this->collKuserToUserRoles = array();
         } else {
             $criteria->add(KuserToUserRolePeer::KUSER_ID, $this->id);
             KuserToUserRolePeer::addSelectColumns($criteria);
             $this->collKuserToUserRoles = KuserToUserRolePeer::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(KuserToUserRolePeer::KUSER_ID, $this->id);
             KuserToUserRolePeer::addSelectColumns($criteria);
             if (!isset($this->lastKuserToUserRoleCriteria) || !$this->lastKuserToUserRoleCriteria->equals($criteria)) {
                 $this->collKuserToUserRoles = KuserToUserRolePeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastKuserToUserRoleCriteria = $criteria;
     return $this->collKuserToUserRoles;
 }
 /**
  * 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(KuserToUserRolePeer::DATABASE_NAME);
         $criteria->add(KuserToUserRolePeer::ID, $pks, Criteria::IN);
         $objs = KuserToUserRolePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
<?php

/**
 * enable feature for each partner
 * set to all partners with partner->partnerPackage > 1 to 1  
 * @package Deployment
 * @subpackage updates
 */
$dryRun = true;
//TODO: change for real run
if (in_array('realrun', $argv)) {
    $dryRun = false;
}
require_once dirname(__FILE__) . '/../../bootstrap.php';
$con = myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2);
KalturaStatement::setDryRun($dryRun);
$c = new Criteria();
$c->add(UserRolePeer::NAME, "System Administrator", Criteria::EQUAL);
$adminRoles = UserRolePeer::doSelect($c, $con);
foreach ($adminRoles as $adminRole) {
    $c = new Criteria();
    $c->add(KuserToUserRolePeer::USER_ROLE_ID, $adminRole->getId(), Criteria::EQUAL);
    $admins = KuserToUserRolePeer::doSelect($c, $con);
    foreach ($admins as $admin) {
        $adminUser = $admin->getkuser($con);
        if ($adminUser) {
            $adminUser->setAllowedPartners('*');
            $adminUser->save();
        }
    }
}