/**
  * Creates a new account.
  */
 public function create($name, $host = 'localhost', $port = '80', $path = '', $username = '', $password = '', $proxy = '', $proxyPort = '')
 {
     $result = false;
     $hook = new \Innomatic\Process\Hook($this->dataAccess, 'innomatic', 'webservicesaccount.create');
     if ($hook->callHooks('calltime', $this, array('name' => $name, 'host' => $host, 'port' => $port, 'path' => $path, 'username' => $username, 'password' => $password)) == \Innomatic\Process\Hook::RESULT_OK) {
         if (strlen($name)) {
             $acc_seq = $this->dataAccess->getNextSequenceValue('webservices_accounts_id_seq');
             $result = $this->dataAccess->execute('INSERT INTO webservices_accounts ' . 'VALUES (' . $acc_seq . ',' . $this->dataAccess->formatText($name) . ',' . $this->dataAccess->formatText($host) . ',' . $this->dataAccess->formatText($path) . ',' . $this->dataAccess->formatText($port) . ',' . $this->dataAccess->formatText($username) . ',' . $this->dataAccess->formatText($password) . ',' . $this->dataAccess->formatText($proxy) . ',' . $this->dataAccess->formatText($proxyPort) . ')');
             if ($result) {
                 $this->mLog->logEvent('Innomatic', 'Created new web services profile account', \Innomatic\Logging\Logger::NOTICE);
                 $this->mId = $acc_seq;
                 $this->mName = $name;
                 $this->mHost = $host;
                 $this->mPath = $path;
                 $this->mPort = $port;
                 $this->mUsername = $username;
                 $this->mPassword = $password;
                 $this->mProxy = $proxy;
                 $this->mProxyPort = $proxyPort;
                 if ($hook->callHooks('accountcreated', $this, array('name' => $name, 'host' => $host, 'port' => $port, 'path' => $path, 'username' => $username, 'password' => $password, 'proxy' => $proxy, 'proxyport' => $proxyPort, 'id' => $this->mId)) != \Innomatic\Process\Hook::RESULT_OK) {
                     $result = false;
                 }
             } else {
                 $result = WebServicesAccount::CREATE_UNABLE_TO_INSERT_ACCOUNT;
             }
         } else {
             $result = WebServicesAccount::CREATE_EMPTY_ACCOUNT_NAME;
         }
     }
     return $result;
 }
Esempio n. 2
0
 /**
  * Add a content page in the database.
  *
  * @param number $parentId Parent page number. 0 = home page.
  * @return boolean
  */
 public function addContent($parentId = 0)
 {
     $id = $this->domainDa->getNextSequenceValue('innomedia_pages_id_seq');
     if ($this->domainDa->execute('INSERT INTO innomedia_pages (id, page, name) VALUES (' . $id . ',' . $this->domainDa->formatText($this->module . '/' . $this->page) . ',' . $this->domainDa->formatText($this->name) . ')')) {
         $this->id = $id;
         // Set the page name for the page tree path.
         $pageName = isset($this->parameters['slug']) ? $this->parameters['slug'] : '';
         // Fallback to page title if the page slug is empty.
         if (!strlen($pageName)) {
             $pageName = isset($this->parameters['title']) ? $this->parameters['title'] : '';
         }
         // Fallback to internal page name if the page title is empty.
         if (!strlen($pageName)) {
             $pageName = $this->name;
         }
         // Fallback to page id if the page name is still empty.
         if (!strlen($pageName)) {
             $pageName = $id;
         }
         // Add the page to the pages tree.
         $tree = new PageTree();
         $tree->addPage($this->module, $this->page, $id, $parentId, $pageName);
         return true;
     } else {
         return false;
     }
 }
