当前位置: 首页>>代码示例>>PHP>>正文


PHP Forum::find方法代码示例

本文整理汇总了PHP中Forum::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Forum::find方法的具体用法?PHP Forum::find怎么用?PHP Forum::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Forum的用法示例。


在下文中一共展示了Forum::find方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dispose

 /**
  * Delete child forums & topics
  */
 public function dispose()
 {
     // Drop subjects
     $subjects = Forum::find('all', ['conditions' => ['forum_id = ?', $this->id]]);
     foreach ($subjects as $sbj) {
         $sbj->delete();
     }
     // Drop themes
     $themes = ForumTheme::find('all', ['conditions' => ['forum_id = ?', $this->id]]);
     foreach ($themes as $thm) {
         $thm->delete();
     }
 }
开发者ID:Max201,项目名称:nanocore,代码行数:16,代码来源:Forum.php

示例2: new_topic

 /**
  * @param Request $request
  * @param $matches
  * @return mixed
  */
 public function new_topic(Request $request, $matches)
 {
     if ($access = $this->authenticated_only()) {
         return $access;
     }
     $subject = $matches->get('id');
     $subject = \Forum::find($subject);
     if (!$subject || !$subject->forum_id) {
         return $this->error404($request);
     }
     if ($request->isMethod('post') && $this->user->can('write_forum')) {
         $data = ['description' => trim($request->get('edit')), 'title' => trim($request->get('title')), 'author_id' => $this->user->id, 'forum_id' => $subject->id];
         $this->view->assign('data', $data);
         $errors = [];
         if (strlen($data['title']) < 3) {
             $errors[] = $this->lang->translate('forum.topic.title_len');
         }
         if (strlen($data['description']) < 3) {
             $errors[] = $this->lang->translate('forum.topic.body_len');
         }
         if (count($errors)) {
             $this->view->assign('errors', $errors);
         } else {
             $topic = new \ForumTheme($data);
             if ($topic->save()) {
                 /** @var Ping $ping */
                 $ping = NCService::load('SocialMedia.Ping');
                 return static::redirect_response($this->map->reverse('topic', ['id' => $topic->id]));
             } else {
                 $this->view->assign('errors', [$this->lang->translate('forum.topic.new_failed')]);
             }
         }
     }
     return $this->view->render('forum/create.twig', ['title' => $this->lang->translate('forum.topic.new'), 'subject' => $subject->to_array()]);
 }
开发者ID:Max201,项目名称:nanocore,代码行数:40,代码来源:Module.php

示例3: search

 public function search()
 {
     fallback($_GET['query'], "");
     $config = Config::current();
     if ($config->clean_urls and substr_count($_SERVER['REQUEST_URI'], "?") and !substr_count($_SERVER['REQUEST_URI'], "%2F")) {
         # Searches with / and clean URLs = server 404
         redirect("search/" . urlencode($_GET['query']) . "/");
     }
     if (empty($_GET['query'])) {
         return Flash::warning(__("Please enter a search term."));
     }
     list($where, $params) = keywords($_GET['query'], "name LIKE :query OR url LIKE :query", "forums");
     $forums = Forum::find(array("placeholders" => true, "where" => $where, "params" => $params));
     list($where, $params) = keywords($_GET['query'], "title LIKE :query OR description LIKE :query OR url LIKE :query", "topics");
     $topics = Topic::find(array("placeholders" => true, "where" => $where, "params" => $params));
     list($where, $params) = keywords($_GET['query'], "body LIKE :query", "messages");
     $messages = Message::find(array("placeholders" => true, "where" => $where, "params" => $params));
     $this->display("discuss/search", array("forums" => new Paginator($forums, 25, "forums_page"), "topics" => new Paginator($topics, 25, "topics_pave"), "messages" => new Paginator($messages, 25, "messages_page"), "search" => $_GET['query']), fix(_f("Search results for \"%s\"", $_GET['query'])));
 }
开发者ID:vito,项目名称:chyrp-site,代码行数:19,代码来源:controller.Discuss.php

示例4: getTopicCount

 /**
  * Compte le nombre de topic dans le forum
  *
  */
 public function getTopicCount($forumId)
 {
     $forum = Forum::find($forumId);
     return Topic::where('forum_id', '=', $forum->id)->count();
 }
开发者ID:raphaeljorge,项目名称:tor,代码行数:9,代码来源:Forum.php

示例5: saveBiography

 public function saveBiography($character)
 {
     $question_ids = Input::get('ids');
     $replies = Input::get('replies');
     if ($character) {
         foreach ($question_ids as $index => $q) {
             $response = CharacterQuestionnaire::firstOrNew(['character_id' => $character->id, 'questionnaire_id' => $q]);
             $response->response = $replies[$index];
             $response->save();
         }
         if (Input::hasFile('backstory')) {
             $file = Input::file('backstory');
             $fileName = preg_replace("([^\\w\\d\\-_~,;:\\[\\]\\(\\).])", '', $character->name . "Backstory." . $file->getClientOriginalExtension());
             $file->move(public_path() . '/content/backstories/', $fileName);
             $character->backstory_file = $fileName;
             $character->save();
         }
         if ($character->active || $character->in_review) {
             //Find the relevant forum post and bump it (or create it if it doesn't exist)
             $post = ForumPost::where('body', "[[questionnaire/{$character->id}]]")->first();
             if ($post) {
                 $topic = $post->topic;
                 $topic->postReply($character->owner->id, "Questionnaire responses updated. (Automatic system post)");
             } else {
                 //42 = Character Backgrounds
                 $topic = Forum::find(42)->post("Character Biography for " . $character->name, "[[questionnaire/{$character->id}]]");
                 $topic->markAsRead(Auth::user());
             }
             return Redirect::to("/forums/topic/" . $topic->id);
         } else {
             return Redirect::to("/dashboard/characters");
         }
     } else {
         return Response::json(["success" => false, "message" => "Character could not be found."]);
     }
 }
开发者ID:AcceptableIce,项目名称:Larp3,代码行数:36,代码来源:SaveController.php

示例6: newTopic

 /**
  * Crée un nouveau topic dans le forum désiré
  *
  * @param $slug Slug du forum dans lequel sera le topic
  * @param $id Id du forum dans lequel sera le topic
  */
 public function newTopic($slug, $id)
 {
     $user = Auth::user();
     $forum = Forum::find($id);
     $category = $forum->getCategory();
     $parsedContent = null;
     // L'utilisateur possède le droit de crée un topic ici
     if ($category->getPermission()->start_topic != true) {
         return Redirect::route('forum_index')->with('message', 'You can\'t start a new topic here');
     }
     // Prévisualisation du post
     if (Request::getMethod() == 'POST' && Input::get('preview') == true) {
         $code = new Decoda\Decoda(Input::get('content'));
         $code->defaults();
         $parsedContent = $code->parse();
     }
     if (Request::getMethod() == 'POST' && Input::get('post') == true) {
         // Crée le topic
         $topic = new Topic();
         $topic->name = Input::get('title');
         $topic->slug = Str::slug(Input::get('title'));
         $topic->state = 'open';
         $topic->first_post_user_id = $topic->last_post_user_id = $user->id;
         $topic->first_post_user_username = $topic->last_post_user_username = $user->username;
         $topic->views = 0;
         $topic->pinned = false;
         $topic->forum_id = $forum->id;
         $v = Validator::make($topic->toArray(), $topic->rules);
         if ($v->passes()) {
             $topic->save();
             $post = new Post();
             $post->content = Input::get('content');
             $post->user_id = $user->id;
             $post->topic_id = $topic->id;
             $v = Validator::make($post->toArray(), $post->rules);
             if ($v->passes()) {
                 $post->save();
                 $topic->num_post = 1;
                 $topic->save();
                 $forum->num_topic = $forum->getTopicCount($forum->id);
                 $forum->num_post = $forum->getPostCount($forum->id);
                 $forum->last_topic_id = $topic->id;
                 $forum->last_topic_name = $topic->name;
                 $forum->last_topic_slug = $topic->slug;
                 $forum->last_post_user_id = $user->id;
                 $forum->last_post_user_username = $user->username;
                 $forum->save();
                 return Redirect::route('forum_topic', array('slug' => $topic->slug, 'id' => $topic->id));
             } else {
                 // Impoossible de save le premier post donc delete le topic
                 $topic->delete();
             }
         } else {
             Session::put('message', 'An error has occurred with this topic. Try again.');
         }
     }
     return View::make('forum.new_topic', array('forum' => $forum, 'category' => $category, 'parsedContent' => $parsedContent, 'title' => Input::get('title'), 'content' => Input::get('content')));
 }
开发者ID:raphaeljorge,项目名称:tor,代码行数:64,代码来源:ForumController.php

示例7: admin_delete_forum

 public function admin_delete_forum($admin)
 {
     if (!isset($_GET['id'])) {
         error(__("Error"), __("No forum ID specified.", "discuss"));
     }
     $forum = new Forum($_GET['id']);
     if ($forum->no_results) {
         error(__("Error"), __("Invalid forum ID specified.", "discuss"));
     }
     if (!$forum->deletable()) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to delete this forum.", "discuss"));
     }
     $admin->display("delete_forum", array("forum" => $forum, "forums" => Forum::find(array("where" => array("id not" => $forum->id)))), _f("Delete Forum &#8220;%s&#8221;", array(fix($forum->name)), "discuss"));
 }
开发者ID:vito,项目名称:chyrp-site,代码行数:14,代码来源:discuss.php

示例8: 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]);
 }
开发者ID:Max201,项目名称:nanocore,代码行数:29,代码来源:Control.php

示例9: postTopic

 function postTopic()
 {
     if (!Auth::check()) {
         return Redirect::to("/forums");
     }
     $topic_id = Input::get("topic_id");
     if (isset($topic_id)) {
         //Edit logic
         $topic = ForumTopic::find(Input::get("topic_id"));
         $post = $topic->firstPost;
         $user = Auth::user();
         if (!$user->canAccessTopic($topic_id)) {
             return "Access denied.";
         }
         if ($post->posted_by == $user->id || $user->isStoryteller()) {
             $body = ForumPost::replaceSpecialTerms(Input::get("body"));
             $post->body = $body;
             $post->save();
             $topic->title = Input::get("title");
             $topic->save();
             //Save an edit record
             $posted_by = Input::get("post-as");
             $poster = User::find($posted_by);
             if (!$poster) {
                 $poster = Auth::user();
             }
             $edit = new ForumEdit();
             $edit->post_id = $post->id;
             $edit->user_id = $poster->id;
             $edit->save();
             ForumTopicAddedUser::where('topic_id', $topic_id)->delete();
             $addedUsersRaw = Input::get("added-users");
             if (strlen(trim($addedUsersRaw)) > 0) {
                 $addedUsers = explode(",", $addedUsersRaw);
                 foreach ($addedUsers as $au) {
                     $new_au = new ForumTopicAddedUser();
                     $new_au->topic_id = $topic->id;
                     $new_au->user_id = $au;
                     $new_au->save();
                 }
             }
             return Redirect::to('/forums/topic/' . $post->topic->id);
         } else {
             return "Post does not belong to user";
         }
     } else {
         $user = Auth::user();
         $forum_id = Input::get("forum_id");
         $title = Input::get("title");
         $body = Input::get("body");
         if (!$user->canAccessForum($forum_id)) {
             return "Access denied.";
         }
         if ($forum_id == null || $title == null || $body == null) {
             //Validate.
             return "failed.";
         } else {
             $forum = Forum::find($forum_id);
             $permission = PermissionDefinition::find($forum->topic_permission);
             if (!$forum->topic_permission || Auth::user()->hasPermission($permission->name) || Auth::user()->isStoryteller()) {
                 $posted_by = Input::get("post-as");
                 $body = ForumPost::replaceSpecialTerms($body);
                 $topic = $forum->post($title, $body, User::find($posted_by));
                 $addedUsersRaw = Input::get("added-users");
                 if (strlen(trim($addedUsersRaw)) > 0) {
                     $addedUsers = explode(",", $addedUsersRaw);
                     foreach ($addedUsers as $au) {
                         $new_au = new ForumTopicAddedUser();
                         $new_au->topic_id = $topic->id;
                         $new_au->user_id = $au;
                         $new_au->save();
                     }
                 }
                 //Check for @mentions.
                 $this->alertMentions($posted_by, $body, $topic);
                 if ($topic) {
                     return Redirect::to('/forums/topic/' . $topic->id);
                 } else {
                     return "No access.";
                 }
             } else {
                 return 'No write permission';
             }
         }
     }
 }
开发者ID:AcceptableIce,项目名称:Larp3,代码行数:86,代码来源:ForumController.php


注:本文中的Forum::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。