21 use Symfony\Component\HttpFoundation\Request;
41 $this->user_pk = $user_pk;
44 public function modifyUserDetails($reqBody, $version = ApiVersion::V1)
47 $restHelper = $container->get(
'helper.restHelper');
48 $userEditObj = $restHelper->getPlugin(
'user_edit');
50 $sessionOwnerUser_pk = $restHelper->getUserId();
51 $SessionUserRec = $userEditObj->GetUserRec($sessionOwnerUser_pk);
52 $SessionIsAdmin = $userEditObj->IsSessionAdmin($SessionUserRec);
54 $symReq = $this->createSymRequest($reqBody, $version);
55 if (!$SessionIsAdmin) {
56 $returnVal =
new Info(403,
"The session owner is not an admin!", InfoType::INFO);
58 $userRec = $userEditObj->CreateUserRec($symReq);
59 $ErrMsgs = $userEditObj->UpdateUser($userRec, $SessionIsAdmin);
61 if ($ErrMsgs ==
null) {
62 $returnVal =
new Info(200,
"User updated succesfully!", InfoType::INFO);
64 $returnVal =
new Info(400, $ErrMsgs, InfoType::INFO);
74 public function createSymRequest($userDetails, $version = ApiVersion::V1)
77 $restHelper = $container->get(
'helper.restHelper');
83 $userDao = $restHelper->getUserDao();
84 $user = $userDao->getUserByPk($this->user_pk);
86 $symfonyRequest =
new Request();
87 $symfonyRequest->request->set(
'user_pk', $userDetails[
'id'] ?? $this->user_pk);
88 $symfonyRequest->request->set(
'user_name', $userDetails[
'name'] ?? $user[
'user_name']);
89 $symfonyRequest->request->set(
'root_folder_fk', $userDetails[
'rootFolderId'] ?? $user[
'root_folder_fk']);
90 $symfonyRequest->request->set(
'default_group_fk', $userDetails[
'defaultGroup'] ?? $user[
'group_fk']);
91 $symfonyRequest->request->set(
'public', $userDetails[
'defaultVisibility'] ?? $user[
'upload_visibility']);
92 $symfonyRequest->request->set(
'default_folder_fk', $userDetails[
'defaultFolderId'] ?? $user[
'default_folder_fk']);
93 $symfonyRequest->request->set(
'user_desc', $userDetails[
'description'] ?? $user[
'user_desc']);
94 $symfonyRequest->request->set(
'_pass1', $userDetails[$version == ApiVersion::V2 ?
'userPass' :
'user_pass'] ??
null);
95 $symfonyRequest->request->set(
'_pass2', $userDetails[$version == ApiVersion::V2 ?
'userPass' :
'user_pass'] ??
null);
96 $symfonyRequest->request->set(
'_blank_pass', $userDetails[
'_blank_pass'] ??
"");
97 $symfonyRequest->request->set(
'user_status', $userDetails[
'user_status'] ?? $user[
'user_status']);
98 $symfonyRequest->request->set(
'user_email', $userDetails[
'email'] ?? $user[
'user_email']);
99 $symfonyRequest->request->set(
'email_notify', isset($userDetails[
'emailNotification']) && $userDetails[
'emailNotification'] ?
"y" : $user[
'email_notify']);
100 $symfonyRequest->request->set(
'default_bucketpool_fk', $userDetails[
'defaultBucketpool'] ?? $user[
'default_bucketpool_fk']);
102 if (isset($userDetails[
'accessLevel'])) {
104 $symfonyRequest->request->set(
'user_perm', $user_perm);
106 $symfonyRequest->request->set(
'user_perm', $user[
'user_perm']);
109 $agentsExists = array();
111 $agentsTempVal = explode(
',', $user[
'user_agent_list']);
112 foreach ($agentsTempVal as $agent) {
113 $agentsExists[
'Check_' . $agent] = 1;
115 $newAgents = array();
116 if (isset($userDetails[
'agents'])) {
117 if (is_string($userDetails[
'agents'])) {
118 $userDetails[
'agents'] = json_decode($userDetails[
'agents'],
true);
120 if (isset($userDetails[
'agents'][
'mime'])) {
121 $newAgents[
'Check_agent_mimetype'] = $userDetails[
'agents'][
'mime'] ? 1 : 0;
123 if (isset($userDetails[
'agents'][
'monk'])) {
124 $newAgents[
'Check_agent_monk'] = $userDetails[
'agents'][
'monk'] ? 1 : 0;
126 if (isset($userDetails[
'agents'][
'ojo'])) {
127 $newAgents[
'Check_agent_ojo'] = $userDetails[
'agents'][
'ojo'] ? 1 : 0;
129 if (isset($userDetails[
'agents'][$version == ApiVersion::V2 ?
'copyrightEmailAuthor' :
'copyright_email_author'])) {
130 $newAgents[
'Check_agent_copyright'] = $userDetails[
'agents'][$version == ApiVersion::V2 ?
'copyrightEmailAuthor' :
'copyright_email_author'] ? 1 : 0;
132 if (isset($userDetails[
'agents'][
'ecc'])) {
133 $newAgents[
'Check_agent_ecc'] = $userDetails[
'agents'][
'ecc'] ? 1 : 0;
135 if (isset($userDetails[
'agents'][
'keyword'])) {
136 $newAgents[
'Check_agent_keyword'] = $userDetails[
'agents'][
'keyword'] ? 1 : 0;
138 if (isset($userDetails[
'agents'][
'nomos'])) {
139 $newAgents[
'Check_agent_nomos'] = $userDetails[
'agents'][
'nomos'] ? 1 : 0;
141 if (isset($userDetails[
'agents'][
'package'])) {
142 $newAgents[
'Check_agent_pkgagent'] = $userDetails[
'agents'][
'package'] ? 1 : 0;
144 if (isset($userDetails[
'agents'][
'reso'])) {
145 $newAgents[
'Check_agent_reso'] = $userDetails[
'agents'][
'reso'] ? 1 : 0;
147 if (isset($userDetails[
'agents'][
'heritage'])) {
148 $newAgents[
'Check_agent_shagent'] = $userDetails[
'agents'][
'heritage'] ? 1 : 0;
152 foreach (array_keys($agentList) as $agentName) {
153 if (!array_key_exists(
"Check_$agentName", $newAgents)) {
154 $newAgents[
"Check_$agentName"] = 0;
158 $agents = array_replace($agentsExists, $newAgents);
160 $symfonyRequest->request->set(
'user_agent_list',
userAgents($agents));
162 return $symfonyRequest;
176 case 'clearing_admin':
177 return Auth::PERM_CADMIN;
Contains the constants and helpers for authentication of user.
Handle user related queries.
__construct($user_pk=null)
getEquivalentValueForPermission($perm)
Different type of infos provided by REST.
Info model to contain general error and return values.
userAgents($agents=null)
Read the UI form and format the user selected agents into a comma separated list.
listAgents()
Search in available plugins and return all agents.