public function __construct()
    {
        parent::__construct();

        $user_id = IsSetGetPost(USERS_USERID);
        if (!$user_id)
        {
            $user_id = BoydsnestSession::GetInstance()->get(USERS_USERID);
        }

        try
        {
            $user_factory =& FCore::LoadDBFactory(BN_DBFACTORY_USERMODEL);
            $this->data = $user_factory->select_first($user_id, array(
                        DBFactory::SELECT_GET_ONLY => array(
                            USERS_USERID, USERS_USERNAME, USERS_SCHEMEUSING,
                            USERS_EMAIL, USERS_SECRETANSWER, USERS_SECRETQUESTION,
                            USERS_EXPIRESWHEN, USERS_CREATEDWHEN
                        )
                    ));
        }
        catch(DBFactoryException $e)
        {
            throw new UserActionException(
                    "An Error Occurred While Trying To Get The Profile",
                    $e);
        }
    }
Beispiel #2
0
    public function __construct($user_id = false)
    {
        parent::__construct();

        // getting the user id
        if (!$user_id)
        {
            $user_id = IsSetGetPost(USERS_USERID);
            if (!$user_id)
            {
                throw new UserActionException("no user selected");
            }
            if (!is_numeric($user_id))
            {
                throw new UserActionException("user id must be numeric");
            }
        }

        // getting the user data
        try
        {
            $user_factory =& FCore::LoadDBFactory(BN_DBFACTORY_USERMODEL);
            $this->data = $user_factory->select_first($user_id);
        }
        catch(Exception $e)
        {
            throw new UserActionException($e->getMessage());
        }
    }
 public function collect()
 {
     $this->manual_factory =& FCore::LoadDBFactory(BN_DBFACTORY_USERMANUALMODEL);
     if (!$this->manual_factory)
     {
         throw new UserActionException(
                 "Cannot Connect To The Usermanual DB");
     }
     $this->page_id = IsSetPost(USERMANUAL_PAGEID);
     if (!$this->page_id)
     {
         throw new UserActionException(
                 "A Page Must Be Selected To Delete");
     }
 }
Beispiel #4
0
 public function validate()
 {
     $this->user_factory =& FCore::LoadDBFactory(BN_DBFACTORY_USERMODEL);
     $user = $this->user_factory->select_first(
             array(
                 array(
                     DBFactory::ID_KEY   => USERS_USERNAME,
                     DBFactory::ID_SIGN  => "=",
                     DBFactory::ID_VAL   => $this->username
                 )
             ),
             array(
                 DBFactory::SELECT_GET_ONLY => array(
                     USERS_USERID,
                     USERS_USERNAME,
                     USERS_PASSWORD,
                     USERS_SALT,
                     USERS_ISACTIVE
                 )
             )
         );
     if ($user == null)
     {
         if (isset($_SESSION[SESSION_LOGIN_ATTEMPTS]))
         {
             $_SESSION[SESSION_LOGIN_ATTEMPTS]++;
         }
         else
         {
             $_SESSION[SESSION_LOGIN_ATTEMPTS] = 1;
         }
         $this->invalid_login_attempt();
     }
     if (!$user[USERS_ISACTIVE])
     {
         DBLogger::log(BN_LOGTYPE_FAILEDLOGIN,
                 "inactive user ".$user[USERS_USERNAME]." attempted to log in");
     }
     if (!BoydsnestSession::GetInstance()->CheckLoginAttempt(
             $user[USERS_USERNAME],
             $this->password,
             $user[USERS_SALT],
             $user[USERS_PASSWORD]))
     {
         $this->invalid_login_attempt();
     }
     $this->user_id = $user[USERS_USERID];
 }
    public function __construct()
    {
        $user_id = IsSetPost(USERS_USERID);
        if (!$user_id)
        {
            throw new UserActionException("a user must be selected to update");
        }
        if (!is_numeric($user_id))
        {
            throw new UserActionException("a user id must be numeric");
        }

        $password = IsSetPost(USERS_PASSWORD);
        if (!$password)
        {
            throw new UserActionException("a password must be set");
        }
        if (!is_string($password))
        {
            throw new UserActionException("a password must a string");
        }
        if (strlen($password) > 20)
        {
            throw new UserActionException("a password cannot be longer than 20 characters");
        }
        if (strlen($password) < 5)
        {
            throw new UserActionException("a password cannot be shorter than 5 characters");
        }
        
        $new_data[USERS_SALT] = GetNewSalt();
        $new_data[USERS_PASSWORD] = GetSecondOrderHash(
                $password,
                $new_data[USERS_SALT]);

        try
        {
            $user_factory =& FCore::LoadDBFactory(BN_DBFACTORY_USERMODEL);
            $user_factory->update($new_data, $user_id);
        }
        catch(Exception $e)
        {
            throw new UserActionException($e->getMessage());
        }
    }
