Пример #1
0
    public function __construct()
    {
        $log_ids = IsSetPost(DBLogger::LOGID);
        if ($log_ids === false)
        {
            throw new UserActionException("nothing to delete");
        }


        foreach($log_ids as $id)
        {
            if (!is_numeric($id))
            {
                throw new SecurityException(
                        "all message ids must be numeric");
            }
        }


        try
        {
            DBLogger::delete($log_ids);
        }
        catch(DBLoggerException $e)
        {
            throw new UserActionException($e->getMessage());
        }
    }
Пример #2
0
 public function attempt_login()
 {
     $template = "userlogin";
     $message = "";
     try
     {
         // all it needs to do is attempt the action, it will
         // throw a DataCollection error if username and password
         // is not filled out, and it will throw a ValidationException
         // if the combination of the two is does not match
         $this->load_local_object("AttemptLogin");
         $template = "loginmessage";
         $session = BoydsnestSession::GetInstance();
         $message = "Welcome ".$session->get(USERS_USERNAME)."!!!";
     }
     catch(UserActionException $e)
     {
         $message = $e->getMessage();
     }
     $page = $this->ready_master();
     $page->apply_param(
             "main_content",
             $this->load_local_php_view(
                     $template,
                     array(
                         'message' => $message,
                         'username' => IsSetPost(USERS_USERNAME, "")
                     ))
             );
     $page->commit_applies();
     return $page->get_page();
 }
Пример #3
0
 public function collect()
 {
     $this->message_ids = IsSetPost(DBMessage::MESSAGE_ID);
     if ($this->message_ids === false)
     {
         throw new UserActionException("nothing to delete");
     }
 }
Пример #4
0
    public function __construct()
    {
        $page_id = IsSetPost(DBForum::POST_ID);
        if (!is_numeric($page_id))
        {
            throw new UserActionException(
                    "a page id must be specified", null);
        }

        $forum = DBForum::GetForum(
                BN_DATATYPE_USERPAGES,
                BoydsnestSession::GetInstance()->get(USERS_USERID));
        if ($forum == null)
        {
            throw new UserActionException(
                    "an error occurred while trying to get the forum", null);
        }

        $new_parent = IsSetPost(DBForum::POSTPARENT);
        $new_order  = IsSetPost(DBForum::POSTORDER);
        if (!is_bool($new_parent) && !is_numeric($new_parent))
        {
            throw new UserActionException(
                    "parent id is not in the correct format", null);
        }
        if (!is_bool($new_order) && !is_numeric($new_order))
        {
            throw new UserActionException(
                    "order id is not in the correct format", null);
        }

        $page = $forum->post_get($page_id, false);
        if ($new_order == $page[DBForum::POSTORDER] ||
            $new_parent == $page[DBForum::POSTPARENT])
        {
            return;
        }

        try
        {
            $forum->post_update(
                    $page_id,
                    false,
                    $new_parent,
                    $new_order,
                    false);
        }
        catch(DBForumException $e)
        {
            throw new UserActionException(
                    "An error occurred while trying to update the page: ".$e->getMessage(), $e);
        }
    }
Пример #5
0
 public function collect()
 {
     $this->password = IsSetPost(USERS_PASSWORD);
     $this->username = IsSetPost(USERS_USERNAME);
     if ($this->password === false ||
         $this->password === "" ||
         $this->username == false  ||
         $this->username == "")
     {
         throw new UserActionException(
                 "Both A Username And A Password Must Be Set");
     }
 }
Пример #6
0
    public function __construct()
    {
        if (!BoydsnestSession::GetInstance()->get(USERS_CANMESSAGE))
        {
            throw new SecurityException(
                    "you are not allowed to send messages");
        }


        
        $message    = IsSetPost(DBMessage::MESSAGE);
        $title      = IsSetPost(DBMessage::TITLE);
        $users_to   = IsSetPost(DBMessage::FCORE_MESSAGE_TOS);
        $user_from  = BoydsnestSession::GetInstance()->get(USERS_USERID);



        if ($message === false)
        {
            $message = '';
        }
        if ($title === false || $title == '')
        {
            $title = "none";
        }
        if (!is_array($users_to) || sizeof($users_to) == 0)
        {
            throw new UserActionException("no user to is specified");
        }
        if ($user_from === false)
        {
            throw new UserActionException("cannot find user from id");
        }


        try
        {
            DBMessage::CreateMessage(
                    $message,
                    $title,
                    array(
                        DBMessage::ORIGIN_ID => $user_from,
                        DBMessage::ORIGIN_TYPE => USERS
                    ),
                    $users_to);
        }
        catch(Exception $e)
        {
            throw new UserActionException($e->getMessage());
        }
    }
