root/devel/mod/rpc/lib/class_tag.php

Revision 454, 3.1 kB (checked in by sven, 2 years ago)

removed some addslashes. replaced some with adodb qstr().
removed some stripslashes. a lot more still want to go, depending on how much we care about showing users even more inappropriate backslashes than currently.
fixed a few more php notices.

  • Property svn:eol-style set to native
Line 
1 <?php
2
3     class Tag extends ElggObject
4     {
5         var $tag;
6         var $tagtype;
7         var $ref;
8         var $access;
9         var $type = 'tag';
10
11         var $exists;
12
13         /**
14          *
15          */
16         function Tag($var = "default")
17         {
18             $this->exists = false;
19
20             // Parameter passed, assume an existing tag
21             if ($var != "")
22             {
23                 if ($result = get_record('tags','ident',$var)) {
24                     $this->ident   = $result->ident;
25                     $this->tag     = $result->tag;
26                     $this->tagtype = $result->tagtype;
27                     $this->ref     = $result->ref;
28                     $this->access  = $result->access;
29                     $this->owner   = $result->owner;
30                     
31                     // Does the requested id exist
32                     $this->exists = true;
33                 }
34             }
35         }
36
37         /**
38          *
39          */
40         function getTagName()
41         {
42             return $this->tag;
43         }
44
45         /**
46          *
47          */
48         function getTagType()
49         {
50             return $this->tagtype;
51         }
52
53         /**
54          *
55          */
56         function getRef()
57         {
58             return $this->ref;
59         }
60
61         /**
62          *
63          */
64         function getAccess()
65         {
66             return $this->access;
67         }
68
69         /**
70          *
71          */
72         function setTagName($val)
73         {
74             $this->tag = trim($val);
75         }
76
77         /**
78          *
79          */
80         function setTagType($val = "weblog")
81         {
82             $this->tagtype = $val;
83         }
84
85         /**
86          *
87          */
88         function setRef($val)
89         {
90             $this->ref = $val;
91         }
92
93         /**
94          *
95          */
96         function setAccess($val = "PUBLIC")
97         {
98             $this->access = $val;
99         }
100
101         /**
102          *
103          */
104         function setOwner($val)
105         {
106             $this->owner = $val;
107         }
108
109         /**
110          *
111          */
112         function delete()
113         {
114             if ($this->exists == true)
115             {
116                 return delete_records('tags','ident',$this->ident);
117             }
118             else
119             {
120                 return false;
121             }
122         }
123
124         /**
125          *
126          */
127         function save()
128         {
129             $t = new StdClass;
130             $t->tagtype = 'weblog';
131             $t->access = $this->access;
132             $t->tag = $this->tag;
133             $t->ref = $this->ref;
134             $t->owner = $this->owner;
135             // Always delete existing tags
136             if ($this->exists == false)
137             {
138                 if ($this->ident = insert_record('tags',$t)) {
139                     $this->exists = true;
140                     return $this->ident;
141                 }
142                 return false;
143             }
144             else
145             {
146                 $t->ident = $this->ident;
147                 if (update_record('tags',$t)) {
148                     return $this->ident;
149                 }
150                 return false;
151             }
152         }
153     }
154 ?>
155
Note: See TracBrowser for help on using the browser.