Exemplo n.º 1
0
 /**
  * Send The SMS Message Using Default Provider
  * @param to mixed	The destination address.
  * @param from mixed  The source/sender address
  * @param text mixed  The text content of the message
  *
  * @return mixed/bool (returns TRUE if sent FALSE or other text for fail)
  */
 public static function send($to = NULL, $from = NULL, $message = NULL)
 {
     if (!$to or !$message) {
         return "Missing Recipients and/or Message";
     }
     // 1. Do we have an SMS Provider?
     $provider = Kohana::config("settings.sms_provider");
     if ($provider) {
         // 2. Does the plugin exist, and if so, is it active?
         $plugin = ORM::factory("plugin")->where("plugin_name", $provider)->where("plugin_active", 1)->find();
         if ($plugin->loaded) {
             // Plugin exists and is active
             // 3. Does this plugin have the SMS Library in place?
             $class = ucfirst($provider) . '_SMS';
             $path = sms::find_provider($provider);
             if ($path) {
                 // File Exists
                 $sender = new $class();
                 // 4. Does the send method exist in this class?
                 if (method_exists($sender, 'send')) {
                     $response = $sender->send($to, $from, $message);
                     return $response;
                 }
             }
         }
     }
     return "No SMS Sending Provider In System";
 }