public function editAction() { $request = $this->getRequest(); $board_id = $request->getRequest('board_id'); $board_info = Model_Boards::getBoard($board_id); if (!$board_info) { $this->forward('error', 'error404'); } $shared = Model_Boards::allowEdit($board_id); if ($board_info['user_id'] != JO_Session::get('user[user_id]')) { if (!$shared) { $this->forward('error', 'error404'); } } $this->view->shared = $shared; if ($shared) { $_POST['newboard'] = $board_info['title']; $_POST['category_id'] = $board_info['category_id']; } $this->view->is_edit = true; if ($request->isPost()) { if (JO_Session::get('user[user_id]')) { if (trim($request->getPost('newboard'))) { $data = Model_Boards::editBoard($board_id, array('title' => trim($request->getPost('newboard')), 'category_id' => $request->getPost('category_id'), 'friends' => $request->getPost('friends'))); if ($data) { $data = array(); $data['href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . JO_Session::get('user[user_id]') . '&board_id=' . $board_id); $this->view->data = $data; } else { $this->view->error = $this->translate('There was a problem with the record. Please try again!'); } } else { $this->view->error = $this->translate('Board name must not be empty!'); } } else { $this->view->error = 'error login'; } echo $this->renderScript('json'); } else { $this->view->cat_title = Model_Boards::getCategoryTitle($board_info['category_id']); $this->view->title = $board_info['title']; $this->view->category_id = $board_info['category_id']; $this->view->another_users = array(); $this->view->board_id = $board_id; $model_images = new Helper_Images(); foreach ($board_info['board_users'] as $u) { $avatar = Helper_Uploadimages::avatar($u, '_A'); $u['avatar'] = $avatar['image']; $u['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $u['user_id']); $this->view->another_users[] = $u; } $uin = Model_Users::getUser($board_info['user_id']); $avatar = Helper_Uploadimages::avatar($uin, '_A'); $this->view->avatar = $avatar['image']; $this->view->fullname = $uin['fullname']; $this->view->userhref = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $uin['user_id']); $this->view->friends_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=friends'); $this->view->form_action = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=edit&user_id=' . $uin['user_id'] . '&board_id=' . $board_id); $this->view->board_href = WM_Router::create($request->getBaseUrl() . '?controller=boards&user_id=' . $uin['user_id'] . '&board_id=' . $board_id); $this->view->board_delete = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=delete&user_id=' . $uin['user_id'] . '&board_id=' . $board_id); //////////// Categories //////////// $this->view->categories = array(); $categories = Model_Categories::getCategories(array('filter_status' => 1)); foreach ($categories as $category) { $category['subcategories'] = Model_Categories::getSubcategories($category['category_id']); $this->view->categories[] = $category; } $this->view->popup_main_box = $this->view->render('popup_form', 'boards'); $this->setViewChange('form'); if ($request->isXmlHttpRequest()) { $this->view->popup = true; echo $this->view->popup_main_box; $this->noViewRenderer(true); } else { $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part'); } } }