function _spamicide_set_css_file in Spamicide 7
Same name and namespace in other branches
- 5 spamicide.module \_spamicide_set_css_file()
- 6 spamicide.module \_spamicide_set_css_file()
Set the spamicide field name and .css file_name
Parameters
array $form_field:
string $op:
4 calls to _spamicide_set_css_file()
- spamicide_admin_adform_form_submit in ./
spamicide.module - Implements hook_form_submit().
- spamicide_admin_form_submit in ./
spamicide.module - Implements hook_form_submit().
- spamicide_delete_confirm_submit in ./
spamicide.module - submission handler of Spamicide delete confirm_form
- spamicide_install in ./
spamicide.install - Implements hook_install(). Create the tables required for the spamicide module
File
- ./
spamicide.inc, line 41 - This module provides yet another tool to eliminate spam.
Code
function _spamicide_set_css_file($form_field, $op) {
$spam_path = 'public://' . variable_get('spamicide_dir', 'spamicide');
if (file_prepare_directory($spam_path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
$css_file = $spam_path . '/' . $form_field . '.css';
if ($op == 'delete') {
$file_check = db_query('SELECT DISTINCT(form_field) FROM {spamicide} WHERE form_field = :form_field', array(
':form_field' => $form_field,
))
->fetchCol();
if (!$file_check || !in_array($form_field, $file_check)) {
file_unmanaged_delete($css_file);
}
}
if ($op == 'create' && !file_exists($css_file)) {
$css = 'div.' . _spamicide_get_css_class($form_field) . ' { display:none; }';
file_save_data($css, $css_file, FILE_EXISTS_REPLACE);
}
}
}