Changeset 1080 for trunk/common
- Timestamp:
- 12/14/09 19:14:17 (2 years ago)
- Location:
- trunk/common
- Files:
-
- 2 edited
-
db/tags.php (modified) (2 diffs)
-
tags.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/common/db/tags.php
r1079 r1080 6 6 // Get list of all tag names, filtered by type and parent 7 7 function tag_get_all($types = null, $parent = null) { 8 $query = "SELECT name, type, parent FROM ia_tags";8 $query = "SELECT id, name, type, parent FROM ia_tags"; 9 9 $where = array(); 10 10 if (!is_null($types)) { … … 97 97 } 98 98 99 // Updates name, type or parent for a tag specified by it's id 100 function tag_update_by_id($tag_id, $tag) { 101 $query = sprintf( 102 "UPDATE ia_tags SET name = %s, type = %s, parent = %s WHERE id = %s", 103 db_quote($tag["name"]), db_quote($tag["type"]), 104 db_quote($tag["parent"]), db_quote($tag_id)); 105 db_query($query); 106 return db_affected_rows() == 1; 107 } 108 109 // Delete a tag identified by it's id 110 function tag_delete_by_id($tag_id) { 111 db_query(sprintf( 112 "DELETE FROM ia_tags WHERE parent = %s", db_quote($tag_id) 113 )); 114 db_query(sprintf("DELETE FROM ia_tags WHERE id = %s", db_quote($tag_id))); 115 return db_affected_rows() == 1; 116 } 117 99 118 // Build ugly where clause to be used in subqueries 100 119 function tag_build_where($obj, $tag_ids, $parent_table = null) { -
trunk/common/tags.php
r1079 r1080 17 17 } 18 18 19 function tag_validate($data, &$errors) { 20 $tags = getattr($data, 'tags'); 19 function tag_validate($data, &$errors, $key = null, $parent_key = null) { 20 if (is_null($key)) { 21 $tag_key = 'tags'; 22 } else { 23 $tag_key = 'tag_'.$key; 24 } 25 $tags = getattr($data, $tag_key); 21 26 if (is_null($tags)) { 22 27 return; … … 25 30 foreach ($tags as $tag) { 26 31 if (!is_tag_name($tag)) { 27 $errors[ 'tags'] = "Cel putin un tag este gresit";32 $errors[$tag_key] = "Cel putin un tag este gresit"; 28 33 return; 34 } 35 } 36 if (count($tags) > 0 && !is_null($parent_key)) { 37 $parent_tag = getattr($data, 'tag_'.$parent_key, ""); 38 if (count(tag_split($parent_tag)) != 1) { 39 $errors['tag_'.$parent_key] = sprintf("Trebuie specificat exact 40 un tag '%s' pentru a specifica taguri '%s'", $parent_key, $key); 29 41 } 30 42 }
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)