summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.26/modules
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.26/modules')
-rw-r--r--kolab.org/www/drupal-7.26/modules/README.txt9
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/aggregator-feed-source.tpl.php36
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/aggregator-item.tpl.php47
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/aggregator-rtl.css7
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/aggregator-summary-item.tpl.php25
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/aggregator-summary-items.tpl.php25
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/aggregator-wrapper.tpl.php20
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/aggregator.admin.inc633
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/aggregator.api.php220
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/aggregator.css41
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/aggregator.fetcher.inc61
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/aggregator.info14
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/aggregator.install330
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/aggregator.module782
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/aggregator.pages.inc582
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/aggregator.parser.inc329
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/aggregator.processor.inc213
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/aggregator.test1019
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/tests/aggregator_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/tests/aggregator_test.module58
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/tests/aggregator_test_atom.xml20
-rw-r--r--kolab.org/www/drupal-7.26/modules/aggregator/tests/aggregator_test_rss091.xml41
-rw-r--r--kolab.org/www/drupal-7.26/modules/block/block-admin-display-form.tpl.php69
-rw-r--r--kolab.org/www/drupal-7.26/modules/block/block.admin.inc700
-rw-r--r--kolab.org/www/drupal-7.26/modules/block/block.api.php368
-rw-r--r--kolab.org/www/drupal-7.26/modules/block/block.css36
-rw-r--r--kolab.org/www/drupal-7.26/modules/block/block.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/block/block.install477
-rw-r--r--kolab.org/www/drupal-7.26/modules/block/block.js152
-rw-r--r--kolab.org/www/drupal-7.26/modules/block/block.module1092
-rw-r--r--kolab.org/www/drupal-7.26/modules/block/block.test979
-rw-r--r--kolab.org/www/drupal-7.26/modules/block/block.tpl.php58
-rw-r--r--kolab.org/www/drupal-7.26/modules/block/tests/block_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/block/tests/block_test.module67
-rw-r--r--kolab.org/www/drupal-7.26/modules/block/tests/themes/block_test_theme/block_test_theme.info20
-rw-r--r--kolab.org/www/drupal-7.26/modules/block/tests/themes/block_test_theme/page.tpl.php78
-rw-r--r--kolab.org/www/drupal-7.26/modules/blog/blog.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/blog/blog.install23
-rw-r--r--kolab.org/www/drupal-7.26/modules/blog/blog.module272
-rw-r--r--kolab.org/www/drupal-7.26/modules/blog/blog.pages.inc127
-rw-r--r--kolab.org/www/drupal-7.26/modules/blog/blog.test213
-rw-r--r--kolab.org/www/drupal-7.26/modules/book/book-all-books-block.tpl.php23
-rw-r--r--kolab.org/www/drupal-7.26/modules/book/book-export-html.tpl.php52
-rw-r--r--kolab.org/www/drupal-7.26/modules/book/book-navigation.tpl.php54
-rw-r--r--kolab.org/www/drupal-7.26/modules/book/book-node-export-html.tpl.php25
-rw-r--r--kolab.org/www/drupal-7.26/modules/book/book-rtl.css15
-rw-r--r--kolab.org/www/drupal-7.26/modules/book/book.admin.inc289
-rw-r--r--kolab.org/www/drupal-7.26/modules/book/book.css58
-rw-r--r--kolab.org/www/drupal-7.26/modules/book/book.info14
-rw-r--r--kolab.org/www/drupal-7.26/modules/book/book.install95
-rw-r--r--kolab.org/www/drupal-7.26/modules/book/book.js27
-rw-r--r--kolab.org/www/drupal-7.26/modules/book/book.module1437
-rw-r--r--kolab.org/www/drupal-7.26/modules/book/book.pages.inc247
-rw-r--r--kolab.org/www/drupal-7.26/modules/book/book.test398
-rw-r--r--kolab.org/www/drupal-7.26/modules/color/color-rtl.css48
-rw-r--r--kolab.org/www/drupal-7.26/modules/color/color.css85
-rw-r--r--kolab.org/www/drupal-7.26/modules/color/color.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/color/color.install66
-rw-r--r--kolab.org/www/drupal-7.26/modules/color/color.js250
-rw-r--r--kolab.org/www/drupal-7.26/modules/color/color.module815
-rw-r--r--kolab.org/www/drupal-7.26/modules/color/color.test133
-rw-r--r--kolab.org/www/drupal-7.26/modules/color/images/hook-rtl.pngbin0 -> 116 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/color/images/hook.pngbin0 -> 116 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/color/images/lock.pngbin0 -> 230 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/color/preview.html7
-rw-r--r--kolab.org/www/drupal-7.26/modules/color/preview.js38
-rw-r--r--kolab.org/www/drupal-7.26/modules/comment/comment-node-form.js32
-rw-r--r--kolab.org/www/drupal-7.26/modules/comment/comment-rtl.css5
-rw-r--r--kolab.org/www/drupal-7.26/modules/comment/comment-wrapper.tpl.php52
-rw-r--r--kolab.org/www/drupal-7.26/modules/comment/comment.admin.inc284
-rw-r--r--kolab.org/www/drupal-7.26/modules/comment/comment.api.php145
-rw-r--r--kolab.org/www/drupal-7.26/modules/comment/comment.css13
-rw-r--r--kolab.org/www/drupal-7.26/modules/comment/comment.info16
-rw-r--r--kolab.org/www/drupal-7.26/modules/comment/comment.install578
-rw-r--r--kolab.org/www/drupal-7.26/modules/comment/comment.module2739
-rw-r--r--kolab.org/www/drupal-7.26/modules/comment/comment.pages.inc123
-rw-r--r--kolab.org/www/drupal-7.26/modules/comment/comment.test2225
-rw-r--r--kolab.org/www/drupal-7.26/modules/comment/comment.tokens.inc243
-rw-r--r--kolab.org/www/drupal-7.26/modules/comment/comment.tpl.php92
-rw-r--r--kolab.org/www/drupal-7.26/modules/contact/contact.admin.inc228
-rw-r--r--kolab.org/www/drupal-7.26/modules/contact/contact.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/contact/contact.install168
-rw-r--r--kolab.org/www/drupal-7.26/modules/contact/contact.module259
-rw-r--r--kolab.org/www/drupal-7.26/modules/contact/contact.pages.inc300
-rw-r--r--kolab.org/www/drupal-7.26/modules/contact/contact.test434
-rw-r--r--kolab.org/www/drupal-7.26/modules/contextual/contextual-rtl.css20
-rw-r--r--kolab.org/www/drupal-7.26/modules/contextual/contextual.api.php40
-rw-r--r--kolab.org/www/drupal-7.26/modules/contextual/contextual.css103
-rw-r--r--kolab.org/www/drupal-7.26/modules/contextual/contextual.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/contextual/contextual.js52
-rw-r--r--kolab.org/www/drupal-7.26/modules/contextual/contextual.module169
-rw-r--r--kolab.org/www/drupal-7.26/modules/contextual/contextual.test49
-rw-r--r--kolab.org/www/drupal-7.26/modules/contextual/images/gear-select.pngbin0 -> 506 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/dashboard/dashboard-rtl.css30
-rw-r--r--kolab.org/www/drupal-7.26/modules/dashboard/dashboard.api.php42
-rw-r--r--kolab.org/www/drupal-7.26/modules/dashboard/dashboard.css134
-rw-r--r--kolab.org/www/drupal-7.26/modules/dashboard/dashboard.info14
-rw-r--r--kolab.org/www/drupal-7.26/modules/dashboard/dashboard.install78
-rw-r--r--kolab.org/www/drupal-7.26/modules/dashboard/dashboard.js223
-rw-r--r--kolab.org/www/drupal-7.26/modules/dashboard/dashboard.module681
-rw-r--r--kolab.org/www/drupal-7.26/modules/dashboard/dashboard.test141
-rw-r--r--kolab.org/www/drupal-7.26/modules/dblog/dblog-rtl.css11
-rw-r--r--kolab.org/www/drupal-7.26/modules/dblog/dblog.admin.inc418
-rw-r--r--kolab.org/www/drupal-7.26/modules/dblog/dblog.css64
-rw-r--r--kolab.org/www/drupal-7.26/modules/dblog/dblog.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/dblog/dblog.install159
-rw-r--r--kolab.org/www/drupal-7.26/modules/dblog/dblog.module187
-rw-r--r--kolab.org/www/drupal-7.26/modules/dblog/dblog.test637
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/field.api.php2698
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/field.attach.inc1416
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/field.crud.inc1010
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/field.default.inc268
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/field.form.inc604
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/field.info18
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/field.info.class.inc668
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/field.info.inc812
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/field.install471
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/field.module1217
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/field.multilingual.inc301
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/field_sql_storage/field_sql_storage.info14
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/field_sql_storage/field_sql_storage.install215
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/field_sql_storage/field_sql_storage.module758
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/field_sql_storage/field_sql_storage.test441
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/list/list.info14
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/list/list.install138
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/list/list.module486
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/list/tests/list.test457
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/list/tests/list_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/list/tests/list_test.module32
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/number/number.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/number/number.install45
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/number/number.module419
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/number/number.test155
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/options/options.api.php74
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/options/options.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/options/options.module417
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/options/options.test553
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/text/text.info14
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/text/text.install95
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/text/text.js49
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/text/text.module611
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/modules/text/text.test517
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/tests/field.test3709
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/tests/field_test.entity.inc500
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/tests/field_test.field.inc413
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/tests/field_test.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/tests/field_test.install162
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/tests/field_test.module269
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/tests/field_test.storage.inc473
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/theme/field-rtl.css14
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/theme/field.css28
-rw-r--r--kolab.org/www/drupal-7.26/modules/field/theme/field.tpl.php62
-rw-r--r--kolab.org/www/drupal-7.26/modules/field_ui/field_ui-rtl.css9
-rw-r--r--kolab.org/www/drupal-7.26/modules/field_ui/field_ui.admin.inc2112
-rw-r--r--kolab.org/www/drupal-7.26/modules/field_ui/field_ui.api.php204
-rw-r--r--kolab.org/www/drupal-7.26/modules/field_ui/field_ui.css71
-rw-r--r--kolab.org/www/drupal-7.26/modules/field_ui/field_ui.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/field_ui/field_ui.js341
-rw-r--r--kolab.org/www/drupal-7.26/modules/field_ui/field_ui.module394
-rw-r--r--kolab.org/www/drupal-7.26/modules/field_ui/field_ui.test751
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/file.api.php60
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/file.css35
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/file.field.inc1024
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/file.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/file.install98
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/file.js155
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/file.module1013
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/icons/application-octet-stream.pngbin0 -> 189 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/icons/application-pdf.pngbin0 -> 346 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/icons/application-x-executable.pngbin0 -> 189 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/icons/audio-x-generic.pngbin0 -> 314 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/icons/image-x-generic.pngbin0 -> 385 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/icons/package-x-generic.pngbin0 -> 260 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/icons/text-html.pngbin0 -> 265 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/icons/text-plain.pngbin0 -> 220 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/icons/text-x-generic.pngbin0 -> 220 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/icons/text-x-script.pngbin0 -> 276 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/icons/video-x-generic.pngbin0 -> 214 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/icons/x-office-document.pngbin0 -> 196 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/icons/x-office-presentation.pngbin0 -> 181 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/icons/x-office-spreadsheet.pngbin0 -> 183 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/tests/file.test1171
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/tests/file_module_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/file/tests/file_module_test.module69
-rw-r--r--kolab.org/www/drupal-7.26/modules/filter/filter.admin.inc408
-rw-r--r--kolab.org/www/drupal-7.26/modules/filter/filter.admin.js44
-rw-r--r--kolab.org/www/drupal-7.26/modules/filter/filter.api.php323
-rw-r--r--kolab.org/www/drupal-7.26/modules/filter/filter.css53
-rw-r--r--kolab.org/www/drupal-7.26/modules/filter/filter.info14
-rw-r--r--kolab.org/www/drupal-7.26/modules/filter/filter.install494
-rw-r--r--kolab.org/www/drupal-7.26/modules/filter/filter.js20
-rw-r--r--kolab.org/www/drupal-7.26/modules/filter/filter.module1786
-rw-r--r--kolab.org/www/drupal-7.26/modules/filter/filter.pages.inc92
-rw-r--r--kolab.org/www/drupal-7.26/modules/filter/filter.test1972
-rw-r--r--kolab.org/www/drupal-7.26/modules/filter/tests/filter.url-input.txt36
-rw-r--r--kolab.org/www/drupal-7.26/modules/filter/tests/filter.url-output.txt36
-rw-r--r--kolab.org/www/drupal-7.26/modules/forum/forum-icon.tpl.php26
-rw-r--r--kolab.org/www/drupal-7.26/modules/forum/forum-list.tpl.php77
-rw-r--r--kolab.org/www/drupal-7.26/modules/forum/forum-rtl.css24
-rw-r--r--kolab.org/www/drupal-7.26/modules/forum/forum-submitted.tpl.php30
-rw-r--r--kolab.org/www/drupal-7.26/modules/forum/forum-topic-list.tpl.php72
-rw-r--r--kolab.org/www/drupal-7.26/modules/forum/forum.admin.inc352
-rw-r--r--kolab.org/www/drupal-7.26/modules/forum/forum.css54
-rw-r--r--kolab.org/www/drupal-7.26/modules/forum/forum.info16
-rw-r--r--kolab.org/www/drupal-7.26/modules/forum/forum.install467
-rw-r--r--kolab.org/www/drupal-7.26/modules/forum/forum.module1396
-rw-r--r--kolab.org/www/drupal-7.26/modules/forum/forum.pages.inc37
-rw-r--r--kolab.org/www/drupal-7.26/modules/forum/forum.test687
-rw-r--r--kolab.org/www/drupal-7.26/modules/forum/forums.tpl.php24
-rw-r--r--kolab.org/www/drupal-7.26/modules/help/help-rtl.css10
-rw-r--r--kolab.org/www/drupal-7.26/modules/help/help.admin.inc86
-rw-r--r--kolab.org/www/drupal-7.26/modules/help/help.api.php63
-rw-r--r--kolab.org/www/drupal-7.26/modules/help/help.css9
-rw-r--r--kolab.org/www/drupal-7.26/modules/help/help.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/help/help.module63
-rw-r--r--kolab.org/www/drupal-7.26/modules/help/help.test137
-rw-r--r--kolab.org/www/drupal-7.26/modules/image/image-rtl.css11
-rw-r--r--kolab.org/www/drupal-7.26/modules/image/image.admin.css60
-rw-r--r--kolab.org/www/drupal-7.26/modules/image/image.admin.inc925
-rw-r--r--kolab.org/www/drupal-7.26/modules/image/image.api.php200
-rw-r--r--kolab.org/www/drupal-7.26/modules/image/image.css14
-rw-r--r--kolab.org/www/drupal-7.26/modules/image/image.effects.inc314
-rw-r--r--kolab.org/www/drupal-7.26/modules/image/image.field.inc642
-rw-r--r--kolab.org/www/drupal-7.26/modules/image/image.info14
-rw-r--r--kolab.org/www/drupal-7.26/modules/image/image.install522
-rw-r--r--kolab.org/www/drupal-7.26/modules/image/image.module1393
-rw-r--r--kolab.org/www/drupal-7.26/modules/image/image.test1865
-rw-r--r--kolab.org/www/drupal-7.26/modules/image/sample.pngbin0 -> 168110 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/image/tests/image_module_test.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/image/tests/image_module_test.module50
-rw-r--r--kolab.org/www/drupal-7.26/modules/locale/locale-rtl.css12
-rw-r--r--kolab.org/www/drupal-7.26/modules/locale/locale.admin.inc1436
-rw-r--r--kolab.org/www/drupal-7.26/modules/locale/locale.api.php41
-rw-r--r--kolab.org/www/drupal-7.26/modules/locale/locale.css32
-rw-r--r--kolab.org/www/drupal-7.26/modules/locale/locale.datepicker.js79
-rw-r--r--kolab.org/www/drupal-7.26/modules/locale/locale.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/locale/locale.install457
-rw-r--r--kolab.org/www/drupal-7.26/modules/locale/locale.module1098
-rw-r--r--kolab.org/www/drupal-7.26/modules/locale/locale.test3143
-rw-r--r--kolab.org/www/drupal-7.26/modules/locale/tests/locale_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/locale/tests/locale_test.js46
-rw-r--r--kolab.org/www/drupal-7.26/modules/locale/tests/locale_test.module242
-rw-r--r--kolab.org/www/drupal-7.26/modules/locale/tests/translations/test.xx.po28
-rw-r--r--kolab.org/www/drupal-7.26/modules/menu/menu.admin.inc700
-rw-r--r--kolab.org/www/drupal-7.26/modules/menu/menu.admin.js46
-rw-r--r--kolab.org/www/drupal-7.26/modules/menu/menu.api.php87
-rw-r--r--kolab.org/www/drupal-7.26/modules/menu/menu.css12
-rw-r--r--kolab.org/www/drupal-7.26/modules/menu/menu.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/menu/menu.install210
-rw-r--r--kolab.org/www/drupal-7.26/modules/menu/menu.js65
-rw-r--r--kolab.org/www/drupal-7.26/modules/menu/menu.module794
-rw-r--r--kolab.org/www/drupal-7.26/modules/menu/menu.test724
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/content_types.inc450
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/content_types.js34
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/node.admin.inc704
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/node.api.php1298
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/node.css10
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/node.info16
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/node.install938
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/node.js43
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/node.module4174
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/node.pages.inc678
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/node.test2848
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/node.tokens.inc191
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/node.tpl.php112
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/tests/node_access_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/tests/node_access_test.install42
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/tests/node_access_test.module230
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/tests/node_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/tests/node_test.module181
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/tests/node_test_exception.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/node/tests/node_test_exception.module15
-rw-r--r--kolab.org/www/drupal-7.26/modules/openid/login-bg.pngbin0 -> 205 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/openid/openid-rtl.css18
-rw-r--r--kolab.org/www/drupal-7.26/modules/openid/openid.api.php116
-rw-r--r--kolab.org/www/drupal-7.26/modules/openid/openid.css46
-rw-r--r--kolab.org/www/drupal-7.26/modules/openid/openid.inc894
-rw-r--r--kolab.org/www/drupal-7.26/modules/openid/openid.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/openid/openid.install230
-rw-r--r--kolab.org/www/drupal-7.26/modules/openid/openid.js49
-rw-r--r--kolab.org/www/drupal-7.26/modules/openid/openid.module1034
-rw-r--r--kolab.org/www/drupal-7.26/modules/openid/openid.pages.inc116
-rw-r--r--kolab.org/www/drupal-7.26/modules/openid/openid.test802
-rw-r--r--kolab.org/www/drupal-7.26/modules/openid/tests/openid_test.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/openid/tests/openid_test.install17
-rw-r--r--kolab.org/www/drupal-7.26/modules/openid/tests/openid_test.module367
-rw-r--r--kolab.org/www/drupal-7.26/modules/overlay/images/background.pngbin0 -> 76 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/overlay/images/close-rtl.pngbin0 -> 368 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/overlay/images/close.pngbin0 -> 344 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/overlay/overlay-child-rtl.css40
-rw-r--r--kolab.org/www/drupal-7.26/modules/overlay/overlay-child.css172
-rw-r--r--kolab.org/www/drupal-7.26/modules/overlay/overlay-child.js196
-rw-r--r--kolab.org/www/drupal-7.26/modules/overlay/overlay-parent.css55
-rw-r--r--kolab.org/www/drupal-7.26/modules/overlay/overlay-parent.js1015
-rw-r--r--kolab.org/www/drupal-7.26/modules/overlay/overlay.api.php40
-rw-r--r--kolab.org/www/drupal-7.26/modules/overlay/overlay.info11
-rw-r--r--kolab.org/www/drupal-7.26/modules/overlay/overlay.install19
-rw-r--r--kolab.org/www/drupal-7.26/modules/overlay/overlay.module1010
-rw-r--r--kolab.org/www/drupal-7.26/modules/overlay/overlay.tpl.php39
-rw-r--r--kolab.org/www/drupal-7.26/modules/path/path.admin.inc314
-rw-r--r--kolab.org/www/drupal-7.26/modules/path/path.api.php73
-rw-r--r--kolab.org/www/drupal-7.26/modules/path/path.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/path/path.js21
-rw-r--r--kolab.org/www/drupal-7.26/modules/path/path.module313
-rw-r--r--kolab.org/www/drupal-7.26/modules/path/path.test537
-rw-r--r--kolab.org/www/drupal-7.26/modules/php/php.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/php/php.install45
-rw-r--r--kolab.org/www/drupal-7.26/modules/php/php.module147
-rw-r--r--kolab.org/www/drupal-7.26/modules/php/php.test120
-rw-r--r--kolab.org/www/drupal-7.26/modules/poll/poll-bar--block.tpl.php26
-rw-r--r--kolab.org/www/drupal-7.26/modules/poll/poll-bar.tpl.php26
-rw-r--r--kolab.org/www/drupal-7.26/modules/poll/poll-results--block.tpl.php28
-rw-r--r--kolab.org/www/drupal-7.26/modules/poll/poll-results.tpl.php30
-rw-r--r--kolab.org/www/drupal-7.26/modules/poll/poll-rtl.css10
-rw-r--r--kolab.org/www/drupal-7.26/modules/poll/poll-vote.tpl.php31
-rw-r--r--kolab.org/www/drupal-7.26/modules/poll/poll.css51
-rw-r--r--kolab.org/www/drupal-7.26/modules/poll/poll.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/poll/poll.install215
-rw-r--r--kolab.org/www/drupal-7.26/modules/poll/poll.module1019
-rw-r--r--kolab.org/www/drupal-7.26/modules/poll/poll.pages.inc97
-rw-r--r--kolab.org/www/drupal-7.26/modules/poll/poll.test872
-rw-r--r--kolab.org/www/drupal-7.26/modules/poll/poll.tokens.inc107
-rw-r--r--kolab.org/www/drupal-7.26/modules/profile/profile-block.tpl.php41
-rw-r--r--kolab.org/www/drupal-7.26/modules/profile/profile-listing.tpl.php52
-rw-r--r--kolab.org/www/drupal-7.26/modules/profile/profile-wrapper.tpl.php24
-rw-r--r--kolab.org/www/drupal-7.26/modules/profile/profile.admin.inc446
-rw-r--r--kolab.org/www/drupal-7.26/modules/profile/profile.css10
-rw-r--r--kolab.org/www/drupal-7.26/modules/profile/profile.info18
-rw-r--r--kolab.org/www/drupal-7.26/modules/profile/profile.install172
-rw-r--r--kolab.org/www/drupal-7.26/modules/profile/profile.js58
-rw-r--r--kolab.org/www/drupal-7.26/modules/profile/profile.module630
-rw-r--r--kolab.org/www/drupal-7.26/modules/profile/profile.pages.inc136
-rw-r--r--kolab.org/www/drupal-7.26/modules/profile/profile.test530
-rw-r--r--kolab.org/www/drupal-7.26/modules/rdf/rdf.api.php106
-rw-r--r--kolab.org/www/drupal-7.26/modules/rdf/rdf.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/rdf/rdf.install49
-rw-r--r--kolab.org/www/drupal-7.26/modules/rdf/rdf.module878
-rw-r--r--kolab.org/www/drupal-7.26/modules/rdf/rdf.test720
-rw-r--r--kolab.org/www/drupal-7.26/modules/rdf/tests/rdf_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/rdf/tests/rdf_test.install25
-rw-r--r--kolab.org/www/drupal-7.26/modules/rdf/tests/rdf_test.module66
-rw-r--r--kolab.org/www/drupal-7.26/modules/search/search-block-form.tpl.php37
-rw-r--r--kolab.org/www/drupal-7.26/modules/search/search-result.tpl.php81
-rw-r--r--kolab.org/www/drupal-7.26/modules/search/search-results.tpl.php35
-rw-r--r--kolab.org/www/drupal-7.26/modules/search/search-rtl.css13
-rw-r--r--kolab.org/www/drupal-7.26/modules/search/search.admin.inc186
-rw-r--r--kolab.org/www/drupal-7.26/modules/search/search.api.php376
-rw-r--r--kolab.org/www/drupal-7.26/modules/search/search.css34
-rw-r--r--kolab.org/www/drupal-7.26/modules/search/search.extender.inc536
-rw-r--r--kolab.org/www/drupal-7.26/modules/search/search.info15
-rw-r--r--kolab.org/www/drupal-7.26/modules/search/search.install182
-rw-r--r--kolab.org/www/drupal-7.26/modules/search/search.module1356
-rw-r--r--kolab.org/www/drupal-7.26/modules/search/search.pages.inc158
-rw-r--r--kolab.org/www/drupal-7.26/modules/search/search.test2079
-rw-r--r--kolab.org/www/drupal-7.26/modules/search/tests/UnicodeTest.txt333
-rw-r--r--kolab.org/www/drupal-7.26/modules/search/tests/search_embedded_form.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/search/tests/search_embedded_form.module70
-rw-r--r--kolab.org/www/drupal-7.26/modules/search/tests/search_extra_type.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/search/tests/search_extra_type.module69
-rw-r--r--kolab.org/www/drupal-7.26/modules/shortcut/shortcut-rtl.css48
-rw-r--r--kolab.org/www/drupal-7.26/modules/shortcut/shortcut.admin.css8
-rw-r--r--kolab.org/www/drupal-7.26/modules/shortcut/shortcut.admin.inc788
-rw-r--r--kolab.org/www/drupal-7.26/modules/shortcut/shortcut.admin.js115
-rw-r--r--kolab.org/www/drupal-7.26/modules/shortcut/shortcut.api.php42
-rw-r--r--kolab.org/www/drupal-7.26/modules/shortcut/shortcut.css106
-rw-r--r--kolab.org/www/drupal-7.26/modules/shortcut/shortcut.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/shortcut/shortcut.install115
-rw-r--r--kolab.org/www/drupal-7.26/modules/shortcut/shortcut.module767
-rw-r--r--kolab.org/www/drupal-7.26/modules/shortcut/shortcut.pngbin0 -> 558 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/shortcut/shortcut.test371
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/drupal_web_test_case.php3706
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/README.txt4
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/css_test_files/comment_hacks.css80
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/css_test_files/comment_hacks.css.optimized.css1
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/css_test_files/comment_hacks.css.unoptimized.css80
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/css_test_files/css_input_with_import.css30
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/css_test_files/css_input_with_import.css.optimized.css6
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/css_test_files/css_input_with_import.css.unoptimized.css40
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/css_test_files/css_input_without_import.css69
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/css_test_files/css_input_without_import.css.optimized.css4
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/css_test_files/css_input_without_import.css.unoptimized.css69
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/css_test_files/css_subfolder/css_input_with_import.css29
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/css_test_files/css_subfolder/css_input_with_import.css.optimized.css6
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/css_test_files/css_subfolder/css_input_with_import.css.unoptimized.css39
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/css_test_files/import1.css6
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/css_test_files/import2.css5
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/html-1.txt1
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/html-2.html1
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/image-1.pngbin0 -> 39325 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/image-2.jpgbin0 -> 1831 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/image-test.gifbin0 -> 183 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/image-test.jpgbin0 -> 1901 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/image-test.pngbin0 -> 125 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/javascript-1.txt3
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/javascript-2.script3
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/php-1.txt3
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/php-2.php2
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/sql-1.txt1
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/files/sql-2.sql1
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/lib/Drupal/simpletest/Tests/PSR0WebTest.php18
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/simpletest.api.php60
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/simpletest.css89
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/simpletest.info62
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/simpletest.install182
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/simpletest.js104
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/simpletest.module626
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/simpletest.pages.inc513
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/simpletest.test746
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/actions.test126
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/actions_loop_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/actions_loop_test.install11
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/actions_loop_test.module95
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/ajax.test530
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/ajax_forms_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/ajax_forms_test.module502
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/ajax_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/ajax_test.module79
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/batch.test403
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/batch_test.callbacks.inc141
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/batch_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/batch_test.module513
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/bootstrap.test543
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/cache.test437
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/common.test2787
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/common_test.css2
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/common_test.info14
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/common_test.module276
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/common_test.print.css2
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/common_test_cron_helper.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/common_test_cron_helper.module17
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/common_test_info.txt9
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/database_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/database_test.install221
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/database_test.module241
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/database_test.test4111
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module1
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module1
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/entity_cache_test.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/entity_cache_test.module27
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/entity_cache_test_dependency.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/entity_cache_test_dependency.module17
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/entity_crud_hook_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/entity_crud_hook_test.module251
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/entity_crud_hook_test.test338
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/entity_query.test1681
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/entity_query_access_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/entity_query_access_test.module54
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/error.test116
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/error_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/error_test.module65
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/file.test2782
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/file_test.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/file_test.module461
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/filetransfer.test168
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/filter_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/filter_test.module64
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/form.test1867
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/form_test.file.inc48
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/form_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/form_test.module1857
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/graph.test195
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/http.php32
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/https.php31
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/image.test507
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/image_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/image_test.module138
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/lock.test57
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/mail.test461
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/menu.test1740
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/menu_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/menu_test.module563
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/module.test304
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/module_test.file.inc13
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/module_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/module_test.install42
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/module_test.module131
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/pager.test159
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/password.test60
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/path.test381
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/path_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/path_test.module23
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/psr_0_test/lib/Drupal/psr_0_test/Tests/ExampleTest.php18
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/psr_0_test/lib/Drupal/psr_0_test/Tests/Nested/NestedExampleTest.php18
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/psr_0_test/psr_0_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/psr_0_test/psr_0_test.module1
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/registry.test142
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/requirements1_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/requirements1_test.install21
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/requirements1_test.module7
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/requirements2_test.info14
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/requirements2_test.module7
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/schema.test384
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/session.test530
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/session_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/session_test.module192
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/system.base.css6
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/system_dependencies_test.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/system_dependencies_test.module1
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/system_incompatible_core_version_dependencies_test.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/system_incompatible_core_version_dependencies_test.module1
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/system_incompatible_core_version_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/system_incompatible_core_version_test.module1
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/system_incompatible_module_version_dependencies_test.info14
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/system_incompatible_module_version_dependencies_test.module1
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/system_incompatible_module_version_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/system_incompatible_module_version_test.module1
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/system_test.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/system_test.module407
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/tablesort.test166
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/taxonomy_test.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/taxonomy_test.install34
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/taxonomy_test.module111
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/theme.test502
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/theme_test.inc15
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/theme_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/theme_test.module134
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/theme_test.template_test.tpl.php2
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/themes/test_basetheme/test_basetheme.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/themes/test_subtheme/test_subtheme.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/themes/test_theme/template.php19
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/themes/test_theme/test_theme.info24
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/unicode.test305
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/update.test115
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/update_script_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/update_script_test.install45
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/update_script_test.module18
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/update_test_1.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/update_test_1.install53
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/update_test_1.module1
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/update_test_2.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/update_test_2.install53
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/update_test_2.module1
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/update_test_3.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/update_test_3.install24
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/update_test_3.module1
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-6.bare.database.php8131
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-6.comments.database.php40
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-6.duplicate-permission.database.php8
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-6.filled.database.php20384
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-6.forum.database.php274
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-6.locale.database.php276
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-6.menu.database.php202
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-6.node_type_broken.database.php34
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-6.translatable.database.php125
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-6.trigger.database.php82
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-6.upload.database.php449
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-6.user-no-password-token.database.php10
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-6.user-password-token.database.php55
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-7.aggregator.database.php149
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-7.bare.minimal.database.php.gzbin0 -> 39843 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-7.bare.standard_all.database.php.gzbin0 -> 77424 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-7.field.database.php16
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-7.filled.minimal.database.php.gzbin0 -> 41805 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-7.filled.standard_all.database.php.gzbin0 -> 97603 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/drupal-7.trigger.database.php28
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/update.aggregator.test47
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/update.field.test61
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/update.trigger.test37
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/update.user.test35
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/upgrade.comment.test32
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/upgrade.filter.test55
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/upgrade.forum.test64
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/upgrade.locale.test143
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/upgrade.menu.test83
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/upgrade.node.test148
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/upgrade.poll.test66
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/upgrade.taxonomy.test201
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/upgrade.test737
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/upgrade.translatable.test51
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/upgrade.trigger.test39
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/upgrade.upload.test83
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/upgrade/upgrade.user.test92
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/url_alter_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/url_alter_test.install12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/url_alter_test.module71
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/xmlrpc.test244
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/xmlrpc_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/simpletest/tests/xmlrpc_test.module111
-rw-r--r--kolab.org/www/drupal-7.26/modules/statistics/statistics.admin.inc319
-rw-r--r--kolab.org/www/drupal-7.26/modules/statistics/statistics.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/statistics/statistics.install159
-rw-r--r--kolab.org/www/drupal-7.26/modules/statistics/statistics.js10
-rw-r--r--kolab.org/www/drupal-7.26/modules/statistics/statistics.module465
-rw-r--r--kolab.org/www/drupal-7.26/modules/statistics/statistics.pages.inc101
-rw-r--r--kolab.org/www/drupal-7.26/modules/statistics/statistics.php31
-rw-r--r--kolab.org/www/drupal-7.26/modules/statistics/statistics.test500
-rw-r--r--kolab.org/www/drupal-7.26/modules/statistics/statistics.tokens.inc63
-rw-r--r--kolab.org/www/drupal-7.26/modules/syslog/syslog.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/syslog/syslog.install15
-rw-r--r--kolab.org/www/drupal-7.26/modules/syslog/syslog.module119
-rw-r--r--kolab.org/www/drupal-7.26/modules/syslog/syslog.test44
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/html.tpl.php63
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/image.gd.inc367
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/language.api.php186
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/maintenance-page.tpl.php95
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/page.tpl.php156
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/region.tpl.php35
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.admin-rtl.css86
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.admin.css271
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.admin.inc3214
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.api.php4899
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.archiver.inc139
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.base-rtl.css58
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.base.css270
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.cron.js19
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.info19
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.install3156
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.js140
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.mail.inc133
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.maintenance.css55
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.menus-rtl.css37
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.menus.css116
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.messages-rtl.css13
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.messages.css63
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.module4021
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.queue.inc370
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.tar.inc1892
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.test2761
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.theme-rtl.css53
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.theme.css239
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.tokens.inc269
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/system.updater.inc150
-rw-r--r--kolab.org/www/drupal-7.26/modules/system/theme.api.php240
-rw-r--r--kolab.org/www/drupal-7.26/modules/taxonomy/taxonomy-term.tpl.php54
-rw-r--r--kolab.org/www/drupal-7.26/modules/taxonomy/taxonomy.admin.inc984
-rw-r--r--kolab.org/www/drupal-7.26/modules/taxonomy/taxonomy.api.php231
-rw-r--r--kolab.org/www/drupal-7.26/modules/taxonomy/taxonomy.css13
-rw-r--r--kolab.org/www/drupal-7.26/modules/taxonomy/taxonomy.info15
-rw-r--r--kolab.org/www/drupal-7.26/modules/taxonomy/taxonomy.install917
-rw-r--r--kolab.org/www/drupal-7.26/modules/taxonomy/taxonomy.js40
-rw-r--r--kolab.org/www/drupal-7.26/modules/taxonomy/taxonomy.module2048
-rw-r--r--kolab.org/www/drupal-7.26/modules/taxonomy/taxonomy.pages.inc181
-rw-r--r--kolab.org/www/drupal-7.26/modules/taxonomy/taxonomy.test1980
-rw-r--r--kolab.org/www/drupal-7.26/modules/taxonomy/taxonomy.tokens.inc189
-rw-r--r--kolab.org/www/drupal-7.26/modules/toolbar/toolbar-rtl.css41
-rw-r--r--kolab.org/www/drupal-7.26/modules/toolbar/toolbar.css150
-rw-r--r--kolab.org/www/drupal-7.26/modules/toolbar/toolbar.info11
-rw-r--r--kolab.org/www/drupal-7.26/modules/toolbar/toolbar.js111
-rw-r--r--kolab.org/www/drupal-7.26/modules/toolbar/toolbar.module363
-rw-r--r--kolab.org/www/drupal-7.26/modules/toolbar/toolbar.pngbin0 -> 558 bytes
-rw-r--r--kolab.org/www/drupal-7.26/modules/toolbar/toolbar.tpl.php39
-rw-r--r--kolab.org/www/drupal-7.26/modules/tracker/tracker.css7
-rw-r--r--kolab.org/www/drupal-7.26/modules/tracker/tracker.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/tracker/tracker.install225
-rw-r--r--kolab.org/www/drupal-7.26/modules/tracker/tracker.module380
-rw-r--r--kolab.org/www/drupal-7.26/modules/tracker/tracker.pages.inc129
-rw-r--r--kolab.org/www/drupal-7.26/modules/tracker/tracker.test268
-rw-r--r--kolab.org/www/drupal-7.26/modules/translation/tests/translation_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/translation/tests/translation_test.module13
-rw-r--r--kolab.org/www/drupal-7.26/modules/translation/translation.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/translation/translation.module551
-rw-r--r--kolab.org/www/drupal-7.26/modules/translation/translation.pages.inc82
-rw-r--r--kolab.org/www/drupal-7.26/modules/translation/translation.test492
-rw-r--r--kolab.org/www/drupal-7.26/modules/trigger/tests/trigger_test.info11
-rw-r--r--kolab.org/www/drupal-7.26/modules/trigger/tests/trigger_test.module136
-rw-r--r--kolab.org/www/drupal-7.26/modules/trigger/trigger.admin.inc319
-rw-r--r--kolab.org/www/drupal-7.26/modules/trigger/trigger.api.php78
-rw-r--r--kolab.org/www/drupal-7.26/modules/trigger/trigger.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/trigger/trigger.install116
-rw-r--r--kolab.org/www/drupal-7.26/modules/trigger/trigger.module671
-rw-r--r--kolab.org/www/drupal-7.26/modules/trigger/trigger.test771
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/aaa_update_test.1_0.xml34
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/aaa_update_test.info11
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/aaa_update_test.module6
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/aaa_update_test.no-releases.xml2
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/bbb_update_test.1_0.xml34
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/bbb_update_test.info11
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/bbb_update_test.module6
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/ccc_update_test.1_0.xml34
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/ccc_update_test.info11
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/ccc_update_test.module6
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/drupal.0.xml34
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/drupal.1.xml51
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/drupal.2-sec.xml69
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/drupal.dev.xml50
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/themes/update_test_basetheme/update_test_basetheme.info10
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/themes/update_test_subtheme/update_test_subtheme.info11
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/update_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/update_test.module191
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/update_test_basetheme.1_1-sec.xml52
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/tests/update_test_subtheme.1_0.xml34
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/update-rtl.css35
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/update.api.php133
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/update.authorize.inc333
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/update.compare.inc831
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/update.css135
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/update.fetch.inc423
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/update.info13
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/update.install190
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/update.manager.inc943
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/update.module993
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/update.report.inc327
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/update.settings.inc128
-rw-r--r--kolab.org/www/drupal-7.26/modules/update/update.test803
-rw-r--r--kolab.org/www/drupal-7.26/modules/user/tests/user_form_test.info12
-rw-r--r--kolab.org/www/drupal-7.26/modules/user/tests/user_form_test.module64
-rw-r--r--kolab.org/www/drupal-7.26/modules/user/user-picture.tpl.php23
-rw-r--r--kolab.org/www/drupal-7.26/modules/user/user-profile-category.tpl.php33
-rw-r--r--kolab.org/www/drupal-7.26/modules/user/user-profile-item.tpl.php26
-rw-r--r--kolab.org/www/drupal-7.26/modules/user/user-profile.tpl.php39
-rw-r--r--kolab.org/www/drupal-7.26/modules/user/user-rtl.css34
-rw-r--r--kolab.org/www/drupal-7.26/modules/user/user.admin.inc1053
-rw-r--r--kolab.org/www/drupal-7.26/modules/user/user.api.php469
-rw-r--r--kolab.org/www/drupal-7.26/modules/user/user.css102
-rw-r--r--kolab.org/www/drupal-7.26/modules/user/user.info16
-rw-r--r--kolab.org/www/drupal-7.26/modules/user/user.install913
-rw-r--r--kolab.org/www/drupal-7.26/modules/user/user.js196
-rw-r--r--kolab.org/www/drupal-7.26/modules/user/user.module4028
-rw-r--r--kolab.org/www/drupal-7.26/modules/user/user.pages.inc562
-rw-r--r--kolab.org/www/drupal-7.26/modules/user/user.permissions.js69
-rw-r--r--kolab.org/www/drupal-7.26/modules/user/user.test2368
-rw-r--r--kolab.org/www/drupal-7.26/modules/user/user.tokens.inc131
714 files changed, 233534 insertions, 0 deletions
diff --git a/kolab.org/www/drupal-7.26/modules/README.txt b/kolab.org/www/drupal-7.26/modules/README.txt
new file mode 100644
index 0000000..8928d80
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/README.txt
@@ -0,0 +1,9 @@
+
+This directory is reserved for core module files. Custom or contributed modules
+should be placed in their own subdirectory of the sites/all/modules directory.
+For multisite installations, they can also be placed in a subdirectory under
+/sites/{sitename}/modules/, where {sitename} is the name of your site (e.g.,
+www.example.com). This will allow you to more easily update Drupal core files.
+
+For more details, see: http://drupal.org/node/176043
+
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/aggregator-feed-source.tpl.php b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator-feed-source.tpl.php
new file mode 100644
index 0000000..f9cfa55
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator-feed-source.tpl.php
@@ -0,0 +1,36 @@
+<?php
+
+/**
+ * @file
+ * Default theme implementation to present the source of the feed.
+ *
+ * The contents are rendered above feed listings when browsing source feeds.
+ * For example, "example.com/aggregator/sources/1".
+ *
+ * Available variables:
+ * - $source_icon: Feed icon linked to the source. Rendered through
+ * theme_feed_icon().
+ * - $source_image: Image set by the feed source.
+ * - $source_description: Description set by the feed source.
+ * - $source_url: URL to the feed source.
+ * - $last_checked: How long ago the feed was checked locally.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_aggregator_feed_source()
+ *
+ * @ingroup themeable
+ */
+?>
+<div class="feed-source">
+ <?php print $source_icon; ?>
+ <?php print $source_image; ?>
+ <div class="feed-description">
+ <?php print $source_description; ?>
+ </div>
+ <div class="feed-url">
+ <em><?php print t('URL:'); ?></em> <a href="<?php print $source_url; ?>"><?php print $source_url; ?></a>
+ </div>
+ <div class="feed-updated">
+ <em><?php print t('Updated:'); ?></em> <?php print $last_checked; ?>
+ </div>
+</div>
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/aggregator-item.tpl.php b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator-item.tpl.php
new file mode 100644
index 0000000..74b2284
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator-item.tpl.php
@@ -0,0 +1,47 @@
+<?php
+
+/**
+ * @file
+ * Default theme implementation to format an individual feed item for display
+ * on the aggregator page.
+ *
+ * Available variables:
+ * - $feed_url: URL to the originating feed item.
+ * - $feed_title: Title of the feed item.
+ * - $source_url: Link to the local source section.
+ * - $source_title: Title of the remote source.
+ * - $source_date: Date the feed was posted on the remote source.
+ * - $content: Feed item content.
+ * - $categories: Linked categories assigned to the feed.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_aggregator_item()
+ *
+ * @ingroup themeable
+ */
+?>
+<div class="feed-item">
+ <h3 class="feed-item-title">
+ <a href="<?php print $feed_url; ?>"><?php print $feed_title; ?></a>
+ </h3>
+
+ <div class="feed-item-meta">
+ <?php if ($source_url): ?>
+ <a href="<?php print $source_url; ?>" class="feed-item-source"><?php print $source_title; ?></a> -
+ <?php endif; ?>
+ <span class="feed-item-date"><?php print $source_date; ?></span>
+ </div>
+
+<?php if ($content): ?>
+ <div class="feed-item-body">
+ <?php print $content; ?>
+ </div>
+<?php endif; ?>
+
+<?php if ($categories): ?>
+ <div class="feed-item-categories">
+ <?php print t('Categories'); ?>: <?php print implode(', ', $categories); ?>
+ </div>
+<?php endif ;?>
+
+</div>
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/aggregator-rtl.css b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator-rtl.css
new file mode 100644
index 0000000..057d015
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator-rtl.css
@@ -0,0 +1,7 @@
+/**
+ * Right-to-Left styles for theme in the Aggregator module.
+ */
+
+#aggregator .feed-source .feed-icon {
+ float: left;
+}
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/aggregator-summary-item.tpl.php b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator-summary-item.tpl.php
new file mode 100644
index 0000000..f9199a5
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator-summary-item.tpl.php
@@ -0,0 +1,25 @@
+<?php
+
+/**
+ * @file
+ * Default theme implementation to present a linked feed item for summaries.
+ *
+ * Available variables:
+ * - $feed_url: Link to originating feed.
+ * - $feed_title: Title of feed.
+ * - $feed_age: Age of remote feed.
+ * - $source_url: Link to remote source.
+ * - $source_title: Locally set title for the source.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_aggregator_summary_item()
+ *
+ * @ingroup themeable
+ */
+?>
+<a href="<?php print $feed_url; ?>"><?php print $feed_title; ?></a>
+<span class="age"><?php print $feed_age; ?></span>
+
+<?php if ($source_url): ?>,
+ <span class="source"><a href="<?php print $source_url; ?>"><?php print $source_title; ?></a></span>
+<?php endif; ?>
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/aggregator-summary-items.tpl.php b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator-summary-items.tpl.php
new file mode 100644
index 0000000..4a0551d
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator-summary-items.tpl.php
@@ -0,0 +1,25 @@
+<?php
+
+/**
+ * @file
+ * Default theme implementation to present feeds as list items.
+ *
+ * Each iteration generates a single feed source or category.
+ *
+ * Available variables:
+ * - $title: Title of the feed or category.
+ * - $summary_list: Unordered list of linked feed items generated through
+ * theme_item_list().
+ * - $source_url: URL to the local source or category.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_aggregator_summary_items()
+ *
+ * @ingroup themeable
+ */
+?>
+<h3><?php print $title; ?></h3>
+<?php print $summary_list; ?>
+<div class="links">
+ <a href="<?php print $source_url; ?>"><?php print t('More'); ?></a>
+</div>
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/aggregator-wrapper.tpl.php b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator-wrapper.tpl.php
new file mode 100644
index 0000000..2fa51a7
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator-wrapper.tpl.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * @file
+ * Default theme implementation to wrap aggregator content.
+ *
+ * Available variables:
+ * - $content: All aggregator content.
+ * - $page: Pager links rendered through theme_pager().
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_aggregator_wrapper()
+ *
+ * @ingroup themeable
+ */
+?>
+<div id="aggregator">
+ <?php print $content; ?>
+ <?php print $pager; ?>
+</div>
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.admin.inc b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.admin.inc
new file mode 100644
index 0000000..443facb
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.admin.inc
@@ -0,0 +1,633 @@
+<?php
+
+/**
+ * @file
+ * Administration page callbacks for the Aggregator module.
+ */
+
+/**
+ * Page callback: Displays the Aggregator module administration page.
+ */
+function aggregator_admin_overview() {
+ return aggregator_view();
+}
+
+/**
+ * Displays the aggregator administration page.
+ *
+ * @return
+ * A HTML-formatted string with administration page content.
+ */
+function aggregator_view() {
+ $result = db_query('SELECT f.fid, f.title, f.url, f.refresh, f.checked, f.link, f.description, f.hash, f.etag, f.modified, f.image, f.block, COUNT(i.iid) AS items FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid GROUP BY f.fid, f.title, f.url, f.refresh, f.checked, f.link, f.description, f.hash, f.etag, f.modified, f.image, f.block ORDER BY f.title');
+
+ $output = '<h3>' . t('Feed overview') . '</h3>';
+
+ $header = array(t('Title'), t('Items'), t('Last update'), t('Next update'), array('data' => t('Operations'), 'colspan' => '3'));
+ $rows = array();
+ foreach ($result as $feed) {
+ $rows[] = array(
+ l($feed->title, "aggregator/sources/$feed->fid"),
+ format_plural($feed->items, '1 item', '@count items'),
+ ($feed->checked ? t('@time ago', array('@time' => format_interval(REQUEST_TIME - $feed->checked))) : t('never')),
+ ($feed->checked && $feed->refresh ? t('%time left', array('%time' => format_interval($feed->checked + $feed->refresh - REQUEST_TIME))) : t('never')),
+ l(t('edit'), "admin/config/services/aggregator/edit/feed/$feed->fid"),
+ l(t('remove items'), "admin/config/services/aggregator/remove/$feed->fid"),
+ l(t('update items'), "admin/config/services/aggregator/update/$feed->fid", array('query' => array('token' => drupal_get_token("aggregator/update/$feed->fid")))),
+ );
+ }
+ $output .= theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No feeds available. <a href="@link">Add feed</a>.', array('@link' => url('admin/config/services/aggregator/add/feed')))));
+
+ $result = db_query('SELECT c.cid, c.title, COUNT(ci.iid) as items FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid GROUP BY c.cid, c.title ORDER BY title');
+
+ $output .= '<h3>' . t('Category overview') . '</h3>';
+
+ $header = array(t('Title'), t('Items'), t('Operations'));
+ $rows = array();
+ foreach ($result as $category) {
+ $rows[] = array(l($category->title, "aggregator/categories/$category->cid"), format_plural($category->items, '1 item', '@count items'), l(t('edit'), "admin/config/services/aggregator/edit/category/$category->cid"));
+ }
+ $output .= theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No categories available. <a href="@link">Add category</a>.', array('@link' => url('admin/config/services/aggregator/add/category')))));
+
+ return $output;
+}
+
+/**
+ * Form constructor for adding and editing feed sources.
+ *
+ * @param $feed
+ * (optional) If editing a feed, the feed to edit as a PHP stdClass value; if
+ * adding a new feed, NULL. Defaults to NULL.
+ *
+ * @ingroup forms
+ * @see aggregator_form_feed_validate()
+ * @see aggregator_form_feed_submit()
+ */
+function aggregator_form_feed($form, &$form_state, stdClass $feed = NULL) {
+ $period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
+ $period[AGGREGATOR_CLEAR_NEVER] = t('Never');
+
+ $form['title'] = array('#type' => 'textfield',
+ '#title' => t('Title'),
+ '#default_value' => isset($feed->title) ? $feed->title : '',
+ '#maxlength' => 255,
+ '#description' => t('The name of the feed (or the name of the website providing the feed).'),
+ '#required' => TRUE,
+ );
+ $form['url'] = array('#type' => 'textfield',
+ '#title' => t('URL'),
+ '#default_value' => isset($feed->url) ? $feed->url : '',
+ '#maxlength' => NULL,
+ '#description' => t('The fully-qualified URL of the feed.'),
+ '#required' => TRUE,
+ );
+ $form['refresh'] = array('#type' => 'select',
+ '#title' => t('Update interval'),
+ '#default_value' => isset($feed->refresh) ? $feed->refresh : 3600,
+ '#options' => $period,
+ '#description' => t('The length of time between feed updates. Requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status'))),
+ );
+ $form['block'] = array('#type' => 'select',
+ '#title' => t('News items in block'),
+ '#default_value' => isset($feed->block) ? $feed->block : 5,
+ '#options' => drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)),
+ '#description' => t("Drupal can make a block with the most recent news items of this feed. You can <a href=\"@block-admin\">configure blocks</a> to be displayed in the sidebar of your page. This setting lets you configure the number of news items to show in this feed's block. If you choose '0' this feed's block will be disabled.", array('@block-admin' => url('admin/structure/block'))),
+ );
+
+ // Handling of categories.
+ $options = array();
+ $values = array();
+ $categories = db_query('SELECT c.cid, c.title, f.fid FROM {aggregator_category} c LEFT JOIN {aggregator_category_feed} f ON c.cid = f.cid AND f.fid = :fid ORDER BY title', array(':fid' => isset($feed->fid) ? $feed->fid : NULL));
+ foreach ($categories as $category) {
+ $options[$category->cid] = check_plain($category->title);
+ if ($category->fid) $values[] = $category->cid;
+ }
+
+ if ($options) {
+ $form['category'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Categorize news items'),
+ '#default_value' => $values,
+ '#options' => $options,
+ '#description' => t('New feed items are automatically filed in the checked categories.'),
+ );
+ }
+
+ $form['actions'] = array('#type' => 'actions');
+ $form['actions']['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Save'),
+ );
+ if (!empty($feed->fid)) {
+ $form['actions']['delete'] = array(
+ '#type' => 'submit',
+ '#value' => t('Delete'),
+ );
+ $form['fid'] = array(
+ '#type' => 'hidden',
+ '#value' => $feed->fid,
+ );
+ }
+
+ return $form;
+}
+
+/**
+ * Form validation handler for aggregator_form_feed().
+ *
+ * @see aggregator_form_feed_submit()
+ */
+function aggregator_form_feed_validate($form, &$form_state) {
+ if ($form_state['values']['op'] == t('Save')) {
+ // Ensure URL is valid.
+ if (!valid_url($form_state['values']['url'], TRUE)) {
+ form_set_error('url', t('The URL %url is invalid. Enter a fully-qualified URL, such as http://www.example.com/feed.xml.', array('%url' => $form_state['values']['url'])));
+ }
+ // Check for duplicate titles.
+ if (isset($form_state['values']['fid'])) {
+ $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE (title = :title OR url = :url) AND fid <> :fid", array(':title' => $form_state['values']['title'], ':url' => $form_state['values']['url'], ':fid' => $form_state['values']['fid']));
+ }
+ else {
+ $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE title = :title OR url = :url", array(':title' => $form_state['values']['title'], ':url' => $form_state['values']['url']));
+ }
+ foreach ($result as $feed) {
+ if (strcasecmp($feed->title, $form_state['values']['title']) == 0) {
+ form_set_error('title', t('A feed named %feed already exists. Enter a unique title.', array('%feed' => $form_state['values']['title'])));
+ }
+ if (strcasecmp($feed->url, $form_state['values']['url']) == 0) {
+ form_set_error('url', t('A feed with this URL %url already exists. Enter a unique URL.', array('%url' => $form_state['values']['url'])));
+ }
+ }
+ }
+}
+
+/**
+ * Form submission handler for aggregator_form_feed().
+ *
+ * @see aggregator_form_feed_validate()
+ *
+ * @todo Add delete confirmation dialog.
+ */
+function aggregator_form_feed_submit($form, &$form_state) {
+ if ($form_state['values']['op'] == t('Delete')) {
+ $title = $form_state['values']['title'];
+ // Unset the title.
+ unset($form_state['values']['title']);
+ }
+ aggregator_save_feed($form_state['values']);
+ if (isset($form_state['values']['fid'])) {
+ if (isset($form_state['values']['title'])) {
+ drupal_set_message(t('The feed %feed has been updated.', array('%feed' => $form_state['values']['title'])));
+ if (arg(0) == 'admin') {
+ $form_state['redirect'] = 'admin/config/services/aggregator/';
+ return;
+ }
+ else {
+ $form_state['redirect'] = 'aggregator/sources/' . $form_state['values']['fid'];
+ return;
+ }
+ }
+ else {
+ watchdog('aggregator', 'Feed %feed deleted.', array('%feed' => $title));
+ drupal_set_message(t('The feed %feed has been deleted.', array('%feed' => $title)));
+ if (arg(0) == 'admin') {
+ $form_state['redirect'] = 'admin/config/services/aggregator/';
+ return;
+ }
+ else {
+ $form_state['redirect'] = 'aggregator/sources/';
+ return;
+ }
+ }
+ }
+ else {
+ watchdog('aggregator', 'Feed %feed added.', array('%feed' => $form_state['values']['title']), WATCHDOG_NOTICE, l(t('view'), 'admin/config/services/aggregator'));
+ drupal_set_message(t('The feed %feed has been added.', array('%feed' => $form_state['values']['title'])));
+ }
+}
+
+/**
+ * Deletes a feed.
+ *
+ * @param $feed
+ * An associative array describing the feed to be cleared.
+ *
+ * @see aggregator_admin_remove_feed_submit()
+ */
+function aggregator_admin_remove_feed($form, $form_state, $feed) {
+ return confirm_form(
+ array(
+ 'feed' => array(
+ '#type' => 'value',
+ '#value' => $feed,
+ ),
+ ),
+ t('Are you sure you want to remove all items from the feed %feed?', array('%feed' => $feed->title)),
+ 'admin/config/services/aggregator',
+ t('This action cannot be undone.'),
+ t('Remove items'),
+ t('Cancel')
+ );
+}
+
+/**
+ * Form submission handler for aggregator_admin_remove_feed().
+ *
+ * Removes all items from a feed and redirects to the overview page.
+ */
+function aggregator_admin_remove_feed_submit($form, &$form_state) {
+ aggregator_remove($form_state['values']['feed']);
+ $form_state['redirect'] = 'admin/config/services/aggregator';
+}
+
+/**
+ * Form constructor for importing feeds from OPML.
+ *
+ * @ingroup forms
+ * @see aggregator_form_opml_validate()
+ * @see aggregator_form_opml_submit()
+ */
+function aggregator_form_opml($form, &$form_state) {
+ $period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
+
+ $form['upload'] = array(
+ '#type' => 'file',
+ '#title' => t('OPML File'),
+ '#description' => t('Upload an OPML file containing a list of feeds to be imported.'),
+ );
+ $form['remote'] = array(
+ '#type' => 'textfield',
+ '#title' => t('OPML Remote URL'),
+ '#maxlength' => 1024,
+ '#description' => t('Enter the URL of an OPML file. This file will be downloaded and processed only once on submission of the form.'),
+ );
+ $form['refresh'] = array(
+ '#type' => 'select',
+ '#title' => t('Update interval'),
+ '#default_value' => 3600,
+ '#options' => $period,
+ '#description' => t('The length of time between feed updates. Requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status'))),
+ );
+ $form['block'] = array('#type' => 'select',
+ '#title' => t('News items in block'),
+ '#default_value' => 5,
+ '#options' => drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)),
+ '#description' => t("Drupal can make a block with the most recent news items of a feed. You can <a href=\"@block-admin\">configure blocks</a> to be displayed in the sidebar of your page. This setting lets you configure the number of news items to show in a feed's block. If you choose '0' these feeds' blocks will be disabled.", array('@block-admin' => url('admin/structure/block'))),
+ );
+
+ // Handling of categories.
+ $options = array_map('check_plain', db_query("SELECT cid, title FROM {aggregator_category} ORDER BY title")->fetchAllKeyed());
+ if ($options) {
+ $form['category'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Categorize news items'),
+ '#options' => $options,
+ '#description' => t('New feed items are automatically filed in the checked categories.'),
+ );
+ }
+ $form['actions'] = array('#type' => 'actions');
+ $form['actions']['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Import')
+ );
+
+ return $form;
+}
+
+/**
+ * Form validation handler for aggregator_form_opml().
+ *
+ * @see aggregator_form_opml_submit()
+ */
+function aggregator_form_opml_validate($form, &$form_state) {
+ // If both fields are empty or filled, cancel.
+ if (empty($form_state['values']['remote']) == empty($_FILES['files']['name']['upload'])) {
+ form_set_error('remote', t('You must <em>either</em> upload a file or enter a URL.'));
+ }
+
+ // Validate the URL, if one was entered.
+ if (!empty($form_state['values']['remote']) && !valid_url($form_state['values']['remote'], TRUE)) {
+ form_set_error('remote', t('This URL is not valid.'));
+ }
+}
+
+/**
+ * Form submission handler for aggregator_form_opml().
+ *
+ * @see aggregator_form_opml_validate()
+ */
+function aggregator_form_opml_submit($form, &$form_state) {
+ $data = '';
+ $validators = array('file_validate_extensions' => array('opml xml'));
+ if ($file = file_save_upload('upload', $validators)) {
+ $data = file_get_contents($file->uri);
+ }
+ else {
+ $response = drupal_http_request($form_state['values']['remote']);
+ if (!isset($response->error)) {
+ $data = $response->data;
+ }
+ }
+
+ $feeds = _aggregator_parse_opml($data);
+ if (empty($feeds)) {
+ drupal_set_message(t('No new feed has been added.'));
+ return;
+ }
+
+ $form_state['values']['op'] = t('Save');
+
+ foreach ($feeds as $feed) {
+ // Ensure URL is valid.
+ if (!valid_url($feed['url'], TRUE)) {
+ drupal_set_message(t('The URL %url is invalid.', array('%url' => $feed['url'])), 'warning');
+ continue;
+ }
+
+ // Check for duplicate titles or URLs.
+ $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE title = :title OR url = :url", array(':title' => $feed['title'], ':url' => $feed['url']));
+ foreach ($result as $old) {
+ if (strcasecmp($old->title, $feed['title']) == 0) {
+ drupal_set_message(t('A feed named %title already exists.', array('%title' => $old->title)), 'warning');
+ continue 2;
+ }
+ if (strcasecmp($old->url, $feed['url']) == 0) {
+ drupal_set_message(t('A feed with the URL %url already exists.', array('%url' => $old->url)), 'warning');
+ continue 2;
+ }
+ }
+
+ $form_state['values']['title'] = $feed['title'];
+ $form_state['values']['url'] = $feed['url'];
+ drupal_form_submit('aggregator_form_feed', $form_state);
+ }
+
+ $form_state['redirect'] = 'admin/config/services/aggregator';
+}
+
+/**
+ * Parses an OPML file.
+ *
+ * Feeds are recognized as <outline> elements with the attributes "text" and
+ * "xmlurl" set.
+ *
+ * @param $opml
+ * The complete contents of an OPML document.
+ *
+ * @return
+ * An array of feeds, each an associative array with a "title" and a "url"
+ * element, or NULL if the OPML document failed to be parsed. An empty array
+ * will be returned if the document is valid but contains no feeds, as some
+ * OPML documents do.
+ */
+function _aggregator_parse_opml($opml) {
+ $feeds = array();
+ $xml_parser = drupal_xml_parser_create($opml);
+ if (xml_parse_into_struct($xml_parser, $opml, $values)) {
+ foreach ($values as $entry) {
+ if ($entry['tag'] == 'OUTLINE' && isset($entry['attributes'])) {
+ $item = $entry['attributes'];
+ if (!empty($item['XMLURL']) && !empty($item['TEXT'])) {
+ $feeds[] = array('title' => $item['TEXT'], 'url' => $item['XMLURL']);
+ }
+ }
+ }
+ }
+ xml_parser_free($xml_parser);
+
+ return $feeds;
+}
+
+/**
+ * Page callback: Refreshes a feed, then redirects to the overview page.
+ *
+ * @param $feed
+ * An object describing the feed to be refreshed.
+ */
+function aggregator_admin_refresh_feed($feed) {
+ if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], 'aggregator/update/' . $feed->fid)) {
+ return MENU_ACCESS_DENIED;
+ }
+ aggregator_refresh($feed);
+ drupal_goto('admin/config/services/aggregator');
+}
+
+/**
+ * Form constructor for the aggregator system settings.
+ *
+ * @see aggregator_admin_form_submit()
+ * @ingroup forms
+ */
+function aggregator_admin_form($form, $form_state) {
+ // Global aggregator settings.
+ $form['aggregator_allowed_html_tags'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed HTML tags'),
+ '#size' => 80,
+ '#maxlength' => 255,
+ '#default_value' => variable_get('aggregator_allowed_html_tags', '<a> <b> <br> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>'),
+ '#description' => t('A space-separated list of HTML tags allowed in the content of feed items. Disallowed tags are stripped from the content.'),
+ );
+
+ // Make sure configuration is sane.
+ aggregator_sanitize_configuration();
+
+ // Get all available fetchers.
+ $fetchers = module_implements('aggregator_fetch');
+ foreach ($fetchers as $k => $module) {
+ if ($info = module_invoke($module, 'aggregator_fetch_info')) {
+ $label = $info['title'] . ' <span class="description">' . $info['description'] . '</span>';
+ }
+ else {
+ $label = $module;
+ }
+ unset($fetchers[$k]);
+ $fetchers[$module] = $label;
+ }
+
+ // Get all available parsers.
+ $parsers = module_implements('aggregator_parse');
+ foreach ($parsers as $k => $module) {
+ if ($info = module_invoke($module, 'aggregator_parse_info')) {
+ $label = $info['title'] . ' <span class="description">' . $info['description'] . '</span>';
+ }
+ else {
+ $label = $module;
+ }
+ unset($parsers[$k]);
+ $parsers[$module] = $label;
+ }
+
+ // Get all available processors.
+ $processors = module_implements('aggregator_process');
+ foreach ($processors as $k => $module) {
+ if ($info = module_invoke($module, 'aggregator_process_info')) {
+ $label = $info['title'] . ' <span class="description">' . $info['description'] . '</span>';
+ }
+ else {
+ $label = $module;
+ }
+ unset($processors[$k]);
+ $processors[$module] = $label;
+ }
+
+ // Only show basic configuration if there are actually options.
+ $basic_conf = array();
+ if (count($fetchers) > 1) {
+ $basic_conf['aggregator_fetcher'] = array(
+ '#type' => 'radios',
+ '#title' => t('Fetcher'),
+ '#description' => t('Fetchers download data from an external source. Choose a fetcher suitable for the external source you would like to download from.'),
+ '#options' => $fetchers,
+ '#default_value' => variable_get('aggregator_fetcher', 'aggregator'),
+ );
+ }
+ if (count($parsers) > 1) {
+ $basic_conf['aggregator_parser'] = array(
+ '#type' => 'radios',
+ '#title' => t('Parser'),
+ '#description' => t('Parsers transform downloaded data into standard structures. Choose a parser suitable for the type of feeds you would like to aggregate.'),
+ '#options' => $parsers,
+ '#default_value' => variable_get('aggregator_parser', 'aggregator'),
+ );
+ }
+ if (count($processors) > 1) {
+ $basic_conf['aggregator_processors'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Processors'),
+ '#description' => t('Processors act on parsed feed data, for example they store feed items. Choose the processors suitable for your task.'),
+ '#options' => $processors,
+ '#default_value' => variable_get('aggregator_processors', array('aggregator')),
+ );
+ }
+ if (count($basic_conf)) {
+ $form['basic_conf'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Basic configuration'),
+ '#description' => t('For most aggregation tasks, the default settings are fine.'),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+ );
+ $form['basic_conf'] += $basic_conf;
+ }
+
+ // Implementing modules will expect an array at $form['modules'].
+ $form['modules'] = array();
+
+ $form['actions'] = array('#type' => 'actions');
+ $form['actions']['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Save configuration'),
+ );
+
+ return $form;
+}
+
+/**
+ * Form submission handler for aggregator_admin_form().
+ */
+function aggregator_admin_form_submit($form, &$form_state) {
+ if (isset($form_state['values']['aggregator_processors'])) {
+ $form_state['values']['aggregator_processors'] = array_filter($form_state['values']['aggregator_processors']);
+ }
+ system_settings_form_submit($form, $form_state);
+}
+
+/**
+ * Form constructor to add/edit/delete aggregator categories.
+ *
+ * @param $edit
+ * An associative array containing:
+ * - title: A string to use for the category title.
+ * - description: A string to use for the category description.
+ * - cid: The category ID.
+ *
+ * @ingroup forms
+ * @see aggregator_form_category_validate()
+ * @see aggregator_form_category_submit()
+ */
+function aggregator_form_category($form, &$form_state, $edit = array('title' => '', 'description' => '', 'cid' => NULL)) {
+ $form['title'] = array('#type' => 'textfield',
+ '#title' => t('Title'),
+ '#default_value' => $edit['title'],
+ '#maxlength' => 64,
+ '#required' => TRUE,
+ );
+ $form['description'] = array('#type' => 'textarea',
+ '#title' => t('Description'),
+ '#default_value' => $edit['description'],
+ );
+ $form['actions'] = array('#type' => 'actions');
+ $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
+ if ($edit['cid']) {
+ $form['actions']['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
+ $form['cid'] = array('#type' => 'hidden', '#value' => $edit['cid']);
+ }
+
+ return $form;
+}
+
+/**
+ * Form validation handler for aggregator_form_category().
+ *
+ * @see aggregator_form_category_submit()
+ */
+function aggregator_form_category_validate($form, &$form_state) {
+ if ($form_state['values']['op'] == t('Save')) {
+ // Check for duplicate titles
+ if (isset($form_state['values']['cid'])) {
+ $category = db_query("SELECT cid FROM {aggregator_category} WHERE title = :title AND cid <> :cid", array(':title' => $form_state['values']['title'], ':cid' => $form_state['values']['cid']))->fetchObject();
+ }
+ else {
+ $category = db_query("SELECT cid FROM {aggregator_category} WHERE title = :title", array(':title' => $form_state['values']['title']))->fetchObject();
+ }
+ if ($category) {
+ form_set_error('title', t('A category named %category already exists. Enter a unique title.', array('%category' => $form_state['values']['title'])));
+ }
+ }
+}
+
+/**
+ * Form submission handler for aggregator_form_category().
+ *
+ * @see aggregator_form_category_validate()
+ *
+ * @todo Add delete confirmation dialog.
+ */
+function aggregator_form_category_submit($form, &$form_state) {
+ if ($form_state['values']['op'] == t('Delete')) {
+ $title = $form_state['values']['title'];
+ // Unset the title.
+ unset($form_state['values']['title']);
+ }
+ aggregator_save_category($form_state['values']);
+ if (isset($form_state['values']['cid'])) {
+ if (isset($form_state['values']['title'])) {
+ drupal_set_message(t('The category %category has been updated.', array('%category' => $form_state['values']['title'])));
+ if (arg(0) == 'admin') {
+ $form_state['redirect'] = 'admin/config/services/aggregator/';
+ return;
+ }
+ else {
+ $form_state['redirect'] = 'aggregator/categories/' . $form_state['values']['cid'];
+ return;
+ }
+ }
+ else {
+ watchdog('aggregator', 'Category %category deleted.', array('%category' => $title));
+ drupal_set_message(t('The category %category has been deleted.', array('%category' => $title)));
+ if (arg(0) == 'admin') {
+ $form_state['redirect'] = 'admin/config/services/aggregator/';
+ return;
+ }
+ else {
+ $form_state['redirect'] = 'aggregator/categories/';
+ return;
+ }
+ }
+ }
+ else {
+ watchdog('aggregator', 'Category %category added.', array('%category' => $form_state['values']['title']), WATCHDOG_NOTICE, l(t('view'), 'admin/config/services/aggregator'));
+ drupal_set_message(t('The category %category has been added.', array('%category' => $form_state['values']['title'])));
+ }
+}
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.api.php b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.api.php
new file mode 100644
index 0000000..d5cac4e
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.api.php
@@ -0,0 +1,220 @@
+<?php
+
+/**
+ * @file
+ * Documentation for aggregator API.
+ */
+
+/**
+ * @addtogroup hooks
+ * @{
+ */
+
+/**
+ * Create an alternative fetcher for aggregator.module.
+ *
+ * A fetcher downloads feed data to a Drupal site. The fetcher is called at the
+ * first of the three aggregation stages: first, data is downloaded by the
+ * active fetcher; second, it is converted to a common format by the active
+ * parser; and finally, it is passed to all active processors, which manipulate
+ * or store the data.
+ *
+ * Modules that define this hook can be set as the active fetcher within the
+ * configuration page. Only one fetcher can be active at a time.
+ *
+ * @param $feed
+ * A feed object representing the resource to be downloaded. $feed->url
+ * contains the link to the feed. Download the data at the URL and expose it
+ * to other modules by attaching it to $feed->source_string.
+ *
+ * @return
+ * TRUE if fetching was successful, FALSE otherwise.
+ *
+ * @see hook_aggregator_fetch_info()
+ * @see hook_aggregator_parse()
+ * @see hook_aggregator_process()
+ *
+ * @ingroup aggregator
+ */
+function hook_aggregator_fetch($feed) {
+ $feed->source_string = mymodule_fetch($feed->url);
+}
+
+/**
+ * Specify the title and short description of your fetcher.
+ *
+ * The title and the description provided are shown within the configuration
+ * page. Use as title the human readable name of the fetcher and as description
+ * a brief (40 to 80 characters) explanation of the fetcher's functionality.
+ *
+ * This hook is only called if your module implements hook_aggregator_fetch().
+ * If this hook is not implemented aggregator will use your module's file name
+ * as title and there will be no description.
+ *
+ * @return
+ * An associative array defining a title and a description string.
+ *
+ * @see hook_aggregator_fetch()
+ *
+ * @ingroup aggregator
+ */
+function hook_aggregator_fetch_info() {
+ return array(
+ 'title' => t('Default fetcher'),
+ 'description' => t('Default fetcher for resources available by URL.'),
+ );
+}
+
+/**
+ * Create an alternative parser for aggregator module.
+ *
+ * A parser converts feed item data to a common format. The parser is called
+ * at the second of the three aggregation stages: first, data is downloaded
+ * by the active fetcher; second, it is converted to a common format by the
+ * active parser; and finally, it is passed to all active processors which
+ * manipulate or store the data.
+ *
+ * Modules that define this hook can be set as the active parser within the
+ * configuration page. Only one parser can be active at a time.
+ *
+ * @param $feed
+ * An object describing the resource to be parsed. $feed->source_string
+ * contains the raw feed data. The hook implementation should parse this data
+ * and add the following properties to the $feed object:
+ * - description: The human-readable description of the feed.
+ * - link: A full URL that directly relates to the feed.
+ * - image: An image URL used to display an image of the feed.
+ * - etag: An entity tag from the HTTP header used for cache validation to
+ * determine if the content has been changed.
+ * - modified: The UNIX timestamp when the feed was last modified.
+ * - items: An array of feed items. The common format for a single feed item
+ * is an associative array containing:
+ * - title: The human-readable title of the feed item.
+ * - description: The full body text of the item or a summary.
+ * - timestamp: The UNIX timestamp when the feed item was last published.
+ * - author: The author of the feed item.
+ * - guid: The global unique identifier (GUID) string that uniquely
+ * identifies the item. If not available, the link is used to identify
+ * the item.
+ * - link: A full URL to the individual feed item.
+ *
+ * @return
+ * TRUE if parsing was successful, FALSE otherwise.
+ *
+ * @see hook_aggregator_parse_info()
+ * @see hook_aggregator_fetch()
+ * @see hook_aggregator_process()
+ *
+ * @ingroup aggregator
+ */
+function hook_aggregator_parse($feed) {
+ if ($items = mymodule_parse($feed->source_string)) {
+ $feed->items = $items;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/**
+ * Specify the title and short description of your parser.
+ *
+ * The title and the description provided are shown within the configuration
+ * page. Use as title the human readable name of the parser and as description
+ * a brief (40 to 80 characters) explanation of the parser's functionality.
+ *
+ * This hook is only called if your module implements hook_aggregator_parse().
+ * If this hook is not implemented aggregator will use your module's file name
+ * as title and there will be no description.
+ *
+ * @return
+ * An associative array defining a title and a description string.
+ *
+ * @see hook_aggregator_parse()
+ *
+ * @ingroup aggregator
+ */
+function hook_aggregator_parse_info() {
+ return array(
+ 'title' => t('Default parser'),
+ 'description' => t('Default parser for RSS, Atom and RDF feeds.'),
+ );
+}
+
+/**
+ * Create a processor for aggregator.module.
+ *
+ * A processor acts on parsed feed data. Active processors are called at the
+ * third and last of the aggregation stages: first, data is downloaded by the
+ * active fetcher; second, it is converted to a common format by the active
+ * parser; and finally, it is passed to all active processors that manipulate or
+ * store the data.
+ *
+ * Modules that define this hook can be activated as a processor within the
+ * configuration page.
+ *
+ * @param $feed
+ * A feed object representing the resource to be processed. $feed->items
+ * contains an array of feed items downloaded and parsed at the parsing stage.
+ * See hook_aggregator_parse() for the basic format of a single item in the
+ * $feed->items array. For the exact format refer to the particular parser in
+ * use.
+ *
+ * @see hook_aggregator_process_info()
+ * @see hook_aggregator_fetch()
+ * @see hook_aggregator_parse()
+ *
+ * @ingroup aggregator
+ */
+function hook_aggregator_process($feed) {
+ foreach ($feed->items as $item) {
+ mymodule_save($item);
+ }
+}
+
+/**
+ * Specify the title and short description of your processor.
+ *
+ * The title and the description provided are shown within the configuration
+ * page. Use as title the natural name of the processor and as description a
+ * brief (40 to 80 characters) explanation of the functionality.
+ *
+ * This hook is only called if your module implements hook_aggregator_process().
+ * If this hook is not implemented aggregator will use your module's file name
+ * as title and there will be no description.
+ *
+ * @return
+ * An associative array defining a title and a description string.
+ *
+ * @see hook_aggregator_process()
+ *
+ * @ingroup aggregator
+ */
+function hook_aggregator_process_info() {
+ return array(
+ 'title' => t('Default processor'),
+ 'description' => t('Creates lightweight records of feed items.'),
+ );
+}
+
+/**
+ * Remove stored feed data.
+ *
+ * Aggregator calls this hook if either a feed is deleted or a user clicks on
+ * "remove items".
+ *
+ * If your module stores feed items for example on hook_aggregator_process() it
+ * is recommended to implement this hook and to remove data related to $feed
+ * when called.
+ *
+ * @param $feed
+ * The $feed object whose items are being removed.
+ *
+ * @ingroup aggregator
+ */
+function hook_aggregator_remove($feed) {
+ mymodule_remove_items($feed->fid);
+}
+
+/**
+ * @} End of "addtogroup hooks".
+ */
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.css b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.css
new file mode 100644
index 0000000..4285631
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.css
@@ -0,0 +1,41 @@
+/**
+ * Styles for theme in the Aggregator module.
+ */
+
+#aggregator .feed-source .feed-title {
+ margin-top: 0;
+}
+#aggregator .feed-source .feed-image img {
+ margin-bottom: 0.75em;
+}
+#aggregator .feed-source .feed-icon {
+ float: right; /* LTR */
+ display: block;
+}
+#aggregator .feed-item {
+ margin-bottom: 1.5em;
+}
+#aggregator .feed-item-title {
+ margin-bottom: 0;
+ font-size: 1.3em;
+}
+#aggregator .feed-item-meta,
+#aggregator .feed-item-body {
+ margin-bottom: 0.5em;
+}
+#aggregator .feed-item-categories {
+ font-size: 0.9em;
+}
+#aggregator td {
+ vertical-align: bottom;
+}
+#aggregator td.categorize-item {
+ white-space: nowrap;
+}
+#aggregator .categorize-item .news-item .body {
+ margin-top: 0;
+}
+#aggregator .categorize-item h3 {
+ margin-bottom: 1em;
+ margin-top: 0;
+}
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.fetcher.inc b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.fetcher.inc
new file mode 100644
index 0000000..0f72877
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.fetcher.inc
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * @file
+ * Fetcher functions for the aggregator module.
+ */
+
+/**
+ * Implements hook_aggregator_fetch_info().
+ */
+function aggregator_aggregator_fetch_info() {
+ return array(
+ 'title' => t('Default fetcher'),
+ 'description' => t('Downloads data from a URL using Drupal\'s HTTP request handler.'),
+ );
+}
+
+/**
+ * Implements hook_aggregator_fetch().
+ */
+function aggregator_aggregator_fetch($feed) {
+ $feed->source_string = FALSE;
+
+ // Generate conditional GET headers.
+ $headers = array();
+ if ($feed->etag) {
+ $headers['If-None-Match'] = $feed->etag;
+ }
+ if ($feed->modified) {
+ $headers['If-Modified-Since'] = gmdate(DATE_RFC1123, $feed->modified);
+ }
+
+ // Request feed.
+ $result = drupal_http_request($feed->url, array('headers' => $headers));
+
+ // Process HTTP response code.
+ switch ($result->code) {
+ case 304:
+ break;
+ case 301:
+ $feed->url = $result->redirect_url;
+ // Do not break here.
+ case 200:
+ case 302:
+ case 307:
+ if (!isset($result->data)) {
+ $result->data = '';
+ }
+ if (!isset($result->headers)) {
+ $result->headers = array();
+ }
+ $feed->source_string = $result->data;
+ $feed->http_headers = $result->headers;
+ break;
+ default:
+ watchdog('aggregator', 'The feed from %site seems to be broken, due to "%error".', array('%site' => $feed->title, '%error' => $result->code . ' ' . $result->error), WATCHDOG_WARNING);
+ drupal_set_message(t('The feed from %site seems to be broken, because of error "%error".', array('%site' => $feed->title, '%error' => $result->code . ' ' . $result->error)));
+ }
+
+ return $feed->source_string === FALSE ? FALSE : TRUE;
+}
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.info b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.info
new file mode 100644
index 0000000..17fb2e5
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.info
@@ -0,0 +1,14 @@
+name = Aggregator
+description = "Aggregates syndicated content (RSS, RDF, and Atom feeds)."
+package = Core
+version = VERSION
+core = 7.x
+files[] = aggregator.test
+configure = admin/config/services/aggregator/settings
+stylesheets[all][] = aggregator.css
+
+; Information added by Drupal.org packaging script on 2014-01-15
+version = "7.26"
+project = "drupal"
+datestamp = "1389815930"
+
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.install b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.install
new file mode 100644
index 0000000..b84556a
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.install
@@ -0,0 +1,330 @@
+<?php
+
+/**
+ * @file
+ * Install, update and uninstall functions for the aggregator module.
+ */
+
+/**
+ * Implements hook_uninstall().
+ */
+function aggregator_uninstall() {
+ variable_del('aggregator_allowed_html_tags');
+ variable_del('aggregator_summary_items');
+ variable_del('aggregator_clear');
+ variable_del('aggregator_category_selector');
+ variable_del('aggregator_fetcher');
+ variable_del('aggregator_parser');
+ variable_del('aggregator_processors');
+ variable_del('aggregator_teaser_length');
+}
+
+/**
+ * Implements hook_schema().
+ */
+function aggregator_schema() {
+ $schema['aggregator_category'] = array(
+ 'description' => 'Stores categories for aggregator feeds and feed items.',
+ 'fields' => array(
+ 'cid' => array(
+ 'type' => 'serial',
+ 'not null' => TRUE,
+ 'description' => 'Primary Key: Unique aggregator category ID.',
+ ),
+ 'title' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'description' => 'Title of the category.',
+ ),
+ 'description' => array(
+ 'type' => 'text',
+ 'not null' => TRUE,
+ 'size' => 'big',
+ 'description' => 'Description of the category',
+ ),
+ 'block' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'size' => 'tiny',
+ 'description' => 'The number of recent items to show within the category block.',
+ )
+ ),
+ 'primary key' => array('cid'),
+ 'unique keys' => array(
+ 'title' => array('title'),
+ ),
+ );
+
+ $schema['aggregator_category_feed'] = array(
+ 'description' => 'Bridge table; maps feeds to categories.',
+ 'fields' => array(
+ 'fid' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => "The feed's {aggregator_feed}.fid.",
+ ),
+ 'cid' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => 'The {aggregator_category}.cid to which the feed is being assigned.',
+ )
+ ),
+ 'primary key' => array('cid', 'fid'),
+ 'indexes' => array(
+ 'fid' => array('fid'),
+ ),
+ 'foreign keys' => array(
+ 'aggregator_category' => array(
+ 'table' => 'aggregator_category',
+ 'columns' => array('cid' => 'cid'),
+ ),
+ ),
+ );
+
+ $schema['aggregator_category_item'] = array(
+ 'description' => 'Bridge table; maps feed items to categories.',
+ 'fields' => array(
+ 'iid' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => "The feed item's {aggregator_item}.iid.",
+ ),
+ 'cid' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => 'The {aggregator_category}.cid to which the feed item is being assigned.',
+ )
+ ),
+ 'primary key' => array('cid', 'iid'),
+ 'indexes' => array(
+ 'iid' => array('iid'),
+ ),
+ 'foreign keys' => array(
+ 'aggregator_category' => array(
+ 'table' => 'aggregator_category',
+ 'columns' => array('cid' => 'cid'),
+ ),
+ ),
+ );
+
+ $schema['aggregator_feed'] = array(
+ 'description' => 'Stores feeds to be parsed by the aggregator.',
+ 'fields' => array(
+ 'fid' => array(
+ 'type' => 'serial',
+ 'not null' => TRUE,
+ 'description' => 'Primary Key: Unique feed ID.',
+ ),
+ 'title' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'description' => 'Title of the feed.',
+ ),
+ 'url' => array(
+ 'type' => 'text',
+ 'not null' => TRUE,
+ 'description' => 'URL to the feed.',
+ ),
+ 'refresh' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => 'How often to check for new feed items, in seconds.',
+ ),
+ 'checked' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => 'Last time feed was checked for new items, as Unix timestamp.',
+ ),
+ 'queued' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => 'Time when this feed was queued for refresh, 0 if not queued.',
+ ),
+ 'link' => array(
+ 'type' => 'text',
+ 'not null' => TRUE,
+ 'description' => 'The parent website of the feed; comes from the <link> element in the feed.',
+ ),
+ 'description' => array(
+ 'type' => 'text',
+ 'not null' => TRUE,
+ 'size' => 'big',
+ 'description' => "The parent website's description; comes from the <description> element in the feed.",
+ ),
+ 'image' => array(
+ 'type' => 'text',
+ 'not null' => TRUE,
+ 'size' => 'big',
+ 'description' => 'An image representing the feed.',
+ ),
+ 'hash' => array(
+ 'type' => 'varchar',
+ 'length' => 64,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'description' => 'Calculated hash of the feed data, used for validating cache.',
+ ),
+ 'etag' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'description' => 'Entity tag HTTP response header, used for validating cache.',
+ ),
+ 'modified' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => 'When the feed was last modified, as a Unix timestamp.',
+ ),
+ 'block' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'size' => 'tiny',
+ 'description' => "Number of items to display in the feed's block.",
+ )
+ ),
+ 'primary key' => array('fid'),
+ 'indexes' => array(
+ 'url' => array(array('url', 255)),
+ 'queued' => array('queued'),
+ ),
+ 'unique keys' => array(
+ 'title' => array('title'),
+ ),
+ );
+
+ $schema['aggregator_item'] = array(
+ 'description' => 'Stores the individual items imported from feeds.',
+ 'fields' => array(
+ 'iid' => array(
+ 'type' => 'serial',
+ 'not null' => TRUE,
+ 'description' => 'Primary Key: Unique ID for feed item.',
+ ),
+ 'fid' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => 'The {aggregator_feed}.fid to which this item belongs.',
+ ),
+ 'title' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'description' => 'Title of the feed item.',
+ ),
+ 'link' => array(
+ 'type' => 'text',
+ 'not null' => TRUE,
+ 'description' => 'Link to the feed item.',
+ ),
+ 'author' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'description' => 'Author of the feed item.',
+ ),
+ 'description' => array(
+ 'type' => 'text',
+ 'not null' => TRUE,
+ 'size' => 'big',
+ 'description' => 'Body of the feed item.',
+ ),
+ 'timestamp' => array(
+ 'type' => 'int',
+ 'not null' => FALSE,
+ 'description' => 'Posted date of the feed item, as a Unix timestamp.',
+ ),
+ 'guid' => array(
+ 'type' => 'text',
+ 'not null' => TRUE,
+ 'description' => 'Unique identifier for the feed item.',
+ )
+ ),
+ 'primary key' => array('iid'),
+ 'indexes' => array(
+ 'fid' => array('fid'),
+ ),
+ 'foreign keys' => array(
+ 'aggregator_feed' => array(
+ 'table' => 'aggregator_feed',
+ 'columns' => array('fid' => 'fid'),
+ ),
+ ),
+ );
+
+ return $schema;
+}
+
+/**
+ * @addtogroup updates-6.x-to-7.x
+ * @{
+ */
+
+/**
+ * Add hash column to aggregator_feed table.
+ */
+function aggregator_update_7000() {
+ db_add_field('aggregator_feed', 'hash', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''));
+}
+
+/**
+ * Add aggregator teaser length to settings from old global default teaser length
+ */
+function aggregator_update_7001() {
+ variable_set('aggregator_teaser_length', variable_get('teaser_length'));
+}
+
+/**
+ * Add queued timestamp.
+ */
+function aggregator_update_7002() {
+ db_add_field('aggregator_feed', 'queued', array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => 'Time when this feed was queued for refresh, 0 if not queued.',
+ ));
+ db_add_index('aggregator_feed', 'queued', array('queued'));
+}
+
+/**
+ * @} End of "addtogroup updates-6.x-to-7.x"
+ */
+
+/**
+ * @addtogroup updates-7.x-extra
+ * @{
+ */
+
+/**
+ * Increase the length of {aggregator_feed}.url.
+ */
+function aggregator_update_7003() {
+ db_drop_unique_key('aggregator_feed', 'url');
+ db_change_field('aggregator_feed', 'url', 'url', array('type' => 'text', 'not null' => TRUE, 'description' => 'URL to the feed.'));
+ db_change_field('aggregator_feed', 'link', 'link', array('type' => 'text', 'not null' => TRUE, 'description' => 'The parent website of the feed; comes from the <link> element in the feed.'));
+ db_change_field('aggregator_item', 'link', 'link', array('type' => 'text', 'not null' => TRUE, 'description' => 'Link to the feed item.'));
+ db_change_field('aggregator_item', 'guid', 'guid', array('type' => 'text', 'not null' => TRUE, 'description' => 'Unique identifier for the feed item.'));
+ db_add_index('aggregator_feed', 'url', array(array('url', 255)));
+}
+
+/**
+ * @} End of "addtogroup updates-7.x-extra"
+ */
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.module b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.module
new file mode 100644
index 0000000..70f8c5c
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.module
@@ -0,0 +1,782 @@
+<?php
+
+/**
+ * @file
+ * Used to aggregate syndicated content (RSS, RDF, and Atom).
+ */
+
+/**
+ * Denotes that a feed's items should never expire.
+ */
+define('AGGREGATOR_CLEAR_NEVER', 0);
+
+/**
+ * Implements hook_help().
+ */
+function aggregator_help($path, $arg) {
+ switch ($path) {
+ case 'admin/help#aggregator':
+ $output = '';
+ $output .= '<h3>' . t('About') . '</h3>';
+ $output .= '<p>' . t('The Aggregator module is an on-site syndicator and news reader that gathers and displays fresh content from RSS-, RDF-, and Atom-based feeds made available across the web. Thousands of sites (particularly news sites and blogs) publish their latest headlines in feeds, using a number of standardized XML-based formats. For more information, see the online handbook entry for <a href="@aggregator-module">Aggregator module</a>.', array('@aggregator-module' => 'http://drupal.org/documentation/modules/aggregator', '@aggregator' => url('aggregator'))) . '</p>';
+ $output .= '<h3>' . t('Uses') . '</h3>';
+ $output .= '<dl>';
+ $output .= '<dt>' . t('Viewing feeds') . '</dt>';
+ $output .= '<dd>' . t('Feeds contain published content, and may be grouped in categories, generally by topic. Users view feed content in the <a href="@aggregator">main aggregator display</a>, or by <a href="@aggregator-sources">their source</a> (usually via an RSS feed reader). The most recent content in a feed or category can be displayed as a block through the <a href="@admin-block">Blocks administration page</a>.', array('@aggregator' => url('aggregator'), '@aggregator-sources' => url('aggregator/sources'), '@admin-block' => url('admin/structure/block'))) . '</a></dd>';
+ $output .= '<dt>' . t('Adding, editing, and deleting feeds') . '</dt>';
+ $output .= '<dd>' . t('Administrators can add, edit, and delete feeds, and choose how often to check each feed for newly updated items on the <a href="@feededit">Feed aggregator administration page</a>.', array('@feededit' => url('admin/config/services/aggregator'))) . '</dd>';
+ $output .= '<dt>' . t('OPML integration') . '</dt>';
+ $output .= '<dd>' . t('A <a href="@aggregator-opml">machine-readable OPML file</a> of all feeds is available. OPML is an XML-based file format used to share outline-structured information such as a list of RSS feeds. Feeds can also be <a href="@import-opml">imported via an OPML file</a>.', array('@aggregator-opml' => url('aggregator/opml'), '@import-opml' => url('admin/config/services/aggregator'))) . '</dd>';
+ $output .= '<dt>' . t('Configuring cron') . '</dt>';
+ $output .= '<dd>' . t('A correctly configured <a href="@cron">cron maintenance task</a> is required to update feeds automatically.', array('@cron' => 'http://drupal.org/cron')) . '</dd>';
+ $output .= '</dl>';
+ return $output;
+ case 'admin/config/services/aggregator':
+ $output = '<p>' . t('Thousands of sites (particularly news sites and blogs) publish their latest headlines and posts in feeds, using a number of standardized XML-based formats. Formats supported by the aggregator include <a href="@rss">RSS</a>, <a href="@rdf">RDF</a>, and <a href="@atom">Atom</a>.', array('@rss' => 'http://cyber.law.harvard.edu/rss/', '@rdf' => 'http://www.w3.org/RDF/', '@atom' => 'http://www.atomenabled.org')) . '</p>';
+ $output .= '<p>' . t('Current feeds are listed below, and <a href="@addfeed">new feeds may be added</a>. For each feed or feed category, the <em>latest items</em> block may be enabled at the <a href="@block">blocks administration page</a>.', array('@addfeed' => url('admin/config/services/aggregator/add/feed'), '@block' => url('admin/structure/block'))) . '</p>';
+ return $output;
+ case 'admin/config/services/aggregator/add/feed':
+ return '<p>' . t('Add a feed in RSS, RDF or Atom format. A feed may only have one entry.') . '</p>';
+ case 'admin/config/services/aggregator/add/category':
+ return '<p>' . t('Categories allow feed items from different feeds to be grouped together. For example, several sport-related feeds may belong to a category named <em>Sports</em>. Feed items may be grouped automatically (by selecting a category when creating or editing a feed) or manually (via the <em>Categorize</em> page available from feed item listings). Each category provides its own feed page and block.') . '</p>';
+ case 'admin/config/services/aggregator/add/opml':
+ return '<p>' . t('<acronym title="Outline Processor Markup Language">OPML</acronym> is an XML format used to exchange multiple feeds between aggregators. A single OPML document may contain a collection of many feeds. Drupal can parse such a file and import all feeds at once, saving you the effort of adding them manually. You may either upload a local file from your computer or enter a URL where Drupal can download it.') . '</p>';
+ }
+}
+
+/**
+ * Implements hook_theme().
+ */
+function aggregator_theme() {
+ return array(
+ 'aggregator_wrapper' => array(
+ 'variables' => array('content' => NULL),
+ 'file' => 'aggregator.pages.inc',
+ 'template' => 'aggregator-wrapper',
+ ),
+ 'aggregator_categorize_items' => array(
+ 'render element' => 'form',
+ 'file' => 'aggregator.pages.inc',
+ ),
+ 'aggregator_feed_source' => array(
+ 'variables' => array('feed' => NULL),
+ 'file' => 'aggregator.pages.inc',
+ 'template' => 'aggregator-feed-source',
+ ),
+ 'aggregator_block_item' => array(
+ 'variables' => array('item' => NULL, 'feed' => 0),
+ ),
+ 'aggregator_summary_items' => array(
+ 'variables' => array('summary_items' => NULL, 'source' => NULL),
+ 'file' => 'aggregator.pages.inc',
+ 'template' => 'aggregator-summary-items',
+ ),
+ 'aggregator_summary_item' => array(
+ 'variables' => array('item' => NULL),
+ 'file' => 'aggregator.pages.inc',
+ 'template' => 'aggregator-summary-item',
+ ),
+ 'aggregator_item' => array(
+ 'variables' => array('item' => NULL),
+ 'file' => 'aggregator.pages.inc',
+ 'template' => 'aggregator-item',
+ ),
+ 'aggregator_page_opml' => array(
+ 'variables' => array('feeds' => NULL),
+ 'file' => 'aggregator.pages.inc',
+ ),
+ 'aggregator_page_rss' => array(
+ 'variables' => array('feeds' => NULL, 'category' => NULL),
+ 'file' => 'aggregator.pages.inc',
+ ),
+ );
+}
+
+/**
+ * Implements hook_menu().
+ */
+function aggregator_menu() {
+ $items['admin/config/services/aggregator'] = array(
+ 'title' => 'Feed aggregator',
+ 'description' => "Configure which content your site aggregates from other sites, how often it polls them, and how they're categorized.",
+ 'page callback' => 'aggregator_admin_overview',
+ 'access arguments' => array('administer news feeds'),
+ 'weight' => 10,
+ 'file' => 'aggregator.admin.inc',
+ );
+ $items['admin/config/services/aggregator/add/feed'] = array(
+ 'title' => 'Add feed',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_form_feed'),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_LOCAL_ACTION,
+ 'file' => 'aggregator.admin.inc',
+ );
+ $items['admin/config/services/aggregator/add/category'] = array(
+ 'title' => 'Add category',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_form_category'),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_LOCAL_ACTION,
+ 'file' => 'aggregator.admin.inc',
+ );
+ $items['admin/config/services/aggregator/add/opml'] = array(
+ 'title' => 'Import OPML',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_form_opml'),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_LOCAL_ACTION,
+ 'file' => 'aggregator.admin.inc',
+ );
+ $items['admin/config/services/aggregator/remove/%aggregator_feed'] = array(
+ 'title' => 'Remove items',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_admin_remove_feed', 5),
+ 'access arguments' => array('administer news feeds'),
+ 'file' => 'aggregator.admin.inc',
+ );
+ $items['admin/config/services/aggregator/update/%aggregator_feed'] = array(
+ 'title' => 'Update items',
+ 'page callback' => 'aggregator_admin_refresh_feed',
+ 'page arguments' => array(5),
+ 'access arguments' => array('administer news feeds'),
+ 'file' => 'aggregator.admin.inc',
+ );
+ $items['admin/config/services/aggregator/list'] = array(
+ 'title' => 'List',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+ $items['admin/config/services/aggregator/settings'] = array(
+ 'title' => 'Settings',
+ 'description' => 'Configure the behavior of the feed aggregator, including when to discard feed items and how to present feed items and categories.',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_admin_form'),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_LOCAL_TASK,
+ 'file' => 'aggregator.admin.inc',
+ );
+ $items['aggregator'] = array(
+ 'title' => 'Feed aggregator',
+ 'page callback' => 'aggregator_page_last',
+ 'access arguments' => array('access news feeds'),
+ 'weight' => 5,
+ 'file' => 'aggregator.pages.inc',
+ );
+ $items['aggregator/sources'] = array(
+ 'title' => 'Sources',
+ 'page callback' => 'aggregator_page_sources',
+ 'access arguments' => array('access news feeds'),
+ 'file' => 'aggregator.pages.inc',
+ );
+ $items['aggregator/categories'] = array(
+ 'title' => 'Categories',
+ 'page callback' => 'aggregator_page_categories',
+ 'access callback' => '_aggregator_has_categories',
+ 'file' => 'aggregator.pages.inc',
+ );
+ $items['aggregator/rss'] = array(
+ 'title' => 'RSS feed',
+ 'page callback' => 'aggregator_page_rss',
+ 'access arguments' => array('access news feeds'),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'aggregator.pages.inc',
+ );
+ $items['aggregator/opml'] = array(
+ 'title' => 'OPML feed',
+ 'page callback' => 'aggregator_page_opml',
+ 'access arguments' => array('access news feeds'),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'aggregator.pages.inc',
+ );
+ $items['aggregator/categories/%aggregator_category'] = array(
+ 'title callback' => '_aggregator_category_title',
+ 'title arguments' => array(2),
+ 'page callback' => 'aggregator_page_category',
+ 'page arguments' => array(2),
+ 'access arguments' => array('access news feeds'),
+ 'file' => 'aggregator.pages.inc',
+ );
+ $items['aggregator/categories/%aggregator_category/view'] = array(
+ 'title' => 'View',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+ $items['aggregator/categories/%aggregator_category/categorize'] = array(
+ 'title' => 'Categorize',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_page_category_form', 2),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_LOCAL_TASK,
+ 'file' => 'aggregator.pages.inc',
+ );
+ $items['aggregator/categories/%aggregator_category/configure'] = array(
+ 'title' => 'Configure',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_form_category', 2),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 1,
+ 'file' => 'aggregator.admin.inc',
+ );
+ $items['aggregator/sources/%aggregator_feed'] = array(
+ 'page callback' => 'aggregator_page_source',
+ 'page arguments' => array(2),
+ 'access arguments' => array('access news feeds'),
+ 'file' => 'aggregator.pages.inc',
+ );
+ $items['aggregator/sources/%aggregator_feed/view'] = array(
+ 'title' => 'View',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+ $items['aggregator/sources/%aggregator_feed/categorize'] = array(
+ 'title' => 'Categorize',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_page_source_form', 2),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_LOCAL_TASK,
+ 'file' => 'aggregator.pages.inc',
+ );
+ $items['aggregator/sources/%aggregator_feed/configure'] = array(
+ 'title' => 'Configure',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_form_feed', 2),
+ 'access arguments' => array('administer news feeds'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 1,
+ 'file' => 'aggregator.admin.inc',
+ );
+ $items['admin/config/services/aggregator/edit/feed/%aggregator_feed'] = array(
+ 'title' => 'Edit feed',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_form_feed', 6),
+ 'access arguments' => array('administer news feeds'),
+ 'file' => 'aggregator.admin.inc',
+ );
+ $items['admin/config/services/aggregator/edit/category/%aggregator_category'] = array(
+ 'title' => 'Edit category',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('aggregator_form_category', 6),
+ 'access arguments' => array('administer news feeds'),
+ 'file' => 'aggregator.admin.inc',
+ );
+
+ return $items;
+}
+
+/**
+ * Title callback: Returns a title for aggregator category pages.
+ *
+ * @param $category
+ * An aggregator category.
+ *
+ * @return
+ * A string with the aggregator category title.
+ */
+function _aggregator_category_title($category) {
+ return $category['title'];
+}
+
+/**
+ * Determines whether there are any aggregator categories.
+ *
+ * @return
+ * TRUE if there is at least one category and the user has access to them;
+ * FALSE otherwise.
+ */
+function _aggregator_has_categories() {
+ return user_access('access news feeds') && (bool) db_query_range('SELECT 1 FROM {aggregator_category}', 0, 1)->fetchField();
+}
+
+/**
+ * Implements hook_permission().
+ */
+function aggregator_permission() {
+ return array(
+ 'administer news feeds' => array(
+ 'title' => t('Administer news feeds'),
+ ),
+ 'access news feeds' => array(
+ 'title' => t('View news feeds'),
+ ),
+ );
+}
+
+/**
+ * Implements hook_cron().
+ *
+ * Queues news feeds for updates once their refresh interval has elapsed.
+ */
+function aggregator_cron() {
+ $result = db_query('SELECT * FROM {aggregator_feed} WHERE queued = 0 AND checked + refresh < :time AND refresh <> :never', array(
+ ':time' => REQUEST_TIME,
+ ':never' => AGGREGATOR_CLEAR_NEVER
+ ));
+ $queue = DrupalQueue::get('aggregator_feeds');
+ foreach ($result as $feed) {
+ if ($queue->createItem($feed)) {
+ // Add timestamp to avoid queueing item more than once.
+ db_update('aggregator_feed')
+ ->fields(array('queued' => REQUEST_TIME))
+ ->condition('fid', $feed->fid)
+ ->execute();
+ }
+ }
+
+ // Remove queued timestamp after 6 hours assuming the update has failed.
+ db_update('aggregator_feed')
+ ->fields(array('queued' => 0))
+ ->condition('queued', REQUEST_TIME - (3600 * 6), '<')
+ ->execute();
+}
+
+/**
+ * Implements hook_cron_queue_info().
+ */
+function aggregator_cron_queue_info() {
+ $queues['aggregator_feeds'] = array(
+ 'worker callback' => 'aggregator_refresh',
+ 'time' => 60,
+ );
+ return $queues;
+}
+
+/**
+ * Implements hook_block_info().
+ */
+function aggregator_block_info() {
+ $blocks = array();
+ $result = db_query('SELECT cid, title FROM {aggregator_category} ORDER BY title');
+ foreach ($result as $category) {
+ $blocks['category-' . $category->cid]['info'] = t('!title category latest items', array('!title' => $category->title));
+ }
+ $result = db_query('SELECT fid, title FROM {aggregator_feed} WHERE block <> 0 ORDER BY fid');
+ foreach ($result as $feed) {
+ $blocks['feed-' . $feed->fid]['info'] = t('!title feed latest items', array('!title' => $feed->title));
+ }
+ return $blocks;
+}
+
+/**
+ * Implements hook_block_configure().
+ */
+function aggregator_block_configure($delta = '') {
+ list($type, $id) = explode('-', $delta);
+ if ($type == 'category') {
+ $value = db_query('SELECT block FROM {aggregator_category} WHERE cid = :cid', array(':cid' => $id))->fetchField();
+ $form['block'] = array(
+ '#type' => 'select',
+ '#title' => t('Number of news items in block'),
+ '#default_value' => $value,
+ '#options' => drupal_map_assoc(range(2, 20)),
+ );
+ return $form;
+ }
+}
+
+/**
+ * Implements hook_block_save().
+ */
+function aggregator_block_save($delta = '', $edit = array()) {
+ list($type, $id) = explode('-', $delta);
+ if ($type == 'category') {
+ db_update('aggregator_category')
+ ->fields(array('block' => $edit['block']))
+ ->condition('cid', $id)
+ ->execute();
+ }
+}
+
+/**
+ * Implements hook_block_view().
+ *
+ * Generates blocks for the latest news items in each category and feed.
+ */
+function aggregator_block_view($delta = '') {
+ if (user_access('access news feeds')) {
+ $block = array();
+ list($type, $id) = explode('-', $delta);
+ $result = FALSE;
+ switch ($type) {
+ case 'feed':
+ if ($feed = db_query('SELECT fid, title, block FROM {aggregator_feed} WHERE block <> 0 AND fid = :fid', array(':fid' => $id))->fetchObject()) {
+ $block['subject'] = check_plain($feed->title);
+ $result = db_query_range("SELECT * FROM {aggregator_item} WHERE fid = :fid ORDER BY timestamp DESC, iid DESC", 0, $feed->block, array(':fid' => $id));
+ $read_more = theme('more_link', array('url' => 'aggregator/sources/' . $feed->fid, 'title' => t("View this feed's recent news.")));
+ }
+ break;
+
+ case 'category':
+ if ($category = db_query('SELECT cid, title, block FROM {aggregator_category} WHERE cid = :cid', array(':cid' => $id))->fetchObject()) {
+ $block['subject'] = check_plain($category->title);
+ $result = db_query_range('SELECT i.* FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON ci.iid = i.iid WHERE ci.cid = :cid ORDER BY i.timestamp DESC, i.iid DESC', 0, $category->block, array(':cid' => $category->cid));
+ $read_more = theme('more_link', array('url' => 'aggregator/categories/' . $category->cid, 'title' => t("View this category's recent news.")));
+ }
+ break;
+ }
+
+ $items = array();
+ if (!empty($result)) {
+ foreach ($result as $item) {
+ $items[] = theme('aggregator_block_item', array('item' => $item));
+ }
+ }
+
+ // Only display the block if there are items to show.
+ if (count($items) > 0) {
+ $block['content'] = theme('item_list', array('items' => $items)) . $read_more;
+ }
+ return $block;
+ }
+}
+
+/**
+ * Adds/edits/deletes aggregator categories.
+ *
+ * @param $edit
+ * An associative array describing the category to be added/edited/deleted.
+ */
+function aggregator_save_category($edit) {
+ $link_path = 'aggregator/categories/';
+ if (!empty($edit['cid'])) {
+ $link_path .= $edit['cid'];
+ if (!empty($edit['title'])) {
+ db_merge('aggregator_category')
+ ->key(array('cid' => $edit['cid']))
+ ->fields(array(
+ 'title' => $edit['title'],
+ 'description' => $edit['description'],
+ ))
+ ->execute();
+ $op = 'update';
+ }
+ else {
+ db_delete('aggregator_category')
+ ->condition('cid', $edit['cid'])
+ ->execute();
+ // Make sure there is no active block for this category.
+ if (module_exists('block')) {
+ db_delete('block')
+ ->condition('module', 'aggregator')
+ ->condition('delta', 'category-' . $edit['cid'])
+ ->execute();
+ }
+ $edit['title'] = '';
+ $op = 'delete';
+ }
+ }
+ elseif (!empty($edit['title'])) {
+ // A single unique id for bundles and feeds, to use in blocks.
+ $link_path .= db_insert('aggregator_category')
+ ->fields(array(
+ 'title' => $edit['title'],
+ 'description' => $edit['description'],
+ 'block' => 5,
+ ))
+ ->execute();
+ $op = 'insert';
+ }
+ if (isset($op)) {
+ menu_link_maintain('aggregator', $op, $link_path, $edit['title']);
+ }
+}
+
+/**
+ * Add/edit/delete an aggregator feed.
+ *
+ * @param $edit
+ * An associative array describing the feed to be added/edited/deleted.
+ */
+function aggregator_save_feed($edit) {
+ if (!empty($edit['fid'])) {
+ // An existing feed is being modified, delete the category listings.
+ db_delete('aggregator_category_feed')
+ ->condition('fid', $edit['fid'])
+ ->execute();
+ }
+ if (!empty($edit['fid']) && !empty($edit['title'])) {
+ db_update('aggregator_feed')
+ ->condition('fid', $edit['fid'])
+ ->fields(array(
+ 'title' => $edit['title'],
+ 'url' => $edit['url'],
+ 'refresh' => $edit['refresh'],
+ 'block' => $edit['block'],
+ ))
+ ->execute();
+ }
+ elseif (!empty($edit['fid'])) {
+ $iids = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $edit['fid']))->fetchCol();
+ if ($iids) {
+ db_delete('aggregator_category_item')
+ ->condition('iid', $iids, 'IN')
+ ->execute();
+ }
+ db_delete('aggregator_feed')->
+ condition('fid', $edit['fid'])
+ ->execute();
+ db_delete('aggregator_item')
+ ->condition('fid', $edit['fid'])
+ ->execute();
+ // Make sure there is no active block for this feed.
+ if (module_exists('block')) {
+ db_delete('block')
+ ->condition('module', 'aggregator')
+ ->condition('delta', 'feed-' . $edit['fid'])
+ ->execute();
+ }
+ }
+ elseif (!empty($edit['title'])) {
+ $edit['fid'] = db_insert('aggregator_feed')
+ ->fields(array(
+ 'title' => $edit['title'],
+ 'url' => $edit['url'],
+ 'refresh' => $edit['refresh'],
+ 'block' => $edit['block'],
+ 'link' => '',
+ 'description' => '',
+ 'image' => '',
+ ))
+ ->execute();
+
+ }
+ if (!empty($edit['title'])) {
+ // The feed is being saved, save the categories as well.
+ if (!empty($edit['category'])) {
+ foreach ($edit['category'] as $cid => $value) {
+ if ($value) {
+ db_insert('aggregator_category_feed')
+ ->fields(array(
+ 'fid' => $edit['fid'],
+ 'cid' => $cid,
+ ))
+ ->execute();
+ }
+ }
+ }
+ }
+}
+
+/**
+ * Removes all items from a feed.
+ *
+ * @param $feed
+ * An object describing the feed to be cleared.
+ */
+function aggregator_remove($feed) {
+ _aggregator_get_variables();
+ // Call hook_aggregator_remove() on all modules.
+ module_invoke_all('aggregator_remove', $feed);
+ // Reset feed.
+ db_update('aggregator_feed')
+ ->condition('fid', $feed->fid)
+ ->fields(array(
+ 'checked' => 0,
+ 'hash' => '',
+ 'etag' => '',
+ 'modified' => 0,
+ ))
+ ->execute();
+}
+
+/**
+ * Gets the fetcher, parser, and processors.
+ *
+ * @return
+ * An array containing the fetcher, parser, and processors.
+ */
+function _aggregator_get_variables() {
+ // Fetch the feed.
+ $fetcher = variable_get('aggregator_fetcher', 'aggregator');
+ if ($fetcher == 'aggregator') {
+ include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'aggregator') . '/aggregator.fetcher.inc';
+ }
+ $parser = variable_get('aggregator_parser', 'aggregator');
+ if ($parser == 'aggregator') {
+ include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'aggregator') . '/aggregator.parser.inc';
+ }
+ $processors = variable_get('aggregator_processors', array('aggregator'));
+ if (in_array('aggregator', $processors)) {
+ include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'aggregator') . '/aggregator.processor.inc';
+ }
+ return array($fetcher, $parser, $processors);
+}
+
+/**
+ * Checks a news feed for new items.
+ *
+ * @param $feed
+ * An object describing the feed to be refreshed.
+ */
+function aggregator_refresh($feed) {
+ // Store feed URL to track changes.
+ $feed_url = $feed->url;
+
+ // Fetch the feed.
+ list($fetcher, $parser, $processors) = _aggregator_get_variables();
+ $success = module_invoke($fetcher, 'aggregator_fetch', $feed);
+
+ // We store the hash of feed data in the database. When refreshing a
+ // feed we compare stored hash and new hash calculated from downloaded
+ // data. If both are equal we say that feed is not updated.
+ $hash = hash('sha256', $feed->source_string);
+
+ if ($success && ($feed->hash != $hash)) {
+ // Parse the feed.
+ if (module_invoke($parser, 'aggregator_parse', $feed)) {
+ // Update feed with parsed data.
+ db_merge('aggregator_feed')
+ ->key(array('fid' => $feed->fid))
+ ->fields(array(
+ 'url' => $feed->url,
+ 'link' => empty($feed->link) ? $feed->url : $feed->link,
+ 'description' => empty($feed->description) ? '' : $feed->description,
+ 'image' => empty($feed->image) ? '' : $feed->image,
+ 'hash' => $hash,
+ 'etag' => empty($feed->etag) ? '' : $feed->etag,
+ 'modified' => empty($feed->modified) ? 0 : $feed->modified,
+ ))
+ ->execute();
+
+ // Log if feed URL has changed.
+ if ($feed->url != $feed_url) {
+ watchdog('aggregator', 'Updated URL for feed %title to %url.', array('%title' => $feed->title, '%url' => $feed->url));
+ }
+
+ watchdog('aggregator', 'There is new syndicated content from %site.', array('%site' => $feed->title));
+ drupal_set_message(t('There is new syndicated content from %site.', array('%site' => $feed->title)));
+
+ // If there are items on the feed, let all enabled processors do their work on it.
+ if (@count($feed->items)) {
+ foreach ($processors as $processor) {
+ module_invoke($processor, 'aggregator_process', $feed);
+ }
+ }
+ }
+ }
+ else {
+ drupal_set_message(t('There is no new syndicated content from %site.', array('%site' => $feed->title)));
+ }
+
+ // Regardless of successful or not, indicate that this feed has been checked.
+ db_update('aggregator_feed')
+ ->fields(array('checked' => REQUEST_TIME, 'queued' => 0))
+ ->condition('fid', $feed->fid)
+ ->execute();
+
+ // Expire old feed items.
+ if (function_exists('aggregator_expire')) {
+ aggregator_expire($feed);
+ }
+}
+
+/**
+ * Loads an aggregator feed.
+ *
+ * @param $fid
+ * The feed id.
+ *
+ * @return
+ * An object describing the feed.
+ */
+function aggregator_feed_load($fid) {
+ $feeds = &drupal_static(__FUNCTION__);
+ if (!isset($feeds[$fid])) {
+ $feeds[$fid] = db_query('SELECT * FROM {aggregator_feed} WHERE fid = :fid', array(':fid' => $fid))->fetchObject();
+ }
+
+ return $feeds[$fid];
+}
+
+/**
+ * Loads an aggregator category.
+ *
+ * @param $cid
+ * The category id.
+ *
+ * @return
+ * An associative array describing the category.
+ */
+function aggregator_category_load($cid) {
+ $categories = &drupal_static(__FUNCTION__);
+ if (!isset($categories[$cid])) {
+ $categories[$cid] = db_query('SELECT * FROM {aggregator_category} WHERE cid = :cid', array(':cid' => $cid))->fetchAssoc();
+ }
+
+ return $categories[$cid];
+}
+
+/**
+ * Returns HTML for an individual feed item for display in the block.
+ *
+ * @param $variables
+ * An associative array containing:
+ * - item: The item to be displayed.
+ * - feed: Not used.
+ *
+ * @ingroup themeable
+ */
+function theme_aggregator_block_item($variables) {
+ // Display the external link to the item.
+ return '<a href="' . check_url($variables['item']->link) . '">' . check_plain($variables['item']->title) . "</a>\n";
+}
+
+/**
+ * Renders the HTML content safely, as allowed.
+ *
+ * @param $value
+ * The content to be filtered.
+ *
+ * @return
+ * The filtered content.
+ */
+function aggregator_filter_xss($value) {
+ return filter_xss($value, preg_split('/\s+|<|>/', variable_get('aggregator_allowed_html_tags', '<a> <b> <br> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>'), -1, PREG_SPLIT_NO_EMPTY));
+}
+
+/**
+ * Checks and sanitizes the aggregator configuration.
+ *
+ * Goes through all fetchers, parsers and processors and checks whether they
+ * are available. If one is missing, resets to standard configuration.
+ *
+ * @return
+ * TRUE if this function resets the configuration; FALSE if not.
+ */
+function aggregator_sanitize_configuration() {
+ $reset = FALSE;
+ list($fetcher, $parser, $processors) = _aggregator_get_variables();
+ if (!module_exists($fetcher)) {
+ $reset = TRUE;
+ }
+ if (!module_exists($parser)) {
+ $reset = TRUE;
+ }
+ foreach ($processors as $processor) {
+ if (!module_exists($processor)) {
+ $reset = TRUE;
+ break;
+ }
+ }
+ if ($reset) {
+ variable_del('aggregator_fetcher');
+ variable_del('aggregator_parser');
+ variable_del('aggregator_processors');
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/**
+ * Helper function for drupal_map_assoc.
+ *
+ * @param $count
+ * Items count.
+ *
+ * @return
+ * A string that is plural-formatted as "@count items".
+ */
+function _aggregator_items($count) {
+ return format_plural($count, '1 item', '@count items');
+}
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.pages.inc b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.pages.inc
new file mode 100644
index 0000000..bfba3ff
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.pages.inc
@@ -0,0 +1,582 @@
+<?php
+
+/**
+ * @file
+ * User page callbacks for the Aggregator module.
+ */
+
+/**
+ * Page callback: Displays the most recent items gathered from any feed.
+ *
+ * @return
+ * The rendered list of items for the feed.
+ */
+function aggregator_page_last() {
+ drupal_add_feed('aggregator/rss', variable_get('site_name', 'Drupal') . ' ' . t('aggregator'));
+
+ $items = aggregator_feed_items_load('sum');
+
+ return _aggregator_page_list($items, arg(1));
+}
+
+/**
+ * Page callback: Displays all the items captured from the particular feed.
+ *
+ * @param $feed
+ * The feed for which to display all items.
+ *
+ * @return
+ * The rendered list of items for a feed.
+ *
+ * @see aggregator_menu()
+ */
+function aggregator_page_source($feed) {
+ drupal_set_title($feed->title);
+ $feed_source = theme('aggregator_feed_source', array('feed' => $feed));
+
+ // It is safe to include the fid in the query because it's loaded from the
+ // database by aggregator_feed_load.
+ $items = aggregator_feed_items_load('source', $feed);
+
+ return _aggregator_page_list($items, arg(3), $feed_source);
+}
+
+/**
+ * Page callback: Displays a form with all items captured from a feed.
+ *
+ * @param $feed
+ * The feed for which to list all of the aggregated items.
+ *
+ * @return
+ * The rendered list of items for the feed.
+ *
+ * @see aggregator_page_source()
+ */
+function aggregator_page_source_form($form, $form_state, $feed) {
+ return aggregator_page_source($feed);
+}
+
+/**
+ * Page callback: Displays all the items aggregated in a particular category.
+ *
+ * @param $category
+ * The category for which to list all of the aggregated items.
+ *
+ * @return
+ * The rendered list of items for the feed.
+ */
+function aggregator_page_category($category) {
+ drupal_add_feed('aggregator/rss/' . $category['cid'], variable_get('site_name', 'Drupal') . ' ' . t('aggregator - @title', array('@title' => $category['title'])));
+
+ // It is safe to include the cid in the query because it's loaded from the
+ // database by aggregator_category_load.
+ $items = aggregator_feed_items_load('category', $category);
+
+ return _aggregator_page_list($items, arg(3));
+}
+
+/**
+ * Page callback: Displays a form containing items aggregated in a category.
+ *
+ * @param $category
+ * The category for which to list all of the aggregated items.
+ *
+ * @return
+ * The rendered list of items for the feed.
+ *
+ * @see aggregator_page_category()
+ */
+function aggregator_page_category_form($form, $form_state, $category) {
+ return aggregator_page_category($category);
+}
+
+/**
+ * Loads and optionally filters feed items.
+ *
+ * @param $type
+ * The type of filter for the items. Possible values are:
+ * - sum: No filtering.
+ * - source: Filter the feed items, limiting the result to items from a
+ * single source.
+ * - category: Filter the feed items by category.
+ * @param $data
+ * Feed or category data used for filtering. The type and value of $data
+ * depends on $type:
+ * - source: $data is an object with $data->fid identifying the feed used to
+ * as filter.
+ * - category: $data is an array with $data['cid'] being the category id to
+ * filter on.
+ * The $data parameter is not used when $type is 'sum'.
+ *
+ * @return
+ * An array of the feed items.
+ */
+function aggregator_feed_items_load($type, $data = NULL) {
+ $items = array();
+ switch ($type) {
+ case 'sum':
+ $query = db_select('aggregator_item', 'i');
+ $query->join('aggregator_feed', 'f', 'i.fid = f.fid');
+ $query->fields('i');
+ $query->addField('f', 'title', 'ftitle');
+ $query->addField('f', 'link', 'flink');
+ break;
+ case 'source':
+ $query = db_select('aggregator_item', 'i');
+ $query
+ ->fields('i')
+ ->condition('i.fid', $data->fid);
+ break;
+ case 'category':
+ $query = db_select('aggregator_category_item', 'c');
+ $query->leftJoin('aggregator_item', 'i', 'c.iid = i.iid');
+ $query->leftJoin('aggregator_feed', 'f', 'i.fid = f.fid');
+ $query
+ ->fields('i')
+ ->condition('cid', $data['cid']);
+ $query->addField('f', 'title', 'ftitle');
+ $query->addField('f', 'link', 'flink');
+ break;
+ }
+
+ $result = $query
+ ->extend('PagerDefault')
+ ->limit(20)
+ ->orderBy('i.timestamp', 'DESC')
+ ->orderBy('i.iid', 'DESC')
+ ->execute();
+
+ foreach ($result as $item) {
+ $item->categories = db_query('SELECT c.title, c.cid FROM {aggregator_category_item} ci LEFT JOIN {aggregator_category} c ON ci.cid = c.cid WHERE ci.iid = :iid ORDER BY c.title', array(':iid' => $item->iid))->fetchAll();
+ $items[] = $item;
+ }
+
+ return $items;
+}
+
+/**
+ * Prints an aggregator page listing a number of feed items.
+ *
+ * Various menu callbacks use this function to print their feeds.
+ *
+ * @param $items
+ * The items to be listed.
+ * @param $op
+ * Which form should be added to the items. Only 'categorize' is now
+ * recognized.
+ * @param $feed_source
+ * The feed source URL.
+ *
+ * @return
+ * The rendered list of items for the feed.
+ */
+function _aggregator_page_list($items, $op, $feed_source = '') {
+ if (user_access('administer news feeds') && ($op == 'categorize')) {
+ // Get form data.
+ $output = aggregator_categorize_items($items, $feed_source);
+ }
+ else {
+ // Assemble themed output.
+ $output = $feed_source;
+ foreach ($items as $item) {
+ $output .= theme('aggregator_item', array('item' => $item));
+ }
+ $output = theme('aggregator_wrapper', array('content' => $output));
+ }
+
+ return $output;
+}
+
+/**
+ * Form constructor to build the page list form.
+ *
+ * @param $items
+ * An array of the feed items.
+ * @param $feed_source
+ * (optional) The feed source URL. Defaults to an empty string.
+ *
+ * @return array
+ * An array of FAPI elements.
+ *
+ * @see aggregator_categorize_items_submit()
+ * @see theme_aggregator_categorize_items()
+ * @ingroup forms
+ */
+function aggregator_categorize_items($items, $feed_source = '') {
+ $form['#submit'][] = 'aggregator_categorize_items_submit';
+ $form['#theme'] = 'aggregator_categorize_items';
+ $form['feed_source'] = array(
+ '#value' => $feed_source,
+ );
+ $categories = array();
+ $done = FALSE;
+ $form['items'] = array();
+ $form['categories'] = array(
+ '#tree' => TRUE,
+ );
+ foreach ($items as $item) {
+ $form['items'][$item->iid] = array('#markup' => theme('aggregator_item', array('item' => $item)));
+ $form['categories'][$item->iid] = array();
+ $categories_result = db_query('SELECT c.cid, c.title, ci.iid FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid AND ci.iid = :iid', array(':iid' => $item->iid));
+ $selected = array();
+ foreach ($categories_result as $category) {
+ if (!$done) {
+ $categories[$category->cid] = check_plain($category->title);
+ }
+ if ($category->iid) {
+ $selected[] = $category->cid;
+ }
+ }
+ $done = TRUE;
+ $form['categories'][$item->iid] = array(
+ '#type' => variable_get('aggregator_category_selector', 'checkboxes'),
+ '#default_value' => $selected,
+ '#options' => $categories,
+ '#size' => 10,
+ '#multiple' => TRUE
+ );
+ }
+ $form['actions'] = array('#type' => 'actions');
+ $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save categories'));
+
+ return $form;
+}
+
+/**
+ * Form submission handler for aggregator_categorize_items().
+ */
+function aggregator_categorize_items_submit($form, &$form_state) {
+ if (!empty($form_state['values']['categories'])) {
+ foreach ($form_state['values']['categories'] as $iid => $selection) {
+ db_delete('aggregator_category_item')
+ ->condition('iid', $iid)
+ ->execute();
+ $insert = db_insert('aggregator_category_item')->fields(array('iid', 'cid'));
+ $has_values = FALSE;
+ foreach ($selection as $cid) {
+ if ($cid && $iid) {
+ $has_values = TRUE;
+ $insert->values(array(
+ 'iid' => $iid,
+ 'cid' => $cid,
+ ));
+ }
+ }
+ if ($has_values) {
+ $insert->execute();
+ }
+ }
+ }
+ drupal_set_message(t('The categories have been saved.'));
+}
+
+/**
+ * Returns HTML for the aggregator page list form for assigning categories.
+ *
+ * @param $variables
+ * An associative array containing:
+ * - form: A render element representing the form.
+ *
+ * @ingroup themeable
+ */
+function theme_aggregator_categorize_items($variables) {
+ $form = $variables['form'];
+
+ $output = drupal_render($form['feed_source']);
+ $rows = array();
+ if (!empty($form['items'])) {
+ foreach (element_children($form['items']) as $key) {
+ $rows[] = array(
+ drupal_render($form['items'][$key]),
+ array('data' => drupal_render($form['categories'][$key]), 'class' => array('categorize-item')),
+ );
+ }
+ }
+ $output .= theme('table', array('header' => array('', t('Categorize')), 'rows' => $rows));
+ $output .= drupal_render($form['submit']);
+ $output .= drupal_render_children($form);
+
+ return theme('aggregator_wrapper', array('content' => $output));
+}
+
+/**
+ * Processes variables for aggregator-wrapper.tpl.php.
+ *
+ * @see aggregator-wrapper.tpl.php
+ */
+function template_preprocess_aggregator_wrapper(&$variables) {
+ $variables['pager'] = theme('pager');
+}
+
+/**
+ * Processes variables for aggregator-item.tpl.php.
+ *
+ * @see aggregator-item.tpl.php
+ */
+function template_preprocess_aggregator_item(&$variables) {
+ $item = $variables['item'];
+
+ $variables['feed_url'] = check_url($item->link);
+ $variables['feed_title'] = check_plain($item->title);
+ $variables['content'] = aggregator_filter_xss($item->description);
+
+ $variables['source_url'] = '';
+ $variables['source_title'] = '';
+ if (isset($item->ftitle) && isset($item->fid)) {
+ $variables['source_url'] = url("aggregator/sources/$item->fid");
+ $variables['source_title'] = check_plain($item->ftitle);
+ }
+ if (date('Ymd', $item->timestamp) == date('Ymd')) {
+ $variables['source_date'] = t('%ago ago', array('%ago' => format_interval(REQUEST_TIME - $item->timestamp)));
+ }
+ else {
+ $variables['source_date'] = format_date($item->timestamp, 'custom', variable_get('date_format_medium', 'D, m/d/Y - H:i'));
+ }
+
+ $variables['categories'] = array();
+ foreach ($item->categories as $category) {
+ $variables['categories'][$category->cid] = l($category->title, 'aggregator/categories/' . $category->cid);
+ }
+}
+
+/**
+ * Page callback: Displays all the feeds used by the aggregator.
+ *
+ * @return
+ * An HTML-formatted string.
+ *
+ * @see aggregator_menu()
+ */
+function aggregator_page_sources() {
+ $result = db_query('SELECT f.fid, f.title, f.description, f.image, MAX(i.timestamp) AS last FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid GROUP BY f.fid, f.title, f.description, f.image ORDER BY last DESC, f.title');
+
+ $output = '';
+ foreach ($result as $feed) {
+ // Most recent items:
+ $summary_items = array();
+ if (variable_get('aggregator_summary_items', 3)) {
+ $items = db_query_range('SELECT i.title, i.timestamp, i.link FROM {aggregator_item} i WHERE i.fid = :fid ORDER BY i.timestamp DESC', 0, variable_get('aggregator_summary_items', 3), array(':fid' => $feed->fid));
+ foreach ($items as $item) {
+ $summary_items[] = theme('aggregator_summary_item', array('item' => $item));
+ }
+ }
+ $feed->url = url('aggregator/sources/' . $feed->fid);
+ $output .= theme('aggregator_summary_items', array('summary_items' => $summary_items, 'source' => $feed));
+ }
+ $output .= theme('feed_icon', array('url' => 'aggregator/opml', 'title' => t('OPML feed')));
+
+ return theme('aggregator_wrapper', array('content' => $output));
+}
+
+/**
+ * Page callback: Displays all the categories used by the Aggregator module.
+ *
+ * @return string
+ * An HTML formatted string.
+ *
+ * @see aggregator_menu()
+ */
+function aggregator_page_categories() {
+ $result = db_query('SELECT c.cid, c.title, c.description FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid LEFT JOIN {aggregator_item} i ON ci.iid = i.iid GROUP BY c.cid, c.title, c.description');
+
+ $output = '';
+ foreach ($result as $category) {
+ if (variable_get('aggregator_summary_items', 3)) {
+ $summary_items = array();
+ $items = db_query_range('SELECT i.title, i.timestamp, i.link, f.title as feed_title, f.link as feed_link FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON i.iid = ci.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE ci.cid = :cid ORDER BY i.timestamp DESC', 0, variable_get('aggregator_summary_items', 3), array(':cid' => $category->cid));
+ foreach ($items as $item) {
+ $summary_items[] = theme('aggregator_summary_item', array('item' => $item));
+ }
+ }
+ $category->url = url('aggregator/categories/' . $category->cid);
+ $output .= theme('aggregator_summary_items', array('summary_items' => $summary_items, 'source' => $category));
+ }
+
+ return theme('aggregator_wrapper', array('content' => $output));
+}
+
+/**
+ * Page callback: Generates an RSS 0.92 feed of aggregator items or categories.
+ *
+ * @return string
+ * An HTML formatted string.
+ */
+function aggregator_page_rss() {
+ $result = NULL;
+ // arg(2) is the passed cid, only select for that category.
+ if (arg(2)) {
+ $category = db_query('SELECT cid, title FROM {aggregator_category} WHERE cid = :cid', array(':cid' => arg(2)))->fetchObject();
+ $result = db_query_range('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_category_item} c LEFT JOIN {aggregator_item} i ON c.iid = i.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE cid = :cid ORDER BY timestamp DESC, i.iid DESC', 0, variable_get('feed_default_items', 10), array(':cid' => $category->cid));
+ }
+ // Or, get the default aggregator items.
+ else {
+ $category = NULL;
+ $result = db_query_range('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_item} i INNER JOIN {aggregator_feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC, i.iid DESC', 0, variable_get('feed_default_items', 10));
+ }
+
+ $feeds = $result->fetchAll();
+ return theme('aggregator_page_rss', array('feeds' => $feeds, 'category' => $category));
+}
+
+/**
+ * Prints the RSS page for a feed.
+ *
+ * @param $variables
+ * An associative array containing:
+ * - feeds: An array of the feeds to theme.
+ * - category: A common category, if any, for all the feeds.
+ *
+ * @return void
+ *
+ * @ingroup themeable
+ */
+function theme_aggregator_page_rss($variables) {
+ $feeds = $variables['feeds'];
+ $category = $variables['category'];
+
+ drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
+
+ $items = '';
+ $feed_length = variable_get('feed_item_length', 'fulltext');
+ foreach ($feeds as $feed) {
+ switch ($feed_length) {
+ case 'teaser':
+ $summary = text_summary($feed->description, NULL, variable_get('aggregator_teaser_length', 600));
+ if ($summary != $feed->description) {
+ $summary .= '<p><a href="' . check_url($feed->link) . '">' . t('read more') . "</a></p>\n";
+ }
+ $feed->description = $summary;
+ break;
+ case 'title':
+ $feed->description = '';
+ break;
+ }
+ $items .= format_rss_item($feed->ftitle . ': ' . $feed->title, $feed->link, $feed->description, array('pubDate' => date('r', $feed->timestamp)));
+ }
+
+ $site_name = variable_get('site_name', 'Drupal');
+ $url = url((isset($category) ? 'aggregator/categories/' . $category->cid : 'aggregator'), array('absolute' => TRUE));
+ $description = isset($category) ? t('@site_name - aggregated feeds in category @title', array('@site_name' => $site_name, '@title' => $category->title)) : t('@site_name - aggregated feeds', array('@site_name' => $site_name));
+
+ $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
+ $output .= "<rss version=\"2.0\">\n";
+ $output .= format_rss_channel(t('@site_name aggregator', array('@site_name' => $site_name)), $url, $description, $items);
+ $output .= "</rss>\n";
+
+ print $output;
+}
+
+/**
+ * Page callback: Generates an OPML representation of all feeds.
+ *
+ * @param $cid
+ * (optional) If set, feeds are exported only from a category with this ID.
+ * Otherwise, all feeds are exported. Defaults to NULL.
+ *
+ * @return
+ * An OPML formatted string.
+ */
+function aggregator_page_opml($cid = NULL) {
+ if ($cid) {
+ $result = db_query('SELECT f.title, f.url FROM {aggregator_feed} f LEFT JOIN {aggregator_category_feed} c on f.fid = c.fid WHERE c.cid = :cid ORDER BY title', array(':cid' => $cid));
+ }
+ else {
+ $result = db_query('SELECT * FROM {aggregator_feed} ORDER BY title');
+ }
+
+ $feeds = $result->fetchAll();
+ return theme('aggregator_page_opml', array('feeds' => $feeds));
+}
+
+/**
+ * Prints the OPML page for the feed.
+ *
+ * @param $variables
+ * An associative array containing:
+ * - feeds: An array of the feeds to theme.
+ *
+ * @ingroup themeable
+ */
+function theme_aggregator_page_opml($variables) {
+ $feeds = $variables['feeds'];
+
+ drupal_add_http_header('Content-Type', 'text/xml; charset=utf-8');
+
+ $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
+ $output .= "<opml version=\"1.1\">\n";
+ $output .= "<head>\n";
+ $output .= '<title>' . check_plain(variable_get('site_name', 'Drupal')) . "</title>\n";
+ $output .= '<dateModified>' . gmdate(DATE_RFC2822, REQUEST_TIME) . "</dateModified>\n";
+ $output .= "</head>\n";
+ $output .= "<body>\n";
+ foreach ($feeds as $feed) {
+ $output .= '<outline text="' . check_plain($feed->title) . '" xmlUrl="' . check_url($feed->url) . "\" />\n";
+ }
+ $output .= "</body>\n";
+ $output .= "</opml>\n";
+
+ print $output;
+}
+
+/**
+ * Processes variables for aggregator-summary-items.tpl.php.
+ *
+ * @see aggregator-summary-items.tpl.php
+ */
+function template_preprocess_aggregator_summary_items(&$variables) {
+ $variables['title'] = check_plain($variables['source']->title);
+ $variables['summary_list'] = theme('item_list', array('items' => $variables['summary_items']));
+ $variables['source_url'] = $variables['source']->url;
+}
+
+/**
+ * Processes variables for aggregator-summary-item.tpl.php.
+ *
+ * @see aggregator-summary-item.tpl.php
+ */
+function template_preprocess_aggregator_summary_item(&$variables) {
+ $item = $variables['item'];
+
+ $variables['feed_url'] = check_url($item->link);
+ $variables['feed_title'] = check_plain($item->title);
+ $variables['feed_age'] = t('%age old', array('%age' => format_interval(REQUEST_TIME - $item->timestamp)));
+
+ $variables['source_url'] = '';
+ $variables['source_title'] = '';
+ if (!empty($item->feed_link)) {
+ $variables['source_url'] = check_url($item->feed_link);
+ $variables['source_title'] = check_plain($item->feed_title);
+ }
+}
+
+/**
+ * Processes variables for aggregator-feed-source.tpl.php.
+ *
+ * @see aggregator-feed-source.tpl.php
+ */
+function template_preprocess_aggregator_feed_source(&$variables) {
+ $feed = $variables['feed'];
+
+ $variables['source_icon'] = theme('feed_icon', array('url' => $feed->url, 'title' => t('!title feed', array('!title' => $feed->title))));
+
+ if (!empty($feed->image) && !empty($feed->title) && !empty($feed->link)) {
+ $variables['source_image'] = l(theme('image', array('path' => $feed->image, 'alt' => $feed->title)), $feed->link, array('html' => TRUE, 'attributes' => array('class' => 'feed-image')));
+ }
+ else {
+ $variables['source_image'] = '';
+ }
+
+ $variables['source_description'] = aggregator_filter_xss($feed->description);
+ $variables['source_url'] = check_url(url($feed->link, array('absolute' => TRUE)));
+
+ if ($feed->checked) {
+ $variables['last_checked'] = t('@time ago', array('@time' => format_interval(REQUEST_TIME - $feed->checked)));
+ }
+ else {
+ $variables['last_checked'] = t('never');
+ }
+
+ if (user_access('administer news feeds')) {
+ $variables['last_checked'] = l($variables['last_checked'], 'admin/config/services/aggregator');
+ }
+}
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.parser.inc b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.parser.inc
new file mode 100644
index 0000000..91fbe3a
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.parser.inc
@@ -0,0 +1,329 @@
+<?php
+
+/**
+ * @file
+ * Parser functions for the aggregator module.
+ */
+
+/**
+ * Implements hook_aggregator_parse_info().
+ */
+function aggregator_aggregator_parse_info() {
+ return array(
+ 'title' => t('Default parser'),
+ 'description' => t('Parses RSS, Atom and RDF feeds.'),
+ );
+}
+
+/**
+ * Implements hook_aggregator_parse().
+ */
+function aggregator_aggregator_parse($feed) {
+ global $channel, $image;
+
+ // Filter the input data.
+ if (aggregator_parse_feed($feed->source_string, $feed)) {
+ $modified = empty($feed->http_headers['last-modified']) ? 0 : strtotime($feed->http_headers['last-modified']);
+
+ // Prepare the channel data.
+ foreach ($channel as $key => $value) {
+ $channel[$key] = trim($value);
+ }
+
+ // Prepare the image data (if any).
+ foreach ($image as $key => $value) {
+ $image[$key] = trim($value);
+ }
+
+ $etag = empty($feed->http_headers['etag']) ? '' : $feed->http_headers['etag'];
+
+ // Add parsed data to the feed object.
+ $feed->link = !empty($channel['link']) ? $channel['link'] : '';
+ $feed->description = !empty($channel['description']) ? $channel['description'] : '';
+ $feed->image = !empty($image['url']) ? $image['url'] : '';
+ $feed->etag = $etag;
+ $feed->modified = $modified;
+
+ // Clear the cache.
+ cache_clear_all();
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ * Parses a feed and stores its items.
+ *
+ * @param $data
+ * The feed data.
+ * @param $feed
+ * An object describing the feed to be parsed.
+ *
+ * @return
+ * FALSE on error, TRUE otherwise.
+ */
+function aggregator_parse_feed(&$data, $feed) {
+ global $items, $image, $channel;
+
+ // Unset the global variables before we use them.
+ unset($GLOBALS['element'], $GLOBALS['item'], $GLOBALS['tag']);
+ $items = array();
+ $image = array();
+ $channel = array();
+
+ // Parse the data.
+ $xml_parser = drupal_xml_parser_create($data);
+ xml_set_element_handler($xml_parser, 'aggregator_element_start', 'aggregator_element_end');
+ xml_set_character_data_handler($xml_parser, 'aggregator_element_data');
+
+ if (!xml_parse($xml_parser, $data, 1)) {
+ watchdog('aggregator', 'The feed from %site seems to be broken, due to an error "%error" on line %line.', array('%site' => $feed->title, '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser)), WATCHDOG_WARNING);
+ drupal_set_message(t('The feed from %site seems to be broken, because of error "%error" on line %line.', array('%site' => $feed->title, '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser))), 'error');
+ return FALSE;
+ }
+ xml_parser_free($xml_parser);
+
+ // We reverse the array such that we store the first item last, and the last
+ // item first. In the database, the newest item should be at the top.
+ $items = array_reverse($items);
+
+ // Initialize items array.
+ $feed->items = array();
+ foreach ($items as $item) {
+
+ // Prepare the item:
+ foreach ($item as $key => $value) {
+ $item[$key] = trim($value);
+ }
+
+ // Resolve the item's title. If no title is found, we use up to 40
+ // characters of the description ending at a word boundary, but not
+ // splitting potential entities.
+ if (!empty($item['title'])) {
+ $item['title'] = $item['title'];
+ }
+ elseif (!empty($item['description'])) {
+ $item['title'] = preg_replace('/^(.*)[^\w;&].*?$/', "\\1", truncate_utf8($item['description'], 40));
+ }
+ else {
+ $item['title'] = '';
+ }
+
+ // Resolve the items link.
+ if (!empty($item['link'])) {
+ $item['link'] = $item['link'];
+ }
+ else {
+ $item['link'] = $feed->link;
+ }
+
+ // Atom feeds have an ID tag instead of a GUID tag.
+ if (!isset($item['guid'])) {
+ $item['guid'] = isset($item['id']) ? $item['id'] : '';
+ }
+
+ // Atom feeds have a content and/or summary tag instead of a description tag.
+ if (!empty($item['content:encoded'])) {
+ $item['description'] = $item['content:encoded'];
+ }
+ elseif (!empty($item['summary'])) {
+ $item['description'] = $item['summary'];
+ }
+ elseif (!empty($item['content'])) {
+ $item['description'] = $item['content'];
+ }
+
+ // Try to resolve and parse the item's publication date.
+ $date = '';
+ foreach (array('pubdate', 'dc:date', 'dcterms:issued', 'dcterms:created', 'dcterms:modified', 'issued', 'created', 'modified', 'published', 'updated') as $key) {
+ if (!empty($item[$key])) {
+ $date = $item[$key];
+ break;
+ }
+ }
+
+ $item['timestamp'] = strtotime($date);
+
+ if ($item['timestamp'] === FALSE) {
+ $item['timestamp'] = aggregator_parse_w3cdtf($date); // Aggregator_parse_w3cdtf() returns FALSE on failure.
+ }
+
+ // Resolve dc:creator tag as the item author if author tag is not set.
+ if (empty($item['author']) && !empty($item['dc:creator'])) {
+ $item['author'] = $item['dc:creator'];
+ }
+
+ $item += array('author' => '', 'description' => '');
+
+ // Store on $feed object. This is where processors will look for parsed items.
+ $feed->items[] = $item;
+ }
+
+ return TRUE;
+}
+
+/**
+ * Performs an action when an opening tag is encountered.
+ *
+ * Callback function used by xml_parse() within aggregator_parse_feed().
+ */
+function aggregator_element_start($parser, $name, $attributes) {
+ global $item, $element, $tag, $items, $channel;
+
+ $name = strtolower($name);
+ switch ($name) {
+ case 'image':
+ case 'textinput':
+ case 'summary':
+ case 'tagline':
+ case 'subtitle':
+ case 'logo':
+ case 'info':
+ $element = $name;
+ break;
+ case 'id':
+ case 'content':
+ if ($element != 'item') {
+ $element = $name;
+ }
+ case 'link':
+ // According to RFC 4287, link elements in Atom feeds without a 'rel'
+ // attribute should be interpreted as though the relation type is
+ // "alternate".
+ if (!empty($attributes['HREF']) && (empty($attributes['REL']) || $attributes['REL'] == 'alternate')) {
+ if ($element == 'item') {
+ $items[$item]['link'] = $attributes['HREF'];
+ }
+ else {
+ $channel['link'] = $attributes['HREF'];
+ }
+ }
+ break;
+ case 'item':
+ $element = $name;
+ $item += 1;
+ break;
+ case 'entry':
+ $element = 'item';
+ $item += 1;
+ break;
+ }
+
+ $tag = $name;
+}
+
+/**
+ * Performs an action when a closing tag is encountered.
+ *
+ * Callback function used by xml_parse() within aggregator_parse_feed().
+ */
+function aggregator_element_end($parser, $name) {
+ global $element;
+
+ switch ($name) {
+ case 'image':
+ case 'textinput':
+ case 'item':
+ case 'entry':
+ case 'info':
+ $element = '';
+ break;
+ case 'id':
+ case 'content':
+ if ($element == $name) {
+ $element = '';
+ }
+ }
+}
+
+/**
+ * Performs an action when data is encountered.
+ *
+ * Callback function used by xml_parse() within aggregator_parse_feed().
+ */
+function aggregator_element_data($parser, $data) {
+ global $channel, $element, $items, $item, $image, $tag;
+ $items += array($item => array());
+ switch ($element) {
+ case 'item':
+ $items[$item] += array($tag => '');
+ $items[$item][$tag] .= $data;
+ break;
+ case 'image':
+ case 'logo':
+ $image += array($tag => '');
+ $image[$tag] .= $data;
+ break;
+ case 'link':
+ if ($data) {
+ $items[$item] += array($tag => '');
+ $items[$item][$tag] .= $data;
+ }
+ break;
+ case 'content':
+ $items[$item] += array('content' => '');
+ $items[$item]['content'] .= $data;
+ break;
+ case 'summary':
+ $items[$item] += array('summary' => '');
+ $items[$item]['summary'] .= $data;
+ break;
+ case 'tagline':
+ case 'subtitle':
+ $channel += array('description' => '');
+ $channel['description'] .= $data;
+ break;
+ case 'info':
+ case 'id':
+ case 'textinput':
+ // The sub-element is not supported. However, we must recognize
+ // it or its contents will end up in the item array.
+ break;
+ default:
+ $channel += array($tag => '');
+ $channel[$tag] .= $data;
+ }
+}
+
+/**
+ * Parses the W3C date/time format, a subset of ISO 8601.
+ *
+ * PHP date parsing functions do not handle this format. See
+ * http://www.w3.org/TR/NOTE-datetime for more information. Originally from
+ * MagpieRSS (http://magpierss.sourceforge.net/).
+ *
+ * @param $date_str
+ * A string with a potentially W3C DTF date.
+ *
+ * @return
+ * A timestamp if parsed successfully or FALSE if not.
+ */
+function aggregator_parse_w3cdtf($date_str) {
+ if (preg_match('/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/', $date_str, $match)) {
+ list($year, $month, $day, $hours, $minutes, $seconds) = array($match[1], $match[2], $match[3], $match[4], $match[5], $match[6]);
+ // Calculate the epoch for current date assuming GMT.
+ $epoch = gmmktime($hours, $minutes, $seconds, $month, $day, $year);
+ if ($match[10] != 'Z') { // Z is zulu time, aka GMT
+ list($tz_mod, $tz_hour, $tz_min) = array($match[8], $match[9], $match[10]);
+ // Zero out the variables.
+ if (!$tz_hour) {
+ $tz_hour = 0;
+ }
+ if (!$tz_min) {
+ $tz_min = 0;
+ }
+ $offset_secs = (($tz_hour * 60) + $tz_min) * 60;
+ // Is timezone ahead of GMT? If yes, subtract offset.
+ if ($tz_mod == '+') {
+ $offset_secs *= -1;
+ }
+ $epoch += $offset_secs;
+ }
+ return $epoch;
+ }
+ else {
+ return FALSE;
+ }
+}
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.processor.inc b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.processor.inc
new file mode 100644
index 0000000..44ed549
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.processor.inc
@@ -0,0 +1,213 @@
+<?php
+
+/**
+ * @file
+ * Processor functions for the aggregator module.
+ */
+
+/**
+ * Implements hook_aggregator_process_info().
+ */
+function aggregator_aggregator_process_info() {
+ return array(
+ 'title' => t('Default processor'),
+ 'description' => t('Creates lightweight records from feed items.'),
+ );
+}
+
+/**
+ * Implements hook_aggregator_process().
+ */
+function aggregator_aggregator_process($feed) {
+ if (is_object($feed)) {
+ if (is_array($feed->items)) {
+ foreach ($feed->items as $item) {
+ // Save this item. Try to avoid duplicate entries as much as possible. If
+ // we find a duplicate entry, we resolve it and pass along its ID is such
+ // that we can update it if needed.
+ if (!empty($item['guid'])) {
+ $entry = db_query("SELECT iid, timestamp FROM {aggregator_item} WHERE fid = :fid AND guid = :guid", array(':fid' => $feed->fid, ':guid' => $item['guid']))->fetchObject();
+ }
+ elseif ($item['link'] && $item['link'] != $feed->link && $item['link'] != $feed->url) {
+ $entry = db_query("SELECT iid, timestamp FROM {aggregator_item} WHERE fid = :fid AND link = :link", array(':fid' => $feed->fid, ':link' => $item['link']))->fetchObject();
+ }
+ else {
+ $entry = db_query("SELECT iid, timestamp FROM {aggregator_item} WHERE fid = :fid AND title = :title", array(':fid' => $feed->fid, ':title' => $item['title']))->fetchObject();
+ }
+ if (!$item['timestamp']) {
+ $item['timestamp'] = isset($entry->timestamp) ? $entry->timestamp : REQUEST_TIME;
+ }
+
+ // Make sure the item title and author fit in the 255 varchar column.
+ $item['title'] = truncate_utf8($item['title'], 255, TRUE, TRUE);
+ $item['author'] = truncate_utf8($item['author'], 255, TRUE, TRUE);
+ aggregator_save_item(array('iid' => (isset($entry->iid) ? $entry->iid : ''), 'fid' => $feed->fid, 'timestamp' => $item['timestamp'], 'title' => $item['title'], 'link' => $item['link'], 'author' => $item['author'], 'description' => $item['description'], 'guid' => $item['guid']));
+ }
+ }
+ }
+}
+
+/**
+ * Implements hook_aggregator_remove().
+ */
+function aggregator_aggregator_remove($feed) {
+ $iids = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchCol();
+ if ($iids) {
+ db_delete('aggregator_category_item')
+ ->condition('iid', $iids, 'IN')
+ ->execute();
+ }
+ db_delete('aggregator_item')
+ ->condition('fid', $feed->fid)
+ ->execute();
+
+ drupal_set_message(t('The news items from %site have been removed.', array('%site' => $feed->title)));
+}
+
+/**
+ * Implements hook_form_aggregator_admin_form_alter().
+ *
+ * Form alter aggregator module's own form to keep processor functionality
+ * separate from aggregator API functionality.
+ */
+function aggregator_form_aggregator_admin_form_alter(&$form, $form_state) {
+ if (in_array('aggregator', variable_get('aggregator_processors', array('aggregator')))) {
+ $info = module_invoke('aggregator', 'aggregator_process', 'info');
+ $items = drupal_map_assoc(array(3, 5, 10, 15, 20, 25), '_aggregator_items');
+ $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
+ $period[AGGREGATOR_CLEAR_NEVER] = t('Never');
+
+ // Only wrap into a collapsible fieldset if there is a basic configuration.
+ if (isset($form['basic_conf'])) {
+ $form['modules']['aggregator'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Default processor settings'),
+ '#description' => $info['description'],
+ '#collapsible' => TRUE,
+ '#collapsed' => !in_array('aggregator', variable_get('aggregator_processors', array('aggregator'))),
+ );
+ }
+ else {
+ $form['modules']['aggregator'] = array();
+ }
+
+ $form['modules']['aggregator']['aggregator_summary_items'] = array(
+ '#type' => 'select',
+ '#title' => t('Number of items shown in listing pages'),
+ '#default_value' => variable_get('aggregator_summary_items', 3),
+ '#empty_value' => 0,
+ '#options' => $items,
+ );
+
+ $form['modules']['aggregator']['aggregator_clear'] = array(
+ '#type' => 'select',
+ '#title' => t('Discard items older than'),
+ '#default_value' => variable_get('aggregator_clear', 9676800),
+ '#options' => $period,
+ '#description' => t('Requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status'))),
+ );
+
+ $form['modules']['aggregator']['aggregator_category_selector'] = array(
+ '#type' => 'radios',
+ '#title' => t('Select categories using'),
+ '#default_value' => variable_get('aggregator_category_selector', 'checkboxes'),
+ '#options' => array('checkboxes' => t('checkboxes'),
+ 'select' => t('multiple selector')),
+ '#description' => t('For a small number of categories, checkboxes are easier to use, while a multiple selector works well with large numbers of categories.'),
+ );
+ $form['modules']['aggregator']['aggregator_teaser_length'] = array(
+ '#type' => 'select',
+ '#title' => t('Length of trimmed description'),
+ '#default_value' => variable_get('aggregator_teaser_length', 600),
+ '#options' => drupal_map_assoc(array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000), '_aggregator_characters'),
+ '#description' => t("The maximum number of characters used in the trimmed version of content.")
+ );
+
+ }
+}
+
+/**
+ * Creates display text for teaser length option values.
+ *
+ * Callback for drupal_map_assoc() within
+ * aggregator_form_aggregator_admin_form_alter().
+ *
+ * @param $length
+ * The desired length of teaser text, in bytes.
+ *
+ * @return
+ * A translated string explaining the teaser string length.
+ */
+function _aggregator_characters($length) {
+ return ($length == 0) ? t('Unlimited') : format_plural($length, '1 character', '@count characters');
+}
+
+/**
+ * Adds/edits/deletes an aggregator item.
+ *
+ * @param $edit
+ * An associative array describing the item to be added/edited/deleted.
+ */
+function aggregator_save_item($edit) {
+ if ($edit['title'] && empty($edit['iid'])) {
+ $edit['iid'] = db_insert('aggregator_item')
+ ->fields(array(
+ 'title' => $edit['title'],
+ 'link' => $edit['link'],
+ 'author' => $edit['author'],
+ 'description' => $edit['description'],
+ 'guid' => $edit['guid'],
+ 'timestamp' => $edit['timestamp'],
+ 'fid' => $edit['fid'],
+ ))
+ ->execute();
+ }
+ if ($edit['iid'] && !$edit['title']) {
+ db_delete('aggregator_item')
+ ->condition('iid', $edit['iid'])
+ ->execute();
+ db_delete('aggregator_category_item')
+ ->condition('iid', $edit['iid'])
+ ->execute();
+ }
+ elseif ($edit['title'] && $edit['link']) {
+ // file the items in the categories indicated by the feed
+ $result = db_query('SELECT cid FROM {aggregator_category_feed} WHERE fid = :fid', array(':fid' => $edit['fid']));
+ foreach ($result as $category) {
+ db_merge('aggregator_category_item')
+ ->key(array(
+ 'iid' => $edit['iid'],
+ 'cid' => $category->cid,
+ ))
+ ->execute();
+ }
+ }
+}
+
+/**
+ * Expires items from a feed depending on expiration settings.
+ *
+ * @param $feed
+ * Object describing feed.
+ */
+function aggregator_expire($feed) {
+ $aggregator_clear = variable_get('aggregator_clear', 9676800);
+
+ if ($aggregator_clear != AGGREGATOR_CLEAR_NEVER) {
+ // Remove all items that are older than flush item timer.
+ $age = REQUEST_TIME - $aggregator_clear;
+ $iids = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid AND timestamp < :timestamp', array(
+ ':fid' => $feed->fid,
+ ':timestamp' => $age,
+ ))
+ ->fetchCol();
+ if ($iids) {
+ db_delete('aggregator_category_item')
+ ->condition('iid', $iids, 'IN')
+ ->execute();
+ db_delete('aggregator_item')
+ ->condition('iid', $iids, 'IN')
+ ->execute();
+ }
+ }
+}
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.test b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.test
new file mode 100644
index 0000000..18d5b33
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/aggregator.test
@@ -0,0 +1,1019 @@
+<?php
+
+/**
+ * @file
+ * Tests for aggregator.module.
+ */
+
+/**
+ * Defines a base class for testing the Aggregator module.
+ */
+class AggregatorTestCase extends DrupalWebTestCase {
+ function setUp() {
+ parent::setUp('aggregator', 'aggregator_test');
+ $web_user = $this->drupalCreateUser(array('administer news feeds', 'access news feeds', 'create article content'));
+ $this->drupalLogin($web_user);
+ }
+
+ /**
+ * Creates an aggregator feed.
+ *
+ * This method simulates the form submission on path
+ * admin/config/services/aggregator/add/feed.
+ *
+ * @param $feed_url
+ * (optional) If given, feed will be created with this URL, otherwise
+ * /rss.xml will be used. Defaults to NULL.
+ *
+ * @return $feed
+ * Full feed object if possible.
+ *
+ * @see getFeedEditArray()
+ */
+ function createFeed($feed_url = NULL) {
+ $edit = $this->getFeedEditArray($feed_url);
+ $this->drupalPost('admin/config/services/aggregator/add/feed', $edit, t('Save'));
+ $this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title'])), format_string('The feed !name has been added.', array('!name' => $edit['title'])));
+
+ $feed = db_query("SELECT * FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $edit['title'], ':url' => $edit['url']))->fetch();
+ $this->assertTrue(!empty($feed), 'The feed found in database.');
+ return $feed;
+ }
+
+ /**
+ * Deletes an aggregator feed.
+ *
+ * @param $feed
+ * Feed object representing the feed.
+ */
+ function deleteFeed($feed) {
+ $this->drupalPost('admin/config/services/aggregator/edit/feed/' . $feed->fid, array(), t('Delete'));
+ $this->assertRaw(t('The feed %title has been deleted.', array('%title' => $feed->title)), 'Feed deleted successfully.');
+ }
+
+ /**
+ * Returns a randomly generated feed edit array.
+ *
+ * @param $feed_url
+ * (optional) If given, feed will be created with this URL, otherwise
+ * /rss.xml will be used. Defaults to NULL.
+ * @return
+ * A feed array.
+ */
+ function getFeedEditArray($feed_url = NULL) {
+ $feed_name = $this->randomName(10);
+ if (!$feed_url) {
+ $feed_url = url('rss.xml', array(
+ 'query' => array('feed' => $feed_name),
+ 'absolute' => TRUE,
+ ));
+ }
+ $edit = array(
+ 'title' => $feed_name,
+ 'url' => $feed_url,
+ 'refresh' => '900',
+ );
+ return $edit;
+ }
+
+ /**
+ * Returns the count of the randomly created feed array.
+ *
+ * @return
+ * Number of feed items on default feed created by createFeed().
+ */
+ function getDefaultFeedItemCount() {
+ // Our tests are based off of rss.xml, so let's find out how many elements should be related.
+ $feed_count = db_query_range('SELECT COUNT(*) FROM {node} n WHERE n.promote = 1 AND n.status = 1', 0, variable_get('feed_default_items', 10))->fetchField();
+ return $feed_count > 10 ? 10 : $feed_count;
+ }
+
+ /**
+ * Updates the feed items.
+ *
+ * This method simulates a click to
+ * admin/config/services/aggregator/update/$fid.
+ *
+ * @param $feed
+ * Feed object representing the feed, passed by reference.
+ * @param $expected_count
+ * Expected number of feed items.
+ */
+ function updateFeedItems(&$feed, $expected_count) {
+ // First, let's ensure we can get to the rss xml.
+ $this->drupalGet($feed->url);
+ $this->assertResponse(200, format_string('!url is reachable.', array('!url' => $feed->url)));
+
+ // Attempt to access the update link directly without an access token.
+ $this->drupalGet('admin/config/services/aggregator/update/' . $feed->fid);
+ $this->assertResponse(403);
+
+ // Refresh the feed (simulated link click).
+ $this->drupalGet('admin/config/services/aggregator');
+ $this->clickLink('update items');
+
+ // Ensure we have the right number of items.
+ $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid));
+ $items = array();
+ $feed->items = array();
+ foreach ($result as $item) {
+ $feed->items[] = $item->iid;
+ }
+ $feed->item_count = count($feed->items);
+ $this->assertEqual($expected_count, $feed->item_count, format_string('Total items in feed equal to the total items in database (!val1 != !val2)', array('!val1' => $expected_count, '!val2' => $feed->item_count)));
+ }
+
+ /**
+ * Confirms an item removal from a feed.
+ *
+ * @param $feed
+ * Feed object representing the feed.
+ */
+ function removeFeedItems($feed) {
+ $this->drupalPost('admin/config/services/aggregator/remove/' . $feed->fid, array(), t('Remove items'));
+ $this->assertRaw(t('The news items from %title have been removed.', array('%title' => $feed->title)), 'Feed items removed.');
+ }
+
+ /**
+ * Adds and removes feed items and ensure that the count is zero.
+ *
+ * @param $feed
+ * Feed object representing the feed.
+ * @param $expected_count
+ * Expected number of feed items.
+ */
+ function updateAndRemove($feed, $expected_count) {
+ $this->updateFeedItems($feed, $expected_count);
+ $count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField();
+ $this->assertTrue($count);
+ $this->removeFeedItems($feed);
+ $count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField();
+ $this->assertTrue($count == 0);
+ }
+
+ /**
+ * Pulls feed categories from {aggregator_category_feed} table.
+ *
+ * @param $feed
+ * Feed object representing the feed.
+ */
+ function getFeedCategories($feed) {
+ // add the categories to the feed so we can use them
+ $result = db_query('SELECT cid FROM {aggregator_category_feed} WHERE fid = :fid', array(':fid' => $feed->fid));
+ foreach ($result as $category) {
+ $feed->categories[] = $category->cid;
+ }
+ }
+
+ /**
+ * Pulls categories from {aggregator_category} table.
+ *
+ * @return
+ * An associative array keyed by category ID and values are set to the
+ * category names.
+ */
+ function getCategories() {
+ $categories = array();
+ $result = db_query('SELECT * FROM {aggregator_category}');
+ foreach ($result as $category) {
+ $categories[$category->cid] = $category;
+ }
+ return $categories;
+ }
+
+ /**
+ * Checks whether the feed name and URL are unique.
+ *
+ * @param $feed_name
+ * String containing the feed name to check.
+ * @param $feed_url
+ * String containing the feed URL to check.
+ *
+ * @return
+ * TRUE if feed is unique.
+ */
+ function uniqueFeed($feed_name, $feed_url) {
+ $result = db_query("SELECT COUNT(*) FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $feed_name, ':url' => $feed_url))->fetchField();
+ return (1 == $result);
+ }
+
+ /**
+ * Creates a valid OPML file from an array of feeds.
+ *
+ * @param $feeds
+ * An array of feeds.
+ *
+ * @return
+ * Path to valid OPML file.
+ */
+ function getValidOpml($feeds) {
+ // Properly escape URLs so that XML parsers don't choke on them.
+ foreach ($feeds as &$feed) {
+ $feed['url'] = htmlspecialchars($feed['url']);
+ }
+ /**
+ * Does not have an XML declaration, must pass the parser.
+ */
+ $opml = <<<EOF
+<opml version="1.0">
+ <head></head>
+ <body>
+ <!-- First feed to be imported. -->
+ <outline text="{$feeds[0]['title']}" xmlurl="{$feeds[0]['url']}" />
+
+ <!-- Second feed. Test string delimitation and attribute order. -->
+ <outline xmlurl='{$feeds[1]['url']}' text='{$feeds[1]['title']}'/>
+
+ <!-- Test for duplicate URL and title. -->
+ <outline xmlurl="{$feeds[0]['url']}" text="Duplicate URL"/>
+ <outline xmlurl="http://duplicate.title" text="{$feeds[1]['title']}"/>
+
+ <!-- Test that feeds are only added with required attributes. -->
+ <outline text="{$feeds[2]['title']}" />
+ <outline xmlurl="{$feeds[2]['url']}" />
+ </body>
+</opml>
+EOF;
+
+ $path = 'public://valid-opml.xml';
+ return file_unmanaged_save_data($opml, $path);
+ }
+
+ /**
+ * Creates an invalid OPML file.
+ *
+ * @return
+ * Path to invalid OPML file.
+ */
+ function getInvalidOpml() {
+ $opml = <<<EOF
+<opml>
+ <invalid>
+</opml>
+EOF;
+
+ $path = 'public://invalid-opml.xml';
+ return file_unmanaged_save_data($opml, $path);
+ }
+
+ /**
+ * Creates a valid but empty OPML file.
+ *
+ * @return
+ * Path to empty OPML file.
+ */
+ function getEmptyOpml() {
+ $opml = <<<EOF
+<?xml version="1.0" encoding="utf-8"?>
+<opml version="1.0">
+ <head></head>
+ <body>
+ <outline text="Sample text" />
+ <outline text="Sample text" url="Sample URL" />
+ </body>
+</opml>
+EOF;
+
+ $path = 'public://empty-opml.xml';
+ return file_unmanaged_save_data($opml, $path);
+ }
+
+ function getRSS091Sample() {
+ return $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'aggregator') . '/tests/aggregator_test_rss091.xml';
+ }
+
+ function getAtomSample() {
+ // The content of this sample ATOM feed is based directly off of the
+ // example provided in RFC 4287.
+ return $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'aggregator') . '/tests/aggregator_test_atom.xml';
+ }
+
+ /**
+ * Creates sample article nodes.
+ *
+ * @param $count
+ * (optional) The number of nodes to generate. Defaults to five.
+ */
+ function createSampleNodes($count = 5) {
+ $langcode = LANGUAGE_NONE;
+ // Post $count article nodes.
+ for ($i = 0; $i < $count; $i++) {
+ $edit = array();
+ $edit['title'] = $this->randomName();
+ $edit["body[$langcode][0][value]"] = $this->randomName();
+ $this->drupalPost('node/add/article', $edit, t('Save'));
+ }
+ }
+}
+
+/**
+ * Tests functionality of the configuration settings in the Aggregator module.
+ */
+class AggregatorConfigurationTestCase extends AggregatorTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Aggregator configuration',
+ 'description' => 'Test aggregator settings page.',
+ 'group' => 'Aggregator',
+ );
+ }
+
+ /**
+ * Tests the settings form to ensure the correct default values are used.
+ */
+ function testSettingsPage() {
+ $edit = array(
+ 'aggregator_allowed_html_tags' => '<a>',
+ 'aggregator_summary_items' => 10,
+ 'aggregator_clear' => 3600,
+ 'aggregator_category_selector' => 'select',
+ 'aggregator_teaser_length' => 200,
+ );
+ $this->drupalPost('admin/config/services/aggregator/settings', $edit, t('Save configuration'));
+ $this->assertText(t('The configuration options have been saved.'));
+
+ foreach ($edit as $name => $value) {
+ $this->assertFieldByName($name, $value, format_string('"@name" has correct default value.', array('@name' => $name)));
+ }
+ }
+}
+
+/**
+ * Tests adding aggregator feeds.
+ */
+class AddFeedTestCase extends AggregatorTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Add feed functionality',
+ 'description' => 'Add feed test.',
+ 'group' => 'Aggregator'
+ );
+ }
+
+ /**
+ * Creates and ensures that a feed is unique, checks source, and deletes feed.
+ */
+ function testAddFeed() {
+ $feed = $this->createFeed();
+
+ // Check feed data.
+ $this->assertEqual($this->getUrl(), url('admin/config/services/aggregator/add/feed', array('absolute' => TRUE)), 'Directed to correct url.');
+ $this->assertTrue($this->uniqueFeed($feed->title, $feed->url), 'The feed is unique.');
+
+ // Check feed source.
+ $this->drupalGet('aggregator/sources/' . $feed->fid);
+ $this->assertResponse(200, 'Feed source exists.');
+ $this->assertText($feed->title, 'Page title');
+ $this->drupalGet('aggregator/sources/' . $feed->fid . '/categorize');
+ $this->assertResponse(200, 'Feed categorization page exists.');
+
+ // Delete feed.
+ $this->deleteFeed($feed);
+ }
+
+ /**
+ * Tests feeds with very long URLs.
+ */
+ function testAddLongFeed() {
+ // Create a feed with a URL of > 255 characters.
+ $long_url = "https://www.google.com/search?ix=heb&sourceid=chrome&ie=UTF-8&q=angie+byron#sclient=psy-ab&hl=en&safe=off&source=hp&q=angie+byron&pbx=1&oq=angie+byron&aq=f&aqi=&aql=&gs_sm=3&gs_upl=0l0l0l10534l0l0l0l0l0l0l0l0ll0l0&bav=on.2,or.r_gc.r_pw.r_cp.,cf.osb&fp=a70b6b1f0abe28d8&biw=1629&bih=889&ix=heb";
+ $feed = $this->createFeed($long_url);
+
+ // Create a second feed of > 255 characters, where the only difference is
+ // after the 255th character.
+ $long_url_2 = "https://www.google.com/search?ix=heb&sourceid=chrome&ie=UTF-8&q=angie+byron#sclient=psy-ab&hl=en&safe=off&source=hp&q=angie+byron&pbx=1&oq=angie+byron&aq=f&aqi=&aql=&gs_sm=3&gs_upl=0l0l0l10534l0l0l0l0l0l0l0l0ll0l0&bav=on.2,or.r_gc.r_pw.r_cp.,cf.osb&fp=a70b6b1f0abe28d8&biw=1629&bih=889";
+ $feed_2 = $this->createFeed($long_url_2);
+
+ // Check feed data.
+ $this->assertTrue($this->uniqueFeed($feed->title, $feed->url), 'The first long URL feed is unique.');
+ $this->assertTrue($this->uniqueFeed($feed_2->title, $feed_2->url), 'The second long URL feed is unique.');
+
+ // Check feed source.
+ $this->drupalGet('aggregator/sources/' . $feed->fid);
+ $this->assertResponse(200, 'Long URL feed source exists.');
+ $this->assertText($feed->title, 'Page title');
+ $this->drupalGet('aggregator/sources/' . $feed->fid . '/categorize');
+ $this->assertResponse(200, 'Long URL feed categorization page exists.');
+
+ // Delete feeds.
+ $this->deleteFeed($feed);
+ $this->deleteFeed($feed_2);
+ }
+}
+
+/**
+ * Tests the categorize feed functionality in the Aggregator module.
+ */
+class CategorizeFeedTestCase extends AggregatorTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Categorize feed functionality',
+ 'description' => 'Categorize feed test.',
+ 'group' => 'Aggregator'
+ );
+ }
+
+ /**
+ * Creates a feed and makes sure you can add more than one category to it.
+ */
+ function testCategorizeFeed() {
+
+ // Create 2 categories.
+ $category_1 = array('title' => $this->randomName(10), 'description' => '');
+ $this->drupalPost('admin/config/services/aggregator/add/category', $category_1, t('Save'));
+ $this->assertRaw(t('The category %title has been added.', array('%title' => $category_1['title'])), format_string('The category %title has been added.', array('%title' => $category_1['title'])));
+
+ $category_2 = array('title' => $this->randomName(10), 'description' => '');
+ $this->drupalPost('admin/config/services/aggregator/add/category', $category_2, t('Save'));
+ $this->assertRaw(t('The category %title has been added.', array('%title' => $category_2['title'])), format_string('The category %title has been added.', array('%title' => $category_2['title'])));
+
+ // Get categories from database.
+ $categories = $this->getCategories();
+
+ // Create a feed and assign 2 categories to it.
+ $feed = $this->getFeedEditArray();
+ $feed['block'] = 5;
+ foreach ($categories as $cid => $category) {
+ $feed['category'][$cid] = $cid;
+ }
+
+ // Use aggregator_save_feed() function to save the feed.
+ aggregator_save_feed($feed);
+ $db_feed = db_query("SELECT * FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $feed['title'], ':url' => $feed['url']))->fetch();
+
+ // Assert the feed has two categories.
+ $this->getFeedCategories($db_feed);
+ $this->assertEqual(count($db_feed->categories), 2, 'Feed has 2 categories');
+ }
+}
+
+/**
+ * Tests functionality of updating the feed in the Aggregator module.
+ */
+class UpdateFeedTestCase extends AggregatorTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Update feed functionality',
+ 'description' => 'Update feed test.',
+ 'group' => 'Aggregator'
+ );
+ }
+
+ /**
+ * Creates a feed and attempts to update it.
+ */
+ function testUpdateFeed() {
+ $remamining_fields = array('title', 'url', '');
+ foreach ($remamining_fields as $same_field) {
+ $feed = $this->createFeed();
+
+ // Get new feed data array and modify newly created feed.
+ $edit = $this->getFeedEditArray();
+ $edit['refresh'] = 1800; // Change refresh value.
+ if (isset($feed->{$same_field})) {
+ $edit[$same_field] = $feed->{$same_field};
+ }
+ $this->drupalPost('admin/config/services/aggregator/edit/feed/' . $feed->fid, $edit, t('Save'));
+ $this->assertRaw(t('The feed %name has been updated.', array('%name' => $edit['title'])), format_string('The feed %name has been updated.', array('%name' => $edit['title'])));
+
+ // Check feed data.
+ $this->assertEqual($this->getUrl(), url('admin/config/services/aggregator/', array('absolute' => TRUE)));
+ $this->assertTrue($this->uniqueFeed($edit['title'], $edit['url']), 'The feed is unique.');
+
+ // Check feed source.
+ $this->drupalGet('aggregator/sources/' . $feed->fid);
+ $this->assertResponse(200, 'Feed source exists.');
+ $this->assertText($edit['title'], 'Page title');
+
+ // Delete feed.
+ $feed->title = $edit['title']; // Set correct title so deleteFeed() will work.
+ $this->deleteFeed($feed);
+ }
+ }
+}
+
+/**
+ * Tests functionality for removing feeds in the Aggregator module.
+ */
+class RemoveFeedTestCase extends AggregatorTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Remove feed functionality',
+ 'description' => 'Remove feed test.',
+ 'group' => 'Aggregator'
+ );
+ }
+
+ /**
+ * Removes a feed and ensures that all of its services are removed.
+ */
+ function testRemoveFeed() {
+ $feed = $this->createFeed();
+
+ // Delete feed.
+ $this->deleteFeed($feed);
+
+ // Check feed source.
+ $this->drupalGet('aggregator/sources/' . $feed->fid);
+ $this->assertResponse(404, 'Deleted feed source does not exists.');
+
+ // Check database for feed.
+ $result = db_query("SELECT COUNT(*) FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $feed->title, ':url' => $feed->url))->fetchField();
+ $this->assertFalse($result, 'Feed not found in database');
+ }
+}
+
+/**
+ * Tests functionality of updating a feed item in the Aggregator module.
+ */
+class UpdateFeedItemTestCase extends AggregatorTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Update feed item functionality',
+ 'description' => 'Update feed items from a feed.',
+ 'group' => 'Aggregator'
+ );
+ }
+
+ /**
+ * Tests running "update items" from 'admin/config/services/aggregator' page.
+ */
+ function testUpdateFeedItem() {
+ $this->createSampleNodes();
+
+ // Create a feed and test updating feed items if possible.
+ $feed = $this->createFeed();
+ if (!empty($feed)) {
+ $this->updateFeedItems($feed, $this->getDefaultFeedItemCount());
+ $this->removeFeedItems($feed);
+ }
+
+ // Delete feed.
+ $this->deleteFeed($feed);
+
+ // Test updating feed items without valid timestamp information.
+ $edit = array(
+ 'title' => "Feed without publish timestamp",
+ 'url' => $this->getRSS091Sample(),
+ );
+
+ $this->drupalGet($edit['url']);
+ $this->assertResponse(array(200), format_string('URL !url is accessible', array('!url' => $edit['url'])));
+
+ $this->drupalPost('admin/config/services/aggregator/add/feed', $edit, t('Save'));
+ $this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title'])), format_string('The feed !name has been added.', array('!name' => $edit['title'])));
+
+ $feed = db_query("SELECT * FROM {aggregator_feed} WHERE url = :url", array(':url' => $edit['url']))->fetchObject();
+
+ aggregator_refresh($feed);
+ $before = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField();
+
+ // Sleep for 3 second.
+ sleep(3);
+ db_update('aggregator_feed')
+ ->condition('fid', $feed->fid)
+ ->fields(array(
+ 'checked' => 0,
+ 'hash' => '',
+ 'etag' => '',
+ 'modified' => 0,
+ ))
+ ->execute();
+ aggregator_refresh($feed);
+
+ $after = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField();
+ $this->assertTrue($before === $after, format_string('Publish timestamp of feed item was not updated (!before === !after)', array('!before' => $before, '!after' => $after)));
+ }
+}
+
+class RemoveFeedItemTestCase extends AggregatorTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Remove feed item functionality',
+ 'description' => 'Remove feed items from a feed.',
+ 'group' => 'Aggregator'
+ );
+ }
+
+ /**
+ * Tests running "remove items" from 'admin/config/services/aggregator' page.
+ */
+ function testRemoveFeedItem() {
+ // Create a bunch of test feeds.
+ $feed_urls = array();
+ // No last-modified, no etag.
+ $feed_urls[] = url('aggregator/test-feed', array('absolute' => TRUE));
+ // Last-modified, but no etag.
+ $feed_urls[] = url('aggregator/test-feed/1', array('absolute' => TRUE));
+ // No Last-modified, but etag.
+ $feed_urls[] = url('aggregator/test-feed/0/1', array('absolute' => TRUE));
+ // Last-modified and etag.
+ $feed_urls[] = url('aggregator/test-feed/1/1', array('absolute' => TRUE));
+
+ foreach ($feed_urls as $feed_url) {
+ $feed = $this->createFeed($feed_url);
+ // Update and remove items two times in a row to make sure that removal
+ // resets all 'modified' information (modified, etag, hash) and allows for
+ // immediate update.
+ $this->updateAndRemove($feed, 4);
+ $this->updateAndRemove($feed, 4);
+ $this->updateAndRemove($feed, 4);
+ // Delete feed.
+ $this->deleteFeed($feed);
+ }
+ }
+}
+
+/**
+ * Tests categorization functionality in the Aggregator module.
+ */
+class CategorizeFeedItemTestCase extends AggregatorTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Categorize feed item functionality',
+ 'description' => 'Test feed item categorization.',
+ 'group' => 'Aggregator'
+ );
+ }
+
+ /**
+ * Checks that children of a feed inherit a defined category.
+ *
+ * If a feed has a category, make sure that the children inherit that
+ * categorization.
+ */
+ function testCategorizeFeedItem() {
+ $this->createSampleNodes();
+
+ // Simulate form submission on "admin/config/services/aggregator/add/category".
+ $edit = array('title' => $this->randomName(10), 'description' => '');
+ $this->drupalPost('admin/config/services/aggregator/add/category', $edit, t('Save'));
+ $this->assertRaw(t('The category %title has been added.', array('%title' => $edit['title'])), format_string('The category %title has been added.', array('%title' => $edit['title'])));
+
+ $category = db_query("SELECT * FROM {aggregator_category} WHERE title = :title", array(':title' => $edit['title']))->fetch();
+ $this->assertTrue(!empty($category), 'The category found in database.');
+
+ $link_path = 'aggregator/categories/' . $category->cid;
+ $menu_link = db_query("SELECT * FROM {menu_links} WHERE link_path = :link_path", array(':link_path' => $link_path))->fetch();
+ $this->assertTrue(!empty($menu_link), 'The menu link associated with the category found in database.');
+
+ $feed = $this->createFeed();
+ db_insert('aggregator_category_feed')
+ ->fields(array(
+ 'cid' => $category->cid,
+ 'fid' => $feed->fid,
+ ))
+ ->execute();
+ $this->updateFeedItems($feed, $this->getDefaultFeedItemCount());
+ $this->getFeedCategories($feed);
+ $this->assertTrue(!empty($feed->categories), 'The category found in the feed.');
+
+ // For each category of a feed, ensure feed items have that category, too.
+ if (!empty($feed->categories) && !empty($feed->items)) {
+ foreach ($feed->categories as $category) {
+ $categorized_count = db_select('aggregator_category_item')
+ ->condition('iid', $feed->items, 'IN')
+ ->countQuery()
+ ->execute()
+ ->fetchField();
+
+ $this->assertEqual($feed->item_count, $categorized_count, 'Total items in feed equal to the total categorized feed items in database');
+ }
+ }
+
+ // Delete feed.
+ $this->deleteFeed($feed);
+ }
+}
+
+/**
+ * Tests importing feeds from OPML functionality for the Aggregator module.
+ */
+class ImportOPMLTestCase extends AggregatorTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Import feeds from OPML functionality',
+ 'description' => 'Test OPML import.',
+ 'group' => 'Aggregator',
+ );
+ }
+
+ /**
+ * Opens OPML import form.
+ */
+ function openImportForm() {
+ db_delete('aggregator_category')->execute();
+
+ $category = $this->randomName(10);
+ $cid = db_insert('aggregator_category')
+ ->fields(array(
+ 'title' => $category,
+ 'description' => '',
+ ))
+ ->execute();
+
+ $this->drupalGet('admin/config/services/aggregator/add/opml');
+ $this->assertText('A single OPML document may contain a collection of many feeds.', 'Found OPML help text.');
+ $this->assertField('files[upload]', 'Found file upload field.');
+ $this->assertField('remote', 'Found Remote URL field.');
+ $this->assertField('refresh', 'Found Refresh field.');
+ $this->assertFieldByName("category[$cid]", $cid, 'Found category field.');
+ }
+
+ /**
+ * Submits form filled with invalid fields.
+ */
+ function validateImportFormFields() {
+ $before = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
+
+ $edit = array();
+ $this->drupalPost('admin/config/services/aggregator/add/opml', $edit, t('Import'));
+ $this->assertRaw(t('You must <em>either</em> upload a file or enter a URL.'), 'Error if no fields are filled.');
+
+ $path = $this->getEmptyOpml();
+ $edit = array(
+ 'files[upload]' => $path,
+ 'remote' => file_create_url($path),
+ );
+ $this->drupalPost('admin/config/services/aggregator/add/opml', $edit, t('Import'));
+ $this->assertRaw(t('You must <em>either</em> upload a file or enter a URL.'), 'Error if both fields are filled.');
+
+ $edit = array('remote' => 'invalidUrl://empty');
+ $this->drupalPost('admin/config/services/aggregator/add/opml', $edit, t('Import'));
+ $this->assertText(t('This URL is not valid.'), 'Error if the URL is invalid.');
+
+ $after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
+ $this->assertEqual($before, $after, 'No feeds were added during the three last form submissions.');
+ }
+
+ /**
+ * Submits form with invalid, empty, and valid OPML files.
+ */
+ function submitImportForm() {
+ $before = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
+
+ $form['files[upload]'] = $this->getInvalidOpml();
+ $this->drupalPost('admin/config/services/aggregator/add/opml', $form, t('Import'));
+ $this->assertText(t('No new feed has been added.'), 'Attempting to upload invalid XML.');
+
+ $edit = array('remote' => file_create_url($this->getEmptyOpml()));
+ $this->drupalPost('admin/config/services/aggregator/add/opml', $edit, t('Import'));
+ $this->assertText(t('No new feed has been added.'), 'Attempting to load empty OPML from remote URL.');
+
+ $after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
+ $this->assertEqual($before, $after, 'No feeds were added during the two last form submissions.');
+
+ db_delete('aggregator_feed')->execute();
+ db_delete('aggregator_category')->execute();
+ db_delete('aggregator_category_feed')->execute();
+
+ $category = $this->randomName(10);
+ db_insert('aggregator_category')
+ ->fields(array(
+ 'cid' => 1,
+ 'title' => $category,
+ 'description' => '',
+ ))
+ ->execute();
+
+ $feeds[0] = $this->getFeedEditArray();
+ $feeds[1] = $this->getFeedEditArray();
+ $feeds[2] = $this->getFeedEditArray();
+ $edit = array(
+ 'files[upload]' => $this->getValidOpml($feeds),
+ 'refresh' => '900',
+ 'category[1]' => $category,
+ );
+ $this->drupalPost('admin/config/services/aggregator/add/opml', $edit, t('Import'));
+ $this->assertRaw(t('A feed with the URL %url already exists.', array('%url' => $feeds[0]['url'])), 'Verifying that a duplicate URL was identified');
+ $this->assertRaw(t('A feed named %title already exists.', array('%title' => $feeds[1]['title'])), 'Verifying that a duplicate title was identified');
+
+ $after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
+ $this->assertEqual($after, 2, 'Verifying that two distinct feeds were added.');
+
+ $feeds_from_db = db_query("SELECT f.title, f.url, f.refresh, cf.cid FROM {aggregator_feed} f LEFT JOIN {aggregator_category_feed} cf ON f.fid = cf.fid");
+ $refresh = $category = TRUE;
+ foreach ($feeds_from_db as $feed) {
+ $title[$feed->url] = $feed->title;
+ $url[$feed->title] = $feed->url;
+ $category = $category && $feed->cid == 1;
+ $refresh = $refresh && $feed->refresh == 900;
+ }
+
+ $this->assertEqual($title[$feeds[0]['url']], $feeds[0]['title'], 'First feed was added correctly.');
+ $this->assertEqual($url[$feeds[1]['title']], $feeds[1]['url'], 'Second feed was added correctly.');
+ $this->assertTrue($refresh, 'Refresh times are correct.');
+ $this->assertTrue($category, 'Categories are correct.');
+ }
+
+ /**
+ * Tests the import of an OPML file.
+ */
+ function testOPMLImport() {
+ $this->openImportForm();
+ $this->validateImportFormFields();
+ $this->submitImportForm();
+ }
+}
+
+/**
+ * Tests functionality of the cron process in the Aggregator module.
+ */
+class AggregatorCronTestCase extends AggregatorTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Update on cron functionality',
+ 'description' => 'Update feeds on cron.',
+ 'group' => 'Aggregator'
+ );
+ }
+
+ /**
+ * Adds feeds and updates them via cron process.
+ */
+ public function testCron() {
+ // Create feed and test basic updating on cron.
+ global $base_url;
+ $key = variable_get('cron_key', 'drupal');
+ $this->createSampleNodes();
+ $feed = $this->createFeed();
+ $this->drupalGet($base_url . '/cron.php', array('external' => TRUE, 'query' => array('cron_key' => $key)));
+ $this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField(), 'Expected number of items in database.');
+ $this->removeFeedItems($feed);
+ $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField(), 'Expected number of items in database.');
+ $this->drupalGet($base_url . '/cron.php', array('external' => TRUE, 'query' => array('cron_key' => $key)));
+ $this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField(), 'Expected number of items in database.');
+
+ // Test feed locking when queued for update.
+ $this->removeFeedItems($feed);
+ db_update('aggregator_feed')
+ ->condition('fid', $feed->fid)
+ ->fields(array(
+ 'queued' => REQUEST_TIME,
+ ))
+ ->execute();
+ $this->drupalGet($base_url . '/cron.php', array('external' => TRUE, 'query' => array('cron_key' => $key)));
+ $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField(), 'Expected number of items in database.');
+ db_update('aggregator_feed')
+ ->condition('fid', $feed->fid)
+ ->fields(array(
+ 'queued' => 0,
+ ))
+ ->execute();
+ $this->drupalGet($base_url . '/cron.php', array('external' => TRUE, 'query' => array('cron_key' => $key)));
+ $this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField(), 'Expected number of items in database.');
+ }
+}
+
+/**
+ * Tests rendering functionality in the Aggregator module.
+ */
+class AggregatorRenderingTestCase extends AggregatorTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Checks display of aggregator items',
+ 'description' => 'Checks display of aggregator items on the page.',
+ 'group' => 'Aggregator'
+ );
+ }
+
+ /**
+ * Adds a feed block to the page and checks its links.
+ *
+ * @todo Test the category block as well.
+ */
+ public function testBlockLinks() {
+ // Create feed.
+ $this->createSampleNodes();
+ $feed = $this->createFeed();
+ $this->updateFeedItems($feed, $this->getDefaultFeedItemCount());
+
+ // Place block on page (@see block.test:moveBlockToRegion())
+ // Need admin user to be able to access block admin.
+ $this->admin_user = $this->drupalCreateUser(array(
+ 'administer blocks',
+ 'access administration pages',
+ 'administer news feeds',
+ 'access news feeds',
+ ));
+ $this->drupalLogin($this->admin_user);
+
+ // Prepare to use the block admin form.
+ $block = array(
+ 'module' => 'aggregator',
+ 'delta' => 'feed-' . $feed->fid,
+ 'title' => $feed->title,
+ );
+ $region = 'footer';
+ $edit = array();
+ $edit['blocks[' . $block['module'] . '_' . $block['delta'] . '][region]'] = $region;
+ // Check the feed block is available in the block list form.
+ $this->drupalGet('admin/structure/block');
+ $this->assertFieldByName('blocks[' . $block['module'] . '_' . $block['delta'] . '][region]', '', 'Aggregator feed block is available for positioning.');
+ // Position it.
+ $this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
+ $this->assertText(t('The block settings have been updated.'), format_string('Block successfully moved to %region_name region.', array( '%region_name' => $region)));
+ // Confirm that the block is now being displayed on pages.
+ $this->drupalGet('node');
+ $this->assertText(t($block['title']), 'Feed block is displayed on the page.');
+
+ // Find the expected read_more link.
+ $href = 'aggregator/sources/' . $feed->fid;
+ $links = $this->xpath('//a[@href = :href]', array(':href' => url($href)));
+ $this->assert(isset($links[0]), format_string('Link to href %href found.', array('%href' => $href)));
+
+ // Visit that page.
+ $this->drupalGet($href);
+ $correct_titles = $this->xpath('//h1[normalize-space(text())=:title]', array(':title' => $feed->title));
+ $this->assertFalse(empty($correct_titles), 'Aggregator feed page is available and has the correct title.');
+
+ // Set the number of news items to 0 to test that the block does not show
+ // up.
+ $feed->block = 0;
+ aggregator_save_feed((array) $feed);
+ // It is necessary to flush the cache after saving the number of items.
+ drupal_flush_all_caches();
+ // Check that the block is no longer displayed.
+ $this->drupalGet('node');
+ $this->assertNoText(t($block['title']), 'Feed block is not displayed on the page when number of items is set to 0.');
+ }
+
+ /**
+ * Creates a feed and checks that feed's page.
+ */
+ public function testFeedPage() {
+ // Increase the number of items published in the rss.xml feed so we have
+ // enough articles to test paging.
+ variable_set('feed_default_items', 30);
+
+ // Create a feed with 30 items.
+ $this->createSampleNodes(30);
+ $feed = $this->createFeed();
+ $this->updateFeedItems($feed, 30);
+
+ // Check for the presence of a pager.
+ $this->drupalGet('aggregator/sources/' . $feed->fid);
+ $elements = $this->xpath("//ul[@class=:class]", array(':class' => 'pager'));
+ $this->assertTrue(!empty($elements), 'Individual source page contains a pager.');
+
+ // Reset the number of items in rss.xml to the default value.
+ variable_set('feed_default_items', 10);
+ }
+}
+
+/**
+ * Tests feed parsing in the Aggregator module.
+ */
+class FeedParserTestCase extends AggregatorTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Feed parser functionality',
+ 'description' => 'Test the built-in feed parser with valid feed samples.',
+ 'group' => 'Aggregator',
+ );
+ }
+
+ function setUp() {
+ parent::setUp();
+ // Do not remove old aggregator items during these tests, since our sample
+ // feeds have hardcoded dates in them (which may be expired when this test
+ // is run).
+ variable_set('aggregator_clear', AGGREGATOR_CLEAR_NEVER);
+ }
+
+ /**
+ * Tests a feed that uses the RSS 0.91 format.
+ */
+ function testRSS091Sample() {
+ $feed = $this->createFeed($this->getRSS091Sample());
+ aggregator_refresh($feed);
+ $this->drupalGet('aggregator/sources/' . $feed->fid);
+ $this->assertResponse(200, format_string('Feed %name exists.', array('%name' => $feed->title)));
+ $this->assertText('First example feed item title');
+ $this->assertLinkByHref('http://example.com/example-turns-one');
+ $this->assertText('First example feed item description.');
+
+ // Several additional items that include elements over 255 characters.
+ $this->assertRaw("Second example feed item title.");
+ $this->assertText('Long link feed item title');
+ $this->assertText('Long link feed item description');
+ $this->assertLinkByHref('http://example.com/tomorrow/and/tomorrow/and/tomorrow/creeps/in/this/petty/pace/from/day/to/day/to/the/last/syllable/of/recorded/time/and/all/our/yesterdays/have/lighted/fools/the/way/to/dusty/death/out/out/brief/candle/life/is/but/a/walking/shadow/a/poor/player/that/struts/and/frets/his/hour/upon/the/stage/and/is/heard/no/more/it/is/a/tale/told/by/an/idiot/full/of/sound/and/fury/signifying/nothing');
+ $this->assertText('Long author feed item title');
+ $this->assertText('Long author feed item description');
+ $this->assertLinkByHref('http://example.com/long/author');
+ }
+
+ /**
+ * Tests a feed that uses the Atom format.
+ */
+ function testAtomSample() {
+ $feed = $this->createFeed($this->getAtomSample());
+ aggregator_refresh($feed);
+ $this->drupalGet('aggregator/sources/' . $feed->fid);
+ $this->assertResponse(200, format_string('Feed %name exists.', array('%name' => $feed->title)));
+ $this->assertText('Atom-Powered Robots Run Amok');
+ $this->assertLinkByHref('http://example.org/2003/12/13/atom03');
+ $this->assertText('Some text.');
+ $this->assertEqual('urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a', db_query('SELECT guid FROM {aggregator_item} WHERE link = :link', array(':link' => 'http://example.org/2003/12/13/atom03'))->fetchField(), 'Atom entry id element is parsed correctly.');
+ }
+}
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/tests/aggregator_test.info b/kolab.org/www/drupal-7.26/modules/aggregator/tests/aggregator_test.info
new file mode 100644
index 0000000..a122ba2
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/tests/aggregator_test.info
@@ -0,0 +1,12 @@
+name = "Aggregator module tests"
+description = "Support module for aggregator related testing."
+package = Testing
+version = VERSION
+core = 7.x
+hidden = TRUE
+
+; Information added by Drupal.org packaging script on 2014-01-15
+version = "7.26"
+project = "drupal"
+datestamp = "1389815930"
+
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/tests/aggregator_test.module b/kolab.org/www/drupal-7.26/modules/aggregator/tests/aggregator_test.module
new file mode 100644
index 0000000..2d26a5d
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/tests/aggregator_test.module
@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * Implements hook_menu().
+ */
+function aggregator_test_menu() {
+ $items['aggregator/test-feed'] = array(
+ 'title' => 'Test feed static last modified date',
+ 'description' => "A cached test feed with a static last modified date.",
+ 'page callback' => 'aggregator_test_feed',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+ return $items;
+}
+
+/**
+ * Page callback. Generates a test feed and simulates last-modified and etags.
+ *
+ * @param $use_last_modified
+ * Set TRUE to send a last modified header.
+ * @param $use_etag
+ * Set TRUE to send an etag.
+ */
+function aggregator_test_feed($use_last_modified = FALSE, $use_etag = FALSE) {
+ $last_modified = strtotime('Sun, 19 Nov 1978 05:00:00 GMT');
+ $etag = drupal_hash_base64($last_modified);
+
+ $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) : FALSE;
+ $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : FALSE;
+
+ // Send appropriate response. We respond with a 304 not modified on either
+ // etag or on last modified.
+ if ($use_last_modified) {
+ drupal_add_http_header('Last-Modified', gmdate(DATE_RFC1123, $last_modified));
+ }
+ if ($use_etag) {
+ drupal_add_http_header('ETag', $etag);
+ }
+ // Return 304 not modified if either last modified or etag match.
+ if ($last_modified == $if_modified_since || $etag == $if_none_match) {
+ drupal_add_http_header('Status', '304 Not Modified');
+ return;
+ }
+
+ // The following headers force validation of cache:
+ drupal_add_http_header('Expires', 'Sun, 19 Nov 1978 05:00:00 GMT');
+ drupal_add_http_header('Cache-Control', 'must-revalidate');
+ drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
+
+ // Read actual feed from file.
+ $file_name = DRUPAL_ROOT . '/' . drupal_get_path('module', 'aggregator') . '/tests/aggregator_test_rss091.xml';
+ $handle = fopen($file_name, 'r');
+ $feed = fread($handle, filesize($file_name));
+ fclose($handle);
+
+ print $feed;
+}
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/tests/aggregator_test_atom.xml b/kolab.org/www/drupal-7.26/modules/aggregator/tests/aggregator_test_atom.xml
new file mode 100644
index 0000000..357b2e5
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/tests/aggregator_test_atom.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+
+ <title>Example Feed</title>
+ <link href="http://example.org/" />
+ <updated>2003-12-13T18:30:02Z</updated>
+ <author>
+ <name>John Doe</name>
+ </author>
+ <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
+
+ <entry>
+ <title>Atom-Powered Robots Run Amok</title>
+ <link href="http://example.org/2003/12/13/atom03" />
+ <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
+ <updated>2003-12-13T18:30:02Z</updated>
+ <summary>Some text.</summary>
+ </entry>
+
+</feed>
diff --git a/kolab.org/www/drupal-7.26/modules/aggregator/tests/aggregator_test_rss091.xml b/kolab.org/www/drupal-7.26/modules/aggregator/tests/aggregator_test_rss091.xml
new file mode 100644
index 0000000..2944022
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/aggregator/tests/aggregator_test_rss091.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rss version="0.91">
+ <channel>
+ <title>Example</title>
+ <link>http://example.com</link>
+ <description>Example updates</description>
+ <language>en-us</language>
+ <copyright>Copyright 2000, Example team.</copyright>
+ <managingEditor>editor@example.com</managingEditor>
+ <webMaster>webmaster@example.com</webMaster>
+ <image>
+ <title>Example</title>
+ <url>http://example.com/images/druplicon.png</url>
+ <link>http://example.com</link>
+ <width>88</width>
+ <height>100</height>
+ <description>Example updates</description>
+ </image>
+ <item>
+ <title>First example feed item title</title>
+ <link>http://example.com/example-turns-one</link>
+ <description>First example feed item description.</description>
+ </item>
+ <item>
+ <title>Second example feed item title. This title is extremely long so that it exceeds the 255 character limit for titles in feed item storage. In fact it's so long that this sentence isn't long enough so I'm rambling a bit to make it longer, nearly there now. Ah now it's long enough so I'll shut up.</title>
+ <link>http://example.com/example-turns-two</link>
+ <description>Second example feed item description.</description>
+ </item>
+ <item>
+ <title>Long link feed item title.</title>
+ <link>http://example.com/tomorrow/and/tomorrow/and/tomorrow/creeps/in/this/petty/pace/from/day/to/day/to/the/last/syllable/of/recorded/time/and/all/our/yesterdays/have/lighted/fools/the/way/to/dusty/death/out/out/brief/candle/life/is/but/a/walking/shadow/a/poor/player/that/struts/and/frets/his/hour/upon/the/stage/and/is/heard/no/more/it/is/a/tale/told/by/an/idiot/full/of/sound/and/fury/signifying/nothing</link>
+ <description>Long link feed item description.</description>
+ </item>
+ <item>
+ <title>Long author feed item title.</title>
+ <link>http://example.com/long/author</link>
+ <author>I wanted to get out and walk eastward toward the park through the soft twilight, but each time I tried to go I became entangled in some wild, strident argument which pulled me back, as if with ropes, into my chair. Yet high over the city our line of yellow windows must have contributed their share of human secrecy to the casual watcher in the darkening streets, and I was him too, looking up and wondering. I was within and without, simultaneously enchanted and repelled by the inexhaustible variety of life.</author>
+ <description>Long author feed item description.</description>
+ </item>
+ </channel>
+</rss>
diff --git a/kolab.org/www/drupal-7.26/modules/block/block-admin-display-form.tpl.php b/kolab.org/www/drupal-7.26/modules/block/block-admin-display-form.tpl.php
new file mode 100644
index 0000000..17a15e4
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/block/block-admin-display-form.tpl.php
@@ -0,0 +1,69 @@
+<?php
+
+/**
+ * @file
+ * Default theme implementation to configure blocks.
+ *
+ * Available variables:
+ * - $block_regions: An array of regions. Keyed by name with the title as value.
+ * - $block_listing: An array of blocks keyed by region and then delta.
+ * - $form_submit: Form submit button.
+ *
+ * Each $block_listing[$region] contains an array of blocks for that region.
+ *
+ * Each $data in $block_listing[$region] contains:
+ * - $data->region_title: Region title for the listed block.
+ * - $data->block_title: Block title.
+ * - $data->region_select: Drop-down menu for assigning a region.
+ * - $data->weight_select: Drop-down menu for setting weights.
+ * - $data->configure_link: Block configuration link.
+ * - $data->delete_link: For deleting user added blocks.
+ *
+ * @see template_preprocess_block_admin_display_form()
+ * @see theme_block_admin_display()
+ *
+ * @ingroup themeable
+ */
+?>
+<?php
+ // Add table javascript.
+ drupal_add_js('misc/tableheader.js');
+ drupal_add_js(drupal_get_path('module', 'block') . '/block.js');
+ foreach ($block_regions as $region => $title) {
+ drupal_add_tabledrag('blocks', 'match', 'sibling', 'block-region-select', 'block-region-' . $region, NULL, FALSE);
+ drupal_add_tabledrag('blocks', 'order', 'sibling', 'block-weight', 'block-weight-' . $region);
+ }
+?>
+<table id="blocks" class="sticky-enabled">
+ <thead>
+ <tr>
+ <th><?php print t('Block'); ?></th>
+ <th><?php print t('Region'); ?></th>
+ <th><?php print t('Weight'); ?></th>
+ <th colspan="2"><?php print t('Operations'); ?></th>
+ </tr>
+ </thead>
+ <tbody>
+ <?php $row = 0; ?>
+ <?php foreach ($block_regions as $region => $title): ?>
+ <tr class="region-title region-title-<?php print $region?>">
+ <td colspan="5"><?php print $title; ?></td>
+ </tr>
+ <tr class="region-message region-<?php print $region?>-message <?php print empty($block_listing[$region]) ? 'region-empty' : 'region-populated'; ?>">
+ <td colspan="5"><em><?php print t('No blocks in this region'); ?></em></td>
+ </tr>
+ <?php foreach ($block_listing[$region] as $delta => $data): ?>
+ <tr class="draggable <?php print $row % 2 == 0 ? 'odd' : 'even'; ?><?php print $data->row_class ? ' ' . $data->row_class : ''; ?>">
+ <td class="block"><?php print $data->block_title; ?></td>
+ <td><?php print $data->region_select; ?></td>
+ <td><?php print $data->weight_select; ?></td>
+ <td><?php print $data->configure_link; ?></td>
+ <td><?php print $data->delete_link; ?></td>
+ </tr>
+ <?php $row++; ?>
+ <?php endforeach; ?>
+ <?php endforeach; ?>
+ </tbody>
+</table>
+
+<?php print $form_submit; ?>
diff --git a/kolab.org/www/drupal-7.26/modules/block/block.admin.inc b/kolab.org/www/drupal-7.26/modules/block/block.admin.inc
new file mode 100644
index 0000000..bd61790
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/block/block.admin.inc
@@ -0,0 +1,700 @@
+<?php
+
+/**
+ * @file
+ * Admin page callbacks for the block module.
+ */
+
+/**
+ * Menu callback for admin/structure/block/demo.
+ */
+function block_admin_demo($theme = NULL) {
+ drupal_add_css(drupal_get_path('module', 'block') . '/block.css');
+ return '';
+}
+
+/**
+ * Menu callback for admin/structure/block.
+ *
+ * @param $theme
+ * The theme to display the administration page for. If not provided, defaults
+ * to the currently used theme.
+ */
+function block_admin_display($theme = NULL) {
+ global $theme_key;
+
+ drupal_theme_initialize();
+
+ if (!isset($theme)) {
+ // If theme is not specifically set, rehash for the current theme.
+ $theme = $theme_key;
+ }
+
+ // Fetch and sort blocks.
+ $blocks = block_admin_display_prepare_blocks($theme);
+
+ return drupal_get_form('block_admin_display_form', $blocks, $theme);
+}
+
+/**
+ * Prepares a list of blocks for display on the blocks administration page.
+ *
+ * @param $theme
+ * The machine-readable name of the theme whose blocks should be returned.
+ *
+ * @return
+ * An array of blocks, as returned by _block_rehash(), sorted by region in
+ * preparation for display on the blocks administration page.
+ *
+ * @see block_admin_display_form()
+ */
+function block_admin_display_prepare_blocks($theme) {
+ $blocks = _block_rehash($theme);
+ $compare_theme = &drupal_static('_block_compare:theme');
+ $compare_theme = $theme;
+ usort($blocks, '_block_compare');
+ return $blocks;
+}
+
+/**
+ * Form constructor for the main block administration form.
+ *
+ * @param $blocks
+ * An array of blocks, as returned by block_admin_display_prepare_blocks().
+ * @param $theme
+ * A string representing the name of the theme to edit blocks for.
+ * @param $block_regions
+ * (optional) An array of regions in which the blocks will be allowed to be
+ * placed. Defaults to all visible regions for the theme whose blocks are
+ * being configured. In all cases, a dummy region for disabled blocks will
+ * also be displayed.
+ *
+ * @return
+ * An array representing the form definition.
+ *
+ * @ingroup forms
+ * @see block_admin_display_form_submit()
+ */
+function block_admin_display_form($form, &$form_state, $blocks, $theme, $block_regions = NULL) {
+
+ $form['#attached']['css'] = array(drupal_get_path('module', 'block') . '/block.css');
+
+ // Get a list of block regions if one was not provided.
+ if (!isset($block_regions)) {
+ $block_regions = system_region_list($theme, REGIONS_VISIBLE);
+ }
+
+ // Weights range from -delta to +delta, so delta should be at least half
+ // of the amount of blocks present. This makes sure all blocks in the same
+ // region get an unique weight.
+ $weight_delta = round(count($blocks) / 2);
+
+ // Build the form tree.
+ $form['edited_theme'] = array(
+ '#type' => 'value',
+ '#value' => $theme,
+ );
+ $form['block_regions'] = array(
+ '#type' => 'value',
+ // Add a last region for disabled blocks.
+ '#value' => $block_regions + array(BLOCK_REGION_NONE => BLOCK_REGION_NONE),
+ );
+ $form['blocks'] = array();
+ $form['#tree'] = TRUE;
+
+ foreach ($blocks as $i => $block) {
+ $key = $block['module'] . '_' . $block['delta'];
+ $form['blocks'][$key]['module'] = array(
+ '#type' => 'value',
+ '#value' => $block['module'],
+ );
+ $form['blocks'][$key]['delta'] = array(
+ '#type' => 'value',
+ '#value' => $block['delta'],
+ );
+ $form['blocks'][$key]['info'] = array(
+ '#markup' => check_plain($block['info']),
+ );
+ $form['blocks'][$key]['theme'] = array(
+ '#type' => 'hidden',
+ '#value' => $theme,
+ );
+ $form['blocks'][$key]['weight'] = array(
+ '#type' => 'weight',
+ '#default_value' => $block['weight'],
+ '#delta' => $weight_delta,
+ '#title_display' => 'invisible',
+ '#title' => t('Weight for @block block', array('@block' => $block['info'])),
+ );
+ $form['blocks'][$key]['region'] = array(
+ '#type' => 'select',
+ '#default_value' => $block['region'] != BLOCK_REGION_NONE ? $block['region'] : NULL,
+ '#empty_value' => BLOCK_REGION_NONE,
+ '#title_display' => 'invisible',
+ '#title' => t('Region for @block block', array('@block' => $block['info'])),
+ '#options' => $block_regions,
+ );
+ $form['blocks'][$key]['configure'] = array(
+ '#type' => 'link',
+ '#title' => t('configure'),
+ '#href' => 'admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure',
+ );
+ if ($block['module'] == 'block') {
+ $form['blocks'][$key]['delete'] = array(
+ '#type' => 'link',
+ '#title' => t('delete'),
+ '#href' => 'admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/delete',
+ );
+ }
+ }
+ // Do not allow disabling the main system content block when it is present.
+ if (isset($form['blocks']['system_main']['region'])) {
+ $form['blocks']['system_main']['region']['#required'] = TRUE;
+ }
+
+ $form['actions'] = array(
+ '#tree' => FALSE,
+ '#type' => 'actions',
+ );
+ $form['actions']['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Save blocks'),
+ );
+
+ return $form;
+}
+
+/**
+ * Form submission handler for block_admin_display_form().
+ *
+ * @see block_admin_display_form()
+ */
+function block_admin_display_form_submit($form, &$form_state) {
+ $transaction = db_transaction();
+ try {
+ foreach ($form_state['values']['blocks'] as $block) {
+ $block['status'] = (int) ($block['region'] != BLOCK_REGION_NONE);
+ $block['region'] = $block['status'] ? $block['region'] : '';
+ db_update('block')
+ ->fields(array(
+ 'status' => $block['status'],
+ 'weight' => $block['weight'],
+ 'region' => $block['region'],
+ ))
+ ->condition('module', $block['module'])
+ ->condition('delta', $block['delta'])
+ ->condition('theme', $block['theme'])
+ ->execute();
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog_exception('block', $e);
+ throw $e;
+ }
+ drupal_set_message(t('The block settings have been updated.'));
+ cache_clear_all();
+}
+
+/**
+ * Sorts active blocks by region, then by weight; sorts inactive blocks by name.
+ *
+ * Callback for usort() in block_admin_display_prepare_blocks().
+ */
+function _block_compare($a, $b) {
+ global $theme_key;
+
+ // Theme should be set before calling this function, or the current theme
+ // is being used.
+ $theme = &drupal_static(__FUNCTION__ . ':theme');
+ if (!isset($theme)) {
+ $theme = $theme_key;
+ }
+
+ $regions = &drupal_static(__FUNCTION__ . ':regions');
+ // We need the region list to correctly order by region.
+ if (!isset($regions)) {
+ $regions = array_flip(array_keys(system_region_list($theme)));
+ $regions[BLOCK_REGION_NONE] = count($regions);
+ }
+
+ // Separate enabled from disabled.
+ $status = $b['status'] - $a['status'];
+ if ($status) {
+ return $status;
+ }
+ // Sort by region (in the order defined by theme .info file).
+ if ((!empty($a['region']) && !empty($b['region'])) && ($place = ($regions[$a['region']] - $regions[$b['region']]))) {
+ return $place;
+ }
+ // Sort by weight, unless disabled.
+ if ($a['region'] != BLOCK_REGION_NONE) {
+ $weight = $a['weight'] - $b['weight'];
+ if ($weight) {
+ return $weight;
+ }
+ }
+ // Sort by title.
+ return strcmp($a['info'], $b['info']);
+}
+
+/**
+ * Form constructor for the block configuration form.
+ *
+ * Also used by block_add_block_form() for adding a new custom block.
+ *
+ * @param $module
+ * Name of the module that implements the block to be configured.
+ * @param $delta
+ * Unique ID of the block within the context of $module.
+ *
+ * @see block_admin_configure_validate()
+ * @see block_admin_configure_submit()
+ * @ingroup forms
+ */
+function block_admin_configure($form, &$form_state, $module, $delta) {
+ $block = block_load($module, $delta);
+ $form['module'] = array(
+ '#type' => 'value',
+ '#value' => $block->module,
+ );
+ $form['delta'] = array(
+ '#type' => 'value',
+ '#value' => $block->delta,
+ );
+
+ // Get the block subject for the page title.
+ $info = module_invoke($block->module, 'block_info');
+ if (isset($info[$block->delta])) {
+ drupal_set_title(t("'%name' block", array('%name' => $info[$block->delta]['info'])), PASS_THROUGH);
+ }
+
+ $form['settings']['title'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Block title'),
+ '#maxlength' => 64,
+ '#description' => $block->module == 'block' ? t('The title of the block as shown to the user.') : t('Override the default title for the block. Use <em>!placeholder</em> to display no title, or leave blank to use the default block title.', array('!placeholder' => '&lt;none&gt;')),
+ '#default_value' => isset($block->title) ? $block->title : '',
+ '#weight' => -19,
+ );
+
+ // Module-specific block configuration.
+ if ($settings = module_invoke($block->module, 'block_configure', $block->delta)) {
+ foreach ($settings as $k => $v) {
+ $form['settings'][$k] = $v;
+ }
+ }
+
+ // Region settings.
+ $form['regions'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Region settings'),
+ '#collapsible' => FALSE,
+ '#description' => t('Specify in which themes and regions this block is displayed.'),
+ '#tree' => TRUE,
+ );
+
+ $theme_default = variable_get('theme_default', 'bartik');
+ $admin_theme = variable_get('admin_theme');
+ foreach (list_themes() as $key => $theme) {
+ // Only display enabled themes
+ if ($theme->status) {
+ $region = db_query("SELECT region FROM {block} WHERE module = :module AND delta = :delta AND theme = :theme", array(
+ ':module' => $block->module,
+ ':delta' => $block->delta,
+ ':theme' => $key,
+ ))->fetchField();
+
+ // Use a meaningful title for the main site theme and administrative
+ // theme.
+ $theme_title = $theme->info['name'];
+ if ($key == $theme_default) {
+ $theme_title = t('!theme (default theme)', array('!theme' => $theme_title));
+ }
+ elseif ($admin_theme && $key == $admin_theme) {
+ $theme_title = t('!theme (administration theme)', array('!theme' => $theme_title));
+ }
+ $form['regions'][$key] = array(
+ '#type' => 'select',
+ '#title' => $theme_title,
+ '#default_value' => !empty($region) && $region != -1 ? $region : NULL,
+ '#empty_value' => BLOCK_REGION_NONE,
+ '#options' => system_region_list($key, REGIONS_VISIBLE),
+ '#weight' => ($key == $theme_default ? 9 : 10),
+ );
+ }
+ }
+
+ // Visibility settings.
+ $form['visibility_title'] = array(
+ '#type' => 'item',
+ '#title' => t('Visibility settings'),
+ );
+ $form['visibility'] = array(
+ '#type' => 'vertical_tabs',
+ '#attached' => array(
+ 'js' => array(drupal_get_path('module', 'block') . '/block.js'),
+ ),
+ );
+
+ // Per-path visibility.
+ $form['visibility']['path'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Pages'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#group' => 'visibility',
+ '#weight' => 0,
+ );
+
+ $access = user_access('use PHP for settings');
+ if (isset($block->visibility) && $block->visibility == BLOCK_VISIBILITY_PHP && !$access) {
+ $form['visibility']['path']['visibility'] = array(
+ '#type' => 'value',
+ '#value' => BLOCK_VISIBILITY_PHP,
+ );
+ $form['visibility']['path']['pages'] = array(
+ '#type' => 'value',
+ '#value' => isset($block->pages) ? $block->pages : '',
+ );
+ }
+ else {
+ $options = array(
+ BLOCK_VISIBILITY_NOTLISTED => t('All pages except those listed'),
+ BLOCK_VISIBILITY_LISTED => t('Only the listed pages'),
+ );
+ $description = t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>'));
+
+ if (module_exists('php') && $access) {
+ $options += array(BLOCK_VISIBILITY_PHP => t('Pages on which this PHP code returns <code>TRUE</code> (experts only)'));
+ $title = t('Pages or PHP code');
+ $description .= ' ' . t('If the PHP option is chosen, enter PHP code between %php. Note that executing incorrect PHP code can break your Drupal site.', array('%php' => '<?php ?>'));
+ }
+ else {
+ $title = t('Pages');
+ }
+ $form['visibility']['path']['visibility'] = array(
+ '#type' => 'radios',
+ '#title' => t('Show block on specific pages'),
+ '#options' => $options,
+ '#default_value' => isset($block->visibility) ? $block->visibility : BLOCK_VISIBILITY_NOTLISTED,
+ );
+ $form['visibility']['path']['pages'] = array(
+ '#type' => 'textarea',
+ '#title' => '<span class="element-invisible">' . $title . '</span>',
+ '#default_value' => isset($block->pages) ? $block->pages : '',
+ '#description' => $description,
+ );
+ }
+
+ // Per-role visibility.
+ $default_role_options = db_query("SELECT rid FROM {block_role} WHERE module = :module AND delta = :delta", array(
+ ':module' => $block->module,
+ ':delta' => $block->delta,
+ ))->fetchCol();
+ $role_options = array_map('check_plain', user_roles());
+ $form['visibility']['role'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Roles'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#group' => 'visibility',
+ '#weight' => 10,
+ );
+ $form['visibility']['role']['roles'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Show block for specific roles'),
+ '#default_value' => $default_role_options,
+ '#options' => $role_options,
+ '#description' => t('Show this block only for the selected role(s). If you select no roles, the block will be visible to all users.'),
+ );
+
+ // Per-user visibility.
+ $form['visibility']['user'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Users'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#group' => 'visibility',
+ '#weight' => 20,
+ );
+ $form['visibility']['user']['custom'] = array(
+ '#type' => 'radios',
+ '#title' => t('Customizable per user'),
+ '#options' => array(
+ BLOCK_CUSTOM_FIXED => t('Not customizable'),
+ BLOCK_CUSTOM_ENABLED => t('Customizable, visible by default'),
+ BLOCK_CUSTOM_DISABLED => t('Customizable, hidden by default'),
+ ),
+ '#description' => t('Allow individual users to customize the visibility of this block in their account settings.'),
+ '#default_value' => isset($block->custom) ? $block->custom : BLOCK_CUSTOM_FIXED,
+ );
+
+ $form['actions'] = array('#type' => 'actions');
+ $form['actions']['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Save block'),
+ );
+
+ return $form;
+}
+
+/**
+ * Form validation handler for block_admin_configure().
+ *
+ * @see block_admin_configure()
+ * @see block_admin_configure_submit()
+ */
+function block_admin_configure_validate($form, &$form_state) {
+ if ($form_state['values']['module'] == 'block') {
+ $custom_block_exists = (bool) db_query_range('SELECT 1 FROM {block_custom} WHERE bid <> :bid AND info = :info', 0, 1, array(
+ ':bid' => $form_state['values']['delta'],
+ ':info' => $form_state['values']['info'],
+ ))->fetchField();
+ if (empty($form_state['values']['info']) || $custom_block_exists) {
+ form_set_error('info', t('Ensure that each block description is unique.'));
+ }
+ }
+}
+
+/**
+ * Form submission handler for block_admin_configure().
+ *
+ * @see block_admin_configure()
+ * @see block_admin_configure_validate()
+ */
+function block_admin_configure_submit($form, &$form_state) {
+ if (!form_get_errors()) {
+ $transaction = db_transaction();
+ try {
+ db_update('block')
+ ->fields(array(
+ 'visibility' => (int) $form_state['values']['visibility'],
+ 'pages' => trim($form_state['values']['pages']),
+ 'custom' => (int) $form_state['values']['custom'],
+ 'title' => $form_state['values']['title'],
+ ))
+ ->condition('module', $form_state['values']['module'])
+ ->condition('delta', $form_state['values']['delta'])
+ ->execute();
+
+ db_delete('block_role')
+ ->condition('module', $form_state['values']['module'])
+ ->condition('delta', $form_state['values']['delta'])
+ ->execute();
+ $query = db_insert('block_role')->fields(array('rid', 'module', 'delta'));
+ foreach (array_filter($form_state['values']['roles']) as $rid) {
+ $query->values(array(
+ 'rid' => $rid,
+ 'module' => $form_state['values']['module'],
+ 'delta' => $form_state['values']['delta'],
+ ));
+ }
+ $query->execute();
+
+ // Store regions per theme for this block
+ foreach ($form_state['values']['regions'] as $theme => $region) {
+ db_merge('block')
+ ->key(array('theme' => $theme, 'delta' => $form_state['values']['delta'], 'module' => $form_state['values']['module']))
+ ->fields(array(
+ 'region' => ($region == BLOCK_REGION_NONE ? '' : $region),
+ 'pages' => trim($form_state['values']['pages']),
+ 'status' => (int) ($region != BLOCK_REGION_NONE),
+ ))
+ ->execute();
+ }
+
+ module_invoke($form_state['values']['module'], 'block_save', $form_state['values']['delta'], $form_state['values']);
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog_exception('block', $e);
+ throw $e;
+ }
+ drupal_set_message(t('The block configuration has been saved.'));
+ cache_clear_all();
+ $form_state['redirect'] = 'admin/structure/block';
+ }
+}
+
+/**
+ * Form constructor for the add block form.
+ *
+ * @see block_add_block_form_validate()
+ * @see block_add_block_form_submit()
+ * @ingroup forms
+ */
+function block_add_block_form($form, &$form_state) {
+ return block_admin_configure($form, $form_state, 'block', NULL);
+}
+
+/**
+ * Form validation handler for block_add_block_form().
+ *
+ * @see block_add_block_form()
+ * @see block_add_block_form_submit()
+ */
+function block_add_block_form_validate($form, &$form_state) {
+ $custom_block_exists = (bool) db_query_range('SELECT 1 FROM {block_custom} WHERE info = :info', 0, 1, array(':info' => $form_state['values']['info']))->fetchField();
+
+ if (empty($form_state['values']['info']) || $custom_block_exists) {
+ form_set_error('info', t('Ensure that each block description is unique.'));
+ }
+}
+
+/**
+ * Form submission handler for block_add_block_form().
+ *
+ * Saves the new custom block.
+ *
+ * @see block_add_block_form()
+ * @see block_add_block_form_validate()
+ */
+function block_add_block_form_submit($form, &$form_state) {
+ $delta = db_insert('block_custom')
+ ->fields(array(
+ 'body' => $form_state['values']['body']['value'],
+ 'info' => $form_state['values']['info'],
+ 'format' => $form_state['values']['body']['format'],
+ ))
+ ->execute();
+ // Store block delta to allow other modules to work with new block.
+ $form_state['values']['delta'] = $delta;
+
+ $query = db_insert('block')->fields(array('visibility', 'pages', 'custom', 'title', 'module', 'theme', 'status', 'weight', 'delta', 'cache'));
+ foreach (list_themes() as $key => $theme) {
+ if ($theme->status) {
+ $query->values(array(
+ 'visibility' => (int) $form_state['values']['visibility'],
+ 'pages' => trim($form_state['values']['pages']),
+ 'custom' => (int) $form_state['values']['custom'],
+ 'title' => $form_state['values']['title'],
+ 'module' => $form_state['values']['module'],
+ 'theme' => $theme->name,
+ 'status' => 0,
+ 'weight' => 0,
+ 'delta' => $delta,
+ 'cache' => DRUPAL_NO_CACHE,
+ ));
+ }
+ }
+ $query->execute();
+
+ $query = db_insert('block_role')->fields(array('rid', 'module', 'delta'));
+ foreach (array_filter($form_state['values']['roles']) as $rid) {
+ $query->values(array(
+ 'rid' => $rid,
+ 'module' => $form_state['values']['module'],
+ 'delta' => $delta,
+ ));
+ }
+ $query->execute();
+
+ // Store regions per theme for this block
+ foreach ($form_state['values']['regions'] as $theme => $region) {
+ db_merge('block')
+ ->key(array('theme' => $theme, 'delta' => $delta, 'module' => $form_state['values']['module']))
+ ->fields(array(
+ 'region' => ($region == BLOCK_REGION_NONE ? '' : $region),
+ 'pages' => trim($form_state['values']['pages']),
+ 'status' => (int) ($region != BLOCK_REGION_NONE),
+ ))
+ ->execute();
+ }
+
+ drupal_set_message(t('The block has been created.'));
+ cache_clear_all();
+ $form_state['redirect'] = 'admin/structure/block';
+}
+
+/**
+ * Form constructor for the custom block deletion form.
+ *
+ * @param $module
+ * The name of the module that implements the block to be deleted. This should
+ * always equal 'block' since it only allows custom blocks to be deleted.
+ * @param $delta
+ * The unique ID of the block within the context of $module.
+ *
+ * @see block_custom_block_delete_submit()
+ */
+function block_custom_block_delete($form, &$form_state, $module, $delta) {
+ $block = block_load($module, $delta);
+ $custom_block = block_custom_block_get($block->delta);
+ $form['info'] = array('#type' => 'hidden', '#value' => $custom_block['info'] ? $custom_block['info'] : $custom_block['title']);
+ $form['bid'] = array('#type' => 'hidden', '#value' => $block->delta);
+
+ return confirm_form($form, t('Are you sure you want to delete the block %name?', array('%name' => $custom_block['info'])), 'admin/structure/block', '', t('Delete'), t('Cancel'));
+}
+
+/**
+ * Form submission handler for block_custom_block_delete().
+ *
+ * @see block_custom_block_delete()
+ */
+function block_custom_block_delete_submit($form, &$form_state) {
+ db_delete('block_custom')
+ ->condition('bid', $form_state['values']['bid'])
+ ->execute();
+ db_delete('block')
+ ->condition('module', 'block')
+ ->condition('delta', $form_state['values']['bid'])
+ ->execute();
+ db_delete('block_role')
+ ->condition('module', 'block')
+ ->condition('delta', $form_state['values']['bid'])
+ ->execute();
+ drupal_set_message(t('The block %name has been removed.', array('%name' => $form_state['values']['info'])));
+ cache_clear_all();
+ $form_state['redirect'] = 'admin/structure/block';
+ return;
+}
+
+/**
+ * Processes variables for block-admin-display-form.tpl.php.
+ *
+ * The $variables array contains the following arguments:
+ * - $form
+ *
+ * @see block-admin-display.tpl.php
+ * @see theme_block_admin_display()
+ */
+function template_preprocess_block_admin_display_form(&$variables) {
+ $variables['block_regions'] = $variables['form']['block_regions']['#value'];
+ if (isset($variables['block_regions'][BLOCK_REGION_NONE])) {
+ $variables['block_regions'][BLOCK_REGION_NONE] = t('Disabled');
+ }
+
+ foreach ($variables['block_regions'] as $key => $value) {
+ // Initialize an empty array for the region.
+ $variables['block_listing'][$key] = array();
+ }
+
+ // Initialize disabled blocks array.
+ $variables['block_listing'][BLOCK_REGION_NONE] = array();
+
+ // Add each block in the form to the appropriate place in the block listing.
+ foreach (element_children($variables['form']['blocks']) as $i) {
+ $block = &$variables['form']['blocks'][$i];
+
+ // Fetch the region for the current block.
+ $region = (isset($block['region']['#default_value']) ? $block['region']['#default_value'] : BLOCK_REGION_NONE);
+
+ // Set special classes needed for table drag and drop.
+ $block['region']['#attributes']['class'] = array('block-region-select', 'block-region-' . $region);
+ $block['weight']['#attributes']['class'] = array('block-weight', 'block-weight-' . $region);
+
+ $variables['block_listing'][$region][$i] = new stdClass();
+ $variables['block_listing'][$region][$i]->row_class = !empty($block['#attributes']['class']) ? implode(' ', $block['#attributes']['class']) : '';
+ $variables['block_listing'][$region][$i]->block_modified = !empty($block['#attributes']['class']) && in_array('block-modified', $block['#attributes']['class']);
+ $variables['block_listing'][$region][$i]->block_title = drupal_render($block['info']);
+ $variables['block_listing'][$region][$i]->region_select = drupal_render($block['region']) . drupal_render($block['theme']);
+ $variables['block_listing'][$region][$i]->weight_select = drupal_render($block['weight']);
+ $variables['block_listing'][$region][$i]->configure_link = drupal_render($block['configure']);
+ $variables['block_listing'][$region][$i]->delete_link = !empty($block['delete']) ? drupal_render($block['delete']) : '';
+ $variables['block_listing'][$region][$i]->printed = FALSE;
+ }
+
+ $variables['form_submit'] = drupal_render_children($variables['form']);
+}
+
diff --git a/kolab.org/www/drupal-7.26/modules/block/block.api.php b/kolab.org/www/drupal-7.26/modules/block/block.api.php
new file mode 100644
index 0000000..d8e129e
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/block/block.api.php
@@ -0,0 +1,368 @@
+<?php
+
+/**
+ * @file
+ * Hooks provided by the Block module.
+ */
+
+/**
+ * @addtogroup hooks
+ * @{
+ */
+
+/**
+ * Define all blocks provided by the module.
+ *
+ * This hook declares to Drupal what blocks are provided by your module and can
+ * optionally specify initial block configuration settings.
+ *
+ * In hook_block_info(), each block your module provides is given a unique
+ * identifier referred to as "delta" (the array key in the return value). Delta
+ * values only need to be unique within your module, and they are used in the
+ * following ways:
+ * - Passed into the other block hooks in your module as an argument to identify
+ * the block being configured or viewed.
+ * - Used to construct the default HTML ID of "block-MODULE-DELTA" applied to
+ * each block when it is rendered. This ID may then be used for CSS styling or
+ * JavaScript programming.
+ * - Used to define a theming template suggestion of block__MODULE__DELTA, for
+ * advanced theming possibilities.
+ * - Used by other modules to identify your block in hook_block_info_alter() and
+ * other alter hooks.
+ * The values of delta can be strings or numbers, but because of the uses above
+ * it is preferable to use descriptive strings whenever possible, and only use a
+ * numeric identifier if you have to (for instance if your module allows users
+ * to create several similar blocks that you identify within your module code
+ * with numeric IDs). The maximum length for delta values is 32 bytes.
+ *
+ * @return
+ * An associative array whose keys define the delta for each block and whose
+ * values contain the block descriptions. Each block description is itself an
+ * associative array, with the following key-value pairs:
+ * - info: (required) The human-readable administrative name of the block.
+ * This is used to identify the block on administration screens, and is not
+ * displayed to non-administrative users.
+ * - cache: (optional) A bitmask describing what kind of caching is
+ * appropriate for the block. Drupal provides the following bitmask
+ * constants for defining cache granularity:
+ * - DRUPAL_CACHE_PER_ROLE (default): The block can change depending on the
+ * roles the user viewing the page belongs to.
+ * - DRUPAL_CACHE_PER_USER: The block can change depending on the user
+ * viewing the page. This setting can be resource-consuming for sites with
+ * large number of users, and should only be used when
+ * DRUPAL_CACHE_PER_ROLE is not sufficient.
+ * - DRUPAL_CACHE_PER_PAGE: The block can change depending on the page being
+ * viewed.
+ * - DRUPAL_CACHE_GLOBAL: The block is the same for every user on every page
+ * where it is visible.
+ * - DRUPAL_CACHE_CUSTOM: The module implements its own caching system.
+ * - DRUPAL_NO_CACHE: The block should not get cached.
+ * - properties: (optional) Array of additional metadata to add to the block.
+ * Common properties include:
+ * - administrative: Boolean that categorizes this block as usable in an
+ * administrative context. This might include blocks that help an
+ * administrator approve/deny comments, or view recently created user
+ * accounts.
+ * - weight: (optional) Initial value for the ordering weight of this block.
+ * Most modules do not provide an initial value, and any value provided can
+ * be modified by a user on the block configuration screen.
+ * - status: (optional) Initial value for block enabled status. (1 = enabled,
+ * 0 = disabled). Most modules do not provide an initial value, and any
+ * value provided can be modified by a user on the block configuration
+ * screen.
+ * - region: (optional) Initial value for theme region within which this
+ * block is set. Most modules do not provide an initial value, and any value
+ * provided can be modified by a user on the block configuration screen.
+ * Note: If you set a region that isn't available in the currently enabled
+ * theme, the block will be disabled.
+ * - visibility: (optional) Initial value for the visibility flag, which tells
+ * how to interpret the 'pages' value. Possible values are:
+ * - BLOCK_VISIBILITY_NOTLISTED: Show on all pages except listed pages.
+ * 'pages' lists the paths where the block should not be shown.
+ * - BLOCK_VISIBILITY_LISTED: Show only on listed pages. 'pages' lists the
+ * paths where the block should be shown.
+ * - BLOCK_VISIBILITY_PHP: Use custom PHP code to determine visibility.
+ * 'pages' gives the PHP code to use.
+ * Most modules do not provide an initial value for 'visibility' or 'pages',
+ * and any value provided can be modified by a user on the block
+ * configuration screen.
+ * - pages: (optional) See 'visibility' above. A string that contains one or
+ * more page paths separated by '\n', '\r', or '\r\n' when 'visibility' is
+ * set to BLOCK_VISIBILITY_NOTLISTED or BLOCK_VISIBILITY_LISTED, or custom
+ * PHP code when 'visibility' is set to BLOCK_VISIBILITY_PHP. Paths may use
+ * '*' as a wildcard (matching any number of characters); '<front>'
+ * designates the site's front page. For BLOCK_VISIBILITY_PHP, the PHP
+ * code's return value should be TRUE if the block is to be made visible or
+ * FALSE if the block should not be visible.
+ *
+ * For a detailed usage example, see block_example.module.
+ *
+ * @see hook_block_configure()
+ * @see hook_block_save()
+ * @see hook_block_view()
+ * @see hook_block_info_alter()
+ */
+function hook_block_info() {
+ // This example comes from node.module.
+ $blocks['syndicate'] = array(
+ 'info' => t('Syndicate'),
+ 'cache' => DRUPAL_NO_CACHE
+ );
+
+ $blocks['recent'] = array(
+ 'info' => t('Recent content'),
+ // DRUPAL_CACHE_PER_ROLE will be assumed.
+ );
+
+ return $blocks;
+}
+
+/**
+ * Change block definition before saving to the database.
+ *
+ * @param $blocks
+ * A multidimensional array of blocks keyed by the defining module and delta;
+ * the values are blocks returned by hook_block_info(). This hook is fired
+ * after the blocks are collected from hook_block_info() and the database,
+ * right before saving back to the database.
+ * @param $theme
+ * The theme these blocks belong to.
+ * @param $code_blocks
+ * The blocks as defined in hook_block_info() before being overwritten by the
+ * database data.
+ *
+ * @see hook_block_info()
+ */
+function hook_block_info_alter(&$blocks, $theme, $code_blocks) {
+ // Disable the login block.
+ $blocks['user']['login']['status'] = 0;
+}
+
+/**
+ * Define a configuration form for a block.
+ *
+ * @param $delta
+ * Which block is being configured. This is a unique identifier for the block
+ * within the module, defined in hook_block_info().
+ *
+ * @return
+ * A configuration form, if one is needed for your block beyond the standard
+ * elements that the block module provides (block title, visibility, etc.).
+ *
+ * For a detailed usage example, see block_example.module.
+ *
+ * @see hook_block_info()
+ * @see hook_block_save()
+ */
+function hook_block_configure($delta = '') {
+ // This example comes from node.module.
+ $form = array();
+ if ($delta == 'recent') {
+ $form['node_recent_block_count'] = array(
+ '#type' => 'select',
+ '#title' => t('Number of recent content items to display'),
+ '#default_value' => variable_get('node_recent_block_count', 10),
+ '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
+ );
+ }
+ return $form;
+}
+
+/**
+ * Save the configuration options from hook_block_configure().
+ *
+ * This hook allows you to save the block-specific configuration settings
+ * defined within your hook_block_configure().
+ *
+ * @param $delta
+ * Which block is being configured. This is a unique identifier for the block
+ * within the module, defined in hook_block_info().
+ * @param $edit
+ * The submitted form data from the configuration form.
+ *
+ * For a detailed usage example, see block_example.module.
+ *
+ * @see hook_block_configure()
+ * @see hook_block_info()
+ */
+function hook_block_save($delta = '', $edit = array()) {
+ // This example comes from node.module.
+ if ($delta == 'recent') {
+ variable_set('node_recent_block_count', $edit['node_recent_block_count']);
+ }
+}
+
+/**
+ * Return a rendered or renderable view of a block.
+ *
+ * @param $delta
+ * Which block to render. This is a unique identifier for the block
+ * within the module, defined in hook_block_info().
+ *
+ * @return
+ * Either an empty array so the block will not be shown or an array containing
+ * the following elements:
+ * - subject: The default localized title of the block. If the block does not
+ * have a default title, this should be set to NULL.
+ * - content: The content of the block's body. This may be a renderable array
+ * (preferable) or a string containing rendered HTML content. If the content
+ * is empty the block will not be shown.
+ *
+ * For a detailed usage example, see block_example.module.
+ *
+ * @see hook_block_info()
+ * @see hook_block_view_alter()
+ * @see hook_block_view_MODULE_DELTA_alter()
+ */
+function hook_block_view($delta = '') {
+ // This example is adapted from node.module.
+ $block = array();
+
+ switch ($delta) {
+ case 'syndicate':
+ $block['subject'] = t('Syndicate');
+ $block['content'] = array(
+ '#theme' => 'feed_icon',
+ '#url' => 'rss.xml',
+ '#title' => t('Syndicate'),
+ );
+ break;
+
+ case 'recent':
+ if (user_access('access content')) {
+ $block['subject'] = t('Recent content');
+ if ($nodes = node_get_recent(variable_get('node_recent_block_count', 10))) {
+ $block['content'] = array(
+ '#theme' => 'node_recent_block',
+ '#nodes' => $nodes,
+ );
+ } else {
+ $block['content'] = t('No content available.');
+ }
+ }
+ break;
+ }
+ return $block;
+}
+
+/**
+ * Perform alterations to the content of a block.
+ *
+ * This hook allows you to modify any data returned by hook_block_view().
+ *
+ * Note that instead of hook_block_view_alter(), which is called for all
+ * blocks, you can also use hook_block_view_MODULE_DELTA_alter() to alter a
+ * specific block.
+ *
+ * @param $data
+ * The data as returned from the hook_block_view() implementation of the
+ * module that defined the block. This could be an empty array or NULL value
+ * (if the block is empty) or an array containing:
+ * - subject: The default localized title of the block.
+ * - content: Either a string or a renderable array representing the content
+ * of the block. You should check that the content is an array before trying
+ * to modify parts of the renderable structure.
+ * @param $block
+ * The block object, as loaded from the database, having the main properties:
+ * - module: The name of the module that defined the block.
+ * - delta: The unique identifier for the block within that module, as defined
+ * in hook_block_info().
+ *
+ * @see hook_block_view_MODULE_DELTA_alter()
+ * @see hook_block_view()
+ */
+function hook_block_view_alter(&$data, $block) {
+ // Remove the contextual links on all blocks that provide them.
+ if (is_array($data['content']) && isset($data['content']['#contextual_links'])) {
+ unset($data['content']['#contextual_links']);
+ }
+ // Add a theme wrapper function defined by the current module to all blocks
+ // provided by the "somemodule" module.
+ if (is_array($data['content']) && $block->module == 'somemodule') {
+ $data['content']['#theme_wrappers'][] = 'mymodule_special_block';
+ }
+}
+
+/**
+ * Perform alterations to a specific block.
+ *
+ * Modules can implement hook_block_view_MODULE_DELTA_alter() to modify a
+ * specific block, rather than implementing hook_block_view_alter().
+ *
+ * @param $data
+ * The data as returned from the hook_block_view() implementation of the
+ * module that defined the block. This could be an empty array or NULL value
+ * (if the block is empty) or an array containing:
+ * - subject: The localized title of the block.
+ * - content: Either a string or a renderable array representing the content
+ * of the block. You should check that the content is an array before trying
+ * to modify parts of the renderable structure.
+ * @param $block
+ * The block object, as loaded from the database, having the main properties:
+ * - module: The name of the module that defined the block.
+ * - delta: The unique identifier for the block within that module, as defined
+ * in hook_block_info().
+ *
+ * @see hook_block_view_alter()
+ * @see hook_block_view()
+ */
+function hook_block_view_MODULE_DELTA_alter(&$data, $block) {
+ // This code will only run for a specific block. For example, if MODULE_DELTA
+ // in the function definition above is set to "mymodule_somedelta", the code
+ // will only run on the "somedelta" block provided by the "mymodule" module.
+
+ // Change the title of the "somedelta" block provided by the "mymodule"
+ // module.
+ $data['subject'] = t('New title of the block');
+}
+
+/**
+ * Act on blocks prior to rendering.
+ *
+ * This hook allows you to add, remove or modify blocks in the block list. The
+ * block list contains the block definitions, not the rendered blocks. The
+ * blocks are rendered after the modules have had a chance to manipulate the
+ * block list.
+ *
+ * You can also set $block->content here, which will override the content of the
+ * block and prevent hook_block_view() from running.
+ *
+ * @param $blocks
+ * An array of $blocks, keyed by the block ID.
+ */
+function hook_block_list_alter(&$blocks) {
+ global $language, $theme_key;
+
+ // This example shows how to achieve language specific visibility setting for
+ // blocks.
+
+ $result = db_query('SELECT module, delta, language FROM {my_table}');
+ $block_languages = array();
+ foreach ($result as $record) {
+ $block_languages[$record->module][$record->delta][$record->language] = TRUE;
+ }
+
+ foreach ($blocks as $key => $block) {
+ // Any module using this alter should inspect the data before changing it,
+ // to ensure it is what they expect.
+ if (!isset($block->theme) || !isset($block->status) || $block->theme != $theme_key || $block->status != 1) {
+ // This block was added by a contrib module, leave it in the list.
+ continue;
+ }
+
+ if (!isset($block_languages[$block->module][$block->delta])) {
+ // No language setting for this block, leave it in the list.
+ continue;
+ }
+
+ if (!isset($block_languages[$block->module][$block->delta][$language->language])) {
+ // This block should not be displayed with the active language, remove
+ // from the list.
+ unset($blocks[$key]);
+ }
+ }
+}
+
+/**
+ * @} End of "addtogroup hooks".
+ */
diff --git a/kolab.org/www/drupal-7.26/modules/block/block.css b/kolab.org/www/drupal-7.26/modules/block/block.css
new file mode 100644
index 0000000..214c8a2
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/block/block.css
@@ -0,0 +1,36 @@
+
+#blocks tr.region-title td {
+ font-weight: bold;
+}
+#blocks tr.region-message {
+ font-weight: normal;
+ color: #999;
+}
+#blocks tr.region-populated {
+ display: none;
+}
+.block-region {
+ background-color: #ff6;
+ margin-top: 4px;
+ margin-bottom: 4px;
+ padding: 3px;
+}
+a.block-demo-backlink,
+a.block-demo-backlink:link,
+a.block-demo-backlink:visited {
+ background-color: #B4D7F0;
+ -moz-border-radius: 0 0 10px 10px;
+ -webkit-border-radius: 0 0 10px 10px;
+ border-radius: 0 0 10px 10px;
+ color: #000;
+ font-family: "Lucida Grande", Verdana, sans-serif;
+ font-size: small;
+ line-height: 20px;
+ left: 20px; /*LTR*/
+ padding: 5px 10px;
+ position: fixed;
+ z-index: 499;
+}
+a.block-demo-backlink:hover {
+ text-decoration: underline;
+}
diff --git a/kolab.org/www/drupal-7.26/modules/block/block.info b/kolab.org/www/drupal-7.26/modules/block/block.info
new file mode 100644
index 0000000..fd0fce0
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/block/block.info
@@ -0,0 +1,13 @@
+name = Block
+description = Controls the visual building blocks a page is constructed with. Blocks are boxes of content rendered into an area, or region, of a web page.
+package = Core
+version = VERSION
+core = 7.x
+files[] = block.test
+configure = admin/structure/block
+
+; Information added by Drupal.org packaging script on 2014-01-15
+version = "7.26"
+project = "drupal"
+datestamp = "1389815930"
+
diff --git a/kolab.org/www/drupal-7.26/modules/block/block.install b/kolab.org/www/drupal-7.26/modules/block/block.install
new file mode 100644
index 0000000..a78c885
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/block/block.install
@@ -0,0 +1,477 @@
+<?php
+
+/**
+ * @file
+ * Install, update and uninstall functions for the block module.
+ */
+
+/**
+ * Implements hook_schema().
+ */
+function block_schema() {
+ $schema['block'] = array(
+ 'description' => 'Stores block settings, such as region and visibility settings.',
+ 'fields' => array(
+ 'bid' => array(
+ 'type' => 'serial',
+ 'not null' => TRUE,
+ 'description' => 'Primary Key: Unique block ID.',
+ ),
+ 'module' => array(
+ 'type' => 'varchar',
+ 'length' => 64,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'description' => "The module from which the block originates; for example, 'user' for the Who's Online block, and 'block' for any custom blocks.",
+ ),
+ 'delta' => array(
+ 'type' => 'varchar',
+ 'length' => 32,
+ 'not null' => TRUE,
+ 'default' => '0',
+ 'description' => 'Unique ID for block within a module.',
+ ),
+ 'theme' => array(
+ 'type' => 'varchar',
+ 'length' => 64,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'description' => 'The theme under which the block settings apply.',
+ ),
+ 'status' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'size' => 'tiny',
+ 'description' => 'Block enabled status. (1 = enabled, 0 = disabled)',
+ ),
+ 'weight' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => 'Block weight within region.',
+ ),
+ 'region' => array(
+ 'type' => 'varchar',
+ 'length' => 64,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'description' => 'Theme region within which the block is set.',
+ ),
+ 'custom' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'size' => 'tiny',
+ 'description' => 'Flag to indicate how users may control visibility of the block. (0 = Users cannot control, 1 = On by default, but can be hidden, 2 = Hidden by default, but can be shown)',
+ ),
+ 'visibility' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'size' => 'tiny',
+ 'description' => 'Flag to indicate how to show blocks on pages. (0 = Show on all pages except listed pages, 1 = Show only on listed pages, 2 = Use custom PHP code to determine visibility)',
+ ),
+ 'pages' => array(
+ 'type' => 'text',
+ 'not null' => TRUE,
+ 'description' => 'Contents of the "Pages" block; contains either a list of paths on which to include/exclude the block or PHP code, depending on "visibility" setting.',
+ ),
+ 'title' => array(
+ 'type' => 'varchar',
+ 'length' => 64,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'description' => 'Custom title for the block. (Empty string will use block default title, <none> will remove the title, text will cause block to use specified title.)',
+ 'translatable' => TRUE,
+ ),
+ 'cache' => array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 1,
+ 'size' => 'tiny',
+ 'description' => 'Binary flag to indicate block cache mode. (-2: Custom cache, -1: Do not cache, 1: Cache per role, 2: Cache per user, 4: Cache per page, 8: Block cache global) See DRUPAL_CACHE_* constants in ../includes/common.inc for more detailed information.',
+ ),
+ ),
+ 'primary key' => array('bid'),
+ 'unique keys' => array(
+ 'tmd' => array('theme', 'module', 'delta'),
+ ),
+ 'indexes' => array(
+ 'list' => array('theme', 'status', 'region', 'weight', 'module'),
+ ),
+ );
+
+ $schema['block_role'] = array(
+ 'description' => 'Sets up access permissions for blocks based on user roles',
+ 'fields' => array(
+ 'module' => array(
+ 'type' => 'varchar',
+ 'length' => 64,
+ 'not null' => TRUE,
+ 'description' => "The block's origin module, from {block}.module.",
+ ),
+ 'delta' => array(
+ 'type' => 'varchar',
+ 'length' => 32,
+ 'not null' => TRUE,
+ 'description' => "The block's unique delta within module, from {block}.delta.",
+ ),
+ 'rid' => array(
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'description' => "The user's role ID from {users_roles}.rid.",
+ ),
+ ),
+ 'primary key' => array('module', 'delta', 'rid'),
+ 'indexes' => array(
+ 'rid' => array('rid'),
+ ),
+ );
+
+ $schema['block_custom'] = array(
+ 'description' => 'Stores contents of custom-made blocks.',
+ 'fields' => array(
+ 'bid' => array(
+ 'type' => 'serial',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'description' => "The block's {block}.bid.",
+ ),
+ 'body' => array(
+ 'type' => 'text',
+ 'not null' => FALSE,
+ 'size' => 'big',
+ 'description' => 'Block contents.',
+ 'translatable' => TRUE,
+ ),
+ 'info' => array(
+ 'type' => 'varchar',
+ 'length' => 128,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'description' => 'Block description.',
+ ),
+ 'format' => array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => FALSE,
+ 'description' => 'The {filter_format}.format of the block body.',
+ ),
+ ),
+ 'unique keys' => array(
+ 'info' => array('info'),
+ ),
+ 'primary key' => array('bid'),
+ );
+
+ $schema['cache_block'] = drupal_get_schema_unprocessed('system', 'cache');
+ $schema['cache_block']['description'] = 'Cache table for the Block module to store already built blocks, identified by module, delta, and various contexts which may change the block, such as theme, locale, and caching mode defined for the block.';
+
+ return $schema;
+}
+
+/**
+ * Implements hook_install().
+ */
+function block_install() {
+
+ // Block should go first so that other modules can alter its output
+ // during hook_page_alter(). Almost everything on the page is a block,
+ // so before block module runs, there will not be much to alter.
+ db_update('system')
+ ->fields(array('weight' => -5))
+ ->condition('name', 'block')
+ ->execute();
+}
+
+/**
+ * Implements hook_update_dependencies().
+ */
+function block_update_dependencies() {
+ // block_update_7005() needs to query the {filter_format} table to get a list
+ // of existing text formats, so it must run after filter_update_7000(), which
+ // creates that table.
+ $dependencies['block'][7005] = array(
+ 'filter' => 7000,
+ );
+
+ return $dependencies;
+}
+
+/**
+ * @addtogroup updates-6.x-to-7.x
+ * @{
+ */
+
+/**
+ * Set system.weight to a low value for block module.
+ *
+ * Block should go first so that other modules can alter its output
+ * during hook_page_alter(). Almost everything on the page is a block,
+ * so before block module runs, there will not be much to alter.
+ */
+function block_update_7000() {
+ db_update('system')
+ ->fields(array('weight' => '-5'))
+ ->condition('name', 'block')
+ ->execute();
+}
+
+/**
+ * Rename {blocks} table to {block}, {blocks_roles} to {block_role} and
+ * {boxes} to {block_custom}.
+ */
+function block_update_7002() {
+ db_drop_index('blocks', 'list');
+ db_rename_table('blocks', 'block');
+ db_rename_table('blocks_roles', 'block_role');
+ db_rename_table('boxes', 'block_custom');
+}
+
+/**
+ * Change the weight column to normal int.
+ */
+function block_update_7003() {
+ db_change_field('block', 'weight', 'weight', array(
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => 'Block weight within region.',
+ ), array(
+ 'indexes' => array(
+ 'list' => array('theme', 'status', 'region', 'weight', 'module'),
+ ),
+ ));
+}
+
+/**
+ * Add new blocks to new regions, migrate custom variables to blocks.
+ */
+function block_update_7004() {
+ // Collect a list of themes with blocks.
+ $themes_with_blocks = array();
+ $result = db_query("SELECT s.name FROM {system} s INNER JOIN {block} b ON s.name = b.theme WHERE s.type = 'theme' GROUP by s.name");
+
+ $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
+ foreach ($result as $theme) {
+ $themes_with_blocks[] = $theme->name;
+ // Add new system generated help block.
+ $insert->values(array(
+ 'module' => 'system',
+ 'delta' => 'help',
+ 'theme' => $theme->name,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'help',
+ 'pages' => '',
+ 'cache' => DRUPAL_CACHE_PER_ROLE,
+ ));
+ // Add new system generated main page content block.
+ $insert->values(array(
+ 'module' => 'system',
+ 'delta' => 'main',
+ 'theme' => $theme->name,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'content',
+ 'pages' => '',
+ 'cache' => DRUPAL_NO_CACHE,
+ ));
+ }
+ $insert->execute();
+
+ // Migrate blocks from left/right regions to first/second regions.
+ db_update('block')
+ ->fields(array('region' => 'sidebar_first'))
+ ->condition('region', 'left')
+ ->execute();
+ db_update('block')
+ ->fields(array('region' => 'sidebar_second'))
+ ->condition('region', 'right')
+ ->execute();
+
+ // Migrate contact form information.
+ $default_format = variable_get('filter_default_format', 1);
+ if ($contact_help = variable_get('contact_form_information', '')) {
+ $bid = db_insert('block_custom')
+ ->fields(array(
+ 'body' => $contact_help,
+ 'info' => 'Contact page help',
+ 'format' => $default_format,
+ ))
+ ->execute();
+
+ $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'visibility', 'pages', 'cache'));
+ foreach ($themes_with_blocks as $theme) {
+ // Add contact help block for themes, which had blocks.
+ $insert->values(array(
+ 'module' => 'block',
+ 'delta' => $bid,
+ 'theme' => $theme,
+ 'status' => 1,
+ 'weight' => 5,
+ 'region' => 'help',
+ 'visibility' => BLOCK_VISIBILITY_LISTED,
+ 'pages' => 'contact',
+ 'cache' => DRUPAL_NO_CACHE,
+ ));
+ }
+ drupal_set_message('The contact form information setting was migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to only show on the site-wide contact page. The block was set to use the default text format, which might differ from the HTML based format used before. Check the block and ensure that the output is right.');
+ }
+ $insert->execute();
+
+ // Migrate user help setting.
+ if ($user_help = variable_get('user_registration_help', '')) {
+ $bid = db_insert('block_custom')->fields(array('body' => $user_help, 'info' => 'User registration guidelines', 'format' => $default_format))->execute();
+
+ $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'visibility', 'pages', 'cache'));
+ foreach ($themes_with_blocks as $theme) {
+ // Add user registration help block for themes, which had blocks.
+ $insert->values(array(
+ 'module' => 'block',
+ 'delta' => $bid,
+ 'theme' => $theme,
+ 'status' => 1,
+ 'weight' => 5,
+ 'region' => 'help',
+ 'visibility' => BLOCK_VISIBILITY_LISTED,
+ 'pages' => 'user/register',
+ 'cache' => DRUPAL_NO_CACHE,
+ ));
+ }
+ drupal_set_message('The user registration guidelines were migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to only show on the user registration page. The block was set to use the default text format, which might differ from the HTML based format used before. Check the block and ensure that the output is right.');
+ $insert->execute();
+ }
+
+ // Migrate site mission setting.
+ if ($mission = variable_get('site_mission')) {
+ $bid = db_insert('block_custom')->fields(array('body' => $mission, 'info' => 'Site mission', 'format' => $default_format))->execute();
+
+ $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'visibility', 'pages', 'cache'));
+ foreach ($themes_with_blocks as $theme) {
+ // Add mission block for themes, which had blocks.
+ $insert->values(array(
+ 'module' => 'block',
+ 'delta' => $bid,
+ 'theme' => $theme,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'highlighted',
+ 'visibility' => BLOCK_VISIBILITY_LISTED,
+ 'pages' => '<front>',
+ 'cache' => DRUPAL_NO_CACHE,
+ ));
+ }
+ drupal_set_message('The site mission was migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to only show on the front page in the highlighted content region. The block was set to use the default text format, which might differ from the HTML based format used before. Check the block and ensure that the output is right. If your theme does not have a highlighted content region, you might need to <a href="' . url('admin/structure/block') . '">relocate the block</a>.');
+ $insert->execute();
+ // Migrate mission to RSS site description.
+ variable_set('feed_description', $mission);
+ }
+
+ // Migrate site footer message to a custom block.
+ if ($footer_message = variable_get('site_footer', '')) {
+ $bid = db_insert('block_custom')->fields(array('body' => $footer_message, 'info' => 'Footer message', 'format' => $default_format))->execute();
+
+ $insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
+ foreach ($themes_with_blocks as $theme) {
+ // Add site footer block for themes, which had blocks.
+ // Set low weight, so the block comes early (it used to be
+ // before the other blocks).
+ $insert->values(array(
+ 'module' => 'block',
+ 'delta' => $bid,
+ 'theme' => $theme,
+ 'status' => 1,
+ 'weight' => -10,
+ 'region' => 'footer',
+ 'pages' => '',
+ 'cache' => DRUPAL_NO_CACHE,
+ ));
+ }
+ drupal_set_message('The footer message was migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to appear in the footer. The block was set to use the default text format, which might differ from the HTML based format used before. Check the block and ensure that the output is right. If your theme does not have a footer region, you might need to <a href="' . url('admin/structure/block') . '">relocate the block</a>.');
+ $insert->execute();
+ }
+
+ // Remove the variables (even if they were saved empty on the admin interface),
+ // to avoid keeping clutter in the variables table.
+ variable_del('contact_form_information');
+ variable_del('user_registration_help');
+ variable_del('site_mission');
+ variable_del('site_footer');
+
+ // Rebuild theme data, so the new 'help' region is identified.
+ system_rebuild_theme_data();
+}
+
+/**
+ * Update the {block_custom}.format column.
+ */
+function block_update_7005() {
+ // For an explanation of these updates, see the code comments in
+ // user_update_7010().
+ db_change_field('block_custom', 'format', 'format', array(
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => FALSE,
+ 'description' => 'The {filter_format}.format of the block body.',
+ ));
+ db_update('block_custom')
+ ->fields(array('format' => NULL))
+ ->condition('body', '')
+ ->condition('format', 0)
+ ->execute();
+ $existing_formats = db_query("SELECT format FROM {filter_format}")->fetchCol();
+ $default_format = variable_get('filter_default_format', 1);
+ db_update('block_custom')
+ ->fields(array('format' => $default_format))
+ ->isNotNull('format')
+ ->condition('format', $existing_formats, 'NOT IN')
+ ->execute();
+}
+
+/**
+ * Recreates cache_block table.
+ *
+ * Converts fields that hold serialized variables from text to blob.
+ * Removes 'headers' column.
+ */
+function block_update_7006() {
+ $schema = system_schema_cache_7054();
+
+ db_drop_table('cache_block');
+ db_create_table('cache_block', $schema);
+}
+
+/**
+ * Change {block_custom}.format into varchar.
+ */
+function block_update_7007() {
+ db_change_field('block_custom', 'format', 'format', array(
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => FALSE,
+ 'description' => 'The {filter_format}.format of the block body.',
+ ));
+}
+
+/**
+ * @} End of "addtogroup updates-6.x-to-7.x".
+ */
+
+/**
+ * @addtogroup updates-7.x-extra
+ * @{
+ */
+
+/**
+ * Update database to match Drupal 7 schema.
+ */
+function block_update_7008() {
+ db_drop_field('block', 'throttle');
+}
+
+/**
+ * @} End of "addtogroup updates-7.x-extra".
+ */
diff --git a/kolab.org/www/drupal-7.26/modules/block/block.js b/kolab.org/www/drupal-7.26/modules/block/block.js
new file mode 100644
index 0000000..acd3f5a
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/block/block.js
@@ -0,0 +1,152 @@
+(function ($) {
+
+/**
+ * Provide the summary information for the block settings vertical tabs.
+ */
+Drupal.behaviors.blockSettingsSummary = {
+ attach: function (context) {
+ // The drupalSetSummary method required for this behavior is not available
+ // on the Blocks administration page, so we need to make sure this
+ // behavior is processed only if drupalSetSummary is defined.
+ if (typeof jQuery.fn.drupalSetSummary == 'undefined') {
+ return;
+ }
+
+ $('fieldset#edit-path', context).drupalSetSummary(function (context) {
+ if (!$('textarea[name="pages"]', context).val()) {
+ return Drupal.t('Not restricted');
+ }
+ else {
+ return Drupal.t('Restricted to certain pages');
+ }
+ });
+
+ $('fieldset#edit-node-type', context).drupalSetSummary(function (context) {
+ var vals = [];
+ $('input[type="checkbox"]:checked', context).each(function () {
+ vals.push($.trim($(this).next('label').text()));
+ });
+ if (!vals.length) {
+ vals.push(Drupal.t('Not restricted'));
+ }
+ return vals.join(', ');
+ });
+
+ $('fieldset#edit-role', context).drupalSetSummary(function (context) {
+ var vals = [];
+ $('input[type="checkbox"]:checked', context).each(function () {
+ vals.push($.trim($(this).next('label').text()));
+ });
+ if (!vals.length) {
+ vals.push(Drupal.t('Not restricted'));
+ }
+ return vals.join(', ');
+ });
+
+ $('fieldset#edit-user', context).drupalSetSummary(function (context) {
+ var $radio = $('input[name="custom"]:checked', context);
+ if ($radio.val() == 0) {
+ return Drupal.t('Not customizable');
+ }
+ else {
+ return $radio.next('label').text();
+ }
+ });
+ }
+};
+
+/**
+ * Move a block in the blocks table from one region to another via select list.
+ *
+ * This behavior is dependent on the tableDrag behavior, since it uses the
+ * objects initialized in that behavior to update the row.
+ */
+Drupal.behaviors.blockDrag = {
+ attach: function (context, settings) {
+ // tableDrag is required and we should be on the blocks admin page.
+ if (typeof Drupal.tableDrag == 'undefined' || typeof Drupal.tableDrag.blocks == 'undefined') {
+ return;
+ }
+
+ var table = $('table#blocks');
+ var tableDrag = Drupal.tableDrag.blocks; // Get the blocks tableDrag object.
+
+ // Add a handler for when a row is swapped, update empty regions.
+ tableDrag.row.prototype.onSwap = function (swappedRow) {
+ checkEmptyRegions(table, this);
+ };
+
+ // A custom message for the blocks page specifically.
+ Drupal.theme.tableDragChangedWarning = function () {
+ return '<div class="messages warning">' + Drupal.theme('tableDragChangedMarker') + ' ' + Drupal.t('The changes to these blocks will not be saved until the <em>Save blocks</em> button is clicked.') + '</div>';
+ };
+
+ // Add a handler so when a row is dropped, update fields dropped into new regions.
+ tableDrag.onDrop = function () {
+ dragObject = this;
+ // Use "region-message" row instead of "region" row because
+ // "region-{region_name}-message" is less prone to regexp match errors.
+ var regionRow = $(dragObject.rowObject.element).prevAll('tr.region-message').get(0);
+ var regionName = regionRow.className.replace(/([^ ]+[ ]+)*region-([^ ]+)-message([ ]+[^ ]+)*/, '$2');
+ var regionField = $('select.block-region-select', dragObject.rowObject.element);
+ // Check whether the newly picked region is available for this block.
+ if ($('option[value=' + regionName + ']', regionField).length == 0) {
+ // If not, alert the user and keep the block in its old region setting.
+ alert(Drupal.t('The block cannot be placed in this region.'));
+ // Simulate that there was a selected element change, so the row is put
+ // back to from where the user tried to drag it.
+ regionField.change();
+ }
+ else if ($(dragObject.rowObject.element).prev('tr').is('.region-message')) {
+ var weightField = $('select.block-weight', dragObject.rowObject.element);
+ var oldRegionName = weightField[0].className.replace(/([^ ]+[ ]+)*block-weight-([^ ]+)([ ]+[^ ]+)*/, '$2');
+
+ if (!regionField.is('.block-region-' + regionName)) {
+ regionField.removeClass('block-region-' + oldRegionName).addClass('block-region-' + regionName);
+ weightField.removeClass('block-weight-' + oldRegionName).addClass('block-weight-' + regionName);
+ regionField.val(regionName);
+ }
+ }
+ };
+
+ // Add the behavior to each region select list.
+ $('select.block-region-select', context).once('block-region-select', function () {
+ $(this).change(function (event) {
+ // Make our new row and select field.
+ var row = $(this).closest('tr');
+ var select = $(this);
+ tableDrag.rowObject = new tableDrag.row(row);
+
+ // Find the correct region and insert the row as the last in the region.
+ table.find('.region-' + select[0].value + '-message').nextUntil('.region-message').last().before(row);
+
+ // Modify empty regions with added or removed fields.
+ checkEmptyRegions(table, row);
+ // Remove focus from selectbox.
+ select.get(0).blur();
+ });
+ });
+
+ var checkEmptyRegions = function (table, rowObject) {
+ $('tr.region-message', table).each(function () {
+ // If the dragged row is in this region, but above the message row, swap it down one space.
+ if ($(this).prev('tr').get(0) == rowObject.element) {
+ // Prevent a recursion problem when using the keyboard to move rows up.
+ if ((rowObject.method != 'keyboard' || rowObject.direction == 'down')) {
+ rowObject.swap('after', this);
+ }
+ }
+ // This region has become empty.
+ if ($(this).next('tr').is(':not(.draggable)') || $(this).next('tr').length == 0) {
+ $(this).removeClass('region-populated').addClass('region-empty');
+ }
+ // This region has become populated.
+ else if ($(this).is('.region-empty')) {
+ $(this).removeClass('region-empty').addClass('region-populated');
+ }
+ });
+ };
+ }
+};
+
+})(jQuery);
diff --git a/kolab.org/www/drupal-7.26/modules/block/block.module b/kolab.org/www/drupal-7.26/modules/block/block.module
new file mode 100644
index 0000000..2977ca8
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/block/block.module
@@ -0,0 +1,1092 @@
+<?php
+
+/**
+ * @file
+ * Controls the visual building blocks a page is constructed with.
+ */
+
+/**
+ * Denotes that a block is not enabled in any region and should not be shown.
+ */
+define('BLOCK_REGION_NONE', -1);
+
+/**
+ * Users cannot control whether or not they see this block.
+ */
+define('BLOCK_CUSTOM_FIXED', 0);
+
+/**
+ * Shows this block by default, but lets individual users hide it.
+ */
+define('BLOCK_CUSTOM_ENABLED', 1);
+
+/**
+ * Hides this block by default but lets individual users show it.
+ */
+define('BLOCK_CUSTOM_DISABLED', 2);
+
+/**
+ * Shows this block on every page except the listed pages.
+ */
+define('BLOCK_VISIBILITY_NOTLISTED', 0);
+
+/**
+ * Shows this block on only the listed pages.
+ */
+define('BLOCK_VISIBILITY_LISTED', 1);
+
+/**
+ * Shows this block if the associated PHP code returns TRUE.
+ */
+define('BLOCK_VISIBILITY_PHP', 2);
+
+/**
+ * Implements hook_help().
+ */
+function block_help($path, $arg) {
+ switch ($path) {
+ case 'admin/help#block':
+ $output = '';
+ $output .= '<h3>' . t('About') . '</h3>';
+ $output .= '<p>' . t('The Block module allows you to create boxes of content, which are rendered into an area, or region, of one or more pages of a website. The core Seven administration theme, for example, implements the regions "Content", "Help", "Dashboard main", and "Dashboard sidebar", and a block may appear in any one of these regions. The <a href="@blocks">Blocks administration page</a> provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions. For more information, see the online handbook entry for <a href="@block">Block module</a>.', array('@block' => 'http://drupal.org/documentation/modules/block/', '@blocks' => url('admin/structure/block'))) . '</p>';
+ $output .= '<h3>' . t('Uses') . '</h3>';
+ $output .= '<dl>';
+ $output .= '<dt>' . t('Positioning content') . '</dt>';
+ $output .= '<dd>' . t('When working with blocks, remember that all themes do <em>not</em> implement the same regions, or display regions in the same way. Blocks are positioned on a per-theme basis. Users with the <em>Administer blocks</em> permission can disable blocks. Disabled blocks are listed on the <a href="@blocks">Blocks administration page</a>, but are not displayed in any region.', array('@block' => 'http://drupal.org/documentation/modules/block/', '@blocks' => url('admin/structure/block'))) . '</dd>';
+ $output .= '<dt>' . t('Controlling visibility') . '</dt>';
+ $output .= '<dd>' . t('Blocks can be configured to be visible only on certain pages, only to users of certain roles, or only on pages displaying certain <a href="@content-type">content types</a>. Administrators can also allow specific blocks to be enabled or disabled by users when they edit their <a href="@user">My account</a> page. Some dynamic blocks, such as those generated by modules, will be displayed only on certain pages.', array('@content-type' => url('admin/structure/types'), '@user' => url('user'))) . '</dd>';
+ $output .= '<dt>' . t('Creating custom blocks') . '</dt>';
+ $output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can <a href="@block-add">add custom blocks</a>, which are then listed on the <a href="@blocks">Blocks administration page</a>. Once created, custom blocks behave just like default and module-generated blocks.', array('@blocks' => url('admin/structure/block'), '@block-add' => url('admin/structure/block/add'))) . '</dd>';
+ $output .= '</dl>';
+ return $output;
+ case 'admin/structure/block/add':
+ return '<p>' . t('Use this page to create a new custom block.') . '</p>';
+ }
+ if ($arg[0] == 'admin' && $arg[1] == 'structure' && $arg['2'] == 'block' && (empty($arg[3]) || $arg[3] == 'list')) {
+ $demo_theme = !empty($arg[4]) ? $arg[4] : variable_get('theme_default', 'bartik');
+ $themes = list_themes();
+ $output = '<p>' . t('This page provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions. Since not all themes implement the same regions, or display regions in the same way, blocks are positioned on a per-theme basis. Remember that your changes will not be saved until you click the <em>Save blocks</em> button at the bottom of the page. Click the <em>configure</em> link next to each block to configure its specific title and visibility settings.') . '</p>';
+ $output .= '<p>' . l(t('Demonstrate block regions (@theme)', array('@theme' => $themes[$demo_theme]->info['name'])), 'admin/structure/block/demo/' . $demo_theme) . '</p>';
+ return $output;
+ }
+}
+
+/**
+ * Implements hook_theme().
+ */
+function block_theme() {
+ return array(
+ 'block' => array(
+ 'render element' => 'elements',
+ 'template' => 'block',
+ ),
+ 'block_admin_display_form' => array(
+ 'template' => 'block-admin-display-form',
+ 'file' => 'block.admin.inc',
+ 'render element' => 'form',
+ ),
+ );
+}
+
+/**
+ * Implements hook_permission().
+ */
+function block_permission() {
+ return array(
+ 'administer blocks' => array(
+ 'title' => t('Administer blocks'),
+ ),
+ );
+}
+
+/**
+ * Implements hook_menu().
+ */
+function block_menu() {
+ $default_theme = variable_get('theme_default', 'bartik');
+ $items['admin/structure/block'] = array(
+ 'title' => 'Blocks',
+ 'description' => 'Configure what block content appears in your site\'s sidebars and other regions.',
+ 'page callback' => 'block_admin_display',
+ 'page arguments' => array($default_theme),
+ 'access arguments' => array('administer blocks'),
+ 'file' => 'block.admin.inc',
+ );
+ $items['admin/structure/block/manage/%/%'] = array(
+ 'title' => 'Configure block',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('block_admin_configure', 4, 5),
+ 'access arguments' => array('administer blocks'),
+ 'file' => 'block.admin.inc',
+ );
+ $items['admin/structure/block/manage/%/%/configure'] = array(
+ 'title' => 'Configure block',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'context' => MENU_CONTEXT_INLINE,
+ );
+ $items['admin/structure/block/manage/%/%/delete'] = array(
+ 'title' => 'Delete block',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('block_custom_block_delete', 4, 5),
+ 'access arguments' => array('administer blocks'),
+ 'type' => MENU_LOCAL_TASK,
+ 'context' => MENU_CONTEXT_NONE,
+ 'file' => 'block.admin.inc',
+ );
+ $items['admin/structure/block/add'] = array(
+ 'title' => 'Add block',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('block_add_block_form'),
+ 'access arguments' => array('administer blocks'),
+ 'type' => MENU_LOCAL_ACTION,
+ 'file' => 'block.admin.inc',
+ );
+ foreach (list_themes() as $key => $theme) {
+ $items['admin/structure/block/list/' . $key] = array(
+ 'title' => check_plain($theme->info['name']),
+ 'page arguments' => array($key),
+ 'type' => $key == $default_theme ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
+ 'weight' => $key == $default_theme ? -10 : 0,
+ 'access callback' => '_block_themes_access',
+ 'access arguments' => array($theme),
+ 'file' => 'block.admin.inc',
+ );
+ if ($key != $default_theme) {
+ $items['admin/structure/block/list/' . $key . '/add'] = array(
+ 'title' => 'Add block',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('block_add_block_form'),
+ 'access arguments' => array('administer blocks'),
+ 'type' => MENU_LOCAL_ACTION,
+ 'file' => 'block.admin.inc',
+ );
+ }
+ $items['admin/structure/block/demo/' . $key] = array(
+ 'title' => check_plain($theme->info['name']),
+ 'page callback' => 'block_admin_demo',
+ 'page arguments' => array($key),
+ 'type' => MENU_CALLBACK,
+ 'access callback' => '_block_themes_access',
+ 'access arguments' => array($theme),
+ 'theme callback' => '_block_custom_theme',
+ 'theme arguments' => array($key),
+ 'file' => 'block.admin.inc',
+ );
+ }
+ return $items;
+}
+
+/**
+ * Menu item access callback - only admin or enabled themes can be accessed.
+ */
+function _block_themes_access($theme) {
+ return user_access('administer blocks') && drupal_theme_access($theme);
+}
+
+/**
+ * Theme callback for the block configuration pages.
+ *
+ * @param $theme
+ * The theme whose blocks are being configured. If not set, the default theme
+ * is assumed.
+ * @return
+ * The theme that should be used for the block configuration page, or NULL
+ * to indicate that the default theme should be used.
+ */
+function _block_custom_theme($theme = NULL) {
+ // We return exactly what was passed in, to guarantee that the page will
+ // always be displayed using the theme whose blocks are being configured.
+ return $theme;
+}
+
+/**
+ * Implements hook_block_info().
+ */
+function block_block_info() {
+ $blocks = array();
+
+ $result = db_query('SELECT bid, info FROM {block_custom} ORDER BY info');
+ foreach ($result as $block) {
+ $blocks[$block->bid]['info'] = $block->info;
+ // Not worth caching.
+ $blocks[$block->bid]['cache'] = DRUPAL_NO_CACHE;
+ }
+ return $blocks;
+}
+
+/**
+ * Implements hook_block_configure().
+ */
+function block_block_configure($delta = 0) {
+ if ($delta) {
+ $custom_block = block_custom_block_get($delta);
+ }
+ else {
+ $custom_block = array();
+ }
+ return block_custom_block_form($custom_block);
+}
+
+/**
+ * Implements hook_block_save().
+ */
+function block_block_save($delta = 0, $edit = array()) {
+ block_custom_block_save($edit, $delta);
+}
+
+/**
+ * Implements hook_block_view().
+ *
+ * Generates the administrator-defined blocks for display.
+ */
+function block_block_view($delta = '') {
+ $block = db_query('SELECT body, format FROM {block_custom} WHERE bid = :bid', array(':bid' => $delta))->fetchObject();
+ $data['subject'] = NULL;
+ $data['content'] = check_markup($block->body, $block->format, '', TRUE);
+ return $data;
+}
+
+/**
+ * Implements hook_page_build().
+ *
+ * Renders blocks into their regions.
+ */
+function block_page_build(&$page) {
+ global $theme;
+
+ // The theme system might not yet be initialized. We need $theme.
+ drupal_theme_initialize();
+
+ // Fetch a list of regions for the current theme.
+ $all_regions = system_region_list($theme);
+
+ $item = menu_get_item();
+ if ($item['path'] != 'admin/structure/block/demo/' . $theme) {
+ // Load all region content assigned via blocks.
+ foreach (array_keys($all_regions) as $region) {
+ // Assign blocks to region.
+ if ($blocks = block_get_blocks_by_region($region)) {
+ $page[$region] = $blocks;
+ }
+ }
+ // Once we've finished attaching all blocks to the page, clear the static
+ // cache to allow modules to alter the block list differently in different
+ // contexts. For example, any code that triggers hook_page_build() more
+ // than once in the same page request may need to alter the block list
+ // differently each time, so that only certain parts of the page are
+ // actually built. We do not clear the cache any earlier than this, though,
+ // because it is used each time block_get_blocks_by_region() gets called
+ // above.
+ drupal_static_reset('block_list');
+ }
+ else {
+ // Append region description if we are rendering the regions demo page.
+ $item = menu_get_item();
+ if ($item['path'] == 'admin/structure/block/demo/' . $theme) {
+ $visible_regions = array_keys(system_region_list($theme, REGIONS_VISIBLE));
+ foreach ($visible_regions as $region) {
+ $description = '<div class="block-region">' . $all_regions[$region] . '</div>';
+ $page[$region]['block_description'] = array(
+ '#markup' => $description,
+ '#weight' => 15,
+ );
+ }
+ $page['page_top']['backlink'] = array(
+ '#type' => 'link',
+ '#title' => t('Exit block region demonstration'),
+ '#href' => 'admin/structure/block' . (variable_get('theme_default', 'bartik') == $theme ? '' : '/list/' . $theme),
+ // Add the "overlay-restore" class to indicate this link should restore
+ // the context in which the region demonstration page was opened.
+ '#options' => array('attributes' => array('class' => array('block-demo-backlink', 'overlay-restore'))),
+ '#weight' => -10,
+ );
+ }
+ }
+}
+
+/**
+ * Gets a renderable array of a region containing all enabled blocks.
+ *
+ * @param $region
+ * The requested region.
+ *
+ * @return
+ * A renderable array of a region containing all enabled blocks.
+ */
+function block_get_blocks_by_region($region) {
+ $build = array();
+ if ($list = block_list($region)) {
+ $build = _block_get_renderable_array($list);
+ }
+ return $build;
+}
+
+/**
+ * Gets an array of blocks suitable for drupal_render().
+ *
+ * @param $list
+ * A list of blocks such as that returned by block_list().
+ *
+ * @return
+ * A renderable array.
+ */
+function _block_get_renderable_array($list = array()) {
+ $weight = 0;
+ $build = array();
+ foreach ($list as $key => $block) {
+ $build[$key] = $block->content;
+ unset($block->content);
+
+ // Add contextual links for this block; skip the main content block, since
+ // contextual links are basically output as tabs/local tasks already. Also
+ // skip the help block, since we assume that most users do not need or want
+ // to perform contextual actions on the help block, and the links needlessly
+ // draw attention on it.
+ if ($key != 'system_main' && $key != 'system_help') {
+ $build[$key]['#contextual_links']['block'] = array('admin/structure/block/manage', array($block->module, $block->delta));
+ }
+
+ $build[$key] += array(
+ '#block' => $block,
+ '#weight' => ++$weight,
+ );
+ $build[$key]['#theme_wrappers'][] ='block';
+ }
+ $build['#sorted'] = TRUE;
+ return $build;
+}
+
+/**
+ * Updates the 'block' DB table with the blocks currently exported by modules.
+ *
+ * @param $theme
+ * The theme to rehash blocks for. If not provided, defaults to the currently
+ * used theme.
+ *
+ * @return
+ * Blocks currently exported by modules.
+ */
+function _block_rehash($theme = NULL) {
+ global $theme_key;
+
+ drupal_theme_initialize();
+ if (!isset($theme)) {
+ // If theme is not specifically set, rehash for the current theme.
+ $theme = $theme_key;
+ }
+ $regions = system_region_list($theme);
+
+ // These are the blocks the function will return.
+ $blocks = array();
+ // These are the blocks defined by code and modified by the database.
+ $current_blocks = array();
+ // These are {block}.bid values to be kept.
+ $bids = array();
+ $or = db_or();
+ // Gather the blocks defined by modules.
+ foreach (module_implements('block_info') as $module) {
+ $module_blocks = module_invoke($module, 'block_info');
+ foreach ($module_blocks as $delta => $block) {
+ // Compile a condition to retrieve this block from the database.
+ $condition = db_and()
+ ->condition('module', $module)
+ ->condition('delta', $delta);
+ $or->condition($condition);
+ // Add identifiers.
+ $block['module'] = $module;
+ $block['delta'] = $delta;
+ $block['theme'] = $theme;
+ $current_blocks[$module][$delta] = $block;
+ }
+ }
+ // Save the blocks defined in code for alter context.
+ $code_blocks = $current_blocks;
+ $database_blocks = db_select('block', 'b', array('fetch' => PDO::FETCH_ASSOC))
+ ->fields('b')
+ ->condition($or)
+ ->condition('theme', $theme)
+ ->execute();
+ $original_database_blocks = array();
+ foreach ($database_blocks as $block) {
+ $module = $block['module'];
+ $delta = $block['delta'];
+ $original_database_blocks[$module][$delta] = $block;
+ // The cache mode can only by set from hook_block_info(), so that has
+ // precedence over the database's value.
+ if (isset($current_blocks[$module][$delta]['cache'])) {
+ $block['cache'] = $current_blocks[$module][$delta]['cache'];
+ }
+ // Preserve info which is not in the database.
+ $block['info'] = $current_blocks[$module][$delta]['info'];
+ // Blocks stored in the database override the blocks defined in code.
+ $current_blocks[$module][$delta] = $block;
+ // Preserve this block.
+ $bids[$block['bid']] = $block['bid'];
+ }
+ drupal_alter('block_info', $current_blocks, $theme, $code_blocks);
+ foreach ($current_blocks as $module => $module_blocks) {
+ foreach ($module_blocks as $delta => $block) {
+ if (!isset($block['pages'])) {
+ // {block}.pages is type 'text', so it cannot have a
+ // default value, and not null, so we need to provide
+ // value if the module did not.
+ $block['pages'] = '';
+ }
+ // Make sure weight is set.
+ if (!isset($block['weight'])) {
+ $block['weight'] = 0;
+ }
+ if (!empty($block['region']) && $block['region'] != BLOCK_REGION_NONE && !isset($regions[$block['region']]) && $block['status'] == 1) {
+ drupal_set_message(t('The block %info was assigned to the invalid region %region and has been disabled.', array('%info' => $block['info'], '%region' => $block['region'])), 'warning');
+ // Disabled modules are moved into the BLOCK_REGION_NONE later so no
+ // need to move the block to another region.
+ $block['status'] = 0;
+ }
+ // Set region to none if not enabled and make sure status is set.
+ if (empty($block['status'])) {
+ $block['status'] = 0;
+ $block['region'] = BLOCK_REGION_NONE;
+ }
+ // There is no point saving disabled blocks. Still, we need to save them
+ // because the 'title' attribute is saved to the {blocks} table.
+ if (isset($block['bid'])) {
+ // If the block has a bid property, it comes from the database and
+ // the record needs to be updated, so set the primary key to 'bid'
+ // before passing to drupal_write_record().
+ $primary_keys = array('bid');
+ // Remove a block from the list of blocks to keep if it became disabled.
+ unset($bids[$block['bid']]);
+ }
+ else {
+ $primary_keys = array();
+ }
+ // If the block is new or differs from the original database block, save
+ // it. To determine whether there was a change it is enough to examine
+ // the values for the keys in the original database record as that
+ // contained every database field.
+ if (!$primary_keys || array_diff_assoc($original_database_blocks[$module][$delta], $block)) {
+ drupal_write_record('block', $block, $primary_keys);
+ // Make it possible to test this.
+ $block['saved'] = TRUE;
+ }
+ // Add to the list of blocks we return.
+ $blocks[] = $block;
+ }
+ }
+ if ($bids) {
+ // Remove disabled that are no longer defined by the code from the
+ // database.
+ db_delete('block')
+ ->condition('bid', $bids, 'NOT IN')
+ ->condition('theme', $theme)
+ ->execute();
+ }
+ return $blocks;
+}
+
+/**
+ * Returns information from database about a user-created (custom) block.
+ *
+ * @param $bid
+ * ID of the block to get information for.
+ *
+ * @return
+ * Associative array of information stored in the database for this block.
+ * Array keys:
+ * - bid: Block ID.
+ * - info: Block description.
+ * - body: Block contents.
+ * - format: Filter ID of the filter format for the body.
+ */
+function block_custom_block_get($bid) {
+ return db_query("SELECT * FROM {block_custom} WHERE bid = :bid", array(':bid' => $bid))->fetchAssoc();
+}
+
+/**
+ * Form constructor for the custom block form.
+ *
+ * @param $edit
+ * (optional) An associative array of information retrieved by
+ * block_custom_get_block() if an existing block is being edited, or an empty
+ * array otherwise. Defaults to array().
+ *
+ * @ingroup forms
+ */
+function block_custom_block_form($edit = array()) {
+ $edit += array(
+ 'info' => '',
+ 'body' => '',
+ );
+ $form['info'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Block description'),
+ '#default_value' => $edit['info'],
+ '#maxlength' => 64,
+ '#description' => t('A brief description of your block. Used on the <a href="@overview">Blocks administration page</a>.', array('@overview' => url('admin/structure/block'))),
+ '#required' => TRUE,
+ '#weight' => -18,
+ );
+ $form['body_field']['#weight'] = -17;
+ $form['body_field']['body'] = array(
+ '#type' => 'text_format',
+ '#title' => t('Block body'),
+ '#default_value' => $edit['body'],
+ '#format' => isset($edit['format']) ? $edit['format'] : NULL,
+ '#rows' => 15,
+ '#description' => t('The content of the block as shown to the user.'),
+ '#required' => TRUE,
+ '#weight' => -17,
+ );
+
+ return $form;
+}
+
+/**
+ * Saves a user-created block in the database.
+ *
+ * @param $edit
+ * Associative array of fields to save. Array keys:
+ * - info: Block description.
+ * - body: Associative array of body value and format. Array keys:
+ * - value: Block contents.
+ * - format: Filter ID of the filter format for the body.
+ * @param $delta
+ * Block ID of the block to save.
+ *
+ * @return
+ * Always returns TRUE.
+ */
+function block_custom_block_save($edit, $delta) {
+ db_update('block_custom')
+ ->fields(array(
+ 'body' => $edit['body']['value'],
+ 'info' => $edit['info'],
+ 'format' => $edit['body']['format'],
+ ))
+ ->condition('bid', $delta)
+ ->execute();
+ return TRUE;
+}
+
+/**
+ * Implements hook_form_FORM_ID_alter() for user_profile_form().
+ */
+function block_form_user_profile_form_alter(&$form, &$form_state) {
+ if ($form['#user_category'] == 'account') {
+ $account = $form['#user'];
+ $rids = array_keys($account->roles);
+ $result = db_query("SELECT DISTINCT b.* FROM {block} b LEFT JOIN {block_role} r ON b.module = r.module AND b.delta = r.delta WHERE b.status = 1 AND b.custom <> 0 AND (r.rid IN (:rids) OR r.rid IS NULL) ORDER BY b.weight, b.module", array(':rids' => $rids));
+
+ $blocks = array();
+ foreach ($result as $block) {
+ $data = module_invoke($block->module, 'block_info');
+ if ($data[$block->delta]['info']) {
+ $blocks[$block->module][$block->delta] = array(
+ '#type' => 'checkbox',
+ '#title' => check_plain($data[$block->delta]['info']),
+ '#default_value' => isset($account->data['block'][$block->module][$block->delta]) ? $account->data['block'][$block->module][$block->delta] : ($block->custom == 1),
+ );
+ }
+ }
+ // Only display the fieldset if there are any personalizable blocks.
+ if ($blocks) {
+ $form['block'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Personalize blocks'),
+ '#description' => t('Blocks consist of content or information that complements the main content of the page. Enable or disable optional blocks using the checkboxes below.'),
+ '#weight' => 3,
+ '#collapsible' => TRUE,
+ '#tree' => TRUE,
+ );
+ $form['block'] += $blocks;
+ }
+ }
+}
+
+/**
+ * Implements hook_user_presave().
+ */
+function block_user_presave(&$edit, $account, $category) {
+ if (isset($edit['block'])) {
+ $edit['data']['block'] = $edit['block'];
+ }
+}
+
+/**
+ * Initializes blocks for enabled themes.
+ *
+ * @param $theme_list
+ * An array of theme names.
+ */
+function block_themes_enabled($theme_list) {
+ foreach ($theme_list as $theme) {
+ block_theme_initialize($theme);
+ }
+}
+
+/**
+ * Assigns an initial, default set of blocks for a theme.
+ *
+ * This function is called the first time a new theme is enabled. The new theme
+ * gets a copy of the default theme's blocks, with the difference that if a
+ * particular region isn't available in the new theme, the block is assigned
+ * to the new theme's default region.
+ *
+ * @param $theme
+ * The name of a theme.
+ */
+function block_theme_initialize($theme) {
+ // Initialize theme's blocks if none already registered.
+ $has_blocks = (bool) db_query_range('SELECT 1 FROM {block} WHERE theme = :theme', 0, 1, array(':theme' => $theme))->fetchField();
+ if (!$has_blocks) {
+ $default_theme = variable_get('theme_default', 'bartik');
+ // Apply only to new theme's visible regions.
+ $regions = system_region_list($theme, REGIONS_VISIBLE);
+ $result = db_query("SELECT * FROM {block} WHERE theme = :theme", array(':theme' => $default_theme), array('fetch' => PDO::FETCH_ASSOC));
+ foreach ($result as $block) {
+ // If the region isn't supported by the theme, assign the block to the theme's default region.
+ if ($block['status'] && !isset($regions[$block['region']])) {
+ $block['region'] = system_default_region($theme);
+ }
+ $block['theme'] = $theme;
+ unset($block['bid']);
+ drupal_write_record('block', $block);
+ }
+ }
+}
+
+/**
+ * Returns all blocks in the specified region for the current user.
+ *
+ * @param $region
+ * The name of a region.
+ *
+ * @return
+ * An array of block objects, indexed with the module name and block delta
+ * concatenated with an underscore, thus: MODULE_DELTA. If you are displaying
+ * your blocks in one or two sidebars, you may check whether this array is
+ * empty to see how many columns are going to be displayed.
+ *
+ * @todo
+ * Now that the block table has a primary key, we should use that as the
+ * array key instead of MODULE_DELTA.
+ */
+function block_list($region) {
+ $blocks = &drupal_static(__FUNCTION__);
+
+ if (!isset($blocks)) {
+ $blocks = _block_load_blocks();
+ }
+
+ // Create an empty array if there are no entries.
+ if (!isset($blocks[$region])) {
+ $blocks[$region] = array();
+ }
+ else {
+ $blocks[$region] = _block_render_blocks($blocks[$region]);
+ }
+
+ return $blocks[$region];
+}
+
+/**
+ * Loads a block object from the database.
+ *
+ * @param $module
+ * Name of the module that implements the block to load.
+ * @param $delta
+ * Unique ID of the block within the context of $module. Pass NULL to return
+ * an empty block object for $module.
+ *
+ * @return
+ * A block object.
+ */
+function block_load($module, $delta) {
+ if (isset($delta)) {
+ $block = db_query('SELECT * FROM {block} WHERE module = :module AND delta = :delta', array(':module' => $module, ':delta' => $delta))->fetchObject();
+ }
+
+ // If the block does not exist in the database yet return a stub block
+ // object.
+ if (empty($block)) {
+ $block = new stdClass();
+ $block->module = $module;
+ $block->delta = $delta;
+ }
+
+ return $block;
+}
+
+/**
+ * Loads blocks' information from the database.
+ *
+ * @return
+ * An array of blocks grouped by region.
+ */
+function _block_load_blocks() {
+ global $theme_key;
+
+ $query = db_select('block', 'b');
+ $result = $query
+ ->fields('b')
+ ->condition('b.theme', $theme_key)
+ ->condition('b.status', 1)
+ ->orderBy('b.region')
+ ->orderBy('b.weight')
+ ->orderBy('b.module')
+ ->addTag('block_load')
+ ->addTag('translatable')
+ ->execute();
+
+ $block_info = $result->fetchAllAssoc('bid');
+ // Allow modules to modify the block list.
+ drupal_alter('block_list', $block_info);
+
+ $blocks = array();
+ foreach ($block_info as $block) {
+ $blocks[$block->region]["{$block->module}_{$block->delta}"] = $block;
+ }
+ return $blocks;
+}
+
+/**
+ * Implements hook_block_list_alter().
+ *
+ * Checks the page, user role, and user-specific visibility settings.
+ * Removes the block if the visibility conditions are not met.
+ */
+function block_block_list_alter(&$blocks) {
+ global $user, $theme_key;
+
+ // Build an array of roles for each block.
+ $block_roles = array();
+ $result = db_query('SELECT module, delta, rid FROM {block_role}');
+ foreach ($result as $record) {
+ $block_roles[$record->module][$record->delta][] = $record->rid;
+ }
+
+ foreach ($blocks as $key => $block) {
+ if (!isset($block->theme) || !isset($block->status) || $block->theme != $theme_key || $block->status != 1) {
+ // This block was added by a contrib module, leave it in the list.
+ continue;
+ }
+
+ // If a block has no roles associated, it is displayed for every role.
+ // For blocks with roles associated, if none of the user's roles matches
+ // the settings from this block, remove it from the block list.
+ if (isset($block_roles[$block->module][$block->delta]) && !array_intersect($block_roles[$block->module][$block->delta], array_keys($user->roles))) {
+ // No match.
+ unset($blocks[$key]);
+ continue;
+ }
+
+ // Use the user's block visibility setting, if necessary.
+ if ($block->custom != BLOCK_CUSTOM_FIXED) {
+ if ($user->uid && isset($user->data['block'][$block->module][$block->delta])) {
+ $enabled = $user->data['block'][$block->module][$block->delta];
+ }
+ else {
+ $enabled = ($block->custom == BLOCK_CUSTOM_ENABLED);
+ }
+ }
+ else {
+ $enabled = TRUE;
+ }
+
+ // Limited visibility blocks must list at least one page.
+ if ($block->visibility == BLOCK_VISIBILITY_LISTED && empty($block->pages)) {
+ $enabled = FALSE;
+ }
+
+ if (!$enabled) {
+ unset($blocks[$key]);
+ continue;
+ }
+
+ // Match path if necessary.
+ if ($block->pages) {
+ // Convert path to lowercase. This allows comparison of the same path
+ // with different case. Ex: /Page, /page, /PAGE.
+ $pages = drupal_strtolower($block->pages);
+ if ($block->visibility < BLOCK_VISIBILITY_PHP) {
+ // Convert the Drupal path to lowercase
+ $path = drupal_strtolower(drupal_get_path_alias($_GET['q']));
+ // Compare the lowercase internal and lowercase path alias (if any).
+ $page_match = drupal_match_path($path, $pages);
+ if ($path != $_GET['q']) {
+ $page_match = $page_match || drupal_match_path($_GET['q'], $pages);
+ }
+ // When $block->visibility has a value of 0 (BLOCK_VISIBILITY_NOTLISTED),
+ // the block is displayed on all pages except those listed in $block->pages.
+ // When set to 1 (BLOCK_VISIBILITY_LISTED), it is displayed only on those
+ // pages listed in $block->pages.
+ $page_match = !($block->visibility xor $page_match);
+ }
+ elseif (module_exists('php')) {
+ $page_match = php_eval($block->pages);
+ }
+ else {
+ $page_match = FALSE;
+ }
+ }
+ else {
+ $page_match = TRUE;
+ }
+ if (!$page_match) {
+ unset($blocks[$key]);
+ }
+ }
+}
+
+/**
+ * Render the content and subject for a set of blocks.
+ *
+ * @param $region_blocks
+ * An array of block objects such as returned for one region by _block_load_blocks().
+ *
+ * @return
+ * An array of visible blocks as expected by drupal_render().
+ */
+function _block_render_blocks($region_blocks) {
+ // Block caching is not compatible with node access modules. We also
+ // preserve the submission of forms in blocks, by fetching from cache only
+ // if the request method is 'GET' (or 'HEAD').
+ $cacheable = !count(module_implements('node_grants')) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD');
+
+ // Proceed to loop over all blocks in order to compute their respective cache
+ // identifiers; this allows us to do one single cache_get_multiple() call
+ // instead of doing one cache_get() call per block.
+ $cached_blocks = array();
+ $cids = array();
+
+ if ($cacheable) {
+ foreach ($region_blocks as $key => $block) {
+ if (!isset($block->content)) {
+ if (($cid = _block_get_cache_id($block))) {
+ $cids[$key] = $cid;
+ }
+ }
+ }
+
+ if ($cids) {
+ // We cannot pass $cids in directly because cache_get_multiple() will
+ // modify it, and we need to use it later on in this function.
+ $cid_values = array_values($cids);
+ $cached_blocks = cache_get_multiple($cid_values, 'cache_block');
+ }
+ }
+
+ foreach ($region_blocks as $key => $block) {
+ // Render the block content if it has not been created already.
+ if (!isset($block->content)) {
+ // Erase the block from the static array - we'll put it back if it has
+ // content.
+ unset($region_blocks[$key]);
+
+ $cid = empty($cids[$key]) ? NULL : $cids[$key];
+
+ // Try fetching the block from the previously loaded cache entries.
+ if (isset($cached_blocks[$cid])) {
+ $array = $cached_blocks[$cid]->data;
+ }
+ else {
+ $array = module_invoke($block->module, 'block_view', $block->delta);
+
+ // Valid PHP function names cannot contain hyphens.
+ $delta = str_replace('-', '_', $block->delta);
+ // Allow modules to modify the block before it is viewed, via either
+ // hook_block_view_alter() or hook_block_view_MODULE_DELTA_alter().
+ drupal_alter(array('block_view', "block_view_{$block->module}_{$delta}"), $array, $block);
+
+ if (isset($cid)) {
+ cache_set($cid, $array, 'cache_block', CACHE_TEMPORARY);
+ }
+ }
+
+ if (isset($array) && is_array($array)) {
+ foreach ($array as $k => $v) {
+ $block->$k = $v;
+ }
+ }
+ if (isset($block->content) && $block->content) {
+ // Normalize to the drupal_render() structure.
+ if (is_string($block->content)) {
+ $block->content = array('#markup' => $block->content);
+ }
+ // Override default block title if a custom display title is present.
+ if ($block->title) {
+ // Check plain here to allow module generated titles to keep any
+ // markup.
+ $block->subject = $block->title == '<none>' ? '' : check_plain($block->title);
+ }
+ if (!isset($block->subject)) {
+ $block->subject = '';
+ }
+ $region_blocks["{$block->module}_{$block->delta}"] = $block;
+ }
+ }
+ }
+ return $region_blocks;
+}
+
+/**
+ * Assemble the cache_id to use for a given block.
+ *
+ * The cache_id string reflects the viewing context for the current block
+ * instance, obtained by concatenating the relevant context information
+ * (user, page, ...) according to the block's cache settings (BLOCK_CACHE_*
+ * constants). Two block instances can use the same cached content when
+ * they share the same cache_id.
+ *
+ * Theme and language contexts are automatically differentiated.
+ *
+ * @param $block
+ * @return
+ * The string used as cache_id for the block.
+ */
+function _block_get_cache_id($block) {
+ global $user;
+
+ // User 1 being out of the regular 'roles define permissions' schema,
+ // it brings too many chances of having unwanted output get in the cache
+ // and later be served to other users. We therefore exclude user 1 from
+ // block caching.
+ if (variable_get('block_cache', FALSE) && !in_array($block->cache, array(DRUPAL_NO_CACHE, DRUPAL_CACHE_CUSTOM)) && $user->uid != 1) {
+ // Start with common sub-patterns: block identification, theme, language.
+ $cid_parts[] = $block->module;
+ $cid_parts[] = $block->delta;
+ $cid_parts = array_merge($cid_parts, drupal_render_cid_parts($block->cache));
+
+ return implode(':', $cid_parts);
+ }
+}
+
+/**
+ * Implements hook_flush_caches().
+ */
+function block_flush_caches() {
+ // Rehash blocks for active themes. We don't use list_themes() here,
+ // because if MAINTENANCE_MODE is defined it skips reading the database,
+ // and we can't tell which themes are active.
+ $themes = db_query("SELECT name FROM {system} WHERE type = 'theme' AND status = 1");
+ foreach ($themes as $theme) {
+ _block_rehash($theme->name);
+ }
+
+ return array('cache_block');
+}
+
+/**
+ * Processes variables for block.tpl.php.
+ *
+ * Prepares the values passed to the theme_block function to be passed
+ * into a pluggable template engine. Uses block properties to generate a
+ * series of template file suggestions. If none are found, the default
+ * block.tpl.php is used.
+ *
+ * Most themes utilize their own copy of block.tpl.php. The default is located
+ * inside "modules/block/block.tpl.php". Look in there for the full list of
+ * variables.
+ *
+ * The $variables array contains the following arguments:
+ * - $block
+ *
+ * @see block.tpl.php
+ */
+function template_preprocess_block(&$variables) {
+ $block_counter = &drupal_static(__FUNCTION__, array());
+ $variables['block'] = $variables['elements']['#block'];
+ // All blocks get an independent counter for each region.
+ if (!isset($block_counter[$variables['block']->region])) {
+ $block_counter[$variables['block']->region] = 1;
+ }
+ // Same with zebra striping.
+ $variables['block_zebra'] = ($block_counter[$variables['block']->region] % 2) ? 'odd' : 'even';
+ $variables['block_id'] = $block_counter[$variables['block']->region]++;
+
+ // Create the $content variable that templates expect.
+ $variables['content'] = $variables['elements']['#children'];
+
+ $variables['classes_array'][] = drupal_html_class('block-' . $variables['block']->module);
+
+ $variables['theme_hook_suggestions'][] = 'block__' . $variables['block']->region;
+ $variables['theme_hook_suggestions'][] = 'block__' . $variables['block']->module;
+ // Hyphens (-) and underscores (_) play a special role in theme suggestions.
+ // Theme suggestions should only contain underscores, because within
+ // drupal_find_theme_templates(), underscores are converted to hyphens to
+ // match template file names, and then converted back to underscores to match
+ // pre-processing and other function names. So if your theme suggestion
+ // contains a hyphen, it will end up as an underscore after this conversion,
+ // and your function names won't be recognized. So, we need to convert
+ // hyphens to underscores in block deltas for the theme suggestions.
+ $variables['theme_hook_suggestions'][] = 'block__' . $variables['block']->module . '__' . strtr($variables['block']->delta, '-', '_');
+
+ // Create a valid HTML ID and make sure it is unique.
+ $variables['block_html_id'] = drupal_html_id('block-' . $variables['block']->module . '-' . $variables['block']->delta);
+}
+
+/**
+ * Implements hook_user_role_delete().
+ *
+ * Removes deleted role from blocks that use it.
+ */
+function block_user_role_delete($role) {
+ db_delete('block_role')
+ ->condition('rid', $role->rid)
+ ->execute();
+}
+
+/**
+ * Implements hook_menu_delete().
+ */
+function block_menu_delete($menu) {
+ db_delete('block')
+ ->condition('module', 'menu')
+ ->condition('delta', $menu['menu_name'])
+ ->execute();
+ db_delete('block_role')
+ ->condition('module', 'menu')
+ ->condition('delta', $menu['menu_name'])
+ ->execute();
+}
+
+/**
+ * Implements hook_form_FORM_ID_alter().
+ */
+function block_form_system_performance_settings_alter(&$form, &$form_state) {
+ $disabled = count(module_implements('node_grants'));
+ $form['caching']['block_cache'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Cache blocks'),
+ '#default_value' => variable_get('block_cache', FALSE),
+ '#disabled' => $disabled,
+ '#description' => $disabled ? t('Block caching is inactive because you have enabled modules defining content access restrictions.') : NULL,
+ '#weight' => -1,
+ );
+}
+
+/**
+ * Implements hook_admin_paths().
+ */
+function block_admin_paths() {
+ $paths = array(
+ // Exclude the block demonstration page from admin (overlay) treatment.
+ // This allows us to present this page in its true form, full page.
+ 'admin/structure/block/demo/*' => FALSE,
+ );
+ return $paths;
+}
+
+/**
+ * Implements hook_modules_uninstalled().
+ *
+ * Cleans up {block} and {block_role} tables from modules' blocks.
+ */
+function block_modules_uninstalled($modules) {
+ db_delete('block')
+ ->condition('module', $modules, 'IN')
+ ->execute();
+ db_delete('block_role')
+ ->condition('module', $modules, 'IN')
+ ->execute();
+}
diff --git a/kolab.org/www/drupal-7.26/modules/block/block.test b/kolab.org/www/drupal-7.26/modules/block/block.test
new file mode 100644
index 0000000..99c81dc
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/block/block.test
@@ -0,0 +1,979 @@
+<?php
+
+/**
+ * @file
+ * Tests for block.module.
+ */
+
+class BlockTestCase extends DrupalWebTestCase {
+ protected $regions;
+ protected $admin_user;
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Block functionality',
+ 'description' => 'Add, edit and delete custom block. Configure and move a module-defined block.',
+ 'group' => 'Block',
+ );
+ }
+
+ function setUp() {
+ parent::setUp();
+
+ // Create and log in an administrative user having access to the Full HTML
+ // text format.
+ $full_html_format = filter_format_load('full_html');
+ $this->admin_user = $this->drupalCreateUser(array(
+ 'administer blocks',
+ filter_permission_name($full_html_format),
+ 'access administration pages',
+ ));
+ $this->drupalLogin($this->admin_user);
+
+ // Define the existing regions
+ $this->regions = array();
+ $this->regions[] = 'header';
+ $this->regions[] = 'sidebar_first';
+ $this->regions[] = 'content';
+ $this->regions[] = 'sidebar_second';
+ $this->regions[] = 'footer';
+ }
+
+ /**
+ * Test creating custom block, moving it to a specific region and then deleting it.
+ */
+ function testCustomBlock() {
+ // Confirm that the add block link appears on block overview pages.
+ $this->drupalGet('admin/structure/block');
+ $this->assertRaw(l('Add block', 'admin/structure/block/add'), 'Add block link is present on block overview page for default theme.');
+ $this->drupalGet('admin/structure/block/list/seven');
+ $this->assertRaw(l('Add block', 'admin/structure/block/list/seven/add'), 'Add block link is present on block overview page for non-default theme.');
+
+ // Confirm that hidden regions are not shown as options for block placement
+ // when adding a new block.
+ theme_enable(array('stark'));
+ $themes = list_themes();
+ $this->drupalGet('admin/structure/block/add');
+ foreach ($themes as $key => $theme) {
+ if ($theme->status) {
+ foreach ($theme->info['regions_hidden'] as $hidden_region) {
+ $elements = $this->xpath('//select[@id=:id]//option[@value=:value]', array(':id' => 'edit-regions-' . $key, ':value' => $hidden_region));
+ $this->assertFalse(isset($elements[0]), format_string('The hidden region @region is not available for @theme.', array('@region' => $hidden_region, '@theme' => $key)));
+ }
+ }
+ }
+
+ // Add a new custom block by filling out the input form on the admin/structure/block/add page.
+ $custom_block = array();
+ $custom_block['info'] = $this->randomName(8);
+ $custom_block['title'] = $this->randomName(8);
+ $custom_block['body[value]'] = $this->randomName(32);
+ $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
+
+ // Confirm that the custom block has been created, and then query the created bid.
+ $this->assertText(t('The block has been created.'), 'Custom block successfully created.');
+ $bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(':info' => $custom_block['info']))->fetchField();
+
+ // Check to see if the custom block was created by checking that it's in the database.
+ $this->assertNotNull($bid, 'Custom block found in database');
+
+ // Check that block_block_view() returns the correct title and content.
+ $data = block_block_view($bid);
+ $format = db_query("SELECT format FROM {block_custom} WHERE bid = :bid", array(':bid' => $bid))->fetchField();
+ $this->assertTrue(array_key_exists('subject', $data) && empty($data['subject']), 'block_block_view() provides an empty block subject, since custom blocks do not have default titles.');
+ $this->assertEqual(check_markup($custom_block['body[value]'], $format), $data['content'], 'block_block_view() provides correct block content.');
+
+ // Check whether the block can be moved to all available regions.
+ $custom_block['module'] = 'block';
+ $custom_block['delta'] = $bid;
+ foreach ($this->regions as $region) {
+ $this->moveBlockToRegion($custom_block, $region);
+ }
+
+ // Verify presence of configure and delete links for custom block.
+ $this->drupalGet('admin/structure/block');
+ $this->assertLinkByHref('admin/structure/block/manage/block/' . $bid . '/configure', 0, 'Custom block configure link found.');
+ $this->assertLinkByHref('admin/structure/block/manage/block/' . $bid . '/delete', 0, 'Custom block delete link found.');
+
+ // Set visibility only for authenticated users, to verify delete functionality.
+ $edit = array();
+ $edit['roles[' . DRUPAL_AUTHENTICATED_RID . ']'] = TRUE;
+ $this->drupalPost('admin/structure/block/manage/block/' . $bid . '/configure', $edit, t('Save block'));
+
+ // Delete the created custom block & verify that it's been deleted and no longer appearing on the page.
+ $this->clickLink(t('delete'));
+ $this->drupalPost('admin/structure/block/manage/block/' . $bid . '/delete', array(), t('Delete'));
+ $this->assertRaw(t('The block %title has been removed.', array('%title' => $custom_block['info'])), 'Custom block successfully deleted.');
+ $this->assertNoText(t($custom_block['title']), 'Custom block no longer appears on page.');
+ $count = db_query("SELECT 1 FROM {block_role} WHERE module = :module AND delta = :delta", array(':module' => $custom_block['module'], ':delta' => $custom_block['delta']))->fetchField();
+ $this->assertFalse($count, 'Table block_role being cleaned.');
+ }
+
+ /**
+ * Test creating custom block using Full HTML.
+ */
+ function testCustomBlockFormat() {
+ // Add a new custom block by filling out the input form on the admin/structure/block/add page.
+ $custom_block = array();
+ $custom_block['info'] = $this->randomName(8);
+ $custom_block['title'] = $this->randomName(8);
+ $custom_block['body[value]'] = '<h1>Full HTML</h1>';
+ $full_html_format = filter_format_load('full_html');
+ $custom_block['body[format]'] = $full_html_format->format;
+ $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
+
+ // Set the created custom block to a specific region.
+ $bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(':info' => $custom_block['info']))->fetchField();
+ $edit = array();
+ $edit['blocks[block_' . $bid . '][region]'] = $this->regions[1];
+ $this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
+
+ // Confirm that the custom block is being displayed using configured text format.
+ $this->drupalGet('node');
+ $this->assertRaw('<h1>Full HTML</h1>', 'Custom block successfully being displayed using Full HTML.');
+
+ // Confirm that a user without access to Full HTML can not see the body field,
+ // but can still submit the form without errors.
+ $block_admin = $this->drupalCreateUser(array('administer blocks'));
+ $this->drupalLogin($block_admin);
+ $this->drupalGet('admin/structure/block/manage/block/' . $bid . '/configure');
+ $this->assertFieldByXPath("//textarea[@name='body[value]' and @disabled='disabled']", t('This field has been disabled because you do not have sufficient permissions to edit it.'), 'Body field contains denied message');
+ $this->drupalPost('admin/structure/block/manage/block/' . $bid . '/configure', array(), t('Save block'));
+ $this->assertNoText(t('Ensure that each block description is unique.'));
+
+ // Confirm that the custom block is still being displayed using configured text format.
+ $this->drupalGet('node');
+ $this->assertRaw('<h1>Full HTML</h1>', 'Custom block successfully being displayed using Full HTML.');
+ }
+
+ /**
+ * Test block visibility.
+ */
+ function testBlockVisibility() {
+ $block = array();
+
+ // Create a random title for the block
+ $title = $this->randomName(8);
+
+ // Create the custom block
+ $custom_block = array();
+ $custom_block['info'] = $this->randomName(8);
+ $custom_block['title'] = $title;
+ $custom_block['body[value]'] = $this->randomName(32);
+ $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
+
+ $bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(':info' => $custom_block['info']))->fetchField();
+ $block['module'] = 'block';
+ $block['delta'] = $bid;
+ $block['title'] = $title;
+
+ // Set the block to be hidden on any user path, and to be shown only to
+ // authenticated users.
+ $edit = array();
+ $edit['pages'] = 'user*';
+ $edit['roles[' . DRUPAL_AUTHENTICATED_RID . ']'] = TRUE;
+ $this->drupalPost('admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure', $edit, t('Save block'));
+
+ // Move block to the first sidebar.
+ $this->moveBlockToRegion($block, $this->regions[1]);
+
+ $this->drupalGet('');
+ $this->assertText($title, 'Block was displayed on the front page.');
+
+ $this->drupalGet('user');
+ $this->assertNoText($title, 'Block was not displayed according to block visibility rules.');
+
+ $this->drupalGet('USER/' . $this->admin_user->uid);
+ $this->assertNoText($title, 'Block was not displayed according to block visibility rules regardless of path case.');
+
+ // Confirm that the block is not displayed to anonymous users.
+ $this->drupalLogout();
+ $this->drupalGet('');
+ $this->assertNoText($title, 'Block was not displayed to anonymous users.');
+ }
+
+ /**
+ * Test block visibility when using "pages" restriction but leaving
+ * "pages" textarea empty
+ */
+ function testBlockVisibilityListedEmpty() {
+ $block = array();
+
+ // Create a random title for the block
+ $title = $this->randomName(8);
+
+ // Create the custom block
+ $custom_block = array();
+ $custom_block['info'] = $this->randomName(8);
+ $custom_block['title'] = $title;
+ $custom_block['body[value]'] = $this->randomName(32);
+ $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
+
+ $bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(':info' => $custom_block['info']))->fetchField();
+ $block['module'] = 'block';
+ $block['delta'] = $bid;
+ $block['title'] = $title;
+
+ // Move block to the first sidebar.
+ $this->moveBlockToRegion($block, $this->regions[1]);
+
+ // Set the block to be hidden on any user path, and to be shown only to
+ // authenticated users.
+ $edit = array();
+ $edit['visibility'] = BLOCK_VISIBILITY_LISTED;
+ $this->drupalPost('admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure', $edit, t('Save block'));
+
+ $this->drupalGet('');
+ $this->assertNoText($title, 'Block was not displayed according to block visibility rules.');
+
+ $this->drupalGet('user');
+ $this->assertNoText($title, 'Block was not displayed according to block visibility rules regardless of path case.');
+
+ // Confirm that the block is not displayed to anonymous users.
+ $this->drupalLogout();
+ $this->drupalGet('');
+ $this->assertNoText($title, 'Block was not displayed to anonymous users.');
+ }
+
+ /**
+ * Test user customization of block visibility.
+ */
+ function testBlockVisibilityPerUser() {
+ $block = array();
+
+ // Create a random title for the block.
+ $title = $this->randomName(8);
+
+ // Create our custom test block.
+ $custom_block = array();
+ $custom_block['info'] = $this->randomName(8);
+ $custom_block['title'] = $title;
+ $custom_block['body[value]'] = $this->randomName(32);
+ $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
+
+ $bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(':info' => $custom_block['info']))->fetchField();
+ $block['module'] = 'block';
+ $block['delta'] = $bid;
+ $block['title'] = $title;
+
+ // Move block to the first sidebar.
+ $this->moveBlockToRegion($block, $this->regions[1]);
+
+ // Set the block to be customizable per user, visible by default.
+ $edit = array();
+ $edit['custom'] = BLOCK_CUSTOM_ENABLED;
+ $this->drupalPost('admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure', $edit, t('Save block'));
+
+ // Disable block visibility for the admin user.
+ $edit = array();
+ $edit['block[' . $block['module'] . '][' . $block['delta'] . ']'] = FALSE;
+ $this->drupalPost('user/' . $this->admin_user->uid . '/edit', $edit, t('Save'));
+
+ $this->drupalGet('');
+ $this->assertNoText($block['title'], 'Block was not displayed according to per user block visibility setting.');
+
+ // Set the block to be customizable per user, hidden by default.
+ $edit = array();
+ $edit['custom'] = BLOCK_CUSTOM_DISABLED;
+ $this->drupalPost('admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure', $edit, t('Save block'));
+
+ // Enable block visibility for the admin user.
+ $edit = array();
+ $edit['block[' . $block['module'] . '][' . $block['delta'] . ']'] = TRUE;
+ $this->drupalPost('user/' . $this->admin_user->uid . '/edit', $edit, t('Save'));
+
+ $this->drupalGet('');
+ $this->assertText($block['title'], 'Block was displayed according to per user block visibility setting.');
+ }
+
+ /**
+ * Test configuring and moving a module-define block to specific regions.
+ */
+ function testBlock() {
+ // Select the Navigation block to be configured and moved.
+ $block = array();
+ $block['module'] = 'system';
+ $block['delta'] = 'management';
+ $block['title'] = $this->randomName(8);
+
+ // Set block title to confirm that interface works and override any custom titles.
+ $this->drupalPost('admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure', array('title' => $block['title']), t('Save block'));
+ $this->assertText(t('The block configuration has been saved.'), 'Block title set.');
+ $bid = db_query("SELECT bid FROM {block} WHERE module = :module AND delta = :delta", array(
+ ':module' => $block['module'],
+ ':delta' => $block['delta'],
+ ))->fetchField();
+
+ // Check to see if the block was created by checking that it's in the database.
+ $this->assertNotNull($bid, 'Block found in database');
+
+ // Check whether the block can be moved to all available regions.
+ foreach ($this->regions as $region) {
+ $this->moveBlockToRegion($block, $region);
+ }
+
+ // Set the block to the disabled region.
+ $edit = array();
+ $edit['blocks[' . $block['module'] . '_' . $block['delta'] . '][region]'] = '-1';
+ $this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
+
+ // Confirm that the block was moved to the proper region.
+ $this->assertText(t('The block settings have been updated.'), 'Block successfully move to disabled region.');
+ $this->assertNoText(t($block['title']), 'Block no longer appears on page.');
+
+ // Confirm that the region's xpath is not available.
+ $xpath = $this->buildXPathQuery('//div[@id=:id]/*', array(':id' => 'block-block-' . $bid));
+ $this->assertNoFieldByXPath($xpath, FALSE, 'Custom block found in no regions.');
+
+ // For convenience of developers, put the navigation block back.
+ $edit = array();
+ $edit['blocks[' . $block['module'] . '_' . $block['delta'] . '][region]'] = $this->regions[1];
+ $this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
+ $this->assertText(t('The block settings have been updated.'), 'Block successfully move to first sidebar region.');
+
+ $this->drupalPost('admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure', array('title' => 'Navigation'), t('Save block'));
+ $this->assertText(t('The block configuration has been saved.'), 'Block title set.');
+ }
+
+ function moveBlockToRegion($block, $region) {
+ // Set the created block to a specific region.
+ $edit = array();
+ $edit['blocks[' . $block['module'] . '_' . $block['delta'] . '][region]'] = $region;
+ $this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
+
+ // Confirm that the block was moved to the proper region.
+ $this->assertText(t('The block settings have been updated.'), format_string('Block successfully moved to %region_name region.', array( '%region_name' => $region)));
+
+ // Confirm that the block is being displayed.
+ $this->drupalGet('node');
+ $this->assertText(t($block['title']), 'Block successfully being displayed on the page.');
+
+ // Confirm that the custom block was found at the proper region.
+ $xpath = $this->buildXPathQuery('//div[@class=:region-class]//div[@id=:block-id]/*', array(
+ ':region-class' => 'region region-' . str_replace('_', '-', $region),
+ ':block-id' => 'block-' . $block['module'] . '-' . $block['delta'],
+ ));
+ $this->assertFieldByXPath($xpath, NULL, format_string('Custom block found in %region_name region.', array('%region_name' => $region)));
+ }
+
+ /**
+ * Test _block_rehash().
+ */
+ function testBlockRehash() {
+ module_enable(array('block_test'));
+ $this->assertTrue(module_exists('block_test'), 'Test block module enabled.');
+
+ // Our new block should be inserted in the database when we visit the
+ // block management page.
+ $this->drupalGet('admin/structure/block');
+ // Our test block's caching should default to DRUPAL_CACHE_PER_ROLE.
+ $current_caching = db_query("SELECT cache FROM {block} WHERE module = 'block_test' AND delta = 'test_cache'")->fetchField();
+ $this->assertEqual($current_caching, DRUPAL_CACHE_PER_ROLE, 'Test block cache mode defaults to DRUPAL_CACHE_PER_ROLE.');
+
+ // Disable caching for this block.
+ variable_set('block_test_caching', DRUPAL_NO_CACHE);
+ // Flushing all caches should call _block_rehash().
+ drupal_flush_all_caches();
+ // Verify that the database is updated with the new caching mode.
+ $current_caching = db_query("SELECT cache FROM {block} WHERE module = 'block_test' AND delta = 'test_cache'")->fetchField();
+ $this->assertEqual($current_caching, DRUPAL_NO_CACHE, "Test block's database entry updated to DRUPAL_NO_CACHE.");
+ }
+}
+
+class NonDefaultBlockAdmin extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Non default theme admin',
+ 'description' => 'Check the administer page for non default theme.',
+ 'group' => 'Block',
+ );
+ }
+
+ /**
+ * Test non-default theme admin.
+ */
+ function testNonDefaultBlockAdmin() {
+ $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes'));
+ $this->drupalLogin($admin_user);
+ theme_enable(array('stark'));
+ $this->drupalGet('admin/structure/block/list/stark');
+ }
+}
+
+/**
+ * Test blocks correctly initialized when picking a new default theme.
+ */
+class NewDefaultThemeBlocks extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'New default theme blocks',
+ 'description' => 'Checks that the new default theme gets blocks.',
+ 'group' => 'Block',
+ );
+ }
+
+ /**
+ * Check the enabled Bartik blocks are correctly copied over.
+ */
+ function testNewDefaultThemeBlocks() {
+ // Create administrative user.
+ $admin_user = $this->drupalCreateUser(array('administer themes'));
+ $this->drupalLogin($admin_user);
+
+ // Ensure no other theme's blocks are in the block table yet.
+ $themes = array();
+ $themes['default'] = variable_get('theme_default', 'bartik');
+ if ($admin_theme = variable_get('admin_theme')) {
+ $themes['admin'] = $admin_theme;
+ }
+ $count = db_query_range('SELECT 1 FROM {block} WHERE theme NOT IN (:themes)', 0, 1, array(':themes' => $themes))->fetchField();
+ $this->assertFalse($count, 'Only the default theme and the admin theme have blocks.');
+
+ // Populate list of all blocks for matching against new theme.
+ $blocks = array();
+ $result = db_query('SELECT * FROM {block} WHERE theme = :theme', array(':theme' => $themes['default']));
+ foreach ($result as $block) {
+ // $block->theme and $block->bid will not match, so remove them.
+ unset($block->theme, $block->bid);
+ $blocks[$block->module][$block->delta] = $block;
+ }
+
+ // Turn on the Stark theme and ensure that it contains all of the blocks
+ // the default theme had.
+ theme_enable(array('stark'));
+ variable_set('theme_default', 'stark');
+ $result = db_query('SELECT * FROM {block} WHERE theme = :theme', array(':theme' => 'stark'));
+ foreach ($result as $block) {
+ unset($block->theme, $block->bid);
+ $this->assertEqual($blocks[$block->module][$block->delta], $block, format_string('Block %name matched', array('%name' => $block->module . '-' . $block->delta)));
+ }
+ }
+}
+
+/**
+ * Test the block system with admin themes.
+ */
+class BlockAdminThemeTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Admin theme block admin accessibility',
+ 'description' => "Check whether the block administer page for a disabled theme accessible if and only if it's the admin theme.",
+ 'group' => 'Block',
+ );
+ }
+
+ /**
+ * Check for the accessibility of the admin theme on the block admin page.
+ */
+ function testAdminTheme() {
+ // Create administrative user.
+ $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes'));
+ $this->drupalLogin($admin_user);
+
+ // Ensure that access to block admin page is denied when theme is disabled.
+ $this->drupalGet('admin/structure/block/list/stark');
+ $this->assertResponse(403, 'The block admin page for a disabled theme can not be accessed');
+
+ // Enable admin theme and confirm that tab is accessible.
+ $edit['admin_theme'] = 'stark';
+ $this->drupalPost('admin/appearance', $edit, t('Save configuration'));
+ $this->drupalGet('admin/structure/block/list/stark');
+ $this->assertResponse(200, 'The block admin page for the admin theme can be accessed');
+ }
+}
+
+/**
+ * Test block caching.
+ */
+class BlockCacheTestCase extends DrupalWebTestCase {
+ protected $admin_user;
+ protected $normal_user;
+ protected $normal_user_alt;
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Block caching',
+ 'description' => 'Test block caching.',
+ 'group' => 'Block',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('block_test');
+
+ // Create an admin user, log in and enable test blocks.
+ $this->admin_user = $this->drupalCreateUser(array('administer blocks', 'access administration pages'));
+ $this->drupalLogin($this->admin_user);
+
+ // Create additional users to test caching modes.
+ $this->normal_user = $this->drupalCreateUser();
+ $this->normal_user_alt = $this->drupalCreateUser();
+ // Sync the roles, since drupalCreateUser() creates separate roles for
+ // the same permission sets.
+ user_save($this->normal_user_alt, array('roles' => $this->normal_user->roles));
+ $this->normal_user_alt->roles = $this->normal_user->roles;
+
+ // Enable block caching.
+ variable_set('block_cache', TRUE);
+
+ // Enable our test block.
+ $edit['blocks[block_test_test_cache][region]'] = 'sidebar_first';
+ $this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
+ }
+
+ /**
+ * Test DRUPAL_CACHE_PER_ROLE.
+ */
+ function testCachePerRole() {
+ $this->setCacheMode(DRUPAL_CACHE_PER_ROLE);
+
+ // Enable our test block. Set some content for it to display.
+ $current_content = $this->randomName();
+ variable_set('block_test_content', $current_content);
+ $this->drupalLogin($this->normal_user);
+ $this->drupalGet('');
+ $this->assertText($current_content, 'Block content displays.');
+
+ // Change the content, but the cached copy should still be served.
+ $old_content = $current_content;
+ $current_content = $this->randomName();
+ variable_set('block_test_content', $current_content);
+ $this->drupalGet('');
+ $this->assertText($old_content, 'Block is served from the cache.');
+
+ // Clear the cache and verify that the stale data is no longer there.
+ cache_clear_all();
+ $this->drupalGet('');
+ $this->assertNoText($old_content, 'Block cache clear removes stale cache data.');
+ $this->assertText($current_content, 'Fresh block content is displayed after clearing the cache.');
+
+ // Test whether the cached data is served for the correct users.
+ $old_content = $current_content;
+ $current_content = $this->randomName();
+ variable_set('block_test_content', $current_content);
+ $this->drupalLogout();
+ $this->drupalGet('');
+ $this->assertNoText($old_content, 'Anonymous user does not see content cached per-role for normal user.');
+
+ $this->drupalLogin($this->normal_user_alt);
+ $this->drupalGet('');
+ $this->assertText($old_content, 'User with the same roles sees per-role cached content.');
+
+ $this->drupalLogin($this->admin_user);
+ $this->drupalGet('');
+ $this->assertNoText($old_content, 'Admin user does not see content cached per-role for normal user.');
+
+ $this->drupalLogin($this->normal_user);
+ $this->drupalGet('');
+ $this->assertText($old_content, 'Block is served from the per-role cache.');
+ }
+
+ /**
+ * Test DRUPAL_CACHE_GLOBAL.
+ */
+ function testCacheGlobal() {
+ $this->setCacheMode(DRUPAL_CACHE_GLOBAL);
+ $current_content = $this->randomName();
+ variable_set('block_test_content', $current_content);
+
+ $this->drupalGet('');
+ $this->assertText($current_content, 'Block content displays.');
+
+ $old_content = $current_content;
+ $current_content = $this->randomName();
+ variable_set('block_test_content', $current_content);
+
+ $this->drupalLogout();
+ $this->drupalGet('user');
+ $this->assertText($old_content, 'Block content served from global cache.');
+ }
+
+ /**
+ * Test DRUPAL_NO_CACHE.
+ */
+ function testNoCache() {
+ $this->setCacheMode(DRUPAL_NO_CACHE);
+ $current_content = $this->randomName();
+ variable_set('block_test_content', $current_content);
+
+ // If DRUPAL_NO_CACHE has no effect, the next request would be cached.
+ $this->drupalGet('');
+ $this->assertText($current_content, 'Block content displays.');
+
+ // A cached copy should not be served.
+ $current_content = $this->randomName();
+ variable_set('block_test_content', $current_content);
+ $this->drupalGet('');
+ $this->assertText($current_content, 'DRUPAL_NO_CACHE prevents blocks from being cached.');
+ }
+
+ /**
+ * Test DRUPAL_CACHE_PER_USER.
+ */
+ function testCachePerUser() {
+ $this->setCacheMode(DRUPAL_CACHE_PER_USER);
+ $current_content = $this->randomName();
+ variable_set('block_test_content', $current_content);
+ $this->drupalLogin($this->normal_user);
+
+ $this->drupalGet('');
+ $this->assertText($current_content, 'Block content displays.');
+
+ $old_content = $current_content;
+ $current_content = $this->randomName();
+ variable_set('block_test_content', $current_content);
+
+ $this->drupalGet('');
+ $this->assertText($old_content, 'Block is served from per-user cache.');
+
+ $this->drupalLogin($this->normal_user_alt);
+ $this->drupalGet('');
+ $this->assertText($current_content, 'Per-user block cache is not served for other users.');
+
+ $this->drupalLogin($this->normal_user);
+ $this->drupalGet('');
+ $this->assertText($old_content, 'Per-user block cache is persistent.');
+ }
+
+ /**
+ * Test DRUPAL_CACHE_PER_PAGE.
+ */
+ function testCachePerPage() {
+ $this->setCacheMode(DRUPAL_CACHE_PER_PAGE);
+ $current_content = $this->randomName();
+ variable_set('block_test_content', $current_content);
+
+ $this->drupalGet('node');
+ $this->assertText($current_content, 'Block content displays on the node page.');
+
+ $old_content = $current_content;
+ $current_content = $this->randomName();
+ variable_set('block_test_content', $current_content);
+
+ $this->drupalGet('user');
+ $this->assertNoText($old_content, 'Block content cached for the node page does not show up for the user page.');
+ $this->drupalGet('node');
+ $this->assertText($old_content, 'Block content cached for the node page.');
+ }
+
+ /**
+ * Private helper method to set the test block's cache mode.
+ */
+ private function setCacheMode($cache_mode) {
+ db_update('block')
+ ->fields(array('cache' => $cache_mode))
+ ->condition('module', 'block_test')
+ ->execute();
+
+ $current_mode = db_query("SELECT cache FROM {block} WHERE module = 'block_test'")->fetchField();
+ if ($current_mode != $cache_mode) {
+ $this->fail(t('Unable to set cache mode to %mode. Current mode: %current_mode', array('%mode' => $cache_mode, '%current_mode' => $current_mode)));
+ }
+ }
+}
+
+/**
+ * Test block HTML id validity.
+ */
+class BlockHTMLIdTestCase extends DrupalWebTestCase {
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Block HTML id',
+ 'description' => 'Test block HTML id validity.',
+ 'group' => 'Block',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('block_test');
+
+ // Create an admin user, log in and enable test blocks.
+ $this->admin_user = $this->drupalCreateUser(array('administer blocks', 'access administration pages'));
+ $this->drupalLogin($this->admin_user);
+
+ // Enable our test block.
+ $edit['blocks[block_test_test_html_id][region]'] = 'sidebar_first';
+ $this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
+
+ // Make sure the block has some content so it will appear
+ $current_content = $this->randomName();
+ variable_set('block_test_content', $current_content);
+ }
+
+ /**
+ * Test valid HTML id.
+ */
+ function testHTMLId() {
+ $this->drupalGet('');
+ $this->assertRaw('block-block-test-test-html-id', 'HTML id for test block is valid.');
+ }
+}
+
+
+/**
+ * Unit tests for template_preprocess_block().
+ */
+class BlockTemplateSuggestionsUnitTest extends DrupalUnitTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Block template suggestions',
+ 'description' => 'Test the template_preprocess_block() function.',
+ 'group' => 'Block',
+ );
+ }
+
+ /**
+ * Test if template_preprocess_block() handles the suggestions right.
+ */
+ function testBlockThemeHookSuggestions() {
+ // Define block delta with underscore to be preprocessed
+ $block1 = new stdClass();
+ $block1->module = 'block';
+ $block1->delta = 'underscore_test';
+ $block1->region = 'footer';
+ $variables1 = array();
+ $variables1['elements']['#block'] = $block1;
+ $variables1['elements']['#children'] = '';
+ template_preprocess_block($variables1);
+ $this->assertEqual($variables1['theme_hook_suggestions'], array('block__footer', 'block__block', 'block__block__underscore_test'), 'Found expected block suggestions for delta with underscore');
+
+ // Define block delta with hyphens to be preprocessed. Hyphens should be
+ // replaced with underscores.
+ $block2 = new stdClass();
+ $block2->module = 'block';
+ $block2->delta = 'hyphen-test';
+ $block2->region = 'footer';
+ $variables2 = array();
+ $variables2['elements']['#block'] = $block2;
+ $variables2['elements']['#children'] = '';
+ template_preprocess_block($variables2);
+ $this->assertEqual($variables2['theme_hook_suggestions'], array('block__footer', 'block__block', 'block__block__hyphen_test'), 'Hyphens (-) in block delta were replaced by underscore (_)');
+ }
+}
+
+/**
+ * Tests for hook_block_view_MODULE_DELTA_alter().
+ */
+class BlockViewModuleDeltaAlterWebTest extends DrupalWebTestCase {
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Block view module delta alter',
+ 'description' => 'Test the hook_block_view_MODULE_DELTA_alter() hook.',
+ 'group' => 'Block',
+ );
+ }
+
+ public function setUp() {
+ parent::setUp(array('block_test'));
+ }
+
+ /**
+ * Tests that the alter hook is called, even if the delta contains a hyphen.
+ */
+ public function testBlockViewModuleDeltaAlter() {
+ $block = new stdClass;
+ $block->module = 'block_test';
+ $block->delta = 'test_underscore';
+ $block->title = '';
+ $render_array = _block_render_blocks(array('region' => $block));
+ $render = array_pop($render_array);
+ $test_underscore = $render->content['#markup'];
+ $this->assertEqual($test_underscore, 'hook_block_view_MODULE_DELTA_alter', 'Found expected altered block content for delta with underscore');
+
+ $block = new stdClass;
+ $block->module = 'block_test';
+ $block->delta = 'test-hyphen';
+ $block->title = '';
+ $render_array = _block_render_blocks(array('region' => $block));
+ $render = array_pop($render_array);
+ $test_hyphen = $render->content['#markup'];
+ $this->assertEqual($test_hyphen, 'hook_block_view_MODULE_DELTA_alter', 'Hyphens (-) in block delta were replaced by underscore (_)');
+ }
+
+}
+
+/**
+ * Tests that hidden regions do not inherit blocks when a theme is enabled.
+ */
+class BlockHiddenRegionTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Blocks not in hidden region',
+ 'description' => 'Checks that a newly enabled theme does not inherit blocks to its hidden regions.',
+ 'group' => 'Block',
+ );
+ }
+
+ function setUp() {
+ parent::setUp(array('block_test'));
+ }
+
+ /**
+ * Tests that hidden regions do not inherit blocks when a theme is enabled.
+ */
+ function testBlockNotInHiddenRegion() {
+ // Create administrative user.
+ $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes', 'search content'));
+ $this->drupalLogin($admin_user);
+
+ // Enable "block_test_theme" and set it as the default theme.
+ $theme = 'block_test_theme';
+ theme_enable(array($theme));
+ variable_set('theme_default', $theme);
+ menu_rebuild();
+
+ // Ensure that "block_test_theme" is set as the default theme.
+ $this->drupalGet('admin/structure/block');
+ $this->assertText('Block test theme(' . t('active tab') . ')', 'Default local task on blocks admin page is the block test theme.');
+
+ // Ensure that the search form block is displayed.
+ $this->drupalGet('');
+ $this->assertText('Search form', 'Block was displayed on the front page.');
+ }
+}
+
+/**
+ * Tests that a block assigned to an invalid region triggers the warning.
+ */
+class BlockInvalidRegionTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Blocks in invalid regions',
+ 'description' => 'Checks that an active block assigned to a non-existing region triggers the warning message and is disabled.',
+ 'group' => 'Block',
+ );
+ }
+
+ function setUp() {
+ parent::setUp(array('block', 'block_test'));
+ // Create an admin user.
+ $admin_user = $this->drupalCreateUser(array('administer site configuration', 'access administration pages'));
+ $this->drupalLogin($admin_user);
+ }
+
+ /**
+ * Tests that blocks assigned to invalid regions work correctly.
+ */
+ function testBlockInInvalidRegion() {
+ // Enable a test block in the default theme and place it in an invalid region.
+ db_merge('block')
+ ->key(array(
+ 'module' => 'block_test',
+ 'delta' => 'test_html_id',
+ 'theme' => variable_get('theme_default', 'stark'),
+ ))
+ ->fields(array(
+ 'status' => 1,
+ 'region' => 'invalid_region',
+ 'cache' => DRUPAL_NO_CACHE,
+ ))
+ ->execute();
+
+ $warning_message = t('The block %info was assigned to the invalid region %region and has been disabled.', array('%info' => t('Test block html id'), '%region' => 'invalid_region'));
+
+ // Clearing the cache should disable the test block placed in the invalid region.
+ $this->drupalPost('admin/config/development/performance', array(), 'Clear all caches');
+ $this->assertRaw($warning_message, 'Enabled block was in the invalid region and has been disabled.');
+
+ // Clear the cache to check if the warning message is not triggered.
+ $this->drupalPost('admin/config/development/performance', array(), 'Clear all caches');
+ $this->assertNoRaw($warning_message, 'Disabled block in the invalid region will not trigger the warning.');
+
+ // Place disabled test block in the invalid region of the default theme.
+ db_merge('block')
+ ->key(array(
+ 'module' => 'block_test',
+ 'delta' => 'test_html_id',
+ 'theme' => variable_get('theme_default', 'stark'),
+ ))
+ ->fields(array(
+ 'region' => 'invalid_region',
+ 'cache' => DRUPAL_NO_CACHE,
+ ))
+ ->execute();
+
+ // Clear the cache to check if the warning message is not triggered.
+ $this->drupalPost('admin/config/development/performance', array(), 'Clear all caches');
+ $this->assertNoRaw($warning_message, 'Disabled block in the invalid region will not trigger the warning.');
+ }
+}
+
+/**
+ * Tests that block rehashing works correctly.
+ */
+class BlockHashTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Block rehash',
+ 'description' => 'Checks _block_rehash() functionality.',
+ 'group' => 'Block',
+ );
+ }
+
+ function setUp() {
+ parent::setUp(array('block'));
+ }
+
+ /**
+ * Tests that block rehashing does not write to the database too often.
+ */
+ function testBlockRehash() {
+ // No hook_block_info_alter(), no save.
+ $this->doRehash();
+ module_enable(array('block_test'), FALSE);
+ // Save the new blocks, check that the new blocks exist by checking weight.
+ _block_rehash();
+ $this->assertWeight(0);
+ // Now hook_block_info_alter() exists but no blocks are saved on a second
+ // rehash.
+ $this->doRehash();
+ $this->assertWeight(0);
+ // Now hook_block_info_alter() exists and is changing one block which
+ // should be saved.
+ $GLOBALS['conf']['block_test_info_alter'] = 1;
+ $this->doRehash(TRUE);
+ $this->assertWeight(10000);
+ // Now hook_block_info_alter() exists but already changed the block's
+ // weight before, so it should not be saved again.
+ $this->doRehash();
+ $this->assertWeight(10000);
+ }
+
+ /**
+ * Performs a block rehash and checks several related assertions.
+ *
+ * @param $alter_active
+ * Set to TRUE if the block_test module's hook_block_info_alter()
+ * implementation is expected to make a change that results in an existing
+ * block needing to be resaved to the database. Defaults to FALSE.
+ */
+ function doRehash($alter_active = FALSE) {
+ $saves = 0;
+ foreach (_block_rehash() as $block) {
+ $module = $block['module'];
+ $delta = $block['delta'];
+ if ($alter_active && $module == 'block_test' && $delta == 'test_html_id') {
+ $this->assertFalse(empty($block['saved']), "$module $delta saved");
+ $saves++;
+ }
+ else {
+ $this->assertTrue(empty($block['saved']), "$module $delta not saved");
+ }
+ }
+ $this->assertEqual($alter_active, $saves);
+ }
+
+ /**
+ * Asserts that the block_test module's block has a given weight.
+ *
+ * @param $weight
+ * The expected weight.
+ */
+ function assertWeight($weight) {
+ $db_weight = db_query('SELECT weight FROM {block} WHERE module = :module AND delta = :delta', array(':module' => 'block_test', ':delta' => 'test_html_id'))->fetchField();
+ // By casting to string the assert fails on FALSE.
+ $this->assertIdentical((string) $db_weight, (string) $weight);
+ }
+}
diff --git a/kolab.org/www/drupal-7.26/modules/block/block.tpl.php b/kolab.org/www/drupal-7.26/modules/block/block.tpl.php
new file mode 100644
index 0000000..f0bfa5c
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/block/block.tpl.php
@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * @file
+ * Default theme implementation to display a block.
+ *
+ * Available variables:
+ * - $block->subject: Block title.
+ * - $content: Block content.
+ * - $block->module: Module that generated the block.
+ * - $block->delta: An ID for the block, unique within each module.
+ * - $block->region: The block region embedding the current block.
+ * - $classes: String of classes that can be used to style contextually through
+ * CSS. It can be manipulated through the variable $classes_array from
+ * preprocess functions. The default values can be one or more of the
+ * following:
+ * - block: The current template type, i.e., "theming hook".
+ * - block-[module]: The module generating the block. For example, the user
+ * module is responsible for handling the default user navigation block. In
+ * that case the class would be 'block-user'.
+ * - $title_prefix (array): An array containing additional output populated by
+ * modules, intended to be displayed in front of the main title tag that
+ * appears in the template.
+ * - $title_suffix (array): An array containing additional output populated by
+ * modules, intended to be displayed after the main title tag that appears in
+ * the template.
+ *
+ * Helper variables:
+ * - $classes_array: Array of html class attribute values. It is flattened
+ * into a string within the variable $classes.
+ * - $block_zebra: Outputs 'odd' and 'even' dependent on each block region.
+ * - $zebra: Same output as $block_zebra but independent of any block region.
+ * - $block_id: Counter dependent on each block region.
+ * - $id: Same output as $block_id but independent of any block region.
+ * - $is_front: Flags true when presented in the front page.
+ * - $logged_in: Flags true when the current user is a logged-in member.
+ * - $is_admin: Flags true when the current user is an administrator.
+ * - $block_html_id: A valid HTML ID and guaranteed unique.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_block()
+ * @see template_process()
+ *
+ * @ingroup themeable
+ */
+?>
+<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
+
+ <?php print render($title_prefix); ?>
+<?php if ($block->subject): ?>
+ <h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
+<?php endif;?>
+ <?php print render($title_suffix); ?>
+
+ <div class="content"<?php print $content_attributes; ?>>
+ <?php print $content ?>
+ </div>
+</div>
diff --git a/kolab.org/www/drupal-7.26/modules/block/tests/block_test.info b/kolab.org/www/drupal-7.26/modules/block/tests/block_test.info
new file mode 100644
index 0000000..846e067
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/block/tests/block_test.info
@@ -0,0 +1,12 @@
+name = Block test
+description = Provides test blocks.
+package = Testing
+version = VERSION
+core = 7.x
+hidden = TRUE
+
+; Information added by Drupal.org packaging script on 2014-01-15
+version = "7.26"
+project = "drupal"
+datestamp = "1389815930"
+
diff --git a/kolab.org/www/drupal-7.26/modules/block/tests/block_test.module b/kolab.org/www/drupal-7.26/modules/block/tests/block_test.module
new file mode 100644
index 0000000..e7ed09b
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/block/tests/block_test.module
@@ -0,0 +1,67 @@
+<?php
+
+/**
+ * @file
+ * Provide test blocks.
+ */
+
+/**
+ * Implements hook_system_theme_info().
+ */
+function block_test_system_theme_info() {
+ $themes['block_test_theme'] = drupal_get_path('module', 'block_test') . '/themes/block_test_theme/block_test_theme.info';
+ return $themes;
+}
+
+/**
+ * Implements hook_block_info().
+ */
+function block_test_block_info() {
+ $blocks['test_cache'] = array(
+ 'info' => t('Test block caching'),
+ 'cache' => variable_get('block_test_caching', DRUPAL_CACHE_PER_ROLE),
+ );
+
+ $blocks['test_underscore'] = array(
+ 'info' => t('Test underscore'),
+ );
+
+ $blocks['test-hyphen'] = array(
+ 'info' => t('Test hyphen'),
+ );
+
+ $blocks['test_html_id'] = array(
+ 'info' => t('Test block html id'),
+ );
+ return $blocks;
+}
+
+/**
+ * Implements hook_block_view().
+ */
+function block_test_block_view($delta = 0) {
+ return array('content' => variable_get('block_test_content', ''));
+}
+
+/**
+ * Implements hook_block_view_MODULE_DELTA_alter().
+ */
+function block_test_block_view_block_test_test_underscore_alter(&$data, $block) {
+ $data['content'] = 'hook_block_view_MODULE_DELTA_alter';
+}
+
+/**
+ * Implements hook_block_view_MODULE_DELTA_alter().
+ */
+function block_test_block_view_block_test_test_hyphen_alter(&$data, $block) {
+ $data['content'] = 'hook_block_view_MODULE_DELTA_alter';
+}
+
+/**
+ * Implements hook_block_info_alter().
+ */
+function block_test_block_info_alter(&$blocks) {
+ if (variable_get('block_test_info_alter')) {
+ $blocks['block_test']['test_html_id']['weight'] = 10000;
+ }
+}
diff --git a/kolab.org/www/drupal-7.26/modules/block/tests/themes/block_test_theme/block_test_theme.info b/kolab.org/www/drupal-7.26/modules/block/tests/themes/block_test_theme/block_test_theme.info
new file mode 100644
index 0000000..3da86d0
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/block/tests/themes/block_test_theme/block_test_theme.info
@@ -0,0 +1,20 @@
+name = Block test theme
+description = Theme for testing the block system
+core = 7.x
+hidden = TRUE
+
+regions[sidebar_first] = Left sidebar
+regions_hidden[] = sidebar_first
+regions[sidebar_second] = Right sidebar
+regions_hidden[] = sidebar_second
+regions[content] = Content
+regions[header] = Header
+regions[footer] = Footer
+regions[highlighted] = Highlighted
+regions[help] = Help
+
+; Information added by Drupal.org packaging script on 2014-01-15
+version = "7.26"
+project = "drupal"
+datestamp = "1389815930"
+
diff --git a/kolab.org/www/drupal-7.26/modules/block/tests/themes/block_test_theme/page.tpl.php b/kolab.org/www/drupal-7.26/modules/block/tests/themes/block_test_theme/page.tpl.php
new file mode 100644
index 0000000..ba72882
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/block/tests/themes/block_test_theme/page.tpl.php
@@ -0,0 +1,78 @@
+<?php
+
+/**
+ * @file
+ * Custom theme implementation to display a single Drupal page without
+ * sidebars. The sidebars are hidden by regions_hidden for this theme, so
+ * the default page.tpl.php will not work without throwing exceptions.
+ */
+?>
+
+ <div id="page-wrapper"><div id="page">
+
+ <div id="header"><div class="section clearfix">
+
+ <?php if ($logo): ?>
+ <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
+ <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
+ </a>
+ <?php endif; ?>
+
+ <?php if ($site_name || $site_slogan): ?>
+ <div id="name-and-slogan">
+ <?php if ($site_name): ?>
+ <?php if ($title): ?>
+ <div id="site-name"><strong>
+ <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
+ </strong></div>
+ <?php else: /* Use h1 when the content title is empty */ ?>
+ <h1 id="site-name">
+ <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
+ </h1>
+ <?php endif; ?>
+ <?php endif; ?>
+
+ <?php if ($site_slogan): ?>
+ <div id="site-slogan"><?php print $site_slogan; ?></div>
+ <?php endif; ?>
+ </div> <!-- /#name-and-slogan -->
+ <?php endif; ?>
+
+ <?php print render($page['header']); ?>
+
+ </div></div> <!-- /.section, /#header -->
+
+ <?php if ($main_menu || $secondary_menu): ?>
+ <div id="navigation"><div class="section">
+ <?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu', 'class' => array('links', 'inline', 'clearfix')), 'heading' => t('Main menu'))); ?>
+ <?php print theme('links__system_secondary_menu', array('links' => $secondary_menu, 'attributes' => array('id' => 'secondary-menu', 'class' => array('links', 'inline', 'clearfix')), 'heading' => t('Secondary menu'))); ?>
+ </div></div> <!-- /.section, /#navigation -->
+ <?php endif; ?>
+
+ <?php if ($breadcrumb): ?>
+ <div id="breadcrumb"><?php print $breadcrumb; ?></div>
+ <?php endif; ?>
+
+ <?php print $messages; ?>
+
+ <div id="main-wrapper"><div id="main" class="clearfix">
+
+ <div id="content" class="column"><div class="section">
+ <?php if ($page['highlighted']): ?><div id="highlighted"><?php print render($page['highlighted']); ?></div><?php endif; ?>
+ <a id="main-content"></a>
+ <?php print render($title_prefix); ?>
+ <?php if ($title): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?>
+ <?php print render($title_suffix); ?>
+ <?php if ($tabs = render($tabs)): ?><div class="tabs"><?php print $tabs; ?></div><?php endif; ?>
+ <?php print render($page['help']); ?>
+ <?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php endif; ?>
+ <?php print render($page['content']); ?>
+ <?php print $feed_icons; ?>
+ </div></div> <!-- /.section, /#content -->
+ </div></div> <!-- /#main, /#main-wrapper -->
+
+ <div id="footer"><div class="section">
+ <?php print render($page['footer']); ?>
+ </div></div> <!-- /.section, /#footer -->
+
+ </div></div> <!-- /#page, /#page-wrapper -->
diff --git a/kolab.org/www/drupal-7.26/modules/blog/blog.info b/kolab.org/www/drupal-7.26/modules/blog/blog.info
new file mode 100644
index 0000000..fbef8c1
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/blog/blog.info
@@ -0,0 +1,12 @@
+name = Blog
+description = Enables multi-user blogs.
+package = Core
+version = VERSION
+core = 7.x
+files[] = blog.test
+
+; Information added by Drupal.org packaging script on 2014-01-15
+version = "7.26"
+project = "drupal"
+datestamp = "1389815930"
+
diff --git a/kolab.org/www/drupal-7.26/modules/blog/blog.install b/kolab.org/www/drupal-7.26/modules/blog/blog.install
new file mode 100644
index 0000000..fffb14b
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/blog/blog.install
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * @file
+ * Install, update and uninstall functions for the blog module.
+ */
+
+/**
+ * Implements hook_install().
+ */
+function blog_install() {
+ // Ensure the blog node type is available.
+ node_types_rebuild();
+ $types = node_type_get_types();
+ node_add_body_field($types['blog']);
+}
+
+/**
+ * Implements hook_uninstall().
+ */
+function blog_uninstall() {
+ variable_del('blog_block_count');
+}
diff --git a/kolab.org/www/drupal-7.26/modules/blog/blog.module b/kolab.org/www/drupal-7.26/modules/blog/blog.module
new file mode 100644
index 0000000..11e3ab9
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/blog/blog.module
@@ -0,0 +1,272 @@
+<?php
+
+/**
+ * @file
+ * Enables multi-user blogs.
+ */
+
+/**
+ * Implements hook_node_info().
+ */
+function blog_node_info() {
+ return array(
+ 'blog' => array(
+ 'name' => t('Blog entry'),
+ 'base' => 'blog',
+ 'description' => t('Use for multi-user blogs. Every user gets a personal blog.'),
+ )
+ );
+}
+
+/**
+ * Implements hook_user_view().
+ */
+function blog_user_view($account) {
+ if (user_access('create blog content', $account)) {
+ $account->content['summary']['blog'] = array(
+ '#type' => 'user_profile_item',
+ '#title' => t('Blog'),
+ // l() escapes the attributes, so we should not escape !username here.
+ '#markup' => l(t('View recent blog entries'), "blog/$account->uid", array('attributes' => array('title' => t("Read !username's latest blog entries.", array('!username' => format_username($account)))))),
+ '#attributes' => array('class' => array('blog')),
+ );
+ }
+}
+
+/**
+ * Implements hook_help().
+ */
+function blog_help($path, $arg) {
+ switch ($path) {
+ case 'admin/help#blog':
+ $output = '<h3>' . t('About') . '</h3>';
+ $output .= '<p>' . t("The Blog module allows registered users to maintain an online journal, or <em>blog</em>. Blogs are made up of individual <em>blog entries</em>. By default, the blog entries are displayed by creation time in descending order, with comments enabled, and are promoted to the site's front page. For more information, see the online handbook entry for <a href='@blog'>Blog module</a>.", array('@blog' => 'http://drupal.org/documentation/modules/blog/')) . '</p>';
+ $output .= '<h3>' . t('Uses') . '</h3>';
+ $output .= '<dl>';
+ $output .= '<dt>' . t('Single-user blogs') . '</dt>';
+ $output .= '<dd>' . t("Each user's blog entries are automatically displayed with a link to the user's main blog page. You can create as many single-user blogs as you have site users with permission to create blog content.") . '</dd>';
+ $output .= '<dt>' . t('Multi-user blogs') . '</dt>';
+ $output .= '<dd>' . t("Blog entries from each single-user blog are also aggregated into one central multi-user blog, which displays the blog content of all users in a single listing.") . '</dd>';
+ $output .= '<dt>' . t('Navigation') . '</dt>';
+ $output .= '<dd>' . t("There is an optional <em>Blogs</em> menu item added to the Navigation menu, which displays all blogs available on your site, and a <em>My blog</em> item displaying the current user's blog entries.") . '</dd>';
+ $output .= '<dt>' . t('Blocks') . '</dt>';
+ $output .= '<dd>' . t('The Blog module also creates a default <em>Recent blog posts</em> block that may be enabled at the <a href="@blocks">blocks administration page</a>.', array('@blocks' => url('admin/structure/block'))) . '</dd>';
+ $output .= '</dl>';
+ return $output;
+ }
+}
+
+/**
+ * Implements hook_form().
+ */
+function blog_form($node, $form_state) {
+ return node_content_form($node, $form_state);
+}
+
+/**
+ * Implements hook_view().
+ */
+function blog_view($node, $view_mode) {
+ if ($view_mode == 'full' && node_is_page($node)) {
+ // Breadcrumb navigation. l() escapes title, so we should not escape !name.
+ drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Blogs'), 'blog'), l(t("!name's blog", array('!name' => format_username($node))), 'blog/' . $node->uid)));
+ }
+ return $node;
+}
+
+/**
+ * Implements hook_node_view().
+ */
+function blog_node_view($node, $view_mode) {
+ if ($view_mode != 'rss') {
+ if ($node->type == 'blog' && (arg(0) != 'blog' || arg(1) != $node->uid)) {
+ // This goes to l(), which escapes !username in both title and attributes.
+ $links['blog_usernames_blog'] = array(
+ 'title' => t("!username's blog", array('!username' => format_username($node))),
+ 'href' => "blog/$node->uid",
+ 'attributes' => array('title' => t("Read !username's latest blog entries.", array('!username' => format_username($node)))),
+ );
+ $node->content['links']['blog'] = array(
+ '#theme' => 'links__node__blog',
+ '#links' => $links,
+ '#attributes' => array('class' => array('links', 'inline')),
+ );
+ }
+ }
+}
+
+/**
+ * Implements hook_menu().
+ */
+function blog_menu() {
+ $items['blog'] = array(
+ 'title' => 'Blogs',
+ 'page callback' => 'blog_page_last',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_SUGGESTED_ITEM,
+ 'file' => 'blog.pages.inc',
+ );
+ $items['blog/%user_uid_optional'] = array(
+ 'title' => 'My blog',
+ 'page callback' => 'blog_page_user',
+ 'page arguments' => array(1),
+ 'access callback' => 'blog_page_user_access',
+ 'access arguments' => array(1),
+ 'file' => 'blog.pages.inc',
+ );
+ $items['blog/%user/feed'] = array(
+ 'title' => 'Blogs',
+ 'page callback' => 'blog_feed_user',
+ 'page arguments' => array(1),
+ 'access callback' => 'blog_page_user_access',
+ 'access arguments' => array(1),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'blog.pages.inc',
+ );
+ $items['blog/feed'] = array(
+ 'title' => 'Blogs',
+ 'page callback' => 'blog_feed_last',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'blog.pages.inc',
+ );
+
+ return $items;
+}
+
+/**
+ * Implements hook_menu_local_tasks_alter().
+ */
+function blog_menu_local_tasks_alter(&$data, $router_item, $root_path) {
+ global $user;
+
+ // Add action link to 'node/add/blog' on 'blog' page.
+ if ($root_path == 'blog') {
+ $item = menu_get_item('node/add/blog');
+ if ($item['access']) {
+ $item['title'] = t('Create new blog entry');
+ $data['actions']['output'][] = array(
+ '#theme' => 'menu_local_action',
+ '#link' => $item,
+ );
+ }
+ }
+ // Provide a helper action link to the author on the 'blog/%' page.
+ elseif ($root_path == 'blog/%' && $router_item['page_arguments'][0]->uid == $user->uid) {
+ $data['actions']['output']['blog'] = array(
+ '#theme' => 'menu_local_action',
+ );
+ if (user_access('create blog content')) {
+ $data['actions']['output']['blog']['#link']['title'] = t('Post new blog entry.');
+ $data['actions']['output']['blog']['#link']['href'] = 'node/add/blog';
+ }
+ else {
+ $data['actions']['output']['blog']['#link']['title'] = t('You are not allowed to post a new blog entry.');
+ }
+ }
+}
+
+/**
+ * Access callback for user blog pages.
+ */
+function blog_page_user_access($account) {
+ // The visitor must be able to access the site's content.
+ // For a blog to 'exist' the user must either be able to
+ // create new blog entries, or it must have existing posts.
+ return $account->uid && user_access('access content') && (user_access('create blog content', $account) || _blog_post_exists($account));
+}
+
+/**
+ * Helper function to determine if a user has blog posts already.
+ */
+function _blog_post_exists($account) {
+ return (bool)db_select('node', 'n')
+ ->fields('n', array('nid'))
+ ->condition('type', 'blog')
+ ->condition('uid', $account->uid)
+ ->condition('status', 1)
+ ->range(0, 1)
+ ->addTag('node_access')
+ ->execute()
+ ->fetchField();
+}
+
+/**
+ * Implements hook_block_info().
+ */
+function blog_block_info() {
+ $block['recent']['info'] = t('Recent blog posts');
+ $block['recent']['properties']['administrative'] = TRUE;
+ return $block;
+}
+
+/**
+ * Implements hook_block_configure().
+ */
+function blog_block_configure($delta = '') {
+ if ($delta == 'recent') {
+ $form['blog_block_count'] = array(
+ '#type' => 'select',
+ '#title' => t('Number of recent blog posts to display'),
+ '#default_value' => variable_get('blog_block_count', 10),
+ '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
+ );
+ return $form;
+ }
+}
+
+/**
+ * Implements hook_block_save().
+ */
+function blog_block_save($delta = '', $edit = array()) {
+ if ($delta == 'recent') {
+ variable_set('blog_block_count', $edit['blog_block_count']);
+ }
+}
+
+/**
+ * Implements hook_block_view().
+ *
+ * Displays the most recent 10 blog titles.
+ */
+function blog_block_view($delta = '') {
+ global $user;
+
+ if (user_access('access content')) {
+ $result = db_select('node', 'n')
+ ->fields('n', array('nid', 'title', 'created'))
+ ->condition('type', 'blog')
+ ->condition('status', 1)
+ ->orderBy('created', 'DESC')
+ ->range(0, variable_get('blog_block_count', 10))
+ ->addTag('node_access')
+ ->execute();
+
+ if ($node_title_list = node_title_list($result)) {
+ $block['subject'] = t('Recent blog posts');
+ $block['content']['blog_list'] = $node_title_list;
+ $block['content']['blog_more'] = array(
+ '#theme' => 'more_link',
+ '#url' => 'blog',
+ '#title' => t('Read the latest blog entries.'),
+ );
+
+ return $block;
+ }
+ }
+}
+
+/**
+ * Implements hook_rdf_mapping().
+ */
+function blog_rdf_mapping() {
+ return array(
+ array(
+ 'type' => 'node',
+ 'bundle' => 'blog',
+ 'mapping' => array(
+ 'rdftype' => array('sioc:Post', 'sioct:BlogPost'),
+ ),
+ ),
+ );
+}
diff --git a/kolab.org/www/drupal-7.26/modules/blog/blog.pages.inc b/kolab.org/www/drupal-7.26/modules/blog/blog.pages.inc
new file mode 100644
index 0000000..3684028
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/blog/blog.pages.inc
@@ -0,0 +1,127 @@
+<?php
+
+/**
+ * @file
+ * Page callback file for the blog module.
+ */
+
+/**
+ * Menu callback; displays a Drupal page containing recent blog entries of a given user.
+ */
+function blog_page_user($account) {
+ global $user;
+
+ drupal_set_title($title = t("@name's blog", array('@name' => format_username($account))), PASS_THROUGH);
+
+ $build = array();
+
+ $query = db_select('node', 'n')->extend('PagerDefault');
+ $nids = $query
+ ->fields('n', array('nid', 'sticky', 'created'))
+ ->condition('type', 'blog')
+ ->condition('uid', $account->uid)
+ ->condition('status', 1)
+ ->orderBy('sticky', 'DESC')
+ ->orderBy('created', 'DESC')
+ ->limit(variable_get('default_nodes_main', 10))
+ ->addTag('node_access')
+ ->execute()
+ ->fetchCol();
+
+ if (!empty($nids)) {
+ $nodes = node_load_multiple($nids);
+ $build += node_view_multiple($nodes);
+ $build['pager'] = array(
+ '#theme' => 'pager',
+ '#weight' => 5,
+ );
+ }
+ else {
+ if ($account->uid == $user->uid) {
+ drupal_set_message(t('You have not created any blog entries.'));
+ }
+ else {
+ drupal_set_message(t('!author has not created any blog entries.', array('!author' => theme('username', array('account' => $account)))));
+ }
+ }
+ drupal_add_feed('blog/' . $account->uid . '/feed', t('RSS - !title', array('!title' => $title)));
+
+ return $build;
+}
+
+/**
+ * Menu callback; displays a Drupal page containing recent blog entries of all users.
+ */
+function blog_page_last() {
+ global $user;
+ $build = array();
+
+ $query = db_select('node', 'n')->extend('PagerDefault');
+ $nids = $query
+ ->fields('n', array('nid', 'sticky', 'created'))
+ ->condition('type', 'blog')
+ ->condition('status', 1)
+ ->orderBy('sticky', 'DESC')
+ ->orderBy('created', 'DESC')
+ ->limit(variable_get('default_nodes_main', 10))
+ ->addTag('node_access')
+ ->execute()
+ ->fetchCol();
+
+ if (!empty($nids)) {
+ $nodes = node_load_multiple($nids);
+ $build += node_view_multiple($nodes);
+ $build['pager'] = array(
+ '#theme' => 'pager',
+ '#weight' => 5,
+ );
+ }
+ else {
+ drupal_set_message(t('No blog entries have been created.'));
+ }
+ drupal_add_feed('blog/feed', t('RSS - blogs'));
+
+ return $build;
+}
+
+/**
+ * Menu callback; displays an RSS feed containing recent blog entries of a given user.
+ */
+function blog_feed_user($account) {
+
+ $nids = db_select('node', 'n')
+ ->fields('n', array('nid', 'created'))
+ ->condition('type', 'blog')
+ ->condition('uid', $account->uid)
+ ->condition('status', 1)
+ ->orderBy('created', 'DESC')
+ ->range(0, variable_get('feed_default_items', 10))
+ ->addTag('node_access')
+ ->execute()
+ ->fetchCol();
+
+ $channel['title'] = t("!name's blog", array('!name' => format_username($account)));
+ $channel['link'] = url('blog/' . $account->uid, array('absolute' => TRUE));
+
+ node_feed($nids, $channel);
+}
+
+/**
+ * Menu callback; displays an RSS feed containing recent blog entries of all users.
+ */
+function blog_feed_last() {
+ $nids = db_select('node', 'n')
+ ->fields('n', array('nid', 'created'))
+ ->condition('type', 'blog')
+ ->condition('status', 1)
+ ->orderBy('created', 'DESC')
+ ->range(0, variable_get('feed_default_items', 10))
+ ->addTag('node_access')
+ ->execute()
+ ->fetchCol();
+
+ $channel['title'] = t('!site_name blogs', array('!site_name' => variable_get('site_name', 'Drupal')));
+ $channel['link'] = url('blog', array('absolute' => TRUE));
+
+ node_feed($nids, $channel);
+}
diff --git a/kolab.org/www/drupal-7.26/modules/blog/blog.test b/kolab.org/www/drupal-7.26/modules/blog/blog.test
new file mode 100644
index 0000000..b917294
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/blog/blog.test
@@ -0,0 +1,213 @@
+<?php
+
+/**
+ * @file
+ * Tests for blog.module.
+ */
+
+class BlogTestCase extends DrupalWebTestCase {
+ protected $big_user;
+ protected $own_user;
+ protected $any_user;
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Blog functionality',
+ 'description' => 'Create, view, edit, delete, and change blog entries and verify its consistency in the database.',
+ 'group' => 'Blog',
+ );
+ }
+
+ /**
+ * Enable modules and create users with specific permissions.
+ */
+ function setUp() {
+ parent::setUp('blog');
+ // Create users.
+ $this->big_user = $this->drupalCreateUser(array('administer blocks'));
+ $this->own_user = $this->drupalCreateUser(array('create blog content', 'edit own blog content', 'delete own blog content'));
+ $this->any_user = $this->drupalCreateUser(array('create blog content', 'edit any blog content', 'delete any blog content', 'access administration pages'));
+ }
+
+ /**
+ * Confirm that the "You are not allowed to post a new blog entry." message
+ * shows up if a user submitted blog entries, has been denied that
+ * permission, and goes to the blog page.
+ */
+ function testUnprivilegedUser() {
+ // Create a blog node for a user with no blog permissions.
+ $this->drupalCreateNode(array('type' => 'blog', 'uid' => $this->big_user->uid));
+
+ $this->drupalLogin($this->big_user);
+
+ $this->drupalGet('blog/' . $this->big_user->uid);
+ $this->assertResponse(200);
+ $this->assertTitle(t("@name's blog", array('@name' => format_username($this->big_user))) . ' | Drupal', 'Blog title was displayed');
+ $this->assertText(t('You are not allowed to post a new blog entry.'), 'No new entries can be posted without the right permission');
+ }
+
+ /**
+ * View the blog of a user with no blog entries as another user.
+ */
+ function testBlogPageNoEntries() {
+ $this->drupalLogin($this->big_user);
+
+ $this->drupalGet('blog/' . $this->own_user->uid);
+ $this->assertResponse(200);
+ $this->assertTitle(t("@name's blog", array('@name' => format_username($this->own_user))) . ' | Drupal', 'Blog title was displayed');
+ $this->assertText(t('@author has not created any blog entries.', array('@author' => format_username($this->own_user))), 'Users blog displayed with no entries');
+ }
+
+ /**
+ * Login users, create blog nodes, and test blog functionality through the admin and user interfaces.
+ */
+ function testBlog() {
+ // Login the admin user.
+ $this->drupalLogin($this->big_user);
+ // Enable the recent blog block.
+ $edit = array();
+ $edit['blocks[blog_recent][region]'] = 'sidebar_second';
+ $this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
+ $this->assertResponse(200);
+ // Verify ability to change number of recent blog posts in block.
+ $edit = array();
+ $edit['blog_block_count'] = 5;
+ $this->drupalPost('admin/structure/block/manage/blog/recent/configure', $edit, t('Save block'));
+ $this->assertEqual(variable_get('blog_block_count', 10), 5, 'Number of recent blog posts changed.');
+
+ // Do basic tests for each user.
+ $this->doBasicTests($this->any_user, TRUE);
+ $this->doBasicTests($this->own_user, FALSE);
+
+ // Create another blog node for the any blog user.
+ $node = $this->drupalCreateNode(array('type' => 'blog', 'uid' => $this->any_user->uid));
+ // Verify the own blog user only has access to the blog view node.
+ $this->verifyBlogs($this->any_user, $node, FALSE, 403);
+
+ // Create another blog node for the own blog user.
+ $node = $this->drupalCreateNode(array('type' => 'blog', 'uid' => $this->own_user->uid));
+ // Login the any blog user.
+ $this->drupalLogin($this->any_user);
+ // Verify the any blog user has access to all the blog nodes.
+ $this->verifyBlogs($this->own_user, $node, TRUE);
+ }
+
+ /**
+ * Run basic tests on the indicated user.
+ *
+ * @param object $user
+ * The logged in user.
+ * @param boolean $admin
+ * User has 'access administration pages' privilege.
+ */
+ private function doBasicTests($user, $admin) {
+ // Login the user.
+ $this->drupalLogin($user);
+ // Create blog node.
+ $node = $this->drupalCreateNode(array('type' => 'blog'));
+ // Verify the user has access to all the blog nodes.
+ $this->verifyBlogs($user, $node, $admin);
+ // Create one more node to test the blog page with more than one node
+ $this->drupalCreateNode(array('type' => 'blog', 'uid' => $user->uid));
+ // Verify the blog links are displayed.
+ $this->verifyBlogLinks($user);
+ }
+
+ /**
+ * Verify the logged in user has the desired access to the various blog nodes.
+ *
+ * @param object $node_user
+ * The user who creates the node.
+ * @param object $node
+ * A node object.
+ * @param boolean $admin
+ * User has 'access administration pages' privilege.
+ * @param integer $response
+ * HTTP response code.
+ */
+ private function verifyBlogs($node_user, $node, $admin, $response = 200) {
+ $response2 = ($admin) ? 200 : 403;
+
+ // View blog help node.
+ $this->drupalGet('admin/help/blog');
+ $this->assertResponse($response2);
+ if ($response2 == 200) {
+ $this->assertTitle(t('Blog | Drupal'), 'Blog help node was displayed');
+ $this->assertText(t('Blog'), 'Blog help node was displayed');
+ }
+
+ // Verify the blog block was displayed.
+ $this->drupalGet('');
+ $this->assertResponse(200);
+ $this->assertText(t('Recent blog posts'), 'Blog block was displayed');
+
+ // View blog node.
+ $this->drupalGet('node/' . $node->nid);
+ $this->assertResponse(200);
+ $this->assertTitle($node->title . ' | Drupal', 'Blog node was displayed');
+ $breadcrumb = array(
+ l(t('Home'), NULL),
+ l(t('Blogs'), 'blog'),
+ l(t("!name's blog", array('!name' => format_username($node_user))), 'blog/' . $node_user->uid),
+ );
+ $this->assertRaw(theme('breadcrumb', array('breadcrumb' => $breadcrumb)), 'Breadcrumbs were displayed');
+
+ // View blog edit node.
+ $this->drupalGet('node/' . $node->nid . '/edit');
+ $this->assertResponse($response);
+ if ($response == 200) {
+ $this->assertTitle('Edit Blog entry ' . $node->title . ' | Drupal', 'Blog edit node was displayed');
+ }
+
+ if ($response == 200) {
+ // Edit blog node.
+ $edit = array();
+ $langcode = LANGUAGE_NONE;
+ $edit["title"] = 'node/' . $node->nid;
+ $edit["body[$langcode][0][value]"] = $this->randomName(256);
+ $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
+ $this->assertRaw(t('Blog entry %title has been updated.', array('%title' => $edit["title"])), 'Blog node was edited');
+
+ // Delete blog node.
+ $this->drupalPost('node/' . $node->nid . '/delete', array(), t('Delete'));
+ $this->assertResponse($response);
+ $this->assertRaw(t('Blog entry %title has been deleted.', array('%title' => $edit["title"])), 'Blog node was deleted');
+ }
+ }
+
+ /**
+ * Verify the blog links are displayed to the logged in user.
+ *
+ * @param object $user
+ * The logged in user.
+ */
+ private function verifyBlogLinks($user) {
+ // Confirm blog entries link exists on the user page.
+ $this->drupalGet('user/' . $user->uid);
+ $this->assertResponse(200);
+ $this->assertText(t('View recent blog entries'), 'View recent blog entries link was displayed');
+
+ // Confirm the recent blog entries link goes to the user's blog page.
+ $this->clickLink('View recent blog entries');
+ $this->assertTitle(t("@name's blog | Drupal", array('@name' => format_username($user))), 'View recent blog entries link target was correct');
+
+ // Confirm a blog page was displayed.
+ $this->drupalGet('blog');
+ $this->assertResponse(200);
+ $this->assertTitle('Blogs | Drupal', 'Blog page was displayed');
+ $this->assertText(t('Home'), 'Breadcrumbs were displayed');
+ $this->assertLink(t('Create new blog entry'));
+
+ // Confirm a blog page was displayed per user.
+ $this->drupalGet('blog/' . $user->uid);
+ $this->assertTitle(t("@name's blog | Drupal", array('@name' => format_username($user))), 'User blog node was displayed');
+
+ // Confirm a blog feed was displayed.
+ $this->drupalGet('blog/feed');
+ $this->assertTitle(t('Drupal blogs'), 'Blog feed was displayed');
+
+ // Confirm a blog feed was displayed per user.
+ $this->drupalGet('blog/' . $user->uid . '/feed');
+ $this->assertTitle(t("@name's blog", array('@name' => format_username($user))), 'User blog feed was displayed');
+ }
+}
diff --git a/kolab.org/www/drupal-7.26/modules/book/book-all-books-block.tpl.php b/kolab.org/www/drupal-7.26/modules/book/book-all-books-block.tpl.php
new file mode 100644
index 0000000..3a5a287
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/book/book-all-books-block.tpl.php
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * @file
+ * Default theme implementation for rendering book outlines within a block.
+ *
+ * This template is used only when the block is configured to "show block on all
+ * pages", which presents multiple independent books on all pages.
+ *
+ * Available variables:
+ * - $book_menus: Array of book outlines keyed to the parent book ID. Call
+ * render() on each to print it as an unordered list.
+ *
+ * @see template_preprocess_book_all_books_block()
+ *
+ * @ingroup themeable
+ */
+?>
+<?php foreach ($book_menus as $book_id => $menu): ?>
+ <div id="book-block-menu-<?php print $book_id; ?>" class="book-block-menu">
+ <?php print render($menu); ?>
+ </div>
+<?php endforeach; ?>
diff --git a/kolab.org/www/drupal-7.26/modules/book/book-export-html.tpl.php b/kolab.org/www/drupal-7.26/modules/book/book-export-html.tpl.php
new file mode 100644
index 0000000..d22b7d2
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/book/book-export-html.tpl.php
@@ -0,0 +1,52 @@
+<?php
+
+/**
+ * @file
+ * Default theme implementation for printed version of book outline.
+ *
+ * Available variables:
+ * - $title: Top level node title.
+ * - $head: Header tags.
+ * - $language: Language code. e.g. "en" for english.
+ * - $language_rtl: TRUE or FALSE depending on right to left language scripts.
+ * - $base_url: URL to home page.
+ * - $contents: Nodes within the current outline rendered through
+ * book-node-export-html.tpl.php.
+ *
+ * @see template_preprocess_book_export_html()
+ *
+ * @ingroup themeable
+ */
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $language->language; ?>" xml:lang="<?php print $language->language; ?>" dir="<?php print $dir; ?>">
+ <head>
+ <title><?php print $title; ?></title>
+ <?php print $head; ?>
+ <base href="<?php print $base_url; ?>" />
+ <link type="text/css" rel="stylesheet" href="misc/print.css" />
+ <?php if ($language_rtl): ?>
+ <link type="text/css" rel="stylesheet" href="misc/print-rtl.css" />
+ <?php endif; ?>
+ </head>
+ <body>
+ <?php
+ /**
+ * The given node is /embedded to its absolute depth in a top level
+ * section/. For example, a child node with depth 2 in the hierarchy is
+ * contained in (otherwise empty) &lt;div&gt; elements corresponding to
+ * depth 0 and depth 1. This is intended to support WYSIWYG output - e.g.,
+ * level 3 sections always look like level 3 sections, no matter their
+ * depth relative to the node selected to be exported as printer-friendly
+ * HTML.
+ */
+ $div_close = '';
+ ?>
+ <?php for ($i = 1; $i < $depth; $i++): ?>
+ <div class="section-<?php print $i; ?>">
+ <?php $div_close .= '</div>'; ?>
+ <?php endfor; ?>
+ <?php print $contents; ?>
+ <?php print $div_close; ?>
+ </body>
+</html>
diff --git a/kolab.org/www/drupal-7.26/modules/book/book-navigation.tpl.php b/kolab.org/www/drupal-7.26/modules/book/book-navigation.tpl.php
new file mode 100644
index 0000000..7a6b34c
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/book/book-navigation.tpl.php
@@ -0,0 +1,54 @@
+<?php
+
+/**
+ * @file
+ * Default theme implementation to navigate books.
+ *
+ * Presented under nodes that are a part of book outlines.
+ *
+ * Available variables:
+ * - $tree: The immediate children of the current node rendered as an unordered
+ * list.
+ * - $current_depth: Depth of the current node within the book outline. Provided
+ * for context.
+ * - $prev_url: URL to the previous node.
+ * - $prev_title: Title of the previous node.
+ * - $parent_url: URL to the parent node.
+ * - $parent_title: Title of the parent node. Not printed by default. Provided
+ * as an option.
+ * - $next_url: URL to the next node.
+ * - $next_title: Title of the next node.
+ * - $has_links: Flags TRUE whenever the previous, parent or next data has a
+ * value.
+ * - $book_id: The book ID of the current outline being viewed. Same as the node
+ * ID containing the entire outline. Provided for context.
+ * - $book_url: The book/node URL of the current outline being viewed. Provided
+ * as an option. Not used by default.
+ * - $book_title: The book/node title of the current outline being viewed.
+ * Provided as an option. Not used by default.
+ *
+ * @see template_preprocess_book_navigation()
+ *
+ * @ingroup themeable
+ */
+?>
+<?php if ($tree || $has_links): ?>
+ <div id="book-navigation-<?php print $book_id; ?>" class="book-navigation">
+ <?php print $tree; ?>
+
+ <?php if ($has_links): ?>
+ <div class="page-links clearfix">
+ <?php if ($prev_url): ?>
+ <a href="<?php print $prev_url; ?>" class="page-previous" title="<?php print t('Go to previous page'); ?>"><?php print t('‹ ') . $prev_title; ?></a>
+ <?php endif; ?>
+ <?php if ($parent_url): ?>
+ <a href="<?php print $parent_url; ?>" class="page-up" title="<?php print t('Go to parent page'); ?>"><?php print t('up'); ?></a>
+ <?php endif; ?>
+ <?php if ($next_url): ?>
+ <a href="<?php print $next_url; ?>" class="page-next" title="<?php print t('Go to next page'); ?>"><?php print $next_title . t(' ›'); ?></a>
+ <?php endif; ?>
+ </div>
+ <?php endif; ?>
+
+ </div>
+<?php endif; ?>
diff --git a/kolab.org/www/drupal-7.26/modules/book/book-node-export-html.tpl.php b/kolab.org/www/drupal-7.26/modules/book/book-node-export-html.tpl.php
new file mode 100644
index 0000000..0c2c67c
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/book/book-node-export-html.tpl.php
@@ -0,0 +1,25 @@
+<?php
+
+/**
+ * @file
+ * Default theme implementation for a single node in a printer-friendly outline.
+ *
+ * @see book-node-export-html.tpl.php
+ * Where it is collected and printed out.
+ *
+ * Available variables:
+ * - $depth: Depth of the current node inside the outline.
+ * - $title: Node title.
+ * - $content: Node content.
+ * - $children: All the child nodes recursively rendered through this file.
+ *
+ * @see template_preprocess_book_node_export_html()
+ *
+ * @ingroup themeable
+ */
+?>
+<div id="node-<?php print $node->nid; ?>" class="section-<?php print $depth; ?>">
+ <h1 class="book-heading"><?php print $title; ?></h1>
+ <?php print $content; ?>
+ <?php print $children; ?>
+</div>
diff --git a/kolab.org/www/drupal-7.26/modules/book/book-rtl.css b/kolab.org/www/drupal-7.26/modules/book/book-rtl.css
new file mode 100644
index 0000000..40dff0e
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/book/book-rtl.css
@@ -0,0 +1,15 @@
+/**
+ * @file
+ * Right-to-Left styling for the Book module.
+ */
+
+.book-navigation .menu {
+ padding: 1em 3em 0 0;
+}
+
+.book-navigation .page-previous {
+ float: right;
+}
+.book-navigation .page-up {
+ float: right;
+}
diff --git a/kolab.org/www/drupal-7.26/modules/book/book.admin.inc b/kolab.org/www/drupal-7.26/modules/book/book.admin.inc
new file mode 100644
index 0000000..cc3f08f
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/book/book.admin.inc
@@ -0,0 +1,289 @@
+<?php
+
+/**
+ * @file
+ * Administration page callbacks for the Book module.
+ */
+
+/**
+ * Returns an administrative overview of all books.
+ *
+ * @return string
+ * A HTML-formatted string with the administrative page content.
+ *
+ * @see book_menu()
+ */
+function book_admin_overview() {
+ $rows = array();
+
+ $headers = array(t('Book'), t('Operations'));
+
+ // Add any recognized books to the table list.
+ foreach (book_get_books() as $book) {
+ $rows[] = array(l($book['title'], $book['href'], $book['options']), l(t('edit order and titles'), 'admin/content/book/' . $book['nid']));
+ }
+
+ return theme('table', array('header' => $headers, 'rows' => $rows, 'empty' => t('No books available.')));
+}
+
+/**
+ * Form constructor for the book settings form.
+ *
+ * @see book_admin_settings_validate()
+ *
+ * @ingroup forms
+ */
+function book_admin_settings() {
+ $types = node_type_get_names();
+ $form['book_allowed_types'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Content types allowed in book outlines'),
+ '#default_value' => variable_get('book_allowed_types', array('book')),
+ '#options' => $types,
+ '#description' => t('Users with the %outline-perm permission can add all content types.', array('%outline-perm' => t('Administer book outlines'))),
+ '#required' => TRUE,
+ );
+ $form['book_child_type'] = array(
+ '#type' => 'radios',
+ '#title' => t('Content type for child pages'),
+ '#default_value' => variable_get('book_child_type', 'book'),
+ '#options' => $types,
+ '#required' => TRUE,
+ );
+ $form['array_filter'] = array('#type' => 'value', '#value' => TRUE);
+ $form['#validate'][] = 'book_admin_settings_validate';
+
+ return system_settings_form($form);
+}
+
+/**
+ * Form validation handler for book_admin_settings().
+ *
+ * @see book_admin_settings_submit()
+ */
+function book_admin_settings_validate($form, &$form_state) {
+ $child_type = $form_state['values']['book_child_type'];
+ if (empty($form_state['values']['book_allowed_types'][$child_type])) {
+ form_set_error('book_child_type', t('The content type for the %add-child link must be one of those selected as an allowed book outline type.', array('%add-child' => t('Add child page'))));
+ }
+}
+
+/**
+ * Form constructor for administering a single book's hierarchy.
+ *
+ * @see book_admin_edit_submit()
+ *
+ * @param $node
+ * The node of the top-level page in the book.
+ *
+ * @see book_admin_edit_validate()
+ * @see book_admin_edit_submit()
+ * @ingroup forms
+ */
+function book_admin_edit($form, $form_state, $node) {
+ drupal_set_title($node->title);
+ $form['#node'] = $node;
+ _book_admin_table($node, $form);
+ $form['save'] = array(
+ '#type' => 'submit',
+ '#value' => t('Save book pages'),
+ );
+
+ return $form;
+}
+
+/**
+ * Form validation handler for book_admin_edit().
+ *
+ * Checks that the book has not been changed while using the form.
+ *
+ * @see book_admin_edit_submit()
+ */
+function book_admin_edit_validate($form, &$form_state) {
+ if ($form_state['values']['tree_hash'] != $form_state['values']['tree_current_hash']) {
+ form_set_error('', t('This book has been modified by another user, the changes could not be saved.'));
+ }
+}
+
+/**
+ * Form submission handler for book_admin_edit().
+ *
+ * This function takes care to save parent menu items before their children.
+ * Saving menu items in the incorrect order can break the menu tree.
+ *
+ * @see book_admin_edit_validate()
+ * @see menu_overview_form_submit()
+ */
+function book_admin_edit_submit($form, &$form_state) {
+ // Save elements in the same order as defined in post rather than the form.
+ // This ensures parents are updated before their children, preventing orphans.
+ $order = array_flip(array_keys($form_state['input']['table']));
+ $form['table'] = array_merge($order, $form['table']);
+
+ foreach (element_children($form['table']) as $key) {
+ if ($form['table'][$key]['#item']) {
+ $row = $form['table'][$key];
+ $values = $form_state['values']['table'][$key];
+
+ // Update menu item if moved.
+ if ($row['plid']['#default_value'] != $values['plid'] || $row['weight']['#default_value'] != $values['weight']) {
+ $row['#item']['plid'] = $values['plid'];
+ $row['#item']['weight'] = $values['weight'];
+ menu_link_save($row['#item']);
+ }
+
+ // Update the title if changed.
+ if ($row['title']['#default_value'] != $values['title']) {
+ $node = node_load($values['nid']);
+ $langcode = LANGUAGE_NONE;
+ $node->title = $values['title'];
+ $node->book['link_title'] = $values['title'];
+ $node->revision = 1;
+ $node->log = t('Title changed from %original to %current.', array('%original' => $node->title, '%current' => $values['title']));
+
+ node_save($node);
+ watchdog('content', 'book: updated %title.', array('%title' => $node->title), WATCHDOG_NOTICE, l(t('view'), 'node/' . $node->nid));
+ }
+ }
+ }
+
+ drupal_set_message(t('Updated book %title.', array('%title' => $form['#node']->title)));
+}
+
+/**
+ * Builds the table portion of the form for the book administration page.
+ *
+ * @param $node
+ * The node of the top-level page in the book.
+ * @param $form
+ * The form that is being modified, passed by reference.
+ *
+ * @see book_admin_edit()
+ */
+function _book_admin_table($node, &$form) {
+ $form['table'] = array(
+ '#theme' => 'book_admin_table',
+ '#tree' => TRUE,
+ );
+
+ $tree = book_menu_subtree_data($node->book);
+ $tree = array_shift($tree); // Do not include the book item itself.
+ if ($tree['below']) {
+ $hash = drupal_hash_base64(serialize($tree['below']));
+ // Store the hash value as a hidden form element so that we can detect
+ // if another user changed the book hierarchy.
+ $form['tree_hash'] = array(
+ '#type' => 'hidden',
+ '#default_value' => $hash,
+ );
+ $form['tree_current_hash'] = array(
+ '#type' => 'value',
+ '#value' => $hash,
+ );
+ _book_admin_table_tree($tree['below'], $form['table']);
+ }
+
+}
+
+/**
+ * Helps build the main table in the book administration page form.
+ *
+ * @param $tree
+ * A subtree of the book menu hierarchy.
+ * @param $form
+ * The form that is being modified, passed by reference.
+ *
+ * @return
+ * The modified form array.
+ *
+ * @see book_admin_edit()
+ */
+function _book_admin_table_tree($tree, &$form) {
+ // The delta must be big enough to give each node a distinct value.
+ $count = count($tree);
+ $delta = ($count < 30) ? 15 : intval($count / 2) + 1;
+
+ foreach ($tree as $data) {
+ $form['book-admin-' . $data['link']['nid']] = array(
+ '#item' => $data['link'],
+ 'nid' => array('#type' => 'value', '#value' => $data['link']['nid']),
+ 'depth' => array('#type' => 'value', '#value' => $data['link']['depth']),
+ 'href' => array('#type' => 'value', '#value' => $data['link']['href']),
+ 'title' => array(
+ '#type' => 'textfield',
+ '#default_value' => $data['link']['link_title'],
+ '#maxlength' => 255,
+ '#size' => 40,
+ ),
+ 'weight' => array(
+ '#type' => 'weight',
+ '#default_value' => $data['link']['weight'],
+ '#delta' => max($delta, abs($data['link']['weight'])),
+ '#title' => t('Weight for @title', array('@title' => $data['link']['title'])),
+ '#title_display' => 'invisible',
+ ),
+ 'plid' => array(
+ '#type' => 'hidden',
+ '#default_value' => $data['link']['plid'],
+ ),
+ 'mlid' => array(
+ '#type' => 'hidden',
+ '#default_value' => $data['link']['mlid'],
+ ),
+ );
+ if ($data['below']) {
+ _book_admin_table_tree($data['below'], $form);
+ }
+ }
+
+ return $form;
+}
+
+/**
+ * Returns HTML for a book administration form.
+ *
+ * @param $variables
+ * An associative array containing:
+ * - form: A render element representing the form.
+ *
+ * @see book_admin_table()
+ * @ingroup themeable
+ */
+function theme_book_admin_table($variables) {
+ $form = $variables['form'];
+
+ drupal_add_tabledrag('book-outline', 'match', 'parent', 'book-plid', 'book-plid', 'book-mlid', TRUE, MENU_MAX_DEPTH - 2);
+ drupal_add_tabledrag('book-outline', 'order', 'sibling', 'book-weight');
+
+ $header = array(t('Title'), t('Weight'), t('Parent'), array('data' => t('Operations'), 'colspan' => '3'));
+
+ $rows = array();
+ $destination = drupal_get_destination();
+ $access = user_access('administer nodes');
+ foreach (element_children($form) as $key) {
+ $nid = $form[$key]['nid']['#value'];
+ $href = $form[$key]['href']['#value'];
+
+ // Add special classes to be used with tabledrag.js.
+ $form[$key]['plid']['#attributes']['class'] = array('book-plid');
+ $form[$key]['mlid']['#attributes']['class'] = array('book-mlid');
+ $form[$key]['weight']['#attributes']['class'] = array('book-weight');
+
+ $data = array(
+ theme('indentation', array('size' => $form[$key]['depth']['#value'] - 2)) . drupal_render($form[$key]['title']),
+ drupal_render($form[$key]['weight']),
+ drupal_render($form[$key]['plid']) . drupal_render($form[$key]['mlid']),
+ l(t('view'), $href),
+ $access ? l(t('edit'), 'node/' . $nid . '/edit', array('query' => $destination)) : '&nbsp;',
+ $access ? l(t('delete'), 'node/' . $nid . '/delete', array('query' => $destination) ) : '&nbsp;',
+ );
+ $row = array('data' => $data);
+ if (isset($form[$key]['#attributes'])) {
+ $row = array_merge($row, $form[$key]['#attributes']);
+ }
+ $row['class'][] = 'draggable';
+ $rows[] = $row;
+ }
+
+ return theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'book-outline'), 'empty' => t('No book content available.')));
+}
diff --git a/kolab.org/www/drupal-7.26/modules/book/book.css b/kolab.org/www/drupal-7.26/modules/book/book.css
new file mode 100644
index 0000000..00e379e
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/book/book.css
@@ -0,0 +1,58 @@
+ /**
+ * @file
+ * Styling for the Book module.
+ */
+
+.book-navigation .menu {
+ border-top: 1px solid #888;
+ padding: 1em 0 0 3em; /* LTR */
+}
+.book-navigation .page-links {
+ border-top: 1px solid #888;
+ border-bottom: 1px solid #888;
+ text-align: center;
+ padding: 0.5em;
+}
+.book-navigation .page-previous {
+ text-align: left;
+ width: 42%;
+ display: block;
+ float: left; /* LTR */
+}
+.book-navigation .page-up {
+ margin: 0 5%;
+ width: 4%;
+ display: block;
+ float: left; /* LTR */
+}
+.book-navigation .page-next {
+ text-align: right;
+ width: 42%;
+ display: block;
+ float: right;
+}
+#book-outline {
+ min-width: 56em;
+}
+.book-outline-form .form-item {
+ margin-top: 0;
+ margin-bottom: 0;
+}
+html.js #edit-book-pick-book {
+ display: none;
+}
+.form-item-book-bid .description {
+ clear: both;
+}
+#book-admin-edit select {
+ margin-right: 24px;
+}
+#book-admin-edit select.progress-disabled {
+ margin-right: 0;
+}
+#book-admin-edit tr.ajax-new-content {
+ background-color: #ffd;
+}
+#book-admin-edit .form-item {
+ float: left;
+}
diff --git a/kolab.org/www/drupal-7.26/modules/book/book.info b/kolab.org/www/drupal-7.26/modules/book/book.info
new file mode 100644
index 0000000..1c2d509
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/book/book.info
@@ -0,0 +1,14 @@
+name = Book
+description = Allows users to create and organize related content in an outline.
+package = Core
+version = VERSION
+core = 7.x
+files[] = book.test
+configure = admin/content/book/settings
+stylesheets[all][] = book.css
+
+; Information added by Drupal.org packaging script on 2014-01-15
+version = "7.26"
+project = "drupal"
+datestamp = "1389815930"
+
diff --git a/kolab.org/www/drupal-7.26/modules/book/book.install b/kolab.org/www/drupal-7.26/modules/book/book.install
new file mode 100644
index 0000000..899ee81
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/book/book.install
@@ -0,0 +1,95 @@
+<?php
+
+/**
+ * @file
+ * Install, update and uninstall functions for the book module.
+ */
+
+/**
+ * Implements hook_install().
+ */
+function book_install() {
+ // Add the node type.
+ _book_install_type_create();
+}
+
+/**
+ * Implements hook_uninstall().
+ */
+function book_uninstall() {
+ variable_del('book_allowed_types');
+ variable_del('book_child_type');
+ variable_del('book_block_mode');
+
+ // Delete menu links.
+ db_delete('menu_links')
+ ->condition('module', 'book')
+ ->execute();
+ menu_cache_clear_all();
+}
+
+/**
+ * Creates the book content type.
+ */
+function _book_install_type_create() {
+ // Create an additional node type.
+ $book_node_type = array(
+ 'type' => 'book',
+ 'name' => t('Book page'),
+ 'base' => 'node_content',
+ 'description' => t('<em>Books</em> have a built-in hierarchical navigation. Use for handbooks or tutorials.'),
+ 'custom' => 1,
+ 'modified' => 1,
+ 'locked' => 0,
+ );
+
+ $book_node_type = node_type_set_defaults($book_node_type);
+ node_type_save($book_node_type);
+ node_add_body_field($book_node_type);
+ // Default to not promoted.
+ variable_set('node_options_book', array('status'));
+ // Use this default type for adding content to books.
+ variable_set('book_allowed_types', array('book'));
+ variable_set('book_child_type', 'book');
+}
+
+/**
+ * Implements hook_schema().
+ */
+function book_schema() {
+ $schema['book'] = array(
+ 'description' => 'Stores book outline information. Uniquely connects each node in the outline to a link in {menu_links}',
+ 'fields' => array(
+ 'mlid' => array(
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => "The book page's {menu_links}.mlid.",
+ ),
+ 'nid' => array(
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => "The book page's {node}.nid.",
+ ),
+ 'bid' => array(
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'default' => 0,
+ 'description' => "The book ID is the {book}.nid of the top-level page.",
+ ),
+ ),
+ 'primary key' => array('mlid'),
+ 'unique keys' => array(
+ 'nid' => array('nid'),
+ ),
+ 'indexes' => array(
+ 'bid' => array('bid'),
+ ),
+ );
+
+ return $schema;
+}
diff --git a/kolab.org/www/drupal-7.26/modules/book/book.js b/kolab.org/www/drupal-7.26/modules/book/book.js
new file mode 100644
index 0000000..64f4aee
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/book/book.js
@@ -0,0 +1,27 @@
+/**
+ * @file
+ * Javascript behaviors for the Book module.
+ */
+
+(function ($) {
+
+Drupal.behaviors.bookFieldsetSummaries = {
+ attach: function (context) {
+ $('fieldset.book-outline-form', context).drupalSetSummary(function (context) {
+ var $select = $('.form-item-book-bid select');
+ var val = $select.val();
+
+ if (val === '0') {
+ return Drupal.t('Not in book');
+ }
+ else if (val === 'new') {
+ return Drupal.t('New book');
+ }
+ else {
+ return Drupal.checkPlain($select.find(':selected').text());
+ }
+ });
+ }
+};
+
+})(jQuery);
diff --git a/kolab.org/www/drupal-7.26/modules/book/book.module b/kolab.org/www/drupal-7.26/modules/book/book.module
new file mode 100644
index 0000000..7afed9a
--- /dev/null
+++ b/kolab.org/www/drupal-7.26/modules/book/book.module
@@ -0,0 +1,1437 @@
+<?php
+
+/**
+ * @file
+ * Allows users to create and organize related content in an outline.
+ */
+
+/**
+ * Implements hook_help().
+ */
+function book_help($path, $arg) {
+ switch ($path) {
+ case 'admin/help#book':
+ $output = '<h3>' . t('About') . '</h3>';
+ $output .= '<p>' . t('The Book module is used for creating structured, multi-page content, such as site resource guides, manuals, and wikis. It allows you to create content that has chapters, sections, subsections, or any similarly-tiered structure. For more information, see the online handbook entry for <a href="@book">Book module</a>.', array('@book' => 'http://drupal.org/documentation/modules/book/')) . '</p>';
+ $output .= '<h3>' . t('Uses') . '</h3>';
+ $output .= '<dl>';
+ $output .= '<dt>' . t('Adding and managing book content') . '</dt>';
+ $output .= '<dd>' . t('You can assign separate permissions for <em>creating</em>, <em>editing</em>, and <em>deleting</em> book content, as well as <em>adding content to books</em>, and <em>creating new books</em>. Users with the <em>Administer book outlines</em> permission can add <em>any</em> type of content to a book by selecting the appropriate book outline while editing the content. They can also view a list of all books, and edit and rearrange section titles on the <a href="@admin-book">Book administration page</a>.', array('@admin-book' => url('admin/content/book'))) . '</dd>';
+ $output .= '<dt>' . t('Book navigation') . '</dt>';
+ $output .= '<dd>' . t("Book pages have a default book-specific navigation block. This navigation block contains links that lead to the previous and next pages in the book, and to the level above the current page in the book's structure. This block can be enabled on the <a href='@admin-block'>Blocks administration page</a>. For book pages to show up in the book navigation, they must be added to a book outline.", array('@admin-block' => url('admin/structure/block'))) . '</dd>';
+ $output .= '<dt>' . t('Collaboration') . '</dt>';
+ $output .= '<dd>' . t('Books can be created collaboratively, as they allow users with appropriate permissions to add pages into existing books, and add those pages to a custom table of contents menu.') . '</dd>';
+ $output .= '<dt>' . t('Printing books') . '</dt>';
+ $output .= '<dd>' . t("Users with the <em>View printer-friendly books</em> permission can select the <em>printer-friendly version</em> link visible at the bottom of a book page's content to generate a printer-friendly display of the page and all of its subsections.") . '</dd>';
+ $output .= '</dl>';
+ return $output;
+ case 'admin/content/book':
+ return '<p>' . t('The book module offers a means to organize a collection of related content pages, collectively known as a book. When viewed, this content automatically displays links to adjacent book pages, providing a simple navigation system for creating and reviewing structured content.') . '</p>';
+ case 'node/%/outline':
+ return '<p>' . t('The outline feature allows you to include pages in the <a href="@book">Book hierarchy</a>, as well as move them within the hierarchy or to <a href="@book-admin">reorder an entire book</a>.', array('@book' => url('book'), '@book-admin' => url('admin/content/book'))) . '</p>';
+ }
+}
+
+/**
+ * Implements hook_theme().
+ */
+function book_theme() {
+ return array(
+ 'book_navigation' => array(
+ 'variables' => array('book_link' => NULL),
+ 'template' => 'book-navigation',
+ ),
+ 'book_export_html' => array(
+ 'variables' => array('title' => NULL, 'contents' => NULL, 'depth' => NULL),
+ 'template' => 'book-export-html',
+ ),
+ 'book_admin_table' => array(
+ 'render element' => 'form',
+ ),
+ 'book_title_link' => array(
+ 'variables' => array('link' => NULL),
+ ),
+ 'book_all_books_block' => array(
+ 'render element' => 'book_menus',
+ 'template' => 'book-all-books-block',
+ ),
+ 'book_node_export_html' => array(
+ 'variables' => array('node' => NULL, 'children' => NULL),
+ 'template' => 'book-node-export-html',
+ ),
+ );
+}
+
+/**
+ * Implements hook_permission().
+ */
+function book_permission() {
+ return array(
+ 'administer book outlines' => array(
+ 'title' => t('Administer book outlines'),
+ ),
+ 'create new books' => array(
+ 'title' => t('Create new books'),
+ ),
+ 'add content to books' => array(
+ 'title' => t('Add content and child pages to books'),
+ ),
+ 'access printer-friendly version' => array(
+ 'title' => t('View printer-friendly books'),
+ 'description' => t('View a book page and all of its sub-pages as a single document for ease of printing. Can be performance heavy.'),
+ ),
+ );
+}
+
+/**
+ * Adds relevant book links to the node's links.
+ *
+ * @param $node
+ * The book page node to add links to.
+ * @param $view_mode
+ * The view mode of the node.
+ */
+function book_node_view_link($node, $view_mode) {
+ $links = array();
+
+ if (isset($node->book['depth'])) {
+ if ($view_mode == 'full' && node_is_page($node)) {
+ $child_type = variable_get('book_child_type', 'book');
+ if ((user_access('add content to books') || user_access('administer book outlines')) && node_access('create', $child_type) && $node->status == 1 && $node->book['depth'] < MENU_MAX_DEPTH) {
+ $links['book_add_child'] = array(
+ 'title' => t('Add child page'),
+ 'href' => 'node/add/' . str_replace('_', '-', $child_type),
+ 'query' => array('parent' => $node->book['mlid']),
+ );
+ }
+
+ if (user_access('access printer-friendly version')) {
+ $links['book_printer'] = array(
+ 'title' => t('Printer-friendly version'),
+ 'href' => 'book/export/html/' . $node->nid,
+ 'attributes' => array('title' => t('Show a printer-friendly version of this book page and its sub-pages.'))
+ );
+ }
+ }
+ }
+
+ if (!empty($links)) {
+ $node->content['links']['book'] = array(
+ '#theme' => 'links__node__book',
+ '#links' => $links,
+ '#attributes' => array('class' => array('links', 'inline')),
+ );
+ }
+}
+
+/**
+ * Implements hook_menu().
+ */
+function book_menu() {
+ $items['admin/content/book'] = array(
+ 'title' => 'Books',
+ 'description' => "Manage your site's book outlines.",
+ 'page callback' => 'book_admin_overview',
+ 'access arguments' => array('administer book outlines'),
+ 'type' => MENU_LOCAL_TASK,
+ 'file' => 'book.admin.inc',
+ );
+ $items['admin/content/book/list'] = array(
+ 'title' => 'List',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ );
+ $items['admin/content/book/settings'] = array(
+ 'title' => 'Settings',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('book_admin_settings'),
+ 'access arguments' => array('administer site configuration'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 8,
+ 'file' => 'book.admin.inc',
+ );
+ $items['admin/content/book/%node'] = array(
+ 'title' => 'Re-order book pages and change titles',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('book_admin_edit', 3),
+ 'access callback' => '_book_outline_access',
+ 'access arguments' => array(3),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'book.admin.inc',
+ );
+ $items['book'] = array(
+ 'title' => 'Books',
+ 'page callback' => 'book_render',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_SUGGESTED_ITEM,
+ 'file' => 'book.pages.inc',
+ );
+ $items['book/export/%/%'] = array(
+ 'page callback' => 'book_export',
+ 'page arguments' => array(2, 3),
+ 'access arguments' => array('access printer-friendly version'),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'book.pages.inc',
+ );
+ $items['node/%node/outline'] = array(
+ 'title' => 'Outline',
+ 'page callback' => 'book_outline',
+ 'page arguments' => array(1),
+ 'access callback' => '_book_outline_access',
+ 'access arguments' => array(1),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2,
+ 'file' => 'book.pages.inc',
+ );
+ $items['node/%node/outline/remove'] = array(
+ 'title' => 'Remove from outline',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('book_remove_form', 1),
+ 'access callback' => '_book_outline_remove_access',
+ 'access arguments' => array(1),
+ 'file' => 'book.pages.inc',
+ );
+
+ return $items;
+}
+
+/**
+ * Access callback: Determines if the outline tab is accessible.
+ *
+ * @param $node
+ * The node whose outline tab is to be viewed.
+ */
+function _book_outline_access($node) {
+ return user_access('administer book outlines') && node_access('view', $node);
+}
+
+/**
+ * Access callback: Determines if the user can remove nodes from the outline.
+ *
+ * @param $node
+ * The node to remove from the outline.
+ *
+ * @see book_menu()
+ */
+function _book_outline_remove_access($node) {
+ return _book_node_is_removable($node) && _book_outline_access($node);
+}
+
+/**
+ * Determines if a node can be removed from the book.
+ *
+ * A node can be removed from a book if it is actually in a book and it either
+ * is not a top-level page or is a top-level page with no children.
+ *
+ * @param $node
+ * The node to remove from the outline.
+ */
+function _book_node_is_removable($node) {
+ return (!empty($node->book['bid']) && (($node->book['bid'] != $node->nid) || !$node->book['has_children']));
+}
+
+/**
+ * Implements hook_admin_paths().
+ */
+function book_admin_paths() {
+ if (variable_get('node_admin_theme')) {
+ $paths = array(
+ 'node/*/outline' => TRUE,
+ 'node/*/outline/remove' => TRUE,
+ );
+ return $paths;
+ }
+}
+
+/**
+ * Implements hook_entity_info_alter().
+ */
+function book_entity_info_alter(&$info) {
+ // Add the 'Print' view mode for nodes.
+ $info['node']['view modes'] += array(
+ 'print' => array(
+ 'label' => t('Print'),
+ 'custom settings' => FALSE,
+ ),
+ );
+}
+
+/**
+ * Implements hook_block_info().
+ */
+function book_block_info() {
+ $block = array();
+ $block['navigation']['info'] = t('Book navigation');
+ $block['navigation']['cache'] = DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE;
+
+ return $block;
+}
+
+/**
+ * Implements hook_block_view().
+ *
+ * Displays the book table of contents in a block when the current page is a
+ * single-node view of a book node.
+ */
+function book_block_view($delta = '') {
+ $block = array();
+ $current_bid = 0;
+ if ($node = menu_get_object()) {
+ $current_bid = empty($node->book['bid']) ? 0 : $node->book['bid'];
+ }
+
+ if (variable_get('book_block_mode', 'all pages') == 'all pages') {
+ $block['subject'] = t('Book navigation');
+ $book_menus = array();
+ $pseudo_tree = array(0 => array('below' => FALSE));
+ foreach (book_get_books() as $book_id => $book) {
+ if ($book['bid'] == $current_bid) {
+ // If the current page is a node associated with a book, the menu
+ // needs to be retrieved.
+ $book_menus[$book_id] = menu_tree_output(menu_tree_all_data($node->book['menu_name'], $node->book));
+ }
+ else {
+ // Since we know we will only display a link to the top node, there
+ // is no reason to run an additional menu tree query for each book.
+ $book['in_active_trail'] = FALSE;
+ // Check whether user can access the book link.
+ $book_node = node_load($book['nid']);
+ $book['access'] = node_access('view', $book_node);
+ $pseudo_tree[0]['link'] = $book;
+ $book_menus[$book_id] = menu_tree_output($pseudo_tree);
+ }
+ }
+ $book_menus['#theme'] = 'book_all_books_block';
+ $block['content'] = $book_menus;
+ }
+ elseif ($current_bid) {
+ // Only display this block when the user is browsing a book.
+ $select = db_select('node', 'n')
+ ->fields('n', array('title'))
+ ->condition('n.nid', $node->book['bid'])
+ ->addTag('node_access');
+ $title = $select->execute()->fetchField();
+ // Only show the block if the user has view access for the top-level node.
+ if ($title) {
+ $tree = menu_tree_all_data($node->book['menu_name'], $node->book);
+ // There should only be one element at the top level.
+ $data = array_shift($tree);
+ $block['subject'] = theme('book_title_link', array('link' => $data['link']));
+ $block['content'] = ($data['below']) ? menu_tree_output($data['below']) : '';
+ }
+ }
+
+ return $block;
+}
+
+/**
+ * Implements hook_block_configure().
+ */
+function book_block_configure($delta = '') {
+ $block = array();
+ $options = array(
+ 'all pages' => t('Show block on all pages'),
+ 'book pages' => t('Show block only on book pages'),
+ );
+ $form['book_block_mode'] = array(
+ '#type' => 'radios',
+ '#title' => t('Book navigation block display'),
+ '#options' => $options,
+ '#default_value' => variable_get('book_block_mode', 'all pages'),
+ '#description' => t("If <em>Show block on all pages</em> is selected, the block will contain the automatically generated menus for all of the site's books. If <em>Show block only on book pages</em> is selected, the block will contain only the one menu corresponding to the current page's book. In this case, if the current page is not in a book, no block will be displayed. The <em>Page specific visibility settings</em> or other visibility settings can be used in addition to selectively display this block."),
+ );
+
+ return $form;
+}
+
+/**
+ * Implements hook_block_save().
+ */
+function book_block_save($delta = '', $edit = array()) {
+ $block = array();
+ variable_set('book_block_mode', $edit['book_block_mode']);
+}
+
+/**
+ * Returns HTML for a link to a book title when used as a block title.
+ *
+ * @param $variables
+ * An associative array containing:
+ * - link: An array containing title, href and options for the link.
+ *
+ * @ingroup themeable
+ */
+function theme_book_title_link($variables) {
+ $link = $variables['link'];
+
+ $link['options']['attributes']['class'] = array('book-title');
+
+ return l($link['title'], $link['href'], $link['options']);
+}
+
+/**
+ * Returns an array of all books.
+ *
+ * This list may be used for generating a list of all the books, or for building
+ * the options for a form select.
+ *
+ * @return
+ * An array of all books.
+ */
+function book_get_books() {
+ $all_books = &drupal_static(__FUNCTION__);
+
+ if (!isset($all_books)) {
+ $all_books = array();
+ $nids = db_query("SELECT DISTINCT(bid) FROM {book}")->fetchCol();
+
+ if ($nids) {
+ $query = db_select('book', 'b', array('fetch' => PDO::FETCH_ASSOC));
+ $query->join('node', 'n', 'b.nid = n.nid');
+ $query->join('menu_links', 'ml', 'b.mlid = ml.mlid');
+ $query->addField('n', 'type', 'type');
+ $query->addField('n', 'title', 'title');
+ $query->fields('b');
+ $query->fields('ml');
+ $query->condition('n.nid', $nids, 'IN');
+ $query->condition('n.status', 1);
+ $query->orderBy('ml.weight');
+ $query->orderBy('ml.link_title');
+ $query->addTag('node_access');
+ $result2 = $query->execute();
+ foreach ($result2 as $link) {
+ $link['href'] = $link['link_path'];
+ $link['options'] = unserialize($link['options']);
+ $all_books[$link['bid']] = $link;
+ }
+ }
+ }
+
+ return $all_books;
+}
+
+/**
+ * Implements hook_form_BASE_FORM_ID_alter() for node_form().
+ *
+ * Adds the book fieldset to the node form.
+ *
+ * @see book_pick_book_nojs_submit()
+ */
+function book_form_node_form_alter(&$form, &$form_state, $form_id) {
+ $node = $form['#node'];
+ $access = user_access('administer book outlines');
+ if (!$access) {
+ if (user_access('add content to books') && ((!empty($node->book['mlid']) && !empty($node->nid)) || book_type_is_allowed($node->type))) {
+ // Already in the book hierarchy, or this node type is allowed.
+ $access = TRUE;
+ }
+ }
+
+ if ($access) {
+ _book_add_form_elements($form, $form_state, $node);
+ // Since the "Book" dropdown can't trigger a form submission when
+ // JavaScript is disabled, add a submit button to do that. book.css hides
+ // this button when JavaScript is enabled.
+ $form['book']['pick-book'] = array(
+ '#type' => 'submit',
+ '#value' => t('Change book (update list of parents)'),
+ '#submit' => array('book_pick_book_nojs_submit'),
+ '#weight' => 20,
+ );
+ }
+}
+
+/**
+ * Form submission handler for node_form().
+ *
+ * This handler is run when JavaScript is disabled. It triggers the form to
+ * rebuild so that the "Parent item" options are changed to reflect the newly
+ * selected book. When JavaScript is enabled, the submit button that triggers
+ * this handler is hidden, and the "Book" dropdown directly triggers the
+ * book_form_update() Ajax callback instead.
+ *
+ * @see book_form_update()
+ * @see book_form_node_form_alter()
+ */
+function book_pick_book_nojs_submit($form, &$form_state) {
+ $form_state['node']->book = $form_state['values']['book'];
+ $form_state['rebuild'] = TRUE;
+}
+
+/**
+ * Builds the parent selection form element for the node form or outline tab.
+ *
+ * This function is also called when generating a new set of options during the
+ * Ajax callback, so an array is returned that can be used to replace an
+ * existing form element.
+ *
+ * @param $book_link
+ * A fully loaded menu link that is part of the book hierarchy.
+ *
+ * @return
+ * A parent selection form element.
+ */
+function _book_parent_select($book_link) {
+ if (variable_get('menu_override_parent_selector', FALSE)) {
+ return array();
+ }
+ // Offer a message or a drop-down to choose a different parent page.
+ $form = array(
+ '#type' => 'hidden',
+ '#value' => -1,
+ '#prefix' => '<div id="edit-book-plid-wrapper">',
+ '#suffix' => '</div>',
+ );
+
+ if ($book_link['nid'] === $book_link['bid']) {
+ // This is a book - at the top level.
+ if ($book_link['original_bid'] === $book_link['bid']) {
+ $form['#prefix'] .= '<em>' . t('This is the top-level page in this book.') . '</em>';
+ }
+ else {
+ $form['#prefix'] .= '<em>' . t('This will be the top-level page in this book.') . '</em>';
+ }
+ }
+ elseif (!$book_link['bid']) {
+ $form['#prefix'] .= '<em>' . t('No book selected.') . '</em>';
+ }
+ else {
+ $form = array(
+ '#type' => 'select',
+ '#title' => t('Parent item'),
+ '#default_value' => $book_link['plid'],
+ '#description' => t('The parent page in the book. The maximum depth for a book and all child pages is !maxdepth. Some pages in the selected book may not be available as parents if selecting them would exceed this limit.', array('!maxdepth' => MENU_MAX_DEPTH)),
+ '#options' => book_toc($book_link['bid'], $book_link['parent_depth_limit'], array($book_link['mlid'])),
+ '#attributes' => array('class' => array('book-title-select')),
+ '#prefix' => '<div id="edit-book-plid-wrapper">',
+ '#suffix' => '</div>',
+ );
+ }
+
+ return $form;
+}
+
+/**
+ * Builds the common elements of the book form for the node and outline forms.
+ *
+ * @param $node
+ * The node whose form is being viewed.
+ */
+function _book_add_form_elements(&$form, &$form_state, $node) {
+ // If the form is being processed during the Ajax callback of our book bid
+ // dropdown, then $form_state will hold the value that was selected.
+ if (isset($form_state['values']['book'])) {
+ $node->book = $form_state['values']['book'];
+ }
+
+ $form['book'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Book outline'),
+ '#weight' => 10,
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#group' => 'additional_settings',
+ '#attributes' => array(
+ 'class' => array('book-outline-form'),
+ ),
+ '#attached' => array(
+ 'js' => array(drupal_get_path('module', 'book') . '/book.js'),
+ ),
+ '#tree' => TRUE,
+ );
+ foreach (array('menu_name', 'mlid', 'nid', 'router_path', 'has_children', 'options', 'module', 'original_bid', 'parent_depth_limit') as $key) {
+ $form['book'][$key] = array(
+ '#type' => 'value',
+ '#value' => $node->book[$key],
+ );
+ }
+
+ $form['book']['plid'] = _book_parent_select($node->book);
+
+ // @see _book_admin_table_tree(). The weight may be larger than 15.
+ $form['book']['weight'] = array(
+ '#type' => 'weight',
+ '#title' => t('Weight'),
+ '#default_value' => $node->book['weight'],
+ '#delta' => max(15, abs($node->book['weight'])),
+ '#weight' => 5,
+ '#description' => t('Pages at a given level are ordered first by weight and then by title.'),
+ );
+ $options = array();
+ $nid = isset($node->nid) ? $node->nid : 'new';
+
+ if (isset($node->nid) && ($nid == $node->book['original_bid']) && ($node->book['parent_depth_limit'] == 0)) {
+ // This is the top level node in a maximum depth book and thus cannot be moved.
+ $options[$node->nid] = $node->title;
+ }
+ else {
+ foreach (book_get_books() as $book) {
+ $options[$book['nid']] = $book['title'];
+ }
+ }
+
+ if (user_access('create new books') && ($nid == 'new' || ($nid != $node->book['original_bid']))) {
+ // The node can become a new book, if it is not one already.
+ $options = array($nid => '<' . t('create a new book') . '>') + $options;
+ }
+ if (!$node->book['mlid']) {
+ // The node is not currently in the hierarchy.
+ $options = array(0 => '<' . t('none') . '>') + $options;
+ }
+
+ // Add a drop-down to select the destination book.
+ $form['book']['bid'] = array(
+ '#type' => 'select',
+ '#title' => t('Book'),
+ '#default_value' => $node->book['bid'],
+ '#options' => $options,
+ '#access' => (bool) $options,
+ '#description' => t('Your page will be a part of the selected book.'),
+ '#weight' => -5,
+ '#attributes' => array('class' => array('book-title-select')),
+ '#ajax' => array(
+ 'callback' => 'book_form_update',
+ 'wrapper' => 'edit-book-plid-wrapper',
+ 'effect' => 'fade',
+ 'speed' => 'fast',
+ ),
+ );
+}
+
+/**
+ * Renders a new parent page select element when the book selection changes.
+ *
+ * This function is called via Ajax when the selected book is changed on a node
+ * or book outline form.
+ *
+ * @return
+ * The rendered parent page select element.
+ */
+function book_form_update($form, $form_state) {
+ return $form['book']['plid'];
+}
+
+/**
+ * Handles additions and updates to the book outline.
+ *
+ * This common helper function performs all additions and updates to the book
+ * outline through node addition, node editing, node deletion, or the outline
+ * tab.
+ *
+ * @param $node
+ * The node that is being saved, added, deleted, or moved.
+ *
+ * @return
+ * TRUE if the menu link was saved; FALSE otherwise.
+ */
+function _book_update_outline($node) {
+ if (empty($node->book['bid'])) {
+ return FALSE;
+ }
+ $new = empty($node->book['mlid']);
+
+ $node->book['link_path'] = 'node/' . $node->nid;
+ $node->book['link_title'] = $node->title;
+ $node->book['parent_mismatch'] = FALSE; // The normal case.
+
+ if ($node->book['bid'] == $node->nid) {
+ $node->book['plid'] = 0;
+ $node->book['menu_name'] = book_menu_name($node->nid);
+ }
+ else {
+ // Check in case the parent is not is this book; the book takes precedence.
+ if (!empty($node->book['plid'])) {
+ $parent = db_query("SELECT * FROM {book} WHERE mlid = :mlid", array(
+ ':mlid' => $node->book['plid'],
+ ))->fetchAssoc();
+ }
+ if (empty($node->book['plid']) || !$parent || $parent['bid'] != $node->book['bid']) {
+ $node->book['plid'] = db_query("SELECT mlid FROM {book} WHERE nid = :nid", array(
+ ':nid' => $node->book['bid'],
+ ))->fetchField();
+ $node->book['parent_mismatch'] = TRUE; // Likely when JS is disabled.
+ }
+ }
+
+ if (menu_link_save($node->book)) {
+ if ($new) {
+ // Insert new.
+ db_insert('book')
+ ->fields(array(
+ 'nid' => $node->nid,
+ 'mlid' => $node->book['mlid'],
+ 'bid' => $node->book['bid'],
+ ))
+ ->execute();
+ // Reset the cache of stored books.
+ drupal_static_reset('book_get_books');
+ }
+ else {
+ if ($node->book['bid'] != db_query("SELECT bid FROM {book} WHERE nid = :nid", array(
+ ':nid' => $node->nid,
+ ))->fetchField()) {
+ // Update the bid for this page and all children.
+ book_update_bid($node->book);
+ // Reset the cache of stored books.
+ drupal_static_reset('book_get_books');
+ }
+ }
+
+ return TRUE;
+ }
+
+ // Failed to save the menu link.
+ return FALSE;
+}
+
+/**
+ * Updates the book ID of a page and its children when it moves to a new book.
+ *
+ * @param $book_link
+ * A fully loaded menu link that is part of the book hierarchy.
+ */
+function book_update_bid($book_link) {
+ $query = db_select('menu_links');
+ $query->addField('menu_links', 'mlid');
+ for ($i = 1; $i <= MENU_MAX_DEPTH && $book_link["p$i"]; $i++) {
+ $query->condition("p$i", $book_link["p$i"]);
+ }
+ $mlids = $query->execute()->fetchCol();
+
+ if ($mlids) {
+ db_update('book')
+ ->fields(array('bid' => $book_link['bid']))
+ ->condition('mlid', $mlids, 'IN')
+ ->execute();
+ }
+}
+
+/**
+ * Gets the book menu tree for a page and returns it as a linear array.
+ *
+ * @param $book_link
+ * A fully loaded menu link that is part of the book hierarchy.
+ *
+ * @return
+ * A linear array of menu links in the order that the links are shown in the
+ * menu, so the previous and next pages are the elements before and after the
+ * element corresponding to the current node. The children of the current node
+ * (if any) will come immediately after it in the array, and links will only
+ * be fetched as deep as one level deeper than $book_link.
+ */
+function book_get_flat_menu($book_link) {
+ $flat = &drupal_static(__FUNCTION__, array());
+
+ if (!isset($flat[$book_link['mlid']])) {
+ // Call menu_tree_all_data() to take advantage of the menu system's caching.
+ $tree = menu_tree_all_data($book_link['menu_name'], $book_link, $book_link['depth'] + 1);
+ $flat[$book_link['mlid']] = array();
+ _book_flatten_menu($tree, $flat[$book_link['mlid']]);
+ }
+
+ return $flat[$book_link['mlid']];
+}
+
+/**
+ * Recursively converts a tree of menu links to a flat array.
+ *
+ * @param $tree
+ * A tree of menu links in an array.
+ * @param $flat
+ * A flat array of the menu links from $tree, passed by reference.
+ *
+ * @see book_get_flat_menu().
+ */
+function _book_flatten_menu($tree, &$flat) {
+ foreach ($tree as $data) {
+ if (!$data['link']['hidden']) {
+ $flat[$data['link']['mlid']] = $data['link'];
+ if ($data['below']) {
+ _book_flatten_menu($data['below'], $flat);
+ }
+ }
+ }
+}
+
+/**
+ * Fetches the menu link for the previous page of the book.
+ *
+ * @param $book_link
+ * A fully loaded menu link that is part of the book hierarchy.
+ *
+ * @return
+ * A fully loaded menu link for the page before the one represented in
+ * $book_link.
+ */
+function book_prev($book_link) {
+ // If the parent is zero, we are at the start of a book.
+ if ($book_link['plid'] == 0) {
+ return NULL;
+ }
+ $flat = book_get_flat_menu($book_link);
+ // Assigning the array to $flat resets the array pointer for use with each().
+ $curr = NULL;
+ do {
+ $prev = $curr;
+ list($key, $curr) = each($flat);
+ } while ($key && $key != $book_link['mlid']);
+
+ if ($key == $book_link['mlid']) {
+ // The previous page in the book may be a child of the previous visible link.
+ if ($prev['depth'] == $book_link['depth'] && $prev['has_children']) {
+ // The subtree will have only one link at the top level - get its data.
+ $tree = book_menu_subtree_data($prev);
+ $data = array_shift($tree);
+ // The link of interest is the last child - iterate to find the deepest one.
+ while ($data['below']) {
+ $data = end($data['below']);
+ }
+
+ return $data['link'];
+ }
+ else {
+ return $prev;
+ }
+ }
+}
+
+/**
+ * Fetches the menu link for the next page of the book.
+ *
+ * @param $book_link
+ * A fully loaded menu link that is part of the book hierarchy.
+ *
+ * @return
+ * A fully loaded menu link for the page after the one represented in
+ * $book_link.
+ */
+function book_next($book_link) {
+ $flat = book_get_flat_menu($book_link);
+ // Assigning the array to $flat resets the array pointer for use with each().
+ do {
+ list($key, $curr) = each($flat);
+ }
+ while ($key && $key != $book_link['mlid']);
+
+ if ($key == $book_link['mlid']) {
+ return current($flat);
+ }
+}
+
+/**
+ * Formats the menu links for the child pages of the current page.
+ *
+ * @param $book_link
+ * A fully loaded menu link that is part of the book hierarchy.
+ *
+ * @return
+ * HTML for the links to the child pages of the current page.
+ */
+function book_children($book_link) {
+ $flat = book_get_flat_menu($book_link);
+
+ $children = array();
+
+ if ($book_link['has_children']) {
+ // Walk through the array until we find the current page.
+ do {
+ $link = array_shift($flat);
+ }
+ while ($link && ($link['mlid'] != $book_link['mlid']));
+ // Continue though the array and collect the links whose parent is this page.
+ while (($link = array_shift($flat)) && $link['plid'] == $book_link['mlid']) {
+ $data['link'] = $link;
+ $data['below'] = '';
+ $children[] = $data;
+ }
+ }
+
+ if ($children) {
+ $elements = menu_tree_output($children);
+ return drupal_render($elements);
+ }
+ return '';
+}
+
+/**
+ * Generates the corresponding menu name from a book ID.
+ *
+ * @param $bid
+ * The book ID for which to make a menu name.
+ *
+ * @return
+ * The menu name.
+ */
+function book_menu_name($bid) {
+ return 'book-toc-' . $bid;
+}
+
+/**
+ * Implements hook_node_load().
+ */
+function book_node_load($nodes, $types) {
+ $result = db_query("SELECT * FROM {book} b INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE b.nid IN (:nids)", array(':nids' => array_keys($nodes)), array('fetch' => PDO::FETCH_ASSOC));
+ foreach ($result as $record) {
+ $nodes[$record['nid']]->book = $record;
+ $nodes[$record['nid']]->book['href'] = $record['link_path'];
+ $nodes[$record['nid']]->book['title'] = $record['link_title'];
+ $nodes[$record['nid']]->book['options'] = unserialize($record['options']);
+ }
+}
+
+/**
+ * Implements hook_node_view().
+ */
+function book_node_view($node, $view_mode) {
+ if ($view_mode == 'full') {
+ if (!empty($node->book['bid']) && empty($node->in_preview)) {
+ $node->content['book_navigation'] = array(
+ '#markup' => theme('book_navigation', array('book_link' => $node->book)),
+ '#weight' => 100,
+ );
+ }
+ }
+
+ if ($view_mode != 'rss') {
+ book_node_view_link($node, $view_mode);
+ }
+}
+
+/**
+ * Implements hook_page_alter().
+ *
+ * Adds the book menu to the list of menus used to build the active trail when
+ * viewing a book page.
+ */
+function book_page_alter(&$page) {
+ if (($node = menu_get_object()) && !empty($node->book['bid'])) {
+ $active_menus = menu_get_active_menu_names();
+ $active_menus[] = $node->book['menu_name'];
+ menu_set_active_menu_names($active_menus);
+ }
+}
+
+/**
+ * Implements hook_node_presave().
+ */
+function book_node_presave($node) {
+ // Always save a revision for non-administrators.
+ if (!empty($node->book['bid']) && !user_access('administer nodes')) {
+ $node->revision = 1;
+ // The database schema requires a log message for every revision.
+ if (!isset($node->log)) {
+ $node->log = '';
+ }
+ }
+ // Make sure a new node gets a new menu link.
+ if (empty($node->nid)) {
+ $node->book['mlid'] = NULL;
+ }
+}
+
+/**
+ * Implements hook_node_insert().
+ */
+function book_node_insert($node) {
+ if (!empty($node->book['bid'])) {
+ if ($node->book['bid'] == 'new') {
+ // New nodes that are their own book.
+ $node->book['bid'] = $node->nid;
+ }
+ $node->book['nid'] = $node->nid;
+ $node->book['menu_name'] = book_menu_name($node->book['bid']);
+ _book_update_outline($node);
+ }
+}
+
+/**
+ * Implements hook_node_update().
+ */
+function book_node_update($node) {
+ if (!empty($node->book['bid'])) {
+ if ($node->book['bid'] == 'new') {
+ // New nodes that are their own book.
+ $node->book['bid'] = $node->nid;
+ }
+ $node->book['nid'] = $node->nid;
+ $node->book['menu_name'] = book_menu_name($node->book['bid']);
+ _book_update_outline($node);
+ }
+}
+
+/**
+ * Implements hook_node_delete().
+ */
+function book_node_delete($node) {
+ if (!empty($node->book['bid'])) {
+ if ($node->nid == $node->book['bid']) {
+ // Handle deletion of a top-level post.
+ $result = db_query("SELECT b.nid FROM {menu_links} ml INNER JOIN {book} b on b.mlid = ml.mlid WHERE ml.plid = :plid", array(
+ ':plid' => $node->book['mlid']
+ ));
+ foreach ($result as $child) {
+ $child_node = node_load($child->nid);
+ $child_node->book['bid'] = $child_node->nid;
+ _book_update_outline($child_node);
+ }
+ }
+ menu_link_delete($node->book['mlid']);
+ db_delete('book')
+ ->condition('mlid', $node->book['mlid'])
+ ->execute();
+ drupal_static_reset('book_get_books');
+ }
+}
+
+/**
+ * Implements hook_node_prepare().
+ */
+function book_node_prepare($node) {
+ // Prepare defaults for the add/edit form.
+ if (empty($node->book) && (user_access('add content to books') || user_access('administer book outlines'))) {
+ $node->book = array();
+
+ if (empty($node->nid) && isset($_GET['parent']) && is_numeric($_GET['parent'])) {
+ // Handle "Add child page" links:
+ $parent = book_link_load($_GET['parent']);
+
+ if ($parent && $parent['access']) {
+ $node->book['bid'] = $parent['bid'];
+ $node->book['plid'] = $parent['mlid'];
+ $node->book['menu_name'] = $parent['menu_name'];
+ }
+ }
+ // Set defaults.
+ $node->book += _book_link_defaults(!empty($node->nid) ? $node->nid : 'new');
+ }
+ else {
+ if (isset($node->book['bid']) && !isset($node->book['original_bid'])) {
+ $node->book['original_bid'] = $node->book['bid'];
+ }
+ }
+ // Find the depth limit for the parent select.
+ if (isset($node->book['bid']) && !isset($node->book['parent_depth_limit'])) {
+ $node->book['parent_depth_limit'] = _book_parent_depth_limit($node->book);
+ }
+}
+
+/**
+ * Finds the depth limit for items in the parent select.
+ *
+ * @param $book_link
+ * A fully loaded menu link that is part of the book hierarchy.
+ *
+ * @return
+ * The depth limit for items in the parent select.
+ */
+function _book_parent_depth_limit($book_link) {
+ return MENU_MAX_DEPTH - 1 - (($book_link['mlid'] && $book_link['has_children']) ? menu_link_children_relative_depth($book_link) : 0);
+}
+
+/**
+ * Implements hook_form_FORM_ID_alter() for node_delete_confirm().
+ *
+ * Alters the confirm form for a single node deletion.
+ *
+ * @see node_delete_confirm()
+ */
+function book_form_node_delete_confirm_alter(&$form, $form_state) {
+ $node = node_load($form['nid']['#value']);
+
+ if (isset($node->book) && $node->book['has_children']) {
+ $form['book_warning'] = array(
+ '#markup' => '<p>' . t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', array('%title' => $node->title)) . '</p>',
+ '#weight' => -10,
+ );
+ }
+}
+
+/**
+ * Returns an array with default values for a book page's menu link.
+ *
+ * @param $nid
+ * The ID of the node whose menu link is being created.
+ *
+ * @return
+ * The default values for the menu link.
+ */
+function _book_link_defaults($nid) {
+ return array('original_bid' => 0, 'menu_name' => '', 'nid' => $nid, 'bid' => 0, 'router_path' => 'node/%', 'plid' => 0, 'mlid' => 0, 'has_children' => 0, 'weight' => 0, 'module' => 'book', 'options' => array());
+}
+
+/**
+ * Processes variables for book-all-books-block.tpl.php.
+ *
+ * All non-renderable elements are removed so that the template has full access
+ * to the structured data but can also simply iterate over all elements and
+ * render them (as in the default template).
+ *
+ * @param $variables
+ * An associative array containing the following key:
+ * - book_menus
+ *
+ * @see book-all-books-block.tpl.php
+ */
+function template_preprocess_book_all_books_block(&$variables) {
+ // Remove all non-renderable elements.
+ $elements = $variables['book_menus'];
+ $variables['book_menus'] = array();
+ foreach (element_children($elements) as $index) {
+ $variables['book_menus'][$index] = $elements[$index];
+ }
+}
+
+/**
+ * Processes variables for book-navigation.tpl.php.
+ *
+ * @param $variables
+ * An associative array containing the following key:
+ * - book_link
+ *
+ * @see book-navigation.tpl.php
+ */
+function template_preprocess_book_navigation(&$variables) {
+ $book_link = $variables['book_link'];
+
+ // Provide extra variables for themers. Not needed by default.
+ $variables['book_id'] = $book_link['bid'];
+ $variables['book_title'] = check_plain($book_link['link_title']);
+ $variables['book_url'] = 'node/' . $book_link['bid'];
+ $variables['current_depth'] = $book_link['depth'];
+ $variables['tree'] = '';
+
+ if ($book_link['mlid']) {
+ $variables['tree'] = book_children($book_link);
+
+ if ($prev = book_prev($book_link)) {
+ $prev_href = url($prev['href']);
+ drupal_add_html_head_link(array('rel' => 'prev', 'href' => $prev_href));
+ $variables['prev_url'] = $prev_href;
+ $variables['prev_title'] = check_plain($prev['title']);
+ }
+
+ if ($book_link['plid'] && $parent = book_link_load($book_link['plid'])) {
+ $parent_href = url($parent['href']);
+ drupal_add_html_head_link(array('rel' => 'up', 'href' => $parent_href));
+ $variables['parent_url'] = $parent_href;
+ $variables['parent_title'] = check_plain($parent['title']);
+ }
+
+ if ($next = book_next($book_link)) {
+ $next_href = url($next['href']);
+ drupal_add_html_head_link(array('rel' => 'next', 'href' => $next_href));
+ $variables['next_url'] = $next_href;
+ $variables['next_title'] = check_plain($next['title']);
+ }
+ }
+
+ $variables['has_links'] = FALSE;
+ // Link variables to filter for values and set state of the flag variable.
+ $links = array('prev_url', 'prev_title', 'parent_url', 'parent_title', 'next_url', 'next_title');
+ foreach ($links as $link) {
+ if (isset($variables[$link])) {
+ // Flag when there is a value.
+ $variables['has_links'] = TRUE;
+ }
+ else {
+ // Set empty to prevent notices.
+ $variables[$link] = '';
+ }
+ }
+}
+
+/**
+ * Recursively processes and formats menu items for book_toc().
+ *
+ * This helper function recursively modifies the table of contents array for
+ * each item in the menu tree, ignoring items in the exclude array or at a depth
+ * greater than the limit. Truncates titles over thirty characters and appends
+ * an indentation string incremented by depth.
+ *
+ * @param $tree
+ * The data structure of the book's menu tree. Includes hidden links.
+ * @param $indent
+ * A string appended to each menu item title. Increments by '--' per depth
+ * level.
+ * @param $toc
+ * Reference to the table of contents array. This is modified in place, so the
+ * function does not have a return value.
+ * @param $exclude
+ * (optional) An array of menu link ID values. Any link whose menu link ID is
+ * in this array will be excluded (along with its children). Defaults to an
+ * empty array.
+ * @param $depth_limit
+ * Any link deeper than this value will be excluded (along with its children).
+ */
+function _book_toc_recurse($tree, $indent, &$toc, $exclude, $depth_limit) {
+ foreach ($tree as $data) {
+ if ($data['link']['depth'] > $depth_limit) {
+ // Don't iterate through any links on this level.
+ break;
+ }
+
+ if (!in_array($data['link']['mlid'], $exclude)) {
+ $toc[$data['link']['mlid']] = $indent . ' ' . truncate_utf8($data['link']['title'], 30, TRUE, TRUE);
+ if ($data['below']) {
+ _book_toc_recurse($data['below'], $indent . '--', $toc, $exclude, $depth_limit);
+ }
+ }
+ }
+}
+
+/**
+ * Returns an array of book pages in table of contents order.
+ *
+ * @param $bid
+ * The ID of the book whose pages are to be listed.
+ * @param $depth_limit
+ * Any link deeper than this value will be excluded (along with its children).
+ * @param $exclude
+ * Optional array of menu link ID values. Any link whose menu link ID is in
+ * this array will be excluded (along with its children).
+ *
+ * @return
+ * An array of (menu link ID, title) pairs for use as options for selecting a
+ * book page.
+ */
+function book_toc($bid, $depth_limit, $exclude = array()) {
+ $tree = menu_tree_all_data(book_menu_name($bid));
+ $toc = array();
+ _book_toc_recurse($tree, '', $toc, $exclude, $depth_limit);
+
+ return $toc;
+}
+
+/**
+ * Processes variables for book-export-html.tpl.php.
+ *
+ * @param $variables
+ * An associative array containing the following keys:
+ * - title
+ * - contents
+ * - depth
+ *
+ * @see book-export-html.tpl.php
+ */
+function template_preprocess_book_export_html(&$variables) {
+ global $base_url, $language;
+
+ $variables['title'] = check_plain($variables['title']);
+ $variables['base_url'] = $base_url;
+ $variables['language'] = $language;
+ $variables['language_rtl'] = ($language->direction == LANGUAGE_RTL);
+ $variables['head'] = drupal_get_html_head();
+ $variables['dir'] = $language->direction ? 'rtl' : 'ltr';
+}
+
+/**
+ * Traverses the book tree to build printable or exportable output.
+ *
+ * During the traversal, the $visit_func() callback is applied to each node and
+ * is called recursively for each child of the node (in weight, title order).
+ *
+ * @param $tree
+ * A subtree of the book menu hierarchy, rooted at the current page.
+ * @param $visit_func
+ * A function callback to be called upon visiting a node in the tree.
+ *
+ * @return
+ * The output generated in visiting each node.
+ */
+function book_export_traverse($tree, $visit_func) {
+ $output = '';
+
+ foreach ($tree as $data) {
+ // Note- access checking is already performed when building the tree.
+ if ($node = node_load($data['link']['nid'], FALSE)) {
+ $children = '';
+
+ if ($data['below']) {
+ $children = book_export_traverse($data['below'], $visit_func);
+ }
+
+ if (function_exists($visit_func)) {
+ $output .= call_user_func($visit_func, $node, $children);
+ }
+ else {
+ // Use the default function.
+ $output .= book_node_export($node, $children);
+ }
+ }
+ }
+
+ return $output;
+}
+
+/**
+ * Generates printer-friendly HTML for a node.
+ *
+ * @param $node
+ * The node that will be output.
+ * @param $children
+ * (optional) All the rendered child nodes within the current node. Defaults
+ * to an empty string.
+ *
+ * @return
+ * The HTML generated for the given node.
+ *
+ * @see book_export_traverse()
+ */
+function book_node_export($node, $children = '') {
+ $build = node_view($node, 'print');
+ unset($build['#theme']);
+ // @todo Rendering should ha