Esempio n. 1
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = Help::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404);
         }
     }
     return $this->_model;
 }
Esempio n. 2
0
 /**
  * Returns the item name for the specified type and code.
  * @param string the item code (corresponding to the 'code' column value)
  * @param string the item name ('title' or 'content').
  * @return string the value for the specified the type and code. False is returned if the item type or code does not exist.
  */
 public static function item($code, $name, $edit = false)
 {
     if (!isset(self::$_item)) {
         self::loadItems($code, $name);
     }
     $item = isset(self::$_items[$code][$name]) ? self::$_items[$code][$name] : null;
     if ($item && $edit) {
         $item = $item . ' ' . Help::model()->buildEditLink(self::$_items[$code]['id']);
     }
     return $item;
 }
Esempio n. 3
0
 /**
  * Generate edit link if user authorized to edit help
  * @param integer help id
  * @return html link
  */
 public function getEditLink($id)
 {
     if (Yii::app()->controller->module->rbac === false && Yii::app()->user->name == 'admin' || Yii::app()->controller->module->rbac !== false && Yii::app()->user->checkAccess(Yii::app()->controller->module->rbac)) {
         return Help::model()->buildEditLink($id, 'createReturnStackUrl');
     } else {
         return null;
     }
 }