Ejemplo n.º 1
0
/**
 * Confirm that an edited user fields properly filled in.
 */
function _guifi_user_queue_device_form_submit($form, $form_state)
{
    guifi_log(GUIFILOG_TRACE, 'function guifi_user_queue_device_form_submit()', $form_state['clicked_button']['#post']);
    switch ($form_state['clicked_button']['#name']) {
        case 'approve':
            $edit =& $form_state['clicked_button']['#post'];
            $d = guifi_device_load($edit['did']);
            $d['flag'] = 'Working';
            $d['radios'][0]['mac'] = $edit['mac'];
            $d['radios'][0]['interfaces'][$edit['iid']]['mac'] = $edit['mac'];
            $d['radios'][0]['interfaces'][$edit['iid']]['ipv4'][0]['links'][$edit['lid']]['flag'] = 'Working';
            guifi_device_save($d);
            $n = guifi_node_load($form_state['clicked_button']['#post']['nid']);
            $form_state['values']['status'] = 'Approved';
        case 'saveUser':
            $u = guifi_user_load($form_state['clicked_button']['#post']['uid']);
            $u['status'] = $form_state['values']['status'];
            guifi_user_save($u);
            break;
    }
    return;
}
Ejemplo n.º 2
0
function guifi_node_get_service($id, $type, $path = FALSE)
{
    if (is_numeric($id)) {
        $z = guifi_node_load($id);
    } else {
        $z = $id;
    }
    $ret = NULL;
    if (!empty($z->{$type})) {
        $ret = $z->{$type};
    } else {
        $ret = guifi_zone_get_service($z->zone_id, $type);
    }
    if ($path) {
        if ($ret) {
            $ret = 'node/' . $ret;
        }
    }
    return $ret;
}
Ejemplo n.º 3
0
/**
 * Select device
 *
 * URL: http://guifi.net/guifi/js/select-device/%
 */
function guifi_ahah_select_device()
{
    $cid = 'form_' . $_POST['form_build_id'];
    $cache = cache_get($cid, 'cache_form');
    $action = arg(3);
    if ($cache) {
        $form = $cache->data;
        if ($action == 'guifi_node_distances') {
            $node = guifi_node_load($_POST['filters']['from_node']);
            $form['list-devices'] = guifi_node_distances_list($_POST['filters'], $node);
        } else {
            $form['list-devices'] = guifi_devices_select($_POST['filters'], $action);
        }
        cache_set($cid, $form, 'cache_form', $cache->expire);
        // Build and render the new select element, then return it in JSON format.
        $form_state = array();
        $form['#post'] = array();
        $form = form_builder($form['form_id']['#value'], $form, $form_state);
        $output = drupal_render($form['list-devices']);
        drupal_json(array('status' => TRUE, 'data' => $output));
    } else {
        drupal_json(array('status' => FALSE, 'data' => ''));
    }
    exit;
}