Esempio n. 3
0
 public function setup($tmpdir)
 {
     $result = false;
     // Checks for definition and structure files
     //
     if (file_exists($tmpdir . 'setup/application.xml')) {
         $genconfig = $this->parseApplicationDefinition($tmpdir . '/setup/application.xml');
         $this->appname = $genconfig['ApplicationIdName'];
         // Checks if Innomatic has been already installed
         //
         $tmpquery = $this->rootDA->execute('SELECT id FROM applications WHERE appid=' . $this->rootDA->formatText($this->appname));
         if (!$tmpquery->getNumberRows()) {
             // Gets id number for the application
             //
             $this->id = $this->rootDA->getNextSequenceValue('applications_id_seq');
             if ($this->rootDA->execute('INSERT INTO applications VALUES ( ' . $this->id . ',' . $this->rootDA->formatText($genconfig['ApplicationIdName']) . ',' . $this->rootDA->formatText($genconfig['ApplicationVersion']) . ',' . $this->rootDA->formatText($genconfig['ApplicationDate']) . ',' . $this->rootDA->formatText($genconfig['ApplicationDescription']) . ',' . $this->rootDA->formatText('') . ',' . $this->rootDA->formatText($this->rootDA->fmtfalse) . ',' . $this->rootDA->formatText($genconfig['ApplicationAuthor']) . ',' . $this->rootDA->formatText($genconfig['ApplicationAuthorEmail']) . ',' . $this->rootDA->formatText($genconfig['ApplicationAuthorWeb']) . ',' . $this->rootDA->formatText($genconfig['ApplicationSupportEmail']) . ',' . $this->rootDA->formatText($genconfig['ApplicationBugsEmail']) . ',' . $this->rootDA->formatText($genconfig['ApplicationCopyright']) . ',' . $this->rootDA->formatText($genconfig['ApplicationLicense']) . ',' . $this->rootDA->formatText($genconfig['ApplicationLicenseFile']) . ',' . $this->rootDA->formatText($genconfig['ApplicationChangesFile']) . ',' . $this->rootDA->formatText($genconfig['ApplicationMaintainer']) . ',' . $this->rootDA->formatText($genconfig['ApplicationMaintainerEmail']) . ',' . $this->rootDA->formatText($genconfig['ApplicationCategory']) . ',' . $this->rootDA->formatText($genconfig['ApplicationIconFile']) . ')')) {
                 // Application dir creation
                 //
                 if (!file_exists($this->container->getHome() . 'core/applications/' . $genconfig['ApplicationIdName'])) {
                     @mkdir($this->container->getHome() . 'core/applications/' . $genconfig['ApplicationIdName'], 0755);
                 }
                 // setup files
                 //
                 $dhandle = @opendir($tmpdir . '/setup');
                 if ($dhandle) {
                     while (false != ($file = readdir($dhandle))) {
                         if ($file != '.' && $file != '..' && is_file($tmpdir . '/setup/' . $file)) {
                             @copy($tmpdir . '/setup/' . $file, $this->container->getHome() . 'core/applications/' . $genconfig['ApplicationIdName'] . '/' . $file);
                         }
                     }
                     closedir($dhandle);
                 }
                 $result = $this->HandleStructure($tmpdir . 'setup/application.xml', Application::INSTALL_MODE_INSTALL, $tmpdir, 0, true);
                 if (strlen($genconfig['ApplicationLicenseFile']) and file_exists($tmpdir . '/setup/' . $genconfig['ApplicationLicenseFile'])) {
                     @copy($tmpdir . '/setup/' . $genconfig['ApplicationLicenseFile'], $this->container->getHome() . 'core/applications/' . $genconfig['ApplicationIdName'] . '/' . $genconfig['ApplicationLicenseFile']);
                 } else {
                     $log = $this->container->getLogger();
                     $log->logEvent('Innomatic', 'Unable to install Innomatic', \Innomatic\Logging\Logger::ERROR);
                 }
             } else {
                 $log = $this->container->getLogger();
                 $log->logEvent('innomatic.applications.applications.setup', 'Unable to insert Innomatic application row in applications table', \Innomatic\Logging\Logger::ERROR);
             }
         } else {
             $log = $this->container->getLogger();
             $log->logEvent('innomatic.applications.applications.setup', 'Attempted to resetup Innomatic', \Innomatic\Logging\Logger::ERROR);
         }
     } else {
         $log = $this->container->getLogger();
         if (!file_exists($tmpdir . 'setup/application.xml')) {
             $log->logEvent('innomatic.applications.applications.setup', 'Innomatic structure file ' . $tmpdir . 'setup/application.xml not found', \Innomatic\Logging\Logger::ERROR);
         }
     }
     return $result;
 }
 /**
  * Adds a new AppCentral remote server.
  *
  * @param \Innomatic\Webservices\WebServicesAccount $accountId Innomatic WebServices account pointing to an AppCentral server.
  * @access public
  * @return void
  */
 public function add($accountId)
 {
     $result = false;
     if ($accountId) {
         $repId = $this->dataAccess->getNextSequenceValue('applications_repositories_id_seq');
         if ($this->dataAccess->execute('INSERT INTO applications_repositories ' . 'VALUES (' . $repId . ',' . $accountId . ')')) {
             $this->id = $repId;
             $this->accountId = $accountId;
             $this->setClient();
             $result = true;
         }
     }
     return $result;
 }
Esempio n. 5
0
 /**
  * Add a new permission type.
  *
  * @param string $name Permission internal name.
  * @param string $title Permission title to be used in the UI.
  * @param string $description Permission description.
  * @param string $catalog Catalog name to be used to get the title string
  * when the permission has been installed by the permission component.
  * @param string $application Application identifier name required when
  * the permission has been installed by the permission component.
  * @access public
  * @return void
  */
 public function add($name, $title, $description, $catalog = '', $application = '')
 {
     $id = $this->dataAccess->getNextSequenceValue('domain_permissions_id_seq');
     $result = $this->dataAccess->execute("INSERT INTO domain_permissions\n            (id, name, title, description, catalog, application)\n            VALUES ({$id}," . $this->dataAccess->formatText($name) . ',' . $this->dataAccess->formatText($title) . ',' . $this->dataAccess->formatText($description) . ',' . $this->dataAccess->formatText($catalog) . ',' . $this->dataAccess->formatText($application) . ")");
     if (!$result) {
         return false;
     }
     $this->id = $id;
     $this->name = $name;
     $this->title = $title;
     $this->description = $description;
     $this->application = $application;
     $this->catalog = $catalog;
     // If the role has been created by an Innomatic component it should have
     // a catalog definition. In that case, replace the title and the description
     // with the localized versions.
     if (strlen($this->catalog)) {
         $localeCatalog = new \Innomatic\Locale\LocaleCatalog($this->catalog, InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getCurrentDomain()->getLanguage());
         $this->title = $localeCatalog->getStr($this->title);
         $this->description = $localeCatalog->getStr($this->description);
     }
     return true;
 }