class TaskItem private Id public Login public Year public Month public

  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
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
class TaskItem
{
private $Id;
public $Login;
public $Year;
public $Month;
public $Day;
public $Text;
public $Expire;
function __construct($Login, $Id = null)
{
global $Language;
global $DatabaseConnection;
$this->Exists = FALSE;
$this->Author = $Login;
$Optional = null;
if(!$IgnoreActive)
{
$Optional = " AND active='1'";
}
if(!empty($Id) && $Query = Database::GetItems('tasks', 0, 1, null, FALSE, " AND id='".$Id."' AND login='".$Login."'".$Optional))
{
$this->Id = $Id;
$this->Login = $Login;
$this->Year = $Query[0]['year'];
$this->Month = $Query[0]['month'];
$this->Day = $Query[0]['day'];
$this->Text = $Query[0]['text'];
}
}
function Exists()
{
return $this->Exists;
}
function Save()
{
global $Language;
global $DatabaseConnection;
$Year = (int) $Year;
$Month = (int) $Month;
$Day = (int) $Day;
$QueryText = "INSERT INTO tasks(id,login,year,month,day,text) VALUES(NULL, '".sqlite_escape_string($this->Login)."', '".$Year."', '".$Month."', '".$Day."', '".sqlite_escape_string($this->Text)."')";
if($this->Exists)
{
$QueryText = "UPDATE tasks SET year='".$Year."', month='".$Month."', day='".$Day."', text='".sqlite_escape_string($this->Text)."' WHERE id=".$this->Id." AND login='".$this->Login."'";
}
$DatabaseConnection->Query($QueryText);
}
}
/*--------------------------------------------------------------------------*/
class TaskGroup extends ItemGroup
{
public $Items = array();
private $Start;
private $Limit;
private $Login;
private $List;
private $Year;
private $Month;
private $Day;
function __construct($Login, $Start = 0, $Limit = 15, $Search)
{
$this->Start = $Start;
$this->Limit = $Limit;
$this->Login = $Login;
if($Query = Database::GetItems('tasks', $Start, $Limit, null, FALSE, " WHERE login='".$Login."'"))
{
$this->Items = $Query;
}
}
function Display()
{
global $Page;
global $Language;
global $DatabaseConnection;
echo "<script language=\"JavaScript\" src=\"includes/table.js\"></script>
<hr><div id=\"sortableTable\">
<table width=\"100%\" id=\"TasksTable\"><thead><tr>
<td align=\"left\" width=\"1%\"><input type=\"checkbox\" name=\"checkingbox\" onChange=\"javascript:SetChecked(this.checked, 'delete[]');\"></td>
<td align=\"left\">$Language[91]</td>
<td align=\"left\">$Language[90]</td>
<td align=\"middle\">$Language[102]</td>
</tr></thead><tbody>";
foreach($this->Items as $Item)
{
echo "<tr>
<td align=\"left\"><input type=\"checkbox\" name=\"delete[]\" value=\"".$Item['id']."\"></td>
<td align=\"left\">";
echo $Item['day'].".".$Item['month'].".".$Item['year'];
$Date = getdate(time());
echo " ".$Date['weekday'];
if((int) $Date['mon'] == (int) $Item['month'] && (int) $Date['year'] == (int) $Item['year'] && (int) $Date['mday'] == (int) $Item['day'])
{
echo " <b>($Language[79])</b>";
}
echo "</td>\n<td align=\"left\">".$Item['text']."</td>\n<td align=\"middle\"><a href=\"?module=profiles&section=calendar&delete=".$Item['id']."\"> <img src=\"images/modules/delete.png\" border=\"0\" title=\"$Language[66]\"></a></td></tr>\n";
}
echo "</tbody></table></div><hr>
<script type=\"text/javascript\">
initTableWidget('TasksTable','100%', '100%',Array(false, 'S','S','S'));
</script>";
$Optional = null;
if(!empty($_GET['search']))
{
$Optional .= "&search=".SecureQuery($_GET['search']);
}
PageNavigation(count(Database::GetItems('tasks', 0, FALSE, null, FALSE, " WHERE login='".$this->Login."' AND text LIKE '%".$Search."%'")), $Page, "?module=profiles&section=calendar".$Optional, $this->Limit);
}
}