Permalink
Browse files

MDL-28615 mod_forum: Fixed the users page that shows all of the users…

… posts
  • Loading branch information...
1 parent 690ef50 commit dbde930a58ac2b26f766d3802fa0233a795a3cda Sam Hemelryk committed Sep 8, 2011
Showing with 738 additions and 175 deletions.
  1. +56 −0 lib/enrollib.php
  2. +9 −1 mod/forum/lang/en/forum.php
  3. +403 −8 mod/forum/lib.php
  4. +269 −161 mod/forum/user.php
  5. +1 −5 user/view.php
View
@@ -261,6 +261,62 @@ function enrol_sharing_course($user1, $user2) {
return $DB->record_exists_sql($sql, $params);
}
+/**
+ * Returns any courses shared by the two users
+ *
+ * The courses has to be visible and enrolments has to be active,
+ * timestart and timeend restrictions are ignored.
+ *
+ * @param stdClass|int $user1
+ * @param stdClass|int $user2
+ * @return array An array of courses that both users are enrolled in
+ */
+function enrol_get_shared_courses($user1, $user2, $preloadcontexts = false) {
+ global $DB, $CFG;
+
+ $user1 = !empty($user1->id) ? $user1->id : $user1;
+ $user2 = !empty($user2->id) ? $user2->id : $user2;
+
+ if (empty($user1) or empty($user2)) {
+ return false;
+ }
+
+ if (!$plugins = explode(',', $CFG->enrol_plugins_enabled)) {
+ return false;
+ }
+
+ list($plugins, $params) = $DB->get_in_or_equal($plugins, SQL_PARAMS_NAMED, 'ee');
+ $params['enabled'] = ENROL_INSTANCE_ENABLED;
+ $params['active1'] = ENROL_USER_ACTIVE;
+ $params['active2'] = ENROL_USER_ACTIVE;
+ $params['user1'] = $user1;
+ $params['user2'] = $user2;
+
+ $ctxselect = '';
+ $ctxjoin = '';
+ if ($preloadcontexts) {
+ list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
+ }
+
+ $sql = "SELECT c.* $ctxselect
+ FROM {course} c
+ JOIN (
+ SELECT DISTINCT c.id
+ FROM {enrol} e
+ JOIN {user_enrolments} ue1 ON (ue1.enrolid = e.id AND ue1.status = :active1 AND ue1.userid = :user1)
+ JOIN {user_enrolments} ue2 ON (ue2.enrolid = e.id AND ue2.status = :active2 AND ue2.userid = :user2)
+ JOIN {course} c ON (c.id = e.courseid AND c.visible = 1)
+ WHERE e.status = :enabled AND e.enrol $plugins
+ ) ec ON ec.id = c.id
+ $ctxjoin";
+ $courses = $DB->get_records_sql($sql, $params);
+ if ($preloadcontexts) {
+ array_map('context_instance_preload', $courses);
+ }
+
+ return $courses;
+}
+
/**
* This function adds necessary enrol plugins UI into the course edit form.
*
@@ -73,6 +73,7 @@
$string['cannotunsubscribe'] = 'Could not unsubscribe you from that forum';
$string['cannotupdatepost'] = 'You can not update this post';
$string['cannotviewpostyet'] = 'You cannot read other students questions in this discussion yet because you haven\'t posted';
+$string['cannotviewusersposts'] = 'There are no posts made by this user that you are able to view.';
$string['cleanreadtime'] = 'Mark old posts as read hour';
$string['completiondiscussions'] = 'Student must create discussions:';
$string['completiondiscussionsgroup'] = 'Require discussions';
@@ -120,6 +121,7 @@
$string['discussions'] = 'Discussions';
$string['discussionsstartedby'] = 'Discussions started by {$a}';
$string['discussionsstartedbyrecent'] = 'Discussions recently started by {$a}';
+$string['discussionsstartedbyuserincourse'] = 'Discussions started by {$a->fullname} in {$a->coursename}';
$string['discussthistopic'] = 'Discuss this topic';
$string['displayend'] = 'Display end';
$string['displayend_help'] = 'This setting specifies whether a forum post should be hidden after a certain date. Note that administrators can always view forum posts.';
@@ -134,6 +136,7 @@
$string['emptymessage'] = 'Something was wrong with your post. Perhaps you left it blank, or the attachment was too big. Your changes have NOT been saved.';
$string['erroremptymessage'] = 'Post message cannot be empty';
$string['erroremptysubject'] = 'Post subject cannot be empty.';
+$string['errorenrolmentrequired'] = 'You must be enrolled in this course to access this content';
$string['errorwhiledelete'] = 'An error occurred while deleting record.';
$string['everyonecanchoose'] = 'Everyone can choose to be subscribed';
$string['everyonecannowchoose'] = 'Everyone can now choose to be subscribed';
@@ -238,7 +241,8 @@
$string['newforumposts'] = 'New forum posts';
$string['noattachments'] = 'There are no attachments to this post';
$string['nodiscussions'] = 'There are no discussion topics yet in this forum';
-$string['nodiscussionsstartedby'] = 'No discussions started by this user';
+$string['nodiscussionsstartedby'] = '{$a} has not started any discussions';
+$string['nodiscussionsstartedbyyou'] = 'You haven\'t started any discussions yet';
$string['noguestpost'] = 'Sorry, guests are not allowed to post.';
$string['noguesttracking'] = 'Sorry, guests are not allowed to set tracking options.';
$string['nomorepostscontaining'] = 'No more posts containing \'{$a}\' were found';
@@ -248,6 +252,8 @@
$string['nopermissiontoview'] = 'You do not have permissions to view this post';
$string['nopostforum'] = 'Sorry, you are not allowed to post to this forum';
$string['noposts'] = 'No posts';
+$string['nopostsmadebyuser'] = '{$a} has made no posts';
+$string['nopostsmadebyyou'] = 'You haven\'t made any posts';
$string['nopostscontaining'] = 'No posts containing \'{$a}\' were found';
$string['noquestions'] = 'There are no questions yet in this forum';
$string['nosubscribers'] = 'There are no subscribers yet for this forum';
@@ -289,6 +295,8 @@
$string['postrating2'] = 'Separate and connected';
$string['postrating3'] = 'Mostly connected knowing';
$string['posts'] = 'Posts';
+$string['postsmadebyuser'] = 'Posts made by {$a}';
+$string['postsmadebyuserincourse'] = 'Posts made by {$a->fullname} in {$a->coursename}';
$string['posttoforum'] = 'Post to forum';
$string['postupdated'] = 'Your post was updated';
$string['potentialsubscribers'] = 'Potential subscribers';
Oops, something went wrong.

0 comments on commit dbde930

Please sign in to comment.