Beispiel #6
0
    public function do_create()
    {
        $user_factory =& FCore::LoadDBFactory(BN_DBFACTORY_USERMODEL);
        $data_rules = $user_factory->get_db_data_rules(
                DataRules::METHOD_POST, false);
        $this->data = GrabDataFromGlobal($data_rules);

        $this->data[USERS_ISMASTER]       = "0";
        $this->data[USERS_SCHEMEUSING]    = 'default';
        $this->data[USERS_CREATEDWHEN]    = array(
            DBFactory::INSERT_ESCAPE_VAL    => false,
            DBFactory::INSERT_QUOTE         => false,
            DBFactory::INSERT_VALUE         => "NOW()"
        );

        $password = IsSetPost(USERS_PASSWORD);
        $this->data[USERS_SALT]     = GetNewSalt();
        $this->data[USERS_PASSWORD] = GetSecondOrderHash($password, $this->data[USERS_SALT]);

        try
        {
            $data_rules->validate_data($this->data);
        }
        catch(Exception $e)
        {
            $this->data[USERS_PASSWORD] = $password;
            throw new UserActionException($e->getMessage());
        }

        try
        {
            $this->data[USERS_USERID] = $user_factory->insert($this->data);
        }
        catch(DBFactoryException $e)
        {
            $this->data[USERS_PASSWORD] = $password;
            throw new UserActionException($e->getPrevious()->getMessage());
        }
        catch(Exception $e)
        {
            $this->data[USERS_PASSWORD] = $password;
            throw new UserActionException($e->getMessage());
        }
    }
 public function __construct()
 {
     parent::__construct();
     try
     {
         $user_factory =& FCore::LoadDBFactory(BN_DBFACTORY_USERMODEL);
         $this->data = $user_factory->select(
                 array(
                     array(
                         DBFactory::ID_KEY => USERS_USERNAME,
                         DBFactory::ID_SIGN => "!=",
                         DBFactory::ID_VAL => "guest",
                     ),
                     "AND",
                     array(
                         DBFactory::ID_KEY => USERS_USERNAME,
                         DBFactory::ID_SIGN => "!=",
                         DBFactory::ID_VAL => "system",
                     ),
                     "AND",
                     array(
                         DBFactory::ID_KEY => USERS_USERID,
                         DBFactory::ID_SIGN => "!=",
                         DBFactory::ID_VAL => BoydsnestSession::GetInstance()->get(USERS_USERID),
                     ),
                     "AND",
                     array(
                         DBFactory::ID_KEY => USERS_ISACTIVE,
                         DBFactory::ID_SIGN => "=",
                         DBFactory::ID_VAL => 1,
                     ),
                 ),
                 array(
                     DBFactory::SELECT_GET_ONLY => array(
                         USERS_USERID, USERS_USERNAME, USERS_DEFAULTRIGHT
                     ),
                     DBFactory::SELECT_ORDER_BY => USERS_USERNAME
                 ));
     }
     catch(Exception $e)
     {
         throw new DataCollection($e->getMessage());
     }
 }
    public function __construct()
    {
        $user_id = IsSetPost(USERS_USERID);
        if (!$user_id)
        {
            throw new UserActionException("a user must be selected to update");
        }
        if (!is_numeric($user_id))
        {
            throw new UserActionException("a user id must be numeric");
        }

        try
        {
            $user_factory =& FCore::LoadDBFactory(BN_DBFACTORY_USERMODEL);
            $rules = $user_factory->get_db_data_rules(DataRules::METHOD_POST);

            $rule_keys = $rules->get_rule_keys();
            foreach($rule_keys as $key)
            {
                if ($key != USERS_EMAIL &&
                    $key != USERS_SECRETANSWER &&
                    $key != USERS_SECRETQUESTION &&
                    $key != USERS_SCHEMEUSING)
                {
                    $rules->remove_rule($key);
                }
            }

            $data = $rules->get_global_data_and_validate();

            $user_factory->update($data, $user_id);
        }
        catch(ValidationException $e)
        {
            throw new UserActionException($e->getMessage());
        }
        catch(DBFactoryException $e)
        {
            throw new UserActionException(
                    "An Error Occurred While Trying To Update The Profile",
                    $e);
        }
    }
 public function collect()
 {
     $this->manual_factory =&
             FCore::LoadDBFactory(BN_DBFACTORY_USERMANUALMODEL);
     if (!$this->manual_factory)
     {
         throw new UserActionException(
                 "Cannot Connect To Usermanual DB");
     }
     $this->page_id = IsSetPost(USERMANUAL_PAGEID);
     $this->page_content = IsSetPost(USERMANUAL_CONTENT);
     if ($this->page_id === false || 
         $this->page_id === '' ||
         $this->page_content === false)
     {
         throw new UserActionException(
                 "Must Specify Content And A Page ID");
     }
 }
 public function collect()
 {
     $manual_factory =& FCore::LoadDBFactory(BN_DBFACTORY_USERMANUALMODEL);
     if (!$manual_factory)
     {
         throw new UserActionException("Cannot Load Usermanual DB");
     }
     $this->data = $manual_factory->select(null,
             array(
                 DBFactory::SELECT_GET_ONLY => array(
                     USERMANUAL_PAGEID, USERMANUAL_TITLE, USERMANUAL_RANK
                 ),
                 DBFactory::SELECT_ORDER_BY => USERMANUAL_RANK
         ));
     if (!$this->data)
     {
         throw new UserActionException("No Data In The Usermanual DB");
     }
 }
