Changeset 10980 for extensions/SmartAlbums/include/functions.inc.php
- Timestamp:
- May 21, 2011, 6:16:47 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/SmartAlbums/include/functions.inc.php
r10871 r10980 7 7 * @return array 8 8 */ 9 function SmartAlbums_make_associations($cat_id)9 function smart_make_associations($cat_id) 10 10 { 11 11 pwg_query("DELETE FROM ".IMAGE_CATEGORY_TABLE." WHERE category_id = ".$cat_id." AND smart = true;"); 12 12 13 $images = SmartAlbums_get_pictures($cat_id); 14 $dbfields = array('image_id', 'category_id', 'smart'); 13 $images = smart_get_pictures($cat_id); 15 14 16 15 if (count($images) != 0) … … 24 23 ); 25 24 } 26 mass_inserts_ignore(IMAGE_CATEGORY_TABLE, $dbfields, $datas); 25 mass_inserts_ignore( 26 IMAGE_CATEGORY_TABLE, 27 array_keys($datas[0]), 28 $datas 29 ); 30 set_random_representant(array($cat_id)); 27 31 } 28 32 … … 37 41 * @return array 38 42 */ 39 function SmartAlbums_get_pictures($cat_id, $filters = null)43 function smart_get_pictures($cat_id, $filters = null) 40 44 { 41 45 global $conf; … … 165 169 166 170 /** 171 * Check if the filter is proper 172 * 173 * @param array filter 174 * @return array or false 175 */ 176 function smart_check_filter($filter) 177 { 178 global $limit_is_set, $page; 179 $error = false; 180 181 # tags 182 if ($filter['type'] == 'tags') 183 { 184 if ($filter['value'] == null) // tags fields musn't be null 185 { 186 $error = true; 187 array_push($page['errors'], l10n('No tag selected')); 188 } 189 else 190 { 191 $filter['value'] = implode(',', get_fckb_tag_ids($filter['value'])); 192 } 193 } 194 # date 195 else if ($filter['type'] == 'date') 196 { 197 if (!preg_match('#([0-9]{4})-([0-9]{2})-([0-9]{2})#', $filter['value'])) // dates must be proper 198 { 199 $error = true; 200 array_push($page['errors'], l10n('Date string is malformed')); 201 } 202 } 203 # limit 204 else if ($filter['type'] == 'limit') 205 { 206 if (!preg_match('#([0-9]{1,})#', $filter['value'])) // limit must be an integer 207 { 208 $error = true; 209 array_push($page['errors'], l10n('Limit must be an integer')); 210 } 211 else if ($limit_is_set == true) // only one limit is allowed, first is saved 212 { 213 $error = true; 214 array_push($page['errors'], l10n('You can\'t use more than one limit')); 215 } 216 else 217 { 218 $limit_is_set = true; 219 } 220 } 221 222 # out 223 if ($error == false) 224 { 225 return $filter; 226 } 227 else 228 { 229 return false; 230 } 231 } 232 233 234 /** 167 235 * inserts multiple lines in a table, ignore duplicate entries 168 236 *
Note: See TracChangeset
for help on using the changeset viewer.