コード例 #1
0
 public static function getInstance()
 {
     if (!self::$_instance) {
         self::$_instance = new CPM_Comment();
     }
     return self::$_instance;
 }
コード例 #2
0
<?php

cpm_get_header(__('Files', 'cpm'), $project_id);
$args = array('post_type' => 'attachment', 'meta_key' => '_project', 'meta_value' => $project_id, 'numberposts' => -1);
$attachments = get_posts($args);
$base_image_url = admin_url('admin-ajax.php?action=cpm_file_get');
if ($attachments) {
    echo '<ul class="cpm-files">';
    foreach ($attachments as $attachment) {
        $file = CPM_Comment::getInstance()->get_file($attachment->ID);
        $topic_url = '#';
        if (!$attachment->post_parent) {
            $parent_id = get_post_meta($attachment->ID, '_parent', true);
            $parent = get_post($parent_id);
        } else {
            $parent = get_post($attachment->post_parent);
        }
        $post_type_object = get_post_type_object($parent->post_type);
        if ($parent->post_type == 'task') {
            $task_list = get_post($parent->post_parent);
            $topic_url = cpm_url_single_task($project_id, $task_list->ID, $parent->ID);
        } else {
            if ($parent->post_type == 'task_list') {
                $topic_url = cpm_url_single_tasklist($project_id, $parent->ID);
            } else {
                if ($parent->post_type == 'message') {
                    $topic_url = cpm_url_single_message($project_id, $parent->ID);
                }
            }
        }
        $file_url = sprintf('%s&file_id=%d&project_id=%d', $base_image_url, $file['id'], $project_id);
コード例 #3
0
 function delete_comment()
 {
     check_ajax_referer('cpm_nonce');
     $comment_id = isset($_POST['comment_id']) ? intval($_POST['comment_id']) : 0;
     CPM_Comment::getInstance()->delete($comment_id, true);
     echo json_encode(array('success' => true));
     exit;
 }
コード例 #4
0
 /**
  * Get all comments on a single task
  *
  * @param int $task_id
  * @return object object array of the result set
  */
 function get_task_comments($task_id)
 {
     return CPM_Comment::getInstance()->get_comments($task_id);
 }
コード例 #5
0
 function get_comments($message_id, $sort = 'ASC')
 {
     $comments = CPM_Comment::getInstance()->get_comments($message_id, $sort);
     return $comments;
 }
コード例 #6
0
 * Project dashboard page
 */
cpm_get_header( __( 'Activity', 'cpm' ), $project_id );
?>
<h3 class="cpm-nav-title">
    <?php _e( 'Project Activity', 'wedevs' ); ?>

    <?php if ( current_user_can( 'delete_others_posts' ) ) { //editor ?>
        <span class="cpm-right">
            <a href="#" class="cpm-icon-delete cpm-project-delete-link" title="<?php esc_attr_e( 'Delete project', 'cpm' ); ?>" <?php cpm_data_attr( array('confirm' => 'Are you sure to delete this project', 'project_id' => $project_id) ) ?>>
                <span><?php _e( 'Delete', 'cpm' ); ?></span>
            </a>
        </span>
    <?php } ?>
</h3>

<ul class="cpm-activity dash">
    <?php
    $activities = CPM_Comment::getInstance()->get_comments( $project_id, 'DESC' );

    if ( $activities ) {
        foreach ($activities as $activity) {
            ?>
            <li>
                <?php echo do_shortcode( $activity->comment_content ); ?> <span class="date">- <?php echo cpm_get_date( $activity->comment_date, true ); ?></span>
            </li>
            <?
        }
    }
    ?>
</ul>