Beispiel #1
0
<?php

// Exit if accessed directly
if (!defined('ABSPATH')) {
    exit;
}
Kanban_Board::init();
class Kanban_Board
{
    static $slug = 'board';
    static function init()
    {
        add_filter('template_include', array(__CLASS__, 'send_page_data_to_template'), 100);
        // must be higher than template
    }
    /**
     * 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)
    {
        if (!isset(Kanban_Template::get_instance()->slug) || Kanban_Template::get_instance()->slug != self::$slug) {
            return $template;
        }
        global $wp_query;
        $wp_query->query_vars['kanban'] = (object) array();
        $wp_query->query_vars['kanban']->board = (object) array();
        // // get all data for the javascript
        $wp_query->query_vars['kanban']->board->allowed_users = Kanban_User::get_allowed_users();
        $wp_query->query_vars['kanban']->board->estimates = Kanban_Terms::terms_in_order('task', 'estimate');
Beispiel #2
0
 /**
  * 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;
 }
Beispiel #3
0
 static function add_defaults()
 {
     global $wpdb;
     $status_table = Kanban_Status::table_name();
     $sql = "SELECT count(`id`)\n\t\t\t\tFROM `{$status_table}`\n\t\t;";
     $status_count = $wpdb->get_var($sql);
     if ($status_count == 0) {
         $statuses = array('Backlog' => '#8224e3', 'Ready' => '#eeee22', 'In progress' => '#81d742', 'QA' => '#f7a738', 'Done' => '#1e73be', 'Archive' => '#333333');
         $i = 0;
         foreach ($statuses as $status => $color) {
             $data = array('title' => $status, 'color_hex' => $color, 'position' => $i);
             Kanban_Status::replace($data);
             $i++;
         }
     }
     $estimate_table = Kanban_Estimate::table_name();
     $sql = "SELECT count(`id`)\n\t\t\t\tFROM `{$estimate_table}`\n\t\t;";
     $estimate_count = $wpdb->get_var($sql);
     if ($estimate_count == 0) {
         $estimates = array('2' => '2h', '4' => '4h', '8' => '1d', '16' => '2d', '32' => '4d');
         $i = 0;
         foreach ($estimates as $hours => $title) {
             $data = array('title' => $title, 'hours' => $hours, 'position' => $i);
             Kanban_Estimate::replace($data);
             $i++;
         }
     }
     $boards_table = Kanban_Board::table_name();
     $sql = "SELECT count(`id`)\n\t\t\t\tFROM `{$boards_table}`\n\t\t;";
     $boards_count = $wpdb->get_var($sql);
     if ($boards_count == 0) {
         $data = array('title' => 'Your first kanban board', 'created_dt_gmt' => Kanban_Utils::mysql_now_gmt(), 'modified_dt_gmt' => Kanban_Utils::mysql_now_gmt(), 'user_id_author' => get_current_user_id(), 'is_active' => 1);
         Kanban_Board::replace($data);
     }
     $tasks_table = Kanban_Board::table_name();
     $sql = "SELECT count(`id`)\n\t\t\t\tFROM `{$tasks_table}`\n\t\t;";
     $tasks_count = $wpdb->get_var($sql);
     if ($tasks_count == 0) {
         $sql = "SELECT `id`\n\t\t\t\t\tFROM `{$boards_table}`\n\t\t\t\t\tLIMIT 1\n\t\t\t;";
         $board_id = $wpdb->get_var($sql);
         $data = array('title' => 'Your first task', 'board_id' => $board_id, 'created_dt_gmt' => Kanban_Utils::mysql_now_gmt(), 'modified_dt_gmt' => Kanban_Utils::mysql_now_gmt(), 'user_id_author' => get_current_user_id(), 'is_active' => 1);
         Kanban_Board::replace($data);
     }
     $options_table = Kanban_Option::table_name();
     $sql = "SELECT *\n\t\t\t\tFROM `{$options_table}`\n\t\t;";
     $options = $wpdb->get_results($sql);
     $options_arr = array();
     foreach ($options as $option) {
         $options_arr[$option->name] = $option->value;
     }
     $defaults = Kanban_Option::get_defaults();
     foreach ($defaults as $name => $value) {
         if (isset($options_arr[$name])) {
             continue;
         }
         $data = array('name' => $name, 'value' => $value);
         Kanban_Option::replace($data);
     }
 }