Skip to content

Commit

Permalink
revert some changes.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.coderepos.org/share/websites/events.php.gr.jp/trunk@35512 d0d07461-0603-4401-acd4-de1884942a52
  • Loading branch information
kaz_29 committed Oct 6, 2009
1 parent 7fa3a39 commit fb392a3
Show file tree
Hide file tree
Showing 470 changed files with 78,989 additions and 11,263 deletions.
52 changes: 27 additions & 25 deletions app/controllers/users_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class UsersController extends AppController
function beforeFilter()
{
//$this->Auth->userScope = array('User.flag' => 0);
$this->Auth->loginAction = '/users/login';
$this->Auth->loginAction = '/users/userlogin';
$this->Auth->logoutAction = '/users/userlogout';
$this->Auth->allow(
'add',
Expand Down Expand Up @@ -52,16 +52,14 @@ protected function getRequest()
$returnTo = 'http://'.$_SERVER['HTTP_HOST'] . $this->here;
$provider_list = array(
'http://profile.typekey.com/',
'http://profile.typepad.com/',
'http://www.hatena.ne.jp/',
'https://www.typepad.com/secure/services/openid/profilesserver/',
'http://mixi.jp/',
);

if ($this->data) {
if (!empty($this->data)) {
try {
if (!in_array($this->data['OpenidUrl']['provider_url'], $provider_list)) {
//throw new Exception('不正なプロバイダURLです');
throw new Exception('不正なプロバイダURLです');
}
$login_url = $this->data['OpenidUrl']['provider_url'];
if (!empty($this->data['OpenidUrl']['username'])) {
Expand Down Expand Up @@ -93,35 +91,35 @@ protected function getRequest()
return false;
}

/**
* login
*
*/
public function login()
function login()
{
$response = $this->getRequest();

// OpenID認証が通った場合
if ($response) {
$username = end(explode('/', trim($response->identity_url, '/')));
$provider_url = dirname(trim($response->identity_url, '/')) . '/';

$user = $this->User->findFromRequest($username, $provider_url);
$user = $this->User->find('first',array(
'conditions' => array(
'User.username' => $username,
'User.provider_url' => $provider_url,
),
'recursive' => -1
));

if ($user) {
//既存のuserなら
if (!empty($user)) {
//登録されているOpenIDユーザなら
$data = array(
'User.username' => $user['Openid']['username'],
'User.password' => $user['Openid']['password'],
'User.provider_url' => $user['Openid']['provider_url']
'User.username' => $user['User']['username'],
'User.password' => $user['User']['password'],
'User.provider_url' => $user['User']['provider_url']
);
foreach ($user['User'] as $key => $value) {
$this->Session->write($key, $value);
}
$this->Session->write('identity_url', $response->identity_url);
$this->__autologinForOpenid($data);
} else {
//既存のuserでなければ
//登録されているOpenIDユーザならニックネーム登録
$this->Session->write('username', $username);
$this->Session->write('provider_url', $provider_url);
$this->Session->write('identity_url', $response->identity_url);
Expand Down Expand Up @@ -171,11 +169,11 @@ function openid_add()
}
}

/**
* userlogout
*
* @todo logoutにrename
*/
function userlogin()
{

}

function userlogout()
{
$this->Session->setFlash('ログアウトしました');
Expand All @@ -184,7 +182,7 @@ function userlogout()
$this->redirect('/events/index');
}

protected function __autologinForOpenid($user){
function __autologinForOpenid($user){
//$this->Auth->userScope = array('User.flag' => 1);
$this->Auth->login($user);
$this->redirect('/events/index');
Expand Down Expand Up @@ -278,6 +276,10 @@ function downgrade()
*/
function config()
{
if (!$this->isUser()) {
$this->redirect('/');
}

$response = $this->getRequest();
if ($response) {
$username = end(explode('/', trim($response->identity_url, '/')));
Expand Down
Binary file modified app/dbs/event.db.default
Binary file not shown.
2 changes: 0 additions & 2 deletions app/models/event.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ function afterFind($result)
}

foreach ($result as $key => $row) {
if (isset($result[$key]['Event']['description'])) {
$result[$key]['Event']['description'] = $this->convertDescription($row['Event']['description'], $this->joined($row['Event']['id']));
}
}

return $result;
Expand Down
13 changes: 0 additions & 13 deletions app/models/openid.php

This file was deleted.

32 changes: 0 additions & 32 deletions app/models/system.php

This file was deleted.

33 changes: 2 additions & 31 deletions app/models/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,8 @@
*/
class User extends AppModel
{
public $name = 'User';
public $useTable = 'user';
public $Openid;

/**
*
*
*/
public function findFromRequest($username, $provider_url)
{
App::import('Model', 'Openid');

$this->Openid = new Openid();

$this->Openid->bindModel(
array(
'belongsTo' => array('User')
)
);

$user = $this->Openid->find('first',
array(
'conditions' => array(
'Openid.username' => $username,
'Openid.provider_url' => $provider_url,
),
)
);

return $user;
}
var $name = 'User';
var $useTable = 'user';
}

?>
120 changes: 36 additions & 84 deletions app/vendors/shells/convert.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,93 +2,27 @@
/**
* ConvertShell
*
* 1バージョンずつ更新していく感じで
*/
class ConvertShell extends Shell
{
public $uses = array('System');
class ConvertShell extends Shell {

var $support_update_version = array(
'2.1.0' => 'update203to210',
'2.0.3' => 'update202to203',
);

/**
* update203to210
*
*/
public function update203to210()
{
$sql_list = array(
'BEGIN TRANSACTION',

'CREATE TABLE openids (
id INTEGER NOT NULL PRIMARY KEY,
user_id INTEGER NOT NULL,
username VARCHAR,
password VARCHAR,
provider_url VACHAR,
created TIMESTAMP,
modified TIMESTAMP
);',

'INSERT INTO openids SELECT
NULL,
id,
username,
password,
provider_url,
created,
modified
FROM user',

'CREATE TEMPORARY TABLE user_tmp (
id INTEGER NOT NULL PRIMARY KEY,
nickname VARCHAR,
role VARCHAR,
created TIMESTAMP,
modified TIMESTAMP
);',

'INSERT INTO user_tmp SELECT id,nickname,role,created,modified FROM user',

'DROP TABLE user',

'CREATE TABLE user (
id INTEGER NOT NULL PRIMARY KEY,
nickname VARCHAR,
role VARCHAR,
created TIMESTAMP,
modified TIMESTAMP
);',

'INSERT INTO user SELECT * FROM user_tmp',

'DROP TABLE user_tmp',

"UPDATE system SET v_value = '2.1.0' WHERE v_column = 'version'",

'COMMIT',
);

foreach ($sql_list as $sql) {
$this->out($sql);
$ret = $this->System->query($sql);
if ($ret === false) {
$this->System->query("ROLLBACK");
$this->out("ROLLBACK!");
return -1;
}
}

$this->out( "done!!");
}

/*
* appディレクトリ内で下記のコマンドを実行でスキーマ変更を実施
* php ../cake/console/cake.php --working `pwd` convert update202to203
*/
public function update202to203()
{
function update202to203(){

require_once CONFIGS . 'database.php';
require_once CAKE.'libs/model/model.php';
require_once CAKE.'libs/model/app_model.php';
require_once APP.'models/event_attendee.php';


$event_attendee = new EventAttendee();

$sql_list = array(
'BEGIN TRANSACTION',

Expand Down Expand Up @@ -183,9 +117,9 @@ public function update202to203()

foreach ($sql_list as $sql) {
$this->out($sql);
$ret = $this->System->query($sql);
$ret = $event_attendee->query($sql);
if ($ret === false) {
$this->System->query("ROLLBACK");
$event_attendee->query("ROLLBACK");
$this->out("ROLLBACK!");
return -1;
}
Expand All @@ -195,9 +129,9 @@ public function update202to203()

}

public function version()
function version()
{
$version = $this->System->getVersion();
$version = $this->getVersion();

if ($version === false) {
$this->out("error: can't find version number");
Expand All @@ -206,9 +140,27 @@ public function version()
}
}

public function update()
private function getVersion()
{
require_once CONFIGS . 'database.php';
require_once CAKE.'libs/model/model.php';
require_once CAKE.'libs/model/app_model.php';
require_once APP.'models/system.php';

$system = new System();

$re = $system->findByVColumn('version');

if ($re === false) {
return false;
} else {
return $re['System']['v_value'];
}
}

function update()
{
$version = $this->System->getVersion();
$version = $this->getVersion();

$max_version = max(array_keys($this->support_update_version));

Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/default.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<?php endif; ?>
</em></li>
<?php else: ?>
<li><?php echo $html->link('Login', '/login'); ?></li>
<li><?php echo $html->link('Login', '/users/login'); ?></li>
<?php endif; ?>
<li><?php echo $html->link('RSS', '/events/rss'); ?></li>
</ul>
Expand Down
7 changes: 7 additions & 0 deletions app/views/users/userlogin.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
if ($session->check('Message.auth')) $session->flash('auth');
echo $form->create('User', array('action' => 'userlogin'));
echo $form->input('username');
echo $form->input('password');
echo $form->end('Login');
?>
Loading

0 comments on commit fb392a3

Please sign in to comment.