/** * 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'); } } }
/** * 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; } }
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>