noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
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.
 
 check ($p_idx, &$p_value)
 
 delete ()
 
 display ()
 Display the note.
 
 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
 
 get_class ()
 Highlight today.
 
 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
 
 load ()
 load the todo_list row thanks it's ID
 
 load_all ()
 load all the task
 
 remove_share ($p_login)
 remove the share with someone
 
 remove_shared_with ($p_array)
 Insert a share for current note in the table todo_list_shared The public shared note cannot be removed.
 
 save ()
 
 save_shared_with ($p_array)
 Insert a share for current note in the table todo_list_shared.
 
 set_is_public ($p_value)
 set a note public
 
 set_parameter ($p_string, $p_value)
 
 toXML ()
 transform into xml for ajax answer
 
 update ()
 
 verify ()
 

Static Public Member Functions

static test_me ()
 static testing function
 
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 :

  • $cn database connx
  • $variable
    • id (todo_list.tl_id)
    • date (todo_list.tl_Date)
    • title (todo_list.title)
    • desc (todo_list.tl_desc)
    • owner (todo_list.use_id)

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

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 420 of file todo_list.class.php.

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

References insert().

+ Here is the call graph for this function:

◆ 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)
83 { $p_value = null;return true;}
84 }
85 if ( strcmp ($p_idx, 'tl_title') == 0 )
86 {
87 $p_value=mb_substr($p_value,0,120) ;
88 return true;
89 }
90 if ( strcmp ($p_idx, 'tl_desc') == 0 )
91 {
92 $p_value=mb_substr($p_value,0,1000) ;
93 return true;
94 }
95 return true;
96 }
isNumber($p_int)
isDate($p_date)
Verifie qu'une date est bien formaté en d.m.y et est valable.
noalyss_strlentrim($p_string)

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 245 of file todo_list.class.php.

246 {
247 global $g_user;
248 if ( $this->use_login != $_SESSION[SESSION_KEY.'g_user'] && $g_user->check_action(SHARENOTEREMOVE)==0) return;
249
250 $sql="delete from todo_list_shared where todo_list_id=$1 ";
251 $res=$this->cn->exec_sql($sql,array($this->tl_id));
252
253 $sql="delete from todo_list where tl_id=$1 ";
254 $res=$this->cn->exec_sql($sql,array($this->tl_id));
255
256
257
258 }
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 314 of file todo_list.class.php.

315 {
316 ob_start();
317 $this->load();
318 include NOALYSS_TEMPLATE.'/todo_list_display.php';
319 $ret=ob_get_clean();
320
321 return $ret;
322 }
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 334 of file todo_list.class.php.

335 {
336 $r="";
337 $highlight=$this->get_class();
338 $p_odd=($highlight == "")?$p_odd:$highlight;
339 if ( $with_tag == 'Y') $r = '<tr id="tr'.$this->tl_id.'" class="'.$p_odd.'">';
340 $r.=
341 '<td sorttable_customkey="'.format_date($this->tl_date,'DD.MM.YYYY','YYYYMMDD').'">'.
342 $this->tl_date.
343 '</td>'.
344 '<td>'.
345 '<a class="line" href="javascript:void(0)" onclick="todo_list_show(\''.$this->tl_id.'\')">'.
346 htmlspecialchars($this->tl_title).
347 '</a>'.
348 '</td>';
349 if ( $this->is_public == 'Y' && $this->use_login != $_SESSION[SESSION_KEY.'g_user'] )
350 { // This is a public note, cannot be removed
351 $r.= '<td></td>';
352 }
353 elseif ($this->use_login == $_SESSION[SESSION_KEY.'g_user'] )
354 {
355 // This a note the user owns
356 $r.= '<td>'.
357 Icon_Action::trash(uniqid(),sprintf("todo_list_remove('%s')",$this->tl_id)).
358 '</td>';
359 }
360 else
361 {
362 // this is a note shared by someone else
363 $r.= '<td>'.
364 Icon_Action::trash(uniqid(),sprintf("todo_list_remove_share('%s','%s','%s')",$this->tl_id,$this->use_login,Dossier::id())).
365 '</td>';
366 }
367
368 if ( $with_tag == 'Y') $r .= '</tr>';
369 return $r;
370 }
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 395 of file todo_list.class.php.

