Ejemplo n.º 1
0
 /**
  * @return	void
  */
 public function action_index()
 {
     // Get the id of the current river
     $river_id = $this->river['id'];
     // The maximum droplet id for pagination and polling
     $max_droplet_id = $this->river['max_drop_id'];
     // River filters
     $filters = $this->get_filters();
     //Get Droplets
     $droplets_array = $this->river_service->get_drops($river_id, 1, 20, NULL, $max_droplet_id, (bool) $this->photos, $filters);
     // Bootstrap the droplet list
     $this->template->header->js .= HTML::script("themes/default/media/js/drops.js");
     $droplet_js = View::factory('pages/drop/js/drops')->set('fetch_base_url', $this->river_base_url)->set('default_view', 'drops')->set('photos', $this->photos ? 1 : 0)->set('polling_enabled', TRUE);
     // Check if any filters exist and modify the fetch urls
     $droplet_js->filters = NULL;
     if (!empty($filters)) {
         $encoded_filters = array();
         parse_str(http_build_query($filters), $encoded_filters);
         $droplet_js->filters = json_encode($encoded_filters);
     }
     $droplet_js->droplet_list = json_encode($droplets_array);
     $droplet_js->max_droplet_id = $max_droplet_id;
     // No content view
     $no_content_view = empty($this->river['channels']) ? View::factory('pages/river/no-channels') : View::factory('pages/river/no-drops')->set('has_drops', $max_droplet_id > 0);
     // Select droplet list view with drops view as the default if list not specified
     $this->droplets_view = View::factory('pages/drop/drops')->set('no_content_view', $no_content_view)->set('asset_templates', View::factory('template/assets'))->bind('droplet_js', $droplet_js)->bind('user', $this->user)->bind('owner', $this->owner)->bind('anonymous', $this->anonymous);
     // Show expiry notice to owners only
     if ($this->owner and $this->river['expired']) {
         $this->droplets_view->nothing_to_display = "";
         $expiry_notice = View::factory('pages/river/expiry_notice');
         $expiry_notice->river_base_url = $this->river_base_url . "/extend";
         $expiry_notice->extension_period = Swiftriver::get_setting('default_river_lifetime');
         $this->droplets_view->river_notice = $expiry_notice;
     } elseif ($this->owner and $this->river['full']) {
         $this->droplets_view->nothing_to_display = "";
         $this->droplets_view->river_notice = View::factory('pages/river/full_notice');
     } else {
         $this->droplets_view->river_notice = '';
     }
     // Extend rivers accessed by an owner during notice perio
     if ($this->owner and !$this->river['expired'] and FALSE) {
         $days_remaining = $this->river->get_days_to_expiry();
         $notice_period = Swiftriver::get_setting('default_river_lifetime');
         if ($days_remaining <= $notice_period and $this->river->is_notified()) {
             Kohana::$log->add(Log::DEBUG, __("Extending lifetime of river with id :id", array(':id' => $this->river->id)));
             $this->river->extend_lifetime();
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Endpoint for extending the lifetime of the river
  * If the current user is not an owner of the river, they are redirected
  * the the river's main page
  */
 public function action_extend()
 {
     if (!$this->owner) {
         $this->request->redirect($this->river_base_url);
     }
     $this->auto_render = FALSE;
     $this->template = "";
     // Get the token
     if (isset($_GET['token']) and ($extension_token = $_GET['token']) !== NULL) {
         if ($this->river->expiry_extension_token === $extension_token) {
             $this->river->extend_lifetime();
         }
     }
     // Redirect to the landing page
     $this->request->redirect($this->river_base_url);
 }