Beispiel #1
0
 function get_all($group_id)
 {
     global $bp, $wpdb;
     $actions = ' , ' . implode(', ', array_keys(bp_gtm_get_actions('involved', 'all')));
     $sql = "SELECT r.`resp_id` AS `id`, `role_id`, `role_name`, COUNT(DISTINCT r.`task_id`) AS `tasks`{$actions}\n                FROM {$bp->gtm->table_resps} AS r\n                LEFT JOIN {$bp->gtm->table_tasks} ON {$bp->gtm->table_tasks}.`group_id` = r.group_id\n                LEFT JOIN {$bp->gtm->table_roles_caps} ON {$bp->gtm->table_roles_caps}.group_id = r.group_id\n                LEFT JOIN {$bp->gtm->table_roles} ON {$bp->gtm->table_roles}.id = {$bp->gtm->table_roles_caps}.role_id\n                WHERE ({$bp->gtm->table_tasks}.group_id = {$group_id} AND {$bp->gtm->table_tasks}.`done` = 0)\n                GROUP BY r.`resp_id`\n                UNION\n                SELECT r.`resp_id` AS `id`, `role_id`, `role_name`, COUNT(DISTINCT r.`task_id`) AS `tasks`{$actions}\n                FROM {$bp->gtm->table_resps} AS r\n                LEFT JOIN {$bp->gtm->table_projects} ON {$bp->gtm->table_projects}.`group_id` = r.group_id \n                LEFT JOIN {$bp->gtm->table_roles_caps} ON {$bp->gtm->table_roles_caps}.group_id = {$bp->gtm->table_projects}.`group_id`\n                LEFT JOIN {$bp->gtm->table_roles} ON {$bp->gtm->table_roles}.id = {$bp->gtm->table_roles_caps}.role_id\n                WHERE ({$bp->gtm->table_projects}.group_id = {$group_id} AND {$bp->gtm->table_projects}.`done` = 0) AND r.`task_id`=0\n                GROUP BY r.`resp_id`";
     $resps = $wpdb->get_results($wpdb->prepare($sql));
     return $resps;
 }
function bp_gtm_role_actions($role)
{
    echo '<input id="input-' . $role->id . '" type="hidden" name="role[' . $role->id . '][role_id]" value="' . $role->id . '" />';
    echo '<li id="li-' . $role->id . '" class="one">
        #' . $role->id . ': ' . $role->role_name . '  &rarr; <input name="role[' . $role->id . '][role_name]" type="text" value="' . $role->role_name . '" />
        <span class="actions">
            <a id="role-open" rel="' . $role->id . '" class="button" href="">' . __('Permissions', 'bp_gtm') . '</a>
            <a id="role-delete" rel="' . $role->id . '" class="button" href="">' . __('Delete role', 'bp_gtm') . '</a>
        </span>
    </li>
    <div id="toggler">
        <div id="box-' . $role->id . '" class="box">
            <div class="left_block">
                <div class="projects">
                    <p class="role_title">' . __('Projects', 'bp_gtm') . '</p><ul>';
    $actions_project = bp_gtm_get_actions('project', 'all');
    foreach ($actions_project as $action_slug => $action_name) {
        echo '<li>
                                <input type="checkbox" name="role[' . $role->id . '][' . $action_slug . ']" value = "1" ' . bp_gtm_get_checked($role->{$action_slug}, '1') . ' /> ' . $action_name . '
                            </li>';
    }
    echo '</ul></div><!-- /projects -->
                <div class="tasks">
                    <p class="role_title">' . __('Tasks', 'bp_gtm') . '</p><ul>';
    $actions_task = bp_gtm_get_actions('task', 'all');
    foreach ($actions_task as $action_slug => $action_name) {
        echo '<li>
                                <input type="checkbox" name="role[' . $role->id . '][' . $action_slug . ']" value = "1" ' . bp_gtm_get_checked($role->{$action_slug}, '1') . ' /> ' . $action_name . '
                            </li>';
    }
    echo '</ul></div><!-- /tasks -->
                <div class="delete">
                    <p class="role_title">' . __('Delete', 'bp_gtm') . '</p><ul>';
    $actions_delete = bp_gtm_get_actions('delete', 'all');
    foreach ($actions_delete as $action_slug => $action_name) {
        echo '<li>
                                <input type="checkbox" name="role[' . $role->id . '][' . $action_slug . ']" value = "1" ' . bp_gtm_get_checked($role->{$action_slug}, '1') . ' /> ' . $action_name . '
                            </li>';
    }
    echo '</ul></div><!-- /delete -->
            </div><!-- /left_block -->
            <div class="right_block">
                <div class="taxon">
                    <p class="role_title">' . __('Classifier', 'bp_gtm') . '</p><ul>';
    $actions_taxon = bp_gtm_get_actions('taxon', 'all');
    foreach ($actions_taxon as $action_slug => $action_name) {
        echo '<li>
                                <input type="checkbox" name="role[' . $role->id . '][' . $action_slug . ']" value = "1" ' . bp_gtm_get_checked($role->{$action_slug}, '1') . ' /> ' . $action_name . '
                            </li>';
    }
    echo '</ul></div><!-- /taxon -->
                <div class="involved">
                    <p class="role_title">' . __('Involved', 'bp_gtm') . '</p><ul>';
    $actions_involved = bp_gtm_get_actions('involved', 'all');
    foreach ($actions_involved as $action_slug => $action_name) {
        echo '<li>
                                <input type="checkbox" name="role[' . $role->id . '][' . $action_slug . ']" value = "1" ' . bp_gtm_get_checked($role->{$action_slug}, '1') . ' /> ' . $action_name . '
                            </li>';
    }
    echo '</ul></div><!-- /involved -->
                <div class="discuss">
                    <p class="role_title">' . __('Discussions', 'bp_gtm') . '</p><ul>';
    $actions_discuss = bp_gtm_get_actions('discuss', 'all');
    foreach ($actions_discuss as $action_slug => $action_name) {
        echo '<li>
                                <input type="checkbox" name="role[' . $role->id . '][' . $action_slug . ']" value = "1" ' . bp_gtm_get_checked($role->{$action_slug}, '1') . ' /> ' . $action_name . '
                            </li>';
    }
    echo '</ul></div><!-- /discuss -->
             <div class="settings">
                    <p class="role_title">' . __('Settings', 'bp_gtm') . '</p><ul>';
    $actions_settings = bp_gtm_get_actions('settings', 'all');
    foreach ($actions_settings as $action_slug => $action_name) {
        echo '<li>
                                <input type="checkbox" name="role[' . $role->id . '][' . $action_slug . ']" value = "1" ' . bp_gtm_get_checked($role->{$action_slug}, '1') . ' /> ' . $action_name . '
                            </li>';
    }
    echo '</ul></div><!-- /settings -->
            </div><!-- /right_block -->
        </div><!-- /box --><div class"clear"></div>
    </div><!-- /toggler -->';
}