Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
Merge branch '2022.11' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
gitlabci committed Mar 16, 2022
2 parents c82af54 + e26268d commit 65847df
Show file tree
Hide file tree
Showing 84 changed files with 2,078 additions and 703 deletions.
1 change: 1 addition & 0 deletions tests/tine20/HumanResources/Controller/ContractTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public function testUpdateContract()
'status' => 'ACCEPTED',
'employee_id' => $employee->getId(),
'account_id' => $myAccount->getId(),
HumanResources_Model_FreeTime::FLD_PROCESS_STATUS => HumanResources_Config::FREE_TIME_PROCESS_STATUS_REQUESTED,
'type' => 'vacation',
'freedays' => array(
array('date' => $firstDayDate, 'duration' => 1)
Expand Down
2 changes: 2 additions & 0 deletions tests/tine20/HumanResources/Controller/DailyWTReportTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ public function testCalculateReportsForEmployeeVacation()
'employee_id' => $this->employee->getId(),
'account_id' => $this->employee->account_id,
'type' => HumanResources_Model_FreeTimeType::ID_VACATION,
HumanResources_Model_FreeTime::FLD_PROCESS_STATUS => HumanResources_Config::FREE_TIME_PROCESS_STATUS_ACCEPTED,
'freedays' => [
['date' => '2018-08-01']
]
Expand Down Expand Up @@ -307,6 +308,7 @@ public function testCalculateReportsForEmployeeSickness()
'employee_id' => $this->employee->getId(),
'account_id' => $this->employee->account_id,
'type' => HumanResources_Model_FreeTimeType::ID_SICKNESS,
HumanResources_Model_FreeTime::FLD_PROCESS_STATUS => HumanResources_Config::FREE_TIME_PROCESS_STATUS_ACCEPTED,
'freedays' => [
['date' => '2018-08-01']
]
Expand Down
48 changes: 47 additions & 1 deletion tests/tine20/HumanResources/Controller/FreeTimeTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @package HumanResources
* @license http://www.gnu.org/licenses/agpl.html
* @copyright Copyright (c) 2018-2021 Metaways Infosystems GmbH (http://www.metaways.de)
* @copyright Copyright (c) 2018-2022 Metaways Infosystems GmbH (http://www.metaways.de)
* @author Cornelius Weiss <c.weiss@metaways.de>
*/

Expand Down Expand Up @@ -40,6 +40,7 @@ protected function _createFreeTime($user = null)
'employee_id' => $this->employee->getId(),
'account_id' => $accountId,
'type' => HumanResources_Model_FreeTimeType::ID_VACATION,
HumanResources_Model_FreeTime::FLD_PROCESS_STATUS => HumanResources_Config::FREE_TIME_PROCESS_STATUS_ACCEPTED,
'freedays' => [
['date' => '2018-08-01'],
['date' => '2018-08-02']
Expand Down Expand Up @@ -136,4 +137,49 @@ public function testAccessOwnDataGrant()
['field' => 'account_id', 'operator' => 'equals', 'value' => $freeTime->account_id],
]))->count());
}

