public function actionIndex($id, $page = 1)
 {
     $page = $page < 1 ? 1 : $page;
     $this->assign("subcategory", ForumSubcategory::findByPk($id));
     $this->assign('threads', ForumThread::findAllForSubcategory($id, $page));
     $this->assign('currentPage', $page);
     $this->assign('categories', ForumCategory::findAllBySection($this->sectionId, true));
 }
 public function afterMove($oldSub, $threadURL)
 {
     if ($oldSub == $this->subcategory_id) {
         return;
     }
     // same sub;
     $sub = ForumSubcategory::findByPk($oldSub);
     if ($sub->last_active_thread_id = $this->id) {
         $sub->checkLastActivity();
     }
     $sub->recalculateNumbers()->save();
     ForumSubcategory::findByPk($this->subcategory_id)->checkLastActivity()->recalculateNumbers()->save();
     if (WebApp::get()->user()->id != $this->user_id) {
         ModelHelper::notifyUser('thread.moved', $threadURL, ["admin" => WebApp::get()->user()->name, 'adminId' => WebApp::get()->user()->id, "title" => $this->title, "threadId" => $this->id, "newCategory" => $this->subcategory->category->name . Config::value('FORUM_PAGE_TITLE_SEPARATOR') . $this->subcategory->title], $this->user_id);
     }
 }
Exemple #3
0
 public function actionEditSubcategory($id)
 {
     $model = ForumSubcategory::findByPk($id);
     if (isset($_POST['ForumSubcategory'])) {
         $model->setAttributes($_POST['ForumSubcategory']);
         if ($model->save()) {
             if (false != ($icon = $this->uploadImage("subcategories", 'icon', $model->id))) {
                 if ($model->icon && $model->icon != "default.png" && $model->icon != $icon) {
                     @unlink($this->getUploadFolder() . 'subcategories' . DIRECTORY_SEPARATOR . $model->icon);
                 }
                 $model->icon = $icon;
                 if (!$model->save()) {
                     @unlink($this->getUploadFolder() . $model->icon);
                 }
             }
             Messages::get()->success("Subcategory saved!");
             $this->goToAction('subcategories', ['category' => $model->category_id]);
         }
     }
     $this->setPageLayout('subcategory');
     $this->assign('model', $model);
 }