Пример #1
0
 /**
  * Projects page
  * list, create, edit or delete project
  */
 public function page_projects()
 {
     $this->options = get_option('tfk_options');
     $this->linkadmin = '?page=taskfreak_projects';
     $this->linkfront = add_query_arg('mode', 'projects', $this->options['page_url']);
     $this->is_manager = tfk_user::check_role('editor');
     if (empty($_REQUEST['id'])) {
         // list projects by default
         // author, editor and admin
         $this->call('admin/project_list.php');
     } else {
         if ($this->is_manager) {
             // only editor and admin can add/edit projects (any projects)
             $this->call('admin/project_edit.php');
         }
     }
 }
Пример #2
0
 /** 
  * check user acces
  */
 public function check_access($what = 'read', $user_id = null)
 {
     $what = 'who_' . $what;
     if (empty($user_id)) {
         $user = wp_get_current_user();
     } else {
         $user = get_user_by('id', $user_id);
     }
     if ($r = $this->get($what)) {
         if (tfk_user::check_role($r, $user)) {
             // all is good
             return true;
         } else {
             // current user does not have sufficient role
             return false;
         }
     } else {
         // no specific role required (public)
         return true;
     }
 }
Пример #3
0
            if (!empty($update_log_info)) {
                $update_log->set('info', implode(',', $update_log_info));
                $update_log->save();
            }
        }
        if (!$this->data->errors['file']) {
            if (headers_sent()) {
                $this->data->load();
                $this->data->errors['global_errors'] = '<p class="tfk_ok">' . __('Changes saved.', 'taskfreak') . '</p>';
            } else {
                wp_redirect(remove_query_arg(array('edit', 'noheader'), add_query_arg('view', $this->pid) . "#tfk_task_title"));
                exit;
            }
        }
    }
} elseif (preg_match('/noheader=1/', $_SERVER['REQUEST_URI'])) {
    echo '<p class="tfk_err">' . __('Upload failed. Check file size.', 'taskfreak') . '</p>';
    return;
}
// --- DISPLAY FORM (prepare data) -----
// load attachments
$this->file = new tfk_item_file();
$this->file->load_list(array('where' => 'item_id = ' . $this->pid . ' AND file_tags = "task"'));
// load projects
$this->projects = new tfk_project_info();
$this->projects->load_list(array('where' => tfk_user::get_roles_sql('who_post') . ' AND trashed = 0 ', 'having' => 'project_status_action_code IN (20, 30)', 'order' => 'name ASC'));
// load users
$this->users = get_users();
// for status list
$this->status = new tfk_item_status();
$this->view('front/edit.php');
Пример #4
0
 function __construct()
 {
     parent::__construct();
 }
Пример #5
0
}
if (isset($_REQUEST['filter'])) {
    $this->filter = $_REQUEST['filter'];
    // check filter
    switch ($_REQUEST['filter']) {
        case 'trash':
            if ($this->is_manager) {
                $where = 'trashed=1';
                break;
            }
        case 'draft':
            if ($this->is_manager) {
                $where .= " AND project_status.action_code='0'";
                break;
            }
        default:
            if ($f = intval($_REQUEST['filter'])) {
                $where .= " AND project_status.action_code='{$f}'";
            } else {
                $this->filter = 'all';
                // all or invalid
            }
            break;
    }
}
$where .= ' AND ' . tfk_user::get_roles_sql('who_read');
$this->data = new tfk_project_info();
$this->data->load_list(array('where' => $where, 'order' => 'project_status_action_code ASC, project_id DESC', 'page_size' => 10, 'page' => empty($_REQUEST['pg']) ? 1 : $_REQUEST['pg']));
wp_register_style('tznadmincss', plugins_url('css/admin.css', TFK_ROOT_FILE));
wp_enqueue_style('tznadmincss');
$this->view('admin/project_list.php');
Пример #6
0
$sort_params = array('priority', 'deadline_date', 'proximity', 'title', 'name', 'display_name', 'log_date', 'item_status_action_code', 'comment_count', 'file_count');
$sort = isset($_REQUEST['sort']) && in_array($_REQUEST['sort'], $sort_params) ? $_REQUEST['sort'] : 'proximity';
$order = isset($_REQUEST['ord']) && in_array($_REQUEST['ord'], array('asc', 'desc')) ? $_REQUEST['ord'] : 'ASC';
$this->page = isset($_REQUEST['pg']) && preg_match('/^\\d+$/', $_REQUEST['pg']) ? $_REQUEST['pg'] : 1;
if (isset($_REQUEST['npg']) && preg_match('/^\\d+$/', $_REQUEST['npg'])) {
    // useful if JS is disabled
    if (!headers_sent()) {
        setcookie('tfk_page_size', $_REQUEST['npg']);
    }
    $this->page_size = $_REQUEST['npg'];
} elseif (isset($_COOKIE['tfk_page_size']) && preg_match('/^\\d+$/', $_COOKIE['tfk_page_size'])) {
    $this->page_size = $_COOKIE['tfk_page_size'];
} elseif ($this->options['tasks_per_page']) {
    $this->page_size = $this->options['tasks_per_page'];
} else {
    $this->page_size = 5;
}
// show "new task" or not
$project = new tfk_project();
$this->user_can_post = $project->load_count(array('where' => tfk_user::get_roles_sql('who_post') . ' AND trashed = 0'));
// show only drafts to their author and to users who have the right to manage the project
if (is_user_logged_in()) {
    $current_user = wp_get_current_user();
    $can_see_drafts = '( item_status_action_code <> 0 OR item.author_id = ' . $current_user->ID . ' )';
} else {
    $can_see_drafts = 'item_status_action_code <> 0';
}
$this->data->load_list(array('where' => tfk_user::get_roles_sql('who_read') . ' AND trashed = 0', 'having' => $can_see_drafts . ($this->filters['filter_task'] == 'all' ? '' : ' AND item_status_action_code = ' . $this->filters['filter_task']), 'order' => $sort . ' ' . $order . ', priority ASC', 'page_size' => $this->page_size, 'page' => $this->page, 'count' => true));
$this->npages = ceil($this->data->total() / $this->page_size);
$this->prio_size = !empty($this->options['prio_size']);
$this->view('front/task_list.php');
Пример #7
0
    echo $this->linktsk;
    ?>
