Example #1
0
/**
* Creates a new or edits and existing user record
* @param int The id of the record, 0 if a new entry
* @param string The current GET/POST option
*/
function editContact($id, $option)
{
    global $database, $my;
    global $mosConfig_absolute_path;
    $row = new mosContact($database);
    // load the row from the db table
    $row->load($id);
    if ($id) {
        // do stuff for existing records
        $row->checkout($my->id);
    } else {
        // do stuff for new records
        $row->imagepos = 'top';
        $row->ordering = 0;
        $row->published = 1;
    }
    $lists = array();
    // build the html select list for ordering
    $query = "SELECT ordering AS value, name AS text" . "\n FROM #__contact_details" . "\n WHERE published >= 0" . "\n AND catid = '{$row->catid}'" . "\n ORDER BY ordering";
    $lists['ordering'] = mosAdminMenus::SpecificOrdering($row, $id, $query, 1);
    // build list of users
    $lists['user_id'] = mosAdminMenus::UserSelect('user_id', $row->user_id, 1);
    // build list of categories
    $lists['catid'] = mosAdminMenus::ComponentCategory('catid', 'com_contact_details', intval($row->catid));
    // build the html select list for images
    $lists['image'] = mosAdminMenus::Images('image', $row->image);
    // build the html select list for the group access
    $lists['access'] = mosAdminMenus::Access($row);
    // build the html radio buttons for published
    $lists['published'] = mosHTML::yesnoradioList('published', '', $row->published);
    // build the html radio buttons for default
    $lists['default_con'] = mosHTML::yesnoradioList('default_con', '', $row->default_con);
    // get params definitions
    $file = $mosConfig_absolute_path . '/administrator/components/com_contact/contact_items.xml';
    $params =& new mosAdminParameters($row->params, $file, 'component');
    HTML_contact::editcontact($row, $lists, $option, $params);
}