/** * Compiles information to add or edit * @param integer The unique id of the record to edit (0 if new) */ function editWeblink($option, $id) { global $database, $my, $mosConfig_absolute_path; $lists = array(); $row = new mosWeblink($database); // load the row from the db table $row->load((int) $id); // fail if checked out not by 'me' if ($row->isCheckedOut($my->id)) { mosRedirect('index2.php?option=' . $option, 'The module $row->title is currently being edited by another administrator.'); } if ($id) { $row->checkout($my->id); } else { // initialise new record $row->published = 1; $row->approved = 1; $row->order = 0; $row->catid = intval(mosGetParam($_POST, 'catid', 0)); } // build the html select list for ordering $query = "SELECT ordering AS value, title AS text" . "\n FROM #__weblinks" . "\n WHERE catid = " . (int) $row->catid . "\n ORDER BY ordering"; $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $id, $query, 1); // build list of categories $lists['catid'] = mosAdminMenus::ComponentCategory('catid', $option, intval($row->catid)); // build the html select list $lists['published'] = mosHTML::yesnoRadioList('published', 'class="inputbox"', $row->published); $file = $mosConfig_absolute_path . '/administrator/components/com_weblinks/weblinks_item.xml'; $params = new mosParameters($row->params, $file, 'component'); HTML_weblinks::editWeblink($row, $lists, $params, $option); }
function editWebLink($id, $option) { global $database, $my; if ($my->gid < 1) { mosNotAuth(); return; } // security check to see if link exists in a menu $link = 'index.php?option=com_weblinks&task=new'; $query = "SELECT id" . "\n FROM #__menu" . "\n WHERE link LIKE '%{$link}%'" . "\n AND published = 1"; $database->setQuery($query); $exists = $database->loadResult(); if (!$exists) { mosNotAuth(); return; } $row = new mosWeblink($database); // load the row from the db table $row->load((int) $id); // fail if checked out not by 'me' if ($row->isCheckedOut($my->id)) { mosRedirect("index2.php?option={$option}", 'The module $row->title is currently being edited by another administrator.'); } if ($id) { $row->checkout($my->id); } else { // initialise new record $row->published = 0; $row->approved = 1; $row->ordering = 0; } // build list of categories $lists['catid'] = mosAdminMenus::ComponentCategory('catid', $option, intval($row->catid)); HTML_weblinks::editWeblink($option, $row, $lists); }