public function testCreateChangeRequestGrant()
{
Tinebase_TransactionManager::getInstance()->unitTestForceSkipRollBack(true);

$freeTime = $this->_createFreeTime('pwulf');

Tinebase_Core::setUser($this->_personas['jsmith']);

try {
HumanResources_Controller_FreeTime::getInstance()->get($freeTime->getId());
$this->fail('pwulf should not see jsmith data');
} catch (Tinebase_Exception_AccessDenied $tead) {}

try {
HumanResources_Controller_Account::getInstance()->get($freeTime->account_id);
$this->fail('pwulf should not see jsmith data');
} catch (Tinebase_Exception_AccessDenied $tead) {}

try {
HumanResources_Controller_Employee::getInstance()->get($freeTime->employee_id);
$this->fail('pwulf should not see jsmith data');
} catch (Tinebase_Exception_AccessDenied $tead) {}

$grants = Tinebase_Container::getInstance()->getGrantsOfContainer(
($d = HumanResources_Controller_Division::getInstance()->get($this->employee->division_id))->container_id,
true);
$grants->addRecord(new HumanResources_Model_DivisionGrants([
'record_id' => $d->container_id,
'account_type' => Tinebase_Acl_Rights::ACCOUNT_TYPE_USER,
'account_id' => $this->_personas['jsmith']->getId(),
HumanResources_Model_DivisionGrants::CREATE_CHANGE_REQUEST => true,
]));
Tinebase_Container::getInstance()->setGrants($d->container_id, $grants, true, false);


HumanResources_Controller_FreeTime::getInstance()->get($freeTime->getId());
HumanResources_Controller_Account::getInstance()->get($freeTime->account_id);
HumanResources_Controller_Employee::getInstance()->get($freeTime->employee_id);
$contracts = HumanResources_Controller_Contract::getInstance()->search(
Tinebase_Model_Filter_FilterGroup::getFilterForModel(HumanResources_Model_Contract::class, [
['field' => 'employee_id', 'operator' => 'equals', 'value' => $freeTime->getIdFromProperty('employee_id')],
]));
$this->assertSame(1, $contracts->count());
}
}
26 changes: 15 additions & 11 deletions tests/tine20/HumanResources/JsonTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public function testGetFeastAndFreeDaysWithGrants()
'employee_id' => $savedEmployee['id'],
'account_id' => $myAccount->getId(),
'type' => 'vacation',
HumanResources_Model_FreeTime::FLD_PROCESS_STATUS => HumanResources_Config::FREE_TIME_PROCESS_STATUS_REQUESTED,
'freedays' => array(
array('date' => $date->getClone()->addDay(60), 'duration' => 1),
)
Expand Down Expand Up @@ -165,6 +166,7 @@ public function testEmployee()
'employee_id' => $savedEmployee['id'],
'account_id' => $myAccount->getId(),
'type' => 'vacation',
HumanResources_Model_FreeTime::FLD_PROCESS_STATUS => HumanResources_Config::FREE_TIME_PROCESS_STATUS_REQUESTED,
'freedays' => array(
array('date' => $firstDayDate, 'duration' => 1),
array('date' => $firstDayDate->getClone()->addDay(1), 'duration' => 1),
Expand Down Expand Up @@ -685,7 +687,7 @@ public function testCalculation()
'account_id' => $accountId2013,
'employee_id' => $employee->getId(),
'type' => 'vacation',
'status' => 'ACCEPTED',
HumanResources_Model_FreeTime::FLD_PROCESS_STATUS => HumanResources_Config::FREE_TIME_PROCESS_STATUS_ACCEPTED,
'firstday_date' => $yesterday->subWeek(1)->toString()
);
$nd = $referenceDate->subMonth(2);
Expand Down Expand Up @@ -726,7 +728,7 @@ public function testCalculation()
'account_id' => $accountId2014,
'employee_id' => $employee->getId(),
'type' => 'vacation',
'status' => 'ACCEPTED',
HumanResources_Model_FreeTime::FLD_PROCESS_STATUS => HumanResources_Config::FREE_TIME_PROCESS_STATUS_ACCEPTED,
'firstday_date' => $refdate,
'lastday_date' => $refdate->addDay(3)->toString(),
'days_count' => 3
Expand Down Expand Up @@ -768,7 +770,7 @@ public function testCalculation()
'account_id' => $accountId2013,
'employee_id' => $employee->getId(),
'type' => 'vacation',
'status' => 'ACCEPTED',
HumanResources_Model_FreeTime::FLD_PROCESS_STATUS => HumanResources_Config::FREE_TIME_PROCESS_STATUS_ACCEPTED,
'firstday_date' => $day->toString()
);

Expand All @@ -793,7 +795,7 @@ public function testCalculation()
'account_id' => $accountId2013,
'employee_id' => $employee->getId(),
'type' => 'sickness',
'status' => 'ACCEPTED',
HumanResources_Model_FreeTime::FLD_PROCESS_STATUS => HumanResources_Config::FREE_TIME_PROCESS_STATUS_ACCEPTED,
'firstday_date' => $day->toString()
);

Expand Down Expand Up @@ -869,7 +871,7 @@ public function testFirstAndLastDayOfFreetime()
'account_id' => $accountId2013,
'employee_id' => $employee->getId(),
'type' => 'vacation',
'status' => 'ACCEPTED',
HumanResources_Model_FreeTime::FLD_PROCESS_STATUS => HumanResources_Config::FREE_TIME_PROCESS_STATUS_ACCEPTED,
);

$newFreeTime['freedays'] = array(
Expand Down Expand Up @@ -1104,7 +1106,7 @@ public function testAddContract()
'employee_id' => $employeeJson['id'],
'account_id' => $account->getId(),
'type' => 'vacation',
'status' => 'ACCEPTED',
HumanResources_Model_FreeTime::FLD_PROCESS_STATUS => HumanResources_Config::FREE_TIME_PROCESS_STATUS_ACCEPTED,
'freedays' => [['duration' => '1', 'date' => '2013-01-11 00:00:00']],
]));

Expand Down Expand Up @@ -1245,7 +1247,7 @@ public function testAlternatingContracts()
'account_id' => $account['id'],
'employee_id' => $recordData['id'],
'type' => 'vacation',
'status' => 'ACCEPTED',
HumanResources_Model_FreeTime::FLD_PROCESS_STATUS => HumanResources_Config::FREE_TIME_PROCESS_STATUS_ACCEPTED,
'firstday_date' => $day->toString()
);

