/**
  * Step #1 - give all admins notices permissions by default
  *
  */
 function step_1()
 {
     if (!isset($this->registry->bf_ugp_adminpermissions['canadminnotices'])) {
         $this->add_error($this->phrase['core']['wrong_bitfield_xml'], self::PHP_TRIGGER_ERROR, true);
     }
     $this->run_query(sprintf($this->phrase['vbphrase']['update_table'], TABLE_PREFIX . 'administrator'), "UPDATE " . TABLE_PREFIX . "administrator SET\n\t\t\t\tadminpermissions = adminpermissions | " . ($this->registry->bf_ugp_adminpermissions['canadminnotices'] + $this->registry->bf_ugp_adminpermissions['canadminmodlog']));
     require_once DIR . '/includes/functions_databuild.php';
     build_birthdays();
 }
Exemple #2
0
                unset($cperm['calendarpermissionid']);
                $cperm['usergroupid'] = $newugid;
                /*insert query*/
                $db->query_write(fetch_query_sql($cperm, 'calendarpermission'));
            }
        }
    }
    $markups = $db->query_read("\n\t\tSELECT usergroupid, opentag, closetag\n\t\tFROM " . TABLE_PREFIX . "usergroup\n\t\tWHERE opentag <> '' OR\n\t\tclosetag <> ''\n\t");
    $usergroupmarkup = array();
    while ($markup = $db->fetch_array($markups)) {
        $usergroupmarkup["{$markup['usergroupid']}"]['opentag'] = $markup['opentag'];
        $usergroupmarkup["{$markup['usergroupid']}"]['closetag'] = $markup['closetag'];
    }
    require_once DIR . '/includes/functions_databuild.php';
    build_forum_permissions();
    build_birthdays();
    // could be changing sig perms -- this is unscientific, but empty the sig cache
    $db->query_write("\n\t\tDELETE FROM " . TABLE_PREFIX . "sigparsed\n\t");
    ($hook = vBulletinHook::fetch_hook('admin_usergroup_save_complete')) ? eval($hook) : false;
    define('CP_REDIRECT', 'usergroup.php?do=modify');
    print_stop_message('saved_usergroup_x_successfully', htmlspecialchars_uni($vbulletin->GPC['usergroup']['title']));
}
// ###################### Start Remove #######################
if ($_REQUEST['do'] == 'remove') {
    if ($vbulletin->GPC['usergroupid'] < 8) {
        print_stop_message('cant_delete_usergroup');
    } else {
        print_delete_confirmation('usergroup', $vbulletin->GPC['usergroupid'], 'usergroup', 'kill', 'usergroup', 0, construct_phrase($vbphrase['all_members_of_this_usergroup_will_revert'], $vbulletin->usergroupcache['2']['title']));
    }
}
// ###################### Start Kill #######################
Exemple #3
0
 /**
  * Fetch today's birthdays
  * @return array birthday information
  */
 public function fetchBirthdays()
 {
     $today = vbdate('Y-m-d', vB::getRequest()->getTimeNow(), false, false);
     $birthdaycache = vB::getDatastore()->getValue('birthdaycache');
     if (!is_array($birthdaycache) or $today != $birthdaycache['day1'] and $today != $birthdaycache['day2'] or !is_array($birthdaycache['users1'])) {
         // Need to update!
         require_once DIR . '/includes/functions_databuild.php';
         $birthdaystore = build_birthdays();
     } else {
         $birthdaystore = $birthdaycache;
     }
     switch ($today) {
         case $birthdaystore['day1']:
             $birthdaysarray = $birthdaystore['users1'];
             break;
         case $birthdaystore['day2']:
             $birthdaysarray = $birthdaystore['users2'];
             break;
         default:
             $birthdaysarray = array();
     }
     // memory saving
     unset($birthdaystore);
     return $birthdaysarray;
 }
