Пример #1
0
 public function testautoincrementIntoDb()
 {
     $dbCon = RsOpenFBDbTestUtils::getDbCon();
     $apiKey = "apiKe";
     $callbackUrl = "dbUrl";
     $canvasUrl = "canUrl";
     $default = 1;
     $name = "name";
     $secretKey = "secKey";
     $sidenavUrl = "sideUrl";
     try {
         $numRows = $this->getNumAllApps($dbCon);
         $id = Api_Dao_App::createApp($apiKey, $callbackUrl, $canvasUrl, $name, $default, $secretKey, $sidenavUrl, null, null);
         $this->assertEquals($numRows + 1, $this->getNumAllApps($dbCon));
         $row = $this->getApp($dbCon, $id);
         $this->assertEquals($callbackUrl, $row['callback_url']);
         $this->assertEquals($canvasUrl, $row['canvas_url']);
         $this->assertEquals($default, $row['isdefault']);
         $this->assertEquals($id, $row['id']);
         $this->assertEquals($name, $row['name']);
         $this->assertEquals($sidenavUrl, $row['sidenav_url']);
     } catch (Exception $exception) {
         Api_Dao_App::deleteApp($id);
         throw $exception;
     }
     Api_Dao_App::deleteApp($id);
     $this->assertEquals($numRows, $this->getNumAllApps($dbCon));
 }
Пример #2
0
 public static function getApp2()
 {
     static $app;
     if (!isset($app)) {
         $apiKey = "1001";
         $callbackUrl = "dbUrl 2";
         $canvasUrl = "canUrl 2";
         $default = 0;
         $name = "app name 2";
         $secretKey = "secKey 2";
         $sidenavUrl = "sideUrl 2";
         $app = Api_Dao_App::createApp($apiKey, $callbackUrl, $canvasUrl, $name, $default, $secretKey, $sidenavUrl, null, null);
     }
     return $app;
 }
Пример #3
0
 public function createApp($name, $apiKey, $secret, $appProperties, $nativeId = null, $domainKey = null)
 {
     $props = array();
     foreach (self::$defaultProperties as $pname => $defaultVal) {
         $props[$pname] = isset($appProperties[$pname]) ? $appProperties[$pname] : $defaultVal;
     }
     $callback_url = $props['callback_url'];
     $canvas_url = $props['canvas_url'];
     $sidenav_url = $props['sidenav_url'];
     $isdefault = $props['isdefault'];
     $icon_url = $props['icon_url'];
     $canvas_type = $props['canvas_type'];
     $desktop = $props['desktop'];
     $developer_mode = $props['developer_mode'];
     $author = $props['author'];
     $author_url = $props['author_url'];
     $author_description = $props['author_description'];
     $support_email = $props['support_email'];
     $application_type = $props['application_type'];
     $mobile = $props['mobile'];
     $deployed = $props['deployed'];
     $description = $props['description'];
     $default_fbml = $props['default_fbml'];
     $tos_url = $props['tos_url'];
     $postadd_url = $props['postadd_url'];
     $postremove_url = $props['postremove_url'];
     $privacy_url = $props['privacy_url'];
     $ip_list = $props['ip_list'];
     $about_url = $props['about_url'];
     $logo_url = $props['logo_url'];
     $edit_url = $props['edit_url'];
     $default_column = $props['default_column'];
     $attachment_action = $props['attachment_action'];
     $attachment_callback_url = $props['attachment_callback_url'];
     $api_key = null;
     //not used, but eliminates Notices
     $secret_key = null;
     //not used, but eliminates Notices
     $c = Doctrine_Manager::getInstance()->getConnectionForComponent('RingsideApp');
     $c->beginTransaction();
     try {
         $appId = Api_Dao_App::createApp($api_key, $callback_url, $canvas_url, $name, $isdefault, $secret_key, $sidenav_url, $icon_url, $canvas_type, $desktop, $developer_mode, $author, $author_url, $author_description, $support_email, $application_type, $mobile, $deployed, $description, $default_fbml, $tos_url, $postadd_url, $postremove_url, $privacy_url, $ip_list, $about_url, $logo_url, $edit_url, $default_column, $attachment_action, $attachment_callback_url, $nativeId);
         if ($appId === false) {
             throw new Exception("[AppServiceImpl] could not create app '{$name}' with api_key={$apiKey} on domain {$domainId}");
         }
         //create app keys for domain
         $keyService = Api_ServiceFactory::create('KeyService');
         $domainService = Api_ServiceFactory::create('DomainService');
         if ($domainKey == null) {
             $localDomainId = $domainService->getNativeIdByName('Ringside');
         } else {
             $localDomainId = $domainService->getNativeIdByApiKey($domainKey);
         }
         if ($localDomainId == null) {
             throw new Exception("[AppServiceImpl] no local domain named 'Ringside' found!");
         }
         if (!$keyService->createKeyset($appId, $localDomainId, $apiKey, $secret)) {
             throw new Exception("[AppServiceImpl] could not create keyset for app '{$name}' with api_key={$apiKey} on domain {$domainId}");
         }
         $c->commit();
     } catch (Exception $e) {
         $c->rollback();
         throw $e;
     }
     return $appId;
 }