Esempio n. 1
0
 protected function initialize()
 {
     $id = $_GET['id'];
     $this->application_id = Renegade::applicationIdForChannelId($id);
     if ($this->isPostBack) {
         $this->processForm();
     }
     $options = array('default' => Renegade::databaseForId($this->application_id));
     $database = Renegade::database(RenegadeConstants::kDatabaseMongoDB, null, $options);
     $channels = $database->selectCollection(RenegadeConstants::kDatabaseChannels);
     $this->channel = $channels->findOne(array('_id' => $id));
     if ($this->channel) {
         $subscriptions = $database->selectCollection(RenegadeConstants::kDatabaseSubscriptions);
         /*
         	TODO index 'application' on subscriptions
         */
         $this->subscriptions = $subscriptions->find(array('application' => array('$ne' => $this->application_id)));
     } else {
         Renegade::redirect('/applications');
     }
 }
Esempio n. 2
0
 $form = AMForm::formWithContext($context);
 if ($form->isValid) {
     // first, does the user own this application?
     $db_applications = Renegade::database(RenegadeConstants::kDatabaseMongoDB, RenegadeConstants::kDatabaseApplications);
     $application = $db_applications->findOne(array('_id' => $form->inputApplicationId, 'owner' => $session->user));
     if ($application) {
         // Next, make sure the channel they are subscribing too is not one of the channels in the application already
         $options_channels = array('default' => Renegade::databaseForId($form->inputApplicationId));
         $db_channels = Renegade::database(RenegadeConstants::kDatabaseMongoDB, RenegadeConstants::kDatabaseChannels, $options_channels);
         $existing_channel = $db_channels->findOne(array('_id' => $form->inputId));
         // Does the user already have this channel in their application?
         if ($existing_channel) {
             echo 'You already have this channel';
             //Renegade::redirect('/applications/'.$form->inputApplicationId.'./channels');
         } else {
             $remote_application = Renegade::applicationIdForChannelId($form->inputId);
             $db_remote_options = array('default' => Renegade::databaseForId($remote_application));
             $db_remote_channels = Renegade::database(RenegadeConstants::kDatabaseMongoDB, RenegadeConstants::kDatabaseChannels, $db_remote_options);
             $remote_channel = $db_remote_channels->findOne(array('_id' => $form->inputId));
             // Is channel they want is real?
             if ($remote_channel) {
                 // is the channel private (no permissions)?
                 if ($remote_channel['defaultPermissions'] == 0) {
                     echo 'channel is private';
                     //Renegade::redirect('/applications/'.$form->inputApplicationId.'./channels');
                 } else {
                     // is subscribing to a subscription channel in another application even possible?
                     // I dont think so, since you would need the channel id anyway, which would point you to
                     // the origin application.
                     /*
                     	TODO