Permalink
Browse files

Lots of work on AllViewed; GPL2 not 3:

  • Loading branch information...
1 parent cb09383 commit 2a233890fc55a1ac8955ddee3a0502d97d34b4f5 @linc linc committed Oct 10, 2010
@@ -3,7 +3,7 @@
// Define the plugin:
$PluginInfo['AllVieiwed'] = array(
- 'Name' => 'AllVieiwed',
+ 'Name' => 'AllViewed',
'Description' => '',
'Version' => '1.0a',
'RequiredApplications' => FALSE,
@@ -14,20 +14,83 @@
'Author' => "Matt Lincoln Russell",
'AuthorEmail' => 'lincolnwebs@gmail.com',
'AuthorUrl' => 'http://www.tmprod.com/web-development/vanilla.php',
- 'License' => 'GNU GPLv3'
+ 'License' => 'GNU GPLv2'
);
class AllVieiwedPlugin extends Gdn_Plugin {
+ /**
+ * Allows user to mark all discussions as viewed.
+ */
+ function DiscussionsController_MarkAllViewed_Create(&$Sender) {
+ $UserModel = Gdn::UserModel();
+ $UserModel->UpdateAllViewed();
+
+ $Sender->RedirectUrl = Url('discussions');
+ $Sender->StatusMessage = T('All discussed marked as viewed.');
+ $Sender->Render();
+ }
+
+ /**
+ * Modify UnreadCommentCount to account for DateAllViewed
+ *
+ * Required in DiscussionModel->Get() just before the return:
+ * $this->EventArguments['Data'] = $Data;
+ * FireEvent('AfterAddColumns') ;
+ * @link http://vanillaforums.org/discussion/13227
+ */
+ function DiscussionModel_AfterAddColumns_Handler(&$Sender) {
+ if (!C('Plugins.AllViewed.Enabled'))
+ return;
+
+ // Only for members
+ $Session = Gdn::Session();
+ if(!$Session->IsValid())
+ return;
+
+ // Get user's DateAllViewed
+
+ // Recalculate New count with user's DateAllViewed
+ $Sender->Data = GetValue('Data', $Sender->EventArguments, '');
+
+ }
+ /**
+ * Update user's AllViewed datetime.
+ */
+ function UserModel_UpdateAllViewed_Create(&$Sender) {
+ if (!C('Plugins.AllViewed.Enabled'))
+ return;
+
+ // Only for members
+ $Session = Gdn::Session();
+ if(!$Session->IsValid())
+ return;
+
+ $UserID = $Session->User->UserID; // Can only activate on yourself
+
+ // Validity check (in case get passed UserID from elsewhere some day)
+ $UserID = (int) $UserID;
+ if (!$UserID) {
+ throw new Exception('A valid UserId is required.');
+ }
+
+ $Sender->SQL->Update('User')
+ ->Set('DateAllViewed', Gdn_Format::ToDateTime());
+
+ $Sender->SQL->Where('UserID', $UserID)->Put();
+
+ // Set in current session?
+
+ }
/**
* 1-Time on Enable
*/
public function Setup() {
$Structure = Gdn::Structure();
$Structure->Table('User')
- ->Column('AllViewed', 'datetime')
+ ->Column('DateAllViewed', 'datetime')
->Set();
SaveToConfig('Plugins.AllViewed.Enabled', TRUE);
@@ -19,7 +19,7 @@
'Author' => "Matt Lincoln Russell",
'AuthorEmail' => 'lincolnwebs@gmail.com',
'AuthorUrl' => 'http://tmprod.com',
- 'License' => 'GNU GPLv3'
+ 'License' => 'GNU GPLv2'
);
Gdn_LibraryMap::SafeCache('library','class.paymentmodel.php',dirname(__FILE__).DS.'models/class.paymentmodel.php');
@@ -15,7 +15,7 @@
'Author' => "Matt Lincoln Russell",
'AuthorEmail' => 'lincolnwebs@gmail.com',
'AuthorUrl' => 'http://www.tmprod.com/web-development/vanilla.php',
- 'License' => 'GNU GPLv3'
+ 'License' => 'GNU GPLv2'
);
class AutoParagraphPlugin extends Gdn_Plugin {
@@ -18,7 +18,7 @@
'Author' => "Matt Lincoln Russell",
'AuthorEmail' => 'lincolnwebs@gmail.com',
'AuthorUrl' => 'http://tmprod.com',
- 'License' => 'GNU GPLv3'
+ 'License' => 'GNU GPLv2'
);
/** @todo Make these options in the Dashboard */
@@ -19,7 +19,7 @@
'Author' => "Matt Lincoln Russell",
'AuthorEmail' => 'lincolnwebs@gmail.com',
'AuthorUrl' => 'http://www.tmprod.com/web-development/vanilla.php',
- 'License' => 'GNU GPLv3'
+ 'License' => 'GNU GPLv2'
);
class DiscussionPrefixPlugin extends Gdn_Plugin {
@@ -20,7 +20,7 @@
'Author' => "Matt Lincoln Russell",
'AuthorEmail' => 'lincolnwebs@gmail.com',
'AuthorUrl' => 'http://tmprod.com',
- 'License' => 'GNU GPLv3'
+ 'License' => 'GNU GPLv2'
);
// $Units data member

0 comments on commit 2a23389

Please sign in to comment.