/** * Compiles information to add or edit a module * @param string The current GET/POST option * @param integer The unique id of the record to edit */ function editMambot($option, $uid, $client) { global $database, $my, $mainframe; global $mosConfig_absolute_path; $lists = array(); $row = new mosMambot($database); // load the row from the db table $row->load($uid); // fail if checked out not by 'me' if ($row->checked_out && $row->checked_out != $my->id) { echo "<script>alert(" . sprintf(T_('The module %s is currently being edited by another administrator'), $row->title) . "); document.location.href='index2.php?option={$option}'</script>\n"; exit(0); } if ($client == 'admin') { $where = "client_id='1'"; } else { $where = "client_id='0'"; } // get list of groups if ($row->access == 99 || $row->client_id == 1) { $lists['access'] = T_('Administrator') . '<input type="hidden" name="access" value="99" />'; } else { // build the html select list for the group access $lists['access'] = mosAdminMenus::Access($row); } if ($uid) { $row->checkout($my->id); if ($row->ordering > -10000 && $row->ordering < 10000) { // build the html select list for ordering $query = "SELECT ordering AS value, name AS text" . "\n FROM #__mambots" . "\n WHERE folder='{$row->folder}'" . "\n AND published > 0" . "\n AND {$where}" . "\n AND ordering > -10000" . "\n AND ordering < 10000" . "\n ORDER BY ordering"; $order = mosGetOrderingList($query); $lists['ordering'] = mosHTML::selectList($order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval($row->ordering)); } else { $lists['ordering'] = '<input type="hidden" name="ordering" value="' . $row->ordering . '" />' . T_('This mambot cannot be reordered'); } $lists['folder'] = '<input type="hidden" name="folder" value="' . $row->folder . '" />' . $row->folder; // xml file for module $xmlfile = $mosConfig_absolute_path . '/mambots/' . $row->folder . '/' . $row->element . '.xml'; $xmlparser =& new mosXMLDescription($xmlfile); $row->description = T_($xmlparser->getDescription('mambot')); } else { $row->folder = ''; $row->ordering = 999; $row->published = 1; $row->description = ''; $folders = mosReadDirectory($mosConfig_absolute_path . '/mambots/'); $folders2 = array(); foreach ($folders as $folder) { if (is_dir($mosConfig_absolute_path . '/mambots/' . $folder) && $folder != 'CVS') { $folders2[] = mosHTML::makeOption($folder); } } $lists['folder'] = mosHTML::selectList($folders2, 'folder', 'class="inputbox" size="1"', 'value', 'text', null); $lists['ordering'] = '<input type="hidden" name="ordering" value="' . $row->ordering . '" />' . T_('New items default to the last place. Ordering can be changed after this item is saved.') . ''; } $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published); // get params definitions $params =& new mosAdminParameters($row->params, $mainframe->getPath('bot_xml', $row->folder . '/' . $row->element), 'mambot'); HTML_modules::editMambot($row, $lists, $params, $option); }
/** * Compiles information to add or edit a module * @param string The current GET/POST option * @param integer The unique id of the record to edit */ function editMambot($option, $uid, $client) { global $database, $my, $mainframe, $adminLanguage; global $mosConfig_absolute_path; $lists = array(); $row = new mosMambot($database); // load the row from the db table $row->load($uid); // fail if checked out not by 'me' if ($row->checked_out && $row->checked_out != $my->id) { echo "<script>alert(\"" . $adminLanguage->A_COMP_CONTENT_MODULE . " " . $row->title . " " . $adminLanguage->A_COMP_MAMB_EDIT . "\"); document.location.href='index2.php?option={$option}'</script>\n"; exit(0); } if ($uid) { $row->checkout($my->id); } if ($client == 'admin') { $where = "client_id='1'"; } else { $where = "client_id='0'"; } if (!$uid) { $row->folder = ''; $row->ordering = 999; $row->published = 1; } // get list of groups if ($row->access == 99 || $row->client_id == 1) { $lists['access'] = 'Administrator<input type="hidden" name="access" value="99" />'; } else { // build the html select list for the group access $lists['access'] = mosAdminMenus::Access($row); } $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published); if ($uid) { if ($row->ordering > -10000 && $row->ordering < 10000) { // build the html select list for ordering $query = "SELECT ordering AS value, name AS text" . "\n FROM #__mambots" . "\n WHERE folder='{$row->folder}'" . "\n AND published > 0" . "\n AND {$where}" . "\n AND ordering > -10000" . "\n AND ordering < 10000" . "\n ORDER BY ordering"; $order = mosGetOrderingList($query); $lists['ordering'] = mosHTML::selectList($order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval($row->ordering)); } else { $lists['ordering'] = '<input type="hidden" name="ordering" value="' . $row->ordering . '" />This mambot cannot be reordered'; } $lists['folder'] = '<input type="hidden" name="folder" value="' . $row->folder . '" />' . $row->folder; } else { $lists['ordering'] = '<input type="hidden" name="ordering" value="' . $row->ordering . '" />New items default to the last place'; $folders = mosReadDirectory($mosConfig_absolute_path . '/mambots/'); $folders2 = array(); foreach ($folders as $folder) { if (is_dir($mosConfig_absolute_path . '/mambots/' . $folder)) { $folders2[] = mosHTML::makeOption($folder); } } $lists['folder'] = mosHTML::selectList($folders2, 'folder', 'class="inputbox" size="1"', 'value', 'text', null); } $row->description = ''; // XML library require_once $mosConfig_absolute_path . '/includes/domit/xml_domit_lite_include.php'; // xml file for module $xmlfile = $mosConfig_absolute_path . '/mambots/' . $row->folder . '/' . $row->element . '.xml'; $xmlDoc =& new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if ($xmlDoc->loadXML($xmlfile, false, true)) { $element =& $xmlDoc->documentElement; if ($element->getTagName() == 'mosinstall' && $element->getAttribute('type') == 'mambot') { $element =& $xmlDoc->getElementsByPath('description', 1); $row->description = $element ? trim($element->getText()) : ''; } } // get params definitions $params =& new mosParameters($row->params, $mainframe->getPath('bot_xml', $row->folder . '/' . $row->element), 'mambot'); HTML_modules::editMambot($row, $lists, $params, $option); }
/** * Compiles information to add or edit a module * @param string The current GET/POST option * @param integer The unique id of the record to edit */ function editMambot($option, $uid, $client) { global $database, $my, $mainframe; global $mosConfig_absolute_path; $lists = array(); $row = new mosMambot($database); // load the row from the db table $row->load((int) $uid); // fail if checked out not by 'me' if ($row->isCheckedOut($my->id)) { mosErrorAlert("O módulo " . $row->title . " está, atualmente, a ser editado por outro administrador"); } if ($client == 'admin') { $where = "client_id='1'"; } else { $where = "client_id='0'"; } // get list of groups if ($row->access == 99 || $row->client_id == 1) { $lists['access'] = 'Administrator<input type="hidden" name="access" value="99" />'; } else { // build the html select list for the group access $lists['access'] = mosAdminMenus::Access($row); } if ($uid) { $row->checkout($my->id); if ($row->ordering > -10000 && $row->ordering < 10000) { // build the html select list for ordering $query = "SELECT ordering AS value, name AS text" . "\n FROM #__mambots" . "\n WHERE folder = " . $database->Quote($row->folder) . "\n AND published > 0" . "\n AND {$where}" . "\n AND ordering > -10000" . "\n AND ordering < 10000" . "\n ORDER BY ordering"; $order = mosGetOrderingList($query); $lists['ordering'] = mosHTML::selectList($order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval($row->ordering)); } else { $lists['ordering'] = '<input type="hidden" name="ordering" value="' . $row->ordering . '" />Este plugin não pode ser reordenado'; } $lists['folder'] = '<input type="hidden" name="folder" value="' . $row->folder . '" />' . $row->folder; // XML library require_once $mosConfig_absolute_path . '/includes/domit/xml_domit_lite_include.php'; // xml file for module $xmlfile = $mosConfig_absolute_path . '/mambots/' . $row->folder . '/' . $row->element . '.xml'; $xmlDoc = new DOMIT_Lite_Document(); $xmlDoc->resolveErrors(true); if ($xmlDoc->loadXML($xmlfile, false, true)) { $root =& $xmlDoc->documentElement; if ($root->getTagName() == 'mosinstall' && $root->getAttribute('type') == 'mambot') { $element =& $root->getElementsByPath('description', 1); $row->description = $element ? trim($element->getText()) : ''; } } } else { $row->folder = ''; $row->ordering = 999; $row->published = 1; $row->description = ''; $folders = mosReadDirectory($mosConfig_absolute_path . '/mambots/'); $folders2 = array(); foreach ($folders as $folder) { if (is_dir($mosConfig_absolute_path . '/mambots/' . $folder) && $folder != 'CVS') { $folders2[] = mosHTML::makeOption($folder); } } $lists['folder'] = mosHTML::selectList($folders2, 'folder', 'class="inputbox" size="1"', 'value', 'text', null); $lists['ordering'] = '<input type="hidden" name="ordering" value="' . $row->ordering . '" />Os novos itens, por padrão, serão adicionados ao final da lista. A ordem pode ser alterada após este item serem salvos.'; } $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published); $path = $mosConfig_absolute_path . "/mambots/{$row->folder}/{$row->element}.xml"; if (!file_exists($path)) { $path = ''; } // get params definitions $params = new mosParameters($row->params, $path, 'mambot'); HTML_modules::editMambot($row, $lists, $params, $option); }