/**
  * Index action
  */
 public function actionIndex()
 {
     if (isset($_GET['alias']) && ($model = CustomPages::model()->find('alias=:alias AND language=:lang', array(':lang' => Yii::app()->language, ':alias' => $_GET['alias'])))) {
         // Page is active?
         if (!$model->status) {
             throw new CHttpException(404, Yii::t('error', 'Sorry, The page you were looking for was not found.'));
         }
         // Check if the language is set for a certain language
         if (Yii::app()->language != $model->language) {
             // Error
             throw new CHttpException(404, Yii::t('error', 'Sorry, The page you were looking for was not found.'));
         }
         // Check if we can view it
         if ($model->visible) {
             $permcheck = false;
             if (count(explode(',', $model->visible))) {
                 foreach (explode(',', $model->visible) as $perm) {
                     if (Yii::app()->user->checkAccess($perm)) {
                         $permcheck = true;
                         break;
                     }
                 }
             }
             if (!$permcheck) {
                 throw new CHttpException(403, Yii::t('error', 'Sorry, You are not authorized to view this page.'));
             }
         }
         // Add in the meta keys and description if any
         if ($model->metadesc) {
             Yii::app()->clientScript->registerMetaTag($model->metadesc, 'description');
         }
         if ($model->metakeys) {
             Yii::app()->clientScript->registerMetaTag($model->metakeys, 'keywords');
         }
         // Add page breadcrumb and title
         $this->pageTitle[] = Yii::t('custompages', $model->title);
         $this->breadcrumbs[Yii::t('custompages', $model->title)] = '';
         $this->render('page', array('model' => $model));
     } else {
         throw new CHttpException(404, Yii::t('error', 'Sorry, The page you were looking for was not found.'));
     }
 }
 /**
  * Delete page action
  */
 public function actiondeletepage()
 {
     // Perms
     if (!Yii::app()->user->checkAccess('op_custompages_deletepages')) {
         throw new CHttpException(403, Yii::t('error', 'Sorry, You don\'t have the required permissions to enter this section'));
     }
     if (isset($_GET['id']) && ($model = CustomPages::model()->findByPk($_GET['id']))) {
         $model->delete();
         Yii::app()->user->setFlash('success', Yii::t('admincustompages', 'Page Deleted.'));
         $this->redirect(array('custompages/index'));
     } else {
         $this->redirect(array('custompages/index'));
     }
 }
 /**
  * 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;
 }