Project:
avelsieve
Code Location:
https://email.uoa.gr/repos/squirrelmail/avelsieve/main_plugin/trunk/avelsieve/main_plugin/trunk
Outline
- > Cn SM_PATH
ajax_handler.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php /** * User-friendly interface to SIEVE server-side mail filtering. * Plugin for Squirrelmail 1.4+ * * This page manages various XHR requests and sends the appropriate responses. * * Licensed under the GNU GPL. For full terms see the file COPYING that came * with the Squirrelmail distribution. * * @version $Id: ajax_handler.php 1063 2010-01-15 11:58:06Z avel $ * @author Alexandros Vellis <avel@users.sourceforge.net> * @copyright 2009 Alexandros Vellis * @package plugins * @subpackage avelsieve */ /** Includes */ if (file_exists('../../include/init.php')) { include_once('../../include/init.php'); } else if (file_exists('../../include/validate.php')) { define('SM_PATH','../../'); include_once(SM_PATH . 'include/validate.php'); include_once(SM_PATH . 'include/load_prefs.php'); } require(SM_PATH . 'plugins/avelsieve/config/config.php'); $prev = sq_bindtextdomain ('avelsieve', SM_PATH . 'plugins/avelsieve/locale'); textdomain ('avelsieve'); include_once(SM_PATH . 'functions/imap.php'); require_once(SM_PATH . 'plugins/avelsieve/include/constants.inc.php'); include_once(SM_PATH . 'plugins/avelsieve/include/html_rulestable.inc.php'); include_once(SM_PATH . 'plugins/avelsieve/include/html_ruleedit.inc.php'); include_once(SM_PATH . 'plugins/avelsieve/include/sieve_conditions.inc.php'); include_once(SM_PATH . 'plugins/avelsieve/include/sieve_actions.inc.php'); include_once(SM_PATH . 'plugins/avelsieve/include/sieve.inc.php'); include_once(SM_PATH . 'plugins/avelsieve/include/support.inc.php'); sqsession_is_active(); if(!isset($_REQUEST['avaction'])) exit; $action = $_REQUEST['avaction']; /* First off, common initialization code for many of the actions */ switch($action) { case 'edit_condition': case 'edit_condition_kind': case 'datetime_get_snippet': // TODO - perhaps avoid connecting to ManageSieve and use cached capabilities $backend_class_name = 'DO_Sieve_'.$avelsieve_backend; $s = new $backend_class_name; $s->init(); // $edit_class_name = 'avelsieve_html_edit_'. $type_get; $edit_class_name = 'avelsieve_html_edit'; $ruleobj = new $edit_class_name($s, 'edit'); break; default: break; } switch($action) { case 'edit_condition': $index = ( isset($_GET['index']) && is_numeric($_GET['index']) ) ? $_GET['index'] : 1; $type = isset($_GET['type']) ? $_GET['type'] : 1; $temprules = array( 'cond' => array( $index => array('type' => $type ) ) ); $ruleobj->set_rule_data($temprules); echo '<span id="condition_line_'.$index.'">'. $ruleobj->condition($index) .'</span>'; exit; case 'edit_condition_kind': /* Return a new condition line - when changing condition_kind. * Arguments: * index: numeric index of line * value: condition_kind to use */ $index = ( isset($_GET['index']) && is_numeric($_GET['index']) ) ? $_GET['index'] : 1; $value = isset($_GET['value']) ? $_GET['value'] : 'message'; $temprules = array( 'cond' => array( $index => array('kind' => $value ) ) ); $ruleobj->set_rule_data($temprules); echo '<span id="condition_line_'.$index.'">'. $ruleobj->condition($index) .'</span>'; exit; case 'datetime_get_snippet': $index = ( isset($_POST['index']) && is_numeric($_POST['index']) ) ? $_POST['index'] : 1; $name = isset($_POST['varname']) ? $_POST['varname'] : ''; $value = isset($_POST['varvalue']) ? $_POST['varvalue'] : ''; if(empty($name) || empty($value)) exit; $temprules = array( 'cond' => array( $index => array('type' => '1' ) ) ); $ruleobj->process_input($_POST, true); $cond = array(); if(isset($ruleobj->rule['cond']) && isset($ruleobj->rule['cond'][$index])) { $cond = $ruleobj->rule['cond'][$index]; } $myCondition = new avelsieve_condition_datetime($s, $temprules, $index); // XXX $htmlOut = $myCondition->ui_tree_output($name, $value); echo json_encode( array('html' => $htmlOut) ); exit; default: break; }
