Commit a73d6f40 authored by Geoff Cant's avatar Geoff Cant Committed by nem@lisp.geek.nz
Browse files

Merge with /Volumes/FREYJA/pennymahara/

parents 85a95066 a3261ae7
......@@ -122,6 +122,16 @@ function xmldb_artefact_file_upgrade($oldversion=0) {
add_field($table, $field);
}
if ($oldversion < 2007042500) {
// migrate everything we had to change to make mysql happy
$prefix = get_config('dbprefix');
execute_sql("ALTER TABLE {$prefix}artefact_file_file_types ALTER COLUMN description TYPE varchar(32)");
execute_sql("ALTER TABLE {$prefix}artefact_file_mime_types ALTER COLUMN mimetype TYPE varchar(128)");
execute_sql("ALTER TABLE {$prefix}artefact_file_mime_types ALTER COLUMN description TYPE varchar(32)");
}
// everything up to here we pre mysql support.
return $status;
}
......
......@@ -181,6 +181,7 @@ class PluginArtefactFile extends PluginArtefact {
// list, add it to the current list.
foreach ($filetypes as $filetype) {
$type = $filetype['#']['description'][0]['#'];
error_log("looking for $type");
if (!in_array($type, $currentlist)) {
log_debug('Adding filetype: ' . $type);
$currentlist[] = $type;
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2007021401;
$config->version = 2007042500;
$config->release = '0.3.1';
?>
......@@ -30,6 +30,15 @@ function xmldb_artefact_internal_upgrade($oldversion=0) {
$status = true;
if ($oldversion < 2007042500) {
// migrate everything we had to change to make mysql happy
$prefix = get_config('dbprefix');
execute_sql("ALTER TABLE {$prefix}artefact_internal_profile_email ALTER COLUMN email TYPE varchar(255)");
execute_sql("ALTER TABLE {$prefix}artefact_internal_profile_icon ALTER COLUMN filename TYPE varchar(255)");
}
// everything up to here we pre mysql support.
return $status;
}
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2007010800;
$config->version = 2007042500;
$config->release = '0.1';
?>
......@@ -51,7 +51,7 @@ $createcommunity = pieform(array(
'name' => array(
'type' => 'text',
'title' => get_string('communityname'),
'rules' => array( 'required' => true ),
'rules' => array( 'required' => true, 'maxlength' => 128 ),
),
'description' => array(
'type' => 'wysiwyg',
......@@ -92,8 +92,6 @@ function createcommunity_submit(Pieform $form, $values) {
global $USER;
global $SESSION;
log_debug($values);
db_begin();
$now = db_format_timestamp(time());
......
......@@ -59,7 +59,7 @@ $editcommunity = pieform(array(
'name' => array(
'type' => 'text',
'title' => get_string('communityname'),
'rules' => array( 'required' => true ),
'rules' => array( 'required' => true, 'maxlength' => 128 ),
'defaultvalue' => $community_data->name,
),
'description' => array(
......@@ -110,8 +110,6 @@ function editcommunity_submit(Pieform $form, $values) {
$now = db_format_timestamp(time());
log_debug($values);
update_record(
'community',
(object) array(
......
......@@ -41,7 +41,7 @@ $userid = $USER->get('id');
if (empty($owned)) { // just get communities this user is a member of.
$data = get_member_communities($userid, $offset, $limit);
$count = get_record_sql('SELECT COUNT(c.*)
$count = get_record_sql('SELECT COUNT(c.id) AS count
FROM ' . $prefix . 'community c
JOIN ' . $prefix . 'community_member cm ON cm.community = c.id
WHERE c.owner != ? AND cm.member = ?', array($userid, $userid));
......@@ -52,7 +52,7 @@ else {
$count = count_records_sql('SELECT COUNT(*) FROM ' . $prefix . 'community c WHERE c.owner = ?',
array($userid));
$datasql = 'SELECT c.id,c.jointype,c.name,c.owner,count(cmr.community) as requestcount, COUNT(v.*) AS hasviews
$datasql = 'SELECT c.id,c.jointype,c.name,c.owner,count(cmr.community) as requestcount, COUNT(v.view) AS hasviews
FROM ' . $prefix . 'community c
LEFT JOIN ' . $prefix . 'community_member_request cmr ON cmr.community = c.id
LEFT JOIN ' . $prefix . 'view_access_community v ON v.community = c.id
......
......@@ -55,7 +55,7 @@ if ($action == 'delete') {
else {
$count = get_field('usr_group', 'COUNT(*)', 'owner', $USER->get('id'));
$data = get_records_sql_array(
'SELECT g.id, g.name, COUNT(m.*) AS count, (SELECT COUNT(*) FROM ' . $dbprefix . 'view_access_group vag WHERE vag.grp=g.id) FROM ' . $dbprefix . 'usr_group g INNER JOIN ' . $dbprefix . 'usr_group_member m ON m.grp=g.id WHERE g.owner=? GROUP BY 1, 2 ORDER BY g.name',
'SELECT g.id, g.name, COUNT(m.grp) AS count, (SELECT COUNT(*) FROM ' . $dbprefix . 'view_access_group vag WHERE vag.grp=g.id) FROM ' . $dbprefix . 'usr_group g INNER JOIN ' . $dbprefix . 'usr_group_member m ON m.grp=g.id WHERE g.owner=? GROUP BY 1, 2 ORDER BY g.name',
array($USER->get('id')),
$offset,
$limit
......
......@@ -78,7 +78,7 @@ function get_member_communities($userid=0, $offset=0, $limit=0) {
$userid = optional_userid($userid);
$prefix = get_config('dbprefix');
return get_records_sql_array('SELECT c.id, c.name, c.description, c.jointype, c.owner, c.ctime, c.mtime, cm.ctime, cm.tutor, COUNT(v.*) AS hasviews
return get_records_sql_array('SELECT c.id, c.name, c.description, c.jointype, c.owner, c.ctime, c.mtime, cm.ctime, cm.tutor, COUNT(v.view) AS hasviews
FROM ' . $prefix . 'community c
JOIN ' . $prefix . 'community_member cm ON cm.community = c.id
LEFT JOIN ' . $prefix . 'view_access_community v ON v.community = c.id
......
......@@ -247,6 +247,23 @@ function xmldb_core_upgrade($oldversion=0) {
upgrade_template('blogandprofile', $template);
}
if ($oldversion < 2007042500) {
// migrate everything we had to change to make mysql happy
execute_sql("ALTER TABLE {$prefix}cron DROP CONSTRAINT {$prefix}cron_cal_pk"); // can't drop primary keys using xmldb...
execute_sql("ALTER TABLE {$prefix}cron ADD CONSTRAINT {$prefix}cron_id_pk PRIMARY KEY (id)"); // or add them!
execute_sql("ALTER TABLE {$prefix}cron ADD CONSTRAINT {$prefix}cron_cal_uk UNIQUE (callfunction)");
execute_sql("ALTER TABLE {$prefix}community ALTER COLUMN name TYPE varchar (128)");
execute_sql("ALTER TABLE {$prefix}usr_activity_preference ALTER COLUMN method TYPE varchar(255)");
execute_sql("ALTER TABLE {$prefix}template_category ALTER COLUMN name TYPE varchar(128)");
execute_sql("ALTER TABLE {$prefix}template_category ALTER COLUMN parent TYPE varchar(128)");
execute_sql("ALTER TABLE {$prefix}template ALTER COLUMN name TYPE varchar(128)");
execute_sql("ALTER TABLE {$prefix}template ALTER COLUMN category TYPE varchar(128)");
execute_sql("ALTER TABLE {$prefix}view ALTER COLUMN template TYPE varchar(128)");
execute_sql("ALTER TABLE {$prefix}view_access ALTER COLUMN accesstype SET DEFAULT 'public'");
}
// everything up to here we pre mysql support.
return $status;
}
......
......@@ -1318,7 +1318,7 @@ function configure_dbconnection() {
increment_perf_db_writes();
$db->Execute("SET NAMES 'utf8'");
if ( is_mysql() ) {
if (is_mysql()) {
$db->Execute("SET SQL_MODE='POSTGRESQL'");
}
......
......@@ -352,7 +352,7 @@ function error ($code, $message, $file, $line, $vars) {
// Ignore errors from smarty templates, which happen all too often
if (function_exists('get_config')) {
$compiledir = get_config('dataroot') . 'smarty/compile';
$compiledir = realpath(get_config('dataroot') . 'smarty/compile');
if (E_NOTICE == $code && substr($file, 0, strlen($compiledir)) == $compiledir) {
return;
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2007042301;
$config->version = 2007042500;
$config->release = '0.8.0.dev';
$config->minupgradefrom = 2007011600;
$config->minupgraderelease = '0.4.0 (build tag BUILD_20070122)';
......
......@@ -75,11 +75,13 @@ class PluginSearchInternal extends PluginSearch {
$publicfields = array('preferredname');
}
$prefix = get_config('dbprefix');
if ( is_postgres() ) {
return search_user_pg($query_string, $limit, $offset, $prefix, $publicfields);
} else if ( is_mysql() ) {
return search_user_my($query_string, $limit, $offset, $prefix, $publicfields);
} else {
if (is_postgres()) {
return self::search_user_pg($query_string, $limit, $offset, $prefix, $publicfields);
}
else if (is_mysql()) {
return self::search_user_my($query_string, $limit, $offset, $prefix, $publicfields);
}
else {
throw new SQLException('search_user() is not implemented for your database engine (' . get_config('dbtype') . ')');
}
}
......@@ -257,11 +259,13 @@ class PluginSearchInternal extends PluginSearch {
* );
*/
public static function search_group($query_string, $limit, $offset = 0) {
if ( is_postgres() ) {
return search_group_pg($query_string, $limit, $offset);
} else if ( is_mysql() ) {
return search_group_my($query_string, $limit, $offset);
} else {
if (is_postgres()) {
return self::search_group_pg($query_string, $limit, $offset);
}
else if (is_mysql()) {
return self::search_group_my($query_string, $limit, $offset);
}
else {
throw new SQLException('search_group() is not implemented for your database engine (' . get_config('dbtype') . ')');
}
}
......@@ -385,11 +389,13 @@ class PluginSearchInternal extends PluginSearch {
* );
*/
public static function search_community($query_string, $limit, $offset=0, $all=false) {
if ( is_postgres() ) {
return search_community_pg($query_string, $limit, $offset, $all);
} else if ( is_mysql() ) {
return search_community_my($query_string, $limit, $offset, $all);
} else {
if (is_postgres()) {
return self::search_community_pg($query_string, $limit, $offset, $all);
}
else if (is_mysql()) {
return self::search_community_my($query_string, $limit, $offset, $all);
}
else {
throw new SQLException('search_community() is not implemented for your database engine (' . get_config('dbtype') . ')');
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment