Show
Ignore:
Timestamp:
07/02/08 00:58:49 (6 months ago)
Author:
kumatch
Message:

Adjusted the reviewed and refactored behaviors to the presentation layer.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • events/phpframework/piece_framework/trunk/web/frontend/webapp/actions/Account/PictureAction.php

    r14106 r15019  
    1313require_once 'Piece/Unity/Service/FlowAction.php'; 
    1414require_once 'Piece/Unity/Service/Runemaster.php'; 
     15require_once 'Phwittr/Self.php'; 
    1516require_once 'Phwittr/Account.php'; 
    1617 
     
    4041     */ 
    4142 
    42     var $_userId; 
     43    var $_self; 
    4344 
    4445    /**#@-*/ 
     
    5051    function entryForm() 
    5152    { 
    52         if (is_null($this->_userId)) { 
    53             $user = $this->_context->getSession()->getAttribute('user'); 
    54             $this->_userId = $user->id; 
     53        if (is_null($this->_self)) { 
     54            $loginUser = $this->_context->getSession()->getAttribute('loginUser'); 
     55            $this->_self = new Phwittr_Self($loginUser->id); 
    5556        } 
    5657    } 
     
    6061        $master = new Piece_Unity_Service_Runemaster(); 
    6162        $master->addForm('AccountPicture', '/account/picture', true, true); 
     63 
     64        $viewElement = $this->_context->getViewElement(); 
     65        $viewElement->setElementByRef('self', $this->_self); 
    6266    } 
    6367 
     
    7175 
    7276        $saveFilePath = PHWITTR_PROFILE_IMAGES_DIRECTORY . 
    73             "/{$this->_userId}" . "/{$formValue->uploadedData['name']}"; 
     77            "/{$this->_self->id}" . "/{$formValue->uploadedData['name']}"; 
    7478        $saveDirectory = dirname($saveFilePath); 
    7579 
     
    7882        move_uploaded_file($formValue->uploadedData['tmp_name'], $saveFilePath); 
    7983 
    80         $account = new Phwittr_Account(); 
    81         $account->updatePicture($this->_userId, $saveFilePath); 
     84        Phwittr_Account::updatePicture($this->_self->id, $saveFilePath); 
     85        unset($this->_self); 
     86        $this->_self = null; 
    8287 
    8388        return 'DisplayForm'; 
     
    9398    { 
    9499        if (!file_exists($directory)) { 
    95             mkdir(dirname($directory)); 
     100            mkdir($directory); 
    96101        } else { 
    97102            $dir = new DirectoryIterator($directory); 
     
    100105                    continue; 
    101106                } 
    102                 if ($dir->isDir()) { 
    103                     $this->_removeInnerDirectory("{$directory}/{$target}"); 
    104                     rmdir("{$directory}/{$target}"); 
    105                 } else { 
    106                     unlink("{$directory}/{$target}"); 
    107                 } 
     107                unlink("{$directory}/{$target}"); 
    108108            } 
    109109        }