Exemplo n.º 1
0
 /**
  * @return	void
  */
 public function before()
 {
     // Execute parent::before first
     parent::before();
     // Anonymous user doesn't have a profile
     if ($this->visited_account->user->username == 'public') {
         Request::current()->redirect('welcome');
     }
     // Check if the visiting user is the owner of the account
     if ($this->account->is_owner($this->visited_account->user->id)) {
         $this->owner = TRUE;
     }
     // Is the account private?
     if (!$this->owner and $this->visited_account->account_private) {
         $this->request->redirect($this->dashboard_url);
     }
     $this->template->content = View::factory('pages/user/layout')->bind('account', $this->visited_account)->bind('owner', $this->owner)->bind('active', $this->active)->bind('sub_content', $this->sub_content)->bind('anonymous', $this->anonymous)->bind('followers', $followers)->bind('following', $following)->bind('view_type', $view_type);
     $this->template->content->nav = $this->get_nav();
     $following = $this->visited_account->user->following->find_all();
     $followers = $this->visited_account->user->followers->find_all();
     $view_type = "dashboard";
     // Some info about the owner of the user profile being visited
     // Will be used later for following unfollowing
     $this->template->content->fetch_url = URL::site() . $this->visited_account->account_path . '/user/user/manage';
     $this->template->content->user_item = json_encode(array("id" => $this->visited_account->user->id, "type" => "user", "item_name" => $this->visited_account->user->name, "item_url" => URL::site() . $this->visited_account->account_path, "following" => $this->user->has('following', $this->visited_account->user), "is_owner" => $this->user->id == $this->visited_account->user->id));
 }
Exemplo n.º 2
0
 /**
  * The before() method is called before main controller action.
  * In our template controller we override this method so that we can
  * set up default values. These variables are then available to our
  * controllers if they need to be modified.
  *
  * @return	void
  */
 public function before()
 {
     // Execute parent::before first
     parent::before();
     if (strtolower(Kohana::$config->load('auth.driver')) == 'riverid') {
         $this->riverid_auth = TRUE;
     }
     $this->template->content = View::factory('pages/login/main')->bind('messages', $this->messages)->bind('errors', $this->errors)->bind('referrer', $this->referrer);
 }
Exemplo n.º 3
0
 /**
  * The before() method is called before main controller action.
  * In our template controller we override this method so that we can
  * set up default values. These variables are then available to our
  * controllers if they need to be modified.
  *
  * @return	void
  */
 public function before()
 {
     // Execute parent::before first
     parent::before();
     if (strtolower(Kohana::$config->load('auth.driver')) == 'riverid') {
         $this->riverid_auth = TRUE;
     }
     $this->template->content = View::factory('pages/login/layout');
     $this->template->content->public_registration_enabled = Model_Setting::get_setting('public_registration_enabled');
 }
Exemplo n.º 4
0
 /**
  * @return	void
  */
 public function before()
 {
     // Execute parent::before first
     parent::before();
     // Get the river/bucket name from the url
     $name_url = $this->request->param('name', 0);
     $this->context = $this->request->param('context');
     switch ($this->context) {
         case "river":
             // Make sure River exists
             $this->river = ORM::factory('river')->where('river_name_url', '=', $name_url)->where('account_id', '=', $this->visited_account->id)->find();
             if (!$this->river->loaded()) {
                 // It doesn't -- redirect back to dashboard
                 $this->request->redirect($this->dashboard_url);
             }
             // Is the logged in user an owner
             if ($this->river->is_owner($this->user->id)) {
                 $this->owner = TRUE;
             }
             // If this river is not public and no ownership...
             if (!$this->river->river_public and !$this->owner) {
                 $request->redirect($this->dashboard_url);
             }
             $this->id = $this->river->id;
             $this->droplets = Model_River::get_droplets($this->user->id, $this->river->id, 0);
             // Default template for river content
             $this->template->content = View::factory('pages/river/layout')->bind('river', $this->river)->bind('droplets_view', $droplets_view)->bind('river_base_url', $this->river_base_url)->bind('settings_url', $this->settings_url)->bind('owner', $this->owner)->bind('user', $this->user)->bind('river_base_url', $this->river_base_url)->bind('nav', $this->nav);
             // Trend template
             $droplets_view = View::factory('pages/trend/river')->bind('trend', $this->trend);
             // Set the base url for this specific river
             $this->river_base_url = $this->river->get_base_url();
             // Settings url
             $this->settings_url = $this->river_base_url . '/settings';
             // Navigation Items
             $this->nav = Swiftriver_Navs::river($this->river);
             break;
         case "bucket":
             // Make sure Bucket exists
             $this->bucket = ORM::factory('bucket')->where('bucket_name_url', '=', $name_url)->where('account_id', '=', $this->visited_account->id)->find();
             if (!$this->bucket->loaded()) {
                 // It doesn't -- redirect back to dashboard
                 $this->request->redirect($this->dashboard_url);
             }
             $this->id = $this->bucket->id;
             $this->droplets = Model_Bucket::get_droplets($this->user->id, $this->bucket->id, 0);
             // Default template for bucket trends
             $this->template->content = View::factory('pages/trend/bucket')->bind('bucket', $this->bucket)->bind('droplets', $this->droplets)->bind('more_url', $this->more_url)->bind('drops_url', $drops_url)->bind('active', self::$active)->bind('trend', $this->trend);
             // Set the base url for this specific bucket
             $this->bucket_base_url = $this->bucket->get_base_url();
             $drops_url = URL::site() . $this->bucket->account->account_path . '/bucket/' . $this->bucket->bucket_name_url;
             $this->more_url = url::site() . $this->account->account_path . '/bucket/' . $this->bucket->bucket_name_url . '/more';
             break;
     }
 }
