cleanup of the dashboard log reader and fix for 497165
authorToby Elliott <telliott@mozilla.com>
Tue, 09 Jun 2009 13:42:29 -0700
changeset 1013 3afd6b26f66d57793f04076b3b648710560b0dc9
parent 1012 ac1bdc8a0c27518bead865dc50915f78ea0a06ff
child 1014 9d0ca5e5ef76036e12df7ad4b12f34686e95041c
push id641
push usertelliott@mozilla.com
push dateTue, 09 Jun 2009 20:42:32 +0000
bugs497165
cleanup of the dashboard log reader and fix for 497165
server/admin/dashboard.php
server/lib/storage.php
server/personadetail.php
server/profile.php
--- a/server/admin/dashboard.php
+++ b/server/admin/dashboard.php
@@ -59,22 +59,17 @@
 		}
 
 		$db = new PersonaStorage();
 
 		$pending = count($db->get_pending_personas());
 		$edits = count($db->get_pending_edits());
 		$total = $db->get_active_persona_count();
 		
-		$logs = $db->get_logs(5);
-        $length = count($logs);
-        
-        for($i=0; $i<$length;$i++) {
-            $logs[$i]['persona'] = $db->get_persona_by_id($logs[$i]['id']);
-        }
+		$logs = $db->get_detailed_admin_logs(5);
 	}
 	catch(Exception $e)
 	{
 		error_log($e->getMessage());
 		print("Database problem. Please try again later.");
 		exit;
 	}
 
@@ -93,18 +88,20 @@
         <p><strong>Total Active Personas:</strong> <?= $total ?></p>
         <p><strong>New Pending Personas:</strong> <a href="pending.php" target="_blank"><?= $pending ?></a></p>
         <p><strong>Personas Awaiting Edit Approval:</strong> <a href="editing.php" target="_blank"><?= $edits ?></a></p>
     </div>
     
     <div id="log">
         <h3>Recent admin activity</h3>
         <ul>
-            <?php foreach($logs as $log): ?>
-                <li><a href="dashboard.php?username=<?=$log['username']; ?>"><?= $log['username'] ?></a> <?=$log['action'];?> <a href="/persona/<?=$log['persona']['id'];?>"><?=$log['persona']['name']?></a></li>
+            <?php foreach($logs as $log): 
+            	$log_url = substr($log['action'], 0, 8) == 'Rejected' ? ('/admin/pending.php?id=' .  $log['id']) :  ('/persona/' . $log['id']);
+            ?>
+                <li>(<a href="dashboard.php?username=<?=$log['username']; ?>"><?= $log['username'] ?></a>) <a href="<?= $log_url ?>"><?= $log['name'] ?></a>: <?=$log['action'];?> </li>
             <?php endforeach; ?>
         </ul>
     </div>
 </div>
 
 <p>
 
 <p><hr><p>
--- a/server/lib/storage.php
+++ b/server/lib/storage.php
@@ -945,24 +945,24 @@ class PersonaStorage
 		{
 			$logs[] = $result;
 		}		
 
 		return $logs;
 	
 	}
     
-    function get_logs($limit = null) {
+    function get_detailed_admin_logs($limit = 100) {
         if (!$this->_dbh)
 			$this->db_connect();		
 
         $limit = (int)$limit;
 		try
 		{
-			$statement = 'select * from log order by date DESC'.($limit ? " limit $limit" : "");
+			$statement = "select * from log, personas where log.id = personas.id and action != 'Added' order by date DESC limit $limit";
 			$sth = $this->_dbh->prepare($statement);
 			$sth->execute();
 		}
 		catch( PDOException $exception )
 		{
 			error_log($exception->getMessage());
 			throw new Exception("Database unavailable", 503);
 		}
--- a/server/personadetail.php
+++ b/server/personadetail.php
@@ -60,17 +60,17 @@
 	{
 		$persona_id = intval($persona_id);
 		$persona = $db->get_persona_by_id($persona_id);
 		$page_header = $persona['name'] . ' by ' . $persona['author'];
 		$category = $persona['category'];
 		$persona['json'] = htmlentities(json_encode(extract_record_data($persona)));
 	}
 
-	$favorite_persona = $username ? $db->is_favorite_persona($username, $persona_id) : null;
+	$favorite_persona = null; #$username ? $db->is_favorite_persona($username, $persona_id) : null;
 	$url_prefix = '/gallery';
 	$tabs = null;
 	
 	$title = $persona['name']; 
 	include 'templates/header.php'; 
 ?>
 <body>
     <div id="outer-wrapper">
--- a/server/profile.php
+++ b/server/profile.php
@@ -58,17 +58,17 @@
     <div id="outer-wrapper">
         <div id="inner-wrapper">
 <?php include 'templates/nav.php'; ?>
             <div id="header">
                 <h2>Change User Details</h2>
             </div>
             <div id="maincontent">
                 <div id="breadcrumbs">
-                    Personas Home : User Details  
+                    <a href="http://www.getpersonas.com">Personas Home</a> : User Details  
                 </div>
 <?php 
 		if ($updated)
 		{
 ?>
                 <div id="signup">
                     <h4>Change User Details</h3>
                 	You have successfully updated your user profile. Thanks for keeping us up to date!