55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
* AVSDev UF Organisations (https://avsdev.uk)
|
|
*
|
|
* @link https://git.avsdev.uk/avsdev/sprinkle-organisations
|
|
* @license https://git.avsdev.uk/avsdev/sprinkle-organisations/blob/master/LICENSE.md (LGPL-3.0 License)
|
|
*/
|
|
|
|
namespace UserFrosting\Sprinkle\Organisations\Repository;
|
|
|
|
use UserFrosting\Sprinkle\Core\Util\ClassMapper;
|
|
use UserFrosting\Sprinkle\UFTweaks\Repository\BasicTokenRepository;
|
|
|
|
/**
|
|
* Token repository class for new organisation approval.
|
|
*
|
|
* @author Craig Williams (https://avsdev.uk)
|
|
*/
|
|
class OrganisationApprovalRepository extends BasicTokenRepository
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected $modelIdentifier = 'organisation_approval';
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function updateTokenOwner($owner_id, $model, $args)
|
|
{
|
|
$organisation = $this->classMapper->getClassMapping('organisation')::findUnique($owner_id, 'id', false);
|
|
|
|
if (!$organisation) {
|
|
return false;
|
|
}
|
|
|
|
// If specified, recored the approver. This assumes the model has an approver_id field which it may not...
|
|
if ($args['approver_id']) {
|
|
$model->approver_id = $args['approver_id'];
|
|
}
|
|
|
|
if ($args['approved']) {
|
|
// Mark the organisation as approved
|
|
$organisation->flag_approved = 1;
|
|
$organisation->save();
|
|
} else {
|
|
// Soft delete the organisation
|
|
$organisation->delete(false);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|