diff options
author | Tom Needham <needham.thomas@gmail.com> | 2012-01-01 01:18:02 +0000 |
---|---|---|
committer | Tom Needham <needham.thomas@gmail.com> | 2012-01-01 01:18:02 +0000 |
commit | cbb2db8622dbcff2314204bc548ebdd3005bd0fc (patch) | |
tree | bbe14faf0201b4131b8ca9c9d4eac59edb7da5e8 /lib | |
parent | e7de25434206a4849a7c7315d4d9926325c7b730 (diff) | |
parent | eb4cd869107d4afa1c259751e765ca39defb9279 (diff) | |
download | nextcloud-server-cbb2db8622dbcff2314204bc548ebdd3005bd0fc.tar.gz nextcloud-server-cbb2db8622dbcff2314204bc548ebdd3005bd0fc.zip |
Fix merge conflicts
Diffstat (limited to 'lib')
-rw-r--r-- | lib/app.php | 2 | ||||
-rw-r--r-- | lib/db.php | 2 | ||||
-rw-r--r-- | lib/helper.php | 25 | ||||
-rw-r--r-- | lib/updater.php | 10 | ||||
-rw-r--r-- | lib/util.php | 4 | ||||
-rw-r--r-- | lib/vobject.php | 207 |
6 files changed, 224 insertions, 26 deletions
diff --git a/lib/app.php b/lib/app.php index d3d99865762..b1aa8ba354d 100644 --- a/lib/app.php +++ b/lib/app.php @@ -223,7 +223,7 @@ class OC_App{ // admin apps menu $settings[] = array( "id" => "core_apps", "order" => 3, "href" => OC_Helper::linkTo( "settings", "apps.php?installed" ), "name" => $l->t("Apps"), "icon" => OC_Helper::imagePath( "settings", "apps.svg" )); // admin log menu - $settings[] = array( "id" => "core_log", "order" => 4, "href" => OC_Helper::linkTo( "settings", "log.php" ), "name" => $l->t("Log"), "icon" => OC_Helper::imagePath( "log", "apps.svg" )); + $settings[] = array( "id" => "core_log", "order" => 4, "href" => OC_Helper::linkTo( "settings", "log.php" ), "name" => $l->t("Log"), "icon" => OC_Helper::imagePath( "settings", "log.svg" )); $settings[]=array( "id" => "admin", "order" => 1000, "href" => OC_Helper::linkTo( "settings", "admin.php" ), "name" => $l->t("Admin"), "icon" => OC_Helper::imagePath( "settings", "admin.svg" )); } diff --git a/lib/db.php b/lib/db.php index c059f5ab336..bcfe320665f 100644 --- a/lib/db.php +++ b/lib/db.php @@ -492,7 +492,7 @@ class PDOStatementWrapper{ } /** - * make exucute return the result instead of a bool + * make execute return the result instead of a bool */ public function execute($input=array()){ $this->lastArguments=$input; diff --git a/lib/helper.php b/lib/helper.php index 5b3e394cafd..24d436225b7 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -160,24 +160,25 @@ class OC_Helper { */ public static function computerFileSize( $str ){ $bytes = 0; + $str=strtolower($str); $bytes_array = array( - 'B' => 1, - 'K' => 1024, - 'KB' => 1024, - 'MB' => 1024 * 1024, - 'M' => 1024 * 1024, - 'GB' => 1024 * 1024 * 1024, - 'G' => 1024 * 1024 * 1024, - 'TB' => 1024 * 1024 * 1024 * 1024, - 'T' => 1024 * 1024 * 1024 * 1024, - 'PB' => 1024 * 1024 * 1024 * 1024 * 1024, - 'P' => 1024 * 1024 * 1024 * 1024 * 1024, + 'b' => 1, + 'k' => 1024, + 'kb' => 1024, + 'mb' => 1024 * 1024, + 'm' => 1024 * 1024, + 'gb' => 1024 * 1024 * 1024, + 'g' => 1024 * 1024 * 1024, + 'tb' => 1024 * 1024 * 1024 * 1024, + 't' => 1024 * 1024 * 1024 * 1024, + 'pb' => 1024 * 1024 * 1024 * 1024 * 1024, + 'p' => 1024 * 1024 * 1024 * 1024 * 1024, ); $bytes = floatval($str); - if (preg_match('#([KMGTP]?B?)$#si', $str, $matches) && !empty($bytes_array[$matches[1]])) { + if (preg_match('#([kmgtp]?b?)$#si', $str, $matches) && !empty($bytes_array[$matches[1]])) { $bytes *= $bytes_array[$matches[1]]; } diff --git a/lib/updater.php b/lib/updater.php index e4db719a62c..cc4a4602539 100644 --- a/lib/updater.php +++ b/lib/updater.php @@ -52,13 +52,9 @@ class OC_Updater{ $tmp['url'] = $data->url; $tmp['web'] = $data->web; - return $tmp; - } - - public static function ShowUpdatingHint(){ $data=OC_Updater::check(); if(isset($data['version']) and $data['version']<>'') { @@ -67,10 +63,8 @@ class OC_Updater{ $txt='Your ownCloud is up to date'; } return($txt); - } - /** * do ownCloud update */ @@ -83,9 +77,5 @@ class OC_Updater{ //update version in config } - } - - - ?> diff --git a/lib/util.php b/lib/util.php index 0f79948bc24..9cf78da6e90 100644 --- a/lib/util.php +++ b/lib/util.php @@ -175,8 +175,8 @@ class OC_Util { $errors=array(); //check for database drivers - if(!is_callable('sqlite_open') and !is_callable('mysql_connect')){ - $errors[]=array('error'=>'No database drivers (sqlite or mysql) installed.<br/>','hint'=>'');//TODO: sane hint + if(!is_callable('sqlite_open') and !is_callable('mysql_connect') and !is_callable('pg_connect')){ + $errors[]=array('error'=>'No database drivers (sqlite, mysql, or postgresql) installed.<br/>','hint'=>'');//TODO: sane hint } $CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" ); $CONFIG_DBNAME = OC_Config::getValue( "dbname", "owncloud" ); diff --git a/lib/vobject.php b/lib/vobject.php new file mode 100644 index 00000000000..e3479fc6d36 --- /dev/null +++ b/lib/vobject.php @@ -0,0 +1,207 @@ +<?php +/** + * ownCloud + * + * @author Bart Visscher + * @copyright 2011 Bart Visscher bartv@thisnet.nl + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ + +/** + * This class provides a streamlined interface to the Sabre VObject classes + */ +class OC_VObject{ + /** @var Sabre_VObject_Component */ + protected $vobject; + + /** + * @returns Sabre_VObject_Component + */ + public function getVObject(){ + return $this->vobject; + } + + /** + * @brief Parses the VObject + * @param string VObject as string + * @returns Sabre_VObject or null + */ + public static function parse($data){ + try { + Sabre_VObject_Reader::$elementMap['LAST-MODIFIED'] = 'Sabre_VObject_Element_DateTime'; + $vobject = Sabre_VObject_Reader::read($data); + if ($vobject instanceof Sabre_VObject_Component){ + $vobject = new OC_VObject($vobject); + } + return $vobject; + } catch (Exception $e) { + OC_Log::write('vobject', $e->getMessage(), OC_Log::ERROR); + return null; + } + } + + /** + * @brief Escapes semicolons + * @param string $value + * @return string + */ + public static function escapeSemicolons($value){ + foreach($value as &$i ){ + $i = implode("\\\\;", explode(';', $i)); + } + return implode(';',$value); + } + + /** + * @brief Creates an array out of a multivalue property + * @param string $value + * @return array + */ + public static function unescapeSemicolons($value){ + $array = explode(';',$value); + for($i=0;$i<count($array);$i++){ + if(substr($array[$i],-2,2)=="\\\\"){ + if(isset($array[$i+1])){ + $array[$i] = substr($array[$i],0,count($array[$i])-2).';'.$array[$i+1]; + unset($array[$i+1]); + } + else{ + $array[$i] = substr($array[$i],0,count($array[$i])-2).';'; + } + $i = $i - 1; + } + } + return $array; + } + + /** + * Constuctor + * @param Sabre_VObject_Component or string + */ + public function __construct($vobject_or_name){ + if (is_object($vobject_or_name)){ + $this->vobject = $vobject_or_name; + } else { + $this->vobject = new Sabre_VObject_Component($vobject_or_name); + } + } + + public function add($item, $itemValue = null){ + if ($item instanceof OC_VObject){ + $item = $item->getVObject(); + } + $this->vobject->add($item, $itemValue); + } + + /** + * @brief Add property to vobject + * @param object $name of property + * @param object $value of property + * @param object $parameters of property + * @returns Sabre_VObject_Property newly created + */ + public function addProperty($name, $value, $parameters=array()){ + if(is_array($value)){ + $value = OC_VObject::escapeSemicolons($value); + } + $property = new Sabre_VObject_Property( $name, $value ); + foreach($parameters as $name => $value){ + $property->parameters[] = new Sabre_VObject_Parameter($name, $value); + } + + $this->vobject->add($property); + return $property; + } + + public function setUID(){ + $uid = substr(md5(rand().time()),0,10); + $this->vobject->add('UID',$uid); + } + + public function setString($name, $string){ + if ($string != ''){ + $string = strtr($string, array("\r\n"=>"\n")); + $this->vobject->__set($name, $string); + }else{ + $this->vobject->__unset($name); + } + } + + /** + * Sets or unsets the Date and Time for a property. + * When $datetime is set to 'now', use the current time + * When $datetime is null, unset the property + * + * @param string property name + * @param DateTime $datetime + * @param int $dateType + * @return void + */ + public function setDateTime($name, $datetime, $dateType=Sabre_VObject_Element_DateTime::LOCALTZ){ + if ($datetime == 'now'){ + $datetime = new DateTime(); + } + if ($datetime instanceof DateTime){ + $datetime_element = new Sabre_VObject_Element_DateTime($name); + $datetime_element->setDateTime($datetime, $dateType); + $this->vobject->__set($name, $datetime_element); + }else{ + $this->vobject->__unset($name); + } + } + + public function getAsString($name){ + return $this->vobject->__isset($name) ? + $this->vobject->__get($name)->value : + ''; + } + + public function getAsArray($name){ + $values = array(); + if ($this->vobject->__isset($name)){ + $values = explode(',', $this->getAsString($name)); + $values = array_map('trim', $values); + } + return $values; + } + + public function &__get($name){ + if ($name == 'children'){ + return $this->vobject->children; + } + $return = $this->vobject->__get($name); + if ($return instanceof Sabre_VObject_Component){ + $return = new OC_VObject($return); + } + return $return; + } + + public function __set($name, $value){ + return $this->vobject->__set($name, $value); + } + + public function __unset($name){ + return $this->vobject->__unset($name); + } + + public function __isset($name){ + return $this->vobject->__isset($name); + } + + public function __call($function,$arguments){ + return call_user_func_array(array($this->vobject, $function), $arguments); + } +} |