- Timestamp:
- Aug 30, 2012, 2:54:29 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 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(); -
trunk/include/ws_functions.inc.php
r17469 r17669 2303 2303 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 2304 2304 2305 $options = array(); 2306 if (!empty($params['status']) and in_array($params['status'], array('private','public'))) 2307 { 2308 $options['status'] = $params['status']; 2309 } 2310 2311 if (!empty($params['visible']) and in_array($params['visible'], array('true','false'))) 2312 { 2313 $options['visible'] = get_boolean($params['visible']); 2314 } 2315 2316 if (!empty($params['commentable']) and in_array($params['commentable'], array('true','false')) ) 2317 { 2318 $options['commentable'] = get_boolean($params['commentable']); 2319 } 2320 2321 if (!empty($params['comment'])) 2322 { 2323 $options['comment'] = $params['comment']; 2324 } 2325 2326 2305 2327 $creation_output = create_virtual_category( 2306 2328 $params['name'], 2307 $params['parent'] 2329 $params['parent'], 2330 $options 2308 2331 ); 2309 2332 … … 2311 2334 { 2312 2335 return new PwgError(500, $creation_output['error']); 2313 }2314 2315 $updates = array();2316 if ( !empty($params['status']) and in_array($params['status'], array('private','public')) )2317 {2318 $updates['status'] = $params['status'];2319 }2320 if ( !empty($params['visible']) and in_array($params['visible'], array('true','false')) )2321 {2322 $updates['visible'] = $params['visible'];2323 }2324 if ( !empty($params['commentable']) and in_array($params['commentable'], array('true','false')) )2325 {2326 $updates['commentable'] = $params['commentable'];2327 }2328 if ( !empty($params['comment']) )2329 {2330 $updates['comment'] = strip_tags($params['comment']);2331 }2332 2333 if (!empty($updates))2334 {2335 single_update(2336 CATEGORIES_TABLE,2337 $updates,2338 array('id'=>$creation_output['id'])2339 );2340 }2341 2342 if ( isset($updates['status']) and 'private' == $updates['status'] )2343 {2344 add_permission_on_category($creation_output['id'], get_admins());2345 2336 } 2346 2337 -
trunk/ws.php
r15850 r17669 310 310 'parent' => array('default' => null), 311 311 'comment' => array('default' => null), 312 'visible' => array('default' => boolean_to_string($conf['newcat_default_visible'])),313 'status' => array('default' => $conf['newcat_default_status']),312 'visible' => array('default' => null), 313 'status' => array('default' => null), 314 314 'commentable' => array('default' => 'true'), 315 315 ),
Note: See TracChangeset
for help on using the changeset viewer.