This repository has been archived on 2025-02-26. You can view files and clone it, but cannot push or open issues or pull requests.
szurubooru/src/Api/Jobs/EditUserJob.php

63 lines
927 B
PHP
Raw Normal View History

2014-05-04 13:39:00 +02:00
<?php
class EditUserJob extends AbstractUserJob
{
2014-05-04 16:27:15 +02:00
protected $subJobs;
2014-05-04 13:39:00 +02:00
2014-05-04 16:27:15 +02:00
public function __construct()
{
$this->subJobs =
2014-05-04 13:39:00 +02:00
[
2014-05-04 14:57:44 +02:00
new EditUserAccessRankJob(),
2014-05-04 13:39:00 +02:00
new EditUserNameJob(),
new EditUserPasswordJob(),
new EditUserEmailJob(),
];
2014-05-04 16:27:15 +02:00
}
public function canEditAnything($user)
{
$this->privileges = [];
foreach ($this->subJobs as $subJob)
{
try
{
$subJob->user = $user;
Api::checkPrivileges($subJob);
return true;
}
catch (SimpleException $e)
{
}
}
return false;
}
public function execute()
{
$user = $this->user;
LogHelper::bufferChanges();
2014-05-04 13:39:00 +02:00
foreach ($subJobs as $subJob)
{
$args = $this->getArguments();
$args[self::USER_NAME] = $user->name;
try
{
Api::run($subJob, $args);
}
catch (ApiMissingArgumentException $e)
{
}
}
LogHelper::flush();
return $user;
}
2014-05-04 16:27:15 +02:00
public function requiresPrivilege()
{
return false;
}
2014-05-04 13:39:00 +02:00
}