Beispiel #11
0
    public function __construct()
    {
        $user_id = IsSetPost(USERS_USERID);
        if (!$user_id)
        {
            throw new UserActionException("a user must be selected to update");
        }
        if (!is_numeric($user_id))
        {
            throw new UserActionException("a user id must be numeric");
        }

        $user_factory =& FCore::LoadDBFactory(BN_DBFACTORY_USERMODEL);
        $data_rules = $user_factory->get_db_data_rules(
                DataRules::METHOD_POST, true);

        $data_rules->remove_rule(USERS_USERID);
        $data_rules->remove_rule(USERS_USERNAME);
        $data_rules->remove_rule(USERS_PASSWORD);
        $data_rules->remove_rule(USERS_SALT);
        $data_rules->remove_rule(USERS_LASTUPDATE);
        $data_rules->remove_rule(USERS_CREATEDWHEN);
        $data_rules->remove_rule(USERS_ISMASTER);

        $data = false;
        try
        {
            $data = $data_rules->get_global_data_and_validate();
        }
        catch(Exception $e)
        {
            throw new UserActionException($e->getMessage());
        }

        try
        {
            $user_factory->update($data, $user_id);
        }
        catch(Exception $e)
        {
            throw new UserActionException($e->getMessage());
        }
    }
 public function collect()
 {
     $this->manual_factory =
             FCore::LoadDBFactory(BN_DBFACTORY_USERMANUALMODEL);
     if ($this->manual_factory == null)
     {
         throw new UserActionException(
                 "Cannot Load The Usermanual DB");
     }
     $this->data[USERMANUAL_TITLE]   = IsSetPost(USERMANUAL_TITLE);
     $this->data[USERMANUAL_RANK]    = IsSetPost(USERMANUAL_RANK);
     if ($this->data[USERMANUAL_TITLE] === false ||
         $this->data[USERMANUAL_RANK] === false ||
         $this->data[USERMANUAL_TITLE] === '' ||
         $this->data[USERMANUAL_RANK] === '')
     {
         throw new UserActionException(
                 "All Required Data Must Be Inserted");
     }
 }
