| 1 |
<?php |
| 2 |
/** |
| 3 |
* UserObjectController.php |
| 4 |
* |
| 5 |
* The UserObjectController class file. |
| 6 |
* |
| 7 |
* PHP versions 5 |
| 8 |
* |
| 9 |
* @author Alexander Schneider <alexanderschneider85@gmail.com> |
| 10 |
* @copyright 2008-2017 Alexander Schneider |
| 11 |
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 |
| 12 |
* @version SVN: $id$ |
| 13 |
* @link http://wordpress.org/extend/plugins/user-access-manager/ |
| 14 |
*/ |
| 15 |
|
| 16 |
declare(strict_types=1); |
| 17 |
|
| 18 |
namespace UserAccessManager\Controller\Backend; |
| 19 |
|
| 20 |
use UserAccessManager\Object\ObjectHandler; |
| 21 |
use UserAccessManager\UserGroup\UserGroupTypeException; |
| 22 |
|
| 23 |
/** |
| 24 |
* Class UserObjectController |
| 25 |
* |
| 26 |
* @package UserAccessManager\Controller\Backend |
| 27 |
*/ |
| 28 |
class UserObjectController extends ObjectController |
| 29 |
{ |
| 30 |
/** |
| 31 |
* The function for the manage_users_columns filter. |
| 32 |
* @param array $defaults The table headers. |
| 33 |
* @return array |
| 34 |
*/ |
| 35 |
public function addUserColumnsHeader(array $defaults): array |
| 36 |
{ |
| 37 |
$defaults[self::COLUMN_NAME] = TXT_UAM_COLUMN_USER_GROUPS; |
| 38 |
return $defaults; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* The function for the manage_users_custom_column action. |
| 43 |
* @param null|string $return The normal return value. |
| 44 |
* @param string $columnName The column name. |
| 45 |
* @param int|string $id The id. |
| 46 |
* @return string|null |
| 47 |
* @throws UserGroupTypeException |
| 48 |
*/ |
| 49 |
public function addUserColumn(?string $return, string $columnName, $id): ?string |
| 50 |
{ |
| 51 |
if ($columnName === self::COLUMN_NAME) { |
| 52 |
$this->setObjectInformation(ObjectHandler::GENERAL_USER_OBJECT_TYPE, $id); |
| 53 |
$return .= $this->getIncludeContents('UserColumn.php'); |
| 54 |
} |
| 55 |
|
| 56 |
return $return; |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* The function for the edit_user_profile action. |
| 61 |
* @throws UserGroupTypeException |
| 62 |
*/ |
| 63 |
public function showUserProfile() |
| 64 |
{ |
| 65 |
$userId = $this->getRequestParameter('user_id'); |
| 66 |
$this->setObjectInformation(ObjectHandler::GENERAL_USER_OBJECT_TYPE, $userId); |
| 67 |
|
| 68 |
echo $this->getIncludeContents('UserProfileEditForm.php'); |
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* The function for the profile_update action. |
| 73 |
* @param int|string $userId The user id. |
| 74 |
* @throws UserGroupTypeException |
| 75 |
* @throws UserGroupTypeException |
| 76 |
*/ |
| 77 |
public function saveUserData($userId) |
| 78 |
{ |
| 79 |
$this->saveObjectData(ObjectHandler::GENERAL_USER_OBJECT_TYPE, $userId); |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* The function for the delete_user action. |
| 84 |
* @param int|string $userId The user id. |
| 85 |
*/ |
| 86 |
public function removeUserData($userId) |
| 87 |
{ |
| 88 |
$this->removeObjectData(ObjectHandler::GENERAL_USER_OBJECT_TYPE, $userId); |
| 89 |
} |
| 90 |
} |
| 91 |
|