示例#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.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = ReasonsSet::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
示例#2
0
 /**
  * Причины банов
  * @throws CHttpException
  */
 public function actionReasons()
 {
     // Проверка прав
     if (Yii::app()->user->isGuest) {
         throw new CHttpException(403, "У Вас недостаточно прав");
     }
     // Задаем лайоут
     $this->layout = '//layouts/column2';
     // Вывод модальки с деталями группы
     if (isset($_POST['groupid'])) {
         $gid = intval($_POST['groupid']);
         // Выбираем все причины
         $reasons = Reasons::model()->findAll();
         // Выбираем группу причин по ID
         $group = ReasonsSet::model()->findByPk($gid);
         $js = CHtml::form('', 'post', array('id' => 'form' . $gid));
         $js .= "<table class=\"table table-bordered table-condensed\"><thead><tr><th colspan=3 style=\"vertical-align: middle\">Название группы " . CHtml::textField('groupname', $group->setname) . "</th></tr><tr><th>Причина</th><th>Срок бана</th><th>Действия</th></thead><tbody>";
         foreach ($reasons as $reason) {
             $server = ReasonsToSet::model()->findByAttributes(array('setid' => $gid, 'reasonid' => $reason->id));
             $js .= "<tr id=\"reason{$reason->id}\">";
             $js .= "<td>";
             $js .= CHtml::encode($reason->reason);
             $js .= "</td>";
             $js .= "<td>";
             $js .= CHtml::encode($reason->static_bantime);
             $js .= "</td>";
             $js .= "<td>";
             $js .= CHtml::checkBox('active[]', $server !== NULL ? TRUE : FALSE, array('value' => $reason->id, 'id' => 'active' . $reason->id));
             $js .= "</td>";
             $js .= "</tr>";
         }
         $js .= "<tr><td colspan=3 style=\"text-align: center\">";
         $js .= CHtml::hiddenField('gid', $gid);
         $js .= CHtml::button('Сохранить', array('class' => 'btn btn-primary save', 'onclick' => '$.post(\'\', $(\'#form' . $gid . '\').serialize(), function(data){eval(data);});'));
         $js .= "</td></tr>";
         $js .= "</tbody></table>";
         $js .= CHtml::endForm();
         Yii::app()->end("\$('#loading').hide();\$('.modal-header').html('<h2>Причины банов для группы \"{$group->setname}\"</h2>');\$('.modal-body').html('{$js}');\$('#reasons-modal').modal('show');");
     }
     // Сохранение деталей группы
     if (isset($_POST['active'])) {
         //Yii::app()->end($_POST['gid']);
         // Если не выбрали причины
         if (empty($_POST['active'])) {
             Yii::app()->end("alert('Выберите причины!');");
         }
         // Если не введено название группы
         if (empty($_POST['groupname'])) {
             Yii::app()->end("alert('Введите название группы!');");
         }
         // Ищем группу
         $set = ReasonsSet::model()->findByPk($_POST['gid']);
         // Если группы нет, возвращаем ошибку
         if ($set === NULL) {
             Yii::app()->end("alert('Ошибка! Группа причин под ID " . intval($_POST['gid']) . " не найдена');");
         }
         // Если изменено название группы, то обновляем в базе и на странице
         $other = "";
         if ($_POST['groupname'] != $set->setname) {
             $set->setname = CHtml::encode($_POST['groupname']);
             if ($set->save()) {
                 $other = "\$('#rgroup{$_POST['gid']}').children('td:first').html('" . CHtml::encode($_POST['groupname']) . "');";
             }
             //Yii::app()->end(var_dump($set->errors()));
         }
         // Ищем и предварительно удаляем все записи для этой группы причин
         if (ReasonsToSet::model()->findAllByAttributes(array('setid' => intval($_POST['gid'])))) {
             ReasonsToSet::model()->deleteAllByAttributes(array('setid' => intval($_POST['gid'])));
         }
         // Циклим и записываем в базу новые причины для этой группы
         foreach ($_POST['active'] as $r) {
             $rts = new ReasonsToSet();
             $rts->setid = intval($_POST['gid']);
             $rts->reasonid = intval($r);
             if ($rts->save()) {
                 $rts->unsetAttributes();
             }
         }
         Yii::app()->end($other . "\$('#reasons-modal').modal('hide');alert('Сохранено!');");
     }
     $this->render('reasons', array('reasons' => new CActiveDataProvider('Reasons', array('criteria' => array('order' => '`static_bantime` DESC'))), 'reasonsset' => new CActiveDataProvider('ReasonsSet')));
 }
示例#3
0
	<p class="note">Поля, отмеченные <span class="required">*</span> обязательны к заполнению.</p>
	<fieldset>
		<?php 
echo $form->errorSummary($model);
?>
			<?php 
echo $form->passwordFieldRow($model, 'rcon', array('size' => 32, 'maxlength' => 32));
?>
			<?php 
echo $form->textFieldRow($model, 'amxban_motd', array('size' => 60, 'maxlength' => 250));
?>
			<?php 
echo $form->textFieldRow($model, 'motd_delay');
?>
			<?php 
echo $form->dropDownListRow($model, 'reasons', ReasonsSet::getList());
?>
			<?php 
echo $form->dropDownListRow($model, 'timezone_fixx', $timezones);
?>
	</fieldset>
	<div class="form-actions">
		<?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? 'Создать' : 'Обновить'));
?>
		<?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'reset', 'label' => 'Сбросить'));
?>
	</div>

	<?php 
示例#4
0
	<p class="note">Поля, отмеченные <span class="required">*</span> обязательны к заполнению.</p>
	<fieldset>
		<?php 
echo $form->errorSummary($model);
?>
			<?php 
echo $form->passwordFieldControlGroup($model, 'rcon', array('size' => 32, 'maxlength' => 32));
?>
			<?php 
echo $form->textFieldControlGroup($model, 'amxban_motd', array('size' => 60, 'maxlength' => 250));
?>
			<?php 
echo $form->textFieldControlGroup($model, 'motd_delay');
?>
			<?php 
echo $form->dropDownListControlGroup($model, 'reasons', ReasonsSet::getList(), array('prompt' => 'Без причин'));
?>
			<?php 
echo $form->dropDownListControlGroup($model, 'timezone_fixx', $timezones);
?>
	</fieldset>
	<div class="form-group">
		<button type="submit" class="btn btn-primary">Сохранить</button>
	</div>
	<?php 
$this->endWidget();
?>
</div>

<?php 
if (!$model->isNewrecord && $model->rcon) {