function extendedParsing($arrayState) { if (isset($arrayState['editgroupsave'])) { $idst = $_POST['idst']; $groupid = $_POST['groupid']; $description = $_POST['description']; $type = $_POST['group_type']; $show_on_platform = ''; if (isset($_POST['show_on_platform'])) { while (list($code, ) = each($_POST['show_on_platform'])) { $show_on_platform .= $code . ','; } } if ($idst !== '') { $this->aclManager->updateGroup($idst, $groupid, $description, NULL, $type, $show_on_platform); } else { $this->aclManager->registerGroup($groupid, $description, NULL, $type, $show_on_platform); } } elseif (isset($arrayState['deletegroup'])) { $idst = $_POST['idst']; if ($idst !== '') { $this->aclManager->deleteGroup($idst); } } // Subscribe the user approved if (isset($arrayState['editwaitsave'])) { require_once $GLOBALS['where_framework'] . '/lib/lib.field.php'; $field_manager = new FieldList(); $idst_group = $_POST['idst']; if (isset($arrayState['waiting_user']) && is_array($arrayState['waiting_user'])) { while (list($idst_user, $action) = each($arrayState['waiting_user'])) { if ($action == 'accept') { $this->aclManager->addToGroup($idst_group, $idst_user); $this->aclManager->removeFromUserWaitingOfGroup($idst_group, $idst_user); } elseif ($action == 'decline') { if ($field_manager->removeUserEntry($idst_user, $idst_group)) { $this->aclManager->removeFromUserWaitingOfGroup($idst_group, $idst_user); } } // end if } //end while } // end if } // end action managment if (isset($arrayState[$this->id])) { if (isset($arrayState[$this->id][$this->_getOpEditItemId()])) { $this->itemSelected = key($arrayState[$this->id][$this->_getOpEditItemId()]); $this->op = 'editgroup'; } if (isset($arrayState[$this->id][$this->_getOpDeleteItemId()])) { $this->itemSelected = key($arrayState[$this->id][$this->_getOpDeleteItemId()]); $this->op = 'deletegroup'; } if (isset($arrayState[$this->id][$this->_getOpAddToItemId()])) { $this->itemSelected = key($arrayState[$this->id][$this->_getOpAddToItemId()]); $this->op = 'addtogroup'; } if (isset($arrayState[$this->id][$this->_getOpAssignFieldId()])) { $this->itemSelected = key($arrayState[$this->id][$this->_getOpAssignFieldId()]); $this->op = 'assignfield'; } if (isset($arrayState[$this->id][$this->_getOpMembersId()])) { $this->itemSelected = key($arrayState[$this->id][$this->_getOpMembersId()]); $this->op = 'membersgroup'; } if (isset($arrayState[$this->id][$this->_getOpWaitingId()])) { $this->itemSelected = key($arrayState[$this->id][$this->_getOpWaitingId()]); $this->op = 'waitinggroup'; } if (isset($arrayState[$this->id]['import_groupuser'])) { $this->op = 'import_groupuser'; } } if ($this->insNew) { $this->setInsNew(checkPerm('creategroup', true)); } }
function savesel() { checkPerm('view'); require_once $GLOBALS['where_framework'] . '/lib/lib.field.php'; require_once _base_ . '/lib/lib.form.php'; $lang =& DoceboLanguage::createInstance('register', 'lms'); $mand_sym = '<span class="mandatory">*</span>'; $extra_field = new FieldList(); $GLOBALS['page']->add(getTitleArea($lang->def('_MYGROUP'), 'mygroup') . '<div class="std_block">', 'content'); $selected = array(); if (isset($_POST['group_sel'])) { $selected = $_POST['group_sel']; } elseif (isset($_POST['group_sel_implode'])) { $selected = explode(',', $_POST['group_sel_implode']); } $play_field = $extra_field->playFieldsForUser(getLogUserId(), $selected, false, false, array('readonly')); if (isset($_POST['save_field']) || $play_field === false || $play_field == '') { $re_filled = $extra_field->isFilledFieldsForUser(getLogUserId(), $selected); if (!$re_filled) { $GLOBALS['page']->add(getErrorUi($lang->def('_SOME_MANDATORY_EMPTY')), 'content'); } else { $acl =& Docebo::user()->getAcl(); $acl_man =& Docebo::user()->getAclManager(); $groups =& $acl_man->getAllGroupsId(array('free', 'moderate')); $groups_id = array_keys($groups); $user_group = $acl->getSTGroupsST(getLogUserId()); $add_groups = array_diff($selected, $user_group); $del_groups = array_diff($groups_id, $selected); $moderate_add = false; if (!empty($add_groups)) { while (list(, $idst) = each($add_groups)) { if ($groups[$idst]['type'] == 'free') { $acl_man->addToGroup($idst, getLogUserId()); } elseif ($groups[$idst]['type'] == 'moderate') { $acl_man->addToWaitingGroup($idst, getLogUserId()); $moderate_add = true; } } } if ($moderate_add === true) { require_once _base_ . '/lib/lib.eventmanager.php'; // message to user that is odified $msg_composer = new EventMessageComposer(); $msg_composer->setSubjectLangText('email', '_TO_APPROVE_GROUP_USER_SBJ', false); $msg_composer->setBodyLangText('email', '_TO_APPROVE_GROUP_USER_TEXT', array('[url]' => Get::sett('url'))); $msg_composer->setBodyLangText('sms', '_TO_APPROVE_GROUP_USER_TEXT_SMS', array('[url]' => Get::sett('url'))); $idst_approve = $acl->getRoleST('/framework/admin/directory/editgroup'); $recipients = $acl_man->getAllRoleMembers($idst_approve); createNewAlert('UserGroupModerated', 'directory', 'moderate', '1', 'User group subscription to moderate', $recipients, $msg_composer); } if (!empty($del_groups)) { while (list(, $idst_group) = each($del_groups)) { $extra_field->removeUserEntry(getLogUserId(), $idst_group); $acl_man->removeFromGroup($idst_group, getLogUserId()); } } // Save fields $extra_field->storeFieldsForUser(getLogUserId()); Util::jump_to('index.php?modname=mygroup&op=group'); } } $GLOBALS['page']->add('<div class="reg_note">' . $lang->def('_GROUPS_FIELDS') . '<ul class="reg_instruction">' . '<li>' . str_replace('[mandatory]', $mand_sym, $lang->def('_REG_MANDATORY')) . '</li>' . '</ul>' . '</div>' . Form::openForm('group_subscription', 'index.php?modname=mygroup&op=savesel') . Form::openElementSpace() . Form::getHidden('group_sel_implode', 'group_sel_implode', isset($_POST['group_sel_implode']) ? $_POST['group_sel_implode'] : implode(',', $selected)) . $play_field . Form::getBreakRow() . Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('save_field', 'save_field', $lang->def('_SAVE')) . Form::closeButtonSpace() . Form::closeForm() . '</div>', 'content'); }