Beispiel #13
0
    public function __construct()
    {
        parent::__construct();

        $user_factory = false;
        try
        {
            $user_factory =& FCore::LoadDBFactory(BN_DBFACTORY_USERMODEL);
            $this->data = $user_factory->select(
                    array(
                        array(
                            DBFactory::ID_KEY   => USERS_USERNAME,
                            DBFactory::ID_SIGN  => "!=",
                            DBFactory::ID_VAL   => "system"
                        ),
                        "AND",
                        array(
                            DBFactory::ID_KEY   => USERS_USERNAME,
                            DBFactory::ID_SIGN  => "!=",
                            DBFactory::ID_VAL   => "Guest"
                        ),
                        "AND",
                        array(
                            DBFactory::ID_KEY   => USERS_USERID,
                            DBFactory::ID_SIGN  => "!=",
                            DBFactory::ID_VAL   => BoydsnestSession::GetInstance()->get(USERS_USERID)
                        ),
                    ),
                    array(
                        DBFactory::SELECT_GET_ONLY => array(
                            USERS_USERID, USERS_USERNAME, USERS_CREATEDWHEN,
                            USERS_ISACTIVE, USERS_LASTUPDATE, USERS_ISLOGGED
                        )
                    ));
        }
        catch(Exception $e)
        {
            throw new UserActionException($e->getMessage());
        }
    }
Beispiel #14
0
    public function __construct()
    {
        // getting the user id
        $user_id = IsSetPost(USERS_USERID);
        if (!$user_id)
        {
            throw new UserActionException("no user selected");
        }
        if (!is_numeric($user_id))
        {
            throw new UserActionException("user id must be numeric");
        }

        // getting the user factory
        $user_factory;
        try
        {
            $user_factory =& FCore::LoadDBFactory(BN_DBFACTORY_USERMODEL);
        }
        catch(Exception $e)
        {
            throw new UserActionException($e->getMessage());
        }

        // actually deleting
        try
        {
            $user_factory->delete($user_id);
            $page_ids = DBForum::DeleteForum(BN_DATATYPE_USERPAGES, $user_id);
            foreach($page_ids as $page_id)
            {
                DBForum::DeleteForum(BN_DATATYPE_PAGERESPONSES, $page_id);
            }
        }
        catch(Exception $e)
        {
            throw new UserActionException($e->getMessage());
        }
    }
