public function love() { $this->return['success'] = 'fail'; $user_id = Session::get('id'); if ($user_id == false || $user_id == 0) { $this->return['errors'] = array(Lang::get('forum-only-logged-users')); return $this->return; } $id = $this->params['id']; $type = $this->params['type']; if ($this->params['interaction_type'] == 'hate') { // Check if the forum topic is ours $topic_owner = ForumTopics::find($id)[0]->user_id; if ($topic_owner == Session::get('id')) { $this->return['errors'] = array(Lang::get('cannot-unlike-own-stuff')); return $this->return_json($this->return); } else { $delete_id = ForumLikes::where('user_id', $user_id)->also('subject_id', $id)->also('type', $type)->delete(); $this->return['success'] = 'ok'; } } else { $i = ForumLikes::where('user_id', $user_id)->also('subject_id', $id)->also('type', $type)->get(1); if (!$i || sizeof($i) == 0) { $interact = new ForumLikes(); $interact->subject_id = $id; $interact->type = trim($type); $interact->user_id = $user_id; $interact->save(); $this->return['success'] = 'ok'; } else { $this->return['errors'] = array(Lang::get('you-allready-done-that')); } } echo json_encode($this->return); }
/** * Toggle topic status */ public function actiontoggletopic() { if (!Yii::app()->user->checkAccess('op_forum_topics')) { throw new CHttpException(403, Yii::t('forum', 'Sorry, You are not allowed to perform that operation.')); } if (isset($_GET['id']) && ($model = ForumTopics::model()->findByPk($_GET['id']))) { $model->visible = $model->visible == 1 ? 0 : 1; $model->update(); Yii::app()->user->setFlash('success', Yii::t('forum', 'Topics Status Changed.')); $this->redirect(Yii::app()->request->getUrlReferrer()); } else { $this->redirect(Yii::app()->request->getUrlReferrer()); } }
/** * Get the rows for the sitemap */ protected function getRows() { $_rows = array(); // Grab blog cats $blogCats = BlogCats::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language)); if (count($blogCats)) { foreach ($blogCats as $blogCat) { $_rows[] = $this->makeData($this->getFullUrl('/blog/category/' . $blogCat->alias), time(), 'monthly', 0.1); } } // Grab blog rows $blogRows = Blog::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language)); if (count($blogRows)) { foreach ($blogRows as $blogRow) { $_rows[] = $this->makeData($this->getFullUrl('/blog/view/' . $blogRow->alias), $blogRow->postdate, 'weekly', 1); } } // Grab tutorials cats $tutorialsCats = TutorialsCats::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language)); if (count($tutorialsCats)) { foreach ($tutorialsCats as $tutorialsCat) { $_rows[] = $this->makeData($this->getFullUrl('/tutorials/category/' . $tutorialsCat->alias), time(), 'monthly', 0.1); } } // Grab tutorials rows $tutorialsRows = Tutorials::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language)); if (count($tutorialsRows)) { foreach ($tutorialsRows as $tutorialsRow) { $_rows[] = $this->makeData($this->getFullUrl('/tutorials/view/' . $tutorialsRow->alias), $tutorialsRow->postdate, 'weekly', 1); } } // Grab extensions cats $extensionsCats = ExtensionsCats::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language)); if (count($extensionsCats)) { foreach ($extensionsCats as $extensionsCat) { $_rows[] = $this->makeData($this->getFullUrl('/extensions/category/' . $extensionsCat->alias), time(), 'monthly', 0.1); } } // Grab extensions rows $extensionsRows = Extensions::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language)); if (count($extensionsRows)) { foreach ($extensionsRows as $extensionsRow) { $_rows[] = $this->makeData($this->getFullUrl('/extensions/view/' . $extensionsRow->alias), $extensionsRow->postdate, 'weekly', 1); } } // Grab users rows $usersRows = Members::model()->findAll(); if (count($usersRows)) { foreach ($usersRows as $usersRow) { $_rows[] = $this->makeData($this->getFullUrl('/user/' . $usersRow->id . '-' . $usersRow->seoname), $usersRow->joined, 'monthly', 1); } } // Grab forum topics rows $forumTopics = ForumTopics::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language)); if (count($forumTopics)) { foreach ($forumTopics as $forumTopic) { $_rows[] = $this->makeData($this->getFullUrl('/forum/topic/' . $forumTopic->id . '-' . $forumTopic->alias), $forumTopic->dateposted, 'daily', 1); } } // Grab custom pages $customPages = CustomPages::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language)); if (count($customPages)) { foreach ($customPages as $customPage) { $_rows[] = $this->makeData($this->getFullUrl('/' . $forumTopic->alias), $customPage->dateposted, 'weekly', 1); } } // Grab documentation pages $documentations = Documentation::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language)); if (count($documentations)) { foreach ($documentations as $documentation) { $_rows[] = $this->makeData($this->getFullUrl('/documentation/guide/' . $documentation->type . '/topic/' . $documentation->mkey), $documentation->last_updated, 'weekly', 1); } } // Return array return $_rows; }