Exemplo n.º 5
0
 public function before()
 {
     parent::before();
     $this->template->content = View::factory('pages/error');
     $this->template->content->page = URL::site(rawurldecode(Request::$initial->uri()));
     // Internal request only!
     if (Request::$initial !== Request::$current) {
         if ($message = rawurldecode($this->request->param('message'))) {
             $this->template->content->message = $message;
         }
     } else {
         $this->request->action(404);
     }
     $this->response->status((int) $this->request->action());
 }
Exemplo n.º 6
0
 /**
  * @return	void
  */
 public function before()
 {
     // Execute parent::before first
     parent::before();
     $this->owner = $this->visited_account['id'] == $this->user['id'];
     $this->template->content = View::factory('pages/user/layout')->bind('account', $this->visited_account)->bind('sub_content', $this->sub_content)->bind('active', $this->active);
     $this->template->content->set('show_navigation', TRUE)->set('nav', $this->get_nav($this->user));
     $following = array();
     $followers = array();
     $view_type = "dashboard";
     if (!$this->owner) {
         $is_following = $this->account_service->is_account_follower($this->visited_account['id'], $this->user['id']);
         $follow_button = View::factory('template/follow');
         $follow_button->data = json_encode(array('id' => $this->user['id'], 'name' => $this->visited_account['owner']['name'], 'type' => 'user', 'following' => $is_following));
         $follow_button->action_url = URL::site($this->visited_account['account_path'] . '/user/followers/manage', TRUE);
         $this->template->content->follow_button = $follow_button;
     }
 }
Exemplo n.º 7
0
 public function before()
 {
     parent::before();
     $this->search_service = new Service_Search($this->api);
     // Check fo URL parameters
     if (!empty($_GET['q'])) {
         // Sanitize the search term - strip all HTML
         // Layout for the seach page
         $this->template->content = View::factory('pages/search/layout')->bind('search_results', $this->search_results)->bind('search_term', $this->search_term)->bind('active', $this->search_type)->bind('navigation_links', $navigation_links);
         // Set the active tab
         $active = strtolower($this->request->query('type'));
         $this->search_type = empty($active) ? 'drops' : $active;
         // Get the search term
         $this->search_term = urldecode($this->request->query('q'));
         $navigation_links = $this->get_search_nav();
     } else {
         $this->template->content = View::factory('pages/search/main');
     }
 }
Exemplo n.º 8
0
 public function before()
 {
     parent::before();
     // Check fo URL parameters
     if (!empty($_GET['q'])) {
         // Sanitize the search term - strip all HTML
         // Layout for the seach page
         $this->template->content = View::factory('pages/search/layout')->bind('sub_content', $this->sub_content)->bind('search_term', $this->search_term)->bind('url_params', $this->url_params);
         // Set the active tab
         $this->template->content->active = $this->request->action();
         // Get the search term
         $this->search_term = trim(strip_tags($_GET['q']));
         if (in_array($this->request->action(), array('photos', 'list'))) {
             // Set the search scope to the previous search scope
             // Necessary when the user the search is on a river/bucket
             // so that the user doesn't get presented with extra tabs
             $search_scope = Cookie::get(Swiftriver::COOKIE_PREVIOUS_SEARCH_SCOPE);
             if ($search_scope != 'all') {
                 $this->search_scope = $search_scope;
             }
         } else {
             // Set the search scope
             $this->search_scope = isset($_GET['search_scope']) ? $_GET['search_scope'] : Cookie::get(Swiftriver::COOKIE_SEARCH_SCOPE);
         }
         // Defaults the scope to 'all' if no scope exists
         if (empty($this->search_scope)) {
             $this->search_scope = "all";
         }
         // Set the search scope
         Cookie::set(Swiftriver::COOKIE_SEARCH_SCOPE, $this->search_scope);
         // URL Parameters
         $this->url_params = http_build_query(array('q' => $this->search_term));
         // If previous scope if empty, set to the current search scope
         $previous_scope = Cookie::get(Swiftriver::COOKIE_PREVIOUS_SEARCH_SCOPE);
         if (empty($previous_scope)) {
             $this->template->content->search_scope = $this->search_scope;
         }
     }
 }
Exemplo n.º 9
0
 /**
  * @return	void
  */
 public function before()
 {
     // Execute parent::before first
     parent::before();
     // Get the form id form the url
     $form_id = $this->request->param('name');
     // Find the matching form from the visited account's forms.
     foreach ($this->visited_account['forms'] as $form) {
         if ($form['id'] == $form_id) {
             $this->form = $this->form_service->get_array($form, $this->user);
         }
     }
     if (!isset($this->form)) {
         throw new HTTP_Exception_404();
     }
     $this->owner = $this->form['is_owner'];
     $this->collaborator = $this->form['collaborator'];
     // If this river is not public and no ownership...
     if (!$this->owner and !$this->collaborator) {
         throw new HTTP_Exception_403();
     }
     $this->form_base_url = $this->form_service->get_base_url($this->form);
 }
Exemplo n.º 10
0
 /**
  * @return	void
  */
 public function before()
 {
     // Execute parent::before first
     parent::before();
     $this->template->content = View::factory('pages/settings/layout')->bind('active', $this->active)->bind('settings_content', $this->settings_content);
 }
Exemplo n.º 11
0
 public function before()
 {
     parent::before();
     // TODO
 }
Exemplo n.º 12
0
 public function before()
 {
     parent::before();
     Swiftriver_Event::add('swiftriver.template.head.css', array($this, 'add_drop_base_css'));
     Swiftriver_Event::add('swiftriver.template.head.js', array($this, 'add_drop_base_js'));
 }