function spa_setup_auths()
{
    # create the auths
    sp_add_auth('view_forum', esc_sql(spa_text_noesc('Can view a forum')), 1, 0, 0, 0, 2);
    sp_add_auth('view_forum_lists', esc_sql(spa_text_noesc('Can view a list of forums only')), 1, 0, 0, 0, 2);
    sp_add_auth('view_forum_topic_lists', esc_sql(spa_text_noesc('Can view a list of forums and list of topics only')), 1, 0, 0, 0, 2);
    sp_add_auth('view_admin_posts', esc_sql(spa_text_noesc('Can view posts by an administrator')), 1, 0, 0, 0, 2);
    sp_add_auth('view_own_admin_posts', esc_sql(spa_text_noesc('Can view only own posts and admin/mod posts')), 1, 0, 0, 1, 2);
    sp_add_auth('start_topics', esc_sql(spa_text_noesc('Can start new topics in a forum')), 1, 0, 0, 0, 3);
    sp_add_auth('reply_topics', esc_sql(spa_text_noesc('Can reply to existing topics in a forum')), 1, 0, 0, 0, 3);
    sp_add_auth('reply_own_topics', esc_sql(spa_text_noesc('Can only reply to own topics')), 1, 0, 0, 1, 3);
    sp_add_auth('bypass_flood_control', esc_sql(spa_text_noesc('Can bypass wait time between posts')), 1, 0, 0, 0, 3);
    sp_add_auth('edit_own_topic_titles', esc_sql(spa_text_noesc('Can edit own topic titles')), 1, 0, 0, 0, 4);
    sp_add_auth('edit_any_topic_titles', esc_sql(spa_text_noesc('Can edit any topic title')), 1, 0, 0, 0, 4);
    sp_add_auth('pin_topics', esc_sql(spa_text_noesc('Can pin topics in a forum')), 1, 0, 0, 0, 7);
    sp_add_auth('move_topics', esc_sql(spa_text_noesc('Can move topics from a forum')), 1, 0, 0, 0, 7);
    sp_add_auth('move_posts', esc_sql(spa_text_noesc('Can move posts from a topic')), 1, 0, 0, 0, 7);
    sp_add_auth('lock_topics', esc_sql(spa_text_noesc('Can lock topics in a forum')), 1, 0, 0, 0, 7);
    sp_add_auth('delete_topics', esc_sql(spa_text_noesc('Can delete topics in forum')), 1, 0, 0, 0, 5);
    sp_add_auth('edit_own_posts_forever', esc_sql(spa_text_noesc('Can edit own posts forever')), 1, 0, 0, 0, 4);
    sp_add_auth('edit_own_posts_reply', esc_sql(spa_text_noesc('Can edit own posts until there has been a reply')), 1, 0, 0, 0, 4);
    sp_add_auth('edit_any_post', esc_sql(spa_text_noesc('Can edit any post')), 1, 0, 0, 0, 4);
    sp_add_auth('delete_own_posts', esc_sql(spa_text_noesc('Can delete own posts')), 1, 0, 0, 0, 5);
    sp_add_auth('delete_any_post', esc_sql(spa_text_noesc('Can delete any post')), 1, 0, 0, 0, 5);
    sp_add_auth('pin_posts', esc_sql(spa_text_noesc('Can pin posts within a topic')), 1, 0, 0, 0, 7);
    sp_add_auth('reassign_posts', esc_sql(spa_text_noesc('Can reassign posts to a different user')), 1, 0, 0, 0, 7);
    sp_add_auth('view_email', esc_sql(spa_text_noesc('Can view email and IP addresses of members')), 1, 0, 0, 0, 2);
    sp_add_auth('view_profiles', esc_sql(spa_text_noesc('Can view profiles of members')), 1, 0, 0, 0, 2);
    sp_add_auth('view_members_list', esc_sql(spa_text_noesc('Can view the members lists')), 1, 0, 0, 0, 2);
    sp_add_auth('bypass_math_question', esc_sql(spa_text_noesc('Can bypass the math question')), 1, 0, 0, 0, 6);
    sp_add_auth('bypass_moderation', esc_sql(spa_text_noesc('Can bypass all post moderation')), 1, 0, 0, 0, 6);
    sp_add_auth('bypass_moderation_once', esc_sql(spa_text_noesc('Can bypass first post moderation')), 1, 0, 0, 0, 6);
    sp_add_auth('moderate_posts', esc_sql(spa_text_noesc('Can moderate pending posts')), 1, 0, 0, 0, 6);
    sp_add_auth('use_spoilers', esc_sql(spa_text_noesc('Can use spoilers in posts')), 1, 0, 0, 0, 3);
    sp_add_auth('view_links', esc_sql(spa_text_noesc('Can view links within posts')), 1, 0, 0, 0, 2);
    sp_add_auth('use_signatures', esc_sql(spa_text_noesc('Can attach a signature to posts')), 1, 1, 0, 0, 3);
    sp_add_auth('upload_avatars', esc_sql(spa_text_noesc('Can upload avatars')), 1, 1, 1, 0, 8);
    sp_add_auth('create_links', esc_sql(spa_text_noesc('Can create links in posts')), 1, 0, 0, 0, 3);
    sp_add_auth('can_use_smileys', esc_sql(spa_text_noesc('Can use smileys in posts')), 1, 0, 0, 0, 3);
    sp_add_auth('can_use_iframes', esc_sql(spa_text_noesc('Can use iframes in posts')), 1, 0, 0, 0, 3);
}
Example #2
0
if ($build < $section) {
    sp_add_option('combinecss', false);
    sp_add_option('combinejs', false);
    sp_response($section);
}
$section = 9400;
if ($build < $section) {
    $sfdisplay = sp_get_option('sfdisplay');
    $sfdisplay['editor']['toolbar'] = 0;
    sp_update_option('sfdisplay', $sfdisplay);
    sp_response($section);
}
# Start of Upgrade Routines - 5.2.1 ============================================================
$section = 9543;
if ($build < $section) {
    spdb_query('UPDATE ' . SFAUTHS . ' SET auth_desc = "' . esc_sql(spa_text_noesc('Can view email and IP addresses of members')) . '" WHERE auth_desc = "' . esc_sql(spa_text_noesc('Can view email addresses of members')) . '"');
    sp_response($section);
}
$section = 9550;
if ($build < $section) {
    # Add default to poster_ip in sfposts - being rerun as was missed from Install in 5.2
    spdb_query('ALTER TABLE ' . SFPOSTS . " CHANGE poster_ip poster_ip VARCHAR(39) NOT NULL DEFAULT '0.0.0.0'");
    sp_response($section);
}
# Start of Upgrade Routines - 5.2.3 ============================================================
$section = 9652;
if ($build < $section) {
    $sfmetatags = sp_get_option('sfmetatags');
    $sfmetatags['sfusekeywords'] = $sfmetatags['sfusekeywords'] ? 2 : 1;
    sp_update_option('sfmetatags', $sfmetatags);
    spdb_query('ALTER TABLE ' . SFFORUMS . ' ADD (keywords varchar(256) default NULL)');
function spa_setup_auths()
{
    # create the auths
    sp_add_auth('view_forum', esc_sql(spa_text_noesc('Can view a forum')), 1, 0, 0, 0, 2, '');
    sp_add_auth('view_forum_lists', esc_sql(spa_text_noesc('Can view a list of forums only')), 1, 0, 0, 0, 2, '');
    sp_add_auth('view_forum_topic_lists', esc_sql(spa_text_noesc('Can view a list of forums and list of topics only')), 1, 0, 0, 0, 2, '');
    sp_add_auth('view_admin_posts', esc_sql(spa_text_noesc('Can view posts by an administrator')), 1, 0, 0, 0, 2, '');
    sp_add_auth('view_own_admin_posts', esc_sql(spa_text_noesc('Can view only own posts and admin/mod posts')), 1, 1, 0, 1, 2, '');
    sp_add_auth('view_email', esc_sql(spa_text_noesc('Can view email and IP addresses of members')), 1, 1, 0, 0, 2, '');
    sp_add_auth('view_profiles', esc_sql(spa_text_noesc('Can view profiles of members')), 1, 0, 0, 0, 2, '');
    sp_add_auth('view_members_list', esc_sql(spa_text_noesc('Can view the members lists')), 1, 0, 0, 0, 2, '');
    sp_add_auth('view_links', esc_sql(spa_text_noesc('Can view links within posts')), 1, 0, 0, 0, 2, '');
    sp_add_auth('start_topics', esc_sql(spa_text_noesc('Can start new topics in a forum')), 1, 0, 0, 0, 3, '');
    sp_add_auth('reply_topics', esc_sql(spa_text_noesc('Can reply to existing topics in a forum')), 1, 0, 0, 0, 3, '');
    sp_add_auth('reply_own_topics', esc_sql(spa_text_noesc('Can only reply to own topics')), 1, 1, 0, 1, 3, '');
    sp_add_auth('bypass_flood_control', esc_sql(spa_text_noesc('Can bypass wait time between posts')), 1, 0, 0, 0, 3, '');
    sp_add_auth('use_spoilers', esc_sql(spa_text_noesc('Can use spoilers in posts in posts')), 1, 0, 0, 0, 3, '');
    sp_add_auth('use_signatures', esc_sql(spa_text_noesc('Can attach a signature to posts')), 1, 1, 0, 0, 3, '');
    sp_add_auth('create_links', esc_sql(spa_text_noesc('Can create links in posts')), 1, 0, 0, 0, 3, '');
    sp_add_auth('can_use_smileys', esc_sql(spa_text_noesc('Can use smileys in posts')), 1, 0, 0, 0, 3, '');
    sp_add_auth('can_use_iframes', esc_sql(spa_text_noesc('Can use iframes in posts')), 1, 1, 0, 0, 3, spa_text('*** WARNING *** The use of iframes is dangerous. Allowing users to create iframes enables them to launch a potential security threat against your website. Enabling iframes requires your trust in your users. Turn on with care.'));
    sp_add_auth('edit_own_topic_titles', esc_sql(spa_text_noesc('Can edit own topic titles')), 1, 1, 0, 0, 4, '');
    sp_add_auth('edit_any_topic_titles', esc_sql(spa_text_noesc('Can edit any topic title')), 1, 1, 0, 0, 4, '');
    sp_add_auth('edit_own_posts_for_time', esc_sql(spa_text_noesc('Can edit own posts for time period')), 1, 1, 0, 0, 4, '');
    sp_add_auth('edit_own_posts_forever', esc_sql(spa_text_noesc('Can edit own posts forever')), 1, 1, 0, 0, 4, '');
    sp_add_auth('edit_own_posts_reply', esc_sql(spa_text_noesc('Can edit own posts until there has been a reply')), 1, 1, 0, 0, 4, '');
    sp_add_auth('edit_any_post', esc_sql(spa_text_noesc('Can edit any post')), 1, 1, 0, 0, 4, '');
    sp_add_auth('delete_topics', esc_sql(spa_text_noesc('Can delete topics in forum')), 1, 1, 0, 0, 5, '');
    sp_add_auth('delete_own_posts', esc_sql(spa_text_noesc('Can delete own posts')), 1, 1, 0, 0, 5, '');
    sp_add_auth('delete_any_post', esc_sql(spa_text_noesc('Can delete any post')), 1, 1, 0, 0, 5, '');
    sp_add_auth('bypass_math_question', esc_sql(spa_text_noesc('Can bypass the math question')), 1, 0, 0, 0, 6, '');
    sp_add_auth('bypass_moderation', esc_sql(spa_text_noesc('Can bypass all post moderation')), 1, 0, 0, 0, 6, 0);
    sp_add_auth('bypass_moderation_once', esc_sql(spa_text_noesc('Can bypass first post moderation')), 1, 0, 0, 0, 6, '');
    sp_add_auth('moderate_posts', esc_sql(spa_text_noesc('Can moderate pending posts')), 1, 1, 0, 0, 6, '');
    sp_add_auth('pin_topics', esc_sql(spa_text_noesc('Can pin topics in a forum')), 1, 0, 0, 0, 7, '');
    sp_add_auth('move_topics', esc_sql(spa_text_noesc('Can move topics from a forum')), 1, 0, 0, 0, 7, '');
    sp_add_auth('move_posts', esc_sql(spa_text_noesc('Can move posts from a topic')), 1, 0, 0, 0, 7, '');
    sp_add_auth('lock_topics', esc_sql(spa_text_noesc('Can lock topics in a forum')), 1, 0, 0, 0, 7, '');
    sp_add_auth('pin_posts', esc_sql(spa_text_noesc('Can pin posts within a topic')), 1, 0, 0, 0, 7, '');
    sp_add_auth('reassign_posts', esc_sql(spa_text_noesc('Can reassign posts to a different user')), 1, 0, 0, 0, 7, '');
    sp_add_auth('upload_avatars', esc_sql(spa_text_noesc('Can upload avatars')), 1, 1, 1, 0, 8, '');
}
function sp_convert_perms_to_auths()
{
    if (!spdb_column_exists(SFMEMBERS, 'auths')) {
        spdb_query('ALTER TABLE ' . SFMEMBERS . ' ADD (auths longtext)');
    }
    spdb_query('ALTER TABLE ' . SFROLES . ' CHANGE role_actions role_auths longtext');
    # populate with existing permissions
    sp_add_auth('view_forum', esc_sql(spa_text_noesc('Can view a forum')), 1, 0, 0);
    sp_add_auth('view_forum_lists', esc_sql(spa_text_noesc('Can view a list of forums only')), 1, 0, 0);
    sp_add_auth('view_forum_topic_lists', esc_sql(spa_text_noesc('Can view a list of forums and list of topics only')), 1, 0, 0);
    sp_add_auth('view_admin_posts', esc_sql(spa_text_noesc('Can view posts by an administrator')), 1, 0, 0);
    sp_add_auth('start_topics', esc_sql(spa_text_noesc('Can start new topics in a forum')), 1, 0, 0);
    sp_add_auth('reply_topics', esc_sql(spa_text_noesc('Can reply to existing topics in a forum')), 1, 0, 0);
    sp_add_auth('edit_own_topic_titles', esc_sql(spa_text_noesc('Can edit own topic titles')), 1, 0, 0);
    sp_add_auth('edit_any_topic_titles', esc_sql(spa_text_noesc('Can edit any topic title')), 1, 0, 0);
    sp_add_auth('pin_topics', esc_sql(spa_text_noesc('Can pin topics in a forum')), 1, 0, 0);
    sp_add_auth('move_topics', esc_sql(spa_text_noesc('Can move topics from a forum')), 1, 0, 0);
    sp_add_auth('move_posts', esc_sql(spa_text_noesc('Can move posts from a topic')), 1, 0, 0);
    sp_add_auth('lock_topics', esc_sql(spa_text_noesc('Can lock topics in a forum')), 1, 0, 0);
    sp_add_auth('delete_topics', esc_sql(spa_text_noesc('Can delete topics in forum')), 1, 0, 0);
    sp_add_auth('edit_own_posts_forever', esc_sql(spa_text_noesc('Can edit own posts forever')), 1, 0, 0);
    sp_add_auth('edit_own_posts_reply', esc_sql(spa_text_noesc('Can edit own posts until there has been a reply')), 1, 0, 0);
    sp_add_auth('edit_any_post', esc_sql(spa_text_noesc('Can edit any post')), 1, 0, 0);
    sp_add_auth('delete_own_posts', esc_sql(spa_text_noesc('Can delete own posts')), 1, 0, 0);
    sp_add_auth('delete_any_post', esc_sql(spa_text_noesc('Can delete any post')), 1, 0, 0);
    sp_add_auth('pin_posts', esc_sql(spa_text_noesc('Can pin posts within a topic')), 1, 0, 0);
    sp_add_auth('reassign_posts', esc_sql(spa_text_noesc('Can reassign posts to a different user')), 1, 0, 0);
    sp_add_auth('view_email', esc_sql(spa_text_noesc('Can view email and IP addresses of members')), 1, 0, 0);
    sp_add_auth('view_profiles', esc_sql(spa_text_noesc('Can view profiles of members')), 1, 0, 0);
    sp_add_auth('view_members_list', esc_sql(spa_text_noesc('Can view the members lists')), 1, 0, 0);
    sp_add_auth('report_posts', esc_sql(spa_text_noesc('Can report a post to administrators')), 1, 0, 0);
    sp_add_auth('bypass_math_question', esc_sql(spa_text_noesc('Can bypass the math question')), 1, 0, 0);
    sp_add_auth('bypass_moderation', esc_sql(spa_text_noesc('Can bypass all post moderation')), 1, 0, 0);
    sp_add_auth('bypass_moderation_once', esc_sql(spa_text_noesc('Can bypass first post moderation')), 1, 0, 0);
    sp_add_auth('moderate_posts', esc_sql(spa_text_noesc('Can moderate pending posts')), 1, 0, 0);
    sp_add_auth('use_spoilers', esc_sql(spa_text_noesc('Can use spoilers in posts')), 1, 0, 0);
    sp_add_auth('view_links', esc_sql(spa_text_noesc('Can view links within posts')), 1, 0, 0);
    sp_add_auth('upload_images', esc_sql(spa_text_noesc('Can upload images in posts')), 1, 1, 0);
    sp_add_auth('upload_media', esc_sql(spa_text_noesc('Can upload media in posts')), 1, 1, 0);
    sp_add_auth('upload_files', esc_sql(spa_text_noesc('Can upload other files in posts')), 1, 1, 0);
    sp_add_auth('use_signatures', esc_sql(spa_text_noesc('Can attach a signature to posts')), 1, 1, 0);
    sp_add_auth('upload_signatures', esc_sql(spa_text_noesc('Can upload signature images')), 1, 1, 0);
    sp_add_auth('upload_avatars', esc_sql(spa_text_noesc('Can upload avatars')), 1, 1, 1);
    sp_add_auth('subscribe', esc_sql(spa_text_noesc('Can subscribe to topics within a forum')), 0, 1, 0);
    sp_add_auth('watch', esc_sql(spa_text_noesc('Can watch topics within a forum')), 0, 1, 0);
    sp_add_auth('change_topic_status', esc_sql(spa_text_noesc('Can change the status of a topic')), 1, 1, 0);
    sp_add_auth('rate_posts', esc_sql(spa_text_noesc('Can rate a post')), 0, 1, 0);
    sp_add_auth('use_pm', esc_sql(spa_text_noesc('Can use the private messaging system')), 0, 1, 1);
    # now we need to convert existing roles
    $roles = spdb_table(SFROLES);
    if ($roles) {
        foreach ($roles as $role) {
            $actions = unserialize($role->role_auths);
            if ($actions) {
                $new_actions = spa_convert_action_to_auth($actions);
                spdb_query('UPDATE ' . SFROLES . " SET role_auths='" . serialize($new_actions) . "' WHERE role_id={$role->role_id}");
            }
        }
    }
}