/** * Save new blog entry * * @return void redirect */ protected function _save() { // Check permission if (!$this->model->access('content')) { throw new Exception(Lang::txt('ALERTNOTAUTH'), 403); } // Incoming $managers = Request::getInt('managers_only', 0); $entry = trim(Request::getVar('blogentry', '')); // Text clean-up $entry = \Hubzero\Utility\Sanitize::stripScripts($entry); $entry = \Hubzero\Utility\Sanitize::stripImages($entry); // Instantiate project microblog entry $objM = new \Components\Projects\Tables\Blog($this->_database); if ($entry) { $objM->projectid = $this->model->get('id'); $objM->blogentry = $entry; $objM->managers_only = $managers; $objM->posted = Date::toSql(); $objM->posted_by = $this->_uid; // Save new blog entry if (!$objM->store()) { $this->setError($objM->getError()); } else { $this->_msg = Lang::txt('PLG_PROJECTS_BLOG_NEW_BLOG_ENTRY_SAVED'); } // Get new entry ID if (!$objM->id) { $objM->checkin(); } // Record activity if ($objM->id) { $aid = $this->model->recordActivity(Lang::txt('COM_PROJECTS_SAID'), $objM->id, '', '', 'blog', 1); } // Store activity ID if ($aid) { $objM->activityid = $aid; $objM->store(); } } // Pass error or success message if ($this->getError()) { Notify::message($this->getError(), 'error', 'projects'); } elseif (!empty($this->_msg)) { Notify::message($this->_msg, 'success', 'projects'); } // Redirect App::redirect(Route::url($this->model->link())); }