Example #1
0
<?php

$tags = BP_GTM_Taxon::get_terms_in_group($bp->groups->current_group->id, 'tag');
$cats = BP_GTM_Taxon::get_terms_in_group($bp->groups->current_group->id, 'cat');
?>
<h4><?php 
_e('Tags and Categories', 'bp_gtm');
?>
 
    <?php 
if (bp_gtm_check_access('taxon_create')) {
    ?>
        &rarr; <a class="button" id="open" href="#"><?php 
    _e('Create new', 'bp_gtm');
    ?>
</a>
    </h4>
    <div id="toggler" class="add-new12">
        <div id="box">
            <p>
                <label for="term_name"><?php 
    _e('New term name', 'bp_gtm');
    ?>
</label>
                <input name="term_name" type="text" value="" id="term_name" />
            </p>
            <p>
                <label for="term_taxon"><?php 
    _e('What\'s this?', 'bp_gtm');
    ?>
</label>
function bp_gtm_get_allcount($group_id = false, $type = 'all')
{
    global $bp, $wpdb;
    if ($type == 'all') {
        if ($group_id != false) {
            $count['cats'] = count(BP_GTM_Taxon::get_terms_in_group($group_id, 'cat'));
            $count['tags'] = count(BP_GTM_Taxon::get_terms_in_group($group_id, 'tag'));
            $count['projects'] = $wpdb->get_var($wpdb->prepare("\n                              SELECT COUNT(DISTINCT `id`) FROM " . $bp->gtm->table_projects . " WHERE `group_id` = '%d'", $group_id));
            $count['tasks'] = $wpdb->get_var($wpdb->prepare("\n                              SELECT COUNT(DISTINCT `id`) FROM " . $bp->gtm->table_tasks . " WHERE `group_id` = '%d'", $group_id));
        } else {
            // no matter in which group
            $count['cats'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(DISTINCT `id`) FROM " . $bp->gtm->table_terms . " WHERE `taxon` = 'cat'"));
            $count['tags'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(DISTINCT `id`) FROM " . $bp->gtm->table_terms . " WHERE `taxon` = 'tag'"));
            $count['projects'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(DISTINCT `id`) FROM " . $bp->gtm->table_projects));
            $count['tasks'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(DISTINCT `id`) FROM " . $bp->gtm->table_tasks));
        }
    } elseif ($type == 'tags') {
        if ($group_id != false) {
            $count['tags'] = count(BP_GTM_Taxon::get_terms_in_group($group_id, 'tag'));
        } else {
            // no matter in which group
            $count['tags'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(DISTINCT `id`) FROM " . $bp->gtm->table_terms . " WHERE `taxon` = 'tag'"));
        }
    } elseif ($type == 'cats') {
        if ($group_id != false) {
            $count['cats'] = count(BP_GTM_Taxon::get_terms_in_group($group_id, 'cat'));
        } else {
            // no matter in which group
            $count['cats'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(DISTINCT `id`) FROM " . $bp->gtm->table_terms . " WHERE `taxon` = 'cat'"));
        }
    } elseif ($type == 'tasks') {
        if ($group_id != false) {
            $count['tasks'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(DISTINCT `id`) FROM " . $bp->gtm->table_tasks . " WHERE `group_id` = '%d'", $group_id));
        } else {
            // no matter in which group
            $count['tasks'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(DISTINCT `id`) FROM " . $bp->gtm->table_tasks));
        }
    } elseif ($type == 'projects') {
        if ($group_id != false) {
            $count['projects'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(DISTINCT `id`) FROM " . $bp->gtm->table_projects . " WHERE `group_id` = '%d'", $group_id));
        } else {
            // no matter in which group
            $count['projects'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(DISTINCT `id`) FROM " . $bp->gtm->table_projects));
        }
    }
    if (!$count['tags']) {
        $count['tags'] = '0';
    }
    if (!$count['cats']) {
        $count['cats'] = '0';
    }
    if (!$count['projects']) {
        $count['projects'] = '0';
    }
    if (!$count['tasks']) {
        $count['tasks'] = '0';
    }
    return $count;
}
Example #3
0
 /**
  * Insert new term (tag or category in database)
  * @param string/array $term_manes string with terms adding by ajax autocompliter
  * @param string/array $task_tags string comma separated new terms
  * @param int $project_id id of terms project 
  * @param int $group_id  id of terms group 
  * @param string $term_type this is tag or cat
  * @return bool true if insert are success and false if not
  */
 protected function bp_gtm_insert_term($term_manes, $task_tags, $project_id = 0, $term_type = 'tag', $task_id = 0, $existing_terms = array())
 {
     global $wpdb, $bp;
     if (!is_array($term_manes) && !is_array($task_tags)) {
         $tags = $this->bp_gtm_split_string($term_manes, $task_tags);
         /// split terms into array of values
         if (!empty($existing_terms)) {
             $tags = array_unique(array_merge($tags, $existing_terms));
         }
     } else {
         if (empty($term_manes)) {
             $term_manes = array();
         }
         if (empty($task_tags)) {
             $task_tags = array();
         }
         $tags = array_unique(array_merge($term_manes, $task_tags));
     }
     if (!empty($tags)) {
         foreach ($tags as $tag) {
             $tag_id = BP_GTM_Taxon::get_term_id_by_name($tag, $term_type);
             if (bp_gtm_is_belong_2group(bp_get_current_group_id(), $tag_id, $term_type) != 1) {
                 $wpdb->query($wpdb->prepare("\n                    INSERT INTO " . $bp->gtm->table_terms . " ( `name`, `group_id`, `taxon` )\n                    VALUES ( %s, %d, '{$term_type}')\n                    ", $tag, bp_get_current_group_id()));
                 $tag_id = $wpdb->insert_id;
             }
             $wpdb->query($wpdb->prepare("\n                INSERT INTO " . $bp->gtm->table_taxon . " ( `task_id`, `project_id`, `group_id`, `term_id`, `taxon` )\n                VALUES ( %d, %d, %d, %d, '{$term_type}')\n                ", $task_id, $project_id, bp_get_current_group_id(), $tag_id));
         }
         return TRUE;
     } else {
         return FALSE;
     }
 }
function bp_gtm_get_task_cats($task_id)
{
    $tags = '';
    $terms = BP_GTM_Taxon::get_terms_4task(bp_get_current_group_id(), $task_id, 'tag');
    if (!empty($terms)) {
        foreach ($terms as $tag) {
            if ($tag['used'] == '1') {
                $tags .= '|' . stripslashes($tag['name']);
            }
        }
    }
    return $tags;
}
Example #5
0
function bp_gtm_get_term_name_by_id($term_id, $link = false, $count = false)
{
    global $bp;
    $term_name = BP_GTM_Taxon::get_term_name_by_id($term_id);
    if ($link == true && $count == true) {
        $pre_term = '<a href="' . bp_get_group_permalink() . $bp->gtm->slug . '/terms/view/' . $term_id . '" title="' . sprintf(_n('%d element', '%d elements', bp_gtm_count_term_usage($term_id, $bp->groups->current_group->id), 'bp_gtm'), bp_gtm_count_term_usage($term_id, $bp->groups->current_group->id)) . '">';
        $post_term = '</a>';
    } elseif ($link == false && $count == true) {
        $pre_term = '<span title="' . bp_gtm_count_term_usage($term_id, $bp->groups->current_group->id) . '"';
        $post_term = '</span>';
    } elseif ($link == true && $count == false) {
        $pre_term = '<a href="' . bp_get_group_permalink() . $bp->gtm->slug . '/terms/view/' . $term_id . '" title="' . __('Tasks and projects with this term', 'bp_gtm') . '">';
        $post_term = '</a>';
    } elseif ($link == false && $count == false) {
        $pre_term = '';
        $post_term = '';
    }
    $term = $pre_term . $term_name . $post_term;
    return $term;
}
Example #6
0
<h4><?php 
printf(__('View tasks and projects for <i>"%s"</i>', 'bp_gtm'), BP_GTM_Taxon::get_term_name_by_id($bp->action_variables[2]));
?>
</h4>

<?php 
do_action('bp_before_gtm_term_view');
?>

<?php 
$elements = BP_GTM_Taxon::get_elements_4term($bp->action_variables[2]);
$gtm_link = bp_get_group_permalink() . $bp->gtm->slug . '/';
//var_dump($gtm_link); die;
?>
<p>&nbsp;</p>
<?php 
if (count($elements['tasks']) && !$elements['tasks']['0']) {
    ?>
    <table class="forum zebra table-left">
        <thead>
            <tr>
                <th id="th-title"><?php 
    _e('Task Name', 'bp_gtm');
    ?>
</th>
                <th id="th-postcount">
                    <?php 
    _e('Done?', 'bp_gtm');
    ?>
                </th>
            </tr>