public function __construct(\Innomatic\Dataaccess\DataAccess $rootDA, \Innomatic\Dataaccess\DataAccess $domainDA, $summaries = '')
 {
     $this->container = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
     $this->log = $this->container->getLogger();
     $this->rootDA = $rootDA;
     $this->domainDA = $domainDA;
     if (is_array($summaries)) {
         $this->summary = $summaries;
     } else {
         $tmpInnoworkcore = InnoworkCore::instance('\\Innowork\\Core\\InnoworkCore', $this->rootDA, $this->domainDA);
         $this->summary = $tmpInnoworkcore->GetSummaries();
     }
 }
예제 #2
0
 public function render()
 {
     if (!$this->mBuilt) {
         $this->Build();
     }
     if ($this->mBuilt) {
         \Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getProcessor()->getResponse()->addHeader('P3P', 'CP="CUR ADM OUR NOR STA NID"');
         echo $this->mLayout;
         return true;
     } else {
         $log = $this->container->getLogger();
         $log->logEvent('innomatic.wui.wui.render', 'Unable to render wui', \Innomatic\Logging\Logger::ERROR);
         throw new \Innomatic\Wui\WuiException(\Innomatic\Wui\WuiException::UNABLE_TO_RENDER);
     }
     return false;
 }
 /**
  * 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;
 }
예제 #4
0
 /**
  * Item constructor.
  *
  * @param \Innomatic\Dataaccess\DataAccess $rrootDb Innomatic root data
  * access.
  * @param \Innomatic\Dataaccess\DataAccess $rdomainDA Domain data access.
  * @param string $itemType Item type name
  * @param int $itemId Item identifier number
  * @access public
  * @return void
  */
 public function __construct(\Innomatic\Dataaccess\DataAccess $rrootDb, \Innomatic\Dataaccess\DataAccess $rdomainDA, $itemType, $itemId = 0)
 {
     $this->container = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
     require_once 'innowork/core/InnoworkAcl.php';
     // Item identification (type + id)
     $this->mItemType = $itemType;
     $this->mItemId = $itemId;
     // DataAccess
     $this->mrRootDb = $rrootDb;
     $this->mrDomainDA = $rdomainDA;
     // Item keys
     $this->mKeys['id'] = 'integer';
     // Trash support
     if ($this->mNoTrash == false) {
         $this->mKeys['trashed'] = 'boolean';
     }
     // Redundant to the default value but safe
     if (!strlen($this->mSearchOrderBy)) {
         $this->mSearchOrderBy = 'id';
     }
     // Search result keys
     $this->mSearchResultKeys[] = 'id';
     $this->mSearchResultKeys[] = 'ownerid';
     if ($this->mNoTrash == false) {
         // If the item type supports trash action, add trashed field to the
         // search result keys
         $this->mSearchResultKeys[] = 'trashed';
     }
     // If this item doesn't support ACLs and there is no defined default
     // creation ACL, set the item as public.
     if ($this->mNoAcl and !isset($this->_mCreationAcl)) {
         $this->_mCreationAcl = InnoworkAcl::TYPE_PUBLIC;
     }
     // Check if the item id is valid
     if ($this->mItemId) {
         // Extract parent id field, if supported
         $parentField = '';
         if (strlen($this->mParentType) > 0 && strlen($this->mParentIdField) > 0) {
             $parentField = ", {$this->mParentIdField} ";
         }
         $check_query = $this->mrDomainDA->execute("SELECT ownerid {$parentField} FROM " . $this->mTable . ' WHERE id=' . $this->mItemId);
         if ($check_query->getNumberRows()) {
             // Get owner id
             //
             $this->mOwnerId = $check_query->getFields('ownerid');
             // Extract parent id, if supported
             if (strlen($this->mParentType) > 0 && strlen($this->mParentIdField) > 0) {
                 $this->mParentId = $check_query->getFields($this->mParentIdField);
             }
         } else {
             $log = $this->container->getLogger();
             $log->logEvent('innoworkcore.innoworkcore.innoworkitem.innoworkitem', 'Invalid item id ' . $this->mItemId . ' from ' . $this->mItemType . ' item type handler', \Innomatic\Logging\Logger::WARNING);
             $this->mItemId = 0;
         }
         $check_query->Free();
     }
     // Item ACL
     if (strlen($this->mParentType) and $this->mParentId > 0) {
         // Gets the ACL from the parent object
         $core = InnoworkCore::instance('\\Innowork\\Core\\InnoworkCore', $this->mrRootDb, $this->mrDomainDA);
         $summaries = $core->getSummaries();
         unset($core);
         $class_name = $summaries[$this->mParentType]['classname'];
         if (class_exists($class_name)) {
             $tmp_class = new $class_name($this->mrRootDb, $this->mrDomainDA, $this->mParentId);
             $this->mAcl =& $tmp_class->mAcl;
         }
     } else {
         // Gets its own ACL
         $this->mAcl = new InnoworkAcl($this->mrRootDb, $this->mrDomainDA, $this->mItemType, $this->mItemId, $this->mOwnerId);
     }
     // Generic fields
     $this->mGenericFields = array('projectid' => '', 'customerid' => '', 'title' => '', 'content' => '', 'binarycontent' => '', 'date' => '', 'spenttime' => '', 'cost' => '');
     // Item folder in filesystem
     if ($itemId != 0) {
         $this->mFsBasePath = $this->container->getCurrentDomain()->getHome() . 'files/' . $this->getItemTypePlural() . '/' . $this->mItemId . '/';
     }
 }