Naujų levelių pridėjimas
Parašė MAnjack 2007 birželio 27 14:06:16
Prieš pradėdami darbą įsitikinkite, kad pasidarėte visų failų kopijas.

1. maincore.php faile apie 432 eilutę susiraskite:

// Display the user's level
function getuserlevel($userlevel) {
global $locale;
if ($userlevel==101) { return $locale['user1']; }
elseif ($userlevel==102) { return $locale['user2']; }
elseif ($userlevel==103) { return $locale['user3']; }
}


Mes modifikuosime šį pridėdami naują levelį Donators (level 100).

// Display the user's level
function getuserlevel($userlevel) {
global $locale;
if ($userlevel==101) { return $locale['user1']; }
elseif ($userlevel==100) { return "Donator"; }
elseif ($userlevel==102) { return $locale['user2']; }
elseif ($userlevel==103) { return $locale['user3']; }
}


2. Eikite žemyn iki 450 eilutės.
// Check if user is assigned to the specified user group
function checkgroup($group) {
if (iSUPERADMIN && ($group == "0" || $group == "101" || $group == "102" || $group == "103")) { return true; }
elseif (iADMIN && ($group == "0" || $group == "101" || $group == "102")) { return true; }
elseif (iMEMBER && ($group == "0" || $group == "101")) { return true; }
elseif (iGUEST && $group == "0") { return true; }
elseif (iMEMBER && in_array($group, explode(".", iUSER_GROUPS))) {
return true;
} else {
return false;
}
}


Pakeičiame:
// Check if user is assigned to the specified user group
function checkgroup($group) {
if (iSUPERADMIN && ($group == "0" || $group == "100" || $group == "101" || $group == "102" || $group == "103")) { return true; }

elseif (iADMIN && ($group == "0" | $group == "100" || $group == "101" || $group == "102")) { return true; }
elseif (iDONATOR && ($group == "0" || $group == "101" || $group == "100")) { return true; }
elseif (iMEMBER && ($group == "0" || $group == "101")) { return true; }
elseif (iGUEST && $group == "0") { return true; }
elseif (iMEMBER && in_array($group, explode(".", iUSER_GROUPS))) {
return true;
} else {
return false;
}
}


3. Toliau einame į 464 eilutę.
// Compile access levels & user group array
function getusergroups() {
global $locale;
$groups_array = array(
array("0", $locale['user0']),
array("101", $locale['user1']),
array("102", $locale['user2']),
array("103", $locale['user3'])
);
$gsql = dbquery("SELECT group_id,group_name FROM ".DB_PREFIX."user_groups");
while ($gdata = dbarray($gsql)) {
array_push($groups_array, array($gdata['group_id'], $gdata['group_name']));
}
return $groups_array;
}


Pakeičiame:
// Compile access levels & user group array
function getusergroups() {
global $locale;
$groups_array = array(
array("0", $locale['user0']),
array("100", "Donator"),
array("101", $locale['user1']),
array("102", $locale['user2']),
array("103", $locale['user3'])

);
$gsql = dbquery("SELECT group_id,group_name FROM ".DB_PREFIX."user_groups");
while ($gdata = dbarray($gsql)) {
array_push($groups_array, array($gdata['group_id'], $gdata['group_name']));
}
return $groups_array;
}


4. Toliau leidžiamės į 481 eilutę.
// Get the name of the access level or user group
function getgroupname($group) {
global $locale;
if ($group == "0") { return $locale['user0']; }
elseif ($group == "101") { return $locale['user1']; }
elseif ($group == "102") { return $locale['user2']; }
elseif ($group == "103") { return $locale['user3'];
} else {
$gsql = dbquery("SELECT group_id,group_name FROM ".DB_PREFIX."user_groups WHERE group_id='$group'");
if (dbrows($gsql)!=0) {
$gdata = dbarray($gsql);
return $gdata['group_name'];
} else {
return "N/A";
}
}
}


Kurią pakeičiame:
// Get the name of the access level or user group
function getgroupname($group) {
global $locale;
if ($group == "0") { return $locale['user0']; }
elseif ($group == "100") { return "Donator"; }
elseif ($group == "101") { return $locale['user1']; }
elseif ($group == "102") { return $locale['user2']; }
elseif ($group == "103") { return $locale['user3'];
} else {
$gsql = dbquery("SELECT group_id,group_name FROM ".DB_PREFIX."user_groups WHERE group_id='$group'");
if (dbrows($gsql)!=0) {
$gdata = dbarray($gsql);
return $gdata['group_name'];
} else {
return "N/A";
}
}
}


5. Liekame tame pačiame faile, 500 eilutėje.
function groupaccess($field) {
if (iSUPERADMIN) { $res = "($field='0' OR $field='101' OR $field='102' OR $field='103'";
} elseif (iADMIN) { $res = "($field='0' OR $field='101' OR $field='102'";
} elseif (iMEMBER) { $res = "($field='0' OR $field='101'";
} elseif (iGUEST) { $res = "($field='0'"; }
if (iUSER_GROUPS != "") $res .= " OR $field='".str_replace(".", "' OR $field='", iUSER_GROUPS)."'";
$res .= ")";
return $res; }


Ją pakeičiame į:
function groupaccess($field) {
if (iSUPERADMIN) { $res = "($field='0' [color=red]OR $field='100'[/color] OR $field='101' OR $field='102' OR $field='103'";
} elseif (iADMIN) { $res = "($field='0' [color=red]OR $field='100'[/color] OR $field='101' OR $field='102'";
} elseif (iDONATOR) { $res = "($field='0' OR $field='101' OR $field='100'";
} elseif (iMEMBER) { $res = "($field='0' OR $field='101'";
} elseif (iGUEST) { $res = "($field='0'"; }
if (iUSER_GROUPS != "") $res .= " OR $field='".str_replace(".", "' OR $field='", iUSER_GROUPS)."'";
$res .= ")";
return $res; }


6. Galiausiai 650 eilutėje
// User level, Admin Rights & User Group definitions
define("iGUEST",$userdata['user_level'] == 0 ? 1 : 0);
define("iDONATOR", $userdata['user_level'] >= 100 ? 1 : 0);
define("iMEMBER", $userdata['user_level'] >= 101 ? 1 : 0);
define("iADMIN", $userdata['user_level'] >= 102 ? 1 : 0);
define("iSUPERADMIN", $userdata['user_level'] == 103 ? 1 : 0);
define("iUSER", $userdata['user_level']);
define("iUSER_RIGHTS", $userdata['user_rights']);
define("iUSER_GROUPS", substr($userdata['user_groups'], 1));


Pridedame:
// User level, Admin Rights & User Group definitions
define("iGUEST",$userdata['user_level'] == 0 ? 1 : 0);
define("iDONATOR", $userdata['user_level'] >= 100 ? 1 : 0);
define("iMEMBER", $userdata['user_level'] >= 101 ? 1 : 0);
define("iADMIN", $userdata['user_level'] >= 102 ? 1 : 0);
define("iSUPERADMIN", $userdata['user_level'] == 103 ? 1 : 0);
define("iUSER", $userdata['user_level']);
define("iUSER_RIGHTS", $userdata['user_rights']);
define("iUSER_GROUPS", substr($userdata['user_groups'], 1));


Gero naudojimo :)

Pagal @MAnjack