Skip to content

Commit

Permalink
Update to current OU live version
Browse files Browse the repository at this point in the history
  • Loading branch information
sammarshallou committed Mar 5, 2015
1 parent 4001cea commit 4c6904b
Show file tree
Hide file tree
Showing 15 changed files with 892 additions and 114 deletions.
2 changes: 1 addition & 1 deletion basicpage.php
Expand Up @@ -40,7 +40,7 @@
}

// Restrict page name
if (textlib::strlen($pagename) > 200) {
if (core_text::strlen($pagename) > 200) {
print_error('pagenametoolong', 'ouwiki');
}
// Convert nbsp to space
Expand Down
2 changes: 1 addition & 1 deletion classes/event/page_version_deleted.php
Expand Up @@ -44,7 +44,7 @@ class page_version_deleted extends \core\event\base {
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'page_version';
$this->data['objecttable'] = 'ouwiki_versions';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/event/page_version_undeleted.php
Expand Up @@ -44,7 +44,7 @@ class page_version_undeleted extends \core\event\base {
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'page_version';
$this->data['objecttable'] = 'ouwiki_versions';
}

/**
Expand Down
53 changes: 53 additions & 0 deletions classes/task/daily_housekeeping.php
@@ -0,0 +1,53 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* A scheduled task for OUWiki cron.
*
* @package mod_ouwiki
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_ouwiki\task;

class daily_housekeeping extends \core\task\scheduled_task {

/**
* Get a descriptive name for this task (shown to admins).
*
* @return string
*/
public function get_name() {
return get_string('ouwikicrontask', 'mod_ouwiki');
}

/**
* Delete old locks from the ouwiki_locks database
*/
public function execute() {
global $DB, $CFG;
// Require to get OUWIKI_LOCK_TIMEOUT.
require_once($CFG->dirroot . '/mod/ouwiki/locallib.php');

$now = time();
// We are going to delete anything with a locked at time longer than now - 30 minutes ago.
$timeout = $now - OUWIKI_LOCK_TIMEOUT;
mtrace('Beginning ouwiki locks cleanup...');
$before = microtime(true);
$DB->delete_records_select('ouwiki_locks', 'lockedat < ?', array($timeout));
mtrace(round(microtime(true)-$before, 1) . 's');
}
}
2 changes: 1 addition & 1 deletion csv_writer.php
Expand Up @@ -76,7 +76,7 @@ public function __construct($filename, $format = null) {
*/
public function quote($varstr) {
if ($this->_excelcsv) {
return textlib::convert('"'.str_replace('"', "'", $varstr).'"', 'UTF-8', 'UTF-16LE');
return core_text::convert('"'.str_replace('"', "'", $varstr).'"', 'UTF-8', 'UTF-16LE');
} else {
return '"'.str_replace('"', "'", $varstr).'"';
}
Expand Down
38 changes: 38 additions & 0 deletions db/tasks.php
@@ -0,0 +1,38 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Definition of Forum scheduled tasks.
*
* @package mod_ouwiki
* @category task
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

$tasks = array(
array(
'classname' => 'mod_ouwiki\task\daily_housekeeping',
'blocking' => 0,
'minute' => '45',
'hour' => '4',
'day' => '*',
'month' => '*',
'dayofweek' => '*'
)
);
1 change: 1 addition & 0 deletions history.php
Expand Up @@ -272,6 +272,7 @@ function ouw_check() {
</script>
';

$a = new stdClass();
$a->atom = $atomurl;
$a->rss = $rssurl;
print '<p class="ouw_subscribe"><a href="'.$atomurl.'" title="'.get_string('feedalt', 'ouwiki').
Expand Down
1 change: 1 addition & 0 deletions lang/en/ouwiki.php
Expand Up @@ -582,3 +582,4 @@
$string['event:ouwikidelete'] = 'ouwiki version delete';
$string['event:ouwikipagecreated'] = 'ouwiki page created';
$string['event:ouwikipageupdated'] = 'ouwiki page updated';
$string['ouwikicrontask'] = 'OU wiki maintenance jobs';
15 changes: 0 additions & 15 deletions lib.php
Expand Up @@ -722,21 +722,6 @@ function ouwiki_cm_info_dynamic(cm_info $cm) {
}
}

function ouwiki_cron() {
global $CFG;

require_once($CFG->dirroot . '/mod/ouwiki/mod_ouwiki_cron.php');

try {
mod_ouwiki_cron::cron();
} catch (moodle_exception $e) {
mtrace("An ouwiki exception occurred and ouwiki cron was aborted: " .
$e->getMessage() . "\n\n" .
$e->debuginfo . "\n\n" .
$e->getTraceAsString()."\n\n");
}
}

/**
* List of view style log actions
* @return array
Expand Down
18 changes: 9 additions & 9 deletions locallib.php
Expand Up @@ -681,7 +681,7 @@ function ouwiki_get_current_page($subwiki, $pagename, $option = OUWIKI_GETPAGE_R

$params = array($subwiki->id);
$pagename_s = 'UPPER(p.title) = ?';
$params[] = textlib::strtoupper($pagename);
$params[] = core_text::strtoupper($pagename);

$jointype = $option == OUWIKI_GETPAGE_REQUIREVERSION ? 'JOIN' : 'LEFT JOIN';

Expand Down Expand Up @@ -714,7 +714,7 @@ function ouwiki_get_current_page($subwiki, $pagename, $option = OUWIKI_GETPAGE_R
}

// Update any missing link records that might exist
$uppertitle = textlib::strtoupper($pagename);
$uppertitle = core_text::strtoupper($pagename);
try {
$DB->execute("UPDATE {ouwiki_links}
SET tomissingpage = NULL, topageid = ?
Expand Down Expand Up @@ -804,7 +804,7 @@ function ouwiki_get_page_version($subwiki, $pagename, $versionid) {
LEFT JOIN {user} u ON v.userid = u.id
WHERE p.subwikiid = ? AND v.id = ? AND UPPER(p.title) = ?";

$pagename = textlib::strtoupper($pagename);
$pagename = core_text::strtoupper($pagename);
$pageversion = $DB->get_record_sql($sql, array($subwiki->id, $versionid, $pagename));

$pageversion->recentversions = false;
Expand Down Expand Up @@ -1974,8 +1974,8 @@ function ouwiki_save_new_version($course, $cm, $ouwiki, $subwiki, $pagename, $co
$link->tomissingpage = null;
foreach ($externallinks as $url) {
// Restrict length of URL
if (textlib::strlen($url) > 255) {
$url = textlib::substr($url, 0, 255);
if (core_text::strlen($url) > 255) {
$url = core_text::substr($url, 0, 255);
}
$link->tourl = $url;
try {
Expand Down Expand Up @@ -2067,11 +2067,11 @@ function ouwiki_get_wiki_link_details($wikilink) {

// Trim to 200 characters or less (note: because we don't want to cut it off
// in the middle of a character, we use proper UTF-8 functions)
if (textlib::strlen($wikilink) > 200) {
$wikilink = textlib::substr($wikilink, 0, 200);
$space = textlib::strrpos($wikilink, ' ');
if (core_text::strlen($wikilink) > 200) {
$wikilink = core_text::substr($wikilink, 0, 200);
$space = core_text::strrpos($wikilink, ' ');
if ($space > 150) {
$wikilink = textlib::substr($wikilink, 0, $space);
$wikilink = core_text::substr($wikilink, 0, $space);
}
}

Expand Down
83 changes: 0 additions & 83 deletions mod_ouwiki_cron.php

This file was deleted.

0 comments on commit 4c6904b

Please sign in to comment.