public function tmpAction()
 {
     $form = new UsersForm();
     $form->setFields();
     $this->view->form = $form;
 }
예제 #2
0
 /**
  * Menu des options
  */
 public function executeOptions(sfWebRequest $r)
 {
     $a = array();
     // Loading forms with our session
     $avt = new AvatarForm($this->getUser()->getAttribute("ses"));
     $usr = new UsersForm($this->getUser()->getAttribute("ses"));
     $invites = new InvitesForm();
     $ipForm = new IpsForm();
     $ipForm->setDefault('ip', $r->getRemoteAddress());
     // Tab for avatar changing
     $a['avatar'] = $this->getTab("Avatar", "picture_edit.png", $this->getPartial($this->getModuleName() . "/avatar", array("form" => $avt)));
     // Loading IPs
     $ips = Doctrine::getTable("Ips")->findByUid($this->getUser()->getAttribute("id"));
     $a['ips'] = $this->getTab("IP address", "ip.png", $this->getPartial($this->getModuleName() . "/ip", array("form" => $ipForm, "ips" => $ips)));
     // Loading invitation codes if enabled
     if (sfConfig::get("app_invitation")) {
         // Getting codes
         $codes = Doctrine::getTable("Invites")->findByUid($this->getUser()->getAttribute("id"));
         // Building tab
         $a['invites'] = $this->getTab("Invitations", "cup.png", $this->getPartial($this->getModuleName() . "/invites", array("form" => $invites, "codes" => $codes)));
     }
     $a["options"] = $this->getTab("Options", "gear_in.png", $this->getPartial($this->getModuleName() . "/edit_profile", array("f" => $usr)));
     // If we've posted someting
     if ($r->isMethod('post')) {
         // If we've uploaded a new avatar
         if ($r->hasParameter("avatars")) {
             // Binding fields
             $avt->bind($r->getParameter($avt->getName()), $r->getFiles($avt->getName()));
             // If everything is OK
             if ($avt->isValid()) {
                 // Record in DB
                 $avt->save();
                 // Tell it to frontend
                 $this->getUser()->setFlash("notice", "Your avatar has been saved !");
                 $this->redirect('@homepage');
             }
         } elseif ($r->hasParameter("profile")) {
             // Binding fields
             $usr->bind($r->getParameter($usr->getName()));
             // If form is valid
             if ($usr->isValid()) {
                 // Save
                 $usr->save();
                 return $this->renderText("ok");
             }
         }
     } else {
         return $this->renderText(json_encode(array("right" => $a)));
     }
 }