Beispiel #1
0
 /**
  * Вывод инфы о бане
  * @param integer $id ID бана
  */
 public function actionView($id)
 {
     // Подгружаем комментарии и файлы
     $files = new Files();
     //$this->performAjaxValidation($files);
     $files->unsetAttributes();
     $comments = new Comments();
     $comments->unsetAttributes();
     // Подгружаем баны
     $model = Bans::model()->with('admin')->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $geo = false;
     // Проверка прав на просмотр IP
     $ipaccess = Webadmins::checkAccess('ip_view');
     if ($ipaccess) {
         $geo = array('city' => 'Н/А', 'region' => 'Не определен', 'country' => 'Не определен', 'lat' => 0, 'lng' => 0);
         $get = @file_get_contents('http://ipgeobase.ru:7020/geo?ip=' . $model->player_ip);
         if ($get) {
             $xml = @simplexml_load_string($get);
             if (!empty($xml->ip)) {
                 $geo['city'] = $xml->ip->city;
                 $geo['region'] = $xml->ip->region;
                 $geo['country'] = $xml->ip->country;
                 $geo['lat'] = $xml->ip->lat;
                 $geo['lng'] = $xml->ip->lng;
             }
         }
     }
     // Добавление файла
     if (isset($_POST['Files'])) {
         // Задаем аттрибуты
         $files->attributes = $_POST['Files'];
         $files->bid = intval($id);
         if ($files->save()) {
             $this->refresh();
         }
     }
     // Добавление комментария
     if (isset($_POST['Comments'])) {
         //exit(print_r($_POST['Comments']));
         $comments->attributes = $_POST['Comments'];
         $comments->bid = $id;
         if ($comments->save()) {
             $this->refresh();
         }
     }
     // Выборка комментариев
     $c = new CActiveDataProvider($comments, array('criteria' => array('condition' => 'bid = :bid', 'params' => array(':bid' => $id))));
     // Выборка файлов
     $f = new CActiveDataProvider(Files::model(), array('criteria' => array('condition' => 'bid = :bid', 'params' => array(':bid' => $id))));
     // История банов
     $history = new CActiveDataProvider('Bans', array('criteria' => array('condition' => '`bid` <> :hbid AND (`player_ip` = :hip OR `player_id` = :hid)', 'params' => array(':hbid' => $id, ':hip' => $model->player_ip, ':hid' => $model->player_id)), 'pagination' => array('pageSize' => 5)));
     // Вывод всего на вьюху
     $this->render('view', array('geo' => $geo, 'ipaccess' => $ipaccess, 'model' => $model, 'files' => $files, 'comments' => $comments, 'f' => $f, 'c' => $c, 'history' => $history));
 }
Beispiel #2
0
            
        </div>
        <div class="col-md-4 col-sm-6">
            <?php 
$this->beginWidget('TbPanel', array('header' => Yii::t('app', "EAV Fields")));
$this->Widget('application.modules.eav.components.eavProp', array('name' => get_class($model), 'attr' => $model->getEavAttributes()));
$this->endWidget();
?>
            <?php 
?>
            <?php 
if (!$model->isNewRecord) {
    $this->beginWidget('TbPanel', array('header' => Yii::t('app', "Attached files")));
    $this->widget('CMultiFileUpload', array('name' => 'Files', 'model' => $model, 'id' => 'Files', 'accept' => '*', 'duplicate' => 'Duplicate file!', 'denied' => 'Invalid file type'));
    $files = new Files('search');
    $files->unsetAttributes();
    $files->parent_type = get_class($model);
    $files->parent_id = $model->id;
    $this->widget('EExcelView', array('id' => 'itm-file-grid', 'dataProvider' => $files->search(), 'template' => '{items}{pager}', 'ajaxUpdate' => true, 'columns' => array(array('name' => 'name', 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode($data->name), Yii::app()->createUrl("download/".$data->id))'), array('name' => 'date', 'value' => 'date("' . Yii::app()->locale->getDateFormat('phpdatetime') . '",CDateTimeParser::parse($data->date,"' . Yii::app()->locale->getDateFormat('yiidbdatetime') . '"))'), array('class' => 'CButtonColumn', 'template' => '{delete}', 'buttons' => array('delete' => array('label' => '<i class="glyphicon glyphicon-trash"></i>', 'deleteConfirmation' => true, 'imageUrl' => false, 'url' => 'Yii::app()->createUrl("files/delete", array("id"=>$data->id))'))))));
    $this->endWidget();
}
?>


        </div>
    </div>
    <?php 
//echo $form->labelEx($model,'owner');
?>
    <?php 
//echo $form->dropDownList($model,'owner',CHtml::listData(User::model()->findAll(), 'id', 'username'));
 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     $model = new Files('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['Files'])) {
         $model->attributes = $_GET['Files'];
     }
     $this->render('admin', array('model' => $model));
 }