Commit 2443fd81 authored by Martyn Smith's avatar Martyn Smith Committed by Martyn Smith
Browse files
parents abb960d4 4e88aee1
......@@ -1324,7 +1324,7 @@ span.block_targetted, div.block_targetted {
font-weight: bold;
padding: 0 0 3px 0;
text-align: right;
width: 132px;
width: 137px;
}
#createview4 #createview4_accesslist_container {
......
......@@ -35,7 +35,6 @@ $createid = param_integer('createid', null);
$data = $SESSION->get('create_' . $createid);
log_debug($data);
$form = array(
'name' => 'createview4',
'elements' => array(
......@@ -56,9 +55,6 @@ function createview4_submit_cancel() {
function createview4_submit(Pieform $form, $values) {
global $SESSION, $USER, $createid, $data;
log_debug($values);
log_debug($data);
if (param_boolean('back')) {
$data['accesslist'] = array_values((array)$values['accesslist']);
......@@ -112,32 +108,35 @@ function createview4_submit(Pieform $form, $values) {
}
// View access
foreach ($values['accesslist'] as $item) {
$accessrecord = new StdClass;
$accessrecord->view = $viewid;
$accessrecord->startdate = db_format_timestamp($item['startdate']);
$accessrecord->stopdate = db_format_timestamp($item['stopdate']);
switch ($item['type']) {
case 'public':
case 'loggedin':
case 'friends':
$accessrecord->accesstype = $item['type'];
insert_record('view_access', $accessrecord);
break;
case 'user':
$accessrecord->usr = $item['id'];
insert_record('view_access_usr', $accessrecord);
break;
case 'group':
$accessrecord->grp = $item['id'];
insert_record('view_access_group', $accessrecord);
break;
case 'community':
$accessrecord->community = $item['id'];
insert_record('view_access_community', $accessrecord);
break;
if ($values['accesslist']) {
foreach ($values['accesslist'] as $item) {
$accessrecord = new StdClass;
$accessrecord->view = $viewid;
$accessrecord->startdate = db_format_timestamp($item['startdate']);
$accessrecord->stopdate = db_format_timestamp($item['stopdate']);
switch ($item['type']) {
case 'public':
case 'loggedin':
case 'friends':
$accessrecord->accesstype = $item['type'];
insert_record('view_access', $accessrecord);
break;
case 'user':
$accessrecord->usr = $item['id'];
insert_record('view_access_usr', $accessrecord);
break;
case 'group':
$accessrecord->grp = $item['id'];
insert_record('view_access_group', $accessrecord);
break;
case 'community':
$accessrecord->community = $item['id'];
insert_record('view_access_community', $accessrecord);
break;
}
}
}
db_commit();
$SESSION->add_ok_msg(get_string('viewcreatedsuccessfully', 'view'));
redirect(get_config('wwwroot') . 'view/');
......
......@@ -40,16 +40,19 @@ $smarty = smarty(array('tablerenderer'), pieform_element_calendar_get_headdata(p
$viewid = param_integer('viewid');
$prefix = get_config('dbprefix');
if (!$data = get_records_sql_array('SELECT va.accesstype AS type, va.startdate, va.stopdate
FROM ' . $prefix . 'view v
LEFT JOIN ' . $prefix . 'view_access va ON (va.view = v.id)
if (!get_field('view', 'COUNT(*)', 'id', $viewid, 'owner', $USER->get('id'))) {
$SESSION->add_error_msg(get_string('canteditdontown', 'view'));
redirect('view/');
}
$data = get_records_sql_array('SELECT va.accesstype AS type, va.startdate, va.stopdate
FROM ' . $prefix . 'view_access va
LEFT JOIN ' . $prefix . 'view v ON (va.view = v.id)
WHERE v.id = ?
AND v.owner = ?
ORDER BY va.accesstype', array($viewid, $USER->get('id')))) {
$SESSION->add_error_msg(get_string('canteditdontown', 'view'));
redirect(get_config('wwwroot') . 'view/');
ORDER BY va.accesstype', array($viewid, $USER->get('id')));
if (!$data) {
$data = array();
}
foreach ($data as &$item) {
$item = (array)$item;
}
......
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