Merge branch 'master' into calendar_repeat
This commit is contained in:
commit
4d1428db0f
|
@ -25,10 +25,15 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
|
|||
// //group specific settings
|
||||
protected $ldapGroupFilter;
|
||||
protected $ldapGroupMemberAssocAttr;
|
||||
protected $configured = false;
|
||||
|
||||
public function __construct() {
|
||||
$this->ldapGroupFilter = OCP\Config::getAppValue('user_ldap', 'ldap_group_filter', '(objectClass=posixGroup)');
|
||||
$this->ldapGroupMemberAssocAttr = OCP\Config::getAppValue('user_ldap', 'ldap_group_member_assoc_attribute', 'uniqueMember');
|
||||
|
||||
if(!empty($this->ldapGroupFilter) && !empty($this->ldapGroupMemberAssocAttr)) {
|
||||
$this->configured = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,6 +45,9 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
|
|||
* Checks whether the user is member of a group or not.
|
||||
*/
|
||||
public function inGroup($uid, $gid) {
|
||||
if(!$this->configured) {
|
||||
return false;
|
||||
}
|
||||
$dn_user = OC_LDAP::username2dn($uid);
|
||||
$dn_group = OC_LDAP::groupname2dn($gid);
|
||||
// just in case
|
||||
|
@ -79,6 +87,9 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
|
|||
* if the user exists at all.
|
||||
*/
|
||||
public function getUserGroups($uid) {
|
||||
if(!$this->configured) {
|
||||
return array();
|
||||
}
|
||||
$userDN = OC_LDAP::username2dn($uid);
|
||||
if(!$userDN) {
|
||||
return array();
|
||||
|
@ -111,6 +122,10 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
|
|||
* @returns array with user ids
|
||||
*/
|
||||
public function usersInGroup($gid) {
|
||||
if(!$this->configured) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$groupDN = OC_LDAP::groupname2dn($gid);
|
||||
if(!$groupDN) {
|
||||
return array();
|
||||
|
@ -149,6 +164,10 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
|
|||
* Returns a list with all groups
|
||||
*/
|
||||
public function getGroups() {
|
||||
if(!$this->configured) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$ldap_groups = OC_LDAP::fetchListOfGroups($this->ldapGroupFilter, array(OC_LDAP::conf('ldapGroupDisplayName'), 'dn'));
|
||||
$groups = OC_LDAP::ownCloudGroupNames($ldap_groups);
|
||||
return $groups;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<form id="openidform">
|
||||
<fieldset class="personalblock">
|
||||
<strong>OpenID</strong>
|
||||
<?php echo ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http').'://'.OCP\Util::getServerHost().OC::$WEBROOT.'/?'; echo OCP\USER::getUser(); ?><br /><em><?php echo $l->t('you can authenticate to other sites with this address');?></em><br />
|
||||
<?php echo (OCP\Util::getServerProtocol()).'://'.OCP\Util::getServerHost().OC::$WEBROOT.'/?'; echo OCP\USER::getUser(); ?><br /><em><?php echo $l->t('you can authenticate to other sites with this address');?></em><br />
|
||||
<label for="identity"><?php echo $l->t('Authorized OpenID provider');?></label>
|
||||
<input type="text" name="identity" id="identity" value="<?php echo $_['identity']; ?>" placeholder="<?php echo $l->t('Your address at Wordpress, Identi.ca, …');?>" /><span class="msg"></span>
|
||||
</fieldset>
|
||||
|
|
|
@ -329,6 +329,11 @@ class OC{
|
|||
date_default_timezone_set('UTC');
|
||||
ini_set('arg_separator.output','&');
|
||||
|
||||
// try to switch magic quotes off.
|
||||
if(function_exists('set_magic_quotes_runtime')) {
|
||||
@set_magic_quotes_runtime(false);
|
||||
}
|
||||
|
||||
//try to configure php to enable big file uploads.
|
||||
//this doesn´t work always depending on the webserver and php configuration.
|
||||
//Let´s try to overwrite some defaults anyways
|
||||
|
|
|
@ -419,7 +419,7 @@ class OC_FileCache{
|
|||
}
|
||||
return $result;
|
||||
}else{
|
||||
OC_Log::write('files','getChached(): file not found in cache ('.$path.')',OC_Log::DEBUG);
|
||||
OC_Log::write('files','getCached(): file not found in cache ('.$path.')',OC_Log::DEBUG);
|
||||
if(isset(self::$savedData[$path])){
|
||||
return self::$savedData[$path];
|
||||
}else{
|
||||
|
|
|
@ -233,6 +233,7 @@ class OC_Group {
|
|||
|
||||
$groups=array_merge($backend->getUserGroups($uid),$groups);
|
||||
}
|
||||
asort($groups);
|
||||
return $groups;
|
||||
}
|
||||
|
||||
|
@ -250,6 +251,7 @@ class OC_Group {
|
|||
|
||||
$groups=array_merge($backend->getGroups(),$groups);
|
||||
}
|
||||
asort($groups);
|
||||
return $groups;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,23 +62,26 @@ class OC_Log_Owncloud {
|
|||
public static function getEntries($limit=50, $offset=0){
|
||||
self::init();
|
||||
$minLevel=OC_Config::getValue( "loglevel", OC_Log::WARN );
|
||||
$entries=array();
|
||||
if(!file_exists(self::$logFile)) {
|
||||
return array();
|
||||
}
|
||||
$contents=file(self::$logFile);
|
||||
if(!$contents) {//error while reading log
|
||||
return array();
|
||||
}
|
||||
$end=max(count($contents)-$offset-1, 0);
|
||||
$start=max($end-$limit,0);
|
||||
$i=$end;
|
||||
while($i>$start){
|
||||
$entry=json_decode($contents[$i]);
|
||||
if($entry->level>=$minLevel){
|
||||
$entries[]=$entry;
|
||||
$entries = array();
|
||||
$handle = fopen(self::$logFile, 'r');
|
||||
if ($handle) {
|
||||
// Just a guess to set the file pointer to the right spot
|
||||
$maxLineLength = 150;
|
||||
fseek($handle, -($limit * $maxLineLength + $offset * $maxLineLength), SEEK_END);
|
||||
// Skip first line, because it is most likely a partial line
|
||||
fgets($handle);
|
||||
while (!feof($handle)) {
|
||||
$line = fgets($handle);
|
||||
if (!empty($line)) {
|
||||
$entry = json_decode($line);
|
||||
if ($entry->level >= $minLevel) {
|
||||
$entries[] = $entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
$i--;
|
||||
fclose($handle);
|
||||
// Extract the needed entries and reverse the order
|
||||
$entries = array_reverse(array_slice($entries, -($limit + $offset), $limit));
|
||||
}
|
||||
return $entries;
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ class OC_Setup {
|
|||
'error' => 'MySQL username and/or password not valid',
|
||||
'hint' => 'You need to enter either an existing account or the administrator.'
|
||||
);
|
||||
return($error);
|
||||
}
|
||||
else {
|
||||
$oldUser=OC_Config::getValue('dbuser', false);
|
||||
|
|
|
@ -21,7 +21,9 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* This class provides all methods for user management.
|
||||
* This class provides wrapper methods for user management. Multiple backends are
|
||||
* supported. User management operations are delegated to the configured backend for
|
||||
* execution.
|
||||
*
|
||||
* Hooks provided:
|
||||
* pre_createUser(&run, uid, password)
|
||||
|
@ -240,7 +242,7 @@ class OC_User {
|
|||
* Checks if the user is logged in
|
||||
*/
|
||||
public static function isLoggedIn(){
|
||||
if( isset($_SESSION['user_id']) AND $_SESSION['user_id'] ){
|
||||
if( isset($_SESSION['user_id']) AND $_SESSION['user_id'] AND self::userExists($_SESSION['user_id']) ){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
|
@ -336,6 +338,7 @@ class OC_User {
|
|||
}
|
||||
}
|
||||
}
|
||||
asort($users);
|
||||
return $users;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,10 @@ define('OC_USER_BACKEND_USER_EXISTS', 0x100000);
|
|||
|
||||
|
||||
/**
|
||||
* abstract base class for user management
|
||||
* subclass this for your own backends and see OC_User_Example for descriptions
|
||||
* Abstract base class for user management. Provides methods for querying backend
|
||||
* capabilities.
|
||||
*
|
||||
* Subclass this for your own backends, and see OC_User_Example for descriptions
|
||||
*/
|
||||
abstract class OC_User_Backend {
|
||||
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud
|
||||
*
|
||||
* @author Frank Karlitschek
|
||||
* @copyright 2012 Robin Appelman icewind@owncloud.com
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* user backend using http auth requests
|
||||
*/
|
||||
class OC_User_HTTP extends OC_User_Backend {
|
||||
/**
|
||||
* split http://user@host/path into a user and url part
|
||||
* @param string path
|
||||
* @return array
|
||||
*/
|
||||
private function parseUrl($url){
|
||||
$parts=parse_url($url);
|
||||
$url=$parts['scheme'].'://'.$parts['host'];
|
||||
if(isset($parts['port'])){
|
||||
$url.=':'.$parts['port'];
|
||||
}
|
||||
$url.=$parts['path'];
|
||||
if(isset($parts['query'])){
|
||||
$url.='?'.$parts['query'];
|
||||
}
|
||||
return array($parts['user'],$url);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* check if an url is a valid login
|
||||
* @param string url
|
||||
* @return boolean
|
||||
*/
|
||||
private function matchUrl($url){
|
||||
return ! is_null(parse_url($url,PHP_URL_USER));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the password is correct
|
||||
* @param $uid The username
|
||||
* @param $password The password
|
||||
* @returns string
|
||||
*
|
||||
* Check if the password is correct without logging in the user
|
||||
* returns the user id or false
|
||||
*/
|
||||
public function checkPassword($uid, $password){
|
||||
if(!$this->matchUrl($uid)){
|
||||
return false;
|
||||
}
|
||||
list($user,$url)=$this->parseUrl($uid);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $user.':'.$password);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
curl_exec($ch);
|
||||
|
||||
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
return $status==200;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief check if a user exists
|
||||
* @param string $uid the username
|
||||
* @return boolean
|
||||
*/
|
||||
public function userExists($uid){
|
||||
return $this->matchUrl($uid);
|
||||
}
|
||||
}
|
11
lib/util.php
11
lib/util.php
|
@ -28,6 +28,14 @@ class OC_Util {
|
|||
exit;
|
||||
}
|
||||
|
||||
// Check if apps folder is writable.
|
||||
if(!is_writable(OC::$SERVERROOT."/apps/")) {
|
||||
$tmpl = new OC_Template( '', 'error', 'guest' );
|
||||
$tmpl->assign('errors',array(1=>array('error'=>"Can't write into apps directory 'apps'",'hint'=>"You can usually fix this by giving the webserver user write access to the config directory in owncloud")));
|
||||
$tmpl->printPage();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Create root dir.
|
||||
if(!is_dir($CONFIG_DATADIRECTORY_ROOT)){
|
||||
$success=@mkdir($CONFIG_DATADIRECTORY_ROOT);
|
||||
|
@ -256,6 +264,9 @@ class OC_Util {
|
|||
if(floatval(phpversion())<5.3){
|
||||
$errors[]=array('error'=>'PHP 5.3 is required.<br/>','hint'=>'Please ask your server administrator to update PHP to version 5.3 or higher. PHP 5.2 is no longer supported by ownCloud and the PHP community.');
|
||||
}
|
||||
if(!defined('PDO::ATTR_DRIVER_NAME')){
|
||||
$errors[]=array('error'=>'PHP PDO module is not installed.<br/>','hint'=>'Please ask your server administrator to install the module.');
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ class OC_VCategories {
|
|||
if(!is_null($vobject)) {
|
||||
$this->loadFromVObject($vobject, $sync);
|
||||
} else {
|
||||
OC_Log::write('core','OC_VCategories::rescan, unable to parse. ID: '.$value[0].', '.substr($value[1], 0, 50).'(...)', OC_Log::DEBUG);
|
||||
OC_Log::write('core','OC_VCategories::rescan, unable to parse. ID: '.', '.substr($object, 0, 100).'(...)', OC_Log::DEBUG);
|
||||
}
|
||||
}
|
||||
$this->save();
|
||||
|
|
|
@ -20,6 +20,7 @@ $rootInfo=OC_FileCache::get('');
|
|||
$used=$rootInfo['size'];
|
||||
$free=OC_Filesystem::free_space();
|
||||
$total=$free+$used;
|
||||
if($total==0) $total=1; // prevent division by zero
|
||||
$relative=round(($used/$total)*10000)/100;
|
||||
|
||||
$email=OC_Preferences::getValue(OC_User::getUser(), 'settings','email','');
|
||||
|
|
|
@ -20,6 +20,16 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Abstract class to provide the basis of backend-specific unit test classes.
|
||||
*
|
||||
* All subclasses MUST assign a backend property in setUp() which implements
|
||||
* user operations (add, remove, etc.). Test methods in this class will then be
|
||||
* run on each separate subclass and backend therein.
|
||||
*
|
||||
* For an example see /tests/lib/user/dummy.php
|
||||
*/
|
||||
|
||||
abstract class Test_User_Backend extends UnitTestCase {
|
||||
/**
|
||||
* @var OC_User_Backend $backend
|
||||
|
|
Loading…
Reference in New Issue