Increase length of City field MDL-19629 - longest place name in NZ is Taumata­whakatangihanga­koauau­o­tamatea­turi­pukakapiki­maunga­horo­nuku­pokai­whenua­kitanatahu which doesn't fit in 20 chars, I figure 100 chars should be enough

This commit is contained in:
Dan Marsden 2010-07-08 07:55:20 +00:00
parent 7851bd35ae
commit ba0c097216
11 changed files with 395 additions and 5 deletions

View file

@ -727,7 +727,7 @@
<FIELD NAME="institution" TYPE="char" LENGTH="40" NOTNULL="true" SEQUENCE="false" PREVIOUS="phone2" NEXT="department"/> <FIELD NAME="institution" TYPE="char" LENGTH="40" NOTNULL="true" SEQUENCE="false" PREVIOUS="phone2" NEXT="department"/>
<FIELD NAME="department" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false" PREVIOUS="institution" NEXT="address"/> <FIELD NAME="department" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false" PREVIOUS="institution" NEXT="address"/>
<FIELD NAME="address" TYPE="char" LENGTH="70" NOTNULL="true" SEQUENCE="false" PREVIOUS="department" NEXT="city"/> <FIELD NAME="address" TYPE="char" LENGTH="70" NOTNULL="true" SEQUENCE="false" PREVIOUS="department" NEXT="city"/>
<FIELD NAME="city" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" PREVIOUS="address" NEXT="country"/> <FIELD NAME="city" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" PREVIOUS="address" NEXT="country"/>
<FIELD NAME="country" TYPE="char" LENGTH="2" NOTNULL="true" SEQUENCE="false" PREVIOUS="city" NEXT="lang"/> <FIELD NAME="country" TYPE="char" LENGTH="2" NOTNULL="true" SEQUENCE="false" PREVIOUS="city" NEXT="lang"/>
<FIELD NAME="lang" TYPE="char" LENGTH="30" NOTNULL="true" DEFAULT="en" SEQUENCE="false" PREVIOUS="country" NEXT="theme"/> <FIELD NAME="lang" TYPE="char" LENGTH="30" NOTNULL="true" DEFAULT="en" SEQUENCE="false" PREVIOUS="country" NEXT="theme"/>
<FIELD NAME="theme" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" PREVIOUS="lang" NEXT="timezone"/> <FIELD NAME="theme" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" PREVIOUS="lang" NEXT="timezone"/>

View file

@ -4687,6 +4687,28 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
upgrade_main_savepoint(true, 2010070604); upgrade_main_savepoint(true, 2010070604);
} }
if ($oldversion < 2010070701) {
/// Before changing the field, drop dependent indexes
/// Define index shortname (not unique) to be dropped form course_request
$table = new xmldb_table('user');
$index = new xmldb_index('city', XMLDB_INDEX_NOTUNIQUE, array('city'));
/// Conditionally launch drop index shortname
if ($dbman->index_exists($table, $index)) {
$dbman->drop_index($table, $index);
}
/// Changing precision of field city on table user to (100)
$field = new xmldb_field('city', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, 'address');
/// Launch change of precision for field city
$dbman->change_field_precision($table, $field);
/// Conditionally launch add index typeitem_ix
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
/// Main savepoint reached
upgrade_main_savepoint(true, 2010070701);
}
return true; return true;
} }

View file

@ -3391,7 +3391,7 @@ function truncate_userinfo($info) {
'institution' => 40, 'institution' => 40,
'department' => 30, 'department' => 30,
'address' => 70, 'address' => 70,
'city' => 20, 'city' => 100,
'country' => 2, 'country' => 2,
'url' => 255, 'url' => 255,
); );

View file

@ -54,7 +54,7 @@ class login_signup_form extends moodleform {
$mform->setType('lastname', PARAM_TEXT); $mform->setType('lastname', PARAM_TEXT);
$mform->addRule('lastname', get_string('missinglastname'), 'required', null, 'server'); $mform->addRule('lastname', get_string('missinglastname'), 'required', null, 'server');
$mform->addElement('text', 'city', get_string('city'), 'maxlength="20" size="20"'); $mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="20"');
$mform->setType('city', PARAM_TEXT); $mform->setType('city', PARAM_TEXT);
$mform->addRule('city', get_string('missingcity'), 'required', null, 'server'); $mform->addRule('city', get_string('missingcity'), 'required', null, 'server');

View file

@ -0,0 +1,16 @@
<?php
$capabilities = array(
'repository/mahara:view' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'user' => CAP_ALLOW,
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
)
);

View file

@ -0,0 +1,20 @@
<?php
function xmldb_repository_mahara_upgrade($oldversion) {
global $CFG, $DB;
$dbman = $DB->get_manager();
$result = true;
/// And upgrade begins here. For each one, you'll need one
/// block of code similar to the next one. Please, delete
/// this comment lines once this file start handling proper
/// upgrade code.
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
/// $result = result of database_manager methods
/// }
return $result;
}

