26require_once NOALYSS_INCLUDE.
'/lib/function_javascript.php';
51 "is_public"=>
"is_public");
60 $this->use_login=$_SESSION[SESSION_KEY.
'g_user'];
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 )
84 if ( strcmp ($p_idx,
'tl_title') == 0 )
86 $p_value=mb_substr($p_value,0,120) ;
89 if ( strcmp ($p_idx,
'tl_desc') == 0 )
91 $p_value=mb_substr($p_value,0,1000) ;
101 if ($this->
check(
$idx,$p_value) ==
true ) $this->
$idx=$p_value;
104 throw new Exception(
"Attribut inexistant $p_string");
114 if (
isDate($this->tl_date) ==
false )
116 $this->tl_date=date(
'd.m.Y');
130 if ( $this->
verify() != 0 )
return;
131 if (trim($this->tl_title)==
'')
132 $this->tl_title=mb_substr(trim($this->tl_desc),0,30);
134 if (trim($this->tl_title)==
'')
136 alert(
'La note est vide');
141 $this->tl_title=mb_substr(trim($this->tl_title),0,30);
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";
147 array($this->tl_date,
159 if ( $this->
verify() != 0 )
return;
161 if (trim($this->tl_title)==
'')
162 $this->tl_title=mb_substr(trim($this->tl_desc),0,40);
164 if (trim($this->tl_title)==
'')
171 $this->tl_title=mb_substr(trim($this->tl_title),0,40);
173 $sql=
"update todo_list set tl_title=$1,tl_date=to_date($2,'DD.MM.YYYY'),tl_desc=$3,is_public=$5 ".
177 array($this->tl_title,
193 to_char( tl_date,'DD.MM.YYYY') as tl_date,
200 or tl_id in (select todo_list_id from todo_list_shared where use_login=$1)
201 order by tl_date::date desc";
204 array($this->use_login));
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 ";
227 foreach ($aIndex as
$idx)
233 public function delete()
236 if ( $this->use_login != $_SESSION[SESSION_KEY.
'g_user'] &&
$g_user->check_action(
SHARENOTEREMOVE)==0)
return;
238 $sql=
"delete from todo_list_shared where todo_list_id=$1 ";
239 $res=$this->
cn->exec_sql(
$sql,array($this->tl_id));
241 $sql=
"delete from todo_list where tl_id=$1 ";
242 $res=$this->
cn->exec_sql(
$sql,array($this->tl_id));
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>';
268 $this->is_public=$p_value;
281 $this->
cn->exec_sql(
'insert into todo_list_shared (todo_list_id,use_login) values ($1,$2)',
294 $this->
cn->exec_sql(
'delete from todo_list_shared where todo_list_id = $1 and use_login=$2',
306 include NOALYSS_TEMPLATE.
'/todo_list_display.php';
319 if (
$a == $this->tl_date) $p_odd=
'highlight';
326 $p_odd=($highlight ==
"")?$p_odd:$highlight;
327 if ( $with_tag ==
'Y')
$r =
'<tr id="tr'.$this->tl_id.
'" class="'.$p_odd.
'">';
329 '<td sorttable_customkey="'.format_date($this->tl_date,
'DD.MM.YYYY',
'YYYYMMDD').
'">'.
333 '<a class="line" href="javascript:void(0)" onclick="todo_list_show(\''.$this->tl_id.
'\')
">'.
334 htmlspecialchars($this->tl_title).
337 if ( $this->is_public == 'Y' && $this->use_login != $_SESSION[SESSION_KEY.'g_user'] )
338 { // This is a public note, cannot be removed
341 elseif ($this->use_login == $_SESSION[SESSION_KEY.'g_user'] )
343 // This a note the user owns
345 Icon_Action::trash(uniqid(),sprintf("todo_list_remove(
'%s')
",$this->tl_id)).
350 // this is a note shared by someone else
352 Icon_Action::trash(uniqid(),sprintf("todo_list_remove_share(
'%s',
'%s',
'%s')
",$this->tl_id,$this->use_login,Dossier::id())).
356 if ( $with_tag == 'Y') $r .= '</tr>';
359 static function to_object ($p_cn,$p_array)
363 if ( $p_array == FALSE ) return $ret;
364 $end=count($p_array);
365 for ($i=0;$i < $end;$i++)
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'];
383 function display_user()
387 $p_array=Noalyss_user::get_list(Dossier::id());
388 $dossier=Dossier::id();
389 include NOALYSS_TEMPLATE.'/todo_list_list_user.php';
398 function is_shared_with($p_login)
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;
408 function add_share($p_login)
410 $this->cn->exec_sql("
insert into todo_list_shared(todo_list_id,use_login) values ($1,$2)
",array($this->tl_id,$p_login));
416 function remove_share($p_login)
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));
422 static function test_me()
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_all($ret)
wrapper for the function pg_fetch_all
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 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