Example #1
0
 /**
  * Constructor
  */
 function __construct()
 {
     // Pre-condition sanity check
     if (empty($this->module)) {
         throw new Exception('$this->module not set');
     }
     if (!$this->r instanceof suxRenderer) {
         throw new Exception('$this->r is not an instance of suxRenderer()');
     }
     // Template
     $this->tpl = new suxTemplate($this->module);
     // Template
     $this->tpl->assignByRef('r', $this->r);
     // Renderer referenced in template
     $this->tpl->configLoad('my.conf', $this->module);
     // Config variables
     // Form
     $this->tpl->assign('form_name', $this->form_name);
     suxValidate::set_form($this->form_name);
     // Common objects
     $this->user = new suxUser();
     $this->log = new suxLog();
     $this->link = new suxLink();
     $this->pager = new suxPager();
     $this->tags = new suxTags();
 }
Example #2
0
 /**
  * Constructor
  *
  */
 function __construct($mode = 'register', $user = null)
 {
     // Declare objects
     $this->r = new userRenderer($this->module);
     // Renderer
     suxValidate::register_object('this', $this);
     // Register self to validator
     parent::__construct();
     // Let the parent do the rest
     // Give a unique form name
     $form_name = 'userEdit';
     $this->tpl->assign('form_name', $form_name);
     suxValidate::set_form($form_name);
     // -------------------------------------------------------------------
     // Edit mode
     // -------------------------------------------------------------------
     if ($mode == 'edit') {
         // Redirect if invalid
         if ($this->user->loginCheck(suxfunct::makeUrl('/user/register'))) {
             $this->mode = 'edit';
         }
         if ($user != $_SESSION['nickname']) {
             // Security check
             // Only a root user can modify other users
             if (!$this->user->isRoot()) {
                 suxFunct::redirect(suxFunct::makeUrl('/home'));
             }
         }
         // Get user
         $u = $this->user->getByNickname($user);
         if (!$u) {
             suxFunct::redirect(suxFunct::getPreviousURL());
         }
         // Invalid user
         $this->users_id = $u['users_id'];
     }
 }