Exemplo n.º 1
0
function editAd($option)
{
    $user =& JFactory::getUser();
    $user_id = $user->get('id');
    if ($user_id == 0) {
        echo 'Please <a href="index.php?option=com_user&view=zlogin">log in</a> to submit an ad.';
        return;
    }
    $query = "SELECT * FROM #__aard_config WHERE id ='1'";
    $db =& JFactory::getDBO();
    $db->setQuery($query);
    $rows = $db->loadObjectList();
    if ($db->getErrorNum()) {
        echo $db->stderr();
        return false;
    }
    foreach ($rows as $row) {
        $currency = $row->currency;
    }
    $row =& JTable::getInstance('classified', 'Table');
    $cid = JRequest::getVar('cid', array(0), '', 'array');
    $id = $cid[0];
    $row->load($id);
    $lists = array();
    $objD =& JFactory::getDBO();
    $lists['ad_delivery'] = getHTMLList('entrega', 'ad_delivery');
    $lists['ad_state'] = getHTMLList('intencion', 'ad_state');
    $lists['cat_name'] = getHTMLList('rubro', 'cat_id');
    $lists['ad_type'] = getHTMLList('tipo', 'ad_type');
    $expiration_date = !$row->date_expiration ? date('Y-m-d') : $row->date_expiration;
    $data = array('expirationdate' => $expiration_date);
    if ($user_id == $row->user_id) {
        HTML_classifieds::editAd($row, $lists, $option, $currency, $data);
    } elseif ($row->user_id == "") {
        HTML_classifieds::editAd($row, $lists, $option, $currency, $data);
    } else {
        echo 'Invalid User';
    }
}