JSlip  1.0
UserAccountController.php
Go to the documentation of this file.
1 <?php
8 require_once(dirname(__FILE__) . '/../../lib/View.php');
9 require_once(dirname(__FILE__) . '/../../lib/Controller.php');
10 require_once(dirname(__FILE__) . '/UserAccountModel.php');
11 
13 {
14  public $param;
15  public $rest;
16  public $model;
17  public $view;
18  public $viewName;
19  public $dat;
20  public $bid;
21 
22  public function main($param) {
23 
24  $this->rest = '';
25  $this->param = $param;
26  $this->model = new UserAccountModel();
27  $this->view = new View();
28  $this->bid = $_SESSION['minfo']['bid'];
29 
30  $this->param['base'] = dirname(__FILE__);
31 
32  if (empty($this->param['act'])) {
33  $this->_edit();
34  } else {
35  switch ($this->param['act']) {
36  case 'check': $this->_check(); break;
37  case 'regist': $this->_regist(); break;
38  default: $this->_edit(); break;
39  }
40  }
41  }
42 
43  private function _edit() {
44 
45  $this->viewName = 'user_account_edit';
46  $this->dat = $this->model->getData($this->bid);
47  }
48 
49  private function _check() {
50 
51  $err = [];
52 
53  $name = $this->param['name'];
54  $email = $this->param['email'];
55  $tel = $this->param['tel'];
56  $passwd0 = $this->param['passwd0'];
57  $passwd1 = $this->param['passwd1'];
58 
59  if (empty($name)) {
60  $err[] = 'メンバー名は必須です。';
61  }
62 
63  if (!empty($passwd1)) {
64  if ($passwd0 != $passwd1) {
65  $err[] = 'パスワードが不正です。';
66  }
67  }
68 
69  if (empty($err)) {
70  $this->rest = json_encode(['sts' => 'OK']);
71  } else {
72  $this->rest = json_encode(['sts' => 'NG', 'err' => $err]);
73  }
74  }
75 
76  private function _regist() {
77 
78  $err = $this->model->regist($this->param);
79 
80  if (!empty($err)) {
81  $this->rest = json_encode(['sts' => 'NG', 'err' => $err]);
82  return;
83  }
84 
85  $this->rest = json_encode(['sts' => 'OK']);
86  }
87 }
UserAccountController\$param
$param
Definition: UserAccountController.php:14
UserAccountController\_regist
_regist()
Definition: UserAccountController.php:76
UserAccountController\$model
$model
Definition: UserAccountController.php:16
UserAccountController\$rest
$rest
Definition: UserAccountController.php:15
UserAccountController\_check
_check()
Definition: UserAccountController.php:49
View
Definition: View.php:8
UserAccountController
Definition: UserAccountController.php:12
UserAccountController\$dat
$dat
Definition: UserAccountController.php:19
Controller
Definition: Controller.php:15
UserAccountController\main
main($param)
Definition: UserAccountController.php:22
UserAccountController\$viewName
$viewName
Definition: UserAccountController.php:18
UserAccountController\$view
$view
Definition: UserAccountController.php:17
UserAccountController\$bid
$bid
Definition: UserAccountController.php:20
UserAccountController\_edit
_edit()
Definition: UserAccountController.php:43
UserAccountModel
Definition: UserAccountModel.php:10