Index: sms/www/sms.tcl =================================================================== RCS file: /usr/local/cvsroot/sms/www/sms.tcl,v diff -u -r1.1 -r1.2 --- sms/www/sms.tcl 14 Jan 2007 11:31:45 -0000 1.1 +++ sms/www/sms.tcl 10 Apr 2007 09:16:39 -0000 1.2 @@ -11,8 +11,9 @@ @creation-date 2007-01-14 @cvs-id $Id$ } { - mobile_number:float + {mobile_number ""} {smstext ""} + {recipient_id ""} {return_url "/"} } -properties { } -validate { @@ -21,20 +22,43 @@ set package_id [ad_conn package_id] -set mobile_number [sms::clean_phone_number -phone_number $mobile_number -package_id $package_id] +# First get the recipien, then clean the number +if {$recipient_id eq ""} { + set recipient_id [db_string recipient "select distinct item_id from cr_revisions, ams_attribute_values, telecom_numbers where revision_id=object_id and value_id = number_id and subscriber_number = ':mobile_number' limit 1"] +} + set form_elements { {mobile_number:float(inform) {label "[_ ams.Mobile_Number]"} {value $mobile_number} } - {smstext:text(text),optional - {label "[_ contacts.SMSText]"} - {html {size 55}} +} + +if {$recipient_id ne ""} { + lappend form_elements { + {recipient_id:float(inform) + {label "[_ contacts.Recipient]"} + {display_template "[contact::name -party_id $recipient_id]"} + } } } +lappend form_elements [list \ + smstext:text(textarea),optional \ + [list label "[_ sms.SMSText]"] \ + [list html [list size 55 onKeyDown "textCounter(document.sms.smstext,document.sms.smslength,480)" onKeyUp "textCounter(document.sms.smstext,document.sms.smslength,480)" wrap physical cols 50 rows 5]] \ + ] +lappend form_elements [list \ + smslength:text(text),optional \ + [list label "[_ sms.SMSLenght]"] \ + [list html {size 3 maxlength 3}] \ + [list value 480] \ + [list help_text "Break Points are 321, 161"] + ] + + ad_form -name sms -action [ad_conn url] \ -form $form_elements \ -on_submit { @@ -51,14 +75,24 @@ if {$sender_phone eq ""} { set sender_phone "[parameter::get -package_id $package_id -parameter DefaultSender]" } + + # If we have a recipient_id we take the number from the recipient, + # otherwise use the mobile number given to us. + set recipient_phone [ams::value -attribute_name [parameter::get -package_id $package_id -parameter MobilePhoneAttribute] -object_id [content::item::get_best_revision -item_id $recipient_id] -format "text"] + if {$recipient_phone ne ""} { + set mobile_number $recipient_phone + } # Handle the phone numbers set sender_phone [sms::clean_phone_number -phone_number $sender_phone -package_id $package_id] + set mobile_number [sms::clean_phone_number -phone_number $mobile_number -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] + if { ![parameter::get_from_package_key -parameter "ForceCountryCodeOneFormatting" -package_key "ams" -default "0"] } { ad_returnredirect $return_url util_user_message -html -message "SMS versendet" }