commit 04e657a75b821f893c6ddacb39f018ca408978f1
Author: root <root@localhost.localdomain>
Date:   Tue Mar 1 07:56:06 2016 -0500

    ユーザー登録機能実装

diff --git a/app/Controller/UsersController.php b/app/Controller/UsersController.php
index e10f428..ccbb42e 100755
--- a/app/Controller/UsersController.php
+++ b/app/Controller/UsersController.php
@@ -9,11 +9,10 @@ App::uses('AppController', 'Controller');
 class UsersController extends AppController {
 
 	public $layout = 'procedure';
-	// var $name = 'users';
 
     public function beforeFilter() {
         parent::beforeFilter();
-        $this->Auth->allow('add');
+        $this->Auth->allow('register','activate');
     }
 
 /**
@@ -48,6 +47,115 @@ class UsersController extends AppController {
 		$this->set('user', $this->User->find('first', $options));
 	}
 
+
+/**
+ * register method
+ *
+ * @return void
+ */
+	public function register() {
+		if($this->request->is('post') || $this->request->is('put')){
+			$this->User->set($this->request->data);
+			if($this->User->validates()){
+				$this->Session->write('register',$this->request->data);
+				$this->redirect(array('action'=>'confirm'));
+			}else{
+			}
+		}
+
+	   //  if (!empty( $this->data)){
+	   //      //  保存
+	   //      if( $this->User->set( $this->data)){
+	   //      // if( $this->User->save( $this->data)){
+	   //          // ユーザアクティベート(本登録)用URLの作成
+	   //          $url = 
+	   //              DS . strtolower($this->name) .          // コントローラ
+	   //              DS . 'activate' .                       // アクション
+	   //              DS . $this->User->id .                  // ユーザID
+	   //              DS . $this->User->getActivationHash();  // ハッシュ値
+	   //          $url = Router::url( $url, true);  // ドメイン(+サブディレクトリ)を付与
+	   //          //  メール送信
+	   //          //  return
+				// $this->redirect(array('action' => 'confirm'));
+				// $this->Session->write('register',$this->request->data);
+	   //          $this->Session->setFlash( '仮登録成功。メール送信しました。');
+	   //      } else {
+	   //          //  バリデーションエラーメッセージを渡す
+	   //          $this->Session->setFlash( '入力エラー');
+	   //      }
+	   //  }
+	}
+	
+/**
+ * register confirm
+ */
+	public function confirm() {
+		if($this->Session->read('register')){
+			$this->set('register',$this->Session->read('register'));
+		}else{
+			$this->redirect(array('action'=>'register'));
+		}
+	}
+
+
+/**
+ * register sent
+ */
+	public function sent() {
+		// if (!empty( $this->data)){
+	 //        //  保存
+	   if( $this->User->save($this->Session->read('register'))){
+	            //  メール送信
+		$this->set('register',$this->Session->read('register'));
+		$name = $this->Session->read('register.user.login_id');
+		$mail = $this->Session->read('register.user.email');
+        // ユーザアクティベート(本登録)用URLの作成
+        $url = 
+            DS . 'users' .          // コントローラ
+            DS . 'activate' .                       // アクション
+            DS . $this->User->id .                  // ユーザID
+            DS . $this->User->getActivationHash();  // ハッシュ値
+        $url = Router::url( $url, true);  // ドメイン(+サブディレクトリ)を付与
+		$comment = $url;
+
+		$Email = new CakeEmail();
+		$Email->charset('ISO-2022-JP');
+		$Email->emailFormat('text');
+		$Email->template('user_register');
+		$Email->viewVars(array('name'=>$name,'comment'=>$comment));
+		$Email->from($mail);
+		$Email->to('hasegawa@i-hearts.jp');
+		$Email->subject('[PICT CODE]問い合わせ');
+		$Email->send();
+
+	            //  return
+				// $this->redirect(array('action' => 'confirm'));
+	            // $this->Session->setFlash( '仮登録成功。メール送信しました。');
+	    //     } else {
+	    //         //  バリデーションエラーメッセージを渡す
+	    //         $this->Session->setFlash( '入力エラー');
+	    //     }
+	    }
+
+	}	
+
+/**
+ * register activate
+ */
+	public function activate( $user_id = null, $in_hash = null) {
+	    // UserモデルにIDをセット
+	    $this->User->id = $user_id;
+	    if ($this->User->exists() && $in_hash == $this->User->getActivationHash()) {
+	    // 本登録に有効なURL
+	        // statusフィールドを0に更新
+	        $this->User->saveField( 'status', 0);
+	        $this->Session->setFlash( 'Your account has been activated.');
+	    }else{
+	    // 本登録に無効なURL
+	        $this->Session->setFlash( 'Invalid activation URL');
+	    }
+	}
+	
 /**
  * add method
  *
@@ -140,4 +248,9 @@ class UsersController extends AppController {
 	public function logout() {
 	    $this->redirect($this->Auth->logout());
 	}
+
+
+
 }
+
+
