Cleanup + AOOSCore::register + commit Form module
[AOOS.git] / modules / User / UserView.php
blob66d2276135acc7174c03c2f3c5a814f15ac1d28b
1 <?php
3 class UserView extends AOOSModule {
4 static public function dependencies() {
5 return array("Paginator", "Form", "Reciever");
8 public function add() {
9 $f = $this->core()->getModule("Form")->getWidget("Form");
10 $r = $this->core()->getModule("Reciever");
11 if ($row = $r->getRow("POST")) {
12 $this->parent()->createUser($row);
14 $f->setFields(array("username", "password", "email"));
15 $f->setModel($this->parent()->dataModel("USER"));
16 return $f;
19 public function edit() {
20 if (!$this->parent()->online()) {
21 return $this->show();
23 $f = $this->core()->getModule("Form")->getWidget("Form");
24 $r = $this->core()->getModule("Reciever");
25 if ($row = $r->getRow("POST")) {
26 $this->parent()->updateUser($row);
28 $f->setModel($this->parent()->dataModel("USER"));
29 return $f;
32 public function show() {
33 $r = $this->core()->getModule("Reciever");
34 if ($row = $r->getRow("POST")) {
35 $this->parent()->login($row);
37 if (!$this->parent()->online()) {
38 $f = $this->core()->getModule("Form")->getWidget("Form");
39 $f->setFields(array("username", "password"));
40 $f->setModel($this->parent()->dataModel("USER"));
41 return $f;
43 return "Hi ".$this->parent()->userInfo()->username;