public function call($name, $params) { $output = false; // Loads user information according to the external user data provided: $params = $this->checkExternalUser($params, $_POST); if (!empty($params[0]) && !isset($params['idst'])) { $params['idst'] = $params[0]; //params[0] should contain user idst } if (empty($params['idst']) && !empty($_POST['idst'])) { $params['idst'] = (int) $_POST['idst']; } switch ($name) { case 'listUsers': case 'userslist': $list = $this->getUsersList(); if ($list['success']) { $output = array('success' => true, 'list' => $list['users_list']); } else { $output = array('success' => false); } break; case 'userdetails': if (count($params) > 0 && !isset($params['ext_not_found'])) { //params[0] should contain user id if (is_numeric($params['idst'])) { $res = $this->getUserDetails($params['idst']); if (!$res) { $output = array('success' => false, 'message' => "Error: unable to retrieve user details."); } else { $output = array('success' => true, 'details' => $res['details']); } } else { $output = array('success' => false, 'message' => 'Invalid passed parameter.'); } } else { $output = array('success' => false, 'message' => 'No parameter provided.'); } break; case 'customfields': $tmp_lang = false; //if not specified, use default language if (isset($params['language'])) { $tmp_lang = $params['language']; } //check if a language has been specified $res = $this->getCustomFields($tmp_lang); if ($res != false) { $output = array('success' => true, 'custom_fields' => $res); } else { $output = array('success' => false, 'message' => 'Error: unable to retrieve custom fields.'); } break; case 'create': case 'createuser': $res = $this->createUser($params, $_POST); if (is_array($res)) { $output = $res; } else { if ($res > 0) { $output = array('success' => true, 'idst' => $res); } else { $output = array('success' => false, 'message' => 'Error: unable to create new user.'); } } break; case 'edit': case 'updateuser': if (count($params) > 0 && !isset($params['ext_not_found'])) { //params[0] should contain user id $res = $this->updateUser($params['idst'], $_POST); if ($res > 0) { $output = array('success' => true); } elseif ($res < 0) { $output = array('success' => false, 'message' => 'Error: incorrect param idst.'); } } else { $output = array('success' => false, 'message' => 'Error: user id to update has not been specified.'); } break; case 'delete': case 'deleteuser': if (count($params) > 0 && !isset($params['ext_not_found'])) { //params[0] should contain user id $output = $this->deleteUser($params['idst'], $_POST); } else { $output = array('success' => false, 'message' => 'Error: user id to update has not been specified.'); } break; case 'userdetailsbyuserid': $acl_man = new DoceboACLManager(); $idst = $acl_man->getUserST($params['userid']); if (!$idst) { $output = array('success' => false, 'message' => 'Error: invalid userid: ' . $params['userid'] . '.'); } else { $output = $this->getUserDetails($idst); } break; case 'userdetailsfromcredentials': if (!isset($params['ext_not_found'])) { $output = $this->getUserDetailsFromCredentials($_POST); } break; case 'updateuserbyuserid': if (count($params) > 0) { //params[0] should contain user id $acl_man = new DoceboACLManager(); $idst = $acl_man->getUserST($params['userid']); if (!$idst) { $output = array('success' => false, 'message' => 'Error: invalid userid: ' . $params['userid'] . '.'); } else { $res = $this->updateUser($idst, $_POST); $output = array('success' => true); } } else { $output = array('success' => false, 'message' => 'Error: user id to update has not been specified.'); } break; case 'userCourses': case 'mycourses': if (!isset($params['ext_not_found'])) { $output = $this->getMyCourses($params['idst'], $_POST); } break; case 'kbsearch': if (!isset($params['ext_not_found'])) { $output = $this->KbSearch($params['idst'], $_POST); } break; case 'importextusers': $output = $this->importExternalUsers($_POST); break; case 'importextusersfromemail': $output = $this->importExternalUsersFromEmail($_POST); break; case 'countusers': $output = $this->countUsers($_POST); break; case 'checkregcode': $output = $this->checkRegistrationCode($_POST); break; case 'checkUsername': case 'checkusername': $output = $this->checkUsername($_POST); break; default: $output = parent::call($name, $_POST); } return $output; }