Пример #1
0
 /**
  * init
  */
 public function init()
 {
     if (!is_array($this->views)) {
         throw new CException('请设置视图类型');
     }
     foreach ($this->views as $key => &$view) {
         $allowViews = array(self::VIEW_GRID, self::VIEW_KANBAN, self::VIEW_SUMMARY, self::VIEW_DETAIL);
         if (is_string($view)) {
             $view = array('name' => $view);
         }
         if (!in_array($view['name'], $allowViews)) {
             unset($view);
             continue;
         }
         if ($view['label'] == '') {
             $view['label'] = $this->_getViewLabel($view['name']);
         }
         if ($view['icon'] == '') {
             $view['icon'] = $this->_getViewIcon($view['name']);
         }
         if ($view['url'] == '') {
             $view['url'] = Yii::app()->createUrl(TUtil::getCurrentRoute(), array('viewType' => $view['name']));
         }
     }
 }
Пример #2
0
 /**
  * 记录系统日志
  * 
  * @param string $message
  * @param int $logType
  * @param string $level
  * @param string $category
  * @return boolean
  */
 public function log($message, $logType = 0, $level = SysLog::LEVEL_INFO, $category = '', $user = null)
 {
     if (trim($message) == '') {
         return false;
     }
     $model = new SysLog();
     $model->attributes = array('user_id' => is_null($user) ? Yii::app()->user->id : $user->id, 'user_name' => is_null($user) ? Yii::app()->user->user_name : $user->user_name, 'category' => $category == '' ? TUtil::getCurrentRoute() : $category, 'log_type' => $logType, 'level' => $level, 'message' => $message, 'log_ip' => $this->getRealIp());
     if ($model->save()) {
         return true;
     } else {
         return false;
     }
 }