/** * 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>'); }