Exemple #4
0
 /**
  * Rebuilds the birthday datastore if the user's birthday has changed
  *
  * @param	integer	User ID
  */
 function update_birthday_datastore($userid)
 {
     if ($this->registry->options['showbirthdays']) {
         if ($this->fetch_field('birthday') != $this->existing['birthday'] or $this->fetch_field('showbirthday') != $this->existing['showbirthday'] or $this->usergroups_changed()) {
             require_once DIR . '/includes/functions_databuild.php';
             build_birthdays();
         }
     }
 }
/**
* Updates the setting table based on data passed in then rebuilds the datastore.
* Only entries in the array are updated (allows partial updates).
*
* @param	array	Array of settings. Format: [setting_name] = new_value
*/
function save_settings($settings)
{
    global $vbulletin, $vbphrase, $stylevar;
    $varnames = array();
    foreach (array_keys($settings) as $varname) {
        $varnames[] = $vbulletin->db->escape_string($varname);
    }
    $oldsettings = $vbulletin->db->query_read("\n\t\tSELECT value, varname, datatype, optioncode\n\t\tFROM " . TABLE_PREFIX . "setting\n\t\tWHERE varname IN ('" . implode("', '", $varnames) . "')\n\t\tORDER BY varname\n\t");
    while ($oldsetting = $vbulletin->db->fetch_array($oldsettings)) {
        switch ($oldsetting['varname']) {
            // **************************************************
            case 'bbcode_html_colors':
                $settings['bbcode_html_colors'] = serialize($settings['bbcode_html_colors']);
                break;
                // **************************************************
            // **************************************************
            case 'styleid':
                $vbulletin->db->query_write("\n\t\t\t\t\tUPDATE " . TABLE_PREFIX . "style\n\t\t\t\t\tSET userselect = 1\n\t\t\t\t\tWHERE styleid = " . $settings['styleid'] . "\n\t\t\t\t");
                break;
                // **************************************************
            // **************************************************
            case 'banemail':
                build_datastore('banemail', $settings['banemail']);
                $settings['banemail'] = '';
                break;
                // **************************************************
            // **************************************************
            case 'editormodes':
                $vbulletin->input->clean_array_gpc('p', array('fe' => TYPE_UINT, 'qr' => TYPE_UINT, 'qe' => TYPE_UINT));
                $settings['editormodes'] = serialize(array('fe' => $vbulletin->GPC['fe'], 'qr' => $vbulletin->GPC['qr'], 'qe' => $vbulletin->GPC['qe']));
                break;
                // **************************************************
            // **************************************************
            case 'cookiepath':
            case 'cookiedomain':
                if ($settings[$oldsetting['varname'] . '_other'] and $settings[$oldsetting['varname'] . '_value']) {
                    $settings[$oldsetting['varname']] = $settings[$oldsetting['varname'] . '_value'];
                }
                break;
                // **************************************************
            // **************************************************
            default:
                ($hook = vBulletinHook::fetch_hook('admin_options_processing')) ? eval($hook) : false;
                if ($oldsetting['optioncode'] == 'multiinput') {
                    $store = array();
                    foreach ($settings["{$oldsetting['varname']}"] as $value) {
                        if ($value != '') {
                            $store[] = $value;
                        }
                    }
                    $settings["{$oldsetting['varname']}"] = serialize($store);
                } else {
                    if (preg_match('#^usergroup:[0-9]+$#', $oldsetting['optioncode'])) {
                        // serialize the array of usergroup inputs
                        if (!is_array($settings["{$oldsetting['varname']}"])) {
                            $settings["{$oldsetting['varname']}"] = array();
                        }
                        $settings["{$oldsetting['varname']}"] = array_map('intval', $settings["{$oldsetting['varname']}"]);
                        $settings["{$oldsetting['varname']}"] = serialize($settings["{$oldsetting['varname']}"]);
                    }
                }
        }
        $newvalue = validate_setting_value($settings["{$oldsetting['varname']}"], $oldsetting['datatype']);
        // this is a strict type check because we want '' to be different from 0
        // some special cases below only use != checks to see if the logical value has changed
        if (strval($oldsetting['value']) !== strval($newvalue)) {
            switch ($oldsetting['varname']) {
                case 'activememberdays':
                case 'activememberoptions':
                    if ($oldsetting['value'] != $newvalue) {
                        $vbulletin->options["{$oldsetting['varname']}"] = $newvalue;
                        require_once DIR . '/includes/functions_databuild.php';
                        build_birthdays();
                    }
                    break;
                case 'showevents':
                case 'showholidays':
                    if ($oldsetting['value'] != $newvalue) {
                        $vbulletin->options["{$oldsetting['varname']}"] = $newvalue;
                        require_once DIR . '/includes/functions_calendar.php';
                        build_events();
                    }
                    break;
                case 'languageid':
                    if ($oldsetting['value'] != $newvalue) {
                        $vbulletin->options['languageid'] = $newvalue;
                        require_once DIR . '/includes/adminfunctions_language.php';
                        build_language($vbulletin->options['languageid']);
                    }
                    break;
                case 'cpstylefolder':
                    $admindm =& datamanager_init('Admin', $vbulletin, ERRTYPE_CP);
                    $admindm->set_existing($vbulletin->userinfo);
                    $admindm->set('cssprefs', $newvalue);
                    $admindm->save();
                    unset($admindm);
                    break;
                case 'storecssasfile':
                    if (!is_demo_mode() and $oldsetting['value'] != $newvalue) {
                        $vbulletin->options['storecssasfile'] = $newvalue;
                        require_once DIR . '/includes/adminfunctions_template.php';
                        print_rebuild_style(-1, '', 1, 0, 0, 0);
                    }
                    break;
                case 'loadlimit':
                    update_loadavg();
                    break;
                case 'view_tagcloud_as_usergroup':
                    build_datastore('tagcloud', serialize(''), 1);
                    break;
                case 'censorwords':
                case 'codemaxlines':
                    if ($oldsetting['value'] != $newvalue) {
                        $vbulletin->db->query_write("TRUNCATE TABLE " . TABLE_PREFIX . "postparsed");
                        if ($vbulletin->options['templateversion'] >= '3.6') {
                            $vbulletin->db->query_write("TRUNCATE TABLE " . TABLE_PREFIX . "sigparsed");
                        }
                    }
                    ($hook = vBulletinHook::fetch_hook('admin_options_processing_censorcode')) ? eval($hook) : false;
                    break;
                default:
                    ($hook = vBulletinHook::fetch_hook('admin_options_processing_build')) ? eval($hook) : false;
            }
            if (is_demo_mode() and in_array($oldsetting['varname'], array('storecssasfile', 'attachfile', 'usefileavatar', 'errorlogdatabase', 'errorlogsecurity', 'safeupload', 'tmppath'))) {
                continue;
            }
            $vbulletin->db->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "setting\n\t\t\t\tSET value = '" . $vbulletin->db->escape_string($newvalue) . "'\n\t\t\t\tWHERE varname = '" . $vbulletin->db->escape_string($oldsetting['varname']) . "'\n\t\t\t");
        }
    }
    build_options();
}
 /**
  * Insert a new usergroup or update an existing usergroup
  *
  * @param array $usergroup Usergroup information to be inserted or updated
  * @param int $ugid_base Usergroup ID. New inserted usergroup's forum permission will based on this usergroup.
  * @param int $usergroupid when updating an existing usergroup, pass usergroup ID as this parameter
  * @return int New or existing usergroup ID
  */
 public function save($usergroup, $ugid_base = 0, $usergroupid = 0)
 {
     $this->checkHasAdminPermission('canadminpermissions');
     $bf_ugp = vB::getDatastore()->get_value('bf_ugp');
     $bf_ugp_adminpermissions = vB::getDatastore()->get_value('bf_ugp_adminpermissions');
     $bf_ugp_genericpermissions = vB::getDatastore()->get_value('bf_ugp_genericpermissions');
     $bf_ugp_genericoptions = vB::getDatastore()->get_value('bf_ugp_genericoptions');
     $bf_misc_useroptions = vB::getDatastore()->get_value('bf_misc_useroptions');
     $usergroupcache = vB::getDatastore()->get_value('usergroupcache');
     $bf_misc_prefixoptions = vB::getDatastore()->get_value('bf_misc_prefixoptions');
     // create bitfield values
     require_once DIR . '/includes/functions_misc.php';
     foreach ($bf_ugp as $permissiongroup => $fields) {
         if ($permissiongroup == 'createpermissions' or $permissiongroup == 'forumpermissions2') {
             continue;
         }
         $usergroup["{$permissiongroup}"] = convert_array_to_bits($usergroup["{$permissiongroup}"], $fields, 1);
     }
     if (!empty($usergroupid)) {
         // update
         if (!($usergroup['adminpermissions'] & $bf_ugp_adminpermissions['cancontrolpanel'])) {
             // check that not removing last admin group
             $checkadmin = vB::getDbAssertor()->getField('usergroup_checkadmin', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED, 'cancontrolpanel' => $bf_ugp_adminpermissions['cancontrolpanel'], 'usergroupid' => $usergroupid));
             if ($usergroupid == 6) {
                 // stop them turning no control panel for usergroup 6, seems the most sensible thing
                 throw new vB_Exception_Api('invalid_usergroup_specified');
             }
             if (!$checkadmin) {
                 throw new vB_Exception_Api('cant_delete_last_admin_group');
             }
         }
         $data = array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_UPDATE, vB_dB_Query::CONDITIONS_KEY => array('usergroupid' => $usergroupid));
         $data = array_merge($data, $usergroup);
         vB::getDbAssertor()->assertQuery('usergroup', $data);
         if (!($usergroup['genericpermissions'] & $bf_ugp_genericpermissions['caninvisible'])) {
             if (!($usergroup['genericoptions'] & $bf_ugp_genericoptions['allowmembergroups'])) {
                 // make the users in this group visible
                 vB::getDbAssertor()->assertQuery('usergroup_makeuservisible', array('invisible' => $bf_misc_useroptions['invisible'], 'usergroupid' => $usergroupid));
             } else {
                 // find all groups allowed to be invisible - don't change people with those as secondary groups
                 vB::getDbAssertor()->assertQuery('updateInvisible', array('caninvisible' => $bf_ugp_genericpermissions['caninvisible'], 'invisible' => $bf_misc_useroptions['invisible'], 'usergroupid' => $usergroupid));
             }
         }
         if ($usergroup['adminpermissions'] & $bf_ugp_adminpermissions['cancontrolpanel']) {
             $ausers = vB::getDbAssertor()->assertQuery('usergroup_fetchausers', array('usergroupid' => $usergroupid));
             foreach ($ausers as $auser) {
                 $userids[] = $auser['userid'];
             }
             if (!empty($userids)) {
                 foreach ($userids as $userid) {
                     $admindm =& datamanager_init('Admin', $vbulletin, ERRTYPE_SILENT);
                     $admindm->set('userid', $userid);
                     $admindm->save();
                     unset($admindm);
                 }
             }
         } else {
             if ($usergroupcache["{$usergroupid}"]['adminpermissions'] & $bf_ugp_adminpermissions['cancontrolpanel']) {
                 // lets find admin usergroupids
                 $ausergroupids = array();
                 $usergroupcache["{$usergroupid}"]['adminpermissions'] = $usergroup['adminpermissions'];
                 foreach ($usergroupcache as $ausergroupid => $ausergroup) {
                     if ($ausergroup['adminpermissions'] & $bf_ugp_adminpermissions['cancontrolpanel']) {
                         $ausergroupids[] = $ausergroupid;
                     }
                 }
                 $ausers = vB::getDbAssertor()->assertQuery('fetchAdminusersFromUsergroup', array('ausergroupids' => $ausergroupids, 'usergroupid' => $usergroupid));
                 foreach ($ausers as $auser) {
                     $userids[] = $auser['userid'];
                 }
                 if (!empty($userids)) {
                     foreach ($userids as $userid) {
                         $info = array('userid' => $userid);
                         $admindm =& datamanager_init('Admin', $vbulletin, ERRTYPE_ARRAY);
                         $admindm->set_existing($info);
                         $admindm->delete();
                         unset($admindm);
                     }
                 }
             }
         }
         vB_Cache::instance()->event('perms_changed');
         vB::getUserContext()->clearChannelPermissions($usergroupid);
     } else {
         // insert
         /*insert query*/
         $newugid = vB::getDbAssertor()->insert('usergroup', $usergroup);
         if ($ugid_base <= 0) {
             // use usergroup registered as default
             foreach ($usergroupcache as $ausergroup) {
                 if ($ausergroup['systemgroupid'] == self::REGISTERED_SYSGROUPID) {
                     $ugid_base = $ausergroup['usergroupid'];
                 }
             }
         }
         if ($ugid_base > 0) {
             $fperms = vB::getDbAssertor()->assertQuery('vBForum:forumpermission', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'usergroupid' => $ugid_base));
             foreach ($fperms as $fperm) {
                 unset($fperm['forumpermissionid']);
                 $fperm['usergroupid'] = $newugid;
                 /*insert query*/
                 $data = array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_INSERT);
                 $data += $fperm;
                 vB::getDbAssertor()->assertQuery('vBForum:forumpermission', $data);
             }
             $cperms = vB::getDbAssertor()->assertQuery('vBForum:calendarpermission', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'usergroupid' => $ugid_base));
             foreach ($cperms as $cperm) {
                 unset($cperm['calendarpermissionid']);
                 $cperm['usergroupid'] = $newugid;
                 /*insert query*/
                 $data = array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_INSERT);
                 $data += $cperm;
                 vB::getDbAssertor()->assertQuery('vBForum:calendarpermission', $data);
             }
             $perms = vB::getDbAssertor()->assertQuery('vBForum:permission', array('groupid' => $ugid_base));
             foreach ($perms as $perm) {
                 unset($perm['permissionid']);
                 $perm['groupid'] = $newugid;
                 vB::getDbAssertor()->insert('vBForum:permission', $perm);
             }
             vB::getUserContext()->clearChannelPermissions();
         }
         vB::getDbAssertor()->assertQuery('usergroup_insertprefixpermission', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED, 'newugid' => $newugid, 'deny_by_default' => $bf_misc_prefixoptions['deny_by_default']));
     }
     vB::getUserContext()->rebuildGroupAccess();
     $markups = vB::getDbAssertor()->getRows('usergroup_fetchmarkups', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED));
     $usergroupmarkup = array();
     foreach ($markups as $markup) {
         $usergroupmarkup["{$markup['usergroupid']}"]['opentag'] = $markup['opentag'];
         $usergroupmarkup["{$markup['usergroupid']}"]['closetag'] = $markup['closetag'];
     }
     require_once DIR . '/includes/adminfunctions.php';
     require_once DIR . '/includes/functions_databuild.php';
     build_channel_permissions();
     build_birthdays();
     // could be changing sig perms -- this is unscientific, but empty the sig cache
     vB::getDbAssertor()->assertQuery('truncateTable', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_METHOD, 'table' => 'sigparsed'));
     if ($newugid) {
         return $newugid;
     } else {
         return $usergroupid;
     }
 }
Exemple #7
0
	$navbits[''] = $foruminfo['title'];
}

$today = vbdate('Y-m-d', TIMENOW, false, false);

// ### TODAY'S BIRTHDAYS #################################################
if ($vbulletin->options['showbirthdays'])
{
	if (!is_array($vbulletin->birthdaycache)
		OR ($today != $vbulletin->birthdaycache['day1'] AND $today != $vbulletin->birthdaycache['day2'])
		OR !is_array($vbulletin->birthdaycache['users1'])
	)
	{
		// Need to update!
		require_once(DIR . '/includes/functions_databuild.php');
		$birthdaystore = build_birthdays();
		DEVDEBUG('Updated Birthdays');
	}
	else
	{
		$birthdaystore = $vbulletin->birthdaycache;
	}

	switch ($today)
	{
		case $birthdaystore['day1']:
			$birthdaysarray = $birthdaystore['users1'];
			break;

		case $birthdaystore['day2']:
			$birthdaysarray = $birthdaystore['users2'];