Exemple #1
0
 function get_elements_4term($term_id)
 {
     global $bp, $wpdb;
     $tasks = $projects = array();
     $temp_tasks = $wpdb->get_results($wpdb->prepare("\n         SELECT `task_id` FROM {$bp->gtm->table_taxon}\n         WHERE `term_id` = %d AND `group_id` = %d", $term_id, $bp->groups->current_group->id));
     foreach ($temp_tasks as $temp_task) {
         if ($temp_task->task_id != null && $temp_task->task_id != '0') {
             $tasks[$temp_task->task_id] = $temp_task->task_id;
             $tasks[$temp_task->task_id] = bp_gtm_get_el_name_by_id($temp_task->task_id, 'task');
         }
     }
     $temp_projects = $wpdb->get_results($wpdb->prepare("\n         SELECT `project_id` FROM {$bp->gtm->table_taxon}\n         WHERE `term_id` = %d AND `group_id` = %d AND `task_id` = 0", $term_id, $bp->groups->current_group->id));
     foreach ($temp_projects as $temp_project) {
         if ($temp_project->project_id != null && $temp_project->project_id != '0') {
             $projects[$temp_project->project_id] = $temp_project->project_id;
             $projects[$temp_project->project_id] = bp_gtm_get_el_name_by_id($temp_project->project_id, 'project');
         }
     }
     $elements['tasks'] = $tasks;
     $elements['projects'] = $projects;
     return $elements;
 }
