Ejemplo n.º 1
0
 public function login($redirectTo)
 {
     $roles = func_get_args();
     array_shift($roles);
     $this->authenticate($roles[0]);
     if (($c = count($roles)) > 1) {
         for ($i = 1; $i < $c; $i++) {
             $this->addRole($roles[$i]);
         }
     }
     if ($response = Sabel_Context::getResponse()) {
         $backUri = null;
         if ($request = Sabel_Context::getRequest()) {
             $backUri = $request->getValueWithMethod("back_uri");
         }
         if ($backUri === null) {
             $response->getRedirector()->to($redirectTo);
         } else {
             l("ACL: back to the page before authentication.", SBL_LOG_DEBUG);
             $response->getRedirector()->uri($backUri);
         }
     }
     $this->remove("login_uri");
     $this->remove("back_uri");
 }
Ejemplo n.º 2
0
 public function build($limit, array $getValues = array())
 {
     $page = 1;
     $pageKey = $this->attributes["pageKey"];
     if (isset($getValues[$pageKey])) {
         $page = $getValues[$pageKey];
         if (!is_numeric($page) || $page < 1) {
             $page = 1;
         }
     }
     $model = $this->model;
     $attributes =& $this->attributes;
     $uriQuery = array();
     foreach ($getValues as $key => $val) {
         if ($key === $pageKey) {
             unset($getValues[$key]);
         } elseif (is_array($val)) {
             foreach ($val as $k => $v) {
                 $uriQuery[] = urlencode("{$key}[{$k}]") . "=" . urlencode($v);
             }
         } else {
             $uriQuery[] = urlencode($key) . "=" . urlencode($val);
         }
     }
     $attributes["uriQuery"] = implode("&", $uriQuery);
     $count = $this->isJoin ? $model->getCount(null, false) : $model->getCount();
     $attributes["count"] = $count;
     $attributes["limit"] = $limit;
     $attributes["page"] = $page;
     $pager = new Sabel_View_Pager($count, $limit);
     $pager->setPageNumber($page);
     $attributes["viewer"] = new Sabel_View_PageViewer($pager);
     if ($count === 0) {
         $attributes["offset"] = 0;
         $attributes["results"] = array();
     } else {
         $offset = $pager->getSqlOffset();
         $this->_setOrderBy($getValues);
         $model->setLimit($limit);
         $model->setOffset($offset);
         $attributes["offset"] = $offset;
         $attributes["results"] = $model->{$this->method}();
         if ($this->uri === null && ($request = Sabel_Context::getRequest())) {
             $attributes["uri"] = get_uri_prefix() . "/" . $request->getUri();
         }
     }
     return $this;
 }