menu();
UI::dol();
}
public function menu() {
$usrLogin = User::getLogin();
?>
';
try {
if (empty($usrLogin)) throw new Exception("Empty user login");
$subTask = V::get('_subTask', '', $_POST);
if ('removeUserGroup' == $subTask) {
$idProfileToRemove = V::get('idProfileToRemove', 0, $_POST, 'int');
$this->removeUserGroup($usrLogin, $idProfileToRemove);
?>
Użytkownik został usunięty z danej grupy
addUserGroup($usrLogin, $idGroup, $idTelboxes);
?>
Dodano grupę [] do użytkownika []
printFormUserGroup($usrLogin);
} catch (Exception $e) {
?>
';// .container
UI::dol();
}
public function printFormUserGroup($usrLogin) {
if (empty($usrLogin)) throw new Exception("Empty user login");
$usrStorageDB = UserStorageFactory::getStorage('DB');
if (!$usrStorageDB) throw new Exception("Storage DB not exists!");
$usr = $usrStorageDB->getUser($usrLogin);
if (!$usr) throw new Exception("Użytkownik '{$usrLogin}' nie istnieje.");
$stanowiska = array();
$stanowiska = $usrStorageDB->getUserProfiles($usrLogin, $fetchNested = false);
uasort($stanowiska, array($this, 'sortStanowiskaByType'));
$groups = UsersHelper::getGroupByUser($usr->primaryKey);
DBG::_('DBG_SU', '>1', 'groups', $groups, __CLASS__, __FUNCTION__, __LINE__);
$groupsNetwork = UsersLdapHelper::getUserGroups($usrLogin, 3);
DBG::_('DBG_SU', '>1', 'groupsNetwork', $groupsNetwork, __CLASS__, __FUNCTION__, __LINE__);
$typeSpecialUserGroups = TypespecialVariable::getInstance(-1, '__USER_GROUPS');
$typeSpecialTelboxes = TypespecialVariable::getInstance(-1, '__TELBOXES');
$idZasobUsersTbl = ProcesHelper::getZasobTableID('ADMIN_USERS');
?>
Ustalanie stanowiska
Użytkownik
isDisabled) : ?>
zablokowany!
aktywny
[primaryKey; ?>] name; ?> login; ?>
0) : ?>
edytuj
synchronizuj do LDAP
Przypisane grupy ():
-
group->realName; ?>
localisationId > 0) : ?>
(lokalizacja [localisationId; ?>])
Dodaj grupę:
hasTableAcl($zasobObj->ID)) throw new Exception("Brak uprawnień do tabeli ID={$zasobObj->ID}");
$tblAcl = $userAcl->getTableAcl($zasobObj->ID);
$forceTblAclInit = ('1' == V::get('_force', '', $_GET));
$tblAcl->init($forceTblAclInit);
$forceFilterInit = array();
$filterInit = new stdClass();
$filterInit->currSortCol = 'ID';
$filterInit->currSortFlip = 'desc';
foreach ($_GET as $k => $v) {
if (strlen($k) > 3 && substr($k, 0, 2) == 'f_' && !empty($v)) {// filter prefix
$filterInit->$k = $v;
}
else if (strlen($k) > 4 && substr($k, 0, 3) == 'sf_' && !empty($v)) {// special filter prefix
$filterInit->$k = $v;
}
else if (strlen($k) > 4 && substr($k, 0, 3) == 'ff_' && !empty($v)) {// force filter prefix
$fldName = substr($k, 3);
$forceFilterInit[$fldName] = $v;
}
}
$forceFilterInit['REMOTE_ID'] = $usr->primaryKey;
$forceFilterInit['REMOTE_TABLE'] = 'ADMIN_USERS';
$tbl = new TableAjax($tblAcl);
$tbl->setLabel($zasobObj->OPIS);
$tbl->setFilterInit($filterInit);
if (!empty($forceFilterInit)) $tbl->setForceFilterInit($forceFilterInit);
$tbl->addRowFunction('edit');
$tbl->addRowFunction('hist');
$tbl->addRowFunction('files');
$tbl->addRowFunction('cp');
$tbl->showProcesInit(false);// hide Proces filter field
echo $tbl->render();
}
}
public function sortStanowiskaByType($a, $b) {
if ($a->group->type != $a->group->type) {
if ($a->group->type == 'network') {
return 1;
}
else if ($a->group->type == 'local') {
return -1;
}
}
return 0;
}
public function removeUserGroup($usrLogin, $idProfileToRemove) {
if (!$usrLogin) throw new Exception("Wrong param user login!");
if (!$idProfileToRemove) throw new Exception("Wrong param id profile to remove!");
$usrStorageDB = UserStorageFactory::getStorage('DB');
if (!$usrStorageDB) throw new Exception("Error storage not exists!");
$profile = $usrStorageDB->getProfileById($idProfileToRemove);
if (!$profile) throw new Exception("Error profile not exists!");
$usrStorageDB->removeUserGroupByProfileId($usrLogin, $profile->group, $idProfileToRemove);
}
public function addUserGroup($usrLogin, $idGroup, $idTelboxes) {
DBG::_('DBG_NG', '>0', 'post', $_POST, __CLASS__, __FUNCTION__, __LINE__);
if (!$usrLogin) throw new Exception("Wrong param user login!");
$usrStorageDB = UserStorageFactory::getStorage('DB');
if (!$usrStorageDB) throw new Exception("Error storage not exists!");
$usr = $usrStorageDB->getUser($usrLogin);
if (!$usr) throw new Exception("Użytkownik {$usrLogin} nie istnieje.");
if ($idGroup > 0) {
$groupToAdd = $usrStorageDB->getGroupWithoutNested($idGroup);
if (!$groupToAdd) throw new Exception("Grupa [{$idGroup}] nie istnieje");
$added = $usrStorageDB->addUserGroup($usrLogin, $groupToAdd, $idTelboxes);
}
}
public function typeSpecialIdGroupAction() {
header("Content-type: application/json");
$typeSpecialUserGroups = TypespecialVariable::getInstance(-1, '__USER_GROUPS');
$query = V::get('q', '', $_REQUEST);
$rawRows = null;
$rows = $typeSpecialUserGroups->getValuesWithExports($query);
DBG::_('DBG', '>0', "rows(q={$query})", $rows, __CLASS__, __FUNCTION__, __LINE__);
foreach ($rows as $kID => $vItem) {
$itemJson = new stdClass();
$itemJson->id = $vItem->id;
$itemJson->name = $vItem->param_out;
if (!empty($vItem->exports)) {
$itemJson->exports = $vItem->exports;
}
$jsonData[] = $itemJson;
}
echo json_encode($jsonData);
}
public function typeSpecialIdTelboxesAction() {
header("Content-type: application/json");
$typeSpecialTelboxes = TypespecialVariable::getInstance(-1, '__TELBOXES');
$query = V::get('q', '', $_REQUEST);
$rawRows = null;
$rows = $typeSpecialTelboxes->getValuesWithExports($query);
DBG::_('DBG', '>0', "rows(q={$query})", $rows, __CLASS__, __FUNCTION__, __LINE__);
foreach ($rows as $kID => $vItem) {
$itemJson = new stdClass();
$itemJson->id = $vItem->id;
$itemJson->name = $vItem->param_out;
if (!empty($vItem->exports)) {
$itemJson->exports = $vItem->exports;
}
$jsonData[] = $itemJson;
}
echo json_encode($jsonData);
}
public function syncGroupAction() {
$idGroup = V::get('idGroup', 0, $_GET, 'int');
$group = null;
UI::gora();
UI::menu();
echo '
';
try {
if (!$idGroup) throw new Exception("Brak numeru grupy!");
$idZasobTableZasoby = ProcesHelper::getZasobTableID('CRM_LISTA_ZASOBOW');
$usrStorageDB = UserStorageFactory::getStorage('DB');
if ($usrStorageDB) $group = $usrStorageDB->getGroup($idGroup);
?>
Synchronizacja grupy do bazy LDAP
Grupa []:
type; ?> zasobDESC; ?>
edytuj
ustal powiązania między grupami uprawnień
syncGroup($idGroup);
} catch (Exception $e) {
?>
getMessage(); ?>
';// .container
UI::dol();
}
public function syncGroup($idGroup) {
$usrStorageDB = UserStorageFactory::getStorage('DB');
$usrStorageLdap = UserStorageFactory::getStorage('MacOSX');
if (!$usrStorageDB) throw new Exception("Error storage DB not exists");
if (!$usrStorageLdap) throw new Exception("Error storage Ldap not exists");
$groupFrom = $usrStorageDB->getGroup($idGroup);
if (!$groupFrom) {
$db = DB::getDB();
$zasob = $db->get_by_id('CRM_LISTA_ZASOBOW', $idGroup);
if (!$zasob) {
throw new Exception("Zasób {$idGroup} nie istnieje");
} else {
throw new Exception("Zasób {$idGroup} nie jest grupą tylko {$zasob->TYPE}");
}
}
else {
$synUsers = new SyncUsers($usrStorageDB, $usrStorageLdap);
$syncTodoList = $synUsers->getSyncGroupTodoList($idGroup, $syncNestedGroups = true);
?>
Brak zadań do wykonania - grupa zsynchronizowana
Lista zadań do wykonania:
syncGroup($idGroup, $syncNestedGroups = true);
if (!$synced) {
?>
Nie udało się zsynchronizować grupy [].
errors: (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($synUsers->getErrorsMsgListWithDbg());echo'';
}
else {
?>
Synchronizacja grupy [] zakończona powodzeniem.
';
try {
if (empty($usrLogin)) throw new Exception("Empty user login");
$usrStorageDB = UserStorageFactory::getStorage('DB');
$usrStorageLdap = UserStorageFactory::getStorage('MacOSX');
if (!$usrStorageDB) throw new Exception("Error storage DB not exists");
if (!$usrStorageLdap) throw new Exception("Error storage Ldap not exists");
echo '
' . "Synchronizacja do LDAP" . '
';
$usrFrom = $usrStorageDB->getUser($usrLogin);
DBG::_('DBG_SU', '>1', 'User from:', $usrFrom, __CLASS__, __FUNCTION__, __LINE__);
if ($usrFrom) {
$idZasobUsersTbl = ProcesHelper::getZasobTableID('ADMIN_USERS');
$idZasobPermsTbl = ProcesHelper::getZasobTableID('CRM_AUTH_PROFILE');
?>
Użytkownik
isDisabled) : ?>
zablokowany!
aktywny
[primaryKey; ?>] name; ?> login; ?>
0) : ?>
edytuj
0) : ?>
ustal stanowisko
syncUser($usrLogin, $usrStorageDB, $usrStorageLdap);
} catch (Exception $e) {
?>
getMessage(); ?>
';// .container
UI::dol();
}
public function syncUser($userName, $usrStorageDB, $usrStorageLdap) {
if (empty($userName)) throw new Exception("Empty user login");
if (!$usrStorageDB) throw new Exception("Error storage DB not exists");
if (!$usrStorageLdap) throw new Exception("Error storage Ldap not exists");
$synUsers = new SyncUsers($usrStorageDB, $usrStorageLdap);
if ('1' == V::get('_runSync', '', $_POST)) {
$synced = $synUsers->syncUser($userName);
if (!$synced) {
?>
Nie udało się zsynchronizować uprawnień użytkownika .
getErrorsMsgListWithDbg();
if (!empty($errorsList)) {
echo'
';
echo "Błędy:\n" . implode("\n", $errorsList);
echo '';
}
}
else {
?>
Synchronizacja uprawnień użytkownika zakończona powodzeniem.
forceSyncUserAliasList($userName);
if (!$synced) {
?>
Nie udało się poprawić aliasów .
getErrorsMsgListWithDbg();
if (!empty($errorsList)) {
echo'
';
echo "Błędy:\n" . implode("\n", $errorsList);
echo '';
}
}
else {
?>
Synchronizacja listy aliasów pocztowych użytkownika zakończona powodzeniem.
getSyncUserTodoList($userName);
?>
Brak zadań do wykonania - użytkownik zsynchronizowany
Lista zadań do wykonania: