Simple History - Version 0.3.8

Version Description

  • Added chinese translation
  • Uses WordPress own human_time_diff() instead of own version
  • Fix for time zones
Download this release

Release Info

Developer eskapism
Plugin Icon 128x128 Simple History
Version 0.3.8
Comparing to
See all releases

Code changes from version 0.3.7 to 0.3.8

index.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Simple History
4
  Plugin URI: http://eskapism.se/code-playground/simple-history/
5
  Description: Get a log of the changes made by users in WordPress.
6
- Version: 0.3.7
7
  Author: Pär Thernström
8
  Author URI: http://eskapism.se/
9
  License: GPL2
@@ -25,7 +25,7 @@ License: GPL2
25
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
  */
27
 
28
- define( "SIMPLE_HISTORY_VERSION", "0.3.7");
29
  define( "SIMPLE_HISTORY_NAME", "Simple History");
30
  define( "SIMPLE_HISTORY_URL", WP_PLUGIN_URL . '/simple-history/');
31
 
@@ -151,7 +151,7 @@ function simple_history_init() {
151
  <item>
152
  <title><![CDATA[<?php echo $item_title; ?>]]></title>
153
  <description><![CDATA[<?php echo $description ?>]]></description>
154
- <pubDate><?php echo date("D, d M Y H:i:s", $one_item->date_unix) ?> GMT</pubDate>
155
  <guid isPermaLink="false"><?php echo $item_guid ?></guid>
156
  </item>
157
  <?php
@@ -595,59 +595,18 @@ function simple_history_add($args) {
595
  $current_user = wp_get_current_user();
596
  $current_user_id = (int) $current_user->ID;
597
  }
598
- $sql = "INSERT INTO {$tableprefix}simple_history SET date = now(), action = '$action', object_type = '$object_type', object_subtype = '$object_subtype', user_id = '$current_user_id', object_id = '$object_id', object_name = '$object_name'";
 
 
 
 
 
 
 
599
  $wpdb->query($sql);
600
  }
601
 
602
 
603
- // Returns an English representation of a past date within the last month
604
- // Graciously stolen from http://ejohn.org/files/pretty.js
605
- // ..and simple_history stole it even more graciously from simple-php-framework http://github.com/tylerhall/simple-php-framework/
606
- function simple_history_time2str($ts) {
607
- #if(!ctype_digit($ts))
608
- # $ts = strtotime($ts);
609
-
610
- $diff = time() - $ts;
611
- if($diff == 0)
612
- return 'now';
613
- elseif($diff > 0)
614
- {
615
- $day_diff = floor($diff / 86400);
616
- if($day_diff == 0)
617
- {
618
- if($diff < 60) return 'just now';
619
- if($diff < 120) return '1 minute ago';
620
- if($diff < 3600) return floor($diff / 60) . ' minutes ago';
621
- if($diff < 7200) return '1 hour ago';
622
- if($diff < 86400) return floor($diff / 3600) . ' hours ago';
623
- }
624
- if($day_diff == 1) return 'Yesterday';
625
- if($day_diff < 7) return $day_diff . ' days ago';
626
- if($day_diff < 31) return ceil($day_diff / 7) . ' weeks ago';
627
- if($day_diff < 60) return 'last month';
628
- return date('F Y', $ts);
629
- }
630
- else
631
- {
632
- $diff = abs($diff);
633
- $day_diff = floor($diff / 86400);
634
- if($day_diff == 0)
635
- {
636
- if($diff < 120) return 'in a minute';
637
- if($diff < 3600) return 'in ' . floor($diff / 60) . ' minutes';
638
- if($diff < 7200) return 'in an hour';
639
- if($diff < 86400) return 'in ' . floor($diff / 3600) . ' hours';
640
- }
641
- if($day_diff == 1) return 'Tomorrow';
642
- if($day_diff < 4) return date('l', $ts);
643
- if($day_diff < 7 + (7 - date('w'))) return 'next week';
644
- if(ceil($day_diff / 7) < 4) return 'in ' . ceil($day_diff / 7) . ' weeks';
645
- if(date('n', $ts) == date('n') + 1) return 'next month';
646
- #return date('F Y', $ts);
647
- return $ts; // return back and let us do something else with it
648
- }
649
- }
650
-
651
  function simple_history_purge_db() {
652
  global $wpdb;
653
  $tableprefix = $wpdb->prefix;
@@ -877,7 +836,7 @@ function simple_history_get_items_array($args) {
877
  $limit_items = $args["items"];
878
  $sql_limit = " LIMIT $limit_page, $args[items]";
879
 
880
- $sql = "SELECT *, UNIX_TIMESTAMP(date) as date_unix FROM {$tableprefix}simple_history $where ORDER BY date DESC ";
881
  $rows = $wpdb->get_results($sql);
882
 
883
  $loopNum = 0;
@@ -976,7 +935,6 @@ function simple_history_print_history($args = null) {
976
  [object_subtype] => page
977
  [user_id] => 1
978
  [object_id] => 732
979
- [date_unix] => 1278184123
980
  [occasions] => array
981
  )
982
  */
@@ -1187,7 +1145,9 @@ function simple_history_print_history($args = null) {
1187
  $date_i18n_date = date_i18n(get_option('date_format'), strtotime($one_row->date), $gmt=false);
1188
  $date_i18n_time = date_i18n(get_option('time_format'), strtotime($one_row->date), $gmt=false);
1189
  echo "By $who, ";
1190
- echo "<span class='when'>".simple_history_time2str($one_row->date_unix)."</span>";
 
 
1191
  echo "<span class='when_detail'>$date_i18n_date at $date_i18n_time</span>";
1192
  echo "</div>";
1193
 
@@ -1206,7 +1166,7 @@ function simple_history_print_history($args = null) {
1206
  echo "<li>";
1207
  $date_i18n_date = date_i18n(get_option('date_format'), strtotime($one_occasion->date), $gmt=false);
1208
  $date_i18n_time = date_i18n(get_option('time_format'), strtotime($one_occasion->date), $gmt=false);
1209
- echo simple_history_time2str($one_occasion->date_unix) . " ($date_i18n_date at $date_i18n_time)";
1210
 
1211
  echo "</li>";
1212
  }
3
  Plugin Name: Simple History
4
  Plugin URI: http://eskapism.se/code-playground/simple-history/
5
  Description: Get a log of the changes made by users in WordPress.
6
+ Version: 0.3.8
7
  Author: Pär Thernström
8
  Author URI: http://eskapism.se/
9
  License: GPL2
25
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
  */
27
 
28
+ define( "SIMPLE_HISTORY_VERSION", "0.3.8");
29
  define( "SIMPLE_HISTORY_NAME", "Simple History");
30
  define( "SIMPLE_HISTORY_URL", WP_PLUGIN_URL . '/simple-history/');
31
 
151
  <item>
152
  <title><![CDATA[<?php echo $item_title; ?>]]></title>
153
  <description><![CDATA[<?php echo $description ?>]]></description>
154
+ <pubDate><?php echo date("D, d M Y H:i:s", strtotime($one_item->date)) ?> GMT</pubDate>
155
  <guid isPermaLink="false"><?php echo $item_guid ?></guid>
156
  </item>
157
  <?php
595
  $current_user = wp_get_current_user();
596
  $current_user_id = (int) $current_user->ID;
597
  }
598
+
599
+ // date, store at utc or local time
600
+ // anything is better than now() anyway!
601
+ // WP seems to use the local time, so I will go with that too I think
602
+ // GMT/UTC-time is: date_i18n($timezone_format, false, 'gmt'));
603
+ // local time is: date_i18n($timezone_format));
604
+ $localtime = current_time("mysql");
605
+ $sql = "INSERT INTO {$tableprefix}simple_history SET date = '$localtime', action = '$action', object_type = '$object_type', object_subtype = '$object_subtype', user_id = '$current_user_id', object_id = '$object_id', object_name = '$object_name'";
606
  $wpdb->query($sql);
607
  }
608
 
609
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
610
  function simple_history_purge_db() {
611
  global $wpdb;
612
  $tableprefix = $wpdb->prefix;
836
  $limit_items = $args["items"];
837
  $sql_limit = " LIMIT $limit_page, $args[items]";
838
 
839
+ $sql = "SELECT * FROM {$tableprefix}simple_history $where ORDER BY date DESC ";
840
  $rows = $wpdb->get_results($sql);
841
 
842
  $loopNum = 0;
935
  [object_subtype] => page
936
  [user_id] => 1
937
  [object_id] => 732
 
938
  [occasions] => array
939
  )
940
  */
1145
  $date_i18n_date = date_i18n(get_option('date_format'), strtotime($one_row->date), $gmt=false);
1146
  $date_i18n_time = date_i18n(get_option('time_format'), strtotime($one_row->date), $gmt=false);
1147
  echo "By $who, ";
1148
+ $now = strtotime(current_time("mysql"));
1149
+ $diff_str = sprintf( __('%s ago'), human_time_diff(strtotime($one_row->date), $now) );
1150
+ echo "<span class='when'>".$diff_str."</span>";
1151
  echo "<span class='when_detail'>$date_i18n_date at $date_i18n_time</span>";
1152
  echo "</div>";
1153
 
1166
  echo "<li>";
1167
  $date_i18n_date = date_i18n(get_option('date_format'), strtotime($one_occasion->date), $gmt=false);
1168
  $date_i18n_time = date_i18n(get_option('time_format'), strtotime($one_occasion->date), $gmt=false);
1169
+ echo sprintf( __('%s ago (%s at %s)', "simple-history"), human_time_diff(strtotime($one_occasion->date), $now), $date_i18n_date, $date_i18n_time );
1170
 
1171
  echo "</li>";
1172
  }
