You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

71 lines
2.7 KiB

<?php
/**
* @package tikiwiki
*/
// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
require_once('tiki-setup.php');
$access->check_feature(['feature_trackers', 'feature_ajax', 'wikiplugin_tracker']);
include_once('lib/wiki-plugins/wikiplugin_tracker.php');
$headerlib->clear_js(); // so store existing js for later and clear
$json_data = [];
$re = $userlib->get_group_info(isset($_REQUEST['chosenGroup']) ? $_REQUEST['chosenGroup'] : 'Registered');
if (! empty($re['usersTrackerId']) && ! empty($re['registrationUsersFieldIds'])) {
$json_data['res'] = wikiplugin_tracker(
'',
[
'trackerId' => $re['usersTrackerId'],
'fields' => explode(':', $re['registrationUsersFieldIds']),
'showdesc' => 'y',
'showmandatory' => 'y',
'embedded' => 'y',
'action' => tra('Register'),
'registration' => 'n',
'formtag' => 'n',
'_ajax_form_ins_id' => 'group',
]
);
$json_data['res'] .= $headerlib->output_js();
} else {
$json_data['res'] = '<div class="form-group row"><label class="col-sm-4 col-form-label">' . tr('Group') . '</label>' .
'<div class="col-sm-8"><div class="form-control"><span class="text-muted">' . $_REQUEST['chosenGroup'] . '</span></div></div></div>';
$json_data['debug'] = $re;
}
/*if ($prefs['feature_jquery_validation'] === 'y') { // dig out the new rules for the js validation
foreach ($headerlib->js as $rank) {
foreach ($rank as $js) {
if (strpos($js, 'ajaxTrackerValidation_group') !== false) {
if (preg_match('/validation:\{([\s\S]*?\})\s*\};/s', $js, $m)) { // get the rules and messages from the js function
//$m = preg_replace('/\s(?:ignore|submitHandler).* /', '', $m[1]); // lose a couple of duplicate options
$m = preg_replace('/,\s*\}\s*$/m', '}', $m[1]); // a trailing comma
$o = preg_replace_callback('/(\w*):/', 'group_tracker_ajax_quote', $m); // surround properties with double quotes
$json_data['validation'] = json_decode('{' . $o . '}');
}
}
}
}
}*/
/**
* @param $matches
* @return string
*/
function group_tracker_ajax_quote($matches)
{
return '"' . $matches[1] . '":';
}
header('Content-Type: application/json');
$access->output_serialized($json_data);