314
repository/mahara/lib.php Executable file
View file

@ -0,0 +1,314 @@
<?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/>.
/**
* repository_mahara class
* This plugin allowed to connect a retrieve a file from Mahara site
* This is a subclass of repository class
*
* @since 2.0
* @package moodlecore
* @subpackage repository
* @copyright 2009 Jerome Mouneyrac <mouneyrac@moodle.org>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once($CFG->dirroot.'/repository/lib.php');
class repository_mahara extends repository {
/**
* Constructor
* @global object $CFG
* @param int $repositoryid
* @param int $context
* @param array $options
*/
public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array()) {
global $CFG;
parent::__construct($repositoryid, $context, $options);
$this->mnet = get_mnet_environment();
}
/**
* Check if user logged in to mahara
* @global object $SESSION
* @return boolean
*/
public function check_login() {
//check session
global $SESSION;
return !empty($SESSION->loginmahara);
}
/**
* Display the file listing - no login required
* @global object $SESSION
* @return array
*/
public function print_login() {
global $SESSION, $CFG, $DB;
//jump to the peer to create a session
$mnetauth = get_auth_plugin('mnet');
$host = $DB->get_record('mnet_host',array('id' => $this->options['peer'])); //need to retrieve the host url
$url = $mnetauth->start_jump_session($host->id, '/repository/repository_callback.php?repo_id='.$this->id, true);
//set session
$SESSION->loginmahara = true;
$ret = array();
$popup_btn = new stdclass;
$popup_btn->type = 'popup';
$popup_btn->url = $url;
$ret['login'] = array($popup_btn);
return $ret;
}
/**
* Display the file listing for the search term
* @param string $search_text
* @return array
*/
public function search($search_text) {
return $this->get_listing('', '', $search_text);
}
/**
* Retrieve the file listing - file picker function
* @global object $CFG
* @global object $DB
* @global object $USER
* @param string $path
* @param string $page
* @param string $search
* @return array
*/
public function get_listing($path = null, $page = 1, $search = '') {
global $CFG, $DB, $USER, $OUTPUT;
///check that Mahara has a good version
///We also check that the "get file list" method has been activated (if it is not
///the method will not be returned by the system method system/listMethods)
require_once($CFG->dirroot . '/mnet/xmlrpc/client.php');
///check that the peer has been setup
if (!array_key_exists('peer',$this->options)) {
echo json_encode(array('e'=>get_string('error').' 9010: '.get_string('hostnotfound','repository_mahara')));
return false;
}
$host = $DB->get_record('mnet_host',array('id' => $this->options['peer'])); //need to retrieve the host url
///check that the peer host exists into the database
if (empty($host)) {
echo json_encode(array('e'=>get_string('error').' 9011: '.get_string('hostnotfound','repository_mahara')));
return false;
}
$mnet_peer = new mnet_peer();
$mnet_peer->set_wwwroot($host->wwwroot);
$client = new mnet_xmlrpc_client();
$client->set_method('system/listMethods');
$client->send($mnet_peer);
$services = $client->response;
if (empty($search)) {
$methodname = 'get_folder_files';
} else {
$methodname = 'search_folders_and_files';
}
if (array_key_exists('repository/mahara/lib.php/'.$methodname, $services) === false) {
echo json_encode(array('e'=>get_string('connectionfailure','repository_mahara')));
return false;
}
///connect to the remote moodle and retrieve the list of files
$client->set_method('repository/mahara/lib.php/'.$methodname);
$client->add_param($USER->username);
if (empty($search)) {
$client->add_param($path);
} else {
$client->add_param($search);
}
///call the method and manage host error
if (!$client->send($mnet_peer)) {
$message =" ";
foreach ($client->error as $errormessage) {
$message .= "ERROR: $errormessage . ";
}
echo json_encode(array('e'=>$message)); //display all error messages
return false;
}
$services = $client->response;
if (empty($search)) {
$newpath = $services[0];
$filesandfolders = $services[1];
} else {
$newpath = '';
$filesandfolders = $services;
}
///display error message if we could retrieve the list or if nothing were returned
if (empty($filesandfolders)) {
echo json_encode(array('e'=>get_string('failtoretrievelist','repository_mahara')));
return false;
}
$list = array();
if (!empty($filesandfolders['folders'])) {
foreach ($filesandfolders['folders'] as $folder) {
$list[] = array('path'=>$folder['id'], 'title'=>$folder['title'], 'date'=>$folder['mtime'], 'size'=>'0', 'children'=>array(), 'thumbnail' => $OUTPUT->pix_url('f/folder'));
}
}
if (!empty($filesandfolders['files'])) {
foreach ($filesandfolders['files'] as $file) {
if ($file['artefacttype'] == 'image') {
$thumbnail = $host->wwwroot."/artefact/file/download.php?file=".$file['id']."&size=70x55";
} else {
$thumbnail = $OUTPUT->pix_url(file_extension_icon( $file['title'], 32));
}
$list[] = array( 'title'=>$file['title'], 'date'=>$file['mtime'], 'source'=>$file['id'], 'thumbnail' => $thumbnail);
}
}
$filepickerlisting = array(
'path' => $newpath,
'dynload' => 1,
'nosearch' => 0,
'list'=> $list,
'manage'=> $host->wwwroot.'/artefact/file/'
);
return $filepickerlisting;
}
/**
* Download a file
* @global object $CFG
* @param string $url the url of file
* @param string $file save location
* @return string the location of the file
* @see curl package
*/
public function get_file($id, $file = '') {
global $CFG, $DB, $USER;
require_once($CFG->dirroot . '/mnet/xmlrpc/client.php');
///set mnet environment and set the mnet host
$host = $DB->get_record('mnet_host',array('id' => $this->options['peer'])); //retrieve the host url
$mnet_peer = new mnet_peer();
$mnet_peer->set_wwwroot($host->wwwroot);
///create the client and set the method to call
$client = new mnet_xmlrpc_client();
$client->set_method('repository/mahara/lib.php/get_file');
$client->add_param($USER->username);
$client->add_param($id);
///call the method and manage host error
if (!$client->send($mnet_peer)) {
$message =" ";
foreach ($client->error as $errormessage) {
$message .= "ERROR: $errormessage . ";
}
echo json_encode(array('e'=>$message));
exit;
}
$services = $client->response; //service contains the file content in the first case of the array,
//and the filename in the second
//the content has been encoded in base64, need to decode it
$content = base64_decode($services[0]);
$file = $services[1]; //filename
///create a temporary folder with a file
$path = $this->prepare_file($file);
///fill the file with the content
$fp = fopen($path, 'w');
fwrite($fp,$content);
fclose($fp);
return array('path'=>$path);
}
/**
* Add Instance settings input to Moodle form
* @global object $CFG
* @global object $DB
* @param object $mform
*/
public function instance_config_form($mform) {
global $CFG, $DB;
//retrieve only Moodle peers
$hosts = $DB->get_records_sql(' SELECT
h.id,
h.wwwroot,
h.ip_address,
h.name,
h.public_key,
h.public_key_expires,
h.transport,
h.portno,
h.last_connect_time,
h.last_log_id,
h.applicationid,
a.name as app_name,
a.display_name as app_display_name,
a.xmlrpc_server_url
FROM {mnet_host} h
JOIN {mnet_application} a ON h.applicationid=a.id
WHERE
h.id <> ? AND
h.deleted = 0 AND
a.name = ? AND
h.name <> ?',
array($CFG->mnet_localhost_id, 'mahara', 'All Hosts'));
$peers = array();
foreach($hosts as $host) {
$peers[$host->id] = $host->name;
}
$mform->addElement('select', 'peer', get_string('peer', 'repository_mahara'),$peers);
$mform->addRule('peer', get_string('required'), 'required', null, 'client');
if (empty($peers)) {
$mform->addElement('static', null, '', get_string('nopeer','repository_mahara'));
}
}
/**
* Names of the instance settings
* @return int
*/
public static function get_instance_option_names() {
///the administrator just need to set a peer
return array('peer');
}
public function supported_returntypes() {
return FILE_INTERNAL;
}
}

BIN
repository/mahara/pix/icon.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

View file

@ -0,0 +1,18 @@
<?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/>.
$plugin->version = 2010021804;

View file

@ -187,7 +187,7 @@ function useredit_shared_definition(&$mform, $editoroptions = null) {
$mform->setDefault('screenreader', 0); $mform->setDefault('screenreader', 0);
$mform->addHelpButton('screenreader', 'screenreaderuse'); $mform->addHelpButton('screenreader', 'screenreaderuse');
$mform->addElement('text', 'city', get_string('city'), 'maxlength="20" size="21"'); $mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="21"');
$mform->setType('city', PARAM_MULTILANG); $mform->setType('city', PARAM_MULTILANG);
$mform->addRule('city', $strrequired, 'required', null, 'client'); $mform->addRule('city', $strrequired, 'required', null, 'client');

View file

@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine // This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php) // whether upgrades should be performed (see lib/db/*.php)
$version = 2010070700; // YYYYMMDD = date of the last version bump $version = 2010070701; // YYYYMMDD = date of the last version bump
// XX = daily increments // XX = daily increments
$release = '2.0 Preview 4+ (Build: 20100708)'; // Human-friendly version name $release = '2.0 Preview 4+ (Build: 20100708)'; // Human-friendly version name