Changeset 14534

Show
Ignore:
Timestamp:
06/24/08 22:18:30 (5 years ago)
Author:
riaf
Message:

Request 実装できてないのに、 protected を実装した。早まった。反省はしていない。

Location:
events/phpframework/rhaco/trunk
Files:
3 added
4 modified

Legend:

Unmodified
Added
Removed
  • events/phpframework/rhaco/trunk/index.php

    r14011 r14534  
    1818$parser = Urls::parser( 
    1919    array( 
     20        // Index Page 
    2021        '^$' => array( 
    2122            'class' => 'Phwittr', 
    2223            'method' => 'index', 
    23         ), 
    24         '^home$' => array( 
    25             'class' => 'Phwittr', 
    26             'method' => 'home', 
    27         ), 
    28         '^status\/update$' => array( 
    29             'class' => 'PhwittrStatus', 
    30             'method' => 'status_update', 
    31         ), 
    32         '^account\/archive$' => array( 
    33             'class' => 'Phwittr', 
    34             'method' => 'archive', 
    3524        ), 
    3625        '^public_timeline$' => array( 
     
    4231            'method' => 'replies', 
    4332        ), 
     33 
     34        // 更新 
     35        '^status\/update$' => array( 
     36            'class' => 'PhwittrStatus', 
     37            'method' => 'status_update', 
     38        ), 
     39 
     40        // Home Page (Logged in) 
     41        '^home$' => array( 
     42            'class' => 'Phwittr', 
     43            'method' => 'home', 
     44        ), 
     45        '^account\/archive$' => array( 
     46            'class' => 'Phwittr', 
     47            'method' => 'archive', 
     48        ), 
    4449        '^statuses\/(\d+)$' => array( 
    4550            'class' => 'PhwittrStatus', 
    4651            'method' => 'status_detail', 
     52        ), 
     53 
     54        // Follow 
     55        '^friendships\/create\/(\d+)$' => array( 
     56            'class' => 'PhwittrUser', 
     57            'method' => 'follow', 
     58        ), 
     59        '^friendships\/destroy\/(\d+)$' => array( 
     60            'class' => 'PhwittrUser', 
     61            'method' => 'disFollow', 
     62        ), 
     63 
     64        // ログイン/サインアップ 
     65        '^login$' => array( 
     66            'class' => 'PhwittrUser', 
     67            'method' => 'login', 
     68        ), 
     69        '^logout$' => array( 
     70            'class' => 'PhwittrUser', 
     71            'method' => 'logout', 
    4772        ), 
    4873        '^signup$' => array( 
     
    5479            'method' => 'signup', 
    5580        ), 
    56          '^login$' => array( 
     81        '^account\/settings$' => array( 
    5782            'class' => 'PhwittrUser', 
    58             'method' => 'login', 
     83            'method' => 'settings', 
    5984        ), 
    60         '^logout$' => array( 
     85        '^account\/password$' => array( 
    6186            'class' => 'PhwittrUser', 
    62             'method' => 'logout', 
     87            'method' => 'passwordChange', 
    6388        ), 
     89        // '^account\/picture$' => array( 
     90        //     'class' => 'PhwittrUser', 
     91        //     'method' => 'picture', 
     92        // ), 
    6493        '^account\/confirm\/(.*?)$' => array( 
    6594            'class' => 'PhwittrUser', 
    6695            'method' => 'confirm', 
    6796        ), 
    68         '^friendships\/create\/(\d+)$' => array( 
    69             'class' => 'PhwittrUser', 
    70             'method' => 'follow', 
    71         ), 
    72         '^friendships\/destroy\/(\d+)$' => array( 
    73             'class' => 'PhwittrUser', 
    74             'method' => 'disFollow', 
    75         ), 
     97 
    7698        // 最後じゃないとダメよ 
    7799        '^([A-Za-z0-9_-]+)$' => array( 
  • events/phpframework/rhaco/trunk/library/Phwittr.php

    r13964 r14534  
    4646        } 
    4747 
    48         $parser = $this->read( 
    49             new Status(), 
    50             new Criteria( 
     48        // protected な人とか居るよねえ。こんな雰囲気で良いのかなあ 
     49        $login = $this->getLoginSession(); 
     50        if($this->isLogin() && $user->getId() == $login->getId()){ 
     51            $criteria = new C( 
    5152                Q::eq(Status::columnUserId(), $user->getId()), 
    5253                Q::orc( 
     
    5859                ), 
    5960                Q::orderDesc(Status::columnCreatedAt()) 
    60             ) 
     61            ); 
     62        } else { 
     63            $criteria = new C( 
     64                Q::eq(Status::columnUserId(), $user->getId()), 
     65                Q::orc( 
     66                    Q::selectIn( 
     67                        Status::columnUserId(), 
     68                        Follow::columnFollowId(), 
     69                        new Criteria(Q::eq(Follow::columnUserId(), $user->getId()), Q::eq(User::columnPrivateFlag(), false)) 
     70                    ) 
     71                ), 
     72                Q::orderDesc(Status::columnCreatedAt()) 
     73            ); 
     74        } 
     75 
     76        $parser = $this->read( 
     77            new Status(), 
     78            $criteria 
    6179        ); 
    6280        $parser->setVariable('user', $user); 
  • events/phpframework/rhaco/trunk/library/PhwittrUser.php

    r14125 r14534  
    5353        return $parser; 
    5454    } 
    55      
     55 
     56    function settings(){ 
     57        $user = $this->loginRequired(); 
     58        $this->clearVariable('id', 'password', 'createdAt', 'updatedAt', 'deleteFlag', 'statusCount', 'followingCount', 'followerCount'); 
     59        $user = $this->dbUtil->get(new User($user->getId())); 
     60        $this->setVariable('privateFlag', ($this->isVariable('privateFlag')) ? 1 : 0); 
     61        $parser = $this->update(Rhaco::url('account/settings'), $this->toObject($user)); 
     62        $parser->setTemplate(Rhaco::constant('THEME') . '/account/settings.html'); 
     63        return $parser; 
     64    } 
     65 
     66    function passwordChange(){ 
     67        $user = $this->loginRequired(); 
     68        $user = $this->dbUtil->get(new User($user->getId())); 
     69        if( 
     70            $this->isPost() 
     71            && sha1($this->getVariable('oldPassword')) == $user->getPassword() 
     72            && $this->getVariable('password') == $this->getVariable('passwordConf') 
     73        ){ 
     74            $user->setPassword(sha1($this->getVariable('password'))); 
     75            if($user->save($this->dbUtil)){ 
     76                Header::redirect(Rhaco::url('account/password')); 
     77            } 
     78        } 
     79        return new HtmlParser(Rhaco::constant('THEME') .'/account/password.html'); 
     80    } 
     81 
    5682    function follow($followId){ 
    5783        $user = $this->loginRequired(); 
  • events/phpframework/rhaco/trunk/resources/templates/default/layout.html

    r14159 r14534  
    3939                <ul> 
    4040                        <li><a href="{$rhaco.url()}">home</a></li> 
    41                         <li><a href="http://phwittr.riaf.jp.s.hatena.ne.jp/">Favorites</a></li> 
    4241                        <li><a href="{$rhaco.url('public_timeline')}">everyone</a></li> 
    4342                <rt:if param="{$isLogin}"> 
    4443                        <li><a href="{$rhaco.url('replies')}">replies</a></li> 
    4544                        <li><a href="{$rhaco.url('account/archive')}">archive</a></li> 
     45                        <li><a href="{$rhaco.url('account/settings')}">settings</a></li> 
    4646                        <li><a href="{$rhaco.url('logout')}">logout</a></li> 
    4747                <rt:else />