Exemple #1
0
function form_options()
{
    $mainframe = JFactory::getApplication();
    $user = JFactory::getUser();
    $option = 'com_formmaker';
    $db = JFactory::getDBO();
    $cid = JRequest::getVar('cid', array(0), '', 'array');
    JArrayHelper::toInteger($cid, array(0));
    $id = $cid[0];
    $row = JTable::getInstance('formmaker', 'Table');
    // load the row from the db table
    $row->load($id);
    $canEdit = $user->authorise('core.edit', 'com_formmaker');
    $canEditOwn = $user->authorise('core.edit.own', 'com_formmaker');
    if (!$canEdit) {
        if (!$canEditOwn || $row->created_by != $user->id) {
            $mainframe->redirect("index.php?option=com_formmaker", JText::_('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED'), 'error');
        }
    }
    $tabs = $mainframe->getUserStateFromRequest($option . 'tabs', 'tabs', 'general_op', 'string');
    $query = "SELECT * FROM #__formmaker_themes WHERE css LIKE '%.wdform_section%' ORDER BY title";
    $db->setQuery($query);
    $themes_new = $db->loadObjectList();
    if ($db->getErrorNum()) {
        echo $db->stderr();
        return false;
    }
    $query = "SELECT * FROM #__formmaker_themes WHERE css NOT LIKE '%.wdform_section%' ORDER BY title";
    $db->setQuery($query);
    $themes_old = $db->loadObjectList();
    if ($db->getErrorNum()) {
        echo $db->stderr();
        return false;
    }
    $query = "SELECT * FROM #__formmaker_query WHERE form_id=" . $db->escape((int) $id) . " ORDER BY id ASC";
    $db->setQuery($query);
    $queries = $db->loadObjectList();
    if ($db->getErrorNum()) {
        echo $db->stderr();
        return false;
    }
    $query = "SELECT * FROM #__usergroups";
    $db->setQuery($query);
    $userGroups = $db->loadObjectList();
    $old = false;
    if (isset($row->form)) {
        $old = true;
    }
    if ($old == false || $old == true && $row->form == '') {
        HTML_contact::form_options($row, $themes_new, $queries, $tabs, $userGroups);
    } else {
        HTML_contact::form_options_old($row, $themes_old);
    }
}