/** * Insert message type item * * @param init $project_id * * @since 1.1 * * @return type */ function cpm_insert_message($project_id) { global $wpdb; $table_name = $wpdb->prefix . 'cpm_project_items'; $messages = CPM_Message::getInstance()->get_all($project_id, true); foreach ($messages as $message) { CPM_Project::getInstance()->new_project_item($project_id, $message->ID, $message->private, 'message', false); } }
function instantiate() { $project = CPM_Project::getInstance(); $message = CPM_Message::getInstance(); $task = CPM_Task::getInstance(); $milestone = CPM_Milestone::getInstance(); $activity = new CPM_Activity(); $ajax = new CPM_Ajax(); $notification = new CPM_Notification(); }
/** * Instantiate all the required classes * * @since 0.1 */ function instantiate() { CPM_Project::getInstance(); CPM_Message::getInstance(); CPM_Task::getInstance(); CPM_Milestone::getInstance(); new CPM_Activity(); new CPM_Ajax(); new CPM_Notification(); // instantiate admin settings only on admin page if (is_admin()) { new CPM_Admin(); } }
/** * Send email to all about a new comment * * @param int $comment_id * @param array $comment_info the post data */ function new_comment($comment_id, $project_id, $data) { $users = $this->prepare_contacts(); if (!$users) { return; } $msg_obj = CPM_Message::getInstance(); $parent_post = get_post($data['comment_post_ID']); $post_type = get_post_type_object($parent_post->post_type); $author = wp_get_current_user(); $subject = sprintf(__('[%s] New comment on %s: %s', 'cpm'), __('Project Manager', 'cpm'), $post_type->labels->singular_name, $parent_post->post_title); $message = sprintf('New comment on %s', $parent_post->post_title) . "\r\n\n"; $message .= sprintf('Author : %s', $author->display_name) . "\r\n"; $message .= sprintf(__('Permalink : %s'), cpm_url_single_message($project_id, $data['comment_post_ID'])) . "\r\n"; $message .= sprintf("Comment : \r\n%s", $data['comment_content']) . "\r\n"; $users = apply_filters('cpm_new_comment_to', $users); $subject = apply_filters('cpm_new_comment_subject', $subject); $message = apply_filters('cpm_new_comment_message', $message); $this->send(implode(', ', $users), $subject, $message); }
function get_message() { check_ajax_referer('cpm_nonce'); $posted = $_POST; $message_id = isset($posted['message_id']) ? intval($posted['message_id']) : 0; $project_id = isset($posted['project_id']) ? intval($posted['project_id']) : 0; $message_obj = CPM_Message::getInstance(); $message = $message_obj->get($message_id); if ($message) { echo json_encode(array('success' => true, 'id' => $message_id, 'content' => cpm_message_form($project_id, $message))); exit; } echo json_encode(array('success' => false)); exit; }
/** * Delete project child elements * * Delete all child task lists, messages and milestones when * a project is deleted. * * @param int $project_id * * @since 0.5.4 * * @return void */ function cpm_delete_project_child($project_id) { $childrens = get_posts(array('post_type' => array('task_list', 'message', 'milestone'), 'post_pre_page' => '-1', 'post_parent' => $project_id)); foreach ($childrens as $key => $children) { switch ($children->post_type) { case 'task_list': CPM_Task::getInstance()->delete_list($children->ID, true); break; case 'message': CPM_Message::getInstance()->delete($children->ID, true); break; case 'milestone': CPM_Milestone::getInstance()->delete($children->ID, true); break; } } }
/** * Send email to all about a new comment * * @param int $comment_id * @param array $comment_info the post data */ function new_comment($comment_id, $project_id, $data) { $users = $this->prepare_contacts(); if (!$users) { return; } $msg_obj = CPM_Message::getInstance(); $parent_post = get_post($data['comment_post_ID']); $author = wp_get_current_user(); $comment_url = ''; switch ($parent_post->post_type) { case 'message': $comment_url = cpm_url_single_message($project_id, $data['comment_post_ID']); break; case 'task_list': $comment_url = cpm_url_single_tasklist($project_id, $parent_post->ID); break; case 'task': $comment_url = cpm_url_single_task($project_id, $parent_post->post_parent, $parent_post->ID); break; } $template_vars = array('%SITE%' => wp_specialchars_decode(get_option('blogname'), ENT_QUOTES), '%PROJECT_NAME%' => get_post_field('post_title', $project_id), '%PROJECT_URL%' => cpm_url_project_details($project_id), '%AUTHOR%' => $author->display_name, '%AUTHOR_EMAIL%' => $author->user_email, '%COMMENT_URL%' => $comment_url, '%COMMENT%' => $data['comment_content'], '%IP%' => get_ipaddress()); $subject = cpm_get_option('new_comment_sub'); $message = cpm_get_option('new_comment_body'); // subject foreach ($template_vars as $key => $value) { $subject = str_replace($key, $value, $subject); } // message foreach ($template_vars as $key => $value) { $message = str_replace($key, $value, $message); } $this->send(implode(', ', $users), $subject, $message); }
/** * Instantiate all the required classes * * @since 0.1 */ function instantiate() { $this->project = CPM_Project::getInstance(); $this->message = CPM_Message::getInstance(); $this->task = CPM_Task::getInstance(); $this->milestone = CPM_Milestone::getInstance(); $this->activity = new CPM_Activity(); $this->ajax = new CPM_Ajax(); $this->notification = new CPM_Notification(); // instantiate admin settings only on admin page if (is_admin()) { $this->admin = new CPM_Admin(); $this->updates = new CPM_Updates(); $this->upgrade = new CPM_Upgrade(); } }
function get_messages($milestone_id) { return CPM_Message::getInstance()->get_by_milestone($milestone_id); }
<?php $users = $this->prepare_contacts(); if (!$users) { return; } cpm_get_email_header(); $tpbk = CPM_URL . '/assets/images/tpbk.png'; $pro_obj = CPM_Project::getInstance(); $msg_obj = CPM_Message::getInstance(); $project = $pro_obj->get($project_id); $msg = $msg_obj->get($message_id); $author = wp_get_current_user(); // $template_vars = array( // '%SITE%' => wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), // '%PROJECT_NAME%' => $project->post_title, // '%PROJECT_URL%' => '<a style="text-decoration: none;" href="'.cpm_url_project_details( $project_id ).'">'.get_post_field( 'post_title', $project_id ).'</a>', // '%AUTHOR%' => $author->display_name, // '%AUTHOR_EMAIL%' => $author->user_email, // '%MESSAGE_URL%' => '<a style="text-decoration: none;" href="'.cpm_url_single_message( $project_id, $message_id ).'">'.get_post_field( 'post_title', $message_id ). '</a>', // '%MESSAGE%' => $msg->post_content, // '%IP%' => get_ipaddress() // ); // $subject = apply_filters( 'new_message_sub', __('New Message', 'cpm') ); // $message = cpm_get_content( cpm_get_option( 'new_message_body' ) ); // // subject // foreach ($template_vars as $key => $value) { // $subject = str_replace( $key, $value, $subject ); // } // // message // foreach ($template_vars as $key => $value) {
function get_messages($milestone_id, $privacy = false) { return CPM_Message::getInstance()->get_by_milestone($milestone_id, $privacy); }
/** * Instantiate all the required classes * * @since 0.1 */ function instantiate() { $this->project = CPM_Project::getInstance(); $this->message = CPM_Message::getInstance(); $this->task = CPM_Task::getInstance(); $this->milestone = CPM_Milestone::getInstance(); $this->activity = CPM_Activity::getInstance(); $this->ajax = CPM_Ajax::getInstance(); $this->notification = CPM_Notification::getInstance(); if (function_exists('json_api_init')) { $this->api = CPM_API::instance(); } // instantiate admin settings only on admin page if (is_admin()) { $this->admin = new CPM_Admin(); $this->upgrade = new CPM_Upgrade(); } do_action('cpm_instantiate', $this); }