/** * Get the children of a given node. * * FOR EXPORT PURPOSES THIS METHOD IS OVERRIDDEN TO EXCLUDE * NODES OF TYPES: ADA_NOTE_TYPE, ADA_PRIVATE_NOTE_TYPE THAT * THAT WE DON'T WANT TO EXPORT * * @access public * * @param $node_id the id of the father * * @return an array of ids containing all the id's of the children of a given node * * @see get_node_info * */ public function &export_get_node_children($node_id, $id_course_instance = "") { $db =& $this->getConnection(); $excludeNodeTypes = array(ADA_NOTE_TYPE, ADA_PRIVATE_NOTE_TYPE); if (AMA_DB::isError($db)) { return $db; } if ($id_course_instance != "") { $sql = "select id_nodo,ordine from nodo where id_nodo_parent='{$node_id}' AND id_istanza='{$id_course_instance}'"; } else { $sql = "select id_nodo,ordine from nodo where id_nodo_parent='{$node_id}'"; } if (is_array($excludeNodeTypes) && !empty($excludeNodeTypes)) { $sql .= " AND `tipo` NOT IN(" . implode(',', $excludeNodeTypes) . ")"; } $sql .= " ORDER BY ordine ASC"; $res_ar =& $db->getCol($sql); if (AMA_DB::isError($res_ar)) { return new AMA_Error(AMA_ERR_GET); } // return an error in case of an empty recordset if (!$res_ar) { $retErr = new AMA_Error(AMA_ERR_NOT_FOUND); return $retErr; } // return nested array return $res_ar; }
/** * get a list of all users data in the utente table * which verifies a given clause * * @access public * * @param $fields_list_ar - a list of fields to return * @param $clause - a clause to filter records * * @return a refrerence to a 2-dim array, * each row will have id_utente in the 0 element * and the fields specified in the list in the others * an AMA_Error object if something goes wrong * **/ public function &find_users_list($fields_list_ar, $clause = "") { // logger("UserDataHandler::find_users_list entered", 3); $db =& parent::getConnection(); if (AMA_DB::isError($db)) { return $db; } // build comma separated string out of $field_list_ar array $n_fields = count($fields_list_ar); if ($n_fields > 1) { $more_fields = ", " . implode(", ", $fields_list_ar); } elseif ($n_fields > 0) { $more_fields = ", " . $fields_list_ar[0]; } else { $more_fields = ""; } // add an 'and' on top of the clause // handle null clause, too if ($clause) { $clause = 'where ' . $clause; } // do the query $sql = "select id_utente{$more_fields} from utente {$clause}"; // logger("performing query: $sql", 4); $users_ar = $db->getAll($sql); if (AMA_DB::isError($users_ar)) { //return $db; return new AMA_Error(AMA_ERR_GET); } // logger("query succeeded", 4); // return nested array in the form return $users_ar; }
public function addRoom($name = "service", $sess_id_course_instance, $sess_id_user, $comment = "Inserimento automatico via ADA", $num_user = 4) { $dh = $GLOBALS['dh']; $error = $GLOBALS['error']; $debug = $GLOBALS['debug']; $root_dir = $GLOBALS['root_dir']; $http_root_dir = $GLOBALS['http_root_dir']; $host = OPENMEETINGS_HOST; $port = OPENMEETINGS_PORT; $dir = OPENMEETINGS_DIR; $room_type = intval(OM_ROOM_TYPE); $ispublic = ROOM_IS_PUBLIC; $videoPodWidth = VIDEO_POD_WIDTH; $videoPodHeight = VIDEO_POD_HEIGHT; $videoPodXPosition = VIDEO_POD_X_POSITION; $videoPodYPosition = VIDEO_POD_y_POSITION; $moderationPanelXPosition = MODERATION_PANEL_X_POSITION; $showWhiteBoard = SHOW_WHITE_BOARD; $whiteBoardPanelXPosition = WHITE_BOARD_PANEL_X_POSITION; $whiteBoardPanelYPosition = WHITE_BOARD_PANEL_Y_POSITION; $whiteBoardPanelHeight = WHITE_BOARD_PANEL_HEIGHT; $whiteBoardPanelWidth = WHITE_BOARD_PANEL_WIDTH; $showFilesPanel = SHOW_FILES_PANEL; $filesPanelXPosition = FILES_PANEL_X_POSITION; $filesPanelYPosition = FILES_PANEL_Y_POSITION; $filesPanelHeight = FILES_PANEL_HEIGHT; $filesPanelWidth = FILES_PANEL_WIDTH; //Create the SoapClient object $this->client_room = new SoapClient("http://" . $host . $port . "/" . $dir . "/services/RoomService?wsdl"); $addRoomWithModerationParams = array('SID' => $this->session_id, 'name' => $name, 'roomtypes_id' => intval($room_type), 'comment' => $comment, 'numberOfPartizipants' => intval($num_user), 'ispublic' => $ispublic, 'appointment' => FALSE, 'isDemoRoom' => FALSE, 'demoTime' => 0, 'isModeratedRoom' => TRUE); $this->resultAddRoom = $this->client_room->addRoomWithModeration($addRoomWithModerationParams); $this->id_room = $this->resultAddRoom->return; $interval = 60 * 60; $videoroom_dataAr['id_room'] = $this->id_room; $videoroom_dataAr['id_istanza_corso'] = $sess_id_course_instance; $videoroom_dataAr['id_tutor'] = $sess_id_user; $videoroom_dataAr['tipo_videochat'] = $room_type; $videoroom_dataAr['descrizione_videochat'] = $name; $videoroom_dataAr['tempo_avvio'] = time(); $videoroom_dataAr['tempo_fine'] = time() + $interval; $videoroom_data = $dh->add_videoroom($videoroom_dataAr); if (AMA_DB::isError($videoroom_data)) { return false; } return $this->id_room; }
/** * generates the form instance and returns the html * * @return the usual array with: html, path and status keys */ public function form($data = null) { require_once MODULES_SERVICECOMPLETE_PATH . '/include/forms/formLinkRules.inc.php'; $dh = $GLOBALS['dh']; // load the courses list to be passed to the form $coursesAr = $dh->find_courses_list(array('nome', 'titolo')); if (!AMA_DB::isError($coursesAr)) { foreach ($coursesAr as $courseEl) { $this->_coursesList[$courseEl[0]] = $courseEl[1] . ' - ' . $courseEl[2]; } } $form = new FormLinkRules($data, $this->_coursesList); /** * path and status are not used for time being (03/dic/2013) */ return array('html' => $form->getHtml(), 'path' => '', 'status' => ''); }
/** * method that checks if the contidion is satisfied * for the passed id_user in the passed id_course_instance * * @param int $id_course_instance * @param int $id_user * @return boolean true if condition is satisfied * @access public */ private function isSatisfied($id_course_instance = null, $id_student = null) { $user = MultiPort::findUser($id_student, $id_course_instance); if ($user instanceof ADAUser && isset($GLOBALS['dh'])) { $level = $user->get_student_level($id_student, $id_course_instance); if (!AMA_DB::isError($level) && is_numeric($level)) { if (intval($this->_param) === 0) { $course_id = $GLOBALS['dh']->get_course_id_for_course_instance($id_course_instance); if (!AMA_DB::isError($course_id) && is_numeric($course_id)) { $max_level = $GLOBALS['dh']->get_course_max_level($course_id); if (!AMA_DB::isError($max_level) && is_numeric($max_level)) { return intval($level) > intval($max_level); } } } else { if (is_numeric($this->_param)) { return intval($level) > intval($this->_param); } } } } return false; }
$button->addChild(new CText(translateFN('OK'))); $button->setAttribute('onclick', 'javascript:self.document.location.href=\'' . MODULES_NEWSLETTER_HTTP . '\''); $containedElement->addChild($spanmsg); $containedElement->addChild($button); $data = $containedElement->getHtml(); /// if it's an ajax request, output html and die if (isset($_POST['requestType']) && trim($_POST['requestType']) === 'ajax') { echo $data; die; } } else { $containedElement = new FormEditNewsLetter('editnewsletter'); $newsletterId = isset($_GET['id']) && intval($_GET['id']) > 0 ? intval($_GET['id']) : 0; if ($newsletterId > 0) { $loadedNewsletter = $dh->get_newsletter($newsletterId); if (!AMA_DB::isError($loadedNewsletter)) { $containedElement->fillWithArrayData($loadedNewsletter); } } $data = $containedElement->render(); } $containerDIV->addChild(new CText($data)); $data = $containerDIV->getHtml(); /** * include proper jquery ui css file depending on wheter there's one * in the template_family css path or the default one */ if (!is_dir(MODULES_NEWSLETTER_PATH . '/layout/' . $userObj->template_family . '/css/jquery-ui')) { $layout_dataAr['CSS_filename'] = array(JQUERY_UI_CSS); } else { $layout_dataAr['CSS_filename'] = array(MODULES_NEWSLETTER_PATH . '/layout/' . $userObj->template_family . '/css/jquery-ui/jquery-ui-1.10.3.custom.min.css');
public function addRoom($name = "service", $sess_id_course_instance, $sess_id_user, $comment = "Inserimento automatico ", $num_user = 4, $course_title = 'service', $selected_provider = ADA_PUBLIC_TESTER) { $dh = $GLOBALS['dh']; $error = $GLOBALS['error']; $debug = $GLOBALS['debug']; $root_dir = $GLOBALS['root_dir']; $http_root_dir = $GLOBALS['http_root_dir']; $ACconnectedUser = $this->getConnectIdUser(); if (is_array($ACconnectedUser)) { return false; } $ACfolderId = $this->getFolderId(); if (is_array($ACfolderId)) { return false; } $ACroomCreatedInfo = $this->createMeeting($name, $sess_id_course_instance, $sess_id_user, $course_title, $selected_provider); if (!$ACroomCreatedInfo[0] && strpos($ACroomCreatedInfo[1], 'duplicate') === false) { return false; } elseif (!$ACroomCreatedInfo[0] && strpos($ACroomCreatedInfo[1], 'duplicate') !== false) { /** * @todo Search a meeting room in order to write the correct one in table DB * $ACroomExistingInfo = $this->searchMeeting($sess_id_course_instance, $selected_provider); var_dump($ACroomExistingInfo);die(); * */ return false; } $ACroomId = $ACroomCreatedInfo[1]; $this->id_room = $ACroomId; $ACroomPath = $ACroomCreatedInfo[2]; /* * make the meeting public */ $ACpermission = $this->setPermission($ACroomId); /** * @todo Delete the room just created in case of error in changing the permission of the room */ if (is_array($ACpermission) && !$ACpermission[0]) { return false; } $meeting_duration = MEETING_ROOM_DURATION * AMA_SECONDS_IN_A_DAY; $videoroom_dataAr['id_room'] = $ACroomId; $videoroom_dataAr['id_istanza_corso'] = $sess_id_course_instance; $videoroom_dataAr['id_tutor'] = $sess_id_user; $videoroom_dataAr['tipo_videochat'] = 'meeting'; $videoroom_dataAr['descrizione_videochat'] = $name; $videoroom_dataAr['tempo_avvio'] = time(); $videoroom_dataAr['tempo_fine'] = time() + $meeting_duration; $videoroom_data = $dh->add_videoroom($videoroom_dataAr); if (AMA_DB::isError($videoroom_data)) { return false; } return $ACroomId; }
$courseId = $courseData['id_corso']; $Flag_course_has_instance = false; $newTesterId = $courseData['id_tester']; if ($newTesterId != $currentTesterId) { // stesso corso su altro tester ? $testerInfoAr = $common_dh->get_tester_info_from_id($newTesterId); if (!AMA_DB::isError($testerInfoAr)) { $tester = $testerInfoAr[10]; $tester_dh = AMA_DataHandler::instance(MultiPort::getDSN($tester)); $currentTesterId = $newTesterId; $course_dataHa = $tester_dh->get_course($courseId); $instancesAr = $tester_dh->course_instance_subscribeable_get_list(array('data_inizio_previsto', 'durata', 'data_fine', 'title'), $courseId); if (is_array($instancesAr) && count($instancesAr) > 0) { $Flag_course_has_instance = true; } if (!AMA_DB::isError($course_dataHa)) { $credits = $course_dataHa['crediti']; // supponiamo che tutti i corsi di un servizio (su tester diversi) abbiano lo stesso numero di crediti // quindi prendiamo solo l'ultimo } else { $credits = 1; // should be ADA_DEFAULT_COURSE_CREDITS } } } if ($Flag_course_has_instance) { $more_info_link = BaseHtmlLib::link("info.php?op=course_info&id={$serviceId}", translateFN('More info')); } else { $more_info_link = BaseHtmlLib::link("info.php", translateFN('No instances available')); } $tbody_data[] = array($service['nome'], $service['descrizione'], $credits, $more_info_link);
/** * name constructor, set menu options and get the * left and right submenus from the DataHandler */ public function __construct($module, $script, $user_type, $menuoptions) { if (!isset($menuoptions['self_instruction']) || strlen($menuoptions['self_instruction']) <= 0) { $self_instruction = false; } else { // set self_instuction to either 0 or 1 $self_instruction = intval($menuoptions['self_instruction']) > 0 ? 1 : 0; } $this->_menuOptions = $menuoptions; // get the menu from the database $dh = $GLOBALS['dh']; $getAllMenuItems = false; // get tree_id, isVertical and db where menu is stored $res = $dh->get_menutree_id($module, $script, $user_type, $self_instruction); if (!AMA_DB::isError($res) && count($res) > 0 && $res !== false) { // set found object properties $this->_tree_id = $res['tree_id']; $this->_isVertical = $res['isVertical']; if (isset($res['linked_from'])) { $this->_linked_from = $res['linked_from']; } // get menu items $resItems = $dh->get_menu_children($this->_tree_id, $res['dbToUse'], $getAllMenuItems); if (!AMA_DB::isError($resItems) && count($resItems) > 0) { $this->_leftItemsArray = isset($resItems['left']) ? $resItems['left'] : null; $this->_rightItemsArray = isset($resItems['right']) ? $resItems['right'] : null; } } }
*/ $retArray['columnDefs'][] = array('sType' => 'date-eu', 'aTargets' => [2]); $retArray['columnDefs'][] = array('sType' => 'date-eu', 'aTargets' => [3]); } else { if ($user_type == AMA_TYPE_AUTHOR) { if (isset($course['id_corso'])) { $id_course = $course['id_corso']; $InstanceAr = $dh->course_instance_get_list(null, $id_course); if (!AMA_DB::isError($InstanceAr)) { $instanceNumber = count($InstanceAr); } $field_list_ar = array('tipo'); $clause = '(tipo =' . ADA_LEAF_TYPE . ' OR tipo =' . ADA_GROUP_TYPE . ' OR tipo =' . ADA_PERSONAL_EXERCISE_TYPE . ')'; $clause .= " AND id_nodo LIKE '%{$id_course}%'"; $NodesAr = $dh->_find_nodes_list($field_list_ar, $clause); if (!AMA_DB::isError($NodesAr)) { $countActivity = 0; if (!empty($NodesAr)) { foreach ($NodesAr as $node => $type) { if ($type[1] == ADA_PERSONAL_EXERCISE_TYPE) { $countActivity++; } } } $nodeNumber = count($NodesAr) - $countActivity; $activitiesNumber = $countActivity; } else { $nodeNumber = 0; $activitiesNumber = 0; } } else {
$allowableTags = '<b><i>'; $PDFdata['title'] = sprintf(translateFN('Cronologia dello studente %s, aggiornata al %s'), $student_name, $ymdhms); $PDFdata['block1'] = $user_historyObj->history_summary_FN(); // replace <br> with new line. // note that \r\n MUST be double quoted, otherwise PhP won't recognize 'em as a <CR><LF> sequence! $PDFdata['block1'] = preg_replace('/<br\\s*?\\/??>/i', "\r\n", $PDFdata['block1']); $PDFdata['block1'] = strip_tags($PDFdata['block1'], $allowableTags); $PDFdata['block1'] = translateFN("Classe") . ": <b>" . $courseInstanceObj->getTitle() . "</b> (" . $courseInstanceObj->getId() . ")\r\n" . $PDFdata['block1']; $PDFdata['block2'] = translateFN("Percentuale nodi visitati/totale: ") . "<b>" . $nodes_percent . "</b>"; $PDFdata['block3'] = translateFN("Tempo totale di visita dei nodi (in ore:minuti): ") . "<b>" . $user_historyObj->history_nodes_time_FN() . "</b>\r\n" . translateFN("Tempo medio di visita dei nodi (in minuti:secondi): ") . "<b>" . $user_historyObj->history_nodes_average_FN() . "</b>"; if ($period != 'all') { $PDFdata['table'][0]['data'] = $user_historyObj->history_nodes_list_filtered_FN($period, false); } else { $PDFdata['table'][0]['data'] = $user_historyObj->get_historyFN(false); } if (!AMA_DB::isError($PDFdata['table'][0]['data']) && is_array($PDFdata['table'][0]['data']) && count($PDFdata['table'][0]['data']) > 0) { // set table title $PDFdata['table'][0]['title'] = $PDFdata['table'][0]['data']['caption']; unset($PDFdata['table'][0]['data']['caption']); // add sequence number to each returned element foreach ($PDFdata['table'][0]['data'] as $num => $row) { $PDFdata['table'][0]['data'][$num]['num'] = $num + 1; } // prepare labels for header row and set columns order // first column is sequence number $PDFdata['table'][0]['cols'] = array('num' => '#'); if (isset($PDFdata['table'][0]['data'][0]) && is_array($PDFdata['table'][0]['data'][0])) { // then all the others as returned in data, we just need the keys so let's take row 0 only foreach ($PDFdata['table'][0]['data'][0] as $key => $val) { if ($key !== 'num') { $PDFdata['table'][0]['cols'][$key] = translateFN($key);
function get_courses_tutorFN($id_user, $isSuper = false) { $dh = $GLOBALS['dh']; $ymdhms = $GLOBALS['ymdhms']; $http_root_dir = $GLOBALS['http_root_dir']; $all_instance = array(); $sub_course_dataHa = array(); $dati_corso = array(); $today_date = $dh->date_to_ts("now"); $all_instance = $dh->course_tutor_instance_get($id_user, $isSuper); // Get the instance courses monitorated by the tutor $num_courses = 0; $id_corso_key = translateFN('Corso'); $titolo_key = translateFN('Titolo corso'); $id_classe_key = translateFN('Classe'); $nome_key = translateFN('Nome classe'); $data_inizio_key = translateFN('Inizio'); $durata_key = translateFN('Durata'); $azioni_key = translateFN('Azioni'); $msg = ""; if (is_array($all_instance)) { foreach ($all_instance as $one_instance) { $num_courses++; $id_instance = $one_instance[0]; $instance_course_ha = $dh->course_instance_get($id_instance); // Get the instance courses data if (AMA_DataHandler::isError($instance_course_ha)) { $msg .= $instance_course_ha->getMessage() . "<br />"; } else { $id_course = $instance_course_ha['id_corso']; if (!empty($id_course)) { $info_course = $dh->get_course($id_course); // Get title course if (AMA_DataHandler::isError($dh)) { $msg .= $dh->getMessage() . "<br />"; } if (!AMA_DB::isError($info_course)) { $titolo = $info_course['titolo']; $id_toc = $info_course['id_nodo_toc']; $durata_corso = sprintf(translateFN('%d giorni'), $instance_course_ha['durata']); $naviga = '<a href="' . $http_root_dir . '/browsing/view.php?id_node=' . $id_course . '_' . $id_toc . '&id_course=' . $id_course . '&id_course_instance=' . $id_instance . '">' . '<img src="img/timon.png" alt="' . translateFN('naviga') . '" title="' . translateFN('naviga') . '" class="tooltip" border="0"></a>'; $valuta = '<a href="' . $http_root_dir . '/tutor/tutor.php?op=student&id_instance=' . $id_instance . '&id_course=' . $id_course . '">' . '<img src="img/magnify.png" alt="' . translateFN('valuta') . '" title="' . translateFN('valuta') . '" class="tooltip" border="0"></a>'; $data_inizio = AMA_DataHandler::ts_to_date($instance_course_ha['data_inizio'], "%d/%m/%Y"); $dati_corso[$num_courses][$id_corso_key] = $instance_course_ha['id_corso']; $dati_corso[$num_courses][$titolo_key] = $titolo; $dati_corso[$num_courses][$id_classe_key] = $id_instance; $dati_corso[$num_courses][$nome_key] = $instance_course_ha['title']; $dati_corso[$num_courses][$data_inizio_key] = $data_inizio; $dati_corso[$num_courses][$durata_key] = $durata_corso; $dati_corso[$num_courses][$azioni_key] = $naviga; $dati_corso[$num_courses][$azioni_key] .= $valuta; } } } } $courses_list = ""; if (count($dati_corso) > 0 && empty($msg)) { $caption = translateFN("Corsi monitorati al") . " {$ymdhms}"; $tObj = BaseHtmlLib::tableElement('id:listCourses', array($id_corso_key, $titolo_key, $id_classe_key, $nome_key, $data_inizio_key, $durata_key, $azioni_key), $dati_corso, null, $caption); $tObj->setAttribute('class', 'default_table doDataTable'); $courses_list = $tObj->getHtml(); } else { $courses_list = $msg; } } else { $tObj = new Table(); $tObj->initTable('0', 'center', '0', '1', '', '', '', '', '', '1'); $caption = translateFN("Non ci sono corsi monitorati da te al {$ymdhms}"); $summary = translateFN("Elenco dei corsi monitorati"); $tObj->setTable($dati_corso, $caption, $summary); $courses_list = $tObj->getTable(); } if (empty($courses_list)) { $courses_list = translateFN('Non ci sono corsi di cui sei tutor.'); } return $courses_list; }
$XMLAllSurveys->appendChild($XMLSurvey); unset($XMLSurvey); } } if (isset($XMLAllSurveys)) { $XMLcourse->appendChild($XMLAllSurveys); } unset($XMLAllSurveys); // end get surveys /** * WARNING!! nodes linking is between: * test_course_survey.id_test and test_nodes.id_nodo !!! */ // get tests $testsArr = $dh_test->test_getNodes(array('id_corso' => $course_id, 'id_nodo_parent' => null, 'id_nodo_radice' => null, 'id_nodo_riferimento' => $exportHelper->exportedNONTestNodeArray, 'id_istanza' => 0)); if (!empty($testsArr) && !AMA_DB::isError($testsArr)) { // $XMLAllTests =& $domtree->createElement('tests'); $exportHelper->testNodeXMLElement = $domtree->createElement('tests'); foreach ($testsArr as &$testElement) { // if this node is in the array of root nodes that MUST // be exported, I can safely remove it from the array itself. $array_key = array_search($testElement['id_nodo'], $surveyRootNodes); if ($array_key !== false) { unset($surveyRootNodes[$array_key]); } // export the node and all of its kids recursively $exportHelper->exportTestNodeChildren($course_id, $testElement['id_nodo'], $domtree, $dh_test); // $XMLAllTests); } } // end get tests
public static function loginForm($form_action = HTTP_ROOT_DIR, $supported_languages = array(), $login_page_language_code, $login_error_message = '') { $div = CDOMElement::create('div', 'id:login_div'); $form = CDOMElement::create('form', "id:login_form, name:login_form, method:post, action:{$form_action}"); $div_username = CDOMElement::create('div', 'id:username'); $span_label_uname = CDOMElement::create('span', 'id:label_uname, class:page_text'); $label_uname = CDOMElement::create('label', 'for:p_username'); $label_uname->addChild(new CText(translateFN('Username'))); $span_label_uname->addChild($label_uname); $span_username = CDOMElement::create('span', 'id:span_username, class:page_input'); $username_input = CDOMElement::create('text', 'id:p_username, name:p_username'); $span_username->addChild($username_input); $div_username->addChild($span_label_uname); $div_username->addChild($span_username); $div_password = CDOMElement::create('div', 'id:password'); $span_label_pwd = CDOMElement::create('span', 'id:label_pwd, class:page_text'); $label_pwd = CDOMElement::create('label', 'for:p_password'); $label_pwd->addChild(new CText(translateFN('Password'))); $span_label_pwd->addChild($label_pwd); $span_password = CDOMElement::create('span', 'id:span_password, class:page_input'); $password_input = CDOMElement::create('password', 'id:p_password, name:p_password'); $span_password->addChild($password_input); $div_password->addChild($span_label_pwd); $div_password->addChild($span_password); $div_remindme = CDOMElement::create('div', 'id:remindme'); $span_label_remindme = CDOMElement::create('span', 'id:label_remindme, class:page_text'); $label_remindme = CDOMElement::create('label', 'for:p_remindme'); $label_remindme->addChild(new CText(translateFN('Resta collegato'))); $span_label_remindme->addChild($label_remindme); $span_remindme = CDOMElement::create('span', 'id:span_remindme, class:page_input'); $remindme_input = CDOMElement::create('checkbox', 'id:p_remindme,name:p_remindme,value:1'); $span_remindme->addChild($remindme_input); $div_remindme->addChild($span_remindme); $div_remindme->addChild($span_label_remindme); $div_select = CDOMElement::create('div', 'id:language_selection'); $select = CDOMElement::create('select', 'id:p_selected_language, name:p_selected_language'); foreach ($supported_languages as $language) { $option = CDOMElement::create('option', "value:{$language['codice_lingua']}"); if ($language['codice_lingua'] == $login_page_language_code) { $option->setAttribute('selected', 'selected'); } $option->addChild(new CText($language['nome_lingua'])); $select->addChild($option); } $div_select->addChild($select); $div_submit = CDOMElement::create('div', 'id:login_button'); if (defined('MODULES_LOGIN') && MODULES_LOGIN) { // load login providers require_once MODULES_LOGIN_PATH . '/include/abstractLogin.class.inc.php'; $loginProviders = abstractLogin::getLoginProviders(); } else { $loginProviders = null; } if (!AMA_DB::isError($loginProviders) && is_array($loginProviders) && count($loginProviders) > 0) { $submit = CDOMElement::create('div', 'id:loginProviders'); $form->addChild(CDOMElement::create('hidden', 'id:selectedLoginProvider, name:selectedLoginProvider')); $form->addChild(CDOMElement::create('hidden', 'id:selectedLoginProviderID, name:selectedLoginProviderID')); // add a DOM element (or html) foreach loginProvider foreach ($loginProviders as $providerID => $loginProvider) { include_once MODULES_LOGIN_PATH . '/include/' . $loginProvider . '.class.inc.php'; if (class_exists($loginProvider)) { $loginObject = new $loginProvider($providerID); $CDOMElement = $loginObject->getCDOMElement(); if (!is_null($CDOMElement)) { $submit->addChild($CDOMElement); } else { $htmlString = $loginObject->getHtml(); if (!is_null($htmlString)) { $submit->addChild(new CText($htmlString)); } } } } } else { // standard submit button if no MODULES_LOGIN $value = translateFN('Accedi'); $submit = CDOMElement::create('submit', "id:p_login, name:p_login"); $submit->setAttribute('value', $value); } $div_submit->addChild($submit); $form->addChild($div_username); $form->addChild($div_password); $form->addChild($div_remindme); $form->addChild($div_select); if ($login_error_message != '') { $div_error_message = CDOMElement::create('div', 'id:login_error_message, class:error'); $div_error_message->addChild(new CText($login_error_message)); $form->addChild($div_error_message); } $form->addChild($div_submit); $div->addChild($form); return $div; }
/** * @author giorgio 19/ago/2014 * * recursively gets all the children of a given menu item * * @param number $tree_id the id of the menu tree to load * @param number $parent_id the id of the parent to get children for * @param AMA_DataHandler $dbToUse the data handler to be used, either Common or Tester * @param boolean $get_all set it to true to get also disabled elements. * * @return array of found children or null if no children found * * @access private */ private function get_menu_children_recursive($tree_id = 0, $parent_id, $dbToUse, $get_all) { $sql = 'SELECT MI.*, MT.extraClass AS menuExtraClass FROM `menu_items` AS MI JOIN `menu_tree` AS MT ON ' . 'MI.item_id=MT.item_id WHERE MT.tree_id=? AND MT.parent_id=?'; if (!$get_all) { $sql .= ' AND MI.enabledON!="' . Menu::NEVER_ENABLED . '"'; } $sql .= ' ORDER BY MI.order ASC'; $res = $dbToUse->getAllPrepared($sql, array($tree_id, $parent_id), AMA_FETCH_ASSOC); if (AMA_DB::isError($res) || count($res) <= 0 || $res === false) { return null; } else { foreach ($res as $count => $element) { $res[$count]['children'] = $this->get_menu_children_recursive($tree_id, $element['item_id'], $dbToUse, $get_all); } return $res; } }
function search_text_in_glosary($text) { $dh = $GLOBALS['dh']; $id_node_text = $this->id; $id_course = strstr($id_node_text, '_', true) . "_"; // preg_match_all('/\b\w+\b/',$text,$textAR); // preg_match_all($pattern, $text, $textAR); // $textAR = explode(" ",$text); $textAR = preg_split('# | |<p>|</p>#', $text); $leaf_word = ADA_LEAF_WORD_TYPE; $group_word = ADA_GROUP_WORD_TYPE; for ($i = 0; $i < count($textAR); $i++) { // foreach ($textAR as $word) { $word = strip_tags(trim($textAR[$i])); // var_dump($word); if (strlen($word) > 2) { $out_fields_ar = array('nome'); $clause = "nome = '{$word}' AND (tipo = {$leaf_word} OR tipo = {$group_word})"; $clause .= " AND id_nodo LIKE '%{$id_course}%'"; $wordsAR = $dh->_find_nodes_list($out_fields_ar, $clause); if (!AMA_DB::isError($wordsAR) && $wordsAR != "" && count($wordsAR) > 0) { $id_node_word = $wordsAR[0][0]; $href = HTTP_ROOT_DIR . '/browsing/view.php?id_node=' . $id_node_word; $text_link = $word; $link_node = BaseHtmlLib::link($href, $text_link); $link_to_word = $link_node->getHtml(); $text = str_replace($word, $link_to_word, $text); $textAR[$i] = $link_to_word; } } } // $text = implode(" ",$textAR); return $text; }
/** * Recursively gets an array with passed node and all of its children * inlcuded values are name and id, used for json encoding when building * course tree for selecting which node to export. * * @param string $rootNode the id of the node to be treated as root * @param AMAImportExportDataHandler $dh the data handler used to retreive datas * @param string $mustRecur * * @return array * * @access public */ public function getAllChildrenArray($rootNode, $dh, $mustRecur = true) { // first get all passed node data $nodeInfo = $dh->get_node_info($rootNode); $retarray = array('id' => $rootNode, 'label' => $nodeInfo['name']); if ($mustRecur) { // get node children only having instance=0 $childNodesArray = $dh->export_get_node_children($rootNode, 0); if (!empty($childNodesArray) && !AMA_DB::isError($childNodesArray)) { $i = 0; $children = array(); foreach ($childNodesArray as &$childNodeId) { $children[$i++] = $this->getAllChildrenArray($childNodeId, $dh, $mustRecur); } $retarray['children'] = $children; } } return $retarray; }
* Performs basic controls before entering this module */ require_once ROOT_DIR . '/include/module_init.inc.php'; require_once ROOT_DIR . '/browsing/include/browsing_functions.inc.php'; // MODULE's OWN IMPORTS require_once MODULES_NEWSLETTER_PATH . '/config/config.inc.php'; require_once MODULES_NEWSLETTER_PATH . '/include/forms/formFilterNewsletter.inc.php'; require_once MODULES_NEWSLETTER_PATH . '/include/AMANewsletterDataHandler.inc.php'; require_once MODULES_NEWSLETTER_PATH . '/include/functions.inc.php'; $self = whoami(); $GLOBALS['dh'] = AMANewsletterDataHandler::instance(MultiPort::getDSN($_SESSION['sess_selected_tester'])); $containerDIV = CDOMElement::create('div', 'id:moduleContent'); if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'GET' && !empty($_GET) && isset($_GET['id']) && intval($_GET['id']) > 0) { $idNewsletter = intval($_GET['id']); $newsletterAr = $dh->get_newsletter($idNewsletter); if (!AMA_DB::isError($newsletterAr) && $newsletterAr !== false) { $historyAr = $dh->get_newsletter_history($idNewsletter); $labels = array(translateFN('filtro'), translateFN('data di invio'), translateFN('n. utenti')); $historyData = array(); foreach ($historyAr as $i => $historyEl) { $historyData[$i] = array($labels[0] => convertFilterArrayToString(json_decode($historyEl['filter'], true), $dh, false), $labels[1] => $historyEl['datesent'], $labels[2] => $historyEl['status'] != MODULES_NEWSLETTER_HISTORY_STATUS_SENDING ? $historyEl['recipientscount'] : translateFN('Invio in corso') . '...'); } $historyTable = new Table(); $historyTable->initTable('0', 'center', '1', '1', '90%', '', '', '', '', '1', '0', '', 'default', 'newsletterHistoryDetails'); $historyTable->setTable($historyData, translateFN('Stroico Newsletter') . ' - ' . $newsletterAr['subject'], translateFN('Stroico Newsletter') . ' - ' . $newsletterAr['subject']); $containerDIV->addChild(new CText($historyTable->getTable())); } else { $containerDIV->addChild(new CText(translateFN('Newsletter non trovata, id= ') . $idNewsletter)); } // if (!AMA_DB::isError($newsletterAr)) } else {
if ($subscriberObj instanceof ADAPractitioner) { /** * @author giorgio 14/apr/2015 * * If the switcher is trying to subscribe a tutor, do it only * if the course instance belongs to a service of type * ADA_SERVICE_TUTORCOMMUNITY */ $canSubscribeUser = $courseInstanceObj instanceof Course_instance && $courseInstanceObj->isFull() && $courseInstanceObj->getServiceLevel() == ADA_SERVICE_TUTORCOMMUNITY; } else { $canSubscribeUser = false; } } if ($canSubscribeUser) { $courseProviderAr = $common_dh->get_tester_info_from_id_course($courseObj->getId()); if (!AMA_DB::isError($courseProviderAr) && is_array($courseProviderAr) && isset($courseProviderAr['puntatore'])) { if (!in_array($courseProviderAr['puntatore'], $subscriberObj->getTesters())) { // subscribe user to course provider $canSubscribeUser = Multiport::setUser($subscriberObj, array($courseProviderAr['puntatore'])); if (!$canSubscribeUser) { $data = new CText(translateFN('Problemi nell\'iscrizione utente al provider del corso.') . ' ' . translateFN('Utente non iscritto')); } } if ($canSubscribeUser) { $subscriptionDate = 0; $s = new Subscription($subscriberObj->getId(), $courseInstanceId, $subscriptionDate, $startStudentLevel); $s->setSubscriptionStatus(ADA_STATUS_SUBSCRIBED); Subscription::addSubscription($s); $data = new CText(translateFN('Utente iscritto')); } else { $data = new CText(translateFN('Problemi') . ' ' . translateFN('Utente non iscritto'));
*/ // redirect sul nodo nel caso in cui venga cliccato un nodo anzichè un gruppo if ($nodeObj->type == ADA_LEAF_TYPE || $nodeObj->type == ADA_LEAF_WORD_TYPE) { header('Location: view.php?id_node=' . $nodeObj->id); exit; } //$node_path = $nodeObj->findPathFN(); // default: link to view.php $node_path = $nodeObj->findPathFN('map'); // THE MAP //$data = "<div><b>MAPPA DEL GRUPPO {$nodeObj->name}</b></div>\n\n"; $data = '<div><b>' . translateFN('MAPPA DEL GRUPPO') . " {$nodeObj->name}.</b></div>\n\n"; $data .= "<div id=\"map_content\" style=\"position:relative;top:0px;left:0px;\">\n"; $nodeList = $nodeObj->graph_indexFN(); $otherPos = array(0, 0, 0, 0); $tipo_mappa = returnMapType(); if (!AMA_DB::isError($nodeList) && is_array($nodeList) && count($nodeList) > 0) { // AND HIS CHILDS foreach ($nodeList as $key) { if ($nodeObj->level <= $userObj->livello) { // print_r($key); $nodePostId = 'input_' . $key['id_child']; // node id for javascript $childNodeObj = read_node_from_DB($key['id_child']); if ($childNodeObj instanceof Node) { // saving new positions if (isset($_POST[$nodePostId])) { $nodeArray = $childNodeObj->object2arrayFN(); $nodeArray['position'] = $_POST[$nodePostId]; // it is a string as requested by NodeEditing::saveNode() $nodeArray['icon'] = $key['icon_child']; // it does not function: NodeEditing::saveNode(), lines 210-214
/** * calls and sets the parent instance method, and if !MULTIPROVIDER * checks if module_login_providers table is in the provider db. * * If found, use the provider DB else use the common * * @param string $dsn */ static function instance($dsn = null) { if (!MULTIPROVIDER && is_null($dsn)) { $dsn = MultiPort::getDSN($GLOBALS['user_provider']); } $theInstance = parent::instance($dsn); if (is_null(self::$dbToUse)) { self::$dbToUse = AMA_Common_DataHandler::instance(); if (!MULTIPROVIDER && !is_null($dsn)) { // must check if passed $dsn has the module login tables // execute this dummy query, if result is not an error table is there $sql = 'SELECT NULL FROM `' . self::$PREFIX . 'providers`'; // must use AMA_DataHandler because we are not able to // query AMALoginDataHandelr in this method! $ok = AMA_DataHandler::instance($dsn)->getOnePrepared($sql); if (!AMA_DB::isError($ok)) { self::$dbToUse = $theInstance; } } } return $theInstance; }
* if user has the terminated status for the course instance, redirect to view */ $id_node = $sess_id_course . '_0'; // if nothing better is found, redirect to course root node if (!ADA_REDIRECT_TO_TEST) { /** * if !ADA_REDIRECT_TO_TEST, redirecting to $test->id_nodo_riferimento * shall not cause a redirection loop */ $id_node = $test->id_nodo_riferimento; } else { /** * else redirect to the parent of $test->id_nodo_riferimento */ $nodeInfo = $GLOBALS['dh']->get_node_info($test->id_nodo_riferimento); if (!AMA_DB::isError($nodeInfo) && isset($nodeInfo['parent_id']) && strlen($nodeInfo['parent_id']) > 0) { $id_node = $nodeInfo['parent_id']; } } redirect(HTTP_ROOT_DIR . '/browsing/view.php?id_node=' . $id_node . '&id_course=' . $sess_id_course . '&id_course_instance=' . $sess_id_course_instance); } $test->run(); $text = $test->render(true); $title = $test->titolo; $nodeObj = new Node($test->id_nodo_riferimento); //present in session $path = $nodeObj->findPathFN(); $courseObj = new Course($sess_id_course); //present in session $course_title = $courseObj->titolo; $courseInstanceObj = new Course_instance($sess_id_course_instance);
function remove_allmessages_chatroom($id_chatroom) { $db =& parent::getConnection(); if (AMA_DB::isError($db)) { return $db; } $sql1 = "delete from messaggi where id_chatroom={$id_chatroom}"; $res = parent::executeCritical($sql1); if (AMA_DB::isError($res)) { return $res; } }
require_once MODULES_LOGIN_PATH . '/config/config.inc.php'; $self = whoami(); $loginProviders = abstractLogin::getLoginProviders(null, true); if (!is_null($loginProviders) && is_array($loginProviders)) { /** * generate HTML for 'New Provider' button and the table */ $configIndexDIV = CDOMElement::create('div', 'id:configindex'); $newButton = CDOMElement::create('button'); $newButton->setAttribute('class', 'newButton top tooltip'); $newButton->setAttribute('title', translateFN('Clicca per creare un nuovo login provider')); $newButton->setAttribute('onclick', 'javascript:editProvider(null);'); $newButton->addChild(new CText(translateFN('Nuovo Provider'))); $configIndexDIV->addChild($newButton); $tableOutData = array(); if (!AMA_DB::isError($loginProviders)) { $labels = array(translateFN('id'), translateFN('ordine'), translateFN('className'), translateFN('Nome'), translateFN('Abilitato'), translateFN('Bottone'), translateFN('azioni')); $hasDefault = false; foreach ($loginProviders as $i => $elementArr) { $links = array(); $linksHtml = ""; $skip = $elementArr['className'] == MODULES_LOGIN_DEFAULT_LOGINPROVIDER && !$hasDefault; for ($j = 0; $j < 6; $j++) { switch ($j) { case 0: if (!$skip) { $type = 'edit'; $title = translateFN('Modifica'); $link = 'editProvider(' . $i . ');'; } break;
* Clear node and layout variable in $_SESSION */ $variableToClearAR = array('node', 'layout', 'course', 'user'); /** * Users (types) allowed to access this module. */ $allowedUsersAr = array(AMA_TYPE_SWITCHER); /** * Get needed objects */ $neededObjAr = array(AMA_TYPE_SWITCHER => array('layout')); /** * Performs basic controls before entering this module */ require_once ROOT_DIR . '/include/module_init.inc.php'; require_once ROOT_DIR . '/browsing/include/browsing_functions.inc.php'; // MODULE's OWN IMPORTS require_once MODULES_NEWSLETTER_PATH . '/config/config.inc.php'; require_once MODULES_NEWSLETTER_PATH . '/include/AMANewsletterDataHandler.inc.php'; $GLOBALS['dh'] = AMANewsletterDataHandler::instance(MultiPort::getDSN($_SESSION['sess_selected_tester'])); $retval = array(); if (isset($_GET['selected']) && intval($_GET['selected']) > 0) { $instancesArr = $dh->course_instance_get_list(array('title'), intval($_GET['selected'])); if (!AMA_DB::isError($instancesArr)) { array_push($retval, array("label" => translateFN('Tutte le istanze'), "value" => 0)); for ($i = 0; $i < count($instancesArr); $i++) { array_push($retval, array("label" => $instancesArr[$i][1], "value" => intval($instancesArr[$i][0]))); } } } echo json_encode($retval);
$goodStatuses = array(ADA_STATUS_SUBSCRIBED, ADA_STATUS_COMPLETED, ADA_STATUS_TERMINATED); $instance = reset($instanceCheck); do { $courseOK = in_array($instance['status'], $goodStatuses); } while (($instance = next($instanceCheck)) !== false && !$courseOK); } } } // courseOK is true either if course is public or the user is subscribed to it if ($courseOK) { // select nome or empty string (whoever is not null) as title to diplay for the news $newscontent = $tester_dh->find_course_nodes_list(array("COALESCE(if(nome='NULL' OR ISNULL(nome ),NULL, nome), '')", "testo"), "tipo IN (" . ADA_LEAF_TYPE . "," . ADA_GROUP_TYPE . ") ORDER BY data_creazione DESC LIMIT " . $count, $course_id); // watch out: $newscontent is NOT associative $output = ''; $maxLength = 600; if (!AMA_DB::isError($newscontent) && count($newscontent) > 0) { foreach ($newscontent as $num => $aNews) { $aNewsDIV = CDOMElement::create('div', 'class:news,id:news-' . ($num + 1)); $aNewsTitle = CDOMElement::create('a', 'class:newstitle,href:' . HTTP_ROOT_DIR . '/browsing/view.php?id_course=' . $course_id . '&id_node=' . $aNews[0]); $aNewsTitle->addChild(new CText($aNews[1])); $aNewsDIV->addChild($aNewsTitle); // @author giorgio 01/ott/2013 // remove unwanted div ids: tabs // NOTE: slider MUST be removed BEFORE tabs because tabs can contain slider and not viceversa $removeIds = array('slider', 'tabs'); $html = new DOMDocument('1.0', ADA_CHARSET); /** * HTML uses the ISO-8859-1 encoding (ISO Latin Alphabet No. 1) as default per it's specs. * So add a meta the should do the encoding hint, and output some PHP warings as well that * are being suppressed with the @ */
$result = $GLOBALS['dh']->deleteOptionByKey(intval($_POST['option_id']), trim($key)); $deletedElement = 'Chiave'; // translateFN delayed when building msg $vowel = 'a'; } else { $result = $GLOBALS['dh']->deleteOptionSet(intval($_POST['option_id'])); $deletedElement = 'Fonte'; // translateFN delayed when building msg $vowel = 'a'; } } else { if (isset($_POST['provider_id'])) { $result = $GLOBALS['dh']->deleteLoginProvider(intval($_POST['provider_id'])); $deletedElement = 'Login Provider'; // translateFN delayed when building msg $vowel = 'o'; } } if (!AMA_DB::isError($result)) { $retArray = array("status" => "OK", "msg" => translateFN($deletedElement . " cancellat" . $vowel)); } else { $retArray = array("status" => "ERROR", "msg" => translateFN("Errore di cancellazione")); } } } else { $retArray = array("status" => "ERROR", "msg" => translateFN("Errore nella trasmissione dei dati")); } if (empty($retArray)) { $retArray = array("status" => "ERROR", "msg" => translateFN("Errore sconosciuto")); } echo json_encode($retArray);
$retArray['status'] = "ERROR"; $retArray['msg'] = $res->getMessage(); } else { // redirect to config page $retArray['status'] = "OK"; $retArray['msg'] = translateFN('Login Provider salvato'); } } else { if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'GET' && isset($_GET['provider_id']) && intval(trim($_GET['provider_id'])) > 0) { /** * it's a GET with an provider_id, load it and display */ $provider_id = intval(trim($_GET['provider_id'])); // try to load it $res = $GLOBALS['dh']->getLoginProvider($provider_id); if (AMA_DB::isError($res)) { // if it's an error display the error message without the form $retArray['status'] = "ERROR"; $retArray['msg'] = $res->getMessage(); } else { // display the form with loaded data $optionsManager = new loginProviderManagement($res); $data = $optionsManager->run(MODULES_LOGIN_EDIT_LOGINPROVIDER); $retArray['status'] = "OK"; $retArray['html'] = $data['htmlObj']->getHtml(); $retArray['dialogTitle'] = translateFN('Modifica Login Provider'); } } else { /** * it's a get without a provider_id, display the empty form */
/** * generate HTML for login provider configuration page */ public function generateConfigPage() { $configIndexDIV = CDOMElement::create('div', 'id:configindex'); $newButton = CDOMElement::create('button'); $newButton->setAttribute('class', 'newButton top tooltip'); $newButton->setAttribute('title', translateFN('Clicca per creare un nuova fonte')); $newButton->setAttribute('onclick', 'javascript:editOptionSet(null);'); $newButton->addChild(new CText(translateFN('Nuova Fonte'))); $configIndexDIV->addChild($newButton); $tableOutData = array(); $optionSetList = $this->getAllOptions(); if (!AMA_DB::isError($optionSetList)) { $labels = array(translateFN('nome'), translateFN('host'), translateFN('stato'), translateFN('azioni')); foreach ($optionSetList as $i => $elementArr) { $isEnabled = intval($elementArr['enabled']) === 1; unset($elementArr['enabled']); unset($elementArr['order']); $keys = array_keys($elementArr); $values = array_values($elementArr); $links = array(); $linksHtml = ""; for ($j = 0; $j < 5; $j++) { switch ($j) { case 0: $type = 'edit'; $title = translateFN('Modifica Fonte'); $link = 'editOptionSet(' . $i . ');'; break; case 1: $type = 'delete'; $title = translateFN('Cancella Fonte'); $link = 'deleteOptionSet($j(this), ' . $i . ' , \'' . urlencode(translateFN("Questo cancellerà l'elemento selezionato")) . '\');'; break; case 2: $type = $isEnabled ? 'disable' : 'enable'; $title = $isEnabled ? translateFN('Disabilita') : translateFN('Abilita'); $link = 'setEnabledOptionSet($j(this), ' . $i . ', ' . ($isEnabled ? 'false' : 'true') . ');'; break; case 3: $type = 'up'; $title = translateFN('Sposta su'); $link = 'moveOptionSet($j(this),' . $i . ',-1);'; break; case 4: $type = 'down'; $title = translateFN('Sposta giu'); $link = 'moveOptionSet($j(this),' . $i . ',1);'; break; } if (isset($type)) { $links[$j] = CDOMElement::create('li', 'class:liactions'); $linkshref = CDOMElement::create('button'); $linkshref->setAttribute('onclick', 'javascript:' . $link); $linkshref->setAttribute('class', $type . 'Button tooltip'); $linkshref->setAttribute('title', $title); $links[$j]->addChild($linkshref); // unset for next iteration unset($type); } } if (!empty($links)) { $linksul = CDOMElement::create('ul', 'class:ulactions'); foreach ($links as $link) { $linksul->addChild($link); } $linksHtml = $linksul->getHtml(); } else { $linksHtml = ''; } $tableOutData[$i] = array($labels[0] => $elementArr['name'], $labels[1] => $elementArr['host'], $labels[2] => $isEnabled ? translateFN('Abilitata') : translateFN('Disabilitata'), $labels[3] => $linksHtml); } $OutTable = BaseHtmlLib::tableElement('id:complete' . strtoupper(get_class($this)) . 'List', $labels, $tableOutData, '', translateFN('Elenco delle fonti ' . strtoupper($this->loadProviderName()))); $configIndexDIV->addChild($OutTable); // if there are more than 10 rows, repeat the add new button below the table if (count($optionSetList) > 10) { $bottomButton = clone $newButton; $bottomButton->setAttribute('class', 'newButton bottom tooltip'); $configIndexDIV->addChild($bottomButton); } } // if (!AMA_DB::isError($optionSetList)) return $configIndexDIV; }
/** * generate HTML for login provider configuration page */ public function generateConfigPage() { $optionSetList = $this->loadOptions(); if (isset($optionSetList['providers_options_id']) && intval($optionSetList['providers_options_id']) > 0) { $optionID = intval($optionSetList['providers_options_id']); } else { $optionID = null; } // If no option id return abstract config page (aka 'no options to configure' message) if (is_null($optionID)) { return parent::generateConfigPage(); } $configIndexDIV = CDOMElement::create('div', 'id:configindex'); $newButton = CDOMElement::create('button'); $newButton->setAttribute('class', 'newButton tooltip top'); $newButton->setAttribute('title', translateFN('Clicca per creare un nuova chiave')); $newButton->setAttribute('onclick', 'javascript:addOptionRow();'); $newButton->addChild(new CText(translateFN('Nuova Chiave'))); $configIndexDIV->addChild($newButton); $tableOutData = array(); if (!AMA_DB::isError($optionSetList)) { unset($optionSetList['optionscount']); unset($optionSetList['providers_options_id']); /** * Add an empty table with one row that will be hidden * and will be used as a template when adding new rows */ $optionSetList = array('' => '') + $optionSetList; $labels = array(translateFN('chiave'), translateFN('valore'), translateFN('azioni')); foreach ($optionSetList as $i => $elementArr) { $links = array(); $linksHtml = ""; for ($j = 0; $j < 1; $j++) { switch ($j) { case 0: $type = 'delete'; $title = translateFN('Cancella'); $link = 'deleteOptionSet($j(this), ' . $optionID . ', \'' . urlencode(translateFN("Questo cancellerà l'elemento selezionato")) . '\');'; break; } if (isset($type)) { $links[$j] = CDOMElement::create('li', 'class:liactions'); $linkshref = CDOMElement::create('button'); $linkshref->setAttribute('onclick', 'javascript:' . $link); $linkshref->setAttribute('class', $type . 'Button tooltip'); $linkshref->setAttribute('title', $title); if ($j == 0) { $linkshref->setAttribute('data-delkey', $i); } $links[$j]->addChild($linkshref); // unset for next iteration unset($type); } } if (!empty($links)) { $linksul = CDOMElement::create('ul', 'class:ulactions'); foreach ($links as $link) { $linksul->addChild($link); } $linksHtml = $linksul->getHtml(); } else { $linksHtml = ''; } $tableOutData[$i] = array($labels[0] => $i, $labels[1] => str_replace(array("\r\n", "\r", "\n"), "<br />", $elementArr), $labels[2] => $linksHtml); } $emptyrow = array(array_shift($tableOutData)); $EmptyTable = BaseHtmlLib::tableElement('id:empty' . strtoupper(get_class($this)), $labels, $emptyrow); $EmptyTable->setAttribute('style', 'display:none'); $OutTable = BaseHtmlLib::tableElement('id:complete' . strtoupper(get_class($this)) . 'List', $labels, $tableOutData, '', translateFN('Opzioni ' . strtoupper($this->loadProviderName()))); $OutTable->setAttribute('data-optionid', $optionID); $configIndexDIV->addChild($EmptyTable); $configIndexDIV->addChild($OutTable); // if there are more than 10 rows, repeat the add new button below the table if (count($optionSetList) > 10) { $bottomButton = clone $newButton; $bottomButton->setAttribute('class', 'newButton bottom tooltip'); $configIndexDIV->addChild($bottomButton); } } return $configIndexDIV; }