Changeset 15136

Show
Ignore:
Timestamp:
07/04/08 01:30:16 (5 years ago)
Author:
kumatch
Message:

Adjusted the change of authenticated user (self) object.

Location:
events/phpframework/piece_framework/trunk
Files:
11 modified

Legend:

Unmodified
Added
Removed
  • events/phpframework/piece_framework/trunk/libs/Phwittr/Interceptor/Self.php

    r15132 r15136  
    1414require_once 'Piece/Unity/Service/Authentication.php'; 
    1515 
    16 // {{{ Phwittr_Interceptor_LayoutSetter 
     16// {{{ Phwittr_Interceptor_Self 
    1717 
    1818/** 
    19  * Phwittr レイアウトセット 
     19 * Phwittr Self Interceptor 
    2020 * 
    2121 * @package    Phwittr_PieceFramework 
     
    2424 * @since      Class available since Release 0.1.0 
    2525 */ 
    26 class Phwittr_Interceptor_LayoutSetter extends Piece_Unity_Plugin_Common 
     26class Phwittr_Interceptor_Self extends Piece_Unity_Plugin_Common 
    2727{ 
    2828 
     
    6161    public function invoke() 
    6262    { 
    63         $viewElement = $this->_context->getViewElement(); 
    6463        $service = new Piece_Unity_Service_Authentication(); 
     64        if ($service->isAuthenticated()) { 
     65            $self = $this->_context->getSession()->getAttribute('self'); 
     66        } else { 
     67            $self = null; 
     68        } 
    6569 
    66         if ($service->isAuthenticated()) { 
    67             $viewElement->setElement('isAuthenticated', true); 
    68         } else { 
    69             $viewElement->setElement('isAuthenticated', false); 
    70         } 
     70        $this->_context->setAttributeByRef('self', $self); 
     71        $this->_context->getViewElement()->setElementByRef('self', $self); 
    7172 
    7273        return true; 
  • events/phpframework/piece_framework/trunk/web/frontend/webapp/actions/Account/PasswordAction.php

    r15019 r15136  
    5252    { 
    5353        if (is_null($this->_self)) { 
    54             $loginUser = $this->_context->getSession()->getAttribute('loginUser'); 
    55             $this->_self = new Phwittr_Self($loginUser->id); 
     54            $this->_self = $this->_context->getAttribute('self'); 
    5655        } 
    5756    } 
     
    6160        $master = new Piece_Unity_Service_Runemaster(); 
    6261        $master->addForm('AccountPassword', '/account/password'); 
    63  
    64         $viewElement = $this->_context->getViewElement(); 
    65         $viewElement->setElementByRef('self', $this->_self); 
    6662    } 
    6763 
     
    7571 
    7672        try { 
    77             Phwittr_Account::updatePassword($this->_userId, 
     73            Phwittr_Account::updatePassword($this->_self->id, 
    7874                                            $formValue->password 
    7975                                            ); 
     76 
    8077            return 'DisplayForm'; 
    8178 
  • events/phpframework/piece_framework/trunk/web/frontend/webapp/actions/Account/PictureAction.php

    r15019 r15136  
    5252    { 
    5353        if (is_null($this->_self)) { 
    54             $loginUser = $this->_context->getSession()->getAttribute('loginUser'); 
    55             $this->_self = new Phwittr_Self($loginUser->id); 
     54            $this->_self = $this->_context->getAttribute('self'); 
    5655        } 
    5756    } 
     
    6160        $master = new Piece_Unity_Service_Runemaster(); 
    6261        $master->addForm('AccountPicture', '/account/picture', true, true); 
    63  
    64         $viewElement = $this->_context->getViewElement(); 
    65         $viewElement->setElementByRef('self', $this->_self); 
    6662    } 
    6763 
     
    8379 
    8480        Phwittr_Account::updatePicture($this->_self->id, $saveFilePath); 
    85         unset($this->_self); 
    86         $this->_self = null; 
     81 
     82        $selfId = $this->_self->id; 
     83        $this->_self = new Phwittr_Self($selfId); 
     84 
     85        $this->_context->getSession()->setAttributeByRef('self', $this->_self); 
     86        $this->_context->getViewElement()->setElementByRef('self', $this->_self); 
    8787 
    8888        return 'DisplayForm'; 
  • events/phpframework/piece_framework/trunk/web/frontend/webapp/actions/Account/SettingsAction.php

    r15018 r15136  
    5353    { 
    5454        if (is_null($this->_self)) { 
    55             $this->_loginUser = $this->_context->getSession()->getAttribute('loginUser'); 
     55            $this->_self = $this->_context->getAttribute('self'); 
    5656 
    57             $this->_self = new Phwittr_Self($this->_loginUser->id); 
    58             $this->_user->userName = $this->_self->userName; 
    59             $this->_user->email = $this->_self->email; 
     57            $this->_user->userName    = $this->_self->userName; 
     58            $this->_user->email       = $this->_self->email; 
    6059            $this->_user->privateFlag = $this->_self->privateFlag; 
    6160        } 
     
    6766        $master->addForm('AccountSettings', '/account/settings'); 
    6867        $master->setFormValue('AccountSettings', $this->_user); 
    69  
    70         $viewElement = $this->_context->getViewElement(); 
    71         $viewElement->setElementByRef('self', $this->_self); 
    7268    } 
    7369 
     
    8076 
    8177        try { 
    82             Phwittr_Account::confirmNewUserName($this->_loginUser->id, 
     78            Phwittr_Account::confirmNewUserName($this->_self->id, 
    8379                                                $this->_user->userName 
    8480                                                ); 
    85             Phwittr_Account::confirmNewEmail($this->_loginUser->id, 
     81            Phwittr_Account::confirmNewEmail($this->_self->id, 
    8682                                             $this->_user->email 
    8783                                             ); 
    8884 
     85            $user = clone($this->_self); 
     86            $user->userName    = $this->_user->userName; 
     87            $user->email       = $this->_user->email; 
     88            $user->privateFlag = $this->_user->privateFlag; 
     89 
    8990            $account = new Phwittr_Account(); 
    90             $account->update($this->_user); 
     91            $account->update($user); 
    9192 
    92             $this->_loginUser->userName = $this->_user->userName; 
    93             $this->_loginUser->email = $this->_user->email; 
    94             $this->_loginUser->privateFlag = $this->_user->privateFlag; 
    95  
    96             $this->_context->getSession()->setAttribute('loginUser', $this->_loginUser); 
    97             $this->_self = new Phwittr_Self($this->_loginUser->id); 
     93            $this->_self->userName = $this->_user->userName; 
     94            $this->_self->email    = $this->_user->email; 
     95            $this->_self->privateFlag = $this->_user->privateFlag; 
    9896 
    9997            return 'DisplayForm'; 
  • events/phpframework/piece_framework/trunk/web/frontend/webapp/actions/AuthenticationAction.php

    r14873 r15136  
    6464 
    6565        try { 
    66             $loginUser = Phwittr_Service::authenticate($this->_user->userName, 
     66            $self = Phwittr_Service::authenticate($this->_user->userName, 
    6767                                                  $this->_user->password 
    6868                                                  ); 
    6969 
    7070            $session = $this->_context->getSession(); 
    71             $session->setAttributeByRef('loginUser', $loginUser); 
     71            $session->setAttributeByRef('self', $self); 
    7272 
    7373            $authentication = &new Piece_Unity_Service_Authentication(); 
  • events/phpframework/piece_framework/trunk/web/frontend/webapp/actions/SelfAction.php

    r14946 r15136  
    5959        } 
    6060 
    61         $loginUser = $this->_context->getSession()->getAttribute('loginUser'); 
    62         $this->_self = new Phwittr_Self($loginUser->id); 
    63  
     61        $this->_self = $this->_context->getAttribute('self'); 
    6462        $this->_page = $this->_context->getAttribute('page'); 
    6563 
  • events/phpframework/piece_framework/trunk/web/frontend/webapp/actions/User/ArchiveAction.php

    r14874 r15136  
    5353        } 
    5454 
    55         $loginUser = $context->getSession()->getAttribute('loginUser'); 
    56         if ($loginUser) { 
    57             $loginUserId = $loginUser->id; 
     55        $self = $context->getAttribute('self'); 
     56        if ($self) { 
     57            $selfId = $self->id; 
    5858        } else { 
    59             $loginUserId = null; 
     59            $selfId = null; 
    6060        } 
    6161 
     
    6363 
    6464        try { 
    65             $user = new Phwittr_User($request->userName, $loginUserId); 
     65            $user = new Phwittr_User($request->userName, $selfId); 
    6666            $viewElement->setElementByRef('user', $user); 
    6767 
  • events/phpframework/piece_framework/trunk/web/frontend/webapp/actions/User/UserListAction.php

    r14874 r15136  
    5555            $userName = $request->userName; 
    5656        } else { 
    57             $loginUser = $context->getSession()->getAttribute('loginUser'); 
    58             $userName = $loginUser->userName; 
     57            $self = $context->getAttribute('self'); 
     58            $userName = $self->userName; 
    5959        } 
    6060 
  • events/phpframework/piece_framework/trunk/web/frontend/webapp/config/piece-unity-config.yaml

    r14939 r15136  
    7070        - Interceptor_Paging 
    7171        - Interceptor_Authentication 
    72         - Interceptor_LayoutSetter 
     72        - Interceptor_Self 
    7373 
    7474- name: Interceptor_Authentication 
  • events/phpframework/piece_framework/trunk/web/frontend/webapp/config/prepare.php

    r13954 r15136  
    1212require_once 'Piece/Unity.php'; 
    1313require_once 'Phwittr/ErrorHandler.php'; 
     14require_once 'Phwittr/Self.php'; 
    1415 
    1516session_name('PHWITTR'); 
  • events/phpframework/piece_framework/trunk/web/frontend/webapp/templates/Layout/Contents.html

    r14937 r15136  
    2727  <div id="header"> 
    2828    <h1><img src="/img/share/phwittr_logo.gif" alt="phwittr" /></h1> 
    29     <ul id="guideNav" if="isAuthenticated"> 
     29    <ul id="guideNav" if="self"> 
    3030      <li><a href="/home">ホーム</a></li> 
    3131      <li><a href="/account/settings">設定</a></li> 
    3232      <li><a href="/logout">ログアウト</a></li> 
    3333    </ul> 
    34     <ul id="guideNav" if="!isAuthenticated"> 
     34    <ul id="guideNav" if="!self"> 
    3535      <li><a href="/login">ログイン</a></li> 
    3636      <li><a href="/signup">ユーザ登録</a></li>