本文整理汇总了PHP中Forum::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Forum::save方法的具体用法?PHP Forum::save怎么用?PHP Forum::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Forum
的用法示例。
在下文中一共展示了Forum::save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveForum
public function saveForum(Forum $forum = null)
{
if ($forum == null) {
$forum = new Forum();
}
$forum->name = Input::get("name");
$forum->description = Input::get("description");
$forum->category_id = Input::get("category");
$forum->sect_id = Input::get("sect") == "NULL" ? null : Input::get("sect");
$forum->clan_id = Input::get("clan") == "NULL" ? null : Input::get("clan");
$forum->background_id = Input::get("background") == "NULL" ? null : Input::get("background");
$forum->read_permission = Input::get("read-permission") == "NULL" ? null : Input::get("read-permission");
$forum->topic_permission = Input::get("topic-permission") == "NULL" ? null : Input::get("topic-permission");
$forum->reply_permission = Input::get("reply-permission") == "NULL" ? null : Input::get("reply-permission");
$forum->is_private = Input::get("private") ? 1 : 0;
$forum->show_on_st_todo_list = Input::get("todo_list") ? 1 : 0;
$forum->asymmetric_replies = Input::get("asymmetric") ? 1 : 0;
$forum->time_limited = Input::get("time-limited") ? 1 : 0;
$forum->player_specific_threads = Input::get("player-specific-threads") ? 1 : 0;
$forum->position = Input::get("position");
$forum->list_header = trim(Input::get("list-header"));
$forum->post_header = trim(Input::get("post-header"));
$forum->thread_template = trim(Input::get("thread-template"));
$forum->save();
Cache::flush();
return Redirect::to('dashboard/storyteller/manage/forums');
}
示例2: actionCreate
/**
* Creates a new forum.
* If creation is successful, the browser will be redirected to the 'show' page.
*/
public function actionCreate()
{
$forum = new Forum();
if (isset($_POST['Forum'])) {
$forum->attributes = $_POST['Forum'];
if ($forum->save()) {
$this->redirect(array('show', ' id' => $forum->id));
}
}
$this->render('create', array('forum' => $forum));
}
示例3: actionCreate
/**
* Создает новую модель Форума.
* Если создание прошло успешно - перенаправляет на просмотр.
*
* @return void
*/
public function actionCreate()
{
$model = new Forum();
if (($data = Yii::app()->getRequest()->getPost('Forum')) !== null) {
$model->setAttributes($data);
if ($model->save()) {
Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('ForumModule.forum', 'Record was created!'));
$this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['create']));
}
}
$this->render('create', ['model' => $model]);
}
示例4: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Forum();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Forum'])) {
$model->attributes = $_POST['Forum'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->ForumID));
}
}
$this->render('create', array('model' => $model));
}
示例5: actionCreate
/**
* create action
*/
public function actionCreate($parentid = null)
{
$forum = new Forum();
$forum->parent_id = $parentid;
// Set default
if (isset($_POST['Forum'])) {
if (!isset($_POST['YII_CSRF_TOKEN']) || $_POST['YII_CSRF_TOKEN'] != Yii::app()->getRequest()->getCsrfToken()) {
throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
}
$forum->attributes = $_POST['Forum'];
if ($forum->validate()) {
if ((int) $forum->parent_id < 1) {
$forum->parent_id = null;
}
$forum->save();
$this->redirect($this->createUrl("index"));
}
}
$this->render('editforum', array('model' => $forum));
}
示例6: save
/**
* Adds a forum assigned to the user when it is created
*
* @return bool
*/
public function save(PropelPDO $con = null)
{
//Check if it's a new user before saving
$new = $this->isNew();
$this->setLastActivityAt(time());
//Save and return false on an error
if (!parent::save($con)) {
return false;
}
//If it was new...
if ($new) {
//Create a forum for it
$forum = new Forum();
$forum->setName($this->getName());
$forum->setType(Forum::TYPE_USER_FORUM);
$forum->setEntityId($this->getId());
//If the forum didn't work
if (!$forum->save()) {
//Delete the group and return false
$this->delete();
return false;
}
}
return true;
}
示例7: edit_topic
public function edit_topic(Request $request, $matches)
{
$title = $this->lang->translate('forum.create');
// Get page for updating
$id = intval($matches->get('id', $request->get('id')));
// Parent topic
$topics = \Forum::as_array(\Forum::find('all', ['conditions' => ['forum_id = 0 AND id <> ?', $id]]));
if ($id > 0) {
$forum = \Forum::find_by_id($id);
$title = $this->lang->translate('forum.editing', $forum->title);
} else {
$forum = ['title' => $this->lang->translate('page.name'), 'forum_id' => null];
}
// Create or update page
if ($request->isMethod('post')) {
if ($forum instanceof \Forum) {
$forum->title = $request->get('title');
$forum->forum_id = $request->get('forum');
$forum->author_id = $this->user->id;
} else {
$forum = new \Forum(['title' => $request->get('title'), 'forum_id' => $request->get('forum'), 'author_id' => $this->user->id]);
}
// Updating instance
$forum->save();
$forum = $forum->to_array();
return static::json_response(['success' => true, 'message' => $this->lang->translate('form.saved')]);
}
return $this->view->render('forum/create.twig', ['forum' => $forum, 'title' => $title, 'topics' => $topics]);
}