Expand All @@ -1265,7 +1267,7 @@ public function testAlternatingContracts()
'account_id' => $account['id'],
'employee_id' => $recordData['id'],
'type' => 'vacation',
'status' => 'ACCEPTED',
HumanResources_Model_FreeTime::FLD_PROCESS_STATUS => HumanResources_Config::FREE_TIME_PROCESS_STATUS_ACCEPTED,
'firstday_date' => $day->toString()
);

Expand All @@ -1288,7 +1290,7 @@ public function testAlternatingContracts()
'account_id' => $account['id'],
'employee_id' => $recordData['id'],
'type' => 'vacation',
'status' => 'ACCEPTED',
HumanResources_Model_FreeTime::FLD_PROCESS_STATUS => HumanResources_Config::FREE_TIME_PROCESS_STATUS_ACCEPTED,
'firstday_date' => $day->toString()
);

Expand All @@ -1311,7 +1313,8 @@ public function testAlternatingContracts()
'account_id' => $account['id'],
'employee_id' => $recordData['id'],
'type' => 'sickness',
'status' => "EXCUSED",
HumanResources_Model_FreeTime::FLD_PROCESS_STATUS => HumanResources_Config::FREE_TIME_PROCESS_STATUS_ACCEPTED,
HumanResources_Model_FreeTime::FLD_TYPE_STATUS => HumanResources_Config::FREE_TIME_TYPE_STATUS_EXCUSED,
'firstday_date' => $day->toString()
);

Expand Down Expand Up @@ -1349,7 +1352,8 @@ public function testAlternatingContracts()
'account_id' => $account['id'],
'employee_id' => $recordData['id'],
'type' => 'sickness',
'status' => "UNEXCUSED",
HumanResources_Model_FreeTime::FLD_PROCESS_STATUS => HumanResources_Config::FREE_TIME_PROCESS_STATUS_ACCEPTED,
HumanResources_Model_FreeTime::FLD_TYPE_STATUS => HumanResources_Config::FREE_TIME_TYPE_STATUS_UNEXCUSED,
'firstday_date' => $day->toString()
);

Expand Down
11 changes: 11 additions & 0 deletions tests/tine20/HumanResources/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ protected function setUp(): void
parent::setUp();
}

protected function tearDown(): void
{
$this->_feast_calendar = null;
$this->_department = null;
$this->_40hoursWorkingTimeScheme = null;
$this->employee = null;
$this->division = null;

parent::tearDown();
}


protected function _createBasicData($account = null)
{
Expand Down
1 change: 1 addition & 0 deletions tests/tine20/Tinebase/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ public function testGetModelsOfAllApplications()
HumanResources_Model_StreamModalReport::class,
HumanResources_Model_WageType::class,
HumanResources_Model_WorkingTimeScheme::class,
HumanResources_Model_WTRCorrection::class,
),
'Inventory' => array(
Inventory_Model_InventoryItem::class,
Expand Down
2 changes: 2 additions & 0 deletions tests/tine20/Tinebase/Frontend/JsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,8 @@ public function testGetAllRegistryData()
// no smtp config found
}

self::assertSame(60, $registryData['Tinebase']['serviceMap']['services']['Sales.createPaperSlip']['apiTimeout']);

self::assertLessThan(2000000, strlen(json_encode($registryData)), 'registry size got too big');
}

Expand Down
12 changes: 8 additions & 4 deletions tests/tine20/Tinebase/Server/JsonTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public function testGetServiceMap()
'name' => 'duplicateCheck'
)
),
'returns' => 'array'
'returns' => 'array',
'apiTimeout' => null,
), $smdArray['services']['Inventory.saveInventoryItem'], 'saveInventoryItem smd mismatch');
$this->assertEquals(array
(
Expand All @@ -66,7 +67,8 @@ public function testGetServiceMap()
'name' => 'ids'
)
),
'returns' => 'array'
'returns' => 'array',
'apiTimeout' => null,
), $smdArray['services']['Inventory.deleteInventoryItems']);

$this->assertEquals(array
Expand All @@ -88,7 +90,8 @@ public function testGetServiceMap()
'name' => 'paging'
)
),
'returns' => 'array'
'returns' => 'array',
'apiTimeout' => null,
), $smdArray['services']['Inventory.searchInventoryItems']);

self::assertEquals(array
Expand Down Expand Up @@ -122,7 +125,8 @@ public function testGetServiceMap()
'name' => 'clientRecordData'
),
),
'returns' => 'array'
'returns' => 'array',
'apiTimeout' => null,
), $smdArray['services']['Inventory.importInventoryItems']);
}

Expand Down
13 changes: 13 additions & 0 deletions tine20/ActiveSync/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class ActiveSync_Config extends Tinebase_Config_Abstract
*/
const DISABLE_ACCESS_LOG = 'disableaccesslog';

const DISABLE_REMOTE_RESET = 'disableremotereset';

