public function beforeDelete()
 {
     if ($this->getOwner()->getGalleryId()) {
         $mapper = Manager::getInstance()->getMapper($this->mapper_alias);
         $aContainer = $mapper->getContainer();
         $categoryId = $this->getOwner()->getGalleryId();
         // Удаляем все записи о фотках из базы
         $oQuery = new DbUpdater(DbUpdater::TYPE_DELETE, $aContainer['TableName'], $aContainer['Object'], $this->getDbConnectionAlias());
         $oCriteria = new CriteriaElement('category_id', Criteria::EQUAL, $categoryId);
         $oQuery->addCriteria($mapper->parseUpdateCriteria($oCriteria->renderWhere()));
         $oQuery->delete();
         $this->getOwner()->getGallery()->delete();
     }
     return true;
 }
Example #2
0
<?php

// Be hacky/lazy and just use the same DRUPAL_ROOT namespace
define('DRUPAL_ROOT', dirname(realpath(__FILE__)));
// Load the general includes file.
require_once DRUPAL_ROOT . '/includes/gen.inc';
// Load up ALL the includes.
load_includes();
// Fire up the bootstrap-imitating conf_init()
conf_init();
// install_schemas();
$file = '/home/sdboyer/Documents/Academic/Padgett.PLSC57500/final/devarchive/2005-January.txt';
date_default_timezone_set('UTC');
$archive = new MailmanArchiveParser($file);
// $dat = introspect_spl_class($archive);
foreach ($archive as $item) {
    $db = new DbUpdater($item);
    $db->prepData();
}
$i = 'break on me';
Example #3
0
 * @package    wpos
 * @copyright  Copyright (c) 2014 WallaceIT. (https://wallaceit.com.au)
 * @link       https://wallacepos.com
 * @author     Michael B Wallace <*****@*****.**>
 * @since      File available since 14/12/13 07:46 PM
 */
die("Please manually enable the installer before proceeding");
$_SERVER['APP_ROOT'] = "/";
if (!isset($_SERVER['DOCUMENT_ROOT'])) {
    $_SERVER['DOCUMENT_ROOT'] = "/app";
    // this is what dokku uses as docroot, we can catch it because it ain't defined (not using mod_php);
}
if (php_sapi_name() == "cli") {
    $_SERVER['DOCUMENT_ROOT'] = "/app";
    // explicitly define docroot
    parse_str(implode('&', array_slice($argv, 1)), $_REQUEST);
}
require $_SERVER['DOCUMENT_ROOT'] . $_SERVER['APP_ROOT'] . 'library/wpos/AutoLoader.php';
//Autoload all the classes.
$dbUpdater = new DbUpdater();
// update
if (isset($_REQUEST['upgrade']) && isset($_REQUEST['version'])) {
    $result = $dbUpdater->upgrade($_REQUEST['version']);
    echo $result;
}
// install
if (isset($_REQUEST['install'])) {
    $result = $dbUpdater->install();
    echo $result;
}
die("<br/>Please remove the install/index.php file after installing, leaving it after installation is dangerous");
Example #4
0
 protected function update($table, $data, $pk)
 {
     $oQuery = new DbUpdater(DbUpdater::TYPE_UPDATE, $table, 't', $this->dbConnection);
     $oQuery->setElement($data);
     $oCriteria = new CriteriaElement('id', Criteria::EQUAL, $pk);
     $oQuery->addCriteria($oCriteria->renderWhere());
     $oQuery->update();
 }
Example #5
0
 protected function updateTableData($table, $data)
 {
     if (isset($data['Insert'])) {
         foreach ($data['Insert'] as $insert) {
             $oQuery = new DbUpdater(DbUpdater::TYPE_INSERT, $table, 't', $this->_dbConnection);
             $oQuery->setElement($insert);
             $oQuery->insert();
         }
     }
     if (isset($data['Update'])) {
         foreach ($data['Update'] as $insert) {
             $oQuery = new DbUpdater(DbUpdater::TYPE_UPDATE, $table, 't', $this->_dbConnection);
             $oQuery->setElement($insert);
             $oCriteria = new CriteriaElement('id', Criteria::EQUAL, $insert['id']);
             $oQuery->addCriteria($oCriteria->renderWhere());
             $oQuery->update();
         }
     }
 }
    function dbupdate()
    {
        startup_gettext();
        if (!SINGLE_USER_MODE && $_SESSION["access_level"] < 10) {
            $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
            render_login_form();
            exit;
        }
        ?>
<html>
			<head>
			<title>Database Updater</title>
			<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
			<link rel="stylesheet" type="text/css" href="css/utility.css"/>
			</head>
			<style type="text/css">
				span.ok { color : #009000; font-weight : bold; }
				span.err { color : #ff0000; font-weight : bold; }
			</style>
		<body>
			<script type='text/javascript'>
			function confirmOP() {
				return confirm("Update the database?");
			}
			</script>

			<div class="floatingLogo"><img src="images/logo_small.png"></div>

			<h1><?php 
        echo __("Database Updater");
        ?>
</h1>

			<div class="content">

			<?php 
        @($op = $_REQUEST["subop"]);
        $updater = new DbUpdater(Db::get(), DB_TYPE, SCHEMA_VERSION);
        if ($op == "performupdate") {
            if ($updater->isUpdateRequired()) {
                print "<h2>Performing updates</h2>";
                print "<h3>Updating to schema version " . SCHEMA_VERSION . "</h3>";
                print "<ul>";
                for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) {
                    print "<li>Performing update up to version {$i}...";
                    $result = $updater->performUpdateTo($i);
                    if (!$result) {
                        print "<span class='err'>FAILED!</span></li></ul>";
                        print_warning("One of the updates failed. Either retry the process or perform updates manually.");
                        print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t\t\t</form>";
                        break;
                    } else {
                        print "<span class='ok'>OK!</span></li>";
                    }
                }
                print "</ul>";
                print_notice("Your Tiny Tiny RSS database is now updated to the latest version.");
                print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t</form>";
            } else {
                print "<h2>Your database is up to date.</h2>";
                print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t</form>";
            }
        } else {
            if ($updater->isUpdateRequired()) {
                print "<h2>Database update required</h2>";
                print "<h3>";
                printf("Your Tiny Tiny RSS database needs update to the latest version: %d to %d.", $updater->getSchemaVersion(), SCHEMA_VERSION);
                print "</h3>";
                print_warning("Please backup your database before proceeding.");
                print "<form method='POST'>\n\t\t\t\t\t\t\t<input type='hidden' name='subop' value='performupdate'>\n\t\t\t\t\t\t\t<input type='submit' onclick='return confirmOP()' value='" . __("Perform updates") . "'>\n\t\t\t\t\t\t</form>";
            } else {
                print_notice("Tiny Tiny RSS database is up to date.");
                print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t</form>";
            }
        }
        ?>

			</div>
			</body>
			</html>
		<?php 
    }
                $feed_id = (int) $line["feed_id"];
            }
            $filter["enabled"] = $line["enabled"] ? "on" : "off";
            $filter["rule"] = array(json_encode(array("reg_exp" => $line["reg_exp"], "feed_id" => $feed_id, "filter_type" => $line["filter_type"])));
            $filter["action"] = array(json_encode(array("action_id" => $line["action_id"], "action_param_label" => $line["action_param"], "action_param" => $line["action_param"])));
            // Oh god it's full of hacks
            $_REQUEST = $filter;
            $_SESSION["uid"] = $owner_uid;
            $filters = new Pref_Filters($_REQUEST);
            $filters->add();
        }
    }
}
if (isset($options["update-schema"])) {
    _debug("checking for updates (" . DB_TYPE . ")...");
    $updater = new DbUpdater(Db::get(), DB_TYPE, SCHEMA_VERSION);
    if ($updater->isUpdateRequired()) {
        _debug("schema update required, version " . $updater->getSchemaVersion() . " to " . SCHEMA_VERSION);
        _debug("WARNING: please backup your database before continuing.");
        _debug("Type 'yes' to continue.");
        if (read_stdin() != 'yes') {
            exit;
        }
        for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) {
            _debug("performing update up to version {$i}...");
            $result = $updater->performUpdateTo($i);
            _debug($result ? "OK!" : "FAILED!");
            if (!$result) {
                return;
            }
        }
Example #8
0
function updateDb($dbConnectionInfo)
{
    $toReturn = false;
    $updater = new DbUpdater($dbConnectionInfo);
    $result = $updater->updateDb();
    if (!$result['updated']) {
        echo $result['message'];
    } else {
        echo "Compatible database version found.";
        $toReturn = true;
    }
    return $toReturn;
}
Example #9
0
 protected function saveForRelationData($oObject, $before = false)
 {
     $saveForRelation = $before ? $oObject->aForSaveRelationsDataBefore : $oObject->aForSaveRelationsData;
     $objectId = $before ? 0 : (int) $oObject->getId();
     if (!empty($saveForRelation)) {
         $relations = $this->relations();
         foreach ($saveForRelation as $rel => $val) {
             $relation = $relations[$rel];
             foreach ($val as $action => $data) {
                 $oRelMapper = Manager::getInstance()->getMapper($relation['ToMapperAlias']);
                 $aRelContainer = $oRelMapper->getContainer();
                 $sRelClassName = $aRelContainer['Object'];
                 switch ($action) {
                     case 'Delete':
                         // Удаляем все что есть
                         $oQuery = new DbUpdater(DbUpdater::TYPE_DELETE, $relation['TableName'], $sRelClassName, $this->getDbConnectionAlias());
                         $oCriteria = new CriteriaElement($relation['Field2'], Criteria::EQUAL, $objectId);
                         $oQuery->addCriteria($this->parseUpdateCriteria($oCriteria->renderWhere()));
                         $oQuery->delete();
                         break;
                     case 'Add':
                         // сохраняем в базу
                         if (is_array($data)) {
                             foreach ($data as $data_val) {
                                 $oQuery = new DbUpdater(DbUpdater::TYPE_INSERT, $relation['TableName'], $sRelClassName, $this->getDbConnectionAlias());
                                 $oQuery->setElement(array($relation['Field'] => $data_val, $relation['Field2'] => $objectId));
                                 $oQuery->insert();
                             }
                         }
                         break;
                         // Has Many
                     // Has Many
                     case 'Set':
                         if (is_array($data)) {
                             $result = new SimpleCollection();
                             foreach ($data as $itm) {
                                 if (!empty($itm['Id'])) {
                                     $obj = $oRelMapper->findById($itm['Id']);
                                 } else {
                                     $obj = $oRelMapper->create();
                                 }
                                 unset($itm['Id']);
                                 $obj->import($itm);
                                 $obj->set($relation['Field'], $objectId);
                                 $obj->save();
                                 $result->add($obj);
                             }
                         }
                         break;
                         // Belongs To
                     // Belongs To
                     case 'SetOne':
                         if (is_array($data)) {
                             if (!empty($data['Id'])) {
                                 $obj = $oRelMapper->findById($data['Id']);
                             } else {
                                 $obj = $oRelMapper->create($data);
                             }
                             unset($data['Id']);
                             $obj->import($data);
                             $id = $obj->save();
                             $oObject->set($relation['Field'], $id);
                             $oObject->set($rel, $obj);
                         } else {
                             if (is_object($data)) {
                                 if (!$data->getId()) {
                                     $data->save();
                                 }
                                 $oObject->set($rel, $data);
                             }
                         }
                         break;
                 }
             }
         }
         if ($before) {
             $oObject->aForSaveRelationsDataBefore = array();
         } else {
             $oObject->aForSaveRelationsData = array();
         }
         return true;
     }
     return false;
 }
Example #10
0
// installer scripts
// update
if (isset($_REQUEST['upgrade']) && isset($_REQUEST['version'])) {
    $dbUpdater = new DbUpdater();
    $result = $dbUpdater->upgrade($_REQUEST['version']);
    // register analytics
    addAnalytics("upgrade");
    echo $result;
    exit;
}
// install
if (isset($_REQUEST['install'])) {
    if (isset($_SESSION['setupvars'])) {
        $_REQUEST['setupvars'] = $_SESSION['setupvars'];
    }
    $dbUpdater = new DbUpdater();
    $result = $dbUpdater->install();
    // register analytics
    addAnalytics("install");
    echo $result;
    exit;
}
// gui installer
if (!isset($_SESSION['install_screen'])) {
    $_SESSION['install_screen'] = 1;
} else {
    if (isset($_REQUEST['screen']) && $_REQUEST['screen'] != "") {
        $_SESSION['install_screen'] = $_REQUEST['screen'];
    }
}
if (isset($_REQUEST['checkdb'])) {
Example #11
0
 private function processDbUpdates()
 {
     if (isset($_GET['db']) && $_GET['db'] == 'update') {
         include_once LIB_ROOT . '/db_updater.class.php';
         $db = new DbUpdater();
         $db->setDbUpdatesFile(DOC_ROOT . '/db_updates.php');
         $db->update();
     }
 }