ProfileController.php
00001 <?php
00009 class User_ProfileController extends Dsao_Controller_Action
00010 {
00014 protected $_userProfile = null;
00015
00021 public function postDispatch()
00022 {
00023
00024 $this->getView()->assign
00025 ('userProfileUser', $this->_userProfile);
00026 }
00027
00028 public function preDispatch()
00029 {
00030 $this->_setDefaultModelClass('User_Profile')
00031 ->getHelper('History')->setAddToHistory();
00032
00033
00034 $this->_userProfile = new Dsao_User();
00035 }
00036
00045 public function editAction()
00046 {
00047
00048 $this->_userProfile = $this->getUser();
00049
00050
00051 $this->getView()->assign('userProfileLayouts', $this->getView()->getLayouts());
00052
00053
00054
00055 if (!$this->getRequest()->isPost() || !$this->getHelper('SessionToken')->hasValidToken())
00056 {
00057 return true;
00058 }
00059
00060
00061 $userDataChanged = $this->_getModel()->editProfile($this->getRequest(), $this->_userProfile);
00062
00063 if ($userDataChanged['invalidCols'])
00064 {
00065 foreach ($userDataChanged['invalidCols'] as $col)
00066 {
00067 $this->getLog()->err
00068 ($this->getTranslate()->_('user_profile_edit_error_invalid_field').
00069 ': '.$this->getTranslate()->_('user_profile_show_'.$col.'_template'));
00070 }
00071 }
00072
00073
00074 if ($userDataChanged['changedCols'])
00075 {
00076
00077 $this->getLog()->affirm('user_profile_edit_affirmation_changed');
00078 }
00079 }
00080
00089 public function showAction()
00090 {
00091
00092 if ($this->getUri()->id)
00093 {
00094 $this->_userProfile->setId($this->getUri()->id)->refresh();
00095 }
00096
00097 else
00098 {
00099 $this->_userProfile = $this->getUser();
00100 }
00101 }
00102 }