Esempio n. 1
1
 function updateDb()
 {
     $params = array();
     $toReturn = array();
     $toReturn['updated'] = true;
     $toReturn['message'] = "";
     $db = new RecordSet($this->dbConnectionInfo, false, true);
     $rows = $db->Open("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA =  '" . $this->dbConnectionInfo['dbName'] . "' AND TABLE_NAME =  'webhelp'");
     if ($rows > 0) {
         $db->Open("SELECT * FROM webhelp;");
         while ($db->MoveNext()) {
             $assoc = $db->getAssoc();
             $params[$db->Field("parameter")] = $db->Field("value");
         }
         $db->Close();
         if ($params['databaseVersion'] != '1') {
             $toReturn['updated'] = false;
             $toReturn['message'] = "Incompatible database version found!";
         }
     } else {
         $toReturn['updated'] = false;
         $toReturn['message'] = "Database structure does not exist! In order to create a compatible database structure you must check option <strong>\"Create new database structure\"</strong> from previous instalation page.";
     }
     return $toReturn;
 }
 /**
  * export Comments for a specified page
  * 	
  * @param IExporter $exporter exporter to be used
  * @param String fields to be exported separated by comma
  * @param String orderClause to be used in selecting records
  */
 function export($exporter, $fields = null, $orderClause = null)
 {
     $whereClause = "";
     $whereFromFilter = $exporter->getFilter()->getSqlFilterClause();
     if ($whereFromFilter != null) {
         $whereClause = "WHERE " . $whereFromFilter;
     }
     $db = new RecordSet($this->dbConnectionInfo);
     $select = "*";
     if ($fields != null) {
         //$select=Utils::arrayToString($fields,",");
         $select = $fields;
     }
     $sql = "SELECT " . $select . " FROM " . $this->tableName . " " . $whereClause;
     if ($orderClause != null) {
         $sql .= " " . $orderClause;
     }
     $sql .= ";";
     if ($db->Open($sql)) {
         $rowArray = $db->getAssoc();
         while ($rowArray) {
             if (is_array($rowArray)) {
                 $exporter->exportRow($rowArray);
             }
             $rowArray = $db->getAssoc();
         }
     }
     $db->Close();
 }
Esempio n. 3
0
 /**
  * @return array all products that share comments with this one
  */
 function getSharedWith()
 {
     $toReturn = array();
     $db = new RecordSet($this->dbConnectionInfo, false, true);
     $query = "Select product,value from webhelp where parameter='name' and version='" . $db->sanitize($this->version) . "' ";
     if (defined('__SHARE_WITH__')) {
         $query .= "AND product in (";
         $shareArray = explode(",", __SHARE_WITH__);
         foreach ($shareArray as $key => $value) {
             $query .= "'" . $db->sanitize($value) . "', ";
         }
         $query = substr($query, 0, -2) . ");";
     }
     error_log($query);
     $prds = $db->Open($query);
     if ($prds > 0) {
         while ($db->MoveNext()) {
             $product = $db->Field('product');
             $value = $db->Field('value');
             $toReturn[$product] = $value;
         }
     }
     $db->close();
     return $toReturn;
 }
function getBaseUrl($product, $version)
{
    global $dbConnectionInfo;
    $toReturn = __BASE_URL__;
    $db = new RecordSet($dbConnectionInfo, false, true);
    $rows = $db->Open("SELECT value FROM webhelp WHERE parameter='path' AND product='" . $product . "' AND version='" . $version . "';");
    if ($rows == 1) {
        $db->MoveNext();
        $toReturn = $db->Field('value');
    }
    $db->Close();
    return $toReturn;
}
Esempio n. 5
0
 /**
  * @return array all products that share comments with this one
  */
 function getSharedWith()
 {
     $toReturn = array();
     $db = new RecordSet($this->dbConnectionInfo, false, true);
     $prds = $db->Open("Select product,value from webhelp where parameter='name' and version='" . $this->version . "' " . (defined('__SHARE_WITH__') ? "AND product in (" . __SHARE_WITH__ . ")" : '') . ";");
     if ($prds > 0) {
         while ($db->MoveNext()) {
             $product = $db->Field('product');
             $value = $db->Field('value');
             $toReturn[$product] = $value;
         }
     }
     $db->close();
     return $toReturn;
 }
