Пример #1
0
function guifi_device_delete($device, $notify = TRUE, $verbose = TRUE)
{
    global $user;
    guifi_log(GUIFILOG_TRACE, 'function guifi_device_delete()');
    $to_mail = explode(',', $device['notification']);
    if ($_POST['confirm']) {
        $log = _guifi_db_delete('guifi_devices', array('id' => $device['id']), $to_mail);
        drupal_set_message($log);
        $subject = t('The device %name has been DELETED by %user.', array('%name' => $device['nick'], '%user' => $user->name));
        drupal_set_message($subject);
        guifi_notify($to_mail, $subject, $log, $verbose, $notify);
        guifi_node_set_flag($device['nid']);
        drupal_goto('node/' . $device['nid']);
    }
    $node = node_load(array('nid' => $device['nid']));
    drupal_set_breadcrumb(guifi_node_ariadna($node));
    $output = drupal_get_form('guifi_device_delete_confirm', array('name' => $device['nick'], 'id' => $device['id']));
    print theme('page', $output, FALSE);
    return;
}
Пример #2
0
/**
 * Remove a device from guifi.net
 *
 * @param GuifiAPI $gapi
 * @param mixed[] $parameters Parameters to remove the device (device_id, basically)
 * @return boolean Whether the device was removed or not
 */
function guifi_api_device_remove($gapi, $parameters)
{
    if (!guifi_api_check_fields($gapi, array('device_id'), $parameters)) {
        return FALSE;
    }
    global $user;
    $device = guifi_device_load($parameters['device_id']);
    if (!$device['id']) {
        $gapi->addError(500, "device_id = {$parameters['device_id']}");
        return FALSE;
    }
    guifi_log(GUIFILOG_TRACE, 'function guifi_device_delete()');
    $to_mail = explode(',', $device['notification']);
    $log = _guifi_db_delete('guifi_devices', array('id' => $device['id']), $to_mail);
    drupal_set_message($log);
    $subject = t('The device %name has been DELETED by %user.', array('%name' => $device['nick'], '%user' => $user->name));
    guifi_notify($to_mail, $subject, $log, $verbose, $notify);
    guifi_node_set_flag($device['nid']);
    return TRUE;
}