/** * Lists the available application versions. * * @param integer $repId Repository id. * @param integer $applicationId Application id. * @param bool $refresh Set to true if a cache refresh is requested. * @access public * @return array */ public function listAvailableApplicationVersions($repId, $applicationId, $refresh = false) { $result = false; $cachedItem = new \Innomatic\Datatransfer\Cache\CachedItem($this->dataAccess, 'appcentral-client', 'repository_application_versions-' . $this->id . '-' . $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->client->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->log->logEvent(['root' => ''], 'innomatic.appcentralremoteserver.listavailableapplications', 'Not an array from server', \Innomatic\Logging\Logger::ERROR); } } else { $this->log->logEvent(['root' => ''], 'innomatic.appcentralremoteserver.listavailableapplications', 'Error in response from server: ' . $xmlrpcResp->faultString(), \Innomatic\Logging\Logger::ERROR); } } else { $this->log->logEvent(['root' => ''], 'innomatic.appcentralremoteserver.listavailableapplications', 'Invalid response from server', \Innomatic\Logging\Logger::ERROR); } } return $result; }
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; }