コード例 #1
0
ファイル: Account.php プロジェクト: Oluwafemikorede/gbedu
 public function signup($slug = null)
 {
     $this->data['title'] = 'Join Us';
     // $module_slug = $slug[0];
     $role = new \models\userrole();
     $user = new User();
     $this->data['user_role'] = $role->all();
     //PULL DATA FROM SITESETTINGS
     $document = new \Helpers\Document();
     $details = $document->siteSettings();
     //GET NEW USER STATUS ID
     $this->model->table('user_status');
     $user_status = $this->model->get_row(array("title" => "inactive"));
     $this->data['reg_form'] = $details['reg_form'];
     if (isset($_POST) && !empty($_POST)) {
         if ($_POST['password'] == $_POST['password2']) {
             $encrypted = md5($_POST['password']);
             $row_count = $user->get(array("email" => $_POST['email']));
             if (count($row_count) >= 1) {
                 $this->data['error'] = 'Email exists in our records, please use a different email';
             } else {
                 $insert_array = array('firstname' => $_POST['fname'], 'lastname' => $_POST['lname'], 'email' => $_POST['email'], 'password' => $encrypted, 'role' => $_POST['role'], 'status' => $user_status->id);
                 $hash = $user->register($insert_array);
                 if ($hash != '') {
                     //SEND ACCOUNT DETAILS TO USER
                     $fullname = $_POST['fname'] . ' ' . $_POST['lname'];
                     $subject = 'New Account';
                     $mail = new \helpers\phpmailer\mail();
                     $mail->template('welcome');
                     $mail->generalEmail($_POST['email'], $subject, $fullname, $hash);
                     $this->data['success'] = 'A link has been sent to your email, please click to activate your account';
                 } else {
                     $this->data['error'] = 'Operation Fails, Please contact admin';
                 }
             }
         } else {
             $this->data['error'] = 'Password does not match!';
         }
     }
     View::rendertemplate('header', $this->data);
     View::render('account/signup', $this->data);
     View::rendertemplate('footer', $this->data);
 }