Exemplo n.º 1
0
$args->course = $course;
$args->cm = $cm;
$args->area = $area;
$args->itemid = $itemid;
$args->client_id = $client_id;
$args->component = $component;
$manager = new comment($args);
echo $OUTPUT->header();
// send headers
// process ajax request
switch ($action) {
    case 'add':
        if ($manager->can_post()) {
            $result = $manager->add($content);
            if (!empty($result) && is_object($result)) {
                $result->count = $manager->count();
                $result->client_id = $client_id;
                echo json_encode($result);
                die;
            }
        }
        break;
    case 'delete':
        $comment_record = $DB->get_record('comments', array('id' => $commentid));
        if ($manager->can_delete($commentid) || $comment_record->userid == $USER->id) {
            if ($manager->delete($commentid)) {
                $result = array('client_id' => $client_id, 'commentid' => $commentid);
                echo json_encode($result);
                die;
            }
        }
Exemplo n.º 2
0
}
$data = '';
if (file_exists("cache/{$id}/comments.{$pid}.cache")) {
    $data = $cache->load("cache/{$id}/comments.{$pid}.cache");
}
if ($data !== false && $data != "" && $got_permission === false) {
    echo $data;
    flush();
} else {
    if ($got_permission === false) {
        ob_start();
    }
    //Pagination starts here with dependencies. No need to change this usually... :3
    $comment = new comment();
    $misc = new misc();
    $count = $comment->count($id, $_GET['page'], $_GET['s']);
    echo "{$count} ";
    if ($count > 1) {
        print "comments";
    } else {
        print "comment";
    }
    echo '<a href="#" id="ci" onclick="showHideIgnored(' . $id . ',\'ci\'); return false;"> (0 hidden)</a><br />';
    //List comments... Could this be better off as a function to use here and on the comment list page? :S
    $query = "SELECT SQL_NO_CACHE id, comment, user, posted_at, score, spam FROM {$comment_table} WHERE post_id='{$id}' ORDER BY posted_at ASC LIMIT {$page}, {$limit}";
    $result = $db->query($query);
    $ccount = 0;
    while ($row = $result->fetch_assoc()) {
        echo '<div id="c' . $row['id'] . '" style="display:inline;"><br /><a href="index.php?page=account_profile&amp;uname=' . $row['user'] . '">' . $row['user'] . '</a><br /><b>Posted on ' . date('Y-m-d H:i:s', $row['posted_at']) . ' Score: <a id="sc' . $row['id'] . '">' . $row['score'] . '</a> (vote <a href="#" onclick="Javascript:vote(\'' . $id . '\', \'' . $row['id'] . '\', \'up\'); return false;">Up</a>/<a href="#" onclick="Javascript:vote(\'' . $id . '\', \'' . $row['id'] . '\', \'down\'); return false;">Down</a>)&nbsp;&nbsp;&nbsp;';
        ?>
			(<?php 
Exemplo n.º 3
0
            if ($updateData['albums_id']) {
                $updateAdd = array('photos_total' => 1, 'comment_num' => $pic_info['comment_num'], 'comment_total' => $pic_info['comment_total']);
                $updateDrop = array('photos_total' => -1, 'comment_num' => -$pic_info['comment_num'], 'comment_total' => -$pic_info['comment_total']);
                if ($pic_info['state']) {
                    $updateAdd['photos_num'] = 1;
                    $updateDrop['photos_num'] = -1;
                }
                $this->api->update('albums', $updateDrop, array('id' => $pic_info['albums_id']), true);
                $this->api->update('albums', $updateAdd, array('id' => $updateData['albums_id']), true);
                $this->api->update('comment', array('albums_id' => $updateData['albums_id']), array('photo_id' => $id));
                $this->api->update('praise', array('albums_id' => $updateData['albums_id'], array('photo_id' => $id)));
            }
            $this->addItem($result);
        }
        $this->output();
    }
    public function deletephoto()
    {
        $id = trim(urldecode($this->input['id']));
        $query = "update " . DB_PREFIX . "photos set isdrop=1 where id in ({$id})";
        $this->addItem($this->core->query_sql($query));
        $this->output();
    }
    /**
	 * 删除照片数据
	 */
    public function delete()
    {
        $id = trim(urldecode($this->input['id']));
        $id_arr = explode(',', $id);
        $ids = array_filter($id_arr, 'filter_arr');
        $id = implode(',', $ids);
        if (empty($id)) {
            $this->errorOutput(PARAM_WRONG);
        }
        //查询自己发布的数据
        $photos_info = $this->api->show(array('count' => -1, 'condition' => array('id' => $id, 'user_id' => $this->user['user_id'])));
        if (!$photos_info) {
            $this->errorOutput(FAILED);
        }
        $photo_ids = $audit_ids = array();
        foreach ($photos_info as $photo) {
            $photo_ids[$photo['id']] = $photo['id'];
            //所有的
            if ($photo['state'] == 1) {
                $audit_ids[$photo['id']] = $photo['id'];
                //已审核
            }
            $albums_id = $photo['albums_id'];
        }
        $dropPicNum = count($audit_ids);
        //删除的已审核的照片数
        $dropTotalPic = count($photo_ids);
        //删除的所有的照片数
        $photo_ids = implode(',', $photo_ids);
        $audit_ids = implode(',', $audit_ids);
        if ($audit_ids) {
            //查询有效的评论数
            include_once CUR_CONF_PATH . 'lib/comment.class.php';
            $commentApi = new comment();
            $comment_num = $commentApi->count(array('photo_id' => $audit_ids, 'state' => 3));
            $comment_total = $commentApi->count(array('photo_id' => $audit_ids));
            //删除照片下的评论
            $this->api->update('comment', array('isdrop' => 1), array('photo_id' => $audit_ids));
            //删除照片下的赞
            $this->api->update('praise', array('isdrop' => 1), array('photo_id' => $audit_ids));
        }
        if ($photo_ids) {
Exemplo n.º 4
0
 /**
  *
  */
 public function display_browse($entry, $options = array())
 {
     global $DB, $CFG;
     $field = $this->_field;
     $fieldid = $field->id;
     $df = $field->get_df();
     // Only for existing entries.
     if (!($entry->id > 0)) {
         return '';
     }
     $str = '';
     require_once "{$CFG->dirroot}/comment/lib.php";
     $cmt = new stdClass();
     $cmt->context = $df->context;
     $cmt->courseid = $df->course->id;
     $cmt->cm = $df->cm;
     $cmt->itemid = $entry->id;
     $cmt->component = 'mod_dataform';
     $cmt->area = $field->name;
     $cmt->showcount = isset($options['showcount']) ? $options['showcount'] : true;
     if (!empty($options['count'])) {
         $comment = new comment($cmt);
         $str = $comment->count();
     } else {
         foreach ($options as $key => $val) {
             $cmt->{$key} = $val;
         }
         $comment = new comment($cmt);
         $str = $comment->output(true);
     }
     return $str;
 }
Exemplo n.º 5
0
    $args->area = $area;
    $args->itemid = $itemid;
    $args->client_id = $client_id;
    $args->component = $component;
    // only for comments in frontpage
    $args->ignore_permission = $ignore_permission;
    $manager = new comment($args);
} else {
    die;
}
// process ajax request
switch ($action) {
    case 'add':
        $result = $manager->add($content);
        if (!empty($result) && is_object($result)) {
            $result->count = $manager->count();
            $result->client_id = $client_id;
            echo json_encode($result);
        }
        break;
    case 'delete':
        $result = $manager->delete($commentid);
        if ($result === true) {
            echo json_encode(array('client_id' => $client_id, 'commentid' => $commentid));
        }
        break;
    case 'get':
    default:
        $result = array();
        $comments = $manager->get_comments($page);
        $result['list'] = $comments;