diff options
| author | 2014-10-16 17:08:48 +0200 | |
|---|---|---|
| committer | 2014-10-17 16:24:21 +0200 | |
| commit | d4ad951b9b686f387056bda8f3fa6ede8d9ca3f1 (patch) | |
| tree | 1079163173ae8b0870d13386e605e9ef51ac72b1 /app | |
| parent | 2796cc9ae559842a90fa15cba65c94a11b29195e (diff) | |
Show more information about user when selected
Diffstat (limited to 'app')
| -rw-r--r-- | app/Controllers/userController.php | 19 | ||||
| -rw-r--r-- | app/Models/Factory.php | 18 | ||||
| -rw-r--r-- | app/Models/UserDAO.php | 4 | ||||
| -rw-r--r-- | app/views/configure/archiving.phtml | 2 | ||||
| -rw-r--r-- | app/views/user/manage.phtml | 2 |
5 files changed, 32 insertions, 13 deletions
diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php index 00b51cc3d..4a04737f2 100644 --- a/app/Controllers/userController.php +++ b/app/Controllers/userController.php @@ -87,11 +87,24 @@ class FreshRSS_user_Controller extends Minz_ActionController { * This action displays the user management page. */ public function manageAction() { + if (!FreshRSS_Auth::hasAccess('admin')) { + Minz_Error::error(403, + array('error' => array(_t('access_denied')))); + } + Minz_View::prependTitle(_t('users.manage') . ' · '); - $this->view->current_user = Minz_Request::param( - 'u', Minz_Session::param('currentUser', '_') - ); + $userDAO = new FreshRSS_UserDAO(); + + $username = Minz_Request::param('u', Minz_Session::param('currentUser')); + if (!$userDAO->exist($username)) { + $username = Minz_Session::param('currentUser'); + } + $this->view->current_user = $username; + + $entryDAO = FreshRSS_Factory::createEntryDao($this->view->current_user); + $this->view->nb_articles = $entryDAO->count(); + $this->view->size_user = $entryDAO->size(); } public function createAction() { diff --git a/app/Models/Factory.php b/app/Models/Factory.php index 08569b2e2..93f4552f7 100644 --- a/app/Models/Factory.php +++ b/app/Models/Factory.php @@ -2,30 +2,30 @@ class FreshRSS_Factory { - public static function createFeedDao() { + public static function createFeedDao($username = null) { $db = Minz_Configuration::dataBase(); if ($db['type'] === 'sqlite') { - return new FreshRSS_FeedDAOSQLite(); + return new FreshRSS_FeedDAOSQLite($username); } else { - return new FreshRSS_FeedDAO(); + return new FreshRSS_FeedDAO($username); } } - public static function createEntryDao() { + public static function createEntryDao($username = null) { $db = Minz_Configuration::dataBase(); if ($db['type'] === 'sqlite') { - return new FreshRSS_EntryDAOSQLite(); + return new FreshRSS_EntryDAOSQLite($username); } else { - return new FreshRSS_EntryDAO(); + return new FreshRSS_EntryDAO($username); } } - public static function createStatsDAO() { + public static function createStatsDAO($username = null) { $db = Minz_Configuration::dataBase(); if ($db['type'] === 'sqlite') { - return new FreshRSS_StatsDAOSQLite(); + return new FreshRSS_StatsDAOSQLite($username); } else { - return new FreshRSS_StatsDAO(); + return new FreshRSS_StatsDAO($username); } } diff --git a/app/Models/UserDAO.php b/app/Models/UserDAO.php index 15215258c..85b45c4a7 100644 --- a/app/Models/UserDAO.php +++ b/app/Models/UserDAO.php @@ -53,4 +53,8 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { } } } + + public function exist($username) { + return file_exists(DATA_PATH . '/' . $username . '_user.php'); + } } diff --git a/app/views/configure/archiving.phtml b/app/views/configure/archiving.phtml index adbfdb77e..8f424c126 100644 --- a/app/views/configure/archiving.phtml +++ b/app/views/configure/archiving.phtml @@ -60,7 +60,7 @@ <div class="form-group"> <p class="group-name"><?php echo _t('current_user'); ?></p> <div class="group-controls"> - <p><?php echo formatNumber($this->nb_total), ' ', _t('articles'), ', ', formatBytes($this->size_user); ?></p> + <p><?php echo _t('articles', formatNumber($this->nb_total)), ' — ', formatBytes($this->size_user); ?></p> <input type="hidden" name="optimiseDatabase" value="1" /> <button type="submit" class="btn btn-important"><?php echo _t('optimize_bdd'); ?></button> <?php echo _i('help'); ?> <?php echo _t('optimize_todo_sometimes'); ?> diff --git a/app/views/user/manage.phtml b/app/views/user/manage.phtml index fb569872b..65e60add5 100644 --- a/app/views/user/manage.phtml +++ b/app/views/user/manage.phtml @@ -63,6 +63,8 @@ <option data-url="<?php echo _url('user', 'manage', 'u', $username); ?>" <?php echo $this->current_user === $username ? 'selected="selected"' : ''; ?> value="<?php echo $username; ?>"><?php echo $username; ?></option> <?php } ?> </select> + + <p><?php echo _t('articles', formatNumber($this->nb_articles)), ', ', formatBytes($this->size_user); ?></p> </div> </div> |