Esempio n. 6
0
 /**
  * Gather user information
  *
  * @param string $username Find information for 'username'
  * @param string $info Required attribute of the user account object
  * @return null|string User information
  * @throws Exception
  */
 public function getUserInformation($username, $info)
 {
     $toReturn = null;
     $db = new RecordSet($this->dbConnectionInfo, false, true);
     $information = $db->Open("SELECT email FROM users WHERE userName = '******' AND password != '';");
     switch ($information) {
         case 1:
             // User found in local database
             $toReturn = $db->Field('email');
             break;
         case 0:
             // User not found in local database
             // Try to find it in LDAP
             if ($this->ldap instanceof Ldap) {
                 try {
                     $information = $this->ldap->getUserInfo($username, array($info));
                     $toReturn = @$information[0][$info][0];
                 } catch (Exception $e) {
                     throw new Exception($e->getMessage());
                 }
             }
             break;
         default:
             throw new Exception('No or more than one email address found for ' . $username);
     }
     return $toReturn;
 }
Esempio n. 7
0
 /**
  * Query all products and versions for existing comments
  */
 function queryInfo()
 {
     $toReturn = array();
     $db = new RecordSet($this->dbConnectionInfo);
     $query = "SELECT DISTINCT product,version FROM comments ORDER BY product;";
     if ($db->Open($query) > 0) {
         while ($db->MoveNext()) {
             $toReturn[$db->Field('product')][] = $db->Field('version');
         }
     }
     $db->Close();
     return $toReturn;
 }
Esempio n. 8
0
 /**
  * Get allproduct for witch this user is valid 
  * 
  * @return multitype:Strign productId=>Name
  */
 function getSharedProducts()
 {
     $toReturn = array();
     $db = new RecordSet($this->dbConnectionInfo, false, true);
     $prds = $db->Open("Select product,value from webhelp where parameter='name' ;");
     if ($prds > 0) {
         while ($db->MoveNext()) {
             $product = $db->Field('product');
             $value = $db->Field('value');
             $toReturn[$product] = $value;
         }
     }
     $db->close();
     return $toReturn;
 }
Esempio n. 9
0
/*
    
Oxygen Webhelp plugin
Copyright (c) 1998-2014 Syncro Soft SRL, Romania.  All rights reserved.
Licensed under the terms stated in the license file EULA_Webhelp.txt 
available in the base directory of this Oxygen Webhelp plugin.
*/
$baseDir0 = dirname(dirname(__FILE__));
include $baseDir0 . '/oxygen-webhelp/resources/php/init.php';
$version = "@PRODUCT_VERSION@";
if (isset($_POST['host']) && isset($_POST['user']) && isset($_POST['passwd']) && isset($_POST['db'])) {
    $dbConnectionInfo = array('dbHost' => $_POST['host'], 'dbName' => $_POST['db'], 'dbPassword' => $_POST['passwd'], 'dbUser' => $_POST['user']);
    try {
        $db = new RecordSet($dbConnectionInfo, false, true);
        $prds = $db->Open("Select product,value from webhelp where parameter='name' and version='" . $version . "'; ");
        if ($prds > 0) {
            echo "<div class=\"title\">Display comments from</div>\n\t\t\t<div class=\"desc\">Share other products comments (having the same version) with this one. You must select one or more products from the list. Hold down the Ctrl (windows) / Command (Mac) button to select multiple options. </div>\n\t\t\t<table>\n\t\t\t<tr>\n\t\t\t<td>Existing products sharing the same database\n\t\t\t</td>\n\t\t\t<td>";
            echo "<select multiple=\"multiple\" name=\"shareWith[]\" size=\"5\">";
            while ($db->MoveNext()) {
                $product = $db->Field('product');
                $name = $db->Field('value');
                echo "<option value=\"" . $product . "\">" . $name . "</option>";
            }
            echo "</select>";
            echo "</td>\n\t\t\t</tr></table></div>";
        }
    } catch (Exception $ex) {
        echo "<br/>Could not connect to database using specified informations:";
        echo "<table class=\"info\">";
        echo "<tr><td>Host </td><td>" . $dbConnectionInfo['dbHost'] . "</td></tr>";