summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
-rw-r--r--lib/l10n/lt_LT.js2
-rw-r--r--lib/l10n/lt_LT.json2
-rw-r--r--lib/private/Mail/Mailer.php6
-rw-r--r--lib/private/Repair.php2
-rw-r--r--lib/private/Repair/NC15/SetVcardDatabaseUID.php137
-rw-r--r--lib/private/Settings/Admin/Sharing.php9
-rw-r--r--lib/private/Share/Share.php20
-rw-r--r--lib/private/Share20/DefaultShareProvider.php4
10 files changed, 160 insertions, 24 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 53a7c9d3cf7..6c2463939bd 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -966,6 +966,7 @@ return array(
'OC\\Repair\\NC13\\RepairInvalidPaths' => $baseDir . '/lib/private/Repair/NC13/RepairInvalidPaths.php',
'OC\\Repair\\NC14\\AddPreviewBackgroundCleanupJob' => $baseDir . '/lib/private/Repair/NC14/AddPreviewBackgroundCleanupJob.php',
'OC\\Repair\\NC14\\RepairPendingCronJobs' => $baseDir . '/lib/private/Repair/NC14/RepairPendingCronJobs.php',
+ 'OC\\Repair\\NC15\\SetVcardDatabaseUID' => $baseDir . '/lib/private/Repair/NC15/SetVcardDatabaseUID.php',
'OC\\Repair\\OldGroupMembershipShares' => $baseDir . '/lib/private/Repair/OldGroupMembershipShares.php',
'OC\\Repair\\Owncloud\\DropAccountTermsTable' => $baseDir . '/lib/private/Repair/Owncloud/DropAccountTermsTable.php',
'OC\\Repair\\Owncloud\\SaveAccountsTableData' => $baseDir . '/lib/private/Repair/Owncloud/SaveAccountsTableData.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 6cd39952b1b..847ae43fb65 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -996,6 +996,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Repair\\NC13\\RepairInvalidPaths' => __DIR__ . '/../../..' . '/lib/private/Repair/NC13/RepairInvalidPaths.php',
'OC\\Repair\\NC14\\AddPreviewBackgroundCleanupJob' => __DIR__ . '/../../..' . '/lib/private/Repair/NC14/AddPreviewBackgroundCleanupJob.php',
'OC\\Repair\\NC14\\RepairPendingCronJobs' => __DIR__ . '/../../..' . '/lib/private/Repair/NC14/RepairPendingCronJobs.php',
+ 'OC\\Repair\\NC15\\SetVcardDatabaseUID' => __DIR__ . '/../../..' . '/lib/private/Repair/NC15/SetVcardDatabaseUID.php',
'OC\\Repair\\OldGroupMembershipShares' => __DIR__ . '/../../..' . '/lib/private/Repair/OldGroupMembershipShares.php',
'OC\\Repair\\Owncloud\\DropAccountTermsTable' => __DIR__ . '/../../..' . '/lib/private/Repair/Owncloud/DropAccountTermsTable.php',
'OC\\Repair\\Owncloud\\SaveAccountsTableData' => __DIR__ . '/../../..' . '/lib/private/Repair/Owncloud/SaveAccountsTableData.php',
diff --git a/lib/l10n/lt_LT.js b/lib/l10n/lt_LT.js
index 0b2ecd6b3eb..9079ab0266b 100644
--- a/lib/l10n/lt_LT.js
+++ b/lib/l10n/lt_LT.js
@@ -52,7 +52,7 @@ OC.L10N.register(
"Delete" : "Ištrinti",
"Overview" : "Apžvalga",
"Basic settings" : "Pagrindiniai nustatymai",
- "Sharing" : "Dalijimasis",
+ "Sharing" : "Bendrinimas",
"Security" : "Saugumas",
"Additional settings" : "Papildomi nustatymai",
"Personal info" : "Asmeninė informacija",
diff --git a/lib/l10n/lt_LT.json b/lib/l10n/lt_LT.json
index ba92e39575e..ea36f3667ac 100644
--- a/lib/l10n/lt_LT.json
+++ b/lib/l10n/lt_LT.json
@@ -50,7 +50,7 @@
"Delete" : "Ištrinti",
"Overview" : "Apžvalga",
"Basic settings" : "Pagrindiniai nustatymai",
- "Sharing" : "Dalijimasis",
+ "Sharing" : "Bendrinimas",
"Security" : "Saugumas",
"Additional settings" : "Papildomi nustatymai",
"Personal info" : "Asmeninė informacija",
diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php
index 6f148bc0c6e..df23b669365 100644
--- a/lib/private/Mail/Mailer.php
+++ b/lib/private/Mail/Mailer.php
@@ -274,7 +274,11 @@ class Mailer implements IMailer {
$binaryPath = '/var/qmail/bin/sendmail';
break;
default:
- $binaryPath = '/usr/sbin/sendmail';
+ $sendmail = \OC_Helper::findBinaryPath('sendmail');
+ if ($sendmail === null) {
+ $sendmail = '/usr/sbin/sendmail';
+ }
+ $binaryPath = $sendmail;
break;
}
diff --git a/lib/private/Repair.php b/lib/private/Repair.php
index ad9662ca1d7..01724fd6a38 100644
--- a/lib/private/Repair.php
+++ b/lib/private/Repair.php
@@ -39,6 +39,7 @@ use OC\Repair\NC11\FixMountStorages;
use OC\Repair\NC13\AddLogRotateJob;
use OC\Repair\NC14\AddPreviewBackgroundCleanupJob;
use OC\Repair\NC14\RepairPendingCronJobs;
+use OC\Repair\NC15\SetVcardDatabaseUID;
use OC\Repair\OldGroupMembershipShares;
use OC\Repair\Owncloud\DropAccountTermsTable;
use OC\Repair\Owncloud\SaveAccountsTableData;
@@ -139,6 +140,7 @@ class Repair implements IOutput{
new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()),
new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()),
new RepairPendingCronJobs(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()),
+ new SetVcardDatabaseUID(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()),
];
}
diff --git a/lib/private/Repair/NC15/SetVcardDatabaseUID.php b/lib/private/Repair/NC15/SetVcardDatabaseUID.php
new file mode 100644
index 00000000000..ccf6c47cbc8
--- /dev/null
+++ b/lib/private/Repair/NC15/SetVcardDatabaseUID.php
@@ -0,0 +1,137 @@
+<?php
+/**
+ * @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC\Repair\NC15;
+
+use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\Migration\IOutput;
+use OCP\Migration\IRepairStep;
+use Sabre\VObject\Reader;
+
+class SetVcardDatabaseUID implements IRepairStep {
+ const MAX_ROWS = 1000;
+
+ /** @var IDBConnection */
+ private $connection;
+
+ /** @var IConfig */
+ private $config;
+
+ private $updateQuery;
+
+ public function __construct(IDBConnection $connection, IConfig $config) {
+ $this->connection = $connection;
+ $this->config = $config;
+ }
+
+ public function getName() {
+ return 'Extract the vcard uid and store it in the db';
+ }
+
+ /**
+ * @return \Generator
+ * @suppress SqlInjectionChecker
+ */
+ private function getInvalidEntries() {
+ $builder = $this->connection->getQueryBuilder();
+
+ $builder->select('id', 'carddata')
+ ->from('cards')
+ ->where($builder->expr()->isNull('uid'))
+ ->setMaxResults(self::MAX_ROWS);
+
+ do {
+ $result = $builder->execute();
+ $rows = $result->fetchAll();
+ foreach ($rows as $row) {
+ yield $row;
+ }
+ $result->closeCursor();
+ } while (count($rows) > 0);
+ }
+
+ /**
+ * Extract UID from vcard
+ *
+ * @param string $cardData the vcard raw data
+ * @return string the uid or empty if none
+ */
+ private function getUID(string $cardData): string {
+ $vCard = Reader::read($cardData);
+ if ($vCard->UID) {
+ $uid = $vCard->UID->getValue();
+ return $uid;
+ }
+
+ return '';
+ }
+
+ /**
+ * @param int $id
+ * @param string $uid
+ */
+ private function update(int $id, string $uid) {
+ if (!$this->updateQuery) {
+ $builder = $this->connection->getQueryBuilder();
+
+ $this->updateQuery = $builder->update('cards')
+ ->set('uid', $builder->createParameter('uid'))
+ ->where($builder->expr()->eq('id', $builder->createParameter('id')));
+ }
+
+ $this->updateQuery->setParameter('id', $id);
+ $this->updateQuery->setParameter('uid', $uid);
+
+ $this->updateQuery->execute();
+ }
+
+ private function repair(): int {
+ $this->connection->beginTransaction();
+ $entries = $this->getInvalidEntries();
+ $count = 0;
+ foreach ($entries as $entry) {
+ $count++;
+ $uid = $this->getUID($entry['carddata']);
+ $this->update($entry['id'], $uid);
+ }
+ $this->connection->commit();
+
+ return $count;
+ }
+
+ private function shouldRun() {
+ $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0');
+
+ // was added to 15.0.0.2
+ return version_compare($versionFromBeforeUpdate, '15.0.0.2', '<=');
+ }
+
+ public function run(IOutput $output) {
+ if ($this->shouldRun()) {
+ $count = $this->repair();
+
+ $output->info('Fixed ' . $count . ' vcards');
+ }
+ }
+}
diff --git a/lib/private/Settings/Admin/Sharing.php b/lib/private/Settings/Admin/Sharing.php
index dfc0b11478b..ee6a64c85bf 100644
--- a/lib/private/Settings/Admin/Sharing.php
+++ b/lib/private/Settings/Admin/Sharing.php
@@ -32,6 +32,7 @@ use OCP\Constants;
use OCP\IConfig;
use OCP\IL10N;
use OCP\Settings\ISettings;
+use OCP\Share\IManager;
use OCP\Util;
class Sharing implements ISettings {
@@ -41,12 +42,16 @@ class Sharing implements ISettings {
/** @var IL10N */
private $l;
+ /** @var IManager */
+ private $shareManager;
+
/**
* @param IConfig $config
*/
- public function __construct(IConfig $config, IL10N $l) {
+ public function __construct(IConfig $config, IL10N $l, IManager $shareManager) {
$this->config = $config;
$this->l = $l;
+ $this->shareManager = $shareManager;
}
/**
@@ -65,7 +70,7 @@ class Sharing implements ISettings {
'allowResharing' => $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes'),
'allowShareDialogUserEnumeration' => $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes'),
'enforceLinkPassword' => Util::isPublicLinkPasswordRequired(),
- 'onlyShareWithGroupMembers' => Share::shareWithGroupMembersOnly(),
+ 'onlyShareWithGroupMembers' => $this->shareManager->shareWithGroupMembersOnly(),
'shareAPIEnabled' => $this->config->getAppValue('core', 'shareapi_enabled', 'yes'),
'shareDefaultExpireDateSet' => $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no'),
'shareExpireAfterNDays' => $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'),
diff --git a/lib/private/Share/Share.php b/lib/private/Share/Share.php
index 36912dcafe3..76a6a1baeca 100644
--- a/lib/private/Share/Share.php
+++ b/lib/private/Share/Share.php
@@ -341,7 +341,7 @@ class Share extends Constants {
}
$uidOwner = \OC_User::getUser();
- $shareWithinGroupOnly = self::shareWithGroupMembersOnly();
+ $shareWithinGroupOnly = \OC::$server->getConfig()->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes';
if (is_null($itemSourceName)) {
$itemSourceName = $itemSource;
@@ -2055,15 +2055,6 @@ class Share extends Constants {
}
/**
- * check if user can only share with group members
- * @return bool
- */
- public static function shareWithGroupMembersOnly() {
- $value = \OC::$server->getConfig()->getAppValue('core', 'shareapi_only_share_with_group_members', 'no');
- return $value === 'yes';
- }
-
- /**
* @return bool
*/
public static function isDefaultExpireDateEnabled() {
@@ -2104,15 +2095,6 @@ class Share extends Constants {
}
/**
- * @param IConfig $config
- * @return bool
- */
- public static function enforcePassword(IConfig $config) {
- $enforcePassword = $config->getAppValue('core', 'shareapi_enforce_links_password', 'no');
- return $enforcePassword === 'yes';
- }
-
- /**
* @param string $password
* @throws \Exception
*/
diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php
index 3bdbc69e897..a2388012fe7 100644
--- a/lib/private/Share20/DefaultShareProvider.php
+++ b/lib/private/Share20/DefaultShareProvider.php
@@ -156,6 +156,8 @@ class DefaultShareProvider implements IShareProvider {
$qb->setValue('password', $qb->createNamedParameter($share->getPassword()));
}
+ $qb->setValue('password_by_talk', $qb->createNamedParameter($share->getSendPasswordByTalk(), IQueryBuilder::PARAM_BOOL));
+
//If an expiration date is set store it
if ($share->getExpirationDate() !== null) {
$qb->setValue('expiration', $qb->createNamedParameter($share->getExpirationDate(), 'datetime'));
@@ -293,6 +295,7 @@ class DefaultShareProvider implements IShareProvider {
$qb->update('share')
->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId())))
->set('password', $qb->createNamedParameter($share->getPassword()))
+ ->set('password_by_talk', $qb->createNamedParameter($share->getSendPasswordByTalk(), IQueryBuilder::PARAM_BOOL))
->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()))
->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()))
->set('permissions', $qb->createNamedParameter($share->getPermissions()))
@@ -940,6 +943,7 @@ class DefaultShareProvider implements IShareProvider {
$share->setSharedWith($data['share_with']);
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
$share->setPassword($data['password']);
+ $share->setSendPasswordByTalk((bool)$data['password_by_talk']);
$share->setToken($data['token']);
}