/** * 添加TODO * * * @param string token , 必填 * @param string text - TODO内容 , 必填 * @param string is_public - 是否公开 , 默认为1 * @param string uid - 要给添加TODO的用户id , uid为0时添加给自己。私有TODO不能添加给其他人 * @return todo array * @author EasyChen */ public function todo_add() { $content = z(t(v('text'))); if (!not_empty($content)) { return $this->send_error(LR_API_ARGS_ERROR, 'TEXT CAN\'T EMPTY'); } $is_public = intval(v('is_public')); if ($is_public != 0) { $is_public = 1; } $uid = intval(v('uid')); // 检查是否已经存在 $sql = "SELECT * FROM `todo` WHERE `content` = '" . s($content) . "' AND `owner_uid` = '" . intval(uid()) . "' LIMIT 1"; if ($todo = get_line($sql)) { if (get_var("SELECT COUNT(*) FROM `todo_user` WHERE `tid` = '" . intval($todo['id']) . "' AND `uid` = '" . intval(uid()) . "' AND `status` != 3 ") > 0) { return $this->send_error(LR_API_ARGS_ERROR, 'TODO EXISTS '); } } if (!($tid = add_todo($content, $is_public))) { return $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . db_error()); } $tinfo = get_todo_info_by_id($tid); if ($is_public == 1) { if ($uid > 0 && $uid != uid()) { $this->todo_assign($tid, $uid, true); $tinfo['other'] = 1; } else { publish_feed(uname() . '添加了TODO【' . $content . '】', uid(), 2, $tid); } } return $this->send_result($tinfo); }
/** * 添加TODO * * * @param string token , 必填 * @param string text - TODO内容 , 必填 * @param string is_public - 是否公开 , 默认为1 * @param string uid - 要给添加TODO的用户id , uid为0时添加给自己。私有TODO不能添加给其他人 * @return todo array * @author EasyChen */ public function todo_add() { $content = z(t(v('text'))); if (!not_empty($content)) { return self::send_error(LR_API_ARGS_ERROR, __('INPUT_CHECK_BAD_ARGS', 'TEXT')); } $due = t(v('due')); $td = new DateTime(); if (!not_empty($due)) { $due = '' . $td->add(new DateInterval("P5D"))->format('Y-m-d'); } else { $due = date('Y-m-d', strtotime($due)); } $is_public = intval(v('is_public')); if ($is_public != 0) { $is_public = 1; } $uid = intval(v('uid')); $owner_uid = $uid > 0 ? $uid : uid(); // 检查是否已经存在 $sql = "SELECT * FROM `todo` WHERE `content` = '" . s($content) . "' AND `owner_uid` = '" . intval($owner_uid) . "' LIMIT 1"; if ($todo = get_line($sql)) { if (get_var("SELECT COUNT(*) FROM `todo_user` WHERE `tid` = '" . intval($todo['id']) . "' AND `uid` = '" . intval($owner_uid) . "' AND `status` != 3 ") > 0) { return self::send_error(LR_API_ARGS_ERROR, __('API_MESSAGE_TODO_EXISTS')); } } if (!($tid = add_todo($content, $due, $is_public))) { return self::send_error(LR_API_DB_ERROR, __('API_MESSAGE_DATABASE_ERROR') . db_error()); } $tinfo = get_todo_info_by_id($tid); if ($is_public == 1) { if ($uid > 0 && $uid != uid()) { $this->todo_assign($tid, $uid, true); $tinfo['other'] = 1; } else { publish_feed(__('API_TEXT_TODO_ADDED', array(uname(), $content)), uid(), 2, $tid); } // .'添加了TODO【'. .'】' } return self::send_result($tinfo); }
$person = array(); $query = 'select person.id,person.first_name,person.last_name'; $query .= ' from person'; if ($gid) { $query .= ',pg where person.id=pg.pid and pg.gid="' . $gid . '"'; } $query .= ' order by last_name'; global $db; $personen = $db->query($query); while (list($p['id'], $p['first_name'], $p['last_name']) = mysql_fetch_row($personen)) { $person[] = $p; } return $person; } $output->secure(); $data = $_POST['data']; $validDate = new Date($data['year'], $data['month'], $data['day']); $data['deadline'] = $validDate->toString() . ' ' . $data['hour'] . ':' . $data['minute'] . ':' . $data['second']; if (!isset($data['expire'])) { $data['expire'] = false; } $ids = array(); if ($_POST['group']) { foreach ($data as $index => $value) { $v['data[' . $index . ']'] = $value; } $ids = complete_ids('g', 'group', $v, $_SESSION['userid']); } add_todo($data, $ids); $_SESSION['calendar_week'] = w_dif($data['deadline']); redirect('./');