Merge branch 'database' into filesystem

This commit is contained in:
Robin Appelman 2011-11-26 01:25:08 +01:00
commit a8e4d2946a
19 changed files with 189 additions and 94 deletions

View File

@ -13,9 +13,7 @@
<select id="category" name="categories[]" multiple="multiple" title="<?php echo $l->t("Select category") ?>">
<?php
if (!isset($_['categories'])) {$_['categories'] = array();}
foreach($_['category_options'] as $category){
echo '<option value="' . $category . '"' . (in_array($category, $_['categories']) ? ' selected="selected"' : '') . '>' . $category . '</option>';
}
echo html_select_options($_['category_options'], $_['categories'], array('combine'=>true));
?>
</select></td>
<th width="75px">&nbsp;&nbsp;&nbsp;<?php echo $l->t("Calendar");?>:</th>
@ -23,9 +21,7 @@
<select style="width:140px;" name="calendar">
<?php
if (!isset($_['calendar'])) {$_['calendar'] = false;}
foreach($_['calendar_options'] as $calendar){
echo '<option value="' . $calendar['id'] . '"' . ($_['calendar'] == $calendar['id'] ? ' selected="selected"' : '') . '>' . $calendar['displayname'] . '</option>';
}
echo html_select_options($_['calendar_options'], $_['calendar'], array('value'=>'id', 'label'=>'displayname'));
?>
</select></td>
</tr>
@ -66,9 +62,7 @@
<select name="repeat" style="width:350px;">
<?php
if (isset($_['repeat_options'])) {
foreach($_['repeat_options'] as $id => $label){
echo '<option value="' . $id . '"' . ($_['repeat'] == $id ? ' selected="selected"' : '') . '>' . $label . '</option>';
}
echo html_select_options($_['repeat_options'], $_['repeat']);
}
?>
</select></td>

View File

@ -51,10 +51,22 @@ if(is_null($vcard)){
exit();
}
$property_types = array(
'ADR' => $l10n->t('Address'),
'TEL' => $l10n->t('Telephone'),
'EMAIL' => $l10n->t('Email'),
'ORG' => $l10n->t('Organization'),
);
$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
$details = OC_Contacts_VCard::structureContact($vcard);
$tmpl = new OC_Template('contacts','part.details');
$tmpl->assign('details',$details);
$tmpl->assign('id',$id);
$tmpl->assign('property_types',$property_types);
$tmpl->assign('adr_types',$adr_types);
$tmpl->assign('phone_types',$phone_types);
$page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page )));

View File

@ -29,9 +29,14 @@ $l10n = new OC_L10N('contacts');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
$addressbooks = OC_Contacts_Addressbook::all(OC_USER::getUser());
$tmpl = new OC_Template('contacts','part.addcardform');
$tmpl->assign('addressbooks',$addressbooks);
$tmpl->assign('adr_types',$adr_types);
$tmpl->assign('phone_types',$phone_types);
$page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'page' => $page )));

View File

@ -61,11 +61,13 @@ if(is_null($line)){
exit();
}
$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
$tmpl = new OC_Template('contacts','part.setpropertyform');
$tmpl->assign('id',$id);
$tmpl->assign('checksum',$checksum);
$tmpl->assign('property',OC_Contacts_VCard::structureProperty($vcard->children[$line]));
$tmpl->assign('adr_types',$adr_types);
$page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'page' => $page )));

View File

@ -4,9 +4,9 @@
#contacts_deletecard {position:absolute;top:15px;right:0;}
#contacts_details_list { list-style:none; }
#contacts_details_list li { overflow:hidden; }
#contacts_details_list li p.contacts_property_name { width:25%; float:left;text-align:right;padding-right:0.3em; }
#contacts_details_list li p.contacts_property_name { width:25%; float:left;text-align:right;padding-right:0.3em;color:#666; }
#contacts_details_list li p.contacts_property_data, #contacts_details_list li ul.contacts_property_data { width:72%; overflow:hidden; }
#contacts_addproperty, #contacts_addproperty_button { margin-left:25%; }
#contacts_addproperty_button, #contacts_setproperty_button { margin-left:25%; }
.contacts_property_data ul, .contacts_property_data ol { list-style:none; }
.contacts_property_data li { overflow: hidden; }

View File

