private function getBoardsInfo() { $boards_info = array(); $this->nid = isset($this->shared_data['network_id']) ? $this->shared_data['network_id'] : PA::$network_info->network_id; $boards = PaForumBoard::listPaForumBoard("network_id = {$this->nid} AND is_active = 1", 'type', 'ASC', 10); if (count($boards) > 0) { for ($i = 0; $i < count($boards); $i++) { $title = $boards[$i]->get_title(); $type = $boards[$i]->get_type(); $boards_info[$i]['title'] = strlen($title) <= self::max_title_length ? $title : substr($title, 0, self::max_title_length + 3) . '...'; $boards_info[$i]['type'] = $type; $net_id = $boards[$i]->get_network_id(); if (Network::is_mother_network($net_id)) { $address = 'www'; } else { $network = Network::get_by_id((int) $net_id); $address = $network->address; } $url = "http://{$address}." . PA::$domain_suffix . PA_ROUTE_FORUMS . "/network_id=" . $net_id; switch ($type) { case PaForumBoard::network_board: break; case PaForumBoard::group_board: $url .= "&gid=" . $boards[$i]->get_owner_id(); break; case PaForumBoard::personal_board: $url .= "&user_id=" . $boards[$i]->get_owner_id(); break; } $boards_info[$i]['url'] = $url; } } return $boards_info; }
private function handleGET_newBoard($request_data) { global $error_msg; $forum_defaults = array('allow_anonymous_post' => false, 'membership_approval' => false, 'allow_users_create_category' => true, 'allow_users_create_forum' => true, 'threads_per_page' => 20, 'posts_per_page' => 20, 'post_edit_mode' => 'tinymce_base', 'avatar_size' => '85x100', 'banned_message' => 'You are banned from this forum!', 'join_requested_message' => 'Your membership request has been sent.', 'join_approved_message' => 'Your membership request has been approved.'); switch ($this->board_type) { case PaForumBoard::network_board: $network = Network::get_by_id((int) $request_data['parent_id']); $title = $network->name . " " . __("network forum board"); break; case PaForumBoard::group_board: $group = Group::load_group_by_id((int) $request_data['parent_id']); $title = $group->title . " " . __("group forum board"); break; case PaForumBoard::personal_board: $user = new User(); $user->load((int) $request_data['parent_id']); $title = $user->login_name . " " . __("personal forum board"); break; } if ($request_data['owner_id'] == PA::$login_uid) { $params = array("owner_id" => $request_data['parent_id'], "network_id" => $this->nid, "title" => $title, "description" => __("Forum Board description goes here"), "type" => $this->board_type, "theme" => 'default', "settings" => serialize($forum_defaults), "is_active" => 1, "created_at" => date("Y-m-d H:i:s")); try { $board_id = PaForumBoard::insertPaForumBoard($params); } catch (Exception $e) { unset($request_data['action']); unset($request_data['owner_id']); $err = "Exception in ForumModule, function handleGET_newBoard();<br />Message: " . $e->getMessage(); $this->redirectWithMessage($err, $request_data); } $status = PaForumsUsers::_owner | PaForumsUsers::_allowed; try { $params = array("user_id" => $request_data['owner_id'], "board_id" => $board_id, "user_status" => $status, "is_active" => 1, "date_join" => date("Y-m-d H:i:s")); PaForumsUsers::insertPaForumsUsers($params); } catch (Exception $e) { unset($request_data['action']); unset($request_data['owner_id']); $err = "Exception in ForumModule, function handleGET_newBoard();<br />Message: " . $e->getMessage(); $this->redirectWithMessage($err, $request_data); } unset($request_data); $request_data['board_id'] = $board_id; $this->redirectWithMessage(__("Forum Board sucessfully saved"), $request_data, 'info_message'); } else { $error_msg = __("You don't have permissions to create this Forum Board!"); return 'skip'; } }