Exemplo n.º 1
0
/**
 * Partial action that lists favorite objects
 * @author Steve Ryan steve@2pisoftware.com 2015
 */
function listfavorite_ALL(Web $w, $params)
{
    $user = $w->Auth->user();
    if (!empty($user)) {
        $results = $w->Favorite->getDataByUser($user->id);
        $favoritesCategorised = array();
        $service = new DBService($w);
        if (!empty($results)) {
            foreach ($results as $k => $favorite) {
                if (!array_key_exists($favorite->object_class, $favoritesCategorised)) {
                    $favoritesCategorised[$favorite->object_class] = array();
                }
                $realObject = $service->getObject($favorite->object_class, $favorite->object_id);
                if (!empty($realObject)) {
                    $templateData = array();
                    $templateData['title'] = $realObject->printSearchTitle();
                    $templateData['url'] = $realObject->printSearchUrl();
                    $templateData['listing'] = $realObject->printSearchListing();
                    if ($realObject->canList($user) && $realObject->canView($user)) {
                        array_push($favoritesCategorised[$favorite->object_class], $templateData);
                    }
                }
            }
        }
        $w->ctx('categorisedFavorites', $favoritesCategorised);
    }
}
Exemplo n.º 2
0
 public static function makeParam($reportID, $reportParameterID)
 {
     $parm = null;
     $db = new DBService();
     $result = $db->query("SELECT rp.*, rpm.parentReportParameterID\n            FROM ReportParameter rp, ReportParameterMap rpm\n            WHERE rp.reportParameterID = '{$reportParameterID}' LIMIT 1")->fetchRow(MYSQLI_ASSOC);
     if ($result['parameterDisplayPrompt'] === 'Provider / Publisher') {
         $parm = new ProviderPublisherParameter($reportID, $db, $result);
     } else {
         if ($result['parameterDisplayPrompt'] === 'Provider') {
             $parm = new ProviderParameter($reportID, $db, $result);
         } else {
             if ($result['parameterDisplayPrompt'] === 'Publisher') {
                 $parm = new PublisherParameter($reportID, $db, $result);
             } else {
                 if ($result['parameterTypeCode'] === 'chk') {
                     if ($result['parameterDisplayPrompt'] === "Do not adjust numbers for use violations") {
                         $parm = new CheckUnadjustedParameter($reportID, $db, $result);
                     } else {
                         $parm = new CheckboxParameter($reportID, $db, $result);
                     }
                 } else {
                     if ($result['parameterTypeCode'] === 'dd') {
                         if ($result['parameterAddWhereClause'] === 'limit') {
                             $parm = new LimitParameter($reportID, $db, $result);
                         } else {
                             if ($result['parameterDisplayPrompt'] === 'Year') {
                                 $parm = new YearParameter($reportID, $db, $result);
                             } else {
                                 if ($result['parameterDisplayPrompt'] === 'Date Range') {
                                     $parm = new DateRangeParameter($reportID, $db, $result);
                                 } else {
                                     $parm = new DropdownParameter($reportID, $db, $result);
                                 }
                             }
                         }
                     } else {
                         if ($result['parameterTypeCode'] === 'ms') {
                             if ($result['parameterDisplayPrompt'] === 'Provider / Publisher' || $result['parameterDisplayPrompt'] === 'Provider' || $result['parameterDisplayPrompt'] === 'Publisher') {
                                 $parm = new ProviderPublisherDropdownParameter($reportID, $db, $result);
                             } else {
                                 $parm = new MultiselectParameter($reportID, $db, $result);
                             }
                         } else {
                             if ($result['parameterTypeCode'] === 'txt') {
                                 $parm = new TextParameter($reportID, $db, $result);
                             } else {
                                 $parm = new Parameter($reportID, $db, $result);
                             }
                         }
                     }
                 }
             }
         }
     }
     return $parm;
 }
Exemplo n.º 3
0
 public function run($archiveInd, $ADD_WHERE1, $ADD_WHERE2, $orderBy)
 {
     if (stripos($this->sql, 'mus')) {
         $ch = 'm';
     } else {
         $ch = 'y';
     }
     $sql = str_replace('ADD_WHERE', "{$ADD_WHERE1} AND {$ch}" . "us.archiveInd = {$archiveInd}", str_replace('ADD_WHERE2', $ADD_WHERE2, $this->sql)) . $orderBy;
     $db = new DBService(Config::$database->{$this->getDBName()});
     return $db->query($sql);
 }
