Merged branch 'master'
|
@ -19,10 +19,12 @@ _darcs/*
|
|||
CVS/*
|
||||
.svn/*
|
||||
RCS/*
|
||||
*.backup*
|
||||
|
||||
# kdevelop
|
||||
.kdev
|
||||
*.kdev4
|
||||
*.kate-swp
|
||||
|
||||
# Lokalize
|
||||
*lokalize*
|
||||
|
|
182
.tx/config
|
@ -1,182 +0,0 @@
|
|||
[main]
|
||||
host = https://www.transifex.net
|
||||
|
||||
[owncloud.core]
|
||||
file_filter = l10n/<lang>/core.po
|
||||
host = http://www.transifex.net
|
||||
source_file = l10n/templates/core.pot
|
||||
source_lang = en
|
||||
trans.bg_BG = l10n/bg_BG/core.po
|
||||
trans.ca = l10n/ca/core.po
|
||||
trans.cs_CZ = l10n/cs_CZ/core.po
|
||||
trans.da = l10n/da/core.po
|
||||
trans.de = l10n/de/core.po
|
||||
trans.el = l10n/el/core.po
|
||||
trans.es = l10n/es/core.po
|
||||
trans.et_EE = l10n/et_EE/core.po
|
||||
trans.fr = l10n/fr/core.po
|
||||
trans.id = l10n/id/core.po
|
||||
trans.it = l10n/it/core.po
|
||||
trans.lb = l10n/lb/core.po
|
||||
trans.ms_MY = l10n/ms_MY/core.po
|
||||
trans.nb_NO = l10n/nb_NO/core.po
|
||||
trans.nl = l10n/nl/core.po
|
||||
trans.pl = l10n/pl/core.po
|
||||
trans.pt_BR = l10n/pt_BR/core.po
|
||||
trans.pt_PT = l10n/pt_PT/core.po
|
||||
trans.ro = l10n/ro/core.po
|
||||
trans.ru = l10n/ru/core.po
|
||||
trans.sr = l10n/sr/core.po
|
||||
trans.sr@latin = l10n/sr@latin/core.po
|
||||
trans.sv = l10n/sv/core.po
|
||||
trans.zh_CN = l10n/zh_CN/core.po
|
||||
|
||||
[owncloud.settings]
|
||||
file_filter = l10n/<lang>/settings.po
|
||||
host = http://www.transifex.net
|
||||
source_file = l10n/templates/settings.pot
|
||||
source_lang = en
|
||||
trans.bg_BG = l10n/bg_BG/settings.po
|
||||
trans.ca = l10n/ca/settings.po
|
||||
trans.cs_CZ = l10n/cs_CZ/settings.po
|
||||
trans.da = l10n/da/settings.po
|
||||
trans.de = l10n/de/settings.po
|
||||
trans.el = l10n/el/settings.po
|
||||
trans.es = l10n/es/settings.po
|
||||
trans.et_EE = l10n/et_EE/settings.po
|
||||
trans.fr = l10n/fr/settings.po
|
||||
trans.id = l10n/id/settings.po
|
||||
trans.it = l10n/it/settings.po
|
||||
trans.lb = l10n/lb/settings.po
|
||||
trans.ms_MY = l10n/ms_MY/settings.po
|
||||
trans.nb_NO = l10n/nb_NO/settings.po
|
||||
trans.nl = l10n/nl/settings.po
|
||||
trans.pl = l10n/pl/settings.po
|
||||
trans.pt_BR = l10n/pt_BR/settings.po
|
||||
trans.pt_PT = l10n/pt_PT/settings.po
|
||||
trans.ro = l10n/ro/settings.po
|
||||
trans.ru = l10n/ru/settings.po
|
||||
trans.sr = l10n/sr/settings.po
|
||||
trans.sr@latin = l10n/sr@latin/settings.po
|
||||
trans.sv = l10n/sv/settings.po
|
||||
trans.zh_CN = l10n/zh_CN/settings.po
|
||||
|
||||
[owncloud.files]
|
||||
file_filter = translations/owncloud.files/<lang>.po
|
||||
host = http://www.transifex.net
|
||||
source_file = l10n/templates/files.pot
|
||||
source_lang = en
|
||||
trans.bg_BG = l10n/bg_BG/files.po
|
||||
trans.ca = l10n/ca/files.po
|
||||
trans.cs_CZ = l10n/cs_CZ/files.po
|
||||
trans.da = l10n/da/files.po
|
||||
trans.de = l10n/de/files.po
|
||||
trans.el = l10n/el/files.po
|
||||
trans.es = l10n/es/files.po
|
||||
trans.et_EE = l10n/et_EE/files.po
|
||||
trans.fr = l10n/fr/files.po
|
||||
trans.id = l10n/id/files.po
|
||||
trans.it = l10n/it/files.po
|
||||
trans.lb = l10n/lb/files.po
|
||||
trans.ms_MY = l10n/ms_MY/files.po
|
||||
trans.nb_NO = l10n/nb_NO/files.po
|
||||
trans.nl = l10n/nl/files.po
|
||||
trans.pl = l10n/pl/files.po
|
||||
trans.pt_BR = l10n/pt_BR/files.po
|
||||
trans.pt_PT = l10n/pt_PT/files.po
|
||||
trans.ro = l10n/ro/files.po
|
||||
trans.ru = l10n/ru/files.po
|
||||
trans.sr = l10n/sr/files.po
|
||||
trans.sr@latin = l10n/sr@latin/files.po
|
||||
trans.sv = l10n/sv/files.po
|
||||
trans.zh_CN = l10n/zh_CN/files.po
|
||||
|
||||
[owncloud.media]
|
||||
file_filter = translations/owncloud.media/<lang>.po
|
||||
host = http://www.transifex.net
|
||||
source_file = l10n/templates/media.pot
|
||||
source_lang = en
|
||||
trans.bg_BG = l10n/bg_BG/media.po
|
||||
trans.ca = l10n/ca/media.po
|
||||
trans.cs_CZ = l10n/cs_CZ/media.po
|
||||
trans.da = l10n/da/media.po
|
||||
trans.de = l10n/de/media.po
|
||||
trans.el = l10n/el/media.po
|
||||
trans.es = l10n/es/media.po
|
||||
trans.et_EE = l10n/et_EE/media.po
|
||||
trans.fr = l10n/fr/media.po
|
||||
trans.id = l10n/id/media.po
|
||||
trans.it = l10n/it/media.po
|
||||
trans.lb = l10n/lb/media.po
|
||||
trans.ms_MY = l10n/ms_MY/media.po
|
||||
trans.nb_NO = l10n/nb_NO/media.po
|
||||
trans.nl = l10n/nl/media.po
|
||||
trans.pl = l10n/pl/media.po
|
||||
trans.pt_BR = l10n/pt_BR/media.po
|
||||
trans.pt_PT = l10n/pt_PT/media.po
|
||||
trans.ro = l10n/ro/media.po
|
||||
trans.ru = l10n/ru/media.po
|
||||
trans.sr = l10n/sr/media.po
|
||||
trans.sr@latin = l10n/sr@latin/media.po
|
||||
trans.sv = l10n/sv/media.po
|
||||
trans.zh_CN = l10n/zh_CN/media.po
|
||||
|
||||
[owncloud.calendar]
|
||||
file_filter = l10n/<lang>/calendar.po
|
||||
host = http://www.transifex.net
|
||||
source_file = l10n/templates/calendar.pot
|
||||
source_lang = en
|
||||
trans.bg_BG = l10n/bg_BG/calendar.po
|
||||
trans.ca = l10n/ca/calendar.po
|
||||
trans.cs_CZ = l10n/cs_CZ/calendar.po
|
||||
trans.da = l10n/da/calendar.po
|
||||
trans.de = l10n/de/calendar.po
|
||||
trans.el = l10n/el/calendar.po
|
||||
trans.es = l10n/es/calendar.po
|
||||
trans.et_EE = l10n/et_EE/calendar.po
|
||||
trans.fr = l10n/fr/calendar.po
|
||||
trans.id = l10n/id/calendar.po
|
||||
trans.it = l10n/it/calendar.po
|
||||
trans.lb = l10n/lb/calendar.po
|
||||
trans.ms_MY = l10n/ms_MY/calendar.po
|
||||
trans.nb_NO = l10n/nb_NO/calendar.po
|
||||
trans.nl = l10n/nl/calendar.po
|
||||
trans.pl = l10n/pl/calendar.po
|
||||
trans.pt_BR = l10n/pt_BR/calendar.po
|
||||
trans.pt_PT = l10n/pt_PT/calendar.po
|
||||
trans.ro = l10n/ro/calendar.po
|
||||
trans.ru = l10n/ru/calendar.po
|
||||
trans.sr = l10n/sr/calendar.po
|
||||
trans.sr@latin = l10n/sr@latin/calendar.po
|
||||
trans.sv = l10n/sv/calendar.po
|
||||
trans.zh_CN = l10n/zh_CN/calendar.po
|
||||
|
||||
[owncloud.contacts]
|
||||
file_filter = translations/owncloud.contacts/<lang>.po
|
||||
host = http://www.transifex.net
|
||||
source_file = l10n/templates/contacts.pot
|
||||
source_lang = en
|
||||
trans.bg_BG = l10n/bg_BG/contacts.po
|
||||
trans.ca = l10n/ca/contacts.po
|
||||
trans.cs_CZ = l10n/cs_CZ/contacts.po
|
||||
trans.da = l10n/da/contacts.po
|
||||
trans.de = l10n/de/contacts.po
|
||||
trans.el = l10n/el/contacts.po
|
||||
trans.es = l10n/es/contacts.po
|
||||
trans.et_EE = l10n/et_EE/contacts.po
|
||||
trans.fr = l10n/fr/contacts.po
|
||||
trans.id = l10n/id/contacts.po
|
||||
trans.it = l10n/it/contacts.po
|
||||
trans.lb = l10n/lb/contacts.po
|
||||
trans.ms_MY = l10n/ms_MY/contacts.po
|
||||
trans.nb_NO = l10n/nb_NO/contacts.po
|
||||
trans.nl = l10n/nl/contacts.po
|
||||
trans.pl = l10n/pl/contacts.po
|
||||
trans.pt_BR = l10n/pt_BR/contacts.po
|
||||
trans.pt_PT = l10n/pt_PT/contacts.po
|
||||
trans.ro = l10n/ro/contacts.po
|
||||
trans.ru = l10n/ru/contacts.po
|
||||
trans.sr = l10n/sr/contacts.po
|
||||
trans.sr@latin = l10n/sr@latin/contacts.po
|
||||
trans.sv = l10n/sv/contacts.po
|
||||
trans.zh_CN = l10n/zh_CN/contacts.po
|
|
@ -35,7 +35,7 @@
|
|||
* @author Vincent Blavet <vincent@phpconcept.net>
|
||||
* @copyright 1997-2010 The Authors
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @version CVS: $Id: Tar.php 323476 2012-02-24 15:27:26Z mrook $
|
||||
* @version CVS: $Id: Tar.php 324840 2012-04-05 08:44:41Z mrook $
|
||||
* @link http://pear.php.net/package/Archive_Tar
|
||||
*/
|
||||
|
||||
|
@ -50,7 +50,7 @@ define('ARCHIVE_TAR_END_BLOCK', pack("a512", ''));
|
|||
* @package Archive_Tar
|
||||
* @author Vincent Blavet <vincent@phpconcept.net>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @version $Revision: 323476 $
|
||||
* @version $Revision: 324840 $
|
||||
*/
|
||||
class Archive_Tar extends PEAR
|
||||
{
|
||||
|
@ -577,7 +577,7 @@ class Archive_Tar extends PEAR
|
|||
}
|
||||
|
||||
// ----- Get the arguments
|
||||
$v_att_list = func_get_args();
|
||||
$v_att_list = &func_get_args();
|
||||
|
||||
// ----- Read the attributes
|
||||
$i=0;
|
||||
|
@ -649,14 +649,14 @@ class Archive_Tar extends PEAR
|
|||
// {{{ _error()
|
||||
function _error($p_message)
|
||||
{
|
||||
$this->error_object = $this->raiseError($p_message);
|
||||
$this->error_object = &$this->raiseError($p_message);
|
||||
}
|
||||
// }}}
|
||||
|
||||
// {{{ _warning()
|
||||
function _warning($p_message)
|
||||
{
|
||||
$this->error_object = $this->raiseError($p_message);
|
||||
$this->error_object = &$this->raiseError($p_message);
|
||||
}
|
||||
// }}}
|
||||
|
||||
|
@ -981,7 +981,7 @@ class Archive_Tar extends PEAR
|
|||
// }}}
|
||||
|
||||
// {{{ _addFile()
|
||||
function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir,$v_stored_filename=null)
|
||||
function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $v_stored_filename=null)
|
||||
{
|
||||
if (!$this->_file) {
|
||||
$this->_error('Invalid file descriptor');
|
||||
|
@ -992,31 +992,32 @@ class Archive_Tar extends PEAR
|
|||
$this->_error('Invalid file name');
|
||||
return false;
|
||||
}
|
||||
if(is_null($v_stored_filename)){
|
||||
|
||||
// ----- Calculate the stored filename
|
||||
$p_filename = $this->_translateWinPath($p_filename, false);
|
||||
$v_stored_filename = $p_filename;
|
||||
if (strcmp($p_filename, $p_remove_dir) == 0) {
|
||||
return true;
|
||||
}
|
||||
if ($p_remove_dir != '') {
|
||||
if (substr($p_remove_dir, -1) != '/')
|
||||
$p_remove_dir .= '/';
|
||||
// ownCloud change to make it possible to specify the filename to use
|
||||
if(is_null($v_stored_filename)) {
|
||||
// ----- Calculate the stored filename
|
||||
$p_filename = $this->_translateWinPath($p_filename, false);
|
||||
$v_stored_filename = $p_filename;
|
||||
if (strcmp($p_filename, $p_remove_dir) == 0) {
|
||||
return true;
|
||||
}
|
||||
if ($p_remove_dir != '') {
|
||||
if (substr($p_remove_dir, -1) != '/')
|
||||
$p_remove_dir .= '/';
|
||||
|
||||
if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir)
|
||||
$v_stored_filename = substr($p_filename, strlen($p_remove_dir));
|
||||
}
|
||||
$v_stored_filename = $this->_translateWinPath($v_stored_filename);
|
||||
if ($p_add_dir != '') {
|
||||
if (substr($p_add_dir, -1) == '/')
|
||||
$v_stored_filename = $p_add_dir.$v_stored_filename;
|
||||
else
|
||||
$v_stored_filename = $p_add_dir.'/'.$v_stored_filename;
|
||||
}
|
||||
if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir)
|
||||
$v_stored_filename = substr($p_filename, strlen($p_remove_dir));
|
||||
}
|
||||
$v_stored_filename = $this->_translateWinPath($v_stored_filename);
|
||||
if ($p_add_dir != '') {
|
||||
if (substr($p_add_dir, -1) == '/')
|
||||
$v_stored_filename = $p_add_dir.$v_stored_filename;
|
||||
else
|
||||
$v_stored_filename = $p_add_dir.'/'.$v_stored_filename;
|
||||
}
|
||||
|
||||
$v_stored_filename = $this->_pathReduction($v_stored_filename);
|
||||
}
|
||||
$v_stored_filename = $this->_pathReduction($v_stored_filename);
|
||||
}
|
||||
|
||||
if ($this->_isArchive($p_filename)) {
|
||||
if (($v_file = @fopen($p_filename, "rb")) == 0) {
|
||||
|
@ -1775,12 +1776,20 @@ class Archive_Tar extends PEAR
|
|||
}
|
||||
|
||||
if ($this->_compress_type == 'gz') {
|
||||
$end_blocks = 0;
|
||||
|
||||
while (!@gzeof($v_temp_tar)) {
|
||||
$v_buffer = @gzread($v_temp_tar, 512);
|
||||
if ($v_buffer == ARCHIVE_TAR_END_BLOCK || strlen($v_buffer) == 0) {
|
||||
$end_blocks++;
|
||||
// do not copy end blocks, we will re-make them
|
||||
// after appending
|
||||
continue;
|
||||
} elseif ($end_blocks > 0) {
|
||||
for ($i = 0; $i < $end_blocks; $i++) {
|
||||
$this->_writeBlock(ARCHIVE_TAR_END_BLOCK);
|
||||
}
|
||||
$end_blocks = 0;
|
||||
}
|
||||
$v_binary_data = pack("a512", $v_buffer);
|
||||
$this->_writeBlock($v_binary_data);
|
||||
|
@ -1789,9 +1798,19 @@ class Archive_Tar extends PEAR
|
|||
@gzclose($v_temp_tar);
|
||||
}
|
||||
elseif ($this->_compress_type == 'bz2') {
|
||||
$end_blocks = 0;
|
||||
|
||||
while (strlen($v_buffer = @bzread($v_temp_tar, 512)) > 0) {
|
||||
if ($v_buffer == ARCHIVE_TAR_END_BLOCK) {
|
||||
if ($v_buffer == ARCHIVE_TAR_END_BLOCK || strlen($v_buffer) == 0) {
|
||||
$end_blocks++;
|
||||
// do not copy end blocks, we will re-make them
|
||||
// after appending
|
||||
continue;
|
||||
} elseif ($end_blocks > 0) {
|
||||
for ($i = 0; $i < $end_blocks; $i++) {
|
||||
$this->_writeBlock(ARCHIVE_TAR_END_BLOCK);
|
||||
}
|
||||
$end_blocks = 0;
|
||||
}
|
||||
$v_binary_data = pack("a512", $v_buffer);
|
||||
$this->_writeBlock($v_binary_data);
|
||||
|
|
|
@ -1412,7 +1412,7 @@ class MDB2_Driver_Datatype_Common extends MDB2_Module_Common
|
|||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
if (isset($db->function) && is_object($this->function) && is_a($db->function, 'MDB2_Driver_Function_Common')) {
|
||||
if (isset($db->function) && is_object($db->function) && is_a($db->function, 'MDB2_Driver_Function_Common')) {
|
||||
return $db->function->now('timestamp');
|
||||
}
|
||||
return 'CURRENT_TIMESTAMP';
|
||||
|
|
|
@ -0,0 +1,499 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP versions 4 and 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1998-2007 Manuel Lemos, Tomas V.V.Cox, |
|
||||
// | Stig. S. Bakken, Lukas Smith |
|
||||
// | All rights reserved. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
|
||||
// | API as well as database abstraction for PHP applications. |
|
||||
// | This LICENSE is in the BSD license style. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | |
|
||||
// | Redistributions in binary form must reproduce the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer in the |
|
||||
// | documentation and/or other materials provided with the distribution. |
|
||||
// | |
|
||||
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
|
||||
// | Lukas Smith nor the names of his contributors may be used to endorse |
|
||||
// | or promote products derived from this software without specific prior|
|
||||
// | written permission. |
|
||||
// | |
|
||||
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
||||
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
||||
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
||||
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
||||
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
|
||||
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
||||
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
||||
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
|
||||
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
||||
// | POSSIBILITY OF SUCH DAMAGE. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Lukas Smith <smith@pooteeweet.org> |
|
||||
// +----------------------------------------------------------------------+
|
||||
|
||||
// $Id: oci8.php 295587 2010-02-28 17:16:38Z quipo $
|
||||
|
||||
require_once 'MDB2/Driver/Datatype/Common.php';
|
||||
|
||||
/**
|
||||
* MDB2 OCI8 driver
|
||||
*
|
||||
* @package MDB2
|
||||
* @category Database
|
||||
* @author Lukas Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
class MDB2_Driver_Datatype_oci8 extends MDB2_Driver_Datatype_Common
|
||||
{
|
||||
// {{{ _baseConvertResult()
|
||||
|
||||
/**
|
||||
* general type conversion method
|
||||
*
|
||||
* @param mixed $value refernce to a value to be converted
|
||||
* @param string $type specifies which type to convert to
|
||||
* @param boolean $rtrim [optional] when TRUE [default], apply rtrim() to text
|
||||
* @return object a MDB2 error on failure
|
||||
* @access protected
|
||||
*/
|
||||
function _baseConvertResult($value, $type, $rtrim = true)
|
||||
{
|
||||
if (null === $value) {
|
||||
return null;
|
||||
}
|
||||
switch ($type) {
|
||||
case 'text':
|
||||
if (is_object($value) && is_a($value, 'OCI-Lob')) {
|
||||
//LOB => fetch into variable
|
||||
$clob = $this->_baseConvertResult($value, 'clob', $rtrim);
|
||||
if (!PEAR::isError($clob) && is_resource($clob)) {
|
||||
$clob_value = '';
|
||||
while (!feof($clob)) {
|
||||
$clob_value .= fread($clob, 8192);
|
||||
}
|
||||
$this->destroyLOB($clob);
|
||||
}
|
||||
$value = $clob_value;
|
||||
}
|
||||
if ($rtrim) {
|
||||
$value = rtrim($value);
|
||||
}
|
||||
return $value;
|
||||
case 'date':
|
||||
return substr($value, 0, strlen('YYYY-MM-DD'));
|
||||
case 'time':
|
||||
return substr($value, strlen('YYYY-MM-DD '), strlen('HH:MI:SS'));
|
||||
}
|
||||
return parent::_baseConvertResult($value, $type, $rtrim);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getTypeDeclaration()
|
||||
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to declare an text type
|
||||
* field to be used in statements like CREATE TABLE.
|
||||
*
|
||||
* @param array $field associative array with the name of the properties
|
||||
* of the field being declared as array indexes. Currently, the types
|
||||
* of supported field properties are as follows:
|
||||
*
|
||||
* length
|
||||
* Integer value that determines the maximum length of the text
|
||||
* field. If this argument is missing the field should be
|
||||
* declared to have the longest length allowed by the DBMS.
|
||||
*
|
||||
* default
|
||||
* Text value to be used as default for this field.
|
||||
*
|
||||
* notnull
|
||||
* Boolean flag that indicates whether this field is constrained
|
||||
* to not be set to null.
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
* @access public
|
||||
*/
|
||||
function getTypeDeclaration($field)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
switch ($field['type']) {
|
||||
case 'text':
|
||||
$length = !empty($field['length'])
|
||||
? $field['length'] : $db->options['default_text_field_length'];
|
||||
$fixed = !empty($field['fixed']) ? $field['fixed'] : false;
|
||||
return $fixed ? 'CHAR('.$length.')' : 'VARCHAR2('.$length.')';
|
||||
case 'clob':
|
||||
return 'CLOB';
|
||||
case 'blob':
|
||||
return 'BLOB';
|
||||
case 'integer':
|
||||
if (!empty($field['length'])) {
|
||||
switch((int)$field['length']) {
|
||||
case 1: $digit = 3; break;
|
||||
case 2: $digit = 5; break;
|
||||
case 3: $digit = 8; break;
|
||||
case 4: $digit = 10; break;
|
||||
case 5: $digit = 13; break;
|
||||
case 6: $digit = 15; break;
|
||||
case 7: $digit = 17; break;
|
||||
case 8: $digit = 20; break;
|
||||
default: $digit = 10;
|
||||
}
|
||||
return 'NUMBER('.$digit.')';
|
||||
}
|
||||
return 'INT';
|
||||
case 'boolean':
|
||||
return 'NUMBER(1)';
|
||||
case 'date':
|
||||
case 'time':
|
||||
case 'timestamp':
|
||||
return 'DATE';
|
||||
case 'float':
|
||||
return 'NUMBER';
|
||||
case 'decimal':
|
||||
$scale = !empty($field['scale']) ? $field['scale'] : $db->options['decimal_places'];
|
||||
return 'NUMBER(*,'.$scale.')';
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _quoteCLOB()
|
||||
|
||||
/**
|
||||
* Convert a text value into a DBMS specific format that is suitable to
|
||||
* compose query statements.
|
||||
*
|
||||
* @param string $value text string value that is intended to be converted.
|
||||
* @param bool $quote determines if the value should be quoted and escaped
|
||||
* @param bool $escape_wildcards if to escape escape wildcards
|
||||
* @return string text string that represents the given argument value in
|
||||
* a DBMS specific format.
|
||||
* @access protected
|
||||
*/
|
||||
function _quoteCLOB($value, $quote, $escape_wildcards)
|
||||
{
|
||||
return 'EMPTY_CLOB()';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _quoteBLOB()
|
||||
|
||||
/**
|
||||
* Convert a text value into a DBMS specific format that is suitable to
|
||||
* compose query statements.
|
||||
*
|
||||
* @param string $value text string value that is intended to be converted.
|
||||
* @param bool $quote determines if the value should be quoted and escaped
|
||||
* @param bool $escape_wildcards if to escape escape wildcards
|
||||
* @return string text string that represents the given argument value in
|
||||
* a DBMS specific format.
|
||||
* @access protected
|
||||
*/
|
||||
function _quoteBLOB($value, $quote, $escape_wildcards)
|
||||
{
|
||||
return 'EMPTY_BLOB()';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _quoteDate()
|
||||
|
||||
/**
|
||||
* Convert a text value into a DBMS specific format that is suitable to
|
||||
* compose query statements.
|
||||
*
|
||||
* @param string $value text string value that is intended to be converted.
|
||||
* @param bool $quote determines if the value should be quoted and escaped
|
||||
* @param bool $escape_wildcards if to escape escape wildcards
|
||||
* @return string text string that represents the given argument value in
|
||||
* a DBMS specific format.
|
||||
* @access protected
|
||||
*/
|
||||
function _quoteDate($value, $quote, $escape_wildcards)
|
||||
{
|
||||
return $this->_quoteText("$value 00:00:00", $quote, $escape_wildcards);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _quoteTimestamp()
|
||||
|
||||
/**
|
||||
* Convert a text value into a DBMS specific format that is suitable to
|
||||
* compose query statements.
|
||||
*
|
||||
* @param string $value text string value that is intended to be converted.
|
||||
* @param bool $quote determines if the value should be quoted and escaped
|
||||
* @param bool $escape_wildcards if to escape escape wildcards
|
||||
* @return string text string that represents the given argument value in
|
||||
* a DBMS specific format.
|
||||
* @access protected
|
||||
*/
|
||||
//function _quoteTimestamp($value, $quote, $escape_wildcards)
|
||||
//{
|
||||
// return $this->_quoteText($value, $quote, $escape_wildcards);
|
||||
//}
|
||||
|
||||
// }}}
|
||||
// {{{ _quoteTime()
|
||||
|
||||
/**
|
||||
* Convert a text value into a DBMS specific format that is suitable to
|
||||
* compose query statements.
|
||||
*
|
||||
* @param string $value text string value that is intended to be converted.
|
||||
* @param bool $quote determines if the value should be quoted and escaped
|
||||
* @param bool $escape_wildcards if to escape escape wildcards
|
||||
* @return string text string that represents the given argument value in
|
||||
* a DBMS specific format.
|
||||
* @access protected
|
||||
*/
|
||||
function _quoteTime($value, $quote, $escape_wildcards)
|
||||
{
|
||||
return $this->_quoteText("0001-01-01 $value", $quote, $escape_wildcards);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ writeLOBToFile()
|
||||
|
||||
/**
|
||||
* retrieve LOB from the database
|
||||
*
|
||||
* @param array $lob array
|
||||
* @param string $file name of the file into which the LOb should be fetched
|
||||
* @return mixed MDB2_OK on success, a MDB2 error on failure
|
||||
* @access protected
|
||||
*/
|
||||
function writeLOBToFile($lob, $file)
|
||||
{
|
||||
if (preg_match('/^(\w+:\/\/)(.*)$/', $file, $match)) {
|
||||
if ($match[1] == 'file://') {
|
||||
$file = $match[2];
|
||||
}
|
||||
}
|
||||
$lob_data = stream_get_meta_data($lob);
|
||||
$lob_index = $lob_data['wrapper_data']->lob_index;
|
||||
$result = $this->lobs[$lob_index]['resource']->writetofile($file);
|
||||
$this->lobs[$lob_index]['resource']->seek(0);
|
||||
if (!$result) {
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
return $db->raiseError(null, null, null,
|
||||
'Unable to write LOB to file', __FUNCTION__);
|
||||
}
|
||||
return MDB2_OK;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _retrieveLOB()
|
||||
|
||||
/**
|
||||
* retrieve LOB from the database
|
||||
*
|
||||
* @param array $lob array
|
||||
* @return mixed MDB2_OK on success, a MDB2 error on failure
|
||||
* @access protected
|
||||
*/
|
||||
function _retrieveLOB(&$lob)
|
||||
{
|
||||
if (!is_object($lob['resource'])) {
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
|
||||
'attemped to retrieve LOB from non existing or NULL column', __FUNCTION__);
|
||||
}
|
||||
|
||||
if (!$lob['loaded']
|
||||
# && !method_exists($lob['resource'], 'read')
|
||||
) {
|
||||
$lob['value'] = $lob['resource']->load();
|
||||
$lob['resource']->seek(0);
|
||||
}
|
||||
$lob['loaded'] = true;
|
||||
return MDB2_OK;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _readLOB()
|
||||
|
||||
/**
|
||||
* Read data from large object input stream.
|
||||
*
|
||||
* @param array $lob array
|
||||
* @param blob $data reference to a variable that will hold data to be
|
||||
* read from the large object input stream
|
||||
* @param int $length integer value that indicates the largest ammount of
|
||||
* data to be read from the large object input stream.
|
||||
* @return mixed length on success, a MDB2 error on failure
|
||||
* @access protected
|
||||
*/
|
||||
function _readLOB($lob, $length)
|
||||
{
|
||||
if ($lob['loaded']) {
|
||||
return parent::_readLOB($lob, $length);
|
||||
}
|
||||
|
||||
if (!is_object($lob['resource'])) {
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
|
||||
'attemped to retrieve LOB from non existing or NULL column', __FUNCTION__);
|
||||
}
|
||||
|
||||
$data = $lob['resource']->read($length);
|
||||
if (!is_string($data)) {
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
return $db->raiseError(null, null, null,
|
||||
'Unable to read LOB', __FUNCTION__);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ patternEscapeString()
|
||||
|
||||
/**
|
||||
* build string to define escape pattern string
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
*
|
||||
* @return string define escape pattern
|
||||
*/
|
||||
function patternEscapeString()
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
return " ESCAPE '". $db->string_quoting['escape_pattern'] ."'";
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _mapNativeDatatype()
|
||||
|
||||
/**
|
||||
* Maps a native array description of a field to a MDB2 datatype and length
|
||||
*
|
||||
* @param array $field native field description
|
||||
* @return array containing the various possible types, length, sign, fixed
|
||||
* @access public
|
||||
*/
|
||||
function _mapNativeDatatype($field)
|
||||
{
|
||||
$db_type = strtolower($field['type']);
|
||||
$type = array();
|
||||
$length = $unsigned = $fixed = null;
|
||||
if (!empty($field['length'])) {
|
||||
$length = $field['length'];
|
||||
}
|
||||
switch ($db_type) {
|
||||
case 'integer':
|
||||
case 'pls_integer':
|
||||
case 'binary_integer':
|
||||
$type[] = 'integer';
|
||||
if ($length == '1') {
|
||||
$type[] = 'boolean';
|
||||
if (preg_match('/^(is|has)/', $field['name'])) {
|
||||
$type = array_reverse($type);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'varchar':
|
||||
case 'varchar2':
|
||||
case 'nvarchar2':
|
||||
$fixed = false;
|
||||
case 'char':
|
||||
case 'nchar':
|
||||
$type[] = 'text';
|
||||
if ($length == '1') {
|
||||
$type[] = 'boolean';
|
||||
if (preg_match('/^(is|has)/', $field['name'])) {
|
||||
$type = array_reverse($type);
|
||||
}
|
||||
}
|
||||
if ($fixed !== false) {
|
||||
$fixed = true;
|
||||
}
|
||||
break;
|
||||
case 'date':
|
||||
case 'timestamp':
|
||||
$type[] = 'timestamp';
|
||||
$length = null;
|
||||
break;
|
||||
case 'float':
|
||||
$type[] = 'float';
|
||||
break;
|
||||
case 'number':
|
||||
if (!empty($field['scale'])) {
|
||||
$type[] = 'decimal';
|
||||
$length = $length.','.$field['scale'];
|
||||
} else {
|
||||
$type[] = 'integer';
|
||||
if ($length == '1') {
|
||||
$type[] = 'boolean';
|
||||
if (preg_match('/^(is|has)/', $field['name'])) {
|
||||
$type = array_reverse($type);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'long':
|
||||
$type[] = 'text';
|
||||
case 'clob':
|
||||
case 'nclob':
|
||||
$type[] = 'clob';
|
||||
break;
|
||||
case 'blob':
|
||||
case 'raw':
|
||||
case 'long raw':
|
||||
case 'bfile':
|
||||
$type[] = 'blob';
|
||||
$length = null;
|
||||
break;
|
||||
case 'rowid':
|
||||
case 'urowid':
|
||||
default:
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
|
||||
'unknown database attribute type: '.$db_type, __FUNCTION__);
|
||||
}
|
||||
|
||||
if ((int)$length <= 0) {
|
||||
$length = null;
|
||||
}
|
||||
|
||||
return array($type, $length, $unsigned, $fixed);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,187 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP versions 4 and 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1998-2008 Manuel Lemos, Tomas V.V.Cox, |
|
||||
// | Stig. S. Bakken, Lukas Smith |
|
||||
// | All rights reserved. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
|
||||
// | API as well as database abstraction for PHP applications. |
|
||||
// | This LICENSE is in the BSD license style. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | |
|
||||
// | Redistributions in binary form must reproduce the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer in the |
|
||||
// | documentation and/or other materials provided with the distribution. |
|
||||
// | |
|
||||
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
|
||||
// | Lukas Smith nor the names of his contributors may be used to endorse |
|
||||
// | or promote products derived from this software without specific prior|
|
||||
// | written permission. |
|
||||
// | |
|
||||
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
||||
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
||||
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
||||
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
||||
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
|
||||
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
||||
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
||||
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
|
||||
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
||||
// | POSSIBILITY OF SUCH DAMAGE. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Lukas Smith <smith@pooteeweet.org> |
|
||||
// +----------------------------------------------------------------------+
|
||||
|
||||
// $Id: oci8.php 295587 2010-02-28 17:16:38Z quipo $
|
||||
|
||||
require_once 'MDB2/Driver/Function/Common.php';
|
||||
|
||||
/**
|
||||
* MDB2 oci8 driver for the function modules
|
||||
*
|
||||
* @package MDB2
|
||||
* @category Database
|
||||
* @author Lukas Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
class MDB2_Driver_Function_oci8 extends MDB2_Driver_Function_Common
|
||||
{
|
||||
// {{{ executeStoredProc()
|
||||
|
||||
/**
|
||||
* Execute a stored procedure and return any results
|
||||
*
|
||||
* @param string $name string that identifies the function to execute
|
||||
* @param mixed $params array that contains the paramaters to pass the stored proc
|
||||
* @param mixed $types array that contains the types of the columns in
|
||||
* the result set
|
||||
* @param mixed $result_class string which specifies which result class to use
|
||||
* @param mixed $result_wrap_class string which specifies which class to wrap results in
|
||||
* @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure
|
||||
* @access public
|
||||
*/
|
||||
function executeStoredProc($name, $params = null, $types = null, $result_class = true, $result_wrap_class = false)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
$query = 'EXEC '.$name;
|
||||
$query .= $params ? '('.implode(', ', $params).')' : '()';
|
||||
return $db->query($query, $types, $result_class, $result_wrap_class);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ functionTable()
|
||||
|
||||
/**
|
||||
* return string for internal table used when calling only a function
|
||||
*
|
||||
* @return string for internal table used when calling only a function
|
||||
* @access public
|
||||
*/
|
||||
function functionTable()
|
||||
{
|
||||
return ' FROM dual';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ now()
|
||||
|
||||
/**
|
||||
* Return string to call a variable with the current timestamp inside an SQL statement
|
||||
* There are three special variables for current date and time:
|
||||
* - CURRENT_TIMESTAMP (date and time, TIMESTAMP type)
|
||||
* - CURRENT_DATE (date, DATE type)
|
||||
* - CURRENT_TIME (time, TIME type)
|
||||
*
|
||||
* @return string to call a variable with the current timestamp
|
||||
* @access public
|
||||
*/
|
||||
function now($type = 'timestamp')
|
||||
{
|
||||
switch ($type) {
|
||||
case 'date':
|
||||
case 'time':
|
||||
case 'timestamp':
|
||||
default:
|
||||
return 'TO_CHAR(CURRENT_TIMESTAMP, \'YYYY-MM-DD HH24:MI:SS\')';
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ unixtimestamp()
|
||||
|
||||
/**
|
||||
* return string to call a function to get the unix timestamp from a iso timestamp
|
||||
*
|
||||
* @param string $expression
|
||||
*
|
||||
* @return string to call a variable with the timestamp
|
||||
* @access public
|
||||
*/
|
||||
function unixtimestamp($expression)
|
||||
{
|
||||
$utc_offset = 'CAST(SYS_EXTRACT_UTC(SYSTIMESTAMP) AS DATE) - CAST(SYSTIMESTAMP AS DATE)';
|
||||
$epoch_date = 'to_date(\'19700101\', \'YYYYMMDD\')';
|
||||
return '(CAST('.$expression.' AS DATE) - '.$epoch_date.' + '.$utc_offset.') * 86400 seconds';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ substring()
|
||||
|
||||
/**
|
||||
* return string to call a function to get a substring inside an SQL statement
|
||||
*
|
||||
* @return string to call a function to get a substring
|
||||
* @access public
|
||||
*/
|
||||
function substring($value, $position = 1, $length = null)
|
||||
{
|
||||
if (null !== $length) {
|
||||
return "SUBSTR($value, $position, $length)";
|
||||
}
|
||||
return "SUBSTR($value, $position)";
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ random()
|
||||
|
||||
/**
|
||||
* return string to call a function to get random value inside an SQL statement
|
||||
*
|
||||
* @return return string to generate float between 0 and 1
|
||||
* @access public
|
||||
*/
|
||||
function random()
|
||||
{
|
||||
return 'dbms_random.value';
|
||||
}
|
||||
|
||||
// }}}}
|
||||
// {{{ guid()
|
||||
|
||||
/**
|
||||
* Returns global unique identifier
|
||||
*
|
||||
* @return string to get global unique identifier
|
||||
* @access public
|
||||
*/
|
||||
function guid()
|
||||
{
|
||||
return 'SYS_GUID()';
|
||||
}
|
||||
|
||||
// }}}}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP versions 4 and 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1998-2006 Manuel Lemos, Tomas V.V.Cox, |
|
||||
// | Stig. S. Bakken, Lukas Smith, Frank M. Kromann |
|
||||
// | All rights reserved. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
|
||||
// | API as well as database abstraction for PHP applications. |
|
||||
// | This LICENSE is in the BSD license style. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | |
|
||||
// | Redistributions in binary form must reproduce the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer in the |
|
||||
// | documentation and/or other materials provided with the distribution. |
|
||||
// | |
|
||||
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
|
||||
// | Lukas Smith nor the names of his contributors may be used to endorse |
|
||||
// | or promote products derived from this software without specific prior|
|
||||
// | written permission. |
|
||||
// | |
|
||||
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
||||
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
||||
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
||||
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
||||
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
|
||||
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
||||
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
||||
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
|
||||
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
||||
// | POSSIBILITY OF SUCH DAMAGE. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Lukas Smith <smith@pooteeweet.org> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id: oci8.php 215004 2006-06-18 21:59:05Z lsmith $
|
||||
//
|
||||
|
||||
require_once 'MDB2/Driver/Native/Common.php';
|
||||
|
||||
/**
|
||||
* MDB2 Oracle driver for the native module
|
||||
*
|
||||
* @package MDB2
|
||||
* @category Database
|
||||
* @author Lukas Smith <smith@dybnet.de>
|
||||
*/
|
||||
class MDB2_Driver_Native_oci8 extends MDB2_Driver_Native_Common
|
||||
{
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,625 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP versions 4 and 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1998-2007 Manuel Lemos, Tomas V.V.Cox, |
|
||||
// | Stig. S. Bakken, Lukas Smith, Frank M. Kromann, Lorenzo Alberton |
|
||||
// | All rights reserved. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
|
||||
// | API as well as database abstraction for PHP applications. |
|
||||
// | This LICENSE is in the BSD license style. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | |
|
||||
// | Redistributions in binary form must reproduce the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer in the |
|
||||
// | documentation and/or other materials provided with the distribution. |
|
||||
// | |
|
||||
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
|
||||
// | Lukas Smith nor the names of his contributors may be used to endorse |
|
||||
// | or promote products derived from this software without specific prior|
|
||||
// | written permission. |
|
||||
// | |
|
||||
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
||||
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
||||
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
||||
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
||||
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
|
||||
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
||||
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
||||
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
|
||||
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
||||
// | POSSIBILITY OF SUCH DAMAGE. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Authors: Lukas Smith <smith@pooteeweet.org> |
|
||||
// | Lorenzo Alberton <l.alberton@quipo.it> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id: oci8.php 295587 2010-02-28 17:16:38Z quipo $
|
||||
//
|
||||
|
||||
require_once 'MDB2/Driver/Reverse/Common.php';
|
||||
|
||||
/**
|
||||
* MDB2 Oracle driver for the schema reverse engineering module
|
||||
*
|
||||
* @package MDB2
|
||||
* @category Database
|
||||
* @author Lukas Smith <smith@dybnet.de>
|
||||
*/
|
||||
class MDB2_Driver_Reverse_oci8 extends MDB2_Driver_Reverse_Common
|
||||
{
|
||||
// {{{ getTableFieldDefinition()
|
||||
|
||||
/**
|
||||
* Get the structure of a field into an array
|
||||
*
|
||||
* @param string $table_name name of table that should be used in method
|
||||
* @param string $field_name name of field that should be used in method
|
||||
* @return mixed data array on success, a MDB2 error on failure
|
||||
* @access public
|
||||
*/
|
||||
function getTableFieldDefinition($table_name, $field_name)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
$result = $db->loadModule('Datatype', null, true);
|
||||
if (PEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
list($owner, $table) = $this->splitTableSchema($table_name);
|
||||
if (empty($owner)) {
|
||||
$owner = $db->dsn['username'];
|
||||
}
|
||||
|
||||
$query = 'SELECT column_name AS "name",
|
||||
data_type AS "type",
|
||||
nullable AS "nullable",
|
||||
data_default AS "default",
|
||||
COALESCE(data_precision, data_length) AS "length",
|
||||
data_scale AS "scale"
|
||||
FROM all_tab_columns
|
||||
WHERE (table_name=? OR table_name=?)
|
||||
AND (owner=? OR owner=?)
|
||||
AND (column_name=? OR column_name=?)
|
||||
ORDER BY column_id';
|
||||
$stmt = $db->prepare($query);
|
||||
if (PEAR::isError($stmt)) {
|
||||
return $stmt;
|
||||
}
|
||||
$args = array(
|
||||
$table,
|
||||
strtoupper($table),
|
||||
$owner,
|
||||
strtoupper($owner),
|
||||
$field_name,
|
||||
strtoupper($field_name)
|
||||
);
|
||||
$result = $stmt->execute($args);
|
||||
if (PEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
$column = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
|
||||
if (PEAR::isError($column)) {
|
||||
return $column;
|
||||
}
|
||||
$stmt->free();
|
||||
$result->free();
|
||||
|
||||
if (empty($column)) {
|
||||
return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
|
||||
$field_name . ' is not a column in table ' . $table_name, __FUNCTION__);
|
||||
}
|
||||
|
||||
$column = array_change_key_case($column, CASE_LOWER);
|
||||
if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
|
||||
if ($db->options['field_case'] == CASE_LOWER) {
|
||||
$column['name'] = strtolower($column['name']);
|
||||
} else {
|
||||
$column['name'] = strtoupper($column['name']);
|
||||
}
|
||||
}
|
||||
$mapped_datatype = $db->datatype->mapNativeDatatype($column);
|
||||
if (PEAR::isError($mapped_datatype)) {
|
||||
return $mapped_datatype;
|
||||
}
|
||||
list($types, $length, $unsigned, $fixed) = $mapped_datatype;
|
||||
$notnull = false;
|
||||
if (!empty($column['nullable']) && $column['nullable'] == 'N') {
|
||||
$notnull = true;
|
||||
}
|
||||
$default = false;
|
||||
if (array_key_exists('default', $column)) {
|
||||
$default = $column['default'];
|
||||
if ($default === 'NULL') {
|
||||
$default = null;
|
||||
}
|
||||
//ugly hack, but works for the reverse direction
|
||||
if ($default == "''") {
|
||||
$default = '';
|
||||
}
|
||||
if ((null === $default) && $notnull) {
|
||||
$default = '';
|
||||
}
|
||||
}
|
||||
|
||||
$definition[0] = array('notnull' => $notnull, 'nativetype' => $column['type']);
|
||||
if (null !== $length) {
|
||||
$definition[0]['length'] = $length;
|
||||
}
|
||||
if (null !== $unsigned) {
|
||||
$definition[0]['unsigned'] = $unsigned;
|
||||
}
|
||||
if (null !== $fixed) {
|
||||
$definition[0]['fixed'] = $fixed;
|
||||
}
|
||||
if ($default !== false) {
|
||||
$definition[0]['default'] = $default;
|
||||
}
|
||||
foreach ($types as $key => $type) {
|
||||
$definition[$key] = $definition[0];
|
||||
if ($type == 'clob' || $type == 'blob') {
|
||||
unset($definition[$key]['default']);
|
||||
}
|
||||
$definition[$key]['type'] = $type;
|
||||
$definition[$key]['mdb2type'] = $type;
|
||||
}
|
||||
if ($type == 'integer') {
|
||||
$query= "SELECT trigger_body
|
||||
FROM all_triggers
|
||||
WHERE table_name=?
|
||||
AND triggering_event='INSERT'
|
||||
AND trigger_type='BEFORE EACH ROW'";
|
||||
// ^^ pretty reasonable mimic for "auto_increment" in oracle?
|
||||
$stmt = $db->prepare($query);
|
||||
if (PEAR::isError($stmt)) {
|
||||
return $stmt;
|
||||
}
|
||||
$result = $stmt->execute(strtoupper($table));
|
||||
if (PEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
while ($triggerstr = $result->fetchOne()) {
|
||||
if (preg_match('/.*SELECT\W+(.+)\.nextval +into +\:NEW\.'.$field_name.' +FROM +dual/im', $triggerstr, $matches)) {
|
||||
$definition[0]['autoincrement'] = $matches[1];
|
||||
}
|
||||
}
|
||||
$stmt->free();
|
||||
$result->free();
|
||||
}
|
||||
return $definition;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getTableIndexDefinition()
|
||||
|
||||
/**
|
||||
* Get the structure of an index into an array
|
||||
*
|
||||
* @param string $table_name name of table that should be used in method
|
||||
* @param string $index_name name of index that should be used in method
|
||||
* @return mixed data array on success, a MDB2 error on failure
|
||||
* @access public
|
||||
*/
|
||||
function getTableIndexDefinition($table_name, $index_name)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
list($owner, $table) = $this->splitTableSchema($table_name);
|
||||
if (empty($owner)) {
|
||||
$owner = $db->dsn['username'];
|
||||
}
|
||||
|
||||
$query = 'SELECT aic.column_name AS "column_name",
|
||||
aic.column_position AS "column_position",
|
||||
aic.descend AS "descend",
|
||||
aic.table_owner AS "table_owner",
|
||||
alc.constraint_type AS "constraint_type"
|
||||
FROM all_ind_columns aic
|
||||
LEFT JOIN all_constraints alc
|
||||
ON aic.index_name = alc.constraint_name
|
||||
AND aic.table_name = alc.table_name
|
||||
AND aic.table_owner = alc.owner
|
||||
WHERE (aic.table_name=? OR aic.table_name=?)
|
||||
AND (aic.index_name=? OR aic.index_name=?)
|
||||
AND (aic.table_owner=? OR aic.table_owner=?)
|
||||
ORDER BY column_position';
|
||||
$stmt = $db->prepare($query);
|
||||
if (PEAR::isError($stmt)) {
|
||||
return $stmt;
|
||||
}
|
||||
$indexnames = array_unique(array($db->getIndexName($index_name), $index_name));
|
||||
$i = 0;
|
||||
$row = null;
|
||||
while ((null === $row) && array_key_exists($i, $indexnames)) {
|
||||
$args = array(
|
||||
$table,
|
||||
strtoupper($table),
|
||||
$indexnames[$i],
|
||||
strtoupper($indexnames[$i]),
|
||||
$owner,
|
||||
strtoupper($owner)
|
||||
);
|
||||
$result = $stmt->execute($args);
|
||||
if (PEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
|
||||
if (PEAR::isError($row)) {
|
||||
return $row;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
if (null === $row) {
|
||||
return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
|
||||
$index_name. ' is not an index on table '. $table_name, __FUNCTION__);
|
||||
}
|
||||
if ($row['constraint_type'] == 'U' || $row['constraint_type'] == 'P') {
|
||||
return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
|
||||
$index_name. ' is a constraint, not an index on table '. $table_name, __FUNCTION__);
|
||||
}
|
||||
|
||||
$definition = array();
|
||||
while (null !== $row) {
|
||||
$row = array_change_key_case($row, CASE_LOWER);
|
||||
$column_name = $row['column_name'];
|
||||
if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
|
||||
if ($db->options['field_case'] == CASE_LOWER) {
|
||||
$column_name = strtolower($column_name);
|
||||
} else {
|
||||
$column_name = strtoupper($column_name);
|
||||
}
|
||||
}
|
||||
$definition['fields'][$column_name] = array(
|
||||
'position' => (int)$row['column_position'],
|
||||
);
|
||||
if (!empty($row['descend'])) {
|
||||
$definition['fields'][$column_name]['sorting'] =
|
||||
($row['descend'] == 'ASC' ? 'ascending' : 'descending');
|
||||
}
|
||||
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
|
||||
}
|
||||
$result->free();
|
||||
if (empty($definition['fields'])) {
|
||||
return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
|
||||
$index_name. ' is not an index on table '. $table_name, __FUNCTION__);
|
||||
}
|
||||
return $definition;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getTableConstraintDefinition()
|
||||
|
||||
/**
|
||||
* Get the structure of a constraint into an array
|
||||
*
|
||||
* @param string $table_name name of table that should be used in method
|
||||
* @param string $constraint_name name of constraint that should be used in method
|
||||
* @return mixed data array on success, a MDB2 error on failure
|
||||
* @access public
|
||||
*/
|
||||
function getTableConstraintDefinition($table_name, $constraint_name)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
list($owner, $table) = $this->splitTableSchema($table_name);
|
||||
if (empty($owner)) {
|
||||
$owner = $db->dsn['username'];
|
||||
}
|
||||
|
||||
$query = 'SELECT alc.constraint_name,
|
||||
CASE alc.constraint_type WHEN \'P\' THEN 1 ELSE 0 END "primary",
|
||||
CASE alc.constraint_type WHEN \'R\' THEN 1 ELSE 0 END "foreign",
|
||||
CASE alc.constraint_type WHEN \'U\' THEN 1 ELSE 0 END "unique",
|
||||
CASE alc.constraint_type WHEN \'C\' THEN 1 ELSE 0 END "check",
|
||||
alc.DELETE_RULE "ondelete",
|
||||
\'NO ACTION\' "onupdate",
|
||||
\'SIMPLE\' "match",
|
||||
CASE alc.deferrable WHEN \'NOT DEFERRABLE\' THEN 0 ELSE 1 END "deferrable",
|
||||
CASE alc.deferred WHEN \'IMMEDIATE\' THEN 0 ELSE 1 END "initiallydeferred",
|
||||
alc.search_condition AS "search_condition",
|
||||
alc.table_name,
|
||||
cols.column_name AS "column_name",
|
||||
cols.position,
|
||||
r_alc.table_name "references_table",
|
||||
r_cols.column_name "references_field",
|
||||
r_cols.position "references_field_position"
|
||||
FROM all_cons_columns cols
|
||||
LEFT JOIN all_constraints alc
|
||||
ON alc.constraint_name = cols.constraint_name
|
||||
AND alc.owner = cols.owner
|
||||
LEFT JOIN all_constraints r_alc
|
||||
ON alc.r_constraint_name = r_alc.constraint_name
|
||||
AND alc.r_owner = r_alc.owner
|
||||
LEFT JOIN all_cons_columns r_cols
|
||||
ON r_alc.constraint_name = r_cols.constraint_name
|
||||
AND r_alc.owner = r_cols.owner
|
||||
AND cols.position = r_cols.position
|
||||
WHERE (alc.constraint_name=? OR alc.constraint_name=?)
|
||||
AND alc.constraint_name = cols.constraint_name
|
||||
AND (alc.owner=? OR alc.owner=?)';
|
||||
$tablenames = array();
|
||||
if (!empty($table)) {
|
||||
$query.= ' AND (alc.table_name=? OR alc.table_name=?)';
|
||||
$tablenames = array($table, strtoupper($table));
|
||||
}
|
||||
$stmt = $db->prepare($query);
|
||||
if (PEAR::isError($stmt)) {
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
$constraintnames = array_unique(array($db->getIndexName($constraint_name), $constraint_name));
|
||||
$c = 0;
|
||||
$row = null;
|
||||
while ((null === $row) && array_key_exists($c, $constraintnames)) {
|
||||
$args = array(
|
||||
$constraintnames[$c],
|
||||
strtoupper($constraintnames[$c]),
|
||||
$owner,
|
||||
strtoupper($owner)
|
||||
);
|
||||
if (!empty($table)) {
|
||||
$args = array_merge($args, $tablenames);
|
||||
}
|
||||
$result = $stmt->execute($args);
|
||||
if (PEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
|
||||
if (PEAR::isError($row)) {
|
||||
return $row;
|
||||
}
|
||||
$c++;
|
||||
}
|
||||
|
||||
$definition = array(
|
||||
'primary' => (boolean)$row['primary'],
|
||||
'unique' => (boolean)$row['unique'],
|
||||
'foreign' => (boolean)$row['foreign'],
|
||||
'check' => (boolean)$row['check'],
|
||||
'deferrable' => (boolean)$row['deferrable'],
|
||||
'initiallydeferred' => (boolean)$row['initiallydeferred'],
|
||||
'ondelete' => $row['ondelete'],
|
||||
'onupdate' => $row['onupdate'],
|
||||
'match' => $row['match'],
|
||||
);
|
||||
|
||||
if ($definition['check']) {
|
||||
// pattern match constraint for check constraint values into enum-style output:
|
||||
$enumregex = '/'.$row['column_name'].' in \((.+?)\)/i';
|
||||
if (preg_match($enumregex, $row['search_condition'], $rangestr)) {
|
||||
$definition['fields'][$column_name] = array();
|
||||
$allowed = explode(',', $rangestr[1]);
|
||||
foreach ($allowed as $val) {
|
||||
$val = trim($val);
|
||||
$val = preg_replace('/^\'/', '', $val);
|
||||
$val = preg_replace('/\'$/', '', $val);
|
||||
array_push($definition['fields'][$column_name], $val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (null !== $row) {
|
||||
$row = array_change_key_case($row, CASE_LOWER);
|
||||
$column_name = $row['column_name'];
|
||||
if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
|
||||
if ($db->options['field_case'] == CASE_LOWER) {
|
||||
$column_name = strtolower($column_name);
|
||||
} else {
|
||||
$column_name = strtoupper($column_name);
|
||||
}
|
||||
}
|
||||
$definition['fields'][$column_name] = array(
|
||||
'position' => (int)$row['position']
|
||||
);
|
||||
if ($row['foreign']) {
|
||||
$ref_column_name = $row['references_field'];
|
||||
$ref_table_name = $row['references_table'];
|
||||
if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
|
||||
if ($db->options['field_case'] == CASE_LOWER) {
|
||||
$ref_column_name = strtolower($ref_column_name);
|
||||
$ref_table_name = strtolower($ref_table_name);
|
||||
} else {
|
||||
$ref_column_name = strtoupper($ref_column_name);
|
||||
$ref_table_name = strtoupper($ref_table_name);
|
||||
}
|
||||
}
|
||||
$definition['references']['table'] = $ref_table_name;
|
||||
$definition['references']['fields'][$ref_column_name] = array(
|
||||
'position' => (int)$row['references_field_position']
|
||||
);
|
||||
}
|
||||
$lastrow = $row;
|
||||
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
|
||||
}
|
||||
$result->free();
|
||||
if (empty($definition['fields'])) {
|
||||
return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
|
||||
$constraint_name . ' is not a constraint on table '. $table_name, __FUNCTION__);
|
||||
}
|
||||
|
||||
return $definition;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getSequenceDefinition()
|
||||
|
||||
/**
|
||||
* Get the structure of a sequence into an array
|
||||
*
|
||||
* @param string $sequence name of sequence that should be used in method
|
||||
* @return mixed data array on success, a MDB2 error on failure
|
||||
* @access public
|
||||
*/
|
||||
function getSequenceDefinition($sequence)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
$sequence_name = $db->getSequenceName($sequence);
|
||||
$query = 'SELECT last_number FROM user_sequences';
|
||||
$query.= ' WHERE sequence_name='.$db->quote($sequence_name, 'text');
|
||||
$query.= ' OR sequence_name='.$db->quote(strtoupper($sequence_name), 'text');
|
||||
$start = $db->queryOne($query, 'integer');
|
||||
if (PEAR::isError($start)) {
|
||||
return $start;
|
||||
}
|
||||
$definition = array();
|
||||
if ($start != 1) {
|
||||
$definition = array('start' => $start);
|
||||
}
|
||||
return $definition;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getTriggerDefinition()
|
||||
|
||||
/**
|
||||
* Get the structure of a trigger into an array
|
||||
*
|
||||
* EXPERIMENTAL
|
||||
*
|
||||
* WARNING: this function is experimental and may change the returned value
|
||||
* at any time until labelled as non-experimental
|
||||
*
|
||||
* @param string $trigger name of trigger that should be used in method
|
||||
* @return mixed data array on success, a MDB2 error on failure
|
||||
* @access public
|
||||
*/
|
||||
function getTriggerDefinition($trigger)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
$query = 'SELECT trigger_name AS "trigger_name",
|
||||
table_name AS "table_name",
|
||||
trigger_body AS "trigger_body",
|
||||
trigger_type AS "trigger_type",
|
||||
triggering_event AS "trigger_event",
|
||||
description AS "trigger_comment",
|
||||
1 AS "trigger_enabled",
|
||||
when_clause AS "when_clause"
|
||||
FROM user_triggers
|
||||
WHERE trigger_name = \''. strtoupper($trigger).'\'';
|
||||
$types = array(
|
||||
'trigger_name' => 'text',
|
||||
'table_name' => 'text',
|
||||
'trigger_body' => 'text',
|
||||
'trigger_type' => 'text',
|
||||
'trigger_event' => 'text',
|
||||
'trigger_comment' => 'text',
|
||||
'trigger_enabled' => 'boolean',
|
||||
'when_clause' => 'text',
|
||||
);
|
||||
$result = $db->queryRow($query, $types, MDB2_FETCHMODE_ASSOC);
|
||||
if (PEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
if (!empty($result['trigger_type'])) {
|
||||
//$result['trigger_type'] = array_shift(explode(' ', $result['trigger_type']));
|
||||
$result['trigger_type'] = preg_replace('/(\S+).*/', '\\1', $result['trigger_type']);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ tableInfo()
|
||||
|
||||
/**
|
||||
* Returns information about a table or a result set
|
||||
*
|
||||
* NOTE: only supports 'table' and 'flags' if <var>$result</var>
|
||||
* is a table name.
|
||||
*
|
||||
* NOTE: flags won't contain index information.
|
||||
*
|
||||
* @param object|string $result MDB2_result object from a query or a
|
||||
* string containing the name of a table.
|
||||
* While this also accepts a query result
|
||||
* resource identifier, this behavior is
|
||||
* deprecated.
|
||||
* @param int $mode a valid tableInfo mode
|
||||
*
|
||||
* @return array an associative array with the information requested.
|
||||
* A MDB2_Error object on failure.
|
||||
*
|
||||
* @see MDB2_Driver_Common::tableInfo()
|
||||
*/
|
||||
function tableInfo($result, $mode = null)
|
||||
{
|
||||
if (is_string($result)) {
|
||||
return parent::tableInfo($result, $mode);
|
||||
}
|
||||
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
$resource = MDB2::isResultCommon($result) ? $result->getResource() : $result;
|
||||
if (!is_resource($resource)) {
|
||||
return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null,
|
||||
'Could not generate result resource', __FUNCTION__);
|
||||
}
|
||||
|
||||
if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
|
||||
if ($db->options['field_case'] == CASE_LOWER) {
|
||||
$case_func = 'strtolower';
|
||||
} else {
|
||||
$case_func = 'strtoupper';
|
||||
}
|
||||
} else {
|
||||
$case_func = 'strval';
|
||||
}
|
||||
|
||||
$count = @OCINumCols($resource);
|
||||
$res = array();
|
||||
|
||||
if ($mode) {
|
||||
$res['num_fields'] = $count;
|
||||
}
|
||||
|
||||
$db->loadModule('Datatype', null, true);
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$column = array(
|
||||
'table' => '',
|
||||
'name' => $case_func(@OCIColumnName($resource, $i+1)),
|
||||
'type' => @OCIColumnType($resource, $i+1),
|
||||
'length' => @OCIColumnSize($resource, $i+1),
|
||||
'flags' => '',
|
||||
);
|
||||
$res[$i] = $column;
|
||||
$res[$i]['mdb2type'] = $db->datatype->mapNativeDatatype($res[$i]);
|
||||
if ($mode & MDB2_TABLEINFO_ORDER) {
|
||||
$res['order'][$res[$i]['name']] = $i;
|
||||
}
|
||||
if ($mode & MDB2_TABLEINFO_ORDERTABLE) {
|
||||
$res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -80,7 +80,7 @@ class MDB2_Driver_mysql extends MDB2_Driver_Common
|
|||
|
||||
protected $start_transaction = false;
|
||||
|
||||
protected $varchar_max_length = 255;
|
||||
public $varchar_max_length = 255;
|
||||
|
||||
// }}}
|
||||
// {{{ constructor
|
||||
|
|
|
@ -294,6 +294,7 @@ class Sabre_CalDAV_CalendarQueryValidator {
|
|||
// in the VALARM component code, so this is a hack, and an
|
||||
// expensive one too.
|
||||
if ($component->parent->name === 'VEVENT' && $component->parent->RRULE) {
|
||||
|
||||
// Fire up the iterator!
|
||||
$it = new Sabre_VObject_RecurrenceIterator($component->parent->parent, (string)$component->parent->UID);
|
||||
while($it->valid()) {
|
||||
|
@ -303,15 +304,37 @@ class Sabre_CalDAV_CalendarQueryValidator {
|
|||
// one is the first to trigger. Based on this, we can
|
||||
// determine if we can 'give up' expanding events.
|
||||
$firstAlarm = null;
|
||||
foreach($expandedEvent->VALARM as $expandedAlarm) {
|
||||
$effectiveTrigger = $expandedAlarm->getEffectiveTriggerTime();
|
||||
if (!$firstAlarm || $effectiveTrigger < $firstAlarm) {
|
||||
$firstAlarm = $effectiveTrigger;
|
||||
}
|
||||
if ($expandedAlarm->isInTimeRange($start, $end)) {
|
||||
return true;
|
||||
}
|
||||
if ($expandedEvent->VALARM !== null) {
|
||||
foreach($expandedEvent->VALARM as $expandedAlarm) {
|
||||
|
||||
$effectiveTrigger = $expandedAlarm->getEffectiveTriggerTime();
|
||||
if ($expandedAlarm->isInTimeRange($start, $end)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((string)$expandedAlarm->TRIGGER['VALUE'] === 'DATE-TIME') {
|
||||
// This is an alarm with a non-relative trigger
|
||||
// time, likely created by a buggy client. The
|
||||
// implication is that every alarm in this
|
||||
// recurring event trigger at the exact same
|
||||
// time. It doesn't make sense to traverse
|
||||
// further.
|
||||
} else {
|
||||
// We store the first alarm as a means to
|
||||
// figure out when we can stop traversing.
|
||||
if (!$firstAlarm || $effectiveTrigger < $firstAlarm) {
|
||||
$firstAlarm = $effectiveTrigger;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_null($firstAlarm)) {
|
||||
// No alarm was found.
|
||||
//
|
||||
// Or technically: No alarm that will change for
|
||||
// every instance of the recurrence was found,
|
||||
// which means we can assume there was no match.
|
||||
return false;
|
||||
}
|
||||
if ($firstAlarm > $end) {
|
||||
return false;
|
||||
|
|
|
@ -49,23 +49,23 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
/**
|
||||
* The email handler for invites and other scheduling messages.
|
||||
*
|
||||
* @var Sabre_CalDAV_Schedule_IMip
|
||||
*
|
||||
* @var Sabre_CalDAV_Schedule_IMip
|
||||
*/
|
||||
protected $imipHandler;
|
||||
|
||||
/**
|
||||
* Sets the iMIP handler.
|
||||
*
|
||||
* iMIP = The email transport of iCalendar scheduling messages. Setting
|
||||
* this is optional, but if you want the server to allow invites to be sent
|
||||
* iMIP = The email transport of iCalendar scheduling messages. Setting
|
||||
* this is optional, but if you want the server to allow invites to be sent
|
||||
* out, you must set a handler.
|
||||
*
|
||||
* Specifically iCal will plain assume that the server supports this. If
|
||||
* the server doesn't, iCal will display errors when inviting people to
|
||||
* Specifically iCal will plain assume that the server supports this. If
|
||||
* the server doesn't, iCal will display errors when inviting people to
|
||||
* events.
|
||||
*
|
||||
* @param Sabre_CalDAV_Schedule_IMip $imipHandler
|
||||
* @param Sabre_CalDAV_Schedule_IMip $imipHandler
|
||||
* @return void
|
||||
*/
|
||||
public function setIMipHandler(Sabre_CalDAV_Schedule_IMip $imipHandler) {
|
||||
|
@ -672,6 +672,42 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
}
|
||||
|
||||
if ($vobj->name !== 'VCALENDAR') {
|
||||
throw new Sabre_DAV_Exception_UnsupportedMediaType('This collection can only support iCalendar objects.');
|
||||
}
|
||||
|
||||
$foundType = null;
|
||||
$foundUID = null;
|
||||
foreach($vobj->getComponents() as $component) {
|
||||
switch($component->name) {
|
||||
case 'VTIMEZONE' :
|
||||
continue 2;
|
||||
case 'VEVENT' :
|
||||
case 'VTODO' :
|
||||
case 'VJOURNAL' :
|
||||
if (is_null($foundType)) {
|
||||
$foundType = $component->name;
|
||||
if (!isset($component->UID)) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('Every ' . $component->name . ' component must have an UID');
|
||||
}
|
||||
$foundUID = (string)$component->UID;
|
||||
} else {
|
||||
if ($foundType !== $component->name) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('A calendar object must only contain 1 component. We found a ' . $component->name . ' as well as a ' . $foundType);
|
||||
}
|
||||
if ($foundUID !== (string)$component->UID) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('Every ' . $component->name . ' in this object must have identical UIDs');
|
||||
}
|
||||
}
|
||||
break;
|
||||
default :
|
||||
throw new Sabre_DAV_Exception_BadRequest('You are not allowed to create components of type: ' . $component->name . ' here');
|
||||
|
||||
}
|
||||
}
|
||||
if (!$foundType)
|
||||
throw new Sabre_DAV_Exception_BadRequest('iCalendar object must contain at least 1 of VEVENT, VTODO or VJOURNAL');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -687,12 +723,12 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
if (!$originator) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('The Originator: header must be specified when making POST requests');
|
||||
}
|
||||
}
|
||||
if (!$recipients) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('The Recipient: header must be specified when making POST requests');
|
||||
}
|
||||
}
|
||||
|
||||
if (!preg_match('/^mailto:(.*)@(.*)$/', $originator)) {
|
||||
if (!preg_match('/^mailto:(.*)@(.*)$/i', $originator)) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('Originator must start with mailto: and must be valid email address');
|
||||
}
|
||||
$originator = substr($originator,7);
|
||||
|
@ -701,14 +737,14 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
foreach($recipients as $k=>$recipient) {
|
||||
|
||||
$recipient = trim($recipient);
|
||||
if (!preg_match('/^mailto:(.*)@(.*)$/', $recipient)) {
|
||||
if (!preg_match('/^mailto:(.*)@(.*)$/i', $recipient)) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('Recipients must start with mailto: and must be valid email address');
|
||||
}
|
||||
$recipient = substr($recipient, 7);
|
||||
$recipients[$k] = $recipient;
|
||||
}
|
||||
|
||||
// We need to make sure that 'originator' matches one of the email
|
||||
// We need to make sure that 'originator' matches one of the email
|
||||
// addresses of the selected principal.
|
||||
$principal = $outboxNode->getOwner();
|
||||
$props = $this->server->getProperties($principal,array(
|
||||
|
@ -724,7 +760,7 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
throw new Sabre_DAV_Exception_Forbidden('The addresses specified in the Originator header did not match any addresses in the owners calendar-user-address-set header');
|
||||
}
|
||||
|
||||
try {
|
||||
try {
|
||||
$vObject = Sabre_VObject_Reader::read($this->server->httpRequest->getBody(true));
|
||||
} catch (Sabre_VObject_ParseException $e) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('The request body must be a valid iCalendar object. Parse error: ' . $e->getMessage());
|
||||
|
@ -749,9 +785,10 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
}
|
||||
|
||||
if (in_array($method, array('REQUEST','REPLY','ADD','CANCEL')) && $componentType==='VEVENT') {
|
||||
$this->iMIPMessage($originator, $recipients, $vObject);
|
||||
$result = $this->iMIPMessage($originator, $recipients, $vObject);
|
||||
$this->server->httpResponse->sendStatus(200);
|
||||
$this->server->httpResponse->sendBody('Messages sent');
|
||||
$this->server->httpResponse->setHeader('Content-Type','application/xml');
|
||||
$this->server->httpResponse->sendBody($this->generateScheduleResponse($result));
|
||||
} else {
|
||||
throw new Sabre_DAV_Exception_NotImplemented('This iTIP method is currently not implemented');
|
||||
}
|
||||
|
@ -760,18 +797,83 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
/**
|
||||
* Sends an iMIP message by email.
|
||||
*
|
||||
* @param string $originator
|
||||
* @param array $recipients
|
||||
* @param Sabre_VObject_Component $vObject
|
||||
* @return void
|
||||
*
|
||||
* This method must return an array with status codes per recipient.
|
||||
* This should look something like:
|
||||
*
|
||||
* array(
|
||||
* 'user1@example.org' => '2.0;Success'
|
||||
* )
|
||||
*
|
||||
* Formatting for this status code can be found at:
|
||||
* https://tools.ietf.org/html/rfc5545#section-3.8.8.3
|
||||
*
|
||||
* A list of valid status codes can be found at:
|
||||
* https://tools.ietf.org/html/rfc5546#section-3.6
|
||||
*
|
||||
* @param string $originator
|
||||
* @param array $recipients
|
||||
* @param Sabre_VObject_Component $vObject
|
||||
* @return array
|
||||
*/
|
||||
protected function iMIPMessage($originator, array $recipients, Sabre_VObject_Component $vObject) {
|
||||
|
||||
if (!$this->imipHandler) {
|
||||
throw new Sabre_DAV_Exception_NotImplemented('No iMIP handler is setup on this server.');
|
||||
$resultStatus = '5.2;This server does not support this operation';
|
||||
} else {
|
||||
$this->imipHandler->sendMessage($originator, $recipients, $vObject);
|
||||
$resultStatus = '2.0;Success';
|
||||
}
|
||||
$this->imipHandler->sendMessage($originator, $recipients, $vObject);
|
||||
|
||||
$result = array();
|
||||
foreach($recipients as $recipient) {
|
||||
$result[$recipient] = $resultStatus;
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a schedule-response XML body
|
||||
*
|
||||
* The recipients array is a key->value list, containing email addresses
|
||||
* and iTip status codes. See the iMIPMessage method for a description of
|
||||
* the value.
|
||||
*
|
||||
* @param array $recipients
|
||||
* @return string
|
||||
*/
|
||||
public function generateScheduleResponse(array $recipients) {
|
||||
|
||||
$dom = new DOMDocument('1.0','utf-8');
|
||||
$dom->formatOutput = true;
|
||||
$xscheduleResponse = $dom->createElement('cal:schedule-response');
|
||||
$dom->appendChild($xscheduleResponse);
|
||||
|
||||
foreach($this->server->xmlNamespaces as $namespace=>$prefix) {
|
||||
|
||||
$xscheduleResponse->setAttribute('xmlns:' . $prefix, $namespace);
|
||||
|
||||
}
|
||||
|
||||
foreach($recipients as $recipient=>$status) {
|
||||
$xresponse = $dom->createElement('cal:response');
|
||||
|
||||
$xrecipient = $dom->createElement('cal:recipient');
|
||||
$xrecipient->appendChild($dom->createTextNode($recipient));
|
||||
$xresponse->appendChild($xrecipient);
|
||||
|
||||
$xrequestStatus = $dom->createElement('cal:request-status');
|
||||
$xrequestStatus->appendChild($dom->createTextNode($status));
|
||||
$xresponse->appendChild($xrequestStatus);
|
||||
|
||||
$xscheduleResponse->appendChild($xresponse);
|
||||
|
||||
}
|
||||
|
||||
return $dom->saveXML();
|
||||
|
||||
}
|
||||
|
||||
|
|
0
3rdparty/Sabre/CalDAV/Property/SupportedCalendarComponentSet.php
vendored
Normal file → Executable file
|
@ -14,7 +14,7 @@ class Sabre_CalDAV_Version {
|
|||
/**
|
||||
* Full version number
|
||||
*/
|
||||
const VERSION = '1.6.2';
|
||||
const VERSION = '1.6.4';
|
||||
|
||||
/**
|
||||
* Stability : alpha, beta, stable
|
||||
|
|
|
@ -108,7 +108,9 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca
|
|||
*/
|
||||
public function createFile($name,$vcardData = null) {
|
||||
|
||||
$vcardData = stream_get_contents($vcardData);
|
||||
if (is_resource($vcardData)) {
|
||||
$vcardData = stream_get_contents($vcardData);
|
||||
}
|
||||
// Converting to UTF-8, if needed
|
||||
$vcardData = Sabre_DAV_StringUtil::ensureUTF8($vcardData);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* @package Sabre
|
||||
* @subpackage CardDAV
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CardDAV_AddressBookQueryParser {
|
||||
|
@ -88,12 +88,22 @@ class Sabre_CardDAV_AddressBookQueryParser {
|
|||
if (is_nan($limit)) $limit = null;
|
||||
|
||||
$filter = $this->xpath->query('/card:addressbook-query/card:filter');
|
||||
if ($filter->length !== 1) {
|
||||
|
||||
// According to the CardDAV spec there needs to be exactly 1 filter
|
||||
// element. However, KDE 4.8.2 contains a bug that will encode 0 filter
|
||||
// elements, so this is a workaround for that.
|
||||
//
|
||||
// See: https://bugs.kde.org/show_bug.cgi?id=300047
|
||||
if ($filter->length === 0) {
|
||||
$test = null;
|
||||
$filter = null;
|
||||
} elseif ($filter->length === 1) {
|
||||
$filter = $filter->item(0);
|
||||
$test = $this->xpath->evaluate('string(@test)', $filter);
|
||||
} else {
|
||||
throw new Sabre_DAV_Exception_BadRequest('Only one filter element is allowed');
|
||||
}
|
||||
|
||||
$filter = $filter->item(0);
|
||||
$test = $this->xpath->evaluate('string(@test)', $filter);
|
||||
if (!$test) $test = self::TEST_ANYOF;
|
||||
if ($test !== self::TEST_ANYOF && $test !== self::TEST_ALLOF) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('The test attribute must either hold "anyof" or "allof"');
|
||||
|
|
|
@ -52,6 +52,8 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
$server->subscribeEvent('report', array($this,'report'));
|
||||
$server->subscribeEvent('onHTMLActionsPanel', array($this,'htmlActionsPanel'));
|
||||
$server->subscribeEvent('onBrowserPostAction', array($this,'browserPostAction'));
|
||||
$server->subscribeEvent('beforeWriteContent', array($this, 'beforeWriteContent'));
|
||||
$server->subscribeEvent('beforeCreateFile', array($this, 'beforeCreateFile'));
|
||||
|
||||
/* Namespaces */
|
||||
$server->xmlNamespaces[self::NS_CARDDAV] = 'card';
|
||||
|
@ -152,7 +154,10 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
$val = stream_get_contents($val);
|
||||
|
||||
// Taking out \r to not screw up the xml output
|
||||
$returnedProperties[200][$addressDataProp] = str_replace("\r","", $val);
|
||||
//$returnedProperties[200][$addressDataProp] = str_replace("\r","", $val);
|
||||
// The stripping of \r breaks the Mail App in OSX Mountain Lion
|
||||
// this is fixed in master, but not backported. /Tanghus
|
||||
$returnedProperties[200][$addressDataProp] = $val;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -283,6 +288,81 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is triggered before a file gets updated with new content.
|
||||
*
|
||||
* This plugin uses this method to ensure that Card nodes receive valid
|
||||
* vcard data.
|
||||
*
|
||||
* @param string $path
|
||||
* @param Sabre_DAV_IFile $node
|
||||
* @param resource $data
|
||||
* @return void
|
||||
*/
|
||||
public function beforeWriteContent($path, Sabre_DAV_IFile $node, &$data) {
|
||||
|
||||
if (!$node instanceof Sabre_CardDAV_ICard)
|
||||
return;
|
||||
|
||||
$this->validateVCard($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is triggered before a new file is created.
|
||||
*
|
||||
* This plugin uses this method to ensure that Card nodes receive valid
|
||||
* vcard data.
|
||||
*
|
||||
* @param string $path
|
||||
* @param resource $data
|
||||
* @param Sabre_DAV_ICollection $parentNode
|
||||
* @return void
|
||||
*/
|
||||
public function beforeCreateFile($path, &$data, Sabre_DAV_ICollection $parentNode) {
|
||||
|
||||
if (!$parentNode instanceof Sabre_CardDAV_IAddressBook)
|
||||
return;
|
||||
|
||||
$this->validateVCard($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the submitted iCalendar data is in fact, valid.
|
||||
*
|
||||
* An exception is thrown if it's not.
|
||||
*
|
||||
* @param resource|string $data
|
||||
* @return void
|
||||
*/
|
||||
protected function validateVCard(&$data) {
|
||||
|
||||
// If it's a stream, we convert it to a string first.
|
||||
if (is_resource($data)) {
|
||||
$data = stream_get_contents($data);
|
||||
}
|
||||
|
||||
// Converting the data to unicode, if needed.
|
||||
$data = Sabre_DAV_StringUtil::ensureUTF8($data);
|
||||
|
||||
try {
|
||||
|
||||
$vobj = Sabre_VObject_Reader::read($data);
|
||||
|
||||
} catch (Sabre_VObject_ParseException $e) {
|
||||
|
||||
throw new Sabre_DAV_Exception_UnsupportedMediaType('This resource only supports valid vcard data. Parse error: ' . $e->getMessage());
|
||||
|
||||
}
|
||||
|
||||
if ($vobj->name !== 'VCARD') {
|
||||
throw new Sabre_DAV_Exception_UnsupportedMediaType('This collection can only support vcard objects.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function handles the addressbook-query REPORT
|
||||
*
|
||||
|
@ -362,6 +442,8 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
$vcard = Sabre_VObject_Reader::read($vcardData);
|
||||
|
||||
if (!$filters) return true;
|
||||
|
||||
foreach($filters as $filter) {
|
||||
|
||||
$isDefined = isset($vcard->{$filter['name']});
|
||||
|
|
|
@ -16,7 +16,7 @@ class Sabre_CardDAV_Version {
|
|||
/**
|
||||
* Full version number
|
||||
*/
|
||||
const VERSION = '1.6.1';
|
||||
const VERSION = '1.6.3';
|
||||
|
||||
/**
|
||||
* Stability : alpha, beta, stable
|
||||
|
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
|
@ -11,7 +11,7 @@
|
|||
* @package Sabre
|
||||
* @subpackage DAVClient
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Client {
|
||||
|
@ -23,6 +23,28 @@ class Sabre_DAV_Client {
|
|||
protected $password;
|
||||
protected $proxy;
|
||||
|
||||
/**
|
||||
* Basic authentication
|
||||
*/
|
||||
const AUTH_BASIC = 1;
|
||||
|
||||
/**
|
||||
* Digest authentication
|
||||
*/
|
||||
const AUTH_DIGEST = 2;
|
||||
|
||||
/**
|
||||
* The authentication type we're using.
|
||||
*
|
||||
* This is a bitmask of AUTH_BASIC and AUTH_DIGEST.
|
||||
*
|
||||
* If DIGEST is used, the client makes 1 extra request per request, to get
|
||||
* the authentication tokens.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $authType;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
@ -46,16 +68,21 @@ class Sabre_DAV_Client {
|
|||
'baseUri',
|
||||
'userName',
|
||||
'password',
|
||||
'proxy'
|
||||
'proxy',
|
||||
);
|
||||
|
||||
|
||||
foreach($validSettings as $validSetting) {
|
||||
if (isset($settings[$validSetting])) {
|
||||
$this->$validSetting = $settings[$validSetting];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($settings['authType'])) {
|
||||
$this->authType = $settings['authType'];
|
||||
} else {
|
||||
$this->authType = self::AUTH_BASIC | self::AUTH_DIGEST;
|
||||
}
|
||||
|
||||
$this->propertyMap['{DAV:}resourcetype'] = 'Sabre_DAV_Property_ResourceType';
|
||||
|
||||
}
|
||||
|
@ -250,14 +277,9 @@ class Sabre_DAV_Client {
|
|||
// Automatically follow redirects
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_MAXREDIRS => 5,
|
||||
CURLOPT_SSL_VERIFYPEER => true,
|
||||
//CURLOPT_SSL_VERIFYPEER => false,
|
||||
);
|
||||
|
||||
switch ($method) {
|
||||
case 'PUT':
|
||||
$curlSettings[CURLOPT_PUT] = true;
|
||||
break;
|
||||
case 'HEAD' :
|
||||
|
||||
// do not read body with HEAD requests (this is neccessary because cURL does not ignore the body with HEAD
|
||||
|
@ -288,8 +310,15 @@ class Sabre_DAV_Client {
|
|||
$curlSettings[CURLOPT_PROXY] = $this->proxy;
|
||||
}
|
||||
|
||||
if ($this->userName) {
|
||||
$curlSettings[CURLOPT_HTTPAUTH] = CURLAUTH_BASIC | CURLAUTH_DIGEST;
|
||||
if ($this->userName && $this->authType) {
|
||||
$curlType = 0;
|
||||
if ($this->authType & self::AUTH_BASIC) {
|
||||
$curlType |= CURLAUTH_BASIC;
|
||||
}
|
||||
if ($this->authType & self::AUTH_DIGEST) {
|
||||
$curlType |= CURLAUTH_DIGEST;
|
||||
}
|
||||
$curlSettings[CURLOPT_HTTPAUTH] = $curlType;
|
||||
$curlSettings[CURLOPT_USERPWD] = $this->userName . ':' . $this->password;
|
||||
}
|
||||
|
||||
|
|