function getList($name, $db, $mail) { $t = loadLists($db, ""); foreach ($t["list"] as $list) { if (strcasecmp($list["name"], $name) == 0) { return $list["id"]; } } $newList = addList($db, $name); if (!$newList['total'] || $newList['total'] < 1) { err("error creating new list.", $mail); } return $newList['list'][0]['id']; }
jsonExit(array('total' => 1)); } elseif (isset($_GET['publishList'])) { check_write_access(); $listId = (int) _post('list'); $publish = (int) _post('publish'); $db->ex("UPDATE {$db->prefix}lists SET published=?,d_created=? WHERE id={$listId}", array($publish ? 1 : 0, time())); jsonExit(array('total' => 1)); } elseif (isset($_GET['moveTask'])) { check_write_access(); $id = (int) _post('id'); $fromId = (int) _post('from'); $toId = (int) _post('to'); $result = moveTask($id, $toId); $t = array('total' => $result ? 1 : 0); if ($fromId == -1 && $result && ($r = $db->sqa("SELECT * FROM {$db->prefix}todolist WHERE id={$id}"))) { $t['list'][] = prepareTaskRow($r, loadLists($db, '')); } jsonExit($t); } elseif (isset($_GET['changeListOrder'])) { check_write_access(); stop_gpc($_POST); $order = (array) _post('order'); $t = array(); $t['total'] = 0; if ($order) { $a = array(); $setCase = ''; foreach ($order as $ow => $id) { $id = (int) $id; $a[] = $id; $setCase .= "WHEN id={$id} THEN {$ow}\n";
echo "<div class='col-xs-4'>"; echo "<button type='button' class = 'btn btn-info btn-primary listbtn' id ='" . $row[0] . "' data-toggle='collapse' data-target='#" . $row[1] . "'>" . $row[0] . "</button>"; echo "<div id='" . $row[1] . "' class='collapse'>"; $sql = "SELECT itemText, email, pos, itemPriority FROM item WHERE listid = '" . $row[1] . "' ORDER BY pos"; $returned = mysql_query($sql, $conn); while ($itemRow = mysql_fetch_row($returned)) { echo "<p><a href='#' data-toggle='popover' title='Added By' data-content='" . $itemRow[1] . " - Priority: " . $itemRow[3] . "'>" . $itemRow[0] . "</a></p>"; } echo "<label for = 'addItemInputField'>Add Item</label>"; echo "<input type = 'text' class = 'form-control' id='" . $row[1] . "-input' placeholder='Item Name'></input>"; echo "<input type = 'text' class = 'form-control' id='" . $row[1] . "-priority' placeholder='Priority - Enter: High, Med, or Low'></input>"; echo "<button type='button' class='btn btn-info addItemBtn'>Add</button>"; echo "<p><label for = 'approveUserInputField'>Approve User For This List</label>"; echo "<input type = 'text' class = 'form-control' id='" . $row[1] . "-approve' placeholder='Enter User To Approve Email'></input>"; echo "<button type='button' class='btn btn-info approveBtn'>Approve</button></p>"; echo "<button type='button' class='btn btn-warning deleteListBtn' id = '" . $row[1] . "-deleteList'>Delete This List</button>"; echo "</div>"; echo "</div>"; if ($countRow == 2) { echo "</div>"; } if ($countRow == 2) { $countRow = 0; } else { $countRow++; } } mysql_close($conn); } loadLists();
function addTask($db, $listId, $title, $tag, $note = null, $priority = null, $duedate = null, $tags = null) { $t = array(); $t['total'] = 0; $title = trim($title); if ($title == '') { return $t; } if ($note) { $note = str_replace("\r\n", "\n", trim($note)); } else { $note = ""; } $duedate = parse_duedate(trim($duedate)); $prio = 0; if ($tags) { $tags = trim($tags); } else { $tags = ''; } if (Config::get('smartsyntax') != 0) { $a = parse_smartsyntax($title); if ($a === false) { jsonExit($t); } $title = $a['title']; $prio = $a['prio']; $tags = ($tags ? $tags . "," : "") . $a['tags']; } if ($priority) { $prio = (int) $priority; } if ($prio < -1) { $prio = -1; } elseif ($prio > 2) { $prio = 2; } if (Config::get('autotag')) { $tags .= ',' . _post('tag'); } $ow = 1 + (int) $db->sq("SELECT MAX(ow) FROM {$db->prefix}todolist WHERE list_id={$listId} AND compl=0"); $db->ex("BEGIN"); $db->dq("INSERT INTO {$db->prefix}todolist (uuid,list_id,title,d_created,d_edited,ow,prio,note,duedate) VALUES(?,?,?,?,?,?,?,?,?)", array(generateUUID(), $listId, $title, time(), time(), $ow, $prio, $note, $duedate)); $id = $db->last_insert_id(); if ($tags != '') { $aTags = prepareTags($tags); if ($aTags) { addTaskTags($id, $aTags['ids'], $listId); $db->ex("UPDATE {$db->prefix}todolist SET tags=?,tags_ids=? WHERE id={$id}", array(implode(',', $aTags['tags']), implode(',', $aTags['ids']))); } } $db->ex("COMMIT"); $r = $db->sqa("SELECT * FROM {$db->prefix}todolist WHERE id={$id}"); $t['list'][] = prepareTaskRow($r, loadLists($db, '')); $t['total'] = 1; return $t; }