Commit 8f685009 authored by Sam Hemelryk's avatar Sam Hemelryk
Browse files

forum MDL-21086 cleaned up boilderplates and php doc packages

parent 496e3ccd
<?php <?php
//This php script contains all the stuff to backup/restore
//forum mods // This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This php script contains all the stuff to backup/restore forum mods
*
* @package mod-forum
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
//This is the "graphical" structure of the forum mod: //This is the "graphical" structure of the forum mod:
// //
......
<?php <?php
// This file is part of Moodle - http://moodle.org/
// //
// Capability definitions for the forum module. // Moodle is free software: you can redistribute it and/or modify
// // it under the terms of the GNU General Public License as published by
// The capabilities are loaded into the database table when the module is // the Free Software Foundation, either version 3 of the License, or
// installed or updated. Whenever the capability definitions are updated, // (at your option) any later version.
// the module version number should be bumped up.
//
// The system has four possible values for a capability:
// CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT, and inherit (not set).
//
//
// CAPABILITY NAMING CONVENTION
//
// It is important that capability names are unique. The naming convention
// for capabilities that are specific to modules and blocks is as follows:
// [mod/block]/<plugin_name>:<capabilityname>
//
// component_name should be the same as the directory name of the mod or block.
//
// Core moodle capabilities are defined thus:
// moodle/<capabilityclass>:<capabilityname>
// //
// Examples: mod/forum:viewpost // Moodle is distributed in the hope that it will be useful,
// block/recent_activity:view // but WITHOUT ANY WARRANTY; without even the implied warranty of
// moodle/site:deleteuser // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// //
// The variable name for the capability definitions array is $capabilities // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Capability definitions for the forum module.
*
* The capabilities are loaded into the database table when the module is
* installed or updated. Whenever the capability definitions are updated,
* the module version number should be bumped up.
*
* The system has four possible values for a capability:
* CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT, and inherit (not set).
*
* CAPABILITY NAMING CONVENTION
*
* It is important that capability names are unique. The naming convention
* for capabilities that are specific to modules and blocks is as follows:
* [mod/block]/<plugin_name>:<capabilityname>
*
* component_name should be the same as the directory name of the mod or block.
*
* Core moodle capabilities are defined thus:
* moodle/<capabilityclass>:<capabilityname>
*
* Examples: mod/forum:viewpost
* block/recent_activity:view
* moodle/site:deleteuser
*
* The variable name for the capability definitions array is $capabilities
*
* @package mod-forum
* @copyright 2006 vyshane
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$capabilities = array( $capabilities = array(
......
<?php <?php
// This file replaces: // This file is part of Moodle - http://moodle.org/
// * STATEMENTS section in db/install.xml //
// * lib.php/modulename_install() post installation hook // Moodle is free software: you can redistribute it and/or modify
// * partially defaults.php // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file replaces:
* - STATEMENTS section in db/install.xml
* - lib.php/modulename_install() post installation hook
* - partially defaults.php
*
* @package mod-forum
* @copyright 2009 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function xmldb_forum_install() { function xmldb_forum_install() {
global $DB; global $DB;
......
<?php <?php
/////////////////////////////////////////////////////////////////////////// // This file is part of Moodle - http://moodle.org/
// Defines message providers (types of messages being sent) // //
/////////////////////////////////////////////////////////////////////////// // Moodle is free software: you can redistribute it and/or modify
// // // it under the terms of the GNU General Public License as published by
// NOTICE OF COPYRIGHT // // the Free Software Foundation, either version 3 of the License, or
// // // (at your option) any later version.
// Moodle - Modular Object-Oriented Dynamic Learning Environment // //
// http://moodle.org // // Moodle is distributed in the hope that it will be useful,
// // // but WITHOUT ANY WARRANTY; without even the implied warranty of
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// // // GNU General Public License for more details.
// This program is free software; you can redistribute it and/or modify // //
// it under the terms of the GNU General Public License as published by // // You should have received a copy of the GNU General Public License
// the Free Software Foundation; either version 2 of the License, or // // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// (at your option) any later version. //
// // /**
// This program is distributed in the hope that it will be useful, // * Defines message providers (types of messages being sent)
// but WITHOUT ANY WARRANTY; without even the implied warranty of // *
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // * @package mod-forum
// GNU General Public License for more details: // * @copyright 1999 onwards Martin Dougiamas http://moodle.com
// // * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
// http://www.gnu.org/copyleft/gpl.html // */
// //
///////////////////////////////////////////////////////////////////////////
$messageproviders = array ( $messageproviders = array (
......
<?php <?php
// This file keeps track of upgrades to // This file is part of Moodle - http://moodle.org/
// the forum module
// //
// Sometimes, changes between versions involve // Moodle is free software: you can redistribute it and/or modify
// alterations to database structures and other // it under the terms of the GNU General Public License as published by
// major things that may break installations. // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// The upgrade function in this file will attempt // Moodle is distributed in the hope that it will be useful,
// to perform all the necessary actions to upgrade // but WITHOUT ANY WARRANTY; without even the implied warranty of
// your older installtion to the current version. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// //
// If there's something it cannot do itself, it // You should have received a copy of the GNU General Public License
// will tell you what you need to do. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
//
// The commands in here will all be database-neutral, /**
// using the methods of database_manager class * This file keeps track of upgrades to
// * the forum module
// Please do not forget to use upgrade_set_timeout() *
// before any action that may take longer time to finish. * Sometimes, changes between versions involve
* alterations to database structures and other
* major things that may break installations.
*
* The upgrade function in this file will attempt
* to perform all the necessary actions to upgrade
* your older installtion to the current version.
*
* If there's something it cannot do itself, it
* will tell you what you need to do.
*
* The commands in here will all be database-neutral,
* using the methods of database_manager class
*
* Please do not forget to use upgrade_set_timeout()
* before any action that may take longer time to finish.
*
* @package mod-forum
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function xmldb_forum_upgrade($oldversion) { function xmldb_forum_upgrade($oldversion) {
global $CFG, $DB, $OUTPUT; global $CFG, $DB, $OUTPUT;
......
<?php <?php
// Displays a post, and all the posts below it. // This file is part of Moodle - http://moodle.org/
// If no post is given, displays all posts in a discussion //
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Displays a post, and all the posts below it.
* If no post is given, displays all posts in a discussion
*
* @package mod-forum
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../../config.php'); require_once('../../config.php');
......
<?php <?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @package mod-forum
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../config.php'); require_once(dirname(__FILE__) . '/../../config.php');
require_once($CFG->dirroot . '/course/lib.php'); require_once($CFG->dirroot . '/course/lib.php');
require_once($CFG->dirroot . '/mod/forum/lib.php'); require_once($CFG->dirroot . '/mod/forum/lib.php');
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/** /**
* @package forum * @package mod-forum
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
...@@ -7965,7 +7965,7 @@ function forum_get_extra_capabilities() { ...@@ -7965,7 +7965,7 @@ function forum_get_extra_capabilities() {
} }
/** /**
* @package forum * @package mod-forum
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
...@@ -8501,12 +8501,35 @@ function forum_extend_settings_navigation($settingsnav, $module=null) { ...@@ -8501,12 +8501,35 @@ function forum_extend_settings_navigation($settingsnav, $module=null) {
return $forumkey; return $forumkey;
} }
/**
* Abstract class used by forum subscriber selection controls
* @package mod-forum
* @copyright 2009 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class forum_subscriber_selector_base extends user_selector_base { abstract class forum_subscriber_selector_base extends user_selector_base {
/**
* The id of the forum this selector is being used for
* @var int
*/
protected $forumid = null; protected $forumid = null;
/**
* The context of the forum this selector is being used for
* @var object
*/
protected $context = null; protected $context = null;
/**
* The id of the current group
* @var int
*/
protected $currentgroup = null; protected $currentgroup = null;
/**
* Constructor method
* @param string $name
* @param array $options
*/
public function __construct($name, $options) { public function __construct($name, $options) {
parent::__construct($name, $options); parent::__construct($name, $options);
if (isset($options['context'])) { if (isset($options['context'])) {
...@@ -8520,6 +8543,11 @@ abstract class forum_subscriber_selector_base extends user_selector_base { ...@@ -8520,6 +8543,11 @@ abstract class forum_subscriber_selector_base extends user_selector_base {
} }
} }
/**
* Returns an array of options to seralise and store for searches
*
* @return array
*/
protected function get_options() { protected function get_options() {
global $CFG; global $CFG;
$options = parent::get_options(); $options = parent::get_options();
...@@ -8532,11 +8560,30 @@ abstract class forum_subscriber_selector_base extends user_selector_base { ...@@ -8532,11 +8560,30 @@ abstract class forum_subscriber_selector_base extends user_selector_base {
} }
/**
* A user selector control for potential subscribers to the selected forum
* @package mod-forum
* @copyright 2009 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class forum_potential_subscriber_selector extends forum_subscriber_selector_base { class forum_potential_subscriber_selector extends forum_subscriber_selector_base {
/**
* If set to true EVERYONE in this course is force subscribed to this forum
* @var bool
*/
protected $forcesubscribed = false; protected $forcesubscribed = false;
/**
* Can be used to store existing subscribers so that they can be removed from
* the potential subscribers list
*/
protected $existingsubscribers = array(); protected $existingsubscribers = array();
/**
* Constructor method
* @param string $name
* @param array $options
*/
public function __construct($name, $options) { public function __construct($name, $options) {
parent::__construct($name, $options); parent::__construct($name, $options);
if (isset($options['forcesubscribed'])) { if (isset($options['forcesubscribed'])) {
...@@ -8544,6 +8591,10 @@ class forum_potential_subscriber_selector extends forum_subscriber_selector_base ...@@ -8544,6 +8591,10 @@ class forum_potential_subscriber_selector extends forum_subscriber_selector_base
} }
} }
/**
* Returns an arary of options for this control
* @return array
*/
protected function get_options() { protected function get_options() {
$options = parent::get_options(); $options = parent::get_options();
if ($this->forcesubscribed===true) { if ($this->forcesubscribed===true) {
...@@ -8552,6 +8603,15 @@ class forum_potential_subscriber_selector extends forum_subscriber_selector_base ...@@ -8552,6 +8603,15 @@ class forum_potential_subscriber_selector extends forum_subscriber_selector_base
return $options; return $options;
} }
/**
* Finds all potential users
*
* Potential users are determined by checking for users with a capability
* determined in {@see forum_get_potential_subscribers()}
*
* @param string $search
* @return array
*/
public function find_users($search) { public function find_users($search) {
global $DB; global $DB;
...@@ -8586,17 +8646,36 @@ class forum_potential_subscriber_selector extends forum_subscriber_selector_base ...@@ -8586,17 +8646,36 @@ class forum_potential_subscriber_selector extends forum_subscriber_selector_base
} }
} }
/**
* Sets the existing subscribers
* @param array $users
*/
public function set_existing_subscribers(array $users) { public function set_existing_subscribers(array $users) {
$this->existingsubscribers = $users; $this->existingsubscribers = $users;
} }
/**
* Sets this forum as force subscribed or not
*/
public function set_force_subscribed($setting=true) { public function set_force_subscribed($setting=true) {
$this->forcesubscribed = true; $this->forcesubscribed = true;
} }
} }
/**
* User selector control for removing subscribed users
* @package mod-forum
* @copyright 2009 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class forum_existing_subscriber_selector extends forum_subscriber_selector_base { class forum_existing_subscriber_selector extends forum_subscriber_selector_base {
/**
* Finds all subscribed users
*
* @param string $search
* @return array
*/
public function find_users($search) { public function find_users($search) {
global $DB; global $DB;
list($wherecondition, $params) = $this->search_sql($search, 'u'); list($wherecondition, $params) = $this->search_sql($search, 'u');
......
<?php <?php
// Set tracking option for the forum. // This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Set tracking option for the forum.
*
* @package mod-forum
* @copyright 2005 mchurch
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once("../../config.php"); require_once("../../config.php");
require_once("lib.php"); require_once("lib.php");
......
<?php <?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @package mod-forum
* @copyright Jamie Pratt <me@jamiep.org>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once ($CFG->dirroot.'/course/moodleform_mod.php'); require_once ($CFG->dirroot.'/course/moodleform_mod.php');
class mod_forum_mod_form extends moodleform_mod { class mod_forum_mod_form extends moodleform_mod {
......
<?php <?php
// Edit and save a new post to a discussion // This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Edit and save a new post to a discussion
*
* @package mod-forum
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../../config.php'); require_once('../../config.php');