languages/simple-history-zh_CN.mo ADDED
Binary file
languages/simple-history-zh_CN.po ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: LERIO\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2010-12-07 14:45+0800\n"
6
+ "PO-Revision-Date: 2010-12-07 14:49+0800\n"
7
+ "Last-Translator: \n"
8
+ "Language-Team: LERIO <LERIO@QQ.COM>\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Poedit-KeywordsList: __;_e\n"
13
+ "X-Poedit-Basepath: ..\n"
14
+ "X-Poedit-Language: Chinese\n"
15
+ "X-Poedit-Country: CHINA\n"
16
+ "X-Poedit-SourceCharset: utf-8\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: index.php:126
20
+ #: index.php:168
21
+ #, php-format
22
+ msgid "Simple History for %s"
23
+ msgstr "简易历史 %s"
24
+
25
+ #: index.php:127
26
+ #: index.php:169
27
+ #, php-format
28
+ msgid "WordPress History for %s"
29
+ msgstr "WordPress 简易历史 %s"
30
+
31
+ #: index.php:139
32
+ #, php-format
33
+ msgid "By %s"
34
+ msgstr "由 %s"
35
+
36
+ #: index.php:143
37
+ #, php-format
38
+ msgid "%d occasions"
39
+ msgstr "%d 事件"
40
+
41
+ #: index.php:173
42
+ msgid "Wrong RSS secret"
43
+ msgstr "错误的私隐 RSS"
44
+
45
+ #: index.php:174
46
+ msgid "Your RSS secret for Simple History RSS feed is wrong. Please see WordPress settings for current link to the RSS feed."
47
+ msgstr "您的简易历史 RSS 私密订阅是错误的。请参阅 WordPress 中的 RSS 订阅链接设置。"
48
+
49
+ #: index.php:247
50
+ msgid "on the dashboard"
51
+ msgstr "显示在控制面版上"
52
+
53
+ #: index.php:252
54
+ msgid "as a page under the tools menu"
55
+ msgstr "显示在右侧功能栏上"
56
+
57
+ #: index.php:283
58
+ msgid "Created new secret RSS adress"
59
+ msgstr "建立新的 RSS 私密地址"
60
+
61
+ #: index.php:294
62
+ msgid "This is a secret RSS feed for Simple History. Only share the link with people you trust"
63
+ msgstr "这是简单历史的私密订阅。只能与你信任的人分享的链接"
64
+
65
+ #: index.php:297
66
+ #, php-format
67
+ msgid "You can <a href='%s'>generate a new address</a> for the RSS feed. This is useful if you think that the address has fallen into the wrong hands."
68
+ msgstr "你可以为 RSS 订阅 <a href='%s'>建立一个新的地址</a>。这是非常有用的,如果你认为地址已经泄漏。"
69
+
70
+ #: index.php:320
71
+ #: index.php:335
72
+ #: index.php:366
73
+ #, php-format
74
+ msgid "From %1$s on %2$s"
75
+ msgstr "从 %1$s 开始到 %2$s"
76
+
77
+ #: index.php:816
78
+ msgid "By all users"
79
+ msgstr "所有用户"
80
+
81
+ #: index.php:1036
82
+ msgid "Unknown or deleted user"
83
+ msgstr "未知或已删除用户"
84
+
85
+ #: index.php:1063
86
+ msgid "created"
87
+ msgstr "创建"
88
+
89
+ #: index.php:1065
90
+ #: index.php:1158
91
+ msgid "updated"
92
+ msgstr "更新"
93
+
94
+ #: index.php:1067
95
+ #: index.php:1160
96
+ msgid "deleted"
97
+ msgstr "删除"
98
+
99
+ #: index.php:1156
100
+ msgid "added"
101
+ msgstr "添加"
102
+
103
+ #: index.php:1162
104
+ msgid "logged in"
105
+ msgstr "登录"
106
+
107
+ #: index.php:1164
108
+ msgid "logged out"
109
+ msgstr "登出"
110
+
111
+ #: index.php:1198
112
+ msgid "+ 1 occasion"
113
+ msgstr "+ 1次"
114
+
115
+ #: index.php:1201
116
+ #, php-format
117
+ msgid "+ %d occasions"
118
+ msgstr "+ %d 次"
119
+
120
+ #: index.php:1230
121
+ #, php-format
122
+ msgid "Show %d more"
123
+ msgstr "显示 %d 个更多"
124
+
125
+ #: index.php:1231
126
+ msgid "Loading..."
127
+ msgstr "载入中..."
128
+
129
+ #: index.php:1232
130
+ msgid "No more history items found."
131
+ msgstr "没有找到更多的历史项目。"
132
+
133
+ #: index.php:1233
134
+ msgid "Simple History RSS feed"
135
+ msgstr "简易历史 RSS 订阅"
136
+
137
+ #: index.php:1249
138
+ msgid "No history items found."
139
+ msgstr "没有找到历史项目。"
140
+
141
+ #: index.php:1250
142
+ msgid "Please note that Simple History only records things that happen after this plugin have been installed."
143
+ msgstr "请注意,简单的历史只能记录插件安装后发生的事情。"
144
+
readme.txt CHANGED
@@ -4,23 +4,23 @@ Donate link: http://eskapism.se/sida/donate/
4
  Tags: history, log, changes, changelog, audit, trail, pages, attachments, users, cms, dashboard, admin
