protected function setUp() { // Setup some variables that will be used throughout this method. $title = 'Blog Bug 409 [' . Core::RandomHex(6) . ']'; $this->blog = new BlogModel(); $this->blog->set('title', $title); // Make sure the page model has been loaded into this model too. $page = $this->blog->getLink('Page'); $page->set('title', $title); $this->blog->save(); $bacon = new BaconIpsumGenerator(); // Create an article with an invalid title. $this->article = new BlogArticleModel(); $this->article->setFromArray(['blogid' => $this->blog->get('id'), 'title' => 'Sömé "ḮnvÁlid" & \'Bad\' T¹tle!¡', 'body' => $bacon->getParagraphsAsMarkup(), 'status' => 'published']); $this->article->save(); }
public function actionBlogCreate() { $model = new BlogModel(); if (isset($_POST['blog'])) { $model->setAttrs($_POST['blog']); $model->date = date("d.m.Y"); if ($_FILES['mainImage']['name']) { $model->mainImage = File::save($_FILES['mainImage'], "assets/images/blog"); } $model->save(); $this->redirect("/admin/blog"); } $this->view("admin/blog/create", array("model" => "BlogModel"), false); }
function RegistrationAction() { //if (true || $this -> ValidateRegistrationAction()){ if ($this->ValidateRegistrationAction()) { $request = Project::getRequest(); $user_model = new UserModel(); $user_model->login = $request->login; $user_model->salt = AppCrypt::generateSalt(); $user_model->pass = AppCrypt::getHash($request->pwd, $user_model->salt); $user_model->email = $request->email; $user_model->first_name = $request->name; $user_model->last_name = $request->surname; $user_model->middle_name = $request->father_name; $user_model->birth_date = $request->year . "-" . $request->month . "-" . $request->day; $user_model->gender = (int) $request->gender; $user_model->marital_status = $request->marital_status; $user_model->icq = $request->icq; $user_model->website = $request->website; $user_model->phone = $request->phone; $user_model->mobile_phone = $request->mobile_phone; $user_model->about = $request->about; $user_model->books = $request->books; $user_model->films = $request->films; $user_model->musicians = $request->musicians; $referer = new UserModel(); $referer->loadByLogin($request->referer); $user_model->referal = $referer->id ? $referer->id : 0; $user_model->country_id = (int) $request->country; $user_model->state_id = (int) $request->state; $user_model->city_id = (int) $request->city; $user_model->user_type_id = UserTypeModel::REGISTRED; $user_model->reputation = 0; $user_model->rate = 0; $user_model->nextmoney = 0; $user_model->registration_date = date("Y-m-d H:i:s"); $user_model->banned = 0; $user_id = (int) $user_model->save(); $rate_nm = $user_model->getUserRateNMByRegistrationData($user_id); if ($rate_nm['nm']) { $user_model->changeUserMoney($user_id, 0, $rate_nm['nm'], 'За регистрацию'); } if ($rate_nm['rate']) { $user_model->changeUserRate($user_id, 0, $rate_nm['rate']); } $separator = ","; if ($user_id <= 0) { $this->_view->addFlashMessage(FM::ERROR, "Ошибка регистрации!"); $this->RegistrationFormAction(); return; } $this->sendRegistrationMail($user_model, $request->pwd); if (strlen($request->interest)) { $interest_list = explode($separator, $request->interest); foreach ($interest_list as $interest) { $interest = trim($interest); if (strlen($interest)) { $interest_model = new InterestsModel(); $interest_id = $interest_model->set($interest); $user_interest_model = new UserInterestsModel(); $user_interest_model->set($user_id, $interest_id); } } } // Blog $blog_model = new BlogModel(); $blog_model->creation_date = date("Y-m-d"); $blog_model->creation_ip = $_SERVER['REMOTE_ADDR']; $blog_model->user_id = $user_id; $blog_model->title = 'Мой блог'; $blog_model->access = 2; $blog_model->save(); Project::getResponse()->redirect(Project::getRequest()->createUrl("User", "CompleteRegistration")); } else { $this->RegistrationFormAction(); } }
/** * Save blog info action */ function SaveAction() { $request = Project::getRequest(); $info = array(); $request_user_id = (int) Project::getUser()->getShowedUser()->id; $user_id = (int) Project::getUser()->getDbUser()->id; if ($request_user_id != $user_id || !$user_id) { Project::getResponse()->redirect($request->createUrl('Blog', 'PostList')); } $blog_model = new BlogModel(); $blog_model->loadByUserId($user_id); if ($blog_model->id <= 0) { $blog_model->creation_date = date("Y-m-d"); $blog_model->creation_ip = $_SERVER['REMOTE_ADDR']; } $blog_model->user_id = $user_id; $blog_model->title = $request->blog_title; $blog_model->access = $request->blog_access; $blog_model->save(); Project::getResponse()->redirect($request->createUrl('Blog', 'PostList')); }
public function AddCommentAction() { $request = Project::getRequest(); $item_name = $request->item_name; $comment_model = new CommentModel($item_name . '_comment', $item_name . '_id', 0); switch ($item_name) { case 'article': $item_model = new ArticleModel(); break; case 'questions': $item_model = new QuestionModel(); break; case 'photo': $item_model = new PhotoModel(); break; case 'bookmarks': $item_model = new BookmarksModel(); break; case 'social': $item_model = new SocialModel(); break; case 'blog': $item_model = new BlogModel('blog_post'); break; } $item_model->load($request->element_id); if ($item_model->id > 0 && $request->add_comment) { $comment_model->addComment(Project::getUser()->getDbUser()->id, $request->avatar_id, 0, $request->element_id, $request->comment, $request->mood_id, $request->mood_text, 0); $item_model->comments++; $item_model->save(); } Project::getResponse()->redirect($request->createUrl($request->cur_controller, $request->cur_action, array($request->element_id))); }