Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/zend/Zend/Service/DeveloperGarden/Request/SendSms/SendSmsAbstract.php
Go to the documentation of this file.
00001 <?php
00002 
00027 require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
00028 
00037 abstract class Zend_Service_DeveloperGarden_Request_SendSms_SendSmsAbstract
00038     extends Zend_Service_DeveloperGarden_Request_RequestAbstract
00039 {
00045     public $number = null;
00046 
00052     public $message = null;
00053 
00059     public $originator = null;
00060 
00066     public $account = null;
00067 
00074     private $_specialChars = array(
00075         '|', 
00076         '^', 
00077         '{', 
00078         '}', 
00079         '[', 
00080         ']', 
00081         '~', 
00082         '\\', 
00083         "\n",
00084         // '€', removed because its counted in utf8 correctly
00085     );
00086 
00095     protected $_smsType = 1;
00096 
00104     protected $_smsLength = 153;
00105 
00111     protected $_maxLength = 765;
00112 
00118     protected $_maxNumbers = 10;
00119 
00125     public function getNumber()
00126     {
00127         return $this->number;
00128     }
00129 
00138     public function setNumber($number)
00139     {
00140         $this->number = $number;
00141         if ($this->getNumberCount() > $this->_maxNumbers) {
00142             require_once 'Zend/Service/DeveloperGarden/Request/Exception.php';
00143             throw new Zend_Service_DeveloperGarden_Request_Exception('The message is too long.');
00144         }
00145         return $this;
00146     }
00147 
00153     public function getMessage()
00154     {
00155         return $this->message;
00156     }
00157 
00166     public function setMessage($message)
00167     {
00168         $this->message = $message;
00169         if ($this->getMessageLength() > $this->_maxLength) {
00170             require_once 'Zend/Service/DeveloperGarden/Request/Exception.php';
00171             throw new Zend_Service_DeveloperGarden_Request_Exception('The message is too long.');
00172         }
00173         return $this;
00174     }
00175 
00181     public function getOriginator()
00182     {
00183         return $this->originator;
00184     }
00185 
00192     public function setOriginator($originator)
00193     {
00194         $this->originator = $originator;
00195         return $this;
00196     }
00197 
00202     public function getAccount()
00203     {
00204         return $this->account;
00205     }
00206 
00213     public function setAccount($account)
00214     {
00215         $this->account = $account;
00216         return $this;
00217     }
00218 
00224     public function getMessageLength()
00225     {
00226         $message = $this->getMessage();
00227         $length  = strlen($message);
00228 
00229         foreach ($this->_specialChars as $char) {
00230             $c = (substr_count($message, $char) * 2) - 1;
00231             if ($c > 0) {
00232                 $length += $c;
00233             }
00234         }
00235 
00236         return $length;
00237     }
00238 
00244     public function getMessageCount()
00245     {
00246         $smsLength = $this->getMessageLength();
00247         $retValue = 1;
00248         if ($smsLength > 160) {
00249             $retValue = ceil($smsLength / $this->_smsLength);
00250         }
00251         return $retValue;
00252     }
00253 
00259     public function getNumberCount()
00260     {
00261         $number   = $this->getNumber();
00262         $retValue = 0;
00263         if (!empty($number)) {
00264             $retValue = count(explode(',', $number));
00265         }
00266         return $retValue;
00267     }
00268 
00277     public function getSmsType()
00278     {
00279         return $this->_smsType;
00280     }
00281 }
 All Data Structures Namespaces Files Functions Variables Enumerations