"><?php 
    _e('Start working!', 'taskfreak');
    ?>
</a>
					<ul>
						<li><a href="<?php 
    echo $this->linkupd;
    ?>
" class="welcome-icon welcome-view-site"><?php 
    _e('Recent updates', 'taskfreak');
    ?>
</a></li>
						<?php 
    if (tfk_user::check_role('editor')) {
        ?>
						<li><a href="<?php 
        echo $this->linkprj;
        ?>
" class="welcome-icon welcome-widgets-menus"><?php 
        _e('Manage projects', 'taskfreak');
        ?>
</a></li>
						<?php 
    }
    ?>
						<li><a href="http://www.taskfreak.com" class="welcome-icon welcome-learn-more" target="_blank"><?php 
    _e('Learn more about TFWP', 'taskfreak');
    ?>
</a></li>
Пример #8
0
<?php

/*
@package TaskFreak
@since 0.1
@version 1.0
List user's project
*/
$this->baselink = add_query_arg('mode', 'projects', tzn_tools::baselink());
$this->data = new tfk_project_info();
if ($this->filters['filter_project'] == 'all') {
    $sql = array('where' => tfk_user::get_roles_sql('who_read') . ' AND trashed=0');
    if (!current_user_can('manage_options')) {
        $sql['having'] = 'project_status_action_code <> 0';
    }
    $this->data->load_list($sql);
} else {
    $this->data->load_list(array('where' => tfk_user::get_roles_sql('who_read') . ' AND trashed=0', 'having' => 'project_status_action_code=' . intval($this->filters['filter_project'])));
}
$this->view('front/project_list.php');
Пример #9
0
        $this->tskusr[$k] = $c;
    }
}
// All tasks
$this->tskall = array(20 => 0, 30 => 0, 60 => 0);
foreach ($this->tskall as $k => $v) {
    $lst = new tfk_item_info();
    if ($c = $lst->load_list(array('where' => 'trashed=0', 'having' => 'item_status_action_code = ' . $k))) {
        $this->tskall[$k] = $c;
    }
}
// User projects
$this->prjusr = array(20 => 0, 30 => 0, 60 => 0);
foreach ($this->prjusr as $k => $v) {
    $lst = new tfk_project_info();
    if ($c = $lst->load_list(array('where' => tfk_user::get_roles_sql('who_read') . ' AND trashed=0', 'having' => 'project_status_action_code=' . $k))) {
        $this->prjusr[$k] = $c;
    }
}
// All projects
$this->prjall = array(20 => 0, 30 => 0, 60 => 0);
foreach ($this->prjall as $k => $v) {
    $lst = new tfk_project_info();
    if ($c = $lst->load_list(array('where' => 'trashed=0', 'having' => 'project_status_action_code=' . $k))) {
        $this->prjall[$k] = $c;
    }
}
// View
wp_register_style('tznadmincss', plugins_url('css/admin.css', TFK_ROOT_FILE));
wp_enqueue_style('tznadmincss');
$this->view('admin/dashboard.php');
Пример #10
0
    /**
     * (non-PHPdoc)
     * @see tzn_model::load_list()
     */
    public function load_list($args = null)
    {
        $sql = array('sql' => 'SELECT log.*,
					user.display_name,
					IF (log.item_id = 0, "project", "task") AS type, 
					IFNULL(title, project.name) AS title_or_name,
					IFNULL(item.creation_date, project.creation_date) AS creation_date,
					IFNULL(who_read,
						(SELECT who_read FROM ' . $this->db_table('project') . ' WHERE project_id = item.project_id LIMIT 1)
					) AS who_read,
					IF( log.project_id = 0,
						(SELECT action_code FROM ' . $this->db_table() . '
						 WHERE item_id = item.item_id
						 AND action_code <> ""
						 AND comment_id = 0
						 ORDER BY log_date DESC LIMIT 1),
						(SELECT action_code FROM ' . $this->db_table() . '
						 WHERE project_id = project.project_id
						 AND action_code <> ""
						 AND comment_id = 0
						 ORDER BY log_date DESC limit 1)
					) AS status
					FROM ' . $this->db_table() . ' AS log
					LEFT JOIN ' . $this->db_table('item') . ' AS item ON item.item_id = log.item_id
					LEFT JOIN ' . $this->db_table('project') . ' AS project ON project.project_id = log.project_id
					LEFT JOIN ' . $this->db->base_prefix . 'users AS user ON user.ID = log.user_id', 'where' => '(log.item_id <> 0 OR project.trashed = 0)', 'having' => tfk_user::get_roles_sql('who_read') . ' AND status > 0', 'order' => 'log_date DESC');
        if (isset($args['where'])) {
            $sql['where'] .= ' AND ' . $args['where'];
        }
        return parent::load_list($sql);
    }