26require_once NOALYSS_INCLUDE.
'/lib/function_javascript.php';
51 "is_public"=>
"is_public");
60 $this->use_login=$_SESSION[SESSION_KEY.
'g_user'];
66 if ( array_key_exists($p_string,self::$variable) )
68 $idx=self::$variable[$p_string];
72 throw new Exception(
"Attribut inexistant $p_string");
74 public function check($p_idx,&$p_value)
76 if ( strcmp ($p_idx,
'tl_id') == 0 )
78 if ( strlen($p_value) > 6 ||
isNumber ($p_value) ==
false)
return false;
80 if ( strcmp ($p_idx,
'tl_date') == 0 )
83 { $p_value =
null;
return true;}
85 if ( strcmp ($p_idx,
'tl_title') == 0 )
87 $p_value=mb_substr($p_value,0,120) ;
90 if ( strcmp ($p_idx,
'tl_desc') == 0 )
92 $p_value=mb_substr($p_value,0,1000) ;
99 if ( array_key_exists($p_string,self::$variable) )
101 $idx=self::$variable[$p_string];
102 if ($this->
check(
$idx,$p_value) ==
true ) $this->
$idx=$p_value;
105 throw new Exception(
"Attribut inexistant $p_string");
111 return var_export(self::$variable,
true);
115 if (
isDate($this->tl_date) ==
false )
131 if ( $this->
verify() != 0 )
return;
132 if (trim($this->tl_title)==
'')
133 $this->tl_title=mb_substr(trim($this->tl_desc??
""),0,30);
135 if (trim($this->tl_title)==
'')
137 alert(
'La note est vide');
142 $this->tl_title=mb_substr(trim($this->tl_title),0,30);
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";
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";
154 array($this->tl_date,
166 if ( $this->
verify() != 0 )
return;
168 if (trim($this->tl_title)==
'')
169 $this->tl_title=mb_substr(trim($this->tl_desc),0,40);
171 if (trim($this->tl_title)==
'')
178 $this->tl_title=mb_substr(trim($this->tl_title),0,40);
180 $sql=
"update todo_list set tl_title=$1,tl_date=to_date($2,'DD.MM.YYYY'),tl_desc=$3,is_public=$5 ".
183 if ($this->tl_date ==
null) {
184 $sql=
"update todo_list set tl_title=$1,tl_date=$2,tl_desc=$3,is_public=$5 ".
189 array($this->tl_title,
205 to_char( tl_date,'DD.MM.YYYY') as tl_date,
212 or tl_id in (select todo_list_id from todo_list_shared where use_login=$1)
213 order by tl_date::date desc";
216 array($this->use_login));
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 ";
238 $aIndex=array_values(self::$variable);
239 foreach ($aIndex as
$idx)
245 public function delete()
248 if ( $this->use_login != $_SESSION[SESSION_KEY.
'g_user'] &&
$g_user->check_action(
SHARENOTEREMOVE)==0)
return;
250 $sql=
"delete from todo_list_shared where todo_list_id=$1 ";
251 $res=$this->
cn->exec_sql(
$sql,array($this->tl_id));
253 $sql=
"delete from todo_list where tl_id=$1 ";
254 $res=$this->
cn->exec_sql(
$sql,array($this->tl_id));
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>';
280 $this->is_public=$p_value;
293 $this->
cn->exec_sql(
'insert into todo_list_shared (todo_list_id,use_login) values ($1,$2)',
306 $this->
cn->exec_sql(
'delete from todo_list_shared where todo_list_id = $1 and use_login=$2',
318 include NOALYSS_TEMPLATE.
'/todo_list_display.php';
331 if (
$a == $this->tl_date) $p_odd=
'highlight';
338 $p_odd=($highlight ==
"")?$p_odd:$highlight;
339 if ( $with_tag ==
'Y')
$r =
'<tr id="tr'.$this->tl_id.
'" class="'.$p_odd.
'">';
341 '<td sorttable_customkey="'.format_date($this->tl_date,
'DD.MM.YYYY',
'YYYYMMDD').
'">'.
345 '<a class="line" href="javascript:void(0)" onclick="todo_list_show(\''.$this->tl_id.
'\')
">'.
346 htmlspecialchars($this->tl_title).
349 if ( $this->is_public == 'Y' && $this->use_login != $_SESSION[SESSION_KEY.'g_user'] )
350 { // This is a public note, cannot be removed
353 elseif ($this->use_login == $_SESSION[SESSION_KEY.'g_user'] )
355 // This a note the user owns
357 Icon_Action::trash(uniqid(),sprintf("todo_list_remove(
'%s')
",$this->tl_id)).
362 // this is a note shared by someone else
364 Icon_Action::trash(uniqid(),sprintf("todo_list_remove_share(
'%s',
'%s',
'%s')
",$this->tl_id,$this->use_login,Dossier::id())).
368 if ( $with_tag == 'Y') $r .= '</tr>';
371 static function to_object ($p_cn,$p_array)
375 if ( $p_array == FALSE ) return $ret;
376 $end=count($p_array);
377 for ($i=0;$i < $end;$i++)
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'];
395 function display_user()
399 $p_array=Noalyss_User::get_list(Dossier::id());
400 $dossier=Dossier::id();
401 include NOALYSS_TEMPLATE.'/todo_list_list_user.php';
410 function is_shared_with($p_login)
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;
420 function add_share($p_login)
422 $this->cn->exec_sql("
insert into todo_list_shared(todo_list_id,use_login) values ($1,$2)
",array($this->tl_id,$p_login));
428 function remove_share($p_login)
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));
434 static function test_me()
isDate($p_date)
Verifie qu'une date est bien formaté en d.m.y et est valable.
noalyss_strlentrim($p_string)
alert($p_msg, $buffer=false)
alert in javascript
global $g_user
if no group available , then stop
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
static fetch_result($ret, $p_row=0, $p_col=0)
wrapper for the function pg_fetch_all
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static fetch_all($ret, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_all
static num_row($ret)
wrapper for the function pg_num_rows
This class manages the table todo_list.
display()
Display the note.
save_shared_with($p_array)
Insert a share for current note in the table todo_list_shared.
load_all()
load all the task
load()
load the todo_list row thanks it's ID
display_row($p_odd, $with_tag='Y')
get_class()
Highlight today.
remove_shared_with($p_array)
Insert a share for current note in the table todo_list_shared The public shared note cannot be remove...
set_parameter($p_string, $p_value)
set_is_public($p_value)
set a note public
toXML()
transform into xml for ajax answer