Index: sms/sms.info
===================================================================
RCS file: /usr/local/cvsroot/sms/sms.info,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sms/sms.info 14 Jan 2007 11:31:45 -0000 1.1
@@ -0,0 +1,37 @@
+
+
+
+
+ SMS
+
+ f
+ f
+
+
+ Malte Sussdorff
+ SMS is a package to send out an SMS to a mobile number. It includes parameters for handling various sets of gateways.
+ 2007-01-14
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: sms/tcl/sms-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/sms/tcl/sms-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sms/tcl/sms-procs.tcl 14 Jan 2007 11:31:45 -0000 1.1
@@ -0,0 +1,55 @@
+# packages/sms/tcl/sms-procs.tcl
+
+ad_library {
+
+ SMS Procedures
+
+ @author Malte Sussdorff ()
+ @creation-date 2007-01-14
+ @cvs-id $Id: sms-procs.tcl,v 1.1 2007/01/14 11:31:45 maltes Exp $
+}
+
+namespace eval sms {}
+
+ad_proc -public sms::clean_phone_number {
+ -phone_number
+ {-package_id ""}
+} {
+
+ This procedure will take a phone number and strip it from "+",
+ leading 0 and whitespace, so we can have a clean phone number
+ which can be used for posting around.
+
+ @author Malte Sussdorff (malte.sussdorff@cognovis.de)
+ @creation-date 2007-01-14
+
+ @param phone_number Number to be cleaned
+
+ @param package_id Package_id to use
+
+ @return Phone number cleaned up with the prefix in front
+
+ @error
+} {
+
+ if {$package_id eq ""} {
+ set package_id [ad_conn package_id]
+ }
+
+ # Strip out the prefix, so we don't have it twice
+ set prefix [parameter::get -package_id $package_id -parameter Prefix]
+ set phone_number [string trimleft $phone_number $prefix]
+
+ # Strip out the "+" sign
+ regsub -all {\+} $phone_number {} phone_number
+
+ # Strip out (), which are being used to mark e.g. area codes
+ regsub -all {\(} $phone_number {} phone_number
+ regsub -all {\)} $phone_number {} phone_number
+
+ # Strip out any whitespace
+ regsub -all { } $phone_number {} phone_number
+
+ return "${prefix}$phone_number"
+}
+
Index: sms/www/sms.adp
===================================================================
RCS file: /usr/local/cvsroot/sms/www/sms.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sms/www/sms.adp 14 Jan 2007 11:31:45 -0000 1.1
@@ -0,0 +1,2 @@
+
+
Index: sms/www/sms.tcl
===================================================================
RCS file: /usr/local/cvsroot/sms/www/sms.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sms/www/sms.tcl 14 Jan 2007 11:31:45 -0000 1.1
@@ -0,0 +1,65 @@
+# packages/sms/www/sms.tcl
+
+ad_page_contract {
+
+ Page to send an SMS to a mobile number.
+
+ It is written to use with http://any-sms.de, but you should be able to use it with other providers just as easily.
+ The number must be all integer and start with the international area code, e.g 49175123456789
+
+ @author Malte Sussdorff (malte@openacs.de)
+ @creation-date 2007-01-14
+ @cvs-id $Id: sms.tcl,v 1.1 2007/01/14 11:31:45 maltes Exp $
+} {
+ mobile_number:float
+ {smstext ""}
+ {return_url "/"}
+} -properties {
+} -validate {
+} -errors {
+}
+
+
+set package_id [ad_conn package_id]
+set mobile_number [sms::clean_phone_number -phone_number $mobile_number -package_id $package_id]
+
+set form_elements {
+ {mobile_number:float(inform)
+ {label "[_ ams.Mobile_Number]"}
+ {value $mobile_number}
+ }
+ {smstext:text(text),optional
+ {label "[_ contacts.SMSText]"}
+ {html {size 55}}
+ }
+}
+
+
+ad_form -name sms -action [ad_conn url] \
+-form $form_elements \
+-on_submit {
+
+ set gateway_url [parameter::get -package_id $package_id -parameter SMSGatewayURL]
+ set login_id [parameter::get -package_id $package_id -parameter LoginID]
+ set password [parameter::get -package_id $package_id -parameter Password]
+ set gateway [parameter::get -package_id $package_id -parameter DefaultGateway]
+ set login_id_name [parameter::get -package_id $package_id -parameter LoginIDName]
+ set password_name [parameter::get -package_id $package_id -parameter PasswordName]
+ set gateway_name [parameter::get -package_id $package_id -parameter GatewayName]
+ set sender_name [parameter::get -package_id $package_id -parameter SenderName]
+ set sender_phone [ams::value -attribute_name [parameter::get -package_id $package_id -parameter MobilePhoneAttribute] -object_id [content::item::get_best_revision -item_id [ad_conn user_id]] -format "text"]
+ if {$sender_phone eq ""} {
+ set sender_phone "[parameter::get -package_id $package_id -parameter DefaultSender]"
+ }
+
+ # Handle the phone numbers
+ set sender_phone [sms::clean_phone_number -phone_number $sender_phone -package_id $package_id]
+
+ set smstext_name [parameter::get -package_id $package_id -parameter SMSTextName]
+ set mobile_phone_name [parameter::get -package_id $package_id -parameter MobilePhoneName]
+ set fetch_url "[export_vars -base "$gateway_url" -url [list [list "$login_id_name" "$login_id"] [list "$password_name" "$password"] [list "$gateway_name" "$gateway"] [list "$smstext_name" "$smstext"] [list "$mobile_phone_name" "$mobile_number"] [list "$sender_name" "$sender_phone"]]]"
+ set return_value [ad_httpget -url $fetch_url]
+ ad_returnredirect $return_url
+ util_user_message -html -message "SMS versendet"
+}
+