/**
 * Template function for adding editing contacts
 *
 * @since 0.1
 */
function rolo_edit_contact()
{
    $contact_id = isset($_GET['id']) ? $_GET['id'] : 0;
    $action = isset($_GET['action']) ? $_GET['action'] : '';
    $contact =& get_post($contact_id);
    if ($contact) {
        //TODO - Check user capabilites
        //TODO - Verify nounce here
        if (isset($_POST['rp_edit_contact']) && $_POST['rp_edit_contact'] == 'edit_contact') {
            $contact_id = _rolo_save_contact_fields();
            if ($contact_id) {
                // echo __("Contacto editado com sucesso.", 'rolopress');
                $location = get_bloginfo('siteurl');
                echo "<script type='text/javascript'>window.location = '" . $location . "';</script>";
            } else {
                echo __("Ocorreu um erro ao editar o contacto", 'rolopress');
                //            TODO - Handle Error properly
            }
        } else {
            if ($action == 'delete') {
                wp_delete_post($contact_id);
                echo __("Contacto removido com sucesso.", 'rolopress');
            } else {
                _rolo_show_edit_contact_form($contact_id);
            }
        }
    } else {
        // TODO: should redirect properly
    }
}
Exemplo n.º 2
0
/**
 * Template function for adding editing contacts
 *
 * @since 0.1
 */
function rolo_edit_contact()
{
    $contact_id = isset($_GET['id']) ? $_GET['id'] : 0;
    $contact =& get_post($contact_id);
    if ($contact) {
        //TODO - Check user capabilites
        //TODO - Verify nounce here
        if (isset($_POST['rp_edit_contact']) && $_POST['rp_edit_contact'] == 'edit_contact') {
            $contact_id = _rolo_save_contact_fields();
            if ($contact_id) {
                echo __("Contact information successfully added.", 'rolopress');
            } else {
                echo __("There was some problem in inserting the contact info", 'rolopress');
                //            TODO - Handle Error properly
            }
        } else {
            _rolo_show_edit_contact_form($contact_id);
        }
    } else {
        // TODO: should redirect properly
    }
}