forked from LeedRSS/Leed
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFolder.class.php
executable file
·103 lines (80 loc) · 2.58 KB
/
Folder.class.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
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
<?php
/*
@nom: Folder
@auteur: Idleman ([email protected])
@description: Classe de gestion des dossiers/catégories contenant les flux
*/
class Folder extends MysqlEntity{
protected $id,$name,$parent,$isopen;
protected $TABLE_NAME = 'folder';
protected $CLASS_NAME = 'Folder';
protected $object_fields =
array(
'id'=>'key',
'name'=>'string',
'parent'=>'integer',
'isopen'=>'integer'
);
function unreadCount(){
$prefixTable = $this->getPrefixTable();
$results = $this->customQuery('SELECT COUNT('.$prefixTable.'event.id) FROM '.$prefixTable.'event INNER JOIN '.$prefixTable.'feed ON ('.$prefixTable.'event.feed = '.$prefixTable.'feed.id) WHERE '.$prefixTable.'event.unread=1 AND '.$prefixTable.'feed.folder = '.$this->getId());
$number = mysql_fetch_array($results);
return $number[0];
}
function getEvents($start=0,$limit=10000,$order,$columns='*'){
$prefixTable = $this->getPrefixTable();
$eventManager = new Event();
$objects = array();
$results = $this->customQuery('SELECT '.$columns.' FROM '.$prefixTable.'event INNER JOIN '.$prefixTable.'feed ON ('.$prefixTable.'event.feed = '.$prefixTable.'feed.id) WHERE '.$prefixTable.'event.unread=1 AND '.$prefixTable.'feed.folder = '.$this->getId().' ORDER BY '.$order.' LIMIT '.$start.','.$limit);
if($results!=false){
while($item = mysql_fetch_array($results)){
$object = new Event();
foreach($object->getObject_fields() as $field=>$type){
$setter = 'set'.ucFirst($field);
if(isset($item[$field])) $object->$setter($item[$field]);
}
$objects[] = $object;
unset($object);
}
}
return $objects;
}
function __construct(){
parent::__construct();
$myUser = (isset($_SESSION['currentUser'])?unserialize($_SESSION['currentUser']):false);
if ($myUser!=false) { $this->setPrefixTable($myUser->getPrefixDatabase()); }
}
function setId($id){
$this->id = $id;
}
function getFeeds(){
$feedManager = new Feed();
return $feedManager->loadAll(array('folder'=>$this->getId()),'name');
}
function getFolders(){
$folderManager = new Folder();
return $folderManager->loadAll(array('parent'=>$this->getId()));
}
function getId(){
return $this->id;
}
function getName(){
return $this->name;
}
function setName($name){
$this->name = $name;
}
function getParent(){
return $this->parent;
}
function setParent($parent){
$this->parent = $parent;
}
function getIsopen(){
return $this->isopen;
}
function setIsopen($isopen){
$this->isopen = $isopen;
}
}
?>