| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: mollom.admin.inc,v 1.1.2.39 2010/09/15 02:56:56 dries Exp $ 3 4 /** 5 * @file 6 * Administrative page callbacks for Mollom module. 7 */ 8 9 /** 10 * Menu callback; Displays a list of forms configured for Mollom. 11 */ 12 function mollom_admin_form_list() { 13 _mollom_testing_mode_warning(); 14 15 $modes = array( 16 MOLLOM_MODE_DISABLED => t('No protection'), 17 MOLLOM_MODE_CAPTCHA => t('CAPTCHA only'), 18 MOLLOM_MODE_ANALYSIS => t('Text analysis and CAPTCHA backup'), 19 ); 20 21 $header = array( 22 t('Form'), 23 t('Protection mode'), 24 array('data' => t('Operations'), 'colspan' => 2), 25 ); 26 $rows = array(); 27 $result = db_query("SELECT form_id FROM {mollom_form}"); 28 while ($form_id = db_result($result)) { 29 $mollom_form = mollom_form_load($form_id); 30 $rows[] = array( 31 $mollom_form['title'], 32 $modes[$mollom_form['mode']], 33 l(t('Configure'), 'admin/settings/mollom/manage/' . $form_id), 34 l(t('Unprotect'), 'admin/settings/mollom/unprotect/' . $form_id), 35 ); 36 } 37 38 // Add a row to add a form. 39 if (empty($rows)) { 40 $rows[] = array(array('data' => l(t('Add form'), 'admin/settings/mollom/add'), 'colspan' => 4)); 41 } 42 43 return theme('table', $header, $rows); 44 } 45 46 /** 47 * Return registered forms as an array suitable for a 'checkboxes' form element #options property. 48 */ 49 function mollom_admin_form_options() { 50 // Retrieve all registered forms. 51 $form_list = mollom_form_list(); 52 53 // Remove already configured form ids. 54 $result = db_query("SELECT form_id FROM {mollom_form}"); 55 while ($form_id = db_result($result)) { 56 unset($form_list[$form_id]); 57 } 58 // If all registered forms are configured already, output a message, and 59 // redirect the user back to overview. 60 if (empty($form_list)) { 61 drupal_set_message(t('All available forms are protected already.')); 62 drupal_goto('admin/settings/mollom'); 63 } 64 65 // Load module information. 66 $modules = module_implements('mollom_form_info'); 67 $placeholders = db_placeholders($modules, 'varchar'); 68 $result = db_query("SELECT name, info FROM {system} WHERE type = 'module' AND name IN ($placeholders)", $modules); 69 $modules = array(); 70 while ($row = db_fetch_object($result)) { 71 $module_info = unserialize($row->info); 72 $modules[$row->name] = t($module_info['name']); 73 } 74 75 // Transform form information into an associative array suitable for #options. 76 foreach ($form_list as $form_id => $info) { 77 $form_list[$form_id] = $modules[$info['module']] . ': ' . $info['title']; 78 } 79 // Sort form options by title. 80 asort($form_list); 81 82 return $form_list; 83 } 84 85 /** 86 * Form builder; Configure Mollom protection for a form. 87 */ 88 function mollom_admin_configure_form(&$form_state, $mollom_form = NULL) { 89 // If no $mollom_form was passed, then we are adding a new form configuration. 90 if (!isset($mollom_form)) { 91 if (!isset($form_state['storage']['mollom_form'])) { 92 $form_state['storage']['step'] = 'select'; 93 } 94 else { 95 $form_state['storage']['step'] = 'configure'; 96 $mollom_form = $form_state['storage']['mollom_form']; 97 } 98 } 99 // When adding a new form configuration, passing form_id via path argument. 100 elseif (is_string($mollom_form)) { 101 $mollom_form = mollom_form_new($mollom_form); 102 $form_state['storage']['step'] = 'configure'; 103 $form_state['storage']['mollom_form'] = $mollom_form; 104 } 105 // Otherwise, we are editing an existing form configuration. 106 else { 107 $form_state['storage']['step'] = 'configure'; 108 $form_state['storage']['mollom_form'] = $mollom_form; 109 } 110 111 $form['#tree'] = TRUE; 112 113 switch ($form_state['storage']['step']) { 114 case 'select': 115 $form['mollom']['form_id'] = array( 116 '#type' => 'select', 117 '#title' => t('Form'), 118 '#options' => mollom_admin_form_options(), 119 '#required' => TRUE, 120 ); 121 $form['actions']['next'] = array( 122 '#type' => 'submit', 123 '#value' => t('Next'), 124 '#submit' => array('mollom_admin_configure_form_next_submit'), 125 ); 126 break; 127 128 case 'configure': 129 drupal_set_title(t('Configure %form-title protection', array('%form-title' => $mollom_form['title']))); 130 $form['#after_build'][] = 'mollom_admin_configure_form_after_build'; 131 132 // Display a list of fields for textual analysis (last step). 133 $form['mollom']['form_id'] = array( 134 '#type' => 'value', 135 '#value' => $mollom_form['form_id'], 136 ); 137 138 $modes = array(); 139 // Textual analysis, if any elements are available. 140 if (!empty($mollom_form['elements'])) { 141 $modes[MOLLOM_MODE_ANALYSIS] = t('Text analysis'); 142 } 143 // CAPTCHA-only, always available. 144 $modes[MOLLOM_MODE_CAPTCHA] = t('CAPTCHA'); 145 146 $form['mollom']['mode'] = array( 147 '#type' => 'radios', 148 '#title' => t('Protection mode'), 149 '#options' => $modes, 150 '#default_value' => $mollom_form['mode'], 151 ); 152 153 if (!empty($mollom_form['elements'])) { 154 // If not re-configuring an existing protection, make it the default. 155 if (!isset($mollom_form['mode'])) { 156 $form['mollom']['mode']['#default_value'] = MOLLOM_MODE_ANALYSIS; 157 } 158 159 // Textual analysis filters. 160 $form['mollom']['checks'] = array( 161 '#type' => 'checkboxes', 162 '#title' => t('Analyze text for'), 163 '#options' => array( 164 'spam' => t('Spam'), 165 ), 166 '#default_value' => $mollom_form['checks'], 167 // D7 only. 168 '#value' => array('spam' => 'spam'), 169 '#access' => FALSE, 170 ); 171 172 // Form elements defined by hook_mollom_form_info() use the 173 // 'parent][child' syntax, which Form API also uses internally for 174 // form_set_error(), and which allows us to recurse into nested fields 175 // during processing of submitted form values. However, since we are using 176 // those keys also as internal values to configure the fields to use for 177 // textual analysis, we need to encode them. Otherwise, a nested field key 178 // would result in the following checkbox attribute: 179 // '#name' => 'mollom[enabled_fields][parent][child]' 180 // This would lead to a form validation error, because it is a valid key. 181 // By encoding them, we prevent this from happening: 182 // '#name' => 'mollom[enabled_fields][parent%5D%5Bchild]' 183 $elements = array(); 184 foreach ($mollom_form['elements'] as $key => $value) { 185 $elements[rawurlencode($key)] = $value; 186 } 187 $enabled_fields = array(); 188 foreach ($mollom_form['enabled_fields'] as $value) { 189 $enabled_fields[] = rawurlencode($value); 190 } 191 $form['mollom']['enabled_fields'] = array( 192 '#type' => 'checkboxes', 193 '#title' => t('Text fields to analyze'), 194 '#options' => $elements, 195 '#default_value' => $enabled_fields, 196 '#required' => $mollom_form['mode'] == MOLLOM_MODE_ANALYSIS, 197 ); 198 } 199 200 $form['actions']['submit'] = array( 201 '#type' => 'submit', 202 '#value' => t('Save'), 203 ); 204 break; 205 } 206 207 $form['actions']['cancel'] = array( 208 '#value' => l(t('Cancel'), 'admin/settings/mollom'), 209 ); 210 211 return $form; 212 } 213 214 /** 215 * #after_build callback for mollom_admin_configure_form(). 216 */ 217 function mollom_admin_configure_form_after_build($form, &$form_state) { 218 // Make field checkboxes required, if protection mode is textual analysis. 219 // Accounts for different add and edit form builds and rebuilds. 220 $form['mollom']['enabled_fields']['#required'] = ($form_state['values']['mollom']['mode'] == MOLLOM_MODE_ANALYSIS); 221 222 return $form; 223 } 224 225 /** 226 * Form submit handler for 'Next' button on Mollom form configuration form. 227 */ 228 function mollom_admin_configure_form_next_submit($form, &$form_state) { 229 $form_id = $form_state['values']['mollom']['form_id']; 230 $form_state['redirect'] = $_GET['q'] . '/' . $form_id; 231 // D6 only. 232 unset($form_state['storage']); 233 } 234 235 /** 236 * Form validation handler for mollom_admin_configure_form(). 237 */ 238 function mollom_admin_configure_form_validate(&$form, &$form_state) { 239 // For the 'configure' step, output custom #required form element errors for 240 // 'checks' and 'enabled_fields', as their labels do not work with the default 241 // #required form error message. 242 if ($form_state['storage']['step'] == 'configure') { 243 // Make field checkboxes required, if protection mode is textual analysis. 244 $required = ($form_state['values']['mollom']['mode'] == MOLLOM_MODE_ANALYSIS); 245 $form['mollom']['checks']['#required'] = $required; 246 $form['mollom']['enabled_fields']['#required'] = $required; 247 248 if ($required && !array_filter($form_state['values']['mollom']['checks'])) { 249 form_error($form['mollom']['checks'], t('At least one text analysis check is required.')); 250 } 251 if ($required && !array_filter($form_state['values']['mollom']['enabled_fields'])) { 252 form_error($form['mollom']['enabled_fields'], t('At least one field is required for text analysis.')); 253 } 254 } 255 } 256 257 /** 258 * Form submit handler for mollom_admin_configure_form(). 259 */ 260 function mollom_admin_configure_form_submit($form, &$form_state) { 261 $mollom_form = $form_state['values']['mollom']; 262 // Merge in form information from $form_state. 263 $mollom_form += $form_state['storage']['mollom_form']; 264 265 // Only store a list of enabled textual analysis checks. 266 $mollom_form['checks'] = array_keys(array_filter($mollom_form['checks'])); 267 // Prepare selected fields for storage. 268 $enabled_fields = array(); 269 foreach (array_keys(array_filter($mollom_form['enabled_fields'])) as $field) { 270 $enabled_fields[] = rawurldecode($field); 271 } 272 $mollom_form['enabled_fields'] = $enabled_fields; 273 274 $status = mollom_form_save($mollom_form); 275 if ($status === SAVED_NEW) { 276 drupal_set_message(t('The form protection has been added.')); 277 } 278 else { 279 drupal_set_message(t('The form protection has been updated.')); 280 } 281 282 unset($form_state['storage']); 283 $form_state['redirect'] = 'admin/settings/mollom'; 284 } 285 286 /** 287 * Form builder; Remove Mollom protection from a form. 288 */ 289 function mollom_admin_unprotect_form(&$form_state, $mollom_form) { 290 $form['#tree'] = TRUE; 291 $form['form'] = array( 292 '#type' => 'item', 293 '#title' => t('Form'), 294 '#value' => $mollom_form['title'], 295 ); 296 $form['mollom']['form_id'] = array( 297 '#type' => 'value', 298 '#value' => $mollom_form['form_id'], 299 ); 300 301 return confirm_form($form, 302 t('Are you sure you want to unprotect this form?'), 303 'admin/settings/mollom', 304 t('Mollom will no longer protect this form from spam.') 305 ); 306 } 307 308 /** 309 * Form submit handler for mollom_admin_unprotect_form(). 310 */ 311 function mollom_admin_unprotect_form_submit($form, &$form_state) { 312 db_query("DELETE FROM {mollom_form} WHERE form_id = '%s'", $form_state['values']['mollom']['form_id']); 313 314 $form_state['redirect'] = 'admin/settings/mollom'; 315 } 316 317 /** 318 * Form constructor to configure the blacklist. 319 * 320 * @param $type 321 * The type of blacklist; i.e., 'spam', 'profanity', or 'unwanted'. 322 */ 323 function mollom_admin_blacklist_form(&$form_state, $type = 'spam') { 324 $form['#tree'] = TRUE; 325 326 // Select options and translation of internal values for rendering. 327 $contexts = array( 328 'everything' => t('All fields'), 329 'links' => t('Links'), 330 'author' => t('Author name'), 331 ); 332 333 $form['blacklist'] = array(); 334 // Do not retrieve the current blacklist when submitting the form. 335 $blacklist = (empty($form_state['input']) ? mollom('mollom.listBlacklistText') : array()); 336 if (is_array($blacklist)) { 337 foreach ($blacklist as $id => $entry) { 338 if ($entry['reason'] != $type) { 339 continue; 340 } 341 $row = array( 342 'context' => array('#value' => check_plain($contexts[$entry['context']])), 343 'text' => array('#value' => check_plain($entry['text'])), 344 'text' => array('#value' => check_plain($entry['text'])), 345 ); 346 $delete_url_parts = array( 347 'admin/settings/mollom/blacklist/delete', 348 base64_encode($entry['text']), 349 $entry['context'], 350 $entry['reason'], 351 ); 352 $row['actions']['delete'] = array( 353 '#value' => l(t('delete'), implode('/', $delete_url_parts), array('query' => drupal_get_destination())), 354 ); 355 $form['blacklist'][$id] = $row; 356 } 357 } 358 359 $form['entry']['context'] = array( 360 '#type' => 'select', 361 '#options' => $contexts, 362 '#default_value' => 'everything', 363 '#required' => TRUE, 364 ); 365 $form['entry']['text'] = array( 366 '#type' => 'textfield', 367 '#size' => 40, 368 '#required' => TRUE, 369 '#maxlength' => 64, 370 ); 371 $form['entry']['reason'] = array( 372 '#type' => 'value', 373 '#value' => $type, 374 ); 375 $form['entry']['actions'] = array( 376 '#tree' => FALSE, 377 ); 378 $form['entry']['actions']['submit'] = array( 379 '#type' => 'submit', 380 '#value' => t('Add'), 381 ); 382 383 return $form; 384 } 385 386 /** 387 * Form submit handler to save a text string to the Mollom blacklist. 388 */ 389 function mollom_admin_blacklist_form_submit($form, &$form_state) { 390 $result = mollom('mollom.addBlacklistText', $form_state['values']['entry']); 391 392 if ($result === TRUE) { 393 drupal_set_message(t('The entry was added to the blacklist.')); 394 } 395 else { 396 drupal_set_message(t('An error occurred upon trying to add the text to the blacklist.'), 'error'); 397 } 398 } 399 400 /** 401 * Formats the blacklist form as table to embed the form. 402 */ 403 function theme_mollom_admin_blacklist_form($form) { 404 $header = array( 405 t('Context'), 406 t('Text'), 407 '', 408 ); 409 $rows = array(); 410 411 $rows[] = array( 412 drupal_render($form['entry']['context']), 413 drupal_render($form['entry']['text']), 414 drupal_render($form['entry']['actions']), 415 ); 416 417 foreach (element_children($form['blacklist']) as $id) { 418 $rows[] = array( 419 drupal_render($form['blacklist'][$id]['context']), 420 drupal_render($form['blacklist'][$id]['text']), 421 drupal_render($form['blacklist'][$id]['actions']), 422 ); 423 } 424 425 // This table is never empty due to the form. 426 $output = theme('table', $header, $rows); 427 $output .= drupal_render($form); 428 429 return $output; 430 } 431 432 /** 433 * Form builder; Builds the confirmation form for deleting a blacklist item. 434 * 435 * @param $key 436 * The blacklist entry text to remove, base64-encoded. 437 * @param $context 438 * The context of the blacklist entry. 439 * @param $reason 440 * The reason of the blacklist entry. 441 * 442 * @ingroup forms 443 * @see mollom_admin_blacklist_delete_submit() 444 */ 445 function mollom_admin_blacklist_delete(&$form_state, $key, $context, $reason) { 446 $text = base64_decode($key); 447 $form['text'] = array( 448 '#type' => 'value', 449 '#value' => $text, 450 ); 451 $form['context'] = array( 452 '#type' => 'value', 453 '#value' => $context, 454 ); 455 $form['reason'] = array( 456 '#type' => 'value', 457 '#value' => $reason, 458 ); 459 460 return confirm_form( 461 $form, 462 t('Are you sure you want to delete %text from the blacklist?', array('%text' => $text)), 463 'admin/settings/mollom/blacklist', 464 t('This action cannot be undone.'), 465 t('Delete'), t('Cancel') 466 ); 467 } 468 469 /** 470 * Form submit handler to delete an entry from the blacklist. 471 */ 472 function mollom_admin_blacklist_delete_submit($form, &$form_state) { 473 $data = array( 474 'text' => $form_state['values']['text'], 475 'context' => $form_state['values']['context'], 476 'reason' => $form_state['values']['reason'], 477 ); 478 $result = mollom('mollom.removeBlacklistText', $data); 479 480 if ($result === TRUE) { 481 drupal_set_message(t('The entry was removed from the blacklist.')); 482 } 483 else { 484 drupal_set_message(t('An error occurred upon trying to remove the item from the blacklist.'), 'error'); 485 } 486 487 $form_state['redirect'] = 'admin/settings/mollom/blacklist'; 488 } 489 490 /** 491 * Form builder; Global Mollom settings form. 492 * 493 * This form does not validate Mollom API keys, since the fallback method still 494 * needs to be able to be reconfigured in case Mollom services are down. 495 * mollom.verifyKey would invalidate the keys and throw an error; hence, 496 * _mollom_fallback() would invoke form_set_error(), effectively preventing this 497 * form from submitting. 498 */ 499 function mollom_admin_settings(&$form_state) { 500 // Output a positive status message, since users keep on asking whether 501 // Mollom should work or not. Re-check on every regular visit of this form to 502 // verify the module's configuration. 503 if (empty($form_state['post'])) { 504 $status = _mollom_status(); 505 // If there is any configuration error, then mollom_init() will have output 506 // it already. 507 if ($status === TRUE) { 508 drupal_set_message(t('We contacted the Mollom servers to verify your keys: the Mollom services are operating correctly. We are now blocking spam.')); 509 } 510 } 511 512 $form['access-keys'] = array( 513 '#type' => 'fieldset', 514 '#title' => t('Access keys'), 515 '#description' => t('To use Mollom, you need a public and private key. To obtain your keys, <a href="@mollom-login-url">register and login on mollom.com</a>, and <a href="@mollom-manager-add-url">create a subscription</a> for your site. Once you created a subscription, copy your private and public access keys from the <a href="@mollom-manager-url">site manager</a> into the form fields below, and you are ready to go.', array( 516 '@mollom-login-url' => 'http://mollom.com/user', 517 '@mollom-manager-add-url' => 'http://mollom.com/site-manager/add', 518 '@mollom-manager-url' => 'http://mollom.com/site-manager', 519 )), 520 '#collapsible' => TRUE, 521 // Only show key configuration fields if they are not configured or invalid. 522 '#collapsed' => !isset($status) ? FALSE : $status === TRUE, 523 ); 524 // Keys are not #required to allow to install this module and configure it 525 // later. 526 $form['access-keys']['mollom_public_key'] = array( 527 '#type' => 'textfield', 528 '#title' => t('Public key'), 529 '#default_value' => variable_get('mollom_public_key', ''), 530 '#description' => t('Used to uniquely identify you.'), 531 ); 532 $form['access-keys']['mollom_private_key'] = array( 533 '#type' => 'textfield', 534 '#title' => t('Private key'), 535 '#default_value' => variable_get('mollom_private_key', ''), 536 '#description' => t('Used to prevent someone else from hijacking your requests. Similar to a password, it should never be shared with anyone.'), 537 ); 538 539 $form['mollom_fallback'] = array( 540 '#type' => 'radios', 541 '#title' => t('Fallback strategy for protected forms'), 542 // Default to treating everything as inappropriate. 543 '#default_value' => variable_get('mollom_fallback', MOLLOM_FALLBACK_BLOCK), 544 '#options' => array( 545 MOLLOM_FALLBACK_BLOCK => t('Block all form submissions'), 546 MOLLOM_FALLBACK_ACCEPT => t('Accept all form submissions'), 547 ), 548 '#description' => t('In case the Mollom services are unreachable, no text analysis is performed and no CAPTCHAs are generated. If this occurs, your site will use the configured fallback strategy until the server problems are resolved. Subscribers to <a href="@pricing-url">Mollom Plus</a> receive access to <a href="@sla-url">Mollom\'s high-availability backend infrastructure</a>, not available to free users, reducing potential downtime.', array( 549 '@pricing-url' => 'http://mollom.com/pricing', 550 '@sla-url' => 'http://mollom.com/standard-service-level-agreement', 551 )), 552 ); 553 554 $form['mollom_privacy_link'] = array( 555 '#type' => 'checkbox', 556 '#title' => t("Link to Mollom's privacy policy on forms protected by textual analysis"), 557 '#return_value' => 1, 558 '#default_value' => variable_get('mollom_privacy_link', 1), 559 '#description' => t('Displays a link to the recommended <a href="@privacy-policy-url">privacy policy on mollom.com</a> on all forms that are protected via <a href="@help-url">textual analysis</a>. When disabling this option, you are required to inform visitors about data privacy through other means, as stated in the <a href="@terms-of-service-url">terms of service</a> applying to your subscription.', array( 560 '@privacy-policy-url' => 'http://mollom.com/web-service-privacy-policy', 561 '@help-url' => url('admin/help/mollom'), 562 '@terms-of-service-url' => 'http://mollom.com/terms-of-service', 563 )), 564 ); 565 566 $form['mollom_testing_mode'] = array( 567 '#type' => 'checkbox', 568 '#title' => t('Enable testing mode'), 569 '#default_value' => variable_get('mollom_testing_mode', 0), 570 '#description' => t('Submitting "ham", "unsure", or "spam" on a protected form will trigger the corresponding behavior, and similarly, word verifications will only respond to "correct" and "incorrect", instead of the actual characters asked for. This option should be disabled in production environments.'), 571 ); 572 573 return system_settings_form($form); 574 } 575 576 /** 577 * Form submit handler to mass-report and unpublish or delete comments. 578 */ 579 function mollom_comment_admin_overview_submit($form, &$form_state) { 580 if (strpos($form_state['values']['operation'], 'mollom-') === 0) { 581 list($id, $operation) = explode('-', $form_state['values']['operation']); 582 foreach ($form_state['values']['comments'] as $cid => $value) { 583 if ($value) { 584 // First, report the comments as spam to Mollom.com. 585 if ($data = mollom_data_load('comment', $cid)) { 586 _mollom_send_feedback($data->session); 587 } 588 589 // Second, perform the proper operation on the comments: 590 if ($comment = _comment_load($cid)) { 591 if ($operation == 'unpublish') { 592 db_query("UPDATE {comments} SET status = %d WHERE cid = %d", COMMENT_NOT_PUBLISHED, $cid); 593 _comment_update_node_statistics($comment->nid); 594 } 595 elseif ($operation == 'delete') { 596 _comment_delete_thread($comment); 597 _comment_update_node_statistics($comment->nid); 598 } 599 } 600 } 601 } 602 603 // Flush caches so the content changes are visible for anonymous users. 604 cache_clear_all(); 605 606 if ($operation == 'delete') { 607 drupal_set_message(t('The selected comments have been reported as inappropriate and are deleted.')); 608 } 609 else { 610 drupal_set_message(t('The selected comments have been reported as inappropriate and are unpublished.')); 611 } 612 } 613 } 614 615 /** 616 * Form submit handler to mass-report and unpublish or delete nodes. 617 */ 618 function mollom_node_admin_overview_submit($form, &$form_state) { 619 if (strpos($form_state['values']['operation'], 'mollom-') === 0) { 620 list($id, $operation) = explode('-', $form_state['values']['operation']); 621 foreach ($form_state['values']['nodes'] as $nid => $value) { 622 if ($value) { 623 // First, report the nodes as spam to Mollom.com. 624 if ($data = mollom_data_load('node', $nid)) { 625 _mollom_send_feedback($data->session); 626 } 627 628 if ($node = node_load($nid)) { 629 if ($operation == 'unpublish') { 630 db_query("UPDATE {node} SET status = 0 WHERE nid = %d", $nid); 631 } 632 elseif ($operation == 'delete') { 633 node_delete($nid); 634 } 635 } 636 } 637 } 638 639 // Flush caches so the content changes are visible for anonymous users. 640 cache_clear_all(); 641 642 if ($operation == 'delete') { 643 drupal_set_message(t('The selected posts have been reported as inappropriate and are deleted.')); 644 } 645 else { 646 drupal_set_message(t('The selected posts have been reported as inappropriate and are unpublished.')); 647 } 648 } 649 } 650 651 /** 652 * Menu callback; Displays the administrative reports page. 653 */ 654 function mollom_reports_page() { 655 $embed_attributes = array( 656 'src' => 'http://mollom.com/statistics.swf?key=' . check_plain(variable_get('mollom_public_key', '')), 657 'quality' => 'high', 658 'width' => '100%', 659 'height' => '430', 660 'name' => 'Mollom', 661 'align' => 'middle', 662 'play' => 'true', 663 'loop' => 'false', 664 'allowScriptAccess' => 'sameDomain', 665 'type' => 'application/x-shockwave-flash', 666 'pluginspage' => 'http://www.adobe.com/go/getflashplayer', 667 ); 668 $form['chart'] = array( 669 '#type' => 'item', 670 '#title' => t('Statistics'), 671 '#value' => '<embed' . drupal_attributes($embed_attributes) . '></embed>', 672 ); 673 if (module_exists('dblog')) { 674 $logs = array(); 675 $query = db_query_range("SELECT message, variables FROM {watchdog} WHERE type = 'mollom' AND severity <= %d ORDER BY wid DESC", WATCHDOG_WARNING, 0, 10); 676 while ($log = db_fetch_object($query)) { 677 $t_args = unserialize($log->variables); 678 $logs[] = t($log->message, ($t_args ? $t_args : array())); 679 } 680 $form['watchdog'] = array( 681 '#type' => 'item', 682 '#title' => t('Recent Mollom messages'), 683 '#value' => $logs ? theme('item_list', $logs) : t('None'), 684 ); 685 } 686 return $form; 687 } 688
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |