noalyss Version-9
Public Member Functions | Static Public Member Functions | Data Fields | Private Attributes | Static Private Attributes
Todo_List Class Reference

This class manages the table todo_list. More...

+ Collaboration diagram for Todo_List:

Public Member Functions

 __construct ($p_init)
 
 add_share ($p_login)
 Add a share with someone. More...
 
 check ($p_idx, &$p_value)
 
 delete ()
 
 display ()
 Display the note. More...
 
 display_row ($p_odd, $with_tag='Y')
 
 display_user ()
 display all the user to select the user with who we want to share the connected user is not shown @global type $g_user More...
 
 get_class ()
 Highlight today. More...
 
 get_info ()
 
 get_parameter ($p_string)
 
 insert ()
 
 is_shared_with ($p_login)
 return the todo_list_shared.id of the note, if nothing is found then return 0 More...
 
 load ()
 load the todo_list row thanks it's ID More...
 
 load_all ()
 load all the task More...
 
 remove_share ($p_login)
 remove the share with someone More...
 
 remove_shared_with ($p_array)
 Insert a share for current note in the table todo_list_shared The public shared note cannot be removed. More...
 
 save ()
 
 save_shared_with ($p_array)
 Insert a share for current note in the table todo_list_shared. More...
 
 set_is_public ($p_value)
 set a note public More...
 
 set_parameter ($p_string, $p_value)
 
 toXML ()
 transform into xml for ajax answer More...
 
 update ()
 
 verify ()
 

Static Public Member Functions

static test_me ()
 static testing function More...
 
static to_object ($p_cn, $p_array)
 

Data Fields

 $tl_desc
 

Private Attributes

 $cn
 
 $is_public
 
 $tl_date
 
 $tl_id
 
 $tl_title
 
 $use_login
 

Static Private Attributes

static $variable
 

Detailed Description

This class manages the table todo_list.

Data Member :

Definition at line 42 of file todo_list.class.php.

Constructor & Destructor Documentation

◆ __construct()

Todo_List::__construct (   $p_init)

Definition at line 55 of file todo_list.class.php.

56 {
57 $this->cn=$p_init;
58 $this->tl_id=0;
59 $this->tl_desc="";
60 $this->use_login=$_SESSION[SESSION_KEY.'g_user'];
61 $this->is_public="N";
62
63 }
$input_from cn
Definition: balance.inc.php:66

References cn.

Member Function Documentation

◆ add_share()

Todo_List::add_share (   $p_login)

Add a share with someone.

Parameters
type$p_login

Definition at line 408 of file todo_list.class.php.

409 {
410 $this->cn->exec_sql("insert into todo_list_shared(todo_list_id,use_login) values ($1,$2)",array($this->tl_id,$p_login));
411 }

◆ check()

Todo_List::check (   $p_idx,
$p_value 
)

Definition at line 74 of file todo_list.class.php.

75 {
76 if ( strcmp ($p_idx, 'tl_id') == 0 )
77 {
78 if ( strlen($p_value) > 6 || isNumber ($p_value) == false) return false;
79 }
80 if ( strcmp ($p_idx, 'tl_date') == 0 )
81 {
82 if ( noalyss_strlentrim($p_value) ==0 ||strlen($p_value) > 12 || isDate ($p_value) == false) return false;
83 }
84 if ( strcmp ($p_idx, 'tl_title') == 0 )
85 {
86 $p_value=mb_substr($p_value,0,120) ;
87 return true;
88 }
89 if ( strcmp ($p_idx, 'tl_desc') == 0 )
90 {
91 $p_value=mb_substr($p_value,0,1000) ;
92 return true;
93 }
94 return true;
95 }
isNumber($p_int)
Definition: ac_common.php:215
isDate($p_date)
Definition: ac_common.php:236
noalyss_strlentrim($p_string)
Definition: ac_common.php:1549

References isDate(), isNumber(), and noalyss_strlentrim().

Referenced by set_parameter().

+ Here is the call graph for this function:

◆ delete()

Todo_List::delete ( )

Definition at line 233 of file todo_list.class.php.

234 {
235 global $g_user;
236 if ( $this->use_login != $_SESSION[SESSION_KEY.'g_user'] && $g_user->check_action(SHARENOTEREMOVE)==0) return;
237
238 $sql="delete from todo_list_shared where todo_list_id=$1 ";
239 $res=$this->cn->exec_sql($sql,array($this->tl_id));
240
241 $sql="delete from todo_list where tl_id=$1 ";
242 $res=$this->cn->exec_sql($sql,array($this->tl_id));
243
244
245
246 }
global $g_user
if no group available , then stop
const SHARENOTEREMOVE

References $g_user, $res, $sql, cn, and SHARENOTEREMOVE.

◆ display()

Todo_List::display ( )

Display the note.

Returns
html string

Definition at line 302 of file todo_list.class.php.

303 {
304 ob_start();
305 $this->load();
306 include NOALYSS_TEMPLATE.'/todo_list_display.php';
307 $ret=ob_get_clean();
308
309 return $ret;
310 }
load()
load the todo_list row thanks it's ID

References $ret, and load().

+ Here is the call graph for this function:

◆ display_row()

Todo_List::display_row (   $p_odd,
  $with_tag = 'Y' 
)

Definition at line 322 of file todo_list.class.php.

323 {
324 $r="";
325 $highlight=$this->get_class();
326 $p_odd=($highlight == "")?$p_odd:$highlight;
327 if ( $with_tag == 'Y') $r = '<tr id="tr'.$this->tl_id.'" class="'.$p_odd.'">';
328 $r.=
329 '<td sorttable_customkey="'.format_date($this->tl_date,'DD.MM.YYYY','YYYYMMDD').'">'.
330 $this->tl_date.
331 '</td>'.
332 '<td>'.
333 '<a class="line" href="javascript:void(0)" onclick="todo_list_show(\''.$this->tl_id.'\')">'.
334 htmlspecialchars($this->tl_title).
335 '</a>'.
336 '</td>';
337 if ( $this->is_public == 'Y' && $this->use_login != $_SESSION[SESSION_KEY.'g_user'] )
338 { // This is a public note, cannot be removed
339 $r.= '<td></td>';
340 }
341 elseif ($this->use_login == $_SESSION[SESSION_KEY.'g_user'] )
342 {
343 // This a note the user owns
344 $r.= '<td>'.
345 Icon_Action::trash(uniqid(),sprintf("todo_list_remove('%s')",$this->tl_id)).
346 '</td>';
347 }
348 else
349 {
350 // this is a note shared by someone else
351 $r.= '<td>'.
352 Icon_Action::trash(uniqid(),sprintf("todo_list_remove_share('%s','%s','%s')",$this->tl_id,$this->use_login,Dossier::id())).
353 '</td>';
354 }
355
356 if ( $with_tag == 'Y') $r .= '</tr>';
357 return $r;
358 }
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
get_class()
Highlight today.

References $r, and get_class().

+ Here is the call graph for this function:

◆ display_user()

Todo_List::display_user ( )

display all the user to select the user with who we want to share the connected user is not shown @global type $g_user

Definition at line 383 of file todo_list.class.php.

384 {
385 global $g_user;
386 // Get array of user
387 $p_array=Noalyss_user::get_list(Dossier::id());
389 include NOALYSS_TEMPLATE.'/todo_list_list_user.php';
390
391 }
$dossier
static id()
return the 'gDossier' value after a check

◆ get_class()

Todo_List::get_class ( )

Highlight today.

Returns
string

Definition at line 315 of file todo_list.class.php.

316 {
317 $p_odd="";
318 $a=date('d.m.Y');
319 if ($a == $this->tl_date) $p_odd='highlight';
320 return $p_odd;
321 }

References $a.

Referenced by display_row().

◆ get_info()

Todo_List::get_info ( )

Definition at line 108 of file todo_list.class.php.

109 {
110 return var_export(self::$variable,true);
111 }

References $variable.

◆ get_parameter()

Todo_List::get_parameter (   $p_string)

Definition at line 64 of file todo_list.class.php.

65 {
66 if ( array_key_exists($p_string,self::$variable) )
67 {
68 $idx=self::$variable[$p_string];
69 return $this->$idx;
70 }
71 else
72 throw new Exception("Attribut inexistant $p_string");
73 }
$idx

References $idx, and $variable.

Referenced by save().

◆ insert()

Todo_List::insert ( )

Definition at line 128 of file todo_list.class.php.

129 {
130 if ( $this->verify() != 0 ) return;
131 if (trim($this->tl_title)=='')
132 $this->tl_title=mb_substr(trim($this->tl_desc),0,30);
133
134 if (trim($this->tl_title)=='')
135 {
136 alert('La note est vide');
137 return;
138 }
139
140 /* limit the title to 35 char */
141 $this->tl_title=mb_substr(trim($this->tl_title),0,30);
142
143 $sql="insert into todo_list (tl_date,tl_title,tl_desc,use_login,is_public) ".
144 " values (to_date($1,'DD.MM.YYYY'),$2,$3,$4,$5) returning tl_id";
145 $res=$this->cn->exec_sql(
146 $sql,
147 array($this->tl_date,
148 $this->tl_title,
149 $this->tl_desc,
150 $this->use_login,
151 $this->is_public)
152 );
153 $this->tl_id=Database::fetch_result($res,0,0);
154
155 }
alert($p_msg, $buffer=false)
alert in javascript
Definition: ac_common.php:738
static fetch_result($ret, $p_row=0, $p_col=0)
wrapper for the function pg_fetch_all

References $res, $sql, alert(), cn, DatabaseCore\fetch_result(), and verify().

Referenced by save().

+ Here is the call graph for this function:

◆ is_shared_with()

Todo_List::is_shared_with (   $p_login)

return the todo_list_shared.id of the note, if nothing is found then return 0

Parameters
$p_login
Returns
int

Definition at line 398 of file todo_list.class.php.

399 {
400 $ret=$this->cn->get_value("select id from todo_list_shared where use_login=$1 and todo_list_id=$2",array($p_login,$this->tl_id));
401 if ($ret == "")return 0;
402 return $ret;
403 }

◆ load()

Todo_List::load ( )

load the todo_list row thanks it's ID

Returns
boolean true if found else false

Definition at line 213 of file todo_list.class.php.

213 :bool
214 {
215
216 $sql="select tl_id,tl_title,tl_desc,to_char( tl_date,'DD.MM.YYYY') as tl_date,is_public,use_login
217 from todo_list where tl_id=$1 ";
218
219 $res=$this->cn->exec_sql(
220 $sql,
221 array($this->tl_id)
222 );
223
224 if ( Database::num_row($res) == 0 ) return false;
226 $aIndex=array_values(self::$variable);
227 foreach ($aIndex as $idx)
228 {
229 $this->$idx=$row[$idx];
230 }
231 return true;
232 }
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows

References $idx, $res, $row, $sql, $variable, cn, DatabaseCore\fetch_array(), and DatabaseCore\num_row().

Referenced by display().

+ Here is the call graph for this function:

◆ load_all()

Todo_List::load_all ( )

load all the task

Returns
an array of the existing tasks of the current user

Definition at line 188 of file todo_list.class.php.

189 {
190 $sql="select tl_id,
191 tl_title,
192 tl_desc,
193 to_char( tl_date,'DD.MM.YYYY') as tl_date,
194 is_public,
195 use_login
196 from todo_list
197 where
198 use_login=$1
199 or is_public = 'Y'
200 or tl_id in (select todo_list_id from todo_list_shared where use_login=$1)
201 order by tl_date::date desc";
202 $res=$this->cn->exec_sql(
203 $sql,
204 array($this->use_login));
206
207 return $array;
208 }
static fetch_all($ret)
wrapper for the function pg_fetch_all

References $array, $res, $sql, cn, and DatabaseCore\fetch_all().

+ Here is the call graph for this function:

◆ remove_share()

Todo_List::remove_share (   $p_login)

remove the share with someone

Parameters
type$p_login

Definition at line 416 of file todo_list.class.php.

417 {
418 $this->cn->exec_sql("delete from todo_list_shared where todo_list_id = $1 and use_login = $2 ",array($this->tl_id,$p_login));
419 }

◆ remove_shared_with()

Todo_List::remove_shared_with (   $p_array)

Insert a share for current note in the table todo_list_shared The public shared note cannot be removed.

Parameters
string(use_login)

Definition at line 292 of file todo_list.class.php.

293 {
294 $this->cn->exec_sql('delete from todo_list_shared where todo_list_id = $1 and use_login=$2',
295 array($this->tl_id,$p_array));
296 }

References $p_array, and cn.

◆ save()

Todo_List::save ( )

Definition at line 120 of file todo_list.class.php.

121 {
122 if ( $this->get_parameter("id") == 0 )
123 $this->insert();
124 else
125 $this->update();
126 }
get_parameter($p_string)

References get_parameter(), insert(), and update().

+ Here is the call graph for this function:

◆ save_shared_with()

Todo_List::save_shared_with (   $p_array)

Insert a share for current note in the table todo_list_shared.

Parameters
string(use_login)

Definition at line 276 of file todo_list.class.php.

277 {
278 global $g_user;
279 if ($g_user->check_action(SHARENOTE) == 1 )
280 {
281 $this->cn->exec_sql('insert into todo_list_shared (todo_list_id,use_login) values ($1,$2)',
282 array($this->tl_id,$p_array));
283
284 }
285 }
const SHARENOTE

References $g_user, $p_array, cn, and SHARENOTE.

◆ set_is_public()

Todo_List::set_is_public (   $p_value)

set a note public

Parameters
$p_valueis Y or N

Definition at line 263 of file todo_list.class.php.

264 {
265 global $g_user;
266 if ($g_user->check_action(SHARENOTEPUBLIC) == 1 )
267 {
268 $this->is_public=$p_value;
269 }
270 }
const SHARENOTEPUBLIC

References $g_user, and SHARENOTEPUBLIC.

◆ set_parameter()

Todo_List::set_parameter (   $p_string,
  $p_value 
)

Definition at line 96 of file todo_list.class.php.

97 {
98 if ( array_key_exists($p_string,self::$variable) )
99 {
100 $idx=self::$variable[$p_string];
101 if ($this->check($idx,$p_value) == true ) $this->$idx=$p_value;
102 }
103 else
104 throw new Exception("Attribut inexistant $p_string");
105
106
107 }
check($p_idx, &$p_value)

References $idx, $variable, and check().

+ Here is the call graph for this function:

◆ test_me()

static Todo_List::test_me ( )
static

static testing function

Definition at line 422 of file todo_list.class.php.

423 {
424 }

◆ to_object()

static Todo_List::to_object (   $p_cn,
  $p_array 
)
static

Definition at line 359 of file todo_list.class.php.

360 {
361
362 $ret=array();
363 if ( $p_array == FALSE ) return $ret;
364 $end=count($p_array);
365 for ($i=0;$i < $end;$i++)
366 {
367 $t=new Todo_List($p_cn);
368 $t->tl_id=$p_array[$i]['tl_id'];
369 $t->tl_date=$p_array[$i]['tl_date'];
370 $t->tl_title=$p_array[$i]['tl_title'];
371 $t->tl_desc=$p_array[$i]['tl_desc'];
372 $t->is_public=$p_array[$i]['is_public'];
373 $t->use_login=$p_array[$i]['use_login'];
374 $ret[$i]=clone $t;
375 }
376 return $ret;
377 }
This class manages the table todo_list.

◆ toXML()

Todo_List::toXML ( )

transform into xml for ajax answer

Definition at line 250 of file todo_list.class.php.

251 {
252 $id='<tl_id>'.$this->tl_id.'</tl_id>';
253 $title='<tl_title>'.escape_xml($this->tl_title).'</tl_title>';
254 $desc='<tl_desc>'.escape_xml($this->tl_desc).'</tl_desc>';
255 $date='<tl_date>'.$this->tl_date.'</tl_date>';
256 $ret='<data>'.$id.$title.$desc.$date.'</data>';
257 return $ret;
258 }

References $date, $desc, $id, $ret, and $title.

◆ update()

Todo_List::update ( )

Definition at line 157 of file todo_list.class.php.

158 {
159 if ( $this->verify() != 0 ) return;
160
161 if (trim($this->tl_title)=='')
162 $this->tl_title=mb_substr(trim($this->tl_desc),0,40);
163
164 if (trim($this->tl_title)=='')
165 {
166
167 return;
168 }
169
170 /* limit the title to 35 char */
171 $this->tl_title=mb_substr(trim($this->tl_title),0,40);
172
173 $sql="update todo_list set tl_title=$1,tl_date=to_date($2,'DD.MM.YYYY'),tl_desc=$3,is_public=$5 ".
174 " where tl_id = $4";
175 $res=$this->cn->exec_sql(
176 $sql,
177 array($this->tl_title,
178 $this->tl_date,
179 $this->tl_desc,
180 $this->tl_id,
181 $this->is_public)
182 );
183
184 }

References $res, $sql, cn, and verify().

Referenced by save().

+ Here is the call graph for this function:

◆ verify()

Todo_List::verify ( )

Definition at line 112 of file todo_list.class.php.

113 {
114 if ( isDate($this->tl_date) == false )
115 {
116 $this->tl_date=date('d.m.Y');
117 }
118 return 0;
119 }

References isDate().

Referenced by insert(), and update().

+ Here is the call graph for this function:

Field Documentation

◆ $cn

Todo_List::$cn
private

Definition at line 52 of file todo_list.class.php.

◆ $is_public

Todo_List::$is_public
private

Definition at line 53 of file todo_list.class.php.

◆ $tl_date

Todo_List::$tl_date
private

Definition at line 53 of file todo_list.class.php.

◆ $tl_desc

Todo_List::$tl_desc

Definition at line 54 of file todo_list.class.php.

◆ $tl_id

Todo_List::$tl_id
private

Definition at line 53 of file todo_list.class.php.

◆ $tl_title

Todo_List::$tl_title
private

Definition at line 53 of file todo_list.class.php.

◆ $use_login

Todo_List::$use_login
private

Definition at line 53 of file todo_list.class.php.

◆ $variable

Todo_List::$variable
staticprivate
Initial value:
=array(
"id"=>"tl_id",
"date"=>"tl_date",
"title"=>"tl_title",
"desc"=>"tl_desc",
"owner"=>"use_login",
"is_public"=>"is_public")

Definition at line 45 of file todo_list.class.php.


The documentation for this class was generated from the following file: