public function testLoadFromFile() { $file = dirname(__FILE__) . '/data/test.xml'; $xmldoc = new TXmlDocument(); try { $xmldoc->loadFromFile('unexistentXmlFile.xml'); self::fail('Expected TIOException not thrown'); } catch (TIOException $e) { } self::assertTrue($xmldoc->loadFromFile($file)); self::assertEquals('1.0', $xmldoc->getVersion()); self::assertEquals('UTF-8', $xmldoc->getEncoding()); }
public function onLoad($param) { parent::onLoad($param); $this->dbConexion = Conexion::getConexion($this->Application, "db"); Conexion::createConfiguracion(); if (!$this->isPostBack) { if (array_search("nusr", $this->User->Roles)) { //Lee el archivo menu.xml para buscar los permisos de acceso a páginas que tenga activos para mostrar opciones $this->permisos = array(); $this->asignados = array(); $doc = new TXmlDocument(); $doc->loadFromFile("protected/layouts/menu.xml"); $x = $doc->getElements(); $this->leeMenuXml($x); $this->cblPermisos->setDataSource($this->permisos); $this->cblPermisos->dataBind(); } $this->Enlaza_Coord(); $this->Enlaza_Usuario(); if (!array_search("nusr", $this->User->Roles)) { $this->addlUsuarios->SelectedValue = $this->User->Name; $this->addlUsuarios_Callback(null, null); $this->addlUsuarios->Visible = false; $this->alblUsuarios->Visible = false; $this->alblPermisos->Visible = false; $this->atxtUsuario->Enabled = false; } } }
public function onInit($param) { parent::onInit($param); /* if($this->User->IsGuest) $this->mnuPrincipal->Visible = false; else*/ $this->mnuPrincipal->Visible = true; /* echo $this->User->Name; echo "<br />"; echo $this->Application->id; */ if ($this->Request["popup"] != null) { $this->mnuPrincipal->Visible = false; $this->pnlEncabezado->Visible = false; if ($this->Request["popup"] == "1") { $this->pnlCerrar->Visible = true; } else { $this->pnlCerrar->Visible = false; } } else { $this->pnlCerrar->Visible = false; $doc = new TXmlDocument(); $doc->loadFromFile("protected/layouts/menu.xml"); $x = $doc->getElements(); $this->creaMenuXml($x, $this->mnuPrincipal); } }
protected function getComponentShortCut() { $data = array(); $app = $this->getApplication(); $db = $app->getModule('horuxDb')->DbConnection; $db->Active = true; $cmd = $this->db->createCommand("SELECT * FROM hr_install WHERE type='component' AND name!='tracking'"); $data_ = $cmd->query(); $data_ = $data_->readAll(); $isComponentHasOne = false; foreach ($data_ as $d) { $doc = new TXmlDocument(); $doc->loadFromFile('./protected/pages/components/' . $d['name'] . '/install.xml'); $name = $doc->getElementByTagName('name'); $installName = $doc->getElementByTagName('installName')->getValue(); $cmd = $this->db->createCommand("SELECT * FROM hr_install WHERE type='component' AND name='{$installName}'"); $data1 = $cmd->query(); $data1 = $data1->readAll(); foreach ($data1 as $d1) { $cmd = $this->db->createCommand("SELECT * FROM hr_install AS i LEFT JOIN hr_component as c ON c.id_install=i.id WHERE i.type='component' AND c.parentmenu=0 AND i.id=" . $d1['id']); $data2 = $cmd->query(); $data2 = $data2->read(); $url = "./themes/letux/images/header/icon-48-link.png"; if (!$isComponentHasOne) { if ($this->isAccess($data2['page'])) { $data[] = array('page' => $data2['page'], 'Name' => Prado::localize($name->getValue(), array(), $data2['name']), 'icon' => $url); } $isComponentHasOne = true; } else { if ($this->isAccess($data2['page'])) { $data[] = array('page' => $data2['page'], 'Name' => Prado::localize($name->getValue(), array(), $data2['name']), 'icon' => $url); } } $cmd = $this->db->createCommand("SELECT * FROM hr_install AS i LEFT JOIN hr_component as c ON c.id_install=i.id WHERE i.type='component' AND c.parentmenu=" . $data2['id'] . " AND c.parentmenu>0 AND i.id=" . $d1['id']); $data2 = $cmd->query(); $data2 = $data2->readAll(); foreach ($data2 as $d2) { if ($this->isAccess($d2['page'])) { $pagePath = str_replace(".", "/", $d2['page']); if (file_exists('./protected/pages/' . $pagePath . '.page')) { $content = file_get_contents('./protected/pages/' . $pagePath . '.page'); if (preg_match("/IconAsset=\"<%~(.*)%>\"/", $content, $matches)) { if (($assetPos = strrpos($matches[1], "assets/")) !== false) { $icon = substr($matches[1], $assetPos + 7); $icon = trim($icon); if ($icon) { $url = Prado::getApplication()->getAssetManager()->publishFilePath(Prado::getApplication()->getBasePath() . '/pages/components/' . $d2['name'] . '/assets/' . $icon); } } } } $data[] = array('page' => $d2['page'], 'Name' => Prado::localize($d2['menuname'], array(), $d2['name']), 'icon' => $url); } } } } return $data; }
/** * Initializes this module. * This method is required by the IModule interface. * @param TXmlElement configuration for this module, can be null * @throws TConfigurationException if {@link getConfigFile ConfigFile} is invalid. */ public function init($config) { if ($this->_configFile !== null) { if (is_file($this->_configFile)) { $dom = new TXmlDocument(); $dom->loadFromFile($this->_configFile); $this->loadConfig($dom); } else { throw new TConfigurationException('logrouter_configfile_invalid', $this->_configFile); } } $this->loadConfig($config); $this->getApplication()->attachEventHandler('OnEndRequest', array($this, 'collectLogs')); }
/** * Initializes this module. * This method is required by the IModule interface. * @param TXmlElement configuration for this module, can be null * @throws TConfigurationException if {@link getConfigFile ConfigFile} is invalid. */ public function init($config) { if ($this->_configFile !== null) { if (is_file($this->_configFile)) { $dom = new TXmlDocument(); $dom->loadFromFile($this->_configFile); $this->loadConfig($dom); } else { throw new TConfigurationException('xmlrpcservice_configfile_invalid', $this->_configFile); } } $this->loadConfig($config); $this->resolveRequest(); }
public function selectionChangedModule($sender, $param) { $value = $sender->getSelectedValue(); $d = array(); $d[] = array("Text" => Prado::localize("-- Select a Module--"), "Value" => "0"); if ($value == "." || $value == "0") { $this->extension->DataSource = $d; $this->extension->dataBind(); $this->displayLanguage(); return; } $list = array(); if ($value == "themes") { $list = scandir("." . DIRECTORY_SEPARATOR . "themes"); } else { $value = str_replace(".", DIRECTORY_SEPARATOR, $value); $list = scandir("." . DIRECTORY_SEPARATOR . "protected" . DIRECTORY_SEPARATOR . "pages" . DIRECTORY_SEPARATOR . $value); } $i = 1; foreach ($list as $l) { if ($l != "." && $l != ".." && $l != ".svn") { $doc = new TXmlDocument(); if ($value == "themes") { $doc->loadFromFile('.' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $l . DIRECTORY_SEPARATOR . 'install.xml'); } else { $doc->loadFromFile('.' . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'pages' . DIRECTORY_SEPARATOR . $value . DIRECTORY_SEPARATOR . $l . DIRECTORY_SEPARATOR . 'install.xml'); } $name = $doc->getElementByTagName('name'); $d[$i]['Value'] = $l; $d[$i++]['Text'] = $name->getValue(); } } $this->extension->DataSource = $d; $this->extension->dataBind(); $this->displayLanguage(); }
public function getData() { $cmd = $this->db->createCommand("SELECT * FROM hr_install WHERE type='language'"); $data = $cmd->query(); $data = $data->readAll(); $template = array(); foreach ($data as $d) { $doc = new TXmlDocument(); $doc->loadFromFile('.' . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'messages' . DIRECTORY_SEPARATOR . '' . $d['param'] . DIRECTORY_SEPARATOR . 'install.xml'); $version = $doc->getElementByTagName('version'); $date = $doc->getElementByTagName('creationDate'); $description = $doc->getElementByTagName('description'); $author = $doc->getElementByTagName('author'); $license = $doc->getElementByTagName('license'); $template[] = array('id' => $d['id'], 'name' => $d['name'], 'default' => $d['default'], 'version' => $version->getValue(), 'date' => $date->getValue(), 'description' => $description->getValue(), 'author' => $author->getValue(), 'license' => $license->getValue()); } return $template; }
/** * Initializes the module by loading parameters. * @param TXmlElement content enclosed within the module tag */ public function init($config) { $this->loadParameters($config); if ($this->_paramFile !== null) { if (($cache = $this->getApplication()->getCache()) !== null) { $cacheKey = 'TParameterModule:' . $this->_paramFile; if (($dom = $cache->get($cacheKey)) === false) { $dom = new TXmlDocument(); $dom->loadFromFile($this->_paramFile); $cache->set($cacheKey, $dom, 0, new TFileCacheDependency($this->_paramFile)); } } else { $dom = new TXmlDocument(); $dom->loadFromFile($this->_paramFile); } $this->loadParameters($dom); } $this->_initialized = true; }
/** * Initializes the module by loading parameters. * @param mixed content enclosed within the module tag */ public function init($config) { $this->loadParameters($config); if ($this->_paramFile !== null) { $configFile = null; if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_XML && ($cache = $this->getApplication()->getCache()) !== null) { $cacheKey = 'TParameterModule:' . $this->_paramFile; if (($configFile = $cache->get($cacheKey)) === false) { $cacheFile = new TXmlDocument(); $cacheFile->loadFromFile($this->_paramFile); $cache->set($cacheKey, $cacheFile, 0, new TFileCacheDependency($this->_paramFile)); } } else { if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) { $configFile = (include $this->_paramFile); } else { $configFile = new TXmlDocument(); $configFile->loadFromFile($this->_paramFile); } } $this->loadParameters($configFile); } $this->_initialized = true; }
/** * Loads a specific config file. * @param string config file name * @param string the page path that the config file is associated with. The page path doesn't include the page name. */ public function loadFromFile($fname, $configPagePath) { Prado::trace("Loading page configuration file {$fname}", 'System.Web.Services.TPageService'); if (empty($fname) || !is_file($fname)) { return; } if (Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) { $fcontent = (include $fname); $this->loadFromPhp($fcontent, dirname($fname), $configPagePath); } else { $dom = new TXmlDocument(); if ($dom->loadFromFile($fname)) { $this->loadFromXml($dom, dirname($fname), $configPagePath); } else { throw new TConfigurationException('pageserviceconf_file_invalid', $fname); } } }
/** * Loads a specific config file. * @param string config file name * @param string the page path that the config file is associated with. The page path doesn't include the page name. */ public function loadFromFile($fname, $configPagePath) { Prado::trace("Loading page configuration file {$fname}", 'System.Web.Services.TPageService'); if (empty($fname) || !is_file($fname)) { return; } $dom = new TXmlDocument(); if ($dom->loadFromFile($fname)) { $this->loadFromXml($dom, dirname($fname), $configPagePath); } else { throw new TConfigurationException('pageserviceconf_file_invalid', $fname); } }
protected function installComponent($compName) { $doc = new TXmlDocument(); $doc->loadFromFile('.' . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'pages' . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . '' . $compName . DIRECTORY_SEPARATOR . 'install.xml'); $installName = $doc->getElementByTagName('installName'); $sqlinstall = $doc->getElementByTagName('sqlinstall'); if ($sqlinstall) { $this->sqlInstall('.' . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'pages' . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . $compName . DIRECTORY_SEPARATOR . $sqlinstall->getValue()); } $cmd = $this->db->createCommand("INSERT INTO hr_install (`name`,`type`,`system`, `default`, `param`) VALUES (:name, 'component',0,0,'')"); $cmd->bindValue(":name", $installName->getValue(), PDO::PARAM_STR); $cmd->execute(); $lastId = $this->db->getLastInsertId(); $mainmenu = $doc->getElementByTagName('mainmenu'); $mainmenu = $mainmenu->getElements(); foreach ($mainmenu as $menu) { $iconmenu = $menu->getAttribute('iconmenu'); $url = $menu->getAttribute('url'); $menuname = $menu->getAttribute('name'); $parentmenu = 0; $cmd = $this->db->createCommand("INSERT INTO hr_component (`id_install`,`parentmenu`,`menuname`, `page`, `iconmenu`) VALUES (:lastId, :parentmenu,:menuname,:url,:iconmenu)"); $cmd->bindValue(":lastId", $lastId, PDO::PARAM_INT); $cmd->bindValue(":iconmenu", $iconmenu, PDO::PARAM_STR); $cmd->bindValue(":url", $url, PDO::PARAM_STR); $cmd->bindValue(":menuname", $menuname, PDO::PARAM_STR); $cmd->bindValue(":parentmenu", $parentmenu, PDO::PARAM_INT); $cmd->execute(); if ($menu->getHasElement()) { $submenu = $menu->getElementByTagName('submenus'); $submenu = $submenu->getElements(); $lastMenuId = $this->db->getLastInsertId(); foreach ($submenu as $smenu) { $iconmenu = $smenu->getAttribute('iconmenu'); $url = $smenu->getAttribute('url'); $menuname = $smenu->getAttribute('name'); $cmd = $this->db->createCommand("INSERT INTO hr_component (`id_install`,`parentmenu`,`menuname`, `page`, `iconmenu`) VALUES (:lastId, :parentmenu,:menuname,:url,:iconmenu)"); $cmd->bindValue(":lastId", $lastId, PDO::PARAM_INT); $cmd->bindValue(":iconmenu", $iconmenu, PDO::PARAM_STR); $cmd->bindValue(":url", $url, PDO::PARAM_STR); $cmd->bindValue(":menuname", $menuname, PDO::PARAM_STR); $cmd->bindValue(":parentmenu", $lastMenuId, PDO::PARAM_INT); $cmd->execute(); } } } $this->moveLanguageDirectory('.' . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'pages' . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . '' . $compName . DIRECTORY_SEPARATOR, $installName->getValue()); return true; }
public function loadFromFile($fname) { $dom = new TXmlDocument(); $dom->loadFromFile($fname); $this->loadFromXml($dom, dirname($fname)); }
/** * Initialize the module from configuration file. * @throws TConfigurationException if {@link getConfigFile ConfigFile} is invalid. */ protected function loadConfigFile() { if (is_file($this->_configFile)) { $dom = new TXmlDocument(); $dom->loadFromFile($this->_configFile); $this->loadUrlMappings($dom); } else { throw new TConfigurationException('urlmapping_configfile_inexistent', $this->_configFile); } }
protected function saveData() { $key = $this->Request->getKeys(); $res = array(); for ($i = 0; $i < count($key); $i++) { if (strpos($key[$i], "hidden_") !== FALSE) { $res[$this->Request[$key[$i]]] = $this->Request[$key[$i + 1]]; } } $id = $this->Request["id"]; $cmd = $this->db->createCommand("SELECT i.name FROM hr_install AS i LEFT JOIN hr_component AS c ON c.id_install=i.id WHERE i.id=:id AND c.parentmenu=0"); $cmd->bindValue(":id", $id, PDO::PARAM_INT); $cmd = $cmd->query(); $data = $cmd->read(); $this->cname->Text = $data["name"]; $xml = "." . DIRECTORY_SEPARATOR . "protected" . DIRECTORY_SEPARATOR . "pages" . DIRECTORY_SEPARATOR . "components" . DIRECTORY_SEPARATOR . $data["name"] . DIRECTORY_SEPARATOR . "config.xml"; if (file_exists($xml)) { $doc = new TXmlDocument(); $doc->loadFromFile($xml); $parameters = $doc->getElementByTagName('parameters'); $parameters = $parameters->getElements(); foreach ($parameters as $parameter) { $k = $parameter->getAttribute('id'); $parameter->setAttribute('value', $res[$k]); } $doc->saveToFile($xml); } return true; }
/** * Initializes the module. * This method is required by IModule and is invoked by application. * It loads user/role information from the module configuration. * @param mixed module configuration */ public function init($config) { $this->loadUserData($config); if ($this->_userFile !== null) { if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) { $userFile = (include $this->_userFile); $this->loadUserDataFromPhp($userFile); } else { $dom = new TXmlDocument(); $dom->loadFromFile($this->_userFile); $this->loadUserDataFromXml($dom); } } $this->_initialized = true; }
public function loadFromFile($fname) { if (Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) { $fcontent = (include $fname); $this->loadFromPhp($fcontent, dirname($fname)); } else { $dom = new TXmlDocument(); $dom->loadFromFile($fname); $this->loadFromXml($dom, dirname($fname)); } }
protected function insertNewPermissions($lastId) { $data = $this->Session['dataPage']; foreach ($data as $v) { switch ($v['id']) { case "controlPanel": $v['access'] ? $this->insertNewPermission($lastId, 'controlPanel.ControlPanel') : ''; break; case "superUser": $v['access'] ? $this->insertNewPermission($lastId, 'superuser.userList', $v['shortcut']) : ''; $v['access'] ? $this->insertNewPermission($lastId, 'superuser.userAdd') : ''; $v['access'] ? $this->insertNewPermission($lastId, 'superuser.userMod') : ''; break; case "superUserGroup": $v['access'] ? $this->insertNewPermission($lastId, 'superuser.userGroupList', $v['shortcut']) : ''; $v['access'] ? $this->insertNewPermission($lastId, 'superuser.userGroupAdd') : ''; $v['access'] ? $this->insertNewPermission($lastId, 'superuser.userGroupMod') : ''; break; case "configuration": $v['access'] ? $this->insertNewPermission($lastId, 'configuration.config', $v['shortcut']) : ''; break; case "site": $v['access'] ? $this->insertNewPermission($lastId, 'site.Site', $v['shortcut']) : ''; break; case "department": $v['access'] ? $this->insertNewPermission($lastId, 'site.department', $v['shortcut']) : ''; $v['access'] ? $this->insertNewPermission($lastId, 'site.add', $v['shortcut']) : ''; $v['access'] ? $this->insertNewPermission($lastId, 'site.mod', $v['shortcut']) : ''; break; case "openTime": $v['access'] ? $this->insertNewPermission($lastId, 'openTime.openTimeList', $v['shortcut']) : ''; $v['access'] ? $this->insertNewPermission($lastId, 'openTime.add') : ''; $v['access'] ? $this->insertNewPermission($lastId, 'openTime.mod') : ''; $v['access'] ? $this->insertNewPermission($lastId, 'openTime.attribute') : ''; break; case "horuxController": $v['access'] ? $this->insertNewPermission($lastId, 'horuxController.horuxController', $v['shortcut']) : ''; $v['access'] ? $this->insertNewPermission($lastId, 'horuxController.add') : ''; $v['access'] ? $this->insertNewPermission($lastId, 'horuxController.mod') : ''; break; case "hardware": $v['access'] ? $this->insertNewPermission($lastId, 'hardware.HardwareList', $v['shortcut']) : ''; $v['access'] ? $this->insertNewPermission($lastId, 'hardware.HardwareAddList') : ''; $path = './protected/pages/hardware/device/'; $files = scandir($path); foreach ($files as $f) { if ($f != '..' && $f != '.' && $f != '.svn' && is_dir($path . $f)) { $doc = new TXmlDocument(); $doc->loadFromFile($path . $f . '/install.xml'); $permissions = $doc->getElementByTagName('permissions'); $permissions = $permissions->getElements(); foreach ($permissions as $perm) { $v['access'] ? $this->insertNewPermission($lastId, $perm->getValue()) : ''; } } } break; case "alarms": $v['access'] ? $this->insertNewPermission($lastId, 'system.Alarms', $v['shortcut']) : ''; break; case "notification": $v['access'] ? $this->insertNewPermission($lastId, 'system.Notification', $v['shortcut']) : ''; $v['access'] ? $this->insertNewPermission($lastId, 'system.NotificationAdd') : ''; $v['access'] ? $this->insertNewPermission($lastId, 'system.NotificationMod') : ''; break; case "service": $v['access'] ? $this->insertNewPermission($lastId, 'system.Service', $v['shortcut']) : ''; break; case "status": $v['access'] ? $this->insertNewPermission($lastId, 'system.Status', $v['shortcut']) : ''; break; case "user": $v['access'] ? $this->insertNewPermission($lastId, 'user.UserList', $v['shortcut']) : ''; $v['access'] ? $this->insertNewPermission($lastId, 'user.add') : ''; $v['access'] ? $this->insertNewPermission($lastId, 'user.mod') : ''; $v['access'] ? $this->insertNewPermission($lastId, 'user.attribution') : ''; $v['access'] ? $this->insertNewPermission($lastId, 'user.groups') : ''; break; case "userGroup": $v['access'] ? $this->insertNewPermission($lastId, 'userGroup.UserGroupList', $v['shortcut']) : ''; $v['access'] ? $this->insertNewPermission($lastId, 'userGroup.add') : ''; $v['access'] ? $this->insertNewPermission($lastId, 'userGroup.mod') : ''; break; case "userWizard": $v['access'] ? $this->insertNewPermission($lastId, 'user.UserWizzard', $v['shortcut']) : ''; break; case "key": $v['access'] ? $this->insertNewPermission($lastId, 'key.KeyList', $v['shortcut']) : ''; $v['access'] ? $this->insertNewPermission($lastId, 'key.add') : ''; $v['access'] ? $this->insertNewPermission($lastId, 'key.mod') : ''; break; case "accessLevel": $v['access'] ? $this->insertNewPermission($lastId, 'accessLevel.accessLevelList', $v['shortcut']) : ''; $v['access'] ? $this->insertNewPermission($lastId, 'accessLevel.add') : ''; $v['access'] ? $this->insertNewPermission($lastId, 'accessLevel.mod') : ''; break; case "nonWorkingDay": $v['access'] ? $this->insertNewPermission($lastId, 'nonWorkingDay.nonWorkingDay', $v['shortcut']) : ''; $v['access'] ? $this->insertNewPermission($lastId, 'nonWorkingDay.add') : ''; $v['access'] ? $this->insertNewPermission($lastId, 'nonWorkingDay.mod') : ''; break; case "install_uninstall": $v['access'] ? $this->insertNewPermission($lastId, 'installation.extensions', $v['shortcut']) : ''; break; case "devices": $v['access'] ? $this->insertNewPermission($lastId, 'installation.devices', $v['shortcut']) : ''; break; case "components": $v['access'] ? $this->insertNewPermission($lastId, 'installation.components', $v['shortcut']) : ''; $v['access'] ? $this->insertNewPermission($lastId, 'installation.componentconfig') : ''; break; case "template": $v['access'] ? $this->insertNewPermission($lastId, 'installation.template', $v['shortcut']) : ''; break; case "language": $v['access'] ? $this->insertNewPermission($lastId, 'installation.language', $v['shortcut']) : ''; break; case "recycling": $v['access'] ? $this->insertNewPermission($lastId, 'key.recycling', $v['shortcut']) : ''; break; case "globalCheckin": $v['access'] ? $this->insertNewPermission($lastId, 'tool.GlobalCheckin', $v['shortcut']) : ''; break; case "guilog": $v['access'] ? $this->insertNewPermission($lastId, 'tool.GuiLog', $v['shortcut']) : ''; break; case "update": $v['access'] ? $this->insertNewPermission($lastId, 'update.Update', $v['shortcut']) : ''; break; case "systemInfo": $v['access'] ? $this->insertNewPermission($lastId, 'help.SystemInfo', $v['shortcut']) : ''; break; case "about": $v['access'] ? $this->insertNewPermission($lastId, 'help.About', $v['shortcut']) : ''; break; default: /*add child permission*/ $path = './protected/pages/components/' . $v['composantname']; $files = scandir($path); $doc = new TXmlDocument(); $doc->loadFromFile($path . '/install.xml'); $permissions = $doc->getElementByTagName('permissions'); $permissions = $permissions->getElements(); $id = 0; $addParent = null; //! find the parent id of $v['id'] foreach ($permissions as $perm) { if ($perm->getValue() == $v['id']) { $id = $perm->getAttribute('id'); $addParent = $perm->getAttribute('add'); } } //add each permission where the parentid equal the id foreach ($permissions as $perm) { if ($id == $perm->getAttribute('parent')) { $v['access'] ? $this->insertNewPermission($lastId, $perm->getValue()) : ''; } } if ($addParent === null || $addParent == "true") { $v['access'] ? $this->insertNewPermission($lastId, $v['id'], $v['shortcut']) : ''; } break; } } }
protected function onPrint() { parent::onPrint(); $param = $this->Application->getParameters(); $groupId = $this->Application->getUser()->getGroupID(); $nCell = 0; $accessRight = array(); $cellHeaderWidth = 6; $cellHeaderHeight = 40; $this->pdf->AddPage('L'); $this->pdf->SetFont('Arial', '', 11); $this->pdf->Cell(0, 10, utf8_decode(Prado::localize('List of the super users groups')), 0, 0, 'L'); $this->pdf->Ln(10); $this->pdf->setDefaultFont(); //! put a marge $this->pdf->Cell(30); $this->pdf->SetFillColor(124, 124, 124); $this->pdf->SetTextColor(255); $this->pdf->SetDrawColor(255); $this->pdf->SetLineWidth(0.3); $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Control Panel')), 1, 0, 'D', true); $accessRight[] = "controlPanel.ControlPanel"; $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Super User')), 1, 0, 'D', true); $accessRight[] = "superuser.userList"; $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Super User Group')), 1, 0, 'D', true); $accessRight[] = "superuser.userGroupList"; if ($param['appMode'] == 'saas' && $groupId == 1 || $param['appMode'] != 'saas') { $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Configuration')), 1, 0, 'D', true); $accessRight[] = "configuration.config"; } else { $nCell--; } $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Site')), 1, 0, 'D', true); $accessRight[] = "site.Site"; $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Hardware')), 1, 0, 'D', true); $accessRight[] = "hardware.HardwareList"; $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Opent time')), 1, 0, 'D', true); $accessRight[] = "openTime.openTimeList"; $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Alarms')), 1, 0, 'D', true); $accessRight[] = "system.Alarms"; if ($param['appMode'] == 'saas' && $groupId == 1 || $param['appMode'] != 'saas') { $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Horux Service')), 1, 0, 'D', true); $accessRight[] = "system.Service"; } else { $nCell--; } $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Horux Status')), 1, 0, 'D', true); $accessRight[] = "system.Status"; $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('User')), 1, 0, 'D', true); $accessRight[] = "user.UserList"; $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('User Group')), 1, 0, 'D', true); $accessRight[] = "userGroup.UserGroupList"; $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('User Wizard')), 1, 0, 'D', true); $accessRight[] = "user.UserWizzard"; $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Key')), 1, 0, 'D', true); $accessRight[] = "key.KeyList"; $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Access Level')), 1, 0, 'D', true); $accessRight[] = "accessLevel.accessLevelList"; $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Non Working Day')), 1, 0, 'D', true); $accessRight[] = "nonWorkingDay.nonWorkingDay"; $cmd = $this->db->createCommand("SELECT * FROM hr_install WHERE type='component'"); $data = $cmd->query(); $data = $data->readAll(); $this->pdf->SetFillColor(176, 176, 176); foreach ($data as $d) { $nCell++; $doc = new TXmlDocument(); $doc->loadFromFile('./protected/pages/components/' . $d['name'] . '/install.xml'); $name = $doc->getElementByTagName('name'); $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize($name->getValue())), 1, 0, 'D', true); $accessRight[] = "components." . $d['name']; } $this->pdf->SetFillColor(124, 124, 124); if ($param['appMode'] == 'saas' && $groupId == 1 || $param['appMode'] != 'saas') { $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Install/Uninstall')), 1, 0, 'D', true); $accessRight[] = "installation.extensions"; $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Devices Manager')), 1, 0, 'D', true); $accessRight[] = "installation.devices"; $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Component Manager')), 1, 0, 'D', true); $accessRight[] = "installation.components"; $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Template Manager')), 1, 0, 'D', true); $accessRight[] = "installation.template"; } else { $nCell -= 4; } $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Language Manager')), 1, 0, 'D', true); $accessRight[] = "installation.language"; $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Global Checkin')), 1, 0, 'D', true); $accessRight[] = "tool.GlobalCheckin"; $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('Horux Gui log')), 1, 0, 'D', true); $accessRight[] = "tool.GuiLog"; $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('System Info')), 1, 0, 'D', true); $accessRight[] = "help.SystemInfo"; $this->pdf->VCell($cellHeaderWidth, $cellHeaderHeight, utf8_decode(Prado::localize('About')), 1, 1, 'D', true); $accessRight[] = "help.About"; $nCell += 25; $groups = $this->getData(); foreach ($groups as $g) { if ($g['superAdmin'] == 1) { $this->pdf->SetFillColor(255, 76, 76); } else { $this->pdf->SetFillColor(124, 124, 124); } $this->pdf->Cell(30, $cellHeaderWidth, utf8_decode($g['name']), 1, 0, 'L', true); for ($i = 0; $i < $nCell; $i++) { $cmd = $this->db->createCommand("SELECT * FROM hr_gui_permissions WHERE page LIKE '" . $accessRight[$i] . "%' AND value=" . $g['id']); $data = $cmd->query(); $data = $data->readAll(); if ($data || $accessRight[$i] == "controlPanel.ControlPanel" || $accessRight[$i] == "help.About") { $this->pdf->Image("./fpdf/ok.png", $this->pdf->GetX() + $i * 6 + 1.5, $this->pdf->GetY() + 1.5, 3, 3); } else { $this->pdf->Image("./fpdf/ko.png", $this->pdf->GetX() + $i * 6 + 1.5, $this->pdf->GetY() + 1.5, 3, 3); } } $this->pdf->Ln(6); } $this->pdf->Ln(10); $this->pdf->SetTextColor(0); $this->pdf->SetDrawColor(0); $groups = $this->getData(); foreach ($groups as $g) { $this->pdf->Cell(80, $cellHeaderWidth, utf8_decode(Prado::Localize('Super users in "{g}" group', array("g" => $g['name']))), 'B', 1); $cmd = $this->db->createCommand("SELECT su.name AS username, u.name, u.firstname FROM hr_superusers AS su LEFT JOIN hr_user AS u ON u.id=su.user_id WHERE su.group_id=" . $g['id']); $data = $cmd->query(); $users = $data->readAll(); $userList = array(); foreach ($users as $user) { $u = $user['username']; if (strlen($user['name']) > 0 || strlen($user['firstname']) > 0) { $u .= " (" . $user['name'] . " " . $user['firstname'] . ")"; } $userList[] = utf8_decode($u); } $userList = join(', ', $userList); $this->pdf->MultiCell(0, 6, $userList, 0, 1); } $this->pdf->render(); }
/** * Initialize the module from configuration file. * @throws TConfigurationException if {@link getConfigFile ConfigFile} is invalid. */ protected function loadConfigFile() { if (is_file($this->_configFile)) { if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) { $config = (include $this->_configFile); $this->loadUrlMappings($dom); } else { $dom = new TXmlDocument(); $dom->loadFromFile($this->_configFile); $this->loadUrlMappings($dom); } } else { throw new TConfigurationException('urlmapping_configfile_inexistent', $this->_configFile); } }
/** * Initializes the module. * This method is required by IModule and is invoked by application. * It loads user/role information from the module configuration. * @param TXmlElement module configuration */ public function init($config) { $this->loadUserData($config); if ($this->_userFile !== null) { $dom = new TXmlDocument(); $dom->loadFromFile($this->_userFile); $this->loadUserData($dom); } $this->_initialized = true; }