Changeset 17669 for trunk/admin/include/functions.php
- Timestamp:
- Aug 30, 2012, 2:54:29 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions.php
r17424 r17669 1197 1197 * @return array with ('info' and 'id') or ('error') key 1198 1198 */ 1199 function create_virtual_category($category_name, $parent_id=null )1199 function create_virtual_category($category_name, $parent_id=null, $options=array()) 1200 1200 { 1201 1201 global $conf, $user; … … 1206 1206 return array('error' => l10n('The name of an album must not be empty')); 1207 1207 } 1208 1209 $parent_id = !empty($parent_id) ? $parent_id : 'NULL'; 1210 1208 1211 1209 $insert = array( 1212 1210 'name' => $category_name, 1213 1211 'rank' => 0, 1214 ' commentable' => boolean_to_string($conf['newcat_default_commentable']),1212 'global_rank' => 0, 1215 1213 ); 1216 1214 1217 if ($parent_id != 'NULL') 1215 // is the album commentable? 1216 if (isset($options['commentable']) and is_bool($options['commentable'])) 1217 { 1218 $insert['commentable'] = $options['commentable']; 1219 } 1220 else 1221 { 1222 $insert['commentable'] = $conf['newcat_default_commentable']; 1223 } 1224 $insert['commentable'] = boolean_to_string($insert['commentable']); 1225 1226 // is the album temporarily locked? (only visible by administrators, 1227 // whatever permissions) (may be overwritten if parent album is not 1228 // visible) 1229 if (isset($options['visible']) and is_bool($options['visible'])) 1230 { 1231 $insert['visible'] = $options['visible']; 1232 } 1233 else 1234 { 1235 $insert['visible'] = $conf['newcat_default_visible']; 1236 } 1237 $insert['visible'] = boolean_to_string($insert['visible']); 1238 1239 // is the album private? (may be overwritten if parent album is private) 1240 if (isset($options['status']) and 'private' == $options['status']) 1241 { 1242 $insert['status'] = 'private'; 1243 } 1244 else 1245 { 1246 $insert['status'] = $conf['newcat_default_status']; 1247 } 1248 1249 // any description for this album? 1250 if (isset($options['comment'])) 1251 { 1252 $insert['comment'] = strip_tags($options['comment']); 1253 } 1254 1255 if (!empty($parent_id) and is_numeric($parent_id)) 1218 1256 { 1219 1257 $query = ' … … 1234 1272 $insert['visible'] = 'false'; 1235 1273 } 1236 else1237 {1238 $insert['visible'] = boolean_to_string($conf['newcat_default_visible']);1239 }1240 1274 1241 1275 // at creation, must a category be public or private ? Warning : if the … … 1246 1280 $insert['status'] = 'private'; 1247 1281 } 1248 else 1249 { 1250 $insert['status'] = $conf['newcat_default_status']; 1251 } 1282 1283 $uppercats_prefix = $parent['uppercats'].','; 1252 1284 } 1253 1285 else 1254 1286 { 1255 $insert['visible'] = boolean_to_string($conf['newcat_default_visible']); 1256 $insert['status'] = $conf['newcat_default_status']; 1257 $insert['global_rank'] = $insert['rank']; 1287 $uppercats_prefix = ''; 1258 1288 } 1259 1289 1260 1290 // we have then to add the virtual category 1261 mass_inserts( 1291 single_insert(CATEGORIES_TABLE, $insert); 1292 $inserted_id = pwg_db_insert_id(CATEGORIES_TABLE); 1293 1294 single_update( 1262 1295 CATEGORIES_TABLE, 1263 array( 1264 'site_id', 'name', 'id_uppercat', 'rank', 'commentable', 1265 'visible', 'status', 'global_rank', 1266 ), 1267 array($insert) 1296 array('uppercats' => $uppercats_prefix.$inserted_id), 1297 array('id' => $inserted_id) 1268 1298 ); 1269 1270 $inserted_id = pwg_db_insert_id(CATEGORIES_TABLE);1271 1272 $query = '1273 UPDATE1274 '.CATEGORIES_TABLE.'1275 SET uppercats = \''.1276 (isset($parent) ? $parent{'uppercats'}.',' : '').1277 $inserted_id.1278 '\'1279 WHERE id = '.$inserted_id.'1280 ;';1281 pwg_query($query);1282 1299 1283 1300 update_global_rank();
Note: See TracChangeset
for help on using the changeset viewer.