Beispiel #15
0
    public function collect()
    {
        try
        {
            $this->user_factory =& FCore::LoadDBFactory(BN_DBFACTORY_USERMODEL);
        }
        catch(Exception $e)
        {
            throw new UserActionException($e->getMessage());
        }

        // initial try to get the required data to do the action
        $this->start = IsSetGet('start');
        $this->amount = IsSetGet('amount');

        // if any of them are false, then attempt post data
        if ($this->start === false || $this->amount === false)
        {
            $this->start = IsSetPost('start');
            $this->amount = IsSetPost('amount');
        }

        // if still any are false, do default values
        if ($this->start === false || $this->amount === false)
        {
            $this->start = 0;
            $this->amount = 40;
        }

        // now check to make sure that all of them are numeric
        if (!is_numeric($this->start))
        {
            throw new UserActionException('start must be numeric');
        }
        if (!is_numeric($this->amount))
        {
            throw new UserActionException('amount must be numeric');
        }
    }
 public function collect()
 {
     $this->manual_factory =&
             FCore::LoadDBFactory(BN_DBFACTORY_USERMANUALMODEL);
     if (!$this->manual_factory)
     {
         throw new UserActionException(
                 "Cannot Connect To Usermanual DB");
     }
     $this->page_id = IsSetPost(USERMANUAL_PAGEID);
     $this->page_title = IsSetPost(USERMANUAL_TITLE);
     $this->page_rank = IsSetPost(USERMANUAL_RANK);
     if ($this->page_id === false || 
             $this->page_title === false ||
             $this->page_rank === false ||
             $this->page_id === '' ||
             $this->page_title === '' ||
             $this->page_rank === '')
     {
         throw new UserActionException(
                 "Must Specify Page Rank, Title And ID");
     }
 }
    public function __construct()
    {
        parent::__construct();

        try
        {
            $user_factory =& FCore::LoadDBFactory(BN_DBFACTORY_USERMODEL);
            $rules = $user_factory->get_db_data_rules();

            foreach($rules->get_rule_keys() as $key)
            {
                $rule = $rules->get_rule($key);
                if (isset($rule[DataRules::DEFAULT_]))
                {
                    $this->data[$key] = $rule[DataRules::DEFAULT_];
                }
            }
        }
        catch(Exception $e)
        {
            throw new UserActionException($e->getMessage());
        }
    }
 public function collect()
 {
     $manual_factory =& FCore::LoadDBFactory(BN_DBFACTORY_USERMANUALMODEL);
     if (!$manual_factory)
     {
         throw new UserActionException("Cannot Load Usermanual DB");
     }
     $page_id = IsSetGet(USERMANUAL_PAGEID);
     if (!$page_id)
     {
         $page_id = IsSetPost(USERMANUAL_PAGEID);
     }
     if (!$page_id)
     {
         $this->data = $manual_factory->select_first(array(
                 array(
                     DBFactory::ID_ESCAPE=> false,
                     DBFactory::ID_KEY   => USERMANUAL_RANK,
                     DBFactory::ID_SIGN  => "=",
                     DBFactory::ID_VAL   => "(SELECT min(".USERMANUAL_RANK.") FROM ".USERMANUAL.")"
                 )
             ));
         if (!$this->data)
         {
             throw new UserActionException("No Usermanual Pages Found");
         }
     }
     else
     {
         $this->data = $manual_factory->select_first($page_id);
         if (!$this->data)
         {
             throw new UserActionException(
                     "Cannot Find Usermanual Page With Requested ID");
         }
     }
 }
    public function __construct()
    {
        $new_master_id = IsSetPost(USERS_USERID);
        if (!$new_master_id)
        {
            throw new UserActionException("a user must be selected to update");
        }
        if (!is_numeric($new_master_id))
        {
            throw new UserActionException("a user id must be numeric");
        }

        try
        {
            $user_factory =& FCore::LoadDBFactory(BN_DBFACTORY_USERMODEL);
            $user_factory->update(array(USERS_ISMASTER => "0"), "");
            $user_factory->update(array(USERS_ISMASTER => "1"), $new_master_id);
            BoydsnestSession::GetInstance()->set(USERS_ISMASTER, 0);
        }
        catch(Exception $e)
        {
            throw new UserActionException($e->getMessage());
        }
    }
Beispiel #20
0
<?php

require_once '../../Boydsnest.php';
require_once FCORE_FILE_DBFACTORY;

header("Content-type: text/css");

$name = IsSetGet("name", "default");

FCore::$LOG_TO_HTML = false;

$scheme = FCore::LoadDBFactory(BN_DBFACTORY_SCHEMEMODEL);
$scheme_instance = $scheme->select_first(
        array(
            array(DBFactory::ID_KEY => SCHEME_SCHEMENAME,
                  DBFactory::ID_SIGN => "=",
                  DBFactory::ID_VAL => $name)
        ));