Exemplo n.º 4
0
 public function loadLoki()
 {
     $db = new DBService();
     $conn = $db->createPDOConnection();
     $sql = "SELECT data FROM lokidbs where name = ?";
     $query = $conn->prepare($sql);
     $query->execute(array($this->lokiName));
     if ($query->rowCount() > 0) {
         $row = $query->fetch(PDO::FETCH_ASSOC);
         $str = $row["data"];
         return $str;
     } else {
         return null;
     }
 }
Exemplo n.º 5
0
 public function invokeHandler(RequestData $data, $search = "")
 {
     $order_by = $data->get("order_by", "updated");
     $search_by = $data->get("search_by", "title");
     $categories = $data->get("categories", array());
     $language = $data->get("language", "");
     $type = $data->get("type", "");
     $stories = new Stories();
     $stories->RELEVANCE = empty($search) ? 0 : 0.1;
     $stories->setCategories($categories);
     $stories->setClasses($type, $language);
     if ($search_by == 'title') {
         $stories_results = $stories->searchByTitle($search, 0, $order_by);
     } else {
         if ($search_by == 'text') {
             $stories_results = $stories->searchByText($search, 0, $order_by);
         } else {
             $stories_results = $stories->searchByAll($search, 0, $order_by);
         }
     }
     if (count($stories_results)) {
         // echo "REPLACE INTO search_cache(search_text) values(".$search.")";
         $RDb = DBService::getDB();
         $res = $RDb->update("REPLACE INTO search_cache(search_text) values('" . $search . "')");
     }
     // print_r($stories->get(0));
     return $stories_results;
 }
Exemplo n.º 6
0
 public function db()
 {
     if (!$this->db) {
         $this->db = DBService::get_connection($this->get_service_id());
     }
     return $this->db;
 }
Exemplo n.º 7
0
 public static function setDatabase(mysqli $db)
 {
     self::$db = null;
     if ($db && $db->ping()) {
         self::$db = $db;
         return true;
     }
     return false;
 }
Exemplo n.º 8
0
 public function value()
 {
     if (isset($_REQUEST["prm_{$this->id}"])) {
         $val = trim(DBService::escapeString($_REQUEST["prm_{$this->id}"]));
         if ($val !== '') {
             return $val;
         }
     }
     return null;
 }
Exemplo n.º 9
0
 /**
  *
  * @param Smarty $viewModel        	
  * @param Header $header        	
  * @param DataModel $dataModel        	
  * @param User $user        	
  * @param string $view        	
  * @param string $module        	
  * @return string
  */
 public function invokeHandler(User $user, $view = "empty", $module = "index_page", RequestData $data, $info = "NO")
 {
     if ($info == "STATS") {
         return new WebSite();
     } else {
         if ($info == "CATEGORIES") {
             return new Categories();
         } else {
             if ($info == "CLASSES") {
                 $RDb = DBService::getDB();
                 return $RDb->fetchAll("SELECT class_id id, class_name name, classtype_id, classtype_name,classtype_title\n\t\t\t\t\tFROM `fanfiction_classes` as c,fanfiction_classtypes as ct \n\t\t\t\t\tWHERE ct.classtype_id=c.class_type");
             }
         }
     }
     return $data;
 }
Exemplo n.º 10
0
 public function invokeHandler(RequestData $data)
 {
     $search = $data->get("search", "");
     $response = array();
     $RDb = DBService::getDB();
     $res = $RDb->fetchAll("SELECT * FROM search_cache\n\t\t\t\tWHERE UPPER(search_text) like UPPER(%s)\n\t\t\t\tORDER BY search_text", "'%" . $search . "%'");
     if (count($res) == 0) {
         $res = $RDb->fetchAll("SELECT title as search_text FROM fanfiction_stories\n\t\t\t\t\tWHERE UPPER(title) like UPPER(%s)\n\t\t\t\t\tORDER BY title", "'%" . $search . "%'");
     }
     if (count($res) == 0) {
         $response['error'] = true;
         return false;
     } else {
         $response['data'] = $res;
         $response['error'] = false;
         return $response;
     }
 }
Exemplo n.º 11
0
 static function close()
 {
     DBService::get_instance()->__destruct();
 }
Exemplo n.º 12
0
 public static function getConnection(DBService $connector)
 {
     return $connector->getConnection();
 }
Exemplo n.º 13
0
<?php

