/** * initialize all config for vi system * @return unknown_type */ public function __construct() { //MD5(?) AND active = "TRUE" $config = Vi_Registry::getConfig(); $db = Vi_Registry::getDB(); parent::__construct($db, $config['database']['params']['prefix'] . "user", 'username', 'password', 'MD5(?) AND enabled = 1'); }
/** * constructor init all data */ public function __construct($username) { $this->_auth = Vi_Auth::getInstance(); $dbPrefix = Vi_Registry::getDBPrefix(); $db = Vi_Registry::getDB(); $sqlSelectPermission = "\r\n\t\t\t\tSELECT p.name as pkey, r.enabled as penabled, r.expand_table_id, p.module as module_name FROM\r\n\t\t\t\t\t(SELECT * FROM {$dbPrefix}user WHERE username = {$db->quote($username)}) u,\r\n\t\t\t\t\t{$dbPrefix}group_permission r,\r\n\t\t\t\t\t{$dbPrefix}permission p\r\n\t\t\t\tWHERE r.permission_id = p.permission_id AND u.group_id = r.group_id;"; $db = Vi_Registry::getDB(); $permissions = $db->fetchAll($sqlSelectPermission); $results = array(); foreach ($permissions as $per) { if (null == $per['expand_table_id']) { $results[$per['module_name']][$per['pkey']] = $per['penabled'] == '1' ? true : false; } else { $results[$per['module_name']][$per['pkey']][$per['expand_table_id']] = $per['penabled'] == '1' ? true : false; } } $this->_permissions = $results; }
public function __construct($params) { $this->_db = Vi_Registry::getDB(); $this->_name = $params['name']; $this->_params = $params; /* get and set stickers in holder */ if ($this->_name == "allstickers") { $this->_stickers = $this->getAllStickerRoot(); } elseif (!isset($params['include'])) { $this->_stickers = $this->getStickers($this->_name); } else { $stickerArr = explode(',', $params['include']); foreach ($stickerArr as $st) { $st = trim($st); if ($st != "") { $this->_stickers[] = $st; } } } // die(print_r($this->_stickers)); /* get and set content pre and post for holder and every sticker */ if (isset($params['preSticker'])) { $this->preStickerContent = $params['preSticker']; } if (isset($params['postSticker'])) { $this->postStickerContent = $params['postSticker']; } if (isset($params['preHolder'])) { $this->preHolderContent = $params['preHolder']; } if (isset($params['postHolder'])) { $this->postHolderContent = $params['postHolder']; } foreach ($this->_stickers as $sticker) { /* Get data from sticker */ $stickerName = $sticker; if (is_array($sticker)) { $stickerName = $sticker['name']; } $className = $stickerName . "Sticker"; $fileName = $className . ".php"; $filePath = "stickers/{$stickerName}/{$fileName}"; if (is_file($filePath)) { require_once $filePath; } else { throw new Exception("Sticker <b>{$stickerName}</b> " . Vi_Language::translate('was not found')); } if (!class_exists($className)) { throw new Exception("Class <b>" . $className . "</b>" . Vi_Language::translate('was not found')); } $stParams = array('name' => $stickerName); if (is_array($sticker)) { $stParams = $sticker; } $st = new $className($stParams); if (is_array($sticker)) { $st->setParams($sticker['params']); } if ($st->isAutoRender()) { $st->render(); } $data = $st->getData(); if ($data != "") { $preSticker = ""; $headerSticker = ""; $postSticker = ""; $editLayoutMode = false; if (Vi_Registry::isRegistered('EDIT_LAYOUT_MODE')) { $editLayoutMode = Vi_Registry::get('EDIT_LAYOUT_MODE'); } // $parentLevel = 2; // if ($this->_name == "allstickers") { // $parentLevel = 3; // } if ($editLayoutMode) { $headerSticker .= '<div class="sticker-header">({name}) [<a href="javascript:void(0);" onclick="layout.removeSticker(this,2,\'{name}\');">X</a>]</div>'; } if (!isset($this->_params['include']) && $this->_name != 'allstickers' && $editLayoutMode) { $preSticker = str_replace('{name}', $sticker['sticker_id'], $this->preStickerContent . $headerSticker); $postSticker = str_replace('{name}', $sticker['sticker_id'], $this->postStickerContent); } else { $preSticker = str_replace('{name}', $stickerName, $this->preStickerContent . $headerSticker); $postSticker = str_replace('{name}', $stickerName, $this->postStickerContent); } $this->_data .= $preSticker . $data . $postSticker; } /* End get data from sticker */ } }