<?php echo $form->textField($model, 'server_password', array('size' => 60, 'maxlength' => 64)); ?> <?php echo $form->error($model, 'server_password'); ?> </div> </div> <div class="control-group"> <?php echo $form->labelEx($model, 'group_id', array('class' => 'control-label')); ?> <div class="controls"> <?php echo $form->dropDownList($model, 'group_id', CHtml::listData(SBGroup::model()->findAll(array('order' => 't.name')), 'id', 'name'), array('empty' => '- ' . Yii::t('sourcebans', 'None') . ' -')); ?> <?php echo $form->error($model, 'group_id'); ?> </div> </div> <div class="control-group"> <?php echo $form->label($model, 'server_groups.name', array('class' => 'control-label')); ?> <div class="controls"> <?php $server_groups = CHtml::listData($model->server_groups, 'id', 'id'); foreach (SBServerGroup::model()->findAll(array('order' => 't.name')) as $server_group) {
/** * 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. * @param integer $id the ID of the model to be loaded * @param string $type the type of the model to be loaded * @return SBGroup|SBServerGroup the loaded model * @throws CHttpException */ public function loadModel($id, $type) { if ($type == 'web') { $model = SBGroup::model()->findByPk($id); } else { $model = SBServerGroup::model()->findByPk($id); } if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Displays the 'groups' admin page */ public function actionGroups() { $this->pageTitle = Yii::t('sourcebans', 'controllers.admin.groups.title'); $this->breadcrumbs = array(Yii::t('sourcebans', 'controllers.admin.index.title') => array('admin/index'), Yii::t('sourcebans', 'controllers.admin.groups.title')); $this->menu = array(array('label' => Yii::t('sourcebans', 'controllers.admin.groups.menu.list'), 'url' => '#list', 'visible' => Yii::app()->user->data->hasPermission('LIST_GROUPS')), array('label' => Yii::t('sourcebans', 'controllers.admin.groups.menu.add'), 'url' => '#add', 'visible' => Yii::app()->user->data->hasPermission('ADD_GROUPS')), array('label' => Yii::t('sourcebans', 'controllers.admin.groups.menu.import'), 'url' => '#import', 'visible' => Yii::app()->user->data->hasPermission('ADD_GROUPS'))); $group = new SBGroup(); $server_group = new SBServerGroup(); $groups = new SBGroup('search'); $groups->unsetAttributes(); // clear any default values $server_groups = new SBServerGroup('search'); $server_groups->unsetAttributes(); // clear any default values $this->render('groups', array('group' => $group, 'groups' => $groups, 'server_group' => $server_group, 'server_groups' => $server_groups)); }
$config = str_replace('{name}', $db['name'], $config); $config = str_replace('{prefix}', $db['prefix'], $config); $file = fopen($paths['config'] . '/sourcebans.php', 'w'); fwrite($file, $config); fclose($file); // Setup database require WEB_ROOT . 'api.php'; $queries = file_get_contents(dirname(__FILE__) . '/data/install.sql'); $queries = str_replace('{prefix}', $db['prefix'], $queries); foreach (explode(';', $queries) as $query) { if (($query = trim($query)) != '') { Yii::app()->db->createCommand($query)->execute(); } } // Setup web group $group = new SBGroup(); $group->name = 'Owner'; $group->permissions = array('OWNER'); if (!$group->save()) { throw new CException('Failed to save group "' . $group->name . '"'); } // Setup admin $admin = new SBAdmin(); $admin->attributes = $_POST['SBAdmin']; $admin->group_id = $group->id; $admin->new_password = $admin->password; if (!$admin->save()) { throw new CException('Failed to save admin "' . $admin->name . '"'); } } catch (Exception $e) { exit(json_encode(array('error' => $e->getMessage())));