Пример #7
0
 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");
     }
 }
Пример #8
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");
        }

        $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());
        }
    }
Пример #9
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());
        }
    }
Пример #10
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");
        }

        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);
        }
    }
Пример #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());
        }
    }
Пример #12
0
 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");
     }
 }
Пример #13
0
 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");
     }
 }
Пример #14
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');
        }
    }
Пример #15
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());
        }
    }
Пример #16
0
 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 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");
         }
     }
 }
Пример #18
0
    public function __construct()
    {
        $page_id = IsSetPost(DBForum::POST_ID);
        if (!is_numeric($page_id))
        {
            throw new UserActionException(
                    "a page id must be specified", null);
        }

        $forum = DBForum::GetForum(
                BN_DATATYPE_USERPAGES,
                BoydsnestSession::GetInstance()->get(USERS_USERID));

        try
        {
            $forum->post_delete($page_id, true);
            $meta = unserialize($forum->get_metadata());
            $new_meta = array();
            foreach($forum->post_get_id_list() as $page)
            {
                if (array_key_exists($page, $meta))
                {
                    $new_meta[$page] = $meta[$page];
                }
            }
            $forum->set_metadata(serialize($new_meta));
            DBForum::DeleteForum(
                    BN_DATATYPE_PAGERESPONSES,
                    $page_id);
        }
        catch(DBForumException $e)
        {
            throw new UserActionException(
                    "An error occurred while trying to delete the page: ".$e->getMessage(), $e);
        }
    }
Пример #19
0
    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());
        }
    }
Пример #20
0
    public function create_page($request)
    {
        FCore::LoadObject("security/IsMasterSecurityCheck");
        $page_title = IsSetPost(USERMANUAL_TITLE, '');
        $page_rank  = IsSetPost(USERMANUAL_RANK);
        $message    = 'Fill In The Information Below To Create A Usermanual Page';
        if ($request == ACTION.ACTION_CREATE)
        {
            try
            {
                $this->load_local_object("actions/CreateUserManualPage");
                return $this->init_request(ACTION_LIST);
            }
            catch(UserActionException $e)
            {
                if ($this->logger != null)
                {
                    $this->logger->log(
                            Logger::LEVEL_WARN,
                            $e->getMessage(),
                            $e->getFile(), $e->getLine());
                }
                $message = $e->getMessage();
            }
            catch(ValidationException $e)
            {
                if ($this->logger != null)
                {
                    $this->logger->log(
                            Logger::LEVEL_WARN,
                            $e->getMessage(),
                            $e->getFile(), $e->getLine());
                }
                $message = $e->getMessage();
            }
            catch(Exception $e)
            {
                if ($this->logger != null)
                {
                    $this->logger->log(
                            Logger::LEVEL_ERROR,
                            $e->getMessage(),
                            $e->getFile(), $e->getLine());
                }
                $message = "An Unexpected Error Occurred: Please Contact The Admin";
            }
        }

        if (!$page_rank)
        {
            $page_rank_getter = $this->load_local_object(
                    "actions/GetNextUserManualRank");
            $page_rank = $page_rank_getter->get_rank();
        }

        $page = $this->ready_master($request);
        $page->consume_string(
                "content",
                $this->load_local_php_view(
                        "views/create",
                        array(
                            'title'     => $page_title,
                            'rank'      => $page_rank,
                            'message'   => $message,
                        )));
        return $page->get_page();
    }
