Changeset 1077 for trunk/common


Ignore:
Timestamp:
12/13/09 19:17:05 (2 years ago)
Author:
savin.tiberiu@…
Message:

Editing and adding tags to a task.
Reviewed: http://reviewboard.infoarena.ro/r/108/

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/common/tags.php

    r1069 r1077  
    55 
    66function tag_split($tag_data) { 
    7     $tags = explode(",", trim($tag_data)); 
     7    $tags = explode(",", $tag_data); 
     8    array_walk($tags, 'trim'); 
    89    $result = array(); 
    910    foreach ($tags as &$tag) { 
     
    3031} 
    3132 
    32 function tag_build_list($obj, $obj_id, $type) { 
     33function tag_build_list($obj, $obj_id, $type, $remove_prefix = true) { 
    3334    $tag_list = tag_get($obj, $obj_id, $type); 
    3435    $tag_names = array(); 
    3536    foreach ($tag_list as $tag) { 
    36         $tag_names[] = $tag['tag_name']; 
     37        if ($remove_prefix) { 
     38            $tag_parts = explode('@', $tag['tag_name']); 
     39            $tag_names[] = trim($tag_parts[ count($tag_parts) - 1 ]); 
     40        } else { 
     41            $tag_names[] = $tag['tag_name']; 
     42        } 
    3743    } 
    3844    return implode(", ", $tag_names); 
    3945} 
    4046 
    41 function tag_update($obj, $obj_id, $type, $tag_data) { 
     47function tag_update($obj, $obj_id, $type, $tag_data, $tag_prefix = "") { 
    4248    tag_clear($obj, $obj_id, $type); 
    4349    $tag_data = tag_split($tag_data); 
    4450    foreach ($tag_data as $tag_name) { 
    45         $tag_id = tag_assign_id(array("name" => $tag_name, "type" => $type)); 
     51        $tag_id = tag_assign_id(array("name" => $tag_prefix.$tag_name, "type" => $type)); 
    4652        tag_add($obj, $obj_id, $tag_id); 
    4753    } 
Note: See TracChangeset for help on using the changeset viewer.