%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
| Server IP : 14.207.165.8 / Your IP : 216.73.216.26 Web Server : Apache/2.4.18 (Ubuntu) System : Linux 246 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : root ( 0) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,pcntl_exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/thread-self/root/var/www/html/ppaobm/vendor/mdmsoft/yii2-admin/models/searchs/ |
Upload File : |
<?php
namespace mdm\admin\models\searchs;
use Yii;
use yii\base\Model;
use yii\data\ArrayDataProvider;
use mdm\admin\components\Configs;
use yii\rbac\Item;
/**
* AuthItemSearch represents the model behind the search form about AuthItem.
*
* @author Misbahul D Munir <misbahuldmunir@gmail.com>
* @since 1.0
*/
class AuthItem extends Model
{
const TYPE_ROUTE = 101;
public $name;
public $type;
public $description;
public $ruleName;
public $data;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['name', 'ruleName', 'description'], 'safe'],
[['type'], 'integer'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'name' => Yii::t('rbac-admin', 'Name'),
'item_name' => Yii::t('rbac-admin', 'Name'),
'type' => Yii::t('rbac-admin', 'Type'),
'description' => Yii::t('rbac-admin', 'Description'),
'ruleName' => Yii::t('rbac-admin', 'Rule Name'),
'data' => Yii::t('rbac-admin', 'Data'),
];
}
/**
* Search authitem
* @param array $params
* @return \yii\data\ActiveDataProvider|\yii\data\ArrayDataProvider
*/
public function search($params)
{
/* @var \yii\rbac\Manager $authManager */
$authManager = Configs::authManager();
if ($this->type == Item::TYPE_ROLE) {
$items = $authManager->getRoles();
} else {
$items = array_filter($authManager->getPermissions(), function($item) {
return $this->type == Item::TYPE_PERMISSION xor strncmp($item->name, '/', 1) === 0;
});
}
$this->load($params);
if ($this->validate()) {
$search = mb_strtolower(trim($this->name));
$desc = mb_strtolower(trim($this->description));
$ruleName = $this->ruleName;
foreach ($items as $name => $item) {
$f = (empty($search) || mb_strpos(mb_strtolower($item->name), $search) !== false) &&
(empty($desc) || mb_strpos(mb_strtolower($item->description), $desc) !== false) &&
(empty($ruleName) || $item->ruleName == $ruleName);
if (!$f) {
unset($items[$name]);
}
}
}
return new ArrayDataProvider([
'allModels' => $items,
]);
}
}