function bp_gtm_filter_short_links($content)
{
    global $bp;
    $gtm_link = bp_get_group_permalink() . $bp->gtm->slug . '/';
    $i = $j = 0;
    if (preg_match_all('~([#]+([TP])(\\d+))~', $content, $data, PREG_SET_ORDER)) {
        $content = strip_tags($content, '<p>');
        // prevent duplicate <a> tags in comments
        $content = nl2br($content);
        //print_var($data);
        foreach ((array) $data as $match) {
            if ($match[2] == 'T') {
                $name = bp_gtm_get_el_name_by_id($match[3], 'task');
                if (!$name) {
                    $name = __('doesn\'t exist', 'bp_gtm');
                    $color = 'color-red';
                }
                if (!$i) {
                    /// prevent duplicate <a> tags in comments
                    $content = str_replace($match[1], '<a class="' . $color . '" href="' . $gtm_link . 'tasks/view/' . $match[3] . '" title="' . __('Task:', 'bp_gtm') . ' ' . $name . '">' . $match[1] . '</a>', $content);
                }
                $i++;
            } elseif ($match[2] == 'P') {
                $name = bp_gtm_get_el_name_by_id($match[3], 'project');
                if (!$name) {
                    $name = __('doesn\'t exist', 'bp_gtm');
                    $color = 'color-red';
                }
                if (!$j) {
                    /// prevent duplicate <a> tags in comments
                    $content = str_replace($match[1], '<a class="' . $color . '" href="' . $gtm_link . 'projects/view/' . $match[3] . '" title="' . __('Project:', 'bp_gtm') . ' ' . $name . '">' . $match[1] . '</a>', $content);
                }
                $j++;
            }
        }
    }
    return $content;
}
function bp_gtm_group_activity($args = '')
{
    global $bp;
    $bp_gtm = get_option('bp_gtm');
    if ($bp_gtm['display_activity'] == 'off') {
        return false;
    }
    $defaults = array('content' => false, 'user_id' => $bp->loggedin_user->id, 'group_id' => $bp->groups->current_group->id, 'elem_id' => false, 'elem_type' => 'task', 'elem_name' => false);
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    $bp->groups->current_group = new BP_Groups_Group($group_id);
    /* Be sure the user is a member of the group before posting. */
    if (!is_super_admin() && !groups_is_user_member($user_id, $group_id)) {
        return false;
    }
    if ($elem_type == 'project') {
        $activity_action = sprintf(__('%s created the project - %s', 'bp_gtm'), bp_core_get_userlink($user_id), '<a href="' . bp_get_group_permalink($bp->groups->current_group) . $bp->gtm->slug . '/projects/view/' . $elem_id . '">' . bp_gtm_get_el_name_by_id($elem_id, $elem_type) . '</a>');
        $activity_type = 'created_project';
    } elseif ($elem_type == 'task') {
        $activity_action = sprintf(__('%s created the task - %s', 'bp_gtm'), bp_core_get_userlink($user_id), '<a href="' . bp_get_group_permalink($bp->groups->current_group) . $bp->gtm->slug . '/tasks/view/' . $elem_id . '">' . bp_gtm_get_el_name_by_id($elem_id, $elem_type) . '</a>');
        $activity_type = 'created_task';
    } else {
        if ($bp_gtm['display_activity_discuss'] == 'off') {
            return false;
        }
        // $elem_type =  'discuss_tasks_' . $_POST['task_id'];
        $discuss = explode('_', $elem_type);
        if ($discuss[1] == 'tasks') {
            $activity_action = sprintf(__('%s posted a comment to the task %s', 'bp_gtm'), bp_core_get_userlink($user_id), '<a href="' . bp_get_group_permalink($bp->groups->current_group) . $bp->gtm->slug . '/' . $discuss[1] . '/view/' . $discuss[2] . '#post-' . $elem_id . '">' . bp_gtm_get_el_name_by_id($discuss[2], $discuss[1]) . '</a>');
        } elseif ($discuss[1] == 'projects') {
            $activity_action = sprintf(__('%s posted a comment to the project %s', 'bp_gtm'), bp_core_get_userlink($user_id), '<a href="' . bp_get_group_permalink($bp->groups->current_group) . $bp->gtm->slug . '/' . $discuss[1] . '/view/' . $discuss[2] . '#post-' . $elem_id . '">' . bp_gtm_get_el_name_by_id($discuss[2], $discuss[1]) . '</a>');
        }
        $activity_type = 'created_discuss';
    }
    $hide_sitewide = $bp->groups->current_group->status != 'private' || $bp->groups->current_group->status != 'hidden' ? TRUE : FALSE;
    /* Record this in activity streams */
    $activity_id = groups_record_activity(array('user_id' => $user_id, 'action' => apply_filters('bp_gtm_activity_new_elem_action', $activity_action), 'content' => apply_filters('bp_gtm_activity_new_elem_content', $activity_content), 'type' => $activity_type, 'component' => $bp->groups->id, 'item_id' => $group_id, 'secondary_item_id' => $elem_id, 'hide_sitewide' => $hide_sitewide));
    /* Require the notifications code so email notifications can be set on the 'bp_activity_posted_update' action. */
    require_once BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php';
    groups_update_groupmeta($group_id, 'last_activity', gmdate("Y-m-d H:i:s"));
    do_action('bp_groups_posted_update', $content, $user_id, $group_id, $activity_id);
    return $activity_id;
}
function bp_gtm_view_disscuss_link($id, $gtm_link, $type)
{
    ?>
        <a class="topic-title" href="<?php 
    echo $gtm_link . $type . '/view/' . $id;
    ?>
" title="<?php 
    _e('Permalink', 'bp_gtm');
    ?>
">
            <?php 
    echo bp_gtm_get_el_name_by_id($id, $type);
    ?>
        </a>
    <?php 
}
Exemple #5
0
    do_action('bp_gtm_task_after_content', $task['0'], 'task', false);
    ?>
    </div>
    <div class="pagination no-ajax">
        <div id="post-count" class="pag-count">
            <?php 
    bp_gtm_task_terms($task['0']->id, 'tag', true);
    ?>
 | <?php 
    bp_gtm_task_terms($task['0']->id, 'cat', true);
    ?>
            <?php 
    if ($task['0']->project_id != '0') {
        echo ' | ';
        _e('Project: ', 'bp_gtm');
        bp_gtm_view_link($task['0']->project_id, bp_gtm_get_el_name_by_id($task['0']->project_id, 'project'), $gtm_link, 'project');
    }
    ?>
        </div>
        <div class="pagination-links" id="topic-pag">
            <p><?php 
    _e('Deadline', 'bp_gtm');
    echo ': ' . bp_gtm_get_format_date($task['0']->deadline);
    ?>
</p>
        </div>
    </div>

    <div class="subtasks"></div>

    <?php