Пример #21
0
    public function do_action()
    {
        $this->data[USERS_USERID] = IsSetPost(USERS_USERID);
        if (!$this->data[USERS_USERID])
        {
            throw new UserActionException(
                    "a user must be selected");
        }

        $forum = DBForum::GetForum(
                BN_DATATYPE_USERPAGES,
                $this->data[USERS_USERID]);
        if ($forum == null)
        {
            try
            {
                DBForum::CreateForum(
                        BN_DATATYPE_USERPAGES,
                        $this->data[USERS_USERID],
                        DBDataType::DATATYPE_MTEXT);
                $forum = DBForum::GetForum(
                    BN_DATATYPE_USERPAGES,
                    $this->data[USERS_USERID]);
            }
            catch(DBForumException $e)
            {
                throw new UserActionException(
                    "an error occurred while trying to create the forum",
                    $e);
            }
        }

        $this->data[PAGETITLE]      = IsSetPost(PAGETITLE, false);
        $this->data[PAGETYPE]       = IsSetPost(PAGETYPE, false);
        $this->data[PAGEPRIVATE]    = IsSetPost(PAGEPRIVATE, 0);
        if (!$this->data[PAGETITLE] || $this->data[PAGETITLE] == '')
        {
            throw new UserActionException("title must be set", null);
        }
        if ($this->data[PAGETYPE] != BN_PAGETHREADTYPE_NONE &&
            $this->data[PAGETYPE] != BN_PAGETHREADTYPE_SINGLE &&
            $this->data[PAGETYPE] != BN_PAGETHREADTYPE_MULTI)
        {
            throw new UserActionException("invalid thread type", null);
        }
        if (!is_numeric($this->data[PAGEPRIVATE]))
        {
            var_dump($this->data[PAGEPRIVATE]);
            throw new UserActionException("invalid private page value", null);
        }
        $metadata   = serialize(array(
                PAGETITLE     => $this->data[PAGETITLE],
                PAGETYPE      => $this->data[PAGETYPE],
                PAGEPRIVATE   => $this->data[PAGEPRIVATE],
            ));
        $this->data[DBDataType::CONTENT] = IsSetPost(DBDataType::CONTENT, '');

        $parent = 0;
        $order = false;
        $this->data["position"] = IsSetPost("position");
        if ($this->data["position"])
        {
            $position = preg_split('/\:/', $this->data["position"]);
            if (is_array($position))
            {
                $parent = $position[0];
                if (sizeof($position) == 2)
                {
                    try
                    {
                        $children = $forum->post_get_children($parent);
                        if (is_array($children))
                        {
                            foreach($children as $child)
                            {
                                if ($order === false)
                                {
                                    if ($child[DBForum::POST_ID] == $position[1])
                                    {
                                        $order = $child[DBForum::POSTORDER] + 1;
                                    }
                                }
                                else
                                {
                                    $forum->post_update(
                                            $child[DBForum::POST_ID],
                                            false,
                                            false,
                                            $child[DBForum::POSTORDER] + 1,
                                            false);
                                }
                            }
                        }
                    }
                    catch(DBForumException $e)
                    {
                        throw new UserActionException(
                                "An error occurred while trying to create the page", $e);
                    }
                }
            }
        }

        try
        {
            $this->data[DBForum::POST_ID] = $forum->post_create(
                    BN_DATATYPE_USERPAGES,
                    $this->data[USERS_USERID],
                    $this->data[DBDataType::CONTENT],
                    $parent,
                    $order,
                    $metadata);
            DBForum::CreateForum(
                    BN_DATATYPE_PAGERESPONSES,
                    $this->data[DBForum::POST_ID],
                    DBDataType::DATATYPE_TEXT);
        }
        catch(DBForumException $e)
        {
            throw new UserActionException(
                    "An error occurred while trying to create the page", $e);
        }
    }
Пример #22
0
    public function write_message($request)
    {
        $message = "";
        if ($request == ACTION.ACTION_WRITE."message")
        {
            try
            {
                $this->load_local_object('personal/objects/WriteMessage');
                $message = "successfully sent message";
                return $this->list_messages($request, $message);
            }
            catch(UserActionException $e)
            {
                $message = $e->getMessage();
            }
        }

        $user_to            = IsSetPost(USERS_USERID, null);
        $message_content    = IsSetPost(DBMessage::MESSAGE, "");
        $message_title      = IsSetPost(DBMessage::TITLE, "");
        if ($user_to == null)
        {
            $user_to = IsSetGet(USERS_USERID, null);
        }

        $user_list = false;
        try
        {
            $user_list = $this->load_local_object(
                    "personal/objects/GetUserList", $user_to);
            $user_list = $user_list->get_data();
        }
        catch(UserActionException $e)
        {
            $message .= $e->getMessage();
        }


        $master = $this->ready_master();
        $master->consume_string(
                "content",
                $this->load_local_php_view(
                        "personal/views/writemessage", array(
                            'message_content'   => $message_content,
                            'message_title'     => $message_title,
                            'message'           => $message,
                            'user_list'         => $user_list,
                            'user_id'           => $user_to
                        ))
                );
        return $master->get_page();
    }
