static function render_comments_meta_box($post) { global $wpdb; $comment_type = Kanban_Utils::format_key(self::$slug, 'comment'); $sql = "SELECT `{$wpdb->prefix}comments`.*\n\t\t\t\tFROM `{$wpdb->prefix}comments`\n\t\t\t\tWHERE `comment_post_ID` = '{$post->ID}'\n\t\t\t\tAND `comment_type` = '{$comment_type}'\n\t\t\t\tORDER BY `{$wpdb->prefix}comments`.`comment_date` DESC\n\t\t\t;"; $sql = apply_filters(sprintf('%s_sql_%s_comments_meta_box', Kanban::get_instance()->settings->basename, self::$slug), $sql); $comments = $wpdb->get_results($sql); ?> <style> #kanban_task_comments .inside { margin: 0; padding: 0; } #kanban_task_comments li { padding: 10px; } #kanban_task_comments small { color: #CCC; display: block; } </style> <ul class="striped"> <?php foreach ($comments as $comment) { $comment_date_dt = new DateTime($comment->comment_date); ?> <li> <small> <?php echo $comment_date_dt->format('D, j M, Y'); ?> at <?php echo $comment_date_dt->format('g:ia'); ?> </small> <?php echo $comment->comment_content; ?> </li> <?php } ?> </ul> <?php }
static function ajax_save() { if (!isset($_POST[Kanban_Utils::get_nonce()]) || !wp_verify_nonce($_POST[Kanban_Utils::get_nonce()], sprintf('%s-save', Kanban::get_instance()->settings->basename)) || !is_user_logged_in()) { wp_send_json_error(); } do_action(sprintf('%s_before_%s_ajax_save', Kanban::get_instance()->settings->basename, self::$slug)); $status_id_old = Kanban_Utils::format_key(self::$slug, 'status_id_old'); $status_id_new = Kanban_Utils::format_key(self::$slug, 'status_id_new'); // build post data $post_data = array('post_type' => Kanban_Post_Types::format_post_type(self::$slug), 'post_title' => sprintf('changed task ID %s from %s to %s', $_POST['task_id'], $_POST['status_id_old'], $_POST['status_id_new']), 'post_parent' => $_POST['task_id'], 'postmeta' => array($status_id_old => $_POST['status_id_old'], $status_id_new => $_POST['status_id_new']), 'terms' => array()); // save our work_hour $post_data = Kanban_Post::save($post_data); if (!$post_data) { wp_send_json_error(); } do_action(sprintf('%s_after_%s_ajax_save', Kanban::get_instance()->settings->basename, self::$slug)); wp_send_json_success(array('message' => sprintf('%s saved', self::$slug), self::$slug => $post_data)); }
static function ajax_save() { if (!isset($_POST[Kanban_Utils::get_nonce()]) || !wp_verify_nonce($_POST[Kanban_Utils::get_nonce()], sprintf('%s-save', Kanban::get_instance()->settings->basename)) || !is_user_logged_in()) { wp_send_json_error(); } do_action(sprintf('%s_before_%s_ajax_save', Kanban::get_instance()->settings->basename, self::$slug)); $user_id_author = isset($_POST['user_id_author']) ? $_POST['user_id_author'] : get_current_user_id(); if (empty($_POST['user_id_worked'])) { $_POST['user_id_worked'] = $user_id_author; } try { $operator = substr($_POST['operator'], 0, 1) == '-' ? '-' : '+'; $val = sprintf('%s%s', $operator, abs(floatval($_POST['operator']))); } catch (Exception $e) { wp_send_json_error(array('message' => sprintf('Error saving %s', str_replace('_', ' ', self::$slug)))); } eval(sprintf('$hours = 0%s;', $val)); $data = array('task_id' => $_POST['task']['id'], 'worked_dt_gmt' => Kanban_Utils::mysql_now_gmt(), 'hours' => $hours, 'status_is' => $_POST['task']['status_id'], 'user_id_author' => $user_id_author, 'user_id_worked' => $_POST['user_id_worked']); $is_successful = self::_insert($data); do_action(sprintf('%s_after_%s_ajax_save', Kanban::get_instance()->settings->basename, self::$slug)); if (!empty($_POST['comment'])) { do_action(sprintf('%s_before_%s_ajax_comment_save', Kanban::get_instance()->settings->basename, self::$slug)); Kanban_Comment::add($_POST['comment'], 'system', $_POST['task']['id']); do_action(sprintf('%s_after_%s_ajax_comment_save', Kanban::get_instance()->settings->basename, self::$slug)); } if ($is_successful) { wp_send_json_success(array('message' => sprintf('%s saved', str_replace('_', ' ', self::$slug)))); } else { wp_send_json_error(array('message' => sprintf('Error saving %s', str_replace('_', ' ', self::$slug)))); } }
static function get_all($sql = NULL) { $table_name = self::table_name(); $sql = "SELECT *\n\t\t\t\tFROM `{$table_name}`\n\t\t\t\tORDER BY `position` ASC\n\t\t;"; $sql = apply_filters(sprintf('%s_sql_%s_get_all', Kanban::get_instance()->settings->basename, self::$table_name), $sql); $records = parent::get_all($sql); return Kanban_Utils::build_array_with_id_keys($records, 'id'); }
static function get_all_terms() { if (!isset(Kanban_Terms::get_instance()->all_terms)) { // get all terms for displaying $args = array('hide_empty' => 0, 'orderby' => 'term_order'); $all_terms = get_terms(Kanban::get_instance()->taxonomies_list, $args); Kanban_Terms::get_instance()->all_terms = Kanban_Utils::build_array_with_id_keys($all_terms, 'term_id'); } return Kanban_Terms::get_instance()->all_terms; }
static function add($comment, $type = 'system', $task_id = 0, $user_id_author = NULL) { do_action(sprintf('%s_before_%s_add', Kanban::get_instance()->settings->basename, self::$slug)); if (!$user_id_author) { $user_id_author = get_current_user_id(); } $data = array('description' => $comment, 'comment_type' => $type, 'task_id' => $task_id, 'user_id_author' => $user_id_author); $success = self::_insert($data); do_action(sprintf('%s_after_%s_add', Kanban::get_instance()->settings->basename, self::$slug), $success, $data); return $success; }
static function get_all($sql = NULL) { $table_name = self::table_name(); $tasks_table_name = Kanban_Task::table_name(); $sql = "SELECT `projects`.*,\n\t\t\t\t(\n\t\t\t\t\tSELECT COUNT(`id`)\n\t\t\t\t\tFROM `{$tasks_table_name}` tasks\n\t\t\t\t\tWHERE `tasks`.`project_id` = `projects`.`id`\n\t\t\t\t\tAND `tasks`.`is_active` = 1\n\t\t\t\t)\n\t\t\t\tAS 'task_count'\n\t\t\t\tFROM `{$table_name}` projects\n\t\t\t\tWHERE `projects`.`is_active` = 1\n\t\t;"; $sql = apply_filters(sprintf('%s_sql_%s_get_all', Kanban::get_instance()->settings->basename, self::$slug), $sql); $records = parent::get_all($sql); foreach ($records as $key => $record) { $records[$key]->title = Kanban_Utils::str_for_frontend($records[$key]->title); } return Kanban_Utils::build_array_with_id_keys($records, 'id'); }
static function ajax_delete() { if (!isset($_POST[Kanban_Utils::get_nonce()]) || !wp_verify_nonce($_POST[Kanban_Utils::get_nonce()], sprintf('%s-save', Kanban::get_instance()->settings->basename)) || $_POST['post_type'] !== Kanban_Post_Types::format_post_type(self::$slug) || !is_user_logged_in()) { wp_send_json_error(); } do_action(sprintf('%s_before_%s_ajax_delete', Kanban::get_instance()->settings->basename, self::$slug)); $is_successful = Kanban_Post::delete($_POST); do_action(sprintf('%s_after_%s_ajax_delete', Kanban::get_instance()->settings->basename, self::$slug)); if ($is_successful) { wp_send_json_success(array('message' => sprintf('%s deleted', self::$slug))); } else { wp_send_json_error(array('message' => sprintf('Error deleting %s', self::$slug))); } }
/** * if a logged in user sees the log in page, and requets access to the kanban board * sends an email to the site admin */ static function request_access() { if (!isset($_POST[Kanban_Utils::get_nonce()]) || !wp_verify_nonce($_POST[Kanban_Utils::get_nonce()], 'request_access')) { return; } $admin_email = get_option('admin_email'); $blogname = get_option('blogname'); $headers = "From: " . $admin_email . "\r\n"; $current_user_id = get_current_user_id(); $current_user = get_user_by('id', $current_user_id); wp_mail($admin_email, sprintf(__('%s: %s has requested access', 'kanban'), Kanban::get_instance()->settings->pretty_name, Kanban_User::get_username_long($current_user)), sprintf(__('The following user has requested access. ' . "\n" . '%s' . "\n\n" . 'To grant them access, please visit this link:' . "\n" . '%s' . "\n" . 'And select them as an allowed user.', 'kanban'), Kanban_User::get_username_long($current_user), admin_url('admin.php?page=' . Kanban::get_instance()->settings->basename)), $headers); Kanban_Flash::flash(__('Your request has been sent.', 'kanban'), 'success'); wp_redirect($_POST['_wp_http_referer']); exit; }
static function welcome_screen_do_activation_redirect() { // Bail if no activation redirect if (!get_transient(sprintf('_%s_welcome_screen_activation_redirect', Kanban::get_instance()->settings->basename))) { return; } // Delete the redirect transient delete_transient(sprintf('_%s_welcome_screen_activation_redirect', Kanban::get_instance()->settings->basename)); // Bail if activating from network, or bulk if (is_network_admin() || isset($_GET['activate-multi'])) { return; } // Redirect to about page wp_safe_redirect(add_query_arg(array('page' => Kanban::get_instance()->settings->basename, 'activation' => '1'), admin_url('admin.php'))); }
/** * load data needed for board's javascript * @param string $template the passed in template path * @return string the same template path */ static function send_page_data_to_template($template) { // make sure we're looking at the board if (!isset(Kanban_Template::get_instance()->slug) || Kanban_Template::get_instance()->slug != self::$slug) { return $template; } // make sure they don't need to upgrade if (Kanban::get_instance()->settings->records_to_move > 0) { ?> <p> <?php echo sprintf(__('We\'ve found %s kanban records that need to be migrated for the latest version of Kanban for WordPress!', 'kanban'), Kanban::get_instance()->settings->records_to_move); ?> </p> <p> <?php echo sprintf(__('Please visit the <a href="%s">Kanban welcome page</a> to migrate your data.', 'kanban'), add_query_arg('page', 'kanban_welcome', admin_url('admin.php'))); ?> <?php exit; } // get the template data global $wp_query; // attach our object to the template data $wp_query->query_vars['kanban'] = (object) array(); $wp_query->query_vars['kanban']->board = (object) array(); // add default filters $wp_query->query_vars['kanban']->board->filters = array('user' => (object) array(), 'project' => (object) array()); // add passed alert $wp_query->query_vars['kanban']->board->alert = !empty($_GET['alert']) ? stripcslashes($_GET['alert']) : ''; // get all data for the javascript $wp_query->query_vars['kanban']->board->settings = Kanban_Option::get_all(); $wp_query->query_vars['kanban']->board->allowed_users = Kanban_User::get_allowed_users(); $wp_query->query_vars['kanban']->board->estimates = Kanban_Estimate::get_all(); $wp_query->query_vars['kanban']->board->statuses = Kanban_Status::get_all(); $wp_query->query_vars['kanban']->board->projects = Kanban_Project::get_all(); $wp_query->query_vars['kanban']->board->tasks = Kanban_Task::get_all(); // get the current user from the allowed users $current_user_id = get_current_user_id(); $wp_query->query_vars['kanban']->board->current_user = $wp_query->query_vars['kanban']->board->allowed_users[$current_user_id]; // figure out percentages here (easier, quicker than in js) $wp_query->query_vars['kanban']->board->col_percent_w = count($wp_query->query_vars['kanban']->board->statuses) > 0 ? 100 / count($wp_query->query_vars['kanban']->board->statuses) : 100; $wp_query->query_vars['kanban']->board->sidebar_w = count($wp_query->query_vars['kanban']->board->statuses) > 0 ? 100 / (count($wp_query->query_vars['kanban']->board->statuses) - 2) : 0; apply_filters('kanban_board_query_vars', $wp_query->query_vars['kanban']->board); return $template; }
static function ajax_save() { if (!isset($_POST[Kanban_Utils::get_nonce()]) || !wp_verify_nonce($_POST[Kanban_Utils::get_nonce()], sprintf('%s-save', Kanban::get_instance()->settings->basename)) || !is_user_logged_in()) { wp_send_json_error(); } do_action(sprintf('%s_before_%s_ajax_save', Kanban::get_instance()->settings->basename, self::$slug)); $current_user_id = get_current_user_id(); $comment_type_field = Kanban_Utils::format_key(self::$slug, 'comment_type'); // build post data $post_data = array('post_type' => Kanban_Post_Types::format_post_type(self::$slug), 'post_title' => sprintf('%s comment for task %s', $_POST['comment_type'], $_POST['id']), 'post_content' => sanitize_text_field(str_replace("\n", '', $_POST['post_content'])), 'post_parent' => $_POST['id'], 'postmeta' => array($comment_type_field => $_POST['comment_type'])); // save our work_hour $post_data = Kanban_Post::save($post_data); if (!$post_data) { wp_send_json_error(); } do_action(sprintf('%s_after_%s_ajax_save', Kanban::get_instance()->settings->basename, self::$slug)); wp_send_json_success(array('message' => sprintf('%s saved', self::$slug), self::$slug => $post_data)); }
static function setup_flash_messages() { // @link http://stackoverflow.com/a/28377350/38241 if (version_compare(phpversion(), "5.4.0") != -1) { if (session_status() == PHP_SESSION_NONE) { session_start(); } } else { if (session_id() == '') { session_start(); } } Kanban::get_instance()->flash = new Kanban_Messages(); Kanban::get_instance()->flash->msgTypes = array('default', 'info', 'warning', 'success', 'danger'); Kanban::get_instance()->flash->msgClass = 'alert alert-'; Kanban::get_instance()->flash->msgWrapper = '<div class="%s%s alert-dismissible"> %s </div>' . "\n"; Kanban::get_instance()->flash = apply_filters(sprintf('%s_after_setup_flash_messages', Kanban::get_instance()->settings->basename), Kanban::get_instance()->flash); }
static function get_allowed_users() { if (!isset(Kanban_User::get_instance()->allowed_users)) { $users_field_name = sprintf('%s_user', Kanban::get_instance()->settings->basename); $allowed_user_ids = Kanban_Settings::get_option($users_field_name, 'allowed_users', array()); if (empty($allowed_user_ids)) { $allowed_user_ids = array(0); } $pm_users = get_users(array('include' => $allowed_user_ids)); Kanban_User::get_instance()->allowed_users = Kanban_Utils::build_array_with_id_keys($pm_users); foreach (Kanban_User::get_instance()->allowed_users as $user_id => $user) { if (self::validate_gravatar($user->data->user_email)) { Kanban_User::get_instance()->allowed_users[$user_id]->data->avatar = get_avatar($user->data->user_email); } Kanban_User::get_instance()->allowed_users[$user_id]->data->long_name_email = Kanban_User::format_user_name($user); Kanban_User::get_instance()->allowed_users[$user_id]->data->short_name = Kanban_User::format_user_name($user, TRUE); Kanban_User::get_instance()->allowed_users[$user_id]->data->initials = Kanban_User::get_initials($user); } } return apply_filters(sprintf('%s_after_get_allowed_users', Kanban::get_instance()->settings->basename), Kanban_User::get_instance()->allowed_users); }
static function ajax_save() { if (!isset($_POST[Kanban_Utils::get_nonce()]) || !wp_verify_nonce($_POST[Kanban_Utils::get_nonce()], sprintf('%s-save', Kanban::get_instance()->settings->basename)) || $_POST['post_type'] !== Kanban_Post_Types::format_post_type(self::$slug) || !is_user_logged_in()) { wp_send_json_error(); } do_action(sprintf('%s_before_%s_ajax_save', Kanban::get_instance()->settings->basename, self::$slug)); // build post data $post_data = array('post_type' => Kanban_Post_Types::format_post_type(self::$slug), 'post_title' => sanitize_text_field($_POST['post_title']), 'postmeta' => array(), 'terms' => array()); $hour_operator = Kanban_Utils::format_key(self::$slug, 'operator'); $post_data['postmeta'][$hour_operator] = $_POST['operator']; // set assignee as author of work hour $task_user_id_assigned_to = Kanban_Utils::format_key('task', 'user_id_assigned'); if ($_POST['postmeta'][$task_user_id_assigned_to] > 0) { $post_data['post_author'] = $_POST['postmeta'][$task_user_id_assigned_to]; } // link task to hour $hour_task_id = Kanban_Utils::format_key(self::$slug, 'project_id'); $post_data['postmeta'][$hour_task_id] = $_POST['ID']; // link current user to hour $hour_user_id_logged = Kanban_Utils::format_key(self::$slug, 'user_id_logged'); $post_data['postmeta'][$hour_user_id_logged] = get_current_user_id(); // set task project as work project $task_project_id = Kanban_Utils::format_key('task', 'project_id'); $hour_project_id = Kanban_Utils::format_key(self::$slug, 'project_id'); $post_data['postmeta'][$hour_project_id] = $_POST['postmeta'][$task_project_id]; // set current task status for work hour $task_status = Kanban_Utils::format_key('task', 'status'); $hour_status_id = Kanban_Utils::format_key(self::$slug, 'task_status_id'); $post_data['postmeta'][$hour_status_id] = $_POST['terms'][$task_status][0]; // save our work_hour $post_data = Kanban_Post::save($post_data); if (!$post_data) { wp_send_json_error(); } do_action(sprintf('%s_after_%s_ajax_save', Kanban::get_instance()->settings->basename, self::$slug)); wp_send_json_success(array('message' => sprintf('%s saved', self::$slug), self::$slug => $post_data)); }
static function save_settings() { if (!isset($_POST[Kanban_Utils::get_nonce()]) || !wp_verify_nonce($_POST[Kanban_Utils::get_nonce()], sprintf('%s-%s', Kanban::get_instance()->settings->basename, Kanban_Option::table_name())) || !is_user_logged_in()) { return; } $statuses = Kanban_Status::get_all(); $status_ids = array_keys($statuses); // any statuses to delete? if (isset($_POST['statuses']['saved'])) { $deleted_statuses = array_diff($status_ids, array_keys($_POST['statuses']['saved'])); if (!empty($deleted_statuses)) { foreach ($deleted_statuses as $key => $id) { Kanban_Status::delete(array('id' => $id)); } } } // add new statuses first if (isset($_POST['statuses']['new'])) { foreach ($_POST['statuses']['new'] as $status) { // save it $success = Kanban_Status::replace($status); if ($success) { $status_id = Kanban_Status::insert_id(); // add it to all the statuses to save $_POST['statuses']['saved'][$status_id] = $status; } } } // now save all statuses with positions if (isset($_POST['statuses']['saved'])) { foreach ($_POST['statuses']['saved'] as $status_id => $status) { $status['id'] = $status_id; Kanban_Status::replace($status); } } $estimates = Kanban_Estimate::get_all(); $estimate_ids = array_keys($estimates); // any estimates to delete? if (isset($_POST['estimates']['saved'])) { $deleted_estimates = array_diff($estimate_ids, array_keys($_POST['estimates']['saved'])); if (!empty($deleted_estimates)) { foreach ($deleted_estimates as $key => $id) { Kanban_Estimate::delete(array('id' => $id)); } } } // add new estimates first if (isset($_POST['estimates']['new'])) { foreach ($_POST['estimates']['new'] as $estimate) { // save it $success = Kanban_Estimate::replace($estimate); if ($success) { $estimate_id = Kanban_Estimate::insert_id(); // add it to all the estimates to save $_POST['estimates']['saved'][$estimate_id] = $estimate; } } } // now save all estimates with positions if (isset($_POST['estimates']['saved'])) { foreach ($_POST['estimates']['saved'] as $estimate_id => $estimate) { $estimate['id'] = $estimate_id; Kanban_Estimate::replace($estimate); } } // get current settings $settings = Kanban_Option::get_all_raw(); $settings = Kanban_Utils::build_array_with_id_keys($settings); // save all single settings foreach ($_POST['settings'] as $key => $value) { if (is_array($value)) { $value = serialize($value); } $data = array('name' => $key, 'value' => $value); // see if it's already set $id = Kanban_Utils::find_key_of_object_by_property('name', $key, $settings); if ($id) { $data['id'] = $id; } Kanban_Option::_replace($data); } $url = add_query_arg(array('message' => urlencode(__('Settings saved', Kanban::get_text_domain()))), $_POST['_wp_http_referer']); wp_redirect($url); exit; }
<span class="glyphicon glyphicon-th-large"></span> </button> <button type="button" class="btn btn-default"> <input type="radio" name="view-compact" value="1" autocomplete="off"> <span class="glyphicon glyphicon-align-justify"></span> </button> </div> <a href="<?php echo admin_url('admin.php?page=' . Kanban::$instance->settings->basename); ?> " class="btn btn-default" target="_blank"> <?php echo __('Admin', Kanban::get_text_domain()); ?> </a> </div> <div class="modal fade" id="modal-projects" data-keyboard="false"> <div class="modal-dialog modal-lg" role="document"> <div class="modal-content"> <div class="modal-body"> <button type="button" class=" btn btn-default btn-close" data-dismiss="modal"> Close </button>
?> ][title]" data-name="estimates[new][count][title]" value="<?php echo isset($title) ? $title : ''; ?> "> </label> <label class="estimate-hours"> <?php echo __('Hours', Kanban::get_text_domain()); ?> : <input name="estimates[saved][<?php echo isset($id) ? $id : ''; ?> ][hours]" data-name="estimates[new][count][hours]" value="<?php echo isset($hours) ? strtolower($hours) : '1'; ?> "> </label> <input type="hidden" name="estimates[saved][<?php echo isset($id) ? $id : ''; ?> ][position]" data-name="estimates[new][count][position]" value="<?php echo isset($position) ? sprintf('%03d', $position) : ''; ?> " class="position"> <button type="button" class="delete"><?php echo __('Delete', Kanban::get_text_domain()); ?> </button> </li>
<div class="project"> <input type="text" class="editable-input project_title" data-toggle="dropdown" data-id="{{=ID}}" value="{{=post_title}}" placeholder="<?php _e('Task project', Kanban::get_text_domain()); ?> " readonly> <ul class="list-group" style="display: none;"> <li class="list-group-edit"> <a href="#" class="btn btn-xs" data-toggle="modal" data-target="#modal-projects"> <?php _e('Edit', Kanban::get_text_domain()); ?> </a> </li> </ul> </div>
{{current_user_can_write}} <ul class="list-group" style="display: none;"> <li class="list-group-edit"> <a href="#" class="btn btn-xs btn-edit-projects" data-toggle="modal" data-target="#modal-projects"> <?php _e('Edit', Kanban::get_text_domain()); ?> </a> </li> </ul> {{/current_user_can_write}} </div> <h3 class="h4 wrapper-task-title"> <textarea class="editable-input task_title resize" rows="1" placeholder="<?php _e('Task name', Kanban::get_text_domain()); ?> " readonly>{{=task.title}}</textarea> </h3> <div class="row row-worked"> <div class="col col-xs-4 col-task-hours"> <div class="btn btn-default btn-task-hours"> </div><!-- btn --> {{current_user_can_write}} <div class="btn-group task-hours-operators"> <button type="button" class="btn btn-default btn-sm" value="+{{=settings.hour_interval}}"> <span class="glyphicon glyphicon-plus"></span> </button> <button type="button" class="btn btn-default btn-sm" value="-{{=settings.hour_interval}}"> <span class="glyphicon glyphicon-minus"></span>
/** * add a js script to a kanban template, without using the WordPress queue */ static function add_script() { if (!isset(self::get_instance()->script) || !is_array(self::get_instance()->script)) { return; } foreach (self::get_instance()->script as $handle => $path) { echo sprintf('<script id="%s-js" src="%s?ver=%s"></script>' . "\n", $handle, $path, Kanban::get_instance()->settings->plugin_data['Version']); } }
/** * get the instance of this class * @return object the instance */ public static function get_instance() { if (!self::$instance) { self::$instance = new self(); } return self::$instance; }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title><?php echo __('Kanban for WordPress', Kanban::get_text_domain()); ?> </title> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> <?php Kanban_Template::add_style(); ?> </head> <body>
<div class="btn btn-default btn-work-hours" data-toggle="dropdown"> <small><?php _e('Worked:', Kanban::get_text_domain()); ?> </small> <b class="task-work-hours"> {{=kanban_task_work_hour_count}} </b> </div><!-- btn -->
/** * Add a message to the queue * * @author Mike Everhart * * @param string $type The type of message to add * @param string $message The message * @param string $redirect_to (optional) If set, the user will be redirected to this URL * @return bool * */ public function add($type, $message, $redirect_to = null) { if (!isset($_SESSION['flash_messages'])) { return false; } if (!isset($type) || !isset($message[0])) { return false; } // Replace any shorthand codes with their full version if (strlen(trim($type)) == 1) { $type = str_replace(array('h', 'i', 'w', 'e', 's'), array('help', 'info', 'warning', 'error', 'success'), $type); // Backwards compatibility... } elseif ($type == 'information') { $type = 'info'; } // Make sure it's a valid message type if (!in_array($type, $this->msgTypes)) { die(__('"' . strip_tags($type) . '" is not a valid message type!', Kanban::get_text_domain())); } // If the session array doesn't exist, create it if (!array_key_exists($type, $_SESSION['flash_messages'])) { $_SESSION['flash_messages'][$type] = array(); } $_SESSION['flash_messages'][$type][] = $message; if (!is_null($redirect_to)) { header("Location: {$redirect_to}"); exit; } return true; }
static function admin_init() { $users_field_name = sprintf('%s_user', Kanban::get_instance()->settings->basename); $status_tax_key = Kanban_Utils::format_key('task', 'status'); $status_color_field_name = sprintf('%s_colors', $status_tax_key); $status_order_field_name = sprintf('%s_order', $status_tax_key); $estimate_tax_key = Kanban_Utils::format_key('task', 'estimate'); $estimate_order_field_name = sprintf('%s_order', $estimate_tax_key); $sections = array(array('id' => $users_field_name, 'title' => 'Users'), array('id' => $status_order_field_name, 'title' => 'Status Order'), array('id' => $status_color_field_name, 'title' => 'Status Colors'), array('id' => $estimate_order_field_name, 'title' => 'Estimate Order')); $fields = array(); $fields[$users_field_name] = array(); $all_users = get_users(); $all_users_arr = array(); foreach ($all_users as $user) { $all_users_arr[$user->ID] = Kanban_User::format_user_name($user); } $fields[$users_field_name][] = array('name' => 'allowed_users', 'label' => 'Allowed Users', 'desc' => 'Users who have access to the board', 'type' => 'multicheck', 'options' => $all_users_arr); $statuses_in_order = Kanban_Terms::terms_in_order('task', 'status'); $fields[$status_color_field_name] = array(); foreach ($statuses_in_order as $status) { $fields[$status_color_field_name][] = array('name' => $status->term_id, 'label' => $status->name, 'type' => 'color'); } $fields[$status_order_field_name] = array(); foreach ($statuses_in_order as $status) { $fields[$status_order_field_name][$status->term_id] = array('name' => $status->term_id, 'label' => $status->name, 'type' => 'number'); } $estimates_in_order = Kanban_Terms::terms_in_order('task', 'estimate'); $fields[$estimate_order_field_name] = array(); foreach ($estimates_in_order as $status) { $fields[$estimate_order_field_name][$status->term_id] = array('name' => $status->term_id, 'label' => $status->name, 'type' => 'number'); } self::get_instance()->settings_api = new WeDevs_Settings_API(); //set sections and fields self::get_instance()->settings_api->set_sections($sections); self::get_instance()->settings_api->set_fields($fields); //initialize them self::get_instance()->settings_api->admin_init(); }
/** * get postmeta or terms for array of posts * @param [type] $post_ids_arr [description] * @param [type] $post_type [description] * @return [type] [description] */ static function get_postmeta_for_posts($post_ids_arr, $post_type) { global $wpdb; // build comma-separated string of post id's for sql $post_ids_str = implode(',', $post_ids_arr); // build look up of post meta data by post id $postmeta_fields_str = sprintf('"%s"', implode('","', Kanban::get_instance()->postmeta_fields_list)); // get records $sql = "SELECT `{$wpdb->prefix}postmeta`.*,\n\t\t\t\t`{$wpdb->prefix}posts`.`post_type`\n\t\t\t\tFROM `{$wpdb->prefix}postmeta`\n\t\t\t\tJOIN `{$wpdb->prefix}posts`\n\t\t\t\tON `{$wpdb->prefix}posts`.`ID` = `{$wpdb->prefix}postmeta`.`post_id`\n\t\t\t\tWHERE `{$wpdb->prefix}postmeta`.`post_id` IN ({$post_ids_str})\n\t\t\t\tAND `{$wpdb->prefix}postmeta`.`meta_key` IN ({$postmeta_fields_str})\n\t\t"; $sql = apply_filters(sprintf('%s_sql_get_postmeta_for_posts', Kanban::get_instance()->settings->basename), $sql); $records = $wpdb->get_results($sql); // build postmeta $postmeta = array(); foreach ($records as $record) { if (!isset($postmeta[$record->post_id])) { $postmeta[$record->post_id] = (object) array(); } $postmeta[$record->post_id]->{$record->meta_key} = $record->meta_value; } // add additional blank fields foreach (Kanban::get_instance()->postmeta_fields_list as $field_name) { if (strpos($field_name, $post_type) === FALSE) { continue; } foreach ($post_ids_arr as $post_id) { if (!isset($postmeta[$post_id])) { $postmeta[$post_id] = (object) array(); } if (!isset($postmeta[$post_id]->{$field_name})) { $postmeta[$post_id]->{$field_name} = Kanban::get_instance()->field_defaults[$field_name]; } } } $postmeta = apply_filters(sprintf('%s_postmeta_for_posts', Kanban::get_instance()->settings->basename), $postmeta); return $postmeta; }
static function get_all($sql = NULL) { $table_name = self::table_name(); $worked_table_name = Kanban_Task_Hour::table_name(); $sql = "SELECT tasks.*,\n\t\t\t\tCOALESCE(SUM(worked.hours), 0) 'hour_count'\n\t\t\t\tFROM {$table_name} tasks\n\t\t\t\tLEFT JOIN {$worked_table_name} worked\n\t\t\t\tON tasks.id = worked.task_id\n\t\t\t\tWHERE tasks.is_active = 1\n\t\t\t\tGROUP BY tasks.id\n\t\t;"; $sql = apply_filters(sprintf('%s_sql_%s_get_all', Kanban::get_instance()->settings->basename, self::$slug), $sql); $records = parent::get_all($sql); foreach ($records as $key => $record) { $records[$key]->title = Kanban_Utils::str_for_frontend($records[$key]->title); $records[$key]->description = Kanban_Utils::str_for_frontend($records[$key]->description); } return Kanban_Utils::build_array_with_id_keys($records, 'id'); }
static function enqueue_js($hook) { if (!is_admin() || isset($_GET['page']) && $_GET['page'] != sprintf('%s_settings', Kanban::get_instance()->settings->basename)) { return; } wp_enqueue_style('wp-color-picker'); wp_enqueue_script('jquery-ui', '//code.jquery.com/ui/1.11.4/jquery-ui.js', array()); wp_enqueue_script('t', sprintf('%s/js/t.min.js', Kanban::get_instance()->settings->uri), array()); wp_enqueue_script(sprintf('%s_settings', Kanban::get_instance()->settings->basename), sprintf('%s/js/admin-settings.js', Kanban::get_instance()->settings->uri), array('wp-color-picker'), false, true); }
<?php include Kanban_Template::find_template('inc/header'); ?> <div class="row" style="margin-top: 60px;"> <form action="" method="post" class="col-sm-4 col-sm-offset-4"> <img src="<?php echo Kanban::get_instance()->settings->uri; ?> /img/kanbanwp-logo.png" class="img-responsive" style="margin: 0 auto 30px;"> <?php Kanban_Flash::flash(); ?> <div class="panel panel-default"> <div class="panel-heading"> <?php if (!is_user_logged_in()) { ?> <h2><?php