Index: branches/dev/data/class/SC_Customer.php
===================================================================
--- branches/dev/data/class/SC_Customer.php	(revision 17)
+++ branches/dev/data/class/SC_Customer.php	(revision 11460)
@@ -50,8 +50,13 @@
 	}
 	
-	function getCustomerDataFromEmailPass( $pass, $email ) {
+	function getCustomerDataFromEmailPass( $pass, $email, $mobile = false ) {
+		$sql_mobile = $mobile ? ' OR email_mobile ILIKE ?' : '';
+		$arrValues = array($email);
+		if ($mobile) {
+			$arrValues[] = $email;
+		}
 		// ËÜÅÐÏ¿¤µ¤ì¤¿²ñ°÷¤Î¤ß
-		$sql = "SELECT * FROM dtb_customer WHERE email ILIKE ? AND del_flg = 0 AND status = 2";
-		$result = $this->conn->getAll($sql, array($email));
+		$sql = "SELECT * FROM dtb_customer WHERE (email ILIKE ?" . $sql_mobile . ") AND del_flg = 0 AND status = 2";
+		$result = $this->conn->getAll($sql, $arrValues);
 		$data = $result[0];
 		
@@ -63,4 +68,94 @@
 		}
 		return false;
+	}
+
+	/**
+	 * ·ÈÂÓÃ¼ËöID¤¬°ìÃ×¤¹¤ë²ñ°÷¤¬Â¸ºß¤¹¤ë¤«¤É¤¦¤«¤ò¥Á¥§¥Ã¥¯¤¹¤ë¡£
+	 *
+	 * @return boolean ³ºÅö¤¹¤ë²ñ°÷¤¬Â¸ºß¤¹¤ë¾ì¹ç¤Ï true¡¢¤½¤ì°Ê³°¤Î¾ì¹ç
+	 *                 ¤Ï false ¤òÊÖ¤¹¡£
+	 */
+	function checkMobilePhoneId() {
+		if (!isset($_SESSION['mobile']['phone_id']) || $_SESSION['mobile']['phone_id'] === false) {
+			return false;
+		}
+
+		// ·ÈÂÓÃ¼ËöID¤¬°ìÃ×¤·¡¢ËÜÅÐÏ¿¤µ¤ì¤¿²ñ°÷¤ò¸¡º÷¤¹¤ë¡£
+		$sql = 'SELECT count(*) FROM dtb_customer WHERE mobile_phone_id = ? AND del_flg = 0 AND status = 2';
+		$result = $this->conn->getOne($sql, array($_SESSION['mobile']['phone_id']));
+		return $result > 0;
+	}
+
+	/**
+	 * ·ÈÂÓÃ¼ËöID¤ò»ÈÍÑ¤·¤Æ²ñ°÷¤ò¸¡º÷¤·¡¢¥Ñ¥¹¥ï¡¼¥É¤Î¾È¹ç¤ò¹Ô¤¦¡£
+	 * ¥Ñ¥¹¥ï¡¼¥É¤¬¹ç¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ï¸ÜµÒ¾ðÊó¤ò¼èÆÀ¤¹¤ë¡£
+	 *
+	 * @param string $pass ¥Ñ¥¹¥ï¡¼¥É
+	 * @return boolean ³ºÅö¤¹¤ë²ñ°÷¤¬Â¸ºß¤·¡¢¥Ñ¥¹¥ï¡¼¥É¤¬¹ç¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ï true¡¢
+	 *                 ¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï false ¤òÊÖ¤¹¡£
+	 */
+	function getCustomerDataFromMobilePhoneIdPass($pass) {
+		if (!isset($_SESSION['mobile']['phone_id']) || $_SESSION['mobile']['phone_id'] === false) {
+			return false;
+		}
+
+		// ·ÈÂÓÃ¼ËöID¤¬°ìÃ×¤·¡¢ËÜÅÐÏ¿¤µ¤ì¤¿²ñ°÷¤ò¸¡º÷¤¹¤ë¡£
+		$sql = 'SELECT * FROM dtb_customer WHERE mobile_phone_id = ? AND del_flg = 0 AND status = 2';
+		@list($data) = $this->conn->getAll($sql, array($_SESSION['mobile']['phone_id']));
+
+		// ¥Ñ¥¹¥ï¡¼¥É¤¬¹ç¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢¸ÜµÒ¾ðÊó¤òcustomer_data¤Ë³ÊÇ¼¤·¤Ætrue¤òÊÖ¤¹¡£
+		if (sha1($pass . ':' . AUTH_MAGIC) == @$data['password']) {
+			$this->customer_data = $data;
+			$this->startSession();
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * ·ÈÂÓÃ¼ËöID¤òÅÐÏ¿¤¹¤ë¡£
+	 *
+	 * @return void
+	 */
+	function updateMobilePhoneId() {
+		if (!isset($_SESSION['mobile']['phone_id']) || $_SESSION['mobile']['phone_id'] === false) {
+			return;
+		}
+
+		if ($this->customer_data['mobile_phone_id'] == $_SESSION['mobile']['phone_id']) {
+			return;
+		}
+
+		$objQuery = new SC_Query;
+		$sqlval = array('mobile_phone_id' => $_SESSION['mobile']['phone_id']);
+		$where = 'customer_id = ? AND del_flg = 0 AND status = 2';
+		$objQuery->update('dtb_customer', $sqlval, $where, array($this->customer_data['customer_id']));
+
+		$this->customer_data['mobile_phone_id'] = $_SESSION['mobile']['phone_id'];
+	}
+
+	/**
+	 * email ¤«¤é email_mobile ¤Ø·ÈÂÓ¤Î¥á¡¼¥ë¥¢¥É¥ì¥¹¤ò¥³¥Ô¡¼¤¹¤ë¡£
+	 *
+	 * @return void
+	 */
+	function updateEmailMobile() {
+		// ¤¹¤Ç¤Ë email_mobile ¤ËÃÍ¤¬Æþ¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ï²¿¤â¤·¤Ê¤¤¡£
+		if ($this->customer_data['email_mobile'] != '') {
+			return;
+		}
+
+		// email ¤¬·ÈÂÓ¤Î¥á¡¼¥ë¥¢¥É¥ì¥¹¤Ç¤Ï¤Ê¤¤¾ì¹ç¤Ï²¿¤â¤·¤Ê¤¤¡£
+		if (!gfIsMobileMailAddress($this->customer_data['email'])) {
+			return;
+		}
+
+		// email ¤«¤é email_mobile ¤Ø¥³¥Ô¡¼¤¹¤ë¡£
+		$objQuery = new SC_Query;
+		$sqlval = array('email_mobile' => $this->customer_data['email']);
+		$where = 'customer_id = ? AND del_flg = 0 AND status = 2';
+		$objQuery->update('dtb_customer', $sqlval, $where, array($this->customer_data['customer_id']));
+
+		$this->customer_data['email_mobile'] = $this->customer_data['email'];
 	}
 	
@@ -101,5 +196,5 @@
 	
 	// ¥í¥°¥¤¥ó¤ËÀ®¸ù¤·¤Æ¤¤¤ë¤«È½Äê¤¹¤ë¡£
-	function isLoginSuccess() {
+	function isLoginSuccess($dont_check_email_mobile = false) {
 		// ¥í¥°¥¤¥ó»þ¤Î¥á¡¼¥ë¥¢¥É¥ì¥¹¤ÈDB¤Î¥á¡¼¥ë¥¢¥É¥ì¥¹¤¬°ìÃ×¤·¤Æ¤¤¤ë¾ì¹ç
 		if(sfIsInt($_SESSION['customer']['customer_id'])) {
@@ -107,4 +202,10 @@
 			$email = $objQuery->get("dtb_customer", "email", "customer_id = ?", array($_SESSION['customer']['customer_id']));
 			if($email == $_SESSION['customer']['email']) {
+				// ¥â¥Ð¥¤¥ë¥µ¥¤¥È¤Î¾ì¹ç¤Ï·ÈÂÓ¤Î¥á¡¼¥ë¥¢¥É¥ì¥¹¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¤³¤È¤â¥Á¥§¥Ã¥¯¤¹¤ë¡£
+				// ¤¿¤À¤· $dont_check_email_mobile ¤¬ true ¤Î¾ì¹ç¤Ï¥Á¥§¥Ã¥¯¤·¤Ê¤¤¡£
+				if (defined('MOBILE_SITE') && !$dont_check_email_mobile) {
+					$email_mobile = $objQuery->get("dtb_customer", "email_mobile", "customer_id = ?", array($_SESSION['customer']['customer_id']));
+					return isset($email_mobile);
+				}
 				return true;
 			}
@@ -121,4 +222,9 @@
 	function setValue($keyname, $val) {
 		$_SESSION['customer'][$keyname] = $val;
+	}
+
+	// ¥Ñ¥é¥á¡¼¥¿¤¬NULL¤«¤É¤¦¤«¤ÎÈ½Äê
+	function hasValue($keyname) {
+		return isset($_SESSION['customer'][$keyname]);
 	}
 	
