public function __construct(\Innomatic\Dataaccess\DataAccess $rrootDb, $application, $itemId, $domainId = 0, $userId = 0) { $this->cachePath = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getHome() . 'core/temp/cache/'; $domainId = (int) $domainId; $userId = (int) $userId; $this->mrRootDb = $rrootDb; if (!$rrootDb->isConnected()) { $this->mResult = CachedItem::ITEM_NOT_FOUND; } else { if (strlen($itemId) and strlen($application)) { $this->mItemId = $itemId; $this->mApplication = $application; $this->mDomainId = $domainId; $this->mUserId = $userId; $item_query = $this->mrRootDb->execute('SELECT itemfile,validator,domainid,userid FROM cache_items WHERE application=' . $this->mrRootDb->formatText($this->mApplication) . ' AND itemid=' . $this->mrRootDb->formatText($this->mItemId) . ($domainId ? ' AND domainid=' . $domainId : '') . ($userId ? ' AND userid=' . $userId : '')); if ($item_query->getNumberRows()) { $this->mValidator = $item_query->getFields('validator'); $this->mItemFile = $this->cachePath . $item_query->getFields('itemfile'); $this->mDomainId = $item_query->getFields('domainid'); $this->mUserId = $item_query->getFields('userid'); $this->mResult = CachedItem::ITEM_FOUND; } else { $this->mResult = CachedItem::ITEM_NOT_FOUND; } } } }
/** * Tells if a page with the given id exists. * * @param integer $pageId * @return boolean */ public function getPageExists($pageId) { // Page 0 is the root page and always exists. if ($pageId == 0) { return true; } $query = $this->dataAccess->execute('SELECT 1 ' . 'FROM innomedia_pages_tree ' . 'WHERE page_id=' . $this->dataAccess->formatInteger($pageId)); return $query->getNumberRows() > 0 ? true : false; }
public function checkIfOptionEnabled($option, $domainId) { $result = true; $subCheck = $this->rootDA->execute('SELECT optionname FROM applications_options_disabled ' . 'WHERE applicationid=' . (int) $this->id . ' AND domainid=' . (int) $domainId . ' AND optionname=' . $this->rootDA->formatText($option)); if ($subCheck->getNumberRows()) { $result = false; } $subCheck->free(); return $result; }
public function getPageInstanceBlocks() { if (!$this->isValid()) { return false; } $pagesParamsQuery = $this->domainDa->execute("SELECT blocks\n FROM innomedia_pages\n WHERE page=" . $this->domainDa->formatText($this->module . '/' . $this->page) . " AND id={$this->id}"); if ($pagesParamsQuery->getNumberRows() > 0) { return json_decode($pagesParamsQuery->getFields('blocks'), true); } return array(); }
/** * Clears the current item cache. * * @access public * @return boolean */ public function cleanCache() { // Extract all the cache objects for the current item id $cache_query = $this->mrRootDb->execute('SELECT itemid' . ' FROM cache_items' . ' WHERE application=' . $this->mrRootDb->formatText('innowork-core') . ' AND itemid LIKE ' . $this->mrRootDb->formatText('itemtypesearch-' . $this->mItemType . '%')); // Delete the cached objects for the current item id while (!$cache_query->eof) { $cached_item = new \Innomatic\Datatransfer\Cache\CachedItem($this->mrRootDb, 'innowork-core', $cache_query->getFields('itemid')); $cached_item->destroy(); $cache_query->moveNext(); } $cache_query->free(); return true; }
/** * Removes the current AppCentral server from the servers list. * * @access public * @return void */ public function remove() { $result = false; if ($this->id) { if ($this->dataAccess->execute('DELETE FROM applications_repositories ' . 'WHERE id=' . $this->id)) { // Destroy the cache for this repository. $cachedItem = new \Innomatic\Datatransfer\Cache\CachedItem($this->dataAccess, 'appcentral-client', 'repositories-' . $this->id); $cachedItem->destroy(); $this->id = 0; $result = true; } } return $result; }
/** * Removes a previously assigned role. * * @param integer|string $role Role identifier number or string, * it gets automatically decoded to the identifier number. * @access public * @return boolean */ public function unassignRole($role) { if (!is_int($this->id)) { return false; } // If the role has been given by name, get its id if (!is_int($role)) { $role = Role::getIdFromName($role); if ($role === false) { return false; } } return $this->dataAccess->execute("DELETE\n FROM domain_roles_permissions\n WHERE roleid={$role} and permissionid={$this->id}"); }
/** * Updates the account information. */ public function update($name, $host = 'localhost', $port = '80', $path = '', $username = '', $password = '', $proxy = '', $proxyPort = '') { $result = false; $hook = new \Innomatic\Process\Hook($this->dataAccess, 'innomatic', 'webservicesaccount.update'); if ($hook->callHooks('calltime', $this, array('name' => $name, 'host' => $host, 'port' => $port, 'path' => $path, 'username' => $username, 'password' => $password)) == \Innomatic\Process\Hook::RESULT_OK) { if ($this->mId) { if (strlen($name)) { $result = $this->dataAccess->execute('UPDATE webservices_accounts ' . 'SET ' . 'name=' . $this->dataAccess->formatText($name) . ',' . 'host=' . $this->dataAccess->formatText($host) . ',' . 'path=' . $this->dataAccess->formatText($path) . ',' . 'port=' . $this->dataAccess->formatText($port) . ',' . 'username='******',' . 'password='******',' . 'proxy=' . $this->dataAccess->formatText($proxy) . ',' . 'proxyport=' . $this->dataAccess->formatText($proxyPort) . ' ' . 'WHERE id=' . (int) $this->mId); if ($result) { if ($hook->callHooks('accountudpated', $this, array('name' => $name, 'host' => $host, 'port' => $port, 'path' => $path, 'username' => $username, 'password' => $password, 'id' => $this->mId)) != \Innomatic\Process\Hook::RESULT_OK) { $result = false; } } else { $result = WebServicesAccount::UPDATE_UNABLE_TO_UPDATE_ACCOUNT; } } else { $result = WebServicesAccount::UPDATE_EMPTY_ACCOUNT_NAME; } } else { $result = WebServicesAccount::REMOVE_EMPTY_ACCOUNT_ID; } } return $result; }
public function __construct($params) { $this->support['affrows'] = true; $this->support['transactions'] = false; return parent::__construct($params); }
/** * Updates the component. * * @param integer $updatemode Update mode (Application::UPDATE_MODE_* constants) * @param array $params Parameters in the component definition * @param string $domainprescript Full path of an optional PHP script to be executed * before proceeding with the component update * @param string $domainpostscript Full path of an optional PHP script to be executed * after proceeding with the component update * @access public * @return void */ public function update($updatemode, $params, $domainprescript = '', $domainpostscript = '') { $result = false; if ($this->getIsDomain() or isset($params['override']) and $params['override'] == self::OVERRIDE_DOMAIN) { $domainsquery = $this->rootda->execute('SELECT * FROM domains'); $modquery = $this->rootda->execute('SELECT id FROM applications WHERE appid=' . $this->rootda->formatText($this->appname)); $appid = $modquery->getFields('id'); } switch ($updatemode) { case Application::UPDATE_MODE_ADD: if ($this->install($params)) { $result = true; if ($this->getIsDomain() or isset($params['override']) and $params['override'] == self::OVERRIDE_DOMAIN) { if ($domainsquery->getNumberRows() > 0) { while (!$domainsquery->eof) { $domaindata = $domainsquery->getFields(); // Check if the application is enabled for the current iteration domain $actquery = $this->rootda->execute('SELECT * FROM applications_enabled WHERE domainid=' . (int) $domaindata['id'] . ' AND applicationid=' . (int) $appid); if ($actquery->getNumberRows()) { // Enable the component for the current iteration domain if (!$this->enable($domainsquery->getFields('id'), $params)) { $result = false; } } $actquery->free(); $domainsquery->moveNext(); } } } } break; case Application::UPDATE_MODE_REMOVE: // Disables the component for each domain, before uninstalling it if ($this->getIsDomain() or isset($params['override']) and $params['override'] == self::OVERRIDE_DOMAIN) { if ($domainsquery->getNumberRows() > 0) { while (!$domainsquery->eof) { $domaindata = $domainsquery->getFields(); $actquery = $this->rootda->execute('SELECT * FROM applications_enabled WHERE domainid=' . (int) $domaindata['id'] . ' AND applicationid=' . (int) $appid); if ($actquery->getNumberRows()) { // Disable the component for the current iteration domain if (!$this->disable($domainsquery->getFields('id'), $params)) { $result = false; } } $actquery->free(); $domainsquery->moveNext(); } } } if ($this->uninstall($params)) { $result = true; } break; case Application::UPDATE_MODE_CHANGE: if ($this->doUpdateAction($params)) { $result = true; if ($this->getIsDomain() or isset($params['override']) and $params['override'] == self::OVERRIDE_DOMAIN) { if ($domainsquery->getNumberRows() > 0) { while (!$domainsquery->eof) { $domaindata = $domainsquery->getFields(); $actquery = $this->rootda->execute('SELECT * FROM applications_enabled WHERE domainid=' . (int) $domaindata['id'] . ' AND applicationid=' . (int) $appid); if ($actquery->getNumberRows()) { $this->container->startDomain($domaindata['domainid']); $this->domainda = $this->container->getCurrentDomain()->getDataAccess(); if (strlen($domainprescript) and file_exists($domainprescript)) { include $domainprescript; } if (!$this->doUpdateDomainAction($domainsquery->getFields('id'), $params)) { $result = false; } if (strlen($domainpostscript) and file_exists($domainpostscript)) { include $domainpostscript; } $this->container->stopDomain(); } $actquery->free(); $domainsquery->moveNext(); } } } } break; default: $log = $this->container->getLogger(); $log->logEvent('innomatic.applications.applicationcomponent.update', 'Invalid update mode', \Innomatic\Logging\Logger::ERROR); break; } if ($this->getIsDomain() or isset($params['override']) and $params['override'] == self::OVERRIDE_DOMAIN) { $domainsquery->free(); $modquery->free(); } return $result; }
public function close() { $this->dataAccess->close(); }