/** * check if the login user have rights to modify * data of other users * * @param int $uid user id to modify * @return bool */ function ask_access_to_modify_user($uid) { if (TRUE == rights::is_login_user($uid)) { return TRUE; } $fields = array('rights'); $data = $GLOBALS['B']->user->get_user($uid, $fields); if ($GLOBALS['B']->auth->user_rights == 4) { if ($data['rights'] < 4) { return TRUE; } return FALSE; } elseif ($GLOBALS['B']->auth->user_rights == 5) { return TRUE; } return FALSE; }
public function proc_upd() { $mini_action = substr(system::action(), -3); if (system::action() == "proc_upd") { // Говорим какой объект нужно изменить $obj = ormObjects::get(system::POST('obj_id')); } else { if (system::action() == "proc_add") { // Говорим какой объект нужно создать $obj = new ormObject(); $obj->setClass('user_group'); } } // Если произошли ошибки, перенаправляем на главную страницу модуля if (!$obj->isInheritor('user_group')) { system::redirect('/users'); } // Присваиваем пришедшие значения полям в объекте $obj->loadFromPost($mini_action); // Сохраняем изменения $obj_id = $obj->save(); // Если объект не сохранился, выводим пользователю текст ошибки. if ($obj_id === false) { system::savePostToSession(); ui::MessageBox(lang::get('TEXT_MESSAGE_ERROR'), $obj->getErrorListText()); system::redirect('/users/group_' . $mini_action . '/' . $_POST['obj_id']); } else { rights::setListForModuls($obj_id, 0); } // Если данные изменились корректно перенаправляем на соответствующию страницу if ($_POST['parram'] == 'apply') { system::redirect('/users/group_upd/' . $obj_id); } else { system::redirect('/users'); } }
public function save() { if (!$this->issetErrors() && (empty($this->values['d_name']) || empty($this->values['d_def_lang']) || empty($this->values['d_email']) || empty($this->values['d_sitename']))) { $this->newError(61, 'Не все обязательные поля были заполнены!'); } if ($this->issetErrors()) { return false; } else { if (!empty($this->id)) { // Изменение домена $sql = $this->getSql(); if (!empty($sql)) { db::q('UPDATE <<domains>> SET ' . $sql . ' WHERE d_id = "' . $this->id . '";'); } system::log('Изменен домен "' . $this->values['d_name'] . '" (id:' . $this->id . ')', warning); // Переименовываем папки с шаблонами if ($this->old_name != $this->values['d_name']) { $lang = languages::getAll(); while (list($key, $val) = each($lang)) { if ($this->id != 1 || $val['l_id'] != 1) { $old_name = '/__' . str_replace('.', '_', $this->old_name) . '_' . $val['l_prefix']; $new_name = '/__' . str_replace('.', '_', $this->values['d_name']) . '_' . $val['l_prefix']; @rename(TEMPL_DIR . $old_name, TEMPL_DIR . $new_name); } } } return true; } else { // Добавление домена $sql = $this->getSql(); if (!empty($sql)) { $this->id = db::q('INSERT INTO <<domains>> SET ' . $sql . ';'); } if (!empty($this->id)) { $lang = languages::getAll(); while (list($key, $val) = each($lang)) { rights::createForStructure($this->id, $val['id']); $templ = new template(); $templ->setName('default'); $templ->setFile('default'); $templ->setLangId($val['id']); $templ->setDomainId($this->id); $templ->save(); reg::setKey('/structure/' . $this->id . '/' . $val['id'] . '/title_prefix', '%text% | ' . $this->values['d_sitename']); reg::setKey('/structure/' . $this->id . '/' . $val['id'] . '/view_as_tree', 1); $dname = '/__' . str_replace('.', '_', $this->values['d_name']) . '_' . $val['l_prefix']; $this->copyDir(TEMPL_DIR, TEMPL_DIR . $dname); } system::log('Создан домен "' . $this->values['d_name'] . '" (id:' . $this->id . ')', warning); return true; } else { $this->newError(62, 'Произошла ошибка при добавлении домена!'); system::log('Произошла ошибка при добавлении домена!', error); return false; } } } }
header("Location: {$config_webserver_ip}/accessdenied.html"); exit; } //current steam objects if ((int) $questionary_id != 0) { $questionary = steam_factory::get_object($steam, $questionary_id); $question_folder = $questionary->get_object_by_name('questions'); $answer_folder = $questionary->get_object_by_name('answers'); if ((int) $question_id != 0) { $question = steam_factory::get_object($steam, $question_id); } } else { header("Location: {$config_webserver_ip}/index.php"); } //create new RIGHTS object $rights = new rights($steam, $questionary, $question_folder, $answer_folder); //check author permission $login_user = $steam->get_login_user(); $login_user_id = $login_user->get_id(); $login_user_groups = $login_user->get_groups(); foreach ($login_user_groups as $login_user_group) { $login_user_group_ids[] = $login_user_group->get_id(); } $is_author = $rights->check_access_edit($login_user, $login_user_group_ids); if (!$is_author || count($answer_folder->get_inventory()) > 0) { //Disconnect & close $steam->disconnect(); die("<html>\n<body onload='javascript:window.close();'>\n</body>\n</html>"); } //load question if ($action == "edit" && isset($question)) {
} //current room steam object if ((int) $questionary_id != 0) { $questionary = steam_factory::get_object($steam, $questionary_id); $question_folder = $questionary->get_object_by_name('questions'); $answer_folder = $questionary->get_object_by_name('answers'); } else { $steam->disconnect(); header("Location: {$config_webserver_ip}/index.php"); } //owner of the questionary $owner = $questionary->get_creator(); $owner_id = $owner->get_id(); $owner_name = $owner->get_name(); //create new RIGHTS object $rights = new rights($steam, $questionary, $question_folder, $answer_folder); //check author permission $login_user = $steam->get_login_user(); $login_user_id = $login_user->get_id(); $login_user_groups = $login_user->get_groups(); foreach ($login_user_groups as $login_user_group) { $login_user_group_ids[] = $login_user_group->get_id(); } $is_author = $rights->check_access_edit($login_user, $login_user_group_ids); if (!$is_author || count($answer_folder->get_inventory()) > 0 || $owner_id != $login_user_id) { //Disconnect & close $steam->disconnect(); die("<html>\n<body onload='javascript:window.close();'>\n</body>\n</html>"); } //get questionary name $questionary_name = $questionary->get_name();
$login_user = $steam->get_login_user(); $login_user_id = $login_user->get_id(); //current room steam object if ((int) $questionary_id != 0) { $questionary = steam_factory::get_object($steam, $questionary_id); $question_folder = $questionary->get_object_by_name('questions'); $answer_folder = $questionary->get_object_by_name('answers'); if ((int) $answer_id != 0) { $answer = steam_factory::get_object($steam, $answer_id); $is_answer_creator = $answer->get_creator()->get_id() == $login_user_id; } } else { header("Location: {$config_webserver_ip}/index.php"); } //create new RIGHTS object $rights = new rights($steam, $questionary, $question_folder, $answer_folder); //check permissions $login_user_groups = $login_user->get_groups(); foreach ($login_user_groups as $login_user_group) { $login_user_group_ids[] = $login_user_group->get_id(); } $is_editor = $rights->check_access_fillout($login_user, $login_user_group_ids); $is_analyst = $rights->check_access_evaluate($login_user, $login_user_group_ids); $is_author = $rights->check_access_edit($login_user, $login_user_group_ids); if (!$is_author && !$is_editor) { //Disconnect & close $steam->disconnect(); die("<html><body>No access right</body></html>"); } //get attributes $attributes = $questionary->get_attributes(array(OBJ_NAME, OBJ_DESC, "bid:questionary:fillout", "bid:questionary:number", "bid:questionary:edittime", "bid:questionary:editanswer", "bid:questionary:editownanswer", "bid:questionary:enabled"));
public function hasRight($_right, $_needAdmin = false, $_user = null) { if (!is_object($_user)) { $_user = $_SESSION['user']; } if (!is_object($_user)) { return false; } if (!isConnect()) { return false; } if (isConnect('admin')) { return true; } if ($_right == 'x') { $rights = rights::byuserIdAndEntity($_user->getId(), 'scenario' . $this->getId() . 'action'); } elseif ($_right == 'w') { $rights = rights::byuserIdAndEntity($_user->getId(), 'scenario' . $this->getId() . 'edit'); } elseif ($_right == 'r') { $rights = rights::byuserIdAndEntity($_user->getId(), 'scenario' . $this->getId() . 'view'); } if (!is_object($rights)) { return $_needAdmin ? false : true; } return $rights->getRight(); }
public function proc_upd() { $mini_action = substr(system::action(), -3); if (system::action() == "proc_upd") { // Говорим какой объект нужно изменить $obj = ormObjects::get(system::POST('obj_id')); } else { if (system::action() == "proc_add") { $class_name = 'user'; $class = ormClasses::get($_POST['class_id']); if ($class instanceof ormClass && $class->isInheritor('user')) { $class_name = $class->getSName(); } // Говорим какой объект нужно создать $obj = new ormObject(); $obj->setClass($class_name); } } // Если произошли ошибки, перенаправляем if ($obj->issetErrors()) { system::redirect('/users/userlist/' . $_POST['groups'][0]); } // Присваиваем полям в объекте пришедшие значения из POST $obj->loadFromPost($mini_action); if ($obj->newVal('active')) { $obj->error_passw = 0; } if ($obj->id == user::get('id')) { $obj->active = 1; } // Сохраняем изменения $obj_id = $obj->save(); // Если объект не сохранился, выводим пользователю текст ошибки. if ($obj_id === false) { system::savePostToSession(); ui::MessageBox(lang::get('TEXT_MESSAGE_ERROR'), $obj->getErrorListText()); ui::selectErrorFields($obj->getErrorFields()); $obj_id = empty($_POST['obj_id']) ? $_POST['groups'][0] : $_POST['obj_id']; system::redirect('/users/user_' . $mini_action . '/' . $obj_id); } else { rights::setListForModuls($obj_id, 1); cache::delete('user' . $obj_id); } // Если данные изменились корректно перенаправляем на соответствующию страницу if ($_POST['parram'] == 'apply') { system::redirect('/users/user_upd/' . $obj_id); } else { system::redirect('/users/userlist/' . $_POST['groups'][0]); } }
function hasRight($_right, $_needAdmin = false) { if (!isConnect()) { return false; } if (isConnect('admin')) { return true; } $rights = rights::byuserIdAndEntity($_SESSION['user']->getId(), $_right); if (!is_object($rights)) { return $_needAdmin ? false : true; } return $rights->getRight(); }
public function hasRight($_right, $_needAdmin = false, $_user = null) { if (!is_object($_user)) { if (session_status() != PHP_SESSION_NONE || !isset($_SESSION) || !isset($_SESSION['user'])) { return true; } $_user = $_SESSION['user']; } if (!is_object($_user)) { return false; } if (!isConnect()) { return false; } if (isConnect('admin')) { return true; } $rights = null; if ($_right == 'x') { $rights = rights::byuserIdAndEntity($_user->getId(), 'eqLogic' . $this->getId() . 'action'); } elseif ($_right == 'r') { $rights = rights::byuserIdAndEntity($_user->getId(), 'eqLogic' . $this->getId() . 'view'); } if (!is_object($rights)) { return $_needAdmin ? false : true; } return $rights->getRight(); }
} else { // Check if you want to change your own rights or status if ($_POST['rights_orig'] != (int) $_POST['rights'] || $_POST['status_orig'] != (int) $_POST['status']) { if (TRUE == rights::is_login_user((int) $_POST['uid'])) { $B->form_error = 'You can not change your own rights or status!'; } } // Check if you can change rights to the demanded level if (FALSE == $B->form_error && $_POST['rights_orig'] != (int) $_POST['rights']) { if (FALSE == rights::ask_set_rights((int) $_POST['uid'], (int) $_POST['rights'])) { $B->form_error = 'You can not change to this rights level!'; } } // Check if you can change status of this user if (FALSE == $B->form_error && $_POST['status_orig'] != (int) $_POST['status']) { if (FALSE == rights::ask_set_status((int) $_POST['uid'])) { $B->form_error = 'You can not change status of this user!'; } } // if no error occure, proceed ... if (empty($B->form_error)) { $B->tmp_data = array('forename' => $B->db->quoteSmart($B->util->stripSlashes($_POST['forename'])), 'lastname' => $B->db->quoteSmart($B->util->stripSlashes($_POST['lastname'])), 'email' => $B->db->quoteSmart($B->util->stripSlashes($_POST['email'])), 'rights' => (int) $_POST['rights'], 'status' => (int) $_POST['status']); // update password if it isnt empty if (!empty($_POST['passwd'])) { $B->tmp_data['passwd'] == $B->db->quoteSmart(md5($_POST['passwd'])); } // update user data if (FALSE != $B->user->update_user((int) $_REQUEST['uid'], $B->tmp_data)) { @header('Location: ' . SF_BASE_LOCATION . '/admin/index.php?m=USER'); exit; } else {
* GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Jeedom. If not, see <http://www.gnu.org/licenses/>. */ try { require_once dirname(__FILE__) . '/../../core/php/core.inc.php'; include_file('core', 'authentification', 'php'); if (!isConnect('admin')) { throw new Exception(__('401 - Accès non autorisé', __FILE__)); } if (init('action') == 'byUserId') { ajax::success(utils::o2a(rights::byUserId(init('user_id')))); } if (init('action') == 'save') { $rights_json = json_decode(init('rights'), true); foreach ($rights_json as $right_json) { $rights = rights::byId($right_json['id']); if (!is_object($rights)) { $rights = new rights(); } utils::a2o($rights, $right_json); $rights->save(); } ajax::success(); } throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayExeption($e), $e->getCode()); }
<?php $tester = new stundenplan(); $ausgabe = $tester->get_Blocks(); //Syntax: get_LFR($klasse_id, $datum, $block_nr) $ausgabe2 = $tester->get_Tagesplan(3, '2009-07-01'); html::showAll($ausgabe2); html::showAll($ausgabe); $ausgabe3 = new rights(); $ausgabe3->getRights(ADMIN); echo '<br>'; $ausgabe3->getRights(FBL); echo '<br>'; $ausgabe3->getRights(LEHRER); echo '<br>'; $ausgabe3->getRights(SCHUELER); echo '<br>'; $ausgabe3->getRights(SEKRETAERIN); echo '<br>';
public function save() { if (!$this->issetErrors() && (empty($this->values['l_name']) || empty($this->values['l_prefix']))) { $this->newError(52, 'Поля "Название" и "Префикс" обязательны для заполнения!'); } if ($this->issetErrors()) { return false; } else { if (!empty($this->id)) { // Изменение языка $sql = $this->getSql(); if (!empty($sql)) { db::q('UPDATE <<langs>> SET ' . $sql . ' WHERE l_id = "' . $this->id . '";'); } system::log('Изменена языковая версия сайта "' . $this->values['l_name'] . '" (id:' . $this->id . ')', warning); // Переименовываем папки с шаблонами if ($this->old_prefix != $this->values['l_prefix']) { $domain = domains::getAll(); while (list($key, $val) = each($domain)) { if ($this->id != 1 || $val['d_id'] != 1) { $old_name = '/__' . str_replace('.', '_', $val['d_name']) . '_' . $this->old_prefix; $new_name = '/__' . str_replace('.', '_', $val['d_name']) . '_' . $this->values['l_prefix']; @rename(TEMPL_DIR . $old_name, TEMPL_DIR . $new_name); } } } return true; } else { // Добавление языка $sql = $this->getSql(); if (!empty($sql)) { $this->id = db::q('INSERT INTO <<langs>> SET ' . $sql . ';'); } if (is_numeric($this->id)) { // Добавляем для каждого домена право и шаблон $domain = domains::getAll(); while (list($key, $val) = each($domain)) { rights::createForStructure($val['id'], $this->id); $templ = new template(); $templ->setName('default'); $templ->setFile('default'); $templ->setLangId($this->id); $templ->setDomainId($val['id']); $templ->save(); reg::setKey('/structure/' . $val['id'] . '/' . $this->id . '/title_prefix', '%text% | ' . $val['d_sitename']); reg::setKey('/structure/' . $val['id'] . '/' . $this->id . '/view_as_tree', 1); // Создаем папки с шаблонами $dname = '/__' . str_replace('.', '_', $val['d_name']) . '_' . $this->values['l_prefix']; $this->copyDir(TEMPL_DIR, TEMPL_DIR . $dname); } system::log('Создана новая языковая версия сайта "' . $this->values['l_name'] . '" (id:' . $this->id . ')', warning); return true; } else { $this->newError(53, 'Произошла ошибка при добавление языка!'); system::log('Произошла ошибка при добавление языка!', error); return false; } } } }
public function proc_upd() { $mini_action = substr(system::action(), -3); $this->createTemplate('template_id'); $this->createTemplate('template2_id'); if (system::action() == "proc_upd") { // Говорим какой объект нужно изменить $obj = new ormPage(system::POST('obj_id')); } else { if (system::action() == "proc_add") { // Говорим какой объект нужно создать $obj = new ormPage(); $obj->setClass(system::POST('class_id')); $obj->setParent(system::POST('obj_id')); } } // Если произошли ошибки, перенаправляем на главную страницу модуля if ($obj->issetErrors()) { system::redirect('/structure/tree'); } // Присваиваем пришедшие значения полям в объекте $obj->loadFromPost($mini_action); rights::setListForObject($obj); // Сохраняем изменения $obj_id = $obj->save(); // Если объект не сохранился, выводим пользователю текст ошибки. if ($obj_id === false) { system::savePostToSession(); ui::MessageBox(lang::get('TEXT_MESSAGE_ERROR'), $obj->getErrorListText()); ui::selectErrorFields($obj->getErrorFields()); $class = $mini_action == 'add' ? '/' . system::POST('class_id') : ''; system::redirect('/structure/page_' . $mini_action . '/' . $_POST['obj_id'] . $class); } else { // Присваиваем выбранные шаблоны для всех вложенных объектов, если выбрано. if (system::POST('template_id_all', isBool)) { $this->inheritTemplate($_POST['template_id'], false, $obj_id); } if (system::POST('template2_id_all', isBool)) { $this->inheritTemplate($_POST['template2_id'], true, $obj_id); } } // Если данные изменились корректно перенаправляем на соответствующию страницу if ($_POST['parram'] == 'apply') { system::redirect('/structure/page_upd/' . $obj_id); } else { if (isset($_SESSION['STRUCTURE_LIST_FLAG']) && $_SESSION['STRUCTURE_LIST_FLAG']) { system::redirect('/structure/list/' . $obj->getParentId()); } else { system::redirect('/structure/tree'); } } }
//User Class instance $B->user =& new user(); // set the base template for this module $B->module = SF_BASE_DIR . '/admin/modules/user/templates/index.tpl.php'; // Assign template var : module handler name $B->this_module = EVT_HANDLER_USER; // Switch to module features switch ($_REQUEST['mf']) { case 'edit_usr': include SF_BASE_DIR . "/admin/modules/user/edituser.php"; // set the base template for this module feature $B->section = SF_BASE_DIR . '/admin/modules/user/templates/edituser.tpl.php'; break; case 'add_usr': // have rights to add users? if (FALSE == rights::ask_access_to_add_user()) { @header('Location: ' . SF_BASE_LOCATION . '/admin/index.php?m=USER'); exit; } if (isset($_POST['adduser'])) { include SF_BASE_DIR . "/admin/modules/user/adduser.php"; } // set the base template for this module feature $B->section = SF_BASE_DIR . '/admin/modules/user/templates/adduser.tpl.php'; break; case 'del_usr': // Include default include SF_BASE_DIR . "/admin/modules/user/deluser.php"; break; default: // set the base template for this module