396 {
397 global $g_user;
398 // Get array of user
399 $p_array=Noalyss_User::get_list(Dossier::id());
401 include NOALYSS_TEMPLATE.'/todo_list_list_user.php';
402
403 }
static id()
return the 'gDossier' value after a check
static get_list($p_dossier, $db_repository=null)
return an array with all the active users who can access $p_dossier including the global admin.

◆ get_class()

Todo_List::get_class ( )

Highlight today.

Returns
string

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

328 {
329 $p_odd="";
330 $a=date('d.m.Y');
331 if ($a == $this->tl_date) $p_odd='highlight';
332 return $p_odd;
333 }

References $a.

Referenced by display_row().

◆ get_info()

Todo_List::get_info ( )

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

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

◆ 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 }

References $idx.

Referenced by save().

◆ insert()

Todo_List::insert ( )

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

130 {
131 if ( $this->verify() != 0 ) return;
132 if (trim($this->tl_title)=='')
133 $this->tl_title=mb_substr(trim($this->tl_desc??""),0,30);
134
135 if (trim($this->tl_title)=='')
136 {
137 alert('La note est vide');
138 return;
139 }
140
141 /* limit the title to 35 char */
142 $this->tl_title=mb_substr(trim($this->tl_title),0,30);
143
144 $sql="insert into todo_list (tl_date,tl_title,tl_desc,use_login,is_public) ".
145 " values (to_date($1,'DD.MM.YYYY'),$2,$3,$4,$5) returning tl_id";
146
147 if ($this->tl_date == null) {
148 $sql="insert into todo_list (tl_date,tl_title,tl_desc,use_login,is_public) ".
149 " values ($1,$2,$3,$4,$5) returning tl_id";
150
151 }
152 $res=$this->cn->exec_sql(
153 $sql,
154 array($this->tl_date,
155 $this->tl_title,
156 $this->tl_desc,
157 $this->use_login,
158 $this->is_public)
159 );
160 $this->tl_id=Database::fetch_result($res,0,0);
161
162 }
alert($p_msg, $buffer=false)
alert in javascript
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 add_share(), and 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 410 of file todo_list.class.php.

411 {
412 $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));
413 if ($ret == "")return 0;
414 return $ret;
415 }

References from.

◆ load()

Todo_List::load ( )

load the todo_list row thanks it's ID

Returns
boolean true if found else false

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

225 :bool
226 {
227
228 $sql="select tl_id,tl_title,tl_desc,to_char( tl_date,'DD.MM.YYYY') as tl_date,is_public,use_login
229 from todo_list where tl_id=$1 ";
230
231 $res=$this->cn->exec_sql(
232 $sql,
233 array($this->tl_id)
234 );
235
236 if ( Database::num_row($res) == 0 ) return false;
238 $aIndex=array_values(self::$variable);
239 foreach ($aIndex as $idx)
240 {
241 $this->$idx=$row[$idx];
242 }
243 return true;
244 }
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, 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 200 of file todo_list.class.php.

201 {
202 $sql="select tl_id,
203 tl_title,
204 tl_desc,
205 to_char( tl_date,'DD.MM.YYYY') as tl_date,
206 is_public,
207 use_login
208 from todo_list
209 where
210 use_login=$1
211 or is_public = 'Y'
212 or tl_id in (select todo_list_id from todo_list_shared where use_login=$1)
213 order by tl_date::date desc";
214 $res=$this->cn->exec_sql(
215 $sql,
216 array($this->use_login));
218
219 return $array;
220 }
static fetch_all($ret, $p_mode=PGSQL_ASSOC)
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 428 of file todo_list.class.php.

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

References from.

◆ 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 304 of file todo_list.class.php.

