| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
class SH4_Reminders_Sms |
| 3 |
{ |
| 4 |
public $self, $settings; |
| 5 |
|
| 6 |
public function __construct( |
| 7 |
HC3_Settings $settings, |
| 8 |
HC3_Hooks $hooks |
| 9 |
) |
| 10 |
{ |
| 11 |
$this->settings = $hooks->wrap( $settings ); |
| 12 |
$this->self = $hooks->wrap( $this ); |
| 13 |
} |
| 14 |
|
| 15 |
public function isEnabled() |
| 16 |
{ |
| 17 |
$ret = function_exists( 'wp_sms_send' ) ? true : false; |
| 18 |
return $ret; |
| 19 |
} |
| 20 |
|
| 21 |
public function send( $to, $msg ) |
| 22 |
{ |
| 23 |
if( ! is_array($to) ) $to = [ $to ]; |
| 24 |
wp_sms_send( $to, $msg ); |
| 25 |
} |
| 26 |
|
| 27 |
public function setUserPhone( $userId, $phoneNo ) |
| 28 |
{ |
| 29 |
$pname = 'sms_user_phone_' . $userId; |
| 30 |
$this->settings->set( $pname, $phoneNo ); |
| 31 |
return $this; |
| 32 |
} |
| 33 |
|
| 34 |
public function getUserPhone( $userId ) |
| 35 |
{ |
| 36 |
$pname = 'sms_user_phone_' . $userId; |
| 37 |
$ret = $this->settings->get( $pname ); |
| 38 |
return $ret; |
| 39 |
} |
| 40 |
|
| 41 |
public function setEmployeePhone( $employeeId, $phoneNo ) |
| 42 |
{ |
| 43 |
$pname = 'sms_employee_phone_' . $employeeId; |
| 44 |
$this->settings->set( $pname, $phoneNo ); |
| 45 |
return $this; |
| 46 |
} |
| 47 |
|
| 48 |
public function getEmployeePhone( $employeeId ) |
| 49 |
{ |
| 50 |
$pname = 'sms_employee_phone_' . $employeeId; |
| 51 |
$ret = $this->settings->get( $pname ); |
| 52 |
return $ret; |
| 53 |
} |
| 54 |
} |