From 3cf5b48455a168a122a0ab2f517e066cdc2986f5 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 24 Aug 2012 17:04:39 -0400 Subject: [PATCH] Refactoring and new generator to aid in responses. --- INSTALL.md | 194 - build-petition.make | 20 - drupal-org.make | 164 - index.html | 61 + make/7.x-1.x-alpha10/build-petition.make | 20 - make/7.x-1.x-alpha10/drupal-org.make | 164 - make/7.x-1.x-auto/build-petition.make | 19 - make/7.x-1.x-auto/drupal-org.make | 129 - make/7.x-1.x/build-petition.make | 19 - make/7.x-1.x/drupal-org.make | 1 - modules/custom/README.txt | 1 - .../govdelivery/govdelivery.admin-reports.inc | 176 - .../custom/govdelivery/govdelivery.admin.inc | 336 -- .../custom/govdelivery/govdelivery.drush.inc | 333 -- modules/custom/govdelivery/govdelivery.info | 10 - .../custom/govdelivery/govdelivery.install | 101 - .../custom/govdelivery/govdelivery.mail.inc | 37 - modules/custom/govdelivery/govdelivery.module | 1030 ---- .../libraries/GovDeliverySubscriberAPI.php | 163 - .../govdelivery/libraries/odmService.php | 158 - .../govdelivery_subscribe.component.inc | 942 --- .../govdelivery_subscribe.info | 7 - .../govdelivery_subscribe.module | 75 - modules/custom/wh_core/wh_core.info | 16 - modules/custom/wh_core/wh_core.install | 648 --- modules/custom/wh_core/wh_core.js | 21 - modules/custom/wh_core/wh_core.module | 108 - modules/custom/wh_core/wh_core.rules.inc | 31 - modules/custom/wh_feedback/images/eagle.jpg | Bin 5856 -> 0 bytes .../images/feedback_btn_sprite.png | Bin 12842 -> 0 bytes modules/custom/wh_feedback/wh_feedback.css | 97 - modules/custom/wh_feedback/wh_feedback.info | 7 - modules/custom/wh_feedback/wh_feedback.js | 107 - modules/custom/wh_feedback/wh_feedback.module | 11 - .../wh_petition_reporting/css/counts.css | 14 - .../wh_petition_reporting/css/summary.css | 22 - .../wh_petition_reporting.hourly.inc | 259 - .../wh_petition_reporting.info | 11 - .../wh_petition_reporting.install | 59 - .../wh_petition_reporting.module | 60 - .../wh_petition_reporting.page.inc | 31 - .../wh_petition_reporting.summary.inc | 374 -- .../wh-petition-tool-homepage.tpl.php | 21 - .../wh-petition-tool-left-nav.tpl.php | 7 - .../wh_petition_tool.admin.inc | 33 - .../wh_petition_tool/wh_petition_tool.info | 7 - .../wh_petition_tool/wh_petition_tool.install | 26 - .../wh_petition_tool/wh_petition_tool.module | 592 -- .../wh_petitions/drush/wh_petitions.drush.inc | 42 - .../wh-petitions-by-the-numbers.tpl.php | 8 - .../wh-petitions-create-header.tpl.php | 14 - ...wh-petitions-display-list-petition.tpl.php | 49 - ...wh-petitions-display-petition-info.tpl.php | 68 - .../wh-petitions-display-signatures.tpl.php | 39 - .../wh-petitions-page-archived.tpl.php | 3 - .../wh-petitions-page-deleted.tpl.php | 6 - .../wh-petitions-page-open-petitions.tpl.php | 63 - .../wh-petitions-page-petition.tpl.php | 155 - .../wh-petitions-page-thank-you.tpl.php | 33 - .../wh-petitions-page-user-dashboard.tpl.php | 28 - .../wh_petitions/wh_petitions.admin.inc | 1420 ----- .../custom/wh_petitions/wh_petitions.admin.js | 85 - .../custom/wh_petitions/wh_petitions.cron.inc | 122 - .../custom/wh_petitions/wh_petitions.form.inc | 1417 ----- .../wh_petitions/wh_petitions.generate.inc | 250 - modules/custom/wh_petitions/wh_petitions.info | 21 - .../custom/wh_petitions/wh_petitions.module | 1490 ----- .../wh_petitions/wh_petitions.pages.inc | 1170 ---- .../wh_petitions/wh_petitions.tokens.inc | 45 - .../wh_profile_migrate/profile_migration.inc | 88 - .../wh_profile_migrate.info | 12 - .../wh_profile_migrate.module | 11 - .../wh-response-display-list-response.tpl.php | 9 - .../wh-response-page-responses.tpl.php | 61 - modules/custom/wh_response/wh_response.css | 25 - .../custom/wh_response/wh_response.form.inc | 180 - modules/custom/wh_response/wh_response.info | 8 - .../custom/wh_response/wh_response.install | 33 - modules/custom/wh_response/wh_response.js | 31 - modules/custom/wh_response/wh_response.module | 1047 ---- .../custom/wh_response/wh_response.pages.inc | 304 - .../wh_zipcodelookup/wh_zipcodelookup.info | 7 - .../wh_zipcodelookup/wh_zipcodelookup.install | 116 - .../wh_zipcodelookup/wh_zipcodelookup.js | 67 - .../wh_zipcodelookup/wh_zipcodelookup.module | 66 - modules/features/README.txt | 1 - ...itions_logintoboggan_settings.features.inc | 11 - .../petitions_logintoboggan_settings.info | 20 - .../petitions_logintoboggan_settings.module | 3 - ...tions_logintoboggan_settings.strongarm.inc | 87 - ...tions_user_registration.features.field.inc | 76 - .../petitions_user_registration.features.inc | 11 - .../petitions_user_registration.info | 13 - .../petitions_user_registration.module | 3 - ...tions_user_registration.rules_defaults.inc | 39 - .../petitions_user_registration.strongarm.inc | 24 - .../taxonomy_sync/taxonomy_sync.features.inc | 11 - .../taxonomy_sync.features.taxonomy.inc | 32 - .../taxonomy_sync.feeds_importer_default.inc | 73 - .../features/taxonomy_sync/taxonomy_sync.info | 12 - .../taxonomy_sync/taxonomy_sync.module | 3 - .../wh_contexts/wh_contexts.context.inc | 360 -- .../wh_contexts/wh_contexts.features.inc | 14 - modules/features/wh_contexts/wh_contexts.info | 18 - .../features/wh_contexts/wh_contexts.module | 3 - modules/features/wh_misc/wh_misc.features.inc | 11 - .../wh_misc.features.user_permission.inc | 584 -- .../wh_misc/wh_misc.features.user_role.inc | 82 - modules/features/wh_misc/wh_misc.info | 102 - modules/features/wh_misc/wh_misc.module | 3 - .../features/wh_misc/wh_misc.strongarm.inc | 31 - .../wh_petition_page.features.field.inc | 88 - .../wh_petition_page.features.inc | 28 - .../wh_petition_page.features.menu_custom.inc | 21 - .../wh_petition_page/wh_petition_page.info | 25 - .../wh_petition_page/wh_petition_page.module | 3 - .../wh_petition_page.strongarm.inc | 87 - .../wh_response_feature.features.field.inc | 927 --- .../wh_response_feature.features.filter.inc | 30 - .../wh_response_feature.features.inc | 62 - .../wh_response_feature.features.taxonomy.inc | 59 - .../wh_response_feature.info | 41 - .../wh_response_feature.module | 3 - .../wh_response_feature.strongarm.inc | 73 - .../wh_user_profile.features.field.inc | 644 --- .../wh_user_profile.features.inc | 28 - .../wh_user_profile/wh_user_profile.info | 18 - .../wh_user_profile/wh_user_profile.module | 3 - .../wh_user_profile.strongarm.inc | 17 - .../wh_user_ss_data.features.field.inc | 139 - .../wh_user_ss_data/wh_user_ss_data.info | 7 - .../wh_user_ss_data/wh_user_ss_data.module | 12 - petition.info | 42 - petition.install | 41 - petition.profile | 54 - petition.rebuild.sh | 4 - readme.md | 97 - selenium/README | 0 selenium/UserLoginTests.selenium.php | 26 - selenium/UserLogoutTests.selenium.php | 27 - selenium/UserPasswordTests.selenium.php | 26 - selenium/UserRegisterTests.selenium.php | 26 - selenium/UserTestsSuite.selenium.php | 17 - themes/petitions/404/README.txt | 6 - ...Azy16WmnnnWKxpexfgsAryolGGaX6yO3GWA5bU.css | 1 - ...XTcIGmFPRfGZOOTJ1xsEckXlqMhF53CkTgnOVA.css | 4 - ...zJ1732WoUaTDQQLeMLK2oENAymYX83JYwHtjVI.css | 17 - ...bdrKmruvnf0Qj7_bz5D-OzL4J_bQfKZBL-XOLs.css | 5 - ...hlMLrjr9xXAC0JufqSSch3oAbkZstSqYdc4uuck.js | 662 --- ...JpBzl-C3fHFnbYgAf6RlaKZx-UT7gKyX6DVTbUQ.js | 22 - ...NOxfaS-X1Byu1sqma0PUntrWUC16ms-blpiBy-0.js | 1100 ---- themes/petitions/404/page-not-found.php | 607 -- themes/petitions/css/ie6.css | 115 - themes/petitions/css/ie7.css | 99 - themes/petitions/css/style.css | 3455 ----------- themes/petitions/css/wh-components.css | 5095 ----------------- themes/petitions/css/wh-grid.css | 464 -- themes/petitions/css/wh-layout.css | 1336 ----- themes/petitions/css/wh-template.css | 73 - themes/petitions/favicon.ico | Bin 1406 -> 0 bytes themes/petitions/general/block.tpl.php | 12 - themes/petitions/general/forward.tpl.php | 21 - .../general/node--wh_petitions_page.tpl.php | 11 - .../general/node--wh_response.tpl.php | 56 - themes/petitions/img/MS-header-oira.jpg | Bin 28056 -> 0 bytes themes/petitions/img/MS-header-ondcp.jpg | Bin 13212 -> 0 bytes themes/petitions/img/ajax-loader.gif | Bin 1737 -> 0 bytes themes/petitions/img/arrow-blue-back.gif | Bin 49 -> 0 bytes themes/petitions/img/arrow-blue-next.gif | Bin 49 -> 0 bytes themes/petitions/img/arrow-hide.gif | Bin 48 -> 0 bytes themes/petitions/img/arrow-mc-next.gif | Bin 999 -> 0 bytes themes/petitions/img/arrow-mc-prev.gif | Bin 956 -> 0 bytes themes/petitions/img/arrow-pg-next.gif | Bin 53 -> 0 bytes themes/petitions/img/arrow-pg-prev.gif | Bin 53 -> 0 bytes themes/petitions/img/arrow-right.gif | Bin 49 -> 0 bytes themes/petitions/img/arrow-show.gif | Bin 49 -> 0 bytes themes/petitions/img/arrow-white-right.png | Bin 986 -> 0 bytes themes/petitions/img/arrow-white-up.gif | Bin 1344 -> 0 bytes themes/petitions/img/arrow-white-up.png | Bin 1125 -> 0 bytes themes/petitions/img/backgrounds/bg-body.gif | Bin 365 -> 0 bytes themes/petitions/img/backgrounds/bg-body.png | Bin 1062 -> 0 bytes .../img/backgrounds/bg-browse-mc.gif | Bin 222 -> 0 bytes .../bg-category-drop-left-edge.png | Bin 514 -> 0 bytes .../bg-category-drop-right-edge.png | Bin 1938 -> 0 bytes .../img/backgrounds/bg-contact-intro.jpg | Bin 2294 -> 0 bytes .../petitions/img/backgrounds/bg-dialog.png | Bin 118 -> 0 bytes .../img/backgrounds/bg-footer-no-bar.jpg | Bin 21098 -> 0 bytes .../img/backgrounds/bg-form-item.png | Bin 142 -> 0 bytes .../bg-hero-president-in-ghana.jpg | Bin 23346 -> 0 bytes .../img/backgrounds/bg-home-callout-trans.gif | Bin 620 -> 0 bytes .../img/backgrounds/bg-home-callout-trans.png | Bin 2015 -> 0 bytes .../img/backgrounds/bg-home-detail-col.gif | Bin 166 -> 0 bytes .../img/backgrounds/bg-home-live-stream.png | Bin 2460 -> 0 bytes .../img/backgrounds/bg-home-num-divide.png | Bin 314 -> 0 bytes .../img/backgrounds/bg-home-title-trans.png | Bin 44313 -> 0 bytes .../img/backgrounds/bg-home-title.png | Bin 44313 -> 0 bytes .../img/backgrounds/bg-home-top-edge.png | Bin 2690 -> 0 bytes .../petitions/img/backgrounds/bg-home-top.jpg | Bin 31106 -> 0 bytes .../img/backgrounds/bg-home-two-col.png | Bin 2859 -> 0 bytes .../img/backgrounds/bg-landing-top.jpg | Bin 16183 -> 0 bytes .../backgrounds/bg-live-stream-callout.png | Bin 154 -> 0 bytes .../img/backgrounds/bg-main-no-nav.jpg | Bin 55229 -> 0 bytes .../img/backgrounds/bg-main-one-ie-1.jpg | Bin 58875 -> 0 bytes .../img/backgrounds/bg-main-one-ie.jpg | Bin 58958 -> 0 bytes .../img/backgrounds/bg-main-one-ie6.jpg | Bin 48525 -> 0 bytes .../img/backgrounds/bg-main-one-ie8.jpg | Bin 61514 -> 0 bytes .../bg-main-one-repeat-no-shadow.jpg | Bin 1331 -> 0 bytes .../img/backgrounds/bg-main-one-repeat.jpg | Bin 478 -> 0 bytes .../petitions/img/backgrounds/bg-main-one.jpg | Bin 48463 -> 0 bytes .../backgrounds/bg-ms-breadcrumb-orange.jpg | Bin 2075 -> 0 bytes .../img/backgrounds/bg-ms-breadcrumb.png | Bin 34831 -> 0 bytes .../img/backgrounds/bg-ms-detail.jpg | Bin 6558 -> 0 bytes .../petitions/img/backgrounds/bg-ms-nav.jpg | Bin 3311 -> 0 bytes .../petitions/img/backgrounds/bg-ms-ondcp.jpg | Bin 36813 -> 0 bytes .../img/backgrounds/bg-ms-open-title.jpg | Bin 1065 -> 0 bytes .../img/backgrounds/bg-ms-quote-close.gif | Bin 574 -> 0 bytes .../img/backgrounds/bg-ms-quote-open.gif | Bin 571 -> 0 bytes .../petitions/img/backgrounds/bg-ms-title.jpg | Bin 13651 -> 0 bytes .../img/backgrounds/bg-nav-featured-left.png | Bin 7292 -> 0 bytes .../img/backgrounds/bg-nav-featured-right.png | Bin 4314 -> 0 bytes .../backgrounds/bg-nav-left-edge-blank.png | Bin 3053 -> 0 bytes .../backgrounds/bg-nav-left-edge-trans.png | Bin 3197 -> 0 bytes .../backgrounds/bg-nav-right-edge-trans.png | Bin 6158 -> 0 bytes .../backgrounds/bg-nav-right-edge-trans2.png | Bin 5953 -> 0 bytes .../img/backgrounds/bg-ogi-featured.jpg | Bin 6306 -> 0 bytes .../img/backgrounds/bg-pag-active.gif | Bin 418 -> 0 bytes .../img/backgrounds/bg-pag-active2.gif | Bin 433 -> 0 bytes .../img/backgrounds/bg-pag-active3.gif | Bin 445 -> 0 bytes .../img/backgrounds/bg-photo-list-active.gif | Bin 56 -> 0 bytes .../img/backgrounds/bg-photo-overlay-old.png | Bin 130 -> 0 bytes .../img/backgrounds/bg-photo-overlay.png | Bin 115 -> 0 bytes .../img/backgrounds/bg-save-vote.jpg | Bin 5786 -> 0 bytes .../img/backgrounds/bg-sort-active.gif | Bin 568 -> 0 bytes .../img/backgrounds/bg-sort-tab-active.gif | Bin 1175 -> 0 bytes .../img/backgrounds/bg-star-required.gif | Bin 538 -> 0 bytes .../petitions/img/backgrounds/bg-textarea.png | Bin 144 -> 0 bytes .../img/backgrounds/bg-title-fade-trans.png | Bin 1082 -> 0 bytes .../img/backgrounds/bg-title-fade-white.gif | Bin 663 -> 0 bytes .../img/backgrounds/bg-title-fade.gif | Bin 976 -> 0 bytes .../img/backgrounds/bg-title-fade.png | Bin 457 -> 0 bytes .../img/backgrounds/bg-title-iga.jpg | Bin 25390 -> 0 bytes .../img/backgrounds/bg-title-midclass.jpg | Bin 25343 -> 0 bytes .../bg-title-stay-connected-trans.png | Bin 6141 -> 0 bytes .../backgrounds/bg-title-stay-connected.png | Bin 6141 -> 0 bytes .../img/backgrounds/bg-title-wh-live.png | Bin 2723 -> 0 bytes .../img/backgrounds/bg-top-edge-no-left.png | Bin 2054 -> 0 bytes .../petitions/img/backgrounds/bg-top-edge.png | Bin 2987 -> 0 bytes .../img/backgrounds/bg-topnav-secondary01.png | Bin 341 -> 0 bytes .../img/backgrounds/bg-tout-blog.png | Bin 35184 -> 0 bytes .../petitions/img/backgrounds/bg-tout-cbb.png | Bin 19182 -> 0 bytes .../img/backgrounds/bg-tout-drug-facts.jpg | Bin 2234 -> 0 bytes .../backgrounds/bg-tout-fed-web-cookie.png | Bin 7347 -> 0 bytes .../img/backgrounds/bg-tout-fiscal.png | Bin 9417 -> 0 bytes .../img/backgrounds/bg-tout-flu-btm.jpg | Bin 2059 -> 0 bytes .../img/backgrounds/bg-tout-flu-tile.jpg | Bin 392 -> 0 bytes .../img/backgrounds/bg-tout-flu-top.jpg | Bin 17885 -> 0 bytes .../img/backgrounds/bg-tout-fy-2010.png | Bin 8712 -> 0 bytes .../bg-tout-latest-news-updates.png | Bin 39209 -> 0 bytes .../img/backgrounds/bg-tout-letters.jpg | Bin 16496 -> 0 bytes .../img/backgrounds/bg-tout-new-era.png | Bin 9355 -> 0 bytes .../img/backgrounds/bg-tout-open-gov.png | Bin 8040 -> 0 bytes .../img/backgrounds/bg-tout-opl-ope.jpg | Bin 10684 -> 0 bytes .../img/backgrounds/bg-tout-photo-gallery.jpg | Bin 20977 -> 0 bytes .../img/backgrounds/bg-tout-recovery.png | Bin 10076 -> 0 bytes .../petitions/img/backgrounds/bg-tout-sm.png | Bin 172 -> 0 bytes .../bg-tout-state-and-local-info.png | Bin 15500 -> 0 bytes .../backgrounds/bg-tout-stay-con-email.png | Bin 8436 -> 0 bytes .../backgrounds/bg-tout-stay-connected.png | Bin 4619 -> 0 bytes .../backgrounds/bg-tout-strong-mid-class.png | Bin 8983 -> 0 bytes .../img/backgrounds/bg-tout-wh-blogs.png | Bin 6548 -> 0 bytes .../img/backgrounds/bg-video-controls.gif | Bin 2618 -> 0 bytes .../petitions/img/backgrounds/bkg-podcast.png | Bin 172 -> 0 bytes themes/petitions/img/backgrounds/bullet.gif | Bin 103 -> 0 bytes .../petitions/img/backgrounds/ms-hero-1.jpg | Bin 23003 -> 0 bytes .../petitions/img/backgrounds/ms-hero-2.jpg | Bin 56853 -> 0 bytes .../img/backgrounds/ogi-rule-301.gif | Bin 61 -> 0 bytes .../petitions/img/bg-comment-bubble-btm.png | Bin 1755 -> 0 bytes .../petitions/img/bg-comment-bubble-mid.png | Bin 973 -> 0 bytes .../petitions/img/bg-comment-bubble-top.png | Bin 1303 -> 0 bytes themes/petitions/img/bg-delete-modal.png | Bin 2175 -> 0 bytes themes/petitions/img/bg-divide.png | Bin 177 -> 0 bytes themes/petitions/img/bg-event-arrow-round.gif | Bin 2042 -> 0 bytes themes/petitions/img/bg-event-arrow-round.png | Bin 2214 -> 0 bytes themes/petitions/img/bg-event-entry-on.png | Bin 929 -> 0 bytes themes/petitions/img/bg-footer.jpg | Bin 19421 -> 0 bytes themes/petitions/img/bg-fuz-divide.png | Bin 955 -> 0 bytes themes/petitions/img/bg-fuz-event-on.png | Bin 958 -> 0 bytes themes/petitions/img/bg-fuz-event.png | Bin 973 -> 0 bytes themes/petitions/img/bg-fuz-line-bar.png | Bin 208 -> 0 bytes themes/petitions/img/bg-fuz-signin.png | Bin 1614 -> 0 bytes themes/petitions/img/bg-hdr-text.gif | Bin 5616 -> 0 bytes themes/petitions/img/bg-hdr-text.png | Bin 6356 -> 0 bytes themes/petitions/img/bg-how-why-left-nav.png | Bin 7577 -> 0 bytes themes/petitions/img/bg-input-text.gif | Bin 1124 -> 0 bytes themes/petitions/img/bg-int-col.gif | Bin 190 -> 0 bytes themes/petitions/img/bg-issues-drop.png | Bin 3858 -> 0 bytes themes/petitions/img/bg-issues-filter-btm.png | Bin 1362 -> 0 bytes themes/petitions/img/bg-issues-filter-mid.png | Bin 1000 -> 0 bytes themes/petitions/img/bg-issues-filter-top.png | Bin 2007 -> 0 bytes themes/petitions/img/bg-left-nav-active.png | Bin 1802 -> 0 bytes themes/petitions/img/bg-load-next-sig.gif | Bin 1805 -> 0 bytes themes/petitions/img/bg-main-one-repeat.jpg | Bin 478 -> 0 bytes themes/petitions/img/bg-main-one.jpg | Bin 48463 -> 0 bytes themes/petitions/img/bg-main.jpg | Bin 50137 -> 0 bytes themes/petitions/img/bg-mc-browse.jpg | Bin 1746 -> 0 bytes themes/petitions/img/bg-mc.gif | Bin 425 -> 0 bytes themes/petitions/img/bg-msg-bar-blue.gif | Bin 12700 -> 0 bytes themes/petitions/img/bg-msg-bar-red.gif | Bin 12235 -> 0 bytes themes/petitions/img/bg-nav-event.gif | Bin 4262 -> 0 bytes themes/petitions/img/bg-nav-pet.gif | Bin 17224 -> 0 bytes themes/petitions/img/bg-nav-signin.gif | Bin 4458 -> 0 bytes themes/petitions/img/bg-num-count-long.gif | Bin 1842 -> 0 bytes themes/petitions/img/bg-num-count.gif | Bin 1769 -> 0 bytes themes/petitions/img/bg-page-no-nav.jpg | Bin 25523 -> 0 bytes themes/petitions/img/bg-petition-hdr.png | Bin 107590 -> 0 bytes .../petitions/img/bg-petitions-action-bar.png | Bin 34722 -> 0 bytes themes/petitions/img/bg-photo-list.jpg | Bin 1594 -> 0 bytes .../img/bg-report-petition-overlay.png | Bin 2902 -> 0 bytes themes/petitions/img/bg-response-call.gif | Bin 1288 -> 0 bytes themes/petitions/img/bg-rightrail-blue.jpg | Bin 13380 -> 0 bytes themes/petitions/img/bg-rightrail.jpg | Bin 13538 -> 0 bytes themes/petitions/img/bg-search-drop.png | Bin 2726 -> 0 bytes themes/petitions/img/bg-sig.gif | Bin 24867 -> 0 bytes themes/petitions/img/bg-signin.jpg | Bin 8450 -> 0 bytes themes/petitions/img/bg-subftr.gif | Bin 7113 -> 0 bytes themes/petitions/img/bg-subftr.jpg | Bin 2806 -> 0 bytes themes/petitions/img/bg-subhdr.jpg | Bin 1637 -> 0 bytes themes/petitions/img/bg-textarea.png | Bin 133 -> 0 bytes themes/petitions/img/bg-tile.jpg | Bin 302 -> 0 bytes themes/petitions/img/bg-utility-bar.gif | Bin 1313 -> 0 bytes themes/petitions/img/bg-utility-block.png | Bin 1015 -> 0 bytes themes/petitions/img/bg-we-petition.gif | Bin 1371 -> 0 bytes .../petitions/img/bg-why-signin-overlay.png | Bin 2570 -> 0 bytes themes/petitions/img/bg_int_col.gif | Bin 557 -> 0 bytes themes/petitions/img/bg_main.jpg | Bin 55295 -> 0 bytes themes/petitions/img/bg_rightrail.jpg | Bin 13538 -> 0 bytes themes/petitions/img/bg_subhdr.jpg | Bin 1637 -> 0 bytes themes/petitions/img/bg_tile.jpg | Bin 302 -> 0 bytes themes/petitions/img/blank.gif | Bin 48 -> 0 bytes themes/petitions/img/block-menu-sprite.png | Bin 24228 -> 0 bytes themes/petitions/img/blog_breadcrum.jpg | Bin 6531 -> 0 bytes themes/petitions/img/blog_header.jpg | Bin 8147 -> 0 bytes themes/petitions/img/blog_slide_arrows.png | Bin 1204 -> 0 bytes .../petitions/img/blog_slide_arrows_flip.png | Bin 441 -> 0 bytes themes/petitions/img/blog_slide_dots.png | Bin 1348 -> 0 bytes .../img/blue-gradient-block-header.png | Bin 299 -> 0 bytes themes/petitions/img/btn-categories.gif | Bin 1395 -> 0 bytes themes/petitions/img/btn-search-sm.gif | Bin 735 -> 0 bytes themes/petitions/img/btn-search.gif | Bin 1621 -> 0 bytes themes/petitions/img/btn_search.gif | Bin 1621 -> 0 bytes themes/petitions/img/bullet-green-arrow.gif | Bin 632 -> 0 bytes themes/petitions/img/bullet-green-arrow.png | Bin 706 -> 0 bytes themes/petitions/img/bullet-white-arrow.png | Bin 578 -> 0 bytes themes/petitions/img/bullet.gif | Bin 103 -> 0 bytes .../img/button-delete-my-petition.gif | Bin 8081 -> 0 bytes .../petitions/img/button-edit-my-petition.gif | Bin 7288 -> 0 bytes .../button-edit-profile-change-password.gif | Bin 3536 -> 0 bytes themes/petitions/img/button-find-out-more.png | Bin 7567 -> 0 bytes themes/petitions/img/button-go-search.gif | Bin 2232 -> 0 bytes .../img/button-publish-my-petition.gif | Bin 11283 -> 0 bytes themes/petitions/img/button-save-changes.gif | Bin 2912 -> 0 bytes ...ton-save-my-petition-and-publish-later.gif | Bin 10064 -> 0 bytes .../img/buttons/arrow-mc-next-sprite.gif | Bin 2900 -> 0 bytes .../img/buttons/arrow-mc-prev-sprite.gif | Bin 2888 -> 0 bytes .../petitions/img/buttons/btn-categories.gif | Bin 2446 -> 0 bytes .../petitions/img/buttons/btn-change-pass.png | Bin 5182 -> 0 bytes .../img/buttons/btn-drugfacts-controls.gif | Bin 1647 -> 0 bytes .../petitions/img/buttons/btn-exit-dialog.gif | Bin 275 -> 0 bytes .../img/buttons/btn-gold-download-pdf.gif | Bin 4512 -> 0 bytes .../img/buttons/btn-gold-more-info.gif | Bin 4484 -> 0 bytes .../img/buttons/btn-gold-read-blog.gif | Bin 4214 -> 0 bytes .../img/buttons/btn-gold-read-report.gif | Bin 4394 -> 0 bytes .../img/buttons/btn-gold-read-the-report.gif | Bin 4394 -> 0 bytes .../petitions/img/buttons/btn-gold-signup.gif | Bin 3592 -> 0 bytes .../img/buttons/btn-join-discussion-blue.gif | Bin 4613 -> 0 bytes .../img/buttons/btn-join-discussion-grey.gif | Bin 4876 -> 0 bytes .../img/buttons/btn-learn-more-blue.gif | Bin 3654 -> 0 bytes .../img/buttons/btn-learn-more-blue.png | Bin 2210 -> 0 bytes .../img/buttons/btn-learn-more-grey.gif | Bin 3780 -> 0 bytes .../img/buttons/btn-learn-more-grey.png | Bin 1576 -> 0 bytes .../petitions/img/buttons/btn-listen-live.gif | Bin 1854 -> 0 bytes .../petitions/img/buttons/btn-mc-controls.png | Bin 3384 -> 0 bytes .../img/buttons/btn-mc-controls1.gif | Bin 3328 -> 0 bytes .../img/buttons/btn-mc-controls1.png | Bin 2891 -> 0 bytes .../img/buttons/btn-mc-pause-hover.png | Bin 2387 -> 0 bytes themes/petitions/img/buttons/btn-mc-pause.png | Bin 2327 -> 0 bytes .../img/buttons/btn-mc-photoplay.gif | Bin 2006 -> 0 bytes .../img/buttons/btn-mc-play-hover.png | Bin 2413 -> 0 bytes themes/petitions/img/buttons/btn-mc-play.png | Bin 2366 -> 0 bytes .../img/buttons/btn-more-info-blue.gif | Bin 4361 -> 0 bytes .../img/buttons/btn-more-info-grey.gif | Bin 4616 -> 0 bytes .../img/buttons/btn-next-back-vote.gif | Bin 3081 -> 0 bytes .../img/buttons/btn-next-grey-sprite.gif | Bin 2501 -> 0 bytes themes/petitions/img/buttons/btn-next.gif | Bin 999 -> 0 bytes .../img/buttons/btn-phase-completed.gif | Bin 1554 -> 0 bytes .../img/buttons/btn-podcast-audio.png | Bin 637 -> 0 bytes .../img/buttons/btn-podcast-itunes.png | Bin 1591 -> 0 bytes .../petitions/img/buttons/btn-podcast-rss.png | Bin 1480 -> 0 bytes .../img/buttons/btn-podcast-video.png | Bin 538 -> 0 bytes .../img/buttons/btn-previous-grey-sprite.gif | Bin 2915 -> 0 bytes themes/petitions/img/buttons/btn-previous.gif | Bin 1557 -> 0 bytes .../img/buttons/btn-read-remarks-blue.gif | Bin 4467 -> 0 bytes .../img/buttons/btn-read-remarks-grey.gif | Bin 4695 -> 0 bytes .../img/buttons/btn-read-the-exec-order.gif | Bin 4961 -> 0 bytes .../petitions/img/buttons/btn-search-blue.png | Bin 1453 -> 0 bytes .../img/buttons/btn-search-grey-sprite.gif | Bin 2912 -> 0 bytes .../petitions/img/buttons/btn-search-sm.gif | Bin 1839 -> 0 bytes themes/petitions/img/buttons/btn-search.gif | Bin 1621 -> 0 bytes themes/petitions/img/buttons/btn-show-all.gif | Bin 3969 -> 0 bytes .../img/buttons/btn-strongmid-about.jpg | Bin 5391 -> 0 bytes .../img/buttons/btn-strongmid-read-report.jpg | Bin 11452 -> 0 bytes themes/petitions/img/buttons/btn-submit.png | Bin 1262 -> 0 bytes .../img/buttons/btn-view-gallery-blue.gif | Bin 4315 -> 0 bytes .../img/buttons/btn-view-gallery-grey.gif | Bin 4526 -> 0 bytes .../img/buttons/btn-view-gallery.png | Bin 4601 -> 0 bytes .../petitions/img/buttons/btn-watch-live.gif | Bin 2152 -> 0 bytes .../img/buttons/btn-watch-stream-blue.gif | Bin 5015 -> 0 bytes .../img/buttons/btn-watch-stream-grey.gif | Bin 3863 -> 0 bytes .../img/buttons/btn-watch-the-video.gif | Bin 4526 -> 0 bytes .../img/buttons/btn-watch-video-blue.gif | Bin 4424 -> 0 bytes .../img/buttons/btn-watch-video-grey.gif | Bin 4602 -> 0 bytes .../img/buttons/btn_view_results.gif | Bin 2135 -> 0 bytes themes/petitions/img/buttons/inno-next.gif | Bin 1165 -> 0 bytes themes/petitions/img/buttons/inno-prev.gif | Bin 1171 -> 0 bytes themes/petitions/img/champs_nav_int_bg.jpg | Bin 5566 -> 0 bytes themes/petitions/img/change_header.gif | Bin 11093 -> 0 bytes themes/petitions/img/change_serve_gov.jpg | Bin 41488 -> 0 bytes .../petitions/img/change_serve_gov_button.jpg | Bin 3164 -> 0 bytes themes/petitions/img/circle-arrow1.png | Bin 1502 -> 0 bytes themes/petitions/img/circle-arrow2.png | Bin 1458 -> 0 bytes themes/petitions/img/circle-arrow3.png | Bin 1382 -> 0 bytes themes/petitions/img/clear.gif | Bin 43 -> 0 bytes themes/petitions/img/contact-banner.png | Bin 43035 -> 0 bytes themes/petitions/img/contact-menu-bg.png | Bin 16749 -> 0 bytes themes/petitions/img/contact-us-main-hero.jpg | Bin 81989 -> 0 bytes .../petitions/img/contact/bg-modal-bottom.png | Bin 752 -> 0 bytes themes/petitions/img/contact/bg-modal-mid.png | Bin 184 -> 0 bytes themes/petitions/img/contact/bg-modal-top.png | Bin 1349 -> 0 bytes themes/petitions/img/contact/bkgdBox-24.png | Bin 2825 -> 0 bytes themes/petitions/img/contact/bkgdBox-8.png | Bin 1709 -> 0 bytes .../petitions/img/contact/contactIcon-blk.png | Bin 289 -> 0 bytes .../petitions/img/contact/contactIcon-blu.png | Bin 268 -> 0 bytes .../petitions/img/contact/contactIcon-lt.png | Bin 262 -> 0 bytes .../img/contact/eagleThankYou-gold.png | Bin 5856 -> 0 bytes .../petitions/img/contact/emailIcon-blk.png | Bin 507 -> 0 bytes .../petitions/img/contact/emailIcon-blu.png | Bin 507 -> 0 bytes themes/petitions/img/contact/emailIcon-lt.png | Bin 355 -> 0 bytes .../img/contact/pointerTriangle-24.png | Bin 680 -> 0 bytes .../img/contact/pointerTriangle-8.png | Bin 616 -> 0 bytes themes/petitions/img/contact/sealThankYou.png | Bin 19431 -> 0 bytes themes/petitions/img/data-gov2.jpg | Bin 26551 -> 0 bytes themes/petitions/img/divide-green-fuz.gif | Bin 1144 -> 0 bytes themes/petitions/img/facebook_bubble.gif | Bin 716 -> 0 bytes .../petitions/img/fb_share_we_the_people.png | Bin 29918 -> 0 bytes themes/petitions/img/featured_petitions.jpg | Bin 8208 -> 0 bytes themes/petitions/img/featured_tax_receipt.jpg | Bin 9526 -> 0 bytes themes/petitions/img/fhs-indexes.png | Bin 4988 -> 0 bytes themes/petitions/img/fhs-nav.png | Bin 7564 -> 0 bytes themes/petitions/img/find-out.png | Bin 3167 -> 0 bytes themes/petitions/img/graphic-417x164.jpg | Bin 7652 -> 0 bytes themes/petitions/img/grey-title-block-bg.png | Bin 274 -> 0 bytes themes/petitions/img/hdr-browse.gif | Bin 898 -> 0 bytes themes/petitions/img/hdr-usa-flag.gif | Bin 1107 -> 0 bytes themes/petitions/img/home/homeslider.png | Bin 168573 -> 0 bytes themes/petitions/img/home/homesprite.png | Bin 70368 -> 0 bytes themes/petitions/img/how-to-numbers.gif | Bin 2122 -> 0 bytes themes/petitions/img/icon-clock.gif | Bin 1349 -> 0 bytes themes/petitions/img/icon-facebook.gif | Bin 1136 -> 0 bytes themes/petitions/img/icon-flickr.gif | Bin 368 -> 0 bytes themes/petitions/img/icon-gallery.gif | Bin 349 -> 0 bytes themes/petitions/img/icon-itunes.gif | Bin 394 -> 0 bytes themes/petitions/img/icon-myspace.gif | Bin 413 -> 0 bytes themes/petitions/img/icon-openid.gif | Bin 1265 -> 0 bytes themes/petitions/img/icon-photo.gif | Bin 349 -> 0 bytes themes/petitions/img/icon-rss-grey.gif | Bin 385 -> 0 bytes themes/petitions/img/icon-rss.gif | Bin 616 -> 0 bytes themes/petitions/img/icon-search1.gif | Bin 338 -> 0 bytes themes/petitions/img/icon-share.gif | Bin 371 -> 0 bytes themes/petitions/img/icon-twitter.gif | Bin 363 -> 0 bytes themes/petitions/img/icon-video.gif | Bin 1049 -> 0 bytes themes/petitions/img/icon-vimeo.gif | Bin 520 -> 0 bytes themes/petitions/img/icon-youtube.gif | Bin 1122 -> 0 bytes themes/petitions/img/icon_search1.gif | Bin 338 -> 0 bytes themes/petitions/img/icons-filter-view.gif | Bin 2514 -> 0 bytes .../petitions/img/icons/icon-audio-home.gif | Bin 568 -> 0 bytes themes/petitions/img/icons/icon-audio-mc.gif | Bin 1057 -> 0 bytes themes/petitions/img/icons/icon-close.gif | Bin 275 -> 0 bytes .../img/icons/icon-download-dark.gif | Bin 187 -> 0 bytes .../petitions/img/icons/icon-facebook-mc.gif | Bin 1858 -> 0 bytes themes/petitions/img/icons/icon-other-mc.gif | Bin 1508 -> 0 bytes themes/petitions/img/icons/icon-rss.gif | Bin 616 -> 0 bytes themes/petitions/img/icons/icon-search1.gif | Bin 338 -> 0 bytes themes/petitions/img/icons/icon-share.gif | Bin 371 -> 0 bytes .../petitions/img/icons/icon-video-home.gif | Bin 325 -> 0 bytes themes/petitions/img/icons/icon-warning.gif | Bin 1054 -> 0 bytes themes/petitions/img/icons/icon_search1.gif | Bin 338 -> 0 bytes .../img/icons/icons-get-connected.gif | Bin 6363 -> 0 bytes .../img/icons/icons-get-connected.png | Bin 13857 -> 0 bytes themes/petitions/img/inPerformance_hero.jpg | Bin 55920 -> 0 bytes themes/petitions/img/line-gr.gif | Bin 1095 -> 0 bytes themes/petitions/img/line-mid.gif | Bin 1095 -> 0 bytes themes/petitions/img/live-controls.gif | Bin 1994 -> 0 bytes themes/petitions/img/loadingAnimation.gif | Bin 5886 -> 0 bytes .../img/login/user_account_account_info.png | Bin 3013 -> 0 bytes .../login/user_account_create_account_btn.png | Bin 11054 -> 0 bytes .../img/login/user_account_login_btn.png | Bin 6237 -> 0 bytes .../login/user_account_openidid_google.png | Bin 3348 -> 0 bytes .../login/user_account_openidid_verisign.png | Bin 4249 -> 0 bytes .../login/user_account_petitions_header.jpg | Bin 25041 -> 0 bytes .../login/user_account_save_changes_btn.png | Bin 9824 -> 0 bytes .../img/login/user_account_submit_btn.png | Bin 6352 -> 0 bytes .../petitions/img/login/user_account_tabs.png | Bin 13558 -> 0 bytes themes/petitions/img/main_nav_cant_wait.jpg | Bin 8442 -> 0 bytes themes/petitions/img/maintenance.jpg | Bin 185376 -> 0 bytes .../petitions/img/menu_interactive_tour.jpg | Bin 8670 -> 0 bytes themes/petitions/img/menu_visitor_records.jpg | Bin 13632 -> 0 bytes themes/petitions/img/ms-quote-01.gif | Bin 13477 -> 0 bytes themes/petitions/img/ms-strongmid.jpg | Bin 13223 -> 0 bytes themes/petitions/img/ms-title-001.jpg | Bin 21824 -> 0 bytes .../img/ms-title-office-pa-engage.jpg | Bin 21155 -> 0 bytes themes/petitions/img/my-petitions-actions.png | Bin 4541 -> 0 bytes themes/petitions/img/nav-pet.gif | Bin 33204 -> 0 bytes themes/petitions/img/nav-sprite-ie.gif | Bin 12747 -> 0 bytes themes/petitions/img/nav-sprite.gif | Bin 12756 -> 0 bytes themes/petitions/img/nav-sprite2.gif | Bin 17655 -> 0 bytes themes/petitions/img/nav_sprite.gif | Bin 12962 -> 0 bytes themes/petitions/img/oira_quote.jpg | Bin 49946 -> 0 bytes themes/petitions/img/openshareicon-14x14.gif | Bin 1023 -> 0 bytes themes/petitions/img/openshareicon-14x14.png | Bin 3652 -> 0 bytes themes/petitions/img/or.gif | Bin 1379 -> 0 bytes themes/petitions/img/pass_verify_header.png | Bin 102334 -> 0 bytes .../img/petitions_landing_btns_0.png | Bin 33735 -> 0 bytes .../petitions/img/petitions_landing_hero.jpg | Bin 54182 -> 0 bytes .../img/petitions_landing_rightrail.png | Bin 6730 -> 0 bytes .../img/petitions_landing_wh_content_01.jpg | Bin 18033 -> 0 bytes .../img/petitions_landing_wh_content_02.jpg | Bin 16356 -> 0 bytes .../petitions/img/petitions_social_icons.jpg | Bin 2923 -> 0 bytes themes/petitions/img/petitions_tw_landing.png | Bin 634 -> 0 bytes .../img/petitions_video_thumb_new.jpg | Bin 32733 -> 0 bytes .../petitions/img/petitionslanding_arrow.png | Bin 200 -> 0 bytes themes/petitions/img/photo-75x40.jpg | Bin 2779 -> 0 bytes themes/petitions/img/photo-770x435.jpg | Bin 147691 -> 0 bytes themes/petitions/img/photo-775x435.jpg | Bin 149864 -> 0 bytes themes/petitions/img/photo-pg-off.gif | Bin 80 -> 0 bytes themes/petitions/img/photo-pg-on.gif | Bin 108 -> 0 bytes themes/petitions/img/photo133x95.jpg | Bin 7940 -> 0 bytes themes/petitions/img/photo325x190.jpg | Bin 27543 -> 0 bytes themes/petitions/img/photo486x287.jpg | Bin 74117 -> 0 bytes themes/petitions/img/photos/biden-123.jpg | Bin 95016 -> 0 bytes themes/petitions/img/photos/hhs.jpg | Bin 123383 -> 0 bytes themes/petitions/img/photos/hhs2.jpg | Bin 136318 -> 0 bytes .../img/photos/livevideo-640x360.jpg | Bin 55627 -> 0 bytes .../petitions/img/photos/notredame-photo.jpg | Bin 48877 -> 0 bytes themes/petitions/img/photos/obama-dog.jpg | Bin 144658 -> 0 bytes themes/petitions/img/photos/oira.jpg | Bin 35739 -> 0 bytes themes/petitions/img/photos/photo-160x90.jpg | Bin 12616 -> 0 bytes themes/petitions/img/photos/photo-216x121.jpg | Bin 9219 -> 0 bytes themes/petitions/img/photos/photo-216x123.jpg | Bin 9287 -> 0 bytes themes/petitions/img/photos/photo-264x170.jpg | Bin 17068 -> 0 bytes themes/petitions/img/photos/photo-265x170.jpg | Bin 17175 -> 0 bytes themes/petitions/img/photos/photo-475x290.jpg | Bin 44058 -> 0 bytes themes/petitions/img/photos/photo-536x346.jpg | Bin 61014 -> 0 bytes themes/petitions/img/photos/photo-536x356.jpg | Bin 72884 -> 0 bytes themes/petitions/img/photos/photo-615x345.jpg | Bin 109135 -> 0 bytes themes/petitions/img/photos/photo-75x40.jpg | Bin 2779 -> 0 bytes themes/petitions/img/photos/photo-770x435.jpg | Bin 147691 -> 0 bytes themes/petitions/img/photos/photo-775x435.jpg | Bin 149864 -> 0 bytes .../petitions/img/photos/photo-obama124.jpg | Bin 106106 -> 0 bytes .../petitions/img/photos/photo-obama125.jpg | Bin 61096 -> 0 bytes themes/petitions/img/photos/video-205x115.gif | Bin 232 -> 0 bytes themes/petitions/img/photos/video-260x180.jpg | Bin 19964 -> 0 bytes themes/petitions/img/photos/video-456x281.jpg | Bin 43085 -> 0 bytes themes/petitions/img/photos/video-457x281.jpg | Bin 43367 -> 0 bytes themes/petitions/img/photos/video-536.jpg | Bin 51572 -> 0 bytes themes/petitions/img/photos/video-640x360.jpg | Bin 66879 -> 0 bytes themes/petitions/img/photos/video-grad.jpg | Bin 82824 -> 0 bytes .../petitions/img/photos/video-obama123.jpg | Bin 42300 -> 0 bytes themes/petitions/img/plus.gif | Bin 146 -> 0 bytes themes/petitions/img/properties_fade.png | Bin 7343 -> 0 bytes themes/petitions/img/regulations-gov2.jpg | Bin 22502 -> 0 bytes themes/petitions/img/right-divide.gif | Bin 1014 -> 0 bytes themes/petitions/img/right_divide.gif | Bin 976 -> 0 bytes themes/petitions/img/scrollable/left.png | Bin 906 -> 0 bytes themes/petitions/img/scrollable/navigator.gif | Bin 118 -> 0 bytes themes/petitions/img/scrollable/navigator.png | Bin 325 -> 0 bytes themes/petitions/img/scrollable/right.png | Bin 946 -> 0 bytes themes/petitions/img/seal-sample-white.gif | Bin 4337 -> 0 bytes themes/petitions/img/seal-sample.gif | Bin 4398 -> 0 bytes themes/petitions/img/sftr-whgov.gif | Bin 1631 -> 0 bytes themes/petitions/img/soc-media-graphics.gif | Bin 6289 -> 0 bytes themes/petitions/img/sotuthumb.jpg | Bin 25778 -> 0 bytes themes/petitions/img/sprite-bg.png | Bin 118645 -> 0 bytes .../petitions/img/sprite-buttons-signin.gif | Bin 5339 -> 0 bytes themes/petitions/img/sprite-buttons.png | Bin 254174 -> 0 bytes themes/petitions/img/sprite-circle-icons.png | Bin 3245 -> 0 bytes themes/petitions/img/sprite-old.gif | Bin 40464 -> 0 bytes themes/petitions/img/sprite.gif | Bin 39465 -> 0 bytes themes/petitions/img/tag-petition-status.png | Bin 8460 -> 0 bytes themes/petitions/img/tb-mac-overlay.png | Bin 136 -> 0 bytes themes/petitions/img/textarea-arrow.gif | Bin 352 -> 0 bytes themes/petitions/img/thank-you-bg.png | Bin 3870 -> 0 bytes .../petitions/img/thickbox/tb-btn-close.gif | Bin 599 -> 0 bytes themes/petitions/img/thickbox/tb-emblem.gif | Bin 2432 -> 0 bytes .../petitions/img/thickbox/tb-mac-overlay.png | Bin 136 -> 0 bytes .../img/timeline/bg-timeline-stage.png | Bin 18992 -> 0 bytes themes/petitions/img/timeline/dot-sprite.gif | Bin 420 -> 0 bytes themes/petitions/img/timeline/tip-body.png | Bin 1015 -> 0 bytes themes/petitions/img/timeline/tip-pointer.png | Bin 543 -> 0 bytes themes/petitions/img/timeline/tip-shadow.png | Bin 4263 -> 0 bytes themes/petitions/img/tip-arrow-down.gif | Bin 1240 -> 0 bytes themes/petitions/img/tip-arrow-up.gif | Bin 1240 -> 0 bytes themes/petitions/img/tip-arrow.gif | Bin 184 -> 0 bytes themes/petitions/img/tweet_retweet.png | Bin 1345 -> 0 bytes .../petitions/img/utility-tab-events-on.png | Bin 1471 -> 0 bytes themes/petitions/img/utility-tab-events.gif | Bin 1336 -> 0 bytes themes/petitions/img/utility-tab-events.png | Bin 1752 -> 0 bytes themes/petitions/img/video-260x180.jpg | Bin 19964 -> 0 bytes themes/petitions/img/video590x335.jpg | Bin 30408 -> 0 bytes themes/petitions/img/video791x473.jpg | Bin 50360 -> 0 bytes themes/petitions/img/vs-bg-gray.png | Bin 1499 -> 0 bytes themes/petitions/js/main.js | 1099 ---- themes/petitions/pages/esi.tpl.php | 8 - themes/petitions/pages/html.tpl.php | 73 - themes/petitions/pages/json.tpl.php | 32 - .../petitions/pages/maintenance-page.tpl.php | 557 -- themes/petitions/pages/page--user--%.tpl.php | 566 -- .../petitions/pages/page--user--edit.tpl.php | 577 -- .../pages/page--user--password.tpl.php | 579 -- .../pages/page--user--register.tpl.php | 593 -- themes/petitions/pages/page--user.tpl.php | 569 -- themes/petitions/pages/page.tpl.php | 563 -- themes/petitions/petitions.info | 16 - themes/petitions/template.php | 9 - 633 files changed, 61 insertions(+), 37958 deletions(-) delete mode 100644 INSTALL.md delete mode 100644 build-petition.make delete mode 100644 drupal-org.make create mode 100644 index.html delete mode 100644 make/7.x-1.x-alpha10/build-petition.make delete mode 100644 make/7.x-1.x-alpha10/drupal-org.make delete mode 100644 make/7.x-1.x-auto/build-petition.make delete mode 100644 make/7.x-1.x-auto/drupal-org.make delete mode 100644 make/7.x-1.x/build-petition.make delete mode 120000 make/7.x-1.x/drupal-org.make delete mode 100644 modules/custom/README.txt delete mode 100644 modules/custom/govdelivery/govdelivery.admin-reports.inc delete mode 100644 modules/custom/govdelivery/govdelivery.admin.inc delete mode 100644 modules/custom/govdelivery/govdelivery.drush.inc delete mode 100644 modules/custom/govdelivery/govdelivery.info delete mode 100644 modules/custom/govdelivery/govdelivery.install delete mode 100644 modules/custom/govdelivery/govdelivery.mail.inc delete mode 100644 modules/custom/govdelivery/govdelivery.module delete mode 100644 modules/custom/govdelivery/libraries/GovDeliverySubscriberAPI.php delete mode 100644 modules/custom/govdelivery/libraries/odmService.php delete mode 100644 modules/custom/govdelivery/webform_components/govdelivery_subscribe/govdelivery_subscribe.component.inc delete mode 100644 modules/custom/govdelivery/webform_components/govdelivery_subscribe/govdelivery_subscribe.info delete mode 100644 modules/custom/govdelivery/webform_components/govdelivery_subscribe/govdelivery_subscribe.module delete mode 100644 modules/custom/wh_core/wh_core.info delete mode 100644 modules/custom/wh_core/wh_core.install delete mode 100644 modules/custom/wh_core/wh_core.js delete mode 100644 modules/custom/wh_core/wh_core.module delete mode 100644 modules/custom/wh_core/wh_core.rules.inc delete mode 100644 modules/custom/wh_feedback/images/eagle.jpg delete mode 100644 modules/custom/wh_feedback/images/feedback_btn_sprite.png delete mode 100644 modules/custom/wh_feedback/wh_feedback.css delete mode 100644 modules/custom/wh_feedback/wh_feedback.info delete mode 100644 modules/custom/wh_feedback/wh_feedback.js delete mode 100644 modules/custom/wh_feedback/wh_feedback.module delete mode 100644 modules/custom/wh_petition_reporting/css/counts.css delete mode 100644 modules/custom/wh_petition_reporting/css/summary.css delete mode 100644 modules/custom/wh_petition_reporting/wh_petition_reporting.hourly.inc delete mode 100644 modules/custom/wh_petition_reporting/wh_petition_reporting.info delete mode 100644 modules/custom/wh_petition_reporting/wh_petition_reporting.install delete mode 100644 modules/custom/wh_petition_reporting/wh_petition_reporting.module delete mode 100644 modules/custom/wh_petition_reporting/wh_petition_reporting.page.inc delete mode 100644 modules/custom/wh_petition_reporting/wh_petition_reporting.summary.inc delete mode 100644 modules/custom/wh_petition_tool/wh-petition-tool-homepage.tpl.php delete mode 100644 modules/custom/wh_petition_tool/wh-petition-tool-left-nav.tpl.php delete mode 100644 modules/custom/wh_petition_tool/wh_petition_tool.admin.inc delete mode 100644 modules/custom/wh_petition_tool/wh_petition_tool.info delete mode 100644 modules/custom/wh_petition_tool/wh_petition_tool.install delete mode 100644 modules/custom/wh_petition_tool/wh_petition_tool.module delete mode 100644 modules/custom/wh_petitions/drush/wh_petitions.drush.inc delete mode 100644 modules/custom/wh_petitions/templates/wh-petitions-by-the-numbers.tpl.php delete mode 100644 modules/custom/wh_petitions/templates/wh-petitions-create-header.tpl.php delete mode 100644 modules/custom/wh_petitions/templates/wh-petitions-display-list-petition.tpl.php delete mode 100644 modules/custom/wh_petitions/templates/wh-petitions-display-petition-info.tpl.php delete mode 100644 modules/custom/wh_petitions/templates/wh-petitions-display-signatures.tpl.php delete mode 100644 modules/custom/wh_petitions/templates/wh-petitions-page-archived.tpl.php delete mode 100644 modules/custom/wh_petitions/templates/wh-petitions-page-deleted.tpl.php delete mode 100644 modules/custom/wh_petitions/templates/wh-petitions-page-open-petitions.tpl.php delete mode 100644 modules/custom/wh_petitions/templates/wh-petitions-page-petition.tpl.php delete mode 100644 modules/custom/wh_petitions/templates/wh-petitions-page-thank-you.tpl.php delete mode 100644 modules/custom/wh_petitions/templates/wh-petitions-page-user-dashboard.tpl.php delete mode 100644 modules/custom/wh_petitions/wh_petitions.admin.inc delete mode 100644 modules/custom/wh_petitions/wh_petitions.admin.js delete mode 100644 modules/custom/wh_petitions/wh_petitions.cron.inc delete mode 100644 modules/custom/wh_petitions/wh_petitions.form.inc delete mode 100644 modules/custom/wh_petitions/wh_petitions.generate.inc delete mode 100644 modules/custom/wh_petitions/wh_petitions.info delete mode 100644 modules/custom/wh_petitions/wh_petitions.module delete mode 100644 modules/custom/wh_petitions/wh_petitions.pages.inc delete mode 100644 modules/custom/wh_petitions/wh_petitions.tokens.inc delete mode 100644 modules/custom/wh_profile_migrate/profile_migration.inc delete mode 100644 modules/custom/wh_profile_migrate/wh_profile_migrate.info delete mode 100644 modules/custom/wh_profile_migrate/wh_profile_migrate.module delete mode 100644 modules/custom/wh_response/templates/wh-response-display-list-response.tpl.php delete mode 100644 modules/custom/wh_response/templates/wh-response-page-responses.tpl.php delete mode 100644 modules/custom/wh_response/wh_response.css delete mode 100644 modules/custom/wh_response/wh_response.form.inc delete mode 100644 modules/custom/wh_response/wh_response.info delete mode 100644 modules/custom/wh_response/wh_response.install delete mode 100644 modules/custom/wh_response/wh_response.js delete mode 100644 modules/custom/wh_response/wh_response.module delete mode 100644 modules/custom/wh_response/wh_response.pages.inc delete mode 100644 modules/custom/wh_zipcodelookup/wh_zipcodelookup.info delete mode 100644 modules/custom/wh_zipcodelookup/wh_zipcodelookup.install delete mode 100644 modules/custom/wh_zipcodelookup/wh_zipcodelookup.js delete mode 100644 modules/custom/wh_zipcodelookup/wh_zipcodelookup.module delete mode 100644 modules/features/README.txt delete mode 100644 modules/features/petitions_logintoboggan_settings/petitions_logintoboggan_settings.features.inc delete mode 100644 modules/features/petitions_logintoboggan_settings/petitions_logintoboggan_settings.info delete mode 100644 modules/features/petitions_logintoboggan_settings/petitions_logintoboggan_settings.module delete mode 100644 modules/features/petitions_logintoboggan_settings/petitions_logintoboggan_settings.strongarm.inc delete mode 100644 modules/features/petitions_user_registration/petitions_user_registration.features.field.inc delete mode 100644 modules/features/petitions_user_registration/petitions_user_registration.features.inc delete mode 100644 modules/features/petitions_user_registration/petitions_user_registration.info delete mode 100644 modules/features/petitions_user_registration/petitions_user_registration.module delete mode 100644 modules/features/petitions_user_registration/petitions_user_registration.rules_defaults.inc delete mode 100644 modules/features/petitions_user_registration/petitions_user_registration.strongarm.inc delete mode 100644 modules/features/taxonomy_sync/taxonomy_sync.features.inc delete mode 100644 modules/features/taxonomy_sync/taxonomy_sync.features.taxonomy.inc delete mode 100644 modules/features/taxonomy_sync/taxonomy_sync.feeds_importer_default.inc delete mode 100644 modules/features/taxonomy_sync/taxonomy_sync.info delete mode 100644 modules/features/taxonomy_sync/taxonomy_sync.module delete mode 100644 modules/features/wh_contexts/wh_contexts.context.inc delete mode 100644 modules/features/wh_contexts/wh_contexts.features.inc delete mode 100644 modules/features/wh_contexts/wh_contexts.info delete mode 100644 modules/features/wh_contexts/wh_contexts.module delete mode 100644 modules/features/wh_misc/wh_misc.features.inc delete mode 100644 modules/features/wh_misc/wh_misc.features.user_permission.inc delete mode 100644 modules/features/wh_misc/wh_misc.features.user_role.inc delete mode 100644 modules/features/wh_misc/wh_misc.info delete mode 100644 modules/features/wh_misc/wh_misc.module delete mode 100644 modules/features/wh_misc/wh_misc.strongarm.inc delete mode 100644 modules/features/wh_petition_page/wh_petition_page.features.field.inc delete mode 100644 modules/features/wh_petition_page/wh_petition_page.features.inc delete mode 100644 modules/features/wh_petition_page/wh_petition_page.features.menu_custom.inc delete mode 100644 modules/features/wh_petition_page/wh_petition_page.info delete mode 100644 modules/features/wh_petition_page/wh_petition_page.module delete mode 100644 modules/features/wh_petition_page/wh_petition_page.strongarm.inc delete mode 100644 modules/features/wh_response_feature/wh_response_feature.features.field.inc delete mode 100644 modules/features/wh_response_feature/wh_response_feature.features.filter.inc delete mode 100644 modules/features/wh_response_feature/wh_response_feature.features.inc delete mode 100644 modules/features/wh_response_feature/wh_response_feature.features.taxonomy.inc delete mode 100644 modules/features/wh_response_feature/wh_response_feature.info delete mode 100644 modules/features/wh_response_feature/wh_response_feature.module delete mode 100644 modules/features/wh_response_feature/wh_response_feature.strongarm.inc delete mode 100644 modules/features/wh_user_profile/wh_user_profile.features.field.inc delete mode 100644 modules/features/wh_user_profile/wh_user_profile.features.inc delete mode 100644 modules/features/wh_user_profile/wh_user_profile.info delete mode 100644 modules/features/wh_user_profile/wh_user_profile.module delete mode 100644 modules/features/wh_user_profile/wh_user_profile.strongarm.inc delete mode 100644 modules/features/wh_user_ss_data/wh_user_ss_data.features.field.inc delete mode 100644 modules/features/wh_user_ss_data/wh_user_ss_data.info delete mode 100644 modules/features/wh_user_ss_data/wh_user_ss_data.module delete mode 100644 petition.info delete mode 100644 petition.install delete mode 100644 petition.profile delete mode 100755 petition.rebuild.sh delete mode 100644 readme.md delete mode 100644 selenium/README delete mode 100644 selenium/UserLoginTests.selenium.php delete mode 100644 selenium/UserLogoutTests.selenium.php delete mode 100644 selenium/UserPasswordTests.selenium.php delete mode 100644 selenium/UserRegisterTests.selenium.php delete mode 100644 selenium/UserTestsSuite.selenium.php delete mode 100644 themes/petitions/404/README.txt delete mode 100644 themes/petitions/404/css_Wu8npAzy16WmnnnWKxpexfgsAryolGGaX6yO3GWA5bU.css delete mode 100644 themes/petitions/404/css_Z_KQyXTcIGmFPRfGZOOTJ1xsEckXlqMhF53CkTgnOVA.css delete mode 100644 themes/petitions/404/css_Zgn45zJ1732WoUaTDQQLeMLK2oENAymYX83JYwHtjVI.css delete mode 100644 themes/petitions/404/css_lv7tebdrKmruvnf0Qj7_bz5D-OzL4J_bQfKZBL-XOLs.css delete mode 100644 themes/petitions/404/js_3jHghlMLrjr9xXAC0JufqSSch3oAbkZstSqYdc4uuck.js delete mode 100644 themes/petitions/404/js_729FJpBzl-C3fHFnbYgAf6RlaKZx-UT7gKyX6DVTbUQ.js delete mode 100644 themes/petitions/404/js_qTv1NOxfaS-X1Byu1sqma0PUntrWUC16ms-blpiBy-0.js delete mode 100644 themes/petitions/404/page-not-found.php delete mode 100644 themes/petitions/css/ie6.css delete mode 100644 themes/petitions/css/ie7.css delete mode 100644 themes/petitions/css/style.css delete mode 100644 themes/petitions/css/wh-components.css delete mode 100644 themes/petitions/css/wh-grid.css delete mode 100644 themes/petitions/css/wh-layout.css delete mode 100644 themes/petitions/css/wh-template.css delete mode 100644 themes/petitions/favicon.ico delete mode 100644 themes/petitions/general/block.tpl.php delete mode 100644 themes/petitions/general/forward.tpl.php delete mode 100644 themes/petitions/general/node--wh_petitions_page.tpl.php delete mode 100644 themes/petitions/general/node--wh_response.tpl.php delete mode 100644 themes/petitions/img/MS-header-oira.jpg delete mode 100644 themes/petitions/img/MS-header-ondcp.jpg delete mode 100644 themes/petitions/img/ajax-loader.gif delete mode 100644 themes/petitions/img/arrow-blue-back.gif delete mode 100644 themes/petitions/img/arrow-blue-next.gif delete mode 100644 themes/petitions/img/arrow-hide.gif delete mode 100644 themes/petitions/img/arrow-mc-next.gif delete mode 100644 themes/petitions/img/arrow-mc-prev.gif delete mode 100644 themes/petitions/img/arrow-pg-next.gif delete mode 100644 themes/petitions/img/arrow-pg-prev.gif delete mode 100644 themes/petitions/img/arrow-right.gif delete mode 100644 themes/petitions/img/arrow-show.gif delete mode 100644 themes/petitions/img/arrow-white-right.png delete mode 100644 themes/petitions/img/arrow-white-up.gif delete mode 100644 themes/petitions/img/arrow-white-up.png delete mode 100644 themes/petitions/img/backgrounds/bg-body.gif delete mode 100644 themes/petitions/img/backgrounds/bg-body.png delete mode 100644 themes/petitions/img/backgrounds/bg-browse-mc.gif delete mode 100644 themes/petitions/img/backgrounds/bg-category-drop-left-edge.png delete mode 100644 themes/petitions/img/backgrounds/bg-category-drop-right-edge.png delete mode 100644 themes/petitions/img/backgrounds/bg-contact-intro.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-dialog.png delete mode 100644 themes/petitions/img/backgrounds/bg-footer-no-bar.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-form-item.png delete mode 100644 themes/petitions/img/backgrounds/bg-hero-president-in-ghana.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-home-callout-trans.gif delete mode 100644 themes/petitions/img/backgrounds/bg-home-callout-trans.png delete mode 100644 themes/petitions/img/backgrounds/bg-home-detail-col.gif delete mode 100644 themes/petitions/img/backgrounds/bg-home-live-stream.png delete mode 100644 themes/petitions/img/backgrounds/bg-home-num-divide.png delete mode 100644 themes/petitions/img/backgrounds/bg-home-title-trans.png delete mode 100644 themes/petitions/img/backgrounds/bg-home-title.png delete mode 100644 themes/petitions/img/backgrounds/bg-home-top-edge.png delete mode 100644 themes/petitions/img/backgrounds/bg-home-top.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-home-two-col.png delete mode 100644 themes/petitions/img/backgrounds/bg-landing-top.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-live-stream-callout.png delete mode 100644 themes/petitions/img/backgrounds/bg-main-no-nav.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-main-one-ie-1.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-main-one-ie.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-main-one-ie6.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-main-one-ie8.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-main-one-repeat-no-shadow.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-main-one-repeat.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-main-one.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-ms-breadcrumb-orange.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-ms-breadcrumb.png delete mode 100644 themes/petitions/img/backgrounds/bg-ms-detail.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-ms-nav.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-ms-ondcp.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-ms-open-title.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-ms-quote-close.gif delete mode 100644 themes/petitions/img/backgrounds/bg-ms-quote-open.gif delete mode 100644 themes/petitions/img/backgrounds/bg-ms-title.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-nav-featured-left.png delete mode 100644 themes/petitions/img/backgrounds/bg-nav-featured-right.png delete mode 100644 themes/petitions/img/backgrounds/bg-nav-left-edge-blank.png delete mode 100644 themes/petitions/img/backgrounds/bg-nav-left-edge-trans.png delete mode 100644 themes/petitions/img/backgrounds/bg-nav-right-edge-trans.png delete mode 100644 themes/petitions/img/backgrounds/bg-nav-right-edge-trans2.png delete mode 100644 themes/petitions/img/backgrounds/bg-ogi-featured.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-pag-active.gif delete mode 100644 themes/petitions/img/backgrounds/bg-pag-active2.gif delete mode 100644 themes/petitions/img/backgrounds/bg-pag-active3.gif delete mode 100644 themes/petitions/img/backgrounds/bg-photo-list-active.gif delete mode 100644 themes/petitions/img/backgrounds/bg-photo-overlay-old.png delete mode 100644 themes/petitions/img/backgrounds/bg-photo-overlay.png delete mode 100644 themes/petitions/img/backgrounds/bg-save-vote.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-sort-active.gif delete mode 100644 themes/petitions/img/backgrounds/bg-sort-tab-active.gif delete mode 100644 themes/petitions/img/backgrounds/bg-star-required.gif delete mode 100644 themes/petitions/img/backgrounds/bg-textarea.png delete mode 100644 themes/petitions/img/backgrounds/bg-title-fade-trans.png delete mode 100644 themes/petitions/img/backgrounds/bg-title-fade-white.gif delete mode 100644 themes/petitions/img/backgrounds/bg-title-fade.gif delete mode 100644 themes/petitions/img/backgrounds/bg-title-fade.png delete mode 100644 themes/petitions/img/backgrounds/bg-title-iga.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-title-midclass.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-title-stay-connected-trans.png delete mode 100644 themes/petitions/img/backgrounds/bg-title-stay-connected.png delete mode 100644 themes/petitions/img/backgrounds/bg-title-wh-live.png delete mode 100644 themes/petitions/img/backgrounds/bg-top-edge-no-left.png delete mode 100644 themes/petitions/img/backgrounds/bg-top-edge.png delete mode 100644 themes/petitions/img/backgrounds/bg-topnav-secondary01.png delete mode 100644 themes/petitions/img/backgrounds/bg-tout-blog.png delete mode 100644 themes/petitions/img/backgrounds/bg-tout-cbb.png delete mode 100644 themes/petitions/img/backgrounds/bg-tout-drug-facts.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-tout-fed-web-cookie.png delete mode 100644 themes/petitions/img/backgrounds/bg-tout-fiscal.png delete mode 100644 themes/petitions/img/backgrounds/bg-tout-flu-btm.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-tout-flu-tile.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-tout-flu-top.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-tout-fy-2010.png delete mode 100644 themes/petitions/img/backgrounds/bg-tout-latest-news-updates.png delete mode 100644 themes/petitions/img/backgrounds/bg-tout-letters.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-tout-new-era.png delete mode 100644 themes/petitions/img/backgrounds/bg-tout-open-gov.png delete mode 100644 themes/petitions/img/backgrounds/bg-tout-opl-ope.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-tout-photo-gallery.jpg delete mode 100644 themes/petitions/img/backgrounds/bg-tout-recovery.png delete mode 100644 themes/petitions/img/backgrounds/bg-tout-sm.png delete mode 100644 themes/petitions/img/backgrounds/bg-tout-state-and-local-info.png delete mode 100644 themes/petitions/img/backgrounds/bg-tout-stay-con-email.png delete mode 100644 themes/petitions/img/backgrounds/bg-tout-stay-connected.png delete mode 100644 themes/petitions/img/backgrounds/bg-tout-strong-mid-class.png delete mode 100644 themes/petitions/img/backgrounds/bg-tout-wh-blogs.png delete mode 100644 themes/petitions/img/backgrounds/bg-video-controls.gif delete mode 100644 themes/petitions/img/backgrounds/bkg-podcast.png delete mode 100644 themes/petitions/img/backgrounds/bullet.gif delete mode 100644 themes/petitions/img/backgrounds/ms-hero-1.jpg delete mode 100644 themes/petitions/img/backgrounds/ms-hero-2.jpg delete mode 100644 themes/petitions/img/backgrounds/ogi-rule-301.gif delete mode 100644 themes/petitions/img/bg-comment-bubble-btm.png delete mode 100644 themes/petitions/img/bg-comment-bubble-mid.png delete mode 100644 themes/petitions/img/bg-comment-bubble-top.png delete mode 100644 themes/petitions/img/bg-delete-modal.png delete mode 100644 themes/petitions/img/bg-divide.png delete mode 100644 themes/petitions/img/bg-event-arrow-round.gif delete mode 100644 themes/petitions/img/bg-event-arrow-round.png delete mode 100644 themes/petitions/img/bg-event-entry-on.png delete mode 100644 themes/petitions/img/bg-footer.jpg delete mode 100644 themes/petitions/img/bg-fuz-divide.png delete mode 100644 themes/petitions/img/bg-fuz-event-on.png delete mode 100644 themes/petitions/img/bg-fuz-event.png delete mode 100644 themes/petitions/img/bg-fuz-line-bar.png delete mode 100644 themes/petitions/img/bg-fuz-signin.png delete mode 100644 themes/petitions/img/bg-hdr-text.gif delete mode 100644 themes/petitions/img/bg-hdr-text.png delete mode 100644 themes/petitions/img/bg-how-why-left-nav.png delete mode 100644 themes/petitions/img/bg-input-text.gif delete mode 100644 themes/petitions/img/bg-int-col.gif delete mode 100644 themes/petitions/img/bg-issues-drop.png delete mode 100644 themes/petitions/img/bg-issues-filter-btm.png delete mode 100644 themes/petitions/img/bg-issues-filter-mid.png delete mode 100644 themes/petitions/img/bg-issues-filter-top.png delete mode 100644 themes/petitions/img/bg-left-nav-active.png delete mode 100644 themes/petitions/img/bg-load-next-sig.gif delete mode 100644 themes/petitions/img/bg-main-one-repeat.jpg delete mode 100644 themes/petitions/img/bg-main-one.jpg delete mode 100644 themes/petitions/img/bg-main.jpg delete mode 100644 themes/petitions/img/bg-mc-browse.jpg delete mode 100644 themes/petitions/img/bg-mc.gif delete mode 100644 themes/petitions/img/bg-msg-bar-blue.gif delete mode 100644 themes/petitions/img/bg-msg-bar-red.gif delete mode 100644 themes/petitions/img/bg-nav-event.gif delete mode 100644 themes/petitions/img/bg-nav-pet.gif delete mode 100644 themes/petitions/img/bg-nav-signin.gif delete mode 100644 themes/petitions/img/bg-num-count-long.gif delete mode 100644 themes/petitions/img/bg-num-count.gif delete mode 100644 themes/petitions/img/bg-page-no-nav.jpg delete mode 100644 themes/petitions/img/bg-petition-hdr.png delete mode 100644 themes/petitions/img/bg-petitions-action-bar.png delete mode 100644 themes/petitions/img/bg-photo-list.jpg delete mode 100644 themes/petitions/img/bg-report-petition-overlay.png delete mode 100644 themes/petitions/img/bg-response-call.gif delete mode 100644 themes/petitions/img/bg-rightrail-blue.jpg delete mode 100644 themes/petitions/img/bg-rightrail.jpg delete mode 100644 themes/petitions/img/bg-search-drop.png delete mode 100644 themes/petitions/img/bg-sig.gif delete mode 100644 themes/petitions/img/bg-signin.jpg delete mode 100644 themes/petitions/img/bg-subftr.gif delete mode 100644 themes/petitions/img/bg-subftr.jpg delete mode 100644 themes/petitions/img/bg-subhdr.jpg delete mode 100644 themes/petitions/img/bg-textarea.png delete mode 100644 themes/petitions/img/bg-tile.jpg delete mode 100644 themes/petitions/img/bg-utility-bar.gif delete mode 100644 themes/petitions/img/bg-utility-block.png delete mode 100644 themes/petitions/img/bg-we-petition.gif delete mode 100644 themes/petitions/img/bg-why-signin-overlay.png delete mode 100644 themes/petitions/img/bg_int_col.gif delete mode 100644 themes/petitions/img/bg_main.jpg delete mode 100644 themes/petitions/img/bg_rightrail.jpg delete mode 100644 themes/petitions/img/bg_subhdr.jpg delete mode 100644 themes/petitions/img/bg_tile.jpg delete mode 100644 themes/petitions/img/blank.gif delete mode 100644 themes/petitions/img/block-menu-sprite.png delete mode 100644 themes/petitions/img/blog_breadcrum.jpg delete mode 100644 themes/petitions/img/blog_header.jpg delete mode 100644 themes/petitions/img/blog_slide_arrows.png delete mode 100644 themes/petitions/img/blog_slide_arrows_flip.png delete mode 100644 themes/petitions/img/blog_slide_dots.png delete mode 100644 themes/petitions/img/blue-gradient-block-header.png delete mode 100644 themes/petitions/img/btn-categories.gif delete mode 100644 themes/petitions/img/btn-search-sm.gif delete mode 100644 themes/petitions/img/btn-search.gif delete mode 100644 themes/petitions/img/btn_search.gif delete mode 100644 themes/petitions/img/bullet-green-arrow.gif delete mode 100644 themes/petitions/img/bullet-green-arrow.png delete mode 100644 themes/petitions/img/bullet-white-arrow.png delete mode 100644 themes/petitions/img/bullet.gif delete mode 100644 themes/petitions/img/button-delete-my-petition.gif delete mode 100644 themes/petitions/img/button-edit-my-petition.gif delete mode 100644 themes/petitions/img/button-edit-profile-change-password.gif delete mode 100644 themes/petitions/img/button-find-out-more.png delete mode 100644 themes/petitions/img/button-go-search.gif delete mode 100644 themes/petitions/img/button-publish-my-petition.gif delete mode 100644 themes/petitions/img/button-save-changes.gif delete mode 100644 themes/petitions/img/button-save-my-petition-and-publish-later.gif delete mode 100644 themes/petitions/img/buttons/arrow-mc-next-sprite.gif delete mode 100644 themes/petitions/img/buttons/arrow-mc-prev-sprite.gif delete mode 100644 themes/petitions/img/buttons/btn-categories.gif delete mode 100644 themes/petitions/img/buttons/btn-change-pass.png delete mode 100644 themes/petitions/img/buttons/btn-drugfacts-controls.gif delete mode 100644 themes/petitions/img/buttons/btn-exit-dialog.gif delete mode 100644 themes/petitions/img/buttons/btn-gold-download-pdf.gif delete mode 100644 themes/petitions/img/buttons/btn-gold-more-info.gif delete mode 100644 themes/petitions/img/buttons/btn-gold-read-blog.gif delete mode 100644 themes/petitions/img/buttons/btn-gold-read-report.gif delete mode 100644 themes/petitions/img/buttons/btn-gold-read-the-report.gif delete mode 100644 themes/petitions/img/buttons/btn-gold-signup.gif delete mode 100644 themes/petitions/img/buttons/btn-join-discussion-blue.gif delete mode 100644 themes/petitions/img/buttons/btn-join-discussion-grey.gif delete mode 100644 themes/petitions/img/buttons/btn-learn-more-blue.gif delete mode 100644 themes/petitions/img/buttons/btn-learn-more-blue.png delete mode 100644 themes/petitions/img/buttons/btn-learn-more-grey.gif delete mode 100644 themes/petitions/img/buttons/btn-learn-more-grey.png delete mode 100644 themes/petitions/img/buttons/btn-listen-live.gif delete mode 100644 themes/petitions/img/buttons/btn-mc-controls.png delete mode 100644 themes/petitions/img/buttons/btn-mc-controls1.gif delete mode 100644 themes/petitions/img/buttons/btn-mc-controls1.png delete mode 100644 themes/petitions/img/buttons/btn-mc-pause-hover.png delete mode 100644 themes/petitions/img/buttons/btn-mc-pause.png delete mode 100644 themes/petitions/img/buttons/btn-mc-photoplay.gif delete mode 100644 themes/petitions/img/buttons/btn-mc-play-hover.png delete mode 100644 themes/petitions/img/buttons/btn-mc-play.png delete mode 100644 themes/petitions/img/buttons/btn-more-info-blue.gif delete mode 100644 themes/petitions/img/buttons/btn-more-info-grey.gif delete mode 100644 themes/petitions/img/buttons/btn-next-back-vote.gif delete mode 100644 themes/petitions/img/buttons/btn-next-grey-sprite.gif delete mode 100644 themes/petitions/img/buttons/btn-next.gif delete mode 100644 themes/petitions/img/buttons/btn-phase-completed.gif delete mode 100644 themes/petitions/img/buttons/btn-podcast-audio.png delete mode 100644 themes/petitions/img/buttons/btn-podcast-itunes.png delete mode 100644 themes/petitions/img/buttons/btn-podcast-rss.png delete mode 100644 themes/petitions/img/buttons/btn-podcast-video.png delete mode 100644 themes/petitions/img/buttons/btn-previous-grey-sprite.gif delete mode 100644 themes/petitions/img/buttons/btn-previous.gif delete mode 100644 themes/petitions/img/buttons/btn-read-remarks-blue.gif delete mode 100644 themes/petitions/img/buttons/btn-read-remarks-grey.gif delete mode 100644 themes/petitions/img/buttons/btn-read-the-exec-order.gif delete mode 100644 themes/petitions/img/buttons/btn-search-blue.png delete mode 100644 themes/petitions/img/buttons/btn-search-grey-sprite.gif delete mode 100644 themes/petitions/img/buttons/btn-search-sm.gif delete mode 100644 themes/petitions/img/buttons/btn-search.gif delete mode 100644 themes/petitions/img/buttons/btn-show-all.gif delete mode 100644 themes/petitions/img/buttons/btn-strongmid-about.jpg delete mode 100644 themes/petitions/img/buttons/btn-strongmid-read-report.jpg delete mode 100644 themes/petitions/img/buttons/btn-submit.png delete mode 100644 themes/petitions/img/buttons/btn-view-gallery-blue.gif delete mode 100644 themes/petitions/img/buttons/btn-view-gallery-grey.gif delete mode 100644 themes/petitions/img/buttons/btn-view-gallery.png delete mode 100644 themes/petitions/img/buttons/btn-watch-live.gif delete mode 100644 themes/petitions/img/buttons/btn-watch-stream-blue.gif delete mode 100644 themes/petitions/img/buttons/btn-watch-stream-grey.gif delete mode 100644 themes/petitions/img/buttons/btn-watch-the-video.gif delete mode 100644 themes/petitions/img/buttons/btn-watch-video-blue.gif delete mode 100644 themes/petitions/img/buttons/btn-watch-video-grey.gif delete mode 100644 themes/petitions/img/buttons/btn_view_results.gif delete mode 100644 themes/petitions/img/buttons/inno-next.gif delete mode 100644 themes/petitions/img/buttons/inno-prev.gif delete mode 100644 themes/petitions/img/champs_nav_int_bg.jpg delete mode 100644 themes/petitions/img/change_header.gif delete mode 100644 themes/petitions/img/change_serve_gov.jpg delete mode 100644 themes/petitions/img/change_serve_gov_button.jpg delete mode 100644 themes/petitions/img/circle-arrow1.png delete mode 100644 themes/petitions/img/circle-arrow2.png delete mode 100644 themes/petitions/img/circle-arrow3.png delete mode 100644 themes/petitions/img/clear.gif delete mode 100644 themes/petitions/img/contact-banner.png delete mode 100644 themes/petitions/img/contact-menu-bg.png delete mode 100755 themes/petitions/img/contact-us-main-hero.jpg delete mode 100644 themes/petitions/img/contact/bg-modal-bottom.png delete mode 100644 themes/petitions/img/contact/bg-modal-mid.png delete mode 100644 themes/petitions/img/contact/bg-modal-top.png delete mode 100644 themes/petitions/img/contact/bkgdBox-24.png delete mode 100644 themes/petitions/img/contact/bkgdBox-8.png delete mode 100644 themes/petitions/img/contact/contactIcon-blk.png delete mode 100644 themes/petitions/img/contact/contactIcon-blu.png delete mode 100644 themes/petitions/img/contact/contactIcon-lt.png delete mode 100644 themes/petitions/img/contact/eagleThankYou-gold.png delete mode 100644 themes/petitions/img/contact/emailIcon-blk.png delete mode 100644 themes/petitions/img/contact/emailIcon-blu.png delete mode 100644 themes/petitions/img/contact/emailIcon-lt.png delete mode 100644 themes/petitions/img/contact/pointerTriangle-24.png delete mode 100644 themes/petitions/img/contact/pointerTriangle-8.png delete mode 100644 themes/petitions/img/contact/sealThankYou.png delete mode 100644 themes/petitions/img/data-gov2.jpg delete mode 100644 themes/petitions/img/divide-green-fuz.gif delete mode 100644 themes/petitions/img/facebook_bubble.gif delete mode 100644 themes/petitions/img/fb_share_we_the_people.png delete mode 100644 themes/petitions/img/featured_petitions.jpg delete mode 100644 themes/petitions/img/featured_tax_receipt.jpg delete mode 100644 themes/petitions/img/fhs-indexes.png delete mode 100644 themes/petitions/img/fhs-nav.png delete mode 100644 themes/petitions/img/find-out.png delete mode 100644 themes/petitions/img/graphic-417x164.jpg delete mode 100644 themes/petitions/img/grey-title-block-bg.png delete mode 100644 themes/petitions/img/hdr-browse.gif delete mode 100644 themes/petitions/img/hdr-usa-flag.gif delete mode 100644 themes/petitions/img/home/homeslider.png delete mode 100644 themes/petitions/img/home/homesprite.png delete mode 100644 themes/petitions/img/how-to-numbers.gif delete mode 100644 themes/petitions/img/icon-clock.gif delete mode 100644 themes/petitions/img/icon-facebook.gif delete mode 100644 themes/petitions/img/icon-flickr.gif delete mode 100644 themes/petitions/img/icon-gallery.gif delete mode 100644 themes/petitions/img/icon-itunes.gif delete mode 100644 themes/petitions/img/icon-myspace.gif delete mode 100644 themes/petitions/img/icon-openid.gif delete mode 100644 themes/petitions/img/icon-photo.gif delete mode 100644 themes/petitions/img/icon-rss-grey.gif delete mode 100644 themes/petitions/img/icon-rss.gif delete mode 100644 themes/petitions/img/icon-search1.gif delete mode 100644 themes/petitions/img/icon-share.gif delete mode 100644 themes/petitions/img/icon-twitter.gif delete mode 100644 themes/petitions/img/icon-video.gif delete mode 100644 themes/petitions/img/icon-vimeo.gif delete mode 100644 themes/petitions/img/icon-youtube.gif delete mode 100644 themes/petitions/img/icon_search1.gif delete mode 100644 themes/petitions/img/icons-filter-view.gif delete mode 100644 themes/petitions/img/icons/icon-audio-home.gif delete mode 100644 themes/petitions/img/icons/icon-audio-mc.gif delete mode 100644 themes/petitions/img/icons/icon-close.gif delete mode 100644 themes/petitions/img/icons/icon-download-dark.gif delete mode 100644 themes/petitions/img/icons/icon-facebook-mc.gif delete mode 100644 themes/petitions/img/icons/icon-other-mc.gif delete mode 100644 themes/petitions/img/icons/icon-rss.gif delete mode 100644 themes/petitions/img/icons/icon-search1.gif delete mode 100644 themes/petitions/img/icons/icon-share.gif delete mode 100644 themes/petitions/img/icons/icon-video-home.gif delete mode 100644 themes/petitions/img/icons/icon-warning.gif delete mode 100644 themes/petitions/img/icons/icon_search1.gif delete mode 100644 themes/petitions/img/icons/icons-get-connected.gif delete mode 100644 themes/petitions/img/icons/icons-get-connected.png delete mode 100644 themes/petitions/img/inPerformance_hero.jpg delete mode 100644 themes/petitions/img/line-gr.gif delete mode 100644 themes/petitions/img/line-mid.gif delete mode 100644 themes/petitions/img/live-controls.gif delete mode 100644 themes/petitions/img/loadingAnimation.gif delete mode 100644 themes/petitions/img/login/user_account_account_info.png delete mode 100644 themes/petitions/img/login/user_account_create_account_btn.png delete mode 100644 themes/petitions/img/login/user_account_login_btn.png delete mode 100644 themes/petitions/img/login/user_account_openidid_google.png delete mode 100644 themes/petitions/img/login/user_account_openidid_verisign.png delete mode 100644 themes/petitions/img/login/user_account_petitions_header.jpg delete mode 100644 themes/petitions/img/login/user_account_save_changes_btn.png delete mode 100644 themes/petitions/img/login/user_account_submit_btn.png delete mode 100644 themes/petitions/img/login/user_account_tabs.png delete mode 100644 themes/petitions/img/main_nav_cant_wait.jpg delete mode 100644 themes/petitions/img/maintenance.jpg delete mode 100644 themes/petitions/img/menu_interactive_tour.jpg delete mode 100644 themes/petitions/img/menu_visitor_records.jpg delete mode 100644 themes/petitions/img/ms-quote-01.gif delete mode 100644 themes/petitions/img/ms-strongmid.jpg delete mode 100644 themes/petitions/img/ms-title-001.jpg delete mode 100644 themes/petitions/img/ms-title-office-pa-engage.jpg delete mode 100644 themes/petitions/img/my-petitions-actions.png delete mode 100755 themes/petitions/img/nav-pet.gif delete mode 100644 themes/petitions/img/nav-sprite-ie.gif delete mode 100644 themes/petitions/img/nav-sprite.gif delete mode 100644 themes/petitions/img/nav-sprite2.gif delete mode 100644 themes/petitions/img/nav_sprite.gif delete mode 100644 themes/petitions/img/oira_quote.jpg delete mode 100644 themes/petitions/img/openshareicon-14x14.gif delete mode 100644 themes/petitions/img/openshareicon-14x14.png delete mode 100644 themes/petitions/img/or.gif delete mode 100644 themes/petitions/img/pass_verify_header.png delete mode 100644 themes/petitions/img/petitions_landing_btns_0.png delete mode 100644 themes/petitions/img/petitions_landing_hero.jpg delete mode 100644 themes/petitions/img/petitions_landing_rightrail.png delete mode 100644 themes/petitions/img/petitions_landing_wh_content_01.jpg delete mode 100644 themes/petitions/img/petitions_landing_wh_content_02.jpg delete mode 100644 themes/petitions/img/petitions_social_icons.jpg delete mode 100644 themes/petitions/img/petitions_tw_landing.png delete mode 100644 themes/petitions/img/petitions_video_thumb_new.jpg delete mode 100644 themes/petitions/img/petitionslanding_arrow.png delete mode 100644 themes/petitions/img/photo-75x40.jpg delete mode 100644 themes/petitions/img/photo-770x435.jpg delete mode 100644 themes/petitions/img/photo-775x435.jpg delete mode 100644 themes/petitions/img/photo-pg-off.gif delete mode 100644 themes/petitions/img/photo-pg-on.gif delete mode 100644 themes/petitions/img/photo133x95.jpg delete mode 100644 themes/petitions/img/photo325x190.jpg delete mode 100644 themes/petitions/img/photo486x287.jpg delete mode 100644 themes/petitions/img/photos/biden-123.jpg delete mode 100644 themes/petitions/img/photos/hhs.jpg delete mode 100644 themes/petitions/img/photos/hhs2.jpg delete mode 100644 themes/petitions/img/photos/livevideo-640x360.jpg delete mode 100644 themes/petitions/img/photos/notredame-photo.jpg delete mode 100644 themes/petitions/img/photos/obama-dog.jpg delete mode 100644 themes/petitions/img/photos/oira.jpg delete mode 100644 themes/petitions/img/photos/photo-160x90.jpg delete mode 100644 themes/petitions/img/photos/photo-216x121.jpg delete mode 100644 themes/petitions/img/photos/photo-216x123.jpg delete mode 100644 themes/petitions/img/photos/photo-264x170.jpg delete mode 100644 themes/petitions/img/photos/photo-265x170.jpg delete mode 100644 themes/petitions/img/photos/photo-475x290.jpg delete mode 100644 themes/petitions/img/photos/photo-536x346.jpg delete mode 100644 themes/petitions/img/photos/photo-536x356.jpg delete mode 100644 themes/petitions/img/photos/photo-615x345.jpg delete mode 100644 themes/petitions/img/photos/photo-75x40.jpg delete mode 100644 themes/petitions/img/photos/photo-770x435.jpg delete mode 100644 themes/petitions/img/photos/photo-775x435.jpg delete mode 100644 themes/petitions/img/photos/photo-obama124.jpg delete mode 100644 themes/petitions/img/photos/photo-obama125.jpg delete mode 100644 themes/petitions/img/photos/video-205x115.gif delete mode 100644 themes/petitions/img/photos/video-260x180.jpg delete mode 100644 themes/petitions/img/photos/video-456x281.jpg delete mode 100644 themes/petitions/img/photos/video-457x281.jpg delete mode 100644 themes/petitions/img/photos/video-536.jpg delete mode 100644 themes/petitions/img/photos/video-640x360.jpg delete mode 100644 themes/petitions/img/photos/video-grad.jpg delete mode 100644 themes/petitions/img/photos/video-obama123.jpg delete mode 100644 themes/petitions/img/plus.gif delete mode 100644 themes/petitions/img/properties_fade.png delete mode 100644 themes/petitions/img/regulations-gov2.jpg delete mode 100644 themes/petitions/img/right-divide.gif delete mode 100644 themes/petitions/img/right_divide.gif delete mode 100644 themes/petitions/img/scrollable/left.png delete mode 100644 themes/petitions/img/scrollable/navigator.gif delete mode 100644 themes/petitions/img/scrollable/navigator.png delete mode 100644 themes/petitions/img/scrollable/right.png delete mode 100644 themes/petitions/img/seal-sample-white.gif delete mode 100644 themes/petitions/img/seal-sample.gif delete mode 100644 themes/petitions/img/sftr-whgov.gif delete mode 100644 themes/petitions/img/soc-media-graphics.gif delete mode 100644 themes/petitions/img/sotuthumb.jpg delete mode 100644 themes/petitions/img/sprite-bg.png delete mode 100644 themes/petitions/img/sprite-buttons-signin.gif delete mode 100644 themes/petitions/img/sprite-buttons.png delete mode 100644 themes/petitions/img/sprite-circle-icons.png delete mode 100644 themes/petitions/img/sprite-old.gif delete mode 100644 themes/petitions/img/sprite.gif delete mode 100644 themes/petitions/img/tag-petition-status.png delete mode 100644 themes/petitions/img/tb-mac-overlay.png delete mode 100644 themes/petitions/img/textarea-arrow.gif delete mode 100644 themes/petitions/img/thank-you-bg.png delete mode 100644 themes/petitions/img/thickbox/tb-btn-close.gif delete mode 100644 themes/petitions/img/thickbox/tb-emblem.gif delete mode 100644 themes/petitions/img/thickbox/tb-mac-overlay.png delete mode 100644 themes/petitions/img/timeline/bg-timeline-stage.png delete mode 100644 themes/petitions/img/timeline/dot-sprite.gif delete mode 100644 themes/petitions/img/timeline/tip-body.png delete mode 100644 themes/petitions/img/timeline/tip-pointer.png delete mode 100644 themes/petitions/img/timeline/tip-shadow.png delete mode 100644 themes/petitions/img/tip-arrow-down.gif delete mode 100644 themes/petitions/img/tip-arrow-up.gif delete mode 100644 themes/petitions/img/tip-arrow.gif delete mode 100644 themes/petitions/img/tweet_retweet.png delete mode 100644 themes/petitions/img/utility-tab-events-on.png delete mode 100644 themes/petitions/img/utility-tab-events.gif delete mode 100644 themes/petitions/img/utility-tab-events.png delete mode 100644 themes/petitions/img/video-260x180.jpg delete mode 100644 themes/petitions/img/video590x335.jpg delete mode 100644 themes/petitions/img/video791x473.jpg delete mode 100644 themes/petitions/img/vs-bg-gray.png delete mode 100644 themes/petitions/js/main.js delete mode 100644 themes/petitions/pages/esi.tpl.php delete mode 100644 themes/petitions/pages/html.tpl.php delete mode 100644 themes/petitions/pages/json.tpl.php delete mode 100644 themes/petitions/pages/maintenance-page.tpl.php delete mode 100644 themes/petitions/pages/page--user--%.tpl.php delete mode 100644 themes/petitions/pages/page--user--edit.tpl.php delete mode 100644 themes/petitions/pages/page--user--password.tpl.php delete mode 100644 themes/petitions/pages/page--user--register.tpl.php delete mode 100644 themes/petitions/pages/page--user.tpl.php delete mode 100644 themes/petitions/pages/page.tpl.php delete mode 100644 themes/petitions/petitions.info delete mode 100644 themes/petitions/template.php diff --git a/INSTALL.md b/INSTALL.md deleted file mode 100644 index 6dcc1af3e..000000000 --- a/INSTALL.md +++ /dev/null @@ -1,194 +0,0 @@ -INSTALL.md -============== - -**Contents** - -* "Alpha" software status -* Install MongoDB for local development -* Installing and configuring Petitions -* Manual Rules import -* MongoDB configuration in settings.php - - -"Alpha" software status --------------------------------- - -"Alpha" means we cannot promise to provide an upgrade path to users who build sites on the current code base. - -Later releases will remove this application's dependence on MongoDB. Our intention is to evolve this code base into an install profile that others can easily reuse, extend and contribute to. This is not the state of the current application, which was made specifically for the White House's particular use cases and hosting environment. - -These instructions will help you install Drupal, get Drupal talking to MySQL and MongoDB, and let you try out the existing code base. - -Where the application still has dependencies on configuration stored in the site's database, these are areas where the install profile remains a work in progress. We will release improvements as we make them on GitHub. In the meanwhile, patches are welcome too. - - -Install MongoDB for local development -------------------------------------- - -For local development on Mac OSX with MAMP (similar with XAMPP), install Homebrew, then do this: - -``` -$ brew versions mongo -$ cd /usr/local/Cellar -$ git checkout dae14ec /usr/local/Library/Formula/mongodb.rb -$ brew install mongo - -$ /Applications/MAMP/bin/php/php5.3.6/bin/pecl install mongo -$ mkdir /data/db -$ mongod # This starts mongo. -$ mongo # This starts the mongo client. -``` - -Note: The application was built to run on MongoDB 1.8 (not 2.x). This doesn't mean it won't work on 2.x. But it hasn't been rigorously tested on 2.x. - - -Installing and configuring Petitions ------------------------------------- - -1) Install Drush - -2) Download Drupal 7.x - -3) Place this petitions directory inside Drupal's profiles directory. - -4) Use Drush make to download contrib projects like this: - -``` -drush -y make --no-core --contrib-destination=. drupal-org.make -``` - -5) Follow the normal Drupal installation process. When prompted to select - a profile, select "Petitions". Drupal will rewrite your settings.php file. - After it does, you will be prompted to add a snippet like this to the end - of settings.php. Do this before you visit your site, otherwise Drupal will - be unhappy: - -```php - // Set mongo configuration - $mongo_host = '127.0.0.1'; - $mongo_db_name = 'petition'; - $conf['mongodb_connections'] = array( - 'default' => array('host' => $mongo_host, 'db' => $mongo_db_name), - 'petition_tool' => array('host' => $mongo_host, 'db' => $mongo_db_name), - 'petition_tool_archive' => array('host' => $mongo_host, 'db' => $mongo_db_name), - 'petition_tool_response' => array('host' => $mongo_host, 'db' => $mongo_db_name), - 'petition_tool_signatures' => array('host' => $mongo_host, 'db' => $mongo_db_name), - ); - $conf['mongodb_collections'] = array( - 'petitions' => 'petition_tool', - 'archive_petitions' => 'petition_tool_archive', - 'petition_response' => 'petition_tool_response', - 'petition_signatures' => 'petition_tool_signatures', - ); - - # (Optional): - # $conf['mongodb_options'] = array( - # 'replicaSet' => 'petitions', - # 'timeout' => 1, - # ); -``` - -6) To quickly, easily install the rest of the required modules, install: -* Petition Install 1 -* Petition Install 2 -* Petition Install 3 -* Petition Install 4 - -You can do this with drush by copying and pasting these commands at the command line: - -``` -drush en -y petition_install1 -drush en -y petition_install2 -drush en -y petition_install3 -drush en -y petition_install4 -``` - -Drupal will complain when you install these modules. If you ignore the error -messages and proceed, you should be able to get a site running with the -basic White House petition creation and signing workflow. - -For development, you may prefer to look at the .info files in the Petition -Install modules, and just install these one-by-one. Petition Install modules -don't actually do anything. They just make it easy to get through -installation quickly and are helpful for work currently in progress to -repackage Petition as an install profile. It doesn't harm anything to have -them on. But for development, you may not want these modules hanging around -your site adding unnecessary dependencies. - -8) The "main" profile should have these fields: First Name, Last Name, City, - State, Zip, Country. To confirm, check here: - -* `admin/structure/profiles` -* `admin/structure/profiles/manage/main/fields` - -If required profile fields are missing, revert Whitehouse User Profile (wh_user_profile) to default here: `admin/structure/features` - -9) The Petitions - User Registration (petitions_user_registration) feature module doesn't always install correctly. - -* Try revert. (Even though Rules Configuration will still say "overridden".) - `admin/structure/features` - -* Enable Rules UI (rules_admin) here: - `admin/modules` - -* Go to Rules and confirm you have two rules, user_submit, user_validate_redirect: - `admin/config/workflow/rules` - -* If these rules are missing, you can import them manually. - -* Import the rules_user_validate_redirect here (check "Overwrite"): - `admin/config/workflow/rules/reaction/import` - -```php - { "rules_user_validate_redirect" : { - "LABEL" : "user_validate_redirect", - "PLUGIN" : "reaction rule", - "TAGS" : [ "user_reg" ], - "REQUIRES" : [ "rules", "wh_core", "logintoboggan_rules" ], - "ON" : [ "logintoboggan_validated" ], - "IF" : [ - { "entity_is_of_type" : { "entity" : [ "account" ], "type" : "user" } }, - { "NOT data_is_empty" : { "data" : [ "account:field-origin" ] } } - ], - "DO" : [ - { "login_user" : { "account" : [ "account" ] } }, - { "redirect" : { "url" : "[account:field-origin]" } }, - { "data_set" : { "data" : [ "account:field-origin" ] } } - ] - } - } -``` - -Import the user_submit rule here (check "Overwrite"): -`admin/config/workflow/rules/reaction/import` - -```php - { "rules_user_submit" : { - "LABEL" : "user_submit", - "PLUGIN" : "reaction rule", - "TAGS" : [ "user_reg" ], - "REQUIRES" : [ "rules" ], - "ON" : [ "user_insert" ], - "IF" : [ - { "entity_is_of_type" : { "entity" : [ "account" ], "type" : "user" } }, - { "NOT data_is_empty" : { "data" : [ "account:field-origin" ] } } - ], - "DO" : [ { "redirect" : { "url" : "[account:field-origin]#thank-you=p" } } ] - } - } -``` - -10) By default petitions are not made public on the site until they clear a certain threshold of signatures. To collect these first signatures, signers must go directly to the petition's URL. Set the signature threshold here: - `admin/config/system/petitions` - -11) Users won't be able to create accounts and sign petitions until CAPTCHA is configured. Just to get things working, all you need to do is go here and follow the link on the config page to get an API key for your site: - `admin/config/people/captcha/recaptcha` - -12) For development, you may want to add this to settings.php: - -```php - $conf['error_level'] = 2; // Show all messages on your screen. - ini_set('display_errors', TRUE); // These lines give you content on - // "white screen of death" (WSOD) pages. - ini_set('display_startup_errors', TRUE); -``` \ No newline at end of file diff --git a/build-petition.make b/build-petition.make deleted file mode 100644 index eaeace2a5..000000000 --- a/build-petition.make +++ /dev/null @@ -1,20 +0,0 @@ -api = 2 -core = 7.x - -; Drupal -; ------- -; -; Patch to handle menu rebuild error -; @see http://drupal.org/node/972536 -; -; -------------------------------------- -projects[drupal][version] = 7.15 -projects[drupal][patch][] = http://drupal.org/files/drupal-menu-int-972536-83-D7.patch - -; Petition installation profile -; ------------------------------- -projects[petition][type] = profile -projects[petition][download][type] = git -projects[petition][download][url] = https://github.com/WhiteHouse/petition.git -projects[petition][download][branch] = 7.x-1.x -projects[petition][download][revision] = 7.x-1.0-alpha10 diff --git a/drupal-org.make b/drupal-org.make deleted file mode 100644 index 008f9b789..000000000 --- a/drupal-org.make +++ /dev/null @@ -1,164 +0,0 @@ -; Petition -; --------- - -; Core version -; ------------- -core = 7.x - -; API version -; ------------ -api = 2 - -; Contrib projects -; ----------------- -projects[advanced_help][version] = 1.0 -projects[advanced_help][subdir] = contrib - -projects[captcha][version] = 1.0-beta2 -projects[captcha][subdir] = contrib - -projects[coder][version] = 1.0-beta6 -projects[coder][subdir] = contrib - -projects[context][version] = 3.0-beta4 -projects[context][subdir] = contrib - -projects[ctools][version] = 1.2 -projects[ctools][subdir] = contrib - -projects[date][version] = 2.6 -projects[date][subdir] = contrib - -projects[devel][version] = 1.2 -projects[devel][subdir] = contrib - -projects[diff][version] = 2.0-beta2 -projects[diff][subdir] = contrib - -projects[email_confirm][version] = 1.0 -projects[email_confirm][subdir] = contrib - -projects[entity][version] = 1.0-rc3 -projects[entity][subdir] = contrib - -projects[entitycache][version] = 1.1 -projects[entitycache][subdir] = contrib - -projects[features][version] = 1.0 -projects[features][subdir] = contrib - -projects[feeds][version] = 2.0-alpha5 -projects[feeds][subdir] = contrib - -projects[forward][version] = 1.3 -projects[forward][subdir] = contrib - -projects[google_analytics][version] = 1.2 -projects[google_analytics][subdir] = contrib - -projects[imce][version] = 1.5 -projects[imce][subdir] = contrib - -projects[job_scheduler][version] = 2.0-alpha3 -projects[job_scheduler][subdir] = contrib - -projects[memcache][version] = 1.0 -projects[memcache][subdir] = contrib - -projects[metatag][version] = 1.0-alpha8 -projects[metatag][subdir] = contrib - -; TODO: Remove this? -; ------------------- -projects[migrate][version] = 2.4 -projects[migrate][subdir] = contrib - -; TODO: Remove this? -; ------------------- -projects[migrate_extras][version] = 2.4 -projects[migrate_extras][subdir] = contrib - -projects[mongodb][version] = 1.0-rc2 -projects[mongodb][subdir] = contrib - -projects[openidadmin][version] = 1.0 -projects[openidadmin][subdir] = contrib - -projects[pathauto][version] = 1.2 -projects[pathauto][subdir] = contrib - -projects[profile2][version] = 1.2 -projects[profile2][subdir] = contrib - -projects[recaptcha][version] = 1.7 -projects[recaptcha][subdir] = contrib - -projects[rules][version] = 2.2 -projects[rules][subdir] = contrib - -projects[strongarm][version] = 2.0 -projects[strongarm][subdir] = contrib - -projects[token][version] = 1.2 -projects[token][subdir] = contrib - -projects[views][version] = 3.4 -projects[views][subdir] = contrib - -projects[wysiwyg][version] = 2.1 -projects[wysiwyg][subdir] = contrib - -; Patched contrib -;----------------- - -; logintoboggan-lower-password.patch -; - Provide password token for emailing users their password upon registration -; - Performance improvement, get rid of mysql LOWER(), it creates a temp table for the whole table -; - @see http://drupal.org/node/1747878 -; -;------------------------------------ -projects[logintoboggan][version] = 1.3 -projects[logintoboggan][subdir] = contrib -projects[logintoboggan][patch][] = http://drupal.org/files/logintoboggan-lower-password.patch - -; check_type.patch -; - Data types were not checked before getting 'status' key from them -; - @see http://drupal.org/node/1572368 -; -; check_checks.patch -; - Improved error handling. -; Before we run checks, lets see if the checks for this module are enabled otherwise, break out of the loop. -; - @see http://drupal.org/node/1747870 -; -;------------------------------------ -projects[nagios][version] = 1.1 -projects[nagios][subdir] = contrib -projects[nagios][patch][] = http://drupal.org/files/check_type.patch -projects[nagios][patch][] = http://drupal.org/files/check_checks.patch - -; Contrib themes ------------------ -projects[tao][type] = theme -projects[tao][version] = 3.0-beta3 - -projects[rubik][type] = theme -projects[rubik][version] = 4.0-beta5 - - -; Custom -; TODO: FIGURE OUT WHAT TO DO WITH THESE -; --------- -; wh_core/ -; wh_feedback/ -; wh_profile_migrate/ -; wh_user_migrate/ -; wh_user_migrate_alt/ -; wh_zipcodelookup/ - - -; features -; TODO: FIGURE OUT WHAT TO DO WITH THESE -; --------- -; petitions_user_registration/ -; wh_user_profile/ -; wh_user_ss_data/ diff --git a/index.html b/index.html new file mode 100644 index 000000000..a7a271163 --- /dev/null +++ b/index.html @@ -0,0 +1,61 @@ + + + + + \ No newline at end of file diff --git a/make/7.x-1.x-alpha10/build-petition.make b/make/7.x-1.x-alpha10/build-petition.make deleted file mode 100644 index eaeace2a5..000000000 --- a/make/7.x-1.x-alpha10/build-petition.make +++ /dev/null @@ -1,20 +0,0 @@ -api = 2 -core = 7.x - -; Drupal -; ------- -; -; Patch to handle menu rebuild error -; @see http://drupal.org/node/972536 -; -; -------------------------------------- -projects[drupal][version] = 7.15 -projects[drupal][patch][] = http://drupal.org/files/drupal-menu-int-972536-83-D7.patch - -; Petition installation profile -; ------------------------------- -projects[petition][type] = profile -projects[petition][download][type] = git -projects[petition][download][url] = https://github.com/WhiteHouse/petition.git -projects[petition][download][branch] = 7.x-1.x -projects[petition][download][revision] = 7.x-1.0-alpha10 diff --git a/make/7.x-1.x-alpha10/drupal-org.make b/make/7.x-1.x-alpha10/drupal-org.make deleted file mode 100644 index 008f9b789..000000000 --- a/make/7.x-1.x-alpha10/drupal-org.make +++ /dev/null @@ -1,164 +0,0 @@ -; Petition -; --------- - -; Core version -; ------------- -core = 7.x - -; API version -; ------------ -api = 2 - -; Contrib projects -; ----------------- -projects[advanced_help][version] = 1.0 -projects[advanced_help][subdir] = contrib - -projects[captcha][version] = 1.0-beta2 -projects[captcha][subdir] = contrib - -projects[coder][version] = 1.0-beta6 -projects[coder][subdir] = contrib - -projects[context][version] = 3.0-beta4 -projects[context][subdir] = contrib - -projects[ctools][version] = 1.2 -projects[ctools][subdir] = contrib - -projects[date][version] = 2.6 -projects[date][subdir] = contrib - -projects[devel][version] = 1.2 -projects[devel][subdir] = contrib - -projects[diff][version] = 2.0-beta2 -projects[diff][subdir] = contrib - -projects[email_confirm][version] = 1.0 -projects[email_confirm][subdir] = contrib - -projects[entity][version] = 1.0-rc3 -projects[entity][subdir] = contrib - -projects[entitycache][version] = 1.1 -projects[entitycache][subdir] = contrib - -projects[features][version] = 1.0 -projects[features][subdir] = contrib - -projects[feeds][version] = 2.0-alpha5 -projects[feeds][subdir] = contrib - -projects[forward][version] = 1.3 -projects[forward][subdir] = contrib - -projects[google_analytics][version] = 1.2 -projects[google_analytics][subdir] = contrib - -projects[imce][version] = 1.5 -projects[imce][subdir] = contrib - -projects[job_scheduler][version] = 2.0-alpha3 -projects[job_scheduler][subdir] = contrib - -projects[memcache][version] = 1.0 -projects[memcache][subdir] = contrib - -projects[metatag][version] = 1.0-alpha8 -projects[metatag][subdir] = contrib - -; TODO: Remove this? -; ------------------- -projects[migrate][version] = 2.4 -projects[migrate][subdir] = contrib - -; TODO: Remove this? -; ------------------- -projects[migrate_extras][version] = 2.4 -projects[migrate_extras][subdir] = contrib - -projects[mongodb][version] = 1.0-rc2 -projects[mongodb][subdir] = contrib - -projects[openidadmin][version] = 1.0 -projects[openidadmin][subdir] = contrib - -projects[pathauto][version] = 1.2 -projects[pathauto][subdir] = contrib - -projects[profile2][version] = 1.2 -projects[profile2][subdir] = contrib - -projects[recaptcha][version] = 1.7 -projects[recaptcha][subdir] = contrib - -projects[rules][version] = 2.2 -projects[rules][subdir] = contrib - -projects[strongarm][version] = 2.0 -projects[strongarm][subdir] = contrib - -projects[token][version] = 1.2 -projects[token][subdir] = contrib - -projects[views][version] = 3.4 -projects[views][subdir] = contrib - -projects[wysiwyg][version] = 2.1 -projects[wysiwyg][subdir] = contrib - -; Patched contrib -;----------------- - -; logintoboggan-lower-password.patch -; - Provide password token for emailing users their password upon registration -; - Performance improvement, get rid of mysql LOWER(), it creates a temp table for the whole table -; - @see http://drupal.org/node/1747878 -; -;------------------------------------ -projects[logintoboggan][version] = 1.3 -projects[logintoboggan][subdir] = contrib -projects[logintoboggan][patch][] = http://drupal.org/files/logintoboggan-lower-password.patch - -; check_type.patch -; - Data types were not checked before getting 'status' key from them -; - @see http://drupal.org/node/1572368 -; -; check_checks.patch -; - Improved error handling. -; Before we run checks, lets see if the checks for this module are enabled otherwise, break out of the loop. -; - @see http://drupal.org/node/1747870 -; -;------------------------------------ -projects[nagios][version] = 1.1 -projects[nagios][subdir] = contrib -projects[nagios][patch][] = http://drupal.org/files/check_type.patch -projects[nagios][patch][] = http://drupal.org/files/check_checks.patch - -; Contrib themes ------------------ -projects[tao][type] = theme -projects[tao][version] = 3.0-beta3 - -projects[rubik][type] = theme -projects[rubik][version] = 4.0-beta5 - - -; Custom -; TODO: FIGURE OUT WHAT TO DO WITH THESE -; --------- -; wh_core/ -; wh_feedback/ -; wh_profile_migrate/ -; wh_user_migrate/ -; wh_user_migrate_alt/ -; wh_zipcodelookup/ - - -; features -; TODO: FIGURE OUT WHAT TO DO WITH THESE -; --------- -; petitions_user_registration/ -; wh_user_profile/ -; wh_user_ss_data/ diff --git a/make/7.x-1.x-auto/build-petition.make b/make/7.x-1.x-auto/build-petition.make deleted file mode 100644 index d80081bd6..000000000 --- a/make/7.x-1.x-auto/build-petition.make +++ /dev/null @@ -1,19 +0,0 @@ -api = 2 -core = 7.x -projects[] = drupal - -; Drupal -; ------- -; -; Patch to handle menu rebuild error -; @see http://drupal.org/node/972536 -; -; -------------------------------------- -projects[drupal][patch][] = http://drupal.org/files/drupal-menu-int-972536-83-D7.patch - -; Petition installation profile -; ------------------------------- -projects[petition][type] = profile -projects[petition][download][type] = git -projects[petition][download][url] = https://github.com/WhiteHouse/petition.git -projects[petition][download][branch] = 7.x-1.x diff --git a/make/7.x-1.x-auto/drupal-org.make b/make/7.x-1.x-auto/drupal-org.make deleted file mode 100644 index f6ff2cfa1..000000000 --- a/make/7.x-1.x-auto/drupal-org.make +++ /dev/null @@ -1,129 +0,0 @@ -; Petition -; --------- - -; Core version -; ------------- -core = 7.x - -; API version -; ------------ -api = 2 - -; Contrib projects -; ----------------- -projects[advanced_help][subdir] = contrib - -projects[captcha][subdir] = contrib - -projects[coder][subdir] = contrib - -projects[context][subdir] = contrib - -projects[ctools][subdir] = contrib - -projects[date][subdir] = contrib - -projects[devel][subdir] = contrib - -projects[diff][subdir] = contrib - -projects[email_confirm][subdir] = contrib - -projects[entity][subdir] = contrib - -projects[entitycache][subdir] = contrib - -projects[features][subdir] = contrib - -projects[feeds][subdir] = contrib - -projects[forward][subdir] = contrib - -projects[google_analytics][subdir] = contrib - -projects[imce][subdir] = contrib - -projects[job_scheduler][subdir] = contrib - -projects[memcache][subdir] = contrib - -projects[metatag][subdir] = contrib - -; TODO: Remove this? -; ------------------- -projects[migrate][subdir] = contrib - -; TODO: Remove this? -; ------------------- -projects[migrate_extras][subdir] = contrib - -projects[mongodb][subdir] = contrib - -projects[openidadmin][subdir] = contrib - -projects[pathauto][subdir] = contrib - -projects[profile2][subdir] = contrib - -projects[recaptcha][subdir] = contrib - -projects[rules][subdir] = contrib - -projects[strongarm][subdir] = contrib - -projects[token][subdir] = contrib - -projects[views][subdir] = contrib - -projects[wysiwyg][subdir] = contrib - -; Patched contrib -;----------------- - -; logintoboggan-lower-password.patch -; - Provide password token for emailing users their password upon registration -; - Performance improvement, get rid of mysql LOWER(), it creates a temp table for the whole table -; - @see http://drupal.org/node/1747878 -; -;------------------------------------ -projects[logintoboggan][subdir] = contrib -projects[logintoboggan][patch][] = http://drupal.org/files/logintoboggan-lower-password.patch - -; check_type.patch -; - Data types were not checked before getting 'status' key from them -; - @see http://drupal.org/node/1572368 -; -; check_checks.patch -; - Improved error handling. -; Before we run checks, lets see if the checks for this module are enabled otherwise, break out of the loop. -; - @see http://drupal.org/node/1747870 -; -;------------------------------------ -projects[nagios][subdir] = contrib -projects[nagios][patch][] = http://drupal.org/files/check_type.patch -projects[nagios][patch][] = http://drupal.org/files/check_checks.patch - -; Contrib themes ------------------ -projects[tao][type] = theme - -projects[rubik][type] = theme - - -; Custom -; TODO: FIGURE OUT WHAT TO DO WITH THESE -; --------- -; wh_core/ -; wh_feedback/ -; wh_profile_migrate/ -; wh_user_migrate/ -; wh_user_migrate_alt/ -; wh_zipcodelookup/ - - -; features -; TODO: FIGURE OUT WHAT TO DO WITH THESE -; --------- -; petitions_user_registration/ -; wh_user_profile/ -; wh_user_ss_data/ diff --git a/make/7.x-1.x/build-petition.make b/make/7.x-1.x/build-petition.make deleted file mode 100644 index d80081bd6..000000000 --- a/make/7.x-1.x/build-petition.make +++ /dev/null @@ -1,19 +0,0 @@ -api = 2 -core = 7.x -projects[] = drupal - -; Drupal -; ------- -; -; Patch to handle menu rebuild error -; @see http://drupal.org/node/972536 -; -; -------------------------------------- -projects[drupal][patch][] = http://drupal.org/files/drupal-menu-int-972536-83-D7.patch - -; Petition installation profile -; ------------------------------- -projects[petition][type] = profile -projects[petition][download][type] = git -projects[petition][download][url] = https://github.com/WhiteHouse/petition.git -projects[petition][download][branch] = 7.x-1.x diff --git a/make/7.x-1.x/drupal-org.make b/make/7.x-1.x/drupal-org.make deleted file mode 120000 index 042cd0d67..000000000 --- a/make/7.x-1.x/drupal-org.make +++ /dev/null @@ -1 +0,0 @@ -../../drupal-org.make \ No newline at end of file diff --git a/modules/custom/README.txt b/modules/custom/README.txt deleted file mode 100644 index 51bc20a09..000000000 --- a/modules/custom/README.txt +++ /dev/null @@ -1 +0,0 @@ -Custom modules will go here diff --git a/modules/custom/govdelivery/govdelivery.admin-reports.inc b/modules/custom/govdelivery/govdelivery.admin-reports.inc deleted file mode 100644 index 071ffdb83..000000000 --- a/modules/custom/govdelivery/govdelivery.admin-reports.inc +++ /dev/null @@ -1,176 +0,0 @@ - 'Subject'), - array( - 'data' => 'Created', - 'field' => 'created', - 'sort' => 'DESC', - ), - array('data' => 'Form'), - ); - - // Query the database for the data. - // $dataquery = "SELECT FROM_DAYS(TO_DAYS(FROM_UNIXTIME(created))) day, cid FROM {" . $queue . "} GROUP BY day, cid " . tablesort_sql($header); - // $countquery = "SELECT COUNT(*) FROM {" . $queue . "}"; - // $result = pager_query($dataquery, 30, 0, $countquery); - - $query = db_select('govdelivery_message_queue', 'q') - ->extend('PagerDefault') - ->extend('TableSort') - ->limit(30) - ->fields('q', array('created', 'cid')) - ->groupBy('created') - ->groupBy('cid'); - $result = $query->execute(); - - // Assign data to rows. - $rows = array(); - - foreach ($result as $queuedmessage) { -// Get the message unserialized. - $queuedmessage->data = govdelivery_queue_get($queue, $queuedmessage->cid); -// Build the row. - if (isset($queuedmessage->data) && !empty($queuedmessage->data)) { - $subject_text = $queuedmessage->data['subject'] ? $queuedmessage->data['subject'] : t('(no subject)'); - $subject_link = l($subject_text, 'admin/reports/govdelivery_message_queue/details/' . $queuedmessage->cid); - $rows[] = array($subject_link, $queuedmessage->created, check_plain($queuedmessage->data['id'])); - } - } - // End foreach. - - // Empty dataset message. - if (empty($rows)) { - $rows[] = array(array( - 'data' => t('No messages currently in the queue.'), - 'colspan' => 3, - )); - } - - $output = theme('table', array('header' => $header, 'rows' => $rows)); - $output .= theme('pager', array('tags' => NULL, 'element' => 0)); - - return $output; -} -// End govdelivery_message_queue_status. - -// View a single message in the queue. -/** - * @todo Please document this function. - * @see http://drupal.org/node/1354 - */ -function govdelivery_details($cid) { - $output = ''; - - $queue = 'govdelivery_message_queue'; - // Build a table to display the message details. - if (!empty($cid)) { - // Get the message unserialized. - $queuedmessage = govdelivery_queue_get($queue, $cid); - if ($queuedmessage != 0) { - // Setup table fields mapping to the data. - $header = array( - array('data' => t('Field')), - array('data' => t('Value')), - ); - // Setup the rows. - $rows = array( - array('CID', check_plain($cid)), - array('ID', check_plain($queuedmessage['id'])), - array('Module', (isset($queuedmessage['module']) ? check_plain($queuedmessage['module']) : '')), - array('Key', (isset($queuedmessage['key']) ? check_plain($queuedmessage['key']) : '')), - array('To', check_plain($queuedmessage['to'])), - array('Subject', (isset($queuedmessage['subject']) ? check_plain($queuedmessage['subject']) : '')), - array('Body', (isset($queuedmessage['body']) ? check_plain($queuedmessage['body']) : '')), - ); - // Language - if (isset($queuedmessage['language']) && !empty($queuedmessage['language'])) { - if (is_object($queuedmessage['language'])) { - $rows[] = array('Language', check_plain($queuedmessage['language']->language)); - } - else { - $rows[] = array('Language', check_plain($queuedmessage['language'])); - } - } - //params - if (isset($queuedmessage['params']) && is_array($queuedmessage['params'])) { - foreach($queuedmessage['params'] as $key => $value) { - $rows[] = array(check_plain($key), check_plain($value)); - } - } - //headers - if (isset($queuedmessage['headers']) && is_array($queuedmessage['headers'])) { - foreach($queuedmessage['headers'] as $key => $value) { - $rows[] = array(check_plain($key), check_plain($value)); - } - } - - } - } - - // Empty dataset message. - // If the data set is empty dont load the form. - if (empty($rows)) { - $rows[] = array(array( - 'data' => t('Message no longer in the queue.'), - 'colspan' => 2, - )); - } - else { - // Im in extreme disstress here as referenced in http://drupal.org/node/224333#unrendered - // I don't have time or the will to rewrite this whole report. - // @todo make this support views and vbo and provide a base report. - $output .= drupal_render(drupal_get_form('govdelivery_details_form', check_plain($cid))); - } - $output .= theme('table', array('header' => $header, 'rows' => $rows)); - - return $output; -} - -// A form to send a message immediately. -/** - * @todo Please document this function. - * @see http://drupal.org/node/1354 - */ -function govdelivery_details_form($form, $cid) { - $form = array( - 'govdelivery_details' => array( - '#type' => 'fieldset', - '#title' => t('Message Actions'), - '#tree' => TRUE, - '#collapsible' => TRUE, - 'cid' => array( - '#type' => 'value', - '#value' => $cid, - ), - 'send' => array( - '#type' => 'submit', - '#value' => t('Send Now'), - ), - ), - ); - return $form; -} - -/** - * @todo Please document this function. - * @see http://drupal.org/node/1354 - */ -function govdelivery_details_form_submit($form, &$postinfo) { - $cid = $postinfo['build_info']['args'][0]; - // Send the message from the queue immediately. - if (!empty($cid)) { - $sent = govdelivery_process_message_queue(NULL, FALSE, $cid); - drupal_set_message(t('Messages sent from the queue: @sent', array('@sent' => $sent))); - } - $postinfo['redirect'] = 'admin/reports/govdelivery_message_queue'; -} diff --git a/modules/custom/govdelivery/govdelivery.admin.inc b/modules/custom/govdelivery/govdelivery.admin.inc deleted file mode 100644 index 03b1e331e..000000000 --- a/modules/custom/govdelivery/govdelivery.admin.inc +++ /dev/null @@ -1,336 +0,0 @@ - 'fieldset', - '#title' => t('Mail Accounts'), - ); - - if (isset($govdelivery_odm_settings) && isset($govdelivery_odm_settings['accounts']) && is_array($govdelivery_odm_settings['accounts'])) { - foreach ($govdelivery_odm_settings['accounts'] as $username => $account_settings) { - $account_fieldset[$username . '%###%' . 'fromname'] = array( - '#type' => "textfield", - '#title' => t('From Name'), - '#default_value' => check_plain((!empty($account_settings['fromname']) ? $account_settings['fromname'] : '')), - ); - $account_fieldset[$username . '%###%' . 'username'] = array( - '#type' => "textfield", - '#title' => t('Username'), - '#default_value' => check_plain((!empty($username) ? $username : '')), - ); - $account_fieldset[$username . '%###%' . 'password'] = array( - '#type' => "textfield", - '#title' => t('Password'), - '#default_value' => '', - ); - } - } - - $account_fieldset['fromname'] = array( - '#type' => "textfield", - '#title' => t('From Name'), - ); - $account_fieldset['username'] = array( - '#type' => "textfield", - '#title' => t('Username'), - ); - $account_fieldset['password'] = array( - '#type' => "textfield", - '#title' => t('Password'), - ); - - $subscription_fieldset = array( - '#type' => 'fieldset', - '#title' => t('Subscription API'), - '#tree' => TRUE, - ); - - $subscription_fieldset['service_url'] = array( - '#type' => "textfield", - '#title' => t('URL for Subscription Service'), - '#default_value' => (!empty($govdelivery_subscription_settings['service_url']) ? check_url($govdelivery_subscription_settings['service_url']) : ''), - ); - - $subscription_fieldset['cron_subscriptions'] = array( - '#type' => 'radios', - '#default_value' => (isset($govdelivery_subscription_settings['cron_subscriptions']) ? $govdelivery_subscription_settings['cron_subscriptions'] : 1), - '#title' => t('Subscriptions Cron (Will automatically resend the subscriptions queue on cron runs)'), - '#options' => array('Disabled', 'Enabled'), - ); - - $subscription_fieldset['subscriber_api_url_base'] = array( - '#type' => 'textfield', - '#title' => t('Base URL for Subscriber API'), - '#default_value' => (!empty($govdelivery_subscription_settings['subscriber_api_url_base']) ? check_url($govdelivery_subscription_settings['subscriber_api_url_base']) : ''), - ); - - $subscription_fieldset['default_topic_category_id'] = array( - '#type' => 'textfield', - '#title' => t('Default Category assigned to new Topics.'), - '#default_value' => (!empty($govdelivery_subscription_settings['default_topic_category_id']) ? $govdelivery_subscription_settings['default_topic_category_id'] : ''), - ); - - $form = array( - 'govdelivery_odm_settings' => array( - '#type' => 'fieldset', - '#title' => t('Mail Server Settings'), - '#tree' => TRUE, - 'accounts' => $account_fieldset, - 'server' => array( - '#type' => "textfield", - '#title' => 'server', - '#default_value' => (!empty($govdelivery_odm_settings['server']) ? check_url($govdelivery_odm_settings['server']) : ''), - ), - 'enabled' => array( - '#type' => 'radios', - '#default_value' => (isset($govdelivery_odm_settings['enabled']) ? $govdelivery_odm_settings['enabled'] : 0), - '#title' => t('Outbound mail rerouting'), - '#options' => array('Disabled', 'Enabled'), - ), - 'queue' => array( - '#type' => 'radios', - '#default_value' => (isset($govdelivery_odm_settings['queue']) ? $govdelivery_odm_settings['queue'] : 1), - '#title' => t('Queue Messages (Messages that fail to send are queued regardless of this setting)'), - '#options' => array('Disabled', 'Enabled'), - ), - 'cron_odm' => array( - '#type' => 'radios', - '#default_value' => (isset($govdelivery_odm_settings['cron_odm']) ? $govdelivery_odm_settings['cron_odm'] : 1), - '#title' => t('Messages Cron (Will automatically resend the messages queue on cron runs)'), - '#options' => array('Disabled', 'Enabled'), - ), - 'override_from' => array( - '#type' => 'radios', - '#default_value' => (isset($govdelivery_odm_settings['override_from']) ? $govdelivery_odm_settings['override_from'] : 0), - '#title' => t('Override the From address on outgoing messages and failback on the predefined From address in this module. - (This will allow webforms and other modules to configure the From address)'), - '#options' => array('Disabled', 'Enabled'), - ), - 'max_bid' => array( - '#type' => 'textfield', - '#title' => t('Maximum bins used with queue asynchronous processing.'), - '#default_value' => (isset($govdelivery_odm_settings['max_bid']) ? $govdelivery_odm_settings['max_bid'] : 5), - ), - 'external_cron_interval' => array( - '#type' => 'textfield', - '#title' => t('External Cron Interval (in seconds).'), - '#default_value' => (isset($govdelivery_odm_settings['external_cron_interval']) ? $govdelivery_odm_settings['external_cron_interval'] : 120), - ), - ), - 'govdelivery_subscription_settings' => $subscription_fieldset, - 'save' => array( - '#type' => 'submit', - '#value' => 'Save Configuration', - ), - ); - - return $form; -// return system_settings_form($form); -} - -/** - * @todo Please document this function. - * @see http://drupal.org/node/1354 - */ -function govdelivery_settings_submit($form, $postinfo) { - $govdelivery_odm_settings = variable_get('govdelivery_odm_settings', array()); - $govdelivery_subscription_settings = variable_get('govdelivery_subscription_settings', array()); - $account_settings = isset($govdelivery_odm_settings['accounts']) ? $govdelivery_odm_settings['accounts'] : array(); - $new_account = array(); - - // change around the account storage to an associative array indexed by username - $accounts_posted = $postinfo['values']['govdelivery_odm_settings']['accounts']; - foreach ($accounts_posted as $composite_key => $value) { - // if we don't have a value we don't want to do anything - if (isset($value) && !empty($value)) { - $key_elements = explode('%###%', $composite_key); - if (count($key_elements) == 2) { - $username = $key_elements[0]; - $field = $key_elements[1]; - - if (!isset($account_settings[$username]) && isset($username) && !empty($username)) { - $account_settings[$username] = array(); - } - if ($field != 'username') { - $account_settings[$username][$field] = $value; - } - } - else { - if (isset($key_elements[0])) { - $new_account[$key_elements[0]] = $value; - } - } - } - } - - if (isset($new_account['username'])) { - $account_settings[$new_account['username']] = array( - "password" => $new_account['password'], - "fromname" => $new_account['fromname'], - ); - } - $govdelivery_odm_settings['accounts'] = $account_settings; - - // Server - $server = $postinfo['values']['govdelivery_odm_settings']['server']; - $govdelivery_odm_settings['server'] = check_url($server); - - // Subscription URL - $service_url = $postinfo['values']['govdelivery_subscription_settings']['service_url']; - $govdelivery_subscription_settings['service_url'] = check_url($service_url); - - // These come in as array place value so 0 or 1. - // Queue Messages - $govdelivery_odm_settings['queue'] = $postinfo['values']['govdelivery_odm_settings']['queue']; - - // Messages Cron - $govdelivery_odm_settings['cron_odm'] = $postinfo['values']['govdelivery_odm_settings']['cron_odm']; - - // Override From address - $govdelivery_odm_settings['override_from'] = $postinfo['values']['govdelivery_odm_settings']['override_from']; - - // Subscriptions Cron - $govdelivery_subscription_settings['cron_subscriptions'] = $postinfo['values']['govdelivery_subscription_settings']['cron_subscriptions']; - - // Subscriber API Base URL - $govdelivery_subscription_settings['subscriber_api_url_base'] = $postinfo['values']['govdelivery_subscription_settings']['subscriber_api_url_base']; - - // Default Category ID when creating new topics. - $govdelivery_subscription_settings['default_topic_category_id'] = $postinfo['values']['govdelivery_subscription_settings']['default_topic_category_id']; - - // Asynchronous Processing Max BID - $govdelivery_odm_settings['max_bid'] = $postinfo['values']['govdelivery_odm_settings']['max_bid']; - - $govdelivery_odm_settings['external_cron_interval'] = $postinfo['values']['govdelivery_odm_settings']['external_cron_interval']; - - // Mail Routing - $govdelivery_odm_settings['enabled'] = $postinfo['values']['govdelivery_odm_settings']['enabled']; - if ($govdelivery_odm_settings['enabled'] == 1) { - $mail_system = variable_get('mail_system'); - $mail_system['default-system'] = 'GovDeliveryMailSystem'; - variable_set('mail_system', $mail_system); - } - else { - $mail_system = variable_get('mail_system'); - if (isset($mail_system) && !empty($mail_system['default-system'])) { - $mail_system['default-system'] = 'DefaultMailSystem'; - variable_set('mail_system', $mail_system); - } - } - - // Save the validated changes - variable_set('govdelivery_subscription_settings', $govdelivery_subscription_settings); - variable_set('govdelivery_odm_settings', $govdelivery_odm_settings); -} - -// Send a test message to the specificed addresses. -/** - * @todo Please document this function. - * @see http://drupal.org/node/1354 - */ -function govdelivery_test_settings($form, &$form_state) { - $form = array( - 'govdelivery_test_settings' => array( - '#type' => 'fieldset', - '#title' => t('GovDelivery Test Settings'), - '#tree' => TRUE, - 'from' => array( - '#type' => 'textfield', - '#title' => t('From address (Optional)'), - ), - 'recipients' => array( - '#type' => 'textfield', - '#title' => t('Recipient\'s Email (Comma seperated)'), - ), - 'test' => array( - '#type' => 'submit', - '#value' => t('Send test message'), - ), - ), - ); - - return $form; -} - -/** - * @todo Please document this function. - * @see http://drupal.org/node/1354 - */ -function govdelivery_test_settings_submit($form, $postinfo) { - $recipients = $postinfo['values']['govdelivery_test_settings']['recipients']; - // Send message. - if (isset($recipients) && !empty($recipients)) { - $from = $postinfo['values']['govdelivery_test_settings']['from']; - // Pass on the list to be sent. - if(!empty($from)) { - $status = govdelivery_send_test_message($recipients, $from); - } - else { - $status = govdelivery_send_test_message($recipients); - } - } - drupal_set_message(t('Your test message has been sent.')); -} - -/** - * @todo Please document this function. - * @see http://drupal.org/node/1354 - */ -function govdelivery_send_test_message($send_to, $from = NULL) { - return drupal_mail('govdelivery', 'test_id', $send_to, language_default(), array(), $from, TRUE); -} - -// Signup an email address for a specified list and pass any known questions and answers along. -/** - * @todo Please document this function. - * @see http://drupal.org/node/1354 - */ -function govdelivery_test_subscriptions($form, &$form_state) { - $form = array( - 'govdelivery_test_subscriptions' => array( - '#type' => 'fieldset', - '#title' => t('GovDelivery Settings Test - Subscriptions'), - '#tree' => TRUE, - 'subscriber' => array( - '#type' => 'textfield', - '#title' => t('Subscriber\'s Email'), - ), - 'list_code' => array( - '#type' => 'textfield', - '#title' => t('Subscription List Code'), - ), - // Use Queue option - 'test' => array( - '#type' => 'submit', - '#value' => t('Test send message'), - ), - ), - ); - - return $form; -} - -// Need validation that there is only one subscriber or change to handle multiple subscriptions. - -/** - * @todo Please document this function. - * @see http://drupal.org/node/1354 - */ -function govdelivery_test_subscriptions_submit($form, $postinfo) { - $subscriber = $postinfo['values']['govdelivery_test_subscriptions']['subscriber']; - $list_code = $postinfo['values']['govdelivery_test_subscriptions']['list_code']; - - //if (isset($subscriber) && !empty($subscriber) && isset($list_code) && !empty($list_code)) { - $status = govdelivery_subscribe($list_code, $subscriber, FALSE); - //} - - drupal_set_message(t('%response', array('%response' => $status ? 'Subscription Added.' : 'Subscription Failed.'))); -} - diff --git a/modules/custom/govdelivery/govdelivery.drush.inc b/modules/custom/govdelivery/govdelivery.drush.inc deleted file mode 100644 index 507dfb181..000000000 --- a/modules/custom/govdelivery/govdelivery.drush.inc +++ /dev/null @@ -1,333 +0,0 @@ - 'drush_govdelivery_send_queue', - // a short description of your command - 'description' => "Send the messages in the govdelivery queue", - 'arguments' => array( - 'type' => 'The type of the queue that should be sent.', - 'bid' => 'The bin id range to send in form \'1,10\'', - 'num' => 'The number of messages to send at a time', - ), - 'aliases' => array('govds'), - ); - - // the key in the $items array is the name of the command. - $items['govdelivery-test'] = array( - // the name of the function implementing your command. - 'callback' => 'drush_govdelivery_send_test_message', - // a short description of your command - 'description' => "Send a test message using the GovDelivery service test functionality.", - 'arguments' => array( - 'addresses' => 'Email to send a test message to.', - 'num' => 'Number of messages to queue.', - ), - ); - - // the key in the $items array is the name of the command. - $items['govdelivery-subscribe'] = array( - // the name of the function implementing your command. - 'callback' => 'govdelivery_drush_subscribe', - // a short description of your command - 'description' => "Sends subscriptions from the subscription queue.", - 'arguments' => array( - 'code' => 'List code for subscription', - 'addresses' => 'Email to subscribe', - ), - ); - - // the key in the $items array is the name of the command. - $items['govdelivery-dump-subscriptions'] = array( - // the name of the function implementing your command. - 'callback' => 'govdelivery_drush_dump_subscriptions', - // a short description of your command - 'description' => "Dump subscriptions for a specific topic from the subscriber api subscription queue.", - 'arguments' => array( - 'topic' => 'List code for subscription', - ), - ); - - $items['govdelivery-test-topic'] = array( - 'callback' => 'govdelivery_drush_test_topic', - 'description' => 'Add a test topic to the queue for sending.', - 'arguments' => array( - 'title' => 'Title of the topic', - 'short_title' => 'Short Title of the topic.', - 'topic_id' => 'Manually set topic id', - 'num' => 'Number of topics to create, title will be used as a prefix.', - ), - ); - - $items['govdelivery-test-subscribe'] = array( - 'callback' => 'govdelivery_drush_test_subscriber', - 'description' => 'Add a test subsciber to the queue for sending.', - 'arguments' => array( - 'email' => 'The subscribers email address.', - 'title' => 'The title of the topic. Optional', - 'topic_id' => 'The topic id. Optional', - 'num' => 'Optional number of times to subscriber.', - ), - ); - - $items['govdelivery-delivery-report'] = array( - 'callback' => 'govdelivery_drush_delivery_report', - 'description' => 'Returns up the number of results desired since the sequence provided or from the begining of time.', - 'arguments' => array( - 'results' => 'The number of results to return upto 10000', - 'sequence' => 'The sequence id to pull results with.', - ), - ); - - return $items; -} - -/** - * Implements hook_drush_help(). - * - * This function is called whenever a drush user calls - * 'drush help ' - * - * @param $section - * - * @internal param $ A string with the help section (prepend with 'drush:')* A string with the help section (prepend with 'drush:') - * - * @return #Fdt|? A string with the help text for your command. - */ -function govdelivery_drush_help($section) { - switch ($section) { - case 'drush:govdelivery send': - return dt("Send messages or subscriptions from the govdelivery queues."); - case 'drush:govdelivery test': - return dt("Sends a test message using govdelivery (this may be queued or sent immediately depending on the settings.)"); - case 'drush:govdelivery subscribe': - return dt("Subscribes a user to a list managed by govdelivery (this may be queued or sent immediately depending on the settings.)"); - } -} - -/** - * @return array - */ -function drush_govdelievery_queue_types() { - $types = array( - 'messages' => array('govdelivery_process_message_queue'), - 'subscribers' => array('govdelivery_process_subscription_queue'), - 'topics' => array('govdelivery_process_subscriber_api_topic_queue'), - 'api_subscribers' => array('govdelivery_process_subscriber_api_subscriber_queue'), - ); - return $types; -} - -/** - * Send messages from the govdelivery queue. - * - * @param null $type - * @param null $bid - * @param null $num - * - * @internal param $ The number of messages to send from the queue.* The number of messages to send from the queue. - */ -function drush_govdelivery_send_queue($type = NULL, $bid = NULL, $num = NULL) { - $types = drush_govdelievery_queue_types(); - if ($type) { - $choice = $type; - } - else { - $choice = drush_choice($types, 'Which queue would you like to process', '!key'); - } - - $messages_sent = call_user_func( - $types[$choice][0], // Function to call. - $num, // Max number of items. - TRUE, // Ignore Execution Time Limit. - NULL, // CID for sending a single message. - $bid); // The Range of Bin IDs in form '1,10'. - - if ( ( $messages_sent ) || ( $messages_sent === 0 ) ) { - drush_log("Queue has been processed, " . $messages_sent . " messages sent.", 'completed'); - } - else { - drush_log("Queue could not be processed. Check watchdog for errors.", 'failed', TRUE); - } -} - -/** - * @param $address - * @param null $num - * @return bool - */ -function drush_govdelivery_send_test_message($address, $num = NULL) { - module_load_include('inc', 'govdelivery', 'govdelivery.admin'); - if ( !isset($address) ) { - drush_log("Cannot send a test message without an address to send to", 'failed', TRUE); - return FALSE; - } - - if (is_numeric($num)) { - for($i = 0; $i < $num; $i++) { - $success = govdelivery_send_test_message($address); - } - } - else { - $success = govdelivery_send_test_message($address); - } - - if ( $success ) { - drush_log("Test message has been queued. It will be sent the next time the queue is processed.", 'completed'); - } - else { - drush_log("Sending a test message failed", 'failed', TRUE); - } - - return $success; -} - -/** - * @param $code - * @param $address - * @return bool - */ -function govdelivery_drush_subscribe($code, $address) { - $success = govdelivery_subscribe($code, $address); - if ( $success ) { - drush_log("User has been subscribed to the list", 'completed'); - } - else { - drush_log("User could not be subscribed", 'failed', TRUE); - } - return $success; -} - -/** - * @param $topic_id - * @return bool - */ -function govdelivery_drush_dump_subscriptions($topic_id) { - if (!is_string($topic_id)) { return FALSE; } - $topic_id = 'petitions_' . $topic_id; - $queue = 'govdelivery_subscriber_api_subscriber_queue'; - $query = db_select($queue, 'q'); - $query->fields('q', array('data', 'created', 'expire', 'serialized')); - - $result = $query->execute(); -//var_dump($result); -//var_dump($result->fetchObject()); - - $handle = fopen('/tmp/subscriber_export_' . time() . '.csv', 'x+'); - fwrite($handle, 'email' . PHP_EOL); - - while($message = $result->fetchObject()) { - if (isset($message->data) && !empty($message->data)) { - $message->data = unserialize($message->data); - if (is_string($message->data->email) && is_string($message->data->title)) { - if ($message->data->title === $topic_id) { - var_dump($message); - fwrite($handle, $message->data->email . ',' . PHP_EOL); - } - } - } - } - fclose($handle); -} - -/** - * @param $title - * @param string $short_title - * @param null $topic_id - * @param null $num - * @return - */ -function govdelivery_drush_test_topic ($title, $short_title = '', $topic_id = NULL, $num = NULL) { - $topics = 0; - - if(is_numeric($num)) { - for ($i = 0; $i < $num; $i++) { - $topics += govdelivery_subscriber_api_add_topic($title . $i, $short_title, $topic_id); - } - } - else { - $topics += govdelivery_subscriber_api_add_topic($title, $short_title, $topic_id); - } - - return $topics; -} - -/** - * @param $email - * @param null $title - * @param null $topic_id - * @param null $num - * @return bool - */ -function govdelivery_drush_test_subscriber($email, $title = NULL, $topic_id = NULL, $num = NULL) { - $subscribed = 0; - - if(is_numeric($num)) { - for ($i = 0; $i < $num; $i++) { - $subscribed += govdelivery_subscriber_api_add_subscriber($email, $title, $topic_id); - } - } - else { - $subscribed = govdelivery_subscriber_api_add_subscriber($email, $title, $topic_id); - } - - return $subscribed; -} - -function govdelivery_drush_delivery_report($results = 100, $sequence = '') { - $govdelivery_odm_settings = variable_get('govdelivery_odm_settings', array()); - - $account_map = variable_get("govdelivery_account_map", NULL); - $account = $account_map['default']; - if (!isset($account) || empty($account)) { - watchdog('govdelivery', 'No default account specified. Check settings.php.', NULL, WATCHDOG_ERROR); - return FALSE; - } - - require_once('odmService.php'); - - $credentials = new ODMCredentials($account, $govdelivery_odm_settings['accounts'][$account]['password']); - $service = new odmService($govdelivery_odm_settings['server'], $credentials); - - $activity = new ODMDeliveryActivitySince(); - $activity->maxResults = $results; - $activity->sequence = $sequence; - $result = $service->deliveryActivitySince($activity); - - $rows[] = array('Message ID', 'Email', 'Status', 'Time'); - foreach($result->delivery as $item) { - $rows[] = array($item->messageID, $item->address, $item->delivered, $item->at); - } - drush_print_table($rows, TRUE, array(), NULL); - drush_print('Sequence: ' . $result->nextSequence); - - return; -} diff --git a/modules/custom/govdelivery/govdelivery.info b/modules/custom/govdelivery/govdelivery.info deleted file mode 100644 index 64f558552..000000000 --- a/modules/custom/govdelivery/govdelivery.info +++ /dev/null @@ -1,10 +0,0 @@ -name = GovDelivery -description = Integrates drupal mail with a different outbound mail system (non smtp) -package = Administration -project = "Other" -core = 7.x - -files[] = govdelivery.mail.inc -files[] = libraries/odmService.php -files[] = libraries/GovDeliverySubscriberAPI.php - diff --git a/modules/custom/govdelivery/govdelivery.install b/modules/custom/govdelivery/govdelivery.install deleted file mode 100644 index 0caca8163..000000000 --- a/modules/custom/govdelivery/govdelivery.install +++ /dev/null @@ -1,101 +0,0 @@ - 'A bin id this message is assigned to.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 1, - 'initial' => 1, - ); - - // Base table definition - $schema_system_cache = drupal_get_schema_unprocessed('system', 'cache'); - - // Message Queue - $schema['govdelivery_message_queue'] = $schema_system_cache; - $schema['govdelivery_message_queue']['fields']['bid'] = $bin; - $schema['govdelivery_message_queue']['indexes']['bid'] = array('bid'); - - // Subscription Queue - $schema['govdelivery_subscription_queue'] = $schema_system_cache; - $schema['govdelivery_subscription_queue']['fields']['bid'] = $bin; - $schema['govdelivery_subscription_queue']['indexes']['bid'] = array('bid'); - - // Subscriber API Topic Queue - $schema['govdelivery_subscriber_api_topic_queue'] = $schema_system_cache; - $schema['govdelivery_subscriber_api_topic_queue']['fields']['bid'] = $bin; - $schema['govdelivery_subscriber_api_topic_queue']['indexes']['bid'] = array('bid'); - - // Subscriber API Subscriber Queue - $schema['govdelivery_subscriber_api_subscriber_queue'] = $schema_system_cache; - $schema['govdelivery_subscriber_api_subscriber_queue']['fields']['bid'] = $bin; - $schema['govdelivery_subscriber_api_subscriber_queue']['indexes']['bid'] = array('bid'); - - return $schema; -} - -function govdelivery_update_7011() { - $topic_table = drupal_get_schema_unprocessed('system', 'cache'); - $subscriber_table = drupal_get_schema_unprocessed('system', 'cache'); - - $subscriber_table['description'] = 'Store topic requests that are unable to be sent for transmitting to govdelivery later'; - $topic_table['description'] = 'Store new subscriber requests that are unable to be sent for transmitting to govdelivery later'; - - db_create_table('govdelivery_subscriber_api_topic_queue', $topic_table); - db_create_table('govdelivery_subscriber_api_subscriber_queue', $subscriber_table); -} - -function govdelivery_update_7015() { - $schema = drupal_get_schema('govdelivery_message_queue', TRUE); - db_add_field('govdelivery_message_queue', 'bid', $schema['fields']['bid']); - db_add_field('govdelivery_subscription_queue', 'bid', $schema['fields']['bid']); - db_add_field('govdelivery_subscriber_api_topic_queue', 'bid', $schema['fields']['bid']); - db_add_field('govdelivery_subscriber_api_subscriber_queue', 'bid', $schema['fields']['bid']); - - db_add_index('govdelivery_message_queue', 'bid', array('bid')); - db_add_index('govdelivery_subscription_queue', 'bid', array('bid')); - db_add_index('govdelivery_subscriber_api_topic_queue', 'bid', array('bid')); - db_add_index('govdelivery_subscriber_api_subscriber_queue', 'bid', array('bid')); -} - -function govdelivery_update_7020() { - variable_set('govdelivery_messages_nagios_critical_threshold', - variable_get('govdelivery_nagios_critical_threshold', 750)); - variable_set('govdelivery_messages_nagios_warning_threshold', - variable_get('govdelivery_nagios_warning_threshold', 350)); -} diff --git a/modules/custom/govdelivery/govdelivery.mail.inc b/modules/custom/govdelivery/govdelivery.mail.inc deleted file mode 100644 index e7591cd8d..000000000 --- a/modules/custom/govdelivery/govdelivery.mail.inc +++ /dev/null @@ -1,37 +0,0 @@ - to - // allow for clean formatting if message isn't XML or HTML already - if (!is_numeric($xml_start) && !is_numeric($html_start)) { - $message['body'] = '
' . $message['body'] . '
'; - } - return $message; - } - - public function mail(array $message) { - $key = md5(print_r($message, TRUE) . microtime() . strval(rand())); - govdelivery_process_message($key, $message); - return TRUE; - } -} -// end GovDeliveryMailSystem diff --git a/modules/custom/govdelivery/govdelivery.module b/modules/custom/govdelivery/govdelivery.module deleted file mode 100644 index f09736db7..000000000 --- a/modules/custom/govdelivery/govdelivery.module +++ /dev/null @@ -1,1030 +0,0 @@ - array( - 'title' => t('Manage GovDelivery Settings'), - 'description' => t('Manage GovDelivery Accounts, Service Endpoints, Enable/Disable Cron Events, Enable/Disable Queuing, Send Test Messages/Subscriptions, Manage the Mail Queue'), - ), - ); -} - -/** - * Implements hook_menu(). - */ -function govdelivery_menu() { - $items['admin/config/services/govdelivery'] = array( - 'title' => 'GovDelivery Settings', - 'description' => 'Settings for GovDelivery to connect with the GovDelivery ODM and Subscription service.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('govdelivery_settings'), - 'access arguments' => array('Manage GovDelivery Settings'), - 'file' => 'govdelivery.admin.inc', - 'type' => MENU_NORMAL_ITEM, - ); - $items['admin/config/services/govdelivery/test'] = array( - 'title' => 'GovDelivery Settings Test - Messages', - 'description' => 'Test sending messages through Drupal correctly route to the GovDelivery service.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('govdelivery_test_settings'), - 'access arguments' => array('Manage GovDelivery Settings'), - 'file' => 'govdelivery.admin.inc', - 'type' => MENU_LOCAL_TASK, - ); - $items['admin/config/services/govdelivery/test_subscriptions'] = array( - 'title' => 'GovDelivery Settings Test - Subscriptions', - 'description' => 'Test signup process for GovDelivery Subscription services.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('govdelivery_test_subscriptions'), - 'access arguments' => array('Manage GovDelivery Settings'), - 'file' => 'govdelivery.admin.inc', - 'type' => MENU_LOCAL_TASK, - ); - $items['admin/reports/govdelivery_message_queue'] = array( - 'title' => 'GovDelivery Message Queue', - 'description' => 'View current items in the message queue.', - 'page callback' => 'govdelivery_message_queue_report', - 'page arguments' => array(), - 'access arguments' => array('Manage GovDelivery Settings'), - 'file' => 'govdelivery.admin-reports.inc', - 'type' => MENU_NORMAL_ITEM, - ); - $items['admin/reports/govdelivery_message_queue/details'] = array( - 'title' => 'GovDelivery Message Details', - 'description' => 'Details of a queued messaged', - 'page callback' => 'govdelivery_details', - 'page arguments' => array(), - 'access arguments' => array('Manage GovDelivery Settings'), - 'file' => 'govdelivery.admin-reports.inc', - 'type' => MENU_CALLBACK, - ); - - return $items; -} - -/** - * Implements hook_mail(). - */ -function govdelivery_mail($key, &$message, $params) { - $message['subject'] = 'GovDelivery test message'; - if (isset($_SERVER['HTTP_HOST'])) { - $_SERVER['HTTP_HOST'] = strtolower($_SERVER['HTTP_HOST']); - if (drupal_valid_http_host($_SERVER['HTTP_HOST'])) { - $message['subject'] = 'GovDelivery test message: ' . $_SERVER['HTTP_HOST'] . ' ' . time() . ' ' . rand(1, 10000); - } - } - - $message['body'][] = chr(0xb); - $message['body'][] = chr(0x10); // Low level ctrl chars. - $message['body'][] = chr(0x800); // Block D7FF < chr < E000 - $message['body'][] = chr(0xFFFE); // Block FFFD < chr < 10000 - $message['body'][] = ""; - $message['body'][] = "

H1 Test

"; - $message['body'][] = "

H2 Test

"; - $message['body'][] = "

H3 Test

"; - $message['body'][] = "

This is a test message from the GovDelivery system

"; - $message['body'][] = "
  1. Item 1
  2. Item 2
  3. Item 3
"; - $message['body'][] = ""; -} - -/** - * - * @todo This is likely broken or limited. - * - * Implements hook_cron(). - */ -function govdelivery_cron() { - $govdelivery_subscription_settings = variable_get('govdelivery_subscription_settings', NULL); - $govdelivery_odm_settings = variable_get('govdelivery_odm_settings', array()); - - // If subscriptions cron is Enabled - if (isset($govdelivery_subscription_settings['cron_subscriptions']) && $govdelivery_subscription_settings['cron_subscriptions']) { - $messages_sent = govdelivery_process_subscription_queue(); - } - - // If subscriptions cron is Enabled - if (isset($govdelivery_odm_settings['cron_odm']) && $govdelivery_odm_settings['cron_odm']) { - $items_sent = govdelivery_process_message_queue(); - } -} - -/** - * Implements hook_nagios_info(). - */ -function govdelivery_nagios_info() { - return array( - 'name' => 'GovDelivery', - 'id' => 'GovDelivery', - ); -} - -/** - * Get the count from a particular queue. - * - */ -function _govdelivery_get_queue_count($table) { - try { - $result = db_select($table)->countQuery()->execute()->fetchField(); - return $result; - } catch (Exception $e) { - return FALSE; - } -} - -/** - * Implement hook_nagios(). - */ -function govdelivery_nagios() { - $queues = array ( - 'messages' => array( - 'table' => 'govdelivery_message_queue', - ), - 'subscriptions' => array ( - 'table' => 'govdelivery_subscription_queue', - ), - 'subscriber_api_topics' => array( - 'table' => 'govdelivery_subscriber_api_topic_queue', - ), - 'subscriber_api_subscribers' => array( - 'table' => 'govdelivery_subscriber_api_subscriber_queue', - ), - ); - - $return = array( - 'key' => 'GovDelivery', - ); - - // Get the user settings. - foreach ($queues as $queue => $details) { - $critical_threshold = variable_get('govdelivery_'. $queue .'_nagios_critical_threshold', 750); - $warning_threshold = variable_get('govdelivery_'. $queue .'_nagios_warning_threshold', 350); - - $count = _govdelivery_get_queue_count($details['table']); - if (is_numeric($count) && is_numeric($critical_threshold) && is_numeric($warning_threshold)) { - if ($count > $critical_threshold) { - $status = NAGIOS_STATUS_CRITICAL; - $text = t("GovDelivery has @count backlogged @queue in the queue.", array('@count' => $count, '@queue' => $queue)); - } - elseif ($count > $warning_threshold) { - $status = NAGIOS_STATUS_WARNING; - $text = t("GovDelivery has @count backlogged @queue in the queue.", array('@count' => $count, '@queue' => $queue)); - } - else { - $status = NAGIOS_STATUS_OK; - $text = ''; - } - } - else { - $status = NAGIOS_STATUS_UNKNOWN; - $text = t("GovDelivery can't determine the queue status for: ", array('@queue' => $queue)); - } - - $return['data_' . $queue] = array('status' => $status, 'type' => 'state', 'text' => $text); - } - - return $return; -} - -/** - * Implements hook_nagios_settings(). - */ -function govdelivery_nagios_settings() { - $queues = array ( - 'messages' => array( - 'table' => 'govdelivery_message_queue', - ), - 'subscriptions' => array ( - 'table' => 'govdelivery_subscription_queue', - ), - 'subscriber_api_topics' => array( - 'table' => 'govdelivery_subscriber_api_topic_queue', - ), - 'subscriber_api_subscribers' => array( - 'table' => 'govdelivery_subscriber_api_subscriber_queue', - ), - ); - - $form = array('Govdelivery' => array()); - foreach($queues as $queue => $detail) { - $form['GovDelivery'][] = array( - 'govdelivery_'. $queue .'_nagios_critical_threshold' => array( - '#type' => 'textfield', - '#title' => t($queue . ' Critical Threshold'), - '#default_value' => variable_get('govdelivery_'. $queue .'_nagios_critical_threshold', 750), - '#description' => t('Issue a critical alert when GovDelivery has this number of items queued. (Make this greater then the warning number)'), - ), - 'govdelivery_'. $queue .'_nagios_warning_threshold' => array( - '#type' => 'textfield', - '#title' => t($queue . ' Warning Threshold'), - '#default_value' => variable_get('govdelivery_'. $queue .'_nagios_warning_threshold', 350), - '#description' => t('Issue a warning alert when GovDelivery has this number of items queued. (Make this less then the critical alert number)'), - ), - ); - } - - return $form; -} - -/** - * Message Queue Processor - */ -function govdelivery_process_message_queue($items = NULL, $ignore_max_time = FALSE, $cid = NULL, $bid = NULL) { - return _govdelivery_preprocess_queue('govdelivery_message_queue', 'govdelivery_send_message', $items, $ignore_max_time, $cid, $bid); -} - -/** - * Original Subscription Queue Processor. - * - * @deprecated This will be removed in version 2.0 - */ -function govdelivery_process_subscription_queue($items = NULL, $ignore_max_time = FALSE, $cid = NULL, $bid = NULL) { - return _govdelivery_preprocess_queue('govdelivery_subscription_queue', 'govdelivery_queued_subscribe', $items, $ignore_max_time, $cid, $bid); -} - -/** - * Subscriber API Topic Queue Processor. - */ -function govdelivery_process_subscriber_api_topic_queue($items = NULL, $ignore_max_time = FALSE, $cid = NULL, $bid = NULL) { - return _govdelivery_preprocess_queue('govdelivery_subscriber_api_topic_queue', 'govdelivery_subscriber_api_send_topic', $items, $ignore_max_time, $cid, $bid); -} - -/** - * Subscriber API Subscriber Queue Processor. - */ -function govdelivery_process_subscriber_api_subscriber_queue($items = NULL, $ignore_max_time = FALSE, $cid = NULL, $bid = NULL) { - return _govdelivery_preprocess_queue('govdelivery_subscriber_api_subscriber_queue', 'govdelivery_subscriber_api_send_subscription', $items, $ignore_max_time, $cid, $bid); -} - -/** - * Generic pre-process queue. - * - * Handles parsing the bids and randomizing their order. - */ -function _govdelivery_preprocess_queue($queue, $callback, $items = NULL, $ignore_max_time = FALSE, $cid = NULL, $bid = NULL) { - $items_sent = 0; - - //@todo check queue. - //@todo check callback. - - try { - foreach(_govdelivery_get_bids_from_bid($bid) as $notrandom => $random) { - $items_sent += govdelivery_process_queue($queue, $callback, $random, $items, $ignore_max_time, $cid); - } - } - catch (Exception $e) { - watchdog('govdelivery', 'Failed to get proper bid for processing. Validate that govdelivery_odmsettings[\'max_bid\'] variable has' - . ' a valid integer value or the Drush command is called with a valid second parameter. Error: @error', - array('@error' => $e->getMessage()), WATCHDOG_INFO); - return FALSE; - } - - watchdog('govdelivery', 'Sent %items items when processing the govdelivery @queue queue.', - array('%items' => $items_sent, '@queue' => $queue), WATCHDOG_INFO); - return $items_sent; -} - -/** - * Used to set high low bid values from a range input of n,n+1-x - * Properly handles default values if no bid is specified in the correct form. - * Handles randomizing the range so that semaphores are less likely to deadlock. - */ -function _govdelivery_get_bids_from_bid($bid) { - $govdelivery_odm_settings = variable_get('govdelivery_odm_settings', array()); - - $return = TRUE; // Flag for errors. - - $bid_range = array(); - if (!is_null($bid)) { - $bid_range = explode(',', $bid); - } - else { - $bid_range[0] = 1; - $bid_range[1] = is_numeric($govdelivery_odm_settings['max_bid']) ? $govdelivery_odm_settings['max_bid'] : 5; - } - - $bids = array(); - if (isset($bid_range[0], $bid_range[1]) - && is_numeric($bid_range[0]) && is_numeric($bid_range[1]) && $bid_range[0] <= $bid_range[1]) { - $bids = range($bid_range[0], $bid_range[1]); - $return = shuffle($bids); // Shuffle returns true/false. - } - else { - $return = FALSE; - } - - if (!$return) { - throw new Exception( - "Invalid Bid Range or unable to Shuffle the bids. Check calling function or the govdelivery_odm_settings['max_bid'] variable."); - } - - return $bids; -} - -/** - * Generic thread-safe queue processor. - */ -function govdelivery_process_queue($queue, $callback, $bid, $items = NULL, $ignore_max_time = FALSE, $cid = NULL) { - $govdelivery_odm_settings = variable_get('govdelivery_odm_settings', array()); - $start_time = (timer_read('page') / 1000); - - // Get the lock name. - lock_initialize(); - if (is_numeric($bid)) { - $lock_name = 'govdelivery_semaphore_' . $queue . '_bin_' . $bid; - } - else { - watchdog('govdelivery', 'Attempting to run govdelivery queue processing with invalid bid.', array(), WATCHDOG_ERROR); - return FALSE; - } - - // Check if the lock is available or fail. - if (!lock_acquire($lock_name, $govdelivery_odm_settings['external_cron_interval'])) { - watchdog('govdelivery', 'Attempting to re-run govdelivery queue processing while it is already running. @bin', - array('@bin' => $lock_name), WATCHDOG_WARNING); - return FALSE; - } - - // checks for maximum execution time cribbed from the job_queue module: drupal.org/project/job_queue - $max_execution_time = ini_get('max_execution_time'); - if (!$ignore_max_time && empty($max_execution_time)) { - $max_execution_time = 5 * 60; - } - - //$cache_queue = db_query("SELECT cid FROM {" . $queue . "} ORDER BY created ASC"); - $query = db_select($queue, 'q'); - $query->fields('q', array('cid')); - $query->condition('bid', $bid, '='); - $cache_queue = $query->execute(); - - $items_sent = 0; - foreach ($cache_queue as $queue_key) { - // check our status against the maximum execution time for a request, and if we've used half of it we want to - // stop processing - it was formerly checking whether half the time was used, rather than whether we had used - // half of it in this module - if (!$ignore_max_time && ( ((timer_read('page') / 1000) - $start_time ) > ($max_execution_time / 2))) { - watchdog('govdelivery', 'Half of the available PHP execution time of %max_execution_time has been use processing the GovDelivery queue and processing will not continue.', - array('%max_execution_time' => $max_execution_time), WATCHDOG_WARNING); - break; // Stop once we have used over half of the maximum execution time - } - - $i = $queue_key->cid; - // Only send one message from the queue if a cid is passed in - // If the cid is null or blank process the queue as normal - if ((!empty($cid) && $i == $cid) || (empty($cid))) { - // get the most recently cached item - $item = govdelivery_queue_get($queue, $i); - // if this item is still in the cache - if ($item) { - // resend the item - // add a callback - $status = call_user_func_array($callback, array($item) ); - if ($status) { - govdelivery_queue_remove($queue, $i); - $items_sent++; - } - } - } - if (isset($items) && ( $items_sent >= $items )) { - break; // break if we've sent the requested number of items - } - } - - lock_release($lock_name); - return $items_sent; -} - -/** - * Retrieve an item from the queue. - */ -function govdelivery_queue_get($queue, $cid) { - - $query = db_select($queue, 'q'); - $query->fields('q', array('data', 'created', 'expire', 'serialized')); - $query->condition('q.cid', $cid); - $result = $query->execute(); - - $message = $result->fetchObject(); - if (isset($message->data) && !empty($message->data)) { - if($message->serialized) { - $message->data = unserialize($message->data); - } - return $message->data; - } - return FALSE; -} - -/** - * Create or update an item in the queue. - */ -function govdelivery_queue_set($queue, $cid, $data) { - $govdelivery_odm_settings = variable_get('govdelivery_odm_settings', array()); - - $serialized = 0; - if (is_object($data) || is_array($data)) { - $data = serialize($data); - $serialized = 1; - } - - $created = REQUEST_TIME; - //db_query("UPDATE {" . $queue . "} SET data = %b, created = %d, serialized = %d WHERE cid = '%s'", $data, $created, $serialized, $cid); - try { - $random = rand(1, $govdelivery_odm_settings['max_bid']); - $query = db_update($queue); - $query->fields(array( - 'data' => $data, - 'created' => $created, - 'serialized' => $serialized, - 'bid' => $random, - )); - $query->condition('cid', $cid); - $num_updated = $query->execute(); - - if ($num_updated <= 0) { - //@db_query("INSERT INTO {" . $queue . "} (cid, data, created, serialized) VALUES ('%s', %b, %d, %d)", $cid, $data, $created, $serialized); - db_insert($queue) - ->fields(array( - 'cid' => $cid, - 'data' => $data, - 'created' => $created, - 'serialized' => $serialized, - 'bid' => $random, - )) - ->execute(); - } - } - catch (Exception $e) { - watchdog('govdelivery', 'Queue Set Error: @e', array('@e' => $e->getMessage()), WATCHDOG_NOTICE); - } -} - -/** - * Remove an item from the queue. - */ -function govdelivery_queue_remove($queue, $cid) { - //db_query("DELETE FROM {" . $queue . "} WHERE cid = '%s'", $cid); - db_delete($queue) - ->condition('cid', $cid) - ->execute(); -} - -/** - * Check the existence of a particular field-value pair in a given queue's data. - * - * @todo Switch this to use cache_api and verify if the multithreaded version gits more hits. - */ -function govdelivery_queue_check($queue, $field, $match_value) { - static $in_queue; - - // Check that the topic id isn't in the static cache of unsent items or in the queue. - if (is_array($in_queue)) { - foreach($in_queue as $cached_value) { - if ($cached_value == $match_value) { - watchdog('govdelivery', 'Cache Hit - Match Value: @match_value is still in the topic queue to be processed so we will not send this item yet.', array('@match_value' => $match_value), WATCHDOG_NOTICE); - return TRUE; - } - } - } - - $query = db_select($queue, 'q')->fields('q'); - $queue_data = $query->execute(); - foreach ($queue_data as $item) { - if (isset($item->data) && !empty($item->data)) { - if($item->serialized) { - $item->data = unserialize($item->data); - } - } - else { - continue; - } - - if (isset($item->data->$field)) { - $in_queue[] = $item->data->$field; // Stash this for speed. - } - else { - continue; - } - - if ($item->data->$field == $match_value) { - watchdog('govdelivery', 'Cache Miss - Match Value: @match_value is still in the topic queue to be processed so we will not send this item yet.', array('@match_value' => $match_value), WATCHDOG_NOTICE); - return TRUE; - } - } - - return FALSE; -} - -/** - * The user may have put in an address of the form "Full Name" instead of just the address, - * so we want to filter to the right address - */ -function govdelivery_filter_email($address) { - - // borrowed from the drupal valid_email_address($mail) function - $user = '[a-zA-Z0-9_\-\.\+\^!#\$%&*+\/\=\?\`\|\{\}~\']+'; - $domain = '(?:(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.?)+'; - $ipv4 = '[0-9]{1,3}(\.[0-9]{1,3}){3}'; - $ipv6 = '[0-9a-fA-F]{1,4}(\:[0-9a-fA-F]{1,4}){7}'; - - // setup an array for the matching expression - $matches = array(); - - // the regex below is adapted from drupal's valid_email_address($mail) function - preg_match("/$user@($domain|(\[($ipv4|$ipv6)\]))/", $address, $matches); - return (isset($matches[0]) ? $matches[0] : ''); -} - -/** - * Send messages immediately or to the queue if enabled. - */ -function govdelivery_process_message($key, $message) { - // Check preferences - $govdelivery_odm_settings = variable_get('govdelivery_odm_settings', array()); - $send_success = FALSE; - - // Attempt to send immediately - if (isset($govdelivery_odm_settings['queue']) && !$govdelivery_odm_settings['queue']) { - $send_success = govdelivery_send_message($message); - - if ($send_success) { - watchdog('govdelivery', 'Successfully sent a message immediately.', array(), WATCHDOG_INFO); - } - } - - // Queue the message if: - // 1. Failure to send immediately - // 2. Queue preferences haven't been set - // 3. Queue is enabled - if (!$send_success) { - govdelivery_queue_set('govdelivery_message_queue', $key, $message); - } -} - -/** - * Queue a topic to be added to govdelivery. - * Use govdelivery_subscriber_get_topic_id($title). - * - * @param string $title - * The Topic's title in GovDelivery. - * @param string $short_title - * The Topic's short title in GovDelivery. - * @return boolean $queue_result - * Return TRUE on successfully queuing or FALSE on error. - */ -function govdelivery_subscriber_api_add_topic($title, $short_title = "", $topic_id = NULL) { - $queue = 'govdelivery_subscriber_api_topic_queue'; - - // Build the data - if(empty($topic_id) && empty($title)) { - return FALSE; - } - - if(empty($topic_id) && !empty($title)) { - $topic_id = variable_get('govdelivery_topic_prefix', '') . $title; - } - - $short_title = (empty($short_title) ? $title : $short_title); - $data = new stdClass; - $data->title = $title; - $data->short_title = $short_title; - $data->topic_id = $topic_id; - - $queue_result = FALSE; - // Try to queue. - $key = md5(print_r($data->title . $data->short_title, TRUE) . microtime() . strval(rand())); - $queue_result = govdelivery_queue_set($queue, $key, $data); - - return $queue_result; -} - -/** - * Queue a topic subscription to be added to GovDelivery. - * If $topic_id is NULL, $title will be used in a call to govdelivery_subscriber_get_topic_id($title). - * - * @param string $email - * The email address being subscribed. If the subscriber doesn't exist a new subscriber will be created. - * @param string $topic_id - * The topic_id from the GovDelivery system. - * @param string $title - * The Topic's title from the GovDelivery system or as created during a call to govdelivery_subscriber_api_add_topic. - * @return boolean $queue_result - * Return TRUE on successfully queuing or FALSE on error. - */ -function govdelivery_subscriber_api_add_subscriber($email, $title = NULL, $topic_id = NULL) { - $queue = 'govdelivery_subscriber_api_subscriber_queue'; - - // Fail if there is noone to subscribe. - if(empty($email)) { - return FALSE; - } - - // Fail if there is no way to get a topic_id. - if(empty($topic_id) && empty($title)) { - return FALSE; - } - - // @todo remove this code. - if(empty($topic_id) && !empty($title)) { - $topic_id = variable_get('govdelivery_topic_prefix', '') . $title; - } - - // Build the data. - $data = new stdClass; - $data->email = $email; - $data->title = $title; - $data->topic_id = $topic_id; - - $queue_result = FALSE; - // Try to queue. - $key = md5(print_r($data->email . $data->topic_id . $data->title, TRUE) . microtime() . strval(rand())); - $queue_result = govdelivery_queue_set($queue, $key, $data); - - return $queue_result; -} - -/** - * Called by the queue processor to send a message from the queued. Also called to send immediately. - */ -function govdelivery_send_message($message) { - $govdelivery_odm_settings = variable_get('govdelivery_odm_settings', array()); - $sendsuccess = FALSE; - - if (class_exists('SoapClient')) { - $ODMmessage = new ODMMessage(); - - // Basically this is saying that a to list can be either an array - // or a comma seperated values list. - // If it is an array each array item may still be a comma seperated list - // So we need to parse the comma seperated list of each array element. - // If it is not initially an array then we need to check for a comma seperated list - // only once and then proceede. - // Its really weird but its possible. - $recipients = array(); - if (is_array($message["to"])) { - foreach ($message["to"] as $address) { - $tolist = explode(',', $address); - if (is_array($tolist)) { - $filtered_list = array_map("govdelivery_filter_email", $tolist); - $recipients = array_merge($recipients, $filtered_list); - } - else { - $recipients[] = govdelivery_filter_email($tolist); - } - } - } - else { - $tolist = explode(',', $message["to"]); - if (is_array($tolist)) { - $filtered_list = array_map("govdelivery_filter_email", $tolist); - $recipients = array_merge($recipients, $filtered_list); - } - else { - $recipients[] = govdelivery_filter_email($tolist); - } - } - - $ODMmessage->to = (array) $recipients; - - // Check account mappings from the settings file. - // @todo fix this so that a checkbox can select the default account in the admin area - $account_map = variable_get("govdelivery_account_map", NULL); - $account = (isset($account_map[$message['id']]) ? $account_map[$message['id']] : $account_map['default']); - if (!isset($account) || empty($account)) { - watchdog('govdelivery', 'No default account specified. Check settings.php.', NULL, WATCHDOG_ERROR); - return FALSE; - } - - // @todo Allowing overriding the from address. - $from_address = $govdelivery_odm_settings['accounts'][$account]['fromname']; - if(isset($govdelivery_odm_settings['override_from']) && !empty($govdelivery_odm_settings['override_from'])) { - if (!empty($message['from'])) { - $from_address = $message['from']; - } - } - - $ODMmessage->setFromName($from_address); - $ODMmessage->setSubject($message["subject"]); - $ODMmessage->setBody($message['body']); - $ODMmessage->trackClicks = FALSE; - $ODMmessage->trackOpens = FALSE; - - try { - $credentials = new ODMCredentials($account, $govdelivery_odm_settings['accounts'][$account]['password']); - $odm = new odmService($govdelivery_odm_settings['server'], $credentials); - $status = $odm->sendMessage($ODMmessage); - - if(isset($status) && is_string($status)) { - $sendsuccess = TRUE; - } - else { - $sendsuccess = FALSE; - } - } - catch (SoapFault $e) { - if (isset($e->detail, $e->detail->ODMFault, $e->detail->ODMFault->category, $e->detail->ODMFault->detail)) { - watchdog('govdelivery', 'ODM Fault - Category: %category; Detail: %detail. Item will be queues for resend on the next cron run.', - array('%category' => $e->detail->ODMFault->category, '%detail' => $e->detail->ODMFault->detail), WATCHDOG_ERROR); - } - else { - watchdog('govdelivery', 'Soap Fault - Message: %message. Item will be queued for resend on the next cron run.', array('%message' => $e->getMessage()), WATCHDOG_ERROR); - } - } - catch (Exception $e) { - watchdog('govdelivery', 'Exception - Message: %message. Item will be queued for resend on the next cron run.', array('%message' => $e->getMessage()), WATCHDOG_ERROR); - } - } - - return $sendsuccess; -} - -/** - * Helper function when calling subscribe from the queue run. - */ -function govdelivery_queued_subscribe($item) { - return govdelivery_subscribe($item['code'], $item['email'], TRUE); -} - -/** - * Process a subscription from the Queue. - * Do not call this directly. - */ -function govdelivery_subscribe($list_code, $email, $from_queue = FALSE) { - // Check the initial prototype input. - if (is_null($list_code) || empty($list_code)) { - watchdog('govdelivery', 'Supplied list code is null or empty.', array(), WATCHDOG_ERROR); - // Return TRUE to remove something from the queue - if ($from_queue) { - return TRUE; - } - return FALSE; - } - - if (is_null($email) || empty($email)) { - watchdog('govdelivery', 'Supplied email is null or empty.', array(), WATCHDOG_ERROR); - // Return TRUE to remove something from the queue - if ($from_queue) { - return TRUE; - } - return FALSE; - } - - // Prototype input is good now lets check the settings. - $request = array( - 'code' => $list_code, - 'email' => $email, - ); - $key = md5(print_r($request, TRUE) . microtime() . strval(rand())); - - $govdelivery_subscription_settings = variable_get('govdelivery_subscription_settings', NULL); - if (is_null($govdelivery_subscription_settings) || empty($govdelivery_subscription_settings)) { - if (!$from_queue) { - govdelivery_queue_set('govdelivery_subscription_queue', $key, $request); - } - watchdog('govdelivery', 'Settings for subscribing this user are not available. Subscription will be queued.', array(), WATCHDOG_ERROR); - return FALSE; - } - - // General settings exist, check the specific settings we need. - $service_url = $govdelivery_subscription_settings['service_url']; - if (is_null($service_url) || empty($service_url)) { - if (!$from_queue) { - govdelivery_queue_set('govdelivery_subscription_queue', $key, $request); - } - watchdog('govdelivery', 'Service URL for subscribing this user is not available. Subscription will be queued.', array(), WATCHDOG_ERROR); - return FALSE; - } - - // Settings are valid now send the request. - $request_url = url($service_url, array('query' => $request)); - $response = drupal_http_request($request_url); - - // The response is well-formed XML, but seems pretty heavyweight to parse as XML, - // we're better off with a simple regex match - $matches = array(); - preg_match("/<\/response>/", $response->data, $matches); - $result_code = $matches[1]; - $message = $matches[2]; - - // Check if the URL is totally borked. - if (!empty($response->error)) { - watchdog('govdelivery', 'System Error: %error', array('%error' => var_export($response, TRUE)), WATCHDOG_ERROR); - return FALSE; - } - - // Check if the url is redirecting...this might need to be removed if something changes on govdeliverys side. - // Currently - 10/24/2011 GovDelivery will redirect to their homepage if you hit the wrong url in their domain. - if (!empty($response->redirect_code)) { - watchdog('govdelivery', 'System Error: %error', array('%error' => var_export($response, TRUE)), WATCHDOG_ERROR); - return FALSE; - } - - // If the response code in the response header from govdelivery is anything other then 200 - // there is something seriously wrong with this request and we should consider it malicious. - // It also doesn't help that GovDelivery isn't sending back a standard response like the - // other error codes. - // Note: This is different then result_code pulled from the xml body of the response. - if ($response->code != '200') { - watchdog('govdelivery', 'Error subscribing - Email: %email List: %list The response from GovDelivery was not 200 meaning this request is probably malicious. Response Code: %response', - array('%email' => $request['email'], '%list' => $request['code'], '%respons' => $response->code), WATCHDOG_ERROR); - // Return TRUE to remove something from the queue - if ($from_queue) { - return TRUE; - } - return FALSE; - } - - - // In the future we should be able to switch this to key off of $response->code but until then we need to keep parsing. - // Key off the Result Code from the response body instead of the header. - switch ($result_code) { - case "200": - watchdog('govdelivery', 'Subscribed Email: %email to List: %list', array('%email' => $request['email'], '%list' => $request['code']), WATCHDOG_INFO); - return TRUE; - break; - case "404": - case "414": - case "500": - watchdog('govdelivery', 'Error subscribing - Email: %email List: %list Response: %response Message: %message; Item will not be queued.', - array('%email' => $request['email'], '%list' => $request['code'], '%response' => $result_code, '%message' => $message), WATCHDOG_ERROR); - // Return TRUE to remove something from the queue - if ($from_queue) { - return TRUE; - } - return FALSE; - break; - default: - if (!$from_queue) { - govdelivery_queue_set('govdelivery_subscription_queue', $key, $request); - } - watchdog('govdelivery', 'Error subscribing - Email: %email List: %list Response: %response Message: %message; Item will be queued.', - array('%email' => $request['email'], '%list' => $request['code'], '%response' => $result_code, '%message' => $message), WATCHDOG_ERROR); - return FALSE; - break; - } -} - -/** - * - * Process a topic create item from the subscriber api queue. - * Do not call this function directly. - * - * Returns TRUE on success or unrecoverable failures. - * Returns FALSE on failure or recoverable failures. - * - */ -function govdelivery_subscriber_api_send_topic($data) { - // @todo Move as much of this to a check function to be called from all the Processors. - // Check the required class library exists or fail. - if(!class_exists('GovDeliverySubscriberAPI')) { - watchdog('govdelivery', - 'No GovDeliverySubscriberAPI class found. Check the libraries folder in the govdelivery module or the govdelivery.info includes.', - NULL, WATCHDOG_ERROR); - return FALSE; - } - - // Check settings are available or fail. - $govdelivery_odm_settings = variable_get('govdelivery_odm_settings', array()); - if(empty($govdelivery_odm_settings)) { - watchdog('govdelivery', 'No settings found. Check settings.php.', NULL, WATCHDOG_ERROR); - return FALSE; - } - - // Check account mappings from the settings file or fail. - $govdelivery_subscription_settings = variable_get('govdelivery_subscription_settings', NULL); - if (isset($govdelivery_subscription_settings['subscriber_api_account']) && !empty($govdelivery_subscription_settings['subscriber_api_account'])) { - $account = $govdelivery_subscription_settings['subscriber_api_account']; - } - else { - watchdog('govdelivery', 'No default account specified. Check settings.php.', NULL, WATCHDOG_ERROR); - return FALSE; - } - - // Get the password parameter or fail. - if (isset($govdelivery_odm_settings['accounts'][$account]['password']) && !empty($govdelivery_odm_settings['accounts'][$account]['password'])) { - $password = $govdelivery_odm_settings['accounts'][$account]['password']; - } - else { - watchdog('govdelivery', 'No password for default account. Check settings.php.', NULL, WATCHDOG_ERROR); - return FALSE; - } - - // Get the URL Base parameter or fail. - $url_base = $govdelivery_subscription_settings['subscriber_api_url_base']; - if (empty($url_base)) { - watchdog('govdelivery', 'Subscription settings subscriber_api_base_url not set. Check settings.php.', NULL, WATCHDOG_ERROR); - return FALSE; - } - - // Try to create the SubscriberAPI object or fail. - $subscriber_api = new GovDeliverySubscriberAPI($account, $password, $url_base); - if (!($subscriber_api instanceof GovDeliverySubscriberAPI)) { - watchdog('govdelivery', 'Failed to create new GovDeliverySubscriberAPI object. Check settings for default account, password, and url base.'); - return FALSE; - } - - $data->topic_id = (!empty($data->topic_id) ? $data->topic_id : $govdelivery_subscription_settings['subscriber_api_topic_prefix'] . $data->title); - // @todo remove this code. - // Check title and topic are present or fail and remove from queue. - if (empty($data->title) && empty($data->topic_id)) { - watchdog('govdelivery', 'Title and topic_id not set. Removing from queue.', NULL, WATCHDOG_ERROR); - return TRUE; // Return TRUE to trick the queue processor into removing this item. - } - - // Send request. - try { - $result = $subscriber_api->create_topic($data); - } - catch (Exception $e) { - watchdog('govdelivery', 'Exception in GovDeliverySubscriberAPI::create_topic($topic), Exception: @e', array('@e' => $e->getMessage()), WATCHDOG_ERROR); - return FALSE; // The message length too long exception we can recover from reasonably with manual intervention. - } - - // Requeue or Remove from queue on success. - switch($result->info['http_code']) { - //Success - case 200: - watchdog('govdelivery', 'Successfully created topic - Topic ID: @topic_id; Title: @title; HTTP Code: @http_code; Item will not be queued.', - array('@topic_id' => $data->topic_id, '@title' => $data->title, '@http_code' => $result->info['http_code']), WATCHDOG_NOTICE); - _govdelivery_set_default_topic_category ($data->topic_id, $subscriber_api); - return TRUE; - - // Non recoverable failure - case 422: // Bad syntax. - watchdog('govdelivery', 'Error creating topic - Topic ID: @topic_id; Title: @title; HTTP Code: %http_code; Response: %response; Item will not be queued.', - array('@topic_id' => $data->topic_id, '@title' => $data->title, '%http_code' => $result->info['http_code'], '%response' => $result->error,), WATCHDOG_ERROR); - return TRUE; // Return TRUE to remove the item from the queue. - - // Recoverable failure - case 302: // Failure to authenticate - case 401: // Unauthorized - default: - watchdog('govdelivery', 'Error creating topic - Topic ID: @topic_id; Title: @title; HTTP Code: %http_code; Response: %response; Item will be queued.', - array('@topic_id' => $data->topic_id, '@title' => $data->title, '%http_code' => $result->info['http_code'], '%response' => $result->error,), WATCHDOG_ERROR); - return FALSE; - } -} - -/** - * Pull the default topic setting and set the supplied topic id to be part of that category. - */ -function _govdelivery_set_default_topic_category ($topic_id, $subscriber_api_object) { - if (!($subscriber_api_object instanceof GovDeliverySubscriberAPI)) { - return FALSE; - } - - if (empty($topic_id)) { - return FALSE; - } - - $govdelivery_subscription_settings = variable_get('govdelivery_subscription_settings', NULL); - $category_id = isset($govdelivery_subscription_settings['default_topic_category_id']) ? $govdelivery_subscription_settings['default_topic_category_id'] : ''; - if (empty($category_id)) { - watchdog('govdelivery', 'Subscription settings default_topic_category_id not set. Check settings.php.', NULL, WATCHDOG_ERROR); - return FALSE; - } - - $data = new stdClass; - $data->topic_id = $topic_id; - $data->category_id = $category_id; - - // Set the default topic category. - // @todo maybe this is imperative to someone else. - try { - $subscriber_api_object->update_topic_category($data); - return TRUE; - } - catch (Exception $e) { - watchdog('govdelivery', 'Exception in GovDeliverySubscriberAPI::update_topic_category($topic), Exception: @e', array('@e' => $e->getMessage()), WATCHDOG_ERROR); - return FALSE; - } -} - -/** - * - * Process a subscription create item from the subscriber api queue. - * Do not call this function directly. - * - * Returns TRUE on success or unrecoverable failures. - * Returns FALSE on failure or recoverable failures. - * - */ -function govdelivery_subscriber_api_send_subscription($data) { - $govdelivery_subscription_settings = variable_get('govdelivery_subscription_settings', NULL); - - // @todo remove this code and hopefully leverage queue_subscribe fully. - $field = 'topic_id'; - $value = $data->$field; - if (empty($value)) { - $field = 'title'; - $value = $govdelivery_subscription_settings['subscriber_api_topic_prefix'] . $data->$field; - } - - if (govdelivery_queue_check('govdelivery_subscriber_api_topic_queue', $field, $value)) { - return FALSE; // Return FALSE to keep the item in the queue. - } - - // If this isn't on the do not send list then send away. - return govdelivery_subscribe($data->topic_id, $data->email, TRUE); -} diff --git a/modules/custom/govdelivery/libraries/GovDeliverySubscriberAPI.php b/modules/custom/govdelivery/libraries/GovDeliverySubscriberAPI.php deleted file mode 100644 index 2bce2fc66..000000000 --- a/modules/custom/govdelivery/libraries/GovDeliverySubscriberAPI.php +++ /dev/null @@ -1,163 +0,0 @@ -govdelivery_account_name = $govdelivery_account_name; - $this->govdelivery_account_password = $govdelivery_account_password; - $this->govdelivery_url_base = $govdelivery_url_base; - // Login header: - // Authorization: Basic base64_encode('username:password'); - $this->auth_header = $this->govdelivery_account_name. ':' . $this->govdelivery_account_password; - } - - /** - * Take a topic item from the queue and create it in GovDelivery - * - * @param $topic Topic object - * - * @return array of return object from topic creation - */ - function create_topic($topic) { - $url = $this->govdelivery_url_base . '/topics.xml'; - - if (!isset($topic->topic_id) || is_null($topic->topic_id)) { - throw new Exception(t('topic_id attribute of supplied topic is unset or null. You must supply a topic_id')); - } - - // GovDelivery Subscriber API requires al topic_id's to be be 32 characers or less - $id_length = strlen($topic->topic_id); - if ($id_length > 32) { - throw new Exception(t('topic_id must be 32 characters or less. Supplied id of %id is %length characters', array('%id' => $topic->topic_id, '%length' => $id_length))); - } - - // GovDelivery Subscriber API requires all topic_id's to be all CAPS. - $topic->topic_id = strtoupper($topic->topic_id); - - $create_topic_xml_request = ' - - - '. $topic->topic_id .' - - - 0 - '. $topic->title .' - false - false - false - - Topic Name - Recent Updates - http://url_for_rss_feed.rss - false - '. $topic->short_title .' - 0 - false - - - http://www.govdelivery.com - - - 2 - '; - - // Set options - $topic_options = array( - CURLOPT_URL => $url, - CURLOPT_FAILONERROR => TRUE, - CURLOPT_RETURNTRANSFER => TRUE, - CURLOPT_TIMEOUT => 120, - CURLOPT_USERPWD => $this->auth_header, - CURLOPT_HEADER => TRUE, - CURLOPT_HTTPHEADER => array('Content-Type: application/xml',), - CURLOPT_POST => TRUE, - CURLOPT_POSTFIELDS => $create_topic_xml_request, - ); - - $ch = curl_init(); // create curl resource - curl_setopt_array($ch, $topic_options); - - $topic_return = new stdClass; - $topic_return->response = curl_exec($ch); // execute and get response - $topic_return->header = substr($topic_return->response, 0, curl_getinfo($ch, CURLINFO_HEADER_SIZE)); - $topic_return->body = substr($topic_return->response, curl_getinfo($ch, CURLINFO_HEADER_SIZE)); - $topic_return->error = curl_error($ch); - $topic_return->info = curl_getinfo($ch); - $topic_return->topic_id = $topic->topic_id; - - return $topic_return; - } - - /** - * Update the GovDelivery category associated with the given topic - * - * @param $topic Topic object - * - * @return array of return object from category updating - */ - function update_topic_category($topic) { - if (!isset($topic->topic_id) || is_null($topic->topic_id)) { - throw new exception(t('topic_id attribute of supplied topic is unset or null. you must supply a topic_id')); - } - - if (!isset($topic->category_id) || is_null($topic->category_id)) { - throw new exception(t('category_id attribute of supplied topic is unset or null. you must supply a category_id')); - } - - $url = $this->govdelivery_url_base . '/topics/' . $topic->topic_id . '/categories.xml'; - $set_category_xml_request = ' - - - - - ' . $topic->category_id . ' - - - '; - - //write the request out to a tmp file since PUT isn't happy taking a string - $fp = fopen('php://memory', 'w+'); - fwrite($fp, $set_category_xml_request); - fseek($fp, 0); - - // Set options - $category_options = array( - CURLOPT_URL => $url, - CURLOPT_FAILONERROR => TRUE, - CURLOPT_RETURNTRANSFER => TRUE, - CURLOPT_TIMEOUT => 30, - CURLOPT_USERPWD => $this->auth_header, - CURLOPT_HEADER => TRUE, - CURLOPT_HTTPHEADER => array('Content-Type: application/xml',), - CURLOPT_PUT => TRUE, - CURLOPT_INFILE => $fp, - CURLOPT_INFILESIZE => strlen($set_category_xml_request), - ); - - $ch = curl_init(); // create curl resource - curl_setopt_array($ch, $category_options); - - $category_return = new stdClass; - $category_return->response = curl_exec($ch); // execute and get response - $category_return->header = substr($category_return->response, 0, curl_getinfo($ch, CURLINFO_HEADER_SIZE)); - $category_return->body = substr($category_return->response, curl_getinfo($ch, CURLINFO_HEADER_SIZE)); - $category_return->error = curl_error($ch); - $category_return->info = curl_getinfo($ch); - - //kill the file stream we created above - fclose($fp); - curl_close($ch); - return $category_return; - } -} diff --git a/modules/custom/govdelivery/libraries/odmService.php b/modules/custom/govdelivery/libraries/odmService.php deleted file mode 100644 index e835428be..000000000 --- a/modules/custom/govdelivery/libraries/odmService.php +++ /dev/null @@ -1,158 +0,0 @@ -username = parent::xmlSpecialChars($username); - $this->password = parent::xmlSpecialChars($password); - } - - public function setRealm($data) { - $this->realm = parent::xmlSpecialChars($data); - } - - public function setUsername($username) { - $this->username = parent::xmlSpecialChars($username); - } - - public function setPassword($password) { - $this->password = parent::xmlSpecialChars($password); - } -} - -class ODMMessage extends XMLData { - public $body; - public $emailColumn = 'email'; - public $fromName; - public $recordDesignator = 'email'; - public $subject; - public $to; - public $trackClicks = TRUE; - public $trackOpens = TRUE; - - - /*public function __set($name, $value) { - watchdog('ben', 'CALLED SET'); - $this->$name = parent::xmlSpecialChars($value); - }*/ - - public function setBody($body) { - $this->body = parent::xmlSpecialChars($body); - } - - public function setEmailColumn($emailColumn) { - $this->emailColumn = parent::xmlSpecialChars($emailColumn); - } - - public function setFromName($fromName) { - $this->fromName = parent::xmlSpecialChars($fromName); - } - - public function setRecordDesignator($recordDesignator) { - $this->recordDesignator = parent::xmlSpecialChars($recordDesignator); - } - - public function setSubject($subject) { - $this->subject = parent::xmlSpecialChars($subject); - } -} - -class ODMDeliveryActivitySince extends XMLData { - public $maxresults; - public $sequence = ''; - - public function setSequence($sequence) { - $this->sequence = parent::xmlSpecialChars($sequence); - } -} - -/** - * ODMv2 Service class - * - */ -class odmService extends SoapClient { - public $server_uri = 'http://odm.govdelivery.com/ODMv2'; - - private static $classmap = array( - 'credentials' => 'ODMCredentials', - 'message' => 'ODMMessage', - 'deliveryActivitySince' => 'ODMDeliveryActivitySince', - ); - - public function odmService($wsdl, ODMCredentials $credentials, $options = array()) { - foreach (self::$classmap as $key => $value) { - if (!isset($options['classmap'][$key])) { - $options['classmap'][$key] = $value; - } - } - - // @todo must be used if runtime debugging feature is added. - $options['trace'] = true; - - $this->setCredentialsHeader($credentials); - - parent::__construct($wsdl, $options); - - } - - private function setCredentialsHeader(ODMCredentials $credentials) { - // Generate the needed credential headers. - // @todo SimpleXMLElement::getDocNamespaces - $header = new SoapHeader($this->server_uri, // Setup the correct namespace...I can't find a good way to query the base namespace from the wsdl. - 'credentials', // Encapsulating tag. - new SoapVar($credentials, SOAP_ENC_OBJECT)); // Generates an unencapsulated set of xml tags and their values. - - // Set the credentials to the header section of the soap envelope. - $this->__setSoapHeaders($header); - } - - /** - * Implements the wsdl sendMessage function. - * - * @todo Add a runtime debugging switch. - * - * @param ODMCredentials $credentials - * @param ODMMessage $message - * @return mixed - * Returns string on success and null or SoapFault exception on failure. - */ - public function sendMessage(ODMMessage $message) { - // Use the autogenerated base method that SoapClient class generates when using a valid WSDL. - $result = parent::sendMessage($message); - return $result; - } - - public function deliveryActivitySince (ODMDeliveryActivitySince $deliveryActivitySince) { - $result = parent::deliveryActivitySince($deliveryActivitySince); - -/* $handle = fopen('/tmp/govd_odmv2.tmp', 'a+'); - fwrite($handle, 'Last Request' . PHP_EOL . $this->__getLastRequest()); - fclose($handle); - */ - - return $result; - } -} diff --git a/modules/custom/govdelivery/webform_components/govdelivery_subscribe/govdelivery_subscribe.component.inc b/modules/custom/govdelivery/webform_components/govdelivery_subscribe/govdelivery_subscribe.component.inc deleted file mode 100644 index 4b4e3eae8..000000000 --- a/modules/custom/govdelivery/webform_components/govdelivery_subscribe/govdelivery_subscribe.component.inc +++ /dev/null @@ -1,942 +0,0 @@ - '', - 'form_key' => NULL, - 'mandatory' => 0, - 'pid' => 0, - 'weight' => 0, - 'value' => '', - 'extra' => array( - 'items' => '', - 'multiple' => TRUE, - 'aslist' => NULL, - 'optrand' => 0, - 'title_display' => 0, - 'description' => '', - 'custom_keys' => TRUE, - 'options_source' => '', - ), - ); -} - -/** - * Implements _webform_theme_component(). - */ -function _webform_theme_govd_subscribe() { - return array( - 'webform_display_govd_subscribe' => array( - 'arguments' => array('element' => NULL), - ), - ); -} - -/** - * Implements _webform_edit_component(). - */ -function _webform_edit_govd_subscribe($component) { - $form = array(); - - drupal_add_js(drupal_get_path('module', 'webform') . '/js/select-admin.js', array('preprocess' => FALSE)); - drupal_add_js(array('webform' => array('selectOptionsUrl' => url('webform/ajax/options/' . $component['nid']))), array('type' => 'setting', 'scope' => JS_DEFAULT)); - - $other = array(); - if ($info = _webform_govd_subscribe_options_info()) { - $options = array('' => t('None')); - foreach ($info as $name => $source) { - $clean_name = check_plain($name); - $clean_title = check_plain($source['title']); - $options[$clean_name] = $clean_title; - } - - $other['options_source'] = array( - '#title' => t('Load a pre-built option list'), - '#type' => 'select', - '#options' => $options, - '#default_value' => $component['extra']['options_source'], - '#description' => t('Use a pre-built list of options rather than entering options manually. Options will not be editable if using pre-built list.'), - '#parents' => array('extra', 'options_source'), - '#weight' => 5, - ); - } - - if (module_exists('select_or_other')) { - $other['other_option'] = array( - '#type' => 'checkbox', - '#title' => t('Allow "Other..." option'), - '#default_value' => $component['extra']['other_option'], - '#description' => t('Check this option if you want to allow users to enter an option not on the list.'), - '#parents' => array('extra', 'other_option'), - '#weight' => 2, - ); - $other['other_text'] = array( - '#type' => 'textfield', - '#title' => t('Text for "Other..." option'), - '#default_value' => check_plain($component['extra']['other_text']), - '#description' => t('If allowing other options, enter text to be used for other-enabling option.'), - '#parents' => array('extra', 'other_text'), - '#weight' => 3, - ); - } - - if (module_exists('options_element')) { - $options = _webform_govd_subscribe_options($component, FALSE, FALSE); - - $form['items'] = array( - '#type' => 'fieldset', - '#title' => t('Options'), - '#collapsible' => TRUE, - '#attributes' => array('class' => 'webform-options-element'), - '#element_validate' => array('_webform_edit_validate_options'), - '#weight' => 2, - ); - - $form['items']['options'] = array( - '#type' => 'options', - '#limit' => 500, - '#optgroups' => $component['extra']['aslist'], - '#multiple' => $component['extra']['multiple'], - '#multiple_toggle' => t('Multiple'), - '#default_value' => $component['value'], - '#options' => $options, - '#key_type' => 'mixed', - '#key_type_toggle' => t('Customize keys (Advanced)'), - '#key_type_toggled' => $component['extra']['custom_keys'], - '#disabled' => !empty($component['extra']['options_source']), - '#weight' => 1, - ); - - $form['items']['options']['option_settings'] = $other; - } - else { - // TODO Please change this theme call to use an associative array for the $variables parameter. - $form['extra']['items'] = array( - '#type' => 'textarea', - '#title' => t('Options'), - '#default_value' => $component['extra']['items'], - '#description' => t('Key-value pairs MUST be specified as "safe_key|Some readable option". Use of only alphanumeric characters and underscores is recommended in keys. One option per line. Option groups may be specified with <Group Name>. <> can be used to insert items at the root of the menu after specifying a group.') . theme('webform_token_help'), - '#cols' => 60, - '#rows' => 5, - '#weight' => 0, - '#required' => TRUE, - '#wysiwyg' => FALSE, - '#element_validate' => array('_webform_edit_validate_govd_subscribe'), - ); - - if (!empty($component['extra']['options_source'])) { - $form['extra']['items']['#attributes'] = array('readonly' => 'readonly'); - } - - $form['extra'] = array_merge($form['extra'], $other); - // TODO Please change this theme call to use an associative array for the $variables parameter. - $form['value'] = array( - '#type' => 'textfield', - '#title' => t('Default value'), - '#default_value' => check_plain($component['value']), - '#description' => t('The default value of the field identified by its key. For multiple govd_subscribes use commas to separate multiple defaults.') . theme('webform_token_help'), - '#size' => 60, - '#maxlength' => 1024, - '#weight' => 0, - ); - $form['extra']['multiple'] = array( - '#type' => 'checkbox', - '#title' => t('Multiple'), - '#default_value' => $component['extra']['multiple'], - '#description' => t('Check this option if the user should be allowed to choose multiple values.'), - '#weight' => 0, - ); - } - - $form['display']['aslist'] = array( - '#type' => 'checkbox', - '#title' => t('Listbox'), - '#default_value' => $component['extra']['aslist'], - '#description' => t('Check this option if you want the govd_subscribe component to be of listbox type instead of radio buttons or checkboxes.'), - '#parents' => array('extra', 'aslist'), - ); - $form['display']['optrand'] = array( - '#type' => 'checkbox', - '#title' => t('Randomize options'), - '#default_value' => $component['extra']['optrand'], - '#description' => t('Randomizes the order of the options when they are displayed in the form.'), - '#parents' => array('extra', 'optrand'), - ); - - return $form; -} - -/** - * Element validation callback. Ensure keys are not duplicated. - */ -function _webform_edit_validate_govd_subscribe($element, &$form_state) { - // Check for duplicate key values to prevent unexpected data loss. Require - // all options to include a safe_key. - /* if (!empty($element['#value'])) { - $lines = explode("\n", trim($element['#value'])); - $existing_keys = array(); - $duplicate_keys = array(); - $missing_keys = array(); - $long_keys = array(); - $group = ''; - foreach ($lines as $line) { - $matches = array(); - $line = trim($line); - if (preg_match('/^\<([^>]*)\>$/', $line, $matches)) { - $group = $matches[1]; - $key = NULL; // No need to store group names. - } - elseif (preg_match('/^([^|]*)\|(.*)$/', $line, $matches)) { - $key = $matches[1]; - if (strlen($key) > 128) { - $long_keys[] = $key; - } - } - else { - $missing_keys[] = $line; - } - - if (isset($key)) { - if (isset($existing_keys[$group][$key])) { - $duplicate_keys[$key] = $key; - } - else { - $existing_keys[$group][$key] = $key; - } - } - } - - if (!empty($missing_keys)) { - form_error($element, t('Every option must have a key specified. Specify each option as "safe_key|Some readable option".')); - } - - if (!empty($long_keys)) { - form_error($element, t('Option keys must be less than 128 characters. The following keys exceed this limit:') . theme('item_list', $long_keys)); - } - - if (!empty($duplicate_keys)) { - form_error($element, t('Options within the govd_subscribe list must be unique. The following keys have been used multiple times:') . theme('item_list', $duplicate_keys)); - } - - } - */ - return TRUE; -} - -/** - * Implements _webform_render_component(). - */ -function _webform_render_govd_subscribe($component, $value = NULL, $filter = TRUE) { - - $element = array( - '#title' => $filter ? _webform_filter_xss($component['name']) : $component['name'], - '#title_display' => $component['extra']['title_display'] ? $component['extra']['title_display'] : 'before', - '#required' => $component['mandatory'], - '#weight' => $component['weight'], - '#description' => $filter ? _webform_filter_descriptions($component['extra']['description']) : $component['extra']['description'], - '#theme_wrappers' => array('webform_element_wrapper'), - '#pre_render' => array('webform_element_title_display'), - '#post_render' => array('webform_element_wrapper'), - '#webform_component' => $component, - ); - - // Convert the user-entered options list into an array. - $default_value = $filter ? _webform_filter_values($component['value'], NULL, NULL, NULL, FALSE) : $component['value']; - $options = _webform_govd_subscribe_options($component, !$component['extra']['aslist'], $filter); - - if ($component['extra']['optrand']) { - _webform_shuffle_options($options); - } - - // Add default options if using a govd_subscribe list with no default. This matches - // Drupal 7's handling of govd_subscribe lists. - if ($component['extra']['aslist'] && !$component['extra']['multiple'] && $default_value === '') { - $options = array('' => ($component['mandatory'] ? t('- Select -') : t('- None -'))) + $options; - } - - // Set the component options. - $element['#options'] = $options; - - // Set the default value. - if (isset($value)) { - if ($component['extra']['multiple']) { - // Set the value as an array. - $element['#default_value'] = array(); - foreach ((array) $value as $key => $option_value) { - $element['#default_value'][] = check_plain($option_value); - } - } - else { - // Set the value as a single string. - $element['#default_value'] = ''; - foreach ((array) $value as $option_value) { - $element['#default_value'] = check_plain($option_value); - } - } - } - elseif ($default_value !== '') { - // Convert default value to a list if necessary. - if ($component['extra']['multiple']) { - $varray = explode(',', $default_value); - foreach ($varray as $key => $v) { - $v = trim($v); - if ($v !== '') { - $element['#default_value'][] = $v; - } - } - } - else { - $element['#default_value'] = $default_value; - } - } - elseif ($component['extra']['multiple']) { - $element['#default_value'] = array(); - } - else { - $element['#default_value'] = FALSE; - } - - if ($component['extra']['other_option'] && module_exists('govd_subscribe_or_other')) { - // Set display as a govd_subscribe_or_other element: - $element['#type'] = 'govd_subscribe_or_other'; - $element['#other'] = !empty($component['extra']['other_text']) ? check_plain($component['extra']['other_text']) : t('Other...'); - $element['#other_unknown_defaults'] = 'other'; - $element['#other_delimiter'] = ', '; - $element['#process'] = array('govd_subscribe_or_other_process', 'webform_expand_govd_subscribe_or_other'); - if ($component['extra']['multiple']) { - $element['#multiple'] = TRUE; - $element['#govd_subscribe_type'] = 'checkboxes'; - } - else { - $element['#multiple'] = FALSE; - $element['#govd_subscribe_type'] = 'radios'; - } - if ($component['extra']['aslist']) { - $element['#govd_subscribe_type'] = 'govd_subscribe'; - } - } - elseif ($component['extra']['aslist']) { - // Set display as a govd_subscribe list: - $element['#type'] = 'govd_subscribe'; - if ($component['extra']['multiple']) { - $element['#size'] = 4; - $element['#multiple'] = TRUE; - } - } - else { - if ($component['extra']['multiple']) { - // Set display as a checkbox set. - $element['#type'] = 'checkboxes'; - // Drupal 6 to properly render on multipage forms. - $element['#process'] = array('govd_subscribe_expand_checkboxes', 'webform_expand_govd_subscribe_ids'); - } - else { - // Set display as a radio set. - $element['#type'] = 'radios'; - $element['#process'] = array('expand_radios', 'webform_expand_govd_subscribe_ids'); - } - } - return $element; - -} - -/** - * Process function to ensure govd_subscribe_or_other elements validate properly. - */ -function webform_expand_govd_subscribe_or_other($element) { - // Disable validation for back-button and save draft. - $element['govd_subscribe']['#validated'] = TRUE; - $element['govd_subscribe']['#webform_validated'] = FALSE; - - $element['other']['#validated'] = TRUE; - $element['other']['#webform_validated'] = FALSE; - - // If the default value contains "govd_subscribe_or_other" (the key of the govd_subscribe - // element for the "other..." choice), discard it and set the "other" value. - if (is_array($element['#default_value']) && in_array('govd_subscribe_or_other', $element['#default_value'])) { - $key = array_search('govd_subscribe_or_other', $element['#default_value']); - unset($element['#default_value'][$key]); - $element['#default_value'] = array_values($element['#default_value']); - $element['other']['#default_value'] = implode(', ', $element['#default_value']); - } - - return $element; -} - -/** - * Drupal 6ism that properly *renders* checkboxes in multistep forms. This is - * different than the value code needed in Drupal 5, which is no longer needed. - */ -function govd_subscribe_expand_checkboxes($element) { - // Elements that have a value set are already in the form structure cause - // them not to be written when the expand_checkboxes function is called. - $default_value = array(); - foreach (element_children($element) as $key) { - if (isset($element[$key]['#default_value'])) { - $default_value[$key] = $element[$key]['#default_value']; - unset($element[$key]); - } - } - - $element = expand_checkboxes($element); - - // Escape the values of checkboxes. - foreach (element_children($element) as $key) { - $element[$key]['#return_value'] = check_plain($element[$key]['#return_value']); - $element[$key]['#name'] = $element['#name'] . '[' . $element[$key]['#return_value'] . ']'; - $element[$key]['#value_callback'] = 'govd_subscribe_checkbox_value'; - $element[$key]['#pre_render'][] = 'govd_subscribe_checkbox_prerender'; - } - - foreach ($default_value as $key => $val) { - $element[$key]['#default_value'] = $val; - } - return $element; -} - -/** - * Helper function to ensure that the default value of "0" checkboxes renders. - * - * The default handling of checkboxes only checks checkboxes based on the #value - * property. If a checkbox has a value of "0" (as a string), the checkbox - * doesn't print out the way it should. - * - * @see theme_checkbox() - */ -function govd_subscribe_checkbox_prerender($element) { - if ($element['#value'] === '0') { - $element['#value'] = TRUE; - } - return $element; -} - -/** - * Helper function to determine the value for a checkbox form element. - * - * Drupal core cannot decern the difference between an unchecked checkbox and - * a checked checkbox that has a value of '0'. This value callback will return - * NULL instead of an integer 0 for checkboxes that are not checked. - * - * @see form_type_checkbox_value() - */ -function govd_subscribe_checkbox_value($form, $edit = FALSE) { - if ($edit !== FALSE) { - if (empty($form['#disabled'])) { - return $edit !== NULL ? $form['#return_value'] : NULL; // 0 in core. - } - else { - return $form['#default_value']; - } - } -} - -/** - * FAPI process function to rename IDs attached to checkboxes and radios. - */ -function webform_expand_govd_subscribe_ids($element) { - $id = $element['#id'] = str_replace('_', '-', _webform_safe_name(strip_tags($element['#id']))); - $delta = 0; - foreach (element_children($element) as $key) { - $delta++; - // Convert the #id for each child to a safe name, regardless of key. - $element[$key]['#id'] = $id . '-' . $delta; - - // Prevent scripts or CSS in the labels for each checkbox or radio. - $element[$key]['#title'] = _webform_filter_xss($element[$key]['#title']); - } - return $element; -} - -/** - * Implements _webform_display_component(). - */ -function _webform_display_govd_subscribe($component, $value, $format = 'html') { - return array( - '#title' => check_plain($component['name']), - '#weight' => $component['weight'], - '#theme' => 'webform_display_govd_subscribe', - '#theme_wrappers' => $format == 'html' ? array('webform_element', 'webform_element_wrapper') : array('webform_element_text'), - '#post_render' => array('webform_element_wrapper'), - '#format' => $format, - '#value' => (array) $value, - '#webform_component' => $component, - ); -} - -/** - * Implements _webform_submit_component(). - * - * Convert FAPI 0/1 values into something saveable. - */ -function _webform_submit_govd_subscribe($component, $value) { - // Build a list of all valid keys expected to be submitted. - $options = _webform_govd_subscribe_options($component, TRUE); - - $return = NULL; - if (is_array($value)) { - $return = array(); - foreach ($value as $key => $option_value) { - // Handle options that are specified options. - if ($option_value !== '' && isset($options[$option_value])) { - // Checkboxes submit a value of FALSE when unchecked. A checkbox with - // a value of '0' is valid, so we can't use empty() here. - if ($option_value === FALSE && !$component['extra']['aslist'] && $component['extra']['multiple']) { - unset($value[$option_value]); - } - else { - $return[] = $option_value; - } - } - // Handle options that are added through the "other" field. Specifically - // exclude the "govd_subscribe_or_other" value, which is added by the govd_subscribe list. - elseif ($component['extra']['other_option'] && module_exists('govd_subscribe_or_other') && $option_value != 'govd_subscribe_or_other') { - $return[] = $option_value; - } - } - } - elseif (is_string($value)) { - $return = $value; - } - - return $return; -} - -/** - * Format the text output for this component. - */ -function theme_webform_display_govd_subscribe($element) { - // TODO: Should this theme webform_display_govd_subscribe be declared in hook_theme()? - $component = $element['#webform_component']; - - // Convert submitted 'safe' values to un-edited, original form. - $options = _webform_govd_subscribe_options($component, TRUE); - - $items = array(); - if ($component['extra']['multiple']) { - foreach ((array) $element['#value'] as $option_value) { - if ($option_value !== '') { - // Administer provided values. - if (isset($options[$option_value])) { - $items[] = $element['#format'] == 'html' ? _webform_filter_xss($options[$option_value]) : $options[$option_value]; - } - // User-specified in the "other" field. - else { - $items[] = $element['#format'] == 'html' ? check_plain($option_value) : $option_value; - } - } - } - } - else { - if (isset($element['#value'][0]) && $element['#value'][0] !== '') { - // Administer provided values. - if (isset($options[$element['#value'][0]])) { - $items[] = $element['#format'] == 'html' ? _webform_filter_xss($options[$element['#value'][0]]) : $options[$element['#value'][0]]; - } - // User-specified in the "other" field. - else { - $items[] = $element['#format'] == 'html' ? check_plain($element['#value'][0]) : $element['#value'][0]; - } - } - } - - if ($element['#format'] == 'html') { - $output = count($items) > 1 ? theme('item_list', array('items' => $items)) : (isset($items[0]) ? $items[0] : ' '); - } - else { - if (count($items) > 1) { - foreach ($items as $key => $item) { - $items[$key] = ' - ' . $item; - } - $output = implode("\n", $items); - } - else { - $output = isset($items[0]) ? $items[0] : ' '; - } - } - - return $output; -} - -/** - * Implements _webform_analysis_component(). - */ -function _webform_analysis_govd_subscribe($component, $sids = array(), $single = FALSE) { - $options = _webform_govd_subscribe_options($component, TRUE); - $show_other_results = $single; - - $sid_placeholders = count($sids) ? array_fill(0, count($sids), "'%s'") : array(); - $sid_filter = count($sids) ? " AND sid IN (" . implode(",", $sid_placeholders) . ")" : ""; - - $option_operator = $show_other_results ? 'NOT IN' : 'IN'; - $placeholders = count($options) ? array_fill(0, count($options), "'%s'") : array(); - $query = 'SELECT data, count(data) as datacount ' . - ' FROM {webform_submitted_data} ' . - ' WHERE nid = %d ' . - ' AND cid = %d ' . - " AND data != ''" . $sid_filter . - ($placeholders ? ' AND data ' . $option_operator . ' (' . implode(',', $placeholders) . ')' : '') . - ' GROUP BY data '; - - $count_query = 'SELECT count(*) as datacount ' . - ' FROM {webform_submitted_data} ' . - ' WHERE nid = %d ' . - ' AND cid = %d ' . - " AND data != ''" . $sid_filter; - - // TODO Please convert this statement to the D7 database API syntax. - $result = db_query($query, array_merge(array($component['nid'], $component['cid']), $sids, array_keys($options))); - $rows = array(); - $normal_count = 0; - while ($data = db_fetch_array($result)) { - $display_option = $single ? $data['data'] : $options[$data['data']]; - $rows[$data['data']] = array(_webform_filter_xss($display_option), $data['datacount']); - $normal_count += $data['datacount']; - } - - if (!$show_other_results) { - // Order the results according to the normal options array. - $ordered_rows = array(); - foreach (array_intersect_key($options, $rows) as $key => $label) { - $ordered_rows[] = $rows[$key]; - } - - // Add a row for any unknown or user-entered values. - if ($component['extra']['other_option']) { - // TODO Please convert this statement to the D7 database API syntax. - $full_count = db_query($count_query, array_merge(array($component['nid'], $component['cid']), $sids))->fetchField(); - $other_count = $full_count - $normal_count; - $display_option = !empty($component['extra']['other_text']) ? check_plain($component['extra']['other_text']) : t('Other...'); - $other_text = $other_count ? $other_count . ' (' . l(t('view'), 'node/' . $component['nid'] . '/webform-results/analysis/' . $component['cid']) . ')' : $other_count; - $ordered_rows[] = array($display_option, $other_text); - } - - $rows = $ordered_rows; - } - - return $rows; -} - -/** - * Implements _webform_table_component(). - */ -function _webform_table_govd_subscribe($component, $value) { - // Convert submitted 'safe' values to un-edited, original form. - $options = _webform_govd_subscribe_options($component, TRUE); - - $value = (array) $value; - $items = array(); - // Set the value as a single string. - foreach ($value as $option_value) { - if ($option_value !== '') { - if (isset($options[$option_value])) { - $items[] = _webform_filter_xss($options[$option_value]); - } - else { - $items[] = check_plain($option_value); - } - } - } - - return implode('
', $items); -} - -/** - * Implements _webform_csv_headers_component(). - */ -function _webform_csv_headers_govd_subscribe($component, $export_options) { - $headers = array( - 0 => array(), - 1 => array(), - 2 => array(), - ); - - if ($component['extra']['multiple'] && $export_options['govd_subscribe_format'] == 'separate') { - $headers[0][] = ''; - $headers[1][] = $component['name']; - $items = _webform_govd_subscribe_options($component, TRUE, FALSE); - if ($component['extra']['other_option']) { - $other_label = !empty($component['extra']['other_text']) ? check_plain($component['extra']['other_text']) : t('Other...'); - $items[$other_label] = $other_label; - } - $count = 0; - foreach ($items as $key => $item) { - // Empty column per sub-field in main header. - if ($count != 0) { - $headers[0][] = ''; - $headers[1][] = ''; - } - if ($export_options['govd_subscribe_keys']) { - $headers[2][] = $key; - } - else { - $headers[2][] = $item; - } - $count++; - } - } - else { - $headers[0][] = ''; - $headers[1][] = ''; - $headers[2][] = $component['name']; - } - return $headers; -} - -/** - * Implements _webform_csv_data_component(). - */ -function _webform_csv_data_govd_subscribe($component, $export_options, $value) { - $options = _webform_govd_subscribe_options($component, TRUE, FALSE); - $return = array(); - - if ($component['extra']['multiple']) { - foreach ($options as $key => $item) { - $index = array_search($key, (array) $value); - if ($index !== FALSE) { - if ($export_options['govd_subscribe_format'] == 'separate') { - $return[] = 'X'; - } - else { - $return[] = $export_options['govd_subscribe_keys'] ? $key : $item; - } - unset($value[$index]); - } - elseif ($export_options['govd_subscribe_format'] == 'separate') { - $return[] = ''; - } - } - - // Any remaining items in the $value array will be user-added options. - if ($component['extra']['other_option']) { - $return[] = count($value) ? implode(',', $value) : ''; - } - } - else { - $key = $value[0]; - if ($export_options['govd_subscribe_keys']) { - $return = $key; - } - else { - $return = isset($options[$key]) ? $options[$key] : $key; - } - } - - if ($component['extra']['multiple'] && $export_options['govd_subscribe_format'] == 'compact') { - $return = implode(',', (array) $return); - } - - return $return; -} - -/** - * Menu callback; Return a predefined list of govd_subscribe options as JSON. - */ -function webform_govd_subscribe_options_ajax($source_name = '') { - $info = _webform_govd_subscribe_options_info(); - - $component['extra']['options_source'] = $source_name; - if ($source_name && isset($info[$source_name])) { - $options = _webform_govd_subscribe_options_to_text(_webform_govd_subscribe_options($component, !$component['extra']['aslist'], FALSE)); - } - else { - $options = ''; - } - - $return = array( - 'elementId' => module_exists('options_element') ? 'edit-items-options-options-field-widget' : 'edit-extra-items', - 'options' => $options, - ); - - drupal_json_output($return); -} - - -/** - * Generate a list of options for a govd_subscribe list. - */ -function _webform_govd_subscribe_options($component, $flat = FALSE, $filter = TRUE) { - if ($component['extra']['options_source']) { - $options = _webform_govd_subscribe_options_callback($component['extra']['options_source'], $component, $flat, $filter); - } - else { - $options = _webform_govd_subscribe_options_from_text($component['extra']['items'], $flat, $filter); - } - - return isset($options) ? $options : array(); -} - -/** - * Load Webform govd_subscribe option info from 3rd party modules. - */ -function _webform_govd_subscribe_options_info() { - static $info; - if (!isset($info)) { - $info = array(); - - foreach (module_implements('webform_govd_subscribe_options_info') as $module) { - $additions = module_invoke($module, 'webform_govd_subscribe_options_info'); - foreach ($additions as $key => $addition) { - $additions[$key]['module'] = $module; - } - $info = array_merge($info, $additions); - } - drupal_alter('webform_govd_subscribe_options_info', $info); - } - return $info; -} - -/** - * Execute a govd_subscribe option callback. - * - * @param $name - * The name of the options group. - * @param $component - * The full Webform component. - * @param $flat - * Whether the information returned should exclude any nested groups. - * @param $filter - * Whether information returned should be sanitized. Defaults to TRUE. - */ -function _webform_govd_subscribe_options_callback($name, $component, $flat = FALSE, $filter = TRUE) { - $info = _webform_govd_subscribe_options_info(); - - // Include any necessary files. - if (isset($info[$name]['file'])) { - $pathinfo = pathinfo($info[$name]['file']); - $path = ($pathinfo['dirname'] ? $pathinfo['dirname'] . '/' : '') . basename($pathinfo['basename'], '.' . $pathinfo['extension']); - module_load_include($pathinfo['extension'], $info[$name]['module'], $path); - } - - // Execute the callback function. - if (isset($info[$name]['options callback']) && function_exists($info[$name]['options callback'])) { - $function = $info[$name]['options callback']; - - $arguments = array(); - if (isset($info[$name]['options arguments'])) { - $arguments = $info[$name]['options arguments']; - } - - return $function($component, $flat, $filter, $arguments); - } -} - -/** - * Utility function to split user-entered values from new-line seperated - * text into an array of options. - * - * @param $text - * Text to be converted into a govd_subscribe option array. - * @param $flat - * Optional. If specified, return the option array and exclude any optgroups. - * @param $filter - * Optional. Whether or not to filter returned values. - */ -function _webform_govd_subscribe_options_from_text($text, $flat = FALSE, $filter = TRUE) { - static $option_cache = array(); - - // Keep each processed option block in an array indexed by the MD5 hash of - // the option text and the value of the $flat variable. - $md5 = md5($text); - - // Check if this option block has been previously processed. - if (!isset($option_cache[$flat][$md5])) { - $options = array(); - $rows = array_filter(explode("\n", trim($text))); - $group = NULL; - foreach ($rows as $option) { - $option = trim($option); - /** - * If the Key of the option is within < >, treat as an optgroup - * - * - * creates an optgroup with the label "Group 1" - * - * <> - * Unsets the current group, allowing items to be inserted at the root element. - */ - if (preg_match('/^\<([^>]*)\>$/', $option, $matches)) { - if (empty($matches[1])) { - unset($group); - } - elseif (!$flat) { - $group = $filter ? _webform_filter_values($matches[1], NULL, NULL, NULL, FALSE) : $matches[1]; - } - } - elseif (preg_match('/^([^|]+)\|(.*)$/', $option, $matches)) { - $key = $filter ? _webform_filter_values($matches[1], NULL, NULL, NULL, FALSE) : $matches[1]; - $value = $filter ? _webform_filter_values($matches[2], NULL, NULL, NULL, FALSE) : $matches[2]; - isset($group) ? $options[$group][$key] = $value : $options[$key] = $value; - } - else { - $filtered_option = $filter ? _webform_filter_values($option, NULL, NULL, NULL, FALSE) : $option; - isset($group) ? $options[$group][$filtered_option] = $filtered_option : $options[$filtered_option] = $filtered_option; - } - } - - $option_cache[$flat][$md5] = $options; - } - - // Return our options from the option_cache array. - return $option_cache[$flat][$md5]; -} - - -/** - * Convert an array of options into text. - */ -function _webform_govd_subscribe_options_to_text($options) { - $output = ''; - $previous_key = FALSE; - - foreach ($options as $key => $value) { - // Convert groups. - if (is_array($value)) { - $output .= '<' . $key . '>' . "\n"; - foreach ($value as $subkey => $subvalue) { - $output .= $subkey . '|' . $subvalue . "\n"; - } - $previous_key = $key; - } - // Typical key|value pairs. - else { - // Exit out of any groups. - if (isset($options[$previous_key]) && is_array($options[$previous_key])) { - $output .= "<>\n"; - } - // Skip empty rows. - if ($options[$key] !== '') { - $output .= $key . '|' . $value . "\n"; - } - $previous_key = $key; - } - } - - return $output; -} - -/** - * Utility function to shuffle an array while preserving key-value pairs. - function _webform_shuffle_options(&$array) { - // First shuffle the array keys, then use them as the basis for ordering - // the options. - $aux = array(); - $keys = array_keys($array); - shuffle($keys); - foreach ($keys as $key) { - $aux[$key] = $array[$key]; - } - $array = $aux; - } - */ diff --git a/modules/custom/govdelivery/webform_components/govdelivery_subscribe/govdelivery_subscribe.info b/modules/custom/govdelivery/webform_components/govdelivery_subscribe/govdelivery_subscribe.info deleted file mode 100644 index 26b8d23b0..000000000 --- a/modules/custom/govdelivery/webform_components/govdelivery_subscribe/govdelivery_subscribe.info +++ /dev/null @@ -1,7 +0,0 @@ -name = GovDelivery Subscribe -description = Provides a Webform 3 component for subscribing to GovDelivery mailing lists -package = GovDelivery Webform Components -core = 7.x - -dependencies[] = govdelivery -dependencies[] = webform diff --git a/modules/custom/govdelivery/webform_components/govdelivery_subscribe/govdelivery_subscribe.module b/modules/custom/govdelivery/webform_components/govdelivery_subscribe/govdelivery_subscribe.module deleted file mode 100644 index 37bd205f2..000000000 --- a/modules/custom/govdelivery/webform_components/govdelivery_subscribe/govdelivery_subscribe.module +++ /dev/null @@ -1,75 +0,0 @@ - t('GovDelivery Subscribe'), - 'description' => t('Provide one or more options for GovDelivery mailinglists to which users can subscribe'), - 'features' => array( - //most of the available options default to the values we want, so aren't specified here - 'required' => FALSE, //the intent is not to provide mandatory subscribing - ), - 'file' => 'govdelivery_subscribe.component.inc', - ); - - return $components; -} - -/** - * Implements hook_webform_submission_insert(). - * - * This function is used to process subscriptions from webforms - * The intention is to be generic and reusable. - * - * Use the webform module to add a govd_select component anywhere you would like to add - * subscriptions. - * - * This module also does a search on the form to find an email address component. If multiple email address - * components appear on the same form the last one will always be selected. - */ -function govdelivery_subscribe_webform_submission_insert($node, $submission) { - //find govd_subscribe components on the node and capture their cid's so we can use them to pull the data from the submission - $govd_components = array(); - $email_component_value = ''; - foreach ($node->webform['components'] as $cid => $component) { - if ($component['type'] == 'govd_subscribe') { - $govd_components[] = $cid; - } - else if ($component['type'] == 'email' || $component['type'] == 'uniquemail') { - $email_component_value = $submission->data[$cid]['value'][0]; - } - } - - //make sure we have govd components and an email, otherwise don't bother continuing - if (!$govd_components) { - return; //form has no govd_subscribe components - } - if (!$email_component_value) { - watchdog('GovD Subscribe', "Unable to retrieve email address from webform at nid: $submission->nid, submission: $submission->sid"); - return; - } - - //grab the selected options from the govd component - $govd_subscriptions = array(); - foreach ($govd_components as $cid) { - if ($submission->data[$cid]['value']) { - $govd_subscriptions = array_merge($govd_subscriptions, $submission->data[$cid]['value']); - } - } - - //subscribe them - foreach ($govd_subscriptions as $subscription_key) { - govdelivery_subscribe($subscription_key, $email_component_value, FALSE); - } -} diff --git a/modules/custom/wh_core/wh_core.info b/modules/custom/wh_core/wh_core.info deleted file mode 100644 index 20535f5a7..000000000 --- a/modules/custom/wh_core/wh_core.info +++ /dev/null @@ -1,16 +0,0 @@ -name = "White House Core" -description = "Encapsulates configurations specific to Petitions in the Whitehouse environment" -core = 7.x -package = White House Custom - -files[] = ../../contrib/captcha/captcha.inc - -dependencies[] = rules -dependencies[] = logintoboggan -dependencies[] = logintoboggan_rules -dependencies[] = petitions_logintoboggan_settings -dependencies[] = wh_zipcodelookup -dependencies[] = wh_user_profile -dependencies[] = captcha -dependencies[] = petitions_user_registration -dependencies[] = wh_user_ss_data diff --git a/modules/custom/wh_core/wh_core.install b/modules/custom/wh_core/wh_core.install deleted file mode 100644 index 5a35b474f..000000000 --- a/modules/custom/wh_core/wh_core.install +++ /dev/null @@ -1,648 +0,0 @@ - -.col-3{ -display: none; -} -.petition-intro-video-wrapper{ -text-align: left; -margin-top: 20px; -} -.header-fix{ -height:120px; -} -.petition-hero{ -background: url(/profiles/petition/themes/petitions/img/petitions_landing_hero.jpg) top center no-repeat; -height: 296px; -} -.petition-hero p{ -color: #fff; -font-size: 28px; -font-family: Georgia,"Times New Roman",Times,serif; -padding: 0 15px; -margin: 0; -line-height: 39px; -} -p.line1{ -padding-top: 22px; -} -p.line2{ - -} -p.line3{ - -} -p.line4{ -padding-top:12px; -} -a.view-petition-btn, a.start-petition-btn{ -background-image: url(/profiles/petition/themes/petitions/img/petitions_landing_btns_0.png); -display:inline-block; -height: 31px; -width:167px; -text-indent: -9999px; -margin: 15px 0 0 15px; -} -.start-petition-btn{ -background-position: 167px 0; -} -.start-petition-btn:hover{ -background-position: 167px 64px; -} -.start-petition-btn:focus{ -background-position: 167px 31px; -} -a.view-petition-btn{ -background-position: 0px 0px; -} -a.view-petition-btn:hover{ -background-position: 0px 64px; -} -a.view-petition-btn:focus{ -background-position: 0px 31px; -} -.easy-steps{ -font-size: 14px; -padding: 15px 0; -} -.bold-intro{ -font-weight:bold; -} -.steps h3{ -font-family: Georgia,"Times New Roman",Times,serif; -margin: 0px; -text-transform: capitalize; -color: #666; -font-weight: lighter; -} -.steps p{ -font-family: Arial,Helvetica,sans-serif; -font-size: 12px; -margin: 8px 0px 20px 0px; -line-height: 1.2em; -height: 57px; -} -.steps hr{ -background-color: #cecece; -border-top: 0px; -border-bottom: 0px; -} -.center-rule{ - -} -.take-action{ -margin-top: -8px; -background-color: #fff; -padding-right: 8px; -text-transform: uppercase; -font-weight: normal; -width: 85px; -} -.petition-landing-wrapper{ -position:relative; -border-bottom: 4px double #cecece; -} -.triangle-link{ -background: url(/profiles/petition/themes/petitions/img/petitionslanding_arrow.png) left 2px no-repeat; -padding: 0px 0px 0px 12px; -margin-top: 10px; -display:block; -} -.right-side{ -display: block; -height: 735px; -width: 313px; -position: absolute; -top: 10px; -right: 10px; -background: url(/profiles/petition/themes/petitions/img/petitions_landing_rightrail.png) top center no-repeat; -} -.right-inner{ -margin-top: 70px; -margin-left:20px; -margin-right: 20px; -position: relative; -} -.right-side h3{ -text-transform: capitalize; -color: #333; -line-height: 20px; -border-bottom: 1px solid #cecece; -font-size: 12px; -} -.right-side .recent{ - margin-top:40px; -} -.right-side .recent a{ -color: #669900; -} -.right-side .recent a:hover, .right-side .recent a:focus{ -color: #4d7400; -} -.right-side .featured, .right-side .recent{ - position: relative; -} -.right-side .featured ul, .right-side .recent ul{ - list-style-type: none; -} -.right-side .featured ul li, .right-side .recent ul li{ -margin: 10px 0 15px; -} -.right-side .featured ul li a, .right-side .recent ul li a{ -font-family: Georgia,"Times New Roman",Times,serif; -font-size: 14px; -} -.right-side .featured .see-all, .right-side .recent .see-all{ -font-weight: bold; -font-size: 11px; -position: absolute; -right: 0; -text-transform: uppercase; -top: 3px; -} -a.video-link{ -background: url(/profiles/petition/themes/petitions/img/petitions_video_thumb_new.jpg); -background-position: 0px 0px; -display: inline-block; -float:left; -text-indent: -9999px; -margin: 0 0 30px 13px; -padding: 127px 149px 58px; -width: 1px; -} -a.video-link:hover, a.video-link:focus{ -background-position: -312px 0px; -} -.petition-landing-wrapper blockquote{ -color: #444; -display: inline-block; -float: left; -font-family: Georgia,"Times New Roman",Times,serif; -margin: 0; -padding: 30px 0 20px 20px; -width: 275px; -} -.attribution{ -display: inline-block; -padding-left: 20px; -color: #444; -} -h3.more{ -border-bottom: 1px solid #CECECE; -font-size: 14px; -font-weight: normal; -line-height: 28px; -margin-bottom: 20px; -padding: 20px 0 0; -} -.follow h4{ -color: #333333; -font-size: 14px; -font-weight: bold; -letter-spacing: -1px; -margin: 6px 0 15px 0px; -text-transform: none; -} -a.facebook-link, a.twitter-link, a.gplus-link{ -background: url(/profiles/petition/themes/petitions/img/petitions_social_icons.jpg) no-repeat; -display:inline-block; -font-weight: bold; -height: 45px; -text-decoration: none; -color: #333; -padding-left: 40px; -padding-top: 5px; -} -a.facebook-link{ -background-position: 0px 0px; -} -a:hover.facebook-link{ -background-position: 0px -161px; -color: #336699; -} -a.twitter-link{ -background-position: 0px -56px -} -a:hover.twitter-link{ -background-position: 0px -217px; -color: #336699; -} -a.gplus-link{ -background-position: 0px -106px -} -a:hover.gplus-link{ -background-position: 0px -267px; -color: #336699; -} -a.image-link{ -display: block; -text-align:center; -text-decoration: none; -height: 154px; -padding:5px 0px; -margin-bottom:10px; -} -a.image-link:hover{ -border: 5px solid #336699; -padding:0px; -} -.petition-twitter{ -position: absolute; -width: 230px; -height: 120px; -top: 595px; -right: 40px; -line-height: 18px; -} -.petition-twitter .retweet, .petition-twitter .reply{ -background: url(/profiles/petition/themes/petitions/img/tweet_retweet.png); -text-indent: -9999px; -display: inline-block; -margin-left: 10px; -} -.tweet{ - position: relative; - height: 122px; -} -.twitter-buttons{ - position: absolute; - bottom: 0px; - right: 0px; -} -.petition-twitter .retweet{ - background-position: 0px 0px; - height: 12px; - width: 14px; -} -.petition-twitter .reply{ - background-position: -55px 0px; - height: 12px; - width: 12px; -} -.twitter-user{ - font-weight: bold; - margin-bottom:5px; -} -object{ - margin-top: 20px; -} -.featured-1 p, .featured-2 p{ -padding-right: 10px; -padding-left: 5px; -font-size: 12px; -} -.featured-2 a.featured-link, .featured-1 a.featured-link{ -padding-left: 5px; -} -.bold{ - font-weight: bold; -} -#petition-tool-content{ -min-height: 1347px !important; -} -.hidden{ -display: none; -} -#petition-tool-region-right{ -display: none; -} -.video-region{ - margin: 50px 0px; -} -.close-link{ - padding-top: 5px; - padding-left: 18px; -} -.video-region iframe{ - padding-left: 18px; -} -.bird-img{ - bottom: 121px; - position: absolute; - right: 43px; -} - - -
-
-

Giving all Americans a way to engage

-

their government on the issues that

-

matter to them.

-

Get Started

- View PetitionsStart a Petition -
-
-
We the People in Three Easy Steps
-
-

Step 1

-

Browse open petitions to find a petition related to your issue, and add your signature.

-
-
Take Action
- Find a petition -
-
-

Step 2

-

If your issue is not currently represented by an active petition, start a new petition.

-
-
Take Action
- Start a Petition -
-
-

Step 3

-

If a petition meets the signature threshold, it will be reviewed by the Administration and we will issue a response.

-
-
Take Action
- View all responses -
-
-
- Watch the Introductory Video -
“My administration is committed to creating an unprecedented level of openness in government. We will work together to ensure the public trust and establish a system of transparency, public participation and collaboration. Openness will strengthen our democracy and promote efficiency and efffectiveness in government.”
-
— President Barack Obama
-
- -
-
-
-

More from the White House

- - - -
-
- -EOF; -variable_set('wh_petitions_homepage_content',$homepage_content); - -} - -/** - * Sets site variables related to registration and emails which are sent. - * - */ -function _set_email_variables() { - variable_set('user_register', 1); // visitors can register without approval - variable_set('user_email_verification', 1); // users must verify their email when registering - - // email settings - variable_set('user_mail_register_no_approval_required_body', _no_approval_required_email_body()); - variable_set('user_mail_register_no_approval_required_subject', _no_approval_required_email_subject()); -} - -/** - * Returns text which should be set as the body of the no approval required user registration email. - * - * @return string - */ -function _no_approval_required_email_body() { - return '
-You\'re only one step away from creating your Petitions.WhiteHouse.gov account. Just click on the link below or cut and paste it into your web browser to confirm this is a working email address: - -[user:one-time-login-url] - -IMPORTANT: If you created your account in the process of signing a petition on We the People, you still need to click on the "Sign this Petition" button on the petition\'s webpage. - -Here is your WhiteHouse.gov account information: - -[site:login-url] -e-mail: [user:mail] -password: [user:password] - -Once you\'ve verified your email address, click on this link or copy and paste it into your web browser to update your profile or change your password: - -[site:login-url] - -More information about WhiteHouse.gov accounts is available in the WhiteHouse.gov\'s Privacy Policy (http://www.whitehouse.gov/privacy) and the Terms of Participation ([site:url]/how-why/terms-participation) for We the People. - -------------------------------------------------------- -This email was automatically sent by Petitions.WhiteHouse.gov because someone attempted to create a Petitions.WhiteHouse.gov account using the address [user:mail] -
'; -} - -/** - * Returns text which should be set as the subject of the no approval required user registration email. - * - * @return string - */ -function _no_approval_required_email_subject() { - return "Almost done! Verify your Petitions.WhiteHouse.gov account"; -} - -/** - * Callback to set reCAPTCHA on the user registration form. - */ -function _enable_recaptcha_user_reg() { - $form_id = 'user_register_form'; - - $captcha_type = new stdClass(); - $captcha_type->module = 'recaptcha'; - $captcha_type->captcha_type = 'reCAPTCHA'; - - module_load_include('inc', 'captcha', 'captcha'); - - // set the recaptcha theme style to 'clean' - variable_set('recaptcha_theme', 'clean'); - - captcha_set_form_id_setting($form_id, $captcha_type); -} - -/** - * Implements hook_update_n(). - * This update fixes internal links on all the pages on petition site. - */ -function wh_core_update_7001() { - db_query("UPDATE {field_data_body} SET body_value = replace(body_value, 'petitions/!/', '/') WHERE entity_id = 79 OR entity_id = 73 OR entity_id = 61 OR entity_id = 67 OR entity_id = 139 OR entity_id = 151 OR entity_id = 145"); - db_query("UPDATE {field_data_body} SET body_value = replace(body_value, 'https://wwws.whitehouse.gov', 'https://petitions.whitehouse.gov') WHERE entity_id = 79"); - db_query("UPDATE {field_data_body} SET body_value = replace(body_value, 'href=\"https://wwws.whitehouse.gov/', 'href=\"') WHERE entity_id = 79"); -} - -/** - * Implements hook_update_N(). - * Fixes a hardcoded links in a content variable. - */ -function wh_core_update_7002() { - variable_set('wh_petitions_report_modal_text', '

Click the button below only if you believe this petition is in violation of the Terms of Participation. Are you sure you want to do this?

'); - - variable_set('wh_petitions_archived_page_text', '

Thanks for your interest in We the People, a new tool on WhiteHouse.gov that allows all Americans to ask the Obama Administration to take action on a range of important issues facing our country.

-

The petition you are trying to access has expired, because it failed to meet the signature threshold.

-

While you can\'t sign this petition, there may be other petitions on We the People on a similar issue that you\'d like to add your name to. Or, you can create your own petition.

-

Create a petition

'); - - variable_set('wh_petitions_flagged_page_text', '

Thanks for your interest in We the People, a new tool on WhiteHouse.gov that allows all Americans to ask the Obama Administration to take action on a range of important issues facing our country.

-

The petition you are trying to access has been removed from the site under our Moderation Policy because it is in violation of our Terms of Participation.

-

While you can\' sign this petition, there may be other petitions on We the People on a similar issue that you\'d like to add your name to. Or, you can create your own petition.

-

Sign a petition

-

Create a petition

'); - - variable_set('wh_petitions_flagged_page_creator_text', '

Thanks for your interest in We the People, a new tool on WhiteHouse.gov that allows all Americans to ask the Obama Administration to take action on a range of important issues facing our country.

-

The petition you are trying to access has been removed from the site under our Moderation Policy because it is in violation of our Terms of Participation.

-

While you can\'t sign this petition, there may be other petitions on We the People on a similar issue that you\'d like to add your name to. Or, you can create your own petition.

-

Sign a petition

-

Create a petition

'); -} - -/** - * Implements hook_update_N(). - * - * Create the blank_users_roles table for role blackholing. - */ -function wh_core_update_7003 () { - db_create_table('blank_users_roles', drupal_get_schema_unprocessed('wh_core', 'blank_users_roles')); -} diff --git a/modules/custom/wh_core/wh_core.js b/modules/custom/wh_core/wh_core.js deleted file mode 100644 index 35f9508cd..000000000 --- a/modules/custom/wh_core/wh_core.js +++ /dev/null @@ -1,21 +0,0 @@ -(function ($) { - - Drupal.behaviors.wh_core_origin_populate = { - attach: function (context) { - start = location.search.indexOf('destination='); - end = location.search.indexOf('&', start); - newVal = 'petitions'; - if (start != -1) { - start += 12; // Add 12 to compensate for destination= part of the string. - if (end == -1) { - newVal = location.search.substr(start); - } - else { - newVal = location.search.substr(start, end - 1); - } - } - $('input[name="field_origin[und][0][value]"]').val(newVal); - } - }; - -})(jQuery); diff --git a/modules/custom/wh_core/wh_core.module b/modules/custom/wh_core/wh_core.module deleted file mode 100644 index 82a8836cb..000000000 --- a/modules/custom/wh_core/wh_core.module +++ /dev/null @@ -1,108 +0,0 @@ - t('Sign up for email updates from President Obama and other senior administration officials'), - '#type' => 'checkbox', - ); - $form['#submit'][] = 'wh_core_user_register_submit'; - } - - if ($form_id == 'user_login') { - $form['name']['#title'] = t('E-Mail:'); - $form['name']['#description'] = t('You may login with your e-mail address.'); - - $form['pass']['#title'] = t('Password:'); - $form['pass']['#description'] = t('The password field is case sensitive'); - } - if ($form_id == 'user_pass') { - $form['name']['#title'] = t('E-Mail:'); - } -} - -/** - * Performs custom validation to munge email into a username and capture ip - * and user agent when a user registers. - */ -function wh_core_user_register_validate($form, &$form_state) { - if (empty($form_state['values']['name']) && !empty($form_state['values']['mail'])) { - $form_state['values']['name'] = trim($form_state['values']['mail']); - $form_state['values']['name'] = preg_replace("/[^\x80-\xF7 [:alnum:]@]/", '_', $form_state['values']['name']); - } - - $form_state['values']['field_ip_address']['und'][0]['value'] = ip_address(); - $form_state['values']['field_user_agent']['und'][0]['value'] = $_SERVER['HTTP_USER_AGENT']; -} - -/** - * Sends email updates field values to the correct govdelivery message. - */ -function wh_core_user_register_submit($form, &$form_state) { - if (!empty($form_state['values']['email_updates']) && $form_state['values']['email_updates'] == 1) { - $request = array('code' => 'USEOPWH_10128', 'email' => $form_state['values']['mail']); - $key = md5(print_r($request, TRUE) . microtime() . strval(rand())); - govdelivery_queue_set('govdelivery_subscription_queue', $key, $request); - } -} -/* Implements hook_user_login(). - * - * Set a custom cookie when a user logins in which can then be used to show - * or hide links using javascript. - */ -function wh_core_user_login(&$edit, $account) { - global $cookie_domain; - setcookie('authenticated', '1', 0, '/', $cookie_domain); -} - -/** - * Implements hook_user_logout(). - * - * Unset the custom cookie set by wh_core_user_login(). - */ -function wh_core_user_logout($account) { - global $cookie_domain; - setcookie('authenticated', '0', time() - 3600, '/', $cookie_domain); -} diff --git a/modules/custom/wh_core/wh_core.rules.inc b/modules/custom/wh_core/wh_core.rules.inc deleted file mode 100644 index 9ff23d906..000000000 --- a/modules/custom/wh_core/wh_core.rules.inc +++ /dev/null @@ -1,31 +0,0 @@ - array( - 'account' => array( - 'type' => 'user', - 'label' => t('user'), - ), - ), - 'group' => t('WH Core'), - 'label' => t('Login a User'), - 'base' => 'wh_core_login_user', - ); - return $actions; -} - -/** - * Provides a call back for the login_user Rules action. - * - */ -function wh_core_login_user($account) { - global $user; - $edit = array(); - $user = user_load($account->uid); - user_login_finalize($edit); -} diff --git a/modules/custom/wh_feedback/images/eagle.jpg b/modules/custom/wh_feedback/images/eagle.jpg deleted file mode 100644 index 2818305314b9ea8c2204f7a74058383147c8cad4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5856 zcmV<679Z(}P)^Z0M zHq(16UZ3-1t<5=5Po;iOT_^>-Hv7?YW-~sAjT2?M2a&~>G|$${A1chP+2#;3X{y_l zbm){w2kkyo-m2J5xDrR-KH}=+{3&;-{9M~55MrOSN`zp=9R{g(-1+o(`4r6i}@OIZpCCawdRXZxloO8~7 zY1CW&ENN-159g4a(b7vll%t;-&!TdF9GjCKg(XLuu&u#4K9- z;P*Ln5tR`gS7mRVK70WP`aj9J)LyDi@WHsLNZI12P&a5=%4b`cc_*^VO+yR$E`(S# zQg57Ohfg+XXOl|$_jTn9x7egYOQ=ZLW|~cL(?Hguw6C6)x6#vCJLlw6*M%Z=D9-FQ zImyWn*$}@~-Y+w4on`|^mSnNB5r<4Psd8SeuMpbXVR;X?Ev@G@&yx+O#FPhLNS8Xp z6vd)!bYA|NA7qm+TKc9E+2j0dqY8VN^!!>Crkac^LbA6Dq}xJF4rYBz6W;F`JCCP`{{9l*s_^WYU#aH zCpKJJhXmbw0A+^Y0X_N&0JVbvvicQ27o#so3@ZEF9xIi`a-O0~dVDi*OQSjr zliTC-OV1SZIiLNO5>AfB&8)wQjEz}6__ay-9CG+;YWX#(N8zjfO6KjOR#_TqJ=^bp zi%cIv93fvC`=4|I0bKIQ=wE7*F9ql9>6Cry(brj)cCk;PnQ-2WZ{>TBQt`rle6+PV zm})(;=2uhbjBd5`ddWYlA?-Vqm`917GIggk#zGHCgs$1Q!tT^AV=1EL_fH$ifzspy z=2RB=cKjSb0@=-;%~i~5}oWBKH5IIk|wHQ}8yt~_>4S{QbSQag=e%OT@8Q_o#% z;{<;=G3AwF5g!oig^)^;-p4Q2(w`+_U5N=WKmvds`3nyx^q!wDWQe zWs@R8#LC3b^~sO;^sJqdYJff!bTuM6XsDL`&uyqrkMbfLs=``r`M2UO2U9JoIvE0hk6}yzJz`le)cy% zM@G1co&IzV_H;?>`7^by2&;poJeNZm;ZGrR1qxtNG3HQz?qNYmCm|J;&4s^g_Ji9_ zVBLv!vii4?8CrhVpK#JNM4%rwUEPLF*<~{{Z5&GyV1D^|j%aOOMDqFZv5hz9TH{Wj zz(VK-8|DrkqVr_(?`zwfP>k5LHxZOtIqQEVnw5V8LOARPRtV*M2z!cg#0LnSsk!%8 z8BLDH4!5|$uSNKfPZ`_pviNOeX}Zw#c1LZV$?Oo}pbcoLX~#)y3@7Hw;n`u})kcQG zj-6@fHq?pE*|IF$L7Lce9!f&4XrG$$Q)Ryu*`%~nUdf(q6$n5dRg^HL_M@~4N-Gs% z9M3pl$5gytb1iA4LByCgZcEZ$E3$JB+|1dE0?C_yvcqpwnAK*VY+6$)-gMAKx=?AB z8(FG;L_NtRj=CJwayLMedq+??(8keXbq)%4chQG#O(NwLuBoHF_vZK6_9qaAznIy( z243q-P#P&d(=a=sx2I)=*b0)@9A=jiMqV?_{jz&O}UD1QKN1Au1o08T) zm>FrK%~#1Xy7Cf_T8~52v&*qbia(l~FPxl0XLNgs0MCq)^?CV& zIf?o_^#ro;_5`sS=E9=TukB<@=78$Z5r!#I5n<#;sq{25Rb_)a1ALT%rUu>n?q>=0 z)`Z41xxXYJ?f_AiGYtR)dNr0~q|`WyC?HIT;z9H&9&US5Mn|J{M7kGnER@)FAo_U# z@K)rksWWqvFVXiVgjFr5UiV7w*`jc?Et8|pV2&lA#pkEb>LeVyIi2=U&?jKN-sCj> zNn{YYnWqkAy?T(trdiQ1n?m{-GUt@SG{tOAq2v)>Q9tcUb#W^(efFozHbBqyIrTqi z?e`+<0G7!46dDZ?+F4V^xV>1j&&UC6jIF5NpDIKfdj23I*~ATunHeBUQjTl5%>R9- ztALNMnr5yJ2f=l+SU^n1$6nk-165C`X-EdY!t*wX8cUWM(#^fAVEl?xB88wygDoan zHv5J~zeg^yyfVT03w3#|&Lpp=vuR-wmYeeZ<#0^b5`$!7Z9y7l9}EuLcg=3rQ~OS2 z;<+x$J>t^}*$B|{VNKN;C1~0!3}tC4#xG!iQZ#DFlvgj5IfxRuiDhsh_f`Wy@d~LA z_PrS(9etgt_{SUM6i(zX9e4`V3d%~#q@n@;a25 zrBV!?SCslZNA^x+MRK&TzwC)mBHGxPfc2VEODLB1g5uT71hT~GrusraQx=GQtVT~o zh~lkq$~l%?7l6Lya_VR{UCwXG&fAxWHLVbkta)O}vTUF$KX)*{gbD?WO`fWWz1A&X z5mc8Nexmf8?@tRj?CL~5gO;uPmd_TJq1YczxditVxj<0IZ>-M!p5`UUarPIGWEYnz zY=YAIiW1v$s zu+xx3(Ub#pDD1y+U#YT3Qw7Q=5M%`5SqBNcC*oz_2;0RiR(Ax%j<|YxuoZP*N z)(PAO0rknPlybnnD{8-@ximdizPk1kKN~Q;F)d31*jPh}I2i)12TURMw56 z7lh<>f&xAfu+pZ21m<)1V!QQMhqJD8#vBZPpf zqa=6S9!!+0Iv@(&LItHA0@`8#rmb^$$~D`{u_muK3!4{iGczlAVZ*Vb8|Cn#4%G$$ zQ1V}-GY(MOF3!-Hyecx(_W@yt+Qb(ea~=2bBU!sxQwNB!3J_lqex5yhV`37ib;$SG z>PvO~++f*i?BXH#Yh;IbTxYr_+jld}P67MityRs#yu+^6XSOvmmJkyIuZOkHl;%Cc zeJ5D6a(X&q35O$Y^4KjW>zJ=dB7HBJQw6F|@fhGi2t)#54mL&qD2G0G;6uJ8nC$2mS{ zsOYT4kavipRINu>cQ_&-Hm(r;cFwmw8)yr_Wo}Se$|p7!NG;sA!!ljq1ns6rjB zjEzsO=43ZY~q5;TWni^w~7P@7(JA;r80e}CvK^rXuc+j5MM0E$;8k_j*1Br4E@mio)P{8NS)Ctz(lNDK=4;-e zL*F7j%AF`bA{X#ntjFt6Vb0aYzG5wArFb!@ zX=7i`Mz>Gs+bfJ`JGE`l!t3iMYqpiga^cshwQLz-Qm_yFCqa4FM`s@fb+Kw3(IHBW zjJhta?zt9LjT~cpZ0IQ0LF>ZFzvL$eW9^)gZcDXuT!vJ!H-s7IBCQ{Z`3%=CDYUXg z?m4sU#ghV8E@1_L)UJYY#aY*WM&#Pu$TX{vk~-}^o1caO&O`PT8M#d``=OiMa;^RB zQsQO_YXgS&nn5T^p*LXCYqKrmSjt@>7u5f)nQld1BlC#OBUek!&`)m} z+p!_lNp^_L!5Q+1y$8$t;!aK-OT_o`5AvMF276BBan4ms2o#p8kw^5W9+tNsrX?j* zG)%?pkd}nPqKYKS<4~m1?O39`@YbFfhdGS0Y_H92M2h3Bnz82=JFG$(kx@Daa}GJ; z%;>jbL!2|mQ7wFEy5!s0T<$t7<|4R~?Y3~O;AfDCRHQtySC1?UENgs3CfDBh3Q^lT zbrg_3Edx&N=LdQG>c;wptDG9+CkOYz9|};$IaN9;a7NJ6Qpt+~F1)&Jp;0GeWv2R^ zm152IEY`DC;HVlgFk!8dGjUqG|wC;#II>$>E$Vl z4#`St_V)^7grtfJ6%i-`F;e>s|HEVoRgU3@&^Q+r>r}}q33;Pl$bDG=n$ke$l~K-T zK~S47nHqac1AK>}2PfLX@8>)kbXB!u5hlS*=Te37@k42DZR-xk(9|ZL8~MU$sQa@G zfFrspDl{9syDHBs9~*GGU;9!ce?eKgP2Dj}qM5XSkSze6WJ2%vIuUd~Uet1^t|r!z zz$=R*mwK5=*JdBRSE`0hUOwM&N=3~u#CdGWeXEt@Vh!kAT>_L!Z80+0=O#6fLC=XU zfTh~vtdHL0#D4IS(isnN3d)FnWF|sEA4)z+nWcO&S#$wrMc+h$GFUnXhB0xi=9`YT zsZBihl^jq#1M{VSLAeGRuU2ZQ~O3vmbYAuBXW&N(C^sG!fe17)x} z>Ei~+JC+7LzOWmJS6!&W9ICg7RIgFoN9FZmN8unV1*?|cd{Sm^_AZCUg$9~FF97Bi zxByQ<_3BTe+ryBMmh$yz4KNJu=HSb~@Eb&)B7@4o8~R`_O?1e&YU2`H0 z2Xi&n*FvSJr1_);8uGp8RbrwcqMH_fJwp%{{g<}=x)A6Qc%SBPKCBi@X*6oQWxHus>d4|; zSbd|)e4@*AT497t9S;CUn%h8bAL@mdOmxl`&U!vw{H=}TmlK4iaXW|_bU1jE*mN>d zs!MRciX1D9)2dE=9I28Ra3^p%z$tiT1{!U?{k#Y`;@Ng|vU^ST+C+Mc_!#uv)jPXE zhyjK@p_@gEj$VFwC(baYcPegYbC`~)HvRJXc6rGp+eH5KD573)Gog;l2tAIRZeX(g z(J?J#Nl0eR9=2iu&m4S9oYXHPml5Uw5~x1oU3s)ZeW~Nt+dJfE{yDv`l^?{pQh_;cQeMS&3W%0A^Y_e zq#|5-kt{%9dvnVR(~cRKKt@{(`WU^E?ELt!w(gj!C^gZ|@}rT3dmhJ^YOldK$Tugc zB9~eMy{iJOql=UtPf%)NgcLlBBK+~O$k$OMddipV+FA)m%i{q~cHF6JeV8IW$h=;w z3b*~$yN(lJ2oeN!kvSB;YI9Xnp^NvXY;y;M|8fg@pf>I264`u>;762~}AJ%~$UZLz{(zXQ4{;kLj}Yh(Ka>Ca<@NU?GdQ>gxvWe&9Wb5cW~tx+Rs6emfB*h1W#WCESX8LGMgEfg@`3B+ zABbFnB3v{4c z|BZjJIeG5hYp?QKYnP|3bI5je_gsDV@;|<~Y3IJyY&P?L`NxSsp&%?Ad-C~_gK9rA z@6b!noLzSLZO=UX%APT!$BjIsEX#;xOEQIgFVG@pGkGIYaW!z1lmvaQH7y7m#igLr zLfrXXkGhQ^YEv^Y9YrDqSP1SEVMVVXJOSFfvcONq0+m{U9sKwwmI`D}A*>&;JY>ZUg8lfRfaWm-*j zMMY`0q{KszQmx4I59bq02miHx=L$#XNzo^tZC)$gL^0u`t0aDRB?vzNtt=* zJPFr(TM@4*@d&yGQ_#yVH)@Dd=W&27y)HB*FqmZo4avr04ho?r}H-V6|9 zu*{`iT`Vb3B4|$173Mge13m4znLr`Tv80WL_$IdcOj1O|oGTiNMnjjW{kuw{X|KTV z!|3Kb){&=|rzv2OEr|Dosp;0EIBYi8WP+}=2S9iX=q~x6gZDmOI z|>n^N`lp-nN}UTP;GL>E;Km59bu#RB<;f!G`L0j;HU28J=L14 zK~;nl%_XA2x;2A|*!7;32;gt`Chin{=_44MzCcq5HK@H$H^EdCNtw>t{3d4ElJ4#t zlc%8ZE0kra+8}lHuoiPfJj%^Gc?L@>Ok1yY4n4J4}d)EQM7siZun#V`QNI%AOG57N>>8f>y~<+^9h!5cyoUlap8kyT%!o zg~iL1xGHq!HPUGA6=hSdAViB;(IhrK(ufl3T&@*IRC;s*NlA%QI19OMna<~JN|h)K zZc#PIX_^Z@qV6Wx!jf=VSEVR~2|*><5;Y6tOt)qb+au$dVSO-h3^MI7O?16*-u&^4 zjv6^)K=sQT_FehgmD~5XFPb@G(a|G+^3a;~JDM=F=;%?4W;Xuh_iNVgY?&~;_WBEF z*H)E7e`?k4|6cZ{^U%ENoSEOe{bj-OVz9q`#t~Qi_6@8onmKCGQBv~e&XzAPnly1l zow&?RMK6>2(oHME*b8j7uBzXc9YZ30f;S_{W!bY~R;P{pxd$`o;?C#n$aP~*Z{tb8P?f=Z^=|inZHkjvLsq zZ+oG;b9nzM>J{DZ=DXVA8QxGa^U#46UHfSgM@DP=JIyQBY&&7<(CaRk)vrwZ9&9H} z9rncqqoZaj7cH8^Aa(BF&a4`N&Y+}&(W0);IQv+=6JAYOL*3{fGV@&HmLAXWAUU=}2M(#~?rCp^&gA&%=VsJaFa<1V;|7i&T+#LJ zF7YSKQBZL+TjmQf*Fg087_dOmmT0rau0S-r0>{G2mZm7W7BA$x7=Fxfyyo^No_KA` zs38Nl?A%>5XpBuj)@MgPm&=xx`^4#?+0CAyIs4#WR^9l}OJD!^ai3gp_?UhjE8k%@ zYd`tqho-IHy8n@t2bkI?OdEFgapNF%w;iac8|>Cm($n4Z#a}$b%$PZT@J*L3`L73_ zzu|%BT->$@Br=O4|C13lf`EoenM$UnWY zj|UDXOm95v*s%}=vUZ?*dj8eFeR1t}TmV&hO?^puB@B~B5BlkOGr#o9=UY1z0igDD zwcWII-7g+k-r2JE)tfI~v1TiR+R_U7ssST)&d+jQ+CVu~dlYaBWy1Sp(V{JdjhiEd4$c^? z-ArcIl_PXtlw&yFqbJk3!XzOQXn@*si zjb>%T(CUVvVkqRxs~gJu^|z`S%4UzBI)dhZ-S26e{a0j-NUV`h!os zvHhK<>H#CW%PQ`9W(xy$;t``Ce(~9|s#5ctYoqKd`wRUf&v+RbG zM+8~^oimSAuTWU8f&BU>Phgf1oNFI^ef{smnh( z_rgVoFP=N@+#fA%>ENvEg9>{t-_w;eZG*M>GIDS|^M_b4@uwa(a^r!pO%unun#zCw zjZX~zRs)wyA`z=85cbYaP2l+Qza>Wv-$^tE3<_~(_4gKAHnK0wT-v97AzHPluy2{KL1ttKvG4?OwW z`B&cc)t^3uZ~yY)qkHV!27TFzb=TbSIK+t~2mHq!Pi)(B0HP@gb46!b^V7m7RdTXm zXI4XNk?mQxbw6D!9q?*(+SY;K`fWy^GRownYQ~`h;9Rq57i`EfhY0KCH~s&x&BQ3priO*ff-hZ2sdX zPQppn+3pq#UoO|vcHpU3w_JG2^v^FjrsKXB>+9+k&l%g?*12ZGPIf1q+cTMwLmK8z zKWzTosnnZW+qzr!ji1!0dQ1C5&%QNf-0PhG?qBxe9e0+ zw~uK78~k_tVTERHzGvdd{wr2*S-WNL_iumZ{FA4B`}zk?I!5QPS(8V-wrxENj(Sr| zn}g(pdjDfDO&-_iAXn{C_+U8ggz58UOwN{;5f(n~vM-n`?|vDcj~+KgO-7ehi-4UP zp}-jG%CGUE%Zz;4GoY<_blt z#0CRi3Tv@~8>JTiQC8Enha6?_~_z`s*H*DC`o`q9mP{@xMR6DG;# zL6wW_ZY@Y8RUB<~scscU46fV0=iL`pZQj1;K-IuTCQZNc!f}%ZLvLyAV8`3Ox0!1e zU2zl&vnDp~*|BNew*8g$c12@WxG3MS;cb8o95m#xVf_Fpi(KXqtdf%918M;I`kFU$ z75y8B3M3~Hz}_8mL3{T5t4dHf;L>(9Y_F-g!QHC6mR+U9|+4NgMbwXg{=n>6>6 z!u?AhJPc*R^$-Evu^G-oq^-o6mJJ zsQ7}Pu8?IR?~Eumo8}RuV1NO7DX$ONS5?O_NMJ50F9(xCmg_=asa@jR`rw+W3nkiI zfSt+qbaf~W7A47YSKyZ(2E&;glIm9I*|B4nt`hNB+}uUsKhA4_lOeVdg4M@Q$OuD4 zbs=A=7{SH1U_3NS%M_-d-rS&0XIVwRz)S;*9F!F~e8 zJXR_I15Wty)S@YnrR?@nM6FQD*~JC{PT`VK4X0v*YXVAOnV11KL#}IjvkO8-E9X1B zb-;{K#N0&#X}+Qjk}f*vH(x5J{x*d*=%{w`IQ%4kVG`W;T)G%ujc2yI_#L)zb z%+AG?Si)}R0KkWfGMqIL>y?z^5ugSbi6nm=uwe==*ieZaEuzyP=u{UXVGc>NJk@YG z76G6pqg-_8Ne5Aqd2~VN^27L`SR6Sj=xVxraugKlwMYqy+pv&RcYZUbx?^=$FziwY z!C(r7FWhN)J6qy0imIrD8Ey=wLA5k2kU zd0Fbca1w4DRaQQYwesX=9<6PTna2jz$(kwZS{7FnSY zC*#dA@yifu2!kV1MJvpE)eV&nk_ylv+DNl#5(mwaTMTwhHrJgS+`lG!?Ojj($DL0$ z)b*<<*O@%T%e1%(n=rvvA1yHRUt&7KDORF311SfRg8v#Snjr*M1AA~=T7AGoq0{GG z8bG?9s5L<1E~1J)Q&G&4u09hv&E_77-y^O)#xU3b7QrM9{Na}Ln$9i7|}{@}uenm9K;@a*l6y!6VtZ7%ly@gFS$r6naZCN_R<@tku{ zouvW$N5l6%p1%=+vaVducmDf{-#)c^%Pt<}y+3$=BUb+-UD_tu6331h_=yiqyZqC~ zWiPp5*)2;~)mK+?r^v=HP#o>7sCq26p{qr&-(tt5X?Jh$Ap&#MLnYQ-No=|}#6D`F zq>F3Ny-1SA#E=Z3CAeqbZf?a0#2wI8UhtL5ngS34Rm8Q^H1(@d8%J~xx@r4BLeWS`y$ zJ<58;>CR03uW5)TfB$?pZ)&-F*Ok6RxM-(B zUTH)YEk!g?_;|cxMY5Jin&x*9PKlh}bY>VZeQi$p;xZr3Yt(u@>WLX%RaJ4;pk zh!s94=jbIi-5f`X*QrD{C(?{oVg;fyZp}*M_X>KTAKVpXWh}wwO1vwI^x?G8Vuh86 zIrGkbOC;rf!e1e}RE9?^Qi_v=K6UdHT=ol1gDXBBnI)4YR-7(=x}pXbgvx`sM8r8^ zGn<+4jL=GsRO3!^dfs8Di=s$dW zCt&n?nxYOk%|xIZ7`dEi@JcT!H(^?#OFVI^C{@&KE6n1e+k8tTwQ;fuj(~PVIV!9= z+QY_35vv=(MlAMq2X6)UQkVoHHeCvxxa354%#Wx@IK#|^&WGYr^Ind8NSt@Qfy5=Kc4K&|;75ar6v5B|#Wf=d>|Re# zq!qH8mS)fC2%)6u)?6mR7o0~M>JkQIL(|z3=1BLw^gZ|qgzM>T1wqH{y*fr$jXz8s zw;Rp55<`VZjFz9Yupae9@n|T7>Af70CUmB(NGg_S&SrB2On>m#IH9MXRiaItrt@Gh zuEg<&dIT1<+0z!!t@jtW(4Cbd7mPlmIl5IRlEHb}QA>`SFmiC+@-;iYann=V-f3QP z+{BL^JK@SZpIg0oFB+B{Ga)p$?4L4vz^#`puCJ*;_oFXuy8d@Buio^I>}Rt-`_h6h zUcXEsPC0qi`6qnyrl*QZe)By1-}=P7DPsmnDpfxH!{4V`nfiW}=PsD$z<~7p+MQSZ z`q`#7W#fEi;dJnzf##zxZM^Ev=bVle%tf}S4F~UkdOb>@{OrpoeewE7fvetR0$p{% ziQl~G&xFMtkAg_u_w;()dEk2=JNJjbmlcAR$=r77A|gY4`tZA8jGN-%@%N4x`DlP{ zPbB4yN$-!|L<9CgahJE>;k7B5wdt>9A$s@X3_T+my8wb@;uP(Ik_K+8P z#b$R~U3D3wwRQKq&%M53!BL0Y`t?(4D^X28Nsi`aOQr|q0$cdzC+6Z3I*Us3&G}r% zP$ zljD|uTUb}6*PDFcnKZJlyLGQeCM`le#!dR+k6>ctonj-xtg%xZb0UkfTH-1p|<;~rCbxBh6hv$%D_Q3O7*nAcoJ?^s$mG?pNY+1FE1}MA^#)nT|^Ek|n^oZZB*e(N^%+#^Nt~__{w{CuhWi)bd&D9rt5Mob9 zi!y&LJL9~?v)63g^}zF+*>V;fHTJU$r;DMz#X!otv%mQ(rlT(ovLZ5;&@gq}aOTjt zS3lI$ZaH^cGIV!dci#)w-mxs#eqhr>S0Zxuw{EfxCR1KNShnmoIJia(wc32ovr_}R zDEoYYSEd9Q&skAQq_PaMkX+`;R(k9&2E9SfKfj9LX8!XlOTK!}DQ$)7a#A4>^wD)T zwfx*8DG6pW^9~>T)lbYnWB$xXmal#GmGwP7mULt?-}&tPi6g3+s#jn5AtP{*hM#C5>LwHh%Fl##V>tqIE)@Vl{vfUKp8;_uN!P?o5ti|*+B$6}7y^S8#0;bD{h8522XHe%EJh8kn?CW7^}9o|>DFEQ>uam7 z`Ckh`j1!C7Bho$qQ@BB_;?Z*Twi^A;|gw{^-PLsq@LW9p#Lb>q)JZ!`T3L6Abqm? zcpJYI^~;b>(&=d$=v?*I_A^hKb^EtIW=71H6l?;HxNT>4%`7H+5YKtamzu5^ZBUq4 zUMw11#jS(Es%88{fO}A&67P4*mX(|98u- zeGp~Qvs}FH%g7*wUMQ4+P>XEU#yxb+ojy)6@M4&GkOO_*;fHEQ_T+#!dy;1N%D1*L zk)bfsjL_G9bQeUH-M!0R{^K*RQ+MTcmE6E({@4rT?*d4(4kHX_UHbFUr+kgi(=V-x zX|>FffBVV3_dfP=eLtHPLS=#FukAXrqG~En6t9gW>jsz#n5mmv@|ubgNwqmp>=K2g z5Sk(-bgB}|d~We9(#_Zyw;%AWIoI9Zyma}xi%y^S)lV&Gz2)(ShT79ln8s;i<(pe8 z>WBKS!n!$T#-x*voq-xMf^%&LCQlzr{Xlcuy^p^(ZNeB%cz6BbnW^JPf8dD2K5+QB z7dN$eEHsfpAD+A@I_8q1uez6P_U7NO_}r;8FF9vnOJ{z~)&pEI&Ye2?2e&@)$ntd{ zLFacqyI|QXTc?g4`q@*DLg=RZp2S()WJx{y+S{D`F8%o*zI^)JuU>Q8sV5u_!@MI7 zd*Q7WlMhi2b`v0WL%b3^p{#GFW!2pNzR)i!(-PrKVX2lbJhZ zBs0-z#NzHhJ(tZ?GD#nKe(l1!lkWWfIo|cX8y-LlG8$%c39qOia?|}!NWalJvI|^s z%M-cwrjm;4mUbHkz>=yKFfcY`A#ia4uboj4q{7h|K$S0S-M#P9>mTAwbNTtFH~^0S z=az@t3KgIF-*?{e-H)Gt+Og-KrXB!X@}GBZ-La>;Lrh>zou?y19*I zqUH;Hbt>Gh=E*j>;?^g*SSTs4ZsxlLlIqcStIP{`4cfJLKKAU(YfCFEHye1wx+nLI z8)=v!>%JmSE-grI;_8zt;NWg)Jf3> z>$T)4vH3?dPB~=g)?Iu5_{?ift(_J1L+pt_X7*tN=T03%ME>;5>sxm2Ev>FAt?b8! zu;hfPwPg%jcGcTkpLz977|Lr0a=|ufRR2vIHf}%ASz1-+r_WJC8bzN<;GH==;dv|VKwP|;_qT%$`uWHJe!5iOxYe!SA|G+_$ zM-SYzVS`!J*DNr{4QS(l%GXvo$RX5~BWwV+?%WF}SC6dk-fFXxM)Z4Q{bn5ZNFHqW z;AkhVC9&7v5@w4MNr%>xBj>}TCym-PRcuuGBT5`OD%pHDiKHYkmg>7u+}{ORCQug% zlnB_jMG!ZgEDcRYq}<}Doglp$$?^{uNfJ(*TY6U#_xd%B1cfG7e* zXO~zKaac&y>(s>0mS)RHBy~1sYmaU-SW>W({AzTU;;Xj?jB~2~`U!(m3r59;!T=Ig z9t16R7)Zhtrf@RzSSdT*u1&Z^>oT>v8VZHwW!F~LgaNw{v>cOw3te0`UZJaoW&i*Y z&`Cr=R1c6`rjY5(^B7w=U}JyK!sFCty^1w5)Roe0q30frm_cEj3YG^+lNg(T5>9vv zkS%5A>QNj2f)~2qe zfMopq3E&Mi0_BR4c#Q59j{ZG6h!zNKhQVb$suu*Aummk>#u1_AyC68F>E(6v6p}nO z{W|whcZ))co&tL&uIUR@W+DjDOFnSmgu`AA;JCb!cUBxmuez=Z6U}rmkKiW%R3jTM zC!L?8JV3SK5NHd83~TpSyr3Wjr-nAHOIjM>g8kfv5kXxHi+D^tRHQ~l>%?@LHM3TMiUUB-NFe4FIxcAZYL* zLD(vO)U~3V7Y_Uqzwp@*LJ6h=2!+F-2)p8F=o8eU&>yTsMzM*W$fA>$*dnvrbsqIn zEZq8Qt>lm()JTQd?O~NRO@f478;l__wn#Q?=7ss2R&QNFJkf$#flRw8QkbR!6%{6Q zOeK@Xw2Q%3wvC8#BOS1y3RamCNpoGTN+L%R%>2_Z2!r9Uc==2bJt3Tltq96Gkx6WMtD`y?2VShi7 zlu`IcF7GFj{v(gh-@#^yq&GkF+o#uW+0*=Yc;D~-pNqiQVfCN*;N;6cH7|R~FP^yV z@i+U|^((6=*VB|(bnRe!v7IG3S%zk0@JgS=E<3Gi+jXhP!?XNan3Qldz-<(0q2 zmKKRT=?da}+;mK2a|Y;rj6#Qp68T|poav)ON(TxN*XCWWHWJg7bUgxqm@XbqD6S`g z&2L=3+uZWy4^PjI{KO44b@l9$vKslk9u-9pPU*uLd;bQVF4!Vx)O>KoIiVk1NzfOC zoF{U=r;$9BPCXxpJp^cof5628N4eo(cP1; zD0G(XInZ`!18;bBMJp{1mkPy?QOujjrhw&%hCl8MqPv5E(O!@QxX$AC=0(x8kG8&C9hdSEOe6u zP#`8jCoM}cO%DSU6#I4>=}18(QqZYbT_M0F(_mmsx!sAWOD}Q*rFe6eR&Fw|cu8Xr z1(1fp>1iv1!1Xjd%naj^A&MP2z#LkMhB!{@u)<}$0*#P`!u3Zht`EjgNesEHPXaN! zD*j-|LL_Bo6k5>cp-Tc7Lg7IRiKIRlaG0cf6``Q8ST~;FJQmzOe_fD@%o^Q$p?gvy zTI|Jy0WR{ptthTu#3K>{W6RMCBaAp((u4SYzWgHt3O1j8M4bCA3jCEV-l38Fpx z4Xeiuz+~emV)O@jM}R`t<*H%EhxprKG!rGoF*ZGdl60Y&UN1p5>5`OLm!_mHiyr92 zVIf3>gRQEfEl8$04N1L@(A)|7-6OZv%{sug1pKP?zcE!CneQ)0uZ0SnLJECR`Rcr4r>M15;EV`jm_Wz~cj22wVy zL|IhX?Y&Uh34m_dPUDUzh7>(!TT*e6DDF*By`;|^iCx9f!5D=mv2cpI(rk$fMT?Hj zQMq^`>!BdDQk5ui6hYj;K*2``?9O5|p34L5_{VTY>qWH*a@pbuhmPS#nl+eFod(u? zkdqEQsy--@bZ_gDW5+9V)RI2o^K?nik0kr7S0d?yFDcoS;)$f!EiLL*5DUuD{MD0v zl>GlDlAbh;j6q&7ZhNQY`L#QgFxsk=n_h{eFK-I;#GDdIlQ-Q0lg)nVw3+w+C7npR zOmvUFYMElT>#<6iHJT1eB>l@eDj|^+wHC(PE?cZb(%&ox-p7s|ANjpfOeFP}B?O=1 z@u#9;X5RRS=y9ahub$qf(-yrB-SZkH!H4lJ%$Yp=uO^aO(kH5liKMxXzKNulo?2UB z<~&F9j3e#AvECJ6ONpf9Xtuu7N6F+dgZd<2(hP~DdhV=`5=l=Z!_^Z>o0UkqYb#EL zMAE?|l5SEW>9G??@szXXT1X`A>Er>qd@S_LpD_wON+cE05=oWqs!SL+RLpiQcG_EZlQY}zM)i;6UG94NN zHc>wrsYKEj){P!EaP#)vdJV6o%8zC$b5!qJQ%#>K_dNRIPwsl+@(VtE-bdz+A6)wK z=1xr+5=ldj<`(vrVj^i$0 zQnyqrjeov}#2_Flk@Qmw+cW*j z>&Po&ncDuTImqh^{mLRd_%CfX73Lj24*oOd&mdRl*;m#nlOS30mZMq4PcOzqQq6Rv zq7qBNE34^WOeC%BSJ8hsKh4D+?x;MG^v5KUwsnz3TGnsSuC_9cBw7O`l}K8B>(Z4_ zERnQXsaIx2iKMeeQ2+VGrxp`Q1>UX$V9b)EVVPqg;V3R~rUfXCj z@UhKZpkhT0#$9jjm#<1El1@AATfc6y-}p2ZVao9CDIf-tE{`ZmB+XbN>5%&A6UMCH z6H>T~IhythRh~$yAlldmozfOoQlK#1%mkZ&D20M2lJYYaWmWvBl~NM`PbnsnmXo-E zk{8Jr}N!fw&{Yl)=R%UKs~(++JEj7+Ac(5|0Y zR@OyEiKK6DKXbvX+rPcUI?>0XaYsZDbd5LfQ<51kin1%EUW->6TlUm9t;Gk?*=B3QQ zKqBdwQ@^f6(ih+8(U$>)Q;DS4-bZF?Oe9rsY`1U*6PIhAOA0Z3Osy>`-{E}E3#sxb zu|!fWa7I;8VqzkK$yiu8)S(le&n-Hd@pyjKR`R*TKuS?Z>(Uq2Uv$O?zVfLBEw?<@ z&`{@zq;I^rg$>iQDn}0;c+AYnA(6DHE!Vn#^3*X%vnG^CI(`gadbsNky>m4El1XD@ z*tAdj^pj0qGs`+iL7dOr{BW;C(uUfqIa5ac;FibPfty-SvP9DP%U;z=Gt`?}+wXb&wW$H*GgA+Yq^WIy@j!`aj_p! zW5@DDQj#^v93bxS-uiHRp)yG%J+7EY z`lCCyZr`m$(nKL9iixB-OQK?ySZbb}u?(dvZhMl1WzxTz`JWd!6$YC(?iw^DlD@h= z`~ac7l_qL2kyOmZ$9{$$3d_;gNfLkQ7DfMT5OlW_f}tQ-BI(eEm_BFH5<0kquK7od zWMY!6$zH(#q!LL7kw9t5ny-??Sz6s-iKLZDA}ObeZ84Fwp}ww9jwbd-4e1|~N5_m9 z5|c_Td9T3U5)(=FRUd)3b%ukMEmc5Pd^aaWQ^nr*19whUJ#j}90#l<%Hw3W=oYY}X3Ua6P1P*zkrj zr2t#OuII&ip6Ke$@1WMBP9o{bH@B4a(>GZtNh0Z4uf9 zJW)5H9l%bOB=vC#<$Jo-ZPp8jenl64q@+2NFq7mYGFlm=pO*1+ph^z(LB*C5Nww|A zL{gVdC6YRU8SPdqB{W@EzdT9-3)!wQdX`8^PGbqb%*s(ebea_1^Tc2OB!(f=loVcy zTu2Q}B14DGMR6#ZCm#|?b#WYqhoz|OGghJ987Qt|ww;H%_h!q=_@ITen(KDGmPlF? zys`(K9!txME-*6gnB4$M&J#&#x>~=e^c+p1rcv?hu*je*VG=ZbZP{#)nlNA@GgSQK zthqpw(}tY}v=I4K+Za~Aevv4`WTpxjX+oAEWr4FmqfNO(mM6+zc4o6kDEQAu0&^fl zKBKfzS17Xxia{D=!tg)|O_@`!DqRAswE>%s9>$=@{a*+4}upqHSHlSw55V?Kg4_WCkSFIMC{6%|w-P}eO~VfBYV zq>$LgZ^#XRf@!@v+HBJ?@*5=e7}25;xHZ5I+xZih6_At$&1`WhbX0sci@^~_W;02P zQBk#btZ2HpY+F~+L6M3D>+;AROxV7Wz(P*u;pAU}hMH%Ks)7Z044D><3m!Z>B&%Jn zI8IV3d=yPsAq}g?mH0WyO}8Kg;+)RPJfEDrNm%;GVTQ1QCJ2A!@jErNcD*a!V|Igh~b zLDuyr@B%SPrL5EC*0~9lD%WY&?QCQ?jh+S&EW#W`+_a0Q=rWyr(wKvC5GEiMkQgF! z!B&mI^Dgh@n0Tky8f-b9AaN-fWq>-m-%lj<+4~QFOed25KiufP*6u2#0{{R307*qo IM6N<$f~JTP@&Et; diff --git a/modules/custom/wh_feedback/wh_feedback.css b/modules/custom/wh_feedback/wh_feedback.css deleted file mode 100644 index 1ce892471..000000000 --- a/modules/custom/wh_feedback/wh_feedback.css +++ /dev/null @@ -1,97 +0,0 @@ -#wh-feedback-modal { - width: 426px; - background: transparent url(http://www.whitehouse.gov/sites/default/themes/whitehouse/img/contact/bg-modal-mid.png) repeat-y scroll 0px 0px; -} - -#wh-feedback-modal p { margin: 0 0 15px !important; } - -#wh-feedback-modal #edit-submit { display: none; } - -#wh-feedback-modal #content { width: 365px !important; margin: -5px 20px 0px 15px; text-align: left !important; background: none !important; } - -#wh-feedback-modal h1 { margin-top: -15px !important; font-size: 14px; font-weight: bold; } - -#wh-feedback-form-display { display: none; } - -#wh-feedback-container .webform-description { border-bottom: 0px !important; margin: 0px !important; } - -#wh-feedback-top { - background: transparent url(http://www.whitehouse.gov/sites/default/themes/whitehouse/img/contact/bg-modal-top.png) no-repeat scroll 0px 0px; - height: 26px; -} -#wh-feedback-container { - display: none; - width: 430px !important; - position: relative; - z-index: 1000; - margin-left: -100px; -} -#wh-feedback-bottom { - background: transparent url(http://www.whitehouse.gov/sites/default/themes/whitehouse/img/contact/bg-modal-bottom.png) no-repeat scroll 0px 0px; - height: 26px; -} - -#wh-feedback-container .textarea-identifier { display: none; } - -#wh-feedback-success { - background: transparent url(http://www.whitehouse.gov/sites/default/modules/wh_feedback/images/eagle.jpg) no-repeat scroll center 120px; - height: 240px; - margin: 0 10px; - padding: 20px 70px; -} -#wh-feedback-success { - color: #369; - font-family: Georgia,"Times New Roman",Times,serif; - font-size: 20px; - line-height: 1.5; - margin: 0px 0 0; - text-align: center; -} - -#wh-feedback-form em { display: none; } -#wh-feedback-submit { - margin: 0px 0px 0px 35px; - float: left; - background: url('http://www.whitehouse.gov/sites/default/modules/wh_feedback/images/feedback_btn_sprite.png') no-repeat 0 0; width: 148px; height: 24px; -} - -#wh-feedback-webform #edit-captcha-response-wrapper label { float: left; } - -#wh-feedback-webform { margin: -10px; width: 380px; } - -.wh-feedback-label { padding: 5px 0px; font-weight: 800; } - -.wh-feedback-2col { width: 45%; float: left; } - -#wh-feedback-webform #edit-submitted-first-name, #wh-feedback-webform #edit-submitted-last-name { width: 145px; } - -#wh-feedback-webform #edit-submitted-comments { width: 325px; } - -.wh-feedback-row { clear: both; margin: 7px; } - -#edit-captcha-response-wrapper .description { display: none; } - -#edit-captcha-response-wrapper label { margin: 0px 10px 10px -35px; } - -#edit-captcha-response-wrapper span { background: none; margin-bottom: -5px; } - -#wh-feedback-webform .captcha .description { display: none; margin: 0px; } - -#wh-feedback-webform .captcha { margin: -25px 0px 20px; } - -#wh-feedback-modal #wh-feedback-close { - background: transparent url(http://www.whitehouse.gov/sites/default/themes/whitehouse/img/icons/icon-close.gif) no-repeat scroll 100% 0px; - color: #999; - float: right; - font-size: 11px; - margin: 0px 20px 4px; - padding: 3px 20px 2px 0px; - text-decoration: none; - line-height: 13px; -} - -span[class^=wh-feedback-error-] { color: red; padding: 5px 0px; } - -#wh-feedback-node-form input.form-submit { float: left !important; } - -textarea #wh-feedback-comments, #wh-feedback-webform #wh-feedback-comments { display: none; visibility: hidden; } diff --git a/modules/custom/wh_feedback/wh_feedback.info b/modules/custom/wh_feedback/wh_feedback.info deleted file mode 100644 index 753a5d7c4..000000000 --- a/modules/custom/wh_feedback/wh_feedback.info +++ /dev/null @@ -1,7 +0,0 @@ -name = "White House Feedback" -description = "Creates widget for getting feedback on every page" -core = 7.x -package = "Custom Developed" - -stylesheets[all][] = wh_feedback.css -scripts[] = wh_feedback.js diff --git a/modules/custom/wh_feedback/wh_feedback.js b/modules/custom/wh_feedback/wh_feedback.js deleted file mode 100644 index b9a39eaf4..000000000 --- a/modules/custom/wh_feedback/wh_feedback.js +++ /dev/null @@ -1,107 +0,0 @@ -(function($) { - -Drupal.behaviors.wh_feedback = { -attach: function (context,settings) { - - if ($.browser.msie) { use_recaptcha = 0; } - - function wh_feedback_valid_email(email) { return /^.+@.+\..+$/.test(email); } - - function wh_feedback_success() { - $('#wh-feedback-submit').remove(); - $('#wh-feedback-modal').html('
Thank you for your feedback!
'); - $('html, body').animate({ - scrollTop: $(".wh-feedback-link").offset().top - }, 1000); - setTimeout(function() { $('#wh-feedback-container').slideToggle('fast'); }, 6000); - } - - function wh_feedback_validate() { - - var error_flag = 1; - $("span[class^=wh-feedback-error-]").remove(); - - if (!$("#wh-feedback-webform textarea[id=edit-submitted-comments]").val()) { - $("#wh-feedback-webform textarea[id=edit-submitted-comments]") - .before("Please provide comments before submitting") - .css('border','2px solid red'); - error_flag = 0; - } - - if ($("#wh-feedback-webform input[id=edit-submitted-email-address]").val()) { - var email = $("#wh-feedback-webform input[id=edit-submitted-email-address]").val(); - if (!wh_feedback_valid_email(email)) { - $("#wh-feedback-webform input[id=edit-submitted-email-address]") - .before("Please provide a valid email address") - .css('border','2px solid red'); - error_flag = 0; - } - } - return error_flag; - - } - $("#wh-feedback-node-form #edit-submit").click(function() { - if (!(wh_feedback_validate())) { - return false; - } - }); - - $(".wh-feedback-link", context) - .after('
') - - .click(function () { - - var wh_feedback_submitted = false; - - $("#wh-feedback-modal").load("https://wwws.whitehouse.gov/splash/feedback-petitions/modal?key="+new Date().getTime(), function() { - - $("#wh-feedback-modal").prepend('Close'); - $("#wh-feedback-modal").append('


'); - $("#wh-feedback-comments").css("display","none"); - - $("#wh-feedback-webform input[id=edit-submitted-email-address]").focus(function() { $(this).css("border","1px solid gainsboro"); $(".wh-feedback-error-email").remove(); }); - $("#wh-feedback-webform textarea[id=edit-submitted-comments]").focus(function() { $(this).css("border","1px solid gainsboro"); $(".wh-feedback-error-comments").remove(); }); - - $("#wh-feedback-container").slideToggle('fast'); - $('#wh-feedback-close').click(function () { $('#wh-feedback-container').slideToggle('fast'); return false; }); - - $("#wh-feedback-submit").click(function () { - $("input[id=edit-submitted-browser-string]").val(navigator.userAgent); - $("input[id=edit-submitted-origin-url]").val($(location).attr('pathname')); - - if (!wh_feedback_submitted) { - if ($("#wh-feedback-webform textarea[id=wh-feedback-comments]").val()) { wh_feedback_success(); wh_feedback_submitted = true; } else { - $.ajax({ - type: "POST", - url: https://wwws.whitehouse.gov/feedback-petitions, - data: $('#wh-feedback-modal form[id^=webform-client-form-]').serialize(), - beforeSend: function() { - if (wh_feedback_validate()) { - $('#wh-feedback-submit').remove(); - $('#wh-feedback-modal').html('
Thank you for your feedback!
'); - $('html, body').animate({ - scrollTop: $(".wh-feedback-link").offset().top - }, 1000); - setTimeout(function() { $('#wh-feedback-container').slideToggle('fast'); }, 6000); - wh_feedback_submitted = true; - } else { - return false; - } - }, - success: function() { - } - }); - } - } - - return false; - }); - }); - - return false; - }); - -} -}; - -})(jQuery); diff --git a/modules/custom/wh_feedback/wh_feedback.module b/modules/custom/wh_feedback/wh_feedback.module deleted file mode 100644 index f610c7b57..000000000 --- a/modules/custom/wh_feedback/wh_feedback.module +++ /dev/null @@ -1,11 +0,0 @@ -debug = $debug; - - $this->lastHourRun = variable_get('wh_petition_reporting_hourly_last_run_hour', 1320105600); //November 1, 2011 at 00:00:00 - - $this->buildDataSet(); - } - - /** - * Generates header including date report data was aggregated - * - */ - public function getReportHeader() { - return '

' . t('Data as of %date', array('%date' => date('m-d-Y H:i:s', $this->lastHourRun))) . '

'; - } - - /** - * Build the page markup for display - */ - public function loadPage() { - $markup = ""; - $data_rows = array(); - - $dataCollection = mongodb_collection('hourly_report_data'); - $dataSet = $dataCollection->find()->sort(array('_id' => -1)); - - foreach($dataSet as $row) { - $this->addRowToHourlyTable($data_rows, $row); - } - - $markup .= '

' . t('Users, Petitions, and Signatures by Hour') . '

'; - $headers = array( - t('Date Range'), - t('Total Users'), - t('New Users'), - t('Total Petitions'), - t('New Petitions'), - t('Total Signatures'), - t('New Signatures'), - ); - $markup .= theme_table(array('header' => $headers, 'rows' => $data_rows, 'attributes' => array('id' => 'hourly-count-table'), 'caption' => '', 'colgroups' => array(), 'sticky' => TRUE, 'empty' => t('No data found'))); - $markup .= '
'; - - return $markup; - } - - private function addRowToHourlyTable(&$data_rows, $data) { - $dateTimeFormat = 'Y-m-d H:i'; - $dateFormat = 'Y-m-d'; - $timeFormat = 'H:i'; - $from = date($dateTimeFormat, $data['_id']['startTS']); - - //only display full date for TO if date has changed, i.e., if the row is showing from 2300 to 0000 - if (date($dateFormat, $data['_id']['startTS']) == date($dateFormat, $data['_id']['endTS'])) { - $to = date($timeFormat, $data['_id']['endTS']); - } - else { - $to = date($dateTimeFormat, $data['_id']['endTS']); - } - - $date_range_cell = array('data' => $from . ' to ' . $to, 'header' => TRUE); - - $newUsers = number_format($data['newUsers']); - $totalUsers = number_format($data['totalUsers']); - $newPetitions = number_format($data['newPetitions']); - $totalPetitions = number_format($data['totalPetitions']); - $newSignatures = number_format($data['newSignatures']); - $totalSignatures = number_format($data['totalSignatures']); - - $data_rows[] = array('data' => - array( - $date_range_cell, - $totalUsers, - $newUsers, - $totalPetitions, - $newPetitions, - $totalSignatures, - $newSignatures, - ), - ); - } - - /** - * Check for new data and aggregate them into the set - */ - private function buildDataSet() { - $currentTS = time(); - $currentHourTS = mktime(date('H', $currentTS), 0, 0, date('n', $currentTS), date('j', $currentTS), date('Y', $currentTS) ); - - $hourInterval = 3600; //number of seconds in an hour - $max = $currentHourTS; - $min = $currentHourTS - $hourInterval; - - //put all the processing into a batch - $operations = array(); - while ($min >= $this->lastHourRun) { - $operations[] = array('hourBatchProcessor', array($min, $max)); - $max = $min; - $min = $min - $hourInterval; - } - - $this->updateLastRun($currentHourTS); - - if (count($operations)) { - $batch = array( - 'operations' => $operations, - 'init_message' => t('Beginning processing of new data'), - 'title' => t('Aggregating new data'), - 'progress_message' => t('Completed aggregating @current of @total hours of new data'), - 'file' => drupal_get_path('module', 'wh_petition_reporting') . '/wh_petition_reporting.hourly.inc', - ); - batch_set($batch); - batch_process(); - } - } - - /** - * update the Drupal var and class attribte marking the last hour for which this ran - */ - private function updateLastRun($lastRunTS) { - variable_set('wh_petition_reporting_hourly_last_run_hour', $lastRunTS); - $this->lastHourRun = $lastRunTS; - } - - /** - * Wrapper to handle retireving data for an hour and writing it to the mongo table - */ - public function processHourRecord($hour_start_timestamp, $hour_end_timestamp) { - HourlyReportManager::writeHourRecord(HourlyReportManager::getHourRecord($hour_start_timestamp, $hour_end_timestamp)); - } - - /** - * Build petition data list - * - * @param $hour_start_timestamp int - * Unix timestamp for when the hour to get should start - * @param $hour_end_timestamp int - * Unix timestamp for when the hour to get should end - * @param $delta_only boolean - * Indicator of whether to get the total vlues or just the new records in that hour - * - * @return array - */ - public function getHourRecord($hour_start_timestamp, $hour_end_timestamp, $delta_only = FALSE) { - - //set up connections - $petitionsCollection = wh_petitions_mongo_petition_connection(); - $signaturesCollection = wh_petitions_mongo_petition_signatures_connection(); - - //petitions - $newPetitionCount = $petitionsCollection->count( - array('created' => - array( - '$lt' => (int) $hour_end_timestamp, - '$gte' => (int) $hour_start_timestamp, - ) - ) - ); - //signatures - $newSignatureCount = $signaturesCollection->count( - array('timestamp' => - array( - '$lt' => (int) $hour_end_timestamp, - '$gte' => (int) $hour_start_timestamp, - ) - ) - ); - //users - $newUserCountQuery = "select count(*) from {users} where created >= :start and created < :end"; - $newUserCount = db_query($newUserCountQuery, array(':start' => $hour_start_timestamp, ':end' => $hour_end_timestamp))->fetchField(); - - //push all the data into a new object which will populate our Mongo table - $newObject = array( - '_id' => array('startTS' => $hour_start_timestamp, 'endTS' => $hour_end_timestamp), - 'newUsers' => (int) $newUserCount, - 'newPetitions' => (int) $newPetitionCount, - 'newSignatures' => (int) $newSignatureCount, - ); - - if (!$delta_only) { - //if we're not asking for only the deltas, get the total counts too - $totalPetitionCount = $petitionsCollection->count( - array('created' => array('$lt' => (int) $hour_end_timestamp)) - ); - - $totalSignatureCount = $signaturesCollection->count( - array('timestamp' => array('$lt' => (int) $hour_end_timestamp)) - ); - - $totalUserCountQuery = "select count(*) from {users} where created < :end"; - $totalUserCount = db_query($totalUserCountQuery, array(':end' => $hour_end_timestamp))->fetchField(); - - $newObject['totalUsers'] = (int) $totalUserCount; - $newObject['totalPetitions'] = (int) $totalPetitionCount; - $newObject['totalSignatures'] = (int) $totalSignatureCount; - } - return $newObject; - } - - /** - * wte a record to the mongo table - */ - public function writeHourRecord($dataObject) { - $collection = mongodb_collection('hourly_report_data'); - $collection->save($dataObject); - } -} - -/** - * Build the hourly report page - */ -function hourly_page() { - drupal_add_css(drupal_get_path('module', 'wh_petition_reporting') . '/css/counts.css', array('type' => 'file')); - $reportManager = new HourlyReportManager(TRUE); - - $markup = "
"; - - //report header - $markup .= $reportManager->getReportHeader(); - - //report body - $markup .= $reportManager->loadPage(); - - $markup .= "
"; - return $markup; - -} - -/** - * callback function for the batch api - */ -function hourBatchProcessor($min, $max, &$context) { - HourlyReportManager::processHourRecord($min, $max); -} diff --git a/modules/custom/wh_petition_reporting/wh_petition_reporting.info b/modules/custom/wh_petition_reporting/wh_petition_reporting.info deleted file mode 100644 index 60bb72b94..000000000 --- a/modules/custom/wh_petition_reporting/wh_petition_reporting.info +++ /dev/null @@ -1,11 +0,0 @@ -name = "WH Petition Reporting" -description = "Reporting Capabilities for We The People" -package = "Custom" -core = "7.x" -version = "7.x-1.2" - -dependencies[] = "wh_response" -dependencies[] = "wh_petitions" - -files[] = 'wh_petition_reporting.summary.inc' -files[] = 'wh_petition_reporting.hourly.inc' diff --git a/modules/custom/wh_petition_reporting/wh_petition_reporting.install b/modules/custom/wh_petition_reporting/wh_petition_reporting.install deleted file mode 100644 index ceceb2843..000000000 --- a/modules/custom/wh_petition_reporting/wh_petition_reporting.install +++ /dev/null @@ -1,59 +0,0 @@ -find(array('created' => array('$exists' => FALSE)), array('_id' => 1)); - foreach ($petitions as $petition) { - $ts = $petition['_id']->getTimestamp(); - $mongoPetitionCollection->update(array('_id' => $petition['_id']), array('$set' => array('created' => $ts))); - } - //put an index on the created field - $mongoPetitionCollection->ensureIndex(array('created'=>-1), array('safe' => TRUE)); -} - -/** - * implements hook_update_N() - * - * put index on petition_signatures.timestamp - * back-fill delta counts for existing records - */ -function wh_petition_reporting_update_7102() { - $mongoSignatureCollection = mongodb_collection('petition_signatures'); - $mongoSignatureCollection->ensureIndex(array('timestamp'=>-1), array('safe' => TRUE)); - - $collection = mongodb_collection('hourly_report_data'); - $collection->setSlaveOkay(TRUE); - - //get the petitions which have all three deltas set to 0 - $query = array( - 'newUsers' => 0, - 'newPetitions' => 0, - 'newSignatures' => 0, - ); - $hours = $collection->find($query); - $i = 0; - foreach ($hours as $hour) { - $i++; - $hours->timeout = 90 * 1000; //90 seconds per record - $start_time = $hour['_id']['startTS']; - $end_time = $hour['_id']['endTS']; - - $dataObject = HourlyReportManager::getHourRecord($start_time, $end_time, TRUE); - - $collection->update(array('_id' => $hour['_id']), array('$set' => array('newUsers' => (int) $dataObject['newUsers'], 'newPetitions' => $dataObject['newPetitions'], 'newSignatures' => $dataObject['newSignatures']))); - } -} diff --git a/modules/custom/wh_petition_reporting/wh_petition_reporting.module b/modules/custom/wh_petition_reporting/wh_petition_reporting.module deleted file mode 100644 index 3f596f1be..000000000 --- a/modules/custom/wh_petition_reporting/wh_petition_reporting.module +++ /dev/null @@ -1,60 +0,0 @@ - MENU_NORMAL_ITEM, - 'title' => 'Petitions Reports', - 'description' => 'View summary reports of Petitions Data', - 'access arguments' => array('access petition reports'), - 'page callback' => 'petition_reports_page', - 'file' => 'wh_petition_reporting.page.inc', - ); - - //Summary counts - $items['admin/petition-reports/summary'] = array( - 'type' => MENU_LOCAL_TASK, - 'title' => 'Summary', - 'description' => 'Some simple summarizations of petitions data', - 'access arguments' => array('access petition reports'), - 'page callback' => 'summary_page', - 'file' => 'wh_petition_reporting.summary.inc', - ); - - //Hourly User, Signature, and Petition count list - $items['admin/petition-reports/hourly-counts'] = array( - 'type' => MENU_LOCAL_TASK, - 'title' => 'Hourly User, Signature, and Petition Creation', - 'description' => '', - 'access arguments' => array('access petition reports'), - 'page callback' => 'hourly_page', - 'file' => 'wh_petition_reporting.hourly.inc', - ); - - return $items; -} - -/** - * Implements hook_permission() - */ -function wh_petition_reporting_permission() { - $permissions = array(); - - $permissions['access petition reports'] = array( - 'title' => t('Access Petition Reports'), - 'description' => t('Access Petition Reports'), - ); - - return $permissions; -} diff --git a/modules/custom/wh_petition_reporting/wh_petition_reporting.page.inc b/modules/custom/wh_petition_reporting/wh_petition_reporting.page.inc deleted file mode 100644 index 3df344488..000000000 --- a/modules/custom/wh_petition_reporting/wh_petition_reporting.page.inc +++ /dev/null @@ -1,31 +0,0 @@ -Please select one of the following reports:

"; - - $report_links = array(); - foreach (wh_petition_reporting_menu() as $path => $report) { - if ($path == $_GET['q'] || $report['type'] == MENU_CALLBACK) { //dont include the current page or any callbacks, cause that's just dumb - continue; - } - $report_links[] = l($report['title'], $path, array('attributes' => array('title' => $report['description']))); - } - $list_variables = array( - 'items' => $report_links, - 'title' => t('Petition Reports'), - 'type' => 'ul', - 'attributes' => array(), - ); - $html .= theme_item_list($list_variables); - return $html; -} diff --git a/modules/custom/wh_petition_reporting/wh_petition_reporting.summary.inc b/modules/custom/wh_petition_reporting/wh_petition_reporting.summary.inc deleted file mode 100644 index 5f5052035..000000000 --- a/modules/custom/wh_petition_reporting/wh_petition_reporting.summary.inc +++ /dev/null @@ -1,374 +0,0 @@ -lastBuild = variable_get('wh_petition_reports_last_build', 0); - if ((time() - $this->lastBuild) >= 3600) { - $this->lastBuild = time(); - variable_set('wh_petition_reports_last_build', $this->lastBuild); - //rebuild the summary data stored in Mongo - $this->buildSummaryData(); - $this->buildIssuesSummaryData(); - } - else { - //the data in mongo is good, so just load it from cache table - $this->loadSummaryData(); - $this->loadIssuesSummaryData(); - } - } - - /** - * Generates header including date report data was aggregated - * - */ - public function getReportHeader() { - return '

' . t('Data generated %date', array('%date' => date('m-d-Y H:i:s', $this->lastBuild))) . '

'; - } - - /** - * get updated data from the database, set it in the $summaryData variable and stored it back to the db - */ - private function buildSummaryData() { - //set up connections - $userQuery = "select count(uid) as users, sum(if(login>0,1,0)) as verified from {users}"; - $userData = db_query($userQuery)->fetchObject(); - $mongoPetitionCollection = wh_petitions_mongo_petition_connection(); - $mongoSignaturesCollection = wh_petitions_mongo_petition_signatures_connection(); - - //store all the data we generated for later use - $this->summaryData = array( - 'users' => $userData->users, - 'verified' => $userData->verified, - 'petitions' => $mongoPetitionCollection->count(), - 'active' => $mongoPetitionCollection->count(array('petition_status' => array('$in' => array(1, 2, 4, 5)))), //1/Private, 2/Public, 4/Under Review,5/Reviewed - 'public' => $mongoPetitionCollection->count(array('petition_status' => array('$in' => array(2, 4, 5)))), - 'awaiting_response' => $mongoPetitionCollection->count(array('response_status' => 1)), - 'responded_to' => $mongoPetitionCollection->count(array('response_status' => 2)), - 'removed' => $mongoPetitionCollection->count(array('petition_status' => 6)), - 'expired' => $mongoPetitionCollection->count(array('petition_status' => 3)), - 'signatures' => $mongoSignaturesCollection->count(), - ); - - //write generated data to mongo - $collection = mongodb_collection('summary_report_data'); - $collection->remove(); //purge the table, this is just a snapshot, not a historical record - $collection->save(array_merge($this->summaryData, array('unix_time' => $this->lastBuild))); - } - - /** - * load summary data from cache table - * - * @todo: finish developing this - */ - private function loadSummaryData() { - //get data from Mongo - $collection = mongodb_collection('summary_report_data')->findOne(); //should only ever be one - - //force it into holding array - $this->summaryData = array( - 'users' => $collection['users'], - 'verified' => $collection['verified'], - 'petitions' => $collection['petitions'], - 'active' => $collection['active'], - 'public' => $collection['public'], - 'awaiting_response' => $collection['awaiting_response'], - 'responded_to' => $collection['responded_to'], - 'removed' => $collection['removed'], - 'expired' => $collection['expired'], - 'signatures' => $collection['signatures'], - ); - } - - /** - * get updated data from the database, set it in the $summaryIssuesData variable and stored it back to the db - */ - private function buildIssuesSummaryData() { - //get list of issues - $vocab = taxonomy_vocabulary_machine_name_load('issues'); - if (empty($vocab)) { - throw new Exception("Unable to load taxonomy with machine name 'issues'"); - } - $issues = taxonomy_get_tree($vocab->vid); - usort($issues, array($this, 'sortIssues')); - - $issue_data = $this->mapReduceIssues(); - - $collection = mongodb_collection('summary_report_data__issues'); - $collection->remove(); //purge the table, this is just a snapshot, not a historical record - - foreach ($issues as $issue) { - //store the data oof to our variable and write it to mongo for later use - $this->issuesData[$issue->name] = $issue_data[$issue->tid]; - $collection->save(array_merge(array('name' => $issue->name), $issue_data[$issue->tid])); - } - } - - /** - * load issues summary data from cache table - * - * @todo: make this work - */ - private function loadIssuesSummaryData() { - //get data from Mongo - $collection = mongodb_collection('summary_report_data__issues')->find(); - - //force it into holding array - foreach ($collection as $record) { - $name = $record['name']; - unset($record['name']); - unset($record['_id']); - - $this->issuesData[$name] = $record; - } - } - - /** - * MapReduce mongo petitions to get counts by issue - * - */ - private function mapReduceIssues() { - - //JAVASCRIPT function - //for this purpose, Removed Petitions do not count - $map_function = new MongoCode("function () { - var public = 0; - if (this.petition_status != 6) { - if (this.petition_status == 2 || this.petition_status == 4 || this.petition_status ==5) { - public = 1; - } - var signatures = this.signature_count; - - if (this.issues != null) { - for (var i = 0; i 'petitions', //the name of the collection - 'map' => $map_function, - 'reduce' => $reduce_function, - 'out' => array('inline' => 1), //eventually we'll want to store these off, I think - ); - - $db = mongodb(); - $issues_data_collection = $db->command($command); - - //convert what we get from mongo into a structure more easily merged with the other data - //result is an array where keys are issue tids and values are array of data - $issues_data = array(); - foreach ($issues_data_collection['results'] as $issue) { - $issues_data[$issue['_id']] = $issue['value']; - } - - return $issues_data; - } - - /** - * Sort array of issues taxonomy objects by issue name - * - * @see http://php.net/manual/en/function.usort.ph - */ - public function sortIssues($a, $b) { - if ($a->name == $b->name) { - return 0; - } - return ($a->name < $b->name) ? -1 : 1; - } - - - /** - * Add a row for the given data point to the data rows array for summary table - * - * @param $data_rows array - * array to which the row will be added and which will eventually be fed to - * theme_table() - * @param $label string - * the translated text which should be written into the label column for the row, - * @param $data string - * string of the data which should be written into the data column for the row - * @param $label_inset boolean - * optional (defaults to FALSE) indicator of if the label should be indented - * @param $data_pct_of integer - * optional; if given the percent value of $data/$data_pct_of is included in the data cell - */ - private function addRowToSummaryTable(&$data_rows, $label, $data, $label_inset = FALSE, $data_pct_of = FALSE) { - if ($data_pct_of) { - if (!is_numeric($data_pct_of) || !is_numeric($data)) { - throw new Exception('Seriously? You asked me to give a percentage but either $data or $data_pct_of are not numeric. Go back and try again.'); - } - $data_string = t('(@percent%) @data', array('@percent' => round(($data/$data_pct_of) * 100, 2), '@data' => number_format($data))); - } - else { - $data_string = t('@data', array('@data' => number_format($data))); - } - - $title_cell = array('data' => $label . ':', 'header' => TRUE, 'class' => ($label_inset ? 'inset' : '')); - $data_cell = array('data' => $data_string); - $data_rows[] = array('data' => array($title_cell, $data_cell)); - } - - /** - * Add a row for the given data point to the data rows array for summary table - * - * @param $data_rows array - * array to which the row will be added and which will eventually be fed to - * theme_table() - * @param $label string - * the translated text which should be written into the label column for the row, - * @param $data_cells string - * string of the data which should be written into the data column for the row - */ - private function addRowToIssuesTable(&$data_rows, $label, $data_cells, $label_inset = FALSE) { - $title_cell = array('data' => $label . ':', 'header' => TRUE, 'class' => ($label_inset ? 'inset' : '')); - $petitions = number_format($data_cells['petitions']); - $petitions_pct = round(($petitions / ($this->summaryData['petitions'] - $this->summaryData['removed'])) * 100, 2) . '%'; - $public = number_format($data_cells['public']); - $public_pct = round(($public / $this->summaryData['public']) * 100, 2) . '%'; - $signatures = number_format($data_cells['signatures']); - - $data_rows[] = array('data' => array($title_cell, $petitions, $petitions_pct, $public, $public_pct, $signatures)); - } - - /** - * Build the Summary Report table - * - * @return string - * HTML markup of table - */ - public function getSummaryReportTable() { - $markup = ''; - $data_rows = array(); - - //Registred Users - $this->addRowToSummaryTable($data_rows, t('Registered Users'), $this->summaryData['users']); - - //Verified Users - $this->addRowToSummaryTable($data_rows, t('Verified Users'), $this->summaryData['verified'], FALSE, $this->summaryData['users']); - - //Total Petitions - $this->addRowToSummaryTable($data_rows, t('Total Petitions'), $this->summaryData['petitions']); - - //Active Petitions - $this->addRowToSummaryTable($data_rows, t('Active'), $this->summaryData['active'], TRUE, $this->summaryData['petitions']); - - //Public - $this->addRowToSummaryTable($data_rows, t('Public'), $this->summaryData['public'], TRUE, $this->summaryData['petitions']); - - //Awaiting Response - $this->addRowToSummaryTable($data_rows, t('Awaiting Reponse'), $this->summaryData['awaiting_response'], TRUE, $this->summaryData['petitions']); - - //Responded To - $this->addRowToSummaryTable($data_rows, t('Responded To'), $this->summaryData['responded_to'], TRUE, $this->summaryData['petitions']); - - //Removed - $this->addRowToSummaryTable($data_rows, t('Removed'), $this->summaryData['removed'], TRUE, $this->summaryData['petitions']); - - //Expired - $this->addRowToSummaryTable($data_rows, t('Exprired'), $this->summaryData['expired'], TRUE, $this->summaryData['petitions']); - - //mongo signatures data - $this->addRowToSummaryTable($data_rows, t('Signatures'), $this->summaryData['signatures']); - - //this is the wrong way to do output, but I'm in a bloody hurry and this is supposed to be a temporary solution - $markup .= '

' . t('Petition Summary Report') . '

'; - $markup .= theme_table(array('header' => array(), 'rows' => $data_rows, 'attributes' => array('id' => 'petition-summary-table'), 'caption' => '', 'colgroups' => array(), 'sticky' => TRUE, 'empty' => t('No data found.'))); - $markup .= '
'; - - return $markup; - } - - /** - * Build the Issue Summary Report table - * - * @return string - * HTML markup of table - */ - public function getIssuesSummaryReportTable() { - $markup = ''; - $data_rows = array(); - foreach ($this->issuesData as $title_cell => $data_cells) { - //put data into table - $this->addRowToIssuesTable($data_rows, $title_cell, $data_cells); - } - //this is the wrong way to do output, but I'm in a bloody hurry and this is supposed to be a temporary solution - $markup .= '

' . t('Petition Issues Summary Report') . '

'; - $headers = array( - t('Issue'), - t('Petitions'), - t('% of Total'), - t('Public Petitions'), - t('% of Total'), - t('Signatures') - ); - $markup .= theme_table(array('header' => $headers, 'rows' => $data_rows, 'attributes' => array('id' => 'petition-issues-table'), 'caption' => '', 'colgroups' => array(), 'sticky' => TRUE, 'empty' => t('No data found.'))); - $markup .= '
'; - - return $markup; - } - - -} - - - -/** - * Page callback form admin/petitino-reports/summary path - */ -function summary_page() { - drupal_add_css(drupal_get_path('module', 'wh_petition_reporting') . '/css/summary.css', array('type' => 'file')); - $reportManager = new SummaryReportManager(); - - $markup = "
"; - - //report header - $markup .= $reportManager->getReportHeader(); - - //Petition Summary Report table - $markup .= $reportManager->getSummaryReportTable(); - - //Petition Issues Summary Report table - $markup .= $reportManager->getIssuesSummaryReportTable(); - - $markup .= "
"; - return $markup; -} - - diff --git a/modules/custom/wh_petition_tool/wh-petition-tool-homepage.tpl.php b/modules/custom/wh_petition_tool/wh-petition-tool-homepage.tpl.php deleted file mode 100644 index c65d2ca10..000000000 --- a/modules/custom/wh_petition_tool/wh-petition-tool-homepage.tpl.php +++ /dev/null @@ -1,21 +0,0 @@ -
-
-
- -
- -
- -
- -
- -
- -
- -
-
-
diff --git a/modules/custom/wh_petition_tool/wh-petition-tool-left-nav.tpl.php b/modules/custom/wh_petition_tool/wh-petition-tool-left-nav.tpl.php deleted file mode 100644 index 86f57e89a..000000000 --- a/modules/custom/wh_petition_tool/wh-petition-tool-left-nav.tpl.php +++ /dev/null @@ -1,7 +0,0 @@ -
-
    - -
  • - -
-
\ No newline at end of file diff --git a/modules/custom/wh_petition_tool/wh_petition_tool.admin.inc b/modules/custom/wh_petition_tool/wh_petition_tool.admin.inc deleted file mode 100644 index 955f68e35..000000000 --- a/modules/custom/wh_petition_tool/wh_petition_tool.admin.inc +++ /dev/null @@ -1,33 +0,0 @@ - t('API Key'), - '#type' => 'textfield', - '#description' => t('The authentication key as configured in the services module of the OpenSaaS Hub'), - '#default_value' => variable_get('wh_petition_tool_hub_key'), - ); - - $form['wh_petition_tool_hub_url'] = array( - '#title' => t('Services URL'), - '#type' => 'textfield', - '#description' => t('The Services URL of the OpenSaaS Hub. Example: http://server.com/services/xmlrpc'), - '#default_value' => variable_get('wh_petition_tool_hub_url', ''), - ); - - $form['wh_petition_tool_request_domain'] = array( - '#title' => t('Request Domain'), - '#type' => 'textfield', - '#description' => t('The domain as configured in the Services API Key Authentication. Example: server.com'), - '#default_value' => variable_get('wh_petition_tool_request_domain'), - ); - - return system_settings_form($form); -} \ No newline at end of file diff --git a/modules/custom/wh_petition_tool/wh_petition_tool.info b/modules/custom/wh_petition_tool/wh_petition_tool.info deleted file mode 100644 index 632efcfb9..000000000 --- a/modules/custom/wh_petition_tool/wh_petition_tool.info +++ /dev/null @@ -1,7 +0,0 @@ -name = White House Petition Tool -description = Provides JSON and AJAX support to deliver content to the main White House site. -dependencies[] = wh_petitions -dependencies[] = wh_response -package = Other -core = 7.x -files[] = wh_petition_tool.module \ No newline at end of file diff --git a/modules/custom/wh_petition_tool/wh_petition_tool.install b/modules/custom/wh_petition_tool/wh_petition_tool.install deleted file mode 100644 index 783f5acbb..000000000 --- a/modules/custom/wh_petition_tool/wh_petition_tool.install +++ /dev/null @@ -1,26 +0,0 @@ -ensureIndex(array('title' => 1)); - $conn->ensureIndex(array('signature_count' => -1)); - $conn->ensureIndex(array('published' => -1)); - $conn->ensureIndex(array('reached_public' => -1)); - $conn->ensureIndex(array('title_keywords' => 1)); - $conn->ensureIndex(array('body_keywords' => 1)); - $conn->ensureIndex(array('nice_url' => 1)); - - // Sets Mongo Signature Indexes - $signature_conn = wh_petitions_mongo_petition_signatures_connection(); - $signature_conn->ensureIndex(array('_id', 'petition_id')); - $signature_conn->ensureIndex('petition_id'); -} - -function wh_petition_tool_update_7001($sandbox) { - // Upping stale file threshold to 60 days to prevent improper caching at Aka - variable_set('drupal_stale_file_threshold', 5184000); -} diff --git a/modules/custom/wh_petition_tool/wh_petition_tool.module b/modules/custom/wh_petition_tool/wh_petition_tool.module deleted file mode 100644 index 0c9b04e35..000000000 --- a/modules/custom/wh_petition_tool/wh_petition_tool.module +++ /dev/null @@ -1,592 +0,0 @@ - array( - 'title' => t('Administer Petition Tool hub Settings settings'), - 'description' => t('Manage the configuration of the Petition Tool Web Services integration with the OpenSaaS Hub'), - ), - ); -} - -/** - * Implementation of hook_menu(). - */ -function wh_petition_tool_menu() { - $items['petitionpage'] = array( - 'title' => 'AJAX responses for Petitions', - 'page callback' => 'wh_petition_tool_page_init', - 'access arguments' => array('access content'), - ); - $items['petitiontool'] = array( - 'title' => 'AJAX responses for Petitions', - 'page callback' => 'wh_petition_tool_page_json', - 'access arguments' => array('access content'), - ); - $items['homepage'] = array( - 'title' => variable_get('wh_petitions_page_title', 'We the People: Your Voice in Our Government'), - 'page callback' => 'wh_petition_tool_homepage', - 'access arguments' => array('access content'), - ); - $items['petitiontool/opengraph/%'] = array( - 'title' => 'OpenGraph data for Petition Tool content', - 'page callback' => 'wh_petition_tool_opengraph_json', - 'page arguments' => array(2), - 'access arguments' => array('access content'), - ); - $items['petitiontool/metadata/%'] = array( - 'title' => 'Metadata for Petition Tool content', - 'page callback' => 'wh_petition_tool_metadata_json', - 'page arguments' => array(2), - 'access arguments' => array('access content'), - ); - $items['petitiontool/cron/response/%'] = array( - 'title' => 'Petition IDs that have been responded to lately', - 'page callback' => 'wh_petition_tool_page_responded_to', - 'page arguments' => array(3), - 'access arguments' => array('access content'), - ); - $items['admin/config/system/petition-tool-hub'] = array( - 'title' => 'Petition Tool Hub Settings', - 'description' => 'Manage Petition Tool Web Service integration with OpenSaas Hub.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('wh_petition_tool_hub_settings'), - 'access arguments' => array('administer petition tool hub settings'), - 'weight' => -10, - 'file' => 'wh_petition_tool.admin.inc', - ); - return $items; -} - -/** - * Themes the petition tool homepage. - */ -function wh_petition_tool_homepage() { - global $base_url; - $bottom_left = variable_get('wh_petitions_homepage_left', ''); - $bottom_middle = variable_get('wh_petitions_homepage_center', ''); - $bottom_right = variable_get('wh_petitions_homepage_right', ''); - $homepage_content = variable_get('wh_petitions_homepage_content', ''); - return theme('wh_petition_tool_homepage', array('url' => $base_url, 'bottom_left' => $bottom_left, 'bottom_middle' => $bottom_middle, 'bottom_right' => $bottom_right, 'homepage_content' => $homepage_content)); -} - -/** - * - */ -function wh_petition_tool_page_init($path = 'petitions') { - print theme_page(); - die; -} - -function wh_petition_tool_page_responded_to($last_id) { - $petition_ids = array(); - $new_last_id = ''; - - $res_conn = wh_response_mongo_response_connection(); - if (!empty($last_id)) { - $result = $res_conn->find(array('_id' => array('$gt' => new MongoId($last_id))))->sort(array('_id' => -1)); - } - else { - $result = $res_conn->find()->sort(array('_id' => -1)); - } - foreach ($result as $res) { - $id = $res['petition']->__toString(); - array_push($petition_ids, $id); - if (empty($new_last_id)) { - $new_last_id = $res['_id']->__toString(); - } - } - - drupal_json_output(array("ids" => $petition_ids, "last_id" => $new_last_id)); -} - -/** - * - */ -function wh_petition_tool_page_json() { - $data = _wh_petition_tool_page_content(); - - header('Content-Type: text/javascript; charset=utf-8'); - if (empty($_GET['callback'])) { - drupal_json_output($data); - } - else { - $callback = check_plain($_GET['callback']); - print $callback . '(' . json_encode($data) . ')'; - exit; - } - -} - -/** - * Implementation of hook_theme(). - * - * Addes the json theme key and tells Drupal to use our substitute for - * html.tpl.php, but still render the page's content as a page. This way, we - * can use the page's render array to encode as json - */ -function wh_petition_tool_theme() { - return array( - 'json' => array( - 'render element' => 'page', - 'template' => 'json', - ), - 'esi' => array( - 'render element' => 'page', - 'template' => 'esi', - ), - 'wh_petition_tool_homepage' => array( - 'arguments' => array(), - 'template' => 'wh-petition-tool-homepage', - ), - 'wh_petition_tool_left_nav' => array( - 'arguments' => array(), - 'template' => 'wh-petition-tool-left-nav', - ), - ); -} - -/** - * Helper function to create an array of data to send as json later. - * This may be deprecated soon. - */ -function _wh_petition_tool_page_content() { - $content = array(); - - module_load_include('inc', 'wh_petitions', 'wh_petitions.pages'); - $content['markup'] = wh_petitions_show_petitions(); - - $content['css'] = drupal_get_css(); - $content['js'] = drupal_get_js(); - - return $content; -} - -/** - * Implementation of hook_page_alter(). - * - * Looks for the wrapper parameter that is sent by the AJAX requests. - */ -function wh_petition_tool_page_alter(&$page) { - if (!empty($_GET['wrapper']) || !empty($_GET['t'])) { - $page['#show_messages'] = FALSE; - if ($_GET['wrapper'] == 'json') { - $page['#theme_wrappers'] = array('json'); - } - elseif ($_GET['wrapper'] == 'esi') { - $page['#theme_wrappers'] = array('esi'); - } - } -} - -/** - * Implements hook_preprocess_node(). - * - * Adds the left nav to page nodes. - */ -function wh_petition_tool_preprocess_node(&$vars) { - $vars['left_nav'] = ''; - if ($vars['node']->type == 'wh_petitions_page') { - $vars['left_nav'] = wh_petition_tool_left_nav(); - } -} - -/** - * Implements hook_preprocess_page(). - * - * Adds the top right text and node type as variables available to the page template. - */ -function wh_petition_tool_preprocess_page(&$vars) { - $vars['top_right_text'] = variable_get('wh_petitions_top_right_text', ''); - $node_type = ''; - if (!empty($vars['node'])) { - $node_type = $vars['node']->type; - } - $vars['node_type'] = $node_type; -} - -/** - * Themes the left nav on page nodes. - */ -function wh_petition_tool_left_nav() { - $menu_links = menu_tree_page_data('menu-how-why', 2, FALSE); - $links = array(); - - foreach ($menu_links as $id => $menu_item) { - if ($menu_item['link']['depth'] == 1 && !$menu_item['link']['hidden']) { - $links[] = $menu_item['link']; - } - } - - return theme('wh_petition_tool_left_nav', array('links' => $links)); -} - -/** - * Request a Short URL from the OpenSaas Hub site. - * - * @param $url - * The original relative URL - * - * @return - * The wh.gov short URL. - */ -function wh_petition_tool_shortenurl($url) { - $op = 'petitiontool.shortenurl'; - $api_key = variable_get('wh_petition_tool_hub_key', ''); - $server = variable_get('wh_petition_tool_hub_url', ''); - - // The domain you are sending the request from, which is specified also in the api key. - $domain = variable_get('wh_petition_tool_request_domain', ''); - - // Timestamp for hash - $timestamp = (string) time(); - - // Single use password - $nonce = user_password(); - - // Create secure hash using your api key. - $hash = hash_hmac('sha256', $timestamp . ';' .$domain . ';' . $nonce . ';' . $op, $api_key); - - // Get a node from the remote server. - $xmlrpc_result = xmlrpc($server, array( - $op => array($hash, $domain, $timestamp, $nonce, $url)) - ); - - if ($xmlrpc_result === FALSE) { - $xmlrpc_error = xmlrpc_error(); - watchdog('wh_petition_tool', 'Services Error (@code): @message', array( - '@code' => $xmlrpc_error->code, - '@message' => $xmlrpc_error->message - ), WATCHDOG_ERROR); - } - - return $xmlrpc_result; -} - -/** - * Menu callback for grabbing ther Open Graph data for an entity. - */ -function wh_petition_tool_opengraph_json($type) { - $elements = arg(); - $path_parts = array_slice($elements, 3); - $path = implode('/', $path_parts); - - switch ($type) { - case 'petition': - $data = wh_petition_tool_petition_opengraph($path); - break; - case 'response': - $data = wh_petition_tool_response_opengraph($path); - break; - default: - $data = array(); - } - - drupal_json_output($data); -} - -/** - * Load the Petition and return the data used for the OpenGraph tags. - */ -function wh_petition_tool_petition_opengraph($path) { - $conn = wh_petitions_mongo_petition_connection(); - - if ($petition = $conn->findOne(array('nice_url' => $path), array('title', 'body'))) { - return array( - 'og:title' => $petition['title'], - 'og:description' => truncate_utf8($petition['body'], 200, TRUE, TRUE), - 'og:type' => 'article', - ); - } - - return array(); -} - -/** - * Load the Response and return the data used for the OpenGraph tags. - */ -function wh_petition_tool_response_opengraph($path) { - if ($url = drupal_lookup_path('source', $path)) { - $nid = arg(1, $url); - $node = node_load($nid); - - // TODO: Do we need to add the "Official Response to..." to the title - $title = check_plain($node->title); - $body = strip_tags($node->body[$node->language][0]['value']); - return array( - 'og:title' => $title, - 'og:description' => truncate_utf8($body, 200, TRUE, TRUE), - 'og:type' => 'article', - ); - } - - return array(); -} - -/** - * Menu callback for grabbing ther Metadata for an entity. - */ -function wh_petition_tool_metadata_json($type) { - $elements = arg(); - $path_parts = array_slice($elements, 3); - $path = implode('/', $path_parts); - - switch ($type) { - case 'petition': - $data = wh_petition_tool_petition_metadata($path); - break; - case 'response': - $data = wh_petition_tool_response_metadata($path); - break; - default: - $data = array(); - } - - drupal_json_output($data); -} - -/** - * Load the Petition and return the data used for the Metadata tags. - */ -function wh_petition_tool_petition_metadata($path) { - $conn = wh_petitions_mongo_petition_connection(); - - if ($petition = $conn->findOne(array('nice_url' => $path), array('title', 'body', 'petition_status', 'issues'))) { - $issues = array(); - if (!empty($petition['issues'])) { - for ($i=0;$iname)); - } - } - } - return array( - 'petition_id' => $petition['_id']->__toString(), - 'title' => check_plain($petition['title']), - 'description' => check_plain(str_replace("\r\n", ' ', strip_tags($petition['body']))), - 'keywords' => implode(', ', $issues), - 'has_response' => ($petition['petition_status'] == WH_PETITION_STATUS_REVIEWED) ? 1 : 0, - ); - } - - return array(); -} - -/** - * Load the Response and return the data used for the Metadata tags. - */ -function wh_petition_tool_response_metadata($path) { - if ($url = drupal_lookup_path('source', $path)) { - $nid = arg(1, $url); - $node = node_load($nid); - - $title = check_plain($node->title); - $body = str_replace("\r\n", ' ', strip_tags($node->body[$node->language][0]['value'])); - $issues = array(); - if (!empty($node->field_issues[$node->language][0])) { - for ($i=0;$ifield_issues[$node->language]);$i++) { - $term = taxonomy_term_load($node->field_issues[$node->language][$i]['tid']); - if (!empty($term)) { - array_push($issues, check_plain($term->name)); - } - } - } - - return array( - 'title' => $title, - 'description' => truncate_utf8($body, 320, TRUE, TRUE), - 'keywords' => implode(', ', $issues), - 'has_response' => 1, - ); - } - - return array(); -} - - -/** - * Implements hook_form_FORM_ID_alter(). - * - * Alters the forward form to uncollapse by default since it's on its own page, add the appropriate submit button, and add a submit handler. - */ -function wh_petition_tool_form_forward_form_alter(&$form, &$form_state) { - $form['message']['#collapsed'] = FALSE; - $form['message']['#collapsible'] = FALSE; - array_push($form['#submit'], 'wh_petition_tool_forward_submit'); - $form['message']['actions']['submit']['#attributes'] = array('class' => array('button-email-this-petition', 'button')); - if (arg(0) == 'response') { - array_push($form['message']['actions']['submit']['#attributes']['class'], 'blue-button'); - $form['message']['actions']['submit']['#value'] = t('Email This Response'); - $nid = arg(2); - $form['message']['nid'] = array( - '#type' => 'hidden', - '#value' => check_plain($nid), - ); - } - - $message = ''; - if (arg(0) == 'petition') { - $message = variable_get('wh_petitions_email_forward_text', ''); - $conn = wh_petitions_mongo_petition_connection(); - $petition_id = arg(2); - $petition = $conn->findOne(array('_id' => new MongoId($petition_id)), array('response_signatures', 'short_url', 'body', 'title', 'published', 'review_timeframe')); - - if (!empty($petition)) { - $time = $petition['published']; - $end_date = strtotime('+' . $petition['review_timeframe'] . ' days', $time); - $end_date = date("F d, Y", $end_date); - - if (empty($petition['short_url'])) $petition['short_url'] = ''; - - $message = str_replace('!petition_description', $petition['body'], $message); - $message = str_replace('!shorturl', $petition['short_url'], $message); - $message = str_replace('!signatures_needed', wh_petitions_format_number($petition['response_signatures']), $message); - $message = str_replace('!date_needed', $end_date, $message); - } - } - else { - $message = variable_get('wh_petitions_email_forward_response_text', ''); - $nid = arg(2); - $node = node_load($nid); - $short_url = $node->field_shorturl[$node->language][0]['value']; - if (!empty($node)) { - $message = str_replace('!shorturl', $short_url, $message); - } - } - $message = str_replace("\r\n", "
", $message); - - $form['preview'] = array( - '#type' => 'markup', - '#markup' => $message, - '#prefix' => '

', - '#weight' => 100, - ); -} - -/** - * Forward form submit handler. Redirects to the appropriate thank you page based on petition or response. - * - * @todo - Ben - If emailing a petition or response is ever enabled we will need to revise this to remove - * hostname and verify the petition id in the args array. - */ -function wh_petition_tool_forward_submit(&$form, &$form_state) { - global $base_url; - $host = variable_get('main_hostname', '') . '/petition-tool'; - if (!empty($host)) { - if ($form_state['values']['op'] == 'Email This Response') { - $url = rtrim($host, '/') . '/response/email_thank'; - $nid = $form_state['values']['nid']; - if (!empty($nid)) { - $url .= '/' . check_plain($nid); - } - } - else { - $url = rtrim($host, '/') . '/petition/email_thank'; - $petition_id = arg(2); - if (!empty($petition_id)) { - $url .= '/' . check_plain($petition_id); - } - } - } - $form_state['redirect'] = $url; -} - -/** - * Implements hook_menu_link_alter(). - * - * Alters the description and title for the Content admin menu path. - */ -function wh_petition_tool_menu_link_alter(&$item) { - if ($item['link_path'] == 'admin/content') { - $item['description'] = t('Find and manage responses and pages.'); - $item['options']['attributes']['title'] = t('Find and manage responses and pages.'); - } -} - -/** - * Implements hook_mail_alter(). - * - * Alters the text of the forward email message to insert petition and response-specific variables. - */ -function wh_petition_tool_mail_alter(&$message) { - if ($message['id'] == 'forward_forward_page') { - if (arg(0) == 'petition') { - $conn = wh_petitions_mongo_petition_connection(); - $petition_id = arg(2); - $petition = $conn->findOne(array('_id' => new MongoId($petition_id)), array('response_signatures', 'short_url', 'body', 'title', 'published', 'review_timeframe')); - - if (!empty($petition)) { - $time = $petition['published']; - $end_date = strtotime('+' . $petition['review_timeframe'] . ' days', $time); - $end_date = date("F d, Y", $end_date); - - if (empty($petition['short_url'])) $petition['short_url'] = ''; - - $message['body'][0] = str_replace('!petition_description', $petition['body'], $message['body'][0]); - $message['body'][0] = str_replace('!shorturl', $petition['short_url'], $message['body'][0]); - $message['body'][0] = str_replace('!signatures_needed', wh_petitions_format_number($petition['response_signatures']), $message['body'][0]); - $message['body'][0] = str_replace('!date_needed', $end_date, $message['body'][0]); - $message['params']['body'] = str_replace('!petition_description', $petition['body'], $message['params']['body']); - $message['params']['body'] = str_replace('!shorturl', $petition['short_url'], $message['params']['body']); - $message['params']['body'] = str_replace('!signatures_needed', wh_petitions_format_number($petition['response_signatures']), $message['params']['body']); - $message['params']['body'] = str_replace('!date_needed', $end_date, $message['params']['body']); - $message['subject'] = $petition['title']; - $message['params']['subject'] = $petition['title']; - } - } - else { - $nid = arg(2); - $node = node_load($nid); - $short_url = $node->field_shorturl[$node->language][0]['value']; - if (!empty($node)) { - $message['body'][0] = str_replace('!shorturl', $short_url, $message['body'][0]); - $message['params']['body'] = str_replace('!shorturl', $short_url, $message['params']['body']); - $message['subject'] = check_plain($node->title); - $message['params']['subject'] = check_plain($node->title); - } - } - } -} - -/** - * Themes the twitter link on petitions and responses. - */ -function wh_petition_tool_twitter_link($id, $title, $type = 'petition', $link_text='', $short_url='', $nice_url='') { - global $base_url; - if (empty($short_url)) { - $short_url = $base_url .'/'. $nice_url; - } - $link = 'http://twitter.com/share?'; - $link .= 'url=' . $short_url; - $link .= '&text=' . urlencode($title); - $link .= '&counturl=' . $base_url .'/'. $nice_url; - - if (empty($link_text)) { - $link_text = t('Twitter'); - } - - return '' . $link_text . ''; -} - -/** - * Themes the facebook share link on petitions and responses. - */ -function wh_petition_tool_facebook_link($id, $title, $type = 'petition', $link_text='', $nice_url='') { - global $base_url; - $url = $base_url . "/$nice_url"; - - if (empty($link_text)) { - $link_text = t('Facebook'); - } - - return '' . $link_text . ''; -} diff --git a/modules/custom/wh_petitions/drush/wh_petitions.drush.inc b/modules/custom/wh_petitions/drush/wh_petitions.drush.inc deleted file mode 100644 index 2df989eba..000000000 --- a/modules/custom/wh_petitions/drush/wh_petitions.drush.inc +++ /dev/null @@ -1,42 +0,0 @@ - 'wh_petitions_generate', - 'description' => "Generate random petitions for testing.", - 'arguments' => array( - 'number' => 'The number of petitions to generate.', - 'uid' => 'The user ID to create the petitions with.', - 'status' => 'The petition status to generate these petitions with.', - ), - 'aliases' => array('petgen'), - ); - - $items['petitions-check-compliance-review-threshold'] = array( - 'callback' => 'wh_petitions_compliance_review_threshold_check_drush', - 'description' => "Check for petitions with enough signatures to pass the compliance review threshold.", - 'arguments' => array( - ), - 'aliases' => array('petcrt'), - ); - - - return $items; -} - - -function wh_petitions_generate($number, $uid = NULL, $status = NULL) { - module_load_include('inc', 'wh_petitions', 'wh_petitions.generate'); - create_petitions($number, $uid, $status); -} - -function wh_petitions_compliance_review_threshold_check_drush() { - $email = variable_get('wh_petitions_compliance_reviewer_emails', FALSE); - $threshold = (int)variable_get('wh_petitions_compliance_review_threshold', FALSE); - - if ($email && $threshold) { - wh_petitions_compliance_review_threshold_check($threshold, $email); - } -} diff --git a/modules/custom/wh_petitions/templates/wh-petitions-by-the-numbers.tpl.php b/modules/custom/wh_petitions/templates/wh-petitions-by-the-numbers.tpl.php deleted file mode 100644 index 6dc017c0b..000000000 --- a/modules/custom/wh_petitions/templates/wh-petitions-by-the-numbers.tpl.php +++ /dev/null @@ -1,8 +0,0 @@ -
- $value): ?> -
- - -
- -
\ No newline at end of file diff --git a/modules/custom/wh_petitions/templates/wh-petitions-create-header.tpl.php b/modules/custom/wh_petitions/templates/wh-petitions-create-header.tpl.php deleted file mode 100644 index 3b6b6c8d7..000000000 --- a/modules/custom/wh_petitions/templates/wh-petitions-create-header.tpl.php +++ /dev/null @@ -1,14 +0,0 @@ -
-
- -
-
- -
-
- -
-
- -
-
\ No newline at end of file diff --git a/modules/custom/wh_petitions/templates/wh-petitions-display-list-petition.tpl.php b/modules/custom/wh_petitions/templates/wh-petitions-display-list-petition.tpl.php deleted file mode 100644 index 3744d3600..000000000 --- a/modules/custom/wh_petitions/templates/wh-petitions-display-list-petition.tpl.php +++ /dev/null @@ -1,49 +0,0 @@ -
-
- -
- -
- - TRUE)); ?> - - TRUE); if (!empty($target)) { $atts['attributes'] = array('target' => $target); } ?> - - - - -
-
-
  
- - - - - - - - 8): ?> - - -
- - -
-
-
\ No newline at end of file diff --git a/modules/custom/wh_petitions/templates/wh-petitions-display-petition-info.tpl.php b/modules/custom/wh_petitions/templates/wh-petitions-display-petition-info.tpl.php deleted file mode 100644 index f61596b86..000000000 --- a/modules/custom/wh_petitions/templates/wh-petitions-display-petition-info.tpl.php +++ /dev/null @@ -1,68 +0,0 @@ - - -
- - -
See the response below.'); ?>
- - -
- -
- -

-

- -
-
- - -
-
-
- -
- -
- - - -
-
- array('class' => array('no-follow')))); ?> - -
-
- - -
-

-
-
- - - -
-
-

$end_date, '!total_needed' => $total_needed)); ?>

-
-
-
-

-
-
-
- -
- -
- - - - - -
- diff --git a/modules/custom/wh_petitions/templates/wh-petitions-display-signatures.tpl.php b/modules/custom/wh_petitions/templates/wh-petitions-display-signatures.tpl.php deleted file mode 100644 index e548a9066..000000000 --- a/modules/custom/wh_petitions/templates/wh-petitions-display-signatures.tpl.php +++ /dev/null @@ -1,39 +0,0 @@ - - $signature): ?> - - -
- - - - -
- -
-
-
-
- -
- - - -
- -
- -
- - - - $sigs_per_page)), $nice_url, array('query' => array('page' => ($page + 1), 'last' => $last_id), 'html' => TRUE, 'attributes' => array('class' => array('load-next', 'no-follow'), 'rel' => $petition_id))); ?> - - \ No newline at end of file diff --git a/modules/custom/wh_petitions/templates/wh-petitions-page-archived.tpl.php b/modules/custom/wh_petitions/templates/wh-petitions-page-archived.tpl.php deleted file mode 100644 index c23da402b..000000000 --- a/modules/custom/wh_petitions/templates/wh-petitions-page-archived.tpl.php +++ /dev/null @@ -1,3 +0,0 @@ -
- -
\ No newline at end of file diff --git a/modules/custom/wh_petitions/templates/wh-petitions-page-deleted.tpl.php b/modules/custom/wh_petitions/templates/wh-petitions-page-deleted.tpl.php deleted file mode 100644 index 006e1dd1b..000000000 --- a/modules/custom/wh_petitions/templates/wh-petitions-page-deleted.tpl.php +++ /dev/null @@ -1,6 +0,0 @@ -
-
-

- -

|

-
\ No newline at end of file diff --git a/modules/custom/wh_petitions/templates/wh-petitions-page-open-petitions.tpl.php b/modules/custom/wh_petitions/templates/wh-petitions-page-open-petitions.tpl.php deleted file mode 100644 index 567442156..000000000 --- a/modules/custom/wh_petitions/templates/wh-petitions-page-open-petitions.tpl.php +++ /dev/null @@ -1,63 +0,0 @@ -
-
    -
  • class="active">
  • - - -
- -
    - array('class' => 'active no-follow')); else $atts = array('attributes' => array('class' => 'no-follow')); ?> -
  • - array('class' => 'active no-follow')); else $atts = array('attributes' => array('class' => 'no-follow')); ?> -
  • -
  • - array("class" => "popup-title no-follow"))); ?> -
  • - - -
- - -
- -
-
-
- -
- - - -
- -
- -
- - - '' . $count . '', '!total' => $total)), "petitions/".$sort."/".($page+1)."/" . $cols . '/' . $issues . '/' . $search, array("html" => TRUE, "attributes" => array("class" => "clear show-more-petitions-bar no-follow"))); ?> - - - -
-
diff --git a/modules/custom/wh_petitions/templates/wh-petitions-page-petition.tpl.php b/modules/custom/wh_petitions/templates/wh-petitions-page-petition.tpl.php deleted file mode 100644 index 16f2f9ab1..000000000 --- a/modules/custom/wh_petitions/templates/wh-petitions-page-petition.tpl.php +++ /dev/null @@ -1,155 +0,0 @@ -
- array('class' => 'arrow')); - if (stripos($reported_link, 'http://') !== FALSE || stripos($reported_link, 'https://') !== FALSE) { $atts = array('attributes' => array('class' => 'arrow no-follow')); } - ?> -
' . ' ' . l(t('Learn More'), $reported_link, $atts); ?>
- - -
-
- -
- -
- - -
- -
- array('rel' => $petition_id, 'id' => 'button-sign-this-petition', 'class' => array('no-follow')))); ?> -
-
-

- - -
- -
-
-

- -
- $return_destination, 'attributes' => array('class' => array('no-follow'), 'id' => 'button-sign-in'))); ?> -
- $return_destination, 'attributes' => array('class' => array('no-follow'), 'id' => 'button-create-an-account'))); ?> -
-
-

click here for help.') ?>


- -
- -
-
-

-

-
- - - -
-
    -
  • - - -
- -
- array('id' => 'report-inappropriate-link', 'class' => array('no-follow')))); ?> - -
- -
-
- - -
- - - -
-
    -
  • - - -
-
-
- -
- -
- - $agency_name)); ?> - -
- -

- - -

- - - -
- - -
- - - -
- - - -
- - -
-
- '' . $signature_count . '', '!total' => '' . $signature_total . '')); ?> -
- - -
- - -
- -
-
-
diff --git a/modules/custom/wh_petitions/templates/wh-petitions-page-thank-you.tpl.php b/modules/custom/wh_petitions/templates/wh-petitions-page-thank-you.tpl.php deleted file mode 100644 index 828392623..000000000 --- a/modules/custom/wh_petitions/templates/wh-petitions-page-thank-you.tpl.php +++ /dev/null @@ -1,33 +0,0 @@ -
-
-

-

-
- -

- -

$email_address)); ?>

- -
-
-
-

$date, '!total_needed' => $total_needed)); ?>

-
-
-
-

-
1
-
-
-
- -

$total_needed, '!date_needed' => $date)); ?>

- -
-
    -
  • - - -
-
-
diff --git a/modules/custom/wh_petitions/templates/wh-petitions-page-user-dashboard.tpl.php b/modules/custom/wh_petitions/templates/wh-petitions-page-user-dashboard.tpl.php deleted file mode 100644 index cc41ea462..000000000 --- a/modules/custom/wh_petitions/templates/wh-petitions-page-user-dashboard.tpl.php +++ /dev/null @@ -1,28 +0,0 @@ -
-
$username)); ?>
-
- - -
-

- -
- - - -
-
-

- -
- - - -
-
-

- -
- -
-
\ No newline at end of file diff --git a/modules/custom/wh_petitions/wh_petitions.admin.inc b/modules/custom/wh_petitions/wh_petitions.admin.inc deleted file mode 100644 index 82cb51bf1..000000000 --- a/modules/custom/wh_petitions/wh_petitions.admin.inc +++ /dev/null @@ -1,1420 +0,0 @@ - '

' . t('Change petition and signature settings and text that displays on the site.') . '

', - ); - - // Petition Configuration Settings - $form['config'] = array( - '#type' => 'fieldset', - '#title' => t('Petition Configuration Settings'), - '#collapsible' => TRUE, - '#collapsed' => FALSE, - ); - $form['config']['wh_petitions_review_timeframe'] = array( - '#type' => 'textfield', - '#title' => t('Review Timeframe'), - '#description' => t('The number of days that a petition has to gather enough signatures to receive a response.'), - '#default_value' => variable_get('wh_petitions_review_timeframe', '30'), - '#required' => TRUE - ); - $form['config']['wh_petitions_public_signatures'] = array( - '#type' => 'textfield', - '#title' => t('Public Signatures'), - '#description' => t('The number of signatures a petition must gather in order to become public.'), - '#default_value' => variable_get('wh_petitions_public_signatures', '20'), - '#required' => TRUE - ); - $form['config']['wh_petitions_review_signatures'] = array( - '#type' => 'textfield', - '#title' => t('Response Signatures'), - '#description' => t('The number of signatures that trigger a petition to be reviewed for a response.'), - '#default_value' => variable_get('wh_petitions_review_signatures', '500'), - '#required' => TRUE - ); - $form['config']['wh_petitions_email_address'] = array( - '#type' => 'textfield', - '#title' => t('From Email Address'), - '#description' => t('From email address used in emails sent from the site (except Email to a Friend).'), - '#default_value' => variable_get('wh_petitions_email_address', ''), - '#required' => TRUE - ); - $form['config']['wh_petitions_abuse_flag_threshhold'] = array( - '#type' => 'textfield', - '#title' => t('Abuse Threshhold'), - '#description' => t('The number of report abuse flags that automatically remove a petition from display.'), - '#default_value' => variable_get('wh_petitions_abuse_flag_threshhold', '5'), - '#required' => TRUE - ); - - // Tooltips - $form['tooltips'] = array( - '#type' => 'fieldset', - '#title' => 'Tooltip texts', - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $form['tooltips']['wh_petitions_tooltip_title'] = array( - '#type' => 'textarea', - '#title' => t('Text for Title Tooltip'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_tooltip_title', '

Keep the title brief and compelling, this will be the first thing people see about this petition. Be sure the title clearly describes the goal of the petition. Double check your spelling, avoid using all capital letters, and avoid acronyms whenever possible.

'), - '#required' => TRUE - ); - $form['tooltips']['wh_petitions_tooltip_description'] = array( - '#type' => 'textarea', - '#title' => t('Text for Description Tooltip'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_tooltip_description', '

Start by clearly articulating a position, and then include additional information or research. Keep the petition description brief, no more than 800 characters, including spaces, are allowed.

Note: If you are starting your petition on behalf of an organization, please indicate that here.

'), - '#required' => TRUE - ); - $form['tooltips']['wh_petitions_tooltip_tags'] = array( - '#type' => 'textarea', - '#title' => t('Text for Keywords Tooltip'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_tooltip_tags', '

Keywords will help further define the issues addressed in the petition, and will make it easier for others to find it. The keywords should be short (one or two words), and should be descriptive of the content of the petition. Try to use no more than five keywords per petition. For example, if a petition is about energy policy, relevant keywords might be "clean energy," "solar power," or "oil."

'), - '#required' => TRUE - ); - $form['tooltips']['wh_petitions_tooltip_why'] = array( - '#type' => 'textarea', - '#title' => t('Text for WHY? Tooltip in the Sign Petition area'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_tooltip_why', '

Why Sign up?

'), - '#required' => TRUE - ); - $form['tooltips']['wh_petitions_tooltip_threshold'] = array( - '#type' => 'textarea', - '#title' => t('Text for Thresholds? Tooltip on the Petition Details page'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_tooltip_threshold', '

In order for a petition to be reviewed by the White House and for an official response to be issued, it must get 5,000 signatures in 30 days. That means it\'s up to you to build support for petitions you care about and gather more signatures. In addition, a petition must get 150 signatures in order to be publicly searchable on WhiteHouse.gov.

We the People is a brand new tool on WhiteHouse.gov, and we\'ve never tried anything like this before. Over time, we may need to adjust the petition signature thresholds, but we\'ll always let you know what the thresholds are.

'), - '#required' => TRUE - ); - - // Emails - $form['emails'] = array( - '#type' => 'fieldset', - '#title' => 'Email Texts', - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $form['emails']['wh_petitions_email_published_subject'] = array( - '#type' => 'textfield', - '#title' => t('Subject for the email sent when a petition is published'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_email_published_subject', ''), - '#required' => TRUE - ); - $form['emails']['wh_petitions_email_published_text'] = array( - '#type' => 'textarea', - '#title' => t('Text for the email sent when a petition is published'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_email_published_text', ''), - '#required' => TRUE - ); - $form['emails']['wh_petitions_published_email_address'] = array( - '#type' => 'textfield', - '#title' => t('New Petition Email Address'), - '#description' => t('Email Address to send new petitions notifications to.'), - '#default_value' => variable_get('wh_petitions_published_email_address', 'wethepeople@whitehouse.gov'), - '#required' => FALSE - ); - $form['emails']['wh_petitions_email_ready_response_subject'] = array( - '#type' => 'textfield', - '#title' => t('Subject for the email sent when a petition gets enough signatures to receive a response.'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_email_ready_response_subject', ''), - '#required' => TRUE - ); - $form['emails']['wh_petitions_email_ready_response_text'] = array( - '#type' => 'textarea', - '#title' => t('Text for the email sent when a petition gets enough signatures to receive a response.'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_email_ready_response_text', ''), - '#required' => TRUE - ); - $form['emails']['wh_petitions_email_forward_text'] = array( - '#type' => 'textarea', - '#title' => t('Text for the email sent when someone chooses to email a friend ( subject = petition title ).'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_email_forward_text', 'Dear Friends, - -I wanted to let you know about an official petition I have signed at WhiteHouse.gov. Will you add your name to mine? If this petition gets !signatures_needed signatures by !date_needed, the White House will review it and respond! - -You can view and sign the petition here: !shorturl - -Here\'s some more information about this petition: -!petition_description'), - '#required' => TRUE - ); - $form['emails']['wh_petitions_email_forward_response_text'] = array( - '#type' => 'textarea', - '#title' => t('Text for the email sent when someone chooses to email a friend - response ( subject = response title ).'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_email_forward_response_text', 'Dear Friends, - -You can read the response here: !shorturl'), - '#required' => TRUE - ); - - // Homepage Blocks - $form['homepage'] = array( - '#type' => 'fieldset', - '#title' => 'Homepage video/block texts/header text', - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $form['homepage']['wh_petitions_homepage_left'] = array( - '#type' => 'textarea', - '#title' => t('Homepage - Lower left block'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_homepage_left', '

What\'s this all about?

The right to petition your government is guaranteed by the First Amendment of the United States Constitution.

Learn more about petitions'), - '#required' => TRUE - ); - $form['homepage']['wh_petitions_homepage_center'] = array( - '#type' => 'textarea', - '#title' => t('Homepage - Lower middle block'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_homepage_center', '

It\'s easy to participate

Discovering, creating and signing petitions is simple. Find out how to get started.

Step-by-step guide'), - '#required' => TRUE - ); - $form['homepage']['wh_petitions_homepage_right'] = array( - '#type' => 'textarea', - '#title' => t('Homepage - Lower right block'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_homepage_right', ''), - '#required' => FALSE - ); - $form['homepage']['wh_petitions_homepage_content'] = array( - '#type' => 'textarea', - '#title' => t('Homepage - Middle content area (video)'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_homepage_content', ' '), - '#required' => TRUE - ); - $form['homepage']['wh_petitions_top_right_text'] = array( - '#type' => 'textarea', - '#title' => t('Homepage - Top Right Text'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_top_right_text', 'White House petitions is
a brand new platform for you
to tell the Obama Administration about the issues that matter to you.'), - '#required' => TRUE - ); - - // Block Bodies - $form['blocks'] = array( - '#type' => 'fieldset', - '#title' => 'Block Body Texts', - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $form['blocks']['wh_petitions_create_account_block_text'] = array( - '#type' => 'textarea', - '#title' => t('Text for the Create A WH Account block'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_create_account_block_text', ''), - '#required' => TRUE - ); - $form['blocks']['wh_petitions_email_updates_block_text'] = array( - '#type' => 'textarea', - '#title' => t('Text for the Email Updates block'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_email_updates_block_text', t('Sign Up for Updates from President Obama and Other Senior Officials.')), - '#required' => TRUE - ); - $form['blocks']['wh_petitions_history_block_text'] = array( - '#type' => 'textarea', - '#title' => t('Text for the Petition History block'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_history_block_text', ''), - '#required' => TRUE - ); - - // By The Numbers block - $form['numbers'] = array( - '#type' => 'fieldset', - '#title' => 'By The Numbers block config', - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $form['numbers']['wh_petitions_numbers_open_petitions'] = array( - '#type' => 'checkbox', - '#title' => t('Show number of Open Petitions'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_numbers_open_petitions', ''), - '#required' => FALSE - ); - $form['numbers']['wh_petitions_numbers_responses'] = array( - '#type' => 'checkbox', - '#title' => t('Show number of Responses'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_numbers_responses', ''), - '#required' => FALSE - ); - $form['numbers']['wh_petitions_numbers_signatures_24'] = array( - '#type' => 'checkbox', - '#title' => t('Total Signatures in Past 24 Hours'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_numbers_signatures_24', ''), - '#required' => FALSE - ); - - // Helpful Hints block - $form['hints'] = array( - '#type' => 'fieldset', - '#title' => 'Helpful Hints block texts', - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $form['hints']['wh_petitions_hints_create_petition'] = array( - '#type' => 'textarea', - '#title' => t('Helpful Hints - Create A Petition'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_hints_create_petition', ''), - '#required' => FALSE - ); - $form['hints']['wh_petitions_hints_open_petitions'] = array( - '#type' => 'textarea', - '#title' => t('Helpful Hints - Open Petitions'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_hints_open_petitions', ''), - '#required' => FALSE - ); - $form['hints']['wh_petitions_hints_petition_detail'] = array( - '#type' => 'textarea', - '#title' => t('Helpful Hints - Petition Detail'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_hints_petition_detail', ''), - '#required' => FALSE - ); - $form['hints']['wh_petitions_hints_responses'] = array( - '#type' => 'textarea', - '#title' => t('Helpful Hints - Responses'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_hints_responses', ''), - '#required' => FALSE - ); - $form['hints']['wh_petitions_hints_response_detail'] = array( - '#type' => 'textarea', - '#title' => t('Helpful Hints - Response Detail'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_hints_response_detail', ''), - '#required' => FALSE - ); - $form['hints']['wh_petitions_hints_dashboard'] = array( - '#type' => 'textarea', - '#title' => t('Helpful Hints - User Dashboard'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_hints_dashboard', ''), - '#required' => FALSE - ); - $form['hints']['wh_petitions_hints_misc'] = array( - '#type' => 'textarea', - '#title' => t('Helpful Hints - Misc Pages'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_hints_misc', ''), - '#required' => FALSE - ); - - // Misc Text - $form['misc'] = array( - '#type' => 'fieldset', - '#title' => 'Miscellaneous Text for Modals and Pages', - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $form['misc']['wh_petitions_delete_modal_text'] = array( - '#type' => 'textarea', - '#title' => t('Text for the Delete Petition modal window'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_delete_modal_text', ''), - '#required' => FALSE - ); - $form['misc']['wh_petitions_archived_page_text'] = array( - '#type' => 'textarea', - '#title' => t('Text for the Archived Petition page'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_archived_page_text', '

Sorry, this petition has expired. It did not reach the required thresholds within the allotted timeframe.

'), - '#required' => FALSE - ); - $form['misc']['wh_petitions_delete_page_text'] = array( - '#type' => 'textarea', - '#title' => t('Text for the Delete Petition page'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_delete_page_text', 'The petition draft is no longer available in your account.'), - '#required' => FALSE - ); - $form['misc']['wh_petitions_report_modal_text'] = array( - '#type' => 'textarea', - '#title' => t('Text for the Report Petition modal window'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_report_modal_text', '

Click the button below to report this petition as inappropriate. Are you sure you want to do this?

'), - '#required' => FALSE - ); - $form['misc']['wh_petitions_comment_modal_text'] = array( - '#type' => 'textarea', - '#title' => t('Text for the Comment modal window'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_comment_modal_text', ''), - '#required' => FALSE - ); - $form['misc']['wh_petitions_flagged_page_text'] = array( - '#type' => 'textarea', - '#title' => t('Text for the Flagged ( Removed ) Petition page'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_flagged_page_text', 'Sorry, this petition has been removed from the system for violating our terms of participation.'), - '#required' => FALSE - ); - $form['misc']['wh_petitions_flagged_page_creator_text'] = array( - '#type' => 'textarea', - '#title' => t('Text for the Flagged ( Removed ) Petition page (displays to petition creator only). If using a link, please add a class of "no-follow" to the tag'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_flagged_page_creator_text', ''), - '#required' => FALSE - ); - $form['misc']['wh_petitions_no_responses_page_text'] = array( - '#type' => 'textarea', - '#title' => t('Text for the Responses page when there are no responses present.'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_no_responses_page_text', ''), - '#required' => FALSE - ); - $form['misc']['wh_petitions_use_no_responses_page'] = array( - '#type' => 'checkbox', - '#title' => t('Use the No Responses page text from above instead of the normal responses page.'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_use_no_responses_page', ''), - '#required' => FALSE - ); - - // Links - $form['links'] = array( - '#type' => 'fieldset', - '#title' => 'Links to static pages', - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $form['links']['wh_petitions_learn_more_link'] = array( - '#type' => 'textfield', - '#title' => t('Learn about Petition Goals (petition detail page)'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_learn_more_link', ''), - '#required' => FALSE - ); - $form['links']['wh_petitions_participate_rules_link'] = array( - '#type' => 'textfield', - '#title' => t('Participation Rules'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_participate_rules_link', ''), - '#required' => FALSE - ); - $form['links']['wh_petitions_read_rules_link'] = array( - '#type' => 'textfield', - '#title' => t('Read the Rules (archived petitions)'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_read_rules_link', ''), - '#required' => FALSE - ); - $form['links']['wh_petitions_reported_as_inappropriate_link'] = array( - '#type' => 'textfield', - '#title' => t('Reported as Inappropriate bar on petition detail page'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_reported_as_inappropriate_link', ''), - '#required' => FALSE - ); - - //Settings related to petition administration - $form['petition_admin'] = array( - '#type' => 'fieldset', - '#title' => t('Petition Administration Settings'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $form['petition_admin']['wh_petitions_compliance_review_threshold'] = array( - '#type' => 'textfield', - '#title' => t('Compliance Review Threshold'), - '#description' => t('The number of signatures on a petition which will flag it for Compliance Review.'), - '#default_value' => variable_get('wh_petitions_compliance_review_threshold', '3'), - '#required' => TRUE, - ); - $form['petition_admin']['wh_petitions_compliance_reviewer_emails'] = array( - '#type' => 'textarea', - '#title' => t('Compliance Reviewer Email Addresses'), - '#description' => t('Enter a comma-separated list of email addresses who should be notified when a petition passes the compliance review threshold.'), - '#default_value' => variable_get('wh_petitions_compliance_reviewer_emails', 'wethepeople@whitehouse.gov'), - '#required' => FALSE, - ); - $form['petition_admin']['wh_petitions_review_threshold_passed_subject'] = array( - '#type' => 'textfield', - '#title' => t('Subject for the email sent when a petition receives enough signatures to pass the compliance review threshold.'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_review_threshold_passed_subject', 'Petition ready for compliance review'), - '#required' => TRUE - ); - $form['petition_admin']['wh_petitions_review_threshold_passed_text'] = array( - '#type' => 'textarea', - '#title' => t('Text for the email sent when a petition receives enough signatures to pass the compliance review threshold.'), - '#description' => '', - '#default_value' => variable_get('wh_petitions_review_threshold_passed_text', 'The petition titled "!petition_title" has passed the number of signatures necessary for compliance review. - -You can review and, if necessary, remove this petition at the following URL: !petition_edit_link - '), - '#required' => TRUE - ); - $form['petition_admin']['wh_petitions_admin_removal_notification_emails'] = array( - '#type' => 'textarea', - '#title' => t('Petition Removal Notification Email Addresses'), - '#description' => t('Enter a comma-separated list of email addresses which should received notices when a petition is removed.'), - '#default_value' => variable_get('wh_petitions_admin_removal_notification_emails', ''), - '#required' => FALSE, - ); - - $form['#validate'][] = 'wh_petitions_admin_petition_settings_validate'; - - return system_settings_form($form, FALSE); -} - -/** - * Validates the submitted petition settings form to make sure all values were integers. - */ -function wh_petitions_admin_petition_settings_validate($form, &$form_state) { - if (!is_numeric($form_state['values']['wh_petitions_review_timeframe'])) { - form_set_error('wh_petitions_review_timeframe', t("Please use integer values.")); - } - if (!is_numeric($form_state['values']['wh_petitions_public_signatures'])) { - form_set_error('wh_petitions_public_signatures', t("Please use integer values.")); - } - if (!is_numeric($form_state['values']['wh_petitions_review_signatures'])) { - form_set_error('wh_petitions_review_signatures', t("Please use integer values.")); - } -} - -/** - * Petition Admin Dashboard page - * - * Allows admins to search for petitions based on: - * -Petition Status ( default: Under Review ) - * -Response Status ( default: Pending ) - * -Date Range - * -Bookmarked petitions by current user - * -Featured petitions - * - * Admins from this page can bookmark or feature petitions, remove them from lists so they're only available by direct url, override flagged status, or go to the petition - * edit screen for more options. - * - * The petition edit screen shows all the information associated with a petition, plus allows administrators to edit certain information and apply a response. - */ -function wh_petitions_admin_petitions() { - global $user; - drupal_add_js(drupal_get_path('module', 'wh_petitions') . "/wh_petitions.admin.js", array('scope' => 'header', 'weight' => 50)); - - // Retrieve filter settings - $session_settings = isset($_SESSION['petition_overview_filter']) ? $_SESSION['petition_overview_filter'] : array(); - $submitted = isset($_GET['submitted']) && is_numeric($_GET['submitted']) && $_GET['submitted'] == 1; - - if ($submitted) { - foreach($_GET as $key => $value) { - $value = check_plain($value); - - if (is_numeric($value)) { - $value = (int) $value; - } - elseif (stripos($value, ',')) { - $values = explode(',', $value); - $final_values = array(); - - foreach($values as $value_item) { - $final_values[] = is_numeric($value_item) ? (int) $value_item : $value_item; - } - - $value = $final_values; - } - - $session_settings[$key] = $value; - } - } - - // Results per page and page we're on - $results_per_page = 25; - $page = 0; - if (!empty($_GET['page'])) { - $get_page = preg_replace('/[^0-9]/', '', $_GET['page']); - if (is_int((int)$get_page)) { - $page = intval($get_page); - } - } - $offset = $page * $results_per_page; - - // Filter Fieldset - $form['filters'] = array( - '#type' => 'fieldset', - '#title' => t('Choose filters'), - '#theme' => 'exposed_filters__node', - ); - - //Petition Id - $default_petition_id = isset($session_settings['petition_id']) ? check_plain($session_settings['petition_id']) : ''; - $form['filters']['petition_id'] = array( - '#type' => 'textfield', - '#title' => t('Petition ID'), - '#description' => t('The long, alphanumeric ID of the petition'), - '#default_value' => $default_petition_id, - '#size' => 25, - '#maxlength' => 25, - ); - - //Petition Id - $default_short_url = isset($session_settings['short_url']) ? check_plain($session_settings['short_url']) : ''; - $form['filters']['short_url'] = array( - '#type' => 'textfield', - '#title' => t('Petition Short URL'), - '#description' => t('The wh.gov url of the petition, including the http://. For example, http://wh.gov/xxx'), - '#default_value' => $default_short_url, - '#size' => 25, - '#maxlength' => 25, - ); - - //Petition Keyworkds - if (isset($session_settings['petition_keywords'])) { - $default_petition_keywords = is_array($session_settings['petition_keywords']) ? $session_settings['petition_keywords'] : array($session_settings['petition_keywords']); - } - else { - $default_petition_keywords = array(); - } - $form['filters']['petition_keywords'] = array( - '#type' => 'textfield', - '#title' => t('Petition Keywords'), - '#description' => t('Enter a comma-separated list of keywords to search against the petition title and body'), - '#default_value' => implode(',', $default_petition_keywords), - '#size' => 25, - ); - - // Petition Statuses - $petition_statuses = array(); - $status_array = array(WH_PETITION_STATUS_DRAFT, WH_PETITION_STATUS_PRIVATE, WH_PETITION_STATUS_PUBLIC, WH_PETITION_STATUS_CLOSED, WH_PETITION_STATUS_UNDER_REVIEW, WH_PETITION_STATUS_REVIEWED, WH_PETITION_STATUS_FLAGGED); - foreach ($status_array as $status) { - $petition_statuses[$status] = wh_petitions_display_status_name($status); - } - if (isset($session_settings['petition_status'])) { - $default_petition_status = is_array($session_settings['petition_status']) ? $session_settings['petition_status'] : array($session_settings['petition_status']); - } - else { - $default_petition_status = array(WH_PETITION_STATUS_UNDER_REVIEW); - } - $form['filters']['petition_status'] = array( - '#type' => 'select', - '#options' => $petition_statuses, - '#title' => t('Petition Status'), - '#default_value' => $default_petition_status, - '#multiple' => TRUE, - ); - - // Response Statuses - $response_statuses = array(); - $status_array = array(WH_PETITION_RESPONSE_STATUS_UNANSWERED, WH_PETITION_RESPONSE_STATUS_PENDING, WH_PETITION_RESPONSE_STATUS_ANSWERED); - foreach ($status_array as $status) { - $response_statuses[$status] = wh_petitions_display_status_name($status, 'response'); - } - if (isset($session_settings['response_status'])) { - $default_response_status = is_array($session_settings['response_status']) ? $session_settings['response_status'] : array($session_settings['response_status']); - } - else { - $default_response_status = array(WH_PETITION_RESPONSE_STATUS_PENDING); - } - $form['filters']['response_status'] = array( - '#type' => 'select', - '#options' => $response_statuses, - '#title' => t('Response Status'), - '#default_value' => $default_response_status, - '#multiple' => TRUE, - ); - - // Date Published After - $default_pub_after = isset($session_settings['published_after']) ? check_plain($session_settings['published_after']) : ''; - $form['filters']['published_after'] = array( - '#type' => 'textfield', - '#title' => t('Published After:'), - '#size' => 20, - '#description' => t('Format: YYYY-MM-DD'), - '#default_value' => $default_pub_after, - ); - - // Date Published Before - $default_pub_before = isset($session_settings['published_before']) ? check_plain($session_settings['published_before']) : ''; - $form['filters']['published_before'] = array( - '#type' => 'textfield', - '#title' => t('Published Before:'), - '#size' => 20, - '#description' => t('Format: YYYY-MM-DD'), - '#default_value' => $default_pub_before, - ); - - // Whether to only show bookmarked - $default_bookmarked = isset($session_settings['show_bookmarked']) && is_numeric($session_settings['show_bookmarked']) ? $session_settings['show_bookmarked'] : 0; - $form['filters']['show_bookmarked'] = array( - '#type' => 'checkbox', - '#title' => t('Show Bookmarked:'), - '#default_value' => $default_bookmarked, - '#suffix' => '

', - ); - - // Whether to only show featured - $default_featured = isset($session_settings['show_featured']) && is_numeric($session_settings['show_featured']) ? $session_settings['show_featured'] : 0; - $form['filters']['show_featured'] = array( - '#type' => 'checkbox', - '#title' => t('Show Featured:'), - '#default_value' => $default_featured, - '#suffix' => '

', - ); - - // Whether to only show hidden - $default_hidden = isset($session_settings['show_hidden']) && is_numeric($session_settings['show_hidden']) ? $session_settings['show_hidden'] : 0; - $form['filters']['show_hidden'] = array( - '#type' => 'checkbox', - '#title' => t('Show Removed From Lists:'), - '#default_value' => $default_hidden, - '#suffix' => '

', - ); - - // Whether to only show petitions that have received flags - $default_flags = isset($session_settings['show_flags']) && is_numeric($session_settings['show_flags']) ? $session_settings['show_flags'] : 0; - $form['filters']['show_flags'] = array( - '#type' => 'checkbox', - '#title' => t('Show Only With Flags:'), - '#default_value' => $default_flags, - '#suffix' => '

', - ); - - // Filter Button - $form['filters']['actions'] = array( - '#type' => 'actions', - '#attributes' => array('class' => array('container-inline')), - ); - $form['filters']['actions']['submit'] = array( - '#type' => 'submit', - '#value' => t('Filter'), - ); - $form['filters']['actions']['reset'] = array( - '#type' => 'submit', - '#value' => t('Reset'), - ); - - // Batch Keyword Form - $form['options'] = array( - '#type' => 'fieldset', - '#title' => t('Batch Apply Keywords'), - '#attributes' => array('class' => array('container-inline')), - ); - $form['options']['private_tags'] = array( - '#type' => 'textfield', - '#title' => t('Private Keywords'), - '#default_value' => '', - '#size' => 25, - ); - $form['options']['submit'] = array( - '#type' => 'submit', - '#value' => t('Update'), - '#validate' => array('wh_petitions_admin_petitions_tags_validate'), - '#submit' => array('wh_petitions_admin_petitions_tags_submit'), - '#suffix' => '     ( ' . t('Separate keywords with a comma') . ' )', - ); - - // Build the sortable table header. - $header = array( - 'title' => array('data' => t('Title'), 'field' => 'title'), - 'signature_count' => array('data' => t('Signatures'), 'field' => 'signature_count'), - 'petition_status' => t('Petition Status'), - 'response_status' => t('Response Status'), - 'flags' => t('Abuse Flags'), - 'reached_ready' => array('data' => t('Date Ready For Response'),'field' => 'reached_ready'), - 'actions' => t('Actions'), - ); - - // Build the query - $conn = wh_petitions_mongo_petition_connection(); - $query = array(); - if (!empty($default_petition_id)) { - $query['_id'] = new MongoId($default_petition_id); - } - if (!empty($default_short_url)) { - $query['short_url'] = $default_short_url; - } - - //keyword searching - if (!empty($default_petition_keywords)) { - $query_or = array(); - $terms = array(); - //set all terms to lowercase - foreach ($default_petition_keywords as $keyword) { - $kwd = trim(strtolower($keyword)); - $terms[] = $kwd; - } - $terms2 = array('horse', 'iran'); - //append the field elements to the query array - foreach (array('title_keywords', 'body_keywords') as $field) { - $query_or[] = array($field => array('$in' => $terms)); - } - $query['$or'] = $query_or; - } - - if (!empty($default_petition_status)) { - $query['petition_status'] = array('$in' => $default_petition_status); - } - if (!empty($default_response_status)) { - $query['response_status'] = array('$in' => $default_response_status); - } - if (!empty($default_pub_after)) { - $query['published'] = array('$gt' => (int)strtotime($default_pub_after)); - } - if (!empty($default_pub_before)) { - $query['published'] = array('$lt' => (int)strtotime($default_pub_before)); - } - if (!empty($default_bookmarked)) { - $query['bookmarked'] = array('$in' => array((int)$user->uid)); - } - if (!empty($default_featured)) { - $query['featured'] = 1; - } - if ($default_hidden == 1) { - $query['hidden'] = 1; - } - if ($default_flags == 1) { - $query['abuse_count'] = array('$gt' => 0); - } - - // Sort - $sort_query = array(); - if (empty($_GET['sort']) || empty($_GET['order'])) { - if ($default_flags == 1) { - $sort_query['abuse_count'] = -1; - } - else { - $sort_query['reached_ready'] = -1; - } - } - // For the table sorts we need to catch the sort from the url and apply it here ( since we're querying mongo instead of building a sql query through drupal's interface, which - // would do it for us. - else { - $asc_desc = -1; - if ($_GET['sort'] == 'asc') { - $asc_desc = 1; - } - - switch($_GET['order']) { - case t('Title'): - $sort_query['title'] = $asc_desc; - break; - case t('Signatures'): - $sort_query['signature_count'] = $asc_desc; - break; - case t('Date Ready For Response'): - $sort_query['reached_ready'] = $asc_desc; - break; - } - } - $retrieve_fields = array('title', 'signature_count', 'reached_ready', 'bookmarked', 'petition_status', 'abuse_count', 'response_status', 'featured', 'hidden', 'nice_url'); - - // If this is a specific edit petition page instead of the list of petitions, the second argument will be the petition id. If this is set, show the batch keywords, plus - // apply response, and get more information about the petition to display at the bottom. - $arg2 = arg(2); - if (!empty($arg2)) { - array_push($retrieve_fields, 'body', 'abuse_count', 'uid', 'user_tags', 'private_tags', 'review_timeframe', 'public_signatures', 'response_signatures', 'published', 'reached_public', 'closed'); - - // Link to return to the petition list - $form['filters'] = array( - '#type' => 'markup', - '#markup' => '
' . l(t('Return To All Petitions'), 'admin/petitions') . '
', - ); - - // Apply Response Form - $form['apply'] = array( - '#type' => 'fieldset', - '#title' => t('Apply Response To This Petition'), - '#attributes' => array('class' => array('container-inline')), - ); - $form['apply']['response_title'] = array( - '#type' => 'textfield', - '#title' => t('Response Title'), - '#size' => 60, - '#maxlength' => 128, - '#default_value' => '', - '#autocomplete_path' => 'response-autocomplete', - ); - $form['apply']['intro'] = array( - '#type' => 'textarea', - '#title' => t('Response Introduction'), - '#rows' => 5, - '#cols' => 40, - '#prefix' => '
', - '#default_value' => '', - ); - $form['apply']['apply_petition_id'] = array( - '#type' => 'hidden', - '#value' => check_plain($arg2), - ); - $form['apply']['submit'] = array( - '#type' => 'submit', - '#value' => t('Apply'), - '#validate' => array('wh_petitions_admin_petitions_apply_validate'), - '#submit' => array('wh_petitions_admin_petitions_apply_submit'), - ); - - //determine if we're getting a mongo petition id or a short url in arg2 - if (strlen($arg2) <= 5) { - //if the key is this short, it's most likely a short url rather than a mongo id - $query = array( - 'short_url' => 'http://wh.gov/' . check_plain($arg2), //concat the arg2 with our short url base - ); - } - else { - $query = array( - '_id' => new MongoId($arg2), - ); - } - $results = $conn->find($query, $retrieve_fields); - } - // Query all the results instead of the single petition - else { - $results = $conn->find($query, $retrieve_fields)->sort($sort_query)->skip($offset)->limit($results_per_page); - } - - // Iterate through the results and construct each line for the table - $options = array(); - foreach ($results as $res) { - $id = $res['_id']->__toString(); - - // Determine if we need to remove the 'apply response' form - if (!empty($arg2)) { - if (!(!empty($res['reached_ready']) && $res['response_status'] != WH_PETITION_RESPONSE_STATUS_ANSWERED && $res['petition_status'] == WH_PETITION_STATUS_UNDER_REVIEW)) { - unset($form['apply']); - } - } - - // When they reached ready for a response. Should only show a date if it has reached ready. - $ready = ''; - if ($res['reached_ready']) { - $ready = date('M d, Y', $res['reached_ready']); - } - - // Bookmark link - $bookmark = '
'; - if (!empty($res['bookmarked'])) { - if (in_array((int)$user->uid, $res['bookmarked'])) { - $bookmark = ''; - } - } - - // Feature link - $featured = ''; - if ($res['featured']) { - $featured = ''; - } - - // Flag ( Remove from Site ) - $hidden_link = ''; - if ($res['petition_status'] == WH_PETITION_STATUS_FLAGGED) { - $hidden_link = ''; - } - - $action_string = $bookmark . ' | ' . $featured . ' | ' . $hidden_link; - $action_string .= ' | ' . l('Download Signature List', 'admin/petitions/download_signatures/' . check_plain($id), array('attributes' => array('target' => '_blank'))); - $action_string .= ' | ' . l('Edit', 'admin/petitions/' . check_plain($id)); - - - // Add the line for this petition to the table - $options[$id] = array( - 'title' => l($res['title'], $res['nice_url'], array('attributes' => array('target' => '_blank'))), - 'signature_count' => wh_petitions_format_number($res['signature_count']), - 'petition_status' => '
' . wh_petitions_display_status_name($res['petition_status']) . '
', - 'response_status' => '
' . wh_petitions_display_status_name($res['response_status'], 'response') . '
', - 'flags' => !empty($res['abuse_count']) ? wh_petitions_format_number($res['abuse_count']) : 0, - 'reached_ready' => $ready, - 'actions' => $action_string, - ); - } - - // Find totals to feed to the pager. - $page_total = 1; - $result_count = 0; - if (!empty($options)) { - $result_count = $conn->find($query)->count(); - $page_total = ceil($result_count / $results_per_page); - } - - // Compose the table - $form['petitions'] = array( - '#type' => 'tableselect', - '#header' => $header, - '#options' => $options, - '#empty' => t('No petitions available.'), - ); - - // Initialize the pager - pager_default_initialize($result_count, $results_per_page); - $form['pager'] = array('#markup' => theme('pager')); - - // If this is a single result, display extra information about the petition - if (!empty($arg2)) { - - $creator = user_load(intval($res['uid'])); - $creator_name_id = $creator->profile_last_name . ', ' . $creator->profile_first_name . ' (' . $creator->uid . ')'; - - $markup = ''; - $markup .= '

' . t('Description:') . ' ' . wh_petitions_format_description($res['body']) . '

 

'; - - //fieldset with details from the user record - $markup .= '
'; - $markup .= '' . t('Petition Creator') . ''; - $markup .= '
'; - $markup .= '

' . t('Name (UID): ') . l($creator_name_id, 'user/' . $creator->uid) . '

'; - $markup .= '

' . t("Email: ") . $creator->mail . '

'; - $markup .= '
'; - $markup .= '
'; - - $markup .= '

' . t('Abuse Flags:') . '' . $res['abuse_count'] . '

'; - $markup .= '

' . t('User Keywords:') . ' ' . check_plain(implode(', ', $res['user_tags'])) . '

'; - $markup .= '

' . t('Private Keywords:') . ' ' . check_plain(implode(', ', $res['private_tags'])) . '

'; - $markup .= '

' . t('Review Timeframe') . ' ' . intval($res['review_timeframe']) . ' Days

'; - $markup .= '

' . t('Signatures for Public') . ' ' . intval($res['public_signatures']) . ' Days

'; - $markup .= '

' . t('Signatures for Response') . ' ' . intval($res['response_signatures']) . ' Days

'; - if (!empty($res['published'])) { - $markup .= '

' . t('Published Date:') . ' ' . date('M d, Y', $res['published']) . '

'; - } - if (!empty($res['reached_public'])) { - $markup .= '

' . t('Reached Public:') . ' ' . date('M d, Y', $res['reached_public']) . '

'; - } - if (!empty($res['reached_ready'])) { - $markup .= '

' . t('Ready for Response:') . ' ' . date('M d, Y', $res['reached_ready']) . '

'; - } - if (!empty($res['closed'])) { - $markup .= '

' . t('Archived Date:') . ' ' . date('M d, Y', $res['closed']) . '

'; - } - $form['petition'] = array( - '#type' => 'markup', - '#markup' => $markup, - ); - } - - $form['#submit'][] = 'wh_petitions_admin_petitions_submit'; - return $form; -} - -/** - * Adds new filter selections to the session - * Note: This needs to be the last submit handler called as it issues a - * drupal_goto. - */ -function wh_petitions_admin_petitions_submit($form, &$form_state) { - // On Reset go to petitions admin with no GET variables. - if ($form_state['clicked_button']['#value'] == 'Reset') { - drupal_goto('admin/petitions'); - } - - $filter_values = array(); - - if (!empty($form_state['values']['petition_id'])) { - $filter_values['petition_id'] = $form_state['values']['petition_id']; - } - - if (!empty($form_state['values']['short_url'])) { - $filter_values['short_url'] = $form_state['values']['short_url']; - } - - if (!empty($form_state['values']['petition_keywords'])) { - $filter_values['petition_keywords'] = $form_state['values']['petition_keywords']; - } - - if (!empty($form_state['values']['petition_status'])) { - $filter_values['petition_status'] = implode(',', $form_state['values']['petition_status']); - } - - if (!empty($form_state['values']['response_status'])) { - $filter_values['response_status'] = implode(',', $form_state['values']['response_status']); - } - - if (!empty($form_state['values']['published_after'])) { - $filter_values['published_after'] = $form_state['values']['published_after']; - } - - if (!empty($form_state['values']['published_before'])) { - $filter_values['published_before'] = $form_state['values']['published_before']; - } - - if (!empty($form_state['values']['show_bookmarked'])) { - $filter_values['show_bookmarked'] = $form_state['values']['show_bookmarked']; - } - - if (!empty($form_state['values']['show_featured'])) { - $filter_values['show_featured'] = $form_state['values']['show_featured']; - } - - if (!empty($form_state['values']['show_hidden'])) { - $filter_values['show_hidden'] = $form_state['values']['show_hidden']; - } - - if (!empty($form_state['values']['show_flags'])) { - $filter_values['show_flags'] = $form_state['values']['show_flags']; - } - - $filter_values['submitted'] = TRUE; - - drupal_goto('admin/petitions', array('query' => $filter_values)); -} - -/** - * Form validate function for the Batch Apply Keywords - */ -function wh_petitions_admin_petitions_tags_validate($form, &$form_state) { - if (empty($form_state['values']['private_tags'])) { - form_set_error('private_tags', t('Please enter at least one keyword.')); - } -} - -/** - * Form validate function for the Apply Response - */ -function wh_petitions_admin_petitions_apply_validate($form, &$form_state) { - if (empty($form_state['values']['response_title'])) { - form_set_error('response_title', t('Please enter a response title.')); - } -} - -/** - * Submit function for the Batch Apply Keywords - */ -function wh_petitions_admin_petitions_tags_submit($form, &$form_state) { - $conn = wh_petitions_mongo_petition_connection(); - - // Get the private keywords - $tags = explode(', ', $form_state['values']['private_tags']); - for ($i=0;$i $value) { - if ($value > 0) { - $petition = wh_petitions_load_slim_petition($conn, $id, array('private_tags')); - $petition['private_tags'] = array_merge($petition['private_tags'], $tags); - $petition['private_tags'] = array_unique($petition['private_tags']); - - $conn->update( - array('_id' => new MongoId($id)), - array('$set' => array('private_tags' => $petition['private_tags'])) - ); - } - } - } - // We have a single petition, apply keywords to that one ( edit petition page ) - elseif (!empty($form_state['values']['petition_id'])) { - $petition = wh_petitions_load_slim_petition($conn, $form_state['values']['petition_id'], array('private_tags')); - $petition['private_tags'] = array_merge($petition['private_tags'], $tags); - $petition['private_tags'] = array_unique($petition['private_tags']); - $conn->update( - array('_id' => new MongoId($form_state['values']['petition_id'])), - array('$set' => array('private_tags' => $petition['private_tags'])) - ); - } - } -} - -/** - * Submit function for the Apply Response - */ -function wh_petitions_admin_petitions_apply_submit($form, &$form_state) { - $pet_conn = wh_petitions_mongo_petition_connection(); - $res_conn = wh_response_mongo_response_connection(); - - $nid = ''; - $response_title = $form_state['values']['response_title']; - preg_match('/^(?:\s*|(.*) )?\[\s*(.+)\s*\]$/', $response_title, $matches); - if (!empty($matches[2])) { - $nid = intval($matches[2]); - } - $petition_id = $form_state['values']['apply_petition_id']; - - if (!empty($nid) && !empty($petition_id)) { - // Verify it's not already part of the node ( trying to attach twice ) - $obj = array(); - $obj = wh_response_load_petition_response($res_conn, $nid, $petition_id); - if (empty($obj) && !empty($nid)) { - // Verify this petition can be attached to this node. ( reached_ready > 0, no response already, UNDER_REVIEW status ) - $petition_obj = array(); - $petition_obj = wh_petitions_load_petition($pet_conn, $petition_id); - if (!empty($petition_obj['reached_ready']) && $petition_obj['response_status'] != WH_PETITION_RESPONSE_STATUS_ANSWERED && $petition_obj['petition_status'] == WH_PETITION_STATUS_UNDER_REVIEW) { - $obj = wh_response_default_petition_relationship(); - $obj['petition'] = $petition_id; - $obj['intro'] = $form_state['values']['intro']; - $obj['nid'] = $nid; - - // Set the statuses on the petition to answered and reviewed - if (wh_response_save_petition_response($res_conn, $obj)) { - $petition_obj['response_status'] = WH_PETITION_RESPONSE_STATUS_ANSWERED; - $petition_obj['petition_status'] = WH_PETITION_STATUS_REVIEWED; - $petition_obj['response_id'] = $nid; - wh_petitions_save_petition($pet_conn, $petition_obj); - } - } - } - } -} - -/** - * Callback function for the Bookmark/Un-Bookmark ajax request - */ -function wh_petitions_bookmark_petitions($petition_id) { - global $user; - - if (!empty($petition_id) && !empty($user->uid) && user_access('administer petitions')) { - $conn = wh_petitions_mongo_petition_connection(); - $petition = array(); - $petition = wh_petitions_load_slim_petition($conn, $petition_id, array('bookmarked')); - if (!in_array((int)$user->uid, $petition['bookmarked'])) { - array_push($petition['bookmarked'], (int)$user->uid); - $conn->update( - array('_id' => $petition['_id']), - array('$set' => array('bookmarked' => $petition['bookmarked'])) - ); - print '' . t('Un-Bookmark') . ''; - exit; - } - else { - $size = sizeof($petition['bookmarked']); - $new_array = array(); - for ($i=0; $i<$size; $i++) { - if ($user->uid != $petition['bookmarked'][$i]) { - array_push($new_array, $petition['bookmarked'][$i]); - } - } - $petition['bookmarked'] = $new_array; - $conn->update( - array('_id' => $petition['_id']), - array('$set' => array('bookmarked' => $petition['bookmarked'])) - ); - print '' . t('Bookmark') . ''; - exit; - } - } - - print ''; -} - -/** - * Callback function for the Feature/Un-Feature ajax request - */ -function wh_petitions_feature_petitions($petition_id) { - global $user; - - if (!empty($petition_id) && !empty($user->uid) && user_access('administer petitions')) { - $conn = wh_petitions_mongo_petition_connection(); - $petition = array(); - $petition = wh_petitions_load_slim_petition($conn, $petition_id, array('featured')); - if ($petition['featured']) { - $petition['featured'] = 0; - $text = t('Feature'); - } - else { - $petition['featured'] = 1; - $text = t('Un-Feature'); - } - $conn->update( - array('_id' => $petition['_id']), - array('$set' => array('featured' => $petition['featured'])) - ); - print '' . $text . ''; - exit; - } - - print ''; -} - -/** - * Callback function for the Remove Lists/Enable Lists ajax request - */ -function wh_petitions_remove_lists($petition_id) { - global $user; - - $return_value = ''; - - if (!empty($petition_id) && !empty($user->uid) && user_access('administer petitions')) { - $conn = wh_petitions_mongo_petition_connection(); - $petition = array(); - $petition = wh_petitions_load_petition($conn, $petition_id); - if ($petition['petition_status'] == WH_PETITION_STATUS_FLAGGED) { - // Check to see what Status it should have - $timestamp = strtotime('- ' . $petition['review_timeframe'] . ' days'); - - if ($petition['published'] < $timestamp) { - $petition['petition_status'] = WH_PETITION_STATUS_CLOSED; - } - elseif ($petition['signature_count'] < $petition['public_signatures']) { - $petition['petition_status'] = WH_PETITION_STATUS_PRIVATE; - } - elseif ($petition['signature_count'] < $petition['response_signatures']) { - $petition['petition_status'] = WH_PETITION_STATUS_PUBLIC; - } - elseif ($petition['signature_count'] >= $petition['response_signatures']) { - $petition['petition_status'] = WH_PETITION_STATUS_UNDER_REVIEW; - $petition['response_status'] = WH_PETITION_RESPONSE_STATUS_PENDING; - } - - wh_petitions_save_petition($conn, $petition); - $text = t('Remove from Site'); - } - else { - //set the status on the object to match what we're about to set in the database record - $petition['petition_status'] = WH_PETITION_STATUS_FLAGGED; - $conn->update( - array('_id' => $petition['_id']), - array('$set' => array('petition_status' => WH_PETITION_STATUS_FLAGGED)) - ); - $text = t('Enable on Site'); - } - //log the activity to the admin_log collection - wh_petitions_admin_log($user, 'petition', $petition); - - //send removal notification - wh_petitions_removal_notification($user, $petition); - - //now that PHP is done with the petition, convert some of the attribute values to text so JS can display them easier - $petition['petition_status'] = wh_petitions_display_status_name($petition['petition_status']); - $petition['response_status'] = wh_petitions_display_status_name($petition['response_status'], 'response'); - - $js_petition = $petition; - - $return_value = drupal_json_output(array( - 'link' => '' . $text . '', //the text of the link for the remove-lists div - 'petition' => $petition, //a representation of the petition for JS to display - )); - } - - drupal_json_output($return_value); -} - -/** - * Menu callback for the autocomplete results. - * - * Retrieves all published responses that match the string that has been typed in. - */ -function wh_petitions_response_autocomplete($string = '') { - $matches = array(); - - // Query - $query = db_select('node', 'n', array('target' => 'slave')) - ->fields('n', array('nid', 'title')) - ->condition('n.type', 'wh_response') - ->where("upper(n.title) LIKE upper(:search)", array(':search' => $string . '%')) - ->orderBy('n.title', 'ASC'); - $result = $query->execute(); - - foreach ($result as $res) { - $matches[check_plain($res->title) . ' [' . check_plain($res->nid). ']'] = check_plain($res->title); - } - - drupal_json_output($matches); -} - - -/** - * Generate a csv list of signatures on the given petition - */ -function wh_petitions_download_signatures_run_batch($petition_id) { - $limit = 500; - $time_stamp = time(); - - $file_name = variable_get('file_temporary_path', '/mnt/tmp/petitions') . '/subscriber_export_' . $petition_id . '_' . $time_stamp . '.csv'; - - $batch = array( - 'title' => t('Exporting Petition Signatures'), - 'progress_message' => t('Dowload of the file will begin automatically when processing is complete. After downloading, close this window.'), - 'operations' => array( - array('wh_petitions_download_signatures_batch', array($petition_id, $limit, $file_name)), - ), - 'file' => drupal_get_path('module', 'wh_petitions') . '/wh_petitions.admin.inc', - ); - - batch_set($batch); - batch_process('admin/petitions/download_signatures/' . $petition_id . '/' . $time_stamp); -} - -/** - * Redirection page for when Batch API completes. - */ -function wh_petitions_download_signatures($petition_id, $time_stamp) { - $file_name = variable_get('file_temporary_path', '/mnt/tmp/petitions') . '/subscriber_export_' . $petition_id . '_' . $time_stamp . '.csv'; - if ($_GET['download']) { - if ($handle = fopen($file_name, 'r')) { - drupal_add_http_header('Content-Type', 'text/csv; utf-8'); - drupal_add_http_header('Content-Disposition', 'attachment; filename="' . $file_name . '"'); - while ($data = fread($handle, 4096)) { - echo $data; - } - fclose($handle); - } - else { - return "I'm sorry, but something went wrong. Welcome to Fail-ville, population: me :(
If you're so inclined, you could close this window and try again."; - } - } - else { - $link = l('download your file', current_path(), array('query' => array('download' => 1))); - return t("Processing complete. You may now !link", array('!link' => $link)); - } -} - - -/** - * Batch API call-back for generating a list of petition signatures - * - * @param $petition_id - * The ID of the petiton for which signatures should be pulled. - * @param $limit - * Number of elements to process in each run of the operation. - * @param $file_name - * Name of the file to which results should be written. - * @param $context - * Batch API state holder. - */ -function wh_petitions_download_signatures_batch($petition_id, $limit, $file_name, &$context) { - - $signatures_collection = wh_petitions_mongo_petition_signatures_connection(); - - $query = array('petition_id' => $petition_id); - $fields = array('uid'); - - //get us a file to which to write output - if(!$file_handle = fopen($file_name, 'a')) { - watchdog('wh_petitions', 'Unable to open file for writing subscriber export'); - return FALSE; - } - - //setup initial sandbox - if (empty($context['sandbox'])) { - $context['sandbox']['progress'] = 0; - $context['sandbox']['max'] = $signatures_collection->count($query); - } - - $mongo_signatures = $signatures_collection->find($query, $fields)->skip($context['sandbox']['progress'])->limit($limit); - $id_list = array(); - foreach ($mongo_signatures as $signature) { - $context['sandbox']['progress']++; - $id_list[] = $signature['uid']; - } - - $mysql_query = db_select('users', 'u'); - $mysql_query->fields('u', array('mail')); - $mysql_query->condition('uid', array($id_list), 'IN'); - $result = $mysql_query->execute(); - - while ($email = $result->fetchField(0)) { - fwrite($file_handle, $email . PHP_EOL); - } - - $context['results']['filename'] = $context['sandbox']['output_file']; - $context['results']['signatures'] = $context['sandbox']['progress']; - $context['message'] = t('Processed !progress signatures', array('!progress' => $context['sandbox']['progress'])); - $context['finished'] = $context['sandbox']['progress']/$context['sandbox']['max']; -} diff --git a/modules/custom/wh_petitions/wh_petitions.admin.js b/modules/custom/wh_petitions/wh_petitions.admin.js deleted file mode 100644 index 5b6266aee..000000000 --- a/modules/custom/wh_petitions/wh_petitions.admin.js +++ /dev/null @@ -1,85 +0,0 @@ -(function ($) { -Drupal.behaviors.bookmarkPetition = { - attach: function(context) { - $(".bookmark").click( - function () { - var pid_arr = $(this).attr('id').split('-'); - var pid = pid_arr[1]; - - $.post("/admin/bookmark/" + pid, { petition_id: pid }, - function(data) { - if(data) { - $("#bookmark-" + pid).html(data).show(); - } - } - ); - } - ); - } -} - -Drupal.behaviors.featurePetition = { - attach: function(context) { - $(".featured").click( - function () { - var pid_arr = $(this).attr('id').split('-'); - var pid = pid_arr[1]; - $.post("/admin/featured/" + pid, { petition_id: pid }, - function(data) { - if(data) { - $("#featured-" + pid).html(data).show(); - } - } - ); - } - ); - } -} - -Drupal.behaviors.hidePetition = { - attach: function(context) { - $(".remove-lists").click( - function () { - var pid_arr = $(this).attr('id').split('-'); - var pid = pid_arr[2]; - $.post("/admin/remove-lists/" + pid, { petition_id: pid }, - function(data) { - if(data) { - $("#remove-lists-" + pid).html(data['link']).show(); - $("#petition-status-" + pid).html(data['petition']['petition_status']).show(); - } - } - ); - } - ); - } -} - -Drupal.behaviors.overridePetition = { - attach: function(context) { - $(".override-status").click( - function () { - var pid_arr = $(this).attr('id').split('-'); - var pid = pid_arr[2]; - $.post("/admin/override-status/" + pid, { petition_id: pid }, - function(data) { - if(data) { - $("#override-status-" + pid).html(data).show(); - } - } - ); - } - ); - } -} - -Drupal.behaviors.privateTags = { - attach: function(context) { - $(".edit-private-tags").click( - function () { - $('#edit-private-tags').toggle(); - } - ); - } -} -})(jQuery); diff --git a/modules/custom/wh_petitions/wh_petitions.cron.inc b/modules/custom/wh_petitions/wh_petitions.cron.inc deleted file mode 100644 index 8913d3e44..000000000 --- a/modules/custom/wh_petitions/wh_petitions.cron.inc +++ /dev/null @@ -1,122 +0,0 @@ - array( - '$in' => array((int)WH_PETITION_STATUS_PRIVATE, (int)WH_PETITION_STATUS_PUBLIC, (int)WH_PETITION_STATUS_FLAGGED) - ), - ); - $retrieve_fields = array('published', 'review_timeframe'); - $results = $conn->find($query, $retrieve_fields); - - $today = time(); - foreach ($results as $res) { - // Identify if this petition has exceeded the review timeframe - $end_date = strtotime('+ ' . $res['review_timeframe'] . ' days', $res['published']); - - // Petition has been open too long, close it. - if ($today > $end_date) { - $id = $res['_id']->__toString(); - - $conn->update( - array('_id' => $res['_id']), - array('$set' => array('petition_status' => (int)WH_PETITION_STATUS_CLOSED, 'closed' => (int)time())) - ); - } - } - - // Petition Counts - Issues - $issues = array(); - $vocab = taxonomy_vocabulary_machine_name_load('issues'); - if (!empty($vocab)) { - $issues_list = taxonomy_get_tree($vocab->vid); - foreach ($issues_list as $issue) { - // Need to get the number of petitions in a given issue. - $query = array( - 'petition_status' => array( - '$in' => array((int)WH_PETITION_STATUS_PUBLIC, (int)WH_PETITION_STATUS_UNDER_REVIEW) - ), - 'hidden' => 0, - ); - $query['issues'] = array('$in' => array((int)$issue->tid)); - $total = $conn->find($query)->count(); - $issues[$issue->tid] = $total; - } - } - variable_set('wh_petitions_petition_issue_counts', $issues); - - // Response Counts - Issues - $issues = array(); - if (!empty($issues_list)) { - foreach ($issues_list as $issue) { - $issues[$issue->tid] = check_plain($issue->name); - - $query = db_select('node', 'n', array('target' => 'slave')); - $query->fields('n', array('nid')) - ->condition('n.type', 'wh_response') - ->condition('n.status', 0, '<>'); - $query->innerJoin('field_data_field_issues', 'i', 'n.nid = i.entity_id'); - $query->condition('i.field_issues_tid', $issue->tid); - // Featured - $query->innerJoin('field_data_field_is_featured', 'f', 'n.nid = f.entity_id'); - $query->addField('f', 'field_is_featured_value', 'field_is_featured_value'); - $query->condition('f.field_is_featured_value', 1); - - $total = $query->countQuery()->execute()->fetchField(); - $issues[$issue->tid] = $total; - } - } - variable_set('wh_petitions_response_issue_counts', $issues); - - // Trending sort - $timestamp = strtotime("-1 day"); - $sig_conn = wh_petitions_mongo_petition_signatures_connection(); - - // Retrieve all the petitions that have been signed within the past 24 hours, with the count of how many signatures are associated with each. - $reduce = "function (obj, prev) { prev.count++; }"; - $result = $sig_conn->group(array('petition_id' => 1), array('count' => 0), $reduce, array('timestamp' => array('$gt' => $timestamp))); - - // Put the results in an array so we can sort - $trending = array(); - foreach ($result['retval'] as $key => $res) { - $trending[$res['petition_id']] = $res['count']; - } - arsort($trending); - - // Retrieve the top 100 and put the ids in an array ( of Mongo Ids that we can feed to a query ) - $trending = array_slice($trending, 0, 100); - $ids = array(); - foreach ($trending as $id => $val) { - array_push($ids, new MongoId($id)); - } - - // Out of those 100, retrieve all that are open to the public and show in lists - $query = array( - 'petition_status' => array( - '$in' => array((int)WH_PETITION_STATUS_PUBLIC, (int)WH_PETITION_STATUS_UNDER_REVIEW) - ), - 'hidden' => 0, - '_id' => array('$in' => $ids), - ); - $results = $conn->find($query, array('title')); - - // Put the results of the previous query into an array of mongo ids to use in the trending sort function. At this point, $ids contains an array of the ids of petitions - // that have been signed the most in the past 24 hours, ordered by the count descending. - $ids = array(); - foreach ($results as $res) { - array_push($ids, $res['_id']); - } - variable_set('wh_petitions_trending_ids', $ids); -} diff --git a/modules/custom/wh_petitions/wh_petitions.form.inc b/modules/custom/wh_petitions/wh_petitions.form.inc deleted file mode 100644 index 9306e6c82..000000000 --- a/modules/custom/wh_petitions/wh_petitions.form.inc +++ /dev/null @@ -1,1417 +0,0 @@ -'; -} - -/** - * Displays the create petition form in the iframe - */ -function wh_petitions_create_petition_iframe_html() { - $styles = drupal_get_css(); - $scripts = drupal_get_js(); - $form_html = drupal_render(drupal_get_form('wh_petitions_create_petition')); - $messages = theme('status_messages'); - - $html = ' - - ' . t('Create A Petition') . ' - ' . $styles . $scripts . ' - - - - -
- ' . $messages . ' - ' . $form_html . ' -
- '; - print $html; - exit; -} - -/** - * Callback for create a petition form. Displays each step of the form based on where the user is. - * - * Step 1: Title + Issues - * Step 2: Similar Petitions - * Step 3: Description + Keywords - * Step 4: Review and Publish/Edit/Delete - * Step 5: Thank You Page - */ -function wh_petitions_create_petition($form, &$form_state) { - global $user; - - // Only let registered users here. Access here should be restricted by the 'create petition' permission anyway, but can't hurt to double-check. - if (empty($user->uid)) { - // This is unfornately hardcoded because of the iframe's path. Subtly, the path is - // petitionS/create, vs, petition/create which loads petitions/create. In this - // case, you can't do a drupal_get_destination() because it loads the wrong path due - // to the iframe. - $destination = array('destination' => '/petition/create'); - $markup = '
' . t('You must verify your email before you can create a White House petition') . '
'; - $markup .= '

' . t('Already Have an Account?') . '

'; - $markup .= '

 

'; - $markup .= l(t('Sign In'), 'user', array('query' => $destination, 'attributes' => array('class' => array('no-follow'), 'id' => 'button-sign-in', 'target' => array('_parent')))); - $markup .= '
'; - $markup .= '
or
'; - $markup .= '

' . t("Don't Have an Account?") . '

'; - $markup .= '

 

'; - $markup .= l(t('Create an Account'), 'user/register', array('query' => $destination, 'attributes' => array('class' => array('no-follow'), 'id' => 'button-create-an-account', 'target' => array('_parent')))); - $markup .= '
'; - - return array( - 'description' => array( - '#type' => 'markup', - '#markup' => $markup, - ), - ); - } - - if (!empty($form_state['create_page'])) { - if ($form_state['create_page'] == 2) { - return wh_petitions_create_petition_step_2($form, $form_state); - } - elseif ($form_state['create_page'] == 3) { - return wh_petitions_create_petition_step_3($form, $form_state); - } - elseif ($form_state['create_page'] == 4) { - return wh_petitions_create_petition_step_4($form, $form_state); - } - elseif ($form_state['create_page'] == 5) { - return wh_petitions_create_petition_thank_you($form, $form_state); - } - } - - // Display the first page - return wh_petitions_create_petition_step_1($form, $form_state); -} - -/** - * First page of the create a petition form. Contains title and issues. Saves the petition as a draft when the user submits. - */ -function wh_petitions_create_petition_step_1($form, &$form_state) { - global $user; - global $base_url; - - // We're on the first page. - $form_state['create_page'] = 1; - $form['#prefix'] = theme('wh_petitions_create_header', array('step' => 1)); - $form['#attributes'] = array('id' => 'create-petition-form-step-1'); - - // If we have a petition saved in the form state, pre-populate with those values. - if (!empty($form_state['petition'])) { - $form_state['values']['petition_title'] = $form_state['petition']['title']; - $issues = array(); - foreach ($form_state['petition']['issues'] as $key) { - $issues[$key] = $key; - } - $form_state['values']['petition_issues'] = $issues; - } - // If the form hasn't been submitted - we're coming here for the first time. - // Check to see if there's an id in the url - if so, we're coming to edit an existing petition off the user's dashboard page. - elseif (empty($form_state['submitted'])) { - $arg_petition_id = arg(2); - if (!empty($arg_petition_id)) { - $conn = wh_petitions_mongo_petition_connection(); - $conn->setSlaveOkay(FALSE); - $petition = array(); - $petition = wh_petitions_load_petition($conn, $arg_petition_id); - - // Make sure we got a petition and that the creator is the current user, and that it's a draft. - if (!empty($petition) && $user->uid == $petition['uid'] && $petition['petition_status'] == WH_PETITION_STATUS_DRAFT) { - $form_state['petition'] = $petition; - $form_state['petition_id'] = $arg_petition_id; - $form_state['values']['petition_title'] = $form_state['petition']['title']; - $issues = array(); - foreach ($form_state['petition']['issues'] as $key) { - $issues[$key] = $key; - } - $form_state['values']['petition_issues'] = $issues; - } - else { - return ''; - } - } - } - - // Set the default petition title to go into the field based on whether we're editing a petition, have already had user input, or use the default. - $default_petition_title = ''; - if (!empty($form_state['values']['petition_title'])) { - $default_petition_title = check_plain($form_state['values']['petition_title']); - } - elseif (!empty($form_state['input']['petition_title'])) { - $default_petition_title = check_plain($form_state['input']['petition_title']); - } - else { - $default_petition_title = t('finish the statement here'); - } - - // Petition Title - This will be themed in a separate function ( wh_petition_title ) because of unusual design requirements. - $form['petition_title'] = array( - '#type' => 'textarea', - '#title' => t('Enter a title for your petition'), - '#required' => FALSE, - '#resizable' => FALSE, - '#theme' => 'wh_petition_title', - '#default_value' => $default_petition_title, - '#attributes' => array('id' => 'form-item-create-petition-title'), - ); - - // Issues - $issues = array(); - $vocab = taxonomy_vocabulary_machine_name_load('issues'); - if (!empty($vocab)) { - $issues_list = taxonomy_get_tree($vocab->vid); - foreach ($issues_list as $issue) { - $issues[$issue->tid] = check_plain($issue->name); - } - } - $form['petition_issues'] = array( - '#type' => 'checkboxes', - '#title' => t('Choose up to 3 issues to describe your petition'), - '#required' => FALSE, - '#options' => $issues, - '#prefix' => '
', - '#suffix' => '
', - '#after_build' => array('wh_petitions_column_checks'), - '#default_value' => !empty($form_state['values']['petition_issues']) ? $form_state['values']['petition_issues'] : array(), - '#attributes' => array('id' => 'form-item-issues-describe'), - ); - - // Next Button - $form['next'] = array( - '#type' => 'submit', - '#value' => t('Save & Continue to Step 2'), - '#submit' => array('wh_petitions_create_petition_step_1_submit'), - '#prefix' => '
', - '#attributes' => array('class' => array('input-button-steps'), 'id' => 'continue-to-step-2'), - ); - $form['#validate'] = array('wh_petitions_create_petition_step_1_validate'); - - $form['#action'] = $base_url . '/' . implode('/', arg()); - - return $form; -} - -/** - * Themes the petition title area which has different design requirements that drupal doesn't inherantly handle with the attributes available to the form. - */ -function theme_wh_petition_title($variables) { - global $base_url; - $element = $variables['element']; - element_set_attributes($element, array('id', 'name', 'cols', 'rows')); - _form_set_class($element, array('form-textarea')); - - $default = !empty($element['#default_value']) ? $element['#default_value'] : t('finish the statement here'); - - $output = '
'; - $output .= '
' . t('We believe the Obama Administration should...') . '
'; - $output .= '
'; - $output .= ' ' . t('finish the statement here') . ''; - $output .= ' '; - $output .= '
'; - $output .= ' '; - $output .= '
' . t('120 characters') . '
'; - $output .= '
'; - - return $output; -} - -/** - * Places the checkboxes into 3 (mostly-equal) columms. - */ -function wh_petitions_column_checks($form_element, &$form_state) { - $size = sizeof($form_element['#options']); - - if ($size > 3) { - $in_each = ceil($size / 3); - $i = 1; - foreach ($form_element['#options'] as $key => $val) { - if ($i == 1) { - $form_element[$key]['#prefix'] = '
'; - } - elseif ($i == ($in_each + 1)) { - $form_element[$key]['#prefix'] = '
'; - } - elseif ($i == (($in_each * 2) + 1)) { - $form_element[$key]['#prefix'] = '
'; - } - elseif ($i == $size) { - $form_element[($key)]['#suffix'] = '
'; - } - - $form_element[$key]['#attributes']['id'] = $form_element['#id']. '-' . $key; - $i++; - } - - return $form_element; - } -} - -/** - * Validation handler - makes sure we have a title with the right number of characters and have between 1 and 3 issues, inclusive - */ -function wh_petitions_create_petition_step_1_validate($form, &$form_state) { - $title = trim(strip_tags($form_state['values']['petition_title'])); - if (empty($title) || $title == 'finish the statement here') { - form_set_error('petition_title', t('Please enter a petition title.')); - } - elseif (wh_petitions_exceed_char_count($title, 120)) { - form_set_error('petition_title', t('Please enter a title that is 120 characters or less.')); - } - - $count = 0; - $issues = $form_state['values']['petition_issues']; - foreach ($issues as $key => $val) { - if ($val > 0) { - $count++; - } - } - if ($count > 3) { - form_set_error('petition_issues', t('Please select a maximum of 3 issues.')); - } - elseif ($count == 0) { - // @todo Make petition_issues optional and easy to enable/disable. - //form_set_error('petition_issues', t('Please select at least 1 issue.')); - $text = t('This petition was has not been tagged with any petition_issues keywords.'); - watchdog('wh_petitions', $text, array(), WATCHDOG_WARNING); - drupal_set_message($text, 'warning'); - } - - // If the user got here other than by clicking the Save and Continue button ( i.e. by clicking the back button in the browser and trying - // to submit a different step ), clear the validation error messages and give them a message of where to go to perform their edits. - if ($form_state['input']['op'] != t('Save & Continue to Step 2')) { - drupal_get_messages('error'); - form_set_error(NULL, '', TRUE); - - $link = '/dashboard'; - drupal_set_message(t('You have clicked the back-button while in the middle creating a petition. The petition you were working on can be continued') . ' ' . l(t('here'), $link, array('attributes' => array('target' => '_top'))) . ' ' . t('or you can begin a new petition on this page.'), 'status'); - return FALSE; - } -} - -/** - * Submit handler for step 1 of the create a petition form. - * Create a draft petition object and rebuild the form to go to step 2. - */ -function wh_petitions_create_petition_step_1_submit($form, &$form_state) { - // Save the petition as a draft and add the id to the form state - global $user; - $conn = wh_petitions_mongo_petition_connection(); - $conn->setSlaveOkay(FALSE); - - // Get a default petition object or load the one we're editing. - if (empty($form_state['petition_id'])) { - $petition = wh_petitions_default_petition(); - } - else { - $petition = wh_petitions_load_petition($conn, $form_state['petition_id']); - - // Make sure we got a petition and that the creator is the current user, and that it's a draft. - if (!empty($petition) && $user->uid == $petition['uid'] && $petition['petition_status'] == WH_PETITION_STATUS_DRAFT) { - $petition['_id'] = new MongoId($form_state['petition_id']); - } - else { - $petition = array(); - } - } - - if (!empty($petition)) { - $petition['uid'] = (int)$user->uid; - $petition['title'] = (string)trim(strip_tags($form_state['values']['petition_title'])); - $petition['title_keywords'] = wh_petitions_generate_keywords($petition['title']); - $petition['petition_status'] = (int)WH_PETITION_STATUS_DRAFT; - $petition['response_status'] = (int)WH_PETITION_RESPONSE_STATUS_UNANSWERED; - - $issues = array(); - foreach ($form_state['values']['petition_issues'] as $key => $val) { - if ($val > 0) { - array_push($issues, intval($key)); - } - } - $petition['issues'] = $issues; - - // Save and retrieve the ID for future use. - $id = wh_petitions_save_petition($conn, $petition); - if (!empty($id)) { - $form_state['petition_id'] = $id; - $form_state['petition'] = $petition; - - // Create a default nice url, it will get something better once - // published but we need this for consistent url handling. - $petition['_id'] = new MongoId($id); - $petition['nice_url'] = "petition/detail/$id"; - wh_petitions_save_petition($conn, $petition); - } - - - // Go to the next page - $form_state['create_page'] = 2; - $form_state['rebuild'] = TRUE; - } - else { - return ''; - } -} - -/** - * Second page of the create a petition form. - * - * Try to find petitions that: - * -Are Open and Public - * -Match at least one of the same issues - * -Match at least one word from the title to the title keywords, omitting common words - * -Sorted by most popular (most signatures), Limit 3 - */ -function wh_petitions_create_petition_step_2($form, &$form_state) { - // We're on the second page. - $form_state['create_page'] = 2; - $form['#prefix'] = theme('wh_petitions_create_header', array('step' => 2)); - $form['#attributes'] = array('id' => 'create-petition-form-step-2'); - - $conn = wh_petitions_mongo_petition_connection(); - $conn->setSlaveOkay(FALSE); - $petition_id = $form_state['petition_id']; - - // Get the issues into an array of keys - $issues = array(); - foreach ($form_state['petition']['issues'] as $key => $val) { - if ($val > 0) { - array_push($issues, intval($val)); - } - } - - // Removed common words from the string of title keywords - $title_keywords = $form_state['petition']['title_keywords']; - $title_terms = array(); - foreach ($title_keywords as $term) { - if (!in_array($term, array("and", "in", "this", "or", "a", "the", "an", "as", "at", "but", "by", "before", "for", "from", "is", "like", "of", "on", "onto", "than", "this", "that", "to", "with"))) { - array_push($title_terms, $term); - } - } - - // Retrieve the top 3 results sorted by signature count DESC that match all the issues and at least one of the title words - $similar = ''; - $similar_html = ''; - $count = 0; - $query = array( - 'issues' => array('$in' => $issues), - 'title_keywords' => array('$in' => $title_terms), - 'petition_status' => array( - '$in' => array((int)WH_PETITION_STATUS_PUBLIC, (int)WH_PETITION_STATUS_UNDER_REVIEW) - ), - 'hidden' => 0, - ); - $result = $conn->find($query, array('title', 'signature_count', 'nice_url'))->sort(array('signature_count' => -1))->limit(3); - - $petition_count = 0; - foreach ($result as $res) { - - $link = $res['nice_url']; - - $similar_html .= theme('wh_petitions_display_list_petition', array( - 'entry_num' => $petition_count, - 'title' => check_plain($res['title']), - 'signature_count' => wh_petitions_format_number($res['signature_count']), - 'nice_url' => $res['signature_count'], - 'petition_link' => l(t('Find out more'), $link, array('attributes' => array('target' => '_top'))), - 'cols' => 2, - 'petition_id' => check_plain($res['_id']->__toString()), - 'target' => '_top', - 'title_link' => $link, - )); - $petition_count++; - } - /** - * @todo - Ben - This feature doesn't work in production so take changes with a grain of salt. - */ - // Retrieve up to 2 related responses based on title matches that match at least one of the issue terms sorted by petition_count desc - $query = db_select('node', 'n', array('target' => 'slave')); - $query->innerJoin('field_data_field_petition_count', 'c', 'n.nid = c.entity_id'); - $query->addField('c', 'field_petition_count_value', 'field_petition_count_value'); - $query->fields('n', array('nid', 'title')) - ->condition('n.type', 'wh_response') - ->condition('n.status', 0, '<>') - ->orderBy('c.field_petition_count_value', 'DESC') - ->orderBy('n.title', 'ASC'); - - // Join to the Issues terms to match at least one - $query->innerJoin('field_data_field_issues', 'i', 'n.nid = i.entity_id'); - $query->condition('i.field_issues_tid', $issues, 'IN'); - - // Join to private keywords to match a title keyword from the draft to a private keyword - $query->innerJoin('field_data_field_private_tags', 't', 'n.nid = t.entity_id'); - $query->innerJoin('taxonomy_term_data', 'td', 't.field_private_tags_tid = td.tid'); - $query->condition('td.name', $title_terms, 'IN'); - $query->distinct(TRUE); - $result = $query->range(0, 2) - ->execute(); - - $response_count = 0; - $entry_num = 0; - if ($petition_count % 2 == 1) { - $entry_num = 1; - } - - foreach ($result as $res) { - $link = url('node/' . $res->nid); - - $similar_html .= theme('wh_response_display_list_response', array( - 'entry_num' => $response_count, - 'cols' => 2, - 'nid' => intval($res->nid), - 'title' => l($res->title, $link, array('attributes' => array('target' => '_top'))), - 'response_link' => l(t('Read Full Response'), $link, array('attributes' => array('target' => '_top'))), - )); - $response_count++; - $entry_num++; - } - - // Determine what text to show based on what we found. - if ($petition_count > 0 || $response_count > 0) { - $similar = '
' . t('Important:') . ' '; - - if ($petition_count > 0 && $response_count == 0) { - $similar .= t('Below are a few petitions that may be similar to yours.'); - } - elseif ($petition_count == 0 && $response_count > 0) { - $similar .= t('Below are a few responses that may be similar to your petition.'); - } - else { - $similar .= t('Below are a few petitions and responses that may be similar to your petition.'); - } - - $similar .= '
'; - $similar .= '
' . t('Consider signing an existing petition instead of creating a new one. Duplicate petitions on the same topic will result in fewer signatures for each petition. Focusing your efforts on signing a petition that already has signatures increases the likelihood that you\'ll get a response from the Obama Administration.') . '
'; - $similar .= '
' . $similar_html . '
'; - $similar .= '
'; - $similar .= '
' . t("Didn't find a similar petition? Click below to continue creating a new petition.") . '
'; - } - else { - $similar = '
' . t('No similar petitions or responses have been found.') . '
'; - } - - $form['similar_issues'] = array( - '#type' => 'markup', - '#markup' => '
' . $similar . '
', - ); - - // Next Button - $form['next'] = array( - '#type' => 'submit', - '#value' => t('Save & Continue to Step 3'), - '#submit' => array('wh_petitions_create_petition_step_2_submit'), - '#attributes' => array('class' => array('input-button-steps'), 'id' => 'continue-to-step-3'), - ); - - $form['#action'] = '/' . implode('/', arg()); - - return $form; -} - -/** - * Submit handler for step 2 of the create a petition form. Don't need to save any values, but update the page and rebuild. - */ -function wh_petitions_create_petition_step_2_submit($form, &$form_state) { - // Go to the next page - $form_state['create_page'] = 3; - $form_state['rebuild'] = TRUE; -} - -/** - * Third page of the create a petition form. Contains body and user-defined keywords. - */ -function wh_petitions_create_petition_step_3($form, &$form_state) { - global $base_url; - // We're on the third page. - $form_state['create_page'] = 3; - $form['#prefix'] = theme('wh_petitions_create_header', array('step' => 3)); - $form['#attributes'] = array('id' => 'create-petition-form-step-3'); - - // Populate with the values from a saved petition - if (!empty($form_state['petition']['body'])) { - $form_state['values']['petition_description'] = $form_state['petition']['body']; - } - if (!empty($form_state['petition']['user_tags'])) { - $form_state['values']['petition_tags'] = implode(', ', $form_state['petition']['user_tags']); - } - - // Description - $form['petition_description'] = array( - '#type' => 'textarea', - '#title' => t('Enter a description for your petition'), - '#description' => '
' . t('Please limit your description to 800 characters.') . '
Tips for writing good descriptions
', - '#required' => FALSE, - '#resizable' => FALSE, - '#default_value' => !empty($form_state['values']['petition_description']) ? $form_state['values']['petition_description'] : '', - ); - - // Free Tags - $form['petition_tags'] = array( - '#type' => 'textfield', - '#title' => t('Enter keywords that best describe your petition'), - '#description' => '
' . t('Separate keywords by commas.') . ' ' . t('Limited to 120 characters.') . '
Tips for writing good keywords
', - '#required' => FALSE, - '#size' => 50, - '#maxlength' => 120, - '#attributes' => array('class' => array('input-text')), - '#default_value' => !empty($form_state['values']['petition_tags']) ? $form_state['values']['petition_tags'] : '', - ); - - // Next Button - $form['next'] = array( - '#type' => 'submit', - '#value' => t('Save & Continue to Final Step'), - '#submit' => array('wh_petitions_create_petition_step_3_submit'), - '#prefix' => '
', - '#attributes' => array('class' => array('input-button-steps'), 'id' => 'continue-to-final-step'), - ); - $form['#validate'] = array('wh_petitions_create_petition_step_3_validate'); - - $form['#action'] = $base_url . '/' . implode('/', arg()); - - return $form; -} - -/** - * Validation handler - makes sure the body is filled out and isn't too long, and keywords aren't too long. - */ -function wh_petitions_create_petition_step_3_validate($form, &$form_state) { - if (empty($form_state['values']['petition_description'])) { - form_set_error('petition_description', t('Please enter a petition description.')); - } - elseif (wh_petitions_exceed_char_count($form_state['values']['petition_description'], 800)) { - form_set_error('petition_description', t('Please enter a description that is 800 characters or less.')); - } - - if (wh_petitions_exceed_char_count($form_state['values']['petition_tags'], 120)) { - form_set_error('petition_tags', t('Please enter keywords that are a total of 120 characters or less.')); - } -} - -/** - * Submit handler for step 3 of the create a petition form. Save the the description and keywords to the petition - */ -function wh_petitions_create_petition_step_3_submit($form, &$form_state) { - global $user; - - // Add the description and keywords to the petition. - $conn = wh_petitions_mongo_petition_connection(); - $conn->setSlaveOkay(FALSE); - $petition = wh_petitions_load_petition($conn, $form_state['petition_id']); - if (!empty($petition) && $user->uid == $petition['uid'] && $petition['petition_status'] == WH_PETITION_STATUS_DRAFT) { - $petition['user_tags'] = array_unique(wh_petitions_generate_keywords(strip_tags($form_state['values']['petition_tags']), ',')); - $petition['body'] = (string)strip_tags($form_state['values']['petition_description']); - $petition['body_keywords'] = wh_petitions_generate_keywords(strip_tags($form_state['values']['petition_description'])); - $conn->update( - array('_id' => $petition['_id']), - array('$set' => array('user_tags' => $petition['user_tags'], 'body' => $petition['body'], 'body_keywords' => $petition['body_keywords'])) - ); - $form_state['petition'] = $petition; - } - - // Go to the next page - $form_state['create_page'] = 4; - $form_state['rebuild'] = TRUE; -} - -/** - * Fourth page of the create a petition form - preview + submit/save/delete - */ -function wh_petitions_create_petition_step_4($form, &$form_state) { - global $user; - global $base_url; - - // We're on the fourth page. - $form_state['create_page'] = 4; - $form['#prefix'] = theme('wh_petitions_create_header', array('step' => 4)); - $form['#attributes'] = array('id' => 'create-petition-form-step-4'); - - // Load the petition - $conn = wh_petitions_mongo_petition_connection(); - $conn->setSlaveOkay(FALSE); - $petition = wh_petitions_load_petition($conn, $form_state['petition_id']); - - // Verify we should be here - if (empty($petition) || $user->uid != $petition['uid'] || $petition['petition_status'] != WH_PETITION_STATUS_DRAFT) { - return ''; - } - - // Load variables to display with the petition - $petition_id = $petition['_id']->__toString(); - $timestamp = $petition['_id']->getTimestamp(); - $created = date("M d, Y", $timestamp); - $issues = array(); - if (!empty($petition['issues'])) { - for ($i=0;$iname, 'petitions/all/0/2/' . intval($term->tid), array('attributes' => array('target' => '_top')))); - } - } - } - $issues = implode(', ', $issues); - $public_needed = variable_get('wh_petitions_public_signatures', 20); - $total_needed = variable_get('wh_petitions_review_signatures', 500); - $signatures_needed = $total_needed - $petition['signature_count']; - $signature_count = $petition['signature_count']; - - // End date is today + number of days to get the signatures ( not from the date it was created - because if it was published today the clock would start from now ) - $end_date = strtotime('+' . variable_get('wh_petitions_review_timeframe', 30) . ' days'); - $end_date = date("F d, Y", $end_date); - - // Show the Petition Info - $form['preview'] = array( - '#type' => 'markup', - '#markup' => theme('wh_petitions_display_petition_info', array( - 'title' => check_plain($petition['title']), - 'body' => wh_petitions_format_description($petition['body']), - 'created' => check_plain($created), - 'issues' => $issues, - 'published' => FALSE, - 'total_needed' => wh_petitions_format_number($total_needed), - 'signatures_needed' => wh_petitions_format_number($signatures_needed), - 'signatures' => wh_petitions_format_number($signature_count), - 'end_date' => check_plain($end_date), - 'archived' => FALSE, - 'responded' => FALSE, - 'flagged' => FALSE, - 'admin' => FALSE, - )), - ); - - // Publish Button and Text - $publish_text = '

' . t('NOTE: You will not be able to edit or delete this petition once you publish it.') . '

' . t('By creating this petition you agree to receive email updates related to this petition.') . '

'; - //$publish_text .= '

' . t('Next Steps') . '

'; - //$publish_text .= '

' . t('Get !public_count signatures before it becomes viewable by the White House community.', array('!public_count' => wh_petitions_format_number($public_needed))) . '

'; - //$publish_text .= '

' . t('Get !total_count signatures before the White House will review it.', array('!total_count' => wh_petitions_format_number($total_needed))) . '

'; - $form['publish'] = array( - '#type' => 'submit', - '#value' => t('Publish my petition'), - '#prefix' => '
', - '#submit' => array('wh_petitions_create_petition_step_4_submit'), - '#suffix' => $publish_text . '
', - '#attributes' => array('id' => 'button-publish-my-petition', 'class' => array('button')), - ); - - // Fieldset for the Save / Edit / Delete buttons - $form['save_edit_delete'] = array( - '#type' => 'fieldset', - '#title' => '', - '#collapsible' => FALSE, - '#collapsed' => FALSE, - '#prefix' => '
', - '#suffix' => '
', - ); - - // Redirect to the main site or the petition tool site, depending on where this request came from - $form['save_edit_delete']['edit'] = array( - '#type' => 'submit', - '#prefix' => '

' . t('Not ready to publish?') . '

' . l(t('Save & Publish Later'), 'dashboard', array('attributes' => array('id' => 'button-save-this-petition-and-publish-later', 'class' => array('button'), 'target' => '_top'))) . '

' . t('Want to make changes?') . '

', - '#suffix' => '
', - '#value' => t('Edit my petition'), - '#submit' => array('wh_petitions_create_petition_edit_petition'), - '#attributes' => array('id' => 'button-back-to-previous-step', 'class' => array('button')), - ); - - $delete_text = variable_get('wh_petitions_delete_modal_text', ''); - $form['save_edit_delete']['delete'] = array( - '#type' => 'markup', - '#markup' => '

' . t('Want to delete this petition? Note: If you delete this petition all of your information will be lost.') . "

" . l(t('Delete'), 'petition/delete/' . $petition_id, array('attributes' => array('id' => 'delete-petition-link-' . $petition_id, 'class' => 'button delete delete-petition-form no-follow button-delete-my-petition', 'rel' => $petition_id))) . '
', - ); - - $form['#action'] = $base_url . '/' . implode('/', arg()); - - return $form; -} - -/** - * Submit handler for step 4 of the create a petition form. Publish the petition. - */ -function wh_petitions_create_petition_step_4_submit($form, &$form_state) { - global $user; - - $petition_id = $form_state['petition_id']; - $conn = wh_petitions_mongo_petition_connection(); - $conn->setSlaveOkay(FALSE); - $petition = wh_petitions_load_petition($conn, $petition_id); - - if (!empty($petition) && $user->uid == $petition['uid'] && $petition['petition_status'] == WH_PETITION_STATUS_DRAFT) { - $petition['petition_status'] = (int)WH_PETITION_STATUS_PRIVATE; - $petition['published'] = (int)time(); - - // Generate a Friendly & Short URL - wh_petitions_generate_nice_url($petition); - wh_petitions_generate_short_url($petition); - - // By default, a user signs their own petition - $user_load = user_load($user->uid); - - - $petition['signature_count'] = 1; - - // Petition should always use the review timeframe, public/review signature counts that are set when the petition is published. - $petition['public_signatures'] = (int)variable_get('wh_petitions_public_signatures', 20); - $petition['response_signatures'] = (int)variable_get('wh_petitions_review_signatures', 500); - $petition['review_timeframe'] = (int)variable_get('wh_petitions_review_timeframe', 30); - - // Make it available publicly if the threshhold is 1 signature. - if ($petition['public_signatures'] == 1) { - $petition['petition_status'] = (int)WH_PETITION_STATUS_PUBLIC; - $petition['reached_public'] = (int)time(); - } - - $new_id = wh_petitions_save_petition($conn, $petition); - - // Create a new GovDelivery list - if (!empty($new_id)) { - govdelivery_subscriber_api_add_topic('petitions_' . $new_id); - } - - $form_state['petition'] = $petition; - - /** - * @todo: Refactor to actually user the wh_petitions_create_signature() function. - */ - $profile = profile2_load_by_user($user_load); - - $signature = array( - 'petition_id' => (string)$new_id, - 'ip_address' => (string)ip_address(), - 'user_agent' => (string)$_SERVER['HTTP_USER_AGENT'], - 'uid' => (int)$user->uid, - 'timestamp' => (int)time(), - 'comment' => '', - 'abuse_flags' => array(), - 'status' => 1, - 'number' => 1, - 'user' => array( - 'first_name' => $profile['main']->field_first_name['und'][0]['value'], - 'last_name' => $profile['main']->field_last_name['und'][0]['value'], - 'city' => $profile['main']->field_city['und'][0]['value'], - 'state' => $profile['main']->field_state['und'][0]['value'], - 'zip' => $profile['main']->field_zip['und'][0]['value'], - 'username' => $user_load->name, - 'country' => $profile['main']->field_country['und'][0]['value'], - ), - ); - wh_petitions_save_signature($signature); - - // Add creator's signature - if (!empty($new_id)) { - govdelivery_subscriber_api_add_subscriber($user->mail, 'petitions_' . $new_id); - } - - // Send an email to the creator - if (!empty($new_id)) { - wh_petitions_email_published($new_id, $user->uid); - } - - // Go to the thank-you page - $form_state['create_page'] = 5; - $form_state['rebuild'] = TRUE; - } - - return ''; -} - -/** - * Save as Draft submit handler. The petition is saved as a draft with every form page, so we've up to date. Just redirect to user dashboard. - */ -function wh_petitions_create_petition_save_petition($form, &$form_state) { - global $user; - drupal_goto('dashboard'); -} - -/** - * Edit my petition submit handler. Go back to the first step of the form. - */ -function wh_petitions_create_petition_edit_petition($form, &$form_state) { - // Load the updated petition into the form_state - $conn = wh_petitions_mongo_petition_connection(); - $conn->setSlaveOkay(FALSE); - $petition = wh_petitions_load_petition($conn, $form_state['petition_id']); - $form_state['petition'] = $petition; - - // Go back to the first page - $form_state['create_page'] = 1; - $form_state['rebuild'] = TRUE; -} - -/** - * Thank-You page ( Step 5 of the process ). Just display the petition. - */ -function wh_petitions_create_petition_thank_you($form, &$form_state) { - global $base_url; - global $user; - - $form_state['create_page'] = 5; - $form['#attributes'] = array('id' => 'create-petition-form-thank-you'); - - // Load the petition and display the thank-you message. - $conn = wh_petitions_mongo_petition_connection(); - $conn->setSlaveOkay(FALSE); - $petition = wh_petitions_load_petition($conn, $form_state['petition_id']); - $date = strtotime('+' . $petition['review_timeframe'] . ' days', $petition['published']); - $date = date("F d, Y", $date); - $link = $base_url . '/' . $petition['nice_url']; - $email_url = $base_url . '/petition/email/' . check_plain($petition['_id']->__toString()); - - $full_link = l($link, $link, array('html' => TRUE, 'attributes' => array('target' => '_top'))); - - // Use the full URL in cases where the short_url service was not available at the time of publishing - $short_url = ''; - if (empty($petition['short_url'])) { - // Service wasn't available, use the full URL - $short_url = $full_link; - } - else { - $short_url = l($petition['short_url'], $petition['short_url'], array('html' => TRUE, 'attributes' => array('target' => '_top'))); - } - - $email_address = $user->mail; - $email_link = l(t('Email This Petition'), $email_url, array('attributes' => array('target' => '_top'))); - - // Display the Thank You message - $form['thank-you'] = array( - '#type' => 'markup', - '#markup' => theme('wh_petitions_page_thank_you', array( - 'days' => check_plain($petition['review_timeframe']), - 'total_needed' => wh_petitions_format_number($petition['response_signatures']), - 'public_needed' => wh_petitions_format_number($petition['public_signatures']), - 'link' => $full_link, - 'short_url' => $short_url, - 'petition_id' => check_plain($petition['_id']->__toString()), - 'petition_title' => check_plain($petition['title']), - 'date' => check_plain($date), - 'email_address' => check_plain($email_address), - 'twitter_link' => wh_petition_tool_twitter_link(check_plain($petition['_id']->__toString()), check_plain($petition['title']), 'petition', '', $petition['short_url'], $petition['nice_url']), - 'facebook_link' => wh_petition_tool_facebook_link(check_plain($petition['_id']->__toString()), check_plain($petition['title']), 'petition', '', $petition['nice_url']), - 'email_link' => $email_link, - )), - ); - $form['#action'] = $base_url . '/' . implode('/', arg()); - return $form; -} - -/** - * Delete a petition handler. Save to a separate collection. - */ -function wh_petitions_create_petition_delete_petition($form, &$form_state) { - $conn = wh_petitions_mongo_petition_connection(); - $conn->setSlaveOkay(FALSE); - if (wh_petitions_delete_petition($conn, $form_state['petition_id'])) { - // Go to delete petition page - drupal_goto('petition/deleted'); - } - else { - return ''; - } -} - -/****************** OPEN PETITIONS PAGE FILTERS ************************/ - -/** - * Callback for the page that has the issues filter form. - */ -function wh_petitions_filter_issue_standalone() { - $form = drupal_get_form('wh_petitions_list_page_issues_form'); - $form = drupal_render($form); - drupal_set_title(t('Filter By Issues')); - - return '

' . t('Filter By Issues') . '

'; -} - -/** - * Callback for the page that has the search filter form. - */ -function wh_petitions_filter_search_standalone() { - $form = drupal_get_form('wh_petitions_list_page_search_form'); - $form = drupal_render($form); - drupal_set_title(t('Petition Search')); - - return '

' . t('Search') . '

'; -} - -/** - * Callback for the saerch and issues filter standalone forms. - */ -function wh_petitions_filter_results() { - $issues = array(); - if (!empty($_POST['filter_issues'])) { - $tmp = check_plain($_POST['filter_issues']); - foreach ($tmp as $key => $val) { - if ($val > 0) { - array_push($issues, intval($key)); - } - } - } - - // Stick something in the url if they didn't select any. - if (empty($issues)) { - $issues = array(0); - } - - $search = 0; - if (!empty($_POST['filter_search'])) { - $search = urlencode(strip_tags($_POST['filter_search'])); - } - - $arr[0] = 'petitions'; - $arr[1] = 'all'; - $arr[2] = 0; - $arr[3] = 2; - - $url = implode('/', $arr) . '/' . implode('+', $issues) . '/' . $search; - - // Redirect to the main site or the petition tool site, depending on where this request came from - $url = '/petitions/' . $url; - drupal_goto($url); -} - -/** - * Filter by issues form on open petitions list page - */ -function wh_petitions_list_page_issues_form($form, &$form_state) { - global $base_url; - $form['#attributes'] = array('id' => 'form-item-issues-filter', 'class' => array('petition-issue-form')); - $form['#action'] = $base_url . '/filter/results/petitions'; - - // Issues - $issues = array(); - $vocab = taxonomy_vocabulary_machine_name_load('issues'); - $counts = variable_get('wh_petitions_petition_issue_counts', array()); - if (!empty($vocab)) { - $issues_list = taxonomy_get_tree($vocab->vid); - foreach ($issues_list as $issue) { - $issues[$issue->tid] = check_plain($issue->name); - $total = 0; - if (!empty($counts[$issue->tid])) { - $total = $counts[$issue->tid]; - } - $issues[$issue->tid] .= ' - ' . $total . ''; - } - } - - // If there are issues in the url, pre-populate the values in the form - $arg_issues = arg(4); - if (!empty($arg_issues)) { - $arg_issues = explode(' ', $arg_issues); - foreach ($arg_issues as $key => $val) { - $form_state['values']['filter_issues'][$val] = $val; - } - } - - // Issues checkboxes - $form['filter_issues'] = array( - '#type' => 'checkboxes', - '#title' => '', - '#prefix' => '
', - '#suffix' => '
', - '#required' => FALSE, - '#options' => $issues, - '#after_build' => array('wh_petitions_column_checks'), - '#default_value' => !empty($form_state['values']['filter_issues']) ? $form_state['values']['filter_issues'] : array(), - ); - - // Submit Button - $form['report'] = array( - '#type' => 'submit', - '#value' => t('Filter by Issues'), - '#attributes' => array('id' => 'button-filter-petitions', 'class' => array('button')), - ); - - return $form; -} - -/** - * Filter by search form on open petitions list page - */ -function wh_petitions_list_page_search_form($form, &$form_state) { - $form['#attributes'] = array('id' => 'form-item-search-drop'); - global $base_url; - $form['#action'] = $base_url . '/filter/results/petitions'; - - // Prepopulate if there was something in the url - $search = arg(5); - if (!empty($search)) { - $search = strip_tags(urldecode($search)); - $form_state['values']['filter_search'] = check_plain($search); - } - - $form['filter_search'] = array( - '#type' => 'textfield', - '#title' => t('Search Terms'), - '#required' => FALSE, - '#attributes' => array('onfocus' => array("if(this.value=='" . t('Enter your search terms') . "'){this.value=''};")), - '#default_value' => !empty($form_state['values']['filter_search']) ? $form_state['values']['filter_search'] : t('Enter your search terms'), - ); - - // Submit Button - $form['go'] = array( - '#type' => 'submit', - '#value' => t('Go'), - '#attributes' => array('id' => 'search-go-button', 'class' => array('button')), - ); - - return $form; -} - -/****************** SIGN A PETITION ************************/ - -/** - * Sign A Petition form - */ -function wh_petitions_sign_petition_form($form, &$form_state, $petition_id) { - $form['petition_id'] = array( - '#type' => 'hidden', - '#value' => check_plain($petition_id), - ); - - // Sign Button - $form['sign'] = array( - '#type' => 'submit', - '#value' => t('Sign This Petition'), - '#attributes' => array('id' => 'button-sign-this-petition'), - '#submit' => array('wh_petitions_sign_petition_form_submit'), - ); - - return $form; -} - -/** - * Add A Comment standalone page ( 508 compliance ) - */ -function wh_petitions_add_comment_form($petition_id) { - $form = drupal_get_form('wh_petitions_comment_petition_form', $petition_id); - $form = drupal_render($form); - - return '

' . t('Add A Comment') . '

'; -} - -/** - * Comment on A Petition form - */ -function wh_petitions_comment_petition_form($form, &$form_state, $petition_id) { - /* - $form['signature_comment'] = array( - '#type' => 'textarea', - '#title' => t('You are welcome to leave a comment with your signature'), - '#description' => '
240 ' . t('characters remaining') . '
', - '#required' => FALSE, - '#resizable' => FALSE, - '#default_value' => t('Type your comment here ...'), - '#attributes' => array('onfocus' => array("if(this.value==this.defaultValue){this.value=''};"), 'onblur' => array("if(this.value==''){this.value=this.defaultValue;}")), - ); - - $form['petition_id'] = array( - '#type' => 'hidden', - '#value' => check_plain($petition_id), - ); - - global $user; - $form['user_id'] = array( - '#type' => 'hidden', - '#value' => check_plain($user->uid), - ); - - // Next Button - $form['sign'] = array( - '#type' => 'submit', - '#value' => t('Submit'), - '#attributes' => array('class' => array('blue-button'), 'id' => 'submit-comment-with-sig'), - '#submit' => array('wh_petitions_comment_petition_form_submit'), - ); - */ - $text = '

' . variable_get('wh_petitions_comment_modal_text', '') . '

'; - $form['additional'] = array( - '#type' => 'markup', - '#markup' => $text, - ); - - global $base_url; - $form['#action'] = $base_url . '/petition/comment/' . check_plain($petition_id); - - return $form; -} - -/** - * Callback for the submit comment form, for a user to add a comment to their signature. - * - * @todo - Ben - Can't test this so verify the redirect works if it is ever used. - */ -function wh_petitions_add_comment() { - global $user; - $petition_id = strip_tags($_POST['petition_id']); - - // Verify we got a petition id and that it's not blank and that the petition_id in the url matches the one from the POST - if (empty($petition_id) || empty($user->uid)) { - if (!empty($_POST['js']) && $_POST['js'] == TRUE) { - print ''; - exit; - } - else { - return ''; - } - } - - // Verify the user_id matches the one from the POST - if (empty($_POST['user_id']) || $_POST['user_id'] != $user->uid) { - if (!empty($_POST['js']) && $_POST['js'] == TRUE) { - print ''; - exit; - } - else { - return ''; - } - } - - // Load the petition - $conn = wh_petitions_mongo_petition_connection(); - $conn->setSlaveOkay(FALSE); - $petition = wh_petitions_load_slim_petition($conn, $petition_id, array('petition_status')); - - // If it wasn't a valid petition id, exit - if (empty($petition)) { - if (!empty($_POST['js']) && $_POST['js'] == TRUE) { - print ''; - exit; - } - else { - return ''; - } - } - - // Can only sign petitions that are open - private, public, under review - if ($petition['petition_status'] != WH_PETITION_STATUS_PRIVATE && $petition['petition_status'] != WH_PETITION_STATUS_PUBLIC && $petition['petition_status'] != WH_PETITION_STATUS_UNDER_REVIEW) { - if (!empty($_POST['js']) && $_POST['js'] == TRUE) { - print ''; - exit; - } - else { - return ''; - } - } - - // Retrieve the comment and trim it to 255 characters if needed ( someone had js disabled ) - $comment = strip_tags($_POST['signature_comment']); - if (wh_petitions_exceed_char_count($comment, 255)) { - $comment = substr($comment, 0, 255); - } - - // Update the comment - $sig_conn = wh_petitions_mongo_petition_signatures_connection(); - $sig_conn->setSlaveOkay(FALSE); - $sig_conn->update( - array('petition_id' => (string)$petition_id, 'uid' => (int)$user->uid), - array('$set' => array('comment' => $comment)) - ); - - // If this was an AJAX request, pass some data back to browser that we had a success - if (!empty($_POST['js']) && $_POST['js'] == TRUE) { - print '

' . t('Your comment has been added to your signature.') . '

'; - exit; - } - // Redirect to the main site or the petition tool site, depending on where this request came from - else { - drupal_goto($petition['nice_url']); - } -} - -/************** MODAL FORMS *************/ - -/** - * Report this petition as inappropriate form - */ -function wh_petitions_report_inappropriate_form($form, &$form_state, $petition_id) { - global $base_url; - $form['#action'] = $base_url . '/petition/inappropriate/' . check_plain($petition_id); - $form['petition_id'] = array( - '#type' => 'hidden', - '#value' => check_plain($petition_id), - ); - - // Report Button - $form['report'] = array( - '#type' => 'submit', - '#value' => t('Report This Petition'), - '#prefix' => '

' . variable_get('wh_petitions_report_modal_text', '') . '

', - '#attributes' => array('id' => 'button-report-this-petition', 'class' => array('button', 'no-follow')), - ); - - return $form; -} - -/** - * Implements the page version of the delete form - */ -function wh_petitions_delete_form($form, &$form_state, $petition_id) { - $form = drupal_get_form('wh_petitions_delete_petition_form'); - $form = drupal_render($form); - - return $form; -} - -/** - * Delete this petition. Called from the 4th page of the Create A Petition form, or from the user dashboard page. - */ -function wh_petitions_delete_petition_form($form, &$form_state, $petition_id) { - global $base_url; - global $user; - $form['#action'] = $base_url . '/petition/delete/' . check_plain($petition_id); - if (arg(0) == 'petitions' && arg(1) == 'create') { - $form['#action'] .= '?process=create_form'; - } - - $form['petition_id'] = array( - '#type' => 'hidden', - '#value' => check_plain($petition_id), - ); - - // Delete Button - $form['delete'] = array( - '#prefix' => '
', - '#type' => 'submit', - '#value' => t('Delete This Petition'), - '#attributes' => array('id' => 'button-delete-this-petition'), - ); - - // No Delete Button - $form['nothanks'] = array( - '#type' => 'markup', - '#markup' => l(t('No Thanks, Keep This Draft'), 'dashboard', array('attributes' => array('id' => 'button-no-thanks-keep', 'rel' => check_plain($petition_id), 'class' => array('no-follow')))), - '#suffix' => '
', - ); - - return $form; -} - -/************** MODALtaylor CALLBACKS *************/ - -/** - * Implements the 'Report as Inappropriate' modal callback - */ -function wh_petitions_inappropriate_modal($petition_id) { - global $user; - if (!empty($petition_id) && !empty($user->uid)) { - // Load the petition - $conn = wh_petitions_mongo_petition_connection(); - $conn->setSlaveOkay(FALSE); - $petition = array(); - $petition = wh_petitions_load_slim_petition($conn, $petition_id, array('abuse_flags', 'petition_status')); - - // If it wasn't a valid petition id, exit - if (!empty($petition)) { - array_push($petition['abuse_flags'], (int)$user->uid); - - $conn->update( - array('_id' => $petition['_id']), - array('$set' => array('abuse_flags' => $petition['abuse_flags'], 'abuse_count' => sizeof($petition['abuse_flags']))) - ); - } - } - - // Redirect to the main site or the petition tool site, depending on where this request came from - drupal_goto($petition['nice_url']); -} - -/** - * Implements the 'Delete Petition modal callback - */ -function wh_petitions_delete_modal($petition_id) { - global $user; - - if (!empty($petition_id) && !empty($user->uid)) { - // Load the petition - $conn = wh_petitions_mongo_petition_connection(); - $conn->setSlaveOkay(FALSE); - $petition = array(); - $petition = wh_petitions_load_slim_petition($conn, $petition_id, array('uid')); - if ($user->uid == $petition['uid']) { - wh_petitions_delete_petition($conn, $petition_id); - } - } - - $redirect_page = 'dashboard'; - if (!empty($_GET['process'])) { - if ($_GET['process'] == 'create_form') { - $redirect_page = 'petition/deleted'; - } - } - - // Redirect to the main site or the petition tool site, depending on where this request came from - drupal_goto($redirect_page); -} - -/** - * Signs a petition - */ -function wh_petitions_sign_modal($petition_id) { - global $user; - // Verify we got a petition id and that it's not blank and that the petition_id in the url matches the one from the POST - if (empty($petition_id) || empty($user->uid)) { - print 0; - exit; - } - - wh_petitions_sign_petition($petition_id, $user->uid, ip_address(), $_SERVER['HTTP_USER_AGENT']); - - if (!empty($_POST['js']) && !empty($_POST['petition_id'])) { - print '

' . t("You've signed this petition") . '

' . t("Thank you for participating. Find other petitions you're interested in or start your own.") . '

'; - exit; - } - - // Otherwise, just return the output. - $url = 'petition/add/comment/' . $petition_id; - drupal_goto($url); -} - -/** - * Ensures that all character counting is the same. Returns true if the string exceeds the count. - */ -function wh_petitions_exceed_char_count($string, $chars) { - $string = str_replace("\r\n", "\n", $string); - if (mb_strlen($string) > $chars) { - return TRUE; - } - else { - return FALSE; - } -} diff --git a/modules/custom/wh_petitions/wh_petitions.generate.inc b/modules/custom/wh_petitions/wh_petitions.generate.inc deleted file mode 100644 index 741ec5e85..000000000 --- a/modules/custom/wh_petitions/wh_petitions.generate.inc +++ /dev/null @@ -1,250 +0,0 @@ -vid); - foreach ($issues_list as $issue) { - array_push($issues, $issue->tid); - } - } - - for ($i=0;$i<$num;$i++) { - // Published, Reached Public dates - $days = rand(1, 40); - $published = strtotime("- " . $days . " days"); - $to_public = rand(1, 29); - $public = strtotime("+ " . $to_public . " days", $published); - - // Issues, between 1 and 3 - $issue_arr = array(); - $issue_num = rand(1, 3); - $issue_size = sizeof($issues); - for ($j=0; $j<$issue_num; $j++) { - $key = rand(0, ($issue_size - 1)); - array_push($issue_arr, (int)$issues[$key]); - } - - $title = create_title(rand(1, 10)); - $arr = explode(" ", $title); - $words = array(); - foreach ($arr as $word) { - $word = preg_replace('/[^A-Za-z0-9]/', '', $word); - array_push($words, trim($word)); - } - $title_keys = $words; - $body = create_title(rand(1, 100)); - $arr = explode(" ", $body); - $words = array(); - foreach ($arr as $word) { - $word = preg_replace('/[^A-Za-z0-9]/', '', $word); - array_push($words, trim($word)); - } - $body_keys = $words; - - if (empty($uid)) { - $pet_uid = 161; // dleonard - } - else { - $pet_uid = $uid; - } - - if ($status == '') { - $pet_status = rand(0, 6); - } - else { - $pet_status = $status; - } - - $ready = 0; - $response_status = WH_PETITION_RESPONSE_STATUS_UNANSWERED; - if ($pet_status == WH_PETITION_STATUS_DRAFT) { - $sig_count = 0; - } - elseif ($pet_status == WH_PETITION_STATUS_PRIVATE) { - $sig_count = rand(1, variable_get('wh_petitions_public_signatures', 20)); - } - elseif ($pet_status == WH_PETITION_STATUS_PUBLIC) { - $sig_count = rand(variable_get('wh_petitions_public_signatures', 20), variable_get('wh_petitions_review_signatures', 500)); - } - elseif ($pet_status == WH_PETITION_STATUS_UNDER_REVIEW) { - $sig_count = rand((variable_get('wh_petitions_review_signatures', 500) + 1), 100000); - $days = rand(1, 20); - $ready = strtotime("- " . $days . " days"); - $response_status = WH_PETITION_RESPONSE_STATUS_PENDING; - } - elseif ($pet_status == WH_PETITION_STATUS_CLOSED) { - $sig_count = rand(1, variable_get('wh_petitions_review_signatures', 500)); - } - elseif ($pet_status == WH_PETITION_STATUS_REVIEWED) { - $sig_count = rand((variable_get('wh_petitions_review_signatures', 500) + 1), 100000); - $days = rand(1, 20); - $ready = strtotime("- " . $days . " days"); - $response_status = WH_PETITION_RESPONSE_STATUS_ANSWERED; - } - elseif ($pet_status == WH_PETITION_STATUS_FLAGGED) { - $sig_count = rand(1, variable_get('wh_petitions_review_signatures', 500)); - } - $timeframe = rand(1, 30); - - $petition = array( - 'uid' => (int)$pet_uid, // Drupal UID of the creator - 'title' => $title, // Display title of the petition - 'title_keywords' => $title_keys, - 'body' => $body, // The body/description of the petition - 'body_keywords' => $body_keys, - 'body_revisions' => array(), // Array of previous petition object ids; only admins can edit a non-draft petition - 'response_id' => 0, // Drupal NID of the response instance - 'issues' => $issue_arr, // Array of taxonomy term IDs - 'user_tags' => array(), // Array of taxonomy term IDs for user-submitted tags - 'private_tags' => array(), // Array of taxonomy term IDs for private admin-added tags - 'related_petitions' => array(), // Array of Mongo IDs of related petitions - 'petition_status' => (int)$pet_status, // State of the petition: public, private, in review, reviewed - 'response_status' => $response_status, // state of the response: none, presidential, etc. - 'published' => (int)$published, // timestamp for when this petition was published - 'reached_public' => (int)$public, // timestamp for when this petition reached the required signatures to become public - 'reached_ready' => (int)$ready, // timestamp for when this petition reached the required signatures to receive a review - 'closed' => 0, // timestamp for when this petition was responded to - 'signature_count' => (int)$sig_count, // count of signatures - 'abuse_flags' => array(), // Drupal UIDs of people who have flagged this as abuse - 'abuse_count' => rand(0, 5000), // Count of times this has been reported for abuse - 'review_timeframe' => $timeframe, // Number of days the petition has to reach X signatures and receive a review - 'response_signatures' => variable_get('wh_petitions_review_signatures', 500), // Number of signatures required to receive a response - 'public_signatures' => variable_get('wh_petitions_public_signatures', 500), // Number of signatures needed to become public - 'featured' => rand(0, 1), - 'bookmarked' => array(), - 'hidden' => 0, - ); - - - wh_petitions_generate_nice_url($petition); - - $petition_id = wh_petitions_save_petition($conn, $petition); - - create_signatures($sig_count, $pet_uid, $published, $petition_id); - } -} - -/** - * Helper function to create the signatures for each petition - */ -function create_signatures($sig_count, $uid, $published, $petition_id) { - $conn = wh_petitions_mongo_petition_signatures_connection(); - - // User signs their own - $signature = array( - 'petition_id' => $petition_id, - 'uid' => (int)$uid, - 'timestamp' => (int)$published, - 'comment' => create_title(rand(1, 25)), - 'abuse_flags' => array(), - 'status' => 1, - 'number' => 1, - 'user' => array( - 'first_name' => 'first-' . rand(1, 1000), - 'last_name' => 'last-' . rand(1, 1000), - 'city' => 'city-' . rand(1, 1000), - 'state' => rand(10, 99), - 'zip' => rand(10000, 99999), - 'username' => 'uname-' . rand(1, 1000), - 'country' => 'Country', - ), - ); - wh_petitions_save_signature($signature, $conn); - $sig_count--; - - for ($i=0;$i<$sig_count;$i++) { - $uid = rand(1, 1000000); - $days = rand(0, 50); - $ts = strtotime("- " . $days . " days"); - $signature = array( - 'petition_id' => $petition_id, - 'uid' => (int)$uid, - 'timestamp' => (int)$ts, - 'comment' => create_title(rand(1, 25)), - 'abuse_flags' => array(), - 'status' => 1, - 'number' => ($i + 2), - 'user' => array( - 'first_name' => 'first-' . rand(1, 1000), - 'last_name' => 'last-' . rand(1, 1000), - 'city' => 'city-' . rand(1, 1000), - 'state' => rand(10, 99), - 'zip' => rand(10000, 99999), - 'username' => 'uname-' . rand(1, 1000), - 'country' => 'Country', - ) - ); - wh_petitions_save_signature($signature, $conn); - } - - return true; -} - -/** - * Helper function to create any field that needs words, copied from devel generate content - */ -function create_title($word_count, $title = FALSE) { - $dictionary = array("abbas", "abdo", "abico", "abigo", "abluo", "accumsan", - "acsi", "ad", "adipiscing", "aliquam", "aliquip", "amet", "antehabeo", - "appellatio", "aptent", "at", "augue", "autem", "bene", "blandit", - "brevitas", "caecus", "camur", "capto", "causa", "cogo", "comis", - "commodo", "commoveo", "consectetuer", "consequat", "conventio", "cui", - "damnum", "decet", "defui", "diam", "dignissim", "distineo", "dolor", - "dolore", "dolus", "duis", "ea", "eligo", "elit", "enim", "erat", - "eros", "esca", "esse", "et", "eu", "euismod", "eum", "ex", "exerci", - "exputo", "facilisi", "facilisis", "fere", "feugiat", "gemino", - "genitus", "gilvus", "gravis", "haero", "hendrerit", "hos", "huic", - "humo", "iaceo", "ibidem", "ideo", "ille", "illum", "immitto", - "importunus", "imputo", "in", "incassum", "inhibeo", "interdico", - "iriure", "iusto", "iustum", "jugis", "jumentum", "jus", "laoreet", - "lenis", "letalis", "lobortis", "loquor", "lucidus", "luctus", "ludus", - "luptatum", "macto", "magna", "mauris", "melior", "metuo", "meus", - "minim", "modo", "molior", "mos", "natu", "neo", "neque", "nibh", - "nimis", "nisl", "nobis", "nostrud", "nulla", "nunc", "nutus", "obruo", - "occuro", "odio", "olim", "oppeto", "os", "pagus", "pala", "paratus", - "patria", "paulatim", "pecus", "persto", "pertineo", "plaga", "pneum", - "populus", "praemitto", "praesent", "premo", "probo", "proprius", - "quadrum", "quae", "qui", "quia", "quibus", "quidem", "quidne", "quis", - "ratis", "refero", "refoveo", "roto", "rusticus", "saepius", - "sagaciter", "saluto", "scisco", "secundum", "sed", "si", "similis", - "singularis", "sino", "sit", "sudo", "suscipere", "suscipit", "tamen", - "tation", "te", "tego", "tincidunt", "torqueo", "tum", "turpis", - "typicus", "ulciscor", "ullamcorper", "usitas", "ut", "utinam", - "utrum", "uxor", "valde", "valetudo", "validus", "vel", "velit", - "veniam", "venio", "vereor", "vero", "verto", "vicis", "vindico", - "virtus", "voco", "volutpat", "vulpes", "vulputate", "wisi", "ymo", - "zelus"); - $dictionary_flipped = array_flip($dictionary); - - $greeking = ''; - - if (!$title) { - $words_remaining = $word_count; - while ($words_remaining > 0) { - $sentence_length = mt_rand(3, 10); - $words = array_rand($dictionary_flipped, $sentence_length); - $sentence = implode(' ', $words); - $greeking .= ucfirst($sentence) . '. '; - $words_remaining -= $sentence_length; - } - } - else { - // Use slightly different method for titles. - $words = array_rand($dictionary_flipped, $word_count); - $greeking = ucwords(implode(' ', $words)); - } - - // Work around possible php garbage collection bug. Without an unset(), this - // function gets very expensive over many calls (php 5.2.11). - unset($dictionary, $dictionary_flipped); - return trim($greeking); -} diff --git a/modules/custom/wh_petitions/wh_petitions.info b/modules/custom/wh_petitions/wh_petitions.info deleted file mode 100644 index 75c569c62..000000000 --- a/modules/custom/wh_petitions/wh_petitions.info +++ /dev/null @@ -1,21 +0,0 @@ -name = "WH Petitions" -description = "Core functionality for Petitions" -package = "Custom" -core = "7.x" -version = "7.x-1.2" - -dependencies[] = "mongodb" -dependencies[] = "pathauto" -dependencies[] = "taxonomy" -dependencies[] = "taxonomy_sync" -dependencies[] = "wh_response" -dependencies[] = "wh_user_profile" - -files[] = wh_petitions.admin.inc -files[] = wh_petitions.cron.inc -files[] = wh_petitions.form.inc -files[] = wh_petitions.generate.inc -files[] = wh_petitions.module -files[] = wh_petitions.pages.inc -files[] = wh_petitions.tokens.inc - diff --git a/modules/custom/wh_petitions/wh_petitions.module b/modules/custom/wh_petitions/wh_petitions.module deleted file mode 100644 index addad82a3..000000000 --- a/modules/custom/wh_petitions/wh_petitions.module +++ /dev/null @@ -1,1490 +0,0 @@ - array( - 'title' => t('Administer petition settings'), - 'description' => t('Change petition and signature levels, administer block and page text.'), - ), - 'administer petitions' => array( - 'title' => t('Administer petitions'), - 'description' => t(''), - ), - 'create petition' => array( - 'title' => t('Create a petition'), - 'description' => '', - ), - ); -} - -/** - * Implements hook_menu(). - */ -function wh_petitions_menu() { - // Admin - Petition Tool Settings - $items['admin/config/system/petitions'] = array( - 'title' => 'Petition Tool Settings', - 'description' => 'Manage petition settings and text.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('wh_petitions_admin_petition_settings'), - 'access arguments' => array('administer petition settings'), - 'weight' => -10, - 'file' => 'wh_petitions.admin.inc', - ); - - // Admin - Petition Dashboard - $items['admin/petitions'] = array( - 'title' => 'Petitions', - 'description' => 'Administer petitions.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('wh_petitions_admin_petitions'), - 'access arguments' => array('administer petitions'), - 'weight' => -10, - 'file' => 'wh_petitions.admin.inc', - ); - - // Admin - Petition Dashboard - $items['admin/petitions/download_signatures/%'] = array( - 'title' => 'Download Signatures', - 'description' => 'Download petition signatures.', - 'page callback' => 'wh_petitions_download_signatures_run_batch', - 'page arguments' => array(3), - 'access arguments' => array('administer petitions'), - 'weight' => -10, - 'file' => 'wh_petitions.admin.inc', - ); - -// Admin - Petition Dashboard - $items['admin/petitions/download_signatures/%/%'] = array( - 'title' => 'Download Signatures', - 'description' => 'Download petition signatures.', - 'page callback' => 'wh_petitions_download_signatures', - 'page arguments' => array(3, 4), - 'access arguments' => array('administer petitions'), - 'weight' => -10, - 'file' => 'wh_petitions.admin.inc', - ); - - - // Admin - AJAX callbacks - $items['admin/bookmark/%'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_bookmark_petitions', - 'page arguments' => array(2), - 'access arguments' => array('administer petitions'), - 'file' => 'wh_petitions.admin.inc', - ); - $items['admin/featured/%'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_feature_petitions', - 'page arguments' => array(2), - 'access arguments' => array('administer petitions'), - 'file' => 'wh_petitions.admin.inc', - ); - $items['admin/remove-lists/%'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_remove_lists', - 'page arguments' => array(2), - 'access arguments' => array('administer petitions'), - 'file' => 'wh_petitions.admin.inc', - ); - $items['admin/override-status/%'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_override_status', - 'page arguments' => array(2), - 'access arguments' => array('administer petitions'), - 'file' => 'wh_petitions.admin.inc', - ); - - // Autocomplete field for Petitions on the Apply Response form - $items['response-autocomplete'] = array( - 'page callback' => 'wh_petitions_response_autocomplete', - 'page arguments' => array(), - 'access arguments' => array('administer petitions'), - 'type' => MENU_CALLBACK, - 'file' => 'wh_petitions.admin.inc', - ); - - // Open Petitions section - $items['petitions'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_show_petitions', - 'page arguments' => array(), - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.pages.inc', - ); - - // Petition Detail page - $items['petition/detail/%'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_petition_detail', - 'page arguments' => array(2), - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.pages.inc', - ); - // Petition Detail for Nice URL - $items['petition/%'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_petition_detail_niceurl', - 'page arguments' => array(1), - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.pages.inc', - ); - - // Email A Petition callbacks - $items['petition/email/%'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_email_petition', - 'page arguments' => array(2), - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.pages.inc', - ); - $items['petition/email_frame/%'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_email_petition_frame', - 'page arguments' => array(2), - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.pages.inc', - ); - $items['petition/email_thank/%'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_email_petition_thank_you', - 'page arguments' => array(2), - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.pages.inc', - ); - - // Iframe with the create a petition form inside - $items['petitions/create'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_create_petition_iframe_html', - 'page arguments' => array(), - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.form.inc', - ); - - // Create A Petition Form ( access control done in callback function ) - $items['petition/create'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_create_petition_iframe', - //'page callback' => 'drupal_get_form', - 'page arguments' => array('wh_petitions_create_petition'), - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.form.inc', - ); - - // User Dashboard ( access control done in page callback function ) - $items['dashboard'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_user_dashboard', - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.pages.inc', - ); - - // More Signatures AJAX call - $items['signatures/more/%/%/%'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_more_signatures', - 'page arguments' => array(2, 3, 4), - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.pages.inc', - ); - - // More Petitions AJAX call - $items['petitions/more/%/%/%/%'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_more_petitions', - 'page arguments' => array(2, 3, 4, 5), - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.pages.inc', - ); - - // Report as Inappropriate modal AJAX call - $items['petition/inappropriate/%'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_inappropriate_modal', - 'page arguments' => array(2, 3), - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.form.inc', - ); - - // Delete Petition callback - $items['petition/delete/%'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_delete_modal', - 'page arguments' => array(2), - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.form.inc', - ); - - // Delete Petition Page callback - $items['petition/deleted'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_deleted_page', - 'page arguments' => array(), - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.pages.inc', - ); - - // Sign Petition AJAX call - $items['petition/sign/%'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_sign_modal', - 'page arguments' => array(2), - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.form.inc', - ); - - // Add Comment Form - $items['petition/add/comment/%'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_add_comment_form', - 'page arguments' => array(3), - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.form.inc', - ); - - // Add Comment AJA callback - $items['petition/comment/%'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_add_comment', - 'page arguments' => array(2), - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.form.inc', - ); - - // Filter Issue Form Standalone Page ( for compliance - they're in hidden divs that use JS normally ) - $items['filter-issues'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_filter_issue_standalone', - 'page arguments' => array(), - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.form.inc', - ); - - // Search Form Standalone Page ( for compliance - they're in hidden divs that use JS normally ) - $items['filter-search'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_filter_search_standalone', - 'page arguments' => array(), - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.form.inc', - ); - - // Filter/Search results callback - $items['filter/results/petitions'] = array( - 'title' => '', - 'description' => '', - 'page callback' => 'wh_petitions_filter_results', - 'page arguments' => array(), - 'access arguments' => array('access content'), - 'file' => 'wh_petitions.form.inc', - ); - - return $items; -} - -/** - * Implements hook_theme(). - */ -function wh_petitions_theme() { - return array( - // Thank You Page after a user has published a petition. - 'wh_petitions_page_thank_you' => array( - 'arguments' => array(), - 'template' => 'templates/wh-petitions-page-thank-you', - ), - // Petition Detail Page - 'wh_petitions_page_petition' => array( - 'arguments' => array(), - 'template' => 'templates/wh-petitions-page-petition', - ), - // Page a user sees after they delete a petition - 'wh_petitions_page_deleted' => array( - 'arguments' => array(), - 'template' => 'templates/wh-petitions-page-deleted', - ), - // Generic archived petition page - 'wh_petitions_page_archived' => array( - 'arguments' => array(), - 'template' => 'templates/wh-petitions-page-archived', - ), - // User Dashboard page - 'wh_petitions_user_dashboard' => array( - 'arguments' => array(), - 'template' => 'templates/wh-petitions-page-user-dashboard', - ), - // Signatures display on a petition detail page - 'wh_petitions_display_signatures' => array( - 'arguments' => array(), - 'template' => 'templates/wh-petitions-display-signatures', - ), - // Petition info at the top of a petition page, last page of create a petition - 'wh_petitions_display_petition_info' => array( - 'arguments' => array(), - 'template' => 'templates/wh-petitions-display-petition-info', - ), - // Open Petitions page - 'wh_petitions_display_petition_page' => array( - 'arguments' => array(), - 'template' => 'templates/wh-petitions-page-open-petitions', - ), - // List view display of a petition - 'wh_petitions_display_list_petition' => array( - 'arguments' => array(), - 'template' => 'templates/wh-petitions-display-list-petition', - ), - // Header on Create A Petition section - 'wh_petitions_create_header' => array( - 'arguments' => array(), - 'template' => 'templates/wh-petitions-create-header', - ), - // Renders the By The Numbers block body - 'wh_petitions_by_the_numbers' => array( - 'arguments' => array(), - 'template' => 'templates/wh-petitions-by-the-numbers', - ), - // Displays the title field on the create a petition form. - 'wh_petition_title' => array( - 'render element' => 'element', - ), - ); -} - -/** - * Implements hook_block_info(). - */ -function wh_petitions_block_info() { - $blocks['wh_petitions_by_numbers'] = array( - 'info' => 'By The Numbers', - 'cache' => DRUPAL_CACHE_GLOBAL, - ); - $blocks['wh_petitions_create_account'] = array( - 'info' => 'Create a WH Account', - 'cache' => DRUPAL_CACHE_GLOBAL, - ); - $blocks['wh_petitions_create_petition'] = array( - 'info' => 'Create Petition Button', - 'cache' => DRUPAL_CACHE_GLOBAL, - ); - $blocks['wh_petitions_back_to_top'] = array( - 'info' => 'Back to top', - 'cache' => DRUPAL_CACHE_GLOBAL, - ); - $blocks['wh_petitions_email_signup'] = array( - 'info' => 'Email Signup', - 'cache' => DRUPAL_CACHE_GLOBAL, - ); - $blocks['wh_petitions_featured_petition'] = array( - 'info' => 'Helpful Hints', - 'cache' => DRUPAL_CACHE_PER_PAGE, - ); - $blocks['wh_petitions_helpful_hints'] = array( - 'info' => 'Helpful Hints', - 'cache' => DRUPAL_CACHE_PER_PAGE, - ); - $blocks['wh_petitions_history'] = array( - 'info' => 'History of Petitions', - 'cache' => DRUPAL_CACHE_GLOBAL, - ); - $blocks['wh_petitions_recent_petitions'] = array( - 'info' => t('Recent Petitions'), - 'cache' => DRUPAL_CACHE_GLOBAL, - ); - $blocks['wh_petitions_similar_petitions'] = array( - 'info' => t('Similar Petitions'), - 'cache' => DRUPAL_CACHE_PER_PAGE, - ); - $blocks['wh_petitions_trending_petitions'] = array( - 'info' => t('Trending Petitions'), - 'cache' => DRUPAL_CACHE_GLOBAL, - ); - - return $blocks; -} - -/** - * Implements hook_block_view(). - */ -function wh_petitions_block_view($delta) { - $block = array(); - - switch ($delta) { - // By The Numbers - case 'wh_petitions_by_numbers': - $block['subject'] = t('By The Numbers'); - $block['content'] = wh_petitions_by_the_numbers(); - break; - // Create A WH Account - case 'wh_petitions_create_account': - $block['subject'] = t('Create a WH Account'); - $block['content'] = variable_get('wh_petitions_create_account_block_text', ''); - break; - // Create A Petition - case 'wh_petitions_create_petition': - $block['subject'] = ''; - $block['content'] = l(t('Create A Petition'), 'petition/create', array('attributes' => array('class' => array('button'), 'id' => 'button-create-a-petition'))); - break; - case 'wh_petitions_back_to_top': - $block['subject'] = ''; - $block['content'] = 'Back to top'; - break; - // Email Updates - case 'wh_petitions_email_signup': - $block['subject'] = t('Sign Up For Email Updates'); - $block['content'] = variable_get('wh_petitions_email_updates_block_text', t('Sign Up for Updates from President Obama and Other Senior Officials.')); - break; - // History of Petitions - case 'wh_petitions_history': - $block['subject'] = t('History of Petitions'); - $block['content'] = variable_get('wh_petitions_history_block_text', ''); - break; - // Helpful Hints - case 'wh_petitions_helpful_hints': - $block['subject'] = t('Helpful Hints'); - - global $user; - $content = ''; - if (arg(0) == 'petition' && arg(1) == 'create') { - $content = variable_get('wh_petitions_hints_create_petition', ''); - } - elseif (arg(0) == 'petitions') { - $content = variable_get('wh_petitions_hints_open_petitions', ''); - } - elseif (arg(0) == 'petition' && arg(1) == 'detail') { - $content = variable_get('wh_petitions_hints_petition_detail', ''); - } - elseif (arg(0) == 'responses') { - $content = variable_get('wh_petitions_hints_responses', ''); - } - elseif (arg(0) == 'response' && arg(1) == 'detail') { - $content = variable_get('wh_petitions_hints_response_detail', ''); - } - elseif (arg(0) == 'dashboard' && !empty($user->uid)) { - $content = variable_get('wh_petitions_hints_dashboard', ''); - } - else { - $content = variable_get('wh_petitions_hints_misc', ''); - } - - $block['content'] = $content; - break; - // Recent Petitions - case 'wh_petitions_recent_petitions': - $block['subject'] = t('Recent Petitions'); - - // Get 3 most recent petitions - $conn = wh_petitions_mongo_petition_connection(); - $query = array( - 'petition_status' => array( - '$in' => array((int)WH_PETITION_STATUS_PUBLIC, (int)WH_PETITION_STATUS_UNDER_REVIEW) - ), - 'hidden' => 0, - ); - $sort_query = array( - 'reached_public' => -1, - ); - $result = $conn->find($query, array('title', 'nice_url'))->sort($sort_query)->limit(3); - - $html = '
    '; - foreach ($result as $res) { - $html .= '
  • ' . l($res['title'], $res['nice_url']) . '
  • '; - } - $html .= '
'; - - $block['content'] = $html; - break; - // Similar Petitions - case 'wh_petitions_similar_petitions': - $block['subject'] = t('Similar Petitions'); - - // Only should display content on a petition detail page. - if ((arg(0) == 'petition')) { - $conn = wh_petitions_mongo_petition_connection(); - $petition_id = wh_petitions_get_petition_id($conn); - $block['content'] = wh_petitions_similar_petitions($conn, $petition_id); - } - else { - $block['content'] = ''; - } - break; - // Trending Petitions - case 'wh_petitions_trending_petitions': - $block['subject'] = t('Trending Petitions'); - - // Get 3 most trending petitions - $conn = wh_petitions_mongo_petition_connection(); - module_load_include('inc', 'wh_petitions', 'wh_petitions.pages'); - $total = 0; - $result = wh_petitions_trending_results($conn, 0, 3, $total); - - $html = '
    '; - foreach ($result as $res) { - $html .= '
  • ' . l($res['title'], $res['nice_url']) . '
  • '; - } - $html .= '
'; - - $block['content'] = $html; - break; - } - - return $block; -} - -/** - * Implements hook_hook_info() - */ -function wh_petitions_hook_info() { - $hooks = array(); - $hooks['wh_petitions_signature_save'] = array( - 'group' => 'petitions', - ); - return $hooks; -} - -/** - * Pulls a list of petitions with more signatures than the compliance review - * threshold and which have not been sent compliance review notifications - * - */ -function wh_petitions_compliance_review_threshold_check($threshold, $compliance_reviewer_emails) { - if ($compliance_reviewer_emails && (int) $threshold) { - $petition_connection = wh_petitions_mongo_petition_connection(); - - $where = array( - 'signature_count' => array('$gte' => (int) $threshold), //have to cast it because otherwise mongo treats it as string - '$or' => array( - array('review_threshold_mail_sent' => 0), - array('review_threshold_mail_sent' => array('$exists' => FALSE)), - ), - 'petition_status' => array('$in' => array(WH_PETITION_STATUS_DRAFT, WH_PETITION_STATUS_PRIVATE, WH_PETITION_STATUS_PUBLIC)), - ); - $fields = array( - '_id', - 'signature_count', - 'review_threshold_mail_sent', - ); - $notification_list = $petition_connection->find($where, $fields); - - foreach($notification_list as $notification) { - $petition = wh_petitions_load_slim_petition($petition_connection, $notification['_id'], array('body')); - - $message = drupal_mail('wh_petitions', 'review_threshold_passed', $compliance_reviewer_emails, language_default(), array('petition' => $petition, )); - - //set the var on the petition record so we know the mail has been sent - $petition_connection->update( - array('_id' => $petition['_id']), - array('$set' => array('review_threshold_mail_sent' => time())) - ); - - watchdog('wh_petitions', 'Petition (@id) Review Threshold Notification Sent.', array('@id' => $notification['_id'])); - } - } -} - -/** - * By The Numbers block body - */ -function wh_petitions_by_the_numbers() { - $conn = wh_petitions_mongo_petition_connection(); - $numbers = array(); - - // Total Petitions that are open - if (variable_get('wh_petitions_numbers_open_petitions', FALSE)) { - $query = array( - 'petition_status' => array( - '$in' => array((int)WH_PETITION_STATUS_PUBLIC, (int)WH_PETITION_STATUS_UNDER_REVIEW) - ), - 'hidden' => 0, - ); - $total = $conn->find($query)->count(); - array_push($numbers, array('key' => t('Open Petitions'), 'value' => check_plain(wh_petitions_format_number($total)))); - } - // Total Responses that are published - if (variable_get('wh_petitions_numbers_responses', FALSE)) { - $query = db_select('node', 'n', array('target' => 'slave')); - $query->fields('n', array('nid')) - ->condition('n.type', 'wh_response') - ->condition('n.status', 0, '<>'); - $total = $query->countQuery()->execute()->fetchField(); - array_push($numbers, array('key' => t('Total Responses'), 'value' => check_plain(wh_petitions_format_number($total)))); - } - // Signatures in Past 24 Hours - if (variable_get('wh_petitions_numbers_signatures_24', FALSE)) { - $sig_conn = wh_petitions_mongo_petition_signatures_connection(); - $timestamp = strtotime("-1 day"); - $query = array( - 'timestamp' => array('$gt' => (int)$timestamp) - ); - $total = $sig_conn->find($query)->count(); - array_push($numbers, array('key' => t('Signatures in Past 24 Hours'), 'value' => check_plain(wh_petitions_format_number($total)))); - } - - return theme('wh_petitions_by_the_numbers', array('numbers' => $numbers)); -} - -/** - * Similar Petitions block body - */ -function wh_petitions_similar_petitions(&$conn, $petition_id) { - $petition = wh_petitions_load_slim_petition($conn, $petition_id, array('issues', 'title_keywords')); - if (empty($petition)) { - return ''; - } - - // Get the issues into an array of keys - $issues = array(); - foreach ($petition['issues'] as $key => $val) { - if ($val > 0) { - array_push($issues, intval($val)); - } - } - - // Removed common words from the string of title keywords - $title_keywords = $petition['title_keywords']; - $title_terms = array(); - foreach ($title_keywords as $term) { - if (!in_array($term, array("and", "in", "this", "or", "a", "the", "an", "as", "at", "but", "by", "before", "for", "from", "is", "like", "of", "on", "onto", "than", "this", "that", "to", "with"))) { - array_push($title_terms, $term); - } - } - - // Retrive the top 3 results sorted by signature count DESC that match all the issues and at least one of the title words and are not the current petition - $similar = ''; - $count = 0; - $query = array( - 'petition_status' => array( - '$in' => array((int)WH_PETITION_STATUS_PUBLIC, (int)WH_PETITION_STATUS_UNDER_REVIEW) - ), - 'hidden' => 0, - 'issues' => array('$in' => $issues), - 'title_keywords' => array('$in' => $title_terms), - '_id' => array('$ne' => $petition['_id']), - ); - $result = $conn->find($query, array('title', 'nice_url'))->sort(array('signature_count' => -1))->limit(3); - - $html = ''; - foreach ($result as $res) { - if (empty($html)) { - $html = '
    '; - } - $html .= '
  • ' . l($res['title'], $res['nice_url']) . '
  • '; - } - if (!empty($html)) { - $html .= '
'; - } - - return $html; -} - -/** - * Implementation of hook_cron(). - * - * Include the function to close any open petitions that have exceeded the limit for amount of days to be open. This function also updates the trending petitions and the counts - * of how many petitions/responses are related to each issue term. - */ -function wh_petitions_cron() { - module_load_include('inc', 'wh_petitions', 'wh_petitions.cron'); - wh_petitions_close_petitions(); - - $email = variable_get('wh_petitions_compliance_reviewer_emails', FALSE); - $threshold = (int)variable_get('wh_petitions_compliance_review_threshold', FALSE); - wh_petitions_compliance_review_threshold_check($threshold, $email); -} - -/** - * Helper function to format a number correctly. ( no decimals, commas for thousands-separators ) - */ -function wh_petitions_format_number($number) { - return number_format(intval($number), 0, '.', ','); -} - -/** - * Helper function to format a description on the petition detail and preview pages ( step 4 - create a petition ) - */ -function wh_petitions_format_description($description) { - if (!empty($description)) { - // Consolidate newlines - $description = preg_replace('/[\r\n]+/', "\n", $description); - $arr = explode("\n", $description); - - $new_description = ''; - foreach ($arr as $line) { - $new_description .= '

' . check_plain(trim($line)) . '

'; - } - $description = $new_description; - } - - return $description; -} - -/** - * Emails the creator of a petition when their petition is published. - */ -function wh_petitions_email_published($petition_id, $uid) { - if (!empty($uid)) { - $user_load = user_load($uid); - - if (!empty($user_load)) { - $email = $user_load->mail; - $params = array('petition_id' => $petition_id); - $from = variable_get('wh_petitions_email_address', ''); - drupal_mail('wh_petitions', 'published', $email, language_default(), $params, $from); - } - } -} - -/** - * Emails the creator of a petition when their petition becomes under review ( enough signatures to receive a response ) - */ -function wh_petitions_email_ready_response($petition_id, $uid) { - if (!empty($uid)) { - $user_load = user_load($uid); - - if (!empty($user_load)) { - $email = $user_load->mail; - $params = array(); - $from = variable_get('wh_petitions_email_address', ''); - //drupal_mail('wh_petitions', 'ready_response', $email, language_default(), $params, $from); - } - } -} - -/** - * Emails the creator of a petition when their petition receives a response. Currently not active. - */ -function wh_petitions_email_receive_response($petition_id, $uid) { - if (!empty($uid)) { - $user_load = user_load($uid); - - if (!empty($user_load)) { - $email = $user_load->mail; - $params = array(); - $from = variable_get('wh_petitions_email_address', ''); - //drupal_mail('wh_petitions', 'receive_response', $email, language_default(), $params, $from); - } - } -} - -/** - * Implements hook_mail(). - * - * Implements the email messages for when a petition is published, is ready for a response and receives a response. - */ -function wh_petitions_mail($key, &$message, $params) { - global $base_url; - $options['language'] = $message['language']; - - switch ($key) { - case 'published': - $langcode = $message['language']->language; - $message['subject'] = variable_get('wh_petitions_email_published_subject', ''); - $message['body'][] = variable_get('wh_petitions_email_published_text', ''); - - $conn = wh_petitions_mongo_petition_connection(); - $petition = wh_petitions_load_slim_petition($conn, $params['petition_id'], array('review_timeframe', 'response_signatures', 'public_signatures', 'published', 'body')); - if (!empty($petition)) { - - // In case the short URL isn't available, use the absolute form of the - // nice URL to use in emails, so that there's at least *something* to - // click on. We don't want to store that value in the short_url of the - // petition so that we can regenerate it later (leave it as false). - $full_link = url($base_url .'/'. $petition['nice_url'], array('absolute' => TRUE)); - - if (empty($petition['short_url'])) $petition['short_url'] = $full_link; - $time = $petition['published']; - $end_date = strtotime('+' . $petition['review_timeframe'] . ' days', $time); - $end_date = date("F d, Y", $end_date); - $message['subject'] = str_replace('!shorturl', $petition['short_url'], $message['subject']); - $message['subject'] = str_replace('!petition_title', $petition['title'], $message['subject']); - $message['body'][0] = str_replace('!petition_description', check_plain($petition['body']), $message['body'][0]); - $message['body'][0] = str_replace('!shorturl', check_plain($petition['short_url']), $message['body'][0]); - $message['body'][0] = str_replace('!petition_title', check_plain($petition['title']), $message['body'][0]); - $message['body'][0] = str_replace('!signatures_needed', wh_petitions_format_number($petition['response_signatures']), $message['body'][0]); - $message['body'][0] = str_replace('!public_signatures', wh_petitions_format_number($petition['public_signatures']), $message['body'][0]); - $message['body'][0] = str_replace('!date_needed', $end_date, $message['body'][0]); - $message['body'][0] = str_replace('!day_timeframe', wh_petitions_format_number($petition['review_timeframe']), $message['body'][0]); - } - else { - unset($message); - } - break; - case 'review_threshold_passed': - $langcode = $message['language']->language; - $message['subject'] = variable_get('wh_petitions_review_threshold_passed_subject', ''); - $message['body'][] = variable_get('wh_petitions_review_threshold_passed_text', ''); - - $petition = $params['petition']; - - if (!empty($petition)) { - $message['body'][0] = str_replace('!petition_id', check_plain($petition['_id']), $message['body'][0]); - $message['body'][0] = str_replace('!petition_edit_link', variable_get('petitions_edit_url', $base_url) . '/admin/petitions/' . check_plain($petition['_id']), $message['body'][0]); - $message['body'][0] = str_replace('!petition_title', check_plain($petition['title']), $message['body'][0]); - $message['body'][0] = str_replace('!petition_body', check_plain($petition['body']), $message['body'][0]); - } - else { - unset($message); - } - break; - - case 'ready_response': - $langcode = $message['language']->language; - $message['subject'] = variable_get('wh_petitions_email_ready_response_subject', ''); - $message['body'][] = variable_get('wh_petitions_email_ready_response_text', ''); - break; - case 'receive_response': - $langcode = $message['language']->language; - $message['subject'] = variable_get('wh_petitions_email_receive_response_subject', ''); - $message['body'][] = variable_get('wh_petitions_email_receive_response_text', ''); - break; - case 'status_change': - if ($params['petition']['petition_status'] == 6) { - $message['subject'] = t('Petition Removal'); - $message['body'][] = t('Petition @title (@id), has been removed by @remover', array('@title' => $params['petition']['title'], '@id' => $params['petition']['_id'], '@remover' => $params['remover'])); - $message['body'][] = t("The creator's email is @mail", array('@mail' => $params['creator_email'])); - break; - } - return FALSE; //we're only sending mail for removals, so don't do anything else - } -} - -/**************** MONGO HELPER FUNCTIONS ******************/ - -/** - * Creates a connection to the petitions collection - */ -function wh_petitions_mongo_petition_connection() { - $collection = mongodb_collection('petitions'); - return $collection; -} - -/** - * Creates a connection to the archive_petitions collection - */ -function wh_petitions_mongo_archive_petition_connection() { - $collection = mongodb_collection('archive_petitions'); - return $collection; -} - -/** - * Creates a connection to the petition signatures collection - */ -function wh_petitions_mongo_petition_signatures_connection() { - $collection = mongodb_collection('petition_signatures'); - return $collection; -} - -/** - * Saves a petition object to the petitions collection. It's more efficient to use the $set operator unless there are major changes or this is the first save. - */ -function wh_petitions_save_petition(&$collection, $petition) { - if (!empty($petition) && !empty($collection)) { - // Explicitly cast the uid as an integer. - $petition['uid'] = (int)$petition['uid']; - if ($petition['created'] == 0) { - $petition['created'] = (int) time(); - } - $collection->save($petition); - return $petition['_id']->__toString(); - } -} - -/** - * Saves a signature object to the petition_signatures collection - * - * @todo: Fix the return. For a new object, there is no _id value. - */ -function wh_petitions_save_signature($signature, $collection = '') { - if (empty($collection)) { - $collection = wh_petitions_mongo_petition_signatures_connection(); - } - if (!empty($signature) && !empty($collection)) { - $collection->save($signature); - module_invoke_all('wh_petitions_signature_save', $signature); - return $signature['_id']->__toString(); - } -} - -/** - * Deletes a petition object. - * - * Saves it to the archive_petition collection, removes from petition collection. - */ -function wh_petitions_delete_petition(&$collection, $petition_id) { - global $user; - - if (!empty($petition_id) && !empty($collection)) { - $archive = wh_petitions_mongo_archive_petition_connection(); - $petition = array(); - $petition = wh_petitions_load_petition($collection, $petition_id); - if (!empty($petition) && $user->uid == $petition['uid'] && $petition['petition_status'] == WH_PETITION_STATUS_DRAFT) { - if ($archive->save($petition)) { - // We successfully saved the petition to the archive, can now safely remove it. - $collection->remove(array('_id' => new MongoId($petition_id))); - - return TRUE; - } - } - } - - return FALSE; -} - -/** - * Gets a petition id from a nice url - */ -function wh_petitions_get_petition_id(&$collection) { - if (!empty($collection)) { - $petition_id = ''; - $petition = $collection->findOne(array('nice_url' => 'petition/' . arg(1)), array('title')); - if (!empty($petition)) { - return $petition['_id']->__toString(); - } - } - - return ''; -} - -/** - * Loads the minimum number of fields from the petition object. Use this instead of load_petition when we don't need access to all ( or a majority ) of fields. - */ -function wh_petitions_load_slim_petition(&$collection, $petition_id, $extra_fields = array()) { - if (!empty($petition_id) && !empty($collection)) { - // Convert to a Mongo ID if we got a string - if (!is_object($petition_id)) { - $petition_id = new MongoId($petition_id); - } - - $retrieve_fields = array('title', 'nice_url', 'short_url'); - $retrieve_fields = array_merge($retrieve_fields, $extra_fields); - - $petition = array(); - $petition = $collection->findOne(array('_id' => $petition_id), $retrieve_fields); - return $petition; - } - - return array(); -} - -/** - * Loads a petition object and merges it with the default petition. - */ -function wh_petitions_load_petition(&$collection, $petition_id, $extra_fields = array()) { - if (!empty($petition_id) && !empty($collection)) { - // Convert to a Mongo ID if we got a string - if (!is_object($petition_id)) { - $petition_id = new MongoId($petition_id); - } - - $petition = array(); - $petition = $collection->findOne(array('_id' => $petition_id)); - - if (!empty($petition)) { - // Merge the default object with the one retrieved to pick up any new fields - $default = wh_petitions_default_petition(); - $petition = array_merge($default, $petition); // Note: Fields with the same string keys from later arrays override those from earlier arrays - return $petition; - } - } - - return array(); -} - -/** - * Gets a petition title. - */ -function wh_petitions_load_petition_title(&$collection, $petition_id) { - if (!empty($petition_id) && !empty($collection)) { - // Convert to a Mongo ID if we got a string - if (!is_object($petition_id)) { - $petition_id = new MongoId($petition_id); - } - - $petition = array(); - $petition = $collection->findOne(array('_id' => $petition_id), array('title')); - return $petition['title']; - } -} - -/** - * Generate keywords for title_keywords, body_keywords and keywords ( public and private ) fields. - */ -function wh_petitions_generate_keywords($string, $delimiter = ' ') { - $words = array(); - - if (!empty($string)) { - $arr = explode($delimiter, $string); - foreach ($arr as $word) { - // Strip all nonalphanumeric, whitespace, etc. - if ($delimiter != ' ') { - $word = trim(preg_replace('/[^A-Za-z0-9\s]/', '', $word)); - } - else { - $word = preg_replace('/[^A-Za-z0-9]/', '', $word); - } - array_push($words, (string)strtolower(trim($word))); - } - } - - return $words; -} - -/** - * Generate a nice url for this petition using pathauto URL cleaning - */ -function wh_petitions_generate_nice_url(&$petition) { - $pattern = variable_get('wh_petitions_nice_url_pattern', WH_PETITION_NICE_URL); - - // Generate path using the pathauto configuration - module_load_include('inc', 'pathauto'); - $alias = token_replace($pattern, array('petition' => $petition), array( - 'clear' => TRUE, - 'callback' => 'pathauto_clean_token_values', - )) . '/' . wh_petitions_generate_hash(8); - - if (_wh_petitions_nice_url_exists($alias, $petition)) { - $separator = variable_get('pathauto_separator', '-'); - $original_alias = $alias; - - $i = 0; - do { - // Append an incrementing numeric suffix until we find a unique alias. - $alias = $original_alias . $separator . $i; - $i++; - } while (_wh_petitions_nice_url_exists($alias, $petition)); - } - - $petition['nice_url'] = $alias; -} - -/** - * Generate a random 8-char hash to append to the end of the url for obfuscation - */ -function wh_petitions_generate_hash($length = 8) { - $characters = 'bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ0123456789'; - $count = mb_strlen($characters) - 1; - $hash = ''; - - for ($i=0;$i<$length;$i++) { - $hash .= $characters[mt_rand(0, $count)]; - } - - return $hash; -} - -/** - * Check to see if the same alias exists for a different Petition - */ -function _wh_petitions_nice_url_exists($alias, $petition) { - $collection = wh_petitions_mongo_petition_connection(); - - $query = array('nice_url' => $alias); - if (isset($petition['_id'])) { - $query['_id'] = array('$ne' => $petition['_id']); - } - - $petitions = $collection->find($query); - return $petitions->count() > 0; -} - -/** - * Generate a short url for this petition. - */ -function wh_petitions_generate_short_url(&$petition) { - if (empty($petition['nice_url'])) { - wh_petitions_generate_nice_url($petition); - } - $petition['short_url'] = wh_petition_tool_shortenurl($petition['nice_url']); -} - -/** - * Returns a default petition object. - */ -function wh_petitions_default_petition() { - $petition = array( - 'uid' => 0, // Drupal UID of the creator - 'title' => '', // Display title of the petition - 'title_keywords' => array(), // Array of words from the title for searching - 'body' => '', // The body/description of the petition - 'body_keywords' => array(), // Array of words from the body for searching - 'body_revisions' => array(), // Array of previous petition object ids; only admins can edit a non-draft petition - 'issues' => array(), // Array of taxonomy term IDs - 'user_tags' => array(), // Array of taxonomy term IDs for user-submitted keywords - 'private_tags' => array(), // Array of taxonomy term IDs for private admin-added keywords - 'related_petitions' => array(), // Array of Mongo IDs of related petitions - 'petition_status' => 0, // State of the petition: public, private, in review, reviewed - 'response_status' => 0, // state of the response: none, presidential, etc. - 'published' => 0, // timestamp for when this petition was published - 'reached_public' => 0, // timestamp for when this petition reached the required signatures to become public - 'reached_ready' => 0, // timestamp for when this petition reached the required signatures to receive a review - 'closed' => 0, // timestamp for when this petition was responded to - 'signature_count' => 0, // count of signatures - 'abuse_flags' => array(), // Drupal UIDs of people who have flagged this as abuse - 'review_timeframe' => 0, // Number of days the petition has to reach X signatures and receive a review - 'response_signatures' => 0, // Number of signatures required to receive a response - 'public_signatures' => 0, // Number of signatures needed to become public - 'bookmarked' => array(), // Array of Drupal UID's of people who have bookmarked this - 'featured' => 0, // Whether this is a featured petition ( 0 or 1 ) - 'hidden' => 0, // Whether this petition has been removed from lists - 'nice_url' => '', // Nice url to display the petition detail page at - 'short_url' => '', // WH.gov shorturl - 'created' => 0, // timestamp for when petition was created - ); - - return $petition; -} - -/** - * Log admin activity (removing/re-enabling) on petitions or signatures - * - * @param $user The drupal user object of the admin - * @param $entity_type String of type of entity - * @param $entity_acted_upon the petition or signature object the admin acted upon - * - * @return mongo id of log entry - */ -function wh_petitions_admin_log($acting_user, $entity_type, $entity_acted_upon) { - //get collection - $collection = mongodb_collection('admin_log'); - - switch ($entity_type) { - case 'petition': - $status = $entity_acted_upon['petition_status']; - break; - case 'petition_signature': - $status = $entity_acted_upon['status']; - break; - default: - $status = $entity_acted_upon['status']; - watchdog('WH Petitions', 'Unknown entity_type (%type) in !file::!line', array('%type' => $entity_type, '!file' => __FILE__, '!line' => __LINE__)); - } - - //build log entry - $entry = array( - 'uid' => $acting_user->uid, - 'timestamp' => time(), - 'entity_type' => $entity_type, - 'entity_id' => $entity_acted_upon['_id'], - 'status' => $status, - ); - - $collection->save($entry); - - return $entry['_id']->__toString(); -} - -/** - * Prepare and send a notification when a petition is removed or re-enabled - */ -function wh_petitions_removal_notification($user, $petition) { - $to_email = variable_get('wh_petitions_admin_removal_notification_emails'); - - if (!$to_email) { - //we can't send mail without a to address, but this may be deliberate, so just end - return; - } - $creator = user_load($petition['uid']); - $params = array( - 'creator_email' => $creator->mail, - 'remover' => $user->mail, - 'petition' => $petition, - ); - $from = variable_get('wh_petitions_email_address', ''); - drupal_mail('wh_petitions', 'status_change', $to_email, language_default(), $params, $from); -} - -/** - * Wrapper for invoking all the functionality that needs to be triggered - * when a petition is signed. - * - * @param $petition_id - * The id of the petition being signed. - * @param $user_id - * The id of the user signing the petition. - * @param $ip_address (optional) - * The IP address from which the user is signing the petition. - * @param $user_agent (optional) - * The user agent string of the signer's browser. - * - * @return boolean - * TRUE on success, FALSE otherwise - */ -function wh_petitions_sign_petition($petition_id, $user_id, $ip_address = '', $user_agent = '') { - - // setup connections for signatures and petitions - $connection = wh_petitions_mongo_petition_connection(); - $connection->setSlaveOkay(FALSE); - $sig_connection = wh_petitions_mongo_petition_signatures_connection(); - $sig_connection->setSlaveOkay(FALSE); - - // Load the petition - $petition = wh_petitions_load_slim_petition($connection, $petition_id, array('petition_status', 'signature_count', 'response_signatures', 'public_signatures')); - - // If it wasn't a valid petition id, exit - if (empty($petition)) { - return FALSE; - } - - //load user - $user = user_load($user_id); - - if(!wh_petitions_create_signature($petition, $user, $sig_connection, $ip_address, $user_agent)) { - watchdog('wh_petitions', 'Failed to create signature for @user on @petition', array('@user' => $user->uid, '@petition' => $petition['_id'])); - return FALSE; - }; - - //up the signature_count on the petition - wh_petitions_increment_signature_count($petition, $connection); - - // Check for GovDelivery list and add the topic id if it wasn't in the petition object previously - $topic_title = 'petitions_' . $petition['_id']->__toString(); - $topic_id = ''; - - ///COMMENTED OUT BECAUSE WE AREN'T IMPLEMENTING CURRENTLY/// - /* - if (empty($petition['govdelivery_id'])) { - $topic_id = govdelivery_subscriber_get_topic_id($topic_title); - if (!empty($topic_id)) { - $connection->update( - array('_id' => $petition['_id']), - array('$set' => array('govdelivery_id' => $topic_id)) - ); - } - } - else { - $topic_id = $petition['govdelivery_id']; - } - */ - - // Add their email to GovDelivery - govdelivery_subscriber_api_add_subscriber($user->mail, $topic_title, $topic_id); -} - -/** - * Create and save a signature object for the given user and petition. - * - * @param $petition - * The petition object being signed. - * @param $user_id - * The user object signing the petition. - * @param $signature_collection_connection - * Connection to be used for querying and storing the signature. - * @param $ip_address (optional) - * The IP address from which the user is signing the petition. - * @param $user_agent (optional) - * The user agent string of the signer's browser. - * - * @return string - * ID of created signature or FALSE on failure - */ -function wh_petitions_create_signature($petition, $user, $signature_collection_connection, $ip_address = '', $user_agent = '') { - // Can only sign petitions that are open - private, public, under review - if ($petition['petition_status'] != WH_PETITION_STATUS_PRIVATE && $petition['petition_status'] != WH_PETITION_STATUS_PUBLIC && $petition['petition_status'] != WH_PETITION_STATUS_UNDER_REVIEW) { - watchdog('wh_petitions', 'unable to create signature on @petition because of invliad petition status (@status)', array('@petition' => $petition['_id'], '@status' => $petition['petition_status'])); - return FALSE; - } - - // Determine if this user has already signed the petition - $query = array( - 'uid' => (int)$user->uid, - 'petition_id' => (string)$petition['_id'], - ); - $result = $signature_collection_connection->findOne($query); - if (!empty($result)) { - watchdog('wh_petitions', 'unable to create signature, user @user has already signed @petition', array('@petition' => $petition['_id'], '@user' => $user->uid)); - return FALSE; - } - - // Load the profile for this user - // @todo: refactor this to not bomb if profile2 isn't installed - $profile = profile2_load_by_user($user); - - // Sign the petition without a comment - $signature_count = $petition['signature_count'] + 1; - $signature = array( - 'petition_id' => (string)$petition['_id'], - 'timestamp' => (int)time(), - 'ip_address' => (string) $ip_address, - 'user_agent' => (string) $user_agent, - 'comment' => '', - 'uid' => (int)$user->uid, - 'abuse_flags' => array(), - 'status' => 1, - 'number' => $signature_count, - 'user' => array( - 'first_name' => $profile['main']->field_first_name['und'][0]['value'], - 'last_name' => $profile['main']->field_last_name['und'][0]['value'], - 'city' => $profile['main']->field_city['und'][0]['value'], - 'state' => $profile['main']->field_state['und'][0]['value'], - 'zip' => $profile['main']->field_zip['und'][0]['value'], - 'username' => $user->name, - 'country' => $profile['main']->field_country['und'][0]['value'], - ), - ); - - return wh_petitions_save_signature($signature); -} - -/** - * Increment the signature_count of a petition and check to see if has passed any milestones - * - * @param $petition - * The petition object which will will be incremented - * @param $connection - * A connection to the petition dataset - */ -function wh_petitions_increment_signature_count(&$petition, $connection) { - $connection->update( - array('_id' => $petition['_id']), - array('$inc' => array('signature_count' => 1)) - ); - - $petition = wh_petitions_load_slim_petition($connection, $petition['_id'], array('petition_status', 'signature_count', 'response_signatures', 'public_signatures')); - - // Update to public petition - $reached_response = FALSE; - if ($petition['petition_status'] == WH_PETITION_STATUS_PRIVATE && $petition['signature_count'] == $petition['public_signatures']) { - $connection->update( - array('_id' => $petition['_id']), - array('$set' => array('petition_status' => (int)WH_PETITION_STATUS_PUBLIC, 'reached_public' => (int)time())) - ); - } - // Record the time the petition became eligible for a response - elseif ($petition['petition_status'] == WH_PETITION_STATUS_PUBLIC && $petition['signature_count'] == $petition['response_signatures']) { - $connection->update( - array('_id' => $petition['_id']), - array('$set' => array('petition_status' => (int)WH_PETITION_STATUS_UNDER_REVIEW, 'response_status' => (int)WH_PETITION_RESPONSE_STATUS_PENDING, 'reached_ready' => (int)time())) - ); - $reached_response = TRUE; - } - - // Email the creator if the petition is ready for a response - if($reached_response) { - wh_petitions_email_ready_response($petition['_id']->__toString(), $petition['uid']); - } - - //reload petition object - $petition = wh_petitions_load_slim_petition($connection, $petition['_id'], array('petition_status', 'signature_count', 'response_signatures', 'public_signatures')); -} diff --git a/modules/custom/wh_petitions/wh_petitions.pages.inc b/modules/custom/wh_petitions/wh_petitions.pages.inc deleted file mode 100644 index 77a2f5e63..000000000 --- a/modules/custom/wh_petitions/wh_petitions.pages.inc +++ /dev/null @@ -1,1170 +0,0 @@ - 0 && ($total > ($page * WH_PETITION_PETITIONS_PER_PAGE))) { - $next_page = 'petitions/' . $sort . '/' . ($page + 1) . '/' . $cols . '/' . implode('+', $issues) . '/' . $search; - } - - // Load the issues and search forms - module_load_include('inc', 'wh_petitions', 'wh_petitions.form'); - $issues_form = drupal_get_form('wh_petitions_list_page_issues_form'); - $issues_form = drupal_render($issues_form); - $search_form = drupal_get_form('wh_petitions_list_page_search_form'); - $search_form = drupal_render($search_form); - - // Theme the petitions page - return theme('wh_petitions_display_petition_page', array( - 'petitions' => $html, - 'sort' => check_plain($sort), - 'page' => intval($page), - 'cols' => intval($cols), - 'issues_form' => $issues_form, - 'issues' => implode(' ', $issues), - 'search_form' => $search_form, - 'search' => urlencode($search), - 'next_page' => urlencode($next_page), - 'count' => intval($count + (WH_RESPONSE_RESPONSES_PER_PAGE * ($page - 1))), - 'total' => wh_petitions_format_number($total), - )); -} - -/** - * Function to retrieve the HTML for the petitions that should show on a given page. Also sanitizes and modifies the page arguments to make sure they're valid. - * - * Arguments: - * 1) sort - * -all: by date they became public desc - * -trending: most signatures in past 24 hours desc - * -popular: total signatures desc - * 2) page number ( 8 per page, default = 0 ) - * 3) columns ( 1 or 2, default = 2 ) - * 4) Issues ( issue term tid's separated by spaces ) - * 5) Search terms ( separated by spaces ) - */ -function wh_petitions_get_petitions(&$sort, &$page, &$cols, &$issues, &$search, &$count, &$total) { - $html = ''; - $count = 0; - $petitions = array(); - $conn = wh_petitions_mongo_petition_connection(); - - // Make sure the sort is a valid option - if (!in_array($sort, array('all', 'trending', 'popular'))) { - $sort = 'all'; - } - - // Validate the page and calculate the offset for the query - $page = intval($page); - if ($page <= 0) { - $page = 1; - } - $offset = ($page - 1) * WH_PETITION_PETITIONS_PER_PAGE; - - // 1 Col or 2 - if ($cols != 1 && $cols != 2) { - $cols = 2; - } - - // Issues - if (!empty($issues)) { - $issues = explode(" ", urldecode($issues)); - for ($i=0; $i