function add_row($row) { $array_substitution = array(); $array_param = explode(',', $this->param_string); if (array_search('[date_subscription]', $array_param) || array_search('[matriculant]', $array_param)) { $query = "SELECT idUser, date_inscr" . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser" . " WHERE idCourse = '" . $row['[id_course]'] . "'" . " AND status = '2'" . ($this->last_execution !== NULL ? " AND date_complete >= '" . $this->last_execution . "'" : ''); $result = sql_query($query); if (mysql_num_rows($result)) { $put = ''; while (list($id_user, $date_inscr) = sql_fetch_row($result)) { foreach ($array_param as $param) { switch ($param) { case '[blank_space]': $array_substitution[] = ''; break; case '[course_code]': $array_substitution[] = html_entity_decode($row['[course_code]'], ENT_QUOTES, "UTF-8"); break; case '[matriculant]': require_once $GLOBALS['where_framework'] . '/lib/lib.field.php'; $field_man = new FieldList(); //TODO: Modificare con il nome del campo della matricola che hanno in piattaforma $id_common_field = $field_man->getFieldIdCommonFromTranslation('Matricola'); $array_field = $field_man->getFieldsAndValueFromUser($id_user); $array_substitution[] = sprintf("%07d", $array_field[$id_common_field][1]); break; case '[date_subscription]': if ($date_inscr !== '0000-00-00' && $date_inscr !== '') { $array_substitution[] = $date_inscr; } else { $array_substitution[] = $row['[date_creation]']; } break; case '[course_creation]': if ($row['[create_date]'] !== '0000-00-00') { $array_substitution[] = $row['[create_date]']; } else { $array_substitution[] = $row['[course_begin]']; } break; default: $array_substitution[] = $param; break; } } $put .= vsprintf($this->asprintf_string, $array_substitution) . "\r\n"; } if (@fwrite($this->filehandle, $put)) { return true; } else { return false; } } return true; } else { if ($row['[create_date]'] < $this->last_execution) { return true; } foreach ($array_param as $param) { switch ($param) { case '[blank_space]': $array_substitution[] = ''; break; case '[course_code]': $array_substitution[] = html_entity_decode($row['[course_code]'], ENT_QUOTES, "UTF-8"); break; case '[course_name]': $array_substitution[] = html_entity_decode(trim($row['[course_name]']), ENT_QUOTES, "UTF-8"); break; case '[course_descr]': $array_substitution[] = html_entity_decode(str_replace(array("\n", "\r"), '', strip_tags(trim($row['[course_descr]']))), ENT_QUOTES, "UTF-8"); break; case '[medium_time]': $array_substitution[] = sprintf("%04d", $row['[medium_time]']) . '00'; break; case '[course_begin]': $array_substitution[] = $row['[course_begin]']; break; case '[course_end]': if ($row['[course_end]'] !== '0000-00-00') { $array_substitution[] = $row['[course_end]']; } else { $array_substitution[] = '2999-12-31'; } break; case '[course_creation]': if ($row['[create_date]'] !== '0000-00-00') { $array_substitution[] = $row['[create_date]']; } else { $array_substitution[] = $row['[course_begin]']; } break; default: $array_substitution[] = $param; break; } } $put = vsprintf($this->asprintf_string, $array_substitution) . "\r\n"; if (@fwrite($this->filehandle, $put)) { return true; } else { return false; } } }
function _special_field($options, $platform, $opt_link) { $lang =& DoceboLanguage::createInstance('register', $platform); // Check for error $out = ''; $error = $this->_checkField($_POST, $options, $platform, false); if ($error['error']) { $this->error = true; $out .= '<div class="reg_err_data">' . $error['msg'] . '</div>'; return $out; } // if the user had enter a code we must check if there are folder related to it and // add the folder's field $registration_code_type = Get::sett('registration_code_type', '0'); $code_is_mandatory = Get::sett('mandatory_code', 'off'); $reg_code = Get::req('reg_code', DOTY_MIXED, ''); if ($registration_code_type === 'custom') { $reg_code = 'change_by_custom_operation'; } $array_folder = false; $folder_group = false; $uma = new UsermanagementAdm(); if ($reg_code != '') { switch ($registration_code_type) { case "0": //nothin to do break; case "tree_course": //a mixed code, let's cut the tree part and go on with the tree_man $reg_code = substr(str_replace('-', '', $reg_code), 0, 10); //procced with tree_man //procced with tree_man case "tree_man": // resolving the tree_man $uma = new UsermanagementAdm(); $array_folder = $uma->getFoldersFromCode($reg_code); break; case "code_module": require_once _adm_ . '/lib/lib.code.php'; $code_manager = new CodeManager(); $valid_code = $code_manager->controlCodeValidity($reg_code); if ($valid_code == 1) { $array_folder = $code_manager->getOrgAssociateWithCode($reg_code); } break; case "tree_drop": // from the dropdown we will recive the id of the folder // then we get the oc and ocd $array_folder = $uma->getFolderGroups($reg_code); break; case "custom": //Custom code require_once _adm_ . '/lib/lib.field.php'; $field_man = new FieldList(); $id_common_filed_1 = $field_man->getFieldIdCommonFromTranslation('Filiale'); $id_common_filed_2 = $field_man->getFieldIdCommonFromTranslation('Codice Concessionario'); $query = "SELECT `translation`" . " FROM core_field_son" . " WHERE id_common_son = " . (int) $_POST['field_dropdown'][$id_common_filed_1] . " AND lang_code = '" . getLanguage() . "'"; list($filed_1_translation) = sql_fetch_row(sql_query($query)); $code_part = substr($filed_1_translation, 1, 1); $reg_code = strtoupper($code_part . '_' . $_POST['field_textfield'][$id_common_filed_2]); // resolving the tree_man $array_folder = $uma->getFoldersFromCode($reg_code); break; } } if ($array_folder !== false) { if ($folder_group === false) { $folder_group = array(); } foreach ($array_folder as $id_org_folder) { $folder_group[] = Docebo::aclm()->getGroupST('/oc_' . $id_org_folder); } } // find all the related extra field $extra_field = new FieldList(); $play_field = $extra_field->playFieldsForUser(0, isset($_POST['group_sel']) ? $_POST['group_sel'] : (isset($_POST['group_sel_implode']) ? explode(',', $_POST['group_sel_implode']) : $array_folder), false, true); if ($play_field === false) { return $this->_opt_in($options, $platform, $opt_link); } $mand_sym = '<span class="mandatory">*</span>'; $out .= '<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>'; $out .= Form::getHidden('next_step', 'next_step', 'opt_in') . Form::getHidden('register_userid', 'register[userid]', $_POST['register']['userid']) . Form::getHidden('register_email', 'register[email]', $_POST['register']['email']) . Form::getHidden('register_firstname', 'register[firstname]', $_POST['register']['firstname']) . Form::getHidden('register_lastname', 'register[lastname]', $_POST['register']['lastname']) . Form::getHidden('register_pwd', 'register[pwd]', $_POST['register']['pwd']) . Form::getHidden('register_pwd_retype', 'register[pwd_retype]', $_POST['register']['pwd_retype']) . Form::getHidden('register_privacy', 'register[privacy]', 'ok'); if (!empty($_POST['group_sel'])) { //&& !empty($_POST['group_sel_implode'])) { $out .= Form::getHidden('group_sel_implode', 'group_sel_implode', isset($_POST['group_sel']) ? implode(',', $_POST['group_sel']) : (isset($_POST['group_sel_implode']) ? $_POST['group_sel_implode'] : '')); } $out .= ($reg_code != '' ? Form::getHidden('reg_code', 'reg_code', $reg_code) : '') . $play_field . Form::getBreakRow() . Form::closeElementSpace() . Form::openButtonSpace('reg_form_button') . Form::getButton('reg_button', 'reg_button', $lang->def('_REGISTER')) . Form::closeButtonSpace(); return $out; }