-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
1,593 additions
and
20,099 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,60 @@ | ||
<?php | ||
|
||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/* SMS Notifier Block | ||
* SMS notifier is a one way SMS messaging block that allows managers, teachers and administrators to | ||
* send text messages to their student and teacher. | ||
* @package blocks | ||
* @author: Azmat Ullah, Talha Noor | ||
* @date: 17-Jul-2014 | ||
*/ | ||
|
||
class block_sms extends block_base { | ||
|
||
public function init() { | ||
$this->title = get_string('sms', 'block_sms'); | ||
} | ||
|
||
public function get_content() { | ||
global $CFG, $USER, $COURSE; | ||
if ($this->content !== null) { | ||
return $this->content; | ||
} | ||
$this->content = new stdClass; | ||
$this->content->text = ''; | ||
$this->content->text .= html_writer::link(new moodle_url('/blocks/sms/view.php', array('viewpage' => '2')), get_string('sms_send', 'block_sms')) . '<br>'; | ||
$this->content->text .= html_writer::link(new moodle_url('/blocks/sms/view.php', array('viewpage' => '3')), get_string('sms_template', 'block_sms')) . '<br>'; | ||
return $this->content; | ||
} | ||
|
||
public function has_config() { | ||
return true; | ||
} | ||
|
||
public function applicable_formats() { | ||
return array('all' => true); | ||
} | ||
|
||
public function instance_allow_config() { | ||
return true; | ||
} | ||
|
||
} | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
/* SMS Notifier Block | ||
* SMS notifier is a one way SMS messaging block that allows managers, teachers and administrators to | ||
* send text messages to their student and teacher. | ||
* @package blocks | ||
* @author: Waqas Ansari | ||
* @date: 21-May-2019 | ||
*/ | ||
/** | ||
* @copyright 2019 3iLogic <[email protected]> | ||
*/ | ||
|
||
defined('MOODLE_INTERNAL') || die; | ||
|
||
class block_sms extends block_base { | ||
|
||
public function init() { | ||
$this->title = get_string('sms', 'block_sms'); | ||
} | ||
|
||
public function get_content() { | ||
global $CFG, $USER, $COURSE; | ||
if ($this->content !== null) { | ||
return $this->content; | ||
} | ||
$this->content = new stdClass; | ||
$this->content->text = ''; | ||
$this->content->text .= html_writer::link(new moodle_url('/blocks/sms/view.php', | ||
array('viewpage' => '2')), | ||
get_string('sms_send', 'block_sms')) . '<br>'; | ||
$this->content->text .= html_writer::link(new moodle_url('/blocks/sms/view.php', | ||
array('viewpage' => '3')), | ||
get_string('sms_template', 'block_sms')) . '<br>'; | ||
return $this->content; | ||
} | ||
|
||
public function has_config() { | ||
return true; | ||
} | ||
public function applicable_formats() { | ||
return array('all' => true); | ||
} | ||
public function instance_allow_config() { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/* SMS notifier Block | ||
* SMS notifier is a one way SMS messaging block that allows managers, teachers and administrators to | ||
* send text messages to their student and teacher. | ||
* @package blocks | ||
* @author: Waqas Ansari | ||
* @date: 21-May-2019 | ||
*/ | ||
/** | ||
* @copyright 2019 3iLogic <[email protected]> | ||
*/ | ||
defined('MOODLE_INTERNAL') || die; | ||
|
||
class ClickatellAPI { | ||
private $uri; | ||
private $apikey; | ||
|
||
public function __construct() { | ||
global $CFG; | ||
$this->uri = "https://platform.clickatell.com/messages/http/send"; | ||
$this->apikey = $CFG->block_sms_clickatell_apikey; | ||
$this->uri = $this->uri . "?apiKey=" . $this->apikey; | ||
} | ||
|
||
public function send_sms($to, $text) { | ||
$result = $this->trigger_api($to, $text); | ||
$status = false; | ||
try { | ||
$result = json_decode($result, true); | ||
$status = $result["messages"][0]["accepted"] == "true"; | ||
} catch (Exception $e) { | ||
";"; | ||
} | ||
return $status; | ||
} | ||
|
||
private function trigger_api($to, $text) { | ||
$data = "&to={$to}&content=" . urlencode($text); | ||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_URL, $this->uri . $data); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | ||
"Accept: application/json")); | ||
$result = curl_exec($ch); | ||
curl_close($ch); | ||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
/* SMS notifier Block | ||
* SMS notifier is a one way SMS messaging block that allows managers, teachers and administrators to | ||
* send text messages to their student and teacher. | ||
* @package blocks | ||
* @author: Waqas Ansari | ||
* @date: 21-May-2019 | ||
*/ | ||
/** | ||
* @copyright 2019 3iLogic <[email protected]> | ||
*/ | ||
defined('MOODLE_INTERNAL') || die(); | ||
class LabsmobileAPI { | ||
private $uri; | ||
private $username; | ||
private $password; | ||
private $sender; | ||
|
||
public function __construct() { | ||
global $CFG; | ||
$this->uri = "https://api.labsmobile.com/get/send.php"; | ||
$this->username = $CFG->block_sms_labsmobile_username; | ||
$this->password = $CFG->block_sms_labsmobile_password; | ||
$this->sender = $CFG->block_sms_labsmobile_sender; | ||
} | ||
|
||
public function send_sms($to, $text) { | ||
$result = $this->trigger_api($to, $text); | ||
$status = false; | ||
if(stripos($result, "<code>") !== FALSE) { | ||
$initpos = stripos($result, "<code>") + 6; | ||
$endpos = stripos($result, "</code>"); | ||
$code = substr($result, $initpos, $endpos - $initpos); | ||
if($code == "0") { | ||
$status = true; | ||
} | ||
} | ||
return $status; | ||
} | ||
|
||
private function trigger_api($to, $text) { | ||
$ch = curl_init(); | ||
$params = "username=" . $this->username . | ||
"&password=" . $this->password . | ||
"&sender=" . $this->sender . | ||
"&msisdn={$to}" . | ||
"&message=" . $text; | ||
curl_setopt($ch, CURLOPT_URL, $this->uri . "?" . $params); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
curl_setopt($ch, CURLOPT_TIMEOUT, 15); | ||
curl_setopt($ch, CURLOPT_HEADER, false); | ||
$output = curl_exec($ch); | ||
curl_close($ch); | ||
return $output; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
/* SMS notifier Block | ||
* SMS notifier is a one way SMS messaging block that allows managers, teachers and administrators to | ||
* send text messages to their student and teacher. | ||
* @package blocks | ||
* @author: Waqas Ansari | ||
* @date: 21-May-2019 | ||
*/ | ||
/** | ||
* @copyright 2019 3iLogic <[email protected]> | ||
*/ | ||
defined('MOODLE_INTERNAL') || die(); | ||
class NexmoAPI { | ||
private $uri; | ||
private $apikey; | ||
private $secretkey; | ||
private $fromnumber; | ||
|
||
public function __construct() { | ||
global $CFG; | ||
$this->uri = "https://rest.nexmo.com/sms/json"; | ||
$this->apikey = $CFG->block_sms_nexmo_apikey; | ||
$this->secretkey = $CFG->block_sms_nexmo_api_secret; | ||
$this->fromnumber = $CFG->block_sms_nexmo_api_from; | ||
$this->uri = $this->uri . "?api_key=" . $this->apikey . "&api_secret=" . $this->secretkey; | ||
} | ||
|
||
public function send_sms($to, $text) { | ||
$result = $this->trigger_api($to, $text); | ||
$status = false; | ||
try { | ||
$result = json_decode($result, true); | ||
$status = $result["messages"][0]["status"] == 0; | ||
} catch (Exception $e) { | ||
";"; | ||
} | ||
return $status; | ||
} | ||
|
||
private function trigger_api($to, $text) { | ||
$data = "from={$this->fromnumber}&to={$to}&text=".urlencode($text); | ||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_URL, $this->uri); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
curl_setopt($ch, CURLOPT_ENCODING, ""); | ||
curl_setopt($ch, CURLOPT_MAXREDIRS, 10); | ||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); | ||
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | ||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); | ||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | ||
"Content-Type: application/x-www-form-urlencoded" | ||
) | ||
); | ||
$output = curl_exec($ch); | ||
curl_close($ch); | ||
return $output; | ||
} | ||
} |
Oops, something went wrong.