Example #1
0
 private function _do_auth($type)
 {
     if ($this->m_once) {
         return;
     }
     $this->m_once++;
     switch ($type) {
         case 'basic':
             if (!ZRequest::getInstance()->isAuth()) {
                 return $this->_request_auth();
             }
             $this->login(ZRequest::getInstance()->user(), ZRequest::getInstance()->password());
             if (!$this->isAuthorized()) {
                 return $this->_request_auth();
             }
             break;
         case 'post':
             if (ZRequest::hasPost('login') and ZRequest::hasPost('password')) {
                 $this->login(ZRequest::getPost('login'), ZRequest::getPost('password'));
             }
             if (!$this->isAuthorized()) {
                 throw new ZControllerException('Unauthorized', ZControllerException::EXC_AUTH);
             }
             break;
         case 'get':
             if (ZRequest::hasGet('login') and ZRequest::hasGet('password')) {
                 $this->login(ZRequest::getPost('login'), ZRequest::getPost('password'));
             }
             if (!$this->isAuthorized()) {
                 throw new ZControllerException('Unauthorized', ZControllerException::EXC_AUTH);
             }
             break;
     }
 }
Example #2
0
 /**
  * Abstract implementation that interates of the children of the element
  * invoking loadRequestData. During this phase of the processing cycle
  * elements should retrieve input data from the ZRequest object
  *
  * @return boolean true if all children were processed, false otherwise
  */
 public function loadRequestData()
 {
     $id = $this->getID();
     if ($this->multiple) {
         $id = substr($id, 0, strlen($id) - 2);
     }
     $value = ZRequest::get($id);
     if (!$value) {
         $value = ZRequest::post($id);
     }
     if ($value) {
         $this->setValue($value);
         if (!is_array($value)) {
             $value = array($value);
         }
         foreach ($this->_childNodes as $child) {
             foreach ($value as $setting) {
                 if ($setting == $child->getValue()) {
                     $child->selected = true;
                 }
             }
         }
     }
     return true;
 }
Example #3
0
 /**
  * The methods will loaded the x & y position of the image click into the
  * ZFormImage component.
  *
  * @return void
  */
 public function loadRequestData()
 {
     /**
      *
      * @todo I don't like getting from both get and post,
      * Options include getting parent until a form is identified
      * Potentially pass bucket in as well
      * I don't like searching up, because for other controls you may not
      *  be contained within a form
      */
     $id = $this->getIDPath();
     $x = ZRequest::get($id . "_x");
     if (!$x) {
         $x = ZRequest::post($id . "_x");
     }
     $y = ZRequest::get($id . "_y");
     if (!$y) {
         $y = ZRequest::post($id . "_y");
     }
     if ($x && $y) {
         $this->_x = $x;
         $this->_y = $y;
     }
     return parent::loadRequestData();
 }
 /**
  * Retrieves the data associated with this element from the ZRequest object.
  *
  * @returns void
  * @todo I don't like getting from both get and post,
  * Options include getting parent until a form is identified
  * Potentially pass bucket in as well
  * I don't like searching up, because for other controls you may not
  * be contained withing a form
  */
 public function loadRequestData()
 {
     $id = $this->getIDPath();
     $value = ZRequest::get($id);
     if (!$value) {
         $value = ZRequest::post($id);
     }
     if ($value) {
         $this->setValue($value);
     } else {
         $id = $this->name;
         $value = ZRequest::get($id);
         if (!$value) {
             $value = ZRequest::post($id);
         }
         if ($value && $value == $this->value) {
             $this->checked = true;
         } else {
             unset($this->_attributes['checked']);
         }
     }
     return true;
 }
 /**
  * Persists the elements to the session for subsequent restoration and
  * presentation to the user (this is useful with multi-page forms).
  * Persisting an element consists of asking itself and each of its
  * children for a memento which is place into the session object.
  * Upon restoreState the memento is passed to the object for
  * reconstitution.
  */
 public function persist()
 {
     $mementos = array();
     $this->_gatherMementos($this, $mementos);
     if (count($mementos) > 0) {
         ZRequest::setSession($this->getIDPath(), $mementos);
     }
     return $mementos;
 }
 public function &__get($a_property)
 {
     switch ($a_property) {
         default:
             break;
         case 'application':
             return Zoombi::getApplication();
         case 'database':
             return Zoombi::getApplication()->getDatabase();
         case 'router':
             return $this->getModule()->getRouter();
         case 'session':
             return Zoombi::getApplication()->getSession();
         case 'request':
             return ZRequest::getInstance();
         case 'response':
             return ZResponse::getInstance();
         case 'module':
             return $this->getModule();
         case 'route':
             return $this->getModule()->getRoute();
         case 'registry':
             return $this->getModule()->getRegistry();
         case 'config':
             return $this->getModule()->getConfig();
         case 'language':
             return $this->getModule()->getLanguage();
         case 'load':
             return $this->getModule()->getLoader();
         case 'acl':
             return $this->getModule()->getAcl();
     }
     try {
         return $this->getProperty($a_property);
     } catch (ZException $e) {
         if ($e->getCode() == ZException::EXC_NO_PROPERTY) {
             return Zoombi::$null;
         }
     }
     return Zoombi::$null;
 }
