1<?php 2 3/* 4 Phoronix Test Suite 5 URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/ 6 Copyright (C) 2014 - 2015, Phoronix Media 7 Copyright (C) 2014 - 2015, Michael Larabel 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 3 of the License, or 12 (at your option) any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program. If not, see <http://www.gnu.org/licenses/>. 21*/ 22 23 24class phoromatic_account_activity implements pts_webui_interface 25{ 26 public static function page_title() 27 { 28 return 'Account Activity'; 29 } 30 public static function page_header() 31 { 32 return null; 33 } 34 public static function preload($PAGE) 35 { 36 return true; 37 } 38 public static function render_page_process($PATH) 39 { 40 41 $main = '<h1>Recent Account Activity</h1>'; 42 43 $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_activity_stream WHERE AccountID = :account_id ORDER BY ActivityTime DESC'); 44 $stmt->bindValue(':account_id', $_SESSION['AccountID']); 45 $result = $stmt->execute(); 46 $row = $result->fetchArray(); 47 $prev_date = null; 48 49 if(empty($row)) 50 { 51 $main .= '<p>No activity found.</p>'; 52 } 53 54 do 55 { 56 if($prev_date != substr($row['ActivityTime'], 0, 10)) 57 { 58 if($prev_date != null) 59 $main .= '</p><hr />'; 60 61 $prev_date = substr($row['ActivityTime'], 0, 10); 62 $new_date = strtotime($row['ActivityTime']); 63 64 if(date('Y-m-d') == $prev_date) 65 { 66 $main .= '<h2>Today</h2>'; 67 } 68 else if($new_date > (time() - (60 * 60 * 24 * 6))) 69 { 70 $main .= '<h2>' . date('l', $new_date) . '</h2>'; 71 } 72 else 73 { 74 $main .= '<h2>' . date('j F Y', $new_date) . '</h2>'; 75 } 76 $main .= '<p>'; 77 } 78 79 $id_link_format = $row['ActivityEventID']; 80 switch($row['ActivityEvent']) 81 { 82 case 'settings': 83 $event_link_format = '<a href="?settings">settings</a>'; 84 break; 85 case 'users': 86 $event_link_format = '<a href="?users">a user</a>'; 87 break; 88 case 'schedule': 89 $event_link_format = '<a href="?schedules">schedule</a>'; 90 91 $stmt1 = phoromatic_server::$db->prepare('SELECT Title FROM phoromatic_schedules WHERE AccountID = :account_id AND ScheduleID = :schedule_id'); 92 $stmt1->bindValue(':account_id', $_SESSION['AccountID']); 93 $stmt1->bindValue(':schedule_id', $row['ActivityEventID']); 94 $result1 = $stmt1->execute(); 95 $row1 = $result1->fetchArray(); 96 $id_link_format = '<a href="?schedules/' . $row['ActivityEventID'] . '">' . $row1['Title'] . '</a>'; 97 break; 98 case 'tests_for_schedule': 99 $event_link_format = 'a test for a schedule'; 100 101 $stmt1 = phoromatic_server::$db->prepare('SELECT Title FROM phoromatic_schedules WHERE AccountID = :account_id AND ScheduleID = :schedule_id'); 102 $stmt1->bindValue(':account_id', $_SESSION['AccountID']); 103 $stmt1->bindValue(':schedule_id', $row['ActivityEventID']); 104 $result1 = $stmt1->execute(); 105 $row1 = $result1->fetchArray(); 106 $id_link_format = '<a href="?schedules/' . $row['ActivityEventID'] . '">' . $row1['Title'] . '</a>'; 107 break; 108 case 'groups': 109 $event_link_format = '<a href="?systems#group_edit">a group</a>'; 110 break; 111 default: 112 $event_link_format = $row['ActivityEvent']; 113 break; 114 } 115 116 if($row['ActivityCreatorType'] == 'USER') 117 { 118 $main .= '<em>' . date('H:i', strtotime($row['ActivityTime'])) . '</em> <strong>' . $row['ActivityCreator'] . '</strong> <strong> ' . $row['ActivityEventType'] . '</strong> <strong>' . $event_link_format . '</strong>'; 119 120 if($id_link_format != null) 121 $main .= ': ' . $id_link_format; 122 123 $main .= '<br />' . PHP_EOL; 124 125 } 126 127 //$main .= '<p>' . $row['ActivityCreator'] . ' ' . $row['ActivityCreatorType'] . ' ' . $row['ActivityEvent'] . ' ' . $row['ActivityEventID'] . ' ' . $row['ActivityEventType'] . '</p>'; 128 } 129 while($row = $result->fetchArray()); 130 131 if($prev_date != null) 132 $main .= '</p>'; 133 134 echo phoromatic_webui_header_logged_in(); 135 echo phoromatic_webui_main($main); 136 echo phoromatic_webui_footer(); 137 } 138} 139 140?> 141