/** * @return void */ public function before() { // Execute parent::before first parent::before(); // Get the river name from the url $bucket_name_url = $this->request->param('name'); $action = $this->request->action(); $this->bucket = ORM::factory('bucket')->where('bucket_name_url', '=', $bucket_name_url)->where('account_id', '=', $this->visited_account->id)->find(); if ($bucket_name_url and !$this->bucket->loaded() and $action != 'manage') { $this->request->redirect($this->dashboard_url); } if ($this->bucket->loaded()) { $this->owner = $this->bucket->is_owner($this->user->id); $this->collaborator = $this->bucket->is_collaborator($this->user->id); // Bucket isn't published and logged in user isn't owner if (!$this->bucket->bucket_publish and !$this->owner and !$this->collaborator) { $this->request->redirect($this->dashboard_url); } // Set the base url for this specific bucket $this->bucket_base_url = $this->bucket->get_base_url(); // Bucket Page Title $this->page_title = ""; if ($this->bucket->account->user->id == $this->user->id) { $this->page_title = $this->bucket->bucket_name; } else { $this->page_title = $this->bucket->account->account_path . ' / ' . $this->bucket->bucket_name; } } }
/** * @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'); } } }
/** * @return void */ public function before() { // Execute parent::before first parent::before(); // Base URL for the bucket $bucket_url_name = $this->request->param('name'); // Does the visited account own a bucket with the specified name? if (($bucket = $this->account_service->has_bucket($this->visited_account, $bucket_url_name)) !== FALSE) { $this->bucket = $this->bucket_service->get_bucket_by_id($bucket['id'], $this->user); $this->owner = $this->bucket['is_owner'] or $this->bucket['is_collaborator']; $this->bucket_base_url = $this->bucket_service->get_base_url($this->bucket); $this->is_collaborator = $this->bucket['is_collaborator']; } // If the bucket does not exist, redirect to the dashboard if (empty($this->bucket)) { $this->redirect($this->dashboard_url, 302); } // Set the page title $this->page_title = $this->bucket['name']; }
/** * @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(); // This check should be made when this controller is accessed // and the database id of the rive is non-zero $this->river = ORM::factory('river')->where('river_name_url', '=', $river_name_url)->where('account_id', '=', $this->visited_account->id)->find(); if ($river_name_url and !$this->river->loaded() and $action != 'manage') { $this->request->redirect($this->dashboard_url); } // Action involves a specific river, check permissions if ($this->river->loaded()) { $this->owner = $this->river->is_owner($this->user->id); $this->collaborator = $this->river->is_collaborator($this->user->id); // If this river is not public and no ownership... if (!$this->river->river_public and !$this->owner and !$this->collaborator) { $this->request->redirect($this->dashboard_url); } $this->river_base_url = $this->river->get_base_url(); $this->settings_url = $this->river_base_url . '/settings'; // Navigation Items $this->nav = Swiftriver_Navs::river($this->river); if ($this->river->account->user->id == $this->user->id or $this->river->account->user->username == 'public') { $this->template->header->title = $this->river->river_name; } else { $this->template->header->title = $this->river->account->account_path . ' / ' . $this->river->river_name; } $this->template->content = View::factory('pages/river/layout')->bind('river', $this->river)->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); $this->template->content->is_collaborator = $this->collaborator; if (!$this->owner) { $river_item = json_encode(array('id' => $this->river->id, 'type' => 'river', 'subscribed' => $this->river->is_subscriber($this->user->id))); // Action URL - To handle the follow/unfollow actions on the river $action_url = URL::site() . $this->visited_account->account_path . '/user/river/manage'; $this->template->content->river_item = $river_item; $this->template->content->action_url = $action_url; } } }