function DoSubscribeAction() { $request = Project::getRequest(); $request_user_id = (int) Project::getUser()->getShowedUser()->id; $user_id = (int) Project::getUser()->getDbUser()->id; if ($user_id) { $subscribeModel = new BlogSubscribeModel(); $subscribe_id = $subscribeModel->isSubscribed($user_id, $request->tree_id); $subscribeModel->load($subscribe_id); if ($subscribeModel->id) { $subscribeModel->delete($subscribe_id); } else { $subscribeModel->user_id = $user_id; $subscribeModel->ub_tree_id = $request->tree_id; $subscribeModel->save(); } } Project::getResponse()->redirect($_SERVER['HTTP_REFERER']); }
function ChangeAction() { $request = Project::getRequest(); $request_user_id = (int) Project::getUser()->getShowedUser()->id; $user_id = (int) Project::getUser()->getDbUser()->id; $tree_id = (int) $request->getKeyByNumber(0); $subscribe_model = new BlogSubscribeModel(); $subscribe_model->changeSubscribe($user_id, $tree_id); $info = array(); $info['id'] = $tree_id; $this->_view->Change($info); $this->_view->ajax(); }