Ejemplo n.º 1
0
 public function index()
 {
     // auth
     Auth::isAdminAuthorized($this->signedUser, null, true, '/profile/sign-in');
     // prep
     $save = Converter::string('save', 'post');
     $form = new \Rebond\Core\User\Form($this->signedUser);
     // action
     if (isset($save)) {
         if ($form->setFromPost()->validate()->isValid()) {
             $obj = \Rebond\Util\Media::UploadForm('avatarId');
             if ($obj->result == ResultType::SUCCESS) {
                 $this->signedUser->setAvatarId($obj->id);
             }
             if ($obj->result != ResultType::ERROR) {
                 $this->signedUser->save();
                 Session::adminSuccess('saved', '/profile');
             } else {
                 Session::set('adminError', $obj->message);
             }
         } else {
             Session::set('adminError', $form->getValidation()->getMessage());
         }
     }
     // view
     $this->setTpl();
     $tplMain = new Template(Template::MODULE, ['core', 'user']);
     $tplMain->set('item', $form);
     // layout
     $this->tplLayout->set('column1', $tplMain->render('profile'));
     // master
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col'));
     $this->tplMaster->set('jsLauncher', 'profile');
     return $this->tplMaster->render('tpl-default');
 }
Ejemplo n.º 2
0
 public function form()
 {
     $simple = new \Rebond\Bus\Simple\Form();
     $post = Util\Converter::string('send', 'post');
     if (isset($post)) {
         if ($simple->setFromPost()->validate()->isValid()) {
             $result = Util\Media::UploadForm('photoId');
             if ($result->result == ResultType::SUCCESS) {
                 $simple->setPhotoId($result->id);
             }
             if ($result->result != ResultType::ERROR) {
                 $simple->save();
                 Util\Session::set('siteSuccess', 'submitted');
             } else {
                 Util\Session::set('siteError', $result->message);
             }
         } else {
             Util\Session::set('siteError', 'invalid');
         }
     }
     // view
     $this->setTpl();
     // main
     $tplMain = new Util\Template(Util\Template::MODULE, ['bus', 'simple']);
     $tplMain->set('item', $simple);
     // layout
     $this->tplLayout->set('column1', $tplMain->render('form'));
     // template
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-2-col'));
     return $this->tplMaster->render('tpl-default');
 }