-<?php
-/*
- NP_TodoList
- by yu (http://nucleus.datoka.jp/)
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
- (see nucleus/documentation/index.html#license for more info)
-
- USAGE
- -----
- <%TodoList%>
- <%TodoList(nodate)%> //date setting
- <%TodoList(normal,1)%> //date setting, memberid
-
- HISTORY
- -------
- Ver0.42: [Fix] Security fix.
- Ver0.41: [Fix] Check edit authority.
- Ver0.4 : [New] Blog members can own each todo list.
-*/
-
-// plugin needs to work on Nucleus versions <=2.0 as well
-if (!function_exists('sql_table')) {
- function sql_table($name) {
- return 'nucleus_' . $name;
- }
-}
-
-// quote variable to make safe
-if(!function_exists('quote_smart')) {
- function quote_smart($value) {
- if (get_magic_quotes_gpc()) $value = stripslashes($value);
- if (!is_numeric($value)) {
- //$value = "'". mysql_real_escape_string($value) ."'";
- $value = "'". mysql_escape_string($value) ."'";
- }
- return $value;
- }
-}
-
-class NP_TodoList extends NucleusPlugin {
- function getName() { return 'Todo List'; }
- function getAuthor() { return 'yu'; }
- function getURL() { return 'http://works.datoka.jp/index.php?itemid=231'; }
- function getVersion() { return '0.42'; }
- function getMinNucleusVersion() { return 200; }
- function getTableList() { return array( sql_table('plug_todolist') ); }
- function getEventList() { return array(); }
- function supportsFeature($what) {
- switch($what) {
- case 'SqlTablePrefix':
- return 1;
- default:
- return 0;
- }
- }
-
- function getDescription() {
- return 'Show Todo List. [USAGE] <%TodoList(mode,memberid)%> ex. <%TodoList%>, <%TodoList(nodate)%>, <%TodoList(normal,1)%>';
- }
-
-
- function install(){
- sql_query ("CREATE TABLE IF NOT EXISTS ". sql_table('plug_todolist') ." (
- tid INT UNSIGNED NOT NULL AUTO_INCREMENT,
- title VARCHAR(255) NOT NULL DEFAULT '',
- rank INT UNSIGNED NOT NULL DEFAULT 0,
- cond INT UNSIGNED NOT NULL DEFAULT 0,
- regdate DATE NOT NULL DEFAULT '1999-01-01',
- enddate DATE NOT NULL DEFAULT '1999-01-01',
- memberid INT UNSIGNED NOT NULL DEFAULT 1,
- primary key (tid))");
-
- if(getNucleusVersion() < 220) {
- $this->createOption('canedit','Edit authority [self | team | self+admin]', 'text', 'self');
- }
- else {
- $this->createOption('canedit','Edit authority [self | team | self+admin]', 'select', 'self', 'Self|self|Team|team|Self + Admin|self+admin');
- }
-
- $this->createOption('dateFormat','Date format', 'text', 'm/d(D)');
- $this->createOption('flg_pluglink','Show plugin link.','yesno','yes');
- $this->createOption('flg_erase', 'Erase data on uninstall.', 'yesno', 'no');
- }
-
- function unInstall() {
- if ($this->getOption(flg_erase) == 'yes') {
- sql_query ('DROP TABLE '. sql_table('plug_todolist') );
- }
- }
-
-
- // .../action.php?action=plugin&name=TodoList&type=ver up&vernum=X.X
- // it need login to update
- function versionUpdate($oldver) {
- switch ($oldver) {
- case 0.1:
- case 0.2:
- case 0.3:
- sql_query ("ALTER TABLE ". sql_table('plug_todolist'). " ADD (
- memberid INT UNSIGNED NOT NULL DEFAULT 1)");
- break;
- case 0.4:
- default:
- //nothing to do
- break;
- }
- }
-
-
- function init() {
- $this->rankname = array('*','**','***');
- $this->condname = array('notyet','working','finished','pending');
- $this->condstyle = array('background:#fff','background:#fd6','background:#add','background:#999;color:white','background:#f00;color:white');
-
- $query = "SHOW TABLES LIKE '". sql_table('plug_todolist') ."'";
- $table = sql_query($query);
- if (mysql_num_rows($table) > 0){
- $query = "SELECT * FROM ". sql_table('plug_todolist') ." ORDER BY cond, enddate";
- $res = sql_query($query);
- while ($data = mysql_fetch_object($res)) {
- $this->list[$data->memberid][] = $data; //set data by memberid
- }
- }
- }
-
- function doSkinVar($skinType, $showmode='normal',$memid='') {
- global $memberid;
-
- if (!$memid) $memid = $memberid; //in member page
- if (!$memid) $memid = 1; //default
-
- $editmode = intRequestVar('todoedit'); //get or post
- $this->showTodoList($editmode, $showmode, $memid);
- }
-
- function isLoggedIn() {
- global $member;
- return $member->isLoggedIn();
- }
-
- function canEdit($memid) {
- global $blog, $member;
-
- if ($blog) $b =& $blog;
- else $b =& $manager->getBlog($CONF['DefaultBlog']);
- $bid = $b->getID();
-
- if (!$member->isLoggedIn()) return 0;
-
- switch ($this->getOption('canedit')) {
- case 'self':
- return ($member->getID() == $memid);
- break;
- case 'team':
- return ($member->teamRights($bid));
- break;
- case 'self+admin':
- return ($member->getID() == $memid || $member->blogAdminRights($bid));
- break;
- default:
- return 0;
- }
- }
-
-
- function showEntryForm($editmode, $showmode, $memid) {
- global $CONF;
-
- if (!$editmode) return;
-?>
-<form class="todolist" method="post" action="<?php echo $CONF['ActionURL'] ?>">
-<input type="hidden" name="action" value="plugin"/>
-<input type="hidden" name="name" value="TodoList" />
-<input type="hidden" name="type" value="add" />
-<input type="hidden" name="memid" value="<?php echo $memid ?>" />
-<select name="rank">
-<?php
- for($i = count($this->rankname)-1; $i>=0; $i--){
- echo "<option value='$i'>{$this->rankname[$i]}</option>\n";
- }
-?>
-</select>
-<select name="cond">
-<?php
- $i = 0;
- foreach($this->condname as $cname){
- echo "<option value='$i'>$cname</option>\n";
- $i++;
- }
-?>
-</select>
-<?php
- if ($showmode != 'nodate') {
-?>
-<input class="formfield" type="text" name="enddate" value="<?php echo date('Y-m-d', mktime(0,0,0,date('m'),date('d')+1,date('Y'))) ?>" size="9" maxlength="10" />
-<?php
- }
-?>
-<input class="formfield" type="text" name="title" value="" size="20" maxlength="255" />
-<input class="formbutton" type="submit" value="Submit" />
-</form>
-<?php
- }
-
-
- function showTodoList($editmode, $showmode, $memid) {
- global $CONF, $member;
-
- $img_path = $this->getAdminURL();
-
- $this->showEntryForm($editmode, $showmode, $memid);
-
- if (empty($this->list[$memid])) {
- echo "<p>No data found.</p>";
- }
- else {
- //sort by rank
- foreach($this->list[$memid] as $l) {
- //if ($l->memberid != $memid) continue; // id check
- $byrank[ $l->rank ][] = $l;
- }
- $sortlist = array();
- for($i=count($this->rankname); $i>0; $i--) {
- $sortlist = array_merge($sortlist, (array)$byrank[$i-1]);
- }
-
- echo "<ul class='todolist'>\n";
-
- foreach($sortlist as $l) {
- $tid = $l->tid;
- $title = htmlspecialchars(stripslashes($l->title), ENT_QUOTES);
- $enddate = $l->enddate;
- $rank = $this->rankname[$l->rank];
- $cond = $this->condname[$l->cond];
-
- if ($editmode) {
-?>
-<form class="todolist" method="post" action="<?php echo $CONF['ActionURL'] ?>">
-<input type="hidden" name="action" value="plugin"/>
-<input type="hidden" name="name" value="TodoList" />
-<input type="hidden" name="type" value="update" />
-<input type="hidden" name="tid" value="<?php echo $tid ?>" />
-<select name="rank">
-<?php
- for($i = count($this->rankname)-1; $i>=0; $i--){
- $selected = '';
- if ($i == $l->rank) $selected = 'selected';
- echo "<option value='$i' $selected>{$this->rankname[$i]}</option>\n";
- }
-?>
-</select>
-<?php
- }
- else {
- echo "<li>";
- $img_file = 'rank'.$l->rank.'.gif';
- $img_title = $this->rankname[$l->rank];
- echo "<img class='icon-mid' src='$img_path$img_file' width='14' height='14' title='$img_title' />";
- }
-
- if ($editmode) {
-?>
-<select name="cond">
-<?php
- $cstyle = $this->condstyle;
- $i = 0;
- foreach($this->condname as $cname){
- $selected = '';
- if ($i == $l->cond) $selected = 'selected';
- echo "<option style='$cstyle[$i]' value='$i' $selected>$cname</option>\n";
- $i++;
- }
- echo "<option style='$cstyle[$i]' value='$i'>[delete]</option>\n";
-?>
-</select>
-<?php
- }
- else {
- $img_file = 'cond'.$l->cond.'.gif';
- $img_title = $this->condname[$l->cond];
- echo " <img class='icon-mid' src='$img_path$img_file' width='52' height='14' title='$img_title' />";
- }
-
- if ($editmode and $showmode != 'nodate') {
-?>
-<input class="formfield" type="text" name="enddate" value="<?php echo $enddate ?>" size="9" maxlength="10" />
-<?php
- }
- else if($showmode != 'nodate') {
- $date_style = 'enddate';
- if ( $enddate == date('Y-m-d', mktime( 0,0,0,date('m'),date('d')+1,date('Y'))) ) {
- $date_style = 'enddate2'; //tomorrow
- }
- else if ($enddate == date('Y-m-d')) {
- $date_style = 'enddate3'; //today
- }
- else if ($enddate < date('Y-m-d')) {
- $date_style = 'enddate4'; //past
- }
-
- //apply date format
- $enddate = date($this->getOption('dateFormat'), strToTime($enddate));
- echo " <span class='$date_style'>$enddate</span>";
- }
-
- if ($editmode) {
-?>
-<input class="formfield" type="text" name="title" value="<?php echo $title ?>" size="20" maxlength="255" />
-<?php
- }
- else {
- echo " <span class='title'>$title</span></li>\n";
- }
-
- if ($editmode) {
- if ($this->getOption('canedit') == 'team'
- and $member->getID() != $memid) $disstr = 'disabled';
- else $disstr = '';
-?>
-<input class="formbutton" type='submit' value='Update' <?php echo $disstr?> />
-</form>
-<?php
- }
- } //end of foreach($sortlist)
-
- echo "</ul>\n";
-
- }// end of if(isset($this->list))
-
- //edit switch
- if ($this->canEdit($memid)) {
- if ($editmode) $str_edit = "checked";
- else $str_show = "checked";
-?>
-<form class="todolist-r" method="post" action="<?php echo $CONF['ActionURL'] ?>">
-<input type="hidden" name="action" value="plugin"/>
-<input type="hidden" name="name" value="TodoList" />
-<input type="hidden" name="type" value="mode" />
-<input type="radio" name="todoedit" value="0" <?php echo $str_show ?> />Show
-<input type="radio" name="todoedit" value="1" <?php echo $str_edit ?> />Edit
-<input class="formbutton" type='submit' value='Change' />
-</form>
-<?php
- }
-
- //plugin link
- if ($this->getOption('flg_pluglink') == 'yes') {
- $pluglink_url = $this->getURL();
- $str_pversion = '';
-
- //version check
- /*
- if ($this->canEdit($memid)) {
- $chkver = $this->getLatestVersion($pluglink_url);
- if ($chkver > $this->getVersion()) {
- $str_pversion = " [Ver $chkver available]";
- }
- }
- */
- echo "<a href='$pluglink_url' title='Jump to the site of this plugin'>";
- echo "<span style='font-size:9px'>» Get \"".$this->getName()."\"$str_pversion</span></a>";
- }
-
- } //end of function
-
-
- function doAction($type) {
- global $CONF, $manager, $blog;
-
- if (! $this->isLoggedIn()) return;
-
- if ($blog) $b = &$blog;
- else $b = &$manager->getBlog($CONF['DefaultBlog']);
-
- switch($type) {
- case 'mode':
- $editmode = intRequestVar('todoedit'); //get or post
- $return = serverVar('HTTP_REFERER');
- $return = preg_replace('/[?&]todoedit=[^&]*/', '', $return); //delete old parameter
- if ( preg_match('/\?/',$return) ) $rvalue = "&todoedit=".$editmode;
- else $rvalue = "?todoedit=".$editmode;
- header("Location: $return$rvalue");
- return;
- break;
- case 'add':
- $query = sprintf("INSERT INTO %s SET title=%s, rank=%d, cond=%d, regdate=%s, enddate=%s, memberid=%s",
- sql_table('plug_todolist'),
- quote_smart(postVar('title')),
- quote_smart(intPostVar('rank')),
- quote_smart(intPostVar('cond')),
- date('Y-m-d', $b->getCorrectTime()),
- quote_smart(postVar('enddate')),
- quote_smart(intPostVar('memid')) );
- sql_query($query);
- break;
- case 'update':
- if ($cond >= count($this->condname)) { //cond = del
- $query = sprintf("DELETE FROM %s WHERE tid=%d",
- sql_table('plug_todolist'),
- quote_smart(intPostVar('tid')) );
- }
- else {
- $query = sprintf("UPDATE %s SET title=%s, rank=%d, cond=%d, enddate=%s WHERE tid=%d",
- sql_table('plug_todolist'),
- quote_smart(postVar('title')),
- quote_smart(intPostVar('rank')),
- quote_smart(intPostVar('cond')),
- quote_smart(postVar('enddate')),
- quote_smart(intPostVar('tid')) );
- }
- sql_query($query);
- break;
- case 'verup':
- $vernum = intRequestVar('vernum');
- $this->versionUpdate($vernum);
- break;
- default:
- break;
- }
- Header('Location: ' . serverVar('HTTP_REFERER') );
- }
-
- function getLatestVersion($url) {
- $name = $this->getShortName();
- if (cookieVar($name)) return false;
-
- $fp = @fopen ($url, "r");
- if ($fp){
- $ref_str = fread($fp, 16384);
- if (preg_match("/<!--NP_Version([^\-]+)-->/", $ref_str, $out)) {
- setcookie($name,1,null,'/'); // set session cookie
- return trim($out[1]);
- }
- }
- return false;
- }
-
-}
+<?php \r
+/*\r
+ NP_TodoList\r
+ by yu (http://nucleus.datoka.jp/)\r
+\r
+ This program is free software; you can redistribute it and/or\r
+ modify it under the terms of the GNU General Public License\r
+ as published by the Free Software Foundation; either version 2\r
+ of the License, or (at your option) any later version.\r
+ (see nucleus/documentation/index.html#license for more info)\r
+ \r
+ USAGE\r
+ -----\r
+ <%TodoList%>\r
+ <%TodoList(nodate)%> //date setting\r
+ <%TodoList(normal,1)%> //date setting, memberid\r
+ \r
+ HISTORY\r
+ -------\r
+ 2008-12-02 Ver0.44: [Fix] "Add TODO" bug fix. (hilbert)\r
+ [Chg] Improve quote_smart() function. (yu)\r
+ 2008-05-19 Ver0.43: [Fix] "Delete TODO" bug fix. (yu)\r
+ 2006-09-30 Ver0.42: [Fix] Security fix. (yu)\r
+ 2004-09-29 Ver0.41: [Fix] Check edit authority. (yu)\r
+ 2004-05-30 Ver0.4 : [New] Blog members can own each todo list. (yu)\r
+*/\r
+\r
+// plugin needs to work on Nucleus versions <=2.0 as well\r
+if (!function_exists('sql_table')) {\r
+ function sql_table($name) {\r
+ return 'nucleus_' . $name;\r
+ }\r
+}\r
+\r
+class NP_TodoList extends NucleusPlugin { \r
+ function getName() { return 'Todo List'; } \r
+ function getAuthor() { return 'yu'; } \r
+ function getURL() { return 'http://works.datoka.jp/index.php?itemid=231'; } \r
+ function getVersion() { return '0.44'; } \r
+ function getMinNucleusVersion() { return 200; }\r
+ function getTableList() { return array( sql_table('plug_todolist') ); }\r
+ function getEventList() { return array(); }\r
+ function supportsFeature($what) {\r
+ switch($what) {\r
+ case 'SqlTablePrefix':\r
+ return 1;\r
+ default:\r
+ return 0;\r
+ }\r
+ }\r
+\r
+ function getDescription() { \r
+ return 'Show Todo List. [USAGE] <%TodoList(mode,memberid)%> ex. <%TodoList%>, <%TodoList(nodate)%>, <%TodoList(normal,1)%>';\r
+ } \r
+\r
+\r
+ function install(){ \r
+ sql_query ("CREATE TABLE IF NOT EXISTS ". sql_table('plug_todolist') ." (\r
+ tid INT UNSIGNED NOT NULL AUTO_INCREMENT,\r
+ title VARCHAR(255) NOT NULL DEFAULT '',\r
+ rank INT UNSIGNED NOT NULL DEFAULT 0,\r
+ cond INT UNSIGNED NOT NULL DEFAULT 0,\r
+ regdate DATE NOT NULL DEFAULT '1999-01-01',\r
+ enddate DATE NOT NULL DEFAULT '1999-01-01',\r
+ memberid INT UNSIGNED NOT NULL DEFAULT 1,\r
+ primary key (tid))");\r
+ \r
+ if(getNucleusVersion() < 220) {\r
+ $this->createOption('canedit','Edit authority [self | team | self+admin]', 'text', 'self');\r
+ }\r
+ else {\r
+ $this->createOption('canedit','Edit authority [self | team | self+admin]', 'select', 'self', 'Self|self|Team|team|Self + Admin|self+admin');\r
+ }\r
+ \r
+ $this->createOption('dateFormat','Date format', 'text', 'm/d(D)');\r
+ $this->createOption('flg_pluglink','Show plugin link.','yesno','yes');\r
+ $this->createOption('flg_erase', 'Erase data on uninstall.', 'yesno', 'no');\r
+ } \r
+ \r
+ function unInstall() { \r
+ if ($this->getOption(flg_erase) == 'yes') {\r
+ sql_query ('DROP TABLE '. sql_table('plug_todolist') );\r
+ }\r
+ } \r
+ \r
+ \r
+ // .../action.php?action=plugin&name=TodoList&type=verup&vernum=X.X\r
+ // it need login to update\r
+ function versionUpdate($oldver) { \r
+ switch ($oldver) {\r
+ case 0.1:\r
+ case 0.2:\r
+ case 0.3:\r
+ sql_query ("ALTER TABLE ". sql_table('plug_todolist'). " ADD (\r
+ memberid INT UNSIGNED NOT NULL DEFAULT 1)");\r
+ break;\r
+ case 0.4:\r
+ default:\r
+ //nothing to do\r
+ break;\r
+ }\r
+ } \r
+ \r
+ \r
+ function init() {\r
+ $this->rankname = array('*','**','***');\r
+ $this->condname = array('notyet','working','finished','pending');\r
+ $this->condstyle = array('background:#fff','background:#fd6','background:#add','background:#999;color:white','background:#f00;color:white');\r
+ \r
+ $query = "SHOW TABLES LIKE '". sql_table('plug_todolist') ."'";\r
+ $table = sql_query($query);\r
+ if (mysql_num_rows($table) > 0){\r
+ $query = "SELECT * FROM ". sql_table('plug_todolist') ." ORDER BY cond, enddate";\r
+ $res = sql_query($query);\r
+ while ($data = mysql_fetch_object($res)) {\r
+ $this->list[$data->memberid][] = $data; //set data by memberid\r
+ }\r
+ }\r
+ }\r
+ \r
+ function doSkinVar($skinType, $showmode='normal',$memid='') {\r
+ global $memberid;\r
+ \r
+ if (!$memid) $memid = $memberid; //in member page\r
+ if (!$memid) $memid = 1; //default\r
+ \r
+ $editmode = intRequestVar('todoedit'); //get or post\r
+ $this->showTodoList($editmode, $showmode, $memid);\r
+ }\r
+ \r
+ function isLoggedIn() {\r
+ global $member;\r
+ return $member->isLoggedIn();\r
+ }\r
+ \r
+ function canEdit($memid) {\r
+ global $blog, $member;\r
+ \r
+ if ($blog) $b =& $blog; \r
+ else $b =& $manager->getBlog($CONF['DefaultBlog']);\r
+ $bid = $b->getID();\r
+ \r
+ if (!$member->isLoggedIn()) return 0;\r
+ \r
+ switch ($this->getOption('canedit')) {\r
+ case 'self':\r
+ return ($member->getID() == $memid);\r
+ break;\r
+ case 'team':\r
+ return ($member->teamRights($bid));\r
+ break;\r
+ case 'self+admin':\r
+ return ($member->getID() == $memid || $member->blogAdminRights($bid));\r
+ break;\r
+ default:\r
+ return 0;\r
+ }\r
+ }\r
+ \r
+ \r
+ function showEntryForm($editmode, $showmode, $memid) {\r
+ global $CONF;\r
+ \r
+ if (!$editmode) return;\r
+?>\r
+<form class="todolist" method="post" action="<?php echo $CONF['ActionURL'] ?>">\r
+<input type="hidden" name="action" value="plugin"/>\r
+<input type="hidden" name="name" value="TodoList" />\r
+<input type="hidden" name="type" value="add" />\r
+<input type="hidden" name="memid" value="<?php echo $memid ?>" />\r
+<select name="rank">\r
+<?php\r
+ for($i = count($this->rankname)-1; $i>=0; $i--){\r
+ echo "<option value='$i'>{$this->rankname[$i]}</option>\n";\r
+ }\r
+?>\r
+</select>\r
+<select name="cond">\r
+<?php\r
+ $i = 0;\r
+ foreach($this->condname as $cname){\r
+ echo "<option value='$i'>$cname</option>\n";\r
+ $i++;\r
+ }\r
+?>\r
+</select>\r
+<?php\r
+ if ($showmode != 'nodate') {\r
+?>\r
+<input class="formfield" type="text" name="enddate" value="<?php echo date('Y-m-d', mktime(0,0,0,date('m'),date('d')+1,date('Y'))) ?>" size="9" maxlength="10" />\r
+<?php\r
+ }\r
+?>\r
+<input class="formfield" type="text" name="title" value="" size="20" maxlength="255" />\r
+<input class="formbutton" type="submit" value="Submit" />\r
+</form>\r
+<?php\r
+ }\r
+ \r
+ \r
+ function showTodoList($editmode, $showmode, $memid) {\r
+ global $CONF, $member;\r
+ \r
+ $img_path = $this->getAdminURL();\r
+ \r
+ $this->showEntryForm($editmode, $showmode, $memid);\r
+ \r
+ if (empty($this->list[$memid])) {\r
+ echo "<p>No data found.</p>";\r
+ }\r
+ else {\r
+ //sort by rank\r
+ foreach($this->list[$memid] as $l) {\r
+ //if ($l->memberid != $memid) continue; // id check\r
+ $byrank[ $l->rank ][] = $l;\r
+ }\r
+ $sortlist = array();\r
+ for($i=count($this->rankname); $i>0; $i--) {\r
+ $sortlist = array_merge($sortlist, (array)$byrank[$i-1]);\r
+ }\r
+ \r
+ echo "<ul class='todolist'>\n";\r
+ \r
+ foreach($sortlist as $l) {\r
+ $tid = $l->tid;\r
+ $title = htmlspecialchars($l->title, ENT_QUOTES);\r
+ $enddate = $l->enddate;\r
+ $rank = $this->rankname[$l->rank];\r
+ $cond = $this->condname[$l->cond];\r
+ \r
+ if ($editmode) {\r
+?>\r
+<form class="todolist" method="post" action="<?php echo $CONF['ActionURL'] ?>">\r
+<input type="hidden" name="action" value="plugin"/>\r
+<input type="hidden" name="name" value="TodoList" />\r
+<input type="hidden" name="type" value="update" />\r
+<input type="hidden" name="tid" value="<?php echo $tid ?>" />\r
+<select name="rank">\r
+<?php\r
+ for($i = count($this->rankname)-1; $i>=0; $i--){\r
+ $selected = '';\r
+ if ($i == $l->rank) $selected = 'selected';\r
+ echo "<option value='$i' $selected>{$this->rankname[$i]}</option>\n";\r
+ }\r
+?>\r
+</select>\r
+<?php\r
+ }\r
+ else {\r
+ echo "<li>";\r
+ $img_file = 'rank'.$l->rank.'.gif';\r
+ $img_title = $this->rankname[$l->rank];\r
+ echo "<img class='icon-mid' src='$img_path$img_file' width='14' height='14' title='$img_title' />";\r
+ }\r
+ \r
+ if ($editmode) {\r
+?>\r
+<select name="cond">\r
+<?php\r
+ $cstyle = $this->condstyle;\r
+ $i = 0;\r
+ foreach($this->condname as $cname){\r
+ $selected = '';\r
+ if ($i == $l->cond) $selected = 'selected';\r
+ echo "<option style='$cstyle[$i]' value='$i' $selected>$cname</option>\n";\r
+ $i++;\r
+ }\r
+ echo "<option style='$cstyle[$i]' value='$i'>[delete]</option>\n";\r
+?>\r
+</select>\r
+<?php\r
+ }\r
+ else {\r
+ $img_file = 'cond'.$l->cond.'.gif';\r
+ $img_title = $this->condname[$l->cond];\r
+ echo " <img class='icon-mid' src='$img_path$img_file' width='52' height='14' title='$img_title' />";\r
+ }\r
+ \r
+ if ($editmode and $showmode != 'nodate') {\r
+?>\r
+<input class="formfield" type="text" name="enddate" value="<?php echo $enddate ?>" size="9" maxlength="10" />\r
+<?php\r
+ }\r
+ else if($showmode != 'nodate') {\r
+ $date_style = 'enddate';\r
+ if ( $enddate == date('Y-m-d', mktime( 0,0,0,date('m'),date('d')+1,date('Y'))) ) {\r
+ $date_style = 'enddate2'; //tomorrow\r
+ }\r
+ else if ($enddate == date('Y-m-d')) {\r
+ $date_style = 'enddate3'; //today\r
+ }\r
+ else if ($enddate < date('Y-m-d')) {\r
+ $date_style = 'enddate4'; //past\r
+ }\r
+ \r
+ //apply date format\r
+ $enddate = date($this->getOption('dateFormat'), strToTime($enddate));\r
+ echo " <span class='$date_style'>$enddate</span>";\r
+ }\r
+ \r
+ if ($editmode) {\r
+?>\r
+<input class="formfield" type="text" name="title" value="<?php echo $title ?>" size="20" maxlength="255" />\r
+<?php\r
+ }\r
+ else {\r
+ echo " <span class='title'>$title</span></li>\n";\r
+ }\r
+ \r
+ if ($editmode) {\r
+ if ($this->getOption('canedit') == 'team' \r
+ and $member->getID() != $memid) $disstr = 'disabled';\r
+ else $disstr = '';\r
+?>\r
+<input class="formbutton" type='submit' value='Update' <?php echo $disstr?> />\r
+</form>\r
+<?php\r
+ }\r
+ } //end of foreach($sortlist)\r
+ \r
+ echo "</ul>\n";\r
+ \r
+ }// end of if(isset($this->list))\r
+ \r
+ //edit switch\r
+ if ($this->canEdit($memid)) {\r
+ if ($editmode) $str_edit = "checked";\r
+ else $str_show = "checked"; \r
+?>\r
+<form class="todolist-r" method="post" action="<?php echo $CONF['ActionURL'] ?>">\r
+<input type="hidden" name="action" value="plugin"/>\r
+<input type="hidden" name="name" value="TodoList" />\r
+<input type="hidden" name="type" value="mode" />\r
+<input type="radio" name="todoedit" value="0" <?php echo $str_show ?> />Show\r
+<input type="radio" name="todoedit" value="1" <?php echo $str_edit ?> />Edit\r
+<input class="formbutton" type='submit' value='Change' />\r
+</form>\r
+<?php\r
+ }\r
+ \r
+ //plugin link\r
+ if ($this->getOption('flg_pluglink') == 'yes') {\r
+ $pluglink_url = $this->getURL();\r
+ \r
+ echo "<a href='$pluglink_url' title='Jump to the site of this plugin'>";\r
+ echo "<span style='font-size:9px'>» Get \"".$this->getName()."\"</span></a>";\r
+ }\r
+ \r
+ } //end of function\r
+ \r
+ \r
+ function doAction($type) {\r
+ global $CONF, $manager, $blog;\r
+ \r
+ if (! $this->isLoggedIn()) return;\r
+ \r
+ if ($blog) $b = &$blog;\r
+ else $b = &$manager->getBlog($CONF['DefaultBlog']);\r
+ \r
+ switch($type) {\r
+ case 'mode':\r
+ $editmode = intRequestVar('todoedit'); //get or post\r
+ $return = serverVar('HTTP_REFERER');\r
+ $return = preg_replace('/[?&]todoedit=[^&]*/', '', $return); //delete old parameter\r
+ if ( preg_match('/\?/',$return) ) $rvalue = "&todoedit=".$editmode;\r
+ else $rvalue = "?todoedit=".$editmode;\r
+ header("Location: $return$rvalue");\r
+ return;\r
+ break;\r
+ case 'add':\r
+ $query = sprintf("INSERT INTO %s SET title=%s, rank=%d, cond=%d, regdate=%s, enddate=%s, memberid=%s",\r
+ sql_table('plug_todolist'),\r
+ $this->quote_smart(postVar('title')),\r
+ $this->quote_smart(intPostVar('rank')),\r
+ $this->quote_smart(intPostVar('cond')),\r
+ date("'Y-m-d'", $b->getCorrectTime()),\r
+ $this->quote_smart(postVar('enddate')),\r
+ $this->quote_smart(intPostVar('memid')) );\r
+ sql_query($query);\r
+ break;\r
+ case 'update':\r
+ if (intPostVar('cond') >= count($this->condname)) { //cond = del\r
+ $query = sprintf("DELETE FROM %s WHERE tid=%d",\r
+ sql_table('plug_todolist'),\r
+ $this->quote_smart(intPostVar('tid')) );\r
+ }\r
+ else {\r
+ $query = sprintf("UPDATE %s SET title=%s, rank=%d, cond=%d, enddate=%s WHERE tid=%d",\r
+ sql_table('plug_todolist'),\r
+ $this->quote_smart(postVar('title')),\r
+ $this->quote_smart(intPostVar('rank')),\r
+ $this->quote_smart(intPostVar('cond')),\r
+ $this->quote_smart(postVar('enddate')),\r
+ $this->quote_smart(intPostVar('tid')) );\r
+ }\r
+ sql_query($query);\r
+ break;\r
+ case 'verup':\r
+ $vernum = intRequestVar('vernum');\r
+ $this->versionUpdate($vernum);\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ Header('Location: ' . serverVar('HTTP_REFERER') );\r
+ }\r
+ \r
+ // quote variable to make safe\r
+ function quote_smart($value) {\r
+ if (get_magic_quotes_gpc()) $value = stripslashes($value);\r
+ if (!is_numeric($value)) {\r
+ $value = "'". mysql_real_escape_string($value) ."'";\r
+ }\r
+ else {\r
+ $value = (int)$value;\r
+ }\r
+ return $value;\r
+ }\r
+\r
+} \r
?>
\ No newline at end of file