/**
  * The subscribe view and processor
  */
 public function subscribeAction()
 {
     $identity = $this->authenticate();
     $userId = $identity['id'];
     if ($this->getRequest()->getParam('subscribe')) {
         // subscribe with id parameter
         $feedId = $this->getRequest()->getParam('feedId');
         $feed = $this->feeds->get($feedId);
         // if feed exists and user can register
         if ($feed && !$this->portal->get($userId, $feedId)) {
             $row = $this->portal->createRow(array('user_id' => $userId, 'feed_id' => $feedId));
             $row->save();
         }
         if ($this->getRequest()->isXmlHttpRequest()) {
             if ($row) {
                 $this->view->status = "Added";
             } else {
                 // error
                 $this->view->status = "Failed";
             }
             return;
         } else {
             $this->_helper->getHelper('Redirector')->goto('subscribe', null, null, array('feedId' => $feed['group_id'], 'subscribe' => true));
         }
     }
     $groupId = (int) $this->getRequest()->getParam('feedId');
     if (!$groupId) {
         $groupId = Feeds::ROOT_GROUP_ID;
     }
     // get all groups
     $this->view->groups = $this->feeds->listGroups($groupId);
     if ($this->view->groups === null) {
         // TODO: handle error - problems in group
         $this->gotoDefault();
     }
     // get predessecors
     $this->view->parents = $this->feeds->listParents($groupId);
     if ($this->view->parents === null) {
         // TODO: handle error - cyclic parents
         $this->gotoDefault();
     }
     // get feeds
     $this->view->feeds = $this->feeds->listFeeds($groupId);
     // check if already subscribed
     $this->view->subscription = array();
     foreach ($this->view->feeds as $feed) {
         $id = $feed['id'];
         $this->view->subscription[$id] = $this->portal->get($userId, $id) === null;
     }
     // user's identity
     $this->view->user = $identity;
     // the current group
     $this->view->groupId = $groupId;
 }