Example #1
0
<?php

if (!isset($_SESSION['logged_in'])) {
    ?>
<p>Sorry, that function is limited to authenticated users.</p>
<?php 
} else {
    select_db();
    publish_feed("rss", 7);
    publish_feed("atom", 7);
    mysql_close();
    ?>

<?php 
}
Example #2
0
 /**
  * @ignore
  */
 private function todo_set_value($field, $value)
 {
     $tid = intval(v('tid'));
     if ($tid < 1) {
         return self::send_error(LR_API_ARGS_ERROR, __('INPUT_CHECK_BAD_ARGS', 'TID'));
     }
     $sql = "SELECT * FROM `todo_user` WHERE  `tid` = '" . intval($tid) . "' AND `uid` = '" . intval($_SESSION['uid']) . "' LIMIT 1";
     if (!($data = get_line($sql))) {
         return self::send_error(LR_API_FORBIDDEN, __('API_MESSAGE_CANNOT_UPDATE_OTHERS_TODO'));
     }
     // delete uid and limit 1
     // to make all record updated at sametime
     // for all the followers
     $sql = "UPDATE `todo_user` SET `" . s($field) . "` = '" . intval($value) . "' , `last_action_at` = NOW() WHERE `tid` = '" . intval($tid) . "' ";
     run_sql($sql);
     if (mysql_errno() != 0) {
         return self::send_error(LR_API_DB_ERROR, __('API_MESSAGE_DATABASE_ERROR') . mysql_error());
     } else {
         $todoinfo = get_todo_info_by_id($tid, true);
         kset('dinfo', $todoinfo['details']['is_public']);
         if ($field == 'status' && $value == 3) {
             if ($todoinfo['details']['is_public'] == 1) {
                 // .'完成了TODO【'.  .'】'
                 publish_feed(__('API_TEXT_FINISH_TODO', array(uname(), $todoinfo['content'])), uid(), 2, $tid);
                 // send notice
                 // 向订阅todo的同学发送通知
                 $sql = "SELECT `uid` FROM `todo_user` WHERE `tid`= '" . intval($tid) . "' AND `is_follow` = 1 ";
                 if ($uitems = get_data($sql)) {
                     foreach ($uitems as $uitem) {
                         if ($uitem['uid'] != uid()) {
                             send_notice($uitem['uid'], __('API_TEXT_FINISH_TODO_FOLLOWED', array(uname(), $todoinfo['content'])), 1, array('tid' => intval($tid), 'count' => $todoinfo['comment_count']));
                         }
                     }
                 }
             }
         }
         return self::send_result($todoinfo);
     }
 }
Example #3
0
 /**
  * @ignore
  */
 private function todo_set_value($field, $value)
 {
     $tid = intval(v('tid'));
     if ($tid < 1) {
         return $this->send_error(LR_API_ARGS_ERROR, 'id FIELD REQUIRED');
     }
     $sql = "SELECT * FROM `todo_user` WHERE  `tid` = '" . intval($tid) . "' AND `uid` = '" . intval($_SESSION['uid']) . "' LIMIT 1";
     if (!($data = get_line($sql))) {
         return $this->send_error(LR_API_FORBIDDEN, 'YOU CANNOT UPDATE OTHERS TODO');
     }
     // delete uid and limit 1
     // to make all record updated at sametime
     // for all the followers
     $sql = "UPDATE `todo_user` SET `" . s($field) . "` = '" . intval($value) . "' , `last_action_at` = NOW() WHERE `tid` = '" . intval($tid) . "' ";
     run_sql($sql);
     if (mysql_errno() != 0) {
         return $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
     } else {
         $todoinfo = get_todo_info_by_id($tid, true);
         kset('dinfo', $todoinfo['details']['is_public']);
         if ($field == 'status' && $value == 3) {
             if ($todoinfo['details']['is_public'] == 1) {
                 publish_feed(uname() . '完成了TODO【' . $todoinfo['content'] . '】', uid(), 2, $tid);
                 // send notice
                 // 向订阅todo的同学发送通知
                 $sql = "SELECT `uid` FROM `todo_user` WHERE `tid`= '" . intval($tid) . "' AND `is_follow` = 1 ";
                 if ($uitems = get_data($sql)) {
                     foreach ($uitems as $uitem) {
                         if ($uitem['uid'] != uid()) {
                             send_notice($uitem['uid'], uname() . '完成了你关注的TODO【' . $todoinfo['content'] . '】', 1, array('tid' => intval($tid), 'count' => $todoinfo['comment_count']));
                         }
                     }
                 }
             }
         }
         return $this->send_result($todoinfo);
     }
 }