Ejemplo n.º 1
0
 /**
  * Enter description here...
  *
  * @param unknown_type $userId
  * @param unknown_type $props
  * @return unknown
  */
 public static function createNetwork($userId, $props)
 {
     if (empty($userId) || Api_Dao_User::isUserAdmin($userId)) {
         //create unique network key
         $uniqueKey = false;
         $netKey = '';
         while (!$uniqueKey) {
             $netKey = '';
             for ($k = 0; $k < 32; $k++) {
                 $netKey .= dechex(mt_rand(1, 15));
             }
             $uniqueKey = Api_Dao_Network::checkUniqueKey($netKey);
         }
         $eprops = array();
         foreach ($props as $name => $val) {
             $eprops[$name] = $val;
         }
         if (!isset($eprops['name'])) {
             $eprops['name'] = $netKey;
         }
         $ret = Api_Dao_Network::createNetwork($userId, $netKey, $eprops);
         $netSecret = '';
         for ($k = 0; $k < 32; $k++) {
             $netSecret .= dechex(mt_rand(1, 15));
         }
         $ret = $ret && Api_Bo_DomainService::create()->createDomain($netKey, $eprops['web_url'], $netKey, $netSecret);
         if ($ret !== false) {
             return array($netKey, $netSecret);
         }
         return false;
     }
     throw new Exception('Only the administrator can create networks. (' . $userId . ')');
 }
Ejemplo n.º 2
0
 public function testIsUserAdmin()
 {
     $dbCon = RsOpenFBDbTestUtils::getDbCon();
     $this->assertFalse(Api_Dao_User::isUserAdmin(2, $dbCon));
     $this->assertTrue(Api_Dao_User::isUserAdmin(9999, $dbCon));
 }
Ejemplo n.º 3
0
 /**
  * Enter description here...
  *
  * @param unknown_type $userId
  * @return unknown
  */
 public static function isUserAdmin($userId)
 {
     return Api_Dao_User::isUserAdmin($userId);
 }