示例#1
0
 public function doUpdateAction($params)
 {
     $result = false;
     if (strlen($params['name'])) {
         $xm = new \Innomatic\Process\Hook($this->rootda, $params['functionapplication'], $params['function']);
         if ($xm->update($params['event'], $this->appname, $params['hookhandler'], $params['hookmethod'])) {
             $result = true;
         } else {
             $this->mLog->logEvent('innomatic.hookcomponent.hookcomponent.doupdateaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Unable to update hook', \Innomatic\Logging\Logger::ERROR);
         }
     } else {
         $this->mLog->logEvent('innomatic.hookcomponent.hookcomponent.doupdateaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Empty hook name', \Innomatic\Logging\Logger::ERROR);
     }
     return $result;
 }
 public function doUninstallAction($params)
 {
     $result = false;
     if (strlen($params['name'])) {
         if (!isset($params['function'])) {
             $params['function'] = '';
         }
         $xm = new \Innomatic\Process\Hook($this->rootda, $this->appname, $params['function']);
         if ($xm->RemoveEvent($params['event'])) {
             $result = true;
         } else {
             $this->mLog->logEvent('innomatic.hookcomponent.hookcomponent.douninstallaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Unable to remove hookevent', \Innomatic\Logging\Logger::ERROR);
         }
     } else {
         $this->mLog->logEvent('innomatic.hookcomponent.hookcomponent.douninstallaction', 'In application ' . $this->appname . ', component ' . $params['name'] . ': Empty hook nameevent', \Innomatic\Logging\Logger::ERROR);
     }
     return $result;
 }
 /**
  * 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 shutdown($exit = true)
 {
     if ($this->state != \Innomatic\Core\InnomaticContainer::STATE_SETUP) {
         if (is_object($this->rootDb)) {
             $hook = new \Innomatic\Process\Hook($this->rootDb, 'innomatic', 'instance');
             $null = '';
             switch ($hook->callHooks('shutdown', $null, '')) {
                 case \Innomatic\Process\Hook::RESULT_ABORT:
                     $this->abort('Shutdown aborted');
                     break;
             }
         }
     }
     switch ($this->state) {
         case \Innomatic\Core\InnomaticContainer::STATE_DEBUG:
             if (is_object($this->loadTimer) and RootContainer::instance('\\Innomatic\\Core\\RootContainer')->isClean() == true) {
                 $this->loadTimer->Mark('end');
                 $log = $this->getLogger();
                 $log->logEvent('innomatic', 'Profiler total time: ' . $this->loadTimer->getTotalTime(), \Innomatic\Logging\Logger::DEBUG);
                 $fh = @fopen($this->home . 'core/temp/pids/' . $this->pid, 'w');
                 if ($fh) {
                     $dump = \Innomatic\Debug\InnomaticDump::instance('\\Innomatic\\Debug\\InnomaticDump');
                     $dump->snapshot();
                     @fwrite($fh, serialize($dump));
                     @fclose($fh);
                 }
             }
             break;
     }
     if (!RootContainer::instance('\\Innomatic\\Core\\RootContainer')->isClean()) {
         if (is_object($this->loadTimer)) {
             $this->loadTimer->Mark('end');
             $log = $this->getLogger();
             $log->logEvent('innomatic', 'Profiler total time: ' . $this->loadTimer->getTotalTime(), \Innomatic\Logging\Logger::DEBUG);
         }
         $fh = @fopen($this->home . 'core/temp/pids/' . $this->pid . '_coredump', 'w');
         if ($fh) {
             $dump = \Innomatic\Debug\InnomaticDump::instance('\\Innomatic\\Debug\\InnomaticDump');
             $dump->snapshot();
             @fwrite($fh, serialize($dump));
             @fclose($fh);
         }
     }
     if (!RootContainer::instance('\\Innomatic\\Core\\RootContainer')->isClean() or $this->state != \Innomatic\Core\InnomaticContainer::STATE_DEBUG and file_exists($this->home . 'core/temp/pids/' . $this->pid)) {
         @unlink($this->home . 'core/temp/pids/' . $this->pid);
     }
     if ($exit) {
         exit;
     }
 }
示例#5
0
 public function disable($domainid)
 {
     $result = false;
     $hook = new \Innomatic\Process\Hook($this->rootda, 'innomatic', 'application.disable');
     if ($hook->callHooks('calltime', $this, array('domainserial' => $domainid, 'modserial' => $this->serial)) == \Innomatic\Process\Hook::RESULT_OK) {
         if ($this->serial) {
             // Checks if the application exists in applications table
             //
             $modquery = $this->rootda->execute('SELECT * FROM applications WHERE id=' . (int) $this->serial);
             if ($modquery->getNumberRows() == 1) {
                 $appdata = $modquery->getFields();
                 if ($appdata['onlyextension'] != $this->rootda->fmttrue) {
                     // Checks if the structure file still exists
                     //
                     if (file_exists($this->container->getHome() . 'core/applications/' . $appdata['appid'] . '/application.xml')) {
                         $this->appname = $appdata['appid'];
                         $domainquery = $this->rootda->execute('SELECT * FROM domains WHERE id=' . $this->rootda->formatText((int) $domainid));
                         $domaindata = $domainquery->getFields();
                         if ($this->container->getEdition() == \Innomatic\Core\InnomaticContainer::EDITION_MULTITENANT) {
                             $args['dbtype'] = $domaindata['dataaccesstype'];
                             $args['dbname'] = $domaindata['domaindaname'];
                             $args['dbhost'] = $domaindata['dataaccesshost'];
                             $args['dbport'] = $domaindata['dataaccessport'];
                             $args['dbuser'] = $domaindata['dataaccessuser'];
                             $args['dbpass'] = $domaindata['dataaccesspassword'];
                             $args['dblog'] = $this->container->getHome() . 'core/domains/' . $domaindata['domainid'] . '/log/dataaccess.log';
                             $dasnString = $args['dbtype'] . '://' . $args['dbuser'] . ':' . $args['dbpass'] . '@' . $args['dbhost'] . ':' . $args['dbport'] . '/' . $args['dbname'] . '?' . 'logfile=' . $args['dblog'];
                             $this->domainda = \Innomatic\Dataaccess\DataAccessFactory::getDataAccess(new \Innomatic\Dataaccess\DataAccessSourceName($dasnString));
                             $this->domainda->Connect();
                         } else {
                             $this->domainda = $this->rootda;
                         }
                         // Dependencies check
                         //
                         $this->unmetdeps = array();
                         $this->unmetsuggs = array();
                         $appdeps = new ApplicationDependencies();
                         $pendingdeps = $appdeps->checkDomainDependingApplications($this->appname, $domaindata['domainid'], false);
                         $modenabled = $appdeps->isEnabled($this->appname, $domaindata['domainid']);
                         // If dependencies are ok, go on
                         //
                         if ($pendingdeps == false and $modenabled == true) {
                             $result = $this->HandleStructure($this->container->getHome() . 'core/applications/' . $appdata['appid'] . '/application.xml', Application::INSTALL_MODE_DISABLE, $this->container->getHome() . 'core/applications/' . $appdata['appid'] . '/', $domainid);
                             $modquery = $this->rootda->execute('SELECT id FROM applications WHERE appid=' . $this->rootda->formatText($this->appname));
                             $this->rootda->execute('DELETE FROM applications_enabled WHERE applicationid=' . (int) $this->serial . ' AND domainid=' . $this->rootda->formatText($domainid));
                             $this->rootda->execute('DELETE FROM applications_options_disabled WHERE applicationid=' . (int) $this->serial . ' AND domainid=' . (int) $domainid);
                             if ($this->container->getConfig()->Value('SecurityAlertOnApplicationDomainOperation') == '1') {
                                 $innomaticSecurity = new \Innomatic\Security\SecurityManager();
                                 $innomaticSecurity->sendAlert('Application ' . $appdata['appid'] . ' has been disabled from domain ' . $domaindata['domainid']);
                                 unset($innomaticSecurity);
                             }
                             if ($hook->callHooks('applicationdisabled', $this, array('domainserial' => $domainid, 'modserial' => $this->serial)) != \Innomatic\Process\Hook::RESULT_OK) {
                                 $result = false;
                             }
                         } elseif ($modenabled == false) {
                         } else {
                             $this->unmetdeps = $pendingdeps;
                         }
                         //if ( $result == true ) $this->mLog->logEvent(
                         //    'Innomatic',
                         //    'Uninstalled application '.$this->appname,
                         //    \Innomatic\Logging\Logger::NOTICE
                         //);
                         $domainquery->free();
                     } else {
                         $log = $this->container->getLogger();
                         $log->logEvent('innomatic.applications.applications.disable', 'Structure file ' . $this->container->getHome() . 'core/applications/' . $appdata['appid'] . '/application.xml' . ' for application ' . $appdata['appid'] . ' was not found', \Innomatic\Logging\Logger::ERROR);
                     }
                 } else {
                     $log = $this->container->getLogger();
                     $log->logEvent('innomatic.applications.applications.disable', 'Tried to disable application ' . $appdata['appid'] . ', but it is an extension only application', \Innomatic\Logging\Logger::ERROR);
                 }
             } else {
                 $log = $this->container->getLogger();
                 $log->logEvent('innomatic.applications.applications.disable', 'A application with serial ' . $this->serial . ' was not found in applications table', \Innomatic\Logging\Logger::ERROR);
             }
             $modquery->free();
         } else {
             $log = $this->container->getLogger();
             $log->logEvent('innomatic.applications.applications.disable', 'Empty application serial', \Innomatic\Logging\Logger::ERROR);
         }
     }
     return $result;
 }
示例#6
0
 public function disableApplication($appid)
 {
     $result = false;
     $hook = new \Innomatic\Process\Hook($this->rootda, 'innomatic', 'domain.application.disable');
     if ($hook->callHooks('calltime', $this, array('domainserial' => $this->domainserial, 'appid' => $appid)) == \Innomatic\Process\Hook::RESULT_OK) {
         if (!empty($this->dataAccess) and !empty($appid) and $this->isApplicationEnabled($appid)) {
             $modquery = $this->rootda->execute('SELECT appid FROM applications WHERE id=' . (int) $appid);
             $tmpmod = new \Innomatic\Application\Application($this->rootda, $appid);
             $this->container->setCurrentDomain($this);
             if ($tmpmod->Disable($this->domainserial)) {
                 if ($hook->CallHooks('applicationdisabled', $this, array('domainserial' => $this->domainserial, 'appid' => $appid)) == \Innomatic\Process\Hook::RESULT_OK) {
                     $result = true;
                 }
                 $log = $this->container->getLogger();
                 $log->logEvent($this->domainid, 'Disabled application ' . $modquery->getFields('appid'), \Innomatic\Logging\Logger::NOTICE);
                 $this->domainlog->logEvent($this->domainid, 'Disabled application ' . $modquery->getFields('appid'), \Innomatic\Logging\Logger::NOTICE);
             }
             $this->unmetdeps = $tmpmod->getLastActionUnmetDeps();
         }
     }
     return $result;
 }
 public function Rename($profileName)
 {
     $result = false;
     $hook = new \Innomatic\Process\Hook($this->mRootDb, 'innomatic', 'webservicesprofile.rename');
     if ($hook->callHooks('calltime', $this, array('name' => $profileName)) == \Innomatic\Process\Hook::RESULT_OK) {
         if ($this->mRootDb) {
             if ($this->mProfileId) {
                 if (strlen($profileName)) {
                     // Removes the profile
                     //
                     $result = $this->mRootDb->execute('UPDATE webservices_profiles ' . 'SET profilename=' . $this->mRootDb->formatText($profileName) . ' ' . 'WHERE id=' . (int) $this->mProfileId);
                     $hook->callHooks('profilerenamed', $this, array('name' => $profileName));
                 } else {
                     $this->mLog->logEvent('innomatic.webservicesprofile.rename', 'Empty new profile name', \Innomatic\Logging\Logger::ERROR);
                 }
             } else {
                 $this->mLog->logEvent('innomatic.webservicesprofile.rename', 'Object not assigned to a profile', \Innomatic\Logging\Logger::ERROR);
             }
         } else {
             $this->mLog->logEvent('innomatic.webservicesprofile.rename', 'Invalid Innomatic database handler', \Innomatic\Logging\Logger::ERROR);
         }
     }
     return $result;
 }
示例#8
0
 public function restore($userId = '')
 {
     $result = false;
     $hook = new \Innomatic\Process\Hook($this->mrRootDb, 'innowork-core', 'innowork.item.restore');
     // Call startcall hooks
     if ($this->mItemId and $this->mNoTrash == false && $hook->callHooks('startcall', $this, array('userid' => $userId)) != \Innomatic\Process\Hook::RESULT_OK) {
         return false;
     }
     // If no user id has been give, user the current user one
     if (!strlen($userId)) {
         $userId = $this->container->getCurrentUser()->getUserId();
     }
     // If the user has enough ACL permissions, restore the item
     if ($this->mNoAcl == true or $userId == $this->mOwnerId or $this->mAcl->checkPermission('', $userId) >= InnoworkAcl::PERMS_DELETE) {
         $result = $this->doRestore($userId);
         if ($result) {
             // Set the item as not trashed
             $result = $this->mrDomainDA->execute('UPDATE ' . $this->mTable . ' SET trashed=' . $this->mrDomainDA->formatText($this->mrDomainDA->fmtfalse) . ' WHERE id=' . $this->mItemId);
             // Clean item cache
             $this->cleanCache();
         }
     } else {
         $this->mLastError = InnoworkAcl::ERROR_NOT_ENOUGH_PERMS;
     }
     // Call endcall hooks
     if ($hook->callHooks('endcall', $this, array('userid' => $userId)) != \Innomatic\Process\Hook::RESULT_OK) {
         return false;
     }
     return $result;
 }
示例#9
0
 public function remove()
 {
     $hook = new \Innomatic\Process\Hook($this->rootDA, 'innomatic', 'domain.user.remove');
     if ($hook->callHooks('calltime', $this, array('domainserial' => $this->domainserial, 'userid' => $this->userid)) == \Innomatic\Process\Hook::RESULT_OK) {
         if ($this->userid != 0) {
             $result = $this->domainDA->execute('DELETE FROM domain_users WHERE id=' . (int) $this->userid);
             // Remove user dir
             $domain_query = $this->rootDA->execute('SELECT domainid FROM domains WHERE id=' . (int) $this->domainserial);
             if ($this->container->getHome() . 'core/domains/' . $domain_query->getFields('domainid') . '/users/' . $this->username != $this->container->getHome() . 'core/domains/' . $domain_query->getFields('domainid') . '/users/') {
                 \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($this->container->getHome() . 'core/domains/' . $domain_query->getFields('domainid') . '/users/' . $this->username, 0755);
             }
             // Remove cached items
             $cache_gc = new \Innomatic\Datatransfer\Cache\CacheGarbageCollector();
             $cache_gc->removeUserItems((int) $this->userid);
             //$this->htp->remuser( $this->username );
             if ($hook->callHooks('userremoved', $this, array('domainserial' => $this->domainserial, 'userid' => $this->userid)) != \Innomatic\Process\Hook::RESULT_OK) {
                 $result = false;
             }
             $this->userid = 0;
             $this->userExists = false;
         }
     }
     return $result;
 }