function loadWithAccessCheck(ResourceAbstractTable $table, $id)
 {
     $id = $this->getInt('id');
     if ($id <= 0) {
         throw new Am_Exception_InputError(___("Wrong link - no id passed"));
     }
     if (!$this->getDi()->auth->getUserId()) {
         $this->_redirect('login?amember_redirect_url=' . $this->getFullUrl());
     }
     $p = $table->load($id);
     if (!$p->hasAccess($this->getDi()->user)) {
         $this->_redirect('no-access/content/' . sprintf('?id=%d&type=%s', $id, $table->getName(true)));
     }
     return $p;
 }
Exemplo n.º 2
0
 function loadWithAccessCheck(ResourceAbstractTable $table, $id)
 {
     if ($id <= 0) {
         throw new Am_Exception_InputError(___('Wrong link - no id passed'));
     }
     $p = $table->load($id);
     if (!$this->getDi()->auth->getUserId()) {
         if ($p->hasAccess(null)) {
             // guest access allowed?
             return $p;
         }
         // then process
         $this->_redirect('login?amember_redirect_url=' . urlencode($this->getFullUrl()));
     }
     if (!$p->hasAccess($this->getDi()->user)) {
         if (!empty($p->no_access_url)) {
             $this->_redirect($p->no_access_url);
         } else {
             $this->_redirect('no-access/content/' . sprintf('?id=%d&type=%s', $id, $table->getName(true)));
         }
     }
     return $p;
 }