forked from changi67/tiki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
group_tracker_ajax.php
63 lines (57 loc) · 2.02 KB
/
group_tracker_ajax.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* @package tikiwiki
*/
// (c) Copyright 2002-2013 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(array('feature_trackers', 'feature_ajax', 'wikiplugin_tracker'));
include_once ('lib/wiki-plugins/wikiplugin_tracker.php');
$json_data = array();
$re = $userlib->get_group_info(isset($_REQUEST['chosenGroup']) ? $_REQUEST['chosenGroup'] : 'Registered');
if (!empty($re['usersTrackerId']) && !empty($re['registrationUsersFieldIds'])) {
$json_data['res'] = wikiplugin_tracker(
'',
array(
'trackerId' => $re['usersTrackerId'],
'fields' => $re['registrationUsersFieldIds'],
'showdesc' => 'y',
'showmandatory' => 'y',
'embedded' => 'y',
'action' => tra('Register'),
'registration' => 'n',
'formtag'=>'n',
'_ajax_form_ins_id' => 'group',
)
);
} else {
$json_data['res'] = $_REQUEST['chosenGroup'];
$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);