include __DIR__ . '/db/db.php';
include __DIR__ . '/func/functions.php';
$args = filter_input_array(INPUT_GET, [
'do' => FILTER_DEFAULT,
'id' => FILTER_DEFAULT
]);
if ($args == null) {
$users = Power::find('all', [
's_id' => $_SESSION['id']
]);
$result = [];
foreach ($users as $value) {
$result[] = [
'id' => $value->id,
'username' => $value->user->username,
'object' => $value->object->name,
'rw' => $value->rw,
'au' => $value->au
];
}
$temple = __DIR__ . '/module/power.phtml';
include __DIR__ . '/module/public/layout.phtml';
} else {
if ($args['do'] == 'delete') {
$record = Power::find_by_id($args['id']);
$queue[0] = [
'id' => $record->id,
's_id' => $record->r_id,
'object_id' => $record->object_id
];
$pow = [];
while ($queue != null) {
$font = array_pop($queue);
$record = Power::find('all', [
's_id' => $font['s_id'],
'object_id' => $font['object_id'],
]);
foreach ($record as $re) {
$value = [
'id' => $re->id,
's_id' => $re->r_id,
'object_id' => $re->object_id
];
$choose = Power::find('all', [
'r_id' => $re->s_id,
'object_id' => $re->object_id
]);
if ($choose != null) {
if ($choose == null) {
array_push($queue, $value);
} else {
array_push($pow, $record);
}
}
}
Power::delete_all([
'conditions' => [
'id' => $font['id']
]
]);
jumpTo('delete OK', 'power.php');
}
while ($pow != null) {
$res = 0;
$font = array_pop($pow);
$power = Power::find('all', [
'r_id' => $font[0]->s_id,
'object_id' => $font[0]->object_id
]);
foreach ($power as $value) {
if ($res == 0) {
$res = $value->rw;
} else if ($res != $value->rw) {
$res = 3;
}
}
$update = Power::find('all', [
's_id' => $font[0]->s_id,
'object_id' => $font[0]->object_id
]);
foreach ($update as $value) {
$value->update_attributes([
'rw' => $res
]);
}
}
}
}
一键复制
编辑
Web IDE
原始数据
按行查看
历史