/** * Only for input. Special function. **/ function event_special_view($op) { checkPerm('view_event_manager'); require_once _base_ . '/lib/lib.table.php'; //require_once(_i18n_.'/lib.lang.php'); require_once _base_ . '/lib/lib.form.php'; $lang =& DoceboLanguage::createInstance('event_manager', 'framework'); $out =& $GLOBALS['page']; $form = new Form(); $out->setWorkingZone('content'); $out->add(getTitleArea($lang->def('_EVENT_MANAGER'), 'event_manager')); $out->add('<div class="std_block">'); if ($op == 'special_save') { $arr_platform = $_POST['platform']; $arr_class = $_POST['class']; $arr_description = $_POST['description']; $arr_recipients = $_POST['recipients']; $arr_show_level = $_POST['show_level']; $idClass = 0; foreach ($arr_platform as $key => $platform) { if ($key == 0) { if ($platform != '') { $result1 = sql_query("INSERT INTO " . $GLOBALS['prefix_fw'] . "_event_class " . " (platform,class,description) VALUES " . " ('" . $platform . "','" . $arr_class[$key] . "','" . $arr_description[$key] . "') "); if ($result1 === FALSE) { break; } $idClass = mysql_insert_id(); DoceboEventManager::registerEventConsumer(array($arr_class[$key]), 'DoceboUserNotifier', $GLOBALS['where_framework'] . '/lib/lib.usernotifier.php'); $result1 = sql_query("INSERT INTO " . $GLOBALS['prefix_fw'] . "_event_manager " . " (idClass,recipients,show_level) VALUES " . " ('" . $idClass . "','" . $arr_recipients[$key] . "','" . $arr_show_level[$key] . "') "); } } else { $result1 = sql_query("UPDATE " . $GLOBALS['prefix_fw'] . "_event_class " . " SET platform='" . $platform . "'," . " class='" . $arr_class[$key] . "'," . " description='" . $arr_description[$key] . "'" . " WHERE idClass = '" . (int) $key . "'"); } if ($result1 === FALSE) { break; } } foreach ($arr_recipients as $key => $recipients) { if ($key == 0) { // do nothing } else { $result2 = sql_query("UPDATE " . $GLOBALS['prefix_fw'] . "_event_manager " . " SET recipients='" . $recipients . "'," . " show_level='" . $arr_show_level[$key] . "'" . " WHERE idEventMgr = '" . (int) $key . "'"); } if ($result1 === FALSE) { break; } } if ($result1 && $result2) { $out->add(getResultUi($lang->def('_OPERATION_SUCCESSFUL'))); } else { $out->add(getErrorUi($lang->def('_ERROR_IN_SAVE'))); } } $out->add($form->openForm('event_special_insert', 'index.php?modname=event_manager&op=special_save')); $out->add($form->openElementSpace()); $tb_event_classes = new Table(400, $lang->def('_EVENT_SETTINGS'), $lang->def('_EVENT_SETTINGS')); $content_h = array($lang->def('_EVENT_PLATFORM'), $lang->def('_NAME'), $lang->def('_DESCRIPTION'), $lang->def('_RECIPIENTS'), 'show_level'); $type_h = array('', '', '', 'image', 'image', 'image', 'image', 'image', ''); $tb_event_classes->setColsStyle($type_h); $tb_event_classes->addHead($content_h); $rs = sql_query("SELECT ec.idClass, class, platform, description, idEventMgr, recipients, show_level" . " FROM " . $GLOBALS['prefix_fw'] . "_event_class as ec" . " JOIN " . $GLOBALS['prefix_fw'] . "_event_manager as em" . " WHERE ec.idClass = em.idClass" . " ORDER BY ec.idClass"); while (list($idClass, $class, $platform, $description, $idEventMgr, $recipients, $show_level) = sql_fetch_row($rs)) { $cont = array(); $cont[] = $form->getInputTextfield('', 'platform_' . $idClass, 'platform[' . $idClass . ']', $platform, '', 50, ''); $cont[] = $form->getInputTextfield('', 'class_' . $idClass, 'class[' . $idClass . ']', $class, '', 50, ''); $cont[] = $form->getInputTextfield('', 'description_' . $idClass, 'description[' . $idClass . ']', $description, '', 50, ''); $cont[] = $form->getInputTextfield('', 'recipients_' . $idEventMgr, 'recipients[' . $idEventMgr . ']', $recipients, '', 50, ''); $cont[] = $form->getInputTextfield('', 'show_level_' . $idEventMgr, 'show_level[' . $idEventMgr . ']', $show_level, '', 50, ''); $tb_event_classes->addBody($cont); } $cont = array(); $cont[] = $form->getInputTextfield('', 'platform_0', 'platform[0]', '', '', 50, ''); $cont[] = $form->getInputTextfield('', 'class_0', 'class[0]', '', '', 50, ''); $cont[] = $form->getInputTextfield('', 'description_0', 'description[0]', '', '', 50, ''); $cont[] = $form->getInputTextfield('', 'recipients_0', 'recipients[0]', '', '', 50, ''); $cont[] = $form->getInputTextfield('', 'show_level_0', 'show_level[0]', '', '', 50, ''); $tb_event_classes->addBody($cont); $out->add($tb_event_classes->getTable()); $out->add($form->closeElementSpace()); $out->add($form->openButtonSpace()); $out->add($form->getButton('save', 'save', $lang->def('_SAVE'))); $out->add($form->closeButtonSpace()); $out->add($form->closeForm()); $out->add('</div>'); }
/** * This method execute the dispatch of the event on all the consumer related * to the class of the event * @param DoceboEvent $event the event to be dispatched * @static * @access public **/ function dispatch(&$event) { $arr_consumer = DoceboEventManager::listConsumerFromClassId($event->getClassId()); foreach ($arr_consumer as $consumer_id => $consumer_param) { if (file_exists(_base_ . '/customscripts' . '/' . _folder_adm_ . $consumer_param[1]) && Get::cfg('enable_customscripts', false) == true) { require_once _base_ . '/customscripts' . '/' . _folder_adm_ . $consumer_param[1]; } else { require_once $GLOBALS['where_framework'] . $consumer_param[1]; } $consumer = eval("return new " . $consumer_param[0] . "(" . $consumer_id . ");"); $consumer->actionEvent($event); } }
function extendedParsing($arrayState, $arrayExpand, $arrayCompress) { if (isset($arrayState['editpersonsave'])) { $idst = $_POST['idst']; $userid = $_POST['userid']; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $pass = $_POST['pass']; $userlevel = $_POST['userlevel']; $olduserlevel = $_POST['olduserlevel']; if ($pass === '') { $pass = FALSE; } $email = $_POST['email']; if ($idst !== '') { //-extra field----------------------------------------------- require_once $GLOBALS['where_framework'] . '/lib/lib.field.php'; $fields = new FieldList(); //$re_filled = $fields->isFilledFieldsForUser($idst); if ($userid != '') { $info = $this->aclManager->getUser($idst, false); $this->aclManager->updateUser($idst, $userid, $firstname, $lastname, $pass, $email, FALSE, FALSE); //-extra field----------------------------------------------- $fields->storeFieldsForUser($idst); //----------------------------------------------------------- // remove from old group level $this->aclManager->removeFromGroup($olduserlevel, $idst); // add to group level $this->aclManager->addToGroup($userlevel, $idst); if ($this->aclManager->absoluteId($userid) != $info[ACL_INFO_USERID] || $this->aclManager->encrypt($pass) != $info[ACL_INFO_PASS]) { require_once _base_ . '/lib/lib.eventmanager.php'; $pl_man = PlatformManager::createInstance(); $array_subst = array('[url]' => Get::sett('url', ''), '[userid]' => $userid, '[password]' => $pass); // message to user that is odified $msg_composer = new EventMessageComposer(); $msg_composer->setSubjectLangText('email', '_MODIFIED_USER_SBJ', false); $msg_composer->setBodyLangText('email', '_MODIFIED_USER_TEXT', $array_subst); if ($pass != '') { $msg_composer->setBodyLangText('email', '_PASSWORD_CHANGED', array('[password]' => $pass)); } $msg_composer->setBodyLangText('sms', '_MODIFIED_USER_TEXT_SMS', $array_subst); if ($pass != '') { $msg_composer->setBodyLangText('sms', '_PASSWORD_CHANGED_SMS', array('[password]' => $pass)); } createNewAlert('UserMod', 'directory', 'edit', '1', 'User ' . $userid . ' was modified', array($userid), $msg_composer); } $GLOBALS['page']->add(getResultUi($this->lang->def('_OPERATION_SUCCESSFUL'))); } else { $this->op = 'reedit_person'; //$GLOBALS['page']->add( getErrorUi( implode(',', $re_filled) ), 'content'); } } else { if (isset($_POST['arr_idst_groups'])) { $arr_idst_groups = unserialize(urldecode($_POST['arr_idst_groups'])); $acl =& Docebo::user()->getACL(); $arr_idst_all = $acl->getArrSTGroupsST($arr_idst_groups); } else { $arr_idst_groups = FALSE; $arr_idst_all = FALSE; } //-verify that userid is not already used if ($this->aclManager->getUserST($userid) !== FALSE) { $GLOBALS['page']->add(getErrorUi($this->lang->def('_USERID_DUPLICATE'))); $_POST['userid'] = ''; $this->op = 'reedit_person'; } else { //-verify mandatory extra field-------------------------------- require_once $GLOBALS['where_framework'] . '/lib/lib.field.php'; $fields = new FieldList(); //$re_filled = $fields->isFilledFieldsForUser(0, $arr_idst_all); if ($arr_idst_groups != FALSE && $userid != '') { $idst = false; if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) { $limit_insert = Docebo::user()->preference->getAdminPreference('admin_rules.limit_user_insert'); $max_insert = Docebo::user()->preference->getAdminPreference('admin_rules.max_user_insert'); $direct_insert = Docebo::user()->preference->getAdminPreference('admin_rules.direct_user_insert'); if ($limit_insert == 'off' || $limit_insert == 'on' && $max_insert > 0) { if ($direct_insert == 'on') { Docebo::user()->preference->setPreference('admin_rules.max_user_insert', $max_insert - 1); $idst = $this->aclManager->registerUser($userid, $firstname, $lastname, $pass, $email, '', ''); require_once _base_ . '/lib/lib.preference.php'; $preference = new UserPreferences($idst); $preference->savePreferences($_POST, 'ui.'); require_once _base_ . "/lib/lib.eventmanager.php"; $pl_man =& PlatformManager::createInstance(); $array_subst = array('[url]' => Get::sett('url', ''), '[userid]' => $userid, '[password]' => $pass); // message to user that is inserted $msg_composer = new EventMessageComposer(); $msg_composer->setSubjectLangText('email', '_REGISTERED_USER_SBJ', false); $msg_composer->setBodyLangText('email', '_REGISTERED_USER_TEXT', $array_subst); $msg_composer->setBodyLangText('sms', '_REGISTERED_USER_TEXT_SMS', $array_subst); createNewAlert('UserNew', 'directory', 'edit', '1', 'User ' . $userid . ' created', array($userid), $msg_composer); $GLOBALS['page']->add(getResultUi($this->lang->def('_INSERTED_NEW_USER'))); } else { $acl = Docebo::user()->getAcl(); $idst = $this->aclManager->registerTempUser($userid, $firstname, $lastname, $pass, $email, 0, getLogUserId()); require_once _base_ . "/lib/lib.eventmanager.php"; $pl_man =& PlatformManager::createInstance(); $array_subst = array('[url]' => Get::sett('url', ''), '[userid]' => $userid, '[password]' => $pass); // message to user that is waiting $msg_composer = new EventMessageComposer(); $msg_composer->setSubjectLangText('email', '_WAITING_USER_SBJ', false); $msg_composer->setBodyLangText('email', '_WAITING_USER_TEXT', $array_subst); $msg_composer->setBodyLangText('sms', '_WAITING_USER_TEXT_SMS', $array_subst); // send message to the user subscribed createNewAlert('UserNew', 'directory', 'edit', '1', 'User ' . $userid . ' was modified', array($userid), $msg_composer); // set as recipients all who can approve a waiting user $msg_c_approve = new EventMessageComposer(); $msg_c_approve->setSubjectLangText('email', '_TO_APPROVE_USER_SBJ', false); $msg_c_approve->setBodyLangText('email', '_TO_APPROVE_USER_TEXT', array('[url]' => Get::sett('url'))); $msg_c_approve->setBodyLangText('sms', '_TO_APPROVE_USER_TEXT_SMS', array('[url]' => Get::sett('url'))); $idst_approve = $acl->getRoleST('/framework/admin/directory/approve_waiting_user'); $recipients = $this->aclManager->getAllRoleMembers($idst_approve); createNewAlert('UserNewModerated', 'directory', 'edit', '1', 'User ' . $userid . ' to moderate', $recipients, $msg_c_approve); $GLOBALS['page']->add(getResultUi($this->lang->def('_INSERTED_WAIT_FOR_ADMIN'))); } } } else { $idst = $this->aclManager->registerUser($userid, $firstname, $lastname, $pass, $email, '', ''); require_once _base_ . '/lib/lib.preference.php'; $preference = new UserPreferences($idst); $preference->savePreferences($_POST, 'ui.'); require_once _base_ . "/lib/lib.eventmanager.php"; $pl_man =& PlatformManager::createInstance(); $array_subst = array('[url]' => Get::sett('url', ''), '[userid]' => $userid, '[password]' => $pass); // message to user that is inserted $msg_composer = new EventMessageComposer(); $msg_composer->setSubjectLangText('email', '_REGISTERED_USER_SBJ', false); $msg_composer->setBodyLangText('email', '_REGISTERED_USER_TEXT', $array_subst); $msg_composer->setBodyLangText('sms', '_REGISTERED_USER_TEXT_SMS', $array_subst); createNewAlert('UserNew', 'directory', 'edit', '1', 'User ' . $userid . ' created', array($idst), $msg_composer); } if ($idst !== false) { foreach ($arr_idst_groups as $idst_group) { $this->aclManager->addToGroup($idst_group, $idst); } // add to group level $this->aclManager->addToGroup($userlevel, $idst); //-save extra field------------------------------------------ $fields->storeFieldsForUser($idst, $arr_idst_all); //----------------------------------------------------------- } } else { $this->op = 'reedit_person'; //$GLOBALS['page']->add(getErrorUi(implode('<br/>', $re_filled)), 'content'); } } } } elseif (isset($arrayState['deleteperson'])) { $idst = $_POST['idst']; if ($idst !== '') { require_once _base_ . "/lib/lib.eventmanager.php"; $u_info = $this->aclManager->getUser($idst, false); $userid = $u_info[ACL_INFO_USERID]; $pl_man =& PlatformManager::createInstance(); $acl_man =& Docebo::user()->getAclManager(); $array_subst = array('[url]' => Get::sett('url', ''), '[userid]' => $acl_man->relativeId($userid)); // message to user that is inserted $msg_composer = new EventMessageComposer(); $msg_composer->setSubjectLangText('email', '_DELETED_USER_SBJ', false); $msg_composer->setBodyLangText('email', '_DELETED_USER_TEXT', $array_subst); $msg_composer->setBodyLangText('sms', '_DELETED_USER_TEXT_SMS', $array_subst); /* createNewAlert( 'UserDel', 'directory', 'edit', '1', 'User '.$userid.' deleted', array($idst), $msg_composer );*/ $event =& DoceboEventManager::newEvent('UserDel', 'directory', 'edit', '1', 'User ' . addslashes($userid) . ' deleted'); $event->setProperty('recipientid', implode(',', array($idst))); $event->setProperty('subject', $msg_composer->getSubject('email', getLanguage())); $event->setProperty('body', $msg_composer->getBody('email', getLanguage())); $msg_composer->prepare_serialize(); $event->setProperty('MessageComposer', addslashes(rawurlencode(serialize($msg_composer)))); $event->setProperty('userdeleted', $idst); DoceboEventManager::dispatch($event); $this->aclManager->deleteUser($idst); $GLOBALS['page']->add(getResultUi($this->lang->def('_OPERATION_SUCCESSFUL'))); } } if (!isset($arrayState[$this->id])) { return; } foreach ($arrayState[$this->id] as $key => $action) { if ($key == 'save_newfolder') { $array_lang = Docebo::langManager()->getAllLangCode(); $mand_lang = getLanguage(); if (!isset($action[$mand_lang])) { $this->op = 'newfolder'; } else { $folderName = array(); foreach ($array_lang as $langItem) { $folderName[$langItem] = $arrayState[$this->id]['new_folder'][$langItem]; } $this->tdb->addFolderByIdTranslation($this->selectedFolder, $folderName); $this->refresh = TRUE; } } elseif ($key == 'save_renamefolder') { $array_lang = Docebo::langManager()->getAllLangCode(); if ($this->getSelectedFolderId() == '0') { $mand_lang = 'root'; } else { $mand_lang = getLanguage(); } if (!isset($action[$mand_lang]) || $action[$mand_lang] == '') { $this->op = 'renamefolder'; } else { $folder_id = $this->getSelectedFolderId(); $acl =& Docebo::user()->getACL(); //-extra field check mandatory ----------------------------- require_once $GLOBALS['where_framework'] . '/lib/lib.field.php'; $fields = new FieldList(); $fields->setGroupFieldsTable($GLOBALS['prefix_fw'] . ORGCHAR_FIELDTABLE); $fields->setFieldEntryTable($GLOBALS['prefix_fw'] . ORGCHAR_FIELDENTRYTABLE); $folder_id = $this->getSelectedFolderId(); $folder =& $this->tdb->getFolderById($folder_id); $ancestor = $this->tdb->getAllParentId($folder, $this->tdb); array_push($ancestor, $folder_id); //$filled = $fields->isFilledFieldsForUser($folder_id, $ancestor, FALSE ); //---------------------------------------------------------- //if( $filled === true ) { $folderName = array(); if ($this->getSelectedFolderId() == '0') { // is root $folderName = $arrayState[$this->id]['rename_folder']['root']; $query_root_name = "\r\n\t\t\t\t\t\t\tUPDATE " . $GLOBALS['prefix_fw'] . "_setting \r\n\t\t\t\t\t\t\tSET param_value = '" . $folderName . "'\r\n\t\t\t\t\t\t\tWHERE param_name = 'title_organigram_chart'"; sql_query($query_root_name); } else { foreach ($array_lang as $langItem) { $folderName[$langItem] = $arrayState[$this->id]['rename_folder'][$langItem]; } $this->tdb->updateFolderByIdTranslation($this->selectedFolder, $folderName); } //-extra field store -------------------------------------- $folder_idst = $this->tdb->getGroupST($folder_id); $fl = new FieldList(); $fl->setGroupFieldsTable($GLOBALS['prefix_fw'] . ORGCHAR_FIELDTABLE); $fl->setFieldEntryTable($GLOBALS['prefix_fw'] . ORGCHAR_FIELDENTRYTABLE); $arr_groups_filterd = $acl->getSTGroupsST($folder_idst, FILTER_FOLD); $fl->storeFieldsForUser($folder_id, $ancestor, FALSE); //---------------------------------------------------------- $this->refresh = TRUE; if ($this->getSelectedFolderId() == '0') { Util::jump_to('index.php?modname=directory&op=org_chart'); } /*} else { $this->op = 'renamefolder'; $GLOBALS['page']->add( getErrorUi(implode('<br/>', $filled)), 'content' ); }*/ } } elseif ($key == 'next_formfield1') { $this->op = 'folder_field2'; } elseif ($key == 'save_formfield') { require_once $GLOBALS['where_framework'] . '/lib/lib.field.php'; if (isset($arrayState[$this->id]['field_set'])) { $arr_fields = $arrayState[$this->id]['field_set']; } else { $arr_fields = array(); } if (isset($arrayState[$this->id]['field_mandatory'])) { $arr_fields_mandatory = $arrayState[$this->id]['field_mandatory']; } else { $arr_fields_mandatory = array(); } $fl = new FieldList(); $fl->setGroupFieldsTable($GLOBALS['prefix_fw'] . ORGCHAR_FIELDTABLE); $arr_all_fields = $fl->getAllFields(); $id_folder = $this->getSelectedFolderId(); // remove all fields foreach ($arr_all_fields as $id_field => $field) { $fl->removeFieldFromGroup($id_field, $id_folder); } // add selected fields foreach ($arr_fields as $id_field => $dummy_val) { $fl->addFieldToGroup($id_field, $id_folder, isset($arr_fields_mandatory[$id_field]) ? $arr_fields_mandatory[$id_field] : 'false'); } } elseif ($key == 'next1_assignfield') { $this->op = 'assign2_field'; } elseif ($key == 'next2_assignfield') { $this->op = 'assign3_field'; } elseif ($key == 'save_assignfield') { $arr_fields = $arrayState[$this->id]['field_set']; $arr_fields_mandatory = isset($arrayState[$this->id]['field_mandatory']) ? $arrayState[$this->id]['field_mandatory'] : array(); $arr_fields_useraccess = isset($arrayState[$this->id]['field_useraccess']) ? $arrayState[$this->id]['field_useraccess'] : array(); require_once $GLOBALS['where_framework'] . '/lib/lib.field.php'; $fl = new FieldList(); foreach ($arr_fields as $id_filed => $status) { switch ($status) { case ORG_CHART_FIELD_NO: $fl->removeFieldFromGroup($id_filed, $this->tdb->getGroupST($this->getSelectedFolderId())); $fl->removeFieldFromGroup($id_filed, $this->tdb->getGroupDescendantsST($this->getSelectedFolderId())); break; case ORG_CHART_FIELD_NORMAL: $fl->removeFieldFromGroup($id_filed, $this->tdb->getGroupDescendantsST($this->getSelectedFolderId())); $fl->addFieldToGroup($id_filed, $this->tdb->getGroupST($this->getSelectedFolderId()), isset($arr_fields_mandatory[$id_filed]) ? $arr_fields_mandatory[$id_filed] : 'false', isset($arr_fields_useraccess[$id_filed]) ? $arr_fields_useraccess[$id_filed] : 'readonly'); break; case ORG_CHART_FIELD_DESCEND: $fl->removeFieldFromGroup($id_filed, $this->tdb->getGroupST($this->getSelectedFolderId())); $fl->addFieldToGroup($id_filed, $this->tdb->getGroupDescendantsST($this->getSelectedFolderId()), isset($arr_fields_mandatory[$id_filed]) ? $arr_fields_mandatory[$id_filed] : 'false', isset($arr_fields_useraccess[$id_filed]) ? $arr_fields_useraccess[$id_filed] : 'readonly'); break; } } } elseif ($key == $this->_getOpFolderField()) { if (is_array($action)) { $this->selectedFolder = key($action); } $this->op = 'folder_field'; } elseif ($key == $this->_getOpImportUsers()) { if (is_array($action)) { $this->selectedFolder = key($action); } $this->op = 'import_users'; } elseif ($key == 'next1_importusers') { $this->op = 'import_users2'; } elseif ($key == 'next2_importusers') { $this->op = 'import_users3'; } elseif ($key == $this->_getOpAssignField()) { if (is_array($action)) { $this->selectedFolder = key($action); } $this->op = 'assign_field'; } elseif ($key == $this->_getOpAssignUser()) { if (is_array($action)) { $this->selectedFolder = key($action); } $this->op = 'addtotree'; } elseif ($key == $this->_getOpCreateUser()) { if (is_array($action)) { $this->selectedFolder = key($action); } $this->op = 'create_user'; } elseif ($key == $this->_getOpWaitingUser()) { $this->op = 'waiting_user'; } } return; $arrayExpand = $arrayExpand; $arrayCompress = $arrayCompress; }