/** * Create a new blog... * * @param string Kind of blog ( 'std', 'photo', 'group', 'forum' ) */ function create($kind = '') { global $DB, $Messages, $basepath, $admin_url, $current_User, $Settings; $DB->begin(); // DB INSERT $this->dbinsert(); $Messages->add(T_('The new blog has been created.'), 'success'); // Change access mode if a stub file exists: $stub_filename = 'blog' . $this->ID . '.php'; if (is_file($basepath . $stub_filename)) { // Stub file exists and is waiting ;) $DB->query('UPDATE T_blogs SET blog_access_type = "relative", blog_siteurl = "' . $stub_filename . '" WHERE blog_ID = ' . $this->ID); $Messages->add(sprintf(T_('The new blog has been associated with the stub file «%s».'), $stub_filename), 'success'); } elseif ($this->access_type == 'relative') { // Show error message only if stub file should exists! $Messages->add(sprintf(T_('No stub file named «%s» was found. You must create it for the blog to function properly with the current settings.'), $stub_filename), 'error'); } // Set default user permissions for this blog (All permissions for the current user, typically the admin who is creating the blog) // Note: current_User can be NULL only during new user registration process, when new user automatically get a new blog // Note: The owner of teh blog has permissions just by the sole fact he is registered as the owner. if ($current_User != NULL) { // Proceed insertions: $perm_statuses = "'review,draft,private,protected,deprecated,community,published'"; $DB->query("\n\t\t\t\t\tINSERT INTO T_coll_user_perms( bloguser_blog_ID, bloguser_user_ID, bloguser_ismember,\n\t\t\t\t\t\tbloguser_perm_poststatuses, bloguser_perm_delpost, bloguser_perm_edit_ts,\n\t\t\t\t\t\tbloguser_perm_recycle_owncmts, bloguser_perm_vote_spam_cmts, bloguser_perm_cmtstatuses,\n\t\t\t\t\t\tbloguser_perm_cats, bloguser_perm_properties,\n\t\t\t\t\t\tbloguser_perm_media_upload, bloguser_perm_media_browse, bloguser_perm_media_change )\n\t\t\t\t\tVALUES ( {$this->ID}, {$current_User->ID}, 1,\n\t\t\t\t\t\t{$perm_statuses}, 1, 1, 1, 1, {$perm_statuses}, 1, 1, 1, 1, 1 )"); } /* if( $kind == 'forum' ) { // Set default group permissions for the Forum blog $GroupCache = & get_GroupCache(); $groups_permissions = array(); if( $GroupCache->get_by_ID( 1, false ) ) { // Check if "Administrators" group still exists $groups_permissions[ 'admins' ] = "( $this->ID, 1, 1, 'published,deprecated,protected,private,draft', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 )"; } if( $GroupCache->get_by_ID( 2, false ) ) { // Check if "Moderators" group still exists $groups_permissions[ 'privileged' ] = "( $this->ID, 2, 1, 'published,deprecated,protected,private,draft', 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1 )"; } if( $GroupCache->get_by_ID( 3, false ) ) { // Check if "Bloggers" group still exists $groups_permissions[ 'bloggers' ] = "( $this->ID, 3, 1, 'published,deprecated,protected,private,draft', 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0 )"; } if( $GroupCache->get_by_ID( 4, false ) ) { // Check if "Basic Users" group still exists $groups_permissions[ 'users' ] = "( $this->ID, 4, 1, 'published', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )"; } if( $GroupCache->get_by_ID( 5, false ) ) { // Check if "Spam/Suspect Users" group still exists $groups_permissions[ 'spam' ] = "( $this->ID, 5, 1, 'published,deprecated,protected,private,draft', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )"; } $DB->query( 'INSERT INTO T_coll_group_perms( bloggroup_blog_ID, bloggroup_group_ID, bloggroup_ismember, bloggroup_perm_poststatuses, bloggroup_perm_delpost, bloggroup_perm_edit_ts, bloggroup_perm_recycle_owncmts, bloggroup_perm_vote_spam_cmts, bloggroup_perm_draft_cmts, bloggroup_perm_publ_cmts, bloggroup_perm_depr_cmts, bloggroup_perm_cats, bloggroup_perm_properties, bloggroup_perm_media_upload, bloggroup_perm_media_browse, bloggroup_perm_media_change ) VALUES '.implode( ',', $groups_permissions ) ); }*/ // Create default category: load_class('chapters/model/_chapter.class.php', 'Chapter'); $edited_Chapter = new Chapter(NULL, $this->ID); $blog_urlname = $this->get('urlname'); $edited_Chapter->set('name', T_('Uncategorized')); $edited_Chapter->set('urlname', $blog_urlname . '-main'); $edited_Chapter->dbinsert(); $Messages->add(T_('A default category has been created for this blog.'), 'success'); // ADD DEFAULT WIDGETS: load_funcs('widgets/_widgets.funcs.php'); insert_basic_widgets($this->ID, false, $kind); $Messages->add(T_('Default widgets have been set-up for this blog.'), 'success'); $DB->commit(); // set caching if ($Settings->get('newblog_cache_enabled')) { $result = set_cache_enabled('cache_enabled', true, $this->ID); if ($result != NULL) { list($status, $message) = $result; $Messages->add($message, $status); } } $this->set_setting('cache_enabled_widgets', $Settings->get('newblog_cache_enabled_widget')); if ($this->get('advanced_perms')) { // Display this warning if blog has the enabled advanced perms be default $Messages->add(sprintf(T_('ATTENTION: go to the <a %s>advanced group permissions for this blog/forum</a> in order to allow some user groups to post new topics into this forum.'), 'href=' . $admin_url . '?ctrl=coll_settings&tab=permgroup&blog=' . $this->ID), 'warning'); } // Commit changes in cache: $BlogCache =& get_BlogCache(); $BlogCache->add($this); }
/** * Install basic widgets. */ function install_basic_widgets($old_db_version = 0) { /** * @var DB */ global $DB; load_funcs('widgets/_widgets.funcs.php'); if ($old_db_version < 11010) { $blog_ids = $DB->get_assoc('SELECT blog_ID, "std" FROM T_blogs'); } else { $blog_ids = $DB->get_assoc('SELECT blog_ID, blog_type FROM T_blogs'); } foreach ($blog_ids as $blog_id => $blog_type) { task_begin('Installing default widgets for blog #' . $blog_id . '... '); insert_basic_widgets($blog_id, true, $blog_type); task_end(); } }
param('type', 'string', ''); param_check_not_empty('type', T_('Please select a type')); if (param_errors_detected()) { $action = 'type'; break; } if ($reset) { // Reset all settings // Remove previous widgets, plugin and skin settings $DB->query('DELETE FROM T_widget WHERE wi_coll_ID = ' . $DB->quote($edited_Blog->ID)); $DB->query('DELETE FROM T_coll_settings WHERE cset_coll_ID = ' . $DB->quote($edited_Blog->ID) . ' AND ( cset_name LIKE "skin%" OR cset_name LIKE "plugin%" )'); // ADD DEFAULT WIDGETS: load_funcs('widgets/_widgets.funcs.php'); insert_basic_widgets($edited_Blog->ID, false, $type); } $edited_Blog->init_by_kind($type, $edited_Blog->get('name'), $edited_Blog->get('shortname'), $edited_Blog->get('urlname')); $edited_Blog->dbupdate(); $Messages->add(T_('The collection type has been updated'), 'success'); // Redirect so that a reload doesn't write to the DB twice: header_redirect($update_redirect_url, 303); // Will EXIT break; case 'enable_setting': case 'disable_setting': // Update blog settings: // Check that this action request is not a CSRF hacked request: $Session->assert_received_crumb('collection'); // Check permissions: $current_User->check_perm('blog_properties', 'edit', true, $blog);
/** * Create a new blog... * * @param string Kind of blog ( 'std', 'photo', 'group', 'forum' ) */ function create($kind = '') { global $DB, $Messages, $basepath, $admin_url, $current_User, $Settings; $DB->begin(); // DB INSERT $this->dbinsert(); $Messages->add(T_('The new blog has been created.'), 'success'); // Change access mode if a stub file exists: $stub_filename = 'blog' . $this->ID . '.php'; if (is_file($basepath . $stub_filename)) { // Stub file exists and is waiting ;) $DB->query('UPDATE T_blogs SET blog_access_type = "relative", blog_siteurl = "' . $stub_filename . '" WHERE blog_ID = ' . $this->ID); $Messages->add(sprintf(T_('The new blog has been associated with the stub file «%s».'), $stub_filename), 'success'); } elseif ($this->access_type == 'relative') { // Show error message only if stub file should exists! $Messages->add(sprintf(T_('No stub file named «%s» was found. You must create it for the blog to function properly with the current settings.'), $stub_filename), 'error'); } // Set default user permissions for this collection (All permissions for the collection owner): if (!empty($this->owner_user_ID)) { // Proceed insertion: $DB->query('INSERT INTO T_coll_user_perms ( bloguser_blog_ID, bloguser_user_ID, bloguser_ismember, bloguser_can_be_assignee, bloguser_perm_poststatuses, bloguser_perm_item_type, bloguser_perm_edit, bloguser_perm_delpost, bloguser_perm_edit_ts, bloguser_perm_delcmts, bloguser_perm_recycle_owncmts, bloguser_perm_vote_spam_cmts, bloguser_perm_cmtstatuses, bloguser_perm_edit_cmt, bloguser_perm_cats, bloguser_perm_properties, bloguser_perm_admin, bloguser_perm_media_upload, bloguser_perm_media_browse, bloguser_perm_media_change ) VALUES ( ' . $this->ID . ', ' . $this->owner_user_ID . ', 1, 1, "published,community,deprecated,protected,private,review,draft,redirected", "admin", "all", 1, 1, 1, 1, 1, "published,community,deprecated,protected,private,review,draft", "all", 1, 1, 1, 1, 1, 1 )'); } // Create default category: load_class('chapters/model/_chapter.class.php', 'Chapter'); $edited_Chapter = new Chapter(NULL, $this->ID); $blog_urlname = $this->get('urlname'); $edited_Chapter->set('name', T_('Uncategorized')); $edited_Chapter->set('urlname', $blog_urlname . '-main'); $edited_Chapter->dbinsert(); $Messages->add(T_('A default category has been created for this blog.'), 'success'); // ADD DEFAULT WIDGETS: load_funcs('widgets/_widgets.funcs.php'); insert_basic_widgets($this->ID, false, $kind); $Messages->add(T_('Default widgets have been set-up for this blog.'), 'success'); $DB->commit(); // set caching if ($Settings->get('newblog_cache_enabled')) { $result = set_cache_enabled('cache_enabled', true, $this->ID); if ($result != NULL) { list($status, $message) = $result; $Messages->add($message, $status); } } $this->set_setting('cache_enabled_widgets', $Settings->get('newblog_cache_enabled_widget')); // Insert default group permissions: $default_perms_inserted = $this->insert_default_group_permissions(); if ($this->get('advanced_perms') && $default_perms_inserted) { // Display this warning if coolection has the enabled advanced perms AND default permissions have been inserted for at least one group: $Messages->add(sprintf(T_('ATTENTION: We have set some advanced permissions for this collection. Please verify the <a %s>User permissions</a> and the <a %s>Group permissions</a> now.'), 'href=' . $admin_url . '?ctrl=coll_settings&tab=perm&blog=' . $this->ID, 'href=' . $admin_url . '?ctrl=coll_settings&tab=permgroup&blog=' . $this->ID), 'warning'); } // Commit changes in cache: $BlogCache =& get_BlogCache(); $BlogCache->add($this); }