Revision 1093 | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed
<?php/**** @package WebanOS CI* @author Lars Tiefland <ltiefland@gmail.com>* @copyright 2016* @version $Rev: 2383 $*/class User_rechte_model extends CI_Model{public function __construct(){parent::__construct();}public function get_rechte($ID = null){$user_properties = array();if ($ID){$sql = "SELECT*FROMuser_propertiesWHEREAccess = ".$ID."";$result = $GLOBALS["db_red"]->query($sql);while ($zeile = $result->unbuffered_row('array')){$user_properties[$zeile["properties"]] = 1;}$sql = "SELECT*FROMAccessWHEREID = ".$ID."";$result = $GLOBALS["db_red"]->query($sql);$user = $result->row_array();list($user_name, $user_site) = explode("@", $user["user"]);$user["site"] = $user_site;$user["properties"] = $user_properties;return $user;}}public function get_rights(){$modules = array();$sql = "SELECT*FROMmodulesORDER byrang";$result = $GLOBALS["db_red"]->query($sql);while ($module = $result->unbuffered_row('array')){//$module["name"] = html_entity_decode($module["name"]);if (isset($GLOBALS["web_rechte"][$module["interner_name"]])){$sql = "SELECTtools.*FROMtoolsWHEREtools.modules = ".$module["ID"]."ORDER BYtools.rang";$result_tools = $GLOBALS["db_red"]->query($sql);while ($tool = $result_tools->unbuffered_row('array')){//$tool["name"] = ($tool["name"]);if (isset($GLOBALS["web_rechte"][$module["interner_name"]][$tool["button_name"]])){$sql = "SELECTproperties.*FROMpropertiesWHEREproperties.tools = ".$tool["ID"]."ANDhidden = 'false'ORDER BYproperties.rang";$result_properties = $GLOBALS["db_red"]->query($sql);while ($property = $result_properties->unbuffered_row('array')){//$property["name"] = utf8_encode($property["name"]);if (isset($GLOBALS["web_rechte"][$module["interner_name"]][$tool["button_name"]][$property["interner_name"]])){if ($GLOBALS["web_rechte"][$module["interner_name"]][$tool["button_name"]][$property["interner_name"]]){$property["web_name"] = $GLOBALS["web_rechte"][$module["interner_name"]][$tool["button_name"]][$property["interner_name"]];if (($property["web_name"])){if (stristr($property["web_name"], ";")){$name = explode(";", $property["web_name"]);if (stristr($name[0], ":")){$property["name"] = $name[0];}}//elseif ($property["web_name"][strlen($property["web_name"])] == ":")elseif (substr($property["web_name"], -1, 1) == ":"){$property["name"] = $property["web_name"];}}}$tool["properties"][] = $property;}}if (@count($tool["properties"])){$module["tools"][] = $tool;}}}if (@count($module["tools"])){$modules[] = $module;}}}return $modules;}public function get_info($user_id){$sql = "SELECT*FROMAccessWHEREid=".$user_id."";$res = $GLOBALS["db_red"]->query($sql);$user = $res->row_array();list($user_local, $domain) = explode("@", $user["user"]);$user["domain"] = $domain;$user["local"] = $user_local;$user["datenquellen"] = unserialize($user["datenquellen"]);return $user;}public function save(){if ($_SERVER['SERVER_NAME'] == "ci.starfleethq.de"){$GLOBALS['db_red_write'] = $GLOBALS['db_red'];}else{$GLOBALS['db_red_write'] = $this->load->database('db_red_write', TRUE);}$sql = "INSERT INTOuser_properties(Access,properties)VALUES(?,?)";$GLOBALS['db_red_write']->trans_start();$this->del();foreach ($this->input->post('modules') as $tools){foreach ($tools as $properties){foreach ($properties as $elem => $val){if ($val){$data = array($this->input->post('ID'),$elem,);$GLOBALS['db_red_write']->query($sql, $data);}}}}$GLOBALS['db_red_write']->trans_complete();}private function del(){$sql = "DELETE FROMuser_propertiesWHEREaccess=".$this->input->post('ID')."";$GLOBALS['db_red_write']->query($sql);}}?>