Merge lp:~chamindra/sahana-agasti/sahana-relief-0.1 into lp:~sahana-relief-team/sahana-agasti/trunk
- sahana-relief-0.1
- Merge into trunk
Proposed by
chamindra
Status: | Merged |
---|---|
Merge reported by: | chamindra |
Merged at revision: | not available |
Proposed branch: | lp:~chamindra/sahana-agasti/sahana-relief-0.1 |
Merge into: | lp:~sahana-relief-team/sahana-agasti/trunk |
Diff against target: | 693 lines |
To merge this branch: | bzr merge lp:~chamindra/sahana-agasti/sahana-relief-0.1 |
Related bugs: | |
Related blueprints: |
Sahana Relief 2 Customizations
(Undefined)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
chamindra | Approve | ||
Ajay Kumar | Approve | ||
Gavin Treadgold (community) | Approve | ||
Review via email: mp+15002@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
chamindra (chamindra) wrote : | # |
Revision history for this message
Ajay Kumar (ajuonline) : | # |
review:
Approve
Revision history for this message
Ajay Kumar (ajuonline) : | # |
review:
Needs Resubmitting
Revision history for this message
Gavin Treadgold (gt) wrote : | # |
From a domain (not code perspective) - very keen to have this merge approved. Very useful functionality.
AJ - why did you suggest a resubmit?
review:
Approve
Revision history for this message
Ajay Kumar (ajuonline) wrote : | # |
Earlier Approve/Resubmit was done in error :)
OK for merge.
review:
Approve
Revision history for this message
chamindra (chamindra) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'inc/lib_gis/plugins/openlayers/openlayers_fns.php' (properties changed: -x to +x) | |||
2 | --- inc/lib_gis/plugins/openlayers/openlayers_fns.php 2009-11-10 23:51:44 +0000 | |||
3 | +++ inc/lib_gis/plugins/openlayers/openlayers_fns.php 2009-11-18 18:15:32 +0000 | |||
4 | @@ -521,8 +521,12 @@ | |||
5 | 521 | if (1==$conf["gis_ol_kml_".$i."_enabled"]) { | 521 | if (1==$conf["gis_ol_kml_".$i."_enabled"]) { |
6 | 522 | $name = $conf["gis_ol_kml_".$i."_name"]; | 522 | $name = $conf["gis_ol_kml_".$i."_name"]; |
7 | 523 | $url = $conf["gis_ol_kml_".$i."_url"]; | 523 | $url = $conf["gis_ol_kml_".$i."_url"]; |
10 | 524 | $file=end(explode('/',$url)); | 524 | |
11 | 525 | $ext=end(explode('.',$url)); | 525 | #$file=end(explode('/',$url)); |
12 | 526 | # Changed to provide a kml extension by default | ||
13 | 527 | $file = md5($url).".kml"; | ||
14 | 528 | $ext = "kml"; #end(explode('.',$url)); | ||
15 | 529 | |||
16 | 526 | $path = $dir."/".$file; | 530 | $path = $dir."/".$file; |
17 | 527 | $ch = curl_init(); | 531 | $ch = curl_init(); |
18 | 528 | curl_setopt($ch, CURLOPT_URL,$url); | 532 | curl_setopt($ch, CURLOPT_URL,$url); |
19 | 529 | 533 | ||
20 | === modified file 'inst/setup_pages.inc' | |||
21 | --- inst/setup_pages.inc 2009-11-10 23:51:44 +0000 | |||
22 | +++ inst/setup_pages.inc 2009-11-18 18:15:32 +0000 | |||
23 | @@ -65,7 +65,8 @@ | |||
24 | 65 | } | 65 | } |
25 | 66 | 66 | ||
26 | 67 | // Check if php-gettext is loaded | 67 | // Check if php-gettext is loaded |
28 | 68 | $value = (extension_loaded('gettext')); | 68 | // TODO: Fix this in Portable app |
29 | 69 | /* $value = (extension_loaded('gettext')); | ||
30 | 69 | $isOK &= $value; | 70 | $isOK &= $value; |
31 | 70 | 71 | ||
32 | 71 | if ($value) { | 72 | if ($value) { |
33 | @@ -74,7 +75,7 @@ | |||
34 | 74 | shn_form_label(_t('PHP-gettext Library'), $cross_img."is not installed"); | 75 | shn_form_label(_t('PHP-gettext Library'), $cross_img."is not installed"); |
35 | 75 | echo "<p><br/>$oops_img Sahana needs PHP-gettext for to support local languages. Please install PHP-gettext and restart the webserver. To find out how to do this for your operating system see <a href=\"http://www.sahana.lk/wiki/doku.php?id=manual:install\">Sahana WIKI</a></p>"; | 76 | echo "<p><br/>$oops_img Sahana needs PHP-gettext for to support local languages. Please install PHP-gettext and restart the webserver. To find out how to do this for your operating system see <a href=\"http://www.sahana.lk/wiki/doku.php?id=manual:install\">Sahana WIKI</a></p>"; |
36 | 76 | } | 77 | } |
38 | 77 | 78 | */ | |
39 | 78 | $value = (extension_loaded('mysql')); | 79 | $value = (extension_loaded('mysql')); |
40 | 79 | $isOK &= $value; | 80 | $isOK &= $value; |
41 | 80 | 81 | ||
42 | 81 | 82 | ||
43 | === modified file 'inst/setup_validations.inc' | |||
44 | --- inst/setup_validations.inc 2009-11-10 23:51:44 +0000 | |||
45 | +++ inst/setup_validations.inc 2009-11-18 18:15:32 +0000 | |||
46 | @@ -48,7 +48,7 @@ | |||
47 | 48 | if (!version_compare(phpversion(), '5', '>')) $continue = false; | 48 | if (!version_compare(phpversion(), '5', '>')) $continue = false; |
48 | 49 | if (!extension_loaded('gd')) $continue = false; | 49 | if (!extension_loaded('gd')) $continue = false; |
49 | 50 | if (!extension_loaded('mysql')) $continue = false; | 50 | if (!extension_loaded('mysql')) $continue = false; |
51 | 51 | if (!extension_loaded('gettext')) $continue = false; | 51 | // TODO: fix gettext in potable apps // if (!extension_loaded('gettext')) $continue = false; |
52 | 52 | if (!is_writable($global['approot'].'www/tmp')) $continue = false; | 52 | if (!is_writable($global['approot'].'www/tmp')) $continue = false; |
53 | 53 | if (!is_writable($global['approot'].'conf')) $continue = false; | 53 | if (!is_writable($global['approot'].'conf')) $continue = false; |
54 | 54 | return $continue; | 54 | return $continue; |
55 | 55 | 55 | ||
56 | === modified file 'mod/msg/lib_sms_errors.inc' (properties changed: -x to +x) | |||
57 | --- mod/msg/lib_sms_errors.inc 2009-11-10 23:51:44 +0000 | |||
58 | +++ mod/msg/lib_sms_errors.inc 2009-11-18 18:15:32 +0000 | |||
59 | @@ -1,1 +1,47 @@ | |||
60 | 1 | <?php | ||
61 | 2 | /** | 1 | /** |
62 | 3 | * | 2 | * |
63 | 4 | * This is a SMS error handler, you can create and manage a SMS error message container | 3 | * This is a SMS error handler, you can create and manage a SMS error message container |
64 | 5 | * and send the errors via SMS to users accessing Sahana through SMS. | 4 | * and send the errors via SMS to users accessing Sahana through SMS. |
65 | 6 | * Developers should note the fact that, error message length should preferably be less than 160 characters | 5 | * Developers should note the fact that, error message length should preferably be less than 160 characters |
66 | 7 | * which is the standard SMS length. Text greater than 160 characters should also be supported but should | 6 | * which is the standard SMS length. Text greater than 160 characters should also be supported but should |
67 | 8 | * ideally be avoided. Make sure you dont print/echo any message in PHP/HTML as this is supposed to be | 7 | * ideally be avoided. Make sure you dont print/echo any message in PHP/HTML as this is supposed to be |
68 | 9 | * dealt via an SMS session, so no echoing of messages. Supress all echo strings or use it for debugging only. | 8 | * dealt via an SMS session, so no echoing of messages. Supress all echo strings or use it for debugging only. |
69 | 10 | * Echoing any strings will break the SMS message text formation and break the session resulting in user not | 9 | * Echoing any strings will break the SMS message text formation and break the session resulting in user not |
70 | 11 | * getting any response to his SMS. | 10 | * getting any response to his SMS. |
71 | 12 | * | 11 | * |
72 | 13 | * PHP version 4 and 5 | 12 | * PHP version 4 and 5 |
73 | 14 | * | 13 | * |
74 | 15 | * LICENSE: This source file is subject to LGPL license | 14 | * LICENSE: This source file is subject to LGPL license |
75 | 16 | * that is available through the world-wide-web at the following URI: | 15 | * that is available through the world-wide-web at the following URI: |
76 | 17 | * http://www.gnu.org/copyleft/lesser.html | 16 | * http://www.gnu.org/copyleft/lesser.html |
77 | 18 | * | 17 | * |
78 | 19 | * @package moduleAPI | 18 | * @package moduleAPI |
79 | 20 | * @subpackage errors | 19 | * @subpackage errors |
80 | 21 | * @author Ajay Kumar <ajuonline at gmail dot com><aj at mindtakers dot com> | 20 | * @author Ajay Kumar <ajuonline at gmail dot com><aj at mindtakers dot com> |
81 | 22 | * @copyright Lanka Software Foundation - http://www.opensource.lk | 21 | * @copyright Lanka Software Foundation - http://www.opensource.lk |
82 | 23 | * @version $Id: lib_sms_errors.inc,v 1.3 2008/11/09 10:52:49 ajuonline Exp $ | 22 | * @version $Id: lib_sms_errors.inc,v 1.3 2008/11/09 10:52:49 ajuonline Exp $ |
83 | 24 | * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL) | 23 | * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL) |
84 | 25 | */ | 24 | */ |
85 | 26 | 25 | ||
86 | 27 | 26 | ||
87 | 28 | 27 | ||
88 | 29 | function _shn_msg_sms_error_code($error_code){ | 28 | function _shn_msg_sms_error_code($error_code){ |
89 | 30 | 29 | ||
90 | 31 | $error_code_messages = array( | 30 | $error_code_messages = array( |
91 | 32 | 31 | ||
92 | 33 | '1' => 'Invalid SMS Keyword Sent. Kindly send HELP to get the list of keywords.', | 32 | '1' => 'Invalid SMS Keyword Sent. Kindly send HELP to get the list of keywords.', |
93 | 34 | 33 | ||
94 | 35 | '2' => 'Sahana Server Error. Unable to connect to Data base. Please try later or contact Sahana Admin at.', | 34 | '2' => 'Sahana Server Error. Unable to connect to Data base. Please try later or contact Sahana Admin at.', |
95 | 36 | 35 | ||
96 | 37 | '3' => 'Login Failed : Invalid user name or password.', | 36 | '3' => 'Login Failed : Invalid user name or password.', |
97 | 38 | 37 | ||
98 | 39 | '4' => 'Login Failed : You have been banned by an administrator of the system.', | 38 | '4' => 'Login Failed : You have been banned by an administrator of the system.', |
99 | 40 | 39 | ||
100 | 41 | '5' => 'Login Failed : This account has been locked. Please contact the Administrator to unlock the account.', | 40 | '5' => 'Login Failed : This account has been locked. Please contact the Administrator to unlock the account.', |
101 | 42 | 41 | ||
102 | 43 | '6' => 'Login Failed : Password log attacked.', | 42 | '6' => 'Login Failed : Password log attacked.', |
103 | 44 | 43 | ||
104 | 45 | '7' => 'Login Failed : Account is not active yet. Contact Administrator to activate your account' | 44 | '7' => 'Login Failed : Account is not active yet. Contact Administrator to activate your account' |
105 | 46 | 45 | ||
106 | 47 | ); | 46 | ); |
107 | 48 | 47 | ||
108 | 49 | if(array_key_exists($error_code, $error_code_messages)){ | 48 | if(array_key_exists($error_code, $error_code_messages)){ |
109 | 50 | 49 | ||
110 | 51 | return $error_code_messages[$error_code]; | 50 | return $error_code_messages[$error_code]; |
111 | 52 | 51 | ||
112 | 53 | } | 52 | } |
113 | 54 | 53 | ||
114 | 55 | else{ | 54 | else{ |
115 | 56 | 55 | ||
116 | 57 | return 0; | 56 | return 0; |
117 | 58 | 57 | ||
118 | 59 | } | 58 | } |
119 | 60 | 59 | ||
120 | 61 | } | 60 | } |
121 | 62 | 61 | ||
122 | 63 | ?> | 62 | ?> |
123 | 64 | \ No newline at end of file | 63 | \ No newline at end of file |
124 | 64 | <?php | ||
125 | 65 | /** | ||
126 | 66 | * | ||
127 | 67 | * This is a SMS error handler, you can create and manage a SMS error message container | ||
128 | 68 | * and send the errors via SMS to users accessing Sahana through SMS. | ||
129 | 69 | * Developers should note the fact that, error message length should preferably be less than 160 characters | ||
130 | 70 | * which is the standard SMS length. Text greater than 160 characters should also be supported but should | ||
131 | 71 | * ideally be avoided. Make sure you dont print/echo any message in PHP/HTML as this is supposed to be | ||
132 | 72 | * dealt via an SMS session, so no echoing of messages. Supress all echo strings or use it for debugging only. | ||
133 | 73 | * Echoing any strings will break the SMS message text formation and break the session resulting in user not | ||
134 | 74 | * getting any response to his SMS. | ||
135 | 75 | * | ||
136 | 76 | * PHP version 4 and 5 | ||
137 | 77 | * | ||
138 | 78 | * LICENSE: This source file is subject to LGPL license | ||
139 | 79 | * that is available through the world-wide-web at the following URI: | ||
140 | 80 | * http://www.gnu.org/copyleft/lesser.html | ||
141 | 81 | * | ||
142 | 82 | * @package moduleAPI | ||
143 | 83 | * @subpackage errors | ||
144 | 84 | * @author Ajay Kumar <ajuonline at gmail dot com><aj at mindtakers dot com> | ||
145 | 85 | * @copyright Lanka Software Foundation - http://www.opensource.lk | ||
146 | 86 | * @version $Id: lib_sms_errors.inc,v 1.3 2008/11/09 10:52:49 ajuonline Exp $ | ||
147 | 87 | * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL) | ||
148 | 88 | */ | ||
149 | 89 | function _shn_msg_sms_error_code($error_code){ | ||
150 | 90 | |||
151 | 91 | $error_code_messages = array( | ||
152 | 92 | |||
153 | 93 | '1' => 'Invalid SMS Keyword Sent. Kindly send HELP to get the list of keywords.', | ||
154 | 94 | 'invalid_keyword' => 'Invalid SMS Keyword Sent. Kindly send HELP to get the list of keywords', | ||
155 | 95 | |||
156 | 96 | '2' => 'Sahana Server Error. Unable to connect to Data base. Please try later or contact Sahana Admin at.', | ||
157 | 97 | '3' => 'Login Failed : Invalid user name or password.', | ||
158 | 98 | '4' => 'Login Failed : You have been banned by an administrator of the system.', | ||
159 | 99 | '5' => 'Login Failed : This account has been locked. Please contact the Administrator to unlock the account.', | ||
160 | 100 | '6' => 'Login Failed : Password log attacked.', | ||
161 | 101 | '7' => 'Login Failed : Account is not active yet. Contact Administrator to activate your account' | ||
162 | 102 | ); | ||
163 | 103 | if(array_key_exists($error_code, $error_code_messages)){ | ||
164 | 104 | return $error_code_messages[$error_code]; | ||
165 | 105 | } | ||
166 | 106 | else{ | ||
167 | 107 | return 0; | ||
168 | 108 | } | ||
169 | 109 | } | ||
170 | 110 | ?> | ||
171 | 65 | 111 | ||
172 | === modified file 'mod/msg/lib_sms_handler.inc' (properties changed: -x to +x) | |||
173 | --- mod/msg/lib_sms_handler.inc 2009-11-10 23:51:44 +0000 | |||
174 | +++ mod/msg/lib_sms_handler.inc 2009-11-18 18:15:32 +0000 | |||
175 | @@ -1,1 +1,343 @@ | |||
176 | 1 | <?php | ||
177 | 2 | /** | 1 | /** |
178 | 3 | * | 2 | * |
179 | 4 | * This library helps in parsing and triggering functions based on SMS Input. A vital component of the framework. | 3 | * This library helps in parsing and triggering functions based on SMS Input. A vital component of the framework. |
180 | 5 | * Developers are required to use this library to facilitate SMS based transactions with the Sahana Core. | 4 | * Developers are required to use this library to facilitate SMS based transactions with the Sahana Core. |
181 | 6 | * | 5 | * |
182 | 7 | * | 6 | * |
183 | 8 | * PHP version 4 and 5 | 7 | * PHP version 4 and 5 |
184 | 9 | * | 8 | * |
185 | 10 | * LICENSE: This source file is subject to LGPL license | 9 | * LICENSE: This source file is subject to LGPL license |
186 | 11 | * that is available through the world-wide-web at the following URI: | 10 | * that is available through the world-wide-web at the following URI: |
187 | 12 | * http://www.gnu.org/copyleft/lesser.html | 11 | * http://www.gnu.org/copyleft/lesser.html |
188 | 13 | * | 12 | * |
189 | 14 | * @package framework | 13 | * @package framework |
190 | 15 | * @subpackage messaging | 14 | * @subpackage messaging |
191 | 16 | * @author Ajay Kumar <ajuonline at gmail dot com><aj at mindtakers dot com> | 15 | * @author Ajay Kumar <ajuonline at gmail dot com><aj at mindtakers dot com> |
192 | 17 | * @copyright Lanka Software Foundation - http://www.opensource.lk | 16 | * @copyright Lanka Software Foundation - http://www.opensource.lk |
193 | 18 | * @version $Id: lib_sms_handler.inc,v 1.2 2008/09/15 13:50:13 franboon Exp $ | 17 | * @version $Id: lib_sms_handler.inc,v 1.2 2008/09/15 13:50:13 franboon Exp $ |
194 | 19 | * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL) | 18 | * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL) |
195 | 20 | * | 19 | * |
196 | 21 | */ | 20 | */ |
197 | 22 | 21 | ||
198 | 23 | global $global; | 22 | global $global; |
199 | 24 | include_once $global['approot']."/mod/msg/lib_sms_errors.inc"; | 23 | include_once $global['approot']."/mod/msg/lib_sms_errors.inc"; |
200 | 25 | include_once $global['approot']."/mod/msg/lib_sms_keywords.inc"; | 24 | include_once $global['approot']."/mod/msg/lib_sms_keywords.inc"; |
201 | 26 | 25 | ||
202 | 27 | /** | 26 | /** |
203 | 28 | * This function will parse the incoming message string sent via GET & POST | 27 | * This function will parse the incoming message string sent via GET & POST |
204 | 29 | * Currently this function will be used by Kannel and SMSTools | 28 | * Currently this function will be used by Kannel and SMSTools |
205 | 30 | * It returns the array containing all words/strings, as single array values, sent in the SMS seperated by a SPACE | 29 | * It returns the array containing all words/strings, as single array values, sent in the SMS seperated by a SPACE |
206 | 31 | * For e.g. For a message string i.e. $message = "login user pass"; | 30 | * For e.g. For a message string i.e. $message = "login user pass"; |
207 | 32 | * $parsed_message[0]="login" | 31 | * $parsed_message[0]="login" |
208 | 33 | * $parsed_message[1]="user" | 32 | * $parsed_message[1]="user" |
209 | 34 | * $parsed_message[2]="pass" | 33 | * $parsed_message[2]="pass" |
210 | 35 | */ | 34 | */ |
211 | 36 | 35 | ||
212 | 37 | function _shn_msg_parse_short_message($message){ | 36 | function _shn_msg_parse_short_message($message){ |
213 | 38 | 37 | ||
214 | 39 | $parsed_message=array(); | 38 | $parsed_message=array(); |
215 | 40 | $parsed_message = explode(" ", $message); | 39 | $parsed_message = explode(" ", $message); |
216 | 41 | return $parsed_message; | 40 | return $parsed_message; |
217 | 42 | } | 41 | } |
218 | 43 | 42 | ||
219 | 44 | /** | 43 | /** |
220 | 45 | * This function will check the first word of the incoming message string | 44 | * This function will check the first word of the incoming message string |
221 | 46 | * and return the corresponding menu value only. | 45 | * and return the corresponding menu value only. |
222 | 47 | * For. e.g. as per our keyword definition file | 46 | * For. e.g. as per our keyword definition file |
223 | 48 | */ | 47 | */ |
224 | 49 | 48 | ||
225 | 50 | function _shn_msg_sms_keyword_check($keyword, $sender){ | 49 | function _shn_msg_sms_keyword_check($keyword, $sender){ |
226 | 51 | 50 | ||
227 | 52 | global $global; | 51 | global $global; |
228 | 53 | global $sms_list_keywords; | 52 | global $sms_list_keywords; |
229 | 54 | if(is_numeric($keyword)){ | 53 | if(is_numeric($keyword)){ |
230 | 55 | if(array_key_exists($keyword, $sms_list_keywords)){ | 54 | if(array_key_exists($keyword, $sms_list_keywords)){ |
231 | 56 | $keyword_check_result = array ('return' => '1', 'type' => 'number'); | 55 | $keyword_check_result = array ('return' => '1', 'type' => 'number'); |
232 | 57 | //echo " Key word valid and is number"; | 56 | //echo " Key word valid and is number"; |
233 | 58 | return $keyword_check_result; | 57 | return $keyword_check_result; |
234 | 59 | } | 58 | } |
235 | 60 | else{ | 59 | else{ |
236 | 61 | $error_message = _shn_msg_sms_error_code(1); | 60 | $error_message = _shn_msg_sms_error_code(1); |
237 | 62 | include_once $global['approot']."/mod/msg/plugins/"."$plugin_name"."/handler_"."$plugin_name".".inc"; | 61 | include_once $global['approot']."/mod/msg/plugins/"."$plugin_name"."/handler_"."$plugin_name".".inc"; |
238 | 63 | $recipients = array ($sender);//handler_plugin.inc send sms function accepts array as input for recipients | 62 | $recipients = array ($sender);//handler_plugin.inc send sms function accepts array as input for recipients |
239 | 64 | shn_msg_plugin_send_sm($recipients, $error_message); | 63 | shn_msg_plugin_send_sm($recipients, $error_message); |
240 | 65 | //shn_msg_store_sent_messages($recipients, $error_message); @todo check the current storage mechanism. smstools_log table | 64 | //shn_msg_store_sent_messages($recipients, $error_message); @todo check the current storage mechanism. smstools_log table |
241 | 66 | //echo "<br \>Error SMS: ".$error_message; | 65 | //echo "<br \>Error SMS: ".$error_message; |
242 | 67 | return 0; | 66 | return 0; |
243 | 68 | } | 67 | } |
244 | 69 | } | 68 | } |
245 | 70 | else{ | 69 | else{ |
246 | 71 | $bool = array_search($keyword, $sms_list_keywords); | 70 | $bool = array_search($keyword, $sms_list_keywords); |
247 | 72 | if(array_search($keyword, $sms_list_keywords)){ | 71 | if(array_search($keyword, $sms_list_keywords)){ |
248 | 73 | $keyword_check_result = array ('return' => '1', 'type' => 'word'); | 72 | $keyword_check_result = array ('return' => '1', 'type' => 'word'); |
249 | 74 | //echo " key word is valid and is WORD"; | 73 | //echo " key word is valid and is WORD"; |
250 | 75 | return $keyword_check_result; | 74 | return $keyword_check_result; |
251 | 76 | } | 75 | } |
252 | 77 | else{ | 76 | else{ |
253 | 78 | $error_message = _shn_msg_sms_error_code(1); | 77 | $error_message = _shn_msg_sms_error_code(1); |
254 | 79 | include_once $global['approot']."/mod/msg/plugins/"."$plugin_name"."/handler_"."$plugin_name".".inc"; | 78 | include_once $global['approot']."/mod/msg/plugins/"."$plugin_name"."/handler_"."$plugin_name".".inc"; |
255 | 80 | $recipients = array ($sender);//handler_plugin.inc send sms function accepts array as input for recipients | 79 | $recipients = array ($sender);//handler_plugin.inc send sms function accepts array as input for recipients |
256 | 81 | shn_msg_plugin_send_sm($recipients, $error_message); | 80 | shn_msg_plugin_send_sm($recipients, $error_message); |
257 | 82 | //shn_msg_store_sent_messages($recipients, $error_message); @todo check the current storage mechanism. smstools_log table | 81 | //shn_msg_store_sent_messages($recipients, $error_message); @todo check the current storage mechanism. smstools_log table |
258 | 83 | //echo "<br \> Error SMS: ".$error_message; | 82 | //echo "<br \> Error SMS: ".$error_message; |
259 | 84 | return 0; | 83 | return 0; |
260 | 85 | } | 84 | } |
261 | 86 | } | 85 | } |
262 | 87 | } | 86 | } |
263 | 88 | 87 | ||
264 | 89 | /** | 88 | /** |
265 | 90 | * This function will check the first word of the incoming message string | 89 | * This function will check the first word of the incoming message string |
266 | 91 | * and return the corresponding menu value only. | 90 | * and return the corresponding menu value only. |
267 | 92 | * For. e.g. as per our keyword definition file | 91 | * For. e.g. as per our keyword definition file |
268 | 93 | */ | 92 | */ |
269 | 94 | 93 | ||
270 | 95 | function _shn_msg_sms_action($parsed_sms, $sender_phone_number){ | 94 | function _shn_msg_sms_action($parsed_sms, $sender_phone_number){ |
271 | 96 | 95 | ||
272 | 97 | global $global; | 96 | global $global; |
273 | 98 | if(("help"==$parsed_sms[0]) || ("911"==$parsed_sms[0])){ | 97 | if(("help"==$parsed_sms[0]) || ("911"==$parsed_sms[0])){ |
274 | 99 | _shn_msg_sms_help($parsed_sms, $sender_phone_number); | 98 | _shn_msg_sms_help($parsed_sms, $sender_phone_number); |
275 | 100 | } | 99 | } |
276 | 101 | 100 | ||
277 | 102 | elseif(("login"==$parsed_sms[0]) || ("100"==$parsed_sms[0])){ | 101 | elseif(("login"==$parsed_sms[0]) || ("100"==$parsed_sms[0])){ |
278 | 103 | _shn_msg_sms_login($parsed_sms, $sender_phone_number); | 102 | _shn_msg_sms_login($parsed_sms, $sender_phone_number); |
279 | 104 | } | 103 | } |
280 | 105 | elseif(("sm"==$parsed_sms[0]) || ("3"==$parsed_sms[0])){ | 104 | elseif(("sm"==$parsed_sms[0]) || ("3"==$parsed_sms[0])){ |
281 | 106 | if("search"==$parsed_sms[1]){ | 105 | if("search"==$parsed_sms[1]){ |
282 | 107 | require_once $global['approot'] . "/inc/lib_gis/gis_fns.inc"; | 106 | require_once $global['approot'] . "/inc/lib_gis/gis_fns.inc"; |
283 | 108 | $keys = array('all' => '1'); | 107 | $keys = array('all' => '1'); |
284 | 109 | $features = shn_gis_get_features_in_radius($keys, $parsed_sms[2], $parsed_sms[3], $parsed_sms[4]); | 108 | $features = shn_gis_get_features_in_radius($keys, $parsed_sms[2], $parsed_sms[3], $parsed_sms[4]); |
285 | 110 | //print_r($features); | 109 | //print_r($features); |
286 | 111 | $count = count($features); | 110 | $count = count($features); |
287 | 112 | //echo "<br /> $count <br />"; | 111 | //echo "<br /> $count <br />"; |
288 | 113 | 112 | ||
289 | 114 | if($count){ | 113 | if($count){ |
290 | 115 | $final_results = array(); | 114 | $final_results = array(); |
291 | 116 | $i = 1; | 115 | $i = 1; |
292 | 117 | $message = "Results Found:\n"; | 116 | $message = "Results Found:\n"; |
293 | 118 | foreach($features as $a){ | 117 | foreach($features as $a){ |
294 | 119 | 118 | ||
295 | 120 | 119 | ||
296 | 121 | //$coords = shn_gis_coord_decode($a[f_coords]); | 120 | //$coords = shn_gis_coord_decode($a[f_coords]); |
297 | 122 | //print_r($coords); @ returns 2 values for 1 input. needed to check with GIS fns and figure out a way | 121 | //print_r($coords); @ returns 2 values for 1 input. needed to check with GIS fns and figure out a way |
298 | 123 | array_push($final_results, array("$a[f_name]", "$a[f_description]", "$a[f_coords]", "$a[f_event_date]")); | 122 | array_push($final_results, array("$a[f_name]", "$a[f_description]", "$a[f_coords]", "$a[f_event_date]")); |
299 | 124 | $message .= "$i. Name - $a[f_name]\nDescription: $a[f_description]\nGPS Loc: $a[f_coords]\nTimeStamp: $a[f_event_date]\n"; | 123 | $message .= "$i. Name - $a[f_name]\nDescription: $a[f_description]\nGPS Loc: $a[f_coords]\nTimeStamp: $a[f_event_date]\n"; |
300 | 125 | $i++; | 124 | $i++; |
301 | 126 | } | 125 | } |
302 | 127 | } | 126 | } |
303 | 128 | else{ | 127 | else{ |
304 | 129 | $message = "No Situations Found! Please try modifying your search."; | 128 | $message = "No Situations Found! Please try modifying your search."; |
305 | 130 | } | 129 | } |
306 | 131 | 130 | ||
307 | 132 | //print_r($final_results); | 131 | //print_r($final_results); |
308 | 133 | 132 | ||
309 | 134 | } | 133 | } |
310 | 135 | elseif("add"==$parsed_sms[1]){ | 134 | elseif("add"==$parsed_sms[1]){ |
311 | 136 | //Valid Input SMS format "sm add <name> <description> <gps_coords>" | 135 | //Valid Input SMS format "sm add <name> <description> <gps_coords>" |
312 | 137 | //Sample: "sm add (First Situation) (Description of the first situation) (77,78)" | 136 | //Sample: "sm add (First Situation) (Description of the first situation) (77,78)" |
313 | 138 | //Restructre parsed SMS Text | 137 | //Restructre parsed SMS Text |
314 | 139 | 138 | ||
315 | 140 | $full_sms_input_text = implode(" ", $parsed_sms); | 139 | $full_sms_input_text = implode(" ", $parsed_sms); |
316 | 141 | //Re-parsing as per Standard SM ADD format mentioned above | 140 | //Re-parsing as per Standard SM ADD format mentioned above |
317 | 142 | //$value = "sm add (First Situation) (Description of the first situation) (77,78)"; | 141 | //$value = "sm add (First Situation) (Description of the first situation) (77,78)"; |
318 | 143 | if (ereg ("(sm) (add) \((.+)\) \((.+)\) \(([0-9]{2,3}),([0-9]{2,3})\)", $full_sms_input_text, $regs)) | 142 | if (ereg ("(sm) (add) \((.+)\) \((.+)\) \(([0-9]{2,3}),([0-9]{2,3})\)", $full_sms_input_text, $regs)) |
319 | 144 | { | 143 | { |
320 | 145 | //print_r($regs); | 144 | //print_r($regs); |
321 | 146 | 145 | ||
322 | 147 | // Include for the GIS Database API. | 146 | // Include for the GIS Database API. |
323 | 148 | require_once $global['approot']."/inc/lib_security/lib_sms_auth.inc"; | 147 | require_once $global['approot']."/inc/lib_security/lib_sms_auth.inc"; |
324 | 149 | print_r($_SESSION); | 148 | print_r($_SESSION); |
325 | 150 | $f_name = $regs[3]; | 149 | $f_name = $regs[3]; |
326 | 151 | $f_description = $regs[4]; | 150 | $f_description = $regs[4]; |
327 | 152 | $f_author = shn_get_user_details($user_data['user_id']);; | 151 | $f_author = shn_get_user_details($user_data['user_id']);; |
328 | 153 | $f_event_date = date("Y-m-d H:i:s"); | 152 | $f_event_date = date("Y-m-d H:i:s"); |
329 | 154 | $marker_x_lat_coordinate = $regs[5]; | 153 | $marker_x_lat_coordinate = $regs[5]; |
330 | 155 | $marker_y_lng_coordinate = $regs[6]; | 154 | $marker_y_lng_coordinate = $regs[6]; |
331 | 156 | require_once $global['approot']."/inc/lib_gis/gis_fns.inc"; | 155 | require_once $global['approot']."/inc/lib_gis/gis_fns.inc"; |
332 | 157 | // Parse the Coordinates to wkt format. | 156 | // Parse the Coordinates to wkt format. |
333 | 158 | $coords_center = array($marker_x_lat_coordinate, $marker_y_lng_coordinate, 0); | 157 | $coords_center = array($marker_x_lat_coordinate, $marker_y_lng_coordinate, 0); |
334 | 159 | $coords = array($coords_center, $coords_center); | 158 | $coords = array($coords_center, $coords_center); |
335 | 160 | $coordinates = shn_gis_coord_encode($coords, 'point'); | 159 | $coordinates = shn_gis_coord_encode($coords, 'point'); |
336 | 161 | 160 | ||
337 | 162 | // Register the values that will make the new feature as an array of key => values. | 161 | // Register the values that will make the new feature as an array of key => values. |
338 | 163 | $keys_ = array( | 162 | $keys_ = array( |
339 | 164 | 'f_type' => 'point', | 163 | 'f_type' => 'point', |
340 | 165 | 'f_projection' => 'EPSG:900913', | 164 | 'f_projection' => 'EPSG:900913', |
341 | 166 | 'f_coords' => $coordinates, | 165 | 'f_coords' => $coordinates, |
342 | 167 | 'f_name' => $f_name, | 166 | 'f_name' => $f_name, |
343 | 168 | 'f_description' => $f_description, | 167 | 'f_description' => $f_description, |
344 | 169 | 'f_author' => $f_author, | 168 | 'f_author' => $f_author, |
345 | 170 | 'f_event_date' => $f_event_date, | 169 | 'f_event_date' => $f_event_date, |
346 | 171 | ); | 170 | ); |
347 | 172 | // print_r($keys_); | 171 | // print_r($keys_); |
348 | 173 | // Create the Feature. | 172 | // Create the Feature. |
349 | 174 | shn_gis_create_feature($keys_); | 173 | shn_gis_create_feature($keys_); |
350 | 175 | 174 | ||
351 | 176 | } else { | 175 | } else { |
352 | 177 | $message = "Invalid Input format for SM Add"; | 176 | $message = "Invalid Input format for SM Add"; |
353 | 178 | } | 177 | } |
354 | 179 | 178 | ||
355 | 180 | } | 179 | } |
356 | 181 | else{ | 180 | else{ |
357 | 182 | $message = "Invalid Keyword for SM Module sent. Please retry or send HELP SM to get list of valid arguements."; | 181 | $message = "Invalid Keyword for SM Module sent. Please retry or send HELP SM to get list of valid arguements."; |
358 | 183 | } | 182 | } |
359 | 184 | include_once $global['approot']."/mod/msg/plugins/"."$plugin_name"."/handler_"."$plugin_name".".inc"; | 183 | include_once $global['approot']."/mod/msg/plugins/"."$plugin_name"."/handler_"."$plugin_name".".inc"; |
360 | 185 | $recipients = array ($sender_phone_number);//handler_plugin.inc send sms function accepts array as input for recipients | 184 | $recipients = array ($sender_phone_number);//handler_plugin.inc send sms function accepts array as input for recipients |
361 | 186 | if($message) shn_msg_plugin_send_sm($recipients, $message); | 185 | if($message) shn_msg_plugin_send_sm($recipients, $message); |
362 | 187 | //shn_msg_store_sent_messages($recipients, $error_message); @todo check the current storage mechanism. smstools_log table | 186 | //shn_msg_store_sent_messages($recipients, $error_message); @todo check the current storage mechanism. smstools_log table |
363 | 188 | //echo "<br \> Error SMS: ".$error_message; | 187 | //echo "<br \> Error SMS: ".$error_message; |
364 | 189 | return 0; | 188 | return 0; |
365 | 190 | } | 189 | } |
366 | 191 | 190 | ||
367 | 192 | else{ | 191 | else{ |
368 | 193 | $error_message = _shn_msg_sms_error_code(1); | 192 | $error_message = _shn_msg_sms_error_code(1); |
369 | 194 | include_once $global['approot']."/mod/msg/plugins/"."$plugin_name"."/handler_"."$plugin_name".".inc"; | 193 | include_once $global['approot']."/mod/msg/plugins/"."$plugin_name"."/handler_"."$plugin_name".".inc"; |
370 | 195 | $recipients = array ($sender_phone_number);//handler_plugin.inc send sms function accepts array as input for recipients | 194 | $recipients = array ($sender_phone_number);//handler_plugin.inc send sms function accepts array as input for recipients |
371 | 196 | shn_msg_plugin_send_sm($recipients, $error_message); | 195 | shn_msg_plugin_send_sm($recipients, $error_message); |
372 | 197 | //shn_msg_store_sent_messages($recipients, $error_message); @todo check the current storage mechanism. smstools_log table | 196 | //shn_msg_store_sent_messages($recipients, $error_message); @todo check the current storage mechanism. smstools_log table |
373 | 198 | //echo "<br \> Error SMS: ".$error_message; | 197 | //echo "<br \> Error SMS: ".$error_message; |
374 | 199 | return 0; | 198 | return 0; |
375 | 200 | } | 199 | } |
376 | 201 | } | 200 | } |
377 | 202 | 201 | ||
378 | 203 | 202 | ||
379 | 204 | 203 | ||
380 | 205 | /** | 204 | /** |
381 | 206 | * Function calls specific to the keyword sent are listed here. Module writers should write module specific calls | 205 | * Function calls specific to the keyword sent are listed here. Module writers should write module specific calls |
382 | 207 | * modified for the purpose of SMS here. | 206 | * modified for the purpose of SMS here. |
383 | 208 | * E.g. The function should return values which can later be formatted as plain text. No HTML output should be returned as is the case | 207 | * E.g. The function should return values which can later be formatted as plain text. No HTML output should be returned as is the case |
384 | 209 | * right now for the Sahana core functions which concentrate on the Web App | 208 | * right now for the Sahana core functions which concentrate on the Web App |
385 | 210 | */ | 209 | */ |
386 | 211 | 210 | ||
387 | 212 | 211 | ||
388 | 213 | /** Action Building Main Menu ***/ | 212 | /** Action Building Main Menu ***/ |
389 | 214 | 213 | ||
390 | 215 | function _shn_msg_sms_menu(){ | 214 | function _shn_msg_sms_menu(){ |
391 | 216 | 215 | ||
392 | 217 | global $sms_list_keywords; | 216 | global $sms_list_keywords; |
393 | 218 | $sms_main_menu = "Sahana Main Menu: \nNumeric Code - Word Code\n"; | 217 | $sms_main_menu = "Sahana Main Menu: \nNumeric Code - Word Code\n"; |
394 | 219 | foreach ($sms_list_keywords as $k => $v) { | 218 | foreach ($sms_list_keywords as $k => $v) { |
395 | 220 | $sms_main_menu .= "[$k] - $v\n"; | 219 | $sms_main_menu .= "[$k] - $v\n"; |
396 | 221 | } | 220 | } |
397 | 222 | return $sms_main_menu; | 221 | return $sms_main_menu; |
398 | 223 | } | 222 | } |
399 | 224 | 223 | ||
400 | 225 | 224 | ||
401 | 226 | /** Action Help - Keyword == help or Numeric Code == 911 **/ | 225 | /** Action Help - Keyword == help or Numeric Code == 911 **/ |
402 | 227 | 226 | ||
403 | 228 | function _shn_msg_sms_help($parsed_sms, $sender_phone_number){ | 227 | function _shn_msg_sms_help($parsed_sms, $sender_phone_number){ |
404 | 229 | 228 | ||
405 | 230 | global $global; | 229 | global $global; |
406 | 231 | $sms_main_menu = _shn_msg_sms_menu(); | 230 | $sms_main_menu = _shn_msg_sms_menu(); |
407 | 232 | include_once $global['approot']."/mod/msg/plugins/"."$plugin_name"."/handler_"."$plugin_name".".inc"; | 231 | include_once $global['approot']."/mod/msg/plugins/"."$plugin_name"."/handler_"."$plugin_name".".inc"; |
408 | 233 | $recipients = array ($sender_phone_number);//handler_plugin.inc send sms function accepts array as input for recipients | 232 | $recipients = array ($sender_phone_number);//handler_plugin.inc send sms function accepts array as input for recipients |
409 | 234 | shn_msg_plugin_send_sm($recipients, $sms_main_menu); | 233 | shn_msg_plugin_send_sm($recipients, $sms_main_menu); |
410 | 235 | //shn_msg_store_sent_messages($recipients, $error_message); @todo check the current storage mechanism. smstools_log table | 234 | //shn_msg_store_sent_messages($recipients, $error_message); @todo check the current storage mechanism. smstools_log table |
411 | 236 | //echo "<br \> Error SMS: ".$error_message; | 235 | //echo "<br \> Error SMS: ".$error_message; |
412 | 237 | return 0; | 236 | return 0; |
413 | 238 | 237 | ||
414 | 239 | } | 238 | } |
415 | 240 | 239 | ||
416 | 241 | 240 | ||
417 | 242 | /** Action Login - Keyword == login or Numeric Code == 100 **/ | 241 | /** Action Login - Keyword == login or Numeric Code == 100 **/ |
418 | 243 | 242 | ||
419 | 244 | function _shn_msg_sms_login($parsed_sms, $sender_phone_number){ | 243 | function _shn_msg_sms_login($parsed_sms, $sender_phone_number){ |
420 | 245 | 244 | ||
421 | 246 | global $global; | 245 | global $global; |
422 | 247 | require_once $global['approot']."/inc/lib_security/lib_sms_auth.inc"; | 246 | require_once $global['approot']."/inc/lib_security/lib_sms_auth.inc"; |
423 | 248 | $user_data = _shn_authenticate_user($parsed_sms); | 247 | $user_data = _shn_authenticate_user($parsed_sms); |
424 | 249 | shn_session_change($user_data); | 248 | shn_session_change($user_data); |
425 | 250 | //print_r($user_data); | 249 | //print_r($user_data); |
426 | 251 | if(!$user_data['error_code']){ | 250 | if(!$user_data['error_code']){ |
427 | 252 | $full_name = shn_get_user_details($user_data['user_id']); | 251 | $full_name = shn_get_user_details($user_data['user_id']); |
428 | 253 | //echo "<br \>Welcome, <strong>".$full_name."</strong> you are logged in to Sahana System via SMS. yAy!! <br \>"; | 252 | //echo "<br \>Welcome, <strong>".$full_name."</strong> you are logged in to Sahana System via SMS. yAy!! <br \>"; |
429 | 254 | $message = "Welcome, ".$full_name." you are logged in to Sahana System via SMS.\n"; | 253 | $message = "Welcome, ".$full_name." you are logged in to Sahana System via SMS.\n"; |
430 | 255 | $sms_main_menu = _shn_msg_sms_menu(); | 254 | $sms_main_menu = _shn_msg_sms_menu(); |
431 | 256 | $sms_to_send = $message . $sms_main_menu; | 255 | $sms_to_send = $message . $sms_main_menu; |
432 | 257 | include_once $global['approot']."/mod/msg/plugins/"."$plugin_name"."/handler_"."$plugin_name".".inc"; | 256 | include_once $global['approot']."/mod/msg/plugins/"."$plugin_name"."/handler_"."$plugin_name".".inc"; |
433 | 258 | $recipients = array ($sender_phone_number);//handler_plugin.inc send sms function accepts array as input for recipients | 257 | $recipients = array ($sender_phone_number);//handler_plugin.inc send sms function accepts array as input for recipients |
434 | 259 | shn_msg_plugin_send_sm($recipients, $sms_to_send); | 258 | shn_msg_plugin_send_sm($recipients, $sms_to_send); |
435 | 260 | //shn_msg_store_sent_messages($recipients, $error_message); @todo check the current storage mechanism. smstools_log table | 259 | //shn_msg_store_sent_messages($recipients, $error_message); @todo check the current storage mechanism. smstools_log table |
436 | 261 | //echo "<br \> Error SMS: ".$error_message; | 260 | //echo "<br \> Error SMS: ".$error_message; |
437 | 262 | return 0; | 261 | return 0; |
438 | 263 | //print_r($_SESSION); | 262 | //print_r($_SESSION); |
439 | 264 | $sessid = session_id(); | 263 | $sessid = session_id(); |
440 | 265 | //echo $sessid; | 264 | //echo $sessid; |
441 | 266 | } | 265 | } |
442 | 267 | 266 | ||
443 | 268 | } | 267 | } |
444 | 269 | 268 | ||
445 | 270 | ?> | 269 | ?> |
446 | 271 | \ No newline at end of file | 270 | \ No newline at end of file |
447 | 271 | <?php | ||
448 | 272 | /** | ||
449 | 273 | * | ||
450 | 274 | * This library helps in parsing and triggering functions based on SMS Input. A vital component of the framework. | ||
451 | 275 | * Developers are required to use this library to facilitate SMS based transactions with the Sahana Core. | ||
452 | 276 | * | ||
453 | 277 | * | ||
454 | 278 | * PHP version 4 and 5 | ||
455 | 279 | * | ||
456 | 280 | * LICENSE: This source file is subject to LGPL license | ||
457 | 281 | * that is available through the world-wide-web at the following URI: | ||
458 | 282 | * http://www.gnu.org/copyleft/lesser.html | ||
459 | 283 | * | ||
460 | 284 | * @package framework | ||
461 | 285 | * @subpackage messaging | ||
462 | 286 | * @author Ajay Kumar <ajuonline at gmail dot com><aj at mindtakers dot com> | ||
463 | 287 | * @copyright Lanka Software Foundation - http://www.opensource.lk | ||
464 | 288 | * @version $Id: lib_sms_handler.inc,v 1.2 2008/09/15 13:50:13 franboon Exp $ | ||
465 | 289 | * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL) | ||
466 | 290 | * | ||
467 | 291 | */ | ||
468 | 292 | global $global; | ||
469 | 293 | |||
470 | 294 | global $sms_list_keywords; | ||
471 | 295 | |||
472 | 296 | # include_once $global['approot']."/mod/msg/lib_sms_keywords.inc"; | ||
473 | 297 | $sms_list_keywords = array( | ||
474 | 298 | '1' => 'login', | ||
475 | 299 | '2' => 'map', | ||
476 | 300 | '3' => 'sm', | ||
477 | 301 | '100' => 'login', | ||
478 | 302 | '911' => 'help' | ||
479 | 303 | ); | ||
480 | 304 | |||
481 | 305 | include_once $global['approot']."/mod/msg/lib_sms_errors.inc"; | ||
482 | 306 | include_once $global['approot']."/mod/msg/plugins/"."$plugin_name"."/handler_"."$plugin_name".".inc"; | ||
483 | 307 | /** | ||
484 | 308 | * This function will parse the incoming message string sent via GET & POST | ||
485 | 309 | * Currently this function will be used by Kannel and SMSTools | ||
486 | 310 | * It returns the array containing all words/strings, as single array values, sent in the SMS seperated by a SPACE | ||
487 | 311 | * For e.g. For a message string i.e. $message = "login user pass"; | ||
488 | 312 | * $parsed_message[0]="login" | ||
489 | 313 | * $parsed_message[1]="user" | ||
490 | 314 | * $parsed_message[2]="pass" | ||
491 | 315 | */ | ||
492 | 316 | function _shn_msg_parse_short_message($message){ | ||
493 | 317 | |||
494 | 318 | $parsed_message=array(); | ||
495 | 319 | $parsed_message = explode(" ", $message); | ||
496 | 320 | |||
497 | 321 | // convert to lower to handle first letter capitilization | ||
498 | 322 | $parsed_message[0] = strtolower($parsed_message[0]); | ||
499 | 323 | |||
500 | 324 | // DEBUG: parsed message | ||
501 | 325 | print_r($parsed_message); | ||
502 | 326 | |||
503 | 327 | return $parsed_message; | ||
504 | 328 | } | ||
505 | 329 | /** | ||
506 | 330 | * This function will check the first word of the incoming message string | ||
507 | 331 | * and return the corresponding menu value only. | ||
508 | 332 | * For. e.g. as per our keyword definition file | ||
509 | 333 | */ | ||
510 | 334 | function _shn_msg_sms_keyword_check($keyword, $sender){ | ||
511 | 335 | |||
512 | 336 | global $global; | ||
513 | 337 | global $sms_list_keywords; | ||
514 | 338 | |||
515 | 339 | // check if number entered is a valid keyword | ||
516 | 340 | if(is_numeric($keyword)){ | ||
517 | 341 | |||
518 | 342 | if(array_key_exists($keyword, $sms_list_keywords)){ | ||
519 | 343 | |||
520 | 344 | $keyword_check_result = array ('return' => '1', 'type' => 'number'); | ||
521 | 345 | //echo " Key word valid and is number"; | ||
522 | 346 | return $keyword_check_result; | ||
523 | 347 | |||
524 | 348 | } else { | ||
525 | 349 | |||
526 | 350 | _shn_msg_sms_help("Invalid Number\n", $sender) ; | ||
527 | 351 | return 0; | ||
528 | 352 | } | ||
529 | 353 | |||
530 | 354 | } else { //check if keyword is a valid one | ||
531 | 355 | |||
532 | 356 | $bool = array_search($keyword, $sms_list_keywords); | ||
533 | 357 | if(array_search($keyword, $sms_list_keywords)){ | ||
534 | 358 | $keyword_check_result = array ('return' => '1', 'type' => 'word'); | ||
535 | 359 | //echo " key word is valid and is WORD"; | ||
536 | 360 | return $keyword_check_result; | ||
537 | 361 | } | ||
538 | 362 | else{ | ||
539 | 363 | _shn_msg_sms_help("Invalid Keyword\n", $sender) ; | ||
540 | 364 | return 0; | ||
541 | 365 | } | ||
542 | 366 | } | ||
543 | 367 | } | ||
544 | 368 | /** | ||
545 | 369 | * This function will check the first word of the incoming message string | ||
546 | 370 | * and return the corresponding menu value only. | ||
547 | 371 | * For. e.g. as per our keyword definition file | ||
548 | 372 | */ | ||
549 | 373 | function _shn_msg_sms_action($parsed_sms, $sender_phone_number){ | ||
550 | 374 | |||
551 | 375 | global $global; | ||
552 | 376 | |||
553 | 377 | $keyword0 = $parsed_sms[0]; | ||
554 | 378 | $keyword1 = strtolower($parsed_sms[1]); | ||
555 | 379 | $full_sms_input_text = implode(" ", $parsed_sms); | ||
556 | 380 | |||
557 | 381 | if (("help"==$keyword0) || ("911"==$keyword0)) { | ||
558 | 382 | |||
559 | 383 | _shn_msg_sms_help("", $sender_phone_number); | ||
560 | 384 | } | ||
561 | 385 | |||
562 | 386 | elseif (("login"==$keyword0) || ("100"==$keyword0)) { | ||
563 | 387 | |||
564 | 388 | _shn_msg_sms_login("", $sender_phone_number); | ||
565 | 389 | |||
566 | 390 | } | ||
567 | 391 | |||
568 | 392 | elseif ( ("map" == $keyword0) || ("sm" == $keyword0) || ("3" == $keyword0)) { | ||
569 | 393 | |||
570 | 394 | if ('help' == $keyword1) { | ||
571 | 395 | |||
572 | 396 | $message = "Type the following:\nmap lat long user title. description\nexample:\nmap n35.7153 w120.7640 hospital granada. building evacuated"; | ||
573 | 397 | |||
574 | 398 | } elseif ("search"==$parsed_sms[1]){ | ||
575 | 399 | |||
576 | 400 | require_once $global['approot'] . "/inc/lib_gis/gis_fns.inc"; | ||
577 | 401 | $keys = array('all' => '1'); | ||
578 | 402 | $features = shn_gis_get_features_in_radius($keys, $parsed_sms[2], $parsed_sms[3], $parsed_sms[4]); | ||
579 | 403 | //print_r($features); | ||
580 | 404 | $count = count($features); | ||
581 | 405 | //echo "<br /> $count <br />"; | ||
582 | 406 | |||
583 | 407 | if($count){ | ||
584 | 408 | $final_results = array(); | ||
585 | 409 | $i = 1; | ||
586 | 410 | $message = "Results Found:\n"; | ||
587 | 411 | foreach($features as $a){ | ||
588 | 412 | |||
589 | 413 | |||
590 | 414 | //$coords = shn_gis_coord_decode($a[f_coords]); | ||
591 | 415 | //print_r($coords); @ returns 2 values for 1 input. needed to check with GIS fns and figure out a way | ||
592 | 416 | array_push($final_results, array("$a[f_name]", "$a[f_description]", "$a[f_coords]", "$a[f_event_date]")); | ||
593 | 417 | $message .= "$i. Name - $a[f_name]\nDescription: $a[f_description]\nGPS Loc: $a[f_coords]\nTimeStamp: $a[f_event_date]\n"; | ||
594 | 418 | $i++; | ||
595 | 419 | } | ||
596 | 420 | } | ||
597 | 421 | else{ | ||
598 | 422 | $message = "No Situations Found! Please try modifying your search."; | ||
599 | 423 | } | ||
600 | 424 | |||
601 | 425 | //print_r($final_results); | ||
602 | 426 | |||
603 | 427 | } | ||
604 | 428 | |||
605 | 429 | elseif( "add" == $keyword1 ){ | ||
606 | 430 | |||
607 | 431 | //Valid Input SMS format "sm add <name> <description> <gps_coords>" | ||
608 | 432 | #if (ereg ("(sm) (add) \((.+)\) \((.+)\) \(([0-9]{2,3}),([0-9]{2,3})\)", $full_sms_input_text, $regs)) | ||
609 | 433 | if (ereg ("(.+) (add) \((.+):(.+)\) \((.*)\) \(([-+]?([0-9]*\.[0-9]+|[0-9]+)),([-+]?([0-9]*\.[0-9]+|[0-9]+))\)", $full_sms_input_text, $regs)) | ||
610 | 434 | { | ||
611 | 435 | print_r($regs); | ||
612 | 436 | |||
613 | 437 | // Include for the GIS Database API. | ||
614 | 438 | require_once $global['approot']."/inc/lib_security/lib_sms_auth.inc"; | ||
615 | 439 | print_r($_SESSION); | ||
616 | 440 | $f_name = $regs[4]; | ||
617 | 441 | $f_description = $regs[5]; | ||
618 | 442 | $f_author = $regs[3]; | ||
619 | 443 | #$f_author = shn_get_user_details($user_data['user_id']);; | ||
620 | 444 | $f_event_date = date("Y-m-d H:i:s"); | ||
621 | 445 | $marker_long_coordinate = $regs[6]; | ||
622 | 446 | $marker_lat_coordinate = $regs[8]; | ||
623 | 447 | require_once $global['approot']."/inc/lib_gis/gis_fns.inc"; | ||
624 | 448 | // Parse the Coordinates to wkt format. | ||
625 | 449 | $coords_center = array($marker_long_coordinate, $marker_lat_coordinate, 0); | ||
626 | 450 | $coords = array($coords_center, $coords_center); | ||
627 | 451 | $coordinates = shn_gis_coord_encode($coords, 'point'); | ||
628 | 452 | |||
629 | 453 | // Register the values that will make the new feature as an array of key => values. | ||
630 | 454 | $keys_ = array( | ||
631 | 455 | 'f_type' => 'point', | ||
632 | 456 | 'f_projection' => 'EPSG:900913', | ||
633 | 457 | 'f_coords' => $coordinates, | ||
634 | 458 | 'f_name' => $f_name, | ||
635 | 459 | 'f_description' => $f_description, | ||
636 | 460 | 'f_author' => $f_author, | ||
637 | 461 | 'f_event_date' => $f_event_date, | ||
638 | 462 | ); | ||
639 | 463 | //print_r($keys_); | ||
640 | 464 | // Create the Feature. | ||
641 | 465 | shn_gis_create_feature($keys_); | ||
642 | 466 | |||
643 | 467 | $message = "Map point [".$f_name."] added to situation map"; | ||
644 | 468 | |||
645 | 469 | |||
646 | 470 | } else { | ||
647 | 471 | $message = "Invalid input.\n Use sm add (title) (description) (latitude, longatitude)"; | ||
648 | 472 | } | ||
649 | 473 | |||
650 | 474 | } else { | ||
651 | 475 | |||
652 | 476 | if (ereg ("(map) ([-+nsNS]?)([0-9]*\.[0-9]+|[0-9]+) ([-+ewEW]?)([0-9]*\.[0-9]+|[0-9]+) ([^ ]+) ([^\.]*)\. ?(.*)", $full_sms_input_text, $regs)) { | ||
653 | 477 | |||
654 | 478 | print_r($regs); | ||
655 | 479 | // Include for the GIS Database API. | ||
656 | 480 | require_once $global['approot']."/inc/lib_security/lib_sms_auth.inc"; | ||
657 | 481 | //print_r($_SESSION); | ||
658 | 482 | // $f_author = $regs[6]; | ||
659 | 483 | $f_author = $sender_phone_number; | ||
660 | 484 | $f_name = $regs[7]; | ||
661 | 485 | $f_description = $regs[8]; | ||
662 | 486 | #$f_author = shn_get_user_details($user_data['user_id']);; | ||
663 | 487 | // change the polarity based on NSEW prefix | ||
664 | 488 | $f_event_date = date("Y-m-d H:i:s"); | ||
665 | 489 | $marker_long_coordinate = $regs[3]; | ||
666 | 490 | if (ereg (strtolower($regs[2]),'s|-')) { | ||
667 | 491 | $marker_long_coordinate = -$marker_long_coordinate; | ||
668 | 492 | } | ||
669 | 493 | $marker_lat_coordinate = $regs[5]; | ||
670 | 494 | if (ereg (strtolower($regs[4]),'w|-')) { | ||
671 | 495 | $marker_lat_coordinate = -$marker_lat_coordinate; | ||
672 | 496 | } | ||
673 | 497 | |||
674 | 498 | require_once $global['approot']."/inc/lib_gis/gis_fns.inc"; | ||
675 | 499 | // Parse the Coordinates to wkt format. | ||
676 | 500 | $coords_center = array($marker_lat_coordinate, $marker_long_coordinate, 0); | ||
677 | 501 | $coords = array($coords_center, $coords_center); | ||
678 | 502 | $coordinates = shn_gis_coord_encode($coords, 'point'); | ||
679 | 503 | |||
680 | 504 | |||
681 | 505 | // Register the values that will make the new feature as an array of key => values. | ||
682 | 506 | $keys_ = array( | ||
683 | 507 | 'f_type' => 'point', | ||
684 | 508 | 'f_projection' => 'EPSG:900913', | ||
685 | 509 | 'f_coords' => $coordinates, | ||
686 | 510 | 'f_name' => $f_name, | ||
687 | 511 | 'f_description' => $f_description, | ||
688 | 512 | 'f_author' => $f_author, | ||
689 | 513 | 'f_event_date' => $f_event_date, | ||
690 | 514 | ); | ||
691 | 515 | |||
692 | 516 | // see if the first keyword can be matched to a class for the marker | ||
693 | 517 | $matched_gis_classes = | ||
694 | 518 | $global['db']->Execute("SELECT * FROM `gis_feature_class` WHERE `name` LIKE '".$regs[6]."'"); | ||
695 | 519 | if (null != $matched_gis_classes) | ||
696 | 520 | $keys_['f_class'] = $matched_gis_classes->fields('feature_class_uuid'); | ||
697 | 521 | |||
698 | 522 | print_r($keys_); | ||
699 | 523 | // Create the Feature. | ||
700 | 524 | shn_gis_create_feature($keys_); | ||
701 | 525 | |||
702 | 526 | $message = "Map point [".$f_name."] added to situation map"; | ||
703 | 527 | } else { | ||
704 | 528 | |||
705 | 529 | $message = "Type the following:\nmap lat long user title. description\nexample:\nmap n35.7153 w120.7640 hospital granada. building evacuated"; | ||
706 | 530 | } | ||
707 | 531 | } | ||
708 | 532 | |||
709 | 533 | $recipients = array ($sender_phone_number);//handler_plugin.inc send sms function accepts array as input for recipients | ||
710 | 534 | |||
711 | 535 | // if a message is created sent it | ||
712 | 536 | if($message) shn_msg_plugin_send_sm($recipients, $message); | ||
713 | 537 | //shn_msg_store_sent_messages($recipients, $error_message); @todo check the current storage mechanism. smstools_log table | ||
714 | 538 | //echo "<br \> Error SMS: ".$error_message; | ||
715 | 539 | return 0; | ||
716 | 540 | |||
717 | 541 | } | ||
718 | 542 | |||
719 | 543 | else{ | ||
720 | 544 | |||
721 | 545 | $error_message = _shn_msg_sms_error_code(1); | ||
722 | 546 | $recipients = array ($sender_phone_number);//handler_plugin.inc send sms function accepts array as input for recipients | ||
723 | 547 | shn_msg_plugin_send_sm($recipients, $error_message); | ||
724 | 548 | //shn_msg_store_sent_messages($recipients, $error_message); @todo check the current storage mechanism. smstools_log table | ||
725 | 549 | //echo "<br \> Error SMS: ".$error_message; | ||
726 | 550 | return 0; | ||
727 | 551 | } | ||
728 | 552 | } | ||
729 | 553 | /** | ||
730 | 554 | * Function calls specific to the keyword sent are listed here. Module writers should write module specific calls | ||
731 | 555 | * modified for the purpose of SMS here. | ||
732 | 556 | * E.g. The function should return values which can later be formatted as plain text. No HTML output should be returned as is the case | ||
733 | 557 | * right now for the Sahana core functions which concentrate on the Web App | ||
734 | 558 | */ | ||
735 | 559 | |||
736 | 560 | |||
737 | 561 | /** Action Building Main Menu ***/ | ||
738 | 562 | function _shn_msg_sms_menu(){ | ||
739 | 563 | |||
740 | 564 | global $sms_list_keywords; | ||
741 | 565 | $sms_main_menu = "Use keywords below:\n"; | ||
742 | 566 | # foreach ($sms_list_keywords as $k => $v) { | ||
743 | 567 | # $sms_main_menu .= "$k-$v\n"; | ||
744 | 568 | # } | ||
745 | 569 | $sms_main_menu .= "map - map point\nhelp - general help\n"; | ||
746 | 570 | $sms_main_menu .= "map help - map syntax\n"; | ||
747 | 571 | return $sms_main_menu; | ||
748 | 572 | } | ||
749 | 573 | |||
750 | 574 | /** Action Help - Keyword == help or Numeric Code == 911 **/ | ||
751 | 575 | function _shn_msg_sms_help($prefix_text, $sender_phone_number){ | ||
752 | 576 | |||
753 | 577 | global $global; | ||
754 | 578 | |||
755 | 579 | $sms_main_menu = _shn_msg_sms_menu(); | ||
756 | 580 | |||
757 | 581 | $recipients = array ($sender_phone_number);//handler_plugin.inc send sms function accepts array as input for recipients | ||
758 | 582 | shn_msg_plugin_send_sm($recipients, $prefix_text.$sms_main_menu); | ||
759 | 583 | //shn_msg_store_sent_messages($recipients, $error_message); @todo check the current storage mechanism. smstools_log table | ||
760 | 584 | |||
761 | 585 | return 0; | ||
762 | 586 | } | ||
763 | 587 | |||
764 | 588 | /** Action Login - Keyword == login or Numeric Code == 100 **/ | ||
765 | 589 | function _shn_msg_sms_login($parsed_sms, $sender_phone_number){ | ||
766 | 590 | |||
767 | 591 | global $global; | ||
768 | 592 | require_once $global['approot']."/inc/lib_security/lib_sms_auth.inc"; | ||
769 | 593 | $user_data = _shn_authenticate_user($parsed_sms); | ||
770 | 594 | shn_session_change($user_data); | ||
771 | 595 | //print_r($user_data); | ||
772 | 596 | if(!$user_data['error_code']){ | ||
773 | 597 | $full_name = shn_get_user_details($user_data['user_id']); | ||
774 | 598 | //echo "<br \>Welcome, <strong>".$full_name."</strong> you are logged in to Sahana System via SMS. yAy!! <br \>"; | ||
775 | 599 | $message = "Welcome, ".$full_name." you are logged in to Sahana System via SMS.\n"; | ||
776 | 600 | $sms_main_menu = _shn_msg_sms_menu(); | ||
777 | 601 | $sms_to_send = $message . $sms_main_menu; | ||
778 | 602 | $recipients = array ($sender_phone_number);//handler_plugin.inc send sms function accepts array as input for recipients | ||
779 | 603 | shn_msg_plugin_send_sm($recipients, $sms_to_send); | ||
780 | 604 | //shn_msg_store_sent_messages($recipients, $error_message); @todo check the current storage mechanism. smstools_log table | ||
781 | 605 | //echo "<br \> Error SMS: ".$error_message; | ||
782 | 606 | return 0; | ||
783 | 607 | //print_r($_SESSION); | ||
784 | 608 | $sessid = session_id(); | ||
785 | 609 | //echo $sessid; | ||
786 | 610 | } | ||
787 | 611 | |||
788 | 612 | } | ||
789 | 613 | ?> | ||
790 | 272 | 614 | ||
791 | === modified file 'mod/msg/lib_sms_keywords.inc' | |||
792 | --- mod/msg/lib_sms_keywords.inc 2009-11-10 23:51:44 +0000 | |||
793 | +++ mod/msg/lib_sms_keywords.inc 2009-11-18 18:15:32 +0000 | |||
794 | @@ -1,5 +1,28 @@ | |||
795 | 1 | <?php | ||
796 | 2 | 1 | ||
797 | 3 | /** | ||
798 | 4 | * | 2 | * |
799 | 5 | * This file is a list of valid keywords that the Sahana server will accept through SMS | 3 | * This file is a list of valid keywords that the Sahana server will accept through SMS |
800 | 6 | * Developers are required to use this file to list keywords and prepare user manuals for it. | 4 | * Developers are required to use this file to list keywords and prepare user manuals for it. |
801 | 7 | * Any changes or additions to the keywords should go in this file. | 5 | * Any changes or additions to the keywords should go in this file. |
802 | 8 | * | 6 | * |
803 | 9 | * | 7 | * |
804 | 10 | * PHP version 4 and 5 | 8 | * PHP version 4 and 5 |
805 | 11 | * | 9 | * |
806 | 12 | * LICENSE: This source file is subject to LGPL license | 10 | * LICENSE: This source file is subject to LGPL license |
807 | 13 | * that is available through the world-wide-web at the following URI: | 11 | * that is available through the world-wide-web at the following URI: |
808 | 14 | * http://www.gnu.org/copyleft/lesser.html | 12 | * http://www.gnu.org/copyleft/lesser.html |
809 | 15 | * | 13 | * |
810 | 16 | * @package framework | 14 | * @package framework |
811 | 17 | * @subpackage messaging | 15 | * @subpackage messaging |
812 | 18 | * @author Ajay Kumar <ajuonline at gmail dot com><aj at mindtakers dot com> | 16 | * @author Ajay Kumar <ajuonline at gmail dot com><aj at mindtakers dot com> |
813 | 19 | * @copyright Lanka Software Foundation - http://www.opensource.lk | 17 | * @copyright Lanka Software Foundation - http://www.opensource.lk |
814 | 20 | * @version $Id: lib_sms_keywords.inc,v 1.2 2008/09/15 13:50:13 franboon Exp $ | 18 | * @version $Id: lib_sms_keywords.inc,v 1.2 2008/09/15 13:50:13 franboon Exp $ |
815 | 21 | * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL) | 19 | * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL) |
816 | 22 | * | 20 | * |
817 | 23 | */ | 21 | */ |
818 | 24 | 22 | ||
819 | 25 | //This needs to be done in a more efficient way. By using the 3 letter module codes from the DB? | 23 | //This needs to be done in a more efficient way. By using the 3 letter module codes from the DB? |
820 | 26 | |||
821 | 27 | |||
822 | 28 | global $sms_list_keywords; | ||
823 | 29 | 24 | ||
824 | 30 | $sms_list_keywords = array('1' => 'mpr', '2' => 'or', '3' => 'sm', '100' => 'login', '911' => 'help'); | 25 | $sms_list_keywords = array('1' => 'mpr', '2' => 'or', '3' => 'sm', '100' => 'login', '911' => 'help'); |
825 | 31 | 26 | ||
826 | 32 | ?> | 27 | ?> |
827 | 33 | \ No newline at end of file | 28 | \ No newline at end of file |
828 | 29 | <?php | ||
829 | 30 | /** | ||
830 | 31 | * | ||
831 | 32 | * This file is a list of valid keywords that the Sahana server will accept through SMS | ||
832 | 33 | * Developers are required to use this file to list keywords and prepare user manuals for it. | ||
833 | 34 | * Any changes or additions to the keywords should go in this file. | ||
834 | 35 | * | ||
835 | 36 | * | ||
836 | 37 | * PHP version 4 and 5 | ||
837 | 38 | * | ||
838 | 39 | * LICENSE: This source file is subject to LGPL license | ||
839 | 40 | * that is available through the world-wide-web at the following URI: | ||
840 | 41 | * http://www.gnu.org/copyleft/lesser.html | ||
841 | 42 | * | ||
842 | 43 | * @package framework | ||
843 | 44 | * @subpackage messaging | ||
844 | 45 | * @author Ajay Kumar <ajuonline at gmail dot com><aj at mindtakers dot com> | ||
845 | 46 | * @copyright Lanka Software Foundation - http://www.opensource.lk | ||
846 | 47 | * @version $Id: lib_sms_keywords.inc,v 1.2 2008/09/15 13:50:13 franboon Exp $ | ||
847 | 48 | * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL) | ||
848 | 49 | * | ||
849 | 50 | */ | ||
850 | 51 | //This needs to be done in a more efficient way. By using the 3 letter module codes from the DB? | ||
851 | 52 | |||
852 | 53 | |||
853 | 54 | global $sms_list_keywords; | ||
854 | 55 | $sms_list_keywords = array('1' => 'mpr', '2' => 'or', '3' => 'sm', '100' => 'login', '911' => 'help'); | ||
855 | 56 | ?> | ||
856 | 34 | \ No newline at end of file | 57 | \ No newline at end of file |
857 | 35 | 58 | ||
858 | === modified file 'mod/msg/lib_sms_main.inc' | |||
859 | --- mod/msg/lib_sms_main.inc 2009-11-10 23:51:44 +0000 | |||
860 | +++ mod/msg/lib_sms_main.inc 2009-11-18 18:15:32 +0000 | |||
861 | @@ -1,3 +1,63 @@ | |||
862 | 1 | <?php | ||
863 | 2 | /** | 1 | /** |
864 | 3 | * | 2 | * |
865 | 4 | * Library functions for implementation independant messaging for SMS | 3 | * Library functions for implementation independant messaging for SMS |
866 | 5 | * Main messaging controller functions with modular plugin architecture irrespective of the SMS Gateway application | 4 | * Main messaging controller functions with modular plugin architecture irrespective of the SMS Gateway application |
867 | 6 | * | 5 | * |
868 | 7 | * | 6 | * |
869 | 8 | * PHP version 4 and 5 | 7 | * PHP version 4 and 5 |
870 | 9 | * | 8 | * |
871 | 10 | * LICENSE: This source file is subject to LGPL license | 9 | * LICENSE: This source file is subject to LGPL license |
872 | 11 | * that is available through the world-wide-web at the following URI: | 10 | * that is available through the world-wide-web at the following URI: |
873 | 12 | * http://www.gnu.org/copyleft/lesser.html | 11 | * http://www.gnu.org/copyleft/lesser.html |
874 | 13 | * | 12 | * |
875 | 14 | * @package framework | 13 | * @package framework |
876 | 15 | * @subpackage messaging | 14 | * @subpackage messaging |
877 | 16 | * @author Ajay Kumar <ajuonline at gmail dot com><aj at mindtakers dot com> | 15 | * @author Ajay Kumar <ajuonline at gmail dot com><aj at mindtakers dot com> |
878 | 17 | * @copyright Lanka Software Foundation - http://www.opensource.lk | 16 | * @copyright Lanka Software Foundation - http://www.opensource.lk |
879 | 18 | * @version $Id: lib_sms_main.inc,v 1.2 2008/09/15 13:50:20 franboon Exp $ | 17 | * @version $Id: lib_sms_main.inc,v 1.2 2008/09/15 13:50:20 franboon Exp $ |
880 | 19 | * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL) | 18 | * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL) |
881 | 20 | * | 19 | * |
882 | 21 | */ | 20 | */ |
883 | 22 | 21 | ||
884 | 23 | global $global; | 22 | global $global; |
885 | 24 | 23 | ||
886 | 25 | require_once $global['approot']."/mod/msg/lib_sms_keywords.inc"; | 24 | require_once $global['approot']."/mod/msg/lib_sms_keywords.inc"; |
887 | 26 | require_once $global['approot']."/mod/msg/lib_sms_errors.inc"; | 25 | require_once $global['approot']."/mod/msg/lib_sms_errors.inc"; |
888 | 27 | require_once $global['approot']."/mod/msg/lib_sms_handler.inc"; | 26 | require_once $global['approot']."/mod/msg/lib_sms_handler.inc"; |
889 | 28 | 27 | ||
890 | 29 | global $sender_phone_number; | ||
891 | 30 | global $sms_sent_timestamp; | 28 | global $sms_sent_timestamp; |
892 | 31 | global $sms_message; | 29 | global $sms_message; |
893 | 32 | 30 | ||
894 | 33 | function shn_msg_push_to_sms_handler($received_message){ | ||
895 | 34 | 31 | ||
896 | 35 | global $global; | 32 | global $global; |
897 | 36 | $sender_phone_number = $received_message['sender']; | 33 | $sender_phone_number = $received_message['sender']; |
898 | 37 | $sms_sent_timestamp = $received_message['received']; | 34 | $sms_sent_timestamp = $received_message['received']; |
899 | 38 | $sms_message = $received_message['message']; | 35 | $sms_message = $received_message['message']; |
900 | 39 | //echo "<br \>SMS Sent to main SMS Handler. <br \>From: ".$sender_phone_number; | 36 | //echo "<br \>SMS Sent to main SMS Handler. <br \>From: ".$sender_phone_number; |
901 | 40 | //shn_msg_sms_authenticate($received_message); add authentication function here | 37 | //shn_msg_sms_authenticate($received_message); add authentication function here |
902 | 41 | // if authenticated check keyword | 38 | // if authenticated check keyword |
903 | 42 | $parsed_sms = _shn_msg_parse_short_message($sms_message); | 39 | $parsed_sms = _shn_msg_parse_short_message($sms_message); |
904 | 43 | //echo "<br \> SMS Text = ".$sms_message; | 40 | //echo "<br \> SMS Text = ".$sms_message; |
905 | 44 | //echo "<br \> Keyword Text = ".$parsed_sms[0]; | 41 | //echo "<br \> Keyword Text = ".$parsed_sms[0]; |
906 | 45 | //check for valid keyword | 42 | //check for valid keyword |
907 | 46 | $keyword_check_result = _shn_msg_sms_keyword_check($parsed_sms[0], $sender_phone_number); | 43 | $keyword_check_result = _shn_msg_sms_keyword_check($parsed_sms[0], $sender_phone_number); |
908 | 47 | if($keyword_check_result!=0){ | 44 | if($keyword_check_result!=0){ |
909 | 48 | if($keyword_check_result['type'] == 'number'){ | 45 | if($keyword_check_result['type'] == 'number'){ |
910 | 49 | //execute_number_menu_function($parsed_sms); | 46 | //execute_number_menu_function($parsed_sms); |
911 | 50 | //echo "<br \>Key word is Valid and number"; | 47 | //echo "<br \>Key word is Valid and number"; |
912 | 51 | _shn_msg_sms_action($parsed_sms, $sender_phone_number); | 48 | _shn_msg_sms_action($parsed_sms, $sender_phone_number); |
913 | 52 | } | 49 | } |
914 | 53 | elseif($keyword_check_result['type'] == 'word'){ | 50 | elseif($keyword_check_result['type'] == 'word'){ |
915 | 54 | //execute_word_menu_function($parsed_sms); | 51 | //execute_word_menu_function($parsed_sms); |
916 | 55 | //echo "<br \>Key word is Valid and WORD <br \>"; | 52 | //echo "<br \>Key word is Valid and WORD <br \>"; |
917 | 56 | _shn_msg_sms_action($parsed_sms, $sender_phone_number); | 53 | _shn_msg_sms_action($parsed_sms, $sender_phone_number); |
918 | 57 | } | 54 | } |
919 | 58 | else{ | 55 | else{ |
920 | 59 | //error already sent echo " Keywords is in invalid format";//impossible tho | 56 | //error already sent echo " Keywords is in invalid format";//impossible tho |
921 | 60 | exit; | 57 | exit; |
922 | 61 | } | 58 | } |
923 | 62 | } | 59 | } |
924 | 63 | else{ | 60 | else{ |
925 | 64 | //error already sent echo " Keyword does not exists in LIST"; | 61 | //error already sent echo " Keyword does not exists in LIST"; |
926 | 65 | exit; | 62 | exit; |
927 | 66 | } | 63 | } |
928 | 67 | } | 64 | } |
929 | 68 | ?> | 65 | ?> |
930 | 69 | \ No newline at end of file | 66 | \ No newline at end of file |
931 | 67 | <?php | ||
932 | 68 | /** | ||
933 | 69 | * | ||
934 | 70 | * Library functions for implementation independant messaging for SMS | ||
935 | 71 | * Main messaging controller functions with modular plugin architecture irrespective of the SMS Gateway application | ||
936 | 72 | * | ||
937 | 73 | * | ||
938 | 74 | * PHP version 4 and 5 | ||
939 | 75 | * | ||
940 | 76 | * LICENSE: This source file is subject to LGPL license | ||
941 | 77 | * that is available through the world-wide-web at the following URI: | ||
942 | 78 | * http://www.gnu.org/copyleft/lesser.html | ||
943 | 79 | * | ||
944 | 80 | * @package framework | ||
945 | 81 | * @subpackage messaging | ||
946 | 82 | * @author Ajay Kumar <ajuonline at gmail dot com><aj at mindtakers dot com> | ||
947 | 83 | * @copyright Lanka Software Foundation - http://www.opensource.lk | ||
948 | 84 | * @version $Id: lib_sms_main.inc,v 1.2 2008/09/15 13:50:20 franboon Exp $ | ||
949 | 85 | * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL) | ||
950 | 86 | * | ||
951 | 87 | */ | ||
952 | 88 | global $global; | ||
953 | 89 | require_once $global['approot']."/mod/msg/lib_sms_keywords.inc"; | ||
954 | 90 | require_once $global['approot']."/mod/msg/lib_sms_errors.inc"; | ||
955 | 91 | require_once $global['approot']."/mod/msg/lib_sms_handler.inc"; | ||
956 | 92 | global $sender_phone_number; | ||
957 | 93 | global $sms_sent_timestamp; | ||
958 | 94 | global $sms_message; | ||
959 | 95 | function shn_msg_push_to_sms_handler($received_message){ | ||
960 | 96 | global $global; | ||
961 | 97 | $sender_phone_number = $received_message['sender']; | ||
962 | 98 | $sms_sent_timestamp = $received_message['received']; | ||
963 | 99 | $sms_message = $received_message['message']; | ||
964 | 100 | //echo "<br \>SMS Sent to main SMS Handler. <br \>From: ".$sender_phone_number; | ||
965 | 101 | //shn_msg_sms_authenticate($received_message); add authentication function here | ||
966 | 102 | // if authenticated check keyword | ||
967 | 103 | $parsed_sms = _shn_msg_parse_short_message($sms_message); | ||
968 | 104 | //echo "<br \> SMS Text = ".$sms_message; | ||
969 | 105 | //echo "<br \> Keyword Text = ".$parsed_sms[0]; | ||
970 | 106 | //check for valid keyword | ||
971 | 107 | $keyword_check_result = _shn_msg_sms_keyword_check($parsed_sms[0], $sender_phone_number); | ||
972 | 108 | if($keyword_check_result!=0){ | ||
973 | 109 | if($keyword_check_result['type'] == 'number'){ | ||
974 | 110 | //execute_number_menu_function($parsed_sms); | ||
975 | 111 | //echo "<br \>Key word is Valid and number"; | ||
976 | 112 | _shn_msg_sms_action($parsed_sms, $sender_phone_number); | ||
977 | 113 | } | ||
978 | 114 | elseif($keyword_check_result['type'] == 'word'){ | ||
979 | 115 | //execute_word_menu_function($parsed_sms); | ||
980 | 116 | //echo "<br \>Key word is Valid and WORD <br \>"; | ||
981 | 117 | _shn_msg_sms_action($parsed_sms, $sender_phone_number); | ||
982 | 118 | } | ||
983 | 119 | else{ | ||
984 | 120 | //error already sent echo " Keywords is in invalid format";//impossible tho | ||
985 | 121 | exit; | ||
986 | 122 | } | ||
987 | 123 | } | ||
988 | 124 | else{ | ||
989 | 125 | //error already sent echo " Keyword does not exists in LIST"; | ||
990 | 126 | exit; | ||
991 | 127 | } | ||
992 | 128 | } | ||
993 | 129 | ?> | ||
994 | 70 | \ No newline at end of file | 130 | \ No newline at end of file |
995 | 71 | 131 | ||
996 | === modified file 'mod/msg/plugins/smstools/handler_smstools.inc' (properties changed: -x to +x) | |||
997 | --- mod/msg/plugins/smstools/handler_smstools.inc 2009-11-10 23:51:44 +0000 | |||
998 | +++ mod/msg/plugins/smstools/handler_smstools.inc 2009-11-18 18:15:32 +0000 | |||
999 | @@ -29,6 +29,8 @@ | |||
1000 | 29 | global $global; | 29 | global $global; |
1001 | 30 | global $conf; | 30 | global $conf; |
1002 | 31 | include_once($global['approot'].'/mod/msg/plugins/smstools/conf.inc'); | 31 | include_once($global['approot'].'/mod/msg/plugins/smstools/conf.inc'); |
1003 | 32 | |||
1004 | 33 | echo "Response Message:".$message; | ||
1005 | 32 | 34 | ||
1006 | 33 | foreach($recipients as $to){ | 35 | foreach($recipients as $to){ |
1007 | 34 | //Let system handle tmp directory: change to absolute dir if needed | 36 | //Let system handle tmp directory: change to absolute dir if needed |
1008 | 35 | 37 | ||
1009 | === modified file 'mod/msg/plugins/smstools/smsfwd/smsevent' (properties changed: -x to +x) | |||
1010 | --- mod/msg/plugins/smstools/smsfwd/smsevent 2009-11-10 23:51:44 +0000 | |||
1011 | +++ mod/msg/plugins/smstools/smsfwd/smsevent 2009-11-18 18:15:32 +0000 | |||
1012 | @@ -137,8 +137,8 @@ | |||
1013 | 137 | echo $RECEIVED; | 137 | echo $RECEIVED; |
1014 | 138 | 138 | ||
1015 | 139 | if [ "$1" == "RECEIVED" ]; | 139 | if [ "$1" == "RECEIVED" ]; |
1017 | 140 | then curl "http://localhost/sahana-phase2/www/index.php?mod=msg&act=receive_message&stream=text&plugin=smstools&From=$FROM&Received=$RECEIVED&message=$URLTEXT"; | 140 | then curl "http://localhost/sahana/www/index.php?mod=msg&act=receive_message&stream=text&plugin=smstools&From=$FROM&Received=$RECEIVED&message=$URLTEXT"; |
1018 | 141 | 141 | ||
1019 | 142 | echo $'\n\nSMS posting successful from '$FROM' message: '$TEXT $'\n\n'; | 142 | echo $'\n\nSMS posting successful from '$FROM' message: '$TEXT $'\n\n'; |
1020 | 143 | fi | 143 | fi |
1021 | 144 | fi | ||
1022 | 145 | \ No newline at end of file | 144 | \ No newline at end of file |
1023 | 145 | fi | ||
1024 | 146 | 146 | ||
1025 | === modified file 'mod/sm/main_fns.inc' (properties changed: -x to +x) | |||
1026 | --- mod/sm/main_fns.inc 2009-11-10 23:51:44 +0000 | |||
1027 | +++ mod/sm/main_fns.inc 2009-11-18 18:15:32 +0000 | |||
1028 | @@ -59,4 +59,87 @@ | |||
1029 | 59 | shn_sm_radius_analyse_process(); | 59 | shn_sm_radius_analyse_process(); |
1030 | 60 | } | 60 | } |
1031 | 61 | 61 | ||
1033 | 62 | ?> | 62 | function shn_text_sm_kml() { |
1034 | 63 | |||
1035 | 64 | global $global; | ||
1036 | 65 | $db = $global['db']; | ||
1037 | 66 | // write the KML content header | ||
1038 | 67 | header("Content-type: application/vnd.google-earth.kml+xml;"); | ||
1039 | 68 | |||
1040 | 69 | $layer=$_REQUEST['layer']; | ||
1041 | 70 | |||
1042 | 71 | $query=" | ||
1043 | 72 | select coord_y, coord_x,m.name,url,m.description,icon,placement_date | ||
1044 | 73 | from gis_features f | ||
1045 | 74 | left join gis_feature_class c on | ||
1046 | 75 | (c.feature_class_uuid=f.feature_class_uuid_ref) | ||
1047 | 76 | left join gis_feature_class_to_layer cl on | ||
1048 | 77 | (c.feature_class_uuid=cl.feature_class_uuid_ref) | ||
1049 | 78 | left join gis_layers l on | ||
1050 | 79 | (cl.layer_uuid_ref=l.layer_uuid) | ||
1051 | 80 | left join gis_feature_metadata m on | ||
1052 | 81 | (f.metadata_uuid_ref=m.metadata_uuid) | ||
1053 | 82 | "; | ||
1054 | 83 | //--where layer_uuid='$layer' | ||
1055 | 84 | $r = $db->Execute($query); | ||
1056 | 85 | # if (!$rs) { | ||
1057 | 86 | # $message = 'Invalid query: ' . $query . "\n"; | ||
1058 | 87 | # $message .= 'Whole query: ' . $query; | ||
1059 | 88 | # die($message); | ||
1060 | 89 | # } | ||
1061 | 90 | //echo "lat lon title description icon iconSize iconOffset\n"; | ||
1062 | 91 | echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; | ||
1063 | 92 | ?> | ||
1064 | 93 | <kml xmlns="http://www.opengis.net/kml/2.2"> | ||
1065 | 94 | <Document> | ||
1066 | 95 | <flyToView>0</flyToView> | ||
1067 | 96 | <? | ||
1068 | 97 | while (!$r->EOF){ | ||
1069 | 98 | |||
1070 | 99 | $y=$r->fields['coord_y']; | ||
1071 | 100 | $x=$r->fields['coord_x']; | ||
1072 | 101 | $title=$r->fields['name']; | ||
1073 | 102 | $url = $r->fields['url']; | ||
1074 | 103 | $desc = $r->fields['description']; | ||
1075 | 104 | $icon = $r->fields['icon']; | ||
1076 | 105 | if (strlen($url)>1){ | ||
1077 | 106 | if (preg_match('/^http:/',$url)){ | ||
1078 | 107 | $url="<br/><a href='".$url."'>Link</a>"; | ||
1079 | 108 | } else $url="<br/><a href='/".$url."'>Link</a>"; | ||
1080 | 109 | } else $url=$url; | ||
1081 | 110 | $date=date("c",strtotime($r->fields['placement_date'])); | ||
1082 | 111 | ?> | ||
1083 | 112 | <Placemark> | ||
1084 | 113 | <name><?=$title?></name> | ||
1085 | 114 | <description><![CDATA[ | ||
1086 | 115 | <?=$desc?><?=$url?>]]></description> | ||
1087 | 116 | <Point> | ||
1088 | 117 | <coordinates><?=$x.','.$y?>,0</coordinates> | ||
1089 | 118 | </Point><?if (strlen($icon)>1){?> | ||
1090 | 119 | <Style> | ||
1091 | 120 | <IconStyle> | ||
1092 | 121 | <Icon> | ||
1093 | 122 | <href><?=$icon?></href> | ||
1094 | 123 | </Icon> | ||
1095 | 124 | </IconStyle> | ||
1096 | 125 | </Style><? | ||
1097 | 126 | } ?><TimeStamp> | ||
1098 | 127 | <when><?=$date?></when> | ||
1099 | 128 | </TimeStamp> | ||
1100 | 129 | </Placemark> | ||
1101 | 130 | <? | ||
1102 | 131 | //echo join("\t",$r); | ||
1103 | 132 | //echo "\n"; | ||
1104 | 133 | $r->MoveNext(); | ||
1105 | 134 | |||
1106 | 135 | } | ||
1107 | 136 | |||
1108 | 137 | ?> | ||
1109 | 138 | </Document> | ||
1110 | 139 | </kml> | ||
1111 | 140 | |||
1112 | 141 | <?php | ||
1113 | 142 | } | ||
1114 | 143 | ?> | ||
1115 | 144 | |||
1116 | 145 |
1) Modified code to work functionally with the messaging module in windows
2) Implemented a new user-friendly SMS protocol for entering map points
e.g. map N35.26272 W120.27373 hospital 30 patients to be evacuated
Response:
Map point hospital confirmed
3) Implemented confirmation notification of map point and other data
4) Updated the SMS help messaging
5) Automatic assignment of feature class and associated icon on situation map based on SMS message
6) Implemented the sharing of KML feeds between Sahana and mods when the KML does not have .kml extension
7) Updated the backend to support the protocol sent by the android application
A few more tweaks are needed on the above to complete