Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
8f685009
Commit
8f685009
authored
Dec 10, 2009
by
Sam Hemelryk
Browse files
forum MDL-21086 cleaned up boilderplates and php doc packages
parent
496e3ccd
Changes
29
Hide whitespace changes
Inline
Side-by-side
mod/forum/backuplib.php
View file @
8f685009
<?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:
//
...
...
mod/forum/db/access.php
View file @
8f685009
<?php
// This file is part of Moodle - http://moodle.org/
//
// 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>
// 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.
//
// Examples: mod/forum:viewpost
// block/recent_activity:view
// moodle/site:deleteuser
// 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.
//
// 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
(
...
...
mod/forum/db/install.php
View file @
8f685009
<?php
// This file replaces:
// * STATEMENTS section in db/install.xml
// * lib.php/modulename_install() post installation hook
// * partially defaults.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/>.
/**
* 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
()
{
global
$DB
;
...
...
mod/forum/db/messages.php
View file @
8f685009
<?php
///////////////////////////////////////////////////////////////////////////
// Defines message providers (types of messages being sent) //
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.org //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
// //
// 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 //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program 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: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
// 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/>.
/**
* Defines message providers (types of messages being sent)
*
* @package mod-forum
* @copyright 1999 onwards Martin Dougiamas http://moodle.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$messageproviders
=
array
(
...
...
mod/forum/db/upgrade.php
View file @
8f685009
<?php
// This file keeps track of upgrades to
// the forum module
// This file is part of Moodle - http://moodle.org/
//
// Sometimes, changes between versions involve
// alterations to database structures and other
// major things that may break installations.
// 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.
//
// The upgrade function in this file will attempt
// to perform all the necessary actions to upgrade
// your older installtion to the current 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.
//
// 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.
// 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 keeps track of upgrades to
* the forum module
*
* 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
)
{
global
$CFG
,
$DB
,
$OUTPUT
;
...
...
mod/forum/discuss.php
View file @
8f685009
<?php
// Displays a post, and all the posts below it.
// If no post is given, displays all posts in 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/>.
/**
* 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'
);
...
...
mod/forum/index.php
View file @
8f685009
<?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
(
$CFG
->
dirroot
.
'/course/lib.php'
);
require_once
(
$CFG
->
dirroot
.
'/mod/forum/lib.php'
);
...
...
mod/forum/lib.php
View file @
8f685009
...
...
@@ -16,7 +16,7 @@
// 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}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
...
...
@@ -7965,7 +7965,7 @@ function forum_get_extra_capabilities() {
}
/**
* @package
forum
* @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
*/
...
...
@@ -8501,12 +8501,35 @@ function forum_extend_settings_navigation($settingsnav, $module=null) {
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
{
/**
* The id of the forum this selector is being used for
* @var int
*/
protected
$forumid
=
null
;
/**
* The context of the forum this selector is being used for
* @var object
*/
protected
$context
=
null
;
/**
* The id of the current group
* @var int
*/
protected
$currentgroup
=
null
;
/**
* Constructor method
* @param string $name
* @param array $options
*/
public
function
__construct
(
$name
,
$options
)
{
parent
::
__construct
(
$name
,
$options
);
if
(
isset
(
$options
[
'context'
]))
{
...
...
@@ -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
()
{
global
$CFG
;
$options
=
parent
::
get_options
();
...
...
@@ -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
{
/**
* If set to true EVERYONE in this course is force subscribed to this forum
* @var bool
*/
protected
$forcesubscribed
=
false
;
/**
* Can be used to store existing subscribers so that they can be removed from
* the potential subscribers list
*/
protected
$existingsubscribers
=
array
();
/**
* Constructor method
* @param string $name
* @param array $options
*/
public
function
__construct
(
$name
,
$options
)
{
parent
::
__construct
(
$name
,
$options
);
if
(
isset
(
$options
[
'forcesubscribed'
]))
{
...
...
@@ -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
()
{
$options
=
parent
::
get_options
();
if
(
$this
->
forcesubscribed
===
true
)
{
...
...
@@ -8552,6 +8603,15 @@ class forum_potential_subscriber_selector extends forum_subscriber_selector_base
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
)
{
global
$DB
;
...
...
@@ -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
)
{
$this
->
existingsubscribers
=
$users
;
}
/**
* Sets this forum as force subscribed or not
*/
public
function
set_force_subscribed
(
$setting
=
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
{
/**
* Finds all subscribed users
*
* @param string $search
* @return array
*/
public
function
find_users
(
$search
)
{
global
$DB
;
list
(
$wherecondition
,
$params
)
=
$this
->
search_sql
(
$search
,
'u'
);
...
...
mod/forum/markposts.php
View file @
8f685009
<?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
(
"lib.php"
);
...
...
mod/forum/mod_form.php
View file @
8f685009
<?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'
);
class
mod_forum_mod_form
extends
moodleform_mod
{
...
...
mod/forum/post.php
View file @
8f685009
<?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
(
'lib.php'
);
...
...
mod/forum/post_form.php
View file @
8f685009
<?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
->
libdir
.
'/formslib.php'
);
class
mod_forum_post_form
extends
moodleform
{
...
...
mod/forum/rate.php
View file @
8f685009
<?php
// Collect ratings, store them, then return to where we came from
/// TODO: Centralise duplicate code in rate.php and rate_ajax.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/>.
/**
* Collect ratings, store them, then return to where we came from
*
* TODO: Centralise duplicate code in rate.php and rate_ajax.php
*
* @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
(
'lib.php'
);
...
...
@@ -23,7 +44,7 @@ if (!$cm = get_coursemodule_from_instance('forum', $forum->id)) {
print_error
(
'invalidcoursemodule'
);
}
else
{
$forum
->
cmidnumber
=
$cm
->
id
;
//MDL-12961
}
}
require_login
(
$course
,
false
,
$cm
);
...
...
mod/forum/rate_ajax.php
View file @
8f685009
<?php
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.org //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// 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 //