Skip to content

Commit 51ea28d

Browse files
committed
fix: vendorize
1 parent b7aa6dd commit 51ea28d

File tree

4 files changed

+11
-90
lines changed

4 files changed

+11
-90
lines changed

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "fullscreeninteractive/silverstripe-forum",
33
"description": "Forum module for SilverStripe.",
4-
"type": "silverstripe-module",
4+
"type": "silverstripe-vendormodule",
55
"keywords": [
66
"silverstripe",
77
"forum"
@@ -15,6 +15,8 @@
1515
],
1616
"require": {
1717
"silverstripe/cms": "^6",
18+
"silverstripe/framework": "^6",
19+
"silverstripe/vendor-plugin": "^2",
1820
"chriskonnertz/bbcode": "^1",
1921
"league/commonmark": "^2"
2022
},

src/Extensions/ForumMemberExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ForumRole extends Extension
3232
'CityPublic' => 'Boolean',
3333
'CountryPublic' => 'Boolean',
3434
'EmailPublic' => 'Boolean',
35-
'LastViewed' => 'SS_Datetime',
35+
'LastViewed' => 'Datetime',
3636
'Signature' => 'Text',
3737
'ForumStatus' => 'Enum("Normal, Banned, Ghost", "Normal")',
3838
'SuspendedUntil' => 'Date'

src/Model/ForumThread.php

Lines changed: 6 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use SilverStripe\ORM\DataObject;
77
use FullscreenInteractive\SilverStripe\Forum\PageTypes\Forum;
88
use SilverStripe\ORM\DB;
9+
use SilverStripe\ORM\FieldType\DBField;
910
use SilverStripe\Security\Security;
1011

1112
class ForumThread extends DataObject
@@ -27,6 +28,10 @@ class ForumThread extends DataObject
2728
'Posts' => Post::class
2829
];
2930

31+
private static $cascade_deletes = [
32+
'Posts'
33+
];
34+
3035
private static $defaults = [
3136
'NumViews' => 0,
3237
'IsSticky' => false,
@@ -202,7 +207,7 @@ public function getHasSubscribed()
202207
{
203208
$member = Security::getCurrentUser();
204209

205-
return ($member) ? ForumThread_Subscription::already_subscribed($this->ID, $member->ID) : false;
210+
return ($member) ? ForumThreadSubscription::singleton()->isSubscribed($this->ID, $member->ID) : false;
206211
}
207212

208213
/**
@@ -239,92 +244,6 @@ public function onAfterWrite()
239244
*/
240245
public function getEscapedTitle()
241246
{
242-
//return DBField::create('Text', $this->dbObject('Title')->XML());
243247
return DBField::create_field('Text', $this->dbObject('Title')->XML());
244248
}
245249
}
246-
247-
248-
/**
249-
* Forum Thread Subscription: Allows members to subscribe to this thread
250-
* and receive email notifications when these topics are replied to.
251-
*
252-
* @package forum
253-
*/
254-
class ForumThread_Subscription extends DataObject
255-
{
256-
257-
private static $db = array(
258-
"LastSent" => "SS_Datetime"
259-
);
260-
261-
private static $has_one = array(
262-
"Thread" => "ForumThread",
263-
"Member" => "Member"
264-
);
265-
266-
/**
267-
* Checks to see if a Member is already subscribed to this thread
268-
*
269-
* @param int $threadID The ID of the thread to check
270-
* @param int $memberID The ID of the currently logged in member (Defaults to Member::currentUserID())
271-
*
272-
* @return bool true if they are subscribed, false if they're not
273-
*/
274-
static function already_subscribed($threadID, $memberID = null)
275-
{
276-
if (!$memberID) {
277-
$memberID = Member::currentUserID();
278-
}
279-
$SQL_threadID = Convert::raw2sql($threadID);
280-
$SQL_memberID = Convert::raw2sql($memberID);
281-
282-
if ($SQL_threadID == '' || $SQL_memberID == '') {
283-
return false;
284-
}
285-
286-
return (DB::query("
287-
SELECT COUNT(\"ID\")
288-
FROM \"ForumThread_Subscription\"
289-
WHERE \"ThreadID\" = '$SQL_threadID' AND \"MemberID\" = $SQL_memberID")->value() > 0) ? true : false;
290-
}
291-
292-
/**
293-
* Notifies everybody that has subscribed to this topic that a new post has been added.
294-
* To get emailed, people subscribed to this topic must have visited the forum
295-
* since the last time they received an email
296-
*
297-
* @param Post $post The post that has just been added
298-
*/
299-
static function notify(Post $post)
300-
{
301-
$list = DataObject::get(
302-
"ForumThread_Subscription",
303-
"\"ThreadID\" = '" . $post->ThreadID . "' AND \"MemberID\" != '$post->AuthorID'"
304-
);
305-
306-
if ($list) {
307-
foreach ($list as $obj) {
308-
$SQL_id = Convert::raw2sql((int)$obj->MemberID);
309-
310-
// Get the members details
311-
$member = DataObject::get_one("Member", "\"Member\".\"ID\" = '$SQL_id'");
312-
$adminEmail = Config::inst()->get('Email', 'admin_email');
313-
314-
if ($member) {
315-
$email = new Email();
316-
$email->setFrom($adminEmail);
317-
$email->setTo($member->Email);
318-
$email->setSubject(_t('Post.NEWREPLY', 'New reply for {title}', array('title' => $post->Title)));
319-
$email->setTemplate('ForumMember_TopicNotification');
320-
$email->populateTemplate($member);
321-
$email->populateTemplate($post);
322-
$email->populateTemplate(array(
323-
'UnsubscribeLink' => Director::absoluteBaseURL() . $post->Thread()->Forum()->Link() . '/unsubscribe/' . $post->ID
324-
));
325-
$email->send();
326-
}
327-
}
328-
}
329-
}
330-
}

src/PageTypes/ForumController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function markasspam(SS_HTTPRequest $request)
197197
// Suspend the member (rather than deleting him),
198198
// which gives him or a moderator the chance to revoke a decision.
199199
if ($author = $post->Author()) {
200-
$author->SuspendedUntil = date('Y-m-d', strtotime('+99 years', SS_Datetime::now()->Format('U')));
200+
$author->SuspendedUntil = date('Y-m-d', strtotime('+99 years', DBDatetime::now()->Format('U')));
201201
$author->write();
202202
}
203203

0 commit comments

Comments
 (0)