From 22bc0ce0e6b166be6ff25c0298241438ead6498f Mon Sep 17 00:00:00 2001 From: Charles Marion Date: Wed, 20 Apr 2011 14:38:56 +0200 Subject: [PATCH] ENH: Removed advanced search Improved user settings Added user privacy --- core/controllers/ErrorController.php | 4 +- core/controllers/SearchController.php | 5 -- core/controllers/UserController.php | 25 ++++++- .../components/NotifyErrorComponent.php | 17 +---- core/controllers/forms/UserForm.php | 4 +- core/layouts/layout.phtml | 3 +- core/public/css/layout/main.css | 5 ++ core/public/css/search/search.advanced.css | 0 core/public/css/user/user.settings.css | 20 +++++ core/public/js/layout/main.js | 2 +- core/public/js/search/search.advanced.js | 0 core/translation/fr-main.csv | 11 ++- core/views/community/manage.phtml | 2 +- core/views/community/view.phtml | 2 +- core/views/element/feed.phtml | 2 +- core/views/helpers/Linkuser.php | 21 ++++++ core/views/item/view.phtml | 4 +- core/views/search/advanced.phtml | 8 -- core/views/user/settings.phtml | 74 ++++++++++++++++--- core/views/user/userpage.phtml | 11 +-- 20 files changed, 159 insertions(+), 61 deletions(-) delete mode 100644 core/public/css/search/search.advanced.css delete mode 100644 core/public/js/search/search.advanced.js create mode 100644 core/views/helpers/Linkuser.php delete mode 100644 core/views/search/advanced.phtml diff --git a/core/controllers/ErrorController.php b/core/controllers/ErrorController.php index 1a5a58a51..53cbcd7fe 100644 --- a/core/controllers/ErrorController.php +++ b/core/controllers/ErrorController.php @@ -3,7 +3,7 @@ class ErrorController extends AppController { public $_models=array(); public $_daos=array(); - public $_components=array('NotifyError'); + public $_components=array('NotifyError','Utility'); public $_forms=array(); private $_error; private $_environment; @@ -81,7 +81,7 @@ public function errorAction() } else { - $this->getLogger()->warn('URL: '.$this->Utility->curPageURL()."\n".$this->view->message); + $this->getLogger()->warn('URL: '.$this->Component->NotifyError->curPageURL()."\n".$this->view->message); } } diff --git a/core/controllers/SearchController.php b/core/controllers/SearchController.php index 38bdf18fe..6b77db8cd 100644 --- a/core/controllers/SearchController.php +++ b/core/controllers/SearchController.php @@ -145,11 +145,6 @@ private function formatResults($order,$items,$folders,$communities,$users) return $resultsArray; }//formatResults - /** advanced search Action */ - public function advancedAction() - { - $this->_helper->layout->disableLayout(); - }//advancedAction /** search live Action */ public function liveAction() diff --git a/core/controllers/UserController.php b/core/controllers/UserController.php index 5e9ec0368..067e10c71 100644 --- a/core/controllers/UserController.php +++ b/core/controllers/UserController.php @@ -8,7 +8,7 @@ class UserController extends AppController public $_daos=array( 'User','Folder','Folderpolicygroup','Folderpolicyuser','Group' ); - public $_components=array('Date','Filter'); + public $_components=array('Date','Filter','Sortdao'); public $_forms=array( 'User' ); @@ -178,7 +178,7 @@ public function settingsAction() $this->_helper->layout->disableLayout(); $userId=$this->_getParam('userId'); - if(isset($userId)&&!$this->userSession->Dao->isAdmin()) + if(isset($userId)&&$userId!=$this->userSession->Dao->getKey()&&!$this->userSession->Dao->isAdmin()) { throw new Zend_Exception('You should be an admin'); } @@ -296,6 +296,23 @@ public function settingsAction() } } + $communities=array(); + $groups=$userDao->getGroups(); + foreach($groups as $group) + { + $community=$group->getCommunity(); + if(!isset($communities[$community->getKey()])) + { + $community->groups=array(); + $communities[$community->getKey()]=$community; + } + $communities[$community->getKey()]->groups[]=$group; + } + $this->Component->Sortdao->field='name'; + $this->Component->Sortdao->order='asc'; + usort($communities, array($this->Component->Sortdao,'sortByName')); + + $this->view->communities=$communities; $this->view->user=$userDao; $this->view->thumbnail=$userDao->getThumbnail(); $this->view->jsonSettings=array(); @@ -325,6 +342,10 @@ public function userpageAction() else { $userDao=$this->User->load($user_id); + if($userDao->getPrivacy()==MIDAS_USER_PRIVATE&&(!isset($this->userSession->Dao)||!$this->userSession->Dao->isAdmin())) + { + throw new Zend_Exception("Permission error"); + } } if(!$userDao instanceof UserDao) diff --git a/core/controllers/components/NotifyErrorComponent.php b/core/controllers/components/NotifyErrorComponent.php index 3cc454324..bf1fbebc0 100644 --- a/core/controllers/components/NotifyErrorComponent.php +++ b/core/controllers/components/NotifyErrorComponent.php @@ -33,15 +33,6 @@ public function fatalEror($logger,$mailer) if(!is_null($e = error_get_last())) { $environment = Zend_Registry::get('configGlobal')->environment; - $db = Zend_Registry::get('dbAdapter'); - if(method_exists($db,"getProfiler")) - { - $profiler = $db->getProfiler(); - } - else - { - $profiler = new Zend_Db_Profiler(); - } switch ($environment) { case 'production': @@ -68,9 +59,9 @@ public function fatalEror($logger,$mailer) header('content-type: text/plain'); echo $this->getFatalErrorMessage($e); } - $logger->crit($this->getFatalErrorMessage($e)); - } - $logger->__destruct(); + $logger->crit($this->getFatalErrorMessage($e)); + $logger->__destruct(); + } } public function warningError($errno, $errstr, $errfile, $errline) @@ -91,7 +82,7 @@ public function warningError($errno, $errstr, $errfile, $errline) } - private function curPageURL() + public function curPageURL() { $pageURL = 'http'; if (isset($_SERVER["HTTPS"] )&&$_SERVER["HTTPS"] == "on") {$pageURL .= "s";} diff --git a/core/controllers/forms/UserForm.php b/core/controllers/forms/UserForm.php index 71db35a32..c5ec860ec 100644 --- a/core/controllers/forms/UserForm.php +++ b/core/controllers/forms/UserForm.php @@ -113,8 +113,8 @@ public function createAccountForm($firstname_value=null,$lastname_value=null,$co $privacy = new Zend_Form_Element_Radio('privacy'); $privacy->addMultiOptions( array( - MIDAS_USER_PUBLIC => $this->t("Public"), - MIDAS_USER_PRIVATE => $this->t("Private"), + MIDAS_USER_PUBLIC => $this->t("Public (Everyone can access to my information)"), + MIDAS_USER_PRIVATE => $this->t("Private (Nobody can access to my page)"), )) ->setRequired(true) ->setValue(MIDAS_COMMUNITY_PUBLIC); diff --git a/core/layouts/layout.phtml b/core/layouts/layout.phtml index 1e1505e91..70e6840c7 100644 --- a/core/layouts/layout.phtml +++ b/core/layouts/layout.phtml @@ -74,7 +74,7 @@ diff --git a/core/views/element/feed.phtml b/core/views/element/feed.phtml index ccffac606..0806f541a 100644 --- a/core/views/element/feed.phtml +++ b/core/views/element/feed.phtml @@ -41,7 +41,7 @@ } echo ""; echo "
"; - echo "{$feed->getUser()->getFullName()} "; + echo $view->linkuser($feed->getUser()).' '; switch($type) { case MIDAS_FEED_CREATE_COMMUNITY: diff --git a/core/views/helpers/Linkuser.php b/core/views/helpers/Linkuser.php new file mode 100644 index 000000000..0b46c3368 --- /dev/null +++ b/core/views/helpers/Linkuser.php @@ -0,0 +1,21 @@ +getPrivacy()==MIDAS_USER_PUBLIC||isset($this->view->userDao)&&$this->view->userDao->isAdmin()||isset($this->view->userDao)&&$userDao->getKey()==$this->view->userDao->getKey()) + { + return "{$userDao->getFullName()}"; + } + return "{$userDao->getFullName()}"; + }//en method t + + + + /** Set view*/ + public function setView(Zend_View_Interface $view) + { + $this->view = $view; + } +}// end class \ No newline at end of file diff --git a/core/views/item/view.phtml b/core/views/item/view.phtml index 8ff6bbc47..7af5817d0 100644 --- a/core/views/item/view.phtml +++ b/core/views/item/view.phtml @@ -31,7 +31,7 @@ $this->headScript()->appendFile($this->coreWebroot . '/public/js/item/item.view. { echo ""; echo " Revision {$revision->getRevision()}"; - echo " {$this->Date->ago($revision->getDate(),false)} {$this->t('by')} {$revision->getUser()->getFullName()}"; + echo " {$this->Date->ago($revision->getDate(),false)} {$this->t('by')} {$this->linkuser($revision->getUser())} "; echo " {$revision->getChanges()}"; echo ""; $node++; @@ -80,7 +80,7 @@ $this->headScript()->appendFile($this->coreWebroot . '/public/js/item/item.view. t('Uploaded by');?> - itemDao->lastrevision->getUser()->getFullName()?> + linkuser($this->itemDao->lastrevision->getUser())?> Revision diff --git a/core/views/search/advanced.phtml b/core/views/search/advanced.phtml deleted file mode 100644 index c34bb22bf..000000000 --- a/core/views/search/advanced.phtml +++ /dev/null @@ -1,8 +0,0 @@ -coreWebroot . '/public/js/search/search.advanced.js?'.time().'">'; -?> - - -TODO - diff --git a/core/views/user/settings.phtml b/core/views/user/settings.phtml index 127b26579..d3bbb7582 100644 --- a/core/views/user/settings.phtml +++ b/core/views/user/settings.phtml @@ -7,29 +7,39 @@ echo '