array_push($allowedUsersAr, AMA_TYPE_SWITCHER); } /** * Performs basic controls before entering this module */ $neededObjAr = array(AMA_TYPE_SWITCHER => array('layout')); require_once ROOT_DIR . '/include/module_init.inc.php'; $self = whoami(); // = admin! include_once 'include/admin_functions.inc.php'; /* * YOUR CODE HERE */ require_once ROOT_DIR . '/include/Forms/CourseModelForm.inc.php'; $options = ''; $languages = Translator::getSupportedLanguages(); // @author giorgio 08/mag/2013 // extract available types from docs subdirectories $availableTypes = dirTree(ROOT_DIR . '/docs'); // @author giorgio 08/mag/2013 // get requested type from querystring $reqType = isset($_REQUEST['type']) ? trim($_REQUEST['type']) : ''; // set 'news' as default type if passed is invalid or not set if (!in_array($reqType, $availableTypes)) { $reqType = 'news'; } /** * giorgio 12/ago/2013 * sets files path if it's switcher or admin */ if (!MULTIPROVIDER && $userObj->getType() == AMA_TYPE_SWITCHER) {
} else { $form = new CText("Si è verificato un errore durante l'aggiornamento dei dati del corso"); } } else { $form = new CText('Form non valido'); } } else { if (!$courseObj instanceof Course || !$courseObj->isFull()) { $form = new CText(translateFN('Corso non trovato')); } else { $providerAuthors = $dh->find_authors_list(array('username'), ''); $authors = array(); foreach ($providerAuthors as $author) { $authors[$author[0]] = $author[1]; } $availableLanguages = Translator::getSupportedLanguages(); $languages = array(); foreach ($availableLanguages as $language) { $languages[$language['id_lingua']] = $language['nome_lingua']; } $form = new CourseModelForm($authors, $languages); if ($courseObj instanceof Course && $courseObj->isFull()) { $formData = array('id_corso' => $courseObj->getId(), 'id_utente_autore' => $courseObj->getAuthorId(), 'id_lingua' => $courseObj->getLanguageId(), 'id_layout' => $courseObj->getLayoutId(), 'nome' => $courseObj->getCode(), 'titolo' => $courseObj->getTitle(), 'descrizione' => $courseObj->getDescription(), 'id_nodo_iniziale' => $courseObj->getRootNodeId(), 'id_nodo_toc' => $courseObj->getTableOfContentsNodeId(), 'media_path' => $courseObj->getMediaPath(), 'static_mode' => $courseObj->getStaticMode(), 'data_creazione' => $courseObj->getCreationDate(), 'data_pubblicazione' => $courseObj->getPublicationDate(), 'crediti' => $courseObj->getCredits(), 'duration_hours' => $courseObj->getDurationHours(), 'service_level' => $courseObj->getServiceLevel()); $form->fillWithArrayData($formData); } else { $form = new CText(translateFN('Corso non trovato')); } } } $label = translateFN('Modifica dei dati del corso'); $help = translateFN('Da qui il provider admin può modificare un corso esistente');
/** * function getAuthorMediaManager, used to manage the properties of each author's media already uploaded. * It is possible for the user to set some properties and save them on DB. * * @param int $id_course * @param string $fckeditorInstance * @return string */ public static function getAuthorMediaManager() { $form = CDOMElement::create('form', 'id:properties_media, class:editor_form'); /* $form = CDOMElement::create('form',"id:uploadfile, name:uploadfileform, enctype:multipart/form-data, action:$php_file_uploader, method:post"); $form->setAttribute('onclick','enterUploadFileState();'); * */ $textarea_div = CDOMElement::create('div', 'id:jstextarea_media_div'); // Title $title_label = CDOMElement::create('DIV'); $title_label->setAttribute('class', 'label_extended'); $title_label->addChild(new CText(translateFN('title'))); $span_title_area = CDOMElement::create('div', 'id:title_media,class:editor_input'); $title_area = CDOMElement::create('text', 'id:jsdata_titlesarea, name:titolo'); $title_area->setAttribute('value', translateFN('Scrivi il titolo')); $span_title_area->addChild($title_area); // preview // $title_label = CDOMElement::create('DIV'); // $title_label->setAttribute('class', 'label_extended'); // $title_label->addChild(new CText(translateFN('title'))); $span_preview_area = CDOMElement::create('div', 'id:preview_media,class:media_preview'); // Description $description_label = CDOMElement::create('DIV'); $description_label->setAttribute('class', 'label_extended'); $description_label->addChild(new CText(translateFN('description'))); $span_description_area = CDOMElement::create('div', 'id:description_media,class:editor_input'); $description_area = CDOMElement::create('textarea', 'id:jsdata_descriptionarea, name:descrizione'); $description_area->addChild(new CText(translateFN('Scrivi la descrizione'))); // $description_area->setAttribute('value', translateFN('Scrivi la descrizione')); $span_description_area->addChild($description_area); // keywords $keywords_label = CDOMElement::create('DIV'); $keywords_label->setAttribute('class', 'label_extended'); $keywords_label->addChild(new CText(translateFN('keywords'))); $span_keywords_area = CDOMElement::create('div', 'id:keywords,class:editor_input'); $keywords_area = CDOMElement::create('text', 'id:jsdata_keywordsarea, name:keywords'); $keywords_area->setAttribute('value', translateFN('Scrivi le keywords')); $span_keywords_area->addChild($keywords_area); // pubblicato // $keywords_label = CDOMElement::create('DIV'); // $keywords_label->setAttribute('class', 'label_extended'); // $keywords_label->addChild(new CText(translateFN('keywords'))); $span_published_area = CDOMElement::create('div', 'id:published,class:editor_input'); $span_published_area->addChild(new CText(translateFN('published'))); $published_check = CDOMElement::create('checkbox', 'id:jsdata_published, name:published'); $published_check->setAttribute('checked', 'true'); $span_published_area->addChild($published_check); // language Translator::loadSupportedLanguagesInSession(); $supported_languages = Translator::getSupportedLanguages(); $select = CDOMElement::create('select', 'id:p_selected_language, name:lingua'); foreach ($supported_languages as $language) { $option = CDOMElement::create('option', "value:{$language['id_lingua']}"); if (isset($login_page_language_code) && $language['codice_lingua'] == $login_page_language_code) { $option->setAttribute('selected', 'selected'); } $option->addChild(new CText($language['nome_lingua'])); $select->addChild($option); } // extended media type $select_extended_media_type = CDOMElement::create('select', 'id:p_selected_media_extended_type, name:tipo'); $option_media_type = CDOMElement::create('option', "value:'0'"); $option_media_type->addChild(new CText(translateFN('inserisci tipo media'))); $select_extended_media_type->addChild($option_media_type); $hidden_input_id_risorsa_ext = CDOMElement::create('hidden', 'name:id_risorsa_ext', 'value:0'); $hidden_copy = CDOMElement::create('hidden', 'name:copyright', 'value:1'); $textarea_div->addChild($title_label); $textarea_div->addChild($span_title_area); $textarea_div->addChild($span_preview_area); $textarea_div->addChild($keywords_label); $textarea_div->addChild($span_keywords_area); $textarea_div->addChild($description_label); $textarea_div->addChild($span_description_area); $textarea_div->addChild($span_published_area); $textarea_div->addChild($select); $textarea_div->addChild($select_extended_media_type); $textarea_div->addChild($hidden_input_id_risorsa_ext); $textarea_div->addChild($hidden_copy); /* $span_select = CDOMElement::create('div','id:span_properties_media, class:editor_input'); $key_label = $keywords = CDOMElement::create('select','id:jsid_properties_files, size:10'); foreach ( $author_media as $media ) { $ada_filetype = Utilities::getFileHintFromADAFileType($media['tipo']); $value = "{$media['tipo']}|{$media['nome_file']}"; $option = CDOMElement::create('option'); $option->setAttribute('value', $value); $option->addChild(new CText("$ada_filetype {$media['nome_file']}")); $select->addChild($option); } $span_select->addChild($select); */ $author_id = $_SESSION['sess_id_user']; $span_button_media_properties = CDOMElement::create('div', 'id:span_properties_media_button, class:editor_input'); $input_button = CDOMElement::create('input_button'); $input_button->setAttribute('onclick', "saveMultimediaProperties(getFileDataFromSelect('jsid_select_files'),{$author_id});"); $input_button->setAttribute('value', translateFN("Salva proprietà media")); $span_button_media_properties->addChild($input_button); $input_button_media_properties = CDOMElement::create('input_button'); $input_button_media_properties->setAttribute('onclick', "toggleVisibility('jsid_div_media_properties');"); $input_button_media_properties->setAttribute('value', translateFN("Chiudi")); $span_button_media_properties->addChild($input_button_media_properties); $form->addChild($textarea_div); // $form->addChild($span_button); $form->addChild($span_button_media_properties); return $form; }
/** * Builds ADA user array from a user_profile coming from login provider * * @param stdClass $user_profile * * @return array an array filled with user data, ready to be saved * * @access public */ public function buildADAUserFromProviderObj($user_profile) { /** * Prepare email field */ if (isset($user_profile->emailVerified) && strlen($user_profile->emailVerified) > 0) { $email = $user_profile->emailVerified; } else { if (isset($user_profile->email) && strlen($user_profile->email) > 0) { $email = $user_profile->email; } else { $email = null; } } /** * prepare birthdate */ if ($user_profile->birthDay > 0 && $user_profile->birthMonth > 0 && $user_profile->birthYear > 0) { $birthDate = sprintf("%02d", $user_profile->birthDay) . '/' . sprintf("%02d", $user_profile->birthMonth) . '/' . $user_profile->birthYear; } else { $birthDate = null; } /** * prepare gender */ if (strtolower($user_profile->gender) == 'male') { $gender = 'M'; } else { if (strtolower($user_profile->gender) == 'female') { $gender = 'F'; } else { $gender = null; } } /** * prepare avatar */ if (isset($user_profile->photoURL) && strlen($user_profile->photoURL) > 0) { // get the basename and remove any URL arguments $avatar = strtok(basename($user_profile->photoURL), '?'); if (stristr($avatar, '.') === false) { $avatar .= '.png'; } } else { $avatar = null; } /** * prepare language */ $language = null; if (isset($user_profile->language) && strlen($user_profile->language) > 0) { if (strlen($user_profile->language) > 2) { $lang = substr($user_profile->language, 0, 2); } else { $lang = $user_profile->language; } foreach (Translator::getSupportedLanguages() as $supportedLang) { if (strtolower($supportedLang['codice_lingua']) === strtolower($lang)) { $language = $supportedLang['id_lingua']; break; } } } /** * build user array */ $adaUser = array('nome' => $user_profile->firstName, 'cognome' => $user_profile->lastName, 'email' => $email, 'username' => $email, 'indirizzo' => isset($user_profile->address) && strlen($user_profile->address) > 0 ? $user_profile->address : null, 'citta' => isset($user_profile->city) && strlen($user_profile->city) > 0 ? $user_profile->city : null, 'provincia' => isset($user_profile->region) && strlen($user_profile->region) > 0 ? $user_profile->region : null, 'nazione' => null, 'birthdate' => $birthDate, 'sesso' => $gender, 'telefono' => isset($user_profile->phone) && strlen($user_profile->phone) > 0 ? $user_profile->phone : null, 'lingua' => $language, 'cap' => isset($user_profile->zip) && strlen($user_profile->zip) > 0 ? $user_profile->zip : '', 'avatar' => $avatar, 'birthcity' => isset($user_profile->region) && strlen($user_profile->region) > 0 ? $user_profile->region : '', 'matricola' => '', 'stato' => ''); return $adaUser; }