/**
* MAX_FILTER_TYPE_EMAIL
*
Expand Down Expand Up @@ -93,6 +95,17 @@ class ActiveSync_Config extends Tinebase_Config_Abstract
// '/^Android-Mail.*/', // example if you like to deny all Android-Mail* clients
],
),
self::DISABLE_REMOTE_RESET => [
//_('Disable Remote Reset Action')
'label' => 'Disable Remote Reset Action',
//_('Disable Remote Reset Action AdminPanel')
'description' => 'Disable Remote Reset Action on AdminPanel',
'type' => Tinebase_Config_Abstract::TYPE_BOOL,
'clientRegistryInclude' => true,
'setByAdminModule' => FALSE,
'setBySetupModule' => TRUE,
'default' => FALSE,
],
self::DISABLE_ACCESS_LOG => array(
//_('Disable Access Log')
'label' => 'Disable Access Log creation',
Expand Down
23 changes: 23 additions & 0 deletions tine20/ActiveSync/Frontend/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,27 @@ public function resetSync(Zend_Console_Getopt $opts)

return ($result) ? 0 : 1;
}


/**
*
* remoteDeviceReset
* set remoteWipe flag for device (id)
* php tine20.php --method=ActiveSync.remoteDeviceReset id=12345
* @param Zend_Console_Getopt $opts
* @return int
* @throws Tinebase_Exception_AccessDenied
* @throws Tinebase_Exception_InvalidArgument
* @throws Tinebase_Exception_NotFound
*/
public function remoteDeviceReset(Zend_Console_Getopt $opts)
{
$args = $this->_parseArgs($opts, ['id']);
if (! $args['id'] || ! $this->_checkAdminRight(false)) {
return 1;
}

ActiveSync_Controller_SyncDevices::getInstance()->remoteResetDevices([ActiveSync_Controller_Device::getInstance()->get($args['id'])]);
return 0;
}
}
19 changes: 11 additions & 8 deletions tine20/ActiveSync/js/SyncDevicesGridPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,18 @@ Tine.ActiveSync.SyncDevicesGridPanel = Ext.extend(Tine.widgets.grid.GridPanel, {
* @returns {Array}
*/
getAdditionalCtxItems: function() {
this.actionRemoteResetDevices = new Ext.Action({
text: this.app.i18n._('Remote Device Reset'),
disabled: ! Tine.Tinebase.common.hasRight('RESET DEVICES', 'ActiveSync'),
scope: this,
handler: this.onRemoteResetDevices,
iconCls: 'action_wipeDevice'
});
if (!this.app.getRegistry().get('config')['disableremotereset'].value) {
this.actionRemoteResetDevices = new Ext.Action({
text: this.app.i18n._('Remote Device Reset'),
disabled: !Tine.Tinebase.common.hasRight('RESET DEVICES', 'ActiveSync'),
scope: this,
handler: this.onRemoteResetDevices,
iconCls: 'action_wipeDevice',
});

return [this.actionRemoteResetDevices];
return [this.actionRemoteResetDevices];
}
return null;
},

/**
Expand Down
9 changes: 7 additions & 2 deletions tine20/Admin/Controller/EmailAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,13 @@ public function resolveAccountEmailUsers($_records)
$emailUserBackend = Tinebase_EmailUser::getInstance(Tinebase_Config::IMAP);
$smtpUserBackend = Tinebase_EmailUser::getInstance(Tinebase_Config::SMTP);

$_record->email_imap_user = $emailUserBackend->getEmailuser($fullUser)->toArray();
$_record->email_smtp_user = $smtpUserBackend->getEmailuser($fullUser)->toArray();
if (method_exists($emailUserBackend, 'getEmailuser')) {
$_record->email_imap_user = $emailUserBackend->getEmailuser($fullUser)->toArray();
}

if (method_exists($smtpUserBackend, 'getEmailuser')) {
$_record->email_smtp_user = $smtpUserBackend->getEmailuser($fullUser)->toArray();
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions tine20/Felamimail/Controller/Sieve.php
Original file line number Diff line number Diff line change
Expand Up @@ -642,10 +642,12 @@ protected function _doMessageSubstitutions(Felamimail_Model_Sieve_Vacation $vaca
$timezone = Tinebase_Core::getUserTimezone();
$representatives = ($vacation->contact_ids) ? Addressbook_Controller_Contact::getInstance()->getMultiple($vacation->contact_ids) : array();
if ($vacation->contact_ids && count($representatives) > 0) {
// sort representatives
// sort and expand representatives
$representativesArray = array();
foreach ($vacation->contact_ids as $id) {
$representativesArray[] = $representatives->getById($id);
if ($contact = $representatives->getById($id)) {
$representativesArray[] = $contact;
}
}
}
try {
Expand Down

0 comments on commit 65847df

Please sign in to comment.