@ -56,13 +56,13 @@ $(document).ready(function(){
$('#contacts_addpropertyform #contacts_fieldpart').remove();
$('#contacts_addpropertyform #contacts_generic').remove();
if($(this).val() == 'ADR'){
$('#contacts_addresspart').clone().insertBefore($('#contacts_addpropertyform input[type="submit"]'));
$('#contacts_addresspart').clone().insertAfter($('#contacts_addpropertyform .contacts_property_name'));
}
else if($(this).val() == 'TEL'){
$('#contacts_phonepart').clone().insertBefore($('#contacts_addpropertyform input[type="submit"]'));
$('#contacts_phonepart').clone().insertAfter($('#contacts_addpropertyform .contacts_property_name'));
}
else{
$('#contacts_generic').clone().insertBefore($('#contacts_addpropertyform input[type="submit"]'));
$('#contacts_generic').clone().insertAfter($('#contacts_addpropertyform .contacts_property_name'));
}
});

View File

@ -95,10 +95,15 @@ class OC_Contacts_VCard{
$card = self::parse($data);
if(!is_null($card)){
// VCARD must have a version
$hasversion = false;
foreach($card->children as $property){
if($property->name == 'FN'){
$fn = $property->value;
}
elseif($property->name == 'VERSION'){
$hasversion = true;
}
elseif(is_null($uri) && $property->name == 'UID' ){
$uri = $property->value.'.vcf';
}
@ -109,6 +114,11 @@ class OC_Contacts_VCard{
$card->add(new Sabre_VObject_Property('UID',$uid));
$data = $card->serialize();
};
// Add version if needed
if(!$hasversion){
$card->add(new Sabre_VObject_Property('VERSION','3.0'));
$data = $card->serialize();
}
}
else{
// that's hard. Creating a UID and not saving it
@ -362,4 +372,24 @@ class OC_Contacts_VCard{
return null;
}
}
public static function getTypesOfProperty($l, $prop){
switch($prop){
case 'ADR':
return array(
'WORK' => $l->t('Work'),
'HOME' => $l->t('Home'),
);
case 'TEL':
return array(
'HOME' => $l->t('Home'),
'CELL' => $l->t('Mobile'),
'WORK' => $l->t('Work'),
'TEXT' => $l->t('Text'),
'VOICE' => $l->t('Voice'),
'FAX' => $l->t('Fax'),
'VIDEO' => $l->t('Video'),
'PAGER' => $l->t('Pager'),
);
}
}
}

View File

@ -7,9 +7,7 @@
<li class="input stringish">
<label class="label" for="id"><?php echo $l->t('Group'); ?></label>
<select name="id" size="1">
<?php foreach($_['addressbooks'] as $addressbook): ?>
<option value="<?php echo $addressbook['id']; ?>"><?php echo $addressbook['displayname']; ?></option>
<?php endforeach; ?>
<?php echo html_select_options($_['addressbooks'], null, array('value'=>'id', 'label'=>'displayname')); ?>
</select>
</li>
</ol>
@ -46,14 +44,7 @@
<li class="fragment">
<label for="tel_type"><?php echo $l->t('Type'); ?></label>
<select id="TEL" name="parameters[TEL][TYPE]" size="1">
<option value="home"><?php echo $l->t('Home'); ?></option>
<option value="cell" selected="selected"><?php echo $l->t('Mobile'); ?></option>
<option value="work"><?php echo $l->t('Work'); ?></option>
<option value="text"><?php echo $l->t('Text'); ?></option>
<option value="voice"><?php echo $l->t('Voice'); ?></option>
<option value="fax"><?php echo $l->t('Fax'); ?></option>
<option value="video"><?php echo $l->t('Video'); ?></option>
<option value="pager"><?php echo $l->t('Pager'); ?></option>
<?php echo html_select_options($_['phone_types'], 'CELL') ?>
</select>
</li>
</ol>
@ -67,8 +58,7 @@
<li class="input">
<label class="label" for="adr_type"><?php echo $l->t('Type'); ?></label>
<select id="adr_type" name="parameters[ADR][TYPE]" size="1">
<option value="work"><?php echo $l->t('Work'); ?></option>
<option value="home" selected="selected"><?php echo $l->t('Home'); ?></option>
<?php echo html_select_options($_['adr_types'], 'HOME') ?>
</select>
</li>
<li class="input stringish">

View File

@ -27,15 +27,13 @@
<input type="hidden" name="id" value="<?php echo $_['id']; ?>">
<p class="contacts_property_name">
<select name="name" size="1">
<option value="ADR"><?php echo $l->t('Address'); ?></option>
<option value="TEL"><?php echo $l->t('Telephone'); ?></option>
<option value="EMAIL" selected="selected"><?php echo $l->t('Email'); ?></option>
<option value="ORG"><?php echo $l->t('Organization'); ?></option>
<?php echo html_select_options($_['property_types'], 'EMAIL') ?>
</select>
</p>
<p class="contacts_property_data" id="contacts_generic">
<input type="text" name="value" value="">
</p><br>
</p>
<br>
<input id="contacts_addproperty_button" type="submit" value="<?php echo $l->t('Add'); ?>">
</form>
<div id="contacts_addcontactsparts" style="display:none;">
@ -43,8 +41,7 @@
<li>
<label for="adr_type"><?php echo $l->t('Type'); ?></label>
<select id="adr_type" name="parameters[TYPE]" size="1">
<option value="work"><?php echo $l->t('Work'); ?></option>
<option value="home" selected="selected"><?php echo $l->t('Home'); ?></option>
<?php echo html_select_options($_['adr_types'], 'HOME') ?>
</select>
</li>
<li>
@ -79,14 +76,7 @@
<p class="contacts_property_data" id="contacts_phonepart">
<input type="text" name="value" value="">
<select name="parameters[TYPE]" size="1">
<option value="home"><?php echo $l->t('Home'); ?></option>
<option value="cell" selected="selected"><?php echo $l->t('Mobile'); ?></option>
<option value="work"><?php echo $l->t('Work'); ?></option>
<option value="text"><?php echo $l->t('Text'); ?></option>
<option value="voice"><?php echo $l->t('Voice'); ?></option>
<option value="fax"><?php echo $l->t('Fax'); ?></option>
<option value="video"><?php echo $l->t('Video'); ?></option>
<option value="pager"><?php echo $l->t('Pager'); ?></option>
<?php echo html_select_options($_['phone_types'], 'CELL') ?>
</select>
</p>
<p class="contacts_property_data" id="contacts_generic">

View File

@ -5,6 +5,12 @@
<?php if($_['property']['name']=='ADR'): ?>
<p class="contacts_property_name"><label for="adr_pobox"><?php echo $l->t('Address'); ?></label></p>
<ol class="contacts_property_data" id="contacts_addresspart">
<li class="input">
<label class="label" for="adr_type"><?php echo $l->t('Type'); ?></label>
<select id="adr_type" name="parameters[TYPE]" size="1">
<?php echo html_select_options($_['adr_types'], strtoupper($_['property']['parameters']['TYPE'])) ?>
</select>
</li>
<li>
<label for="adr_pobox"><?php echo $l->t('PO Box'); ?></label>
<input id="adr_pobox" type="text" name="value[0]" value="<?php echo $_['property']['value'][0] ?>">

View File

@ -89,6 +89,10 @@ $upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'
$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
$maxUploadFilesize = min($upload_max_filesize, $post_max_size);
$freeSpace=OC_Filesystem::free_space('/');
$freeSpace=max($freeSpace,0);
$maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
$tmpl = new OC_Template( "files", "index", "user" );
$tmpl->assign( "fileList", $list->fetchPage() );
$tmpl->assign( "breadcrumb", $breadcrumbNav->fetchPage() );

View File

@ -168,9 +168,6 @@ class MDB2_Driver_Manager_sqlite3 extends MDB2_Driver_Manager_Common
if (PEAR::isError($query_fields)) {
return $query_fields;
}
if (!empty($options['primary'])) {
$query_fields.= ', PRIMARY KEY ('.implode(', ', array_keys($options['primary'])).')';
}
if (!empty($options['foreign_keys'])) {
foreach ($options['foreign_keys'] as $fkname => $fkdef) {
if (empty($fkdef)) {
@ -534,9 +531,26 @@ class MDB2_Driver_Manager_sqlite3 extends MDB2_Driver_Manager_Common
return MDB2_OK;
}
if (empty($changes['remove']) and empty($changes['rename']) and empty($changes['change']) ){//if only rename or add changes are required, we can use ALTER TABLE
$query = '';
if (!empty($changes['name'])) {
$change_name = $db->quoteIdentifier($changes['name'], true);
$query = 'RENAME TO ' . $change_name;
$db->exec("ALTER TABLE $name $query");
}
if (!empty($changes['add']) && is_array($changes['add'])) {
foreach ($changes['add'] as $field_name => $field) {
$query= 'ADD ' . $db->getDeclaration($field['type'], $field_name, $field);
$db->exec("ALTER TABLE $name $query");
}
}
return MDB2_OK;
}
$db->loadModule('Reverse', null, true);
// actually sqlite 2.x supports no ALTER TABLE at all .. so we emulate it
// for other operations we need to emulate them with sqlite3
$fields = $db->manager->listTableFields($name);
if (PEAR::isError($fields)) {
return $fields;
@ -636,44 +650,54 @@ class MDB2_Driver_Manager_sqlite3 extends MDB2_Driver_Manager_Common
}
}
//rename the old table so we can create the new one
$db->exec("ALTER TABLE $name RENAME TO __$name");
$data = null;
if (!empty($select_fields)) {
$query = 'SELECT '.implode(', ', $select_fields).' FROM '.$db->quoteIdentifier($name, true);
$data = $db->queryAll($query, null, MDB2_FETCHMODE_ORDERED);
}
$result = $this->dropTable($name);
if (PEAR::isError($result)) {
return $result;
}
$result = $this->createTable($name_new, $fields, $options);
if (PEAR::isError($result)) {
return $result;
}
foreach ($indexes as $index => $definition) {
$this->createIndex($name_new, $index, $definition);
//these seem to only give errors
// foreach ($indexes as $index => $definition) {
// $this->createIndex($name_new, $index, $definition);
// }
// foreach ($constraints as $constraint => $definition) {
// $this->createConstraint($name_new, $constraint, $definition);
// }
//fill the new table with data from the old one
if (!empty($select_fields)) {
$query = 'INSERT INTO '.$db->quoteIdentifier($name_new, true);
$query.= '('.implode(', ', array_slice(array_keys($fields), 0, count($select_fields))).')';
$query .= ' SELECT '.implode(', ', $select_fields).' FROM '.$db->quoteIdentifier('__'.$name, true);
$db->exec($query);
}
foreach ($constraints as $constraint => $definition) {
$this->createConstraint($name_new, $constraint, $definition);
}
// if (!empty($select_fields) && !empty($data)) {
// $query = 'INSERT INTO '.$db->quoteIdentifier($name_new, true);
// $query.= '('.implode(', ', array_slice(array_keys($fields), 0, count($select_fields))).')';
// $query.=' VALUES (?'.str_repeat(', ?', (count($select_fields) - 1)).')';
// $stmt =$db->prepare($query, null, MDB2_PREPARE_MANIP);
// if (PEAR::isError($stmt)) {
// return $stmt;
// }
// foreach ($data as $row) {
// $result = $stmt->execute($row);
// if (PEAR::isError($result)) {
// return $result;
// }
// }
// }
if (!empty($select_fields) && !empty($data)) {
$query = 'INSERT INTO '.$db->quoteIdentifier($name_new, true);
$query.= '('.implode(', ', array_slice(array_keys($fields), 0, count($select_fields))).')';
$query.=' VALUES (?'.str_repeat(', ?', (count($select_fields) - 1)).')';
$stmt =$db->prepare($query, null, MDB2_PREPARE_MANIP);
if (PEAR::isError($stmt)) {
return $stmt;
}
foreach ($data as $row) {
$result = $stmt->execute($row);
if (PEAR::isError($result)) {
return $result;
}
}
//remove the old table
$result = $this->dropTable('__'.$name);
if (PEAR::isError($result)) {
return $result;
}
return MDB2_OK;
}
@ -798,7 +822,7 @@ class MDB2_Driver_Manager_sqlite3 extends MDB2_Driver_Manager_Common
return $db;
}
$query = "SELECT name FROM sqlite_master WHERE type='table' AND sql NOT NULL ORDER BY name";
$query = "SELECT name FROM sqlite_master WHERE type='table' AND sql NOT NULL AND name!='sqlite_sequence' ORDER BY name";
$table_names = $db->queryCol($query);
if (PEAR::isError($table_names)) {
return $table_names;

View File

@ -69,7 +69,7 @@ class MDB2_Driver_Reverse_sqlite3 extends MDB2_Driver_Reverse_Common
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'unexpected empty table column definition list', __FUNCTION__);
}
$regexp = '/^\s*([^\s]+) +(CHAR|VARCHAR|VARCHAR2|TEXT|BOOLEAN|SMALLINT|INT|INTEGER|DECIMAL|BIGINT|DOUBLE|FLOAT|DATETIME|DATE|TIME|LONGTEXT|LONGBLOB)( ?\(([1-9][0-9]*)(:([1-9][0-9]*))?\))?( NULL| NOT NULL)?( UNSIGNED)?( NULL| NOT NULL)?( PRIMARY KEY)?( DEFAULT (\'[^\']*\'|[^ ]+))?( NULL| NOT NULL)?( PRIMARY KEY)?(\s*\-\-.*)?$/i';
$regexp = '/^\s*([^\s]+) +(CHAR|VARCHAR|VARCHAR2|TEXT|BOOLEAN|SMALLINT|INT|INTEGER|DECIMAL|BIGINT|DOUBLE|FLOAT|DATETIME|DATE|TIME|LONGTEXT|LONGBLOB)( ?\(([1-9][0-9]*)(:([1-9][0-9]*))?\))?( NULL| NOT NULL)?( UNSIGNED)?( NULL| NOT NULL)?( PRIMARY KEY)?( AUTOINCREMENT)?( DEFAULT (\'[^\']*\'|[^ ]+))?( NULL| NOT NULL)?( PRIMARY KEY)?(\s*\-\-.*)?$/i';
$regexp2 = '/^\s*([^ ]+) +(PRIMARY|UNIQUE|CHECK)$/i';
for ($i=0, $j=0; $i<$count; ++$i) {
if (!preg_match($regexp, trim($column_sql[$i]), $matches)) {
@ -90,11 +90,16 @@ class MDB2_Driver_Reverse_sqlite3 extends MDB2_Driver_Reverse_Common
if (isset($matches[8]) && strlen($matches[8])) {
$columns[$j]['unsigned'] = true;
}
if (isset($matches[9]) && strlen($matches[9])) {
if (isset($matches[10]) && strlen($matches[10])) {
$columns[$j]['autoincrement'] = true;
$columns[$j]['notnull']=true;
}
if (isset($matches[12]) && strlen($matches[12])) {
$default = $matches[12];
if (isset($matches[10]) && strlen($matches[10])) {
$columns[$j]['autoincrement'] = true;
$columns[$j]['notnull']=true;
}
if (isset($matches[13]) && strlen($matches[13])) {
$default = $matches[13];
if (strlen($default) && $default[0]=="'") {
$default = str_replace("''", "'", substr($default, 1, strlen($default)-2));
}
@ -107,8 +112,8 @@ class MDB2_Driver_Reverse_sqlite3 extends MDB2_Driver_Reverse_Common
$columns[$j]['notnull'] = ($matches[7] === ' NOT NULL');
} else if (isset($matches[9]) && strlen($matches[9])) {
$columns[$j]['notnull'] = ($matches[9] === ' NOT NULL');
} else if (isset($matches[13]) && strlen($matches[13])) {
$columns[$j]['notnull'] = ($matches[13] === ' NOT NULL');
} else if (isset($matches[14]) && strlen($matches[14])) {
$columns[$j]['notnull'] = ($matches[14] === ' NOT NULL');
}
++$j;
}

View File

@ -100,11 +100,11 @@ class OC_App{
}
/**
* @brief enables an app
* @brief disables an app
* @param $app app
* @returns true/false
*
* This function set an app as enabled in appconfig.
* This function set an app as disabled in appconfig.
*/
public static function disable( $app ){
OC_Appconfig::setValue( $app, 'enabled', 'no' );

View File

@ -119,6 +119,13 @@ class OC{
}
}
$installedVersion=OC_Config::getValue('version','0.0.0');
$currentVersion=implode('.',OC_Util::getVersion());
if (version_compare($currentVersion, $installedVersion, '>')) {
OC_DB::updateDbFromStructure('../db_structure.xml');
OC_Config::setValue('version',implode('.',OC_Util::getVersion()));
}
ini_set('session.cookie_httponly','1;');
session_start();
@ -184,8 +191,6 @@ if( !isset( $RUNTIME_NOAPPS )){
$RUNTIME_NOAPPS = false;
}
OC::init();
if(!function_exists('get_temp_dir')) {
function get_temp_dir() {
if( $temp=ini_get('upload_tmp_dir') ) return $temp;
@ -201,6 +206,8 @@ if(!function_exists('get_temp_dir')) {
}
}
OC::init();
require_once('fakedirstream.php');
// FROM search.php

View File

@ -338,7 +338,6 @@ class OC_DB {
* @param $file file to read structure from
*/
public static function updateDbFromStructure($file){
$CONFIG_DBNAME = OC_Config::getValue( "dbname", "owncloud" );
$CONFIG_DBTABLEPREFIX = OC_Config::getValue( "dbtableprefix", "oc_" );
$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
@ -347,17 +346,17 @@ class OC_DB {
// read file
$content = file_get_contents( $file );
$previousSchema = self::$schema->getDefinitionFromDatabase();
// Make changes and save them to a temporary file
$file2 = tempnam( get_temp_dir(), 'oc_db_scheme_' );
$content = str_replace( '*dbname*', $CONFIG_DBNAME, $content );
$content = str_replace( '*dbname*', $previousSchema['name'], $content );
$content = str_replace( '*dbprefix*', $CONFIG_DBTABLEPREFIX, $content );
if( $CONFIG_DBTYPE == 'pgsql' ){ //mysql support it too but sqlite doesn't
$content = str_replace( '<default>0000-00-00 00:00:00</default>', '<default>CURRENT_TIMESTAMP</default>', $content );
}
file_put_contents( $file2, $content );
$previousSchema = self::$schema->getDefinitionFromDatabase();
$op = $schema->updateDatabase($file2, $previousSchema, array(), false);
$op = self::$schema->updateDatabase($file2, $previousSchema, array(), false);
if (PEAR::isError($op)) {
$error = $op->getMessage();
OC_Log::write('core','Failed to update database structure ('.$error.')',OC_Log::FATAL);

View File

@ -20,7 +20,7 @@ class OC_Hook{
* TODO: write example
*/
static public function connect( $signalclass, $signalname, $slotclass, $slotname ){
// Cerate the data structure
// Create the data structure
if( !array_key_exists( $signalclass, self::$registered )){
self::$registered[$signalclass] = array();
}

View File

@ -158,8 +158,8 @@ class OC_Setup {
//add prefix to the postgresql user name to prevent collissions
$dbusername='oc_'.$username;
//hash the password so we don't need to store the admin config in the config file
$dbpassword=md5(time().$password);
//create a new password so we don't need to store the admin config in the config file
$dbpassword=md5(time());
self::pg_createDBUser($dbusername, $dbpassword, $connection);
@ -219,7 +219,7 @@ class OC_Setup {
}
public static function createDatabase($name,$user,$connection) {
//we cant user OC_BD functions here because we need to connect as the administrative user.
//we cant use OC_BD functions here because we need to connect as the administrative user.
$query = "CREATE DATABASE IF NOT EXISTS `$name`";
$result = mysql_query($query, $connection);
if(!$result) {
@ -241,7 +241,7 @@ class OC_Setup {
}
public static function pg_createDatabase($name,$user,$connection) {
//we cant user OC_BD functions here because we need to connect as the administrative user.
//we cant use OC_BD functions here because we need to connect as the administrative user.
$query = "CREATE DATABASE $name OWNER $user";
$result = pg_query($connection, $query);
if(!$result) {

View File

@ -98,6 +98,33 @@ function relative_modified_date($timestamp) {
else { return $l->t('years ago'); }
}
function html_select_options($options, $selected, $params=array()) {
if (!is_array($selected)){
$selected=array($selected);
}
if (isset($params['combine']) && $params['combine']){
$options = array_combine($options, $options);
}
$value_name = $label_name = false;
if (isset($params['value'])){
$value_name = $params['value'];
}
if (isset($params['label'])){
$label_name = $params['label'];
}
$html = '';
foreach($options as $value => $label){
if ($value_name && is_array($label)){
$value = $label[$value_name];
}
if ($label_name && is_array($label)){
$label = $label[$label_name];
}
$select = in_array($value, $selected) ? ' selected="selected"' : '';
$html .= '<option value="' . $value . '"' . $select . '>' . $label . '</option>';
}
return $html;
}
/**
* This class provides the templates for owncloud.