コード例 #1
0
 /**
  * Display subscribe options.
  * @param mod_forumng $forum Forum
  * @param string $text Textual note
  * @param int $subscribed
  * @param bool $button True if subscribe/unsubscribe button should be shown
  * @param bool $viewlink True if 'view subscribers' link should be shown
  * @return string HTML code for this area
  */
 public function render_subscribe_options($forum, $text, $subscribed, $button, $viewlink)
 {
     $out = '<div class="forumng-subscribe-options">' . '<h3>' . get_string('subscription', 'forumng') . '</h3>' . '<p>' . $text . '</p>';
     $cm = $forum->get_course_module();
     if ($button) {
         $outsubmit = '';
         $currentgroupid = mod_forumng::get_activity_group($cm, true);
         if ($currentgroupid == mod_forumng::NO_GROUPS) {
             $currentgroupid = 0;
         }
         if ($subscribed == mod_forumng::FULLY_SUBSCRIBED || $subscribed == mod_forumng::FULLY_SUBSCRIBED_GROUPMODE) {
             $outsubmit .= '<input type="submit" name="submitunsubscribe" value="' . get_string('unsubscribeshort', 'forumng') . '" />';
         } else {
             if ($subscribed == mod_forumng::PARTIALLY_SUBSCRIBED) {
                 // Print both subscribe button and unsubscribe button.
                 $outsubmit .= '<input type="submit" name="submitsubscribe" value="' . get_string('subscribelong', 'forumng') . '" />' . '<input type="submit" name="submitunsubscribe" value="' . get_string('unsubscribelong', 'forumng') . '" />';
             } else {
                 if ($subscribed == mod_forumng::NOT_SUBSCRIBED) {
                     // Default unsubscribed, print subscribe button.
                     $outsubmit .= '<input type="submit" name="submitsubscribe" value="' . get_string('subscribeshort', 'forumng') . '" />';
                 } else {
                     if ($subscribed == mod_forumng::THIS_GROUP_PARTIALLY_SUBSCRIBED) {
                         $outsubmit .= '<input type="submit" name="submitsubscribe_thisgroup" value="' . get_string('subscribegroup', 'forumng') . '" />' . '<input type="submit" name="submitunsubscribe_thisgroup" value="' . get_string('unsubscribegroup_partial', 'forumng') . '" />' . '<input type="hidden" name="g" value="' . $currentgroupid . '" />';
                     } else {
                         if ($subscribed == mod_forumng::THIS_GROUP_SUBSCRIBED) {
                             $outsubmit .= '<input type="submit" name="submitunsubscribe_thisgroup" value="' . get_string('unsubscribegroup', 'forumng') . '" />' . '<input type="hidden" name="g" value="' . $currentgroupid . '" />';
                         } else {
                             if ($subscribed == mod_forumng::THIS_GROUP_NOT_SUBSCRIBED) {
                                 $outsubmit .= '<input type="submit" name="submitsubscribe_thisgroup" value="' . get_string('subscribegroup', 'forumng') . '" />' . '<input type="hidden" name="g" value="' . $currentgroupid . '" />';
                             }
                         }
                     }
                 }
             }
         }
         $out .= '&nbsp;<form action="subscribe.php" method="post"><div>' . $forum->get_link_params(mod_forumng::PARAM_FORM) . '<input type="hidden" name="back" value="view" />' . $outsubmit . '</div></form>';
     }
     if ($subscribed != mod_forumng::NOT_SUBSCRIBED) {
         $out .= $this->render_subscribe_info($forum->get_context());
     }
     if ($viewlink) {
         $out .= ' <div class="forumng-subscribe-admin">' . '<a href="subscribers.php?' . $forum->get_link_params(mod_forumng::PARAM_HTML) . '">' . get_string('viewsubscribers', 'forumng') . '</a></div>';
     }
     $out .= '</div>';
     return $out;
 }
コード例 #2
0
 /**
  * Obtains the next forum from the list.
  * @param mod_forumng &$forum Forum (out variable)
  * @param object &$cm Course-module object (out variable)
  * @param object &$context Context object (out variable)
  * @param object &$course Course object (out variable)
  */
 function next_forum(&$forum, &$cm, &$context, &$course)
 {
     // Skip if required to get to new forum
     while ($this->forum != null) {
         $this->next_discussion($discussion);
     }
     // Get record
     if ($this->storedrecord) {
         $record = $this->storedrecord;
         $this->storedrecord = null;
     } else {
         if (!$this->rs) {
             // Already used entire list and closed recordset
             return false;
         } else {
             if (!$this->rs->valid()) {
                 // End of the line. Mark everything as mailed
                 $this->mark_mailed($this->time);
                 $this->rs->close();
                 $this->rs = null;
                 return false;
             }
             $record = $this->rs->current();
             $this->rs->next();
         }
     }
     // Set data
     $this->storedrecord = clone $record;
     $cm = mod_forumng_utils::extract_subobject($record, 'cm_');
     $course = mod_forumng_utils::extract_subobject($record, 'c_');
     context_helper::preload_from_record(mod_forumng_utils::extract_subobject($record, 'x_'));
     $context = context_module::instance($cm->id);
     $forum = new mod_forumng($course, $cm, $context, mod_forumng_utils::extract_subobject($record, 'f_'));
     if ($forum->is_shared()) {
         $forum->set_clone_reference($record->cloneid);
         $cm = $forum->get_course_module();
         $course = $forum->get_course();
         $context = $forum->get_context();
     }
     $this->forum = $forum;
     return true;
 }