Beispiel #1
0
 /**
  * @return	void
  */
 public function action_index()
 {
     $this->template->header->title = $this->river->river_name . ' ~ ' . __('Channel Settings');
     $this->active = 'channels';
     $this->settings_content = View::factory('pages/river/settings/channels');
     $this->settings_content->channels_config = json_encode(Swiftriver_Plugins::channels());
     $this->settings_content->channels = json_encode($this->river->get_channels(TRUE));
     $this->settings_content->base_url = $this->river->get_base_url() . '/settings/channels';
 }
Beispiel #2
0
 /**
  * @return	void
  */
 public function before()
 {
     // Execute parent::before first
     parent::before();
     // Get the river name from the url
     $river_name_url = $this->request->param('name');
     $action = $this->request->action();
     // Find the matching river from the visited account's rivers.
     if (($river = $this->account_service->has_river($this->visited_account, $river_name_url)) !== FALSE) {
         $this->river = $this->river_service->get_river_by_id($river['id'], $this->user);
     }
     if ($river_name_url and !$this->river and $action != 'manage') {
         $this->redirect($this->dashboard_url, 302);
     }
     // Action involves a specific river, check permissions
     if ($this->river) {
         $this->owner = $this->river['is_owner'] or $this->river['is_collaborator'];
         $this->is_collaborator = $this->river['is_collaborator'];
         $this->public = (bool) $this->river['public'];
         // If this river is not public and no ownership...
         if (!$this->public and !$this->owner and !$this->is_collaborator) {
             $this->redirect($this->dashboard_url, 302);
         }
         $this->river_base_url = $this->river_service->get_base_url($this->river);
         $this->settings_url = $this->river_base_url . '/settings';
         // Navigation Items
         $this->nav = Swiftriver_Navs::river($this->river);
         if ($this->owner) {
             $this->page_title = $this->river['name'];
         } else {
             $this->page_title = $this->river['account']['account_path'] . ' / ' . $this->river['name'];
         }
         $this->template->header->title = $this->page_title;
         $this->template->content = View::factory('pages/river/layout')->bind('droplets_view', $this->droplets_view)->bind('river_base_url', $this->river_base_url)->bind('settings_url', $this->settings_url)->bind('owner', $this->owner)->bind('anonymous', $this->anonymous)->bind('user', $this->user)->bind('nav', $this->nav)->bind('active', $this->active)->bind('page_title', $this->page_title)->bind('follow_button', $follow_button)->bind('is_collaborator', $this->is_collaborator);
         $view_data = array('channels_config' => json_encode(Swiftriver_Plugins::channels()), 'channels' => json_encode($this->river['channels']), 'channels_base_url' => $this->river_base_url . '/settings/channels/options', 'river' => $this->river);
         $this->template->content->set($view_data);
         $this->template->header->js .= HTML::script("themes/default/media/js/channels.js");
         // Show the follow button?
         if (!$this->owner and !$this->is_collaborator) {
             $is_following = $this->river_service->is_follower($this->river['id'], $this->user['id']);
             $river_data = json_encode(array('id' => $this->river['id'], 'name' => $this->river['name'], 'type' => 'river', 'following' => $is_following));
             $follow_button = View::factory('template/follow')->bind('data', $river_data)->bind('action_url', $action_url);
             $action_url = URL::site($this->river['url'] . '/manage');
         }
     }
 }
Beispiel #3
0
 /**
  * Create a New River
  * Step 2 - Open Channels
  * @return	void
  */
 public function action_open()
 {
     $this->step_content = View::factory('pages/river/settings/channels');
     $this->step = 'open';
     // This River
     $id = $this->request->param('id', 0);
     $river = ORM::factory('river', $id);
     if (!$river->loaded()) {
         $this->request->redirect(URL::site() . $this->account_path . '/river/create');
     }
     $this->step_content->channels_config = json_encode(Swiftriver_Plugins::channels());
     $this->step_content->channels = json_encode($river->get_channels(TRUE));
     $this->step_content->base_url = $river->get_base_url() . '/settings/channels';
     // Open Url
     $this->open_url = URL::site() . $this->account_path . '/river/create/open/' . $river->id;
     // View Url
     $this->view_url = URL::site() . $this->account_path . '/river/create/view/' . $river->id;
 }
Beispiel #4
0
 /**
  * Find all the active plugins with channel services
  *
  * @param   bool $reload Reloads the channel configs when TRUE
  * @return	array $channels
  */
 public static function channels($reload = FALSE)
 {
     if (!$reload and !empty(self::$channels)) {
         return self::$channels;
     }
     self::$channels = array();
     // Load the plugin configs and fetch only those that
     // have the channel property set to TRUE
     $config_plugins = Kohana::$config->load('plugin');
     $active_plugins = Kohana::$config->load('site')->get('plugins');
     foreach ($active_plugins as $active_plugin) {
         if (!isset($config_plugins[$active_plugin])) {
             continue;
         }
         $plugin_config = $config_plugins[$active_plugin];
         if (isset($plugin_config['channel']) and $plugin_config['channel'] == TRUE) {
             $channel_config = self::_validate_channel_plugin_config($plugin_config);
             if (!isset($channel_config)) {
                 continue;
             }
             self::$channels[] = array('name' => $plugin_config['name'], 'channel' => $active_plugin, 'options' => $channel_config);
         }
     }
     return self::$channels;
 }
Beispiel #5
0
 /**
  * Find all the active plugins with channel services
  *
  * @param   bool $reload Reloads the channel configs when TRUE
  * @return	array $channels
  */
 public static function channels($reload = FALSE)
 {
     if (!$reload and !empty(self::$channels)) {
         return self::$channels;
     }
     self::$channels = array();
     // Load the plugin configs and fetch only those that
     // have the channel property set to TRUE
     $config_plugins = Kohana::$config->load('plugin');
     $active_plugins = ORM::factory('plugin')->where('plugin_enabled', '=', '1')->find_all();
     foreach ($active_plugins as $active_plugin) {
         $plugin_config = $config_plugins[$active_plugin->plugin_path];
         if (isset($plugin_config['channel']) and $plugin_config['channel'] == TRUE) {
             if (!($channel_config = self::_validate_channel_plugin_config($plugin_config))) {
                 continue;
             }
             self::$channels[] = array('name' => $plugin_config['name'], 'channel' => $active_plugin->plugin_path, 'options' => $channel_config);
         }
     }
     return self::$channels;
 }