forked from craigk5n/webcalendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax.php
77 lines (68 loc) · 2.42 KB
/
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
* Description
* This is the handler for Ajax httpXmlRequests.
*/
require_once 'includes/translate.php';
require_once 'includes/classes/WebCalendar.php';
$WebCalendar = new WebCalendar( __FILE__ );
require_once 'includes/config.php';
require_once 'includes/dbi4php.php';
require_once 'includes/formvars.php';
require_once 'includes/functions.php';
$WebCalendar->initializeFirstPhase();
require_once "includes/$user_inc";
require_once 'includes/access.php';
require_once 'includes/validate.php';
$WebCalendar->initializeSecondPhase();
load_global_settings();
load_user_preferences();
$WebCalendar->setLanguage();
$cat_id = getValue ( 'cat_id', '-?[0-9]*', true );
$name = getValue ( 'name' );
$page = getValue ( 'page' );
// We're processing edit_remotes Calendar ID field.
if ( $page == 'edit_remotes' || $page == 'edit_nonuser' ) {
$res = dbi_execute ( 'SELECT cal_login FROM webcal_nonuser_cals
WHERE cal_login = ?', [$NONUSER_PREFIX . $name] );
if ( $res ) {
$row = dbi_fetch_row ( $res );
// Presuming we are using '_NUC_' as $NONUSER_PREFIX.
if ( $name == substr ( $row[0], strlen ( $NONUSER_PREFIX ) ) )
echo str_replace ( 'XXX', $name, translate ( 'Duplicate Name XXX', true ) );
}
} elseif ( $page == 'register' || $page == 'edit_user' ) {
// We're processing username field.
$res = dbi_execute ( 'SELECT cal_login
FROM webcal_user
WHERE cal_login = ?', [$name] );
if ( $res ) {
$row = dbi_fetch_row ( $res );
if ( $row && $row[0] == $name )
echo str_replace ( 'XXX', $name,
translate ( 'Username XXX already exists.', true ) );
}
} elseif ( $page == 'email' ) {
// We're processing email field from any page.
$res = dbi_execute ( 'SELECT cal_email
FROM webcal_user
WHERE cal_email = ?', [$name] );
if ( $res ) {
$row = dbi_fetch_row ( $res );
if ( $row[0] == $name )
echo str_replace ( 'XXX', $name,
translate ( 'Email address XXX already exists.', true ) );
}
} elseif ( $page == 'minitask' ) {
$name = ( empty ( $name ) ? 0 : $name );
require_once 'includes/classes/Event.class';
require_once 'includes/classes/RptEvent.class';
require_once 'includes/gradient.php';
$column_array = ['we.cal_priority', 'we.cal_name', 'we.cal_due_date', 'weu.cal_percent'];
$task_filter = ' ORDER BY ' . $column_array[$name % 4]
. ( $name > 3 ? ' ASC' : ' DESC' );
echo display_small_tasks ( $cat_id );
} else {
echo "Invalid page: $page \n";
}
?>