예제 #1
0
<?php

/**
 * @var $this UserController
 * @var $user YdUser
 *
 * @author Brett O'Donnell <*****@*****.**>
 * @author Zain Ul abidin <*****@*****.**>
 * @copyright 2013 Mr PHP
 * @link https://github.com/cornernote/yii-dressing
 * @license BSD-3-Clause https://raw.github.com/cornernote/yii-dressing/master/license.txt
 */
/** @var YdActiveForm $form */
$form = $this->beginWidget('dressing.widgets.YdActiveForm', array('type' => 'horizontal', 'method' => 'get', 'htmlOptions' => array('class' => 'hide')));
$form->searchToggle('user-grid-search', 'user-grid');
echo '<fieldset>';
echo '<legend>' . $this->getName() . ' ' . Yii::t('dressing', 'Search') . '</legend>';
echo $form->textFieldControlGroup($user, 'name');
echo $form->textFieldControlGroup($user, 'email', array('size' => 60, 'maxlength' => 255));
echo $form->dropDownListControlGroup($user, 'role', CHtml::listData(YdRole::model()->findAll(), 'id', 'name'), array('empty' => ''));
echo '</fieldset>';
echo '<div class="form-actions">';
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'icon' => 'search white', 'label' => Yii::t('dressing', 'Search')));
echo '</div>';
$this->endWidget();
 /**
  * Delete and Undelete
  * @param $id
  */
 public function actionDelete($id = null)
 {
     $task = YdHelper::getSubmittedField('task', 'YdRole') == 'undelete' ? 'undelete' : 'delete';
     if (YdHelper::getSubmittedField('confirm', 'YdRole')) {
         foreach (YdHelper::getGridIds($id) as $_id) {
             $role = YdRole::model()->findByPk($_id);
             if (!$role) {
                 continue;
             }
             call_user_func(array($role, $task));
             Yii::app()->user->addFlash(strtr('Role :name has been :tasked.', array(':name' => $role->getName(), ':tasked' => $task . 'd')), 'success');
         }
         $this->redirect(ReturnUrl::getUrl(Yii::app()->user->getState('index.role', array('/role/index'))));
     }
     $this->render('delete', array('id' => $id, 'task' => $task));
 }
예제 #3
0
<?php

/**
 * @var $this UserController
 * @var $user YdUser
 *
 * @author Brett O'Donnell <*****@*****.**>
 * @author Zain Ul abidin <*****@*****.**>
 * @copyright 2013 Mr PHP
 * @link https://github.com/cornernote/yii-dressing
 * @license BSD-3-Clause https://raw.github.com/cornernote/yii-dressing/master/license.txt
 */
$columns = array();
$columns[] = array('name' => 'id', 'class' => 'dressing.widgets.YdDropdownColumn', 'value' => '$data->getIdString()');
$columns[] = array('name' => 'email', 'value' => '$data->email ? CHtml::link($data->email, "mailto:" . $data->email) : null', 'type' => 'raw');
$columns[] = array('name' => 'phone', 'filter' => false);
if (!$user->role_id) {
    $columns[] = array('name' => 'role_id', 'value' => 'implode(", ",CHtml::listData($data->role,"id","name"))', 'filter' => CHtml::listData(YdRole::model()->findAll(), 'id', 'name'), 'type' => 'raw');
}
// multi actions
$multiActions = array();
$multiActions[] = array('name' => Yii::t('dressing', 'Delete'), 'url' => Yii::app()->createUrl('/user/delete'));
// grid
$this->widget('dressing.widgets.YdGridView', array('id' => 'user-grid', 'dataProvider' => $user->search(), 'filter' => $user, 'columns' => $columns, 'multiActions' => $multiActions));