5
  Requires at least: 2.9.2
6
  Tested up to: 3.0
7
- Stable tag: 0.3.7
8
 
9
- View changes made by users within WordPress. It’s a history/change log/audit/recent changes-plugin.
10
 
11
  == Description ==
12
 
13
- Simple History is a plugin that shows recent changes made within WordPress.
14
 
15
- Users of the system can see what articles have been created, modified or deleted,
16
  what attachments have been uploaded, modified or deleted, and what plugins that have been
17
- activated or deactivated.
18
 
19
- All changes are also avaialable as a RSS feed som you can keep track of the changes made
20
- via your favorite RSS reader on your phone, on your iPad, or on your computer. Or any where you like.
21
 
22
- It’s a pretty good plugin to have on websites where several people are
23
- involved.
24
 
25
  #### Example scenarios
26
 
@@ -36,9 +36,19 @@ that must be it."_
36
  See the plugin in action with this short screencast:
37
  [youtube http://www.youtube.com/watch?v=4cu4kooJBzs]
38
 
 
 
 
 
 
 
 
 
 
 
39
  #### Donation and more plugins
40
  * If you like this plugin don't forget to [donate to support further development](http://eskapism.se/sida/donate/).
41
- * Check out some [more plugins](http://wordpress.org/extend/plugins/profile/eskapism) by the same author.
42
 
43
  == Installation ==
44
 
@@ -65,6 +75,11 @@ to only use the secret RSS feed to keep track of the changes on you web site/Wor
65
 
66
  == Changelog ==
67
 
 
 
 
 
 
68
  = 0.3.7 =
69
  - Directly after installation of Simple History you could view the history RSS feed without using any secret. Now a secret is automatically set during installation.
70
 
4
  Tags: history, log, changes, changelog, audit, trail, pages, attachments, users, cms, dashboard, admin
5
  Requires at least: 2.9.2
6
  Tested up to: 3.0
7
+ Stable tag: 0.3.8
8
 
9
+ View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
10
 
11
  == Description ==
12
 
13
+ Simple History shows recent changes made within WordPress, directly on your dashboard or on a separate page.
14
 
15
+ Users of the system can **see what articles have been created, modified or deleted,
16
  what attachments have been uploaded, modified or deleted, and what plugins that have been
17
+ activated or deactivated**.
18
 
19
+ All **changes are also v as a RSS feed** so you can keep track of the changes made
20
+ via your favorite RSS reader on your phone, on your iPad, or on your computer..
21
 
22
+ It’s a plugin that is good to have on websites where several people are
23
+ involved in editing the content.
24
 
25
  #### Example scenarios
26
 
36
  See the plugin in action with this short screencast:
37
  [youtube http://www.youtube.com/watch?v=4cu4kooJBzs]
38
 
39
+ #### Add your own events to simple history
40
+ If you are a plugin developer and would like to add your own things/events to Simple History
41
+ you can do that by calling the function simple_history_add like this:
42
+ `<?php
43
+ # will return “Plugin your_plugin_name Edited”
44
+ simple_history_add("action=edited&object_type=plugin&object_name=your_plugin_name");
45
+ ?>`
46
+
47
+ `<?php simple_history_add("action=repaired&object_type=starship&object_name=USS Enterprise"); ?>`
48
+
49
  #### Donation and more plugins
50
  * If you like this plugin don't forget to [donate to support further development](http://eskapism.se/sida/donate/).
51
+ * More [WordPress CMS plugins](http://wordpress.org/extend/plugins/profile/eskapism) by the same author.
52
 
53
  == Installation ==
54
 
75
 
76
  == Changelog ==
77
 
78
+ = 0.3.8 =
79
+ - Added chinese translation
80
+ - Uses WordPress own human_time_diff() instead of own version
81
+ - Fix for time zones
82
+
83
  = 0.3.7 =
84
  - Directly after installation of Simple History you could view the history RSS feed without using any secret. Now a secret is automatically set during installation.
85