| 1 |
<?php |
<?php |
| 2 |
// $Id: jgrowl.module,v 1.2.2.1 2008/09/29 16:37:30 stevemckenzie Exp $ |
// $Id: jgrowl.module,v 1.2.2.2 2008/10/01 07:26:07 stevemckenzie Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* |
* |
| 14 |
*/ |
*/ |
| 15 |
|
|
| 16 |
define('JGROWL_SYSTEM_MESSAGES', variable_get('jgrowl_system_messages', TRUE)); |
define('JGROWL_SYSTEM_MESSAGES', variable_get('jgrowl_system_messages', TRUE)); |
| 17 |
|
define('JGROWL_STICKY_ERRORS', variable_get('jgrowl_sticky_errors', TRUE)); |
| 18 |
|
define('JGROWL_STICKY_STATUSES', variable_get('jgrowl_sticky_statuses', FALSE)); |
| 19 |
|
|
| 20 |
/** |
/** |
| 21 |
* Implementation of hook_perm(). |
* Implementation of hook_perm(). |
| 97 |
|
|
| 98 |
// No need to add items that are already using their default values. |
// No need to add items that are already using their default values. |
| 99 |
foreach ($defaults as $name => $default) { |
foreach ($defaults as $name => $default) { |
| 100 |
if ($name && $variables[$name] == $default) { |
if ($name && $variables[$name] === $default) { |
| 101 |
unset($variables[$name]); |
unset($variables[$name]); |
| 102 |
} |
} |
| 103 |
} |
} |
| 126 |
'#default_value' => JGROWL_SYSTEM_MESSAGES, |
'#default_value' => JGROWL_SYSTEM_MESSAGES, |
| 127 |
); |
); |
| 128 |
|
|
| 129 |
|
$form['jgrowl_sticky_errors'] = array( |
| 130 |
|
'#title' => t('Sticky error messages'), |
| 131 |
|
'#description' => t('Automatically sticky error messages even if sticky is not enabled below.'), |
| 132 |
|
'#type' => 'checkbox', |
| 133 |
|
'#default_value' => JGROWL_STICKY_ERRORS, |
| 134 |
|
); |
| 135 |
|
|
| 136 |
|
$form['jgrowl_sticky_statuses'] = array( |
| 137 |
|
'#title' => t('Sticky status messages'), |
| 138 |
|
'#description' => t('Automatically sticky status messages even if sticky is not enabled below.'), |
| 139 |
|
'#type' => 'checkbox', |
| 140 |
|
'#default_value' => JGROWL_STICKY_STATUSES, |
| 141 |
|
); |
| 142 |
|
|
| 143 |
$form['variables'] = array('#title' => t('Configuration'), '#type' => 'fieldset', '#collapsible' => TRUE, '#description' => t('For more information on the variables available and what they do, visit the !site.', array('!site' => l(t('plugin\'s site'), 'http://stanlemon.net/projects/jgrowl.html')))); |
$form['variables'] = array('#title' => t('Configuration'), '#type' => 'fieldset', '#collapsible' => TRUE, '#description' => t('For more information on the variables available and what they do, visit the !site.', array('!site' => l(t('plugin\'s site'), 'http://stanlemon.net/projects/jgrowl.html')))); |
| 144 |
|
|
| 145 |
foreach (jgrowl_variables('settings') as $variable => $value) { |
foreach (jgrowl_variables('settings') as $variable => $value) { |
| 177 |
if (JGROWL_SYSTEM_MESSAGES && !empty($_SESSION['messages'])) { |
if (JGROWL_SYSTEM_MESSAGES && !empty($_SESSION['messages'])) { |
| 178 |
jgrowl_include(); |
jgrowl_include(); |
| 179 |
|
|
| 180 |
// Remove them from the session and display them with growl. |
// Remove messages from the session and display them with growl. |
| 181 |
$js = ''; |
$js = ''; |
| 182 |
foreach ($_SESSION['messages'] as $type => $messages) { |
foreach ($_SESSION['messages'] as $type => $messages) { |
| 183 |
foreach ($messages as $key => $message) { |
foreach ($messages as $key => $message) { |
| 184 |
$js .= theme('jgrowl_message', $message, array('theme' => $type)); |
$options = array('theme' => $type); |
| 185 |
|
switch ($type) { |
| 186 |
|
case 'status': |
| 187 |
|
if (JGROWL_STICKY_STATUSES) { |
| 188 |
|
$options['sticky'] = TRUE; |
| 189 |
|
} |
| 190 |
|
break; |
| 191 |
|
case 'error': |
| 192 |
|
if (JGROWL_STICKY_ERRORS) { |
| 193 |
|
$options['sticky'] = TRUE; |
| 194 |
|
} |
| 195 |
|
break; |
| 196 |
|
} |
| 197 |
|
|
| 198 |
|
$js .= theme('jgrowl_message', $message, $options); |
| 199 |
unset($_SESSION['messages'][$type][$key]); |
unset($_SESSION['messages'][$type][$key]); |
| 200 |
} |
} |
| 201 |
unset($_SESSION['messages'][$type]); |
unset($_SESSION['messages'][$type]); |