Merge branch 'master' into calendar_import

This commit is contained in:
Georg Ehrke 2012-07-06 11:01:12 +02:00
commit 9a10efd80f
10 changed files with 69 additions and 52 deletions

View File

@ -22,6 +22,7 @@ class Sabre_DAV_Client {
protected $userName;
protected $password;
protected $proxy;
protected $capath;
/**
* Constructor
@ -49,6 +50,11 @@ class Sabre_DAV_Client {
'proxy'
);
$this->capath = '';
if (isset($settings['capath'])) {
$this->capath = $settings['capath'];
}
foreach($validSettings as $validSetting) {
if (isset($settings[$validSetting])) {
$this->$validSetting = $settings[$validSetting];
@ -249,9 +255,12 @@ class Sabre_DAV_Client {
// Automatically follow redirects
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_MAXREDIRS => 5,
CURLOPT_SSL_VERIFYPEER => true,
//CURLOPT_SSL_VERIFYPEER => false,
);
if ($this->capath != '') $curlSettings[CURLOPT_CAPATH] = $this->capath;
switch ($method) {
case 'PUT':
$curlSettings[CURLOPT_PUT] = true;

View File

@ -327,7 +327,7 @@ Contacts={
// Make sure proper DOM is loaded.
if(!$('#card')[0] && newid) {
$.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{},function(jsondata){
$.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{requesttoken:requesttoken},function(jsondata){
if(jsondata.status == 'success'){
$('#rightcontent').html(jsondata.data.page).ready(function() {
Contacts.UI.loadHandlers();

View File

@ -41,7 +41,7 @@ class OC_Contacts_Addressbook{
/**
* @brief Returns the list of addressbooks for a specific user.
* @param string $uid
* @param boolean $active Only return calendars with this $active state, default(=false) is don't care
* @param boolean $active Only return addressbooks with this $active state, default(=false) is don't care
* @return array or false.
*/
public static function all($uid, $active=false){

View File

@ -164,7 +164,7 @@ class OC_Contacts_App {
* @brief returns the default categories of ownCloud
* @return (array) $categories
*/
protected static function getDefaultCategories(){
public static function getDefaultCategories(){
return array(
(string)self::$l10n->t('Birthday'),
(string)self::$l10n->t('Business'),

View File

@ -36,10 +36,15 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
$this->root.='/';
}
$capath = '';
if($caview = \OCP\Files::getStorage('files_external')) {
$capath=\OCP\Config::getSystemValue('datadirectory').$caview->getAbsolutePath("");
}
$settings = array(
'baseUri' => $this->createBaseUri(),
'userName' => $this->user,
'password' => $this->password,
'capath' => $capath,
);
$this->client = new Sabre_DAV_Client($settings);

View File

@ -81,7 +81,7 @@
</table>
<br />
<?php if (!$_['isAdminPage']): ?>
<?php if (!$_['isAdminPage'] && false): // disabled until sabredav can handle uploaded ca certs ?>
<table id="sslCertificate" data-admin='<?php echo json_encode($_['isAdminPage']); ?>'>
<thead>
<tr>

View File

@ -12,5 +12,5 @@ OCP\Util::addscript('files_versions', 'versions');
// Listen to write signals
OCP\Util::connectHook('OC_Filesystem', 'post_write', "OCA_Versions\Hooks", "write_hook");
// Listen to delete and rename signals
OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA_Versions\Storage", "removeVersions");
OCP\Util::connectHook('OC_Filesystem', 'rename', "OCA_Versions\Storage", "renameVersions");
OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA_Versions\Hooks", "remove_hook");
OCP\Util::connectHook('OC_Filesystem', 'rename', "OCA_Versions\Hooks", "rename_hook");

View File

@ -30,6 +30,43 @@ class Hooks {
}
}
/**
* @brief Erase versions of deleted file
* @param array
*
* This function is connected to the delete signal of OC_Filesystem
* cleanup the versions directory if the actual file gets deleted
*/
public static function remove_hook($params) {
$rel_path = $params['path'];
$abs_path = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_path.'.v';
if(Storage::isversioned($rel_path)) {
$versions = Storage::getVersions($rel_path);
foreach ($versions as $v){
unlink($abs_path . $v['version']);
}
}
}
/**
* @brief rename/move versions of renamed/moved files
* @param array with oldpath and newpath
*
* This function is connected to the rename signal of OC_Filesystem and adjust the name and location
* of the stored versions along the actual file
*/
public static function rename_hook($params) {
$rel_oldpath = $params['oldpath'];
$abs_oldpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_oldpath.'.v';
$abs_newpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$params['newpath'].'.v';
if(Storage::isversioned($rel_oldpath)) {
$versions = Storage::getVersions($rel_oldpath);
foreach ($versions as $v){
rename($abs_oldpath.$v['version'], $abs_newpath.$v['version']);
}
}
}
}
?>

View File

@ -147,6 +147,9 @@ class Storage {
public static function rollback($filename,$revision) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
$users_view = \OCP\Files::getStorage("files_versions");
$users_view->chroot(\OCP\User::getUser().'/');
if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) {
$pos = strpos($source, '/files', 1);
$uid = substr($source, 1, $pos - 1);
@ -159,7 +162,7 @@ class Storage {
$filesfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/files';
// rollback
if ( @copy($versionsFolderName.'/'.$filename.'.v'.$revision,$filesfoldername.'/'.$filename) ) {
if( @$users_view->copy('versions'.$filename.'.v'.$revision, 'files'.$filename) ) {
return true;
@ -323,41 +326,4 @@ class Storage {
return $this->view->deleteAll( $dir, true );
}
/**
* @brief Erase versions of deleted file
* @param array
*
* This function is connected to the delete signal of OC_Filesystem
* cleanup the versions directory if the actual file gets deleted
*/
public static function removeVersions($params) {
$rel_path = $params['path'];
$abs_path = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_path.'.v';
if(Storage::isversioned($rel_path)) {
$versions = Storage::getVersions($rel_path);
foreach ($versions as $v){
unlink($abs_path . $v['version']);
}
}
}
/**
* @brief rename/move versions of renamed/moved files
* @param array with oldpath and newpath
*
* This function is connected to the rename signal of OC_Filesystem and adjust the name and location
* of the stored versions along the actual file
*/
public static function renameVersions($params) {
$rel_oldpath = $params['oldpath'];
$abs_oldpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_oldpath.'.v';
$abs_newpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$params['newpath'].'.v';
if(Storage::isversioned($rel_oldpath)) {
$versions = Storage::getVersions($rel_oldpath);
foreach ($versions as $v){
rename($abs_oldpath.$v['version'], $abs_newpath.$v['version']);
}
}
}
}

View File

@ -240,17 +240,13 @@ class OC_User {
* Checks if the user is logged in
*/
public static function isLoggedIn(){
static $is_login_checked = null;
if (!is_null($is_login_checked)) {
return $is_login_checked;
}
if( isset($_SESSION['user_id']) AND $_SESSION['user_id']) {
OC_App::loadApps(array('authentication'));
if (self::userExists($_SESSION['user_id']) ){
return $is_login_checked = true;
return true;
}
}
return $is_login_checked = false;
return false;
}
/**
@ -349,13 +345,17 @@ class OC_User {
* @return boolean
*/
public static function userExists($uid){
static $user_exists_checked = null;
if (!is_null($user_exists_checked)) {
return $user_exists_checked;
}
foreach(self::$_usedBackends as $backend){
$result=$backend->userExists($uid);
if($result===true){
return true;
return $user_exists_checked = true;
}
}
return false;
return $user_exists_checked = false;
}
/**