From 5d447bd84513c77ba30838674be212088838a33c Mon Sep 17 00:00:00 2001
From: Leslie Michael Orchard
Date: Thu, 15 Jul 2010 13:47:13 -0400
Subject: [PATCH] bug 553678: First stab at recording an activity log for
plugin actions
---
application/controllers/index.php | 5 +
application/controllers/local.php | 5 +
application/controllers/plugins.php | 129 ++++++++++-
.../locale/en_US/LC_MESSAGES/messages.po | 204 ++++++++++--------
application/locale/keys.pot | 186 ++++++++--------
application/models/auditlogevent.php | 117 ++++++++++
application/models/plugin.php | 6 +-
application/views/index/index_shell.html | 15 ++
application/views/macros/auditlogevents.html | 50 +++++
application/views/plugins/activitylog.html | 36 ++++
application/views/plugins/detail.html | 17 ++
application/views/plugins/edit.html | 6 +-
htdocs/css/main.css | 44 +++-
13 files changed, 636 insertions(+), 184 deletions(-)
create mode 100644 application/models/auditlogevent.php
create mode 100644 application/views/macros/auditlogevents.html
create mode 100644 application/views/plugins/activitylog.html
diff --git a/application/controllers/index.php b/application/controllers/index.php
index 07bfd6e..c07b6c3 100644
--- a/application/controllers/index.php
+++ b/application/controllers/index.php
@@ -38,6 +38,11 @@ function index($by_cat=null)
break;
}
+ $this->view->events = ORM::factory('auditLogEvent')
+ ->orderby(array('created'=>'DESC'))
+ ->limit(15)
+ ->find_all_for_view();
+
$this->view->by_cat = $by_cat;
$this->view->set_filename('index/index_by' . $this->view->by_cat);
}
diff --git a/application/controllers/local.php b/application/controllers/local.php
index b33b709..eda2604 100644
--- a/application/controllers/local.php
+++ b/application/controllers/local.php
@@ -15,6 +15,11 @@ public function __construct()
{
parent::__construct();
+ if (authprofiles::is_logged_in()) {
+ AuditLogEvent_Model::$current_profile =
+ authprofiles::get_profile();
+ }
+
Event::add('system.403', array($this, 'show_forbidden'));
Event::add('system.forbidden', array($this, 'show_forbidden'));
}
diff --git a/application/controllers/plugins.php b/application/controllers/plugins.php
index d4ac636..46c6911 100644
--- a/application/controllers/plugins.php
+++ b/application/controllers/plugins.php
@@ -19,7 +19,8 @@ public function __construct()
/**
* Produce a JSON index of all plugins with release counts.
*/
- function index_json(){
+ function index_json()
+ {
$this->auto_render = FALSE;
$name_counts = ORM::factory('plugin')->find_release_counts();
$out = array();
@@ -118,6 +119,13 @@ function create($screen_name=null)
// Create a new plugin from the export.
$new_plugin = ORM::factory('plugin')->import($import);
+ // Log the plugin creation
+ ORM::factory('auditLogEvent')->set(array(
+ 'action' => 'created',
+ 'plugin_id' => $new_plugin->id,
+ 'new_state' => $import,
+ ))->save();
+
// Bounce over to the created plugin
if ($new_plugin->sandbox_profile_id) {
url::redirect(
@@ -172,11 +180,61 @@ function sandbox($screen_name, $format='html') {
if ($screen_name == authprofiles::get_profile('screen_name')) {
// HACK: Since this is using the index page shell, inform it which tab
// to select. This should probably be done all in the view.
+ $this->view->events = ORM::factory('auditLogEvent')
+ ->orderby(array('created'=>'DESC'))
+ ->where('profile_id', $profile->id)
+ ->limit(15)
+ ->find_all_for_view();
$this->view->by_cat = 'sandbox';
$this->view->set_filename('plugins/sandbox_mine');
}
}
+ /**
+ * Display the activity log for a plugin
+ */
+ function activitylog($pfs_id=null, $screen_name=null)
+ {
+ if (null == $pfs_id) {
+ $plugin = null;
+ } else {
+ list($plugin, $plugin_profile) =
+ $this->_find_plugin($pfs_id, $screen_name);
+ if (!authprofiles::is_allowed($plugin, 'view'))
+ return Event::run('system.forbidden');
+ }
+
+ $per_page = $this->input->get('limit', 25);
+ $curr_page = $this->input->get('page', 1);
+
+ if (null == $plugin) {
+ $total_items = ORM::factory('auditLogEvent')->count_all();
+ } else {
+ $total_items = ORM::factory('auditLogEvent')
+ ->where('plugin_id', $plugin->id)->count_all();
+ }
+
+ $pagination = new Pagination(array(
+ 'base_url' => url::current(),
+ 'total_items' => $total_items,
+ 'items_per_page' => $per_page,
+ 'query_string' => 'page'
+ ));
+
+ $events = ORM::factory('auditLogEvent')
+ ->orderby(array('created'=>'DESC'));
+ if ($plugin)
+ $events->where('plugin_id', $plugin->id);
+ $events->limit($pagination->items_per_page, $pagination->sql_offset);
+
+ $this->view->set(array(
+ 'screenname' => $screen_name,
+ 'plugin' => $plugin,
+ 'pagination' => $pagination,
+ 'events' => $events->find_all_for_view()
+ ));
+ }
+
/**
* Display plugin details, accept POST updates.
*/
@@ -221,7 +279,18 @@ function detail($pfs_id, $format='html', $screen_name=null)
}
}
- $plugin = ORM::factory('plugin')->import($data);
+ $old_state = $plugin->export();
+
+ $updated_plugin = ORM::factory('plugin')->import($data);
+
+ // Log the plugin modification
+ ORM::factory('auditLogEvent')->set(array(
+ 'action' => 'modified',
+ 'plugin_id' => $plugin->id,
+ 'old_state' => $old_state,
+ 'new_state' => $data,
+ ))->save();
+
}
// Return the plugin data as an export in JSON
@@ -241,6 +310,12 @@ function detail($pfs_id, $format='html', $screen_name=null)
// Do a rough version sort.
uksort($releases, array($this, '_versionCmp'));
+
+ $this->view->events = ORM::factory('auditLogEvent')
+ ->orderby(array('created'=>'DESC'))
+ ->where('plugin_id', $plugin->id)
+ ->limit(15)
+ ->find_all_for_view();
$this->view->releases = $releases;
}
@@ -272,6 +347,15 @@ function copy($pfs_id, $screen_name=null)
// Create a new plugin from the export.
$new_plugin = ORM::factory('plugin')->import($export);
+ // Log the sandbox copy.
+ ORM::factory('auditLogEvent')->set(array(
+ 'action' => 'copied_to_sandbox',
+ 'plugin_id' => $plugin->id,
+ 'details' => array(
+ 'sandbox_profile' => authprofiles::get_profile()->as_array()
+ ),
+ ))->save();
+
$auth_screen_name = authprofiles::get_profile('screen_name');
if (empty($_GET)) {
// Bounce over to sandbox.
@@ -311,6 +395,20 @@ function deploy($pfs_id, $screen_name=null) {
// Import the export to finish deployment.
$new_plugin = ORM::factory('plugin')->import($export);
+ ORM::factory('auditLogEvent')->set(array(
+ 'action' => 'deployed_from_sandbox',
+ 'plugin_id' => $plugin->id,
+ ))->save();
+
+ ORM::factory('auditLogEvent')->set(array(
+ 'action' => 'deployed_from_sandbox',
+ 'plugin_id' => $new_plugin->id,
+ 'details' => array(
+ 'sandbox_profile'=>$plugin_profile->as_array()
+ ),
+ 'new_state' => $new_plugin->export(),
+ ))->save();
+
// Bounce over to the deployed plugin
url::redirect("plugins/detail/{$new_plugin->pfs_id}");
@@ -329,6 +427,12 @@ function delete($pfs_id, $screen_name=null)
// Only perform the delete on POST.
if ('post' == request::method()) {
+ ORM::factory('auditLogEvent')->set(array(
+ 'action' => 'deleted',
+ 'plugin_id' => $plugin->id,
+ 'old_state' => $plugin->export(),
+ ))->save();
+
$plugin->delete();
// Bounce over to sandbox.
@@ -385,6 +489,11 @@ function requestpush($pfs_id, $screen_name=null)
Session::instance()
->set_flash('message', 'Approval requested');
+ ORM::factory('auditLogEvent')->set(array(
+ 'action' => 'requested_push',
+ 'plugin_id' => $plugin->id,
+ ))->save();
+
// Bounce over to sandbox.
$auth_screen_name = authprofiles::get_profile('screen_name');
url::redirect(
@@ -406,6 +515,14 @@ function addtrusted($pfs_id, $screen_name)
if ('post' == request::method()) {
$plugin->add_trusted($plugin_profile);
+ ORM::factory('auditLogEvent')->set(array(
+ 'action' => 'add_trusted',
+ 'details' => array(
+ 'profile' => $plugin_profile->as_array()
+ ),
+ 'plugin_id' => $plugin->id,
+ ))->save();
+
// Bounce over to sandbox.
$auth_screen_name = authprofiles::get_profile('screen_name');
url::redirect(
@@ -427,6 +544,14 @@ function removetrusted($pfs_id, $screen_name)
if ('post' == request::method()) {
$plugin->remove_trusted($plugin_profile);
+ ORM::factory('auditLogEvent')->set(array(
+ 'action' => 'remove_trusted',
+ 'details' => array(
+ 'profile' => $plugin_profile->as_array()
+ ),
+ 'plugin_id' => $plugin->id,
+ ))->save();
+
// Bounce over to sandbox.
$auth_screen_name = authprofiles::get_profile('screen_name');
url::redirect(
diff --git a/application/locale/en_US/LC_MESSAGES/messages.po b/application/locale/en_US/LC_MESSAGES/messages.po
index d2f5304..639cd41 100644
--- a/application/locale/en_US/LC_MESSAGES/messages.po
+++ b/application/locale/en_US/LC_MESSAGES/messages.po
@@ -42,7 +42,7 @@ msgstr " Use this form to provide details to create a new pl
" modify these values.\n"
" "
-#: views/index/index_shell.html:67
+#: views/index/index_shell.html:75
msgid " If you want to get involved, you can sign up for a\n"
" profile. This will give you access to a sandbox in which to \n"
" edit plugin records, test them against our detection code in \n"
@@ -56,7 +56,7 @@ msgstr " If you want to get involved, you can sign up for a\n"
" approval and inclusion in the database.\n"
" "
-#: views/index/index_shell.html:60
+#: views/index/index_shell.html:68
msgid " This site is an attempt to collect and provide information about\n"
" third-party browser plugins installed by people across the web. \n"
" "
@@ -124,20 +124,20 @@ msgstr " The following is a list of plugins detected as installed\n"
#. i18n: %1$s = plugin_name_e
#. i18n: %2$s = screen_name_e
-#: views/plugins/detail.html:55
+#: views/plugins/detail.html:63
#, php-format
msgid "%1$s (%2$s sandbox)"
msgstr "%1$s (%2$s sandbox)"
-#: models/plugin.php:1078
+#: models/plugin.php:1103
msgid "(0/1) whether or not the OS needs to restart after plugin installation"
msgstr "(0/1) whether or not the OS needs to restart after plugin installation"
-#: models/plugin.php:1074
+#: models/plugin.php:1099
msgid "(0/1) whether or not the installer displays a user interface"
msgstr "(0/1) whether or not the installer displays a user interface"
-#: models/plugin.php:1082 models/plugin.php:1086 models/plugin.php:1090
+#: models/plugin.php:1107 models/plugin.php:1111 models/plugin.php:1115
msgid "(Not sure, inherited from PFS1, need a description)"
msgstr "(Not sure, inherited from PFS1, need a description)"
@@ -149,15 +149,15 @@ msgstr "+ Create new sandbox plugin"
msgid "### available"
msgstr "### available"
-#: models/plugin.php:1030
+#: models/plugin.php:1055
msgid "A GUID for the plugin release, may differ between releases and platforms (unlike pfs_id)"
msgstr "A GUID for the plugin release, may differ between releases and platforms (unlike pfs_id)"
-#: models/plugin.php:1010
+#: models/plugin.php:1035
msgid "A dot-separated normalized version for the plugin, may differ from official vendor versioning scheme in order to maintain internal consistency in PFS2"
msgstr "A dot-separated normalized version for the plugin, may differ from official vendor versioning scheme in order to maintain internal consistency in PFS2"
-#: models/plugin.php:1070
+#: models/plugin.php:1095
msgid "A hash of the installer contents for verifying its integrity"
msgstr "A hash of the installer contents for verifying its integrity"
@@ -181,8 +181,25 @@ msgstr "Access denied"
msgid "Account activation email sent."
msgstr "Account activation email sent."
+#: views/plugins/activitylog.html:66
+msgid "Activity log"
+msgstr "Activity log"
+
+#. i18n: %1$s = plugin_name_e
+#: views/plugins/activitylog.html:55
+#, php-format
+msgid "Activity log for %1$s"
+msgstr "Activity log for %1$s"
+
+#. i18n: %1$s = plugin_name_e
+#. i18n: %2$s = screen_name_e
+#: views/plugins/activitylog.html:46
+#, php-format
+msgid "Activity log for %1$s (%2$s sandbox)"
+msgstr "Activity log for %1$s (%2$s sandbox)"
+
#. i18n: %1$s = screen_name_e
-#: views/plugins/detail.html:152
+#: views/plugins/detail.html:160
#, php-format
msgid "Add %1$s as trusted"
msgstr "Add %1$s as trusted"
@@ -203,7 +220,7 @@ msgstr "Also submitting the following additional information:"
msgid "Any"
msgstr "Any"
-#: models/plugin.php:1094
+#: models/plugin.php:1119
msgid "Application ID for client app"
msgstr "Application ID for client app"
@@ -219,19 +236,19 @@ msgstr "Basics"
msgid "Bio / About you"
msgstr "Bio / About you"
-#: views/index/index_shell.html:101
+#: views/index/index_shell.html:156
msgid "By Application"
msgstr "By Application"
-#: views/index/index_shell.html:109
+#: views/index/index_shell.html:164
msgid "By MIME Type"
msgstr "By MIME Type"
-#: views/index/index_shell.html:97
+#: views/index/index_shell.html:152
msgid "By Name"
msgstr "By Name"
-#: views/index/index_shell.html:105
+#: views/index/index_shell.html:160
msgid "By Operating System"
msgstr "By Operating System"
@@ -292,19 +309,19 @@ msgstr "Check your inbox for a link to verify this new email address."
msgid "Click here to try again."
msgstr "Click here to try again."
-#: models/plugin.php:1114
+#: models/plugin.php:1139
msgid "Client app OS for which the plugin is intended (* is wildcard)"
msgstr "Client app OS for which the plugin is intended (* is wildcard)"
-#: models/plugin.php:1109
+#: models/plugin.php:1134
msgid "Client app locale for which the plugin is intended (* is wildcard)"
msgstr "Client app locale for which the plugin is intended (* is wildcard)"
-#: models/plugin.php:1099
+#: models/plugin.php:1124
msgid "Client app release for which the plugin is intended (* is wildcard)"
msgstr "Client app release for which the plugin is intended (* is wildcard)"
-#: models/plugin.php:1104
+#: models/plugin.php:1129
msgid "Client app version for which the plugin is intended (* is wildcard)"
msgstr "Client app version for which the plugin is intended (* is wildcard)"
@@ -330,7 +347,7 @@ msgstr "Copy this plugin to your sandbox?"
msgid "Copy to Sandbox"
msgstr "Copy to Sandbox"
-#: views/plugins/detail.html:179
+#: views/plugins/detail.html:187
msgid "Copy to sandbox"
msgstr "Copy to sandbox"
@@ -358,7 +375,7 @@ msgstr "Create new sandbox plugin for %1$s"
msgid "Current JSON data"
msgstr "Current JSON data"
-#: models/plugin.php:1002
+#: models/plugin.php:1027
msgid "Current status of the release, eg. latest, outdated, vulnerable"
msgstr "Current status of the release, eg. latest, outdated, vulnerable"
@@ -366,7 +383,7 @@ msgstr "Current status of the release, eg. latest, outdated, vulnerable"
msgid "Date"
msgstr "Date"
-#: views/plugins/delete.html:43 views/plugins/detail.html:205
+#: views/plugins/delete.html:43 views/plugins/detail.html:213
msgid "Delete plugin"
msgstr "Delete plugin"
@@ -380,7 +397,7 @@ msgstr "Delete plugin \"%1$s\""
msgid "Delete this plugin?"
msgstr "Delete this plugin?"
-#: PluginDir/Editor.js:512
+#: PluginDir/Editor.js:522
msgid "Delete this release?"
msgstr "Delete this release?"
@@ -392,15 +409,15 @@ msgstr "Description"
msgid "Detected Version"
msgstr "Detected Version"
-#: models/plugin.php:1018
+#: models/plugin.php:1043
msgid "Detection scheme used in the client to derive the detected_version value"
msgstr "Detection scheme used in the client to derive the detected_version value"
-#: views/plugins/detail.html:346
+#: views/plugins/detail.html:409
msgid "Download / Details"
msgstr "Download / Details"
-#: views/plugins/detail.html:192
+#: views/plugins/detail.html:200
msgid "Edit details"
msgstr "Edit details"
@@ -438,7 +455,7 @@ msgstr "Email is required."
msgid "Feedback Actions"
msgstr "Feedback Actions"
-#: models/plugin.php:1042
+#: models/plugin.php:1067
msgid "Filename of the plugin as installed"
msgstr "Filename of the plugin as installed"
@@ -446,11 +463,11 @@ msgstr "Filename of the plugin as installed"
msgid "Firefox"
msgstr "Firefox"
-#: models/plugin.php:1038
+#: models/plugin.php:1063
msgid "For status vulnerable, a URL detailing security vulnerabilities for the plugin release"
msgstr "For status vulnerable, a URL detailing security vulnerabilities for the plugin release"
-#: models/plugin.php:1034
+#: models/plugin.php:1059
msgid "For status vulnerable, a short description of security vulnerabilities for the plugin release"
msgstr "For status vulnerable, a short description of security vulnerabilities for the plugin release"
@@ -474,7 +491,7 @@ msgstr "Full name is required"
msgid "Full name must contain only alphanumeric characters"
msgstr "Full name must contain only alphanumeric characters"
-#: views/index/index_shell.html:27
+#: views/index/index_shell.html:35
msgid "Home"
msgstr "Home"
@@ -498,16 +515,16 @@ msgstr "Invalid email verification token."
msgid "Invalid password reset attempt."
msgstr "Invalid password reset attempt."
-#: views/plugins/detail.html:218
+#: views/plugins/detail.html:226
msgid "JSON export"
msgstr "JSON export"
-#: PluginDir/Editor.js:194
+#: PluginDir/Editor.js:184
#, c-format
msgid "Last saved at %1$s"
msgstr "Last saved at %1$s"
-#: views/macros/statuses.html:33 views/plugins/edit.html:287 models/plugin.php:987
+#: views/macros/statuses.html:33 views/plugins/edit.html:287 models/plugin.php:1012
msgid "Latest"
msgstr "Latest"
@@ -519,23 +536,27 @@ msgstr "Linux"
msgid "Literal aliases"
msgstr "Literal aliases"
-#: PluginDir/Editor.js:251
+#: PluginDir/Editor.js:241
#, c-format
msgid "Loaded at %1$s"
msgstr "Loaded at %1$s"
+#: views/auth_profiles/login.html:27 views/auth_profiles/login.html:51 views/auth_profiles/login.html:117 views/layout.html:94
+msgid "Log in"
+msgstr "Log in"
+
+#: views/auth_profiles/logout.html:33
+msgid "Log in again?"
+msgstr "Log in again?"
+
+#: views/auth_profiles/logout.html:19 views/layout.html:83
+msgid "Log out"
+msgstr "Log out"
+
#: views/auth_profiles/logout.html:27
msgid "Logged out."
msgstr "Logged out."
-#: views/auth_profiles/login.html:27 views/auth_profiles/login.html:51 views/auth_profiles/login.html:117
-msgid "Login"
-msgstr "Login"
-
-#: views/auth_profiles/logout.html:33
-msgid "Login again?"
-msgstr "Login again?"
-
#: views/auth_profiles/register.html:46
msgid "Login details"
msgstr "Login details"
@@ -564,10 +585,6 @@ msgstr "Login name must contain only alphanumeric characters"
msgid "Login?"
msgstr "Login?"
-#: views/auth_profiles/logout.html:19
-msgid "Logout"
-msgstr "Logout"
-
#: views/plugins/edit.html:188
msgid "MIME types"
msgstr "MIME types"
@@ -603,7 +620,7 @@ msgstr "Mark as seen"
msgid "Mark as unseen"
msgstr "Mark as unseen"
-#: models/plugin.php:1022
+#: models/plugin.php:1047
msgid "More verbose description of the plugin"
msgstr "More verbose description of the plugin"
@@ -619,11 +636,11 @@ msgstr "Mozilla Plugin Directory"
msgid "Name"
msgstr "Name"
-#: models/plugin.php:1006
+#: models/plugin.php:1031
msgid "Name of the plugin"
msgstr "Name of the plugin"
-#: models/plugin.php:1026
+#: models/plugin.php:1051
msgid "Name of the vendor providing the plugin"
msgstr "Name of the vendor providing the plugin"
@@ -655,7 +672,7 @@ msgstr "New password confirmation required"
msgid "New password is required"
msgstr "New password is required"
-#: views/index/index_byinstalled.html:97 models/plugin.php:990
+#: views/index/index_byinstalled.html:97 models/plugin.php:1015
msgid "Newer than directory"
msgstr "Newer than directory"
@@ -667,7 +684,7 @@ msgstr "No search results, please change your search terms and try again."
msgid "No submissions."
msgstr "No submissions."
-#: views/plugins/detail.html:294 views/plugins/submissions.html:49 views/search/results.html:65
+#: views/plugins/detail.html:357 views/plugins/submissions.html:49 views/search/results.html:65
msgid "OS"
msgstr "OS"
@@ -687,7 +704,7 @@ msgstr "Old password is required"
msgid "Options"
msgstr "Options"
-#: views/macros/statuses.html:42 views/plugins/edit.html:291 models/plugin.php:988
+#: views/macros/statuses.html:42 views/plugins/edit.html:291 models/plugin.php:1013
msgid "Outdated"
msgstr "Outdated"
@@ -731,7 +748,7 @@ msgstr "Password must be 8 characters or greater in length, contain at least on
msgid "Password must be between 8 and 255 characters in length."
msgstr "Password must be between 8 and 255 characters in length."
-#: views/plugins/detail.html:290 views/plugins/submissions.html:53 views/search/results.html:61
+#: views/plugins/detail.html:353 views/plugins/submissions.html:53 views/search/results.html:61
msgid "Platform"
msgstr "Platform"
@@ -749,7 +766,7 @@ msgstr "Plugin Sandbox for %1$s"
msgid "Plugin details"
msgstr "Plugin details"
-#: views/plugins/detail.html:235
+#: views/plugins/detail.html:298
msgid "Plugin icon"
msgstr "Plugin icon"
@@ -769,7 +786,7 @@ msgstr "Profile settings for %3$s"
msgid "Push changes to this plugin live?"
msgstr "Push changes to this plugin live?"
-#: views/plugins/detail.html:109
+#: views/plugins/detail.html:117
msgid "Push live"
msgstr "Push live"
@@ -805,7 +822,7 @@ msgstr "Regex aliases"
msgid "Regexes matching names by which this plugin has been known"
msgstr "Regexes matching names by which this plugin has been known"
-#: views/auth_profiles/forgotpassword.html:27 views/auth_profiles/register.html:27 views/auth_profiles/register.html:82
+#: views/auth_profiles/forgotpassword.html:27 views/auth_profiles/register.html:27 views/auth_profiles/register.html:82 views/layout.html:100
msgid "Register"
msgstr "Register"
@@ -817,7 +834,7 @@ msgstr "Register (verified)"
msgid "Register (verify)"
msgstr "Register (verify)"
-#: views/plugins/edit.html:245 PluginDir/Editor.js:452
+#: views/plugins/edit.html:245 PluginDir/Editor.js:462
msgid "Release"
msgstr "Release"
@@ -826,7 +843,7 @@ msgid "Releases"
msgstr "Releases"
#. i18n: %1$s = screen_name_e
-#: views/plugins/detail.html:140
+#: views/plugins/detail.html:148
#, php-format
msgid "Remove %1$s as trusted"
msgstr "Remove %1$s as trusted"
@@ -842,7 +859,7 @@ msgstr "Remove %1$s as trusted for \"%2$s\""
msgid "Remove as trusted"
msgstr "Remove as trusted"
-#: views/plugins/detail.html:122 views/plugins/requestpush.html:38
+#: views/plugins/detail.html:130 views/plugins/requestpush.html:38
msgid "Request approval"
msgstr "Request approval"
@@ -868,7 +885,7 @@ msgstr "Role"
msgid "Sandbox Actions"
msgstr "Sandbox Actions"
-#: PluginDir/Editor.js:199
+#: PluginDir/Editor.js:189
#, c-format
msgid "Save failed at %1$s"
msgstr "Save failed at %1$s"
@@ -881,7 +898,7 @@ msgstr "Save now"
msgid "Saved JSON data"
msgstr "Saved JSON data"
-#: PluginDir/Editor.js:179
+#: PluginDir/Editor.js:169
#, c-format
msgid "Saving at %1$s"
msgstr "Saving at %1$s"
@@ -908,7 +925,7 @@ msgstr "Screen name must contain only alphanumeric characters"
msgid "Settings for %1$s"
msgstr "Settings for %1$s"
-#: models/plugin.php:992
+#: views/plugins/edit.html:299 models/plugin.php:1017
msgid "Should be disabled"
msgstr "Should be disabled"
@@ -916,7 +933,7 @@ msgstr "Should be disabled"
msgid "Sorry, that action is not allowed."
msgstr "Sorry, that action is not allowed."
-#: views/plugins/detail.html:298 views/plugins/submissions.html:45 views/plugins/submit.html:106 views/search/results.html:69
+#: views/plugins/detail.html:361 views/plugins/submissions.html:45 views/plugins/submit.html:106 views/search/results.html:69
msgid "Status"
msgstr "Status"
@@ -984,7 +1001,7 @@ msgstr "This login has been temporarily disabled, due to multiple failed login
msgid "This request appears to be an attempt at cross-site request forgery and has been rejected!"
msgstr "This request appears to be an attempt at cross-site request forgery and has been rejected!"
-#: models/plugin.php:1118
+#: models/plugin.php:1143
msgid "Timestamp when last the release record was modified"
msgstr "Timestamp when last the release record was modified"
@@ -992,39 +1009,39 @@ msgstr "Timestamp when last the release record was modified"
msgid "Try again?"
msgstr "Try again?"
-#: views/plugins/detail.html:302
+#: views/plugins/detail.html:365
msgid "URL"
msgstr "URL"
-#: models/plugin.php:1058
+#: models/plugin.php:1083
msgid "URL for a manually-launched executable installer for the plugin"
msgstr "URL for a manually-launched executable installer for the plugin"
-#: models/plugin.php:1062
+#: models/plugin.php:1087
msgid "URL for an XPI-based installer for the plugin"
msgstr "URL for an XPI-based installer for the plugin"
-#: models/plugin.php:1066
+#: models/plugin.php:1091
msgid "URL for an executable installer for the plugin (mainly for Windows)"
msgstr "URL for an executable installer for the plugin (mainly for Windows)"
-#: models/plugin.php:1050
+#: models/plugin.php:1075
msgid "URL to an image icon for the plugin"
msgstr "URL to an image icon for the plugin"
-#: models/plugin.php:1054
+#: models/plugin.php:1079
msgid "URL where the license for using the plugin may be found"
msgstr "URL where the license for using the plugin may be found"
-#: models/plugin.php:1046
+#: models/plugin.php:1071
msgid "URL with details describing the plugin"
msgstr "URL with details describing the plugin"
-#: models/plugin.php:991
+#: models/plugin.php:1016
msgid "Uncertain"
msgstr "Uncertain"
-#: views/macros/statuses.html:59 models/plugin.php:986
+#: views/macros/statuses.html:59 models/plugin.php:1011
msgid "Unknown"
msgstr "Unknown"
@@ -1064,11 +1081,15 @@ msgstr "Vendor"
msgid "Version"
msgstr "Version"
-#: models/plugin.php:1014
+#: models/plugin.php:1039
msgid "Version detected in the client, can differ from vendor-intended version depending on capabilities of detection_type"
msgstr "Version detected in the client, can differ from vendor-intended version depending on capabilities of detection_type"
-#: views/plugins/detail.html:96
+#: views/index/index_shell.html:128 views/plugins/detail.html:284
+msgid "View all activity"
+msgstr "View all activity"
+
+#: views/plugins/detail.html:104
msgid "View live"
msgstr "View live"
@@ -1080,11 +1101,11 @@ msgstr "Vulnerability URL"
msgid "Vulnerability description"
msgstr "Vulnerability description"
-#: views/index/index_byinstalled.html:105 views/macros/statuses.html:51 views/plugins/edit.html:295 models/plugin.php:989
+#: views/index/index_byinstalled.html:105 views/macros/statuses.html:51 views/plugins/edit.html:295 models/plugin.php:1014
msgid "Vulnerable"
msgstr "Vulnerable"
-#: views/index/index_shell.html:56
+#: views/index/index_shell.html:64
msgid "Welcome to the Mozilla Plugin Directory"
msgstr "Welcome to the Mozilla Plugin Directory"
@@ -1112,7 +1133,7 @@ msgstr "You appear to have an outdated version of this plugin that needs an upd
msgid "You appear to have the latest version of this plugin as far as the directory is concerned. If this is incorrect, you can suggest a correction."
msgstr "You appear to have the latest version of this plugin as far as the directory is concerned. If this is incorrect, you can suggest a correction."
-#: views/index/index_shell.html:90
+#: views/index/index_shell.html:145
msgid "Your Sandbox"
msgstr "Your Sandbox"
@@ -1148,22 +1169,14 @@ msgstr "delete"
msgid "edit"
msgstr "edit"
-#: views/auth_profiles/changeemail.html:60 views/layout.html:94
+#: views/auth_profiles/changeemail.html:60
msgid "login"
msgstr "login"
-#: views/layout.html:83
-msgid "logout"
-msgstr "logout"
-
-#: models/plugin.php:998
+#: models/plugin.php:1023
msgid "pfs_id of the plugin within PFS2"
msgstr "pfs_id of the plugin within PFS2"
-#: views/layout.html:100
-msgid "register"
-msgstr "register"
-
#: views/layout.html:117
msgid "search releases"
msgstr "search releases"
@@ -1226,6 +1239,15 @@ msgstr "settings"
#~ msgid "Have feedback?"
#~ msgstr "Have feedback?"
+#~ msgid "Login"
+#~ msgstr "Login"
+
+#~ msgid "Login again?"
+#~ msgstr "Login again?"
+
+#~ msgid "Logout"
+#~ msgstr "Logout"
+
#~ msgid "Newer"
#~ msgstr "Newer"
@@ -1267,3 +1289,9 @@ msgstr "settings"
#~ msgid "Your Installed Plugins"
#~ msgstr "Your Installed Plugins"
+
+#~ msgid "logout"
+#~ msgstr "logout"
+
+#~ msgid "register"
+#~ msgstr "register"
diff --git a/application/locale/keys.pot b/application/locale/keys.pot
index da189f4..0917496 100644
--- a/application/locale/keys.pot
+++ b/application/locale/keys.pot
@@ -34,7 +34,7 @@ msgid " Use this form to provide details to create a new "
" "
msgstr ""
-#: views/index/index_shell.html:67
+#: views/index/index_shell.html:75
msgid " If you want to get involved, you can sign up for a\n"
" profile. This will give you access to a sandbox in "
"which to \n"
@@ -46,7 +46,7 @@ msgid " If you want to get involved, you can sign up for a\n"
" "
msgstr ""
-#: views/index/index_shell.html:60
+#: views/index/index_shell.html:68
msgid " This site is an attempt to collect and provide "
"information about\n"
" third-party browser plugins installed by people across "
@@ -104,21 +104,21 @@ msgstr ""
#. i18n: %1$s = plugin_name_e
#. i18n: %2$s = screen_name_e
-#: views/plugins/detail.html:55
+#: views/plugins/detail.html:63
#, php-format
msgid "%1$s (%2$s sandbox)"
msgstr ""
-#: models/plugin.php:1078
+#: models/plugin.php:1103
msgid "(0/1) whether or not the OS needs to restart after plugin "
"installation"
msgstr ""
-#: models/plugin.php:1074
+#: models/plugin.php:1099
msgid "(0/1) whether or not the installer displays a user interface"
msgstr ""
-#: models/plugin.php:1082 models/plugin.php:1086 models/plugin.php:1090
+#: models/plugin.php:1107 models/plugin.php:1111 models/plugin.php:1115
msgid "(Not sure, inherited from PFS1, need a description)"
msgstr ""
@@ -131,18 +131,18 @@ msgstr ""
msgid "### available"
msgstr ""
-#: models/plugin.php:1030
+#: models/plugin.php:1055
msgid "A GUID for the plugin release, may differ between releases and "
"platforms (unlike pfs_id)"
msgstr ""
-#: models/plugin.php:1010
+#: models/plugin.php:1035
msgid "A dot-separated normalized version for the plugin, may differ from "
"official vendor versioning scheme in order to maintain internal "
"consistency in PFS2"
msgstr ""
-#: models/plugin.php:1070
+#: models/plugin.php:1095
msgid "A hash of the installer contents for verifying its integrity"
msgstr ""
@@ -166,8 +166,25 @@ msgstr ""
msgid "Account activation email sent."
msgstr ""
+#: views/plugins/activitylog.html:66
+msgid "Activity log"
+msgstr ""
+
+#. i18n: %1$s = plugin_name_e
+#: views/plugins/activitylog.html:55
+#, php-format
+msgid "Activity log for %1$s"
+msgstr ""
+
+#. i18n: %1$s = plugin_name_e
+#. i18n: %2$s = screen_name_e
+#: views/plugins/activitylog.html:46
+#, php-format
+msgid "Activity log for %1$s (%2$s sandbox)"
+msgstr ""
+
#. i18n: %1$s = screen_name_e
-#: views/plugins/detail.html:152
+#: views/plugins/detail.html:160
#, php-format
msgid "Add %1$s as trusted"
msgstr ""
@@ -188,7 +205,7 @@ msgstr ""
msgid "Any"
msgstr ""
-#: models/plugin.php:1094
+#: models/plugin.php:1119
msgid "Application ID for client app"
msgstr ""
@@ -205,19 +222,19 @@ msgstr ""
msgid "Bio / About you"
msgstr ""
-#: views/index/index_shell.html:101
+#: views/index/index_shell.html:156
msgid "By Application"
msgstr ""
-#: views/index/index_shell.html:109
+#: views/index/index_shell.html:164
msgid "By MIME Type"
msgstr ""
-#: views/index/index_shell.html:97
+#: views/index/index_shell.html:152
msgid "By Name"
msgstr ""
-#: views/index/index_shell.html:105
+#: views/index/index_shell.html:160
msgid "By Operating System"
msgstr ""
@@ -282,19 +299,19 @@ msgstr ""
msgid "Click here to try again."
msgstr ""
-#: models/plugin.php:1114
+#: models/plugin.php:1139
msgid "Client app OS for which the plugin is intended (* is wildcard)"
msgstr ""
-#: models/plugin.php:1109
+#: models/plugin.php:1134
msgid "Client app locale for which the plugin is intended (* is wildcard)"
msgstr ""
-#: models/plugin.php:1099
+#: models/plugin.php:1124
msgid "Client app release for which the plugin is intended (* is wildcard)"
msgstr ""
-#: models/plugin.php:1104
+#: models/plugin.php:1129
msgid "Client app version for which the plugin is intended (* is wildcard)"
msgstr ""
@@ -320,7 +337,7 @@ msgstr ""
msgid "Copy to Sandbox"
msgstr ""
-#: views/plugins/detail.html:179
+#: views/plugins/detail.html:187
msgid "Copy to sandbox"
msgstr ""
@@ -348,7 +365,7 @@ msgstr ""
msgid "Current JSON data"
msgstr ""
-#: models/plugin.php:1002
+#: models/plugin.php:1027
msgid "Current status of the release, eg. latest, outdated, vulnerable"
msgstr ""
@@ -356,7 +373,7 @@ msgstr ""
msgid "Date"
msgstr ""
-#: views/plugins/delete.html:43 views/plugins/detail.html:205
+#: views/plugins/delete.html:43 views/plugins/detail.html:213
msgid "Delete plugin"
msgstr ""
@@ -370,7 +387,7 @@ msgstr ""
msgid "Delete this plugin?"
msgstr ""
-#: PluginDir/Editor.js:512
+#: PluginDir/Editor.js:522
msgid "Delete this release?"
msgstr ""
@@ -382,16 +399,16 @@ msgstr ""
msgid "Detected Version"
msgstr ""
-#: models/plugin.php:1018
+#: models/plugin.php:1043
msgid "Detection scheme used in the client to derive the detected_version "
"value"
msgstr ""
-#: views/plugins/detail.html:346
+#: views/plugins/detail.html:409
msgid "Download / Details"
msgstr ""
-#: views/plugins/detail.html:192
+#: views/plugins/detail.html:200
msgid "Edit details"
msgstr ""
@@ -430,7 +447,7 @@ msgstr ""
msgid "Feedback Actions"
msgstr ""
-#: models/plugin.php:1042
+#: models/plugin.php:1067
msgid "Filename of the plugin as installed"
msgstr ""
@@ -438,12 +455,12 @@ msgstr ""
msgid "Firefox"
msgstr ""
-#: models/plugin.php:1038
+#: models/plugin.php:1063
msgid "For status vulnerable, a URL detailing security vulnerabilities for "
"the plugin release"
msgstr ""
-#: models/plugin.php:1034
+#: models/plugin.php:1059
msgid "For status vulnerable, a short description of security "
"vulnerabilities for the plugin release"
msgstr ""
@@ -469,7 +486,7 @@ msgstr ""
msgid "Full name must contain only alphanumeric characters"
msgstr ""
-#: views/index/index_shell.html:27
+#: views/index/index_shell.html:35
msgid "Home"
msgstr ""
@@ -493,17 +510,17 @@ msgstr ""
msgid "Invalid password reset attempt."
msgstr ""
-#: views/plugins/detail.html:218
+#: views/plugins/detail.html:226
msgid "JSON export"
msgstr ""
-#: PluginDir/Editor.js:194
+#: PluginDir/Editor.js:184
#, c-format
msgid "Last saved at %1$s"
msgstr ""
#: views/macros/statuses.html:33 views/plugins/edit.html:287
-#: models/plugin.php:987
+#: models/plugin.php:1012
msgid "Latest"
msgstr ""
@@ -515,22 +532,26 @@ msgstr ""
msgid "Literal aliases"
msgstr ""
-#: PluginDir/Editor.js:251
+#: PluginDir/Editor.js:241
#, c-format
msgid "Loaded at %1$s"
msgstr ""
-#: views/auth_profiles/logout.html:27
-msgid "Logged out."
-msgstr ""
-
#: views/auth_profiles/login.html:27 views/auth_profiles/login.html:51
-#: views/auth_profiles/login.html:117
-msgid "Login"
+#: views/auth_profiles/login.html:117 views/layout.html:94
+msgid "Log in"
msgstr ""
#: views/auth_profiles/logout.html:33
-msgid "Login again?"
+msgid "Log in again?"
+msgstr ""
+
+#: views/auth_profiles/logout.html:19 views/layout.html:83
+msgid "Log out"
+msgstr ""
+
+#: views/auth_profiles/logout.html:27
+msgid "Logged out."
msgstr ""
#: views/auth_profiles/register.html:46
@@ -563,10 +584,6 @@ msgstr ""
msgid "Login?"
msgstr ""
-#: views/auth_profiles/logout.html:19
-msgid "Logout"
-msgstr ""
-
#: views/plugins/edit.html:188
msgid "MIME types"
msgstr ""
@@ -603,7 +620,7 @@ msgstr ""
msgid "Mark as unseen"
msgstr ""
-#: models/plugin.php:1022
+#: models/plugin.php:1047
msgid "More verbose description of the plugin"
msgstr ""
@@ -620,11 +637,11 @@ msgstr ""
msgid "Name"
msgstr ""
-#: models/plugin.php:1006
+#: models/plugin.php:1031
msgid "Name of the plugin"
msgstr ""
-#: models/plugin.php:1026
+#: models/plugin.php:1051
msgid "Name of the vendor providing the plugin"
msgstr ""
@@ -656,7 +673,7 @@ msgstr ""
msgid "New password is required"
msgstr ""
-#: views/index/index_byinstalled.html:97 models/plugin.php:990
+#: views/index/index_byinstalled.html:97 models/plugin.php:1015
msgid "Newer than directory"
msgstr ""
@@ -668,7 +685,7 @@ msgstr ""
msgid "No submissions."
msgstr ""
-#: views/plugins/detail.html:294 views/plugins/submissions.html:49
+#: views/plugins/detail.html:357 views/plugins/submissions.html:49
#: views/search/results.html:65
msgid "OS"
msgstr ""
@@ -690,7 +707,7 @@ msgid "Options"
msgstr ""
#: views/macros/statuses.html:42 views/plugins/edit.html:291
-#: models/plugin.php:988
+#: models/plugin.php:1013
msgid "Outdated"
msgstr ""
@@ -741,7 +758,7 @@ msgstr ""
msgid "Password must be between 8 and 255 characters in length."
msgstr ""
-#: views/plugins/detail.html:290 views/plugins/submissions.html:53
+#: views/plugins/detail.html:353 views/plugins/submissions.html:53
#: views/search/results.html:61
msgid "Platform"
msgstr ""
@@ -760,7 +777,7 @@ msgstr ""
msgid "Plugin details"
msgstr ""
-#: views/plugins/detail.html:235
+#: views/plugins/detail.html:298
msgid "Plugin icon"
msgstr ""
@@ -780,7 +797,7 @@ msgstr ""
msgid "Push changes to this plugin live?"
msgstr ""
-#: views/plugins/detail.html:109
+#: views/plugins/detail.html:117
msgid "Push live"
msgstr ""
@@ -819,6 +836,7 @@ msgstr ""
#: views/auth_profiles/forgotpassword.html:27
#: views/auth_profiles/register.html:27 views/auth_profiles/register.html:82
+#: views/layout.html:100
msgid "Register"
msgstr ""
@@ -831,7 +849,7 @@ msgstr ""
msgid "Register (verify)"
msgstr ""
-#: views/plugins/edit.html:245 PluginDir/Editor.js:452
+#: views/plugins/edit.html:245 PluginDir/Editor.js:462
msgid "Release"
msgstr ""
@@ -840,7 +858,7 @@ msgid "Releases"
msgstr ""
#. i18n: %1$s = screen_name_e
-#: views/plugins/detail.html:140
+#: views/plugins/detail.html:148
#, php-format
msgid "Remove %1$s as trusted"
msgstr ""
@@ -856,7 +874,7 @@ msgstr ""
msgid "Remove as trusted"
msgstr ""
-#: views/plugins/detail.html:122 views/plugins/requestpush.html:38
+#: views/plugins/detail.html:130 views/plugins/requestpush.html:38
msgid "Request approval"
msgstr ""
@@ -882,7 +900,7 @@ msgstr ""
msgid "Sandbox Actions"
msgstr ""
-#: PluginDir/Editor.js:199
+#: PluginDir/Editor.js:189
#, c-format
msgid "Save failed at %1$s"
msgstr ""
@@ -895,7 +913,7 @@ msgstr ""
msgid "Saved JSON data"
msgstr ""
-#: PluginDir/Editor.js:179
+#: PluginDir/Editor.js:169
#, c-format
msgid "Saving at %1$s"
msgstr ""
@@ -922,7 +940,7 @@ msgstr ""
msgid "Settings for %1$s"
msgstr ""
-#: models/plugin.php:992
+#: views/plugins/edit.html:299 models/plugin.php:1017
msgid "Should be disabled"
msgstr ""
@@ -930,7 +948,7 @@ msgstr ""
msgid "Sorry, that action is not allowed."
msgstr ""
-#: views/plugins/detail.html:298 views/plugins/submissions.html:45
+#: views/plugins/detail.html:361 views/plugins/submissions.html:45
#: views/plugins/submit.html:106 views/search/results.html:69
msgid "Status"
msgstr ""
@@ -1005,7 +1023,7 @@ msgid "This request appears to be an attempt at cross-site request forgery "
"and has been rejected!"
msgstr ""
-#: models/plugin.php:1118
+#: models/plugin.php:1143
msgid "Timestamp when last the release record was modified"
msgstr ""
@@ -1013,39 +1031,39 @@ msgstr ""
msgid "Try again?"
msgstr ""
-#: views/plugins/detail.html:302
+#: views/plugins/detail.html:365
msgid "URL"
msgstr ""
-#: models/plugin.php:1058
+#: models/plugin.php:1083
msgid "URL for a manually-launched executable installer for the plugin"
msgstr ""
-#: models/plugin.php:1062
+#: models/plugin.php:1087
msgid "URL for an XPI-based installer for the plugin"
msgstr ""
-#: models/plugin.php:1066
+#: models/plugin.php:1091
msgid "URL for an executable installer for the plugin (mainly for Windows)"
msgstr ""
-#: models/plugin.php:1050
+#: models/plugin.php:1075
msgid "URL to an image icon for the plugin"
msgstr ""
-#: models/plugin.php:1054
+#: models/plugin.php:1079
msgid "URL where the license for using the plugin may be found"
msgstr ""
-#: models/plugin.php:1046
+#: models/plugin.php:1071
msgid "URL with details describing the plugin"
msgstr ""
-#: models/plugin.php:991
+#: models/plugin.php:1016
msgid "Uncertain"
msgstr ""
-#: views/macros/statuses.html:59 models/plugin.php:986
+#: views/macros/statuses.html:59 models/plugin.php:1011
msgid "Unknown"
msgstr ""
@@ -1088,12 +1106,16 @@ msgstr ""
msgid "Version"
msgstr ""
-#: models/plugin.php:1014
+#: models/plugin.php:1039
msgid "Version detected in the client, can differ from vendor-intended "
"version depending on capabilities of detection_type"
msgstr ""
-#: views/plugins/detail.html:96
+#: views/index/index_shell.html:128 views/plugins/detail.html:284
+msgid "View all activity"
+msgstr ""
+
+#: views/plugins/detail.html:104
msgid "View live"
msgstr ""
@@ -1106,11 +1128,11 @@ msgid "Vulnerability description"
msgstr ""
#: views/index/index_byinstalled.html:105 views/macros/statuses.html:51
-#: views/plugins/edit.html:295 models/plugin.php:989
+#: views/plugins/edit.html:295 models/plugin.php:1014
msgid "Vulnerable"
msgstr ""
-#: views/index/index_shell.html:56
+#: views/index/index_shell.html:64
msgid "Welcome to the Mozilla Plugin Directory"
msgstr ""
@@ -1144,7 +1166,7 @@ msgid "You appear to have the latest version of this plugin as far as the "
"correction."
msgstr ""
-#: views/index/index_shell.html:90
+#: views/index/index_shell.html:145
msgid "Your Sandbox"
msgstr ""
@@ -1180,22 +1202,14 @@ msgstr ""
msgid "edit"
msgstr ""
-#: views/auth_profiles/changeemail.html:60 views/layout.html:94
+#: views/auth_profiles/changeemail.html:60
msgid "login"
msgstr ""
-#: views/layout.html:83
-msgid "logout"
-msgstr ""
-
-#: models/plugin.php:998
+#: models/plugin.php:1023
msgid "pfs_id of the plugin within PFS2"
msgstr ""
-#: views/layout.html:100
-msgid "register"
-msgstr ""
-
#: views/layout.html:117
msgid "search releases"
msgstr ""
diff --git a/application/models/auditlogevent.php b/application/models/auditlogevent.php
new file mode 100644
index 0000000..5f6eb30
--- /dev/null
+++ b/application/models/auditlogevent.php
@@ -0,0 +1,117 @@
+
+ */
+
+/**
+ * Audit log event model class
+ */
+class AuditLogEvent_Model extends ORM_Resource
+{
+ protected $table_name = "activity_log";
+
+ public $belongs_to = array(
+ 'profile', 'plugin', 'pluginrelease'
+ );
+
+ public $json_fields = array(
+ 'details', 'old_state', 'new_state'
+ );
+
+ public static $current_profile = null;
+
+ /**
+ * Find all, with pre-digestion for use in a view.
+ */
+ public function find_all_for_view()
+ {
+ $events_db = $this->find_all();
+ $events = array();
+ foreach ($events_db as $event_db) {
+ $event = array_merge($event_db->as_array(), array(
+ 'profile' => $event_db->profile->as_array(),
+ 'plugin' => $event_db->plugin->as_array(),
+ 'plugin_release' => $event_db->pluginrelease->as_array(),
+ 'isotime' => gmdate('c', strtotime($event_db->created)),
+ 'relative_date' =>
+ $this->relative_date(strtotime($event_db->created)),
+ 'time' =>
+ gmdate('g:i:s A', strtotime($event_db->created))
+ ));
+ if (!empty($event_db->plugin->sandbox_profile_id)) {
+ $event['plugin']['sandbox_profile'] =
+ ORM::factory('profile', $event_db->plugin->sandbox_profile_id)
+ ->as_array();
+ }
+ $events[] = $event;
+ }
+ return $events;
+ }
+
+ /**
+ * Build a relative date display
+ * TODO: Move this into a helper
+ */
+ public function relative_date($time) {
+ $today = strtotime(gmdate('M j, Y'));
+ $reldays = ($time - $today)/86400;
+ if ($reldays >= 0 && $reldays < 1) {
+ return 'today';
+ } else if ($reldays >= 1 && $reldays < 2) {
+ return 'tomorrow';
+ } else if ($reldays >= -1 && $reldays < 0) {
+ return 'yesterday';
+ }
+ if (abs($reldays) < 7) {
+ if ($reldays > 0) {
+ $reldays = floor($reldays);
+ return 'in ' . $reldays . ' day' . ($reldays != 1 ? 's' : '');
+ } else {
+ $reldays = abs(floor($reldays));
+ return $reldays . ' day' . ($reldays != 1 ? 's' : '') . ' ago';
+ }
+ }
+ if (abs($reldays) < 182) {
+ return gmdate('l, F j',$time ? $time : time());
+ } else {
+ return gmdate('l, F j, Y',$time ? $time : time());
+ }
+ }
+
+ /**
+ * Before saving, update with current profile, if necessary.
+ */
+ public function save()
+ {
+ if (empty($this->profile_id) && !empty(self::$current_profile)) {
+ $this->profile_id = self::$current_profile->id;
+ }
+ if (!empty($this->plugin_id)) {
+ $this->pfs_id = $this->plugin->pfs_id;
+ }
+ foreach ($this->json_fields as $name) {
+ if (!empty($this->{$name}) && is_array($this->{$name})) {
+ $this->{$name} = json_encode($this->{$name});
+ }
+ }
+ return parent::save();
+ }
+
+ /**
+ * After loading from database, decode the grab bag of attributes from JSON.
+ */
+ public function load_values(array $values)
+ {
+ parent::load_values($values);
+ foreach ($this->json_fields as $name) {
+ if (!empty($this->{$name}) && is_string($this->{$name})) {
+ $this->{$name} = json_decode($this->{$name}, TRUE);
+ }
+ }
+ }
+
+}
diff --git a/application/models/plugin.php b/application/models/plugin.php
index 5bc4647..67873b6 100644
--- a/application/models/plugin.php
+++ b/application/models/plugin.php
@@ -107,8 +107,12 @@ public function find_for_sandbox($profile_id)
/**
* Assemble a data structure suitable for later import from plugin records.
*/
- public function export()
+ public function export($force_fresh=FALSE)
{
+ if ($force_fresh) {
+ $this->db->clear_cache();
+ }
+
// Build the export scaffolding.
$out = array(
'meta' => array(
diff --git a/application/views/index/index_shell.html b/application/views/index/index_shell.html
index ef9a90d..2b85a9b 100644
--- a/application/views/index/index_shell.html
+++ b/application/views/index/index_shell.html
@@ -1,6 +1,7 @@
{% extends "layout.html" %}
{% import "index/index_shell.html" as this %}
+{% import "macros/auditlogevents.html" as auditlogevents %}
{% block title %}
{% trans "Home" %}
@@ -29,6 +30,20 @@ {% trans "Welcome to the Mozilla Plugin Directory" %}
{% endblocktrans %}
+
+