Beispiel #1
0
 /**
  * Logs a message.
  * @param string $title title of the message
  * @param string $message message to be logged
  * @param string $type type of the message ({@link SBLog}::TYPE_ERROR, {@link SBLog}::TYPE_INFORMATION, {@link SBLog}::TYPE_WARNING).
  */
 public static function log($title, $message, $type = SBLog::TYPE_INFORMATION)
 {
     $log = new SBLog();
     $log->type = $type;
     $log->title = $title;
     $log->message = $message;
     $log->save();
 }
Beispiel #2
0
 /**
  * Displays the 'settings' admin page
  */
 public function actionSettings()
 {
     $this->pageTitle = Yii::t('sourcebans', 'controllers.admin.settings.title');
     $this->breadcrumbs = array(Yii::t('sourcebans', 'controllers.admin.index.title') => array('admin/index'), Yii::t('sourcebans', 'controllers.admin.settings.title'));
     $this->menu = array(array('label' => Yii::t('sourcebans', 'controllers.admin.settings.menu.settings'), 'url' => '#settings'), array('label' => Yii::t('sourcebans', 'controllers.admin.settings.menu.plugins'), 'url' => '#plugins'), array('label' => Yii::t('sourcebans', 'controllers.admin.settings.menu.logs'), 'url' => '#logs'));
     $model = new SettingsForm();
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'settings-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     if (isset($_POST['SettingsForm'])) {
         $model->attributes = $_POST['SettingsForm'];
         if ($model->validate() && $model->save()) {
             $this->redirect(array('', '#' => 'settings'));
         }
     }
     // Find new plugins and save to database
     $files = CFileHelper::findFiles(Yii::getPathOfAlias('application.plugins'), array('fileTypes' => array('php'), 'level' => 1));
     foreach ($files as $file) {
         $id = substr(pathinfo($file, PATHINFO_DIRNAME), strlen(Yii::getPathOfAlias('application.plugins')) + 1);
         $class = (!empty($id) ? $id . '.' : '') . pathinfo($file, PATHINFO_FILENAME);
         $plugin = new SBPlugin();
         $plugin->class = $class;
         $plugin->save();
     }
     $plugins = new CArrayDataProvider(SBPlugin::model()->findAll(), array('keyField' => 'class', 'sort' => array('attributes' => array('author', 'name', 'version', '*'), 'defaultOrder' => array('name' => CSort::SORT_ASC))));
     $logs = new SBLog('search');
     $logs->unsetAttributes();
     // clear any default values
     if (isset($_GET['SBLog'])) {
         $logs->attributes = $_GET['SBLog'];
     }
     $this->render('settings', array('logs' => $logs, 'plugins' => $plugins, 'settings' => $model));
 }