From fffbf261590c15bac92e9437fe7d4b99a485a072 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 23 Apr 2012 11:21:13 +0200 Subject: [PATCH 1/6] don't forget to declare class properties --- apps/user_ldap/group_ldap.php | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/user_ldap/group_ldap.php b/apps/user_ldap/group_ldap.php index e5948459dd0..b1619e06530 100644 --- a/apps/user_ldap/group_ldap.php +++ b/apps/user_ldap/group_ldap.php @@ -25,6 +25,7 @@ class OC_GROUP_LDAP extends OC_Group_Backend { // //group specific settings protected $ldapGroupFilter; protected $ldapGroupDisplayName; + protected $ldapGroupMemberAttr; public function __construct() { $this->ldapGroupFilter = OC_Appconfig::getValue('user_ldap', 'ldap_group_filter', '(objectClass=posixGroup)'); From 6ee7dc5f590e26f54d2a986a72bb328ed0b0db8f Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 23 Apr 2012 12:32:17 +0200 Subject: [PATCH 2/6] only retrieve requested attributes --- apps/user_ldap/lib_ldap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/user_ldap/lib_ldap.php b/apps/user_ldap/lib_ldap.php index eea4a82011c..1016b955dcb 100644 --- a/apps/user_ldap/lib_ldap.php +++ b/apps/user_ldap/lib_ldap.php @@ -73,7 +73,7 @@ class OC_LDAP { * Executes an LDAP search */ static public function search($filter, $attr = null) { - $sr = ldap_search(self::getConnectionResource(), self::$ldapBase, $filter); + $sr = ldap_search(self::getConnectionResource(), self::$ldapBase, $filter, array($attr)); $findings = ldap_get_entries(self::getConnectionResource(), $sr ); if(!is_null($attr)) { From 912c87eedaa3ea909d5721d8066fa4455529aa1b Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Mon, 23 Apr 2012 13:04:58 +0200 Subject: [PATCH 3/6] LDAP: optimize LDAP requests for users and groups. Settings are still to do, though. --- apps/user_ldap/group_ldap.php | 27 +++++++++++------------- apps/user_ldap/lib_ldap.php | 39 +++++++++++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 19 deletions(-) diff --git a/apps/user_ldap/group_ldap.php b/apps/user_ldap/group_ldap.php index b1619e06530..fe0789cdeb7 100644 --- a/apps/user_ldap/group_ldap.php +++ b/apps/user_ldap/group_ldap.php @@ -47,14 +47,12 @@ class OC_GROUP_LDAP extends OC_Group_Backend { LDAP_GROUP_MEMBER_ASSOC_ATTR.'='.$uid, $this->ldapGroupDisplayName.'='.$gid )); - $groups = OC_LDAP::search($filter, $this->ldapGroupDisplayName); + $groups = $this->retrieveList($filter, $this->ldapGroupDisplayName); - if(count($groups) == 1) { + if(count($groups) > 0) { return true; - } else if(count($groups) < 1) { - return false; } else { - throw new Exception('Too many groups of the same name!? – this exception should never been thrown :)'); + return false; } } @@ -85,7 +83,7 @@ class OC_GROUP_LDAP extends OC_Group_Backend { $this->ldapGroupDisplayName.'='.$gid )); - return $this->retrieveList($filter, $this->ldapGroupMemberAttr); + return $this->retrieveList($filter, $this->ldapGroupMemberAttr, false); } /** @@ -95,13 +93,7 @@ class OC_GROUP_LDAP extends OC_Group_Backend { * Returns a list with all groups */ public function getGroups() { - $groups = OC_LDAP::search($this->ldapGroupFilter, $this->ldapGroupDisplayName); - - if(count($groups) == 0 ) - return array(); - else { - return array_unique($groups, SORT_LOCALE_STRING); - } + return $this->retrieveList($this->ldapGroupFilter, $this->ldapGroupDisplayName); } /** @@ -113,8 +105,13 @@ class OC_GROUP_LDAP extends OC_Group_Backend { return in_array($gid, $this->getGroups()); } - private function retrieveList($filter, $attr) { - $list = OC_LDAP::search($filter, $attr); + private function retrieveList($filter, $attr, $searchForGroups = true) { + if($searchForGroups) { + $list = OC_LDAP::searchGroups($filter, $attr); + } else { + $list = OC_LDAP::searchUsers($filter, $attr); + } + if(is_array($list)) { return array_unique($list, SORT_LOCALE_STRING); diff --git a/apps/user_ldap/lib_ldap.php b/apps/user_ldap/lib_ldap.php index 1016b955dcb..752ac4f2289 100644 --- a/apps/user_ldap/lib_ldap.php +++ b/apps/user_ldap/lib_ldap.php @@ -38,6 +38,8 @@ class OC_LDAP { static protected $ldapHost; static protected $ldapPort; static protected $ldapBase; + static protected $ldapBaseUsers; + static protected $ldapBaseGroups; static protected $ldapAgentName; static protected $ldapAgentPassword; static protected $ldapTLS; @@ -65,15 +67,40 @@ class OC_LDAP { } /** - * @brief executes an LDAP search + * @brief executes an LDAP search, optimized for Users * @param $filter the LDAP filter for the search * @param $attr optional, when a certain attribute shall be filtered out * @returns array with the search result * * Executes an LDAP search */ - static public function search($filter, $attr = null) { - $sr = ldap_search(self::getConnectionResource(), self::$ldapBase, $filter, array($attr)); + static public function searchUsers($filter, $attr = null) { + return self::search($filter, self::$ldapBaseUsers, $attr); + } + + /** + * @brief executes an LDAP search, optimized for Groups + * @param $filter the LDAP filter for the search + * @param $attr optional, when a certain attribute shall be filtered out + * @returns array with the search result + * + * Executes an LDAP search + */ + static public function searchGroups($filter, $attr = null) { + return self::search($filter, self::$ldapBaseGroups, $attr); + } + + /** + * @brief executes an LDAP search + * @param $filter the LDAP filter for the search + * @param $base the LDAP subtree that shall be searched + * @param $attr optional, when a certain attribute shall be filtered out + * @returns array with the search result + * + * Executes an LDAP search + */ + static private function search($filter, $base, $attr = null) { + $sr = ldap_search(self::getConnectionResource(), $base, $filter, array($attr)); $findings = ldap_get_entries(self::getConnectionResource(), $sr ); if(!is_null($attr)) { @@ -150,7 +177,9 @@ class OC_LDAP { self::$ldapPort = OC_Appconfig::getValue('user_ldap', 'ldap_port', OC_USER_BACKEND_LDAP_DEFAULT_PORT); self::$ldapAgentName = OC_Appconfig::getValue('user_ldap', 'ldap_dn',''); self::$ldapAgentPassword = OC_Appconfig::getValue('user_ldap', 'ldap_password',''); - self::$ldapBase = OC_Appconfig::getValue('user_ldap', 'ldap_base',''); + self::$ldapBase = OC_Appconfig::getValue('user_ldap', 'ldap_base', ''); + self::$ldapBaseUsers = OC_Appconfig::getValue('user_ldap', 'ldap_base_users',self::$ldapBase); + self::$ldapBaseGroups = OC_Appconfig::getValue('user_ldap', 'ldap_base_groups', self::$ldapBase); self::$ldapTLS = OC_Appconfig::getValue('user_ldap', 'ldap_tls',0); self::$ldapNoCase = OC_Appconfig::getValue('user_ldap', 'ldap_nocase', 0); self::$ldapUserDisplayName = OC_Appconfig::getValue('user_ldap', 'ldap_display_name', OC_USER_BACKEND_LDAP_DEFAULT_DISPLAY_NAME); @@ -163,6 +192,8 @@ class OC_LDAP { || ( empty(self::$ldapAgentName) && empty(self::$ldapAgentPassword)) ) && !empty(self::$ldapBase) + && !empty(self::$ldapBaseUsers) + && !empty(self::$ldapBaseGroups) && !empty(self::$ldapUserDisplayName) ) { From 3ba9a9e6a8a49277583a56543fe8a55f985da564 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Mon, 23 Apr 2012 14:19:03 +0200 Subject: [PATCH 4/6] adding proper copyright and license notice to the style files --- apps/files_sharing/css/sharing.css | 6 +++++- apps/media/css/music.css | 4 ++++ core/css/multiselect.css | 4 ++++ core/css/styles.css | 2 +- files/css/files.css | 2 +- search/css/results.css | 4 ++++ settings/css/settings.css | 4 ++++ 7 files changed, 23 insertions(+), 3 deletions(-) diff --git a/apps/files_sharing/css/sharing.css b/apps/files_sharing/css/sharing.css index db59a3d340b..5acd9af589a 100644 --- a/apps/files_sharing/css/sharing.css +++ b/apps/files_sharing/css/sharing.css @@ -1,3 +1,7 @@ +/* Copyright (c) 2011, Jan-Christoph Borchardt, http://jancborchardt.net + This file is licensed under the Affero General Public License version 3 or later. + See the COPYING-README file. */ + #dropdown { display:block; position:absolute; z-index:100; width:16em; right:0; margin-right:7em; background:#eee; padding:1em; -moz-box-shadow:0 1px 1px #777; -webkit-box-shadow:0 1px 1px #777; box-shadow:0 1px 1px #777; -moz-border-radius-bottomleft:1em; -webkit-border-bottom-left-radius:1em; border-bottom-left-radius:1em; @@ -6,4 +10,4 @@ #public { border-top:1px solid #ddd; padding-top:0.5em; } a.unshare { float:right; display:inline; margin:0 .5em; padding:.3em .3em 0 .3em !important; opacity:.5; } a.unshare:hover { opacity:1; } -#share_with { width: 16em; } \ No newline at end of file +#share_with { width: 16em; } diff --git a/apps/media/css/music.css b/apps/media/css/music.css index 164a6c62ae6..c782e8afeeb 100644 --- a/apps/media/css/music.css +++ b/apps/media/css/music.css @@ -1,3 +1,7 @@ +/* Copyright (c) 2011, Jan-Christoph Borchardt, http://jancborchardt.net + This file is licensed under the Affero General Public License version 3 or later. + See the COPYING-README file. */ + #controls ul.jp-controls { padding:0; } #controls ul.jp-controls li { display:inline; } #controls ul.jp-controls li a { position:absolute; padding:.8em 1em .8em 0; } diff --git a/core/css/multiselect.css b/core/css/multiselect.css index 1202ea18427..3dac0ea1a16 100644 --- a/core/css/multiselect.css +++ b/core/css/multiselect.css @@ -1,3 +1,7 @@ +/* Copyright (c) 2011, Jan-Christoph Borchardt, http://jancborchardt.net + This file is licensed under the Affero General Public License version 3 or later. + See the COPYING-README file. */ + ul.multiselectoptions { z-index:49; position:absolute; background-color:#fff; padding-top:.5em; border:1px solid #ddd; border-top:none; -moz-border-radius-bottomleft:.5em; -webkit-border-bottom-left-radius:.5em; border-bottom-left-radius:.5em; -moz-border-radius-bottomright:.5em; -webkit-border-bottom-right-radius:.5em; border-bottom-right-radius:.5em; -moz-box-shadow:0 1px 1px #ddd; -webkit-box-shadow:0 1px 1px #ddd; box-shadow:0 1px 1px #ddd; } ul.multiselectoptions>li{ white-space:nowrap; overflow: hidden; } div.multiselect { padding-right:.6em; display:inline; position:relative; display:inline-block; vertical-align: bottom; } diff --git a/core/css/styles.css b/core/css/styles.css index ccebc984fbb..945e5846683 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Jan-Christoph Borchardt +/* Copyright (c) 2011, Jan-Christoph Borchardt, http://jancborchardt.net This file is licensed under the Affero General Public License version 3 or later. See the COPYING-README file. */ diff --git a/files/css/files.css b/files/css/files.css index fd551b27625..2cf4f38fd20 100644 --- a/files/css/files.css +++ b/files/css/files.css @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Jan-Christoph Borchardt +/* Copyright (c) 2011, Jan-Christoph Borchardt, http://jancborchardt.net This file is licensed under the Affero General Public License version 3 or later. See the COPYING-README file. */ diff --git a/search/css/results.css b/search/css/results.css index 440e68ee48f..40d5563e89e 100644 --- a/search/css/results.css +++ b/search/css/results.css @@ -1,3 +1,7 @@ +/* Copyright (c) 2011, Jan-Christoph Borchardt, http://jancborchardt.net + This file is licensed under the Affero General Public License version 3 or later. + See the COPYING-README file. */ + #searchresults { list-style:none; position:fixed; top:3.5em; right:0; z-index:75; background-color:#fff; overflow:hidden; text-overflow:ellipsis; max-height:80%; width:26.5em; padding-bottom:1em; -moz-box-shadow:0 0 10px #000; -webkit-box-shadow:0 0 10px #000; box-shadow:0 0 10px #000; -moz-border-radius-bottomleft:1em; -webkit-border-bottom-left-radius:1em; border-bottom-left-radius:1em; } #searchresults li.resultHeader { font-size:1.2em; font-weight:bold; border-bottom:solid 1px #CCC; padding:.2em; background-color:#eee; } #searchresults li.result { margin-left:2em; } diff --git a/settings/css/settings.css b/settings/css/settings.css index 62e84654d55..36d9b8d26f9 100644 --- a/settings/css/settings.css +++ b/settings/css/settings.css @@ -1,3 +1,7 @@ +/* Copyright (c) 2011, Jan-Christoph Borchardt, http://jancborchardt.net + This file is licensed under the Affero General Public License version 3 or later. + See the COPYING-README file. */ + select#languageinput, select#timezone { width:15em; } input#openid, input#webdav { width:20em; } From 1b29fc3fb2b090ca132cbe496276c3c0cc2e466e Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Mon, 23 Apr 2012 14:29:11 +0200 Subject: [PATCH 5/6] fixing multiselect overflow, issue 341 --- core/css/multiselect.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/css/multiselect.css b/core/css/multiselect.css index 3dac0ea1a16..040b0f46ed3 100644 --- a/core/css/multiselect.css +++ b/core/css/multiselect.css @@ -4,8 +4,8 @@ ul.multiselectoptions { z-index:49; position:absolute; background-color:#fff; padding-top:.5em; border:1px solid #ddd; border-top:none; -moz-border-radius-bottomleft:.5em; -webkit-border-bottom-left-radius:.5em; border-bottom-left-radius:.5em; -moz-border-radius-bottomright:.5em; -webkit-border-bottom-right-radius:.5em; border-bottom-right-radius:.5em; -moz-box-shadow:0 1px 1px #ddd; -webkit-box-shadow:0 1px 1px #ddd; box-shadow:0 1px 1px #ddd; } ul.multiselectoptions>li{ white-space:nowrap; overflow: hidden; } -div.multiselect { padding-right:.6em; display:inline; position:relative; display:inline-block; vertical-align: bottom; } +div.multiselect { padding-right:.6em; display:inline; position:relative; display:inline-block; vertical-align: bottom; min-width:100px; max-width:400px; } div.multiselect.active { background-color:#fff; border-bottom:none; border-bottom-left-radius:0; border-bottom-right-radius:0; z-index:50; position:relative } -div.multiselect>span:first-child { margin-right:2em; float:left; } -div.multiselect>span:last-child { float:right; position:relative } +div.multiselect>span:first-child { margin-right:2em; float:left; width:90%; overflow:hidden; text-overflow:ellipsis; } +div.multiselect>span:last-child { position:absolute; right:.8em; } ul.multiselectoptions input.new{ margin:0; padding-bottom:0.2em; padding-top:0.2em; border-top-left-radius:0; border-top-right-radius:0; } From f5c9fe9ece6fdfb35bab5eefdf83830b5045b5a8 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Mon, 23 Apr 2012 15:50:30 +0200 Subject: [PATCH 6/6] =?UTF-8?q?first=20step=20to=20an=20public=20api=20of?= =?UTF-8?q?=20ownCloud=20for=20the=20apps.=20In=20the=20future=20they=20sh?= =?UTF-8?q?ouldn=C2=B4t=20call=20internall=20classes,=20functions=20or=20s?= =?UTF-8?q?ession=20variables=20because=20this=20will=20change=20and=20bre?= =?UTF-8?q?ak=20in=20upcoming=20versions.=20Apps=20should=20only=20call=20?= =?UTF-8?q?this=20public=20interface=20that=20we=20will=20kepp=20stable=20?= =?UTF-8?q?over=20different=20releases.=20The=20namespace=20is=20OCP=20for?= =?UTF-8?q?=20ownCloud=20public.=20This=20is=20just=20the=20first=20step.?= =?UTF-8?q?=20more=20coming=20soon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/base.php | 3 +++ lib/public/util.php | 60 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 lib/public/util.php diff --git a/lib/base.php b/lib/base.php index f3dacdc0f76..5c42000b9e1 100644 --- a/lib/base.php +++ b/lib/base.php @@ -81,6 +81,9 @@ class OC{ elseif(strpos($className,'OC_')===0){ require_once strtolower(str_replace('_','/',substr($className,3)) . '.php'); } + elseif(strpos($className,'OCP\\')===0){ + require_once 'public/'.strtolower(str_replace('\\','/',substr($className,3)) . '.php'); + } elseif(strpos($className,'Sabre_')===0) { require_once str_replace('_','/',$className) . '.php'; } diff --git a/lib/public/util.php b/lib/public/util.php new file mode 100644 index 00000000000..3425ed9df3b --- /dev/null +++ b/lib/public/util.php @@ -0,0 +1,60 @@ +. +* +*/ + +/** + * Public interface of ownCloud for apps to use. + * Utility Class. + * + */ + +// use OCP namespace for all classes that are considered public. +// This means that they should be used by apps instead of the internal ownCloud classes +namespace OCP; + +class Util { + + /** + * send an email + * + * @param string $toaddress + * @param string $toname + * @param string $subject + * @param string $mailtext + * @param string $fromaddress + * @param string $fromname + * @param bool $html + */ + public static function sendmail($toaddress,$toname,$subject,$mailtext,$fromaddress,$fromname,$html=0,$altbody='',$ccaddress='',$ccname='',$bcc='') { + + // call the internal mail class + OC_MAIL::send($toaddress,$toname,$subject,$mailtext,$fromaddress,$fromname,$html=0,$altbody='',$ccaddress='',$ccname='',$bcc=''); + + } + + + +} + + + + +?>