Example #7
0
 /**
  * Get ZRequest instance
  * @return ZRequest
  */
 public static final function &getInstance()
 {
     if (self::$m_instance === null) {
         self::$m_instance = new self();
     }
     return self::$m_instance;
 }
 /**
  * Retrieves the data associated with this element from the ZRequest object.
  *
  * @returns void
  * @todo I don't like getting from both get and post,
  * Options include getting parent until a form is identified
  * Potentially pass bucket in as well
  * I don't like searching up, because for other controls you may not
  * be contained withing a form
  */
 public function loadRequestData()
 {
     $id = $this->name ? $this->name : $this->getID();
     $value = ZRequest::get($id);
     if (!$value) {
         $value = ZRequest::post($id);
     }
     if ($value) {
         $this->setValue($value);
     }
     return parent::loadRequestData();
 }
Example #9
0
 /**
  * Route path
  * @param string $a_path
  * @return ZModule
  */
 public final function &route($a_path, $a_args = array())
 {
     if (substr($a_path, 0, 1) == Zoombi::SS) {
         return Zoombi::getApplication()->route(substr($a_path, 1));
     }
     if (substr($a_path, 0, 3) == '..' . Zoombi::SS) {
         $parent = $this->getModule();
         if (!$parent) {
             $parent = Zoombi::getApplication();
         }
         return $parent->route(substr($a_path, 3));
     }
     $rewrite = $this->getRouter()->rewrite($a_path);
     $path = new ZRoute($rewrite);
     $epath = new ZRoutePath();
     if ($path->getSegment(0) == $this->getName()) {
         if ($this->getLoader()->hasController($path->getSegment(1)) or $this->getLoader()->hasModule($path->getSegment(1))) {
             $path->pop_start();
         }
     }
     $epath->parents[] = $this;
     $m = $this;
     do {
         $s = $path->getSegment(0);
         $m = $m->getLoader()->module($s, false);
         if ($m) {
             $epath->parents[] = $m;
             $path->pop_start();
         }
     } while ($m);
     $sc = $path->getSegment(0);
     $path->pop_start();
     $mod = $epath->module;
     if (!$mod) {
         $this->triggerError(new ZException('Application router can\'t find module "' . $path->getSegment(0) . '" -> ' . $rewrite, ZControllerException::EXC_LOAD));
     }
     $ctl = $epath->module->getLoader()->controller($sc, false);
     if (!$ctl) {
         return $this->triggerError(new ZException('Application router can\'t find controller "' . $sc . '" in module "' . $this->module->getName() . '" -> ' . $rewrite, ZControllerException::EXC_LOAD));
     }
     $epath->controller = $ctl;
     $sa = $path->getSegment(0);
     $path->pop_start();
     if (!$epath->controller->hasAction($sa)) {
         return $this->triggerError(new ZException('Application router can\'t find action "' . $sa . '" in controller "' . $sc . '" of module "' . $mod->getName() . '" -> ' . $rewrite, ZControllerException::EXC_ACTION));
     }
     $epath->action = $sa;
     ZRequest::getInstance()->setExecPath($epath);
     ZRequest::getInstance()->setRoutePath($epath);
     $old_args = $this->getArgs();
     $old_route = $this->getRoute();
     $old_current = $this->getRouter()->getForward();
     $nr = new ZRoute(implode(Zoombi::SS, array_merge($epath->toArray(), $path->getSegments())) . $path->queryString());
     $this->setArgs($a_args);
     $this->setRoute($nr);
     $this->getRouter()->setForward($nr);
     $epath->controller->requestAction($epath->action, $path->getSegments());
     /* $this->setReturn($epath->controller->getReturn());
     	  $this->setOutput($epath->controller->getOutput()); */
     foreach ($epath->parents as $mod) {
         if ($mod and $mod instanceof ZModule) {
             $mod->setReturn($epath->controller->getReturn());
             $mod->setOutput($epath->controller->getOutput());
         }
     }
     $this->setArgs($old_args);
     $this->setRoute($old_route);
     $this->getRouter()->setForward($old_current);
     return $this;
 }