Changeset 2634 for trunk/admin/include/functions.php
- Timestamp:
- Oct 1, 2008, 11:08:51 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions.php
r2588 r2634 1817 1817 } 1818 1818 1819 function create_tag($tag_name) 1820 { 1821 $tag_name = mysql_real_escape_string($tag_name); 1822 1823 // does the tag already exists? 1824 $query = ' 1825 SELECT id 1826 FROM '.TAGS_TABLE.' 1827 WHERE name = \''.$tag_name.'\' 1828 ;'; 1829 $existing_tags = array_from_query($query, 'id'); 1830 1831 if (count($existing_tags) == 0) 1832 { 1833 mass_inserts( 1834 TAGS_TABLE, 1835 array('name', 'url_name'), 1836 array( 1837 array( 1838 'name' => $tag_name, 1839 'url_name' => str2url($tag_name), 1840 ) 1841 ) 1842 ); 1843 1844 $inserted_id = mysql_insert_id(); 1845 1846 return array( 1847 'info' => sprintf( 1848 l10n('Tag "%s" was added'), 1849 stripslashes($tag_name) 1850 ), 1851 'id' => $inserted_id, 1852 ); 1853 } 1854 else 1855 { 1856 return array( 1857 'error' => sprintf( 1858 l10n('Tag "%s" already exists'), 1859 stripslashes($tag_name) 1860 ) 1861 ); 1862 } 1863 } 1819 1864 ?>
Note: See TracChangeset
for help on using the changeset viewer.