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);
        }
    }
Example #2
0
    public function __construct($data)
    {
        parent::__construct();

        if (!isset($data["user_id"]) || !is_numeric($data["user_id"]))
        {
            throw new UserActionException("user_id must be numeric", null);
        }
        if (!isset($data["page_id"]) || !is_numeric($data["page_id"]))
        {
            throw new UserActionException("page_id must be numeric", null);
        }

        $forum = DBForum::GetForum(BN_DATATYPE_USERPAGES, $data["user_id"]);
        
        $this->data   = $forum->post_get($data["page_id"]);
        if ($this->data[DBForum::METADATA] != null)
        {
            $extra = unserialize($this->data[DBForum::METADATA]);

            $this->data[PAGETITLE] =
                    array_key_exists(PAGETITLE, $extra)
                    ? $extra[PAGETITLE] : "";
            $this->data[PAGETYPE] =
                    array_key_exists(PAGETYPE, $extra)
                    ? $extra[PAGETYPE] : BN_PAGETHREADTYPE_NONE;
            $this->data[PAGEPRIVATE] =
                    array_key_exists(PAGEPRIVATE, $extra)
                    ? $extra[PAGEPRIVATE] : false;
            if ($this->data[DBDataType::CONTENT] == null)
            {
                $this->data[DBDataType::CONTENT] = "";
            }
        }

        $this->data[PAGEFOLLOWERS] = array();
        $this->data[PAGERIGHTS] = array();
        $forum_meta = unserialize($forum->get_metadata());
        if (is_array($forum_meta) &&
            array_key_exists($data["page_id"], $forum_meta))
        {
            $this_meta = $forum_meta[$data["page_id"]];
            if (array_key_exists(PAGEFOLLOWERS, $this_meta))
            {
                $this->data[PAGEFOLLOWERS] = $this_meta[PAGEFOLLOWERS];
            }
            if (array_key_exists(PAGERIGHTS, $this_meta))
            {
                $this->data[PAGERIGHTS] = $this_meta[PAGERIGHTS];
            }
        }
    }
    public function __construct($page_id)
    {
        parent::__construct();

        if (!is_numeric($page_id))
        {
            throw new UserActionException('page id must be numeric', null);
        }

        $forum = DBForum::GetForum(BN_DATATYPE_PAGERESPONSES, $page_id);
        if ($forum == null)
        {
            return;
        }

        $this->data = $forum->build_hierarchy();
    }
Example #4
0
    public function __construct()
    {
        $page_state = array();

        $page_state[USERS_USERID] = IsSetGet(USERS_USERID);
        $page_state[DBForum::POST_ID] = IsSetGet(DBForum::POST_ID);

        if (!$page_state[USERS_USERID] &&
            !$page_state[DBForum::POST_ID])
        {
            $page_state = false;
        }
        else if ($page_state[USERS_USERID] &&
                !$page_state[DBForum::POST_ID])
        {
            $page_state[DBForum::POST_ID] = DBForum::GetFirstRootIdOfForum(
                    BN_DATATYPE_USERPAGES,
                    $page_state[USERS_USERID]);
            if ($page_state[DBForum::POST_ID] == null)
            {
                throw new UserActionException(
                        "no pages were found with this user", null);
            }
        }
        else if (!$page_state[USERS_USERID] ||
                 !$page_state[DBForum::POST_ID])
        {
            $page_state = false;
        }

        if (is_array($page_state))
        {
            if (!is_numeric($page_state[USERS_USERID]))
            {
                throw new UserActionException(
                        "user id must be numeric", null);
            }
            if (!is_numeric($page_state[DBForum::POST_ID]))
            {
                throw new UserActionException(
                        "page id must be numeric", null);
            }
        }

        $this->state = $page_state;
    }
    public function __construct($data)
    {
        parent::__construct();

        if (!is_array($data))
        {
            throw new UserActionException("invalid data type", null);
        }
        if (!array_key_exists("page_id", $data))
        {
            throw new UserActionException("no page id specified", null);
        }
        if (!array_key_exists("post_id", $data))
        {
            throw new UserActionException("no post id specified", null);
        }

        $forum = DBForum::GetForum(BN_DATATYPE_PAGERESPONSES, $data["page_id"]);

        $this->data = $forum->post_get($data["post_id"]);
    }
Example #6
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());
        }
    }
Example #7
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);
        }
    }
Example #8
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);
        }
    }
    public function __construct($data = null)
    {
        parent::__construct();

        $user_id    = BoydsnestSession::GetInstance()->get(USERS_USERID);
        $page_root  = 0;
        $extended   = false;

        if (is_array($data))
        {
            if (array_key_exists(USERS_USERID, $data))
            {
                $user_id = $data[USERS_USERID];
            }
            if (array_key_exists("page_id", $data))
            {
                $page_root = $data["page_id"];
            }
            if (array_key_exists("extended", $data))
            {
                $extended = $data["extended"];
            }
        }
        else if (is_numeric($data))
        {
            $user_id = $data;
        }

        $forum = DBForum::GetForum(BN_DATATYPE_USERPAGES, $user_id);
        if ($forum == null)
        {
            $this->data = null;
            return;
        }

        $data;
        if ($extended)
        {
            $data = $forum->build_hierarchy($page_root);
        }
        else
        {
            $data = $forum->post_get_children($page_root);
        }

        if ($data == null)
        {
            $this->data = null;
            return;
        }

        foreach($data as $page)
        {
            $meta = unserialize($page[DBForum::METADATA]);
            if (is_array($meta))
            {
                if (array_key_exists(PAGETITLE, $meta))
                {
                    $page[PAGETITLE] = $meta[PAGETITLE];
                }
                if (array_key_exists(PAGEPRIVATE, $meta))
                {
                    $page[PAGEPRIVATE] = $meta[PAGEPRIVATE];
                }
                if (array_key_exists(PAGETYPE, $meta))
                {
                    $page[PAGETYPE] = $meta[PAGETYPE];
                }
            }
            $this->data[] = $page;
        }
    }
    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));
    }
Example #11
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);
        }
    }
Example #12
0
            $forum->post_create("users", 123, "he said hello", $post_id);
            $forum->post_create("users", 12, "how are you");
$post_id2 = $forum->post_create("users", 124, "i'm going to move my post by parent");
$post_id5 = $forum->post_create("users", 124, "i'm going to change my content");
            $forum->post_create("users", 13, "i'm fine, how are you");
            $forum->post_create("users", 12, "i'm doing good");
$post_id6 = $forum->post_create("users", 124, "i'm goign to be deleted");
$post_id3 = $forum->post_create("users", 124, "i'm going to move my post by order");
            $forum->post_create("users", 13, "thats nice");
$post_id =  $forum->post_create("users", 12, "eat shit");
$post_id4 = $forum->post_create("users", 12, "i'm sorry, i take it back", $post_id);
            $forum->post_create("users", 123, "he said sorry", $post_id4);
            $forum->post_create("users", 123, "he said sorry", $post_id);
            $forum->post_create("users", 13, "thats nice");

$forum->post_update($post_id2, false, $post_id, false);
$forum->post_update($post_id3, false, false, -1);
$forum->post_update($post_id5, "i changed my content", false, false);
$forum->post_delete($post_id6);

$hierarchy = $forum->build_hierarchy();
print_forum($hierarchy, $forum);

echo "<br /><br /><br />";

$hierarchy = $forum->build_hierarchy($post_id);
print_forum($hierarchy, $forum);

DBForum::DeleteForum("test", 123);

?>