public function getIndex() { Allow::permission($this->module['group'], 'users'); ## Фильтр юзеров по группе $group = false; $group_id = Input::get('group_id'); $group_name = Input::get('group'); $users = new User(); ## Обрабатываем условия фильтра if ($group_id != '' && !is_null($group = Group::where('id', $group_id)->first())) { $users = $users->where('group_id', $group->id); } elseif ($group_name != '' && !is_null($group = Group::where('name', $group_name)->first())) { $users = $users->where('group_id', $group->id); } #else # $users = User::all(); if (!Allow::superuser()) { $users = $users->where('group_id', '!=', 1); } $users = $users->get(); #Helper::tad($users); if (@(!is_object($group))) { $group = Group::firstOrNew(array('id' => 0)); } $groups = Group::all(); $groups_ids = array(); foreach ($groups as $grp) { $groups_ids[] = $grp->id; } return View::make($this->module['tpl'] . 'index', compact('group', 'users', 'groups', 'groups_ids')); }
public function getEdit($id) { Allow::permission($this->module['group'], 'groups'); if ($id == 1 && !Allow::superuser()) { Redirect(link::auth($this->module['rest'])); } $groups = Group::all(); $group = Group::find($id); $mod_actions = Config::get('mod_actions'); $mod_info = Config::get('mod_info'); #Helper::dd($mod_actions); #Helper::dd($mod_info); $group_actions = Action::where('group_id', $group->id)->get(); #$actions = $group->actions(); $actions = array(); foreach ($group_actions as $action) { #Helper::d($action->status); #continue; if ($action->status) { $actions[$action->module][$action->action] = $action->status; } } #Helper::dd($actions); $group_actions = $actions; return View::make($this->module['tpl'] . 'edit', compact('groups', 'group', 'mod_actions', 'mod_info', 'group_actions')); }
public function getPhpInfo() { if (!Allow::superuser()) { App::abort(404); } phpinfo(); die; }
<div class="row"> <div class="col-xs-12 col-sm-12 col-md-12 col-lg-8"> <table class="table table-striped table-bordered"> <thead> <tr> <th class="col-lg-1 text-center">ID</th> <th class="col-lg-1 text-center">Аватар</th> <th class="col-lg-9 text-center" style="white-space:nowrap;">Данные пользователя</th> <th class="col-lg-1 text-center">Действия</th> </tr> </thead> <tbody> @foreach($users as $user) <? #Helper::ta($user); if ($user->group_id == 1 && !Allow::superuser()) continue; ?> <tr class="vertical-middle<? if($user->active == 0){ echo ' warning'; } ?>"> <td class="text-center">{{ $user->id }}</td> <td class="text-center"> @if(!empty($user->thumbnail)) <figure class="avatar-container"> <img src="{{ url($user->thumbnail) }}" alt="{{ $user->name }} {{ $user->surname }}" class="avatar bordered circle"> </figure> @else <i class="fa fa-user" style="font-size:36px; color:#999"></i> @endif </td> <td> {{ $user->name }} {{ $user->surname }}
'title' => 'Все пользователи', 'class' => 'btn btn-default' ); } */ $temp = array(); $def_arr = array( 'link' => mb_substr(action($module['class'] . '@getIndex'), 0, -6), 'title' => 'Все пользователи (' . (Allow::superuser() ? User::count() : User::where('group_id', '!=', 1)->count()) . ')', ); $temp[] = $def_arr; if(isset($groups) && $groups->count()) { foreach ($groups as $grp) { if ($grp->id == 1 && !Allow::superuser()) continue; $arr = array( 'link' => mb_substr(action($module['class'] . '@getIndex'), 0, -6) . "?group_id=" . $grp->id, 'title' => $grp->desc . ' (' . $grp->count_users() . ')', ); if (@is_object($group) && $group->name == $grp->name) $def_arr = $arr; $temp[] = $arr; } } $def_arr['class'] = 'btn btn-default'; if (count($temp) > 1)
$current_link_attributes = Helper::multiArrayToAttributes(Input::get('filter'), 'filter'); $menus[] = array( 'link' => action(is_numeric($dic_id) ? 'dicval.create' : 'entity.create', array('dic_id' => $dic_id) + $current_link_attributes), 'title' => 'Добавить', 'class' => 'btn btn-primary' ); } if (Allow::action($module['group'], 'import')) { $menus[] = array( 'link' => action('dic.import', array('dic_id' => $dic_id)), 'title' => 'Импорт', 'class' => 'btn btn-primary' ); } if (Allow::action($module['group'], 'edit') && (!$dic->entity || Allow::superuser())) { $menus[] = array( 'link' => action('dic.edit', array('dic_id' => $dic->id)), 'title' => 'Изменить', 'class' => 'btn btn-success' ); } if (isset($total_elements_current_selection) && is_numeric($total_elements_current_selection) && $total_elements_current_selection > 0 && Allow::superuser()) { $menus[] = array( #'link' => URL::route('dic.clear', array('dic_id' => $dic->id)), 'title' => 'Очистить', 'class' => 'btn btn-danger' 'raw' => Form::open(['url' => URL::route('dic.clear', array('dic_id' => $dic->id)), 'method' => 'POST', 'class' => 'clear_dic', 'style' => 'display:inline-block']) . Form::submit('Очистить', ['class' => 'btn btn-danger margin-bottom-5']) . Form::close(), ); } if (isset($dic_settings['menus'])) $dic_menu = $dic_settings['menus']; #Helper::d($dic_menu); if (isset($dic_menu) && is_callable($dic_menu)) { $tmp = (array)$dic_menu($dic, isset($element) && is_object($element) ? $element : NULL); $menus = array_merge($menus, $tmp); } #Helper::d($menus);
private function checkDicPermission($dic) { if (!is_object($dic)) { return false; } $return = true; if ((int) $dic->view_access == 0) { $return = true; } elseif ((int) $dic->view_access == 1 && !Allow::superuser()) { $return = false; } elseif ((int) $dic->view_access == 2 && !Allow::action($this->module['group'], 'hidden')) { $return = false; } #Helper::dd($return); return $return; }
public function getSphinx($dic_id) { if (!Allow::superuser()) { App::abort(404); } $dic = Dictionary::where(is_numeric($dic_id) ? 'id' : 'slug', $dic_id)->first(); if (!is_object($dic)) { App::abort(404); } #Helper::d('Данные словаря:') . Helper::ta($dic); $fields = Config::get('dic/' . $dic->slug . '.fields'); if (isset($fields) && is_callable($fields)) { $fields = $fields(); } #Helper::d('Доп. поля словаря (fields):') . Helper::d($fields); $fields_i18n = Config::get('dic/' . $dic->slug . '.fields_i18n'); if (isset($fields_i18n) && is_callable($fields_i18n)) { $fields_i18n = $fields_i18n(); } #Helper::d('Мультиязычные доп. поля словаря (fields_i18n):') . Helper::d($fields_i18n); $tbl_dic_field_val = (new DicFieldVal())->getTable(); $tbl_dic_textfield_val = (new DicTextFieldVal())->getTable(); /** * Будут индексироваться только поля следующих типов */ $indexed_types = array('textarea', 'textarea_redactor', 'text'); $fulltext_types = array('textarea', 'textarea_redactor'); $selects = array("dicval.id AS id", $dic->id . " AS dic_id", $dic->id . " AS source_id", "'" . $dic->name . "' AS dic_name", "'" . $dic->slug . "' AS dic_slug", "dicval.name AS name"); $sql = array(); $j = 0; /** * Поиск по обычным полям */ if (isset($fields) && is_array($fields) && count($fields)) { foreach ($fields as $field_key => $field) { if (!isset($field['type']) || !in_array($field['type'], $indexed_types)) { continue; } $tbl_field = in_array($field['type'], $fulltext_types) ? $tbl_dic_textfield_val : $tbl_dic_field_val; ++$j; $tbl = "tbl" . $j; ##$selects[] = $tbl . '.language AS language'; $selects[] = $tbl . '.value AS ' . $field_key; $sql[] = "LEFT JOIN " . $tbl_field . " AS " . $tbl . " ON " . $tbl . ".dicval_id = dicval.id AND " . $tbl . ".key = '" . $field_key . "' AND " . $tbl . ".language IS NULL"; } } /** * Поиск по мультиязычным полям */ if (isset($fields_i18n) && is_array($fields_i18n) && count($fields_i18n)) { foreach ($fields_i18n as $field_key => $field) { if (!in_array($field['type'], $indexed_types)) { continue; } $tbl_field = in_array($field['type'], $fulltext_types) ? $tbl_dic_textfield_val : $tbl_dic_field_val; ++$j; $tbl = "tbl" . $j; ##$selects[] = $tbl . '.language AS language'; $selects[] = $tbl . '.value AS `' . $field_key . '`'; $sql[] = "LEFT JOIN " . $tbl_field . " AS " . $tbl . " ON " . $tbl . ".dicval_id = dicval.id AND " . $tbl . ".key = '" . $field_key . "' AND " . $tbl . ".language IS NOT NULL"; } } $sql[] = "WHERE dicval.version_of IS NULL AND dicval.dic_id = '" . $dic->id . "'"; $selects_compile = implode(', ', $selects); array_unshift($sql, "SELECT " . $selects_compile . " FROM " . (new DicVal())->getTable() . " AS dicval"); return "<h1>Поиск по словарю «" . $dic->name . "» (" . $dic->slug . ")</h1>" . "<h3>SQL-запрос для тестирования (phpMyAdmin):</h3>" . nl2br(implode("\n", $sql)) . "<h3>SQL-запрос для вставки в конфиг Sphinx:</h3>" . "<pre>\n sql_query = \\\n " . implode(' \\' . "\n ", $sql) . "\n\n sql_attr_uint = source_id\n</pre>"; }
} if (Allow::action($module['group'], 'create')) { $menus[] = array( 'link' => URL::route('dic.create', null), 'title' => 'Добавить', 'class' => 'btn btn-primary' ); } if (Allow::action($module['group'], 'import') && @$dic_id) { $menus[] = array( 'link' => action('dic.import', array('dic_id' => $dic_id)), 'title' => 'Импорт', 'class' => 'btn btn-primary' ); } if (Allow::superuser() && @is_object($element) && $element->id) { $menus[] = array( 'link' => action('dic.sphinx', array('dic_id' => $element->id)), 'title' => '<i class="fa fa-search-plus"></i>', 'class' => 'btn btn-info', 'others' => array( 'title' => 'SQL-запрос для Sphinx', 'target' => '_blank', ), ); } ?> <h1>Словари</h1> {{ Helper::drawmenu($menus) }}