Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching to scss #1785

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
011d5f5
Harden empty
VicDeo Sep 22, 2016
c4fcd1f
Update tests for phunit 5.5
VicDeo Sep 27, 2016
4d28358
hide storage wrapper warning for the readonly storage
MorrisJobke Oct 12, 2016
a49d571
fix and tidy up tests after merge conflicts
blizzz Oct 13, 2016
77272ea
Use cache to determine if value need to be updated
rullzer Oct 13, 2016
6c5f7d5
Fix migration tests
rullzer Oct 13, 2016
dd7c267
[3rdparty] Bump synfony/process
rullzer Oct 14, 2016
5cd90d4
[9.2] Sync deathdate and anniversary to birthday calendar (#25655)
DeepDiver1975 Sep 30, 2016
dade28c
Merge branch 'master' into downstream-ldap-3
blizzz Oct 14, 2016
4d6ec43
Do not reset the list after adding cached entries
nickvergessen Oct 17, 2016
22f76d9
ellipsize sharee name to not overlap with
jancborchardt Oct 18, 2016
86fd9ca
fix list height and border to be as in Files
jancborchardt Oct 18, 2016
1945671
improve look of Add group flow
jancborchardt Oct 18, 2016
76fd77d
jquery UI fixes
jancborchardt Oct 18, 2016
4fbffe0
Merge pull request #1777 from nextcloud/user-mgmt-layout
MorrisJobke Oct 18, 2016
deb59d3
Merge pull request #1722 from nextcloud/hide-storage-warnings
MorrisJobke Oct 18, 2016
10e5372
Merge pull request #1780 from nextcloud/jquery-ui-fixes
jancborchardt Oct 18, 2016
d366b0e
Merge pull request #1774 from nextcloud/ellipsize-sharee
MorrisJobke Oct 18, 2016
16b9c90
Merge pull request #1739 from nextcloud/bump_symfony_process
LukasReschke Oct 18, 2016
0923d26
Merge pull request #1742 from nextcloud/us_sync-date-of-death
LukasReschke Oct 18, 2016
c55a737
Merge pull request #1734 from nextcloud/setvalue_opt
LukasReschke Oct 18, 2016
9759f55
Merge pull request #1771 from nextcloud/fix-issue-loading-checks-from…
LukasReschke Oct 18, 2016
b8eea5f
Merge pull request #1729 from nextcloud/downstream-ldap-3
LukasReschke Oct 18, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 43 additions & 22 deletions apps/dav/lib/CalDAV/BirthdayService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,19 @@ public function __construct(CalDavBackend $calDavBackEnd, CardDavBackend $cardDa
* @param string $cardData
*/
public function onCardChanged($addressBookId, $cardUri, $cardData) {

$targetPrincipals = $this->getAllAffectedPrincipals($addressBookId);

$book = $this->cardDavBackEnd->getAddressBookById($addressBookId);
$targetPrincipals[] = $book['principaluri'];
$datesToSync = [
['postfix' => '', 'field' => 'BDAY', 'symbol' => '*'],
['postfix' => '-death', 'field' => 'DEATHDATE', 'symbol' => "†"],
['postfix' => '-anniversary', 'field' => 'ANNIVERSARY', 'symbol' => "⚭"],
];
foreach ($targetPrincipals as $principalUri) {
$calendar = $this->ensureCalendarExists($principalUri);
$objectUri = $book['uri'] . '-' . $cardUri. '.ics';
$calendarData = $this->buildBirthdayFromContact($cardData);
$existing = $this->calDavBackEnd->getCalendarObject($calendar['id'], $objectUri);
if (is_null($calendarData)) {
if (!is_null($existing)) {
$this->calDavBackEnd->deleteCalendarObject($calendar['id'], $objectUri);
}
} else {
if (is_null($existing)) {
$this->calDavBackEnd->createCalendarObject($calendar['id'], $objectUri, $calendarData->serialize());
} else {
if ($this->birthdayEvenChanged($existing['calendardata'], $calendarData)) {
$this->calDavBackEnd->updateCalendarObject($calendar['id'], $objectUri, $calendarData->serialize());
}
}
foreach ($datesToSync as $type) {
$this->updateCalendar($cardUri, $cardData, $book, $calendar['id'], $type);
}
}
}
Expand All @@ -98,8 +89,10 @@ public function onCardDeleted($addressBookId, $cardUri) {
$targetPrincipals[] = $book['principaluri'];
foreach ($targetPrincipals as $principalUri) {
$calendar = $this->ensureCalendarExists($principalUri);
$objectUri = $book['uri'] . '-' . $cardUri . '.ics';
$this->calDavBackEnd->deleteCalendarObject($calendar['id'], $objectUri);
foreach (['', '-death', '-anniversary'] as $tag) {
$objectUri = $book['uri'] . '-' . $cardUri . $tag .'.ics';
$this->calDavBackEnd->deleteCalendarObject($calendar['id'], $objectUri);
}
}
}

Expand All @@ -124,9 +117,11 @@ public function ensureCalendarExists($principal) {

/**
* @param string $cardData
* @param string $dateField
* @param string $summarySymbol
* @return null|VCalendar
*/
public function buildBirthdayFromContact($cardData) {
public function buildDateFromContact($cardData, $dateField, $summarySymbol) {
if (empty($cardData)) {
return null;
}
Expand All @@ -136,10 +131,10 @@ public function buildBirthdayFromContact($cardData) {
return null;
}

if (!isset($doc->BDAY)) {
if (!isset($doc->{$dateField})) {
return null;
}
$birthday = $doc->BDAY;
$birthday = $doc->{$dateField};
if (!(string)$birthday) {
return null;
}
Expand Down Expand Up @@ -168,7 +163,7 @@ public function buildBirthdayFromContact($cardData) {
$vEvent->DTEND['VALUE'] = 'DATE';
$vEvent->{'UID'} = $doc->UID;
$vEvent->{'RRULE'} = 'FREQ=YEARLY';
$vEvent->{'SUMMARY'} = $title . ' (*' . $date->format('Y') . ')';
$vEvent->{'SUMMARY'} = $title . ' (' . $summarySymbol . $date->format('Y') . ')';
$vEvent->{'TRANSP'} = 'TRANSPARENT';
$alarm = $vCal->createComponent('VALARM');
$alarm->add($vCal->createProperty('TRIGGER', '-PT0M', ['VALUE' => 'DURATION']));
Expand Down Expand Up @@ -233,4 +228,30 @@ protected function getAllAffectedPrincipals($addressBookId) {
return array_values(array_unique($targetPrincipals, SORT_STRING));
}

/**
* @param string $cardUri
* @param string $cardData
* @param array $book
* @param int $calendarId
* @param string $type
*/
private function updateCalendar($cardUri, $cardData, $book, $calendarId, $type) {
$objectUri = $book['uri'] . '-' . $cardUri . $type['postfix'] . '.ics';
$calendarData = $this->buildDateFromContact($cardData, $type['field'], $type['symbol']);
$existing = $this->calDavBackEnd->getCalendarObject($calendarId, $objectUri);
if (is_null($calendarData)) {
if (!is_null($existing)) {
$this->calDavBackEnd->deleteCalendarObject($calendarId, $objectUri);
}
} else {
if (is_null($existing)) {
$this->calDavBackEnd->createCalendarObject($calendarId, $objectUri, $calendarData->serialize());
} else {
if ($this->birthdayEvenChanged($existing['calendardata'], $calendarData)) {
$this->calDavBackEnd->updateCalendarObject($calendarId, $objectUri, $calendarData->serialize());
}
}
}
}

}
55 changes: 34 additions & 21 deletions apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ class BirthdayServiceTest extends TestCase {
/** @var CardDavBackend | \PHPUnit_Framework_MockObject_MockObject */
private $cardDav;
/** @var GroupPrincipalBackend | \PHPUnit_Framework_MockObject_MockObject */
private $groupPrincialBackend;
private $groupPrincipalBackend;

public function setUp() {
parent::setUp();

$this->calDav = $this->getMockBuilder('OCA\DAV\CalDAV\CalDavBackend')->disableOriginalConstructor()->getMock();
$this->cardDav = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')->disableOriginalConstructor()->getMock();
$this->groupPrincialBackend = $this->getMockBuilder('OCA\DAV\DAV\GroupPrincipalBackend')->disableOriginalConstructor()->getMock();
$this->calDav = $this->getMockBuilder(CalDavBackend::class)->disableOriginalConstructor()->getMock();
$this->cardDav = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock();
$this->groupPrincipalBackend = $this->getMockBuilder(GroupPrincipalBackend::class)->disableOriginalConstructor()->getMock();

$this->service = new BirthdayService($this->calDav, $this->cardDav, $this->groupPrincialBackend);
$this->service = new BirthdayService($this->calDav, $this->cardDav, $this->groupPrincipalBackend);
}

/**
Expand All @@ -59,7 +59,7 @@ public function setUp() {
* @param string | null $data
*/
public function testBuildBirthdayFromContact($nullExpected, $data) {
$cal = $this->service->buildBirthdayFromContact($data);
$cal = $this->service->buildDateFromContact($data, 'BDAY', '*');
if ($nullExpected) {
$this->assertNull($cal);
} else {
Expand All @@ -83,7 +83,9 @@ public function testOnCardDeleted() {
->willReturn([
'id' => 1234
]);
$this->calDav->expects($this->once())->method('deleteCalendarObject')->with(1234, 'default-gump.vcf.ics');
$this->calDav->expects($this->at(1))->method('deleteCalendarObject')->with(1234, 'default-gump.vcf.ics');
$this->calDav->expects($this->at(2))->method('deleteCalendarObject')->with(1234, 'default-gump.vcf-death.ics');
$this->calDav->expects($this->at(3))->method('deleteCalendarObject')->with(1234, 'default-gump.vcf-anniversary.ics');
$this->cardDav->expects($this->once())->method('getShares')->willReturn([]);

$this->service->onCardDeleted(666, 'gump.vcf');
Expand All @@ -107,26 +109,37 @@ public function testOnCardChanged($expectedOp) {
$this->cardDav->expects($this->once())->method('getShares')->willReturn([]);

/** @var BirthdayService | \PHPUnit_Framework_MockObject_MockObject $service */
$service = $this->getMockBuilder('\OCA\DAV\CalDAV\BirthdayService')
->setMethods(['buildBirthdayFromContact', 'birthdayEvenChanged'])
->setConstructorArgs([$this->calDav, $this->cardDav, $this->groupPrincialBackend])
$service = $this->getMockBuilder(BirthdayService::class)
->setMethods(['buildDateFromContact', 'birthdayEvenChanged'])
->setConstructorArgs([$this->calDav, $this->cardDav, $this->groupPrincipalBackend])
->getMock();

if ($expectedOp === 'delete') {
$this->calDav->expects($this->once())->method('getCalendarObject')->willReturn('');
$service->expects($this->once())->method('buildBirthdayFromContact')->willReturn(null);
$this->calDav->expects($this->once())->method('deleteCalendarObject')->with(1234, 'default-gump.vcf.ics');
$this->calDav->expects($this->exactly(3))->method('getCalendarObject')->willReturn('');
$service->expects($this->exactly(3))->method('buildDateFromContact')->willReturn(null);
$this->calDav->expects($this->exactly(3))->method('deleteCalendarObject')->withConsecutive(
[1234, 'default-gump.vcf.ics'],
[1234, 'default-gump.vcf-death.ics'],
[1234, 'default-gump.vcf-anniversary.ics']
);
}
if ($expectedOp === 'create') {
$service->expects($this->once())->method('buildBirthdayFromContact')->willReturn(new VCalendar());
$this->calDav->expects($this->once())->method('createCalendarObject')->with(1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n");
$service->expects($this->exactly(3))->method('buildDateFromContact')->willReturn(new VCalendar());
$this->calDav->expects($this->exactly(3))->method('createCalendarObject')->withConsecutive(
[1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"],
[1234, 'default-gump.vcf-death.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"],
[1234, 'default-gump.vcf-anniversary.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"]
);
}
if ($expectedOp === 'update') {
$service->expects($this->once())->method('buildBirthdayFromContact')->willReturn(new VCalendar());
$service->expects($this->once())->method('birthdayEvenChanged')->willReturn(true);
$this->calDav->expects($this->once())->method('getCalendarObject')->willReturn([
'calendardata' => '']);
$this->calDav->expects($this->once())->method('updateCalendarObject')->with(1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n");
$service->expects($this->exactly(3))->method('buildDateFromContact')->willReturn(new VCalendar());
$service->expects($this->exactly(3))->method('birthdayEvenChanged')->willReturn(true);
$this->calDav->expects($this->exactly(3))->method('getCalendarObject')->willReturn(['calendardata' => '']);
$this->calDav->expects($this->exactly(3))->method('updateCalendarObject')->withConsecutive(
[1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"],
[1234, 'default-gump.vcf-death.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"],
[1234, 'default-gump.vcf-anniversary.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 3.5.0//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"]
);
}

$service->onCardChanged(666, 'gump.vcf', '');
Expand Down Expand Up @@ -162,7 +175,7 @@ public function testGetAllAffectedPrincipals() {
'{http://owncloud.org/ns}principal' => 'principals/groups/users'
],
]);
$this->groupPrincialBackend->expects($this->once())->method('getGroupMemberSet')
$this->groupPrincipalBackend->expects($this->once())->method('getGroupMemberSet')
->willReturn([
[
'uri' => 'principals/users/user01',
Expand Down
4 changes: 4 additions & 0 deletions apps/encryption/tests/MigrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ private function prepareDB() {
unset($cache['files_encryption']);
$this->invokePrivate(\OC::$server->getAppConfig(), 'cache', [$cache]);

$cache = $this->invokePrivate($config, 'userCache');
unset($cache[self::TEST_ENCRYPTION_MIGRATION_USER1]);
$this->invokePrivate(\OC::$server->getAppConfig(), 'userCache', [$cache]);

// delete default values set by the encryption app during initialization

/** @var \OCP\IDBConnection $connection */
Expand Down
7 changes: 6 additions & 1 deletion apps/files/css/mobile.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ table td.filename .nametext .innernametext {
max-width: 50%;
}

/* ellipsis on user names in share sidebar */
#shareWithList .username {
max-width: 80px !important;
}

/* proper notification area for multi line messages */
#notification-container {
display: -webkit-box;
Expand All @@ -82,4 +87,4 @@ table td.filename .nametext .innernametext {
display: block !important;
}

}
}
26 changes: 15 additions & 11 deletions apps/user_ldap/lib/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,14 @@ public function readAttribute($dn, $attr, $filter = 'objectClass=*') {
$dn = $this->helper->DNasBaseParameter($dn);
$rr = @$this->ldap->read($cr, $dn, $filter, array($attr));
if(!$this->ldap->isResource($rr)) {
if(!empty($attr)) {
if ($attr !== '') {
//do not throw this message on userExists check, irritates
\OCP\Util::writeLog('user_ldap', 'readAttribute failed for DN '.$dn, \OCP\Util::DEBUG);
}
//in case an error occurs , e.g. object does not exist
return false;
}
if (empty($attr) && ($filter === 'objectclass=*' || $this->ldap->countEntries($cr, $rr) === 1)) {
if ($attr === '' && ($filter === 'objectclass=*' || $this->ldap->countEntries($cr, $rr) === 1)) {
\OCP\Util::writeLog('user_ldap', 'readAttribute: '.$dn.' found', \OCP\Util::DEBUG);
return array();
}
Expand Down Expand Up @@ -422,8 +422,8 @@ public function dn2ocname($fdn, $ldapName = null, $isUser = true) {
}

if($isUser) {
$usernameAttribute = $this->connection->ldapExpertUsernameAttr;
if(!empty($usernameAttribute)) {
$usernameAttribute = strval($this->connection->ldapExpertUsernameAttr);
if ($usernameAttribute !== '') {
$username = $this->readAttribute($fdn, $usernameAttribute);
$username = $username[0];
} else {
Expand Down Expand Up @@ -1128,7 +1128,7 @@ public function combineFilterWithOr($filters) {
private function combineFilter($filters, $operator) {
$combinedFilter = '('.$operator;
foreach($filters as $filter) {
if(!empty($filter) && $filter[0] !== '(') {
if ($filter !== '' && $filter[0] !== '(') {
$filter = '('.$filter.')';
}
$combinedFilter.=$filter;
Expand Down Expand Up @@ -1211,7 +1211,7 @@ private function getFilterPartForSearch($search, $searchAttributes, $fallbackAtt

$search = $this->prepareSearchTerm($search);
if(!is_array($searchAttributes) || count($searchAttributes) === 0) {
if(empty($fallbackAttribute)) {
if ($fallbackAttribute === '') {
return '';
}
$filter[] = $fallbackAttribute . '=' . $search;
Expand All @@ -1237,8 +1237,12 @@ private function prepareSearchTerm($term) {

$allowEnum = $config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes');

$result = empty($term) ? '*' :
$allowEnum !== 'no' ? $term . '*' : $term;
$result = $term;
if ($term === '') {
$result = '*';
} else if ($allowEnum !== 'no') {
$result = $term . '*';
}
return $result;
}

Expand Down Expand Up @@ -1285,7 +1289,7 @@ public function getUserDnByUuid($uuid) {
$filter = $this->connection->ldapUserFilter;
$base = $this->connection->ldapBaseUsers;

if($this->connection->ldapUuidUserAttribute === 'auto' && empty($uuidOverride)) {
if ($this->connection->ldapUuidUserAttribute === 'auto' && $uuidOverride === '') {
// Sacrebleu! The UUID attribute is unknown :( We need first an
// existing DN to be able to reliably detect it.
$result = $this->search($filter, $base, ['dn'], 1);
Expand Down Expand Up @@ -1341,7 +1345,7 @@ private function detectUuidAttribute($dn, $isUser = true, $force = false) {
return true;
}

if(!empty($uuidOverride) && !$force) {
if ($uuidOverride !== '' && !$force) {
$this->connection->$uuidAttr = $uuidOverride;
return true;
}
Expand Down Expand Up @@ -1384,7 +1388,7 @@ public function getUUID($dn, $isUser = true) {
if($this->detectUuidAttribute($dn, $isUser)) {
$uuid = $this->readAttribute($dn, $this->connection->$uuidAttr);
if( !is_array($uuid)
&& !empty($uuidOverride)
&& $uuidOverride !== ''
&& $this->detectUuidAttribute($dn, $isUser, true)) {
$uuid = $this->readAttribute($dn,
$this->connection->$uuidAttr);
Expand Down
4 changes: 2 additions & 2 deletions apps/user_ldap/lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function setConfiguration($config, &$applied = null) {
break;
case 'homeFolderNamingRule':
$trimmedVal = trim($val);
if(!empty($trimmedVal) && strpos($val, 'attr:') === false) {
if ($trimmedVal !== '' && strpos($val, 'attr:') === false) {
$val = 'attr:'.$trimmedVal;
}
break;
Expand Down Expand Up @@ -309,7 +309,7 @@ protected function setMultiLine($varName, $value) {
foreach($value as $key => $val) {
if(is_string($val)) {
$val = trim($val);
if(!empty($val)) {
if ($val !== '') {
//accidental line breaks are not wanted and can cause
// odd behaviour. Thus, away with them.
$finalValue[] = $val;
Expand Down
13 changes: 8 additions & 5 deletions apps/user_ldap/lib/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function __set($name, $value) {
$this->configuration->$name = $value;
$after = $this->configuration->$name;
if($before !== $after) {
if(!empty($this->configID)) {
if ($this->configID !== '') {
$this->configuration->saveConfiguration();
}
$this->validateConfiguration();
Expand Down Expand Up @@ -358,8 +358,8 @@ private function doSoftValidation() {
}
}

$backupPort = $this->configuration->ldapBackupPort;
if(empty($backupPort)) {
$backupPort = intval($this->configuration->ldapBackupPort);
if ($backupPort <= 0) {
$this->configuration->backupPort = $this->configuration->ldapPort;
}

Expand Down Expand Up @@ -427,7 +427,10 @@ private function doCriticalValidation() {
//combinations
$agent = $this->configuration->ldapAgentName;
$pwd = $this->configuration->ldapAgentPassword;
if((empty($agent) && !empty($pwd)) || (!empty($agent) && empty($pwd))) {
if (
($agent === '' && $pwd !== '')
|| ($agent !== '' && $pwd === '')
) {
\OCP\Util::writeLog('user_ldap',
$errorStr.'either no password is given for the'.
'user agent or a password is given, but not an'.
Expand Down Expand Up @@ -568,7 +571,7 @@ private function establishConnection() {
* @throws \OC\ServerNotAvailableException
*/
private function doConnect($host, $port) {
if(empty($host)) {
if ($host === '') {
return false;
}
$this->ldapConnectionRes = $this->ldap->connect($host, $port);
Expand Down
Loading