Commit 1d8ae4fe authored by Penny Leach's avatar Penny Leach
Browse files

fixing stuff in mysql

parent e86d2073
......@@ -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));
......
......@@ -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
......
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