public function &search($searchKeys, $userId = '', $globalSearch = false, $trashcan = false, $limit = 0, $offset = 0, $restrictToPermission = InnoworkItem::SEARCH_RESTRICT_NONE) { $result = array(); $goon = true; $to_be_cached = false; if (!is_array($searchKeys) and !strlen($searchKeys) and !$trashcan and !$limit and !$offset and $restrictToPermission == InnoworkItem::SEARCH_RESTRICT_NONE) { $cached_item = new \Innomatic\Datatransfer\Cache\CachedItem($this->mrRootDb, 'innowork-core', 'itemtypesearch-' . $this->mItemType . strtolower(str_replace(' ', '', $this->mSearchOrderBy)), $this->container->getCurrentDomain()->domaindata['id'], $this->container->getCurrentUser()->getUserId()); $cache_content = $cached_item->Retrieve(); if ($cache_content != false) { $goon = false; $to_be_cached = false; $result = unserialize($cache_content); } else { $to_be_cached = true; } } // Check if the search keys to be returned are valid keys // if (is_array($searchKeys)) { while (list($key, ) = each($searchKeys)) { if (!isset($this->mKeys[$key])) { unset($searchKeys[$key]); } } reset($searchKeys); if (!count($searchKeys)) { $goon = false; } } if ($goon) { // Check if we should use the current user id // if (!strlen($userId)) { $userId = $this->container->getCurrentUser()->getUserId(); } $result = array(); // Call the search method // $search_result = $this->doSearch($searchKeys, $userId, $globalSearch, $trashcan, $limit, $offset); if (strlen($this->mParentType) > 0 && strlen($this->mParentIdField) > 0) { $tmp_innoworkcore = InnoworkCore::instance('\\Innowork\\Core\\InnoworkCore', $this->mrRootDb, $this->mrDomainDA); $summaries = $tmp_innoworkcore->getSummaries(); $parentTable = $summaries[$this->mParentType]['table']; } // Check if the user has enough permissions for each row in the result set, // and add the ones with enough permissions // if (is_array($search_result) and count($search_result)) { while (list($id, $val) = each($search_result)) { // Get the item ACL or the item parent ACL if supported if (strlen($this->mParentType) > 0 && strlen($this->mParentIdField) > 0) { $aclItemId = $val[$this->mParentIdField]; $aclItemType = $this->mParentType; $aclItemOwnerId = ''; if (strlen($parentTable)) { $parentOwnerQuery = $this->mrDomainDA->execute("SELECT ownerid FROM {$parentTable} WHERE id={$aclItemId}"); if ($parentOwnerQuery->getNumberRows() > 0) { $aclItemOwnerId = $parentOwnerQuery->getFields('ownerid'); } } $aclNoAcl = false; } else { $aclItemId = $id; $aclItemType = $this->mItemType; $aclItemOwnerId = $val['ownerid']; $aclNoAcl = $this->mNoAcl; } $tmp_acl = new InnoworkAcl($this->mrRootDb, $this->mrDomainDA, $aclItemType, $aclItemId); if ($aclNoAcl == true or $aclItemOwnerId == $this->container->getCurrentUser()->getUserId() or $tmp_acl->checkPermission('', $userId) >= InnoworkAcl::PERMS_SEARCH) { $restrict = false; switch ($restrictToPermission) { case InnoworkItem::SEARCH_RESTRICT_TO_OWNER: if ($aclItemOwnerId != $this->container->getCurrentUser()->getUserId()) { $restrict = true; } break; case InnoworkItem::SEARCH_RESTRICT_TO_RESPONSIBLE: $restrict = true; if ($aclItemOwnerId == $this->container->getCurrentUser()->getUserId() or $tmp_acl->checkPermission('', $userId) == InnoworkAcl::PERMS_RESPONSIBLE) { $restrict = false; } break; case InnoworkItem::SEARCH_RESTRICT_TO_PARTICIPANT: if ($aclItemOwnerId == $this->container->getCurrentUser()->getUserId() or $tmp_acl->checkPermission('', $userId) >= InnoworkAcl::PERMS_ALL) { $restrict = true; } break; case InnoworkItem::SEARCH_RESTRICT_NONE: default: break; } if (!$restrict) { $result[$id] = $val; $result[$id]['_acl']['type'] = $tmp_acl->GetType(); } } } } } if ($to_be_cached) { $cached_item->store(serialize($result)); } return $result; }
public function initTheme() { $result = false; if (strlen($this->mTheme)) { $innomatic = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer'); if ($this->mTheme == 'default') { $this->mTheme = \Innomatic\Wui\Wui::DEFAULT_THEME; } if ($this->mTheme != 'userdefined') { if (file_exists($innomatic->getHome() . 'core/conf/themes/' . $this->mTheme . '_wuitheme.ini')) { $this->mThemeFile = $innomatic->getHome() . 'core/conf/themes/' . $this->mTheme . '_wuitheme.ini'; } else { $this->mTheme = \Innomatic\Wui\Wui::DEFAULT_THEME; $this->mThemeFile = $innomatic->getHome() . 'core/conf/themes/' . \Innomatic\Wui\Wui::DEFAULT_THEME . '_wuitheme.ini'; } $cfg_file = @parse_ini_file($this->mThemeFile); if ($cfg_file !== false) { $this->mIconsSetName = $cfg_file['THEME.ICONSSET']; $this->mColorsSetName = $cfg_file['THEME.COLORSSET']; $this->mStyleName = $cfg_file['THEME.STYLE']; } else { $log = $innomatic->getLogger(); $log->LogEvent('innomatic.wuithemes.wuitheme.inittheme', 'Unable to open theme configuration file ' . $this->mThemeFile, \Innomatic\Logging\Logger::ERROR); } } else { $this->mIconsSetName = $this->mUserSettings['iconsset']; $this->mColorsSetName = $this->mUserSettings['colorsset']; $this->mStyleName = $this->mUserSettings['stylename']; } $this->mIconsSetBase = $innomatic->getExternalBaseUrl() . '/shared/icons/' . $this->mIconsSetName . '/'; $this->mIconsBase = $innomatic->getExternalBaseUrl() . '/shared/icons/'; $this->mIconsSetDir = $innomatic->getHome() . 'shared/icons/' . $this->mIconsSetName . '/'; $this->mStyleBase = $innomatic->getExternalBaseUrl() . '/shared/styles/'; $this->mStyleDir = $innomatic->getHome() . 'shared/styles/' . $this->mStyleName . '/'; $wui_colors = new WuiColorsSet($this->mrRootDb, $this->mColorsSetName); $wui_icons = new WuiIconsSet($this->mrRootDb, $this->mIconsSetName); $wui_style = new WuiStyle($this->mrRootDb, $this->mStyleName); if ($innomatic->getState() != \Innomatic\Core\InnomaticContainer::STATE_SETUP) { $cached_iconsset = new \Innomatic\Datatransfer\Cache\CachedItem($this->mrRootDb, 'innomatic', 'wuiiconsset-' . $this->mIconsSetName); $cached_colorsset = new \Innomatic\Datatransfer\Cache\CachedItem($this->mrRootDb, 'innomatic', 'wuicolorsset-' . $this->mColorsSetName); $cached_style = new \Innomatic\Datatransfer\Cache\CachedItem($this->mrRootDb, 'innomatic', 'wuistyle-' . $this->mStyleName); $this->mIconsSet = unserialize($cached_iconsset->Retrieve()); $this->mColorsSet = unserialize($cached_colorsset->Retrieve()); $this->mStyle = unserialize($cached_style->Retrieve()); } if (!$this->mIconsSet or !$this->mColorsSet or !$this->mStyle) { if (\Innomatic\Wui\Wui::DEFAULT_THEME == $this->mTheme) { $this->mColorsSet = $wui_colors->getColorsSet(); $this->mIconsSet = $wui_icons->getIconsSet(); $this->mStyle = $wui_style->getStyle(); } else { $def_cfg_file = @parse_ini_file($innomatic->getHome() . 'core/conf/themes/' . \Innomatic\Wui\Wui::DEFAULT_THEME . '_wuitheme.ini'); if ($def_cfg_file !== false) { $def_icons_set_name = $def_cfg_file['THEME.ICONSSET']; $def_colors_set_name = $def_cfg_file['THEME.COLORSSET']; $def_style_name = $def_cfg_file['THEME.STYLE']; } else { $log = $innomatic->getLogger(); $log->LogEvent('innomatic.wuithemes.wuitheme.inittheme', 'Unable to open default theme configuration file ' . $innomatic->getHome() . 'core/conf/themes/' . \Innomatic\Wui\Wui::DEFAULT_THEME . '_wuitheme.ini', \Innomatic\Logging\Logger::ERROR); } $wui_def_colors = new WuiColorsSet($this->mrRootDb, $def_colors_set_name); $wui_def_icons = new WuiIconsSet($this->mrRootDb, $def_icons_set_name); $wui_def_style = new WuiStyle($this->mrRootDb, $def_style_name); $this->mColorsSet = $this->DefOpts($wui_def_colors->getColorsSet(), $wui_colors->getColorsSet()); $this->mIconsSet = $this->DefOpts($wui_def_icons->getIconsSet(), $wui_icons->getIconsSet()); $this->mStyle = $this->DefOpts($wui_def_style->getStyle(), $wui_style->getStyle()); } while (list($style_name, $style_item) = each($this->mStyle)) { $this->mStyle[$style_name] = $this->mStyleBase . $style_item['base'] . '/' . $style_item['value']; } if ($innomatic->getState() != \Innomatic\Core\InnomaticContainer::STATE_SETUP) { $cached_iconsset->Store(serialize($this->mIconsSet)); $cached_colorsset->Store(serialize($this->mColorsSet)); $cached_style->Store(serialize($this->mStyle)); } } } return $result; }
public function ListAvailableApplicationVersions($repId, $applicationId, $refresh = false) { $result = false; $cachedItem = new \Innomatic\Datatransfer\Cache\CachedItem($this->mrRootDb, 'appcentral-client', 'repository_application_versions-' . $this->mId . '-' . $repId . '-' . $applicationId); $goon = true; if (!$refresh) { $cacheContent = $cachedItem->Retrieve(); if ($cacheContent != false) { $goon = false; $result = unserialize($cacheContent); } } if ($goon) { $xmlrpcMessage = new \Innomatic\Webservices\Xmlrpc\XmlRpcMsg('appcentral-server.list_available_application_versions', array(new \Innomatic\Webservices\Xmlrpc\XmlRpcVal($repId, 'int'), new \Innomatic\Webservices\Xmlrpc\XmlRpcVal($applicationId, 'int'))); $xmlrpcResp = $this->mXClient->Send($xmlrpcMessage); if ($xmlrpcResp) { if (!$xmlrpcResp->FaultCode()) { $xv = \Innomatic\Webservices\Xmlrpc\php_xmlrpc_decode($xmlrpcResp->Value()); if (is_array($xv)) { $cachedItem->Store(serialize($xv)); $result = $xv; } else { $this->mLogCenter->logEvent(array('root' => ''), 'appcentral-client.appcentral-client.appcentralremoteserver.listavailableapplications', 'Not an array from server', \Innomatic\Logging\Logger::ERROR); } } else { $this->mLogCenter->logEvent(array('root' => ''), 'appcentral-client.appcentral-client.appcentralremoteserver.listavailableapplications', 'Error in response from server: ' . $xmlrpcResp->FaultString(), \Innomatic\Logging\Logger::ERROR); } } else { $this->mLogCenter->logEvent(array('root' => ''), 'appcentral-client.appcentral-client.appcentralremoteserver.listavailableapplications', 'Invalid response from server', \Innomatic\Logging\Logger::ERROR); } } return $result; }