if ($scheme_instance == null){
    $scheme_instance = $scheme->select_first(
        array(
            array(DBFactory::ID_KEY => SCHEME_SCHEMENAME,
                  DBFactory::ID_SIGN => "=",
                  DBFactory::ID_VAL => "default"
            )
        ));

    if ($scheme_instance == null){
        echo "Error: no data found in database";
        return;
Beispiel #21
0
    public function __construct($user_id = false)
    {
        parent::__construct();

        $user_factory = false;
        try
        {
            $user_factory =& FCore::LoadDBFactory(BN_DBFACTORY_USERMODEL);
            if (!$user)
            {
                $this->data = $user_factory->select(
                        array(
                            array(
                                DBFactory::ID_KEY => USERS_USERNAME,
                                DBFactory::ID_SIGN => "!=",
                                DBFactory::ID_VAL => "guest"
                            ),
                            "AND",
                            array(
                                DBFactory::ID_KEY => USERS_USERNAME,
                                DBFactory::ID_SIGN => "!=",
                                DBFactory::ID_VAL => "system"
                            ),
                            "AND",
                            array(
                                DBFactory::ID_KEY => USERS_ISACTIVE,
                                DBFactory::ID_SIGN => "=",
                                DBFactory::ID_VAL => 1
                            ),
                            "AND",
                            array(
                                DBFactory::ID_KEY => USERS_USERID,
                                DBFactory::ID_SIGN => "!=",
                                DBFactory::ID_VAL =>
                                    BoydsnestSession::GetInstance()->get(USERS_USERID)
                            ),
                        ),
                        array(
                            DBFactory::SELECT_GET_ONLY => array(
                                USERS_USERID, USERS_USERNAME
                            ),
                            DBFactory::SELECT_ORDER_BY => USERS_USERNAME
                        ));
            }
            else
            {
                $this->data = $user_factory->select(
                        $user_id,
                        array(
                            DBFactory::SELECT_GET_ONLY => array(
                                USERS_USERID, USERS_USERNAME
                            ),
                            DBFactory::SELECT_ORDER_BY => USERS_USERNAME
                        ));
            }
        }
        catch(Exception $e)
        {
            throw new UserActionException($e->getMessage());
        }
    }
Beispiel #22
0
    public function __construct()
    {
        parent::__construct();

        // getting the user id
        $this->user_id = IsSetGetPost(USERS_USERID);
        if (!$this->user_id)
        {
            throw new UserActionException("no user selected");
        }
        if (!is_numeric($this->user_id))
        {
            throw new UserActionException("user id must be numeric");
        }

        $this->start  = IsSetGetPost('start', 0);
        $this->amount = IsSetGetPost('amount', 20);

        if (!is_numeric($this->start))
        {
            $this->start = 0;
        }
        if (!is_numeric($this->amount))
        {
            $this->amount = 20;
        }

        // get the username
        try
        {
            $user_factory = FCore::LoadDBFactory(BN_DBFACTORY_USERMODEL);
            $this->username = $user_factory->select_first(
                    $this->user_id,
                    array(
                        DBFactory::SELECT_GET_ONLY => array(
                            USERS_USERNAME
                        )
                    ));
            if ($this->username == null)
            {
                $this->username = "******";
            }
            else
            {
                $this->username = $this->username[USERS_USERNAME];
            }
        }
        catch(Exception $e)
        {
            FCore::GetLogger()->log(Logger::LEVEL_ERROR, $e->getMessage());
            DBLogger::log(BN_LOGTYPE_ERROR, $e->getMessage());
            $this->username = "******";
        }

        // getting the user logs
        try
        {
            $this->data = DBLogger::GetLimitedBy(
                    USERS.$this->user_id, $this->start, $this->amount);
        }
        catch(DBLoggerException $e)
        {
            throw new UserActionException($e->getMessage());
        }
    }
    public function __construct()
    {
        // get page id
        $page_id = IsSetPost(DBForum::POST_ID);
        if (!$page_id || !is_numeric($page_id))
        {
            throw new UserActionException("no page selected", null);
        }

        // get the user ids and make sure that they are in the correct format
        $user_ids = IsSetPost("user_ids");
        if (!$user_ids)
        {
            throw new UserActionException("no users selected", null);
        }
        $user_ids = preg_split('/\:/', $user_ids);
        if (!is_array($user_ids))
        {
            throw new UserActionException("no users selected", null);
        }
        foreach($user_ids as $user_id)
        {
            if (!is_numeric($user_id))
            {
                throw new UserActionException(
                        "an error occurred with the format of user ids", null);
            }
        }

        // get the forum for the user
        $forum = DBForum::GetForum(
                BN_DATATYPE_USERPAGES,
                BoydsnestSession::GetInstance()->get(USERS_USERID));
        if ($forum == null)
        {
            throw new UserActionException(
                    "error occurred while trying to load the user pages", null);
        }
        $metadata = unserialize($forum->get_metadata());
        if (!array_key_exists($page_id, $metadata))
        {
            $metadata[$page_id] = array();
        }

        // get the list of rights for all the users
        $user_rights = array();
        try
        {
            $user_factory =& FCore::LoadDBFactory(BN_DBFACTORY_USERMODEL);
            $raw_rights = $user_factory->select(
                    $user_ids,
                    array(
                        DBFactory::SELECT_GET_ONLY => array(
                            USERS_USERID, USERS_DEFAULTRIGHT
                        )
                    ));
            foreach($raw_rights as $right)
            {
                $user_rights[$right[USERS_USERID]] = $right[USERS_DEFAULTRIGHT];
            }
        }
        catch(Exception $e)
        {
            throw new UserActionException($e->getMessage(), $e);
        }

        foreach($user_ids as $user_id)
        {
            if (!array_key_exists($user_id, $user_rights))
            {
                throw new UserActionException(
                        "system error occurred with user ids 1", null);
            }
            $defaultright = $user_rights[$user_id];
            $askedright = IsSetPost($user_id);
            if ($askedright === false)
            {
                throw new UserActionException(
                        "system error occurred with user ids 2", null);
            }
            if ($askedright != USERS_DEFAULTRIGHT_NONE &&
                $askedright != USERS_DEFAULTRIGHT_SEE &&
                $askedright != USERS_DEFAULTRIGHT_COMMENT &&
                $askedright != USERS_DEFAULTRIGHT_WRITE)
            {
                throw new UserActionException(
                        "system error occurred with user ids 3", null);
            }
            if ($askedright < $defaultright)
            {
                throw new UserActionException(
                        "system error occurred with user ids 4", null);
            }
            if ($askedright == $defaultright)
            {
                if (array_key_exists($user_id, $metadata[$page_id][PAGERIGHTS]))
                {
                    unset($metadata[$page_id][PAGERIGHTS][$user_id]);
                }
            }
            else if($askedright > $defaultright)
            {
                $metadata[$page_id][PAGERIGHTS][$user_id] = $askedright;
            }
        }

        $forum->set_metadata(serialize($metadata));
    }
    public function __construct($selected = null)
    {
        parent::__construct();

        $user_factory =& FCore::LoadDBFactory(BN_DBFACTORY_USERMODEL);
        if (!$user_factory)
        {
            throw new UserActionException(
                    "could not connect to the user database", null);
        }

        try
        {
            $this->data = $user_factory->select(
                    array(
                        array(
                            DBFactory::ID_KEY   => USERS_USERNAME,
                            DBFactory::ID_SIGN  => "!=",
                            DBFactory::ID_VAL   => "system",
                        ),
                        "AND",
                        array(
                            DBFactory::ID_KEY   => USERS_USERNAME,
                            DBFactory::ID_SIGN  => "!=",
                            DBFactory::ID_VAL   => "guest",
                        ),
                        "AND",
                        array(
                            DBFactory::ID_KEY   => USERS_ISACTIVE,
                            DBFactory::ID_SIGN  => "=",
                            DBFactory::ID_VAL   => "1",
                        ),
                        "AND",
                        array(
                            DBFactory::ID_KEY   => USERS_ISFAMILY,
                            DBFactory::ID_SIGN  => "=",
                            DBFactory::ID_VAL   => "1",
                        ),
                    ),
                    array(
                        DBFactory::SELECT_GET_ONLY => array(
                            USERS_USERID, USERS_USERNAME, 
                        ),
                        DBFactory::SELECT_ORDER_BY => USERS_USERNAME
                    ));
        }
        catch(DBFactoryException $e)
        {
            throw new UserActionException(
                    "an error occurred while getting user data", $e);
        }

        if ($selected)
        {
            foreach($this->data as $key => $user)
            {
                if ($user[USERS_USERID] == $selected[USERS_USERID])
                {
                    $this->data[$key][DBForum::POSTCHILDREN] = FCore::LoadObject(
                        "pages/GetUserPageHierarchy",
                        array(
                            USERS_USERID    => $selected[USERS_USERID],
                            "extended"      => true,
                        ));
                    if (is_a($this->data[$key][DBForum::POSTCHILDREN], "DataCollection"))
                    {
                        $this->data[$key][DBForum::POSTCHILDREN] =
                                $this->data[$key][DBForum::POSTCHILDREN]->get_data();
                    }
                    break;
                }
            }
        }
    }