function defineLocale($lang = '') { $locale = langToLocale($lang); if (!empty($locale)) { define('LOCALE', $locale); } else { define('LOCALE', detect_language()); } $results = putenv("LC_ALL=" . LOCALE); $results = putenv("LANG=" . LOCALE); $results = setlocale(LC_ALL, LOCALE . '.utf8'); $results = bind_textdomain_codeset("messages", "UTF-8"); $results = bindtextdomain("messages", "./locales"); $results = textdomain("messages"); }
function confRoomNew($name, $floor) { $link = Link::get_link('domoleaf'); $floorList = $this->confFloorList(); if (empty($floorList[$floor])) { return null; } $tmpName = $name; if (empty($name)) { $tmpName = 'room'; } $sql = 'INSERT INTO room (room_name, floor) VALUES (:name, :floor)'; $req = $link->prepare($sql); $req->bindValue(':name', $tmpName, PDO::PARAM_STR); $req->bindValue(':floor', $floor, PDO::PARAM_INT); $req->execute() or die(error_log(serialize($req->errorInfo()))); $newroomid = $link->lastInsertId(); if (!empty($newroomid)) { $sql = 'INSERT INTO mcuser_room (mcuser_id, room_id) SELECT mcuser_id, ' . $newroomid . ' FROM mcuser'; $req = $link->prepare($sql); $req->execute() or die(error_log(serialize($req->errorInfo()))); if (empty($name)) { $LOCALE = langToLocale($this->getLanguage()); putenv("LC_ALL=" . $LOCALE); setlocale(LC_ALL, $LOCALE); bind_textdomain_codeset("messages", "UTF-8"); bindtextdomain("messages", "/etc/domoleaf/www/locales"); textdomain("messages"); $name = _('Room') . ' ' . $newroomid; $this->confRoomRename($newroomid, $name); } } $sql = 'SELECT mcuser_id FROM mcuser WHERE mcuser_level>=2'; $req = $link->prepare($sql); $req->execute() or die(error_log(serialize($req->errorInfo()))); while ($do = $req->fetch(PDO::FETCH_OBJ)) { $this->confUserVisibleRoom($do->mcuser_id, $newroomid, 1); } }