+++ /dev/null
-#!/usr/bin/php
-<?php
-/**
- * Script to migrate forums from datatree agora_forms table
- */
-
-require_once dirname(__FILE__) . '/../../lib/Application.php';
-Horde_Registry::appInit('agora', array('authentication' => 'none', 'cli' => true));
-
-/* Open the database. */
-$db = $injector->getInstance('Horde_Db_Pear')->getDb();
-
-/* Copy forums. */
-$max_id = 0;
-$forums = $db->getAll('SELECT * FROM horde_datatree WHERE group_uid LIKE \'agora.forums%\'', DB_FETCHMODE_ASSOC);
-foreach ($forums as $forum) {
- if ($forum['datatree_id'] > $max_id) {
- $max_id = $forum['datatree_id'];
- }
-
- $result = $db->getAll('SELECT * FROM horde_datatree_attributes WHERE datatree_id = ?', array($forum['datatree_id']), DB_FETCHMODE_ASSOC);
- $attributes = array();
- foreach ($result as $attr) {
- $attributes[$attr['attribute_name'] . '_' . $attr['attribute_key']] = $attr['attribute_value'];
- }
-
- $sql = 'INSERT INTO agora_forums' .
- ' (forum_id, scope, active, forum_name, forum_description, author, forum_moderated, message_count, forum_attachments, forum_parent_id, count_views, thread_count)' .
- ' VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 0, 0)';
-
- $values = array($forum['datatree_id'],
- ($forum['group_uid'] == 'agora.forums') ? 'agora' : substr($forum['group_uid'], 13),
- 1,
- $forum['datatree_name'],
- $attributes['forum_description'],
- $forum['user_uid'],
- (int)$attributes['forum_moderated'],
- $attributes['message_seq'],
- (int)$attributes['forum_attachments']);
-
- $result = $db->query($sql, $values);
- if ($result instanceof PEAR_Error) {
- var_dump($result);
- exit;
- }
-}
-
-// Update DB sequence.
-while ($db->nextId('agora_forums') < $max_id);
+++ /dev/null
-#!/usr/bin/php
-<?php
-/**
- * TODO: Attachments
- *
- * Script to migrate forums from datatree agora_forms table
- */
-
-require_once dirname(__FILE__) . '/../../lib/Application.php';
-Horde_Registry::appInit('agora', array('authentication' => 'none', 'cli' => true));
-
-/* Open the database. */
-$db = $injector->getInstance('Horde_Db_Pear')->getDb();
-
-/* Get messages. */
-$sql = 'SELECT DISTINCT d.datatree_id, d.datatree_parents FROM horde_datatree d, horde_datatree_attributes a '
- . ' WHERE d.group_uid = \'agora.threads\' AND d.datatree_id = a.datatree_id';
-$threads = $db->getAssoc($sql);
-if ($threads instanceof PEAR_Error) {
- var_dump($threads);
- exit;
-}
-
-/* SQL mesage insert statement */
-$sql = 'INSERT INTO agora_messages '
- . '(message_id, forum_id, parents, message_thread, message_author, message_subject, body, message_timestamp, attachments, ip)'
- . ' VALUES (?, ?, ?, ?, ?, ?, ?, ?, 0, \'\') ';
-
-foreach ($threads as $id => $parents) {
- $result = $db->getAll('SELECT * FROM horde_datatree_attributes WHERE datatree_id = ?', array($id), DB_FETCHMODE_ASSOC);
- $attributes = array();
- foreach ($result as $attr) {
- $attributes[$attr['attribute_key']] = $attr['attribute_value'];
- }
-
- // Remove main thread
- $thread = explode(':', $parents);
- unset($thread[1]);
-
- $params = array($id);
- $params[] = $attributes['forum_id'];
- $params[] = implode(':', $thread);
- $params[] = count($thread) > 1 ? $thread[2] : 0;
- $params[] = $attributes['author'];
- $params[] = $attributes['subject'];
- $params[] = $attributes['body'];
- $params[] = $attributes['timestamp'];
-
- $result = $db->query($sql, $params);
- if ($result instanceof PEAR_Error) {
- var_dump($result);
- exit;
- }
-}
+++ /dev/null
-#!/usr/bin/php
-<?php
-/**
- * Upgrades counters
- *
- * TODO Get rid of moderation
- */
-
-require_once dirname(__FILE__) . '/../../lib/Application.php';
-Horde_Registry::appInit('agora', array('authentication' => 'none', 'cli' => true));
-
-/* Open the database. */
-$db = $injector->getInstance('Horde_Db_Pear')->getDb();
-
-/* Get threads. */
-$sql = 'SELECT message_id, forum_id FROM agora_messages WHERE message_thread = ?';
-$threads = $db->getAssoc($sql, false, array(0));
-if ($threads instanceof PEAR_Error) {
- var_dump($threads);
- exit;
-}
-
-/* Reset message count */
-$db->query('UPDATE agora_messages SET message_seq = 0');
-echo 'Processing ' . count($threads) . ' threads' . "\n";
-
-$sql = 'SELECT message_thread, COUNT(*) FROM agora_messages WHERE message_thread > ? GROUP BY message_thread';
-$counts = $db->getAssoc($sql, false, array(0));
-if ($counts instanceof PEAR_Error) {
- var_dump($counts);
- exit;
-}
-
-/* Update the number of messages in thread */
-$forums = array();
-foreach ($threads as $message_id => $forum_id) {
- if (!isset($counts[$message_id])) {
- continue;
- }
- $count = $counts[$message_id];
- $db->query('UPDATE agora_messages SET message_seq = ? WHERE message_id = ?', array($count, $message_id));
-
- if (!isset($forums[$forum_id])) {
- $forums[$forum_id] = array('threads' => 0,
- 'messages' => 0,
- 'forum_id' => $forum_id);
- }
-
- $forums[$forum_id]['threads'] += 1;
- $forums[$forum_id]['messages'] += ($count + 1);
-}
-
-echo "Update forums \n";
-
-/* Update thread and message count for forums */
-$db->query('UPDATE agora_forums SET thread_count = 0, message_count = 0');
-$sth = $db->prepare('UPDATE agora_forums SET thread_count = ?, message_count = ? WHERE forum_id = ?');
-$result = $db->executeMultiple($sth, $forums);
-if ($result instanceof PEAR_Error) {
- var_dump($result);
- exit;
-}
-
-echo "Clean cache \n";
-
-/* Clean cache */
-$forums = Agora_Messages::singleton('agora');
-foreach ($forums->getForums(0, false) as $forum_id) {
- @$forums->cleanCache($forum_id);
-}
-
-echo "done\n";
+++ /dev/null
-CREATE TABLE agora_moderators (
- forum_id INT DEFAULT 0 NOT NULL,
- horde_uid VARCHAR(32) NOT NULL,
---
- PRIMARY KEY (forum_id, horde_uid)
-);
|| $group->userIsInGroup($user_uid, 1, false)
|| $group->userIsInGroup($user_uid, 2, false)) {
- $db = $GLOBALS['injector']->getInstance('Horde_Db_Pear')->getDb();
- $password = $db->getOne('SELECT password FROM mails.accountuser WHERE username = ?', array($user_uid . '@' . $_SERVER['SERVER_NAME']));
+ $db = $GLOBALS['injector']->getInstance('Horde_Db_Adapter');
+ $password = $db->selectValue('SELECT password FROM mails.accountuser WHERE username = ?', array($user_uid . '@' . $_SERVER['SERVER_NAME']));
$try = $GLOBALS['registry']->callByPackage('imp', 'authenticate', array($user_uid, array('password' => $password)));
if ($try) {
throw new Horde_Exception(_("Username can contain only alphanumeric characters, underscore and minus."));
}
- $_db = $GLOBALS['injector']->getInstance('Horde_Db_Pear')->getDb();
+ $db = $GLOBALS['injector']->getInstance('Horde_Db_Adapter');
$query = 'SELECT user_uid, user_email FROM folks_users WHERE user_uid = ? OR user_email = ?';
- $result = $_db->getRow($query, array($username, $info['extra']['email']), DB_FETCHMODE_ASSOC);
+ $result = $db->selectOne($query, array($username, $info['extra']['email']), DB_FETCHMODE_ASSOC);
if ($result instanceof PEAR_Error) {
throw new Horde_Exception_Prior($result);
// Here we connect to the database and update folks user table
// with additional user data and send confirmation code to check his email
- public function signup_addextra($userID, $extra)
- {
+ public function signup_addextra($userID, $extra)
+ {
global $conf;
- $_db = $GLOBALS['injector']->getInstance('Horde_Db_Pear')->getDb();
+ $db = $GLOBALS['injector']->getInstance('Horde_Db_Adapter');
$fields = array();
$values = array();
foreach ($extra as $field => $value) {
$query = 'UPDATE folks_users SET ' . implode(' = ?, ', $fields) . ' = ? '
. ' WHERE user_uid = ?';
- $result = $_db->query($query, $values);
- if ($result instanceof PEAR_Error) {
- throw new Horde_Exception_Prior($result);
- }
+ $result = $db->update($query, $values);
require_once $GLOBALS['registry']->get('fileroot', 'folks') . '/lib/Folks.php';
$code = Folks::encodeString($userID, 'activate' . hash('md5', $extra['password']));
$result = Folks::sendMail($extra['email'], _("Confirmation code"), $body);
if ($result instanceof PEAR_Error) {
- $_db->query('DELETE FROM folks_users WHERE user_uid = ?', array($userID));
+ $db->delete('DELETE FROM folks_users WHERE user_uid = ?', array($userID));
}
return $result;
- }
+ }
// This is an example of a post-push hook; it is called right after an
// application is pushed successfully onto the app stack. Here we check
+++ /dev/null
-#!@php_bin@
-<?php
-/**
- * Copyright 2007-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @package admintools
- * @author Chuck Hagenbuch <chuck@horde.org>
- */
-
-require_once dirname(__FILE__) . '/horde-base.php';
-Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true));
-
-$db_lib = 'DB';
-$sequence = null;
-
-if (isset($_SERVER['argv']) && count($_SERVER['argv']) >= 2) {
- array_shift($_SERVER['argv']);
- while ($arg = array_shift($_SERVER['argv'])) {
- if ($arg == '--mdb2') {
- $db_lib = 'MDB2';
- } else {
- $sequence = $arg;
- }
- }
-}
-if (is_null($sequence)) {
- $sequence = $cli->prompt(_("What sequence do you want to create (_seq will be added automatically)?"));
-}
-
-switch ($db_lib) {
-case 'DB':
- $dbh = $injector->getInstance('Horde_Db_Pear')->getDb();
- break;
-
-case 'MDB2':
- require_once 'MDB2.php';
- $params = $conf['sql'];
- unset($params['charset']);
- $dbh = MDB2::factory($params);
- break;
-
-default:
- throw new Horde_Exception('Unknown database abstraction library');
-}
-if (is_a($dbh, 'PEAR_Error')) {
- throw new Horde_Exception_Prior($dbh);
-}
-
-if (!preg_match('/^\w+$/', $sequence)) {
- $cli->fatal('Invalid sequence name');
-}
-
-switch ($db_lib) {
-case 'DB':
- $result = $dbh->createSequence($sequence);
- break;
-
-case 'MDB2':
- $dbh->loadModule('Manager', null, true);
- $result = $dbh->manager->createSequence($sequence);
- break;
-}
-if (is_a($result, 'PEAR_Error')) {
- $cli->fatal($result->getMessage());
-}
-
-$cli->green('Sequence created.');
-exit(0);
<contents>
<dir name="/">
<file name="horde-base.php" role="script" />
- <file name="horde-create-sequence.php" role="script">
- <tasks:replace from="@php_bin@" to="php_bin" type="pear-config"/>
- </file>
<file name="horde-remove-pref.php" role="script">
<tasks:replace from="@php_bin@" to="php_bin" type="pear-config"/>
</file>
<phprelease>
<filelist>
<install name="horde-base.php" as="horde-base.php" />
- <install name="horde-create-sequence.php" as="horde-create-sequence.php" />
<install name="horde-remove-pref.php" as="horde-remove-pref.php" />
<install name="horde-sql-shell.php" as="horde-sql-shell.php" />
</filelist>
?>
<div>
-<h1 class="header"><?php echo $title ?></h1><br />
+<h1 class="header"><?php echo $title ?></h1>
<form name="sqlshell" action="sqlshell.php" method="post">
<?php Horde_Util::pformInput() ?>
<?php
-$dbh = $injector->getInstance('Horde_Db_Pear')->getDb();
+$db = $injector->getInstance('Horde_Db_Adapter');
if (Horde_Util::getFormData('list-tables')) {
$description = 'LIST TABLES';
- $result = $dbh->getListOf('tables');
- $command = null;
-} elseif (Horde_Util::getFormData('list-dbs')) {
- $description = 'LIST DATABASES';
- $result = $dbh->getListOf('databases');
+ $result = $db->tables();
$command = null;
} elseif ($command = trim(Horde_Util::getFormData('sql'))) {
// Keep a cache of prior queries for convenience.
}
// Parse out the query results.
- $result = $dbh->query(Horde_String::convertCharset($command, $GLOBALS['registry']->getCharset(), $conf['sql']['charset']));
+ $result = $db->execute(Horde_String::convertCharset($command, $GLOBALS['registry']->getCharset(), $conf['sql']['charset']));
}
if (isset($result)) {
if ($command) {
- echo '<h1 class="header">' . _("Query") . '</h1><br /><pre class="text">' . htmlspecialchars($command) . '</pre>';
+ echo '<h1 class="header">' . _("Query") . '</h1><pre class="text">' . htmlspecialchars($command) . '</pre>';
}
- echo '<h1 class="header">' . _("Results") . '</h1><br />';
+ echo '<h1 class="header">' . _("Results") . '</h1>';
- if ($result instanceof PEAR_Error) {
- echo '<pre class="text">'; var_dump($result); echo '</pre>';
- } else {
- if (is_object($result)) {
- echo '<table cellspacing="1" class="item striped">';
- $first = true;
- $i = 0;
- while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
- if ($first) {
- echo '<tr>';
- foreach ($row as $key => $val) {
- echo '<th align="left">' . (!strlen($key) ? ' ' : htmlspecialchars(Horde_String::convertCharset($key, $conf['sql']['charset']))) . '</th>';
- }
- echo '</tr>';
- $first = false;
- }
+ if (is_object($result)) {
+ echo '<table cellspacing="1" class="item striped">';
+ $first = true;
+ $i = 0;
+ while ($row = $result->fetch()) {
+ if ($first) {
echo '<tr>';
- foreach ($row as $val) {
- echo '<td class="fixed">' . (!strlen($val) ? ' ' : htmlspecialchars(Horde_String::convertCharset($val, $conf['sql']['charset']))) . '</td>';
+ foreach ($row as $key => $val) {
+ echo '<th align="left">' . (!strlen($key) ? ' ' : htmlspecialchars(Horde_String::convertCharset($key, $conf['sql']['charset']))) . '</th>';
}
echo '</tr>';
+ $first = false;
}
- echo '</table>';
- } elseif (is_array($result)) {
- echo '<table cellspacing="1" class="item striped">';
- $first = true;
- $i = 0;
- foreach ($result as $val) {
- if ($first) {
- echo '<tr><th align="left">' . (isset($description) ? htmlspecialchars($description) : ' ') . '</th></tr>';
- $first = false;
- }
- echo '<tr><td class="fixed">' . (!strlen($val) ? ' ' : htmlspecialchars(Horde_String::convertCharset($val, $conf['sql']['charset']))) . '</td></tr>';
+ echo '<tr>';
+ foreach ($row as $val) {
+ echo '<td class="fixed">' . (!strlen($val) ? ' ' : htmlspecialchars(Horde_String::convertCharset($val, $conf['sql']['charset']))) . '</td>';
}
- echo '</table>';
- } else {
- echo '<strong>' . _("Success") . '</strong>';
+ echo '</tr>';
}
+ echo '</table>';
+ } elseif (is_array($result)) {
+ echo '<table cellspacing="1" class="item striped">';
+ $first = true;
+ $i = 0;
+ foreach ($result as $val) {
+ if ($first) {
+ echo '<tr><th align="left">' . (isset($description) ? htmlspecialchars($description) : ' ') . '</th></tr>';
+ $first = false;
+ }
+ echo '<tr><td class="fixed">' . (!strlen($val) ? ' ' : htmlspecialchars(Horde_String::convertCharset($val, $conf['sql']['charset']))) . '</td></tr>';
+ }
+ echo '</table>';
+ } else {
+ echo '<strong>' . _("Success") . '</strong>';
}
-
- echo '<br />';
}
?>
<option value="<?php echo htmlspecialchars($query) ?>"><?php echo htmlspecialchars($query) ?></option>
<?php endforeach; ?>
</select>
- <input type="button" value="<?php echo _("Paste") ?>" class="button" onclick="document.sqlshell.sql.value = document.sqlshell.query_cache[document.sqlshell.query_cache.selectedIndex].value;" />
- <input type="button" value="<?php echo _("Run") ?>" class="button" onclick="document.sqlshell.sql.value = document.sqlshell.query_cache[document.sqlshell.query_cache.selectedIndex].value; document.sqlshell.submit();" />
- <br />
+ <input type="button" value="<?php echo _("Paste") ?>" class="button" onclick="document.sqlshell.sql.value = document.sqlshell.query_cache[document.sqlshell.query_cache.selectedIndex].value;">
+ <input type="button" value="<?php echo _("Run") ?>" class="button" onclick="document.sqlshell.sql.value = document.sqlshell.query_cache[document.sqlshell.query_cache.selectedIndex].value; document.sqlshell.submit();">
<?php endif; ?>
<label for="sql" class="hidden"><?php echo ("SQL Query") ?></label>
<textarea class="fixed" id="sql" name="sql" rows="10" cols="80">
<?php if (strlen($command)) echo htmlspecialchars($command) ?></textarea>
-<br />
-<input type="submit" class="button" value="<?php echo _("Execute") ?>" />
-<input type="button" class="button" value="<?php echo _("Clear Query") ?>" onclick="document.sqlshell.sql.value=''" />
+
+<input type="submit" class="button" value="<?php echo _("Execute") ?>">
+<input type="button" class="button" value="<?php echo _("Clear Query") ?>" onclick="document.sqlshell.sql.value=''">
<?php if (strlen($command)): ?>
-<input type="reset" class="button" value="<?php echo _("Restore Last Query") ?>" />
+<input type="reset" class="button" value="<?php echo _("Restore Last Query") ?>">
<?php endif; ?>
-<?php if ($dbh->getSpecialQuery('tables') !== null): ?><input type="submit" class="button" name="list-tables" value="<?php echo _("List Tables") ?>" /> <?php endif; ?>
-<?php if ($dbh->getSpecialQuery('databases') !== null): ?><input type="submit" class="button" name="list-dbs" value="<?php echo _("List Databases") ?>" /> <?php endif; ?>
+<input type="submit" class="button" name="list-tables" value="<?php echo _("List Tables") ?>">
<?php echo Horde_Help::link('admin', 'admin-sqlshell') ?>
</form>
'path' => 'Date/Calc.php',
'error' => 'Horde requires the Date_Calc class for Kronolith to calculate dates.'
),
- 'DB' => array(
- 'error' => 'You will need DB if you are using SQL.',
- 'function' => '_checkPearDbVersion'
- ),
'HTTP_Request' => array(
'error' => 'Parts of Horde (Jonah, the XML-RPC client/server) use the HTTP_Request library to retrieve URLs and do other HTTP requests.'
),
}
/**
- * Additional check for PEAR DB module for its version.
- *
- * @return string Returns error string on error.
- */
- protected function _checkPearDbVersion()
- {
- if (!defined('DB_PORTABILITY_LOWERCASE')) {
- return 'Your version of DB is not recent enough.';
- }
- }
-
- /**
* Check the list of required files
*
* @return string The HTML output.