305 {
306 $this->cn->exec_sql('delete from todo_list_shared where todo_list_id = $1 and use_login=$2',
307 array($this->tl_id,$p_array));
308 }

References $p_array, and cn.

◆ save()

Todo_List::save ( )

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

122 {
123 if ( $this->get_parameter("id") == 0 )
124 $this->insert();
125 else
126 $this->update();
127 }
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 288 of file todo_list.class.php.

289 {
290 global $g_user;
291 if ($g_user->check_action(SHARENOTE) == 1 )
292 {
293 $this->cn->exec_sql('insert into todo_list_shared (todo_list_id,use_login) values ($1,$2)',
294 array($this->tl_id,$p_array));
295
296 }
297 }
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 275 of file todo_list.class.php.

276 {
277 global $g_user;
278 if ($g_user->check_action(SHARENOTEPUBLIC) == 1 )
279 {
280 $this->is_public=$p_value;
281 }
282 }
const SHARENOTEPUBLIC

References $g_user, and SHARENOTEPUBLIC.

◆ set_parameter()

Todo_List::set_parameter ( $p_string,
$p_value )

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

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

References $idx, and check().

+ Here is the call graph for this function:

◆ test_me()

static Todo_List::test_me ( )
static

static testing function

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

435 {
436 }

◆ to_object()

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

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

372 {
373
374 $ret=array();
375 if ( $p_array == FALSE ) return $ret;
376 $end=count($p_array);
377 for ($i=0;$i < $end;$i++)
378 {
379 $t=new Todo_List($p_cn);
380 $t->tl_id=$p_array[$i]['tl_id'];
381 $t->tl_date=$p_array[$i]['tl_date'];
382 $t->tl_title=$p_array[$i]['tl_title'];
383 $t->tl_desc=$p_array[$i]['tl_desc'];
384 $t->is_public=$p_array[$i]['is_public'];
385 $t->use_login=$p_array[$i]['use_login'];
386 $ret[$i]=clone $t;
387 }
388 return $ret;
389 }
$t
Definition compute.php:46

Referenced by Noalyss\Widget\Todo_List\display().

◆ toXML()

Todo_List::toXML ( )

transform into xml for ajax answer

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

263 {
264 $id='<tl_id>'.$this->tl_id.'</tl_id>';
265 $title='<tl_title>'.escape_xml($this->tl_title).'</tl_title>';
266 $desc='<tl_desc>'.escape_xml($this->tl_desc).'</tl_desc>';
267 $date='<tl_date>'.$this->tl_date.'</tl_date>';
268 $ret='<data>'.$id.$title.$desc.$date.'</data>';
269 return $ret;
270 }

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

◆ update()

Todo_List::update ( )

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

165 {
166 if ( $this->verify() != 0 ) return;
167
168 if (trim($this->tl_title)=='')
169 $this->tl_title=mb_substr(trim($this->tl_desc),0,40);
170
171 if (trim($this->tl_title)=='')
172 {
173
174 return;
175 }
176
177 /* limit the title to 35 char */
178 $this->tl_title=mb_substr(trim($this->tl_title),0,40);
179
180 $sql="update todo_list set tl_title=$1,tl_date=to_date($2,'DD.MM.YYYY'),tl_desc=$3,is_public=$5 ".
181 " where tl_id = $4";
182
183 if ($this->tl_date == null) {
184 $sql="update todo_list set tl_title=$1,tl_date=$2,tl_desc=$3,is_public=$5 ".
185 " where tl_id = $4";
186 }
187 $res=$this->cn->exec_sql(
188 $sql,
189 array($this->tl_title,
190 $this->tl_date,
191 $this->tl_desc,
192 $this->tl_id,
193 $this->is_public)
194 );
195
196 }

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

Referenced by save().

+ Here is the call graph for this function:

◆ verify()

Todo_List::verify ( )

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

114 {
115 if ( isDate($this->tl_date) == false )
116 {
117 $this->tl_date=null;
118 }
119 return 0;
120 }

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: