Example #1
0
 public function beforeValidate()
 {
     // Alias
     if ($this->alias) {
         $this->alias = makeAlias($this->alias);
     } else {
         $this->alias = makeAlias($this->question);
     }
     if ($this->isNewRecord) {
         // Check if we already have an alias with those parameters
         if (HelpTopic::model()->exists('alias=:alias', array(':alias' => $this->alias))) {
             $this->addError('alias', at('There is already a help topic with that alias.'));
         }
     } else {
         // Check if we already have an alias with those parameters
         if (HelpTopic::model()->exists('alias=:alias AND id!=:id', array(':id' => $this->id, ':alias' => $this->alias))) {
             $this->addError('alias', at('There is already a help topic with that alias.'));
         }
     }
     return parent::beforeValidate();
 }
 /**
  * Delete help topic action
  */
 public function actionDelete()
 {
     // Check Access
     checkAccessThrowException('op_helptopics_delete');
     if (isset($_GET['id']) && ($model = HelpTopic::model()->findByPk($_GET['id']))) {
         alog(at("Deleted Help Topic '{name}'.", array('{name}' => $model->name)));
         $model->delete();
         fok(at('Help Topic Deleted.'));
         $this->redirect(array('helptopics/index'));
     } else {
         $this->redirect(array('helptopics/index'));
     }
 }
 /**
  * Lists all models.
  */
 public function actionAdmin()
 {
     Acl::hasPrivilege($this->privileges, $this->resource, Acl::ACTION_VIEW);
     $this->pageTitle = 'Manage ' . $this->homeTitle;
     $this->render('admin', array('model' => HelpTopic::model()->searchModel()));
 }