include_once 'bootstrap.php';
Config::init();
if (isset($_POST['step'])) {
    $step = $_POST['step'];
} else {
    $step = 0;
}
$errorMessage = array();
if ($step == "1") {
    $dbservice = new DBService();
    //make sure SQL file exists
    $test_sql_file = "test_create.sql";
    $sql_file = "create_tables_data.sql";
    if (!file_exists($test_sql_file)) {
        $errorMessage[] = "Could not open sql file: " . $test_sql_file . ".  If this file does not exist you must download new install files.";
    } else {
        //run the file - checking for errors at each SQL execution
        $f = fopen($test_sql_file, "r");
        $sqlFile = fread($f, filesize($test_sql_file));
        $sqlArray = explode(";", $sqlFile);
        //Process the sql file by statements
        foreach ($sqlArray as $stmt) {
            if (strlen(trim($stmt)) > 3) {
                //replace the DATABASE_NAME parameter with what was actually input
                $stmt = str_replace("_DATABASE_NAME_", Config::$database->name, $stmt);
                try {
                    $result = $dbservice->query($stmt);
                } catch (RuntimeException $exception) {
                    $errorMessage[] = $dbservice->error() . "<br /><br />For statement: " . $stmt;
Exemplo n.º 14
0
 public function publisherNotes()
 {
     $db = new DBService(Config::$database->{$this->dbname});
     return $db->query("SELECT startYear, endYear, noteText, reportDisplayName\n\t\t\t\tFROM PublisherPlatformNote pn, PublisherPlatform pp\n\t\t\t\tWHERE pp.publisherPlatformID = pn.publisherPlatformID\n\t\t\t\tAND pp.publisherPlatformID in (" . $db->sanitize(join(',', array_keys($this->pubIDs))) . ");")->fetchRows(MYSQLI_ASSOC);
 }
Exemplo n.º 15
0
<?php

$page = "impressum";
require_once '../scr/classes/db/DBConnection.php';
require_once '../scr/classes/db/DBService.php';
$db = new DBService();
if (isset($_POST["save_button"])) {
    $db->updateContent($_POST["impressum"], $db->findContentIdByPageName($page));
}
$content = $db->findContent($page, NULL);
?>

<!DOCTYPE html>
<html lang="en">
    <head>       
        <script src="../ckeditor/ckeditor.js"></script>
    </head>
    <body>  
        <form class="form-horizontal" action='' method="POST" accept-charset="utf-8">
            <textarea name="impressum" id="impressum" rows="10" cols="80">
                <?php 
echo $content['content'];
?>
            </textarea>
            <script>
                CKEDITOR.replace('impressum');
            </script>
            <input type="submit" value="Speichern" name="save_button" />
        </form>       
    </body>
</html>
Exemplo n.º 16
0
 public function reportIdProvider()
 {
     $db = new DBService();
     $ids = array();
     foreach ($db->query("SELECT reportID FROM Report")->fetchRows(MYSQLI_ASSOC) as $report) {
         $ids[] = array($report['reportID']);
     }
     return $ids;
 }
Exemplo n.º 17
0
function saint_exception_handler($e)
{
    $l = ob_get_level();
    while ($l--) {
        ob_end_clean();
    }
    # manually attempt to close all db connections
    DBService::close();
    if (SHELL) {
        $e->log();
    } else {
        Usher::handle_error($e);
    }
    exit;
}
Exemplo n.º 18
0
				</td>
			</tr>
			<tr>
				<td class="fullborder"><br /> <br />
					<div id='div_report'>
						<label for="reportID">
							<?php 
echo _("Select Report");
?>
						</label>
						<select name='reportID' id='reportID' class='opt'>
							<option value=''></option>
<?php 
// get all reports for output in drop down
$db = new DBService();
foreach ($db->query("SELECT reportID, reportName FROM Report ORDER BY 2, 1")->fetchRows(MYSQLI_ASSOC) as $report) {
    echo "<option value='" . $report['reportID'] . "' ";
    if (isset($report['reportID']) && isset($_GET['reportID']) && $report['reportID'] === $_GET['reportID']) {
        echo 'selected';
    }
    echo ">" . $report['reportName'] . "</option>";
}
unset($db);
?>
						</select>
					</div>
					<div id='div_parm'>
<?php 
if (isset($_GET['reportID'])) {
    $reportID = $_GET['reportID'];
Exemplo n.º 19
0
 public static function initDB($configname)
 {
     if (!self::$connected) {
         include_once "db/AbstractDb.php";
         self::$connected = true;
     }
     self::$map[$configname] = new AbstractDb(Config::getSection($configname));
     return self::$map[$configname];
 }