Exemple #1
0
function form_layout()
{
    $mainframe = JFactory::getApplication();
    $user = JFactory::getUser();
    $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');
        }
    }
    $ids = array();
    $types = array();
    $labels = array();
    $fields = explode('*:*new_field*:*', $row->form_fields);
    $fields = array_slice($fields, 0, count($fields) - 1);
    foreach ($fields as $field) {
        $temp = explode('*:*id*:*', $field);
        array_push($ids, $temp[0]);
        $temp = explode('*:*type*:*', $temp[1]);
        array_push($types, $temp[0]);
        $temp = explode('*:*w_field_label*:*', $temp[1]);
        array_push($labels, $temp[0]);
    }
    $fields = array('ids' => $ids, 'types' => $types, 'labels' => $labels);
    HTML_contact::form_layout($row, $fields);
}