Пример #23
0
    public function __construct()
    {
        $page_id = IsSetPost(DBForum::POST_ID);
        if (!is_numeric($page_id))
        {
            throw new UserActionException(
                    "a page id must be specified", null);
        }

        $forum = DBForum::GetForum(
                BN_DATATYPE_USERPAGES,
                BoydsnestSession::GetInstance()->get(USERS_USERID));
        if ($forum == null)
        {
            throw new UserActionException(
                    "an error occurred while trying to get the forum", null);
        }

        $page_data = $forum->post_get($page_id);
        if ($page_data == null)
        {
            throw new UserActionException(
                    "an error occurred while trying to find the page", null);
        }

        $metadata   = unserialize($page_data[DBForum::METADATA]);
        $title = IsSetPost(PAGETITLE, '');
        if (strlen($title) < 5)
        {
            throw new UserActionException(
                    "title must be longer then 5 characters", null);
        }
        if (strlen($title) > 20)
        {
            throw new UserActionException(
                    "title must be no longer then 20 characters", null);
        }
        $metadata[PAGETITLE] = $title;

        $private = IsSetPost(PAGEPRIVATE, 0);
        if (!is_numeric($private))
        {
            throw new UserActionException(
                    "input error with private", null);
        }
        $metadata[PAGEPRIVATE] = $private ? true : false;

        $content    = IsSetPost(DBDataType::CONTENT, false);

        try
        {
            $forum->post_update(
                    $page_id,
                    $content,
                    false,
                    false,
                    serialize($metadata));
        }
        catch(DBForumException $e)
        {
            throw new UserActionException(
                    "An error occurred while trying to update the page: ".$e->getMessage(), $e);
        }
    }
Пример #24
0
/**
 * 
 * @param array $rules
 * @return <type>
 */
function GrabDataFromGlobal(DataRules &$rules)
{
    $result = array();
    foreach($rules->get_rule_keys() as $key)
    {
        $rule = $rules->get_rule($key);
        $attempt;
        if (!isset($rule[DataRules::METHOD]))
        {
            continue;
        }
        switch($rule[DataRules::METHOD])
        {
            case DataRules::METHOD_GET:
                $attempt = IsSetGet($key, false);
                break;
            case DataRules::METHOD_POST:
                $attempt = IsSetPost($key, false);
                break;
            case DataRules::METHOD_SESSION:
                $attempt = IsSetSession($key, false);
                break;
        }
        if ($attempt !== false)
        {
            $result[$key] = $attempt;
        }
    }
    return $result;
}
Пример #25
0
 /**
  *
  * @param <type> $return_result
  * @return <type> 
  */
 public function get_global_data_and_validate()
 {
     $result = array();
     $keys = array_keys($this->rules);
     foreach($keys as $key)
     {
         $rule = $this->get_rule($key);
         $attempt = false;
         if (!isset($rule[DataRules::METHOD]))
         {
             continue;
         }
         switch($rule[DataRules::METHOD])
         {
             case DataRules::METHOD_GET:
                 $attempt = IsSetGet($key, false);
                 break;
             case DataRules::METHOD_POST:
                 $attempt = IsSetPost($key, false);
                 break;
             case DataRules::METHOD_SESSION:
                 $attempt = IsSetSession($key, false);
                 break;
             case DataRules::METHOD_GETPOST:
                 $attempt = IsSetGetPost($key, false);
                 break;
         }
         if ($attempt !== false)
         {
             $result[$key] = $attempt;
         }
     }
     return $this->validate_data($result, true);
 }
Пример #26
0
    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));
    }