Browse Source

Show more information about user when selected

Marien Fressinaud 11 years ago
parent
commit
d4ad951b9b

+ 16 - 3
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() {

+ 9 - 9
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);
 		}
 	}
 

+ 4 - 0
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');
+	}
 }

+ 1 - 1
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'); ?>

+ 2 - 0
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>