public static function access() { $db = CONFIG::primary_database(); if (isset(self::$roles[$db]) && self::$roles[$db]["types"][self::role()]) { foreach (self::$roles[$db]["types"][self::role()]["value"] as $subkey => $subvalue) { if (self::startswith(strtolower($subkey), "view:")) { if (CONFIG::has_attribute($subvalue, "name", true) && $subvalue["@attributes"]["name"] == REQUEST::GET("view")) { self::has_redirect($subvalue); self::is_allowed_in_subview($subvalue); if (!self::$allowed_in_subview || !self::$allowed_in_view && !self::$has_subview) { self::$redirect = true; } } } } } //role can't be found error ? }
public static function access() { if (REQUEST::$POST && FORM::passed()) { if (isset(FORM::$ACCOUNT[self::$FORMNAME]) && isset(FORM::$ACCOUNT[self::$FORMNAME]["access_type"]) && isset(FORM::$COLUMN[self::$FORMNAME]) && !empty(FORM::$COLUMN[self::$FORMNAME])) { $db = CONFIG::primary_database(); if (isset(ACCOUNT::$roles[$db])) { $username_value = null; $password_value = null; $dbconfig = ACCOUNT::get_database_config(); extract($dbconfig); $accountname = self::$FORMNAME; foreach (FORM::$COLUMN[self::$FORMNAME] as $field => $schema) { if ($table == $schema["table"]) { if ($schema["column"] == ACCOUNT::$roles[$db]["username"]) { $username_value = FORM::$accountname("username"); } if ($schema["column"] == ACCOUNT::$roles[$db]["password"]) { $password_value = self::bool_val(ACCOUNT::$roles[$db]["encrypt_password"]) == true ? ACCOUNT::encrypt_password(FORM::$accountname("password")) : FORM::$accountname("password"); } } } if ($username_value != null) { $useraccount = ACCOUNT::get($username, $username_value); if ($useraccount != null) { if (FORM::$ACCOUNT[self::$FORMNAME]["access_type"] == "recover") { ACCOUNT::recover($useraccount); } if (FORM::$ACCOUNT[self::$FORMNAME]["access_type"] == "register") { ACCOUNT::$error_already_exists = true; } if (FORM::$ACCOUNT[self::$FORMNAME]["access_type"] == "login") { if ($useraccount->{$password} == $password_value) { SESSION::setaccount($useraccount->{$id}); } else { ACCOUNT::$error_log_in_failed = true; } } } else { if (FORM::$ACCOUNT[self::$FORMNAME]["access_type"] == "register") { ACCOUNT::create(FORM::fields()); } elseif (FORM::$ACCOUNT[self::$FORMNAME]["access_type"] == "recover") { ACCOUNT::$error_not_found = true; } else { ACCOUNT::$error_not_found = true; } } } else { ACCOUNT::$error_log_in_failed = true; } } } } }