function newCategory($parent, $last_parent_id)
 {
     global $serendipity;
     if (function_exists('serendipity_addCategory')) {
         $parent_id = serendipity_addCategory($parent, '', 0, '', $last_parent_id);
     } else {
         $this->serendipity_addCategory($parent, '', 0, '', $last_parent_id);
         $parent_id = serendipity_db_insert_id('category', 'categoryid');
     }
     return $parent_id;
 }
Example #2
0
 if (is_array($serendipity['POST']['cat']['write_authors']) && in_array(0, $serendipity['POST']['cat']['write_authors'])) {
     $authorid = 0;
 } else {
     $authorid = $serendipity['authorid'];
 }
 $icon = $serendipity['POST']['cat']['icon'];
 $parentid = isset($serendipity['POST']['cat']['parent_cat']) && is_numeric($serendipity['POST']['cat']['parent_cat']) ? $serendipity['POST']['cat']['parent_cat'] : 0;
 if ($serendipity['GET']['adminAction'] == 'new' || $serendipity['GET']['adminAction'] == 'newSub') {
     # only continue if category-name doesn't already exists, as user have no means to distinguish between them
     $r = serendipity_db_query("SELECT category_name FROM {$serendipity['dbPrefix']}category WHERE category_name = '" . serendipity_db_escape_string($name) . "'");
     if (is_array($r) && is_array($r[0])) {
         $data['error_name'] = true;
         $data['category_name'] = $name;
     } else {
         $data['new'] = true;
         $catid = serendipity_addCategory($name, $desc, $authorid, $icon, $parentid);
         serendipity_ACLGrant($catid, 'category', 'read', $serendipity['POST']['cat']['read_authors']);
         serendipity_ACLGrant($catid, 'category', 'write', $serendipity['POST']['cat']['write_authors']);
     }
 } elseif ($serendipity['GET']['adminAction'] == 'edit') {
     $data['edit'] = true;
     if (!serendipity_checkPermission('adminCategoriesMaintainOthers') && !serendipity_ACLCheck($serendipity['authorid'], $serendipity['GET']['cid'], 'category', 'write')) {
         $data['editPermission'] = false;
     } else {
         /* Check to make sure parent is not a child of self */
         $r = serendipity_db_query("SELECT categoryid FROM {$serendipity['dbPrefix']}category c\n                                                WHERE c.categoryid = " . (int) $parentid . "\n                                                    AND c.category_left BETWEEN " . implode(' AND ', serendipity_fetchCategoryRange((int) $serendipity['GET']['cid'])));
         if (is_array($r)) {
             $r = serendipity_db_query("SELECT category_name FROM {$serendipity['dbPrefix']}category\n                                                        WHERE categoryid = " . (int) $parentid);
             $data['subcat'] = sprintf(ALREADY_SUBCATEGORY, serendipity_specialchars($r[0]['category_name']), serendipity_specialchars($name));
         } else {
             serendipity_updateCategory($serendipity['GET']['cid'], $name, $desc, $authorid, $icon, $parentid, $serendipity['POST']['cat']['sort_order'], $serendipity['POST']['cat']['hide_sub'], $admin_category);