}
redirect("$CFG->wwwroot/user/edit.php?id=$user->id&course=$site->id");
-
+
} else { // List all users for editing
$stredituser = get_string("edituser");
$strshowallusers = get_string("showallusers");
if ($firstinitial or $lastinitial or $search or $page) {
- print_header("$site->shortname: $stredituser", $site->fullname,
+ print_header("$site->shortname: $stredituser", $site->fullname,
"<a href=\"index.php\">$stradministration</a> -> ".
"<a href=\"users.php\">$strusers</a> -> ".
"<a href=\"user.php\">$stredituser</a>");
} else {
- print_header("$site->shortname: $stredituser", $site->fullname,
+ print_header("$site->shortname: $stredituser", $site->fullname,
"<a href=\"index.php\">$stradministration</a> -> ".
"<a href=\"users.php\">$strusers</a> -> $stredituser");
}
echo "</center>";
print_paging_bar($usercount, $page, $perpage,
- "user.php?sort=$sort&dir=$dir&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial&search=$search&");
+ "user.php?sort=$sort&dir=$dir&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial&search=$search&");
flush();
if ($search) {
echo "<input type=\"button\" onclick=\"document.location='user.php';\" value=\"$strshowallusers\">";
}
- echo "</form>";
+ echo "</form>";
echo "</td></tr></table>";
print_heading("<a href=\"user.php?newuser=true\">".get_string("addnewuser")."</a>");
print_paging_bar($usercount, $page, $perpage,
"user.php?sort=$sort&dir=$dir&perpage=$perpage".
- "&firstinitial=$firstinitial&lastinitial=$lastinitial&search=$search&");
+ "&firstinitial=$firstinitial&lastinitial=$lastinitial&search=$search&");
}
$CFG->prefix.'user_teachers ut '.
'WHERE us.course='.$course->id.' AND gm.groupid='.$selectedgroup.
' AND (gm.userid=us.userid OR gm.userid=ut.userid) AND gm.userid=u.id';
- $courseusers = get_records_sql($sql);
+ $courseusers = get_records_sql($sql);
} else {
$courseusers = get_course_users($course->id, '', '', 'u.id, u.firstname, u.lastname');
}
}
}
-function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $perpage=100,
+function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $perpage=100,
$url="", $modname="", $modid=0, $modaction="", $groupid=0) {
// It is assumed that $date is the GMT time of midnight for that day,
$joins = array();
if ($course->category) {
- $joins[] = "l.course='$course->id'";
+ $joins[] = "l.course='$course->id'";
} else {
$courses[0] = '';
if ($ccc = get_courses("all", "c.id ASC", "c.id,c.shortname")) {
print_string("displayingrecords", "", $totalcount);
echo "</p>";
- print_paging_bar($totalcount, $page, $perpage, "$url&perpage=$perpage&");
+ print_paging_bar($totalcount, $page, $perpage, "$url&perpage=$perpage&");
echo '<table border="0" align="center" cellpadding="3" cellspacing="3">';
foreach ($logs as $log) {
}
echo '</table>';
- print_paging_bar($totalcount, $page, $perpage, "$url&perpage=$perpage&");
+ print_paging_bar($totalcount, $page, $perpage, "$url&perpage=$perpage&");
}
/**
* execute a given sql command string
-*
+*
* Completely general function - it just runs some SQL and reports success.
*
* @param type description
/// Completely general function - it just runs some SQL and reports success.
global $db;
-
+
$result = $db->Execute("$command");
if ($result) {
}
/**
* Run an arbitrary sequence of semicolon-delimited SQL commands
-*
-* Assumes that the input text (file or string) consists of
-* a number of SQL statements ENDING WITH SEMICOLONS. The
+*
+* Assumes that the input text (file or string) consists of
+* a number of SQL statements ENDING WITH SEMICOLONS. The
* semicolons MUST be the last character in a line.
* Lines that are blank or that start with "#" are ignored.
* Only tested with mysql dump files (mysqldump -p -d moodle)
global $CFG;
- $success = true; // Let's be optimistic
+ $success = true; // Let's be optimistic
if (!empty($sqlfile)) {
if (!is_readable($sqlfile)) {
$line = rtrim($line);
$length = strlen($line);
- if ($length and $line[0] <> "#") {
+ if ($length and $line[0] <> "#") {
if (substr($line, $length-1, 1) == ";") {
$line = substr($line, 0, $length-1); // strip ;
$command .= $line;
/**
* Add a new field to a table, or modify an existing one (if oldfield is defined).
-*
+*
* Add a new field to a table, or modify an existing one (if oldfield is defined).
*
* @param type description
//Check db-version
$dbinfo = $db->ServerInfo();
$dbver = substr($dbinfo['version'],0,3);
-
+
//to prevent conflicts with reserved words
$realfield = "\"$field\"";
$field = "\"${field}_alter_column_tmp\"";
case "integer":
if ($size <= 4) {
$type = "INT2";
- }
+ }
if ($size <= 10) {
$type = "INT";
}
execute_sql("ALTER TABLE {$CFG->prefix}$table ADD COLUMN $field $type");
//Add default values
execute_sql("UPDATE {$CFG->prefix}$table SET $field=$default");
-
+
if ($dbver >= "7.3") {
// modifying 'not null' is posible before 7.3
}
execute_sql("ALTER TABLE {$CFG->prefix}$table ALTER COLUMN $field SET DEFAULT $default");
-
+
if ( $oldfield != "\"\"" ) {
execute_sql("UPDATE {$CFG->prefix}$table SET $field = $oldfield");
execute_sql("ALTER TABLE {$CFG->prefix}$table drop column $oldfield");
}
- execute_sql("ALTER TABLE {$CFG->prefix}$table RENAME COLUMN $field TO $realfield");
-
+ execute_sql("ALTER TABLE {$CFG->prefix}$table RENAME COLUMN $field TO $realfield");
+
return execute_sql("COMMIT");
break;
/**
* Returns true or false depending on whether the specified record exists
-*
+*
* Returns true or false depending on whether the specified record exists
*
* @param type description
/**
* Returns true or false depending on whether the specified record exists
-*
+*
* The sql statement is provided as a string.
*
* @param type description
/**
* Get all the records and count them
-*
+*
* Get all the records and count them
*
* @param type description
/**
* Get all the records and count them
-*
+*
* Get all the records and count them
*
* @param type description
/**
* Get all the records and count them
-*
+*
* The sql statement is provided as a string.
*
* @param type description
/**
* Get a single record as an object
-*
+*
* Get a single record as an object
*
* @param string $table the name of the table to select from
* @return object(fieldset) a fieldset object containing the first record selected
*/
function get_record($table, $field1, $value1, $field2="", $value2="", $field3="", $value3="") {
-
+
global $CFG ;
$select = "WHERE $field1 = '$value1'";
/**
* Get a single record as an object
-*
+*
* The sql statement is provided as a string.
* A LIMIT is normally added to only look for 1 record
*
/**
* Gets one record from a table, as an object
-*
+*
* "select" is a fragment of SQL to define the selection criteria
*
* @param type description
/**
* Get a number of records as an array of objects
-*
+*
* Can optionally be sorted eg "time ASC" or "time DESC"
* If "fields" is specified, only those fields are returned
* The "key" is the first column returned, eg usually "id"
case "postgres7":
$limit = "LIMIT $limitnum OFFSET $limitfrom";
break;
- default:
+ default:
$limit = "LIMIT $limitnum,$limitfrom";
}
} else {
/**
* Get a number of records as an array of objects
-*
+*
* Can optionally be sorted eg "time ASC" or "time DESC"
* "select" is a fragment of SQL to define the selection criteria
* The "key" is the first column returned, eg usually "id"
case "postgres7":
$limit = "LIMIT $limitnum OFFSET $limitfrom";
break;
- default:
+ default:
$limit = "LIMIT $limitnum,$limitfrom";
}
} else {
/**
* Get a number of records as an array of objects
-*
-* Differs from get_records() in that the values variable
+*
+* Differs from get_records() in that the values variable
* can be a comma-separated list of values eg "4,5,6,10"
* Can optionally be sorted eg "time ASC" or "time DESC"
* The "key" is the first column returned, eg usually "id"
/**
* Get a number of records as an array of objects
-*
+*
* The "key" is the first column returned, eg usually "id"
* The sql statement is provided as a string.
*
}
return false;
}
-
+
if ( $rs->RecordCount() > 0 ) {
if ($records = $rs->GetAssoc(true)) {
foreach ($records as $key => $record) {
/**
* Get a number of records as an array of objects
-*
+*
* Can optionally be sorted eg "time ASC" or "time DESC"
* If "fields" is specified, only those fields are returned
* The "key" is the first column returned, eg usually "id"
-*
+*
* @param type description
*/
function get_records_menu($table, $field="", $value="", $sort="", $fields="*") {
/**
* Get a number of records as an array of objects
-*
+*
* Can optionally be sorted eg "time ASC" or "time DESC"
* "select" is a fragment of SQL to define the selection criteria
* Returns associative array of first two fields
-*
+*
* @param type description
*/
function get_records_select_menu($table, $select="", $sort="", $fields="*") {
/**
-* Given an SQL select, this function returns an associative
-*
-* array of the first two columns. This is most useful in
-* combination with the choose_from_menu function to create
+* Given an SQL select, this function returns an associative
+*
+* array of the first two columns. This is most useful in
+* combination with the choose_from_menu function to create
* a form menu.
*
* @param type description
$rs->MoveNext();
}
return $menu;
-
+
} else {
return false;
}
/**
* Get a single field from a database record
-*
+*
* longdesc
*
* @param type description
/**
* Get a single field from a database record
-*
+*
* longdesc
*
* @param type description
/**
* Set a single field in a database record
-*
+*
* longdesc
*
* @param type description
/**
* Delete one or more records from a table
-*
+*
* Delete one or more records from a table
*
* @param type description
/**
* Delete one or more records from a table
-*
+*
* "select" is a fragment of SQL to define the selection criteria
*
* @param type description
/**
* Insert a record into a table and return the "id" field if required
-*
+*
* If the return ID isn't required, then this just reports success as true/false.
* $dataobject is an object containing needed data
*
* @param type description
*/
function insert_record($table, $dataobject, $returnid=true, $primarykey='id') {
-
+
global $db, $CFG;
/// Execute a dummy query to get an empty recordset
if (!$rs = $db->Execute("SELECT * FROM $CFG->prefix$table WHERE $primarykey ='-1'")) {
return false;
}
-
+
/// Get the correct SQL from adoDB
if (!$insertSQL = $db->GetInsertSQL($rs, (array)$dataobject, true)) {
return false;
}
-
+
/// Run the SQL statement
if (!$rs = $db->Execute($insertSQL)) {
if (isset($CFG->debug) and $CFG->debug > 7) {
}
return false;
}
-
+
/// If a return ID is not needed then just return true now
- if (!$returnid) {
+ if (!$returnid) {
return true;
}
}
return false;
- default:
+ default:
return $db->Insert_ID(); // Should work on most databases, but not all!
}
}
/**
* Update a record in a table
-*
+*
* $dataobject is an object containing needed data
-* Relies on $dataobject having a variable "id" to
+* Relies on $dataobject having a variable "id" to
* specify the record to update
*
* @param type description
/// USER DATABASE ////////////////////////////////////////////////
/**
-* Get a complete user record, which includes all the info
-*
+* Get a complete user record, which includes all the info
+*
* in the user record, as well as membership information
* Suitable for setting as $USER session cookie.
*
/**
* Does this username and password specify a valid admin user?
-*
+*
* longdesc
*
* @param type description
global $CFG;
- return record_exists_sql("SELECT u.id
- FROM {$CFG->prefix}user u,
- {$CFG->prefix}user_admins a
- WHERE u.id = a.userid
- AND u.username = '$username'
+ return record_exists_sql("SELECT u.id
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}user_admins a
+ WHERE u.id = a.userid
+ AND u.username = '$username'
AND u.password = '$md5password'");
}
/**
* Get the guest user information from the database
-*
+*
* longdesc
*
* @param type description
/**
* Returns $user object of the main admin user
-*
+*
* longdesc
*
* @param type description
if ( $admins = get_admins() ) {
foreach ($admins as $admin) {
- return $admin; // ie the first one
+ return $admin; // ie the first one
}
} else {
return false;
/**
* Returns list of all admins
-*
+*
* longdesc
*
* @param type description
global $CFG;
- return get_records_sql("SELECT u.*, a.id as adminid
- FROM {$CFG->prefix}user u,
+ return get_records_sql("SELECT u.*, a.id as adminid
+ FROM {$CFG->prefix}user u,
{$CFG->prefix}user_admins a
WHERE a.userid = u.id
ORDER BY a.id ASC");
/**
* Returns list of all creators
-*
+*
* longdesc
*
* @param type description
/**
* Returns $user object of the main teacher for a course
-*
+*
* longdesc
*
* @param type description
/**
* Searches logs to find all enrolments since a certain date
-*
+*
* used to print recent activity
*
* @param type description
FROM {$CFG->prefix}user u,
{$CFG->prefix}user_students s,
{$CFG->prefix}log l
- WHERE l.time > '$timestart'
+ WHERE l.time > '$timestart'
AND l.course = '$courseid'
- AND l.module = 'course'
+ AND l.module = 'course'
AND l.action = 'enrol'
AND l.info = u.id
AND u.id = s.userid
/**
* Returns array of userinfo of all students in this course
* or on this site if courseid is id of site
-*
+*
* @param type description
*/
function get_course_students($courseid, $sort="s.timeaccess", $dir="", $page=0, $recordsperpage=99999,
$firstinitial="", $lastinitial="", $group=NULL, $search="", $fields='', $exceptions='') {
global $CFG;
-
- if ($courseid == SITEID and $CFG->allusersaresitestudents) {
+
+ if ($courseid == SITEID and $CFG->allusersaresitestudents) {
// return users with confirmed, undeleted accounts who are not site teachers
// the following is a mess because of different conventions in the different user functions
$sort = str_replace('s.timeaccess', 'lastaccess', $sort); // site users can't be sorted by timeaccess
$sort = str_replace('timeaccess', 'lastaccess', $sort); // site users can't be sorted by timeaccess
$sort = str_replace('u.', '', $sort); // the get_user function doesn't use the u. prefix to fields
- $fields = str_replace('u.', '', $fields);
+ $fields = str_replace('u.', '', $fields);
if ($sort) {
$sort = "$sort $dir";
}
}
$exceptions = ltrim($exceptions, ',');
}
- return get_users(true, $search, true, $exceptions, $sort, $firstinitial, $lastinitial,
+ return get_users(true, $search, true, $exceptions, $sort, $firstinitial, $lastinitial,
$page, $recordsperpage, $fields ? $fields : '*');
}
$limit = "LIMIT $recordsperpage OFFSET ".($page);
$LIKE = "ILIKE";
break;
- default:
+ default:
$fullname = " firstname||\" \"||lastname ";
$limit = "LIMIT $recordsperpage,$page";
$LIKE = "ILIKE";
$groupmembers = ", {$CFG->prefix}groups_members gm ";
$select .= " AND u.id = gm.userid AND gm.groupid = '$group'";
}
-
+
if (!empty($exceptions)) {
$select .= " AND u.id NOT IN ($exceptions)";
}
if ($courseid != SITEID) {
return $students;
}
-
+
// We are here because we need the students for the site.
// These also include teachers on real courses minus those on the site
if ($teachers = get_records('user_teachers', 'course', SITEID)) {
/**
* Counts the students in a given course (or site), or a subset of them
-*
+*
* @param type description
*/
function count_course_students($course, $search="", $firstinitial="", $lastinitial="", $group=NULL, $exceptions='') {
/**
-* Returns list of all teachers in this course
+* Returns list of all teachers in this course
* (also works for site)
-*
+*
* @param type description
*/
function get_course_teachers($courseid, $sort="t.authority ASC", $exceptions='') {
}
return get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat, u.maildigest,
- u.email, u.city, u.country, u.lastlogin, u.picture, u.lang, u.timezone,
+ u.email, u.city, u.country, u.lastlogin, u.picture, u.lang, u.timezone,
u.emailstop, t.authority,t.role,t.editall,t.timeaccess as lastaccess
- FROM {$CFG->prefix}user u,
+ FROM {$CFG->prefix}user u,
{$CFG->prefix}user_teachers t
- WHERE t.course = '$courseid' AND t.userid = u.id
+ WHERE t.course = '$courseid' AND t.userid = u.id
AND u.deleted = '0' AND u.confirmed = '1' $except
ORDER BY $sort");
}
$fullname = " u.firstname||' '||u.lastname ";
$LIKE = "ILIKE";
break;
- default:
+ default:
$fullname = " u.firstname||\" \"||u.lastname ";
$LIKE = "ILIKE";
}
-
+
if (!empty($exceptions)) {
$except = " AND u.id NOT IN ($exceptions) ";
} else {
} else {
$order = '';
}
-
+
$select = "u.deleted = '0' AND u.confirmed = '1'";
if (!$courseid or $courseid == SITEID) {
WHERE $select
AND ($fullname $LIKE '%$searchtext%' OR u.email $LIKE '%$searchtext%')
$except $order");
- } else {
+ } else {
if ($groupid) {
return get_records_sql("SELECT u.id, u.firstname, u.lastname, u.email
- FROM {$CFG->prefix}user u,
+ FROM {$CFG->prefix}user u,
{$CFG->prefix}groups_members g
WHERE $select AND g.groupid = '$groupid' AND g.userid = u.id
AND ($fullname $LIKE '%$searchtext%' OR u.email $LIKE '%$searchtext%')
$except $order");
} else {
if (!$teachers = get_records_sql("SELECT u.id, u.firstname, u.lastname, u.email
- FROM {$CFG->prefix}user u,
+ FROM {$CFG->prefix}user u,
{$CFG->prefix}user_teachers s
WHERE $select AND s.course = '$courseid' AND s.userid = u.id
AND ($fullname $LIKE '%$searchtext%' OR u.email $LIKE '%$searchtext%')
$teachers = array();
}
if (!$students = get_records_sql("SELECT u.id, u.firstname, u.lastname, u.email
- FROM {$CFG->prefix}user u,
+ FROM {$CFG->prefix}user u,
{$CFG->prefix}user_students s
WHERE $select AND s.course = '$courseid' AND s.userid = u.id
AND ($fullname $LIKE '%$searchtext%' OR u.email $LIKE '%$searchtext%')
/**
-* Returns a subset of users
-*
+* Returns a subset of users
+*
* longdesc
*
* @param bookean $get if false then only a count of the records is returned
$fullname = " firstname||' '||lastname ";
$LIKE = "ILIKE";
break;
- default:
+ default:
$limit = "LIMIT $recordsperpage,$page";
$fullname = " firstname||\" \"||lastname ";
$LIKE = "ILIKE";
if ($firstinitial) {
$select .= " AND firstname $LIKE '$firstinitial%'";
- }
+ }
if ($lastinitial) {
$select .= " AND lastname $LIKE '$lastinitial%'";
- }
+ }
if ($sort and $get) {
$sort = " ORDER BY $sort ";
/**
* shortdesc
-*
+*
* longdesc
*
* @param type description
$fullname = " firstname||' '||lastname ";
$LIKE = "ILIKE";
break;
- default:
+ default:
$limit = "LIMIT $recordsperpage,$page";
$fullname = " firstname||' '||lastname ";
$LIKE = "LIKE";
/// warning: will return UNCONFIRMED USERS
return get_records_sql("SELECT id, username, email, firstname, lastname, city, country, lastaccess, confirmed
- FROM {$CFG->prefix}user
+ FROM {$CFG->prefix}user
WHERE $select $sort $limit ");
}
/**
* shortdesc
-*
+*
* longdesc
*
* @param type description
*/
function get_users_confirmed() {
global $CFG;
- return get_records_sql("SELECT *
- FROM {$CFG->prefix}user
- WHERE confirmed = 1
+ return get_records_sql("SELECT *
+ FROM {$CFG->prefix}user
+ WHERE confirmed = 1
AND deleted = 0
- AND username <> 'guest'
+ AND username <> 'guest'
AND username <> 'changeme'");
}
/**
* shortdesc
-*
+*
* longdesc
*
* @param type description
*/
function get_users_unconfirmed($cutofftime=2000000000) {
global $CFG;
- return get_records_sql("SELECT *
- FROM {$CFG->prefix}user
+ return get_records_sql("SELECT *
+ FROM {$CFG->prefix}user
WHERE confirmed = 0
- AND firstaccess > 0
+ AND firstaccess > 0
AND firstaccess < '$cutofftime'");
}
/**
* shortdesc
-*
+*
* longdesc
*
* @param type description
global $CFG;
return get_records_sql("SELECT DISTINCT *
FROM {$CFG->prefix}user_students
- WHERE timeaccess > '0'
+ WHERE timeaccess > '0'
AND timeaccess < '$cutofftime' ");
}
/**
* Returns an array of group objects that the user is a member of
-* in the given course. If userid isn't specified, then return a
+* in the given course. If userid isn't specified, then return a
* list of all groups in the course.
-*
+*
* @param type description
*/
function get_groups($courseid, $userid=0) {
/**
* Returns an array of user objects
-*
+*
* @param type description
*/
function get_group_users($groupid, $sort="u.lastaccess DESC", $exceptions='') {
}
return get_records_sql("SELECT DISTINCT u.*
FROM {$CFG->prefix}user u,
- {$CFG->prefix}groups_members m
+ {$CFG->prefix}groups_members m
WHERE m.groupid = '$groupid'
AND m.userid = u.id $except
ORDER BY $sort");
/**
* An efficient way of finding all the users who aren't in groups yet
-*
+*
* @param type description
*/
function get_users_not_in_group($courseid) {
/**
* Returns an array of user objects
-*
+*
* @param type description
*/
function get_group_students($groupid, $sort="u.lastaccess DESC") {
{$CFG->prefix}groups g,
{$CFG->prefix}user_students s
WHERE m.groupid = '$groupid'
- AND m.userid = u.id
- AND m.groupid = g.id
+ AND m.userid = u.id
+ AND m.groupid = g.id
AND g.courseid = s.course
AND s.userid = u.id
ORDER BY $sort");
/**
* Returns the user's group in a particular course
-*
+*
* @param type description
*/
function user_group($courseid, $userid) {
/**
* Returns $course object of the top-level site.
-*
+*
* Returns $course object of the top-level site.
*
* @param type description
/**
* Returns list of courses, for whole site, or category
-*
+*
* Returns list of courses, for whole site, or category
*
* @param type description
/**
* Returns list of courses, for whole site, or category
-*
+*
* Similar to get_courses, but allows paging
*
* @param type description
*/
-function get_courses_page($categoryid="all", $sort="c.sortorder ASC", $fields="c.*",
+function get_courses_page($categoryid="all", $sort="c.sortorder ASC", $fields="c.*",
&$totalcount, $limitfrom="", $limitnum="") {
global $USER, $CFG;
case "postgres7":
$limit = "LIMIT $limitnum OFFSET $limitfrom";
break;
- default:
+ default:
$limit = "LIMIT $limitnum,$limitfrom";
}
} else {
/**
* shortdesc
-*
+*
* longdesc
*
* @param type description
// The following is correct but VERY slow with large datasets
//
-// return get_records_sql("SELECT c.*
-// FROM {$CFG->prefix}course c,
-// {$CFG->prefix}user_students s,
-// {$CFG->prefix}user_teachers t
+// return get_records_sql("SELECT c.*
+// FROM {$CFG->prefix}course c,
+// {$CFG->prefix}user_students s,
+// {$CFG->prefix}user_teachers t
// WHERE (s.userid = '$userid' AND s.course = c.id)
// OR (t.userid = '$userid' AND t.course = c.id)
-// GROUP BY c.id
+// GROUP BY c.id
// ORDER BY $sort");
}
/**
* Returns a list of courses that match a search
-*
+*
* Returns a list of courses that match a search
*
* @param type description
case "postgres7":
$limit = "LIMIT $recordsperpage OFFSET ".($page * $recordsperpage);
break;
- default:
+ default:
$limit = "LIMIT $recordsperpage,$page";
}
$totalcount = count_records_sql("SELECT COUNT(*) FROM $selectsql");
- $courses = get_records_sql("SELECT * FROM $selectsql ORDER BY $sort $limit");
+ $courses = get_records_sql("SELECT * FROM $selectsql ORDER BY $sort $limit");
if ($courses) { /// Remove unavailable courses from the list
foreach ($courses as $key => $course) {
/**
* Returns a sorted list of categories
-*
+*
* Returns a sorted list of categories
*
* @param type description
* @param type description
*/
function fix_course_sortorder($categoryid=0, $n=0) {
-
+
$count = 0;
if ($courses = get_courses($categoryid)) {
foreach ($courses as $course) {
}
}
set_field("course_categories", "coursecount", $count, "id", $categoryid);
-
+
if ($categories = get_categories($categoryid)) {
foreach ($categories as $category) {
$n = fix_course_sortorder($category->id, $n);
}
}
-
+
return $n;
}
/**
* This function creates a default separated/connected scale
-*
+*
* This function creates a default separated/connected scale
-* so there's something in the database. The locations of
-* strings and files is a bit odd, but this is because we
+* so there's something in the database. The locations of
+* strings and files is a bit odd, but this is because we
* need to maintain backward compatibility with many different
* existing language translations and older sites.
*
get_string("postrating3", "forum");
$defaultscale->timemodified = time();
- /// Read in the big description from the file. Note this is not
+ /// Read in the big description from the file. Note this is not
/// HTML (despite the file extension) but Moodle format text.
$parentlang = get_string("parentlang");
if (is_readable("$CFG->dirroot/lang/$CFG->lang/help/forum/ratings.html")) {
/**
* Returns a menu of all available scales from the site as well as the given course
-*
+*
* Returns a menu of all available scales from the site as well as the given course
*
* @param type description
function get_scales_menu($courseid=0) {
global $CFG;
-
- $sql = "SELECT id, name FROM {$CFG->prefix}scale
- WHERE courseid = '0' or courseid = '$courseid'
+
+ $sql = "SELECT id, name FROM {$CFG->prefix}scale
+ WHERE courseid = '0' or courseid = '$courseid'
ORDER BY courseid ASC, name ASC";
if ($scales = get_records_sql_menu("$sql")) {
/**
* Just gets a raw list of all modules in a course
-*
+*
* Just gets a raw list of all modules in a course
*
* @param type description
global $CFG;
return get_records_sql("SELECT cm.*, m.name as modname
- FROM {$CFG->prefix}modules m,
+ FROM {$CFG->prefix}modules m,
{$CFG->prefix}course_modules cm
- WHERE cm.course = '$courseid'
+ WHERE cm.course = '$courseid'
AND cm.deleted = '0'
AND cm.module = m.id ");
}
/**
* Given an instance of a module, finds the coursemodule description
-*
+*
* Given an instance of a module, finds the coursemodule description
*
* @param type description
global $CFG;
return get_record_sql("SELECT cm.*, m.name
- FROM {$CFG->prefix}course_modules cm,
- {$CFG->prefix}modules md,
- {$CFG->prefix}$modulename m
- WHERE cm.course = '$courseid' AND
+ FROM {$CFG->prefix}course_modules cm,
+ {$CFG->prefix}modules md,
+ {$CFG->prefix}$modulename m
+ WHERE cm.course = '$courseid' AND
cm.deleted = '0' AND
- cm.instance = m.id AND
- md.name = '$modulename' AND
+ cm.instance = m.id AND
+ md.name = '$modulename' AND
md.id = cm.module AND
m.id = '$instance'");
/**
* Returns an array of all the active instances of a particular module in a given course, sorted in the order they are defined
-*
+*
* Returns an array of all the active instances of a particular
* module in a given course, sorted in the order they are defined
* in the course. Returns false on any errors.
}
if (!$rawmods = get_records_sql("SELECT cm.id as coursemodule, m.*,cw.section,cm.visible as visible,cm.groupmode
- FROM {$CFG->prefix}course_modules cm,
- {$CFG->prefix}course_sections cw,
- {$CFG->prefix}modules md,
- {$CFG->prefix}$modulename m
- WHERE cm.course = '$course->id' AND
- cm.instance = m.id AND
+ FROM {$CFG->prefix}course_modules cm,
+ {$CFG->prefix}course_sections cw,
+ {$CFG->prefix}modules md,
+ {$CFG->prefix}$modulename m
+ WHERE cm.course = '$course->id' AND
+ cm.instance = m.id AND
cm.deleted = '0' AND
- cm.section = cw.id AND
- md.name = '$modulename' AND
+ cm.section = cw.id AND
+ md.name = '$modulename' AND
md.id = cm.module")) {
return array();
}
/**
* determine whether a module instance is visible within a course
-*
-* Given a valid module object with info about the id and course,
-* and the module's type (eg "forum") returns whether the object
+*
+* Given a valid module object with info about the id and course,
+* and the module's type (eg "forum") returns whether the object
* is visible or not
*
* @param type description
FROM {$CFG->prefix}course_modules cm,
{$CFG->prefix}modules m
WHERE cm.course = '$module->course' AND
- cm.module = m.id AND
- m.name = '$moduletype' AND
- cm.instance = '$module->id'")) {
+ cm.module = m.id AND
+ m.name = '$moduletype' AND
+ cm.instance = '$module->id'")) {
foreach ($records as $record) { // there should only be one - use the first one
return $record->visible;
/**
* Add an entry to the log table.
-*
+*
* Add an entry to the log table. These are "action" focussed rather
-* than web server hits, and provide a way to easily reconstruct what
+* than web server hits, and provide a way to easily reconstruct what
* any particular student has been doing.
*
* @param int $course the course id
* @param string $module the module name - e.g. forum, journal, resource, course, user etc
* @param string $action view, edit, post (often but not always the same as the file.php)
* @param string $url the file and parameters used to see the results of the action
-* @param string $info additional description information
+* @param string $info additional description information
* @param string $cm the course_module->id if there is one
* @param string $user if log regards $user other than $USER
*/
$timenow = time();
$info = addslashes($info);
+ $url = html_entity_decode($url); // for php < 4.3.0 this is defined in moodlelib.php
$result = $db->Execute("INSERT INTO {$CFG->prefix}log (time, userid, course, ip, module, cmid, action, url, info)
VALUES ('$timenow', '$userid', '$courseid', '$REMOTE_ADDR', '$module', '$cm', '$action', '$url', '$info')");
if (!$result and ($CFG->debug > 7)) {
echo "<p>Error: Could not insert a new entry to the Moodle log</p>"; // Don't throw an error
- }
+ }
if (!$user and isset($USER->id)) {
if ($courseid == SITEID) {
- $db->Execute("UPDATE {$CFG->prefix}user SET lastIP='$REMOTE_ADDR', lastaccess='$timenow'
+ $db->Execute("UPDATE {$CFG->prefix}user SET lastIP='$REMOTE_ADDR', lastaccess='$timenow'
WHERE id = '$USER->id' ");
} else if (isstudent($courseid)) {
$db->Execute("UPDATE {$CFG->prefix}user_students SET timeaccess = '$timenow' ".
$db->Execute("UPDATE {$CFG->prefix}user_teachers SET timeaccess = '$timenow' ".
"WHERE course = '$courseid' AND userid = '$userid'");
}
- }
+ }
}
/**
* select all log records based on SQL criteria
-*
+*
* select all log records based on SQL criteria
-*
+*
* @param string $select SQL select criteria
* @param string $order SQL order by clause to sort the records returned
*/
case "postgres7":
$limit = "LIMIT $limitnum OFFSET $limitfrom";
break;
- default:
+ default:
$limit = "LIMIT $limitnum,$limitfrom";
}
} else {
$selectsql = "{$CFG->prefix}log l LEFT JOIN {$CFG->prefix}user u ON l.userid = u.id ".((strlen($select) > 0) ? "WHERE $select" : "");
$totalcount = count_records_sql("SELECT COUNT(*) FROM $selectsql");
- return get_records_sql("SELECT l.*, u.firstname, u.lastname, u.picture
- FROM $selectsql $order $limit");
+ return get_records_sql("SELECT l.*, u.firstname, u.lastname, u.picture
+ FROM $selectsql $order $limit");
}
/**
* select all log records for a given course and user
-*
+*
* select all log records for a given course and user
*
* @param type description
$courseselect = '';
}
- return get_records_sql("SELECT floor((`time` - $coursestart)/86400) as day, count(*) as num
- FROM {$CFG->prefix}log
- WHERE userid = '$userid'
+ return get_records_sql("SELECT floor((`time` - $coursestart)/86400) as day, count(*) as num
+ FROM {$CFG->prefix}log
+ WHERE userid = '$userid'
AND `time` > '$coursestart' $courseselect
GROUP BY day ");
}
/**
* select all log records for a given course, user, and day
-*
+*
* select all log records for a given course, user, and day
*
* @param type description
return get_records_sql("SELECT floor((`time` - $daystart)/3600) as hour, count(*) as num
FROM {$CFG->prefix}log
- WHERE userid = '$userid'
+ WHERE userid = '$userid'
AND `time` > '$daystart' $courseselect
GROUP BY hour ");
}
/**
* Returns an object with counts of failed login attempts
*
- * Returns information about failed login attempts. If the current user is
- * an admin, then two numbers are returned: the number of attempts and the
+ * Returns information about failed login attempts. If the current user is
+ * an admin, then two numbers are returned: the number of attempts and the
* number of accounts. For non-admins, only the attempts on the given user
* are shown.
*
/**
* dump a given object's information in a PRE block
-*
+*
* dump a given object's information in a PRE block
* Mostly just for debugging
*
var value = params[field];
switch(field) {
case "url" : upper.document.getElementById('f_url').value = value;
- upper.ipreview.location.replace('popups/preview.php?id='+ <?php print($course->id);?> +'&imageurl='+ value);
+ upper.ipreview.location.replace('popups/preview.php?id='+ <?php print($course->id);?> +'&imageurl='+ value);
break;
case "isize" : upper.document.getElementById('isize').value = value; break;
case "itype" : upper.document.getElementById('itype').value = value; break;
case "upload":
html_header($course, $wdir);
require_once($CFG->dirroot.'/lib/uploadlib.php');
-
+
if (!empty($save)) {
$um = new upload_manager('userfile',false,false,$course,false,0);
$dir = "$basedir$wdir";
if (!$course = get_record("course", "id", $id)) {
$course->fullname = ""; // Just to keep display happy, though browsing may fail
}
-
+
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title><?php print_string("insertimage","editor");?></title>
<script language="javascript" type="text/javascript" src="popup.js"></script>
<script language="javascript" type="text/javascript">
+<!--
var preview_window = null;
function Init() {
document.getElementById("f_horiz").value = param["f_horiz"] != -1 ? param["f_horiz"] : 0;
document.getElementById("f_width").value = param["f_width"];
document.getElementById("f_height").value = param["f_height"];
- window.ipreview.location.replace('preview.php?id='+ <?php print($course->id);?> +'&imageurl='+ param.f_url);
+ window.ipreview.location.replace('preview.php?id='+ <?php print($course->id);?> +'&imageurl='+ param.f_url);
}
document.getElementById("f_url").focus();
};
alert("Nothing to do!");
el.focus();
return false;
- }
+ }
}
function submit_form(dothis) {
if(dothis == "zip") {
window.ibrowser.document.dirform.action.value = "zip";
}
-
+
window.ibrowser.document.dirform.submit();
return false;
}
-
+//-->
</script>
<style type="text/css">
html, body {
<tr>
<td width="15%" align="right"><?php print_string("imageurl","editor");?>:</td>
<td width="60%"><input name="f_url" type="text" id="f_url" style="width: 100%;" /></td>
- <td width="23%" align="center">
+ <td width="23%" align="center">
<button name="btnOK" type="button" id="btnOK" onclick="return onOK();"><?php print_string("ok","editor") ?></button></td>
</tr>
<tr>
<td align="right"><?php print_string("alternatetext","editor");?>:</td>
<td><input name="f_alt" type="text" id="f_alt" style="width: 100%;" /></td>
- <td align="center">
+ <td align="center">
<button name="btnCancel" type="button" id="btnCancel" onclick="return onCancel();"><?php print_string("cancel","editor") ?></button></td>
</tr>
</table>
</table></form>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
- <td width="55%" valign="top"><?php
+ <td width="55%" valign="top"><?php
if(isteacher($id)) {
print_string("filebrowser","editor");
} else {
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
- <tr>
+ <tr>
<td width="55%"><div class="space"></div>
<?php if(isteacher($id)) { ?>
<table border="0" cellpadding="2" cellspacing="0">
<input name="btnRename" type="submit" id="btnRename" value="<?php print_string("rename","editor");?>" /></form></td>
<tr></table>
<br />
- <?php
+ <?php
} else {
print "";
} ?>
<legend><?php print_string("properties","editor");?></legend>
<div class="space"></div>
<div class="space"></div>
- <?php print_string("size","editor");?>:
+ <?php print_string("size","editor");?>:
<input type="text" id="isize" name="isize" size="10" style="background: transparent; border: none;" />
<?php print_string("type","editor");?>: <input type="text" id="itype" name="itype" size="10" style="background: transparent; border: none;" />
<div class="space"></div>
<div class="space"></div>
</fieldset></td>
</tr>
- <tr>
+ <tr>
<td height="22"><?php
if(isteacher($id)) { ?>
<form name="cfolder" id="cfolder" action="../coursefiles.php" method="post" target="ibrowser">
<input type="file" name="userfile" id="userfile" size="35" />
<input name="save" type="submit" id="save" onclick="return checkvalue('userfile','uploader');" value="<?php print_string("upload","editor");?>" />
</form>
- <?php
+ <?php
} else {
print "";
} ?>
return (record_exists('user_students', 'userid', $userid)
or record_exists('user_teachers', 'userid', $userid));
}
- }
+ }
if (!$userid) {
return !empty($USER->student[$courseid]);
} else {
$auth = $user->auth;
}
-
+
if (!file_exists("$CFG->dirroot/auth/$auth/lib.php")) {
$auth = "manual"; // Can't find auth module, default to internal
}
$student->timeend = $timeend;
$student->time = time();
return update_record("user_students", $student);
-
+
} else {
$student->userid = $userid;
$student->course = $courseid;
$teacher->authority = 1;
}
delete_records("user_students", "userid", $userid, "course", $courseid); // Unenrol as student
-
+
/// Add forum subscriptions for new users
require_once('../mod/forum/lib.php');
forum_add_user($userid, $courseid);
if (!record_exists("user_admins", "userid", $userid)) {
if (record_exists("user", "id", $userid)) {
$admin->userid = $userid;
-
+
// any admin is also a teacher on the site course
if (!record_exists('user_teachers', 'course', SITEID, 'userid', $userid)) {
if (!add_teacher($userid, SITEID)) {
return false;
}
}
-
+
return insert_record("user_admins", $admin);
}
return false;
function remove_course_userdata($courseid, $showfeedback=true,
$removestudents=true, $removeteachers=false, $removegroups=true,
$removeevents=true, $removelogs=false) {
-/// This function will empty a course of USER data as much as
-/// possible. It will retain the activities and the structure
+/// This function will empty a course of USER data as much as
+/// possible. It will retain the activities and the structure
/// of the course.
global $CFG, $THEME, $USER, $SESSION;
$mail->AddCustomHeader($from->customheaders);
}
}
-
+
if ($messagehtml) {
$mail->IsHTML(true);
$mail->Encoding = "quoted-printable"; // Encoding to use
function email_is_not_allowed($email) {
-/// Check that an email is allowed. It returns an error message if there
+/// Check that an email is allowed. It returns an error message if there
/// was a problem.
global $CFG;
$recip = get_admins();
break;
}
-
+
if (empty($CFG->lastnotifyfailure)) {
$CFG->lastnotifyfailure=0;
}
-
- // we need to deal with the threshold stuff first.
+
+ // we need to deal with the threshold stuff first.
if (empty($CFG->notifyloginthreshold)) {
$CFG->notifyloginthreshold = 10; // default to something sensible.
}
- $notifyipsrs = $db->Execute("SELECT ip FROM {$CFG->prefix}log WHERE time > {$CFG->lastnotifyfailure}
+ $notifyipsrs = $db->Execute("SELECT ip FROM {$CFG->prefix}log WHERE time > {$CFG->lastnotifyfailure}
AND module='login' AND action='error' GROUP BY ip HAVING count(*) > $CFG->notifyloginthreshold");
- $notifyusersrs = $db->Execute("SELECT info FROM {$CFG->prefix}log WHERE time > {$CFG->lastnotifyfailure}
+ $notifyusersrs = $db->Execute("SELECT info FROM {$CFG->prefix}log WHERE time > {$CFG->lastnotifyfailure}
AND module='login' AND action='error' GROUP BY info HAVING count(*) > $CFG->notifyloginthreshold");
-
+
if ($notifyipsrs) {
$ipstr = '';
while ($row = $notifyipsrs->FetchRow()) {
$logs = get_logs("time > {$CFG->lastnotifyfailure} AND module='login' AND action='error' "
.((strlen($ipstr) > 0 && strlen($userstr) > 0) ? " AND ( ip IN ($ipstr) OR info IN ($userstr) ) "
: ((strlen($ipstr) != 0) ? " AND ip IN ($ipstr) " : " AND info IN ($userstr) ")),"l.time DESC","","",$count);
-
+
// if we haven't run in the last hour and we have something useful to report and we are actually supposed to be reporting to somebody
- if (is_array($recip) and count($recip) > 0 and ((time() - (60 * 60)) > $CFG->lastnotifyfailure)
+ if (is_array($recip) and count($recip) > 0 and ((time() - (60 * 60)) > $CFG->lastnotifyfailure)
and is_array($logs) and count($logs) > 0) {
-
+
$message = '';
$site = get_site();
$subject = get_string('notifyloginfailuressubject','',$site->fullname);
}
function mtrace($string, $eol="\n") {
-// For outputting debugging info
+// For outputting debugging info
if (defined('STDOUT')) {
fwrite(STDOUT, $string.$eol);
return $ip;
}
+if(!function_exists('html_entity_decode')) {
+// html_entity_decode is only supported by php 4.3.0 and higher
+// so if it is not predefined, define it here
+ function html_entity_decode($string) {
+ $trans_tbl = get_html_translation_table(HTML_ENTITIES);
+ $trans_tbl = array_flip($trans_tbl);
+ return strtr($string, $trans_tbl);
+ }
+}
+
// vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
?>
}
$startoutput = '<form action="" method="get" target="'.$CFG->framename.'" name="'.$formname.'">';
- $output = "<select name=\"popup\" onchange=\"$targetwindow.location=document.$formname.popup.options[document.$formname.popup.selectedIndex].value\">\n";
+ $output = "<select name=\"popup\" onchange=\"$targetwindow.location=document.$formname.popup.options[document.$formname.popup.selectedIndex].value;\">\n";
if ($nothing != "") {
$output .= " <option value=\"javascript:void(0)\">$nothing</option>\n";
}
if ($usexml) { // Added by Gustav Delius / Mad Alex for MathML output
+ // Modified by Julian Sedding
$currentlanguage = current_language();
-
- @header("Content-type: application/xhtml+xml");
- echo "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n";
+ $mathplayer = preg_match("/MathPlayer/i", $_SERVER['HTTP_USER_AGENT']);
+ if(!$mathplayer) {
+ header('Content-Type: application/xhtml+xml');
+ }
+ echo "<?xml version=\"1.0\" ?>\n";
if (!empty($CFG->xml_stylesheets)) {
$stylesheets = explode(";", $CFG->xml_stylesheets);
foreach ($stylesheets as $stylesheet) {
echo " plus $CFG->xml_doctype_extra";
}
echo "//" . strtoupper($currentlanguage) . "\" \"$CFG->xml_dtd\">\n";
- $direction = " xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"$currentlanguage\" $direction";
+ $direction = " xmlns=\"http://www.w3.org/1999/xhtml\"
+ xmlns:math=\"http://www.w3.org/1998/Math/MathML\"
+ xml:lang=\"en\"
+ xmlns:xlink=\"http://www.w3.org/1999/xlink\"
+ $direction";
+ if($mathplayer) {
+ $meta .= '<object id="mathplayer" classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987">' . "\n";
+ $meta .= "<!--comment required to prevent this becoming an empty tag-->\n";
+ $meta .= "</object>\n";
+ $meta .= '<?import namespace="math" implementation="#mathplayer" ?>' . "\n";
+ }
}
$title = str_replace('"', '"', $title);
function redirect($url, $message="", $delay="0") {
// Redirects the user to another page, after printing a notice
+ // '&' needs to be encoded into '&' for XHTML compliance,
+ // however, this is not true for javascript. Therefore we
+ // first decode all entities in $url (since we cannot rely on)
+ // the correct input) and then encode for where it's needed
+ // echo "<script type='text/javascript'>alert('Redirect $url');</script>";
+ $url = html_entity_decode($url); // for php < 4.3.0 this is defined in moodlelib.php
+ $encodedurl = htmlentities($url);
if (empty($message)) {
- echo "<meta http-equiv=\"refresh\" content=\"$delay; url=$url\" />";
- echo "<script type=\"text/javascript\">location.replace('$url');</script>"; // To cope with Mozilla bug
+ echo "<meta http-equiv=\"refresh\" content=\"$delay; url=$encodedurl\" />";
+ echo "<script type=\"text/javascript\">\n<!--\nlocation.replace('$url');\n//-->\n</script>"; // To cope with Mozilla bug
} else {
if (empty($delay)) {
$delay = 3; // There's no point having a message with no delay
}
- print_header("", "", "", "", "<meta http-equiv=\"refresh\" content=\"$delay; url=$url\" />");
+ print_header("", "", "", "", "<meta http-equiv=\"refresh\" content=\"$delay; url=$encodedurl\" />");
echo "<center>";
echo "<p>$message</p>";
- echo "<p>( <a href=\"$url\">".get_string("continue")."</a> )</p>";
+ echo "<p>( <a href=\"$encodedurl\">".get_string("continue")."</a> )</p>";
echo "</center>";
flush();
sleep($delay);
- echo "<script type=\"text/javascript\">location.replace('$url');</script>"; // To cope with Mozilla bug
+ echo "<script type=\"text/javascript\">\n<!--\nlocation.replace('$url');\n//-->\n</script>"; // To cope with Mozilla bug
}
die;
}
continue;
}
- if(!ereg('win=(chat|users|message|beep).*&chat_sid=([a-zA-Z0-9]*)&groupid=([0-9]*) HTTP', $data, $info)) {
+ if(!ereg('win=(chat|users|message|beep).*&chat_sid=([a-zA-Z0-9]*)&groupid=([0-9]*) HTTP', $data, $info)) {
// Malformed data
$DAEMON->trace('UFO with '.$handle.': Request with malformed data; connection closed', E_USER_WARNING);
$DAEMON->dismiss_ufo($handle, true, 'Request with malformed data; connection closed');
if ($arsc_my = arsc_getdatafromsid($arsc_sid))
{
include("../shared/language/".$arsc_my["language"].".inc.php");
-
+
$arsc_user = $arsc_my["user"];
$arsc_room = $arsc_my["room"];
if ($arsc_lastid == "")
$arsc_b = mysql_fetch_array($arsc_result);
$arsc_lastid = $arsc_b["timeid"];
}
-
+
if ($arsc_my["level"] < 0)
{
switch($arsc_my["level"])
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-Type: text/html");
- header("Refresh: 4; url=chatmsg.php?arsc_sid=".$arsc_sid."&arsc_lastid=".$arsc_lastid."&dummy=".time()."#end");
+ header("Refresh: 4; url=chatmsg.php?arsc_sid=".$arsc_sid."&arsc_lastid=".$arsc_lastid."&dummy=".time()."#end");
echo $arsc_parameters["htmlhead"];
-
+
set_magic_quotes_runtime(0);
$arsc_sendtime = date("H:i:s");
$arsc_timeid = arsc_microtime();
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-Type: text/html");
-header("Refresh: $CFG->chat_refresh_room; url=jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&groupid=$groupid");
+header("Refresh: $CFG->chat_refresh_room; url=jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&groupid=$groupid");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
$beep = false;
if ($chat_lasttime) {
- if ($messages = get_records_select("chat_messages",
- "chatid = '$chatuser->chatid' AND timestamp > '$chat_lasttime' $groupselect",
+ if ($messages = get_records_select("chat_messages",
+ "chatid = '$chatuser->chatid' AND timestamp > '$chat_lasttime' $groupselect",
"timestamp ASC")) {
foreach ($messages as $message) {
$formatmessage = chat_format_message($message, $chat->course);
$message->message = "enter";
$message->system = 1;
$message->timestamp = time();
-
+
if (!insert_record("chat_messages", $message)) {
error("Could not insert a chat message!");
}
$message->message = "beep $beep";
$message->system = 0;
$message->timestamp = time();
-
+
if (!insert_record("chat_messages", $message)) {
error("Could not insert a chat message!");
}
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-Type: text/html");
-header("Refresh: $CFG->chat_refresh_userlist; url=users.php?chat_sid=$chat_sid&groupid=$groupid");
+header("Refresh: $CFG->chat_refresh_userlist; url=users.php?chat_sid=$chat_sid&groupid=$groupid");
print_header();
require_login($course->id);
}
- if (!empty($move)) {
+ if (!empty($move)) {
if (!isteacher($course->id)) {
error("Only teachers can do that!");
}
if ($course->category) {
print_header("$course->shortname: $discussion->name", "$course->fullname",
"<a href=../../course/view.php?id=$course->id>$course->shortname</a> ->
- $navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm), false);
+ $navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm));
} else {
print_header("$course->shortname: $discussion->name", "$course->fullname",
- "$navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm), false);
+ "$navmiddle -> $navtail", "", "", true, $searchform, navmenu($course, $cm));
}
}
if (!empty($forummenu)) {
echo "<div align=\"right\">";
- echo popup_form("$CFG->wwwroot/mod/forum/", $forummenu, "forummenu", "",
+ echo popup_form("$CFG->wwwroot/mod/forum/", $forummenu, "forummenu", "",
get_string("movethisdiscussionto", "forum"), "", "", true);
echo "</div>";
}
}
- // Parse and organise all the forums. Most forums are course modules but
- // some special ones are not. These get placed in the general forums
+ // Parse and organise all the forums. Most forums are course modules but
+ // some special ones are not. These get placed in the general forums
// category with the forums in section 0.
$generalforums = array(); // For now
unset($learningforums[$forum->keyreference]);
}
break;
- case "teacher":
+ case "teacher":
if (isteacher($course->id)) {
$forum->visible = true;
$generalforums[] = $forum;
if (isset($forum->keyreference)) {
unset($learningforums[$forum->keyreference]);
}
- }
+ }
break;
}
}
} else {
$groupmode = NOGROUPS;
}
-
+
if ($groupmode == SEPARATEGROUPS and !isteacheredit($course->id)) {
$count = count_records_select("forum_discussions", "forum = '$forum->id' AND (groupid = '$currentgroup' OR groupid = '-1')");
} else {
$count = count_records("forum_discussions", "forum", "$forum->id");
}
-
+
$forum->intro = forum_shorten_post($forum->intro);
replace_smilies($forum->intro);
$forum->intro = "<span style=\"font-size:x-small;\">$forum->intro</span>";;
$generaltable->data[] = array ($forumlink, "$forum->intro", "$count");
}
}
- }
+ }
// Start of the table for Learning Forums
// Add extra field for section number, at the front
array_unshift($learningtable->head, "");
array_unshift($learningtable->align, "center");
-
+
if ($learningforums) {
$currentsection = "";
foreach ($learningforums as $key => $forum) {
$groupmode = groupmode($course, $forum); /// Can do this because forum->groupmode is defined
-
+
if ($groupmode == SEPARATEGROUPS and !isteacheredit($course->id)) {
$count = count_records("forum_discussions", "forum", "$forum->id", "groupid", $currentgroup);
} else {
$count = count_records("forum_discussions", "forum", "$forum->id");
}
-
+
$forum->intro = forum_shorten_post($forum->intro);
replace_smilies($forum->intro);
$forum->intro = "<span style=\"font-size:x-small;\">$forum->intro</span>";
-
+
if ($forum->section != $currentsection) {
$printsection = $forum->section;
if ($currentsection) {
} else {
$forumlink = "<a class=\"dimmed\" href=\"view.php?f=$forum->id\">$forum->name</a>";
}
-
+
if ($can_subscribe) {
if (forum_is_forcesubscribed($forum->id)) {
$sublink = get_string("yes");
"<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> -> $strforums",
"", "", true, $searchform, navmenu($course));
} else {
- print_header("$course->shortname: $strforums", "$course->fullname", "$strforums",
+ print_header("$course->shortname: $strforums", "$course->fullname", "$strforums",
"", "", true, $searchform, navmenu($course));
}
error("Could not add the discussion for this forum");
}
}
-
+
if ($forum->forcesubscribe == FORUM_INITIALSUBSCRIBE) { // all users should be subscribed initially
$users = get_course_users($forum->course);
foreach ($users as $user) {
"List-id: <moodlecourse{$post->course}@$hostname>",
"Message-Id: <moodlepost{$post->id}@$hostname>",
"In-Reply-To: <moodlepost{$post->parent}@$hostname>",
- "References: <moodlepost{$post->parent}@$hostname>"
+ "References: <moodlepost{$post->parent}@$hostname>"
);
$posttext = forum_make_mail_text($course, $forum, $discussion, $post, $userfrom, $userto);
$posthtml = forum_make_mail_html($course, $forum, $discussion, $post, $userfrom, $userto);
- if (!$mailresult = email_to_user($userto, $userfrom, $postsubject, $posttext,
+ if (!$mailresult = email_to_user($userto, $userfrom, $postsubject, $posttext,
$posthtml, '', '', $CFG->forum_replytouser)) {
mtrace("Error: mod/forum/cron.php: Could not send out mail for id $post->id to user $userto->id".
" ($userto->email) .. not trying again.");
- add_to_log($course->id, 'forum', 'mail error', "discuss.php?d=$discussion->id#$post->id",
+ add_to_log($course->id, 'forum', 'mail error', "discuss.php?d=$discussion->id#$post->id",
substr($post->subject,0,30), $cm->id, $userto->id);
$errorcount++;
} else if ($mailresult === 'emailstop') {
- add_to_log($course->id, 'forum', 'mail blocked', "discuss.php?d=$discussion->id#$post->id",
+ add_to_log($course->id, 'forum', 'mail blocked', "discuss.php?d=$discussion->id#$post->id",
substr($post->subject,0,30), $cm->id, $userto->id);
} else {
$mailcount++;
/// Now see if there are any digest mails waiting to be sent, and if we should send them
- if (!isset($CFG->digestmailtimelast)) { // To catch the first time
+ if (!isset($CFG->digestmailtimelast)) { // To catch the first time
set_config('digestmailtimelast', 0);
}
}
$posthtml .= '</body>';
- if (!$mailresult = email_to_user($userto, $site->shortname, $postsubject, $posttext, $posthtml,
+ if (!$mailresult = email_to_user($userto, $site->shortname, $postsubject, $posttext, $posthtml,
'', '', $CFG->forum_replytouser)) {
mtrace("ERROR!");
echo "Error: mod/forum/cron.php: Could not send out digest mail to user $userto->id ($userto->email)... not trying again.\n";
$userselect = "";
}
-
+
if ($visiblegroups == -1) {
$groupselect = "";
} else {
if ($courseid == SITEID) {
$forum->name = get_string("sitenews");
$forum->forcesubscribe = 0;
- }
+ }
break;
case "social":
$forum->name = addslashes(get_string("namesocial", "forum"));
function forum_print_discussion_header(&$post, $forum, $datestring="") {
/// This function prints the overview of a discussion in the forum listing.
/// It needs some discussion information and some post information, these
-/// happen to be combined for efficiency in the $post parameter by the function
+/// happen to be combined for efficiency in the $post parameter by the function
/// that calls this one
/// forum_print_latest_discussions()
$groupmode = SEPARATEGROUPS;
}
}
-
+
if (forum_user_can_post_discussion($forum, $currentgroup)) {
echo "<p align=\"center\">";
WHERE p.modified > '$sincetime' $forumselect
AND p.userid = u.id $userselect
AND d.course = '$courseid'
- AND p.discussion = d.id
+ AND p.discussion = d.id
AND cm.instance = f.id
AND cm.course = d.course
AND cm.course = f.course
$post->id = $post->edit;
$message = '';
if (forum_update_post($post,$message)) {
-
- add_to_log($post->course, "forum", "update post",
+
+ add_to_log($post->course, "forum", "update post",
"discuss.php?d=$post->discussion&parent=$post->id", "$post->id", $cm->id);
$timemessage = 2;
$timemessage = 4;
}
$message .= '<br />'.get_string("postupdated", "forum");
-
+
if ($subscribemessage = forum_post_subscription($post)) {
$timemessage = 4;
}
redirect(forum_go_back_to("discuss.php?d=$post->discussion#$post->id"), $message.$subscribemessage, $timemessage);
} else {
- error(get_string("couldnotupdate", "forum"), $errordestination);
+ error(get_string("couldnotupdate", "forum"), $errordestination);
}
exit;
$message = '';
if ($post->id = forum_add_new_post($post,$message)) {
- add_to_log($post->course, "forum", "add post",
+ add_to_log($post->course, "forum", "add post",
"discuss.php?d=$post->discussion&parent=$post->id", "$post->id", $cm->id);
$timemessage = 2;
redirect(forum_go_back_to("discuss.php?d=$post->discussion#$post->id"), $message.$subscribemessage, $timemessage);
} else {
- error(get_string("couldnotadd", "forum"), $errordestination);
+ error(get_string("couldnotadd", "forum"), $errordestination);
}
exit;
$message = '';
if ($discussion->id = forum_add_discussion($discussion,$message)) {
- add_to_log($post->course, "forum", "add discussion",
+ add_to_log($post->course, "forum", "add discussion",
"discuss.php?d=$discussion->id", "$discussion->id", $cm->id);
$timemessage = 2;
$timemessage = 4;
}
$message .= '<br />'.get_string("postadded", "forum", format_time($CFG->maxeditingtime));
-
+
if ($subscribemessage = forum_post_subscription($discussion)) {
$timemessage = 4;
}
redirect(forum_go_back_to("view.php?f=$post->forum"), $message.$subscribemessage, $timemessage);
} else {
- error(get_string("couldnotadd", "forum"), $errordestination);
+ error(get_string("couldnotadd", "forum"), $errordestination);
}
exit;
}
if (isset($confirm)) { // User has confirmed the delete
if ($post->totalscore) {
- notice(get_string("couldnotdeleteratings", "forum"),
+ notice(get_string("couldnotdeleteratings", "forum"),
forum_go_back_to("discuss.php?d=$post->discussion"));
} else if (record_exists("forum_posts", "parent", $delete)) {
}
if (! $post->parent) { // post is a discussion topic as well, so delete discussion
if ($forum->type == "single") {
- notice("Sorry, but you are not allowed to delete that discussion!",
+ notice("Sorry, but you are not allowed to delete that discussion!",
forum_go_back_to("discuss.php?d=$post->discussion"));
}
forum_delete_discussion($discussion);
- add_to_log($discussion->course, "forum", "delete discussion",
+ add_to_log($discussion->course, "forum", "delete discussion",
"view.php?id=$cm->id", "$forum->id", $cm->id);
- redirect("view.php?f=$discussion->forum",
+ redirect("view.php?f=$discussion->forum",
get_string("deleteddiscussion", "forum"), 1);
} else if (forum_delete_post($post)) {
- add_to_log($discussion->course, "forum", "delete post",
+ add_to_log($discussion->course, "forum", "delete post",
"discuss.php?d=$post->discussion", "$post->id", $cm->id);
- redirect(forum_go_back_to("discuss.php?d=$post->discussion"),
+ redirect(forum_go_back_to("discuss.php?d=$post->discussion"),
get_string("deletedpost", "forum"), 1);
} else {
error("An error occurred while deleting record $post->id");
forum_set_return();
print_header();
- notice_yesno(get_string("deletesure", "forum"),
+ notice_yesno(get_string("deletesure", "forum"),
"post.php?delete=$delete&confirm=$delete",
$_SERVER["HTTP_REFERER"]);
-
+
echo "<center><hr />";
forum_print_post($post, $forum->course, $ownpost=false, $reply=false, $link=false);
echo "</center>";
} else if (isset($prune)) { // Teacher is pruning
-
+
if (! $post = forum_get_post_full($prune)) {
error("Post ID was incorrect");
}
}
if (isset($_REQUEST['name'])) { // User has confirmed the prune
-
+
$newdiscussion->course = $discussion->course;
$newdiscussion->forum = $discussion->forum;
$newdiscussion->name = $name;
$newdiscussion->groupid = $discussion->groupid;
$newdiscussion->assessed = $discussion->assessed;
$newdiscussion->usermodified = $post->userid;
-
+
if (!$newid = insert_record('forum_discussions', $newdiscussion)) {
error('Could not create new discussion');
}
-
+
$newpost->id = $post->id;
$newpost->parent = 0;
$newpost->subject = $name;
}
forum_change_discussionid($post->id, $newid);
-
+
// set timemodified to time of last post in each discussion
$lastpost = get_record_sql("SELECT MAX(modified) AS time
- FROM {$CFG->prefix}forum_posts
+ FROM {$CFG->prefix}forum_posts
WHERE discussion = '$discussion->id'");
set_field('forum_discussions', 'timemodified', $lastpost->time, 'id', $discussion->id);
$lastpost = get_record_sql("SELECT MAX(modified) AS time
- FROM {$CFG->prefix}forum_posts
+ FROM {$CFG->prefix}forum_posts
WHERE discussion = '$newid'");
- set_field('forum_discussions', 'timemodified', $lastpost->time, 'id', $newid);
+ set_field('forum_discussions', 'timemodified', $lastpost->time, 'id', $newid);
if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $forum->course)) { // For the logs
$cm->id = 0;
}
- add_to_log($discussion->course, "forum", "prune post",
+ add_to_log($discussion->course, "forum", "prune post",
"discuss.php?d=$newid", "$post->id", $cm->id);
redirect(forum_go_back_to("discuss.php?d=$newid"), get_string("prunedpost", "forum"), 1);
$course = get_record('course', 'id', $forum->course);
$strforums = get_string("modulenameplural", "forum");
print_header_simple("$discussion->name: $post->subject", "",
- "<a href=\"../forum/index.php?id=$course->id\">$strforums</a> ->
- <a href=\"view.php?f=$forum->id\">$forum->name</a> ->
+ "<a href=\"../forum/index.php?id=$course->id\">$strforums</a> ->
+ <a href=\"view.php?f=$forum->id\">$forum->name</a> ->
<a href=\"discuss.php?d=$discussion->id\">$post->subject</a> -> ".
get_string("prune", "forum"), '', "", true, "", navmenu($course, $cm));
-
+
print_heading(get_string('pruneheading', 'forum'));
echo '<center>';
-
+
include('prune.html');
-
+
forum_print_post($post, $forum->course, $ownpost=false, $reply=false, $link=false);
echo '</center>';
}
}
- // To get here they need to edit a post, and the $post
+ // To get here they need to edit a post, and the $post
// variable will be loaded with all the particulars,
// so bring up the form.
//This is the "graphical" structure of the forum mod:
//
- // forum
+ // forum
// (CL,pk->id)
// |
- // -----------------------------------
+ // -----------------------------------
// | |
// subscriptions forum_discussions
// (UL,pk->id, fk->forum) (UL,pk->id, fk->forum)
// |
// |
// forum_posts
- // (UL,pk->id,fk->discussion,nt->parent,files)
+ // (UL,pk->id,fk->discussion,nt->parent,files)
// |
// |
// |
$forum->scale = -($scale->new_id);
}
}
-
+
$forumtobeinserted = true;
//If the forum is a teacher forum, then we have to look if it exists in destination course
if ($forum->type == "teacher") {
if ($user) {
$post->userid = $user->new_id;
}
-
+
//The structure is equal to the db, so insert the forum_posts
$newid = insert_record ("forum_posts",$post);
//First, locate course's moddata directory
$moddata_path = $CFG->dataroot."/".$restore->course_id."/".$CFG->moddata;
-
+
//Check it exists and create it
$status = check_dir_exists($moddata_path,true);
//This function returns a log record with all the necessay transformations
//done. It's used by restore_log_module() to restore modules log.
function forum_restore_logs($restore,$log) {
-
+
$status = false;
-
+
//Depending of the action, we recode different things
switch ($log->action) {
case "add":
$status = true;
}
}
- }
+ }
break;
case "delete post":
if ($log->cmid) {
}
//Return a content decoded to support interactivities linking. Every module
- //should have its own. They are called automatically from
+ //should have its own. They are called automatically from
//forum_decode_content_links_caller() function in each module
//in the restore process
function forum_decode_content_links ($content,$restore) {
//If it is a link to this course, update the link to its new location
if($rec->new_id && $rec2->new_id) {
//Now replace it
- $result= preg_replace($searchstring,$CFG->wwwroot.'/mod/forum/discuss.php?d='.$rec->new_id.'&parent='.$rec2->new_id,$result);
+ $result= preg_replace($searchstring,$CFG->wwwroot.'/mod/forum/discuss.php?d='.$rec->new_id.'&parent='.$rec2->new_id,$result);
} else {
//It's a foreign link so leave it as original
- $result= preg_replace($searchstring,$restore->original_wwwroot.'/mod/forum/discuss.php?d='.$old_id.'&parent='.$old_id2,$result);
+ $result= preg_replace($searchstring,$restore->original_wwwroot.'/mod/forum/discuss.php?d='.$old_id.'&parent='.$old_id2,$result);
}
}
}
$status = true;
echo "<ul>";
-
+
//FORUM: Decode every POST (message) in the coure
-
+
//Check we are restoring forums
if ($restore->mods['forum']->restore == 1) {
echo "<li>".get_string("from")." ".get_string("modulenameplural","forum");
$i = 0; //Counter to send some output to the browser to avoid timeouts
foreach ($posts as $post) {
//Increment counter
- $i++;
+ $i++;
$content = $post->message;
$result = forum_decode_content_links($content,$restore);
if ($result != $content) {
function forum_rss_newstuff($forum, $time) {
// If there is new stuff in the forum since $time then this returns
// true. Otherwise it returns false.
- if ($forum->rsstype == 1) {
+ if ($forum->rsstype == 1) {
$items = forum_rss_feed_discussions($forum, $time);
- } else {
+ } else {
$items = forum_rss_feed_posts($forum, $time);
}
return (!empty($items));
if (empty($CFG->enablerssfeeds)) {
//Some debug...
if ($CFG->debug > 7) {
- echo "DISABLED (admin variables)";
- }
+ echo "DISABLED (admin variables)";
+ }
//Check CFG->forum_enablerssfeeds
} else if (empty($CFG->forum_enablerssfeeds)) {
- //Some debug...
+ //Some debug...
if ($CFG->debug > 7) {
echo "DISABLED (module configuration)";
- }
+ }
//It's working so we start...
} else {
//Check the forum has rss activated
$items = forum_rss_feed_discussions($forum);
} else { //Post RSS
$items = forum_rss_feed_posts($forum);
-
+
}
//Now, if items, we begin building the structure
if (!empty($items)) {
$status = $header.$articles.$footer;
} else {
$status = false;
- }
+ }
} else {
$status = false;
}
$newsince = "";
}
- if ($recs = get_records_sql ("SELECT d.id discussionid,
- d.name discussionname,
- u.id userid,
+ if ($recs = get_records_sql ("SELECT d.id discussionid,
+ d.name discussionname,
+ u.id userid,
u.firstname userfirstname,
u.lastname userlastname,
p.message postmessage,
}
return $items;
}
-
+
//This function returns "items" record array to be used to build the rss feed
//for a Type=posts forum
function forum_rss_feed_posts($forum, $newsince=0) {
$user->lastname = $rec->userlastname;
$item->author = fullname($user);
$item->pubdate = $rec->postcreated;
- $item->link = $CFG->wwwroot."/mod/forum/discuss.php?d=".$rec->discussionid."&parent=".$rec->postid;
+ $item->link = $CFG->wwwroot."/mod/forum/discuss.php?d=".$rec->discussionid."&parent=".$rec->postid;
$item->description = format_text($rec->postmessage,$rec->postformat,NULL,$forum->course);
$items[] = $item;
$articlesleft--;
require_login($course->id);
}
- add_to_log($course->id, "forum", "search", "search.php?id=$course->id&search=".urlencode($search), $search);
+ add_to_log($course->id, "forum", "search", "search.php?id=$course->id&search=".urlencode($search), $search);
$strforums = get_string("modulenameplural", "forum");
$strsearch = get_string("search", "forum");
if (!$search) {
print_header_simple("$strsearch", "",
"<a href=\"index.php?id=$course->id\">$strforums</a> -> $strsearch", "search.search",
- "", "", " ", navmenu($course));
+ "", "", " ", navmenu($course), true);
print_simple_box_start("center");
echo "<center>";
print_header_simple("$strsearchresults", "",
- "<a href=\"index.php?id=$course->id\">$strforums</a> ->
- <a href=\"search.php?id=$course->id\">$strsearch</a> -> \"$search\"", "search.search",
- "", "", " ", navmenu($course));
+ "<a href=\"index.php?id=$course->id\">$strforums</a> ->
+ <a href=\"search.php?id=$course->id\">$strsearch</a> -> \"$search\"", "search.search",
+ "", "", " ", navmenu($course), true);
print_heading(get_string("nopostscontaining", "forum", $search));
print_simple_box_start("center");
}
print_header_simple("$strsearchresults", "",
- "<a href=\"index.php?id=$course->id\">$strforums</a> ->
- <a href=\"search.php?id=$course->id\">$strsearch</a> -> \"$search\"", "search.search",
- "", "", $searchform, navmenu($course));
+ "<a href=\"index.php?id=$course->id\">$strforums</a> ->
+ <a href=\"search.php?id=$course->id\">$strsearch</a> -> \"$search\"", "search.search",
+ "", "", $searchform, navmenu($course), true);
print_heading("$strsearchresults: $totalcount");
echo "<center>";
- print_paging_bar($totalcount, $page, $perpage, "search.php?search=$search&id=$course->id&perpage=$perpage&");
+ print_paging_bar($totalcount, $page, $perpage, "search.php?search=$search&id=$course->id&perpage=$perpage&");
echo "</center>";
foreach ($posts as $post) {
}
echo "<center>";
- print_paging_bar($totalcount, $page, $perpage, "search.php?search=".urlencode($search)."&id=$course->id&perpage=$perpage&");
+ print_paging_bar($totalcount, $page, $perpage, "search.php?search=".urlencode($search)."&id=$course->id&perpage=$perpage&");
echo "</center>";
}
<a href=\"view.php?f=$forum->id\">$forum->name</a> -> $strsubscribers";
print_header_simple("$strsubscribers", "", "$navigation",
- "", "", true, forum_update_subscriptions_button($course->id, $id));
+ "", "", true, forum_update_subscriptions_button($course->id, $id), true);
/// Check to see if groups are being used in this forum
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
}
print_header_simple("$forum->name", "",
- "$navigation $forum->name", "", "", true, $buttontext, navmenu($course, $cm));
+ "$navigation $forum->name", "", "", true, $buttontext, navmenu($course, $cm), true);
if (!$cm->visible and !isteacher($course->id)) {
notice(get_string("activityiscurrentlyhidden"));
global $CFG;
- $status = true;
+ $status = true;
//Get the comments array
$comments = $info['#']['COMMENTS']['0']['#']['COMMENT'];
}
backup_flush(300);
}
- if ($newid) {
+ if ($newid) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code,"glossary_comments",$oldid,$newid);
} else {
global $CFG;
- $status = true;
+ $status = true;
//Get the comments array
$aliases = $info['#']['ALIASES']['0']['#']['ALIAS'];
global $CFG;
- $status = true;
+ $status = true;
//Get the entryids array
$entryids = $info['#']['ENTRIES']['0']['#']['ENTRY'];
//Now, build the GLOSSARY_ENTRIES_CATEGORIES record structure
$entry_category->categoryid = $new_category_id;
$entry_category->entryid = backup_todb($ent_info['#']['ENTRYID']['0']['#']);
-
+
//We have to recode the entryid field
$entry = backup_getid($restore->backup_unique_code,"glossary_entries",$entry_category->entryid);
if ($entry) {
//This function returns a log record with all the necessay transformations
//done. It's used by restore_log_module() to restore modules log.
function glossary_restore_logs($restore,$log) {
-
+
$status = false;
-
+
//Depending of the action, we recode different things
switch ($log->action) {
case "add":
//Get the new_id of the glossary_entry (to recode the info and url field)
$ent = backup_getid($restore->backup_unique_code,"glossary_entries",$log->info);
if ($ent) {
- $log->url = "view.php?id=".$log->cmid."&mode=entry&hook=".$ent->new_id;
+ $log->url = "view.php?id=".$log->cmid."&mode=entry&hook=".$ent->new_id;
$log->info = $ent->new_id;
$status = true;
}
//Get the new_id of the glossary_entry (to recode the info and url field)
$ent = backup_getid($restore->backup_unique_code,"glossary_entries",$log->info);
if ($ent) {
- $log->url = "view.php?id=".$log->cmid."&mode=entry&hook=".$ent->new_id;
+ $log->url = "view.php?id=".$log->cmid."&mode=entry&hook=".$ent->new_id;
$log->info = $ent->new_id;
$status = true;
}
//Get the new_id of the glossary_entry (to recode the info and url field)
$ent = backup_getid($restore->backup_unique_code,"glossary_entries",$log->info);
if ($ent) {
- $log->url = "showentry.php?id=".$log->cmid."&eid=".$ent->new_id;
+ $log->url = "showentry.php?id=".$log->cmid."&eid=".$ent->new_id;
$log->info = $ent->new_id;
$status = true;
}
//Get the new_id of the glossary_comment (to recode the info field)
$com = backup_getid($restore->backup_unique_code,"glossary_comments",$log->info);
if ($ent and $com) {
- $log->url = "comments.php?id=".$log->cmid."&eid=".$ent->new_id;
+ $log->url = "comments.php?id=".$log->cmid."&eid=".$ent->new_id;
$log->info = $com->new_id;
$status = true;
}
//Get the new_id of the glossary_comment (to recode the info field)
$com = backup_getid($restore->backup_unique_code,"glossary_comments",$log->info);
if ($ent and $com) {
- $log->url = "comments.php?id=".$log->cmid."&eid=".$ent->new_id;
+ $log->url = "comments.php?id=".$log->cmid."&eid=".$ent->new_id;
$log->info = $com->new_id;
$status = true;
}
//Get the new_id of the glossary_comment (to recode the info field)
$com = backup_getid($restore->backup_unique_code,"glossary_comments",$log->info);
if ($ent and $com) {
- $log->url = "comments.php?id=".$log->cmid."&eid=".$ent->new_id;
+ $log->url = "comments.php?id=".$log->cmid."&eid=".$ent->new_id;
$log->info = $com->new_id;
$status = true;
}
if (empty($CFG->enablerssfeeds)) {
//Some debug...
if ($CFG->debug > 7) {
- echo "DISABLED (admin variables)";
- }
+ echo "DISABLED (admin variables)";
+ }
//Check CFG->glossary_enablerssfeeds
} else if (empty($CFG->glossary_enablerssfeeds)) {
- //Some debug...
+ //Some debug...
if ($CFG->debug > 7) {
echo "DISABLED (module configuration)";
- }
+ }
//It's working so we start...
} else {
//Check the glossary has rss activated
$items = glossary_rss_feed_withauthor($glossary);
} else { //Without author RSS
$items = glossary_rss_feed_withoutauthor($glossary);
-
+
}
//Now, if items, we begin building the structure
if (!empty($items)) {
$status = $header.$articles.$footer;
} else {
$status = false;
- }
+ }
} else {
$status = false;
}
if ($newsince) {
$newsince = " AND e.timecreated > '$newsince'";
- } else {
+ } else {
$newsince = "";
- }
+ }
- if ($recs = get_records_sql ("SELECT e.id entryid,
- e.concept entryconcept,
- e.definition entrydefinition,
- e.format entryformat,
- e.timecreated entrytimecreated,
- u.id userid,
+ if ($recs = get_records_sql ("SELECT e.id entryid,
+ e.concept entryconcept,
+ e.definition entrydefinition,
+ e.format entryformat,
+ e.timecreated entrytimecreated,
+ u.id userid,
u.firstname userfirstname,
u.lastname userlastname
FROM {$CFG->prefix}glossary_entries e,
$user->lastname = $rec->userlastname;
$item->author = fullname($user);
$item->pubdate = $rec->entrytimecreated;
- $item->link = $CFG->wwwroot."/mod/glossary/showentry.php?courseid=".$glossary->course."&eid=".$rec->entryid;
+ $item->link = $CFG->wwwroot."/mod/glossary/showentry.php?courseid=".$glossary->course."&eid=".$rec->entryid;
$item->description = format_text($rec->entrydefinition,$rec->entryformat,NULL,$glossary->course);
$items[] = $item;
$articlesleft--;
$user->lastname = $rec->userlastname;
//$item->author = fullname($user);
$item->pubdate = $rec->entrytimecreated;
- $item->link = $CFG->wwwroot."/mod/glossary/showentry.php?courseid=".$glossary->course."&eid=".$rec->entryid;
+ $item->link = $CFG->wwwroot."/mod/glossary/showentry.php?courseid=".$glossary->course."&eid=".$rec->entryid;
$item->description = format_text($rec->entrydefinition,$rec->entryformat,NULL,$glossary->course);
$items[] = $item;
$articlesleft--;
}
return $items;
}
-
+
?>
//This php script contains all the stuff to backup/restore
//lesson mods
- //This is the "graphical" structure of the lesson mod:
+ //This is the "graphical" structure of the lesson mod:
//
// lesson ----------------------------|
- // (CL,pk->id) |
+ // (CL,pk->id) |
// | |
// | lesson_grades
// | (UL, pk->id,fk->lessonid)
$data = backup_getid($restore->backup_unique_code,$mod->modtype,$mod->id);
if ($data) {
- //Now get completed xmlized object
+ //Now get completed xmlized object
$info = $data->info;
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//The structure is equal to the db, so insert the lesson
$newid = insert_record("lesson", $lesson);
- //Do some output
+ //Do some output
echo "<ul><li>".get_string("modulename","lesson")." \"".$lesson->name."\"<br>";
backup_flush(300);
$status = false;
}
- //Finalize ul
+ //Finalize ul
echo "</ul>";
-
+
} else {
$status = false;
}
//We'll need this later!!
$oldid = backup_todb($page_info['#']['PAGEID']['0']['#']);
-
+
//Now, build the lesson_pages record structure
$page->lessonid = $lessonid;
$page->prevpageid = $prevpageid;
$newid = insert_record ("lesson_pages",$page);
// save the new pageids (needed to fix the absolute jumps in the answers)
- $newpageid[backup_todb($page_info['#']['PAGEID']['0']['#'])] = $newid;
-
+ $newpageid[backup_todb($page_info['#']['PAGEID']['0']['#'])] = $newid;
+
// fix the forwards link of the previous page
if ($prevpageid) {
if (!set_field("lesson_pages", "nextpageid", $newid, "id", $prevpageid)) {
}
}
$prevpageid = $newid;
-
+
//Do some output
if (($i+1) % 10 == 0) {
echo ".";
$status = false;
}
}
-
+
// we've restored all the pages and answers, we now need to fix the jumps in the
// answer records if they are absolute
if ($answers = get_records("lesson_answers", "lessonid", $lessonid)) {
foreach ($answers as $answer) {
if ($answer->jumpto > 0) {
// change the absolute page id
- if (!set_field("lesson_answers", "jumpto", $newpageid[$answer->jumpto], "id",
+ if (!set_field("lesson_answers", "jumpto", $newpageid[$answer->jumpto], "id",
$answer->id)) {
error("Lesson restorelib: unable to reset jump");
}
//traverse_xmlize($grade_info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
-
+
//We'll need this later!!
$olduserid = backup_todb($grade_info['#']['USERID']['0']['#']);
//This function returns a log record with all the necessay transformations
//done. It's used by restore_log_module() to restore modules log.
function lesson_restore_logs($restore,$log) {
-
+
$status = false;
-
+
//Depending of the action, we recode different things
switch ($log->action) {
case "add":
//Get the new_id of the page (to recode the url field)
$pag = backup_getid($restore->backup_unique_code,"lesson_pages",$log->info);
if ($pag) {
- $log->url = "view.php?id=".$log->cmid."&action=navigation&pageid=".$pag->new_id;
+ $log->url = "view.php?id=".$log->cmid."&action=navigation&pageid=".$pag->new_id;
$log->info = $pag->new_id;
$status = true;
}
/// Extended by Michael Schneider
/// This page prints a particular instance of wiki
-
+
require_once("../../config.php");
require_once("lib.php");
-
+
require_login($course->id);
-
+
optional_variable($id); // Course Module ID, or
optional_variable($page, false); // Pagename
optional_variable($action,""); // Admin Action
optional_variable($userid, 0); // User wiki.
optional_variable($groupid, 0); // Group wiki.
-
+
if ($id) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
error("Course Module ID was incorrect");
}
}
-
+
/// Build the ewsiki script constant
$ewbase = 'view.php?id='.$id;
if (isset($userid) && $userid!=0) $ewbase .= '&userid='.$userid;
define("EWIKI_SCRIPT", $ewscript);
if($wiki->ewikiacceptbinary) {
define("EWIKI_UPLOAD_MAXSIZE", get_max_upload_file_size());
- define("EWIKI_SCRIPT_BINARY", $ewbase."&binary=");
+ define("EWIKI_SCRIPT_BINARY", $ewbase."&binary=");
}
-
-
+
+
/// Add the course module 'groupmode' to the wiki object, for easy access.
$wiki->groupmode = $cm->groupmode;
if(!$action) {
error(get_string("noadministrationaction","wiki"));
}
-
+
/// Correct Action ?
if(!in_array($action, array("setpageflags", "removepages", "strippages", "checklinks", "revertpages"))) {
error("Unknown action '$action'","wiki");
}
-
-
+
+
/// May the User administrate it ?
if (($wiki_entry = wiki_get_entry($wiki, $course, $userid, $groupid)) === false || wiki_can_edit_entry($wiki_entry, $wiki, $USER, $course) === false) {
error(get_string("notadministratewiki","wiki"));
if(!($wiki->wtype=="student" || isteacher($course->id))) {
add_to_log($course->id, "wiki", "hack", "", $wiki->name.": Tried to trick admin.php with action=$action.");
error("Hack attack detected !");
- }
+ }
}
-
+
# Database and Binary Handler
include_once($CFG->dirroot."/mod/wiki/ewikimoodlelib.php");
include_once($CFG->dirroot."/mod/wiki/ewiki/plugins/moodle/moodle_binary_store.php");
-
+
/// The wiki_entry->pagename is set to the specified value of the wiki,
/// or the default value in the 'lang' file if the specified value was empty.
define("EWIKI_PAGE_INDEX",$wiki_entry->pagename);
/// Validate Form
if ($form = data_submitted()) {
- switch($action) {
+ switch($action) {
case "revertpages":
if(!$form->deleteversions || 0 > $form->deleteversions || $form->deleteversions > 1000) {
$focus="form.deleteversions";
$err->deleteversions=get_string("deleteversionserror","wiki");
- }
+ }
if(!$form->changesfield || 0 > $form->changesfield || $form->changesfield > 100000) {
$focus="form.changesfield";
$err->changesfield=get_string("changesfielderror","wiki");
- }
+ }
if($form->authorfieldpattern=="") {
$focus="form.authorfieldpattern";
$err->authorfieldpattern=get_string("authorfieldpatternerror","wiki");
- }
+ }
break;
default: break;
}
- }
-
+ }
+
print_header_simple("$wiki_entry->pagename", "",
"<A HREF=\"index.php?id=$course->id\">$strwikis</A> -> <A HREF=\"view.php?id=$id\">$wiki->name</a> ->".
get_string("administration","wiki"),
$focus, "", true, update_module_button($cm->id, $course->id, $strwiki),
navmenu($course, $cm));
-
+
////////////////////////////////////////////////////////////
/// Check if the Form has been submitted and display confirmation
////////////////////////////////////////////////////////////
/// Get additional info
$addloginfo="";
switch($action) {
- case "removepages":
+ case "removepages":
$addloginfo=@join(", ", $form->pagestodelete);
- break;
+ break;
case "strippages":
$addloginfo=@join(", ", $form->pagestostrip);
break;
break;
}
add_to_log($course->id, "wiki", $action, "admin.php?action=$action&userid=$userid&groupid=$groupid&id=$id", $wiki->name.($addloginfo?": ".$addloginfo:""));
- $link="admin.php?action=$action".($userid?"&userid=".$userid:"").($groupid?"&groupid=".$groupid:"")."&id=$id&page=$page";
+ $link="admin.php?action=$action".($userid?"&userid=".$userid:"").($groupid?"&groupid=".$groupid:"")."&id=$id&page=$page";
switch($action) {
- case "removepages":
- if($form->proceed) {
+ case "removepages":
+ if($form->proceed) {
if(!$confirm && $form->pagestodelete) {
notice_yesno(get_string("removepagecheck", "wiki")."<br />".join(", ", $form->pagestodelete),
- $link."&confirm=".urlencode(join(" ",$form->pagestodelete)), $link);
+ $link."&confirm=".urlencode(join(" ",$form->pagestodelete)), $link);
print_footer($course);
exit;
}
}
break;
case "strippages":
- if($form->proceed) {
+ if($form->proceed) {
if(!$confirm && $form->pagestostrip) {
$err=array();
$strippages=wiki_admin_strip_versions($form->pagestostrip,$form->version, $err);
}
if(count($err)==0) {
notice_yesno(get_string("strippagecheck", "wiki")."<br />".join(", ", $form->pagestostrip),
- $link.$confirm, $link);
+ $link.$confirm, $link);
print_footer($course);
exit;
}
}
}
- break;
+ break;
case "checklinks":
- if($form->proceed) {
+ if($form->proceed) {
if(!$confirm && $form->pagetocheck) {
$confirm="&confirm=".$form->pagetocheck;
notice_yesno(get_string("checklinkscheck", "wiki").$form->pagetocheck,
- $link.$confirm, $link);
+ $link.$confirm, $link);
print_footer($course);
exit;
}
}
- break;
+ break;
case "setpageflags":
// pageflagstatus is used in setpageflags.html
$pageflagstatus=wiki_admin_setpageflags($form->flags);
- break;
- case "revertpages":
+ break;
+ case "revertpages":
if(!$err) {
if(!$confirm) {
$confirm="&confirm[changesfield]=".urlencode($form->changesfield).
$revertedpages=wiki_admin_revert("", $form->authorfieldpattern, $form->changesfield, $form->howtooperate, $form->deleteversions);
if($revertedpages) {
notice_yesno(get_string("revertpagescheck", "wiki")."<br />".$revertedpages,
- $link.$confirm, $link);
+ $link.$confirm, $link);
print_footer($course);
- exit;
+ exit;
} else {
$err->remark=get_string("nochangestorevert","wiki");
}
}
}
- break;
+ break;
default: error("No such Wiki-Admin action: $action");
break;
}
- }
-
+ }
+
/// Actions which need a confirmation. If confirmed, do the action
$redirect="view.php?".($groupid?"&groupid=".$groupid:"").($userid?"&userid=".$userid:"")."&id=$id&page=$page";
if($confirm && !$err) {
} else {
error($ret);
}
- exit;
+ exit;
case "checklinks":
$ret=wiki_admin_checklinks($confirm);
redirect($redirect, get_string("linkschecked","wiki")."<br />".$ret, 5);
- exit;
+ exit;
case "revertpages":
$revertedpages=wiki_admin_revert(1, $confirm["authorfieldpattern"], $confirm["changesfield"], $confirm["howtooperate"], $confirm["deleteversions"]);
redirect($redirect, get_string("pagesreverted","wiki"), 1);
# No confirmation needed
break;
default: error("No such action '$action' with confirmation");
- }
+ }
}
-
+
/// The top row contains links to other wikis, if applicable.
if ($wiki_list = wiki_get_other_wikis($wiki, $USER, $course, $wiki_entry->id)) {
echo '<td class="sideblockheading" bgcolor="'.$THEME->cellheading.'" align="right">'
.get_string('otherwikis', 'wiki').': ';
$script = 'self.location=document.otherwikis.wikiselect.options[document.otherwikis.wikiselect.selectedIndex].value';
-
+
/// Add Admin-Action
reset($wiki_list);
$wiki_admin_list=array();
$wiki_admin_list[$key."&action=$action"]=$val;
}
choose_from_menu($wiki_admin_list, "wikiselect", $selected, "choose", $script);
- echo '</td>';
+ echo '</td>';
echo '</tr></table>';
echo '</form>';
if ($wiki_entry) {
-
+
/// Page Actions
echo '<table border="0" width="100%">';
echo '<tr>';
# echo '<tr><td align="center">';
# $specialpages=array("SearchPages", "PageIndex","NewestPages","MostVisitedPages","MostOftenChangedPages","UpdatedPages","FileDownload","FileUpload","OrphanedPages","WantedPages");
# wiki_print_page_actions($cm->id, $specialpages, $ewiki_id, $ewiki_action, $wiki->ewikiacceptbinary, $canedit);
-# echo '</td>';
+# echo '</td>';
/// Searchform
- echo '<td align="center">';
+ echo '<td align="center">';
wiki_print_search_form($cm->id, $q, $userid, $groupid, false);
echo '</td>';
-
+
/// Internal Wikilinks
-
+
/// TODO: DOES NOT WORK !!!!
echo '<td align="center">';
wiki_print_wikilinks_block($cm->id, $wiki->ewikiacceptbinary);
echo '</td>';
-
- /// Administrative Links
- echo '<td align="center">';
+
+ /// Administrative Links
+ echo '<td align="center">';
wiki_print_administration_actions($wiki, $cm->id, $userid, $groupid, $page, $wiki->htmlmode!=2, $course);
echo '</td>';
-
+
# if($wiki->htmlmode!=2) {
-# echo '<td align="center">';
+# echo '<td align="center">';
# helpbutton('formattingrules', get_string('formattingrules', 'wiki'), 'wiki');
# echo get_string("formattingrules","wiki");
# echo '</td>';
# }
-
+
echo '</tr></table>';
}
// The wiki Contents
print_simple_box_start( "center", "100%", "$THEME->cellcontent", "20");
- // Do the Action
+ // Do the Action
# "setpageflags", "removepages", "strippages", "checklinks", "revertpages"
print_heading_with_help(get_string($action,"wiki"), $action, "wiki");
- include $action.".html";
+ include $action.".html";
print_simple_box_end();
/// Finish the page
print_footer($course);
exit;
-
+
?>
\ No newline at end of file
define("EWIKI_ESCAPE_AT", 0); # For the algebraic filter
function wiki_add_instance($wiki) {
-/// Given an object containing all the necessary data,
-/// (defined by the form in mod.html) this function
-/// will create a new instance and return the id number
+/// Given an object containing all the necessary data,
+/// (defined by the form in mod.html) this function
+/// will create a new instance and return the id number
/// of the new instance.
$wiki->timemodified = time();
function wiki_update_instance($wiki) {
-/// Given an object containing all the necessary data,
-/// (defined by the form in mod.html) this function
+/// Given an object containing all the necessary data,
+/// (defined by the form in mod.html) this function
/// will update an existing instance with new data.
/// Determine the pagename for this wiki.
$handle = @opendir($basedir);
if($handle) {
while (false!==($folder = readdir($handle))) {
- if($folder != "." && $folder != ".." && $Folder != "CVS") {
+ if($folder != "." && $folder != ".." && $Folder != "CVS") {
wiki_rmdir("$basedir/$folder"); // recursive
- }
+ }
}
closedir($handle);
}
function wiki_delete_instance($id) {
/// Given an ID of an instance of this module,
-/// this function will permanently delete the instance
-/// and any data that depends on it.
+/// this function will permanently delete the instance
+/// and any data that depends on it.
global $CFG;
-
+
if (! $wiki = get_record("wiki", "id", $id)) {
return false;
}
}
}
#if (!$exception) { // Delete directory as well, if empty
- wiki_rmdir("$basedir");
+ wiki_rmdir("$basedir");
#}
- }
+ }
}
-
+
# Delete any dependent records here #
if (! delete_records("wiki", "id", $wiki->id)) {
$result = false;
}
}
}
-
+
return $result;
}
}
function wiki_print_recent_activity($course, $isteacher, $timestart) {
-/// Given a course and a time, this module should find recent activity
-/// that has occurred in wiki activities and print it out.
+/// Given a course and a time, this module should find recent activity
+/// that has occurred in wiki activities and print it out.
/// Return true if there was output, or false is there was none.
global $CFG;
- return false; // True if anything was printed, otherwise false
+ return false; // True if anything was printed, otherwise false
}
function wiki_cron () {
/// Function to be run periodically according to the moodle cron
-/// This function searches for things that need to be done, such
-/// as sending out mail, toggling flags etc ...
+/// This function searches for things that need to be done, such
+/// as sending out mail, toggling flags etc ...
global $CFG;
}
function wiki_grades($wikiid) {
-/// Must return an array of grades for a given instance of this module,
+/// Must return an array of grades for a given instance of this module,
/// indexed by user. It also returns a maximum allowed grade.
return NULL;
}
//////////////////////////////////////////////////////////////////////////////////////
-/// Any other wiki functions go here. Each of them must have a name that
+/// Any other wiki functions go here. Each of them must have a name that
/// starts with wiki_
function wiki_wiki_name($wikiname) {
function wiki_is_wiki_name($wikiname) {
/// Check for correct wikiname syntax and return true or false.
- /// If there are spaces between the words, incorrect format.
+ /// If there are spaces between the words, incorrect format.
if (preg_match_all('/\w+/', $wikiname, $out) > 1) {
return false;
}
else if (preg_match_all('/[A-Z]+[a-z_]+/', $wikiname, $out) > 1) {
return true;
}
- else {
+ else {
return false;
}
}
/// Valid values for $byindex are 'student', 'group'.
if ($byindex == 'student') {
- return get_records('wiki_entries', 'wikiid', $wiki->id, '',
+ return get_records('wiki_entries', 'wikiid', $wiki->id, '',
'userid,id,wikiid,course,groupid,pagename,timemodified');
}
else if ($byindex == 'group') {
- return get_records('wiki_entries', 'wikiid', $wiki->id, '',
+ return get_records('wiki_entries', 'wikiid', $wiki->id, '',
'groupid,id,wikiid,course,userid,pagename,timemodified');
}
else {
$pagename = $defpagename;
}
- $key = $ME.'?id='.$id.'&userid='.$student->id.'&page='.$pagename;
+ $key = $ME.'?id='.$id.'&userid='.$student->id.'&page='.$pagename;
$wikis[$key] = fullname($student).':'.$pagename;
}
}
$pagename = $defpagename;
}
- $key = $ME.'?id='.$id.'&userid='.$student->id.'&page='.$pagename;
+ $key = $ME.'?id='.$id.'&userid='.$student->id.'&page='.$pagename;
$wikis[$key] = fullname($student).':'.$pagename;
}
}
}
else if ($groupmode == VISIBLEGROUPS) {
- /// Get all students in your group.
+ /// Get all students in your group.
if ($students = get_group_students($mygroupid)) {
$defpagename = empty($wiki->pagename) ? get_string('wikidefaultpagename', 'wiki') : $wiki->pagename;
foreach ($students as $student) {
else {
$pagename = $defpagename;
}
- $key = $ME.'?id='.$id.'&userid='.$student->id.'&page='.$pagename;
+ $key = $ME.'?id='.$id.'&userid='.$student->id.'&page='.$pagename;
$wikis[$key] = fullname($student).':'.$pagename;
}
}
$wiki_entries = get_records_sql($sql);
$wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
foreach ($wiki_entries as $wiki_entry) {
- $key = $ME.'?id='.$id.'&userid='.$wiki_entry->userid.'&page='.$wiki_entry->pagename;
+ $key = $ME.'?id='.$id.'&userid='.$wiki_entry->userid.'&page='.$wiki_entry->pagename;
$wikis[$key] = fullname($wiki_entry).':'.$wiki_entry->pagename;
if ($currentid == $wiki_entry->id) {
$wikis['selected'] = $key;
}
}
- }
+ }
}
else {
/// A user can see other student wikis if they are a member of the same
$wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
foreach ($wiki_entries as $wiki_entry) {
if (($viewall === true) or ismember($viewall, $wiki_entry->userid)) {
- $key = $ME.'?id='.$id.'&userid='.$wiki_entry->userid.'&page='.$wiki_entry->pagename;
+ $key = $ME.'?id='.$id.'&userid='.$wiki_entry->userid.'&page='.$wiki_entry->pagename;
$wikis[$key] = fullname($wiki_entry).':'.$wiki_entry->pagename;
if ($currentid == $wiki_entry->id) {
$wikis['selected'] = $key;
$pagename = $defpagename;
}
- $key = $ME.'?id='.$id.($group->id?"&groupid=".$group->id:"").'&page='.$pagename;
+ $key = $ME.'?id='.$id.($group->id?"&groupid=".$group->id:"").'&page='.$pagename;
$wikis[$key] = $group->name.':'.$pagename;
}
}
$wiki_entries = get_records_sql($sql);
$wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
foreach ($wiki_entries as $wiki_entry) {
- $key = $ME.'?id='.$id.($wiki_entry->groupid?"&groupid=".$wiki_entry->groupid:"").'&page='.$wiki_entry->pagename;
+ $key = $ME.'?id='.$id.($wiki_entry->groupid?"&groupid=".$wiki_entry->groupid:"").'&page='.$wiki_entry->pagename;
$wikis[$key] = $wiki_entry->gname.':'.$wiki_entry->pagename;
if ($currentid == $wiki_entry->id) {
$wikis['selected'] = $key;
if ($groupmode and ($isteacheredit or ($isteacher and !$mygroupid))) {
if ($groups = get_groups($course->id)) {
$defpagename = empty($wiki->pagename) ? get_string('wikidefaultpagename', 'wiki') : $wiki->pagename;
-
+
foreach ($groups as $group) {
/// If this group already has an entry, use its pagename.
if ($wiki_entries[$group->id]) {
$pagename = $defpagename;
}
- $key = $ME.'?id='.$id.($group->id?"&groupid=".$group->id:"").'&page='.$pagename;
+ $key = $ME.'?id='.$id.($group->id?"&groupid=".$group->id:"").'&page='.$pagename;
$wikis[$key] = $group->name.':'.$pagename;
}
}
$wiki_entries = get_records_sql($sql);
$wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
foreach ($wiki_entries as $wiki_entry) {
- $key = $ME.'?id='.$id.($wiki_entry->groupid?"&groupid=".$wiki_entry->groupid:"").'&page='.$wiki_entry->pagename;
+ $key = $ME.'?id='.$id.($wiki_entry->groupid?"&groupid=".$wiki_entry->groupid:"").'&page='.$wiki_entry->pagename;
$wikis[$key] = $wiki_entry->gname.':'.$wiki_entry->pagename;
if ($currentid == $wiki_entry->id) {
$wikis['selected'] = $key;
$wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
foreach ($wiki_entries as $wiki_entry) {
if (($viewall === true) or $viewall == $wiki_entry->groupid) {
- $key = $ME.'?id='.$id.($wiki_entry->groupid?"&groupid=".$wiki_entry->groupid:"").'&page='.$wiki_entry->pagename;
+ $key = $ME.'?id='.$id.($wiki_entry->groupid?"&groupid=".$wiki_entry->groupid:"").'&page='.$wiki_entry->pagename;
$wikis[$key] = $wiki_entry->gname.':'.$wiki_entry->pagename;
if ($currentid == $wiki_entry->id) {
$wikis['selected'] = $key;
}
break;
}
-
+
return $wikis;
}
}
/// If not requesting a group, must be a member of a group.
else if ($groupid == 0) {
- return ($mygroupid != 0);
+ return ($mygroupid != 0);
}
/// If requesting a group, must be an editing teacher, a non-editing teacher with no assigned group,
/// or a non-editing teacher requesting their group.
}
/// If not requesting a group, must be a member of a group.
else if ($groupid == 0) {
- return ($mygroupid != 0 and isteacher($course->id));
+ return ($mygroupid != 0 and isteacher($course->id));
}
- /// If there is a group mode, non-editing teachers with an assigned group, can only create wikis
+ /// If there is a group mode, non-editing teachers with an assigned group, can only create wikis
/// in their group. Non-editing teachers with no assigned group and editing teachers can create any wiki.
else {
- return (isteacheredit($course->id) or
+ return (isteacheredit($course->id) or
(isteacher($course->id) and ($mygroupid == 0 or $mygroupid == $groupid)));
}
break;
$groupmode = groupmode($course, $wiki);
$mygroupid = mygroupid($course->id);
- /// Editing teacher's and admins can edit all wikis, non-editing teachers can edit wikis in their groups,
+ /// Editing teacher's and admins can edit all wikis, non-editing teachers can edit wikis in their groups,
/// or all wikis if group mode is 'no groups' or they don't belong to a group.
if (isadmin($user->id) or isteacheredit($course->id, $user->id) or
((!$groupmode or $mygroupid == 0) and isteacher($course->id, $user->id))) {
/// - they are a non-editing teacher and group mode is NOGROUPS.
/// - they are an administrator (mostly for site-level wikis).
if (($userid and ($USER->id == $userid)) or ($groupmode == VISIBLEGROUPS) or
- (($groupmode == SEPARATEGROUPS) and ismember($usersgroup, $userid)) or
+ (($groupmode == SEPARATEGROUPS) and ismember($usersgroup, $userid)) or
(isteacheredit($course->id, $USER->id)) or
(isteacher($course->id, $USER->id) and (!$usersgroup or ($groupmode == NOGROUPS))) or
(isadmin())) {
/// - group mode is SEPARATEGROUPS, and they are a member of the requested group,
/// - they are an editing teacher or administrator,
/// - they are a non-editing teacher not assigned to a specific group.
- if (($groupmode == NOGROUPS) or ($groupmode == VISIBLEGROUPS) or
- (($groupmode == SEPARATEGROUPS) and ($usersgroup == $groupid)) or
+ if (($groupmode == NOGROUPS) or ($groupmode == VISIBLEGROUPS) or
+ (($groupmode == SEPARATEGROUPS) and ($usersgroup == $groupid)) or
(isteacheredit($course->id, $USER->id)) or
(isteacher($course->id, $USER->id) and !$usersgroup)) {
$can_access = true;
/// - group mode is VISIBLEGROUPS,
/// - group mode is SEPARATEGROUPS, and they are a member of the requested group,
/// - they are a teacher or administrator,
- if (($groupmode == NOGROUPS) or ($groupmode == VISIBLEGROUPS) or
+ if (($groupmode == NOGROUPS) or ($groupmode == VISIBLEGROUPS) or
(($groupmode == SEPARATEGROUPS) and (mygroupid($course->id) == $groupid)) or
(isteacher($course->id, $USER->id))){
$can_access = true;
if($binary) {
$links["FileDownload"]=get_string("filedownload", "wiki");
}
- popup_form(EWIKI_SCRIPT, $links, "wikilinks", "", get_string("choosewikilinks", "wiki"), "", "", $return);
+ popup_form(EWIKI_SCRIPT, $links, "wikilinks", "", get_string("choosewikilinks", "wiki"), "", "", $return);
}
function wiki_print_page_actions($cmid, $specialpages, $page, $action, $binary=false, $canedit=true) {
// Edit this Page
if (in_array($action, array("edit", "links", "info", "attachments"))) {
- $page["view/$page"]=get_string("viewpage","wiki");
+ $page["view/$page"]=get_string("viewpage","wiki");
}
if ($canedit && !in_array($page, $specialpages) && $action != "edit") {
$page["edit/$page"]=get_string("editthispage","wiki");
$page["attachments/$page"]=get_string("attachments","wiki");
}
- popup_form(EWIKI_SCRIPT, $page, "wikiactions", "", get_string("action", "wiki"), "", "", false);
+ popup_form(EWIKI_SCRIPT, $page, "wikiactions", "", get_string("action", "wiki"), "", "", false);
}
function wiki_print_administration_actions($wiki, $cmid, $userid, $groupid, $page, $noeditor, $course) {
/// Displays actions which can be performed on the page
- global $ME;
+ global $ME;
-
- /// Create the URL
+
+ /// Create the URL
$ewscript = 'admin.php?id='.$cmid;
if (isset($userid) && $userid!=0) $ewscript .= '&userid='.$userid;
if (isset($groupid) && $groupid!=0) $ewscript .= '&groupid='.$groupid;
if($noeditor) {
$action["checklinks"]=get_string("checklinks", "wiki");
}
- popup_form($ewscript, $action, "wikiadministration", "", get_string("chooseadministration", "wiki"), "", "", false);
+ popup_form($ewscript, $action, "wikiadministration", "", get_string("chooseadministration", "wiki"), "", "", false);
}
function wiki_admin_get_flagarray() {
EWIKI_DB_F_READONLY => get_string("flagro","wiki"),
EWIKI_DB_F_WRITEABLE => get_string("flagwr","wiki"),
);
-
+
return $ret;
}
///////// Ewiki Administration. Mostly taken from the ewiki/tools folder and changed
function wiki_admin_setpageflags_list($pageflagstatus) {
- $FD = wiki_admin_get_flagarray();
+ $FD = wiki_admin_get_flagarray();
$table->head = array(get_string("pagename","wiki"), get_string("flags","wiki"));
if($pageflagstatus) {
$table->head[]=get_string("status","wiki");
}
-
+
$result = ewiki_database("GETALL", array("version", "flags"));
while ($row = $result->get()) {
$id = $row["id"];
$cell_pagename .= '<A HREF="' . EWIKI_SCRIPT_BINARY . $id . '">';
}
$cell_pagename .= htmlentities($id) . '</A> / '.get_string("version","wiki").": ".$row["version"];
-
+
foreach ($FD as $n=>$str) {
$cell_flags .='<INPUT TYPE="checkbox" NAME="flags['. rawurlencode($id)
. '][' . $n . ']" VALUE="1" '
function wiki_admin_setpageflags($pageflags) {
$FD = wiki_admin_get_flagarray();
-
+
$status=array();
- if($pageflags) {
+ if($pageflags) {
foreach($pageflags as $page=>$fa) {
$page = rawurldecode($page);
}
}
}
- return $status;
+ return $status;
}
function wiki_admin_remove_list($listall="") {
/// Table header
$table->head = array(" ", get_string("pagename","wiki"), get_string("errororreason","wiki"));
-
+
/// Get all pages
$result = ewiki_database("GETALL", array("version"));
$selected = array();
$selected[$row["id"]] = get_string("listall","wiki")."<br />";
}
}
- while ($page = $result->get()) {
+ while ($page = $result->get()) {
$id = $page["id"];
$page = ewiki_database("GET", array("id"=>$id));
$flags = $page["flags"];
- #print "$id ".strlen(trim(($page["content"])))."<br />";
+ #print "$id ".strlen(trim(($page["content"])))."<br />";
if (!strlen(trim(($page["content"]))) && !($flags & EWIKI_DB_F_BINARY)) {
@$selected[$id] .= get_string("emptypage","wiki")."<br />";
}
-
+
// Check for orphaned pages
$result2 = ewiki_database("SEARCH", array("content" => $id));
$orphanedpage=true;
while ($row = $result2->get()) {
$checkcontent = ewiki_database("GET", array("id"=>$row["id"]));
$checkcontent = strtolower($checkcontent["content"]);
-
+
if(strpos($checkcontent, strtolower($id)) !== false) {
$orphanedpage=false;
}
}
}
- /// Some more reasons for Deletion...
+ /// Some more reasons for Deletion...
if ($orphanedpage && $id!=EWIKI_PAGE_INDEX &&!($flags & EWIKI_DB_F_BINARY)) {
@$selected[$id] .= get_string("orphanedpage","wiki")."<br />";
}
@$selected[$id] .= get_string("deletemewikiwordfound","wiki",get_string("deletemewikiword","wiki"))."<br />";
}
}
-
- foreach ($selected as $id => $reason) {
+
+ foreach ($selected as $id => $reason) {
$table_checkbox='<INPUT TYPE="checkbox" VALUE="'.rawurlencode($id).'" NAME="pagestodelete[]" />';
#-- link & id
#-- print reason
$table_reason=$reason;
-
+
$table->data[]=array($table_checkbox, $table_page, $table_reason);
- }
-
- return $table;
+ }
+
+ return $table;
}
/// This function actually removes the pages
function wiki_admin_remove($pagestodelete, $course, $wiki, $userid, $groupid) {
- $ret="";
+ $ret="";
foreach ($pagestodelete as $id) {
$id = rawurldecode($id);
@unlink("$filepath");
}
}
-
+
}
return $ret;
}
function wiki_admin_strip_list($pagestostrip="",$version="",$err="") {
/// Table header
$table->head = array(" ", get_string("pagename","wiki"), get_string("deleteversions","wiki"));
-
+
$vc=ewiki_database("COUNTVERSIONS", array());
$result = ewiki_database("GETALL",array());
$i=0;
$error="";
if($err[$id]) {
$error=" ".join(", ",$err[$id]);
- }
+ }
$checked="";
if($pagestostrip=="" || $pagestostrip[$i]) {
$checked=" CHECKED";
} else {
$versiondefault=$version[$i];
}
- $table->data[]=array('<input type="checkbox" value="'.rawurlencode($id).'" name="pagestostrip['.$i.']" '.$checked.' />',
+ $table->data[]=array('<input type="checkbox" value="'.rawurlencode($id).'" name="pagestostrip['.$i.']" '.$checked.' />',
'<A HREF="'.EWIKI_SCRIPT.$id.'">'.htmlentities($id).'</A> / '.get_string("version","wiki").": ".$row["version"],
'<input name="version['.$i.']" value="'.$versiondefault.'" size="7" />'.$error);
-
+
}
$i++;
}
function wiki_admin_strip_versions($pagestostrip, $version, &$err) {
$ret=array();
foreach ($pagestostrip as $key => $id_ue) {
-
+
$id = rawurldecode($id_ue);
if (preg_match('/^(\d+)[-\s._:]+(\d+)$/', trim($version[$key]), $uu)) {
$versA = $uu[1];
$versZ = $uu[2];
-
+
// Let the last Version in the database
$checkdata = ewiki_database("GET", array("id" => $id));
if($versZ>=$checkdata["version"]) {
- $err[$id][] = get_string("versionrangetoobig","wiki");
+ $err[$id][] = get_string("versionrangetoobig","wiki");
} else {
if($versA<=$versZ) {
for ($v=$versA; $v<=$versZ; $v++) {
}
return $ret;
}
-
+
function wiki_admin_strip($pagestostrip) {
/// Purges old page-versions
foreach($pagestostrip as $id => $versions) {
ewiki_database("DELETE", array("id"=>$id, "version"=>$version));
}
}
-}
+}
function wiki_admin_checklinks_list() {
$ret=array();
if($pagetocheck) {
$get = ewiki_database("GET", array("id" => $pagetocheck));
$content = $get["content"];
-
+
preg_match_all('_(http.?://[^\s"\'<>#,;]+[^\s"\'<>#,;.])_', $content, $links);
$badlinks = array();
if(!$links[1]) {
} else {
foreach ($links[1] as $href) {
#print "[ $href ]";
- #$d = @implode("", @file($href));
+ #$d = @implode("", @file($href));
$d="";
if($checkfd = @fopen($href, 'r')) {
fclose($checkfd);
} else {
$ret.="[".get_string("linkok","wiki")."] $href <br />\n";
}
- }
+ }
}
-
+
/// Remove old Notices
$content = eregi_replace(' µµ__~\['.get_string("offline","wiki").'\]__µµ ','', $content);
$m_time = $changesfield * 3600;
$depth = $deleteversions - 1;
$depth = ($depth>0?$depth:0);
-
+
#-- walk through
$result = ewiki_database("GETALL", array("id", "author", "lastmodified"));
while ($row = $result->get()) {
}
else {
$verA = $verZ-$depth;
- if ($verA <= 0) {
+ if ($verA <= 0) {
$verA = 1;
}
}
global $ewiki_title;
/// #-- predefine some of the configuration constants
-
-
+
+
/// EWIKI_NAME is defined in ewikimoodlelibs, so that also admin.php can use this
#define("EWIKI_NAME", $wiki_entry->pagename);
if($ewiki_title=="SearchPages") {
$qArgument="&q=".urlencode($q);
}
-
+
/// Build the ewsiki script constant
/// ewbase will also be needed by EWIKI_SCRIPT_BINARY
$ewbase = $ME.'?id='.$moodleID;
# Binary Handling
if($wiki->ewikiacceptbinary) {
define("EWIKI_UPLOAD_MAXSIZE", get_max_upload_file_size());
- define("EWIKI_SCRIPT_BINARY", $ewbase."&binary=");
+ define("EWIKI_SCRIPT_BINARY", $ewbase."&binary=");
define("EWIKI_ALLOW_BINARY",1);
define("EWIKI_IMAGE_CACHING",1);
#define("EWIKI_AUTOVIEW",1);
# The mighty Wiki itself
include_once($CFG->dirroot."/mod/wiki/ewiki/ewiki.php");
- if($canceledit) {
+ if($canceledit) {
if ($delim = strpos($page, EWIKI_ACTION_SEP_CHAR)) {
@$page = substr($page, $delim + 1);
} else {
$moodle_format=FORMAT_HTML;
}
if($wiki->htmlmode == 2) {
- # HTML Only
+ # HTML Only
$moodle_format=FORMAT_HTML;
$ewiki_use_editor=1;
$ewiki_config["htmlentities"]=array(); // HTML is allowed
if(!isset($ewiki_title)) {
$ewiki_title="";
}
-
+
/// Moodle Log
add_to_log($course->id, "wiki", $ewiki_action, "view.php?id=$cm->id&groupid=$groupid&userid=$userid&page=$page", $wiki->name." ".$ewiki_title);
.get_string('otherwikis', 'wiki').': ';
$script = 'self.location=document.otherwikis.wikiselect.options[document.otherwikis.wikiselect.selectedIndex].value';
choose_from_menu($wiki_list, "wikiselect", $selected, "choose", $script);
- echo '</td>';
+ echo '</td>';
echo '</tr></table>';
echo '</form>';
/// Page Actions
echo '<table border="0" width="100%">';
echo '<tr>';
-
+
/// Searchform
- echo '<td align="center">';
+ echo '<td align="center">';
wiki_print_search_form($cm->id, $q, $userid, $groupid, false);
echo '</td>';
-
+
/// Internal Wikilinks
echo '<td align="center">';
wiki_print_wikilinks_block($cm->id, $wiki->ewikiacceptbinary);
echo '</td>';
-
+
/// Administrative Links
if($canedit) {
- echo '<td align="center">';
+ echo '<td align="center">';
wiki_print_administration_actions($wiki, $cm->id, $userid, $groupid, $ewiki_title, $wiki->htmlmode!=2, $course);
echo '</td>';
}
-
+
/// Formatting Rules
- echo '<td align="right">';
+ echo '<td align="right">';
helpbutton('howtowiki', get_string('howtowiki', 'wiki'), 'wiki');
echo '</td>';
-
+
echo '</tr></table>';
}
print "<br />";
}
}
-
+
// The wiki Contents
if (!empty($canedit)) { /// Print tabs with commands for this page
}
foreach ($tabs as $tab) {
$tabname = get_string("tab$tab", 'wiki');
- if ($ewiki_action != "$tab" && !in_array($page, $specialpages)) {
+ if ($ewiki_action != "$tab" && !in_array($page, $specialpages)) {
echo '<td class="generaltab" '.$tabstyle.' bgcolor="'.$THEME->cellheading.'">';
echo '<a href="'.$ewbase.'&page='.$tab.'/'.$ewiki_id.'">'.$tabname.'</a>';
echo '</td>';
require_variable($id); // user id
require_variable($course); // course id
-
+
if (! $user = get_record("user", "id", $id)) {
error("User ID was incorrect");
}
if ($user->confirmed and user_not_fully_set_up($user)) {
- // Special case which can only occur when a new account
+ // Special case which can only occur when a new account
// has just been created by EXTERNAL authentication
// This is the only page in Moodle that has the exception
// so that users can set up their accounts
} else {
$timenow = time();
-
+
if (!$usernew->picture = save_profile_image($user->id,$um,'users')) {
if (!empty($usernew->deletepicture)) {
set_field('user', 'picture', 0, 'id', $user->id); /// Delete picture
$usernew->picture = $user->picture;
}
}
-
+
$usernew->timemodified = time();
-
+
if (isadmin()) {
if (!empty($usernew->newpassword)) {
$usernew->password = md5($usernew->newpassword);
unset($USER->newadminuser);
redirect("$CFG->wwwroot/", get_string("changessaved"));
}
- redirect("$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id", get_string("changessaved"));
+ redirect("$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id", get_string("changessaved"));
} else {
redirect("$CFG->wwwroot/$CFG->admin/user.php", get_string("changessaved"));
}
}
}
}
-
+
/// Otherwise fill and print the form.
$streditmyprofile = get_string("editmyprofile");
}
if ($course->category) {
print_header("$course->shortname: $streditmyprofile", "$course->fullname: $streditmyprofile",
- "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>
+ "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>
-> <a href=\"index.php?id=$course->id\">$strparticipants</a>
- -> <a href=\"view.php?id=$user->id&course=$course->id\">$userfullname</a>
+ -> <a href=\"view.php?id=$user->id&course=$course->id\">$userfullname</a>
-> $streditmyprofile", "");
} else {
if (isset($USER->newadminuser)) {
print_header();
} else {
print_header("$course->shortname: $streditmyprofile", "$course->fullname",
- "<a href=\"view.php?id=$user->id&course=$course->id\">$userfullname</a>
+ "<a href=\"view.php?id=$user->id&course=$course->id\">$userfullname</a>
-> $streditmyprofile", "");
}
}
$err["email"] = get_string("emailexists");
}
}
-
+
if (empty($err["email"]) and !isadmin()) {
if ($error = email_is_not_allowed($usernew->email)) {
$err["email"] = $error;
echo "<center><p align=\"center\">";
echo get_string("firstname")." : ";
if ($firstinitial) {
- echo " <a href=\"index.php?id=$course->id&sort=firstname&dir=ASC&".
+ echo " <a href=\"index.php?id=$course->id&sort=firstname&dir=ASC&".
"perpage=$perpage&lastinitial=$lastinitial\">$strall</a> ";
} else {
echo " <b>$strall</b> ";
if ($letter == $firstinitial) {
echo " <b>$letter</b> ";
} else {
- echo " <a href=\"index.php?id=$course->id&sort=firstname&dir=ASC&".
+ echo " <a href=\"index.php?id=$course->id&sort=firstname&dir=ASC&".
"perpage=$perpage&lastinitial=$lastinitial&firstinitial=$letter\">$letter</a> ";
}
}
echo get_string("lastname")." : ";
if ($lastinitial) {
- echo " <a href=\"index.php?id=$course->id&sort=lastname&dir=ASC&".
+ echo " <a href=\"index.php?id=$course->id&sort=lastname&dir=ASC&".
"perpage=$perpage&firstinitial=$firstinitial\">$strall</a> ";
} else {
echo " <b>$strall</b> ";
if ($letter == $lastinitial) {
echo " <b>$letter</b> ";
} else {
- echo " <a href=\"index.php?id=$course->id&sort=lastname&dir=ASC&".
+ echo " <a href=\"index.php?id=$course->id&sort=lastname&dir=ASC&".
"perpage=$perpage&firstinitial=$firstinitial&lastinitial=$letter\">$letter</a> ";
}
}
echo "</center>";
print_paging_bar($matchcount, $page, $perpage,
- "index.php?id=$course->id&sort=$sort&dir=$dir&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial&");
+ "index.php?id=$course->id&sort=$sort&dir=$dir&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial");
}
} else if ($matchcount > 0) {
print_user_table($students, $isteacher);
print_paging_bar($matchcount, $page, $perpage,
- "index.php?id=$course->id&sort=$sort&dir=$dir&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial&");
+ "index.php?id=$course->id&sort=$sort&dir=$dir&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial");
if ($perpage < $totalcount) {
echo "<center><p>";
require_login();
}
- add_to_log($course->id, "user", "view", "view.php?id=$user->id&course=$course->id", "$user->id");
+ add_to_log($course->id, "user", "view", "view.php?id=$user->id&course=$course->id", "$user->id");
if ($student = get_record("user_students", "userid", $user->id, "course", $course->id)) {
$user->lastaccess = $student->timeaccess;