示例#1
0
/**
 * Initialize cache settings and folders (during install or upgrade)
 */
function system_init_caches()
{
    global $cache_path, $Settings, $DB;
    // create /cache and /cache/plugins/ folders
    if (!system_create_cache_folder()) {
        return false;
    }
    $Settings->set('newblog_cache_enabled', true);
    set_cache_enabled('general_cache_enabled', true);
    $existing_blogs = system_get_blog_IDs(false);
    foreach ($existing_blogs as $blog_ID) {
        set_cache_enabled('cache_enabled', true, $blog_ID);
    }
    return true;
}
示例#2
0
    /**
     * 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&amp;tab=permgroup&amp;blog=' . $this->ID), 'warning');
        }
        // Commit changes in cache:
        $BlogCache =& get_BlogCache();
        $BlogCache->add($this);
    }
示例#3
0
     $Settings->set('default_blog_ID', $default_blog_ID);
 }
 $Settings->set('blogs_order_by', param('blogs_order_by', 'string', true));
 $Settings->set('blogs_order_dir', param('blogs_order_dir', 'string', true));
 // Reload page timeout
 $reloadpage_timeout = param_duration('reloadpage_timeout');
 if ($reloadpage_timeout > 99999) {
     param_error('reloadpage_timeout', sprintf(T_('Reload-page timeout must be between %d and %d seconds.'), 0, 99999));
 }
 $Settings->set('reloadpage_timeout', $reloadpage_timeout);
 // Smart hit count
 $Settings->set('smart_view_count', param('smart_view_count', 'integer', 0));
 $new_cache_status = param('general_cache_enabled', 'integer', 0);
 if (!$Messages->has_errors()) {
     load_funcs('collections/model/_blog.funcs.php');
     $result = set_cache_enabled('general_cache_enabled', $new_cache_status, NULL, false);
     if ($result != NULL) {
         // general cache setting was changed
         list($status, $message) = $result;
         $Messages->add($message, $status);
     }
 }
 $Settings->set('newblog_cache_enabled', param('newblog_cache_enabled', 'integer', 0));
 $Settings->set('newblog_cache_enabled_widget', param('newblog_cache_enabled_widget', 'integer', 0));
 // Outbound pinging:
 param('outbound_notifications_mode', 'string', true);
 $Settings->set('outbound_notifications_mode', get_param('outbound_notifications_mode'));
 // Categories:
 $Settings->set('allow_moving_chapters', param('allow_moving_chapters', 'integer', 0));
 $Settings->set('chapter_ordering', param('chapter_ordering', 'string', 'alpha'));
 // Cross posting:
     if (!param_errors_detected()) {
         // Update settings:
         $Blog->dbupdate();
         $Messages->add(T_('Plugin settings have 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 'advanced':
     if ($edited_Blog->load_from_Request(array('pings', 'cache', 'authors', 'login', 'styles'))) {
         // Commit update to the DB:
         if ($current_User->check_perm('blog_admin', 'edit', false, $edited_Blog->ID)) {
             $cache_status = param('cache_enabled', 'integer', 0);
             load_funcs('collections/model/_blog.funcs.php');
             $result = set_cache_enabled('cache_enabled', $cache_status, $edited_Blog->ID, false);
             if ($result != NULL) {
                 list($status, $message) = $result;
                 $Messages->add($message, $status);
             }
         }
         $edited_Blog->dbupdate();
         $Messages->add(T_('The blog settings have 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 'perm':
     blog_update_perms($blog, 'user');
     $Messages->add(T_('The blog permissions have been updated'), 'success');
示例#5
0
/**
 * Initialize cache settings and folders (during install or upgrade)
 *
 * This is called on install and on upgrade.
 */
function system_init_caches($verbose = false, $force_enable = true)
{
    global $cache_path, $Settings, $Plugins, $DB;
    // create /_cache and /_cache/plugins/ folders
    task_begin('Checking/creating <code>/_cache/</code> &amp; <code>/_cache/plugins/</code> folders...');
    if (!system_create_cache_folder($verbose)) {
        // The error message were displayed
        task_end('');
        return false;
    }
    task_end();
    if ($force_enable) {
        task_begin('Enabling page caching by default...');
        if (!is_object($Settings)) {
            // create Settings object
            load_class('settings/model/_generalsettings.class.php', 'GeneralSettings');
            $Settings = new GeneralSettings();
        }
        // New blog should have their cache enabled by default: (?)
        $Settings->set('newblog_cache_enabled', true);
        // Enable general cache
        set_cache_enabled('general_cache_enabled', true);
        // Enable caches for all collections:
        $existing_blogs = system_get_blog_IDs(false);
        foreach ($existing_blogs as $blog_ID) {
            set_cache_enabled('cache_enabled', true, $blog_ID);
        }
        task_end();
    }
}
示例#6
0
    /**
     * 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 &laquo;%s&raquo;.'), $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 &laquo;%s&raquo; 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&amp;tab=perm&amp;blog=' . $this->ID, 'href=' . $admin_url . '?ctrl=coll_settings&amp;tab=permgroup&amp;blog=' . $this->ID), 'warning');
        }
        // Commit changes in cache:
        $BlogCache =& get_BlogCache();
        $BlogCache->add($this);
    }