-
Notifications
You must be signed in to change notification settings - Fork 0
/
Person.php
72 lines (67 loc) · 2 KB
/
Person.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
class Person{
public $UserId;
public $carrier;
public $number;
public $timezone;
private $database;
function __construct($id){
$this->database = new Database();
$this->_LoadUserFromId($id);
}
private function _LoadUserFromId($UserId){
$query = "SELECT * FROM `".PrayerEng::USERS."` WHERE `Id` = ".$UserId;
if(!$this->database->runQuery($query))
return false;
if ($this->database->numRows > 0){
$results = $this->database->getFirstResult();
$this->UserId = $UserId;
$this->carrier = $results["Carrier"];
$this->number = $results["Number"];
$this->timezone = $results["Timezone"];
return true;
}else {
return false;
}
}
public function GetUsersTime($time = "now"){
$timezone = new DateTimeZone(timezone_name_from_abbr($this->timezone));
$date = new DateTime($time, $timezone);
return $date->format("H");
}
public function GetUserDate($time = "now"){
$timezone = new DateTimeZone(timezone_name_from_abbr($this->timezone));
$date = new DateTime($time, $timezone);
return $date->format("Y-m-d");
}
public function ScriptsToRun($hour = "now"){
if(!isset($hour) || !is_numeric($hour)){
$hour = $this->GetUsersTime();
}
$query = "SELECT `Task` FROM `".PrayerEng::SCHEDULE. "` WHERE `Hour` = ".$hour." AND `UserId` = ".$this->UserId;
if(!$this->database->runQuery($query))
return false;
if ($this->database->numRows > 0){
$results = $this->database->getResultsAssoc();
$tasks = array();
foreach($results as $r){
$tasks[] = $r['Task'];
}
return $tasks;
}else {
return false;
}
}
public function SendTextMsg($subject, $msg){
$to = $this->number.'@'.$this->carrier;
$subject = $subject;
$message = $msg;
mail($to, $subject, $message, null, '[email protected]');
}
//-----------------------------------------------------------
//------------------- Private -----------------------------
//-----------------------------------------------------------
}
?>