diff --git a/commons.make b/commons.make deleted file mode 100644 index 8c38d61..0000000 --- a/commons.make +++ /dev/null @@ -1,152 +0,0 @@ - -api = 2 -core = 7.x - -; Commons modules. - - -projects[commons_activity_streams][type] = "module" -projects[commons_activity_streams][subdir] = "commons" -projects[commons_activity_streams][download][url] = "http://git.drupal.org/project/commons_activity_streams.git" -projects[commons_activity_streams][download][branch] = "7.x-3.x" - -projects[commons_featured][type] = "module" -projects[commons_featured][subdir] = "commons" -projects[commons_featured][download][url] = "http://git.drupal.org/project/commons_featured.git" -projects[commons_featured][download][branch] = "7.x-3.x" - -projects[commons_notices][type] = "module" -projects[commons_notices][subdir] = "commons" -projects[commons_notices][download][url] = "http://git.drupal.org/project/commons_notices.git" -projects[commons_notices][download][branch] = "7.x-3.x" - -projects[commons_profile_social][type] = "module" -projects[commons_profile_social][subdir] = "commons" -projects[commons_profile_social][download][url] = "http://git.drupal.org/project/commons_profile_social.git" -projects[commons_profile_social][download][branch] = "7.x-3.x" - -projects[commons_user_profile_pages][type] = "module" -projects[commons_user_profile_pages][subdir] = "commons" -projects[commons_user_profile_pages][download][url] = "http://git.drupal.org/project/commons_user_profile_pages.git" -projects[commons_user_profile_pages][download][branch] = "7.x-3.x" - -projects[commons_body][type] = "module" -projects[commons_body][subdir] = "commons" -projects[commons_body][download][url] = "http://git.drupal.org/project/commons_body.git" -projects[commons_body][download][branch] = "7.x-3.x" - -projects[commons_follow][type] = "module" -projects[commons_follow][subdir] = "commons" -projects[commons_follow][download][url] = "http://git.drupal.org/project/commons_follow.git" -projects[commons_follow][download][branch] = "7.x-3.x" - -projects[commons_notify][type] = "module" -projects[commons_notify][subdir] = "commons" -projects[commons_notify][download][url] = "http://git.drupal.org/project/commons_notify.git" -projects[commons_notify][download][branch] = "7.x-3.x" - -projects[commons_utility_links][type] = "module" -projects[commons_utility_links][subdir] = "commons" -projects[commons_utility_links][download][url] = "http://git.drupal.org/project/commons_utility_links.git" -projects[commons_utility_links][download][branch] = "7.x-3.x" -; add utility links block to openstack theme instead of commons_origins -projects[commons_utility_links][patch][] = "patches/0001-utility-links-block-install-theme.patch" - -projects[commons_bw][type] = "module" -projects[commons_bw][subdir] = "commons" -projects[commons_bw][download][url] = "http://git.drupal.org/project/commons_bw.git" -projects[commons_bw][download][branch] = "7.x-3.x" - -projects[commons_groups][type] = "module" -projects[commons_groups][subdir] = "commons" -projects[commons_groups][download][url] = "http://git.drupal.org/project/commons_groups.git" -projects[commons_groups][download][branch] = "7.x-3.x" - -; Error notice when creating or updating groups with locale module enabled -; https://drupal.org/node/2039619#comment-7854797 -projects[commons_groups][patch][] = "patches/2039619-remove-privacy-settings-wrapper-4.patch" - -projects[commons_pages][type] = "module" -projects[commons_pages][subdir] = "commons" -projects[commons_pages][download][url] = "http://git.drupal.org/project/commons_pages.git" -projects[commons_pages][download][branch] = "7.x-3.x" - -projects[commons_radioactivity][type] = "module" -projects[commons_radioactivity][subdir] = "commons" -projects[commons_radioactivity][download][url] = "http://git.drupal.org/project/commons_radioactivity.git" -projects[commons_radioactivity][download][branch] = "7.x-3.x" - -projects[commons_content_moderation][type] = "module" -projects[commons_content_moderation][subdir] = "commons" -projects[commons_content_moderation][download][url] = "http://git.drupal.org/project/commons_content_moderation.git" -projects[commons_content_moderation][download][branch] = "7.x-3.x" - -projects[commons_like][type] = "module" -projects[commons_like][subdir] = "commons" -projects[commons_like][download][url] = "http://git.drupal.org/project/commons_like.git" -projects[commons_like][download][branch] = "7.x-3.x" - -projects[commons_search][type] = "module" -projects[commons_search][subdir] = "commons" -projects[commons_search][download][url] = "http://git.drupal.org/project/commons_search.git" -projects[commons_search][download][branch] = "7.x-3.x" - -projects[commons_wysiwyg][type] = "module" -projects[commons_wysiwyg][subdir] = "commons" -projects[commons_wysiwyg][download][url] = "http://git.drupal.org/project/commons_wysiwyg.git" -projects[commons_wysiwyg][download][branch] = "7.x-3.x" - -projects[commons_documents][type] = "module" -projects[commons_documents][subdir] = "commons" -projects[commons_documents][download][url] = "http://git.drupal.org/project/commons_documents.git" -projects[commons_documents][download][branch] = "7.x-3.x" - -projects[commons_location][type] = "module" -projects[commons_location][subdir] = "commons" -projects[commons_location][download][url] = "http://git.drupal.org/project/commons_location.git" -projects[commons_location][download][branch] = "7.x-3.x" - -projects[commons_posts][type] = "module" -projects[commons_posts][subdir] = "commons" -projects[commons_posts][download][url] = "http://git.drupal.org/project/commons_posts.git" -projects[commons_posts][download][branch] = "7.x-3.x" - -projects[commons_site_homepage][type] = "module" -projects[commons_site_homepage][subdir] = "commons" -projects[commons_site_homepage][download][url] = "http://git.drupal.org/project/commons_site_homepage.git" -projects[commons_site_homepage][download][branch] = "7.x-3.x" - -projects[commons_events][type] = "module" -projects[commons_events][subdir] = "commons" -projects[commons_events][download][url] = "http://git.drupal.org/project/commons_events.git" -projects[commons_events][download][branch] = "7.x-3.x" - -projects[commons_misc][type] = "module" -projects[commons_misc][subdir] = "commons" -projects[commons_misc][download][url] = "http://git.drupal.org/project/commons_misc.git" -projects[commons_misc][download][branch] = "7.x-3.x" - -projects[commons_profile_base][type] = "module" -projects[commons_profile_base][subdir] = "commons" -projects[commons_profile_base][download][url] = "http://git.drupal.org/project/commons_profile_base.git" -projects[commons_profile_base][download][branch] = "7.x-3.x" - -projects[commons_topics][type] = "module" -projects[commons_topics][subdir] = "commons" -projects[commons_topics][download][url] = "http://git.drupal.org/project/commons_topics.git" -projects[commons_topics][download][branch] = "7.x-3.x" - -projects[commons_social_sharing][type] = "module" -projects[commons_social_sharing][subdir] = "commons" -projects[commons_social_sharing][download][url] = "http://git.drupal.org/project/commons_social_sharing.git" -projects[commons_social_sharing][download][branch] = "7.x-3.x" - -projects[commons_trusted_contacts][type] = "module" -projects[commons_trusted_contacts][subdir] = "commons" -projects[commons_trusted_contacts][download][url] = "http://git.drupal.org/project/commons_trusted_contacts.git" -projects[commons_trusted_contacts][download][branch] = "7.x-3.x" - -projects[commons_origins][type] = "theme" -projects[commons_origins][subdir] = "commons" -projects[commons_origins][download][url] = "http://git.drupal.org/project/commons_origins.git" -projects[commons_origins][download][branch] = "7.x-3.x" diff --git a/drupal-org-core.make b/drupal-org-core.make index ba988f2..4065fb7 100644 --- a/drupal-org-core.make +++ b/drupal-org-core.make @@ -3,19 +3,9 @@ core = 7.x ; Download Drupal core and apply core patches if needed. projects[drupal][type] = "core" -projects[drupal][version] = "7.27" +projects[drupal][version] = "7.28" projects[drupal][download][type] = get -projects[drupal][download][url] = http://ftp.drupal.org/files/projects/drupal-7.27.tar.gz - -; Hide the profiles under /profiles, so Commons is the only one. This allows -; the installation to start at the Language selection screen, bypassing a -; baffling and silly choice, especially for non-native speakers. -; http://drupal.org/node/1780598#comment-6480088 -projects[drupal][patch][] = http://drupal.org/files/spark-install-1780598-5.patch -; This requires a core bug fix to not show the profile selection page when only -; one profile is visible. -; http://drupal.org/node/1074108#comment-6463662 -projects[drupal][patch][] = http://drupal.org/files/1074108-skip-profile-16-7.x-do-not-test.patch +projects[drupal][download][url] = http://ftp.drupal.org/files/projects/drupal-7.28.tar.gz ; This patch allows install profile to list requirements on the install page ; http://drupal.org/node/1971072 @@ -28,3 +18,15 @@ projects[drupal][patch][] = http://drupal.org/files/drupal-7.x-allow_profile_cha ; Allow to specify SCRIPT HTML element attributes through drupal_add_js() ; http://drupal.org/node/1664602#comment-6221066 projects[drupal][patch][] = http://drupal.org/files/1664602-1.patch + +; Optimize node access queries. +; https://drupal.org/comment/8516319#comment-8516319 +projects[drupal][patch][] = https://drupal.org/files/issues/drupal-optimize_node_access_queries-106721-D7-71-do-not-test.patch + +; Statically cache node access grants +; https://drupal.org/comment/8495029#comment-8495029 +projects[drupal][patch][] = https://drupal.org/files/issues/node_access_grants-static-cache-11.patch + +; File_get_file_references is slow and buggy +; https://drupal.org/node/1805690#comment-8734045 +projects[drupal][patch][] = https://drupal.org/files/issues/1805690_11.patch \ No newline at end of file diff --git a/drupal-org.make b/drupal-org.make index 849b849..1228d44 100644 --- a/drupal-org.make +++ b/drupal-org.make @@ -1,9 +1,6 @@ api = 2 core = 7.x -includes[commons] = "commons.make" -includes[translations] = "groups-translations.make" - ; Contributed modules. projects[addressfield][type] = "module" @@ -12,22 +9,29 @@ projects[addressfield][version] = "1.0-beta5" projects[addressfield_tokens][type] = "module" projects[addressfield_tokens][subdir] = "contrib" -projects[addressfield_tokens][version] = "1.3" +projects[addressfield_tokens][version] = "1.4" -projects[advancedqueue][type] = "module" -projects[advancedqueue][subdir] = "contrib" -projects[advancedqueue][version] = "1.0-alpha2" +projects[admin_icons][type] = "module" +projects[admin_icons][subdir] = "contrib" +projects[admin_icons][download][type] = "git" +projects[admin_icons][download][url] = "http://git.drupal.org/project/admin_icons.git" +projects[admin_icons][download][branch] = "7.x-1.x" +projects[admin_icons][download][revision] = "60d9f28801533fecc92216a60d444d89d80e7611" projects[apachesolr][type] = "module" projects[apachesolr][subdir] = "contrib" -projects[apachesolr][version] = "1.4" +projects[apachesolr][version] = "1.6" projects[apachesolr_og][type] = "module" projects[apachesolr_og][subdir] = "contrib" projects[apachesolr_og][download][type] = "git" projects[apachesolr_og][download][url] = "http://git.drupal.org/project/apachesolr_og.git" projects[apachesolr_og][download][branch] = "7.x-1.x" -projects[apachesolr_og][download]revision] = "49820b4a4fcff7c1c4efe449da033fb6d8711ac5" +projects[apachesolr_og][download][revision] = "49820b4a4fcff7c1c4efe449da033fb6d8711ac5" + +; Check the user object before trying to display a result. +; https://drupal.org/node/2077281#comment-7807937 +projects[apachesolr_og][patch][] = "https://drupal.org/files/issues/apachesolr_og-check-for-anonymous.patch" projects[apachesolr_proximity][type] = "module" projects[apachesolr_proximity][subdir] = "contrib" @@ -40,13 +44,16 @@ projects[apachesolr_user][download][url] = "http://git.drupal.org/project/apache projects[apachesolr_user][download][branch] = "7.x-1.x" projects[apachesolr_user][download]revision] = "a86c5aebfceaf4a3fc53544762a36ca1b70809d5" -; Check the user object before trying to display a result +; Check the user object before trying to display a result. ; https://drupal.org/node/2077281#comment-7807937 projects[apachesolr_user][patch][] = "http://drupal.org/files/2077281-apache-solr-user-check-3.patch" projects[breakpoints][type] = "module" projects[breakpoints][subdir] = "contrib" -projects[breakpoints][version] = "1.1" +projects[breakpoints][download][type] = "git" +projects[breakpoints][download][url] = "http://git.drupal.org/project/breakpoints.git" +projects[breakpoints][download][branch] = "7.x-1.x" +projects[breakpoints][download][revision] = "c4f3665" projects[connector][type] = "module" projects[connector][subdir] = "contrib" @@ -54,24 +61,38 @@ projects[connector][version] = "1.0-beta2" projects[ckeditor][type] = "module" projects[ckeditor][subdir] = "contrib" -projects[ckeditor][version] = "1.13" +projects[ckeditor][download][type] = "git" +projects[ckeditor][download][url] = "http://git.drupal.org/project/ckeditor.git" +projects[ckeditor][download][branch] = "7.x-1.x" +projects[ckeditor][download][revision] = "b69a9ac" + +; Only load CSS when necessary. +; https://drupal.org/node/1370894 +projects[ckeditor][patch][] = "https://drupal.org/files/issues/attach-ckeditor-css-1370894-8.patch" + +; Accomodate latest Media changes. +; https://drupal.org/node/2159403 +projects[ckeditor][patch][] = "https://drupal.org/files/issues/ckeditor-accomodate-latest-media-changes-0.patch" + +; Remove redundant external plugin declarations. +; https://drupal.org/comment/8284591#comment-8284591 +projects[ckeditor][patch][] = "https://drupal.org/files/issues/ckeditor-remove-external-plugin-declarations-1-alt.patch" projects[ctools][type] = "module" projects[ctools][subdir] = "contrib" -projects[ctools][version] = "1.4" +projects[ctools][download][type] = "git" +projects[ctools][download][url] = "http://git.drupal.org/project/ctools.git" +projects[ctools][download][branch] = "7.x-1.x" +projects[ctools][download][revision] = "e720f61d" projects[custom_search][type] = "module" projects[custom_search][subdir] = "contrib" -projects[custom_search][download][type] = "git" -projects[custom_search][download][url] = "http://git.drupal.org/project/custom_search.git" -projects[custom_search][download][branch] = "7.x-1.x" -projects[custom_search][download][revision] = "20144e64494c83a448067d587e59df5d7e4780bb" +projects[custom_search][version] = "1.16" ; Avoid akward sanitization of user-entered search strings. ; https://drupal.org/node/2012210 projects[custom_search][patch][] = "http://drupal.org/files/commons_search_js_encode.patch" - projects[date][type] = "module" projects[date][subdir] = "contrib" projects[date][version] = "2.7" @@ -89,24 +110,29 @@ projects[diff][type] = "module" projects[diff][subdir] = "contrib" projects[diff][version] = "3.2" +; Profile has no recommended release. +projects[edit_profile][type] = "module" +projects[edit_profile][subdir] = "contrib" +projects[edit_profile][version] = "1.0-beta2" + +projects[elements][type] = "module" +projects[elements][subdir] = "contrib" +projects[elements][version] = "1.4" + projects[email_registration][type] = "module" projects[email_registration][subdir] = "contrib" -projects[email_registration][version] = "1.1" +projects[email_registration][download][type] = "git" +projects[email_registration][download][url] = "http://git.drupal.org/project/email_registration.git" +projects[email_registration][download][branch] = "7.x-1.x" +projects[email_registration][download][revision] = "1656416" projects[entity][type] = "module" projects[entity][subdir] = "contrib" -projects[entity][version] = "1.3" - -; Force LANGUAGE_NONE entities to still display within rendered entities. -; http://drupal.org/node/1782134 -projects[entity][patch][] = "http://drupal.org/files/entity-translatable_fields_not_overriding_und_with_empty_values.patch" +projects[entity][version] = "1.5" projects[entitycache][type] = "module" projects[entitycache][subdir] = "contrib" -projects[entitycache][download][type] = "git" -projects[entitycache][download][url] = "http://git.drupal.org/project/entitycache.git" -projects[entitycache][download][branch] = "7.x-1.x" -projects[entitycache][download][revision] = "7e390b5" +projects[entitycache][version] = "1.2" ; Fix core translation support. ; http://drupal.org/node/1349566#comment-7781063 @@ -114,62 +140,104 @@ projects[entitycache][patch][] = "http://drupal.org/files/add-translation-inform projects[entityreference][type] = "module" projects[entityreference][subdir] = "contrib" -projects[entityreference][download][type] = "git" -projects[entityreference][download][url] = "http://git.drupal.org/project/entityreference.git" -projects[entityreference][download][branch] = "7.x-1.x" -projects[entityreference][download][revision] = "1c176daef3e7483389cbebeb34784b3af6521f7f" - -; Profile has no recommended release -projects[edit_profile][type] = "module" -projects[edit_profile][subdir] = "contrib" -projects[edit_profile][version] = "1.0-beta2" +projects[entityreference][version] = "1.1" projects[entityreference_prepopulate][type] = "module" projects[entityreference_prepopulate][subdir] = "contrib" -projects[entityreference_prepopulate][version] = "1.3" +projects[entityreference_prepopulate][version] = "1.5" + +projects[entity_translation][type] = "module" +projects[entity_translation][subdir] = "contrib" +projects[entity_translation][version] = "1.0-beta3" + +projects[facetapi][type] = "module" +projects[facetapi][subdir] = "contrib" +projects[facetapi][version] = "1.3" projects[features][type] = "module" projects[features][subdir] = "contrib" -projects[features][version] = "2.0-rc3" +projects[features][version] = "2.0" -; Issue #1921982: Add 'customized' to the fields we check when comparing a menu_link feature -; http://drupal.org/node/1921982 -projects[features][patch][] = "http://drupal.org/files/menu_links_customized-927576-8.patch" +projects[file_entity][type] = "module" +projects[file_entity][subdir] = "contrib" +projects[file_entity][version] = "2.0-alpha3" + +; Issue #2081713: Fix undefined index errors with empty (remote) files. +; https://drupal.org/node/2081713 +projects[file_entity][patch][] = "https://drupal.org/files/issues/add-filesize-checks-2081713-13.patch" projects[flag][type] = "module" projects[flag][subdir] = "contrib" -projects[flag][version] = "2.1" +projects[flag][version] = "2.2" ; Issue #1965760: Manually set taxonomy term flag types because its different. ; http://drupal.org/node/1965760 -projects[flag][patch][] = "http://drupal.org/files/1965760-flag-taxonomy-types.patch" +projects[flag][patch][] = "https://drupal.org/files/issues/1965760.29.flag_.entity-tokens.patch" projects[flag_abuse][type] = "module" projects[flag_abuse][subdir] = "contrib" -projects[flag_abuse][version] = "2.0-alpha1" +projects[flag_abuse][version] = "2.0" -projects[redirect][type] = "module" -projects[redirect][subdir] = "contrib" -projects[redirect][version] = "1.0-rc1" +projects[gravatar][type] = "module" +projects[gravatar][subdir] = "contrib" +projects[gravatar][download][type] = "git" +projects[gravatar][download][url] = "http://git.drupal.org/project/gravatar.git" +projects[gravatar][download][branch] = "7.x-1.x" +projects[gravatar][download][revision] = "bb2f81e6" projects[http_client][type] = "module" projects[http_client][subdir] = "contrib" projects[http_client][version] = "2.4" -projects[admin_icons][type] = "module" -projects[admin_icons][subdir] = "contrib" -projects[admin_icons][download][type] = "git" -projects[admin_icons][download][url] = "http://git.drupal.org/project/admin_icons.git" -projects[admin_icons][download][branch] = "7.x-1.x" -projects[admin_icons][download][revision] = "60d9f28801533fecc92216a60d444d89d80e7611" +projects[i18n][type] = "module" +projects[i18n][subdir] = "contrib" +projects[i18n][version] = "1.11" + +projects[i18nviews][type] = "module" +projects[i18nviews][subdir] = "contrib" +projects[i18nviews][download][type] = "git" +projects[i18nviews][download][url] = "http://git.drupal.org/project/i18nviews.git" +projects[i18nviews][download][branch] = "7.x-3.x" +projects[i18nviews][download][revision] = "26bd52c" + +projects[kissmetrics][type] = "module" +projects[kissmetrics][subdir] = "contrib" +projects[kissmetrics][version] = "1.0-rc3" + +projects[l10n_update][type] = "module" +projects[l10n_update][subdir] = "contrib" +projects[l10n_update][version] = "1.0" projects[libraries][type] = "module" projects[libraries][subdir] = "contrib" -projects[libraries][version] = "2.1" +projects[libraries][version] = "2.2" + +projects[lingotek][type] = "module" +projects[lingotek][subdir] = "contrib" +projects[lingotek][version] = "5.06" projects[link][type] = "module" projects[link][subdir] = "contrib" -projects[link][version] = "1.1" +projects[link][version] = "1.2" + +projects[media][type] = "module" +projects[media][subdir] = "contrib" +projects[media][download][type] = "git" +projects[media][download][url] = "http://git.drupal.org/project/media.git" +projects[media][download][branch] = "7.x-2.x" +projects[media][download][revision] = "b2c2d78" + +; New filelfield browser widget is massively confusing the user +; https://drupal.org/comment/8570379#comment-8570379 +projects[media][patch][] = "https://drupal.org/files/issues/automatically-attach-files-2216329-2.patch" + +projects[media_oembed][type] = "module" +projects[media_oembed][subdir] = "contrib" +projects[media_oembed][version] = "2.1" + +projects[memcache][type] = "module" +projects[memcache][subdir] = "contrib" +projects[memcache][version] = "1.0" projects[menu_attributes][type] = "module" projects[menu_attributes][subdir] = "contrib" @@ -183,30 +251,21 @@ projects[message][version] = "1.9" ; http://drupal.org/node/1920560#comment-7080942 projects[message][patch][] = "http://drupal.org/files/1920560-message-access-alterable.patch" +; Add support for the undefined language. +; http://drupal.org/node/2006702#comment-7842259 +projects[message][patch][] = "http://drupal.org/files/message_field_undefined-lang.2006702-14.patch" + projects[message_notify][type] = "module" projects[message_notify][subdir] = "contrib" -projects[message_notify][download][type] = "git" -projects[message_notify][download][url] = "http://git.drupal.org/project/message_notify.git" -projects[message_notify][download][branch] = "7.x-2.x" -projects[message_notify][download][revision] = "e546b0a6e3d2dfd48f4fd3a4d45806c066c9a9bc" +projects[message_notify][version] = "2.5" projects[message_subscribe][type] = "module" projects[message_subscribe][subdir] = "contrib" -projects[message_subscribe][download][type] = "git" -projects[message_subscribe][download][url] = "http://git.drupal.org/project/message_subscribe.git" -projects[message_subscribe][download][branch] = "7.x-1.x" - -projects[memcache][type] = "module" -projects[memcache][subdir] = "contrib" -projects[memcache][version] = "1.0" +projects[message_subscribe][version] = "1.0-rc2" projects[metatag][type] = "module" projects[metatag][subdir] = "contrib" -projects[metatag][version] = "1.0-beta7" - -; Support for rel=author link in head. -; http://drupal.org/node/1865228#comment-6839604 -projects[metatag][patch][] = "http://drupal.org/files/metatag-n1865228-3.patch" +projects[metatag][version] = "1.0-beta9" projects[module_filter][type] = "module" projects[module_filter][subdir] = "contrib" @@ -214,130 +273,164 @@ projects[module_filter][version] = "1.8" projects[mollom][type] = "module" projects[mollom][subdir] = "contrib" -projects[mollom][version] = "2.7" +projects[mollom][version] = "2.10" projects[navbar][type] = "module" projects[navbar][subdir] = "contrib" -projects[navbar][download][type] = "git" -projects[navbar][download][url] = "http://git.drupal.org/project/navbar.git" -projects[navbar][download][branch] = "7.x-1.x" -projects[navbar][download][revision] = "dd542e1a74d9c9b3a9b5bd699aad9a4b65e5c5b7" +projects[navbar][version] = "1.4" + +; Change I-beam cursors in the navbar to be a pointer instead. +; https://drupal.org/node/2173041 +projects[navbar][patch][] = "https://drupal.org/files/issues/2173041-3-i-beam-menu-hover.patch" projects[oauth][type] = "module" projects[oauth][subdir] = "contrib" -projects[oauth][version] = "3.1" +projects[oauth][version] = "3.2" projects[oauthconnector][type] = "module" projects[oauthconnector][subdir] = "contrib" projects[oauthconnector][download][type] = "git" projects[oauthconnector][download][url] = "http://git.drupal.org/project/oauthconnector.git" projects[oauthconnector][download][branch] = "7.x-1.x" -projects[oauthconnector][download][revision] = "0ce7ac9614710c0f68d0a58cb4ae4667f8bd6fa7" +projects[oauthconnector][download][revision] = "42c6f66" + +projects[oembed][type] = "module" +projects[oembed][subdir] = "contrib" +projects[oembed][download][type] = "git" +projects[oembed][download][url] = "http://git.drupal.org/project/oembed.git" +projects[oembed][download][branch] = "7.x-1.x" +projects[oembed][download][revision] = "9aa5303" projects[og][type] = "module" projects[og][subdir] = "contrib" -projects[og][version] = "2.4" +projects[og][version] = "2.7" ; Auto-assign role to group manager broken on groups with overridden roles. ; https://drupal.org/node/2005800#comment-7684873 -projects[og][patch][] = "http://drupal.org/files/og-default-role-member-2005800-21.patch" +projects[og][patch][] = "http://drupal.org/files/issues/og-default-role-member-2005800-25.patch" -; og_ui should give users the theme, not admin ui when creating groups +; og_ui should give users the theme, not admin ui when creating groups. ; http://drupal.org/node/1800208 projects[og][patch][] = "http://drupal.org/files/og_ui-group_node_add_theme-1800208-5.patch" -; _og_access_verify_access_field_existence() assumes node group type, throws an exception rebuilding node access. -;projects[og][patch][] = "http://drupal.org/files/og-access-rebuild-exception-group-type.patch" - projects[panelizer][type] = "module" projects[panelizer][subdir] = "contrib" projects[panelizer][version] = "3.1" projects[panels][type] = "module" projects[panels][subdir] = "contrib" -projects[panels][version] = "3.3" - -; Fatal error: Call to undefined function panels_get_layouts() -; http://drupal.org/node/1828684#comment-6694732 -projects[panels][patch][] = "http://drupal.org/files/1828684-layout-fix-6.patch" - -; PHP 5.3.9 Strict Warning on Panels Empty Value -; http://drupal.org/node/1632898#comment-6412840 -projects[panels][patch][] = "http://drupal.org/files/panels-n1632898-15.patch" - -; Add internationalization support. -; http://drupal.org/node/1179034#comment-7216342 -projects[panels][patch][] = "http://drupal.org/files/panels-1179034-41_____panels-uuids-127790-100__-80.patch" +projects[panels][download][type] = "git" +projects[panels][download][url] = "http://git.drupal.org/project/panels.git" +projects[panels][download][branch] = "7.x-3.x" +projects[panels][download][revision] = "8059bda2b" projects[paranoia][type] = "module" projects[paranoia][subdir] = "contrib" -projects[paranoia][version] = "1.2" +projects[paranoia][version] = "1.3" projects[pathauto][type] = "module" projects[pathauto][subdir] = "contrib" projects[pathauto][version] = "1.2" -projects[placeholder][type] = "module" -projects[placeholder][subdir] = "contrib" -projects[placeholder][version] = "1.0" +projects[picture][type] = "module" +projects[picture][subdir] = "contrib" +projects[picture][download][type] = "git" +projects[picture][download][url] = "http://git.drupal.org/project/picture.git" +projects[picture][download][branch] = "7.x-1.x" +projects[picture][download][revision] = "18b94b9" + +; Add ctools as a dependency +; https://drupal.org/node/2173043 +projects[picture][patch][] = "https://drupal.org/files/issues/add-ctools-dependency-2173043-1.patch" + +; Allow filter tips to be translated +; https://drupal.org/node/2139459 +projects[picture][patch][] = "https://drupal.org/files/issues/translate-filter-tips-2139459-1.patch" + +; Move hook_uninstall() to picture.install to fix issues on uninstall. +; https://drupal.org/node/2173015 +projects[picture][patch][] = "https://drupal.org/files/issues/move-uninstall-hook-implementation-2173015-1.patch" + +; Remove implementation of hook_file_formatter_info() to remove duplicate file formatter. +; https://drupal.org/node/2172841 +projects[picture][patch][] = "https://drupal.org/files/issues/remove-file-formatter-hook-implementation-2172831-1.patch" + +; Remove implementation of hook_ctools_plugin_api() to fix issues with features. +; https://drupal.org/node/2172831 +projects[picture][patch][] = "https://drupal.org/files/issues/remove-ctools-hook-implementation-2172831-1.patch" projects[pm_existing_pages][type] = "module" projects[pm_existing_pages][subdir] = "contrib" projects[pm_existing_pages][version] = "1.4" +projects[potx][type] = "module" +projects[potx][subdir] = "contrib" +projects[potx][version] = "1.0" + projects[privatemsg][type] = "module" projects[privatemsg][subdir] = "contrib" projects[privatemsg][version] = "1.4" -; Add preliminary Views integration +; Add preliminary Views integration. ; http://drupal.org/node/1573000 projects[privatemsg][patch][] = "http://drupal.org/files/privatemsg-1573000-64.patch" -; Enable privatemsg_realname when realname is enabled +; Enable privatemsg_realname when realname is enabled. ; https://drupal.org/node/2070719 projects[privatemsg][patch][] = "http://drupal.org/files/2077223-privatemsg-realname-enabled-1.patch" projects[quicktabs][type] = "module" projects[quicktabs][subdir] = "contrib" -projects[quicktabs][download][type] = "git" -projects[quicktabs][download][url] = "http://git.drupal.org/project/quicktabs.git" -projects[quicktabs][download][branch] = "7.x-3.x" -projects[quicktabs][download][revision] = "89f7fd0b7313782d0f7504996daa36bde798ec79" - -projects[radioactivity][type] = "module" -projects[radioactivity][subdir] = "contrib" -projects[radioactivity][download][type] = "git" -projects[radioactivity][download][url] = "http://git.drupal.org/project/radioactivity.git" -projects[radioactivity][download][branch] = "7.x-2.x" -projects[radioactivity][download][revision] = "aee21dbed4f54d0e626e3c19ecc550bf1ec656f6" - -; Radioactivity not compatible with Memcache module -; http://drupal.org/node/1860216 -projects[radioactivity][patch][] = "http://drupal.org/files/radioactivity-memcache.patch" +projects[quicktabs][version] = "3.6" +projects[quicktabs][patch][] = "http://drupal.org/files/2104643-revert-qt-487518-5.patch" projects[r4032login][type] = "module" projects[r4032login][subdir] = "contrib" -projects[r4032login][version] = "1.6" +projects[r4032login][version] = "1.7" + +projects[radioactivity][type] = "module" +projects[radioactivity][subdir] = "contrib" +projects[radioactivity][version] = "2.9" projects[rate][type] = "module" projects[rate][subdir] = "contrib" -projects[rate][version] = "1.6" +projects[rate][version] = "1.7" -; Add widget to node/comment $links +; Add widget to node/comment $links. ; http://drupal.org/node/947516#comment-6979780 projects[rate][patch][] = "http://drupal.org/files/947516-rate-node-links-15.patch" +; Only load CSS when necessary. +; https://drupal.org/node/2180853 +projects[rate][patch][] = "https://drupal.org/files/issues/attach-rate-css-2180853-3.patch" + projects[realname][type] = "module" projects[realname][subdir] = "contrib" -projects[realname][version] = "1.1" +projects[realname][version] = "1.2" + +; Realname entityreference autocomplete API update +; https://drupal.org/node/2225889 +projects[realname][patch][] = "https://drupal.org/files/issues/2225889-realname-correct-menu-2.patch" + +projects[redirect][type] = "module" +projects[redirect][subdir] = "contrib" +projects[redirect][version] = "1.0-rc1" projects[registration][subdir] = "contrib" projects[registration][type] = "module" -projects[registration][version] = "1.2" +projects[registration][version] = "1.3" + +projects[rich_snippets][type] = "module" +projects[rich_snippets][subdir] = "contrib" +projects[rich_snippets][version] = "1.0-beta3" projects[rules][type] = "module" projects[rules][subdir] = "contrib" -projects[rules][version] = "2.3" +projects[rules][version] = "2.7" + +projects[schemaorg][type] = "module" +projects[schemaorg][subdir] = "contrib" +projects[schemaorg][version] = "1.0-beta4" projects[search_facetapi][type] = "module" projects[search_facetapi][subdir] = "contrib" @@ -345,23 +438,11 @@ projects[search_facetapi][version] = "1.0-beta2" projects[sharethis][type] = "module" projects[sharethis][subdir] = "contrib" -projects[sharethis][version] = "2.5" +projects[sharethis][version] = "2.6" -projects[facetapi][type] = "module" -projects[facetapi][subdir] = "contrib" -projects[facetapi][version] = "1.3" - -projects[rich_snippets][type] = "module" -projects[rich_snippets][subdir] = "contrib" -projects[rich_snippets][version] = "1.0-beta3" - -; Remove snippets from non-node type searches: -; http://drupal.org/node/1923904#comment-7094488 -projects[rich_snippets][patch][] = "http://drupal.org/files/1923904-search-nodes-only.patch" - -projects[schemaorg][type] = "module" -projects[schemaorg][subdir] = "contrib" -projects[schemaorg][version] = "1.0-beta3" +projects[smartcrop][type] = "module" +projects[smartcrop][subdir] = "contrib" +projects[smartcrop][version] = "1.0-beta2" projects[strongarm][type] = "module" projects[strongarm][subdir] = "contrib" @@ -372,13 +453,9 @@ projects[strongarm][download][revision] = "5a2326ba67e59923ecce63d9bb5e0ed6548ab projects[timeago][type] = "module" projects[timeago][subdir] = "contrib" -projects[timeago][version] = "2.x-dev" -projects[timeago][download][type] = "git" -projects[timeago][download][url] = "http://git.drupal.org/project/timeago.git" -projects[timeago][download][branch] = "7.x-2.x" -projects[timeago][download][revision] = "768ea66" +projects[timeago][version] = "2.2" -; Provide a dedicated date type: +; Provide a dedicated date type. ; http://drupal.org/node/1427226#comment-6638836 projects[timeago][patch][] = "http://drupal.org/files/1427226-timeago-date-type.patch" @@ -390,37 +467,49 @@ projects[token][type] = "module" projects[token][subdir] = "contrib" projects[token][version] = "1.5" +projects[translation_helpers][type] = "module" +projects[translation_helpers][subdir] = "contrib" +projects[translation_helpers][version] = "1.0" + +projects[variable][type] = "module" +projects[variable][subdir] = "contrib" +projects[variable][version] = "2.5" + projects[views][type] = "module" projects[views][subdir] = "contrib" -projects[views][version] = "3.7" +projects[views][version] = "3.8" + +; Update Views Content access filter per core performance improvements. +; https://drupal.org/comment/8516039#comment-8516039 +projects[views][patch][] = "https://drupal.org/files/issues/2204257-views-content-access-filter-core-depends-on-core-patch.patch" + +projects[views_bulk_operations][type] = "module" +projects[views_bulk_operations][subdir] = "contrib" +projects[views_bulk_operations][version] = "3.2" projects[views_field_view][type] = "module" projects[views_field_view][subdir] = "contrib" projects[views_field_view][version] = "1.1" -projects[views_load_more][type] = "module" -projects[views_load_more][subdir] = "contrib" -projects[views_load_more][version] = "1.1" - -projects[views_bulk_operations][type] = "module" -projects[views_bulk_operations][subdir] = "contrib" -projects[views_bulk_operations][version] = "3.1" - projects[views_litepager][type] = "module" projects[views_litepager][subdir] = "contrib" projects[views_litepager][version] = "3.0" -; We have the version of voting api at the top so it doesn't get included in our dev make patch. -projects[votingapi][version] = "2.11" +projects[views_load_more][type] = "module" +projects[views_load_more][subdir] = "contrib" +projects[views_load_more][version] = "1.2" + +; Suppress notice error when loading more content from views_load_more. +; https://drupal.org/node/2207467 +projects[views_load_more][patch][] = "https://drupal.org/files/issues/fix-notice-undefined-index-2152935-3.patch" + projects[votingapi][type] = "module" projects[votingapi][subdir] = "contrib" +projects[votingapi][version] = "2.11" -; Registry Rebuild -; We can probably remove this later, but for now keep it included -; See https://drupal.org/node/1983606#comment-7788313 for more information. -projects[registry_rebuild][version] = "1.10" -projects[registry_rebuild][type] = "module" -projects[registry_rebuild][subdir] = "contrib" +projects[voting_rules][type] = "module" +projects[voting_rules][subdir] = "contrib" +projects[voting_rules][version] = "1.0-alpha1" projects[geophp][version] = "1.7" projects[geophp][type] = "module" @@ -430,7 +519,7 @@ projects[geocoder][version] = "1.2" projects[geocoder][type] = "module" projects[geocoder][subdir] = "contrib" -projects[geofield][version] = "2.0" +projects[geofield][version] = "2.1" projects[geofield][type] = "module" projects[geofield][subdir] = "contrib" @@ -442,7 +531,7 @@ projects[leaflet_mapbox][version] = "1.2" projects[leaflet_mapbox][type] = "module" projects[leaflet_mapbox][subdir] = "contrib" -projects[leaflet_more_maps][version] = "1.6" +projects[leaflet_more_maps][version] = "1.9" projects[leaflet_more_maps][type] = "module" projects[leaflet_more_maps][subdir] = "contrib" @@ -475,44 +564,64 @@ projects[feeds_fetcher_directory][patch][] = "https://drupal.org/files/feeds_fet projects[zen][type] = "theme" projects[zen][subdir] = "contrib" -projects[zen][version] = "5.4" +projects[zen][version] = "5.5" projects[adaptivetheme][type] = "theme" projects[adaptivetheme][subdir] = "contrib" projects[adaptivetheme][download][type] = "git" projects[adaptivetheme][download][url] = "http://git.drupal.org/project/adaptivetheme.git" projects[adaptivetheme][download][branch] = "7.x-3.x" -projects[adaptivetheme][download][revision] = "b4b38c3c01d066e733c2942020c51962cd64231c" +projects[adaptivetheme][download][revision] = "18693ff59db7cb3171f282a982d04fe6544b63a1" -; Remove link around comment creation date. -; http://drupal.org/node/1427226#comment-6638836 -projects[adaptivetheme][patch][] = "http://drupal.org/files/remove-comment-creation-link-2018081-1.patch" +projects[ember][type] = "theme" +projects[ember][subdir] = "contrib" +projects[ember][download][type] = "git" +projects[ember][download][url] = "http://git.drupal.org/project/ember.git" +projects[ember][download][branch] = "7.x-2.x" +projects[ember][download][revision] = "caf4df7" projects[sky][type] = "theme" projects[sky][subdir] = "contrib" -projects[sky][version] = "3.0-rc1" +projects[sky][version] = "3.0" ; Libraries. ; NOTE: These need to be listed in http://drupal.org/packaging-whitelist. -libraries[underscore][download][type] = "get" -libraries[underscore][type] = "libraries" -libraries[underscore][download][url] = "https://github.com/jashkenas/underscore/archive/1.4.4.zip" libraries[backbone][download][type] = "get" libraries[backbone][type] = "libraries" -libraries[backbone][download][url] = "https://github.com/jashkenas/backbone/archive/1.0.0.tar.gz" +libraries[backbone][download][url] = "https://github.com/jashkenas/backbone/archive/1.1.0.tar.gz" libraries[ckeditor][download][type] = "get" -libraries[ckeditor][download][url] = "http://download.cksource.com/CKEditor/CKEditor/CKEditor%204.0/ckeditor_4.0_standard.tar.gz" +libraries[ckeditor][download][url] = "http://download.cksource.com/CKEditor/CKEditor/CKEditor%204.3.4/ckeditor_4.3.4_full.zip" libraries[ckeditor][type] = "libraries" +libraries[ckeditor_lineutils][download][type] = "get" +libraries[ckeditor_lineutils][download][url] = "http://download.ckeditor.com/lineutils/releases/lineutils_4.3.4.zip" +libraries[ckeditor_lineutils][type] = "libraries" +libraries[ckeditor_lineutils][subdir] = "ckeditor/plugins" +libraries[ckeditor_lineutils][directory_name] = "lineutils" + +libraries[ckeditor_widget][download][type] = "get" +libraries[ckeditor_widget][download][url] = "http://download.ckeditor.com/widget/releases/widget_4.3.4.zip" +libraries[ckeditor_widget][type] = "libraries" +libraries[ckeditor_widget][subdir] = "ckeditor/plugins" +libraries[ckeditor_widget][directory_name] = "widget" + +libraries[modernizr][download][type] = "get" +libraries[modernizr][type] = "libraries" +libraries[modernizr][download][url] = "https://github.com/Modernizr/Modernizr/archive/v2.7.1.tar.gz" + libraries[placeholder][download][type] = "get" libraries[placeholder][type] = "libraries" libraries[placeholder][download][url] = "https://github.com/mathiasbynens/jquery-placeholder/archive/v2.0.7.tar.gz" libraries[timeago][download][type] = "get" libraries[timeago][type] = "libraries" -libraries[timeago][download][url] = "https://raw.github.com/rmm5t/jquery-timeago/v1.4.0/jquery.timeago.js" +libraries[timeago][download][url] = "https://raw.github.com/rmm5t/jquery-timeago/v1.4.1/jquery.timeago.js" + +libraries[underscore][download][type] = "get" +libraries[underscore][type] = "libraries" +libraries[underscore][download][url] = "https://github.com/jashkenas/underscore/archive/1.5.2.zip" libraries[leaflet][download][type] = "get" libraries[leaflet][type] = "libraries" diff --git a/groups.info b/groups.info index 69a0096..08f56e8 100644 --- a/groups.info +++ b/groups.info @@ -5,7 +5,7 @@ description = Ready-to-use solution for managing OpenStack communities. core = 7.x php_memory_limit = 192M -; Core modules. +; Install required core modules. dependencies[] = block dependencies[] = comment dependencies[] = dblog @@ -14,30 +14,37 @@ dependencies[] = field_ui dependencies[] = file dependencies[] = image dependencies[] = list -dependencies[] = locale dependencies[] = menu dependencies[] = number dependencies[] = options dependencies[] = path +dependencies[] = rdf dependencies[] = search dependencies[] = shortcut dependencies[] = taxonomy -; Contributed modules. +; Install required contributed modules. dependencies[] = addressfield dependencies[] = addressfield_tokens dependencies[] = breakpoints +dependencies[] = ckeditor dependencies[] = ctools dependencies[] = custom_search dependencies[] = diff +dependencies[] = elements dependencies[] = email_registration dependencies[] = entity dependencies[] = entityreference dependencies[] = entitycache dependencies[] = edit_profile dependencies[] = features +dependencies[] = file_entity dependencies[] = flag dependencies[] = http_client +dependencies[] = libraries +dependencies[] = media +dependencies[] = media_internet +dependencies[] = media_wysiwyg dependencies[] = menu_attributes dependencies[] = message dependencies[] = message_notify @@ -45,20 +52,22 @@ dependencies[] = message_subscribe dependencies[] = metatag dependencies[] = module_filter dependencies[] = navbar +dependencies[] = media_oembed dependencies[] = og +dependencies[] = panelizer dependencies[] = panels +dependencies[] = panels_ipe dependencies[] = paranoia dependencies[] = pathauto -dependencies[] = placeholder dependencies[] = privatemsg dependencies[] = privatemsg_realname dependencies[] = quicktabs dependencies[] = r4032login -dependencies[] = libraries dependencies[] = radioactivity dependencies[] = realname dependencies[] = redirect dependencies[] = rules +dependencies[] = schemaorg dependencies[] = sharethis dependencies[] = strongarm dependencies[] = token @@ -66,38 +75,50 @@ dependencies[] = views dependencies[] = views_bulk_operations dependencies[] = views_ui dependencies[] = votingapi -dependencies[] = advancedqueue -dependencies[] = ckeditor + +; Install commons specific modules dependencies[] = commons_activity_streams dependencies[] = commons_bw +dependencies[] = commons_content_moderation dependencies[] = commons_events -dependencies[] = commons_events_pages dependencies[] = commons_featured dependencies[] = commons_follow dependencies[] = commons_follow_group dependencies[] = commons_follow_node dependencies[] = commons_follow_term -dependencies[] = commons_follow_user dependencies[] = commons_follow_ui -dependencies[] = commons_like -dependencies[] = commons_search -dependencies[] = commons_search_core +dependencies[] = commons_follow_user dependencies[] = commons_groups -dependencies[] = commons_groups_pages +dependencies[] = commons_like +dependencies[] = commons_location +dependencies[] = commons_media +dependencies[] = commons_misc dependencies[] = commons_notify +dependencies[] = commons_polls dependencies[] = commons_posts -dependencies[] = commons_pages -dependencies[] = commons_content_moderation dependencies[] = commons_profile_base dependencies[] = commons_profile_social -dependencies[] = commons_utility_links -dependencies[] = commons_user_profile_pages -dependencies[] = commons_activity_page -dependencies[] = commons_misc -dependencies[] = commons_location -dependencies[] = commons_wysiwyg +dependencies[] = commons_q_a +dependencies[] = commons_search +dependencies[] = commons_search_core dependencies[] = commons_social_sharing -dependencies[] = commons_trusted_contacts +dependencies[] = commons_utility_links +dependencies[] = commons_wysiwyg + +; Disabled commons modules +;dependencies[] = commons_activity_page +;dependencies[] = commons_events_pages +;dependencies[] = commons_groups_directory +;dependencies[] = commons_groups_pages +;dependencies[] = commons_pages +;dependencies[] = commons_q_a_pages +;dependencies[] = commons_site_homepage +;dependencies[] = commons_trusted_contacts +;dependencies[] = commons_user_profile_pages +;dependencies[] = commons_wikis +;dependencies[] = commons_wikis_pages + +; Install Groups dependencies dependencies[] = geophp dependencies[] = geocoder dependencies[] = geofield @@ -109,6 +130,7 @@ dependencies[] = job_scheduler dependencies[] = feeds dependencies[] = drush_feeds_import dependencies[] = feeds_ui +dependencies[] = feeds_fetcher_directory ; Custom modules dependencies[] = field_property_list diff --git a/groups.install b/groups.install index 2fbb98c..3b5d6a2 100644 --- a/groups.install +++ b/groups.install @@ -82,17 +82,17 @@ function groups_install() { drupal_write_record('block', $search_block); // Create a default role for site administrators, with all available permissions assigned. - $admin_role = new stdClass(); - $admin_role->name = 'administrator'; - $admin_role->weight = 2; - user_role_save($admin_role); + // $admin_role = new stdClass(); + // $admin_role->name = 'administrator'; + // $admin_role->weight = 2; + // user_role_save($admin_role); // Set this as the administrator role. variable_set('user_admin_role', $admin_role->rid); // Assign user 1 the "administrator" role. - db_insert('users_roles') - ->fields(array('uid' => 1, 'rid' => $admin_role->rid)) - ->execute(); + // db_insert('users_roles') + // ->fields(array('uid' => 1, 'rid' => $admin_role->rid)) + // ->execute(); // AdaptiveTheme requires that the system theme settings form // be submitted in order for its themes' settings to be properly set diff --git a/groups.profile b/groups.profile index 043f522..dcbd4b3 100644 --- a/groups.profile +++ b/groups.profile @@ -5,6 +5,33 @@ */ define('DRUPAL_MINIMUM_MAX_EXECUTION_TIME', 120); +/** + * Get Commons entity integration information. + * + * @param $entity_type + * (optional) The entity type to load, e.g. node or user. + * + * @return + * An associative array of entity integrations whose keys define the entity + * type for each integration and whose values contain the bundles which have + * been integrated. Each bundle is itself an associative array, whose keys + * define the type of integration to enable and whose values contain the + * status of the integration. TRUE = enabled, FALSE = disabled. + */ +function commons_entity_integration_info($entity_type = NULL) { + $info = &drupal_static(__FUNCTION__); + if (!$info) { + $info = module_invoke_all('commons_entity_integration'); + drupal_alter('commons_entity_integration', $info); + } + if ($entity_type) { + return isset($info[$entity_type]) ? $info[$entity_type] : array(); + } + else { + return $info; + } +} + /** * Implements hook_admin_paths_alter(). */ diff --git a/modules/commons/commons_activity_streams/commons_activity_page/commons_activity_page.features.inc b/modules/commons/commons_activity_streams/commons_activity_page/commons_activity_page.features.inc new file mode 100644 index 0000000..05903a2 --- /dev/null +++ b/modules/commons/commons_activity_streams/commons_activity_page/commons_activity_page.features.inc @@ -0,0 +1,14 @@ + "1"); + } +} diff --git a/modules/commons/commons_activity_streams/commons_activity_page/commons_activity_page.info b/modules/commons/commons_activity_streams/commons_activity_page/commons_activity_page.info new file mode 100644 index 0000000..d8620ea --- /dev/null +++ b/modules/commons/commons_activity_streams/commons_activity_page/commons_activity_page.info @@ -0,0 +1,11 @@ +name = Commons Activity Page +description = Allows users to view a stream of site-wide and personalized activity. +core = 7.x +package = Commons - Landing pages +dependencies[] = commons_activity_streams +dependencies[] = commons_featured +dependencies[] = ctools +dependencies[] = page_manager +features[ctools][] = page_manager:pages_default:1 +features[features_api][] = api:2 +features[page_manager_pages][] = commons_activity_streams_activity diff --git a/modules/commons/commons_activity_streams/commons_activity_page/commons_activity_page.module b/modules/commons/commons_activity_streams/commons_activity_page/commons_activity_page.module new file mode 100644 index 0000000..0a72c76 --- /dev/null +++ b/modules/commons/commons_activity_streams/commons_activity_page/commons_activity_page.module @@ -0,0 +1,7 @@ +disabled = FALSE; /* Edit this to true to make a default page disabled initially */ + $page->api_version = 1; + $page->name = 'commons_activity_streams_activity'; + $page->task = 'page'; + $page->admin_title = 'Activity'; + $page->admin_description = ''; + $page->path = 'activity'; + $page->access = array( + 'type' => 'none', + 'settings' => NULL, + ); + $page->menu = array(); + $page->arguments = array(); + $page->conf = array( + 'admin_paths' => FALSE, + ); + $page->default_handlers = array(); + $handler = new stdClass(); + $handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */ + $handler->api_version = 1; + $handler->name = 'page_commons_activity_streams_activity_panel_context'; + $handler->task = 'page'; + $handler->subtask = 'commons_activity_streams_activity'; + $handler->handler = 'panel_context'; + $handler->weight = 0; + $handler->conf = array( + 'title' => 'Activity', + 'no_blocks' => 0, + 'pipeline' => 'ipe', + 'body_classes_to_remove' => '', + 'body_classes_to_add' => '', + 'css_id' => '', + 'css' => '', + 'contexts' => array(), + 'relationships' => array(), + ); + $display = new panels_display(); + $display->layout = 'two_66_33'; + $display->layout_settings = array(); + $display->panel_settings = array( + 'style_settings' => array( + 'default' => NULL, + 'two_66_33_top' => NULL, + 'two_66_33_first' => NULL, + 'two_66_33_second' => NULL, + 'two_66_33_bottom' => NULL, + ), + ); + $display->cache = array(); + $display->title = 'Recent site activity'; + $display->uuid = '5421dc96-4e35-5794-5539-fc6123374548'; + $display->content = array(); + $display->panels = array(); + $pane = new stdClass(); + $pane->pid = 'new-6251a6df-20d2-5034-f9d8-a66cd04f16e9'; + $pane->panel = 'two_66_33_first'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_activity_streams_activity-panel_pane_3'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = '6251a6df-20d2-5034-f9d8-a66cd04f16e9'; + $display->content['new-6251a6df-20d2-5034-f9d8-a66cd04f16e9'] = $pane; + $display->panels['two_66_33_first'][0] = 'new-6251a6df-20d2-5034-f9d8-a66cd04f16e9'; + $pane = new stdClass(); + $pane->pid = 'new-6668ecda-9f18-0744-71cb-afcb5fb5114d'; + $pane->panel = 'two_66_33_second'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_featured-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = '6668ecda-9f18-0744-71cb-afcb5fb5114d'; + $display->content['new-6668ecda-9f18-0744-71cb-afcb5fb5114d'] = $pane; + $display->panels['two_66_33_second'][0] = 'new-6668ecda-9f18-0744-71cb-afcb5fb5114d'; + $pane = new stdClass(); + $pane->pid = 'new-e5d75ae1-dae7-bb04-0977-6e6c5a230f3d'; + $pane->panel = 'two_66_33_second'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_groups_contributors-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 1; + $pane->locks = array(); + $pane->uuid = 'e5d75ae1-dae7-bb04-0977-6e6c5a230f3d'; + $display->content['new-e5d75ae1-dae7-bb04-0977-6e6c5a230f3d'] = $pane; + $display->panels['two_66_33_second'][1] = 'new-e5d75ae1-dae7-bb04-0977-6e6c5a230f3d'; + $display->hide_title = PANELS_TITLE_FIXED; + $display->title_pane = 'new-6251a6df-20d2-5034-f9d8-a66cd04f16e9'; + $handler->conf['display'] = $display; + $page->default_handlers[$handler->name] = $handler; + $pages['commons_activity_streams_activity'] = $page; + + return $pages; + +} diff --git a/modules/commons/commons_activity_streams/commons_activity_streams.features.field_instance.inc b/modules/commons/commons_activity_streams/commons_activity_streams.features.field_instance.inc new file mode 100644 index 0000000..2f4f612 --- /dev/null +++ b/modules/commons/commons_activity_streams/commons_activity_streams.features.field_instance.inc @@ -0,0 +1,210 @@ + 'commons_activity_streams_comment_created', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_target_comments', + 'label' => 'Target comment', + 'required' => 0, + 'settings' => array( + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 1, + ), + ); + + // Exported field_instance: 'message-commons_activity_streams_comment_created-field_target_nodes' + $field_instances['message-commons_activity_streams_comment_created-field_target_nodes'] = array( + 'bundle' => 'commons_activity_streams_comment_created', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 1, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_target_nodes', + 'label' => 'Target nodes', + 'required' => 0, + 'settings' => array( + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 3, + ), + ); + + // Exported field_instance: 'message-commons_activity_streams_node_created-field_target_nodes' + $field_instances['message-commons_activity_streams_node_created-field_target_nodes'] = array( + 'bundle' => 'commons_activity_streams_node_created', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 2, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_target_nodes', + 'label' => 'Target nodes', + 'required' => 0, + 'settings' => array( + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 3, + ), + ); + + // Exported field_instance: 'message-commons_activity_streams_user_profile_updated-field_target_users' + $field_instances['message-commons_activity_streams_user_profile_updated-field_target_users'] = array( + 'bundle' => 'commons_activity_streams_user_profile_updated', + 'default_value' => NULL, + 'default_value_function' => '', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 2, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_target_users', + 'label' => 'Target users', + 'required' => 0, + 'settings' => array( + 'behaviors' => array( + 'prepopulate' => array( + 'status' => 0, + ), + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 42, + ), + ); + + // Translatables + // Included for use with string extractors like potx. + t('Target comment'); + t('Target nodes'); + t('Target users'); + + return $field_instances; +} diff --git a/modules/commons/commons_activity_streams/commons_activity_streams.features.inc b/modules/commons/commons_activity_streams/commons_activity_streams.features.inc new file mode 100644 index 0000000..23366ab --- /dev/null +++ b/modules/commons/commons_activity_streams/commons_activity_streams.features.inc @@ -0,0 +1,111 @@ + "1"); + } +} + +/** + * Implements hook_views_api(). + */ +function commons_activity_streams_views_api($module = NULL, $api = NULL) { + return array("api" => "3.0"); +} + +/** + * Implements hook_default_message_type(). + */ +function commons_activity_streams_default_message_type() { + $items = array(); + $items['commons_activity_streams_comment_created'] = entity_import('message_type', '{ + "name" : "commons_activity_streams_comment_created", + "description" : "commons_activity_streams_comment_created", + "argument_keys" : [], + "argument" : [], + "category" : "message_type", + "data" : { "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" } }, + "language" : "", + "arguments" : null, + "message_text" : { "und" : [ + { + "value" : "[message:user:picture:35x35]", + "format" : "filtered_html", + "safe_value" : "[message:user:picture:35x35]" + }, + { + "value" : "\\u003Ca href=\\u0022[message:user:url:absolute]\\u0022\\u003E[message:user:name]\\u003C\\/a\\u003E commented on \\u003Ca href=\\u0022[message:field-target-nodes:0:url]\\u0022\\u003E[message:field-target-nodes:0:title_field]\\u003C\\/a\\u003E", + "format" : "full_html", + "safe_value" : "\\u003Ca href=\\u0022[message:user:url:absolute]\\u0022\\u003E[message:user:name]\\u003C\\/a\\u003E commented on \\u003Ca href=\\u0022[message:field-target-nodes:0:url]\\u0022\\u003E[message:field-target-nodes:0:title_field]\\u003C\\/a\\u003E" + }, + { + "value" : "[commons-groups:in-groups-text]", + "format" : "full_html", + "safe_value" : "[commons-groups:in-groups-text]" + } + ] + }, + "rdf_mapping" : [] + }'); + $items['commons_activity_streams_node_created'] = entity_import('message_type', '{ + "name" : "commons_activity_streams_node_created", + "description" : "commons_activity_streams_node_created", + "argument_keys" : [], + "argument" : [], + "category" : "message_type", + "data" : { "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" } }, + "language" : "", + "arguments" : null, + "message_text" : { "und" : [ + { + "value" : "[message:user:picture:35x35]", + "format" : "filtered_html", + "safe_value" : "[message:user:picture:35x35]" + }, + { + "value" : "\\u003Ca href=\\u0022[message:user:url:absolute]\\u0022\\u003E[message:user:name]\\u003C\\/a\\u003E created \\u003Ca href=\\u0022[message:field-target-nodes:0:url]\\u0022\\u003E[message:field-target-nodes:0:title_field]\\u003C\\/a\\u003E", + "format" : "full_html", + "safe_value" : "\\u003Ca href=\\u0022[message:user:url:absolute]\\u0022\\u003E[message:user:name]\\u003C\\/a\\u003E created \\u003Ca href=\\u0022[message:field-target-nodes:0:url]\\u0022\\u003E[message:field-target-nodes:0:title_field]\\u003C\\/a\\u003E" + }, + { + "value" : "[commons-groups:in-groups-text]", + "format" : "full_html", + "safe_value" : "[commons-groups:in-groups-text]" + } + ] + }, + "rdf_mapping" : [] + }'); + $items['commons_activity_streams_user_profile_updated'] = entity_import('message_type', '{ + "name" : "commons_activity_streams_user_profile_updated", + "description" : "commons_activity_streams_user_profile_updated", + "argument_keys" : [], + "argument" : [], + "category" : "message_type", + "data" : { "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" } }, + "language" : "", + "arguments" : null, + "message_text" : { "und" : [ + { + "value" : "[message:user:picture:35x35]", + "format" : "filtered_html", + "safe_value" : "[message:user:picture:35x35]" + }, + { + "value" : "\\u003Ca href=\\u0022[message:user:url:absolute]\\u0022\\u003E[message:user:name]\\u003C\\/a\\u003E has an updated profile", + "format" : "full_html", + "safe_value" : "\\u003Ca href=\\u0022[message:user:url:absolute]\\u0022\\u003E[message:user:name]\\u003C\\/a\\u003E has an updated profile" + } + ] + }, + "rdf_mapping" : [] + }'); + return $items; +} diff --git a/modules/commons/commons_activity_streams/commons_activity_streams.info b/modules/commons/commons_activity_streams/commons_activity_streams.info new file mode 100644 index 0000000..665ad02 --- /dev/null +++ b/modules/commons/commons_activity_streams/commons_activity_streams.info @@ -0,0 +1,39 @@ +name = Commons Activity Streams +core = 7.x +package = Commons - Building blocks +dependencies[] = commons_follow +dependencies[] = ctools +dependencies[] = entity +dependencies[] = entityreference +dependencies[] = features +dependencies[] = message +dependencies[] = strongarm +dependencies[] = timeago +dependencies[] = token +dependencies[] = views +dependencies[] = views_content +dependencies[] = views_load_more +features[ctools][] = strongarm:strongarm:1 +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[field_instance][] = message-commons_activity_streams_comment_created-field_target_comments +features[field_instance][] = message-commons_activity_streams_comment_created-field_target_nodes +features[field_instance][] = message-commons_activity_streams_node_created-field_target_nodes +features[field_instance][] = message-commons_activity_streams_user_profile_updated-field_target_users +features[message_type][] = commons_activity_streams_comment_created +features[message_type][] = commons_activity_streams_node_created +features[message_type][] = commons_activity_streams_user_profile_updated +features[variable][] = field_bundle_settings_message__commons_activity_streams_comment_created +features[variable][] = field_bundle_settings_message__commons_activity_streams_node_created +features[variable][] = field_bundle_settings_message__commons_activity_streams_user_profile_updated +features[variable][] = timeago_comment +features[variable][] = timeago_node +features[views_view][] = commons_activity_streams_activity +features[views_view][] = commons_activity_streams_user_activity +features_exclude[field][message-commons_activity_streams_comment_created-field_target_comments] = message-commons_activity_streams_comment_created-field_target_comments +features_exclude[field][message-commons_activity_streams_comment_created-field_target_nodes] = message-commons_activity_streams_comment_created-field_target_nodes +features_exclude[field][message-commons_activity_streams_node_created-field_target_nodes] = message-commons_activity_streams_node_created-field_target_nodes +features_exclude[field][message-commons_activity_streams_user_profile_updated-field_target_users] = message-commons_activity_streams_user_profile_updated-field_target_users +features_exclude[field_base][field_target_nodes] = field_target_nodes +features_exclude[field_base][field_target_comments] = field_target_comments +features_exclude[views_view][commons_bw_all] = commons_bw_all diff --git a/modules/commons/commons_activity_streams/commons_activity_streams.install b/modules/commons/commons_activity_streams/commons_activity_streams.install new file mode 100644 index 0000000..4bfc7cf --- /dev/null +++ b/modules/commons/commons_activity_streams/commons_activity_streams.install @@ -0,0 +1,65 @@ + array('message_type', 'field_instance'))); + return array(); +} + +/** + * Set activity stream user pictures to 35x35 image style. + */ +function commons_activity_streams_update_3102() { + $revert = array( + 'commons_activity_streams' => array('message_type'), + ); + features_revert($revert); + return array(); +} + +/** + * Reset field instances to hide the target users field from the updated profile message. + */ +function commons_activity_streams_update_3103() { + $revert = array( + 'commons_activity_streams' => array('field_instance'), + ); + features_revert($revert); + return array(); +} + +/** + * Enable timeago for nodes and comments. + */ +function commons_activity_streams_update_3104() { + $revert = array( + 'commons_activity_streams' => array('variable'), + ); + features_revert($revert); + return array(); +} + +/** + * Remove duplicative node access filters from Commons Activity Streams views. + */ +function commons_activity_streams_update_3105() { + $revert = array( + 'commons_activity_streams' => array('views_view'), + 'commons_activity_streams_groups' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Add empty text to Commons Activity Streams views. + */ +function commons_activity_streams_update_3106() { + $revert = array( + 'commons_activity_streams' => array('views_view'), + ); + features_revert($revert); + return array(); +} diff --git a/modules/commons/commons_activity_streams/commons_activity_streams.module b/modules/commons/commons_activity_streams/commons_activity_streams.module new file mode 100644 index 0000000..0f0641b --- /dev/null +++ b/modules/commons/commons_activity_streams/commons_activity_streams.module @@ -0,0 +1,265 @@ +uid); + // Allow other modules to change the message type used for this event. + $hook = 'node_insert'; + $message_type = 'commons_activity_streams_node_created'; + drupal_alter('commons_activity_streams_message_selection', $message_type, $hook, $node); + $message = message_create($message_type, array('uid' => $account->uid, 'timestamp' => $node->created)); + // Save reference to the node in the node reference field, and the + $wrapper = entity_metadata_wrapper('message', $message); + // We use a multiple value field in case we wish to use the same + // field for grouping messages in the future + // (eg http://drupal.org/node/1757060). + $wrapper->field_target_nodes[] = $node; + $wrapper->save(); +} + +/** + * Implements hook_comment_insert(). + */ +function commons_activity_streams_comment_insert($comment) { + $account = user_load($comment->uid); + $node = node_load($comment->nid); + // Allow other modules to change the message type used for this event. + $hook = 'comment_insert'; + $message_type = 'commons_activity_streams_comment_created'; + drupal_alter('commons_activity_streams_message_selection', $message_type, $hook, $node); + $message = message_create($message_type, array('uid' => $account->uid, 'timestamp' => $comment->created)); + + // Save reference to the node in the node reference field, and the + // "publish" state (i.e. if the node is published or unpublished). + $wrapper = entity_metadata_wrapper('message', $message); + $wrapper->field_target_nodes[] = $node; + $wrapper->field_target_comments[] = $comment; + + // The message should be published only if the node and the comment are + // both published. + // @todo: Deal with message publishing/unpublishing. + /* + $published = $node->status && $comment->status; + $wrapper->field_published->set($published); + */ + $wrapper->save(); +} + +/** + * Implements hook_comment_delete(). + */ +function commons_activity_streams_comment_delete($comment) { + // Delete the activity stream message created when this comment + // was posted. + if ($mids = commons_activity_streams_existing_messages($comment->uid, array($comment->cid), 'field_target_comments', 'commons_activity_streams_comment_created')) { + message_delete_multiple($mids); + } +} + +/** + * Implements hook_message_access_alter(). + */ +function commons_activity_streams_message_access_alter(&$access, $context) { + // We're only interested in the 'view' operation. + if ($context['op'] != 'view') { + return; + } + + $message = $context['entity']; + // Verify view access to nodes referenced in the message. + if (isset($message->field_target_nodes)) { + foreach ($message->field_target_nodes[LANGUAGE_NONE] as $key => $value) { + $node = node_load($value['target_id']); + if (!node_access('view', $node, $context['account'])) { + // If the user cannot view any nodes in the message, + // deny access to the entire message; + $access = FALSE; + return; + } + } + } +} + +/** +* Find existing messages that match certain parameters. +*/ +function commons_activity_streams_existing_messages($acting_uid, $target_ids, $target_field, $message_type) { + $query = new EntityFieldQuery(); + $query->entityCondition('entity_type', 'message', '=') + ->propertyCondition('uid', $acting_uid) + ->propertyCondition('type', $message_type, '=') + ->fieldCondition($target_field, 'target_id', $target_ids, 'IN') + ->execute(); + + if (!empty($query->ordered_results)) { + $mids = array(); + foreach($query->ordered_results as $result) { + $mids[] = $result->entity_id; + } + return $mids; + } + return FALSE; +} + +/** + * Create an activity stream message when a user updates her profile. + */ +function commons_activity_streams_user_profile_submit($form, &$form_state) { + global $user; + + // Fields to ignore in $form_state['values'] when detecting changes. + $remove_keys = array( + 'uid', + 'name', + 'pass', + 'current_pass_required_values', + 'current_pass', + 'status', + 'roles', + 'notify', + 'signature', + 'picture_delete', + 'message_subscribe_email', + 'og_user_node', + 'cancel', + 'metatags', + 'timezone', + 'signature_format', + 'form_token', + 'form_id', + 'form_build_id', + 'picture_upload', + 'submit' + ); + $profile_values = array_diff_key($form_state['values'], array_flip($remove_keys)); + ksort($profile_values); + $profile_data = serialize($profile_values); + + $stored_profile_values = array_diff_key($form_state['storage']['values'], array_flip($remove_keys)); + ksort($stored_profile_values); + $stored_profile_data = serialize($stored_profile_values); + + // Do not generate a message if + // - the user did not submit their own form + // - no changes were detected + // - a profile update message created within the last 15 minutes + $time_ago = time() - 900; + $query = new EntityFieldQuery(); + $query->entityCondition('entity_type', 'message') + ->propertyCondition('uid', $form_state['user']->uid) + ->propertyCondition('type', 'commons_activity_streams_user_profile_updated') + ->propertyCondition('timestamp', $time_ago, '>') + ->count(); + $count = $query->execute(); + + if ($user->uid != $form_state['user']->uid || + $profile_data == $stored_profile_data || + $count > 0) { + return; + } + + $account = $form_state['user']; + // Allow other modules to change the message type used for this event. + $hook = 'user_profile_update'; + $message_type = 'commons_activity_streams_user_profile_updated'; + drupal_alter('commons_activity_streams_message_selection', $message_type, $hook, $account); + $message = message_create($message_type, array('uid' => $account->uid, 'timestamp' => REQUEST_TIME)); + // Save reference to the node in the node reference field, and the + $wrapper = entity_metadata_wrapper('message', $message); + $wrapper->field_target_users[] = $account; + $wrapper->save(); +} + +/** + * Implements hook_token_info(). + */ +function commons_activity_streams_token_info() { + $styles = image_styles(); + $tokens = array(); + foreach ($styles as $style_name => $style) { + $tokens['picture:' . $style_name] = array( + 'name' => t('Picture: @st image style', array('@st' => $style_name)), + 'description' => t('Picture: @st image style', array('@st' => $style_name)), + ); + } + return array( + 'tokens' => array( + 'user' => $tokens, + ), + ); +} + +/** + * Implements hook_tokens(). + */ +function commons_activity_streams_tokens($type, $tokens, array $data = array(), array $options = array()) { + $replacements = array(); + if ($type == 'user' && isset($data['user'])) { + $user = $data['user']; + $user_wrapper = entity_metadata_wrapper('user', $user); + $alt = $user->name; + if (isset($user->field_name_first)) { + $alt = $user_wrapper->field_name_first->value(); + if (isset($user->field_name_last)) { + $alt .= " " . $user_wrapper->field_name_last->value(); + } + } + $alt = t("@name's picture", array('@name' => $alt)); + foreach ($tokens as $token => $original) { + if (strpos($token, 'picture:') !== FALSE) { + list( , $style) = explode(':', $token); + $path = variable_get('user_picture_default', '/profiles/commons/images/avatars/user-avatar.png'); + if (!empty($user->picture)) { + $path = image_style_url($style, $user->picture->uri); + } + $image_variables = array( + 'path' => $path, + 'alt' => $alt, + 'title' => $alt, + 'class' => array('image-style-none'), + ); + $image = theme('image', $image_variables); + $user_path = user_uri($user); + $link_options = array( + 'attributes' => array( + 'title' => t('View user profile.'), + ), + 'html' => TRUE, + ); + $replacements[$original] = "
" . l($image, $user_path['path'], $link_options) . "
"; + } + } + } + return $replacements; +} diff --git a/modules/commons/commons_activity_streams/commons_activity_streams.strongarm.inc b/modules/commons/commons_activity_streams/commons_activity_streams.strongarm.inc new file mode 100644 index 0000000..13df9ef --- /dev/null +++ b/modules/commons/commons_activity_streams/commons_activity_streams.strongarm.inc @@ -0,0 +1,130 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_message__commons_activity_streams_comment_created'; + $strongarm->value = array( + 'view_modes' => array(), + 'extra_fields' => array( + 'form' => array(), + 'display' => array( + 'message__message_text__0' => array( + 'message_notify_email_subject' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + ), + 'message__message_text__1' => array( + 'message_notify_email_subject' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + ), + ), + ), + ); + $export['field_bundle_settings_message__commons_activity_streams_comment_created'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_message__commons_activity_streams_node_created'; + $strongarm->value = array( + 'view_modes' => array(), + 'extra_fields' => array( + 'form' => array(), + 'display' => array( + 'message__message_text__0' => array( + 'message_notify_email_subject' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + ), + 'message__message_text__1' => array( + 'message_notify_email_subject' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + ), + ), + ), + ); + $export['field_bundle_settings_message__commons_activity_streams_node_created'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_message__commons_activity_streams_user_profile_updated'; + $strongarm->value = array( + 'view_modes' => array(), + 'extra_fields' => array( + 'form' => array(), + 'display' => array( + 'message__message_text__0' => array( + 'message_notify_email_subject' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + ), + 'message__message_text__1' => array( + 'message_notify_email_subject' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + ), + ), + ), + ); + $export['field_bundle_settings_message__commons_activity_streams_user_profile_updated'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'timeago_comment'; + $strongarm->value = 1; + $export['timeago_comment'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'timeago_node'; + $strongarm->value = 1; + $export['timeago_node'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_activity_streams/commons_activity_streams.views_default.inc b/modules/commons/commons_activity_streams/commons_activity_streams.views_default.inc new file mode 100644 index 0000000..a66e096 --- /dev/null +++ b/modules/commons/commons_activity_streams/commons_activity_streams.views_default.inc @@ -0,0 +1,320 @@ +name = 'commons_activity_streams_activity'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'message'; + $view->human_name = 'Commons Activity Streams - Activity (Site-wide)'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Recent site activity'; + $handler->display->display_options['use_ajax'] = TRUE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['link_display'] = 'custom_url'; + $handler->display->display_options['access']['type'] = 'none'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['pager']['options']['items_per_page'] = '20'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '0'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'Nobody has performed any activity on the site recently.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: Entity Reference: Referenced Entity */ + $handler->display->display_options['relationships']['field_target_nodes_target_id']['id'] = 'field_target_nodes_target_id'; + $handler->display->display_options['relationships']['field_target_nodes_target_id']['table'] = 'field_data_field_target_nodes'; + $handler->display->display_options['relationships']['field_target_nodes_target_id']['field'] = 'field_target_nodes_target_id'; + /* Field: Message: Rendered Message */ + $handler->display->display_options['fields']['rendered_entity']['id'] = 'rendered_entity'; + $handler->display->display_options['fields']['rendered_entity']['table'] = 'views_entity_message'; + $handler->display->display_options['fields']['rendered_entity']['field'] = 'rendered_entity'; + $handler->display->display_options['fields']['rendered_entity']['label'] = ''; + $handler->display->display_options['fields']['rendered_entity']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['rendered_entity']['link_to_entity'] = 1; + $handler->display->display_options['fields']['rendered_entity']['display'] = 'view'; + $handler->display->display_options['fields']['rendered_entity']['view_mode'] = 'full'; + /* Field: Message: Timestamp */ + $handler->display->display_options['fields']['timestamp']['id'] = 'timestamp'; + $handler->display->display_options['fields']['timestamp']['table'] = 'message'; + $handler->display->display_options['fields']['timestamp']['field'] = 'timestamp'; + $handler->display->display_options['fields']['timestamp']['label'] = ''; + $handler->display->display_options['fields']['timestamp']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['timestamp']['date_format'] = 'time_ago_dynamic'; + /* Sort criterion: Message: Timestamp */ + $handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp'; + $handler->display->display_options['sorts']['timestamp']['table'] = 'message'; + $handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp'; + $handler->display->display_options['sorts']['timestamp']['order'] = 'DESC'; + /* Contextual filter: Message: Message ID */ + $handler->display->display_options['arguments']['mid']['id'] = 'mid'; + $handler->display->display_options['arguments']['mid']['table'] = 'message'; + $handler->display->display_options['arguments']['mid']['field'] = 'mid'; + $handler->display->display_options['arguments']['mid']['default_action'] = 'default'; + $handler->display->display_options['arguments']['mid']['default_argument_type'] = 'commons_follow_message'; + $handler->display->display_options['arguments']['mid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['mid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['mid']['summary_options']['items_per_page'] = '25'; + $handler->display->display_options['arguments']['mid']['break_phrase'] = TRUE; + /* Filter criterion: Content: Published or admin */ + $handler->display->display_options['filters']['status_extra']['id'] = 'status_extra'; + $handler->display->display_options['filters']['status_extra']['table'] = 'node'; + $handler->display->display_options['filters']['status_extra']['field'] = 'status_extra'; + $handler->display->display_options['filters']['status_extra']['relationship'] = 'field_target_nodes_target_id'; + /* Filter criterion: Message: User Follow */ + $handler->display->display_options['filters']['cf_user_follow_message']['id'] = 'cf_user_follow_message'; + $handler->display->display_options['filters']['cf_user_follow_message']['table'] = 'message'; + $handler->display->display_options['filters']['cf_user_follow_message']['field'] = 'cf_user_follow_message'; + $handler->display->display_options['filters']['cf_user_follow_message']['value'] = '0'; + $handler->display->display_options['filters']['cf_user_follow_message']['exposed'] = TRUE; + $handler->display->display_options['filters']['cf_user_follow_message']['expose']['operator_id'] = ''; + $handler->display->display_options['filters']['cf_user_follow_message']['expose']['label'] = 'Show'; + $handler->display->display_options['filters']['cf_user_follow_message']['expose']['operator'] = 'cf_user_follow_message_op'; + $handler->display->display_options['filters']['cf_user_follow_message']['expose']['identifier'] = 'following'; + $handler->display->display_options['filters']['cf_user_follow_message']['expose']['required'] = TRUE; + $handler->display->display_options['filters']['cf_user_follow_message']['expose']['remember'] = TRUE; + $handler->display->display_options['filters']['cf_user_follow_message']['expose']['remember_roles'] = array( + 2 => '2', + 1 => 0, + ); + /* Filter criterion: Message: Message category */ + $handler->display->display_options['filters']['type_category']['id'] = 'type_category'; + $handler->display->display_options['filters']['type_category']['table'] = 'message'; + $handler->display->display_options['filters']['type_category']['field'] = 'type_category'; + $handler->display->display_options['filters']['type_category']['value'] = array( + 'message_type' => 'message_type', + ); + + /* Display: Activity (Sidebar) */ + $handler = $view->new_display('panel_pane', 'Activity (Sidebar)', 'panel_pane_1'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['defaults']['use_more'] = FALSE; + $handler->display->display_options['use_more'] = TRUE; + $handler->display->display_options['defaults']['use_more_always'] = FALSE; + $handler->display->display_options['defaults']['use_more_always'] = FALSE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['defaults']['use_more_text'] = FALSE; + $handler->display->display_options['link_url'] = 'activity'; + $handler->display->display_options['defaults']['pager'] = FALSE; + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['pager']['options']['items_per_page'] = '5'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['defaults']['relationships'] = FALSE; + /* Relationship: Entity Reference: Referenced Entity */ + $handler->display->display_options['relationships']['field_target_nodes_target_id']['id'] = 'field_target_nodes_target_id'; + $handler->display->display_options['relationships']['field_target_nodes_target_id']['table'] = 'field_data_field_target_nodes'; + $handler->display->display_options['relationships']['field_target_nodes_target_id']['field'] = 'field_target_nodes_target_id'; + $handler->display->display_options['defaults']['arguments'] = FALSE; + $handler->display->display_options['defaults']['filter_groups'] = FALSE; + $handler->display->display_options['defaults']['filters'] = FALSE; + /* Filter criterion: Message: Message category */ + $handler->display->display_options['filters']['type_category']['id'] = 'type_category'; + $handler->display->display_options['filters']['type_category']['table'] = 'message'; + $handler->display->display_options['filters']['type_category']['field'] = 'type_category'; + $handler->display->display_options['filters']['type_category']['value'] = array( + 'message_type' => 'message_type', + ); + /* Filter criterion: Content: Published or admin */ + $handler->display->display_options['filters']['status_extra']['id'] = 'status_extra'; + $handler->display->display_options['filters']['status_extra']['table'] = 'node'; + $handler->display->display_options['filters']['status_extra']['field'] = 'status_extra'; + $handler->display->display_options['filters']['status_extra']['relationship'] = 'field_target_nodes_target_id'; + + /* Display: Activity - Full view */ + $handler = $view->new_display('panel_pane', 'Activity - Full view', 'panel_pane_3'); + $handler->display->display_options['defaults']['title'] = FALSE; + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['pane_category']['name'] = 'Commons'; + $handler->display->display_options['pane_category']['weight'] = '0'; + $handler->display->display_options['inherit_panels_path'] = '1'; + $translatables['commons_activity_streams_activity'] = array( + t('Master'), + t('Recent site activity'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('Nobody has performed any activity on the site recently.'), + t('Content entity referenced from field_target_nodes'), + t('All'), + t('Show'), + t('Activity (Sidebar)'), + t('Commons'), + t('Activity - Full view'), + ); + $export['commons_activity_streams_activity'] = $view; + + $view = new view(); + $view->name = 'commons_activity_streams_user_activity'; + $view->description = ''; + $view->tag = 'commons'; + $view->base_table = 'message'; + $view->human_name = 'Commons Activity Streams (User-specific activity)'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Recent site activity'; + $handler->display->display_options['use_ajax'] = TRUE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['link_display'] = 'custom_url'; + $handler->display->display_options['access']['type'] = 'none'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['pager']['options']['items_per_page'] = '20'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '0'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'This person hasn\'t performed any activities on the site yet.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: Entity Reference: Referenced Entity */ + $handler->display->display_options['relationships']['field_target_nodes_target_id']['id'] = 'field_target_nodes_target_id'; + $handler->display->display_options['relationships']['field_target_nodes_target_id']['table'] = 'field_data_field_target_nodes'; + $handler->display->display_options['relationships']['field_target_nodes_target_id']['field'] = 'field_target_nodes_target_id'; + /* Field: Message: Rendered Message */ + $handler->display->display_options['fields']['rendered_entity']['id'] = 'rendered_entity'; + $handler->display->display_options['fields']['rendered_entity']['table'] = 'views_entity_message'; + $handler->display->display_options['fields']['rendered_entity']['field'] = 'rendered_entity'; + $handler->display->display_options['fields']['rendered_entity']['label'] = ''; + $handler->display->display_options['fields']['rendered_entity']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['rendered_entity']['link_to_entity'] = 1; + $handler->display->display_options['fields']['rendered_entity']['display'] = 'view'; + $handler->display->display_options['fields']['rendered_entity']['view_mode'] = 'full'; + /* Field: Message: Timestamp */ + $handler->display->display_options['fields']['timestamp']['id'] = 'timestamp'; + $handler->display->display_options['fields']['timestamp']['table'] = 'message'; + $handler->display->display_options['fields']['timestamp']['field'] = 'timestamp'; + $handler->display->display_options['fields']['timestamp']['label'] = ''; + $handler->display->display_options['fields']['timestamp']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['timestamp']['date_format'] = 'time_ago_dynamic'; + /* Sort criterion: Message: Timestamp */ + $handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp'; + $handler->display->display_options['sorts']['timestamp']['table'] = 'message'; + $handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp'; + $handler->display->display_options['sorts']['timestamp']['order'] = 'DESC'; + /* Contextual filter: Message: User uid */ + $handler->display->display_options['arguments']['user']['id'] = 'user'; + $handler->display->display_options['arguments']['user']['table'] = 'message'; + $handler->display->display_options['arguments']['user']['field'] = 'user'; + $handler->display->display_options['arguments']['user']['default_action'] = 'not found'; + $handler->display->display_options['arguments']['user']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['user']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['user']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['user']['summary_options']['items_per_page'] = '25'; + /* Filter criterion: Content: Published or admin */ + $handler->display->display_options['filters']['status_extra']['id'] = 'status_extra'; + $handler->display->display_options['filters']['status_extra']['table'] = 'node'; + $handler->display->display_options['filters']['status_extra']['field'] = 'status_extra'; + $handler->display->display_options['filters']['status_extra']['relationship'] = 'field_target_nodes_target_id'; + /* Filter criterion: Message: Message category */ + $handler->display->display_options['filters']['type_category']['id'] = 'type_category'; + $handler->display->display_options['filters']['type_category']['table'] = 'message'; + $handler->display->display_options['filters']['type_category']['field'] = 'type_category'; + $handler->display->display_options['filters']['type_category']['value'] = array( + 'message_type' => 'message_type', + ); + + /* Display: Activity (Sidebar) */ + $handler = $view->new_display('panel_pane', 'Activity (Sidebar)', 'panel_pane_1'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['defaults']['use_more'] = FALSE; + $handler->display->display_options['use_more'] = TRUE; + $handler->display->display_options['defaults']['use_more_always'] = FALSE; + $handler->display->display_options['defaults']['use_more_always'] = FALSE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['defaults']['use_more_text'] = FALSE; + $handler->display->display_options['defaults']['pager'] = FALSE; + $handler->display->display_options['pager']['type'] = 'load_more'; + $handler->display->display_options['pager']['options']['items_per_page'] = '5'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '0'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['pane_category']['name'] = 'Commons'; + $handler->display->display_options['pane_category']['weight'] = '0'; + $handler->display->display_options['argument_input'] = array( + 'user' => array( + 'type' => 'context', + 'context' => 'entity:user.uid', + 'context_optional' => 0, + 'panel' => '0', + 'fixed' => '', + 'label' => 'Message: User uid', + ), + ); + + /* Display: Activity - Full view */ + $handler = $view->new_display('panel_pane', 'Activity - Full view', 'panel_pane_3'); + $handler->display->display_options['defaults']['title'] = FALSE; + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['pane_category']['name'] = 'Commons'; + $handler->display->display_options['pane_category']['weight'] = '0'; + $translatables['commons_activity_streams_user_activity'] = array( + t('Master'), + t('Recent site activity'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('This person hasn\'t performed any activities on the site yet.'), + t('Content entity referenced from field_target_nodes'), + t('All'), + t('Activity (Sidebar)'), + t('Commons'), + t('Activity - Full view'), + ); + $export['commons_activity_streams_user_activity'] = $view; + + return $export; +} diff --git a/modules/commons/commons_activity_streams/commons_activity_streams_groups/commons_activity_streams_groups.features.inc b/modules/commons/commons_activity_streams/commons_activity_streams_groups/commons_activity_streams_groups.features.inc new file mode 100644 index 0000000..e5a7598 --- /dev/null +++ b/modules/commons/commons_activity_streams/commons_activity_streams_groups/commons_activity_streams_groups.features.inc @@ -0,0 +1,12 @@ + "3.0"); +} diff --git a/modules/commons/commons_activity_streams/commons_activity_streams_groups/commons_activity_streams_groups.info b/modules/commons/commons_activity_streams/commons_activity_streams_groups/commons_activity_streams_groups.info new file mode 100644 index 0000000..b6b2ea0 --- /dev/null +++ b/modules/commons/commons_activity_streams/commons_activity_streams_groups/commons_activity_streams_groups.info @@ -0,0 +1,11 @@ +name = Commons Activity Streams Groups +description = Contains Organic Groups integration for Commons Activity Streams +core = 7.x +package = Commons - Building blocks +dependencies[] = commons_activity_streams +dependencies[] = entity +dependencies[] = views +dependencies[] = views_content +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[views_view][] = activity_group diff --git a/modules/commons/commons_activity_streams/commons_activity_streams_groups/commons_activity_streams_groups.install b/modules/commons/commons_activity_streams/commons_activity_streams_groups/commons_activity_streams_groups.install new file mode 100644 index 0000000..eacba80 --- /dev/null +++ b/modules/commons/commons_activity_streams/commons_activity_streams_groups/commons_activity_streams_groups.install @@ -0,0 +1,12 @@ + array('views_view'), + ); + features_revert($revert); + return array(); +} diff --git a/modules/commons/commons_activity_streams/commons_activity_streams_groups/commons_activity_streams_groups.module b/modules/commons/commons_activity_streams/commons_activity_streams_groups/commons_activity_streams_groups.module new file mode 100644 index 0000000..ebfd5eb --- /dev/null +++ b/modules/commons/commons_activity_streams/commons_activity_streams_groups/commons_activity_streams_groups.module @@ -0,0 +1,7 @@ +name = 'activity_group'; + $view->description = ''; + $view->tag = 'Commons'; + $view->base_table = 'message'; + $view->human_name = 'Commons Activity Streams - Group activity'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Recent activity in this group'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'none'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['pager']['options']['items_per_page'] = '4'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'Nobody has performed any activity in this group recently.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: Entity Reference: Referenced Entity */ + $handler->display->display_options['relationships']['field_target_nodes_target_id']['id'] = 'field_target_nodes_target_id'; + $handler->display->display_options['relationships']['field_target_nodes_target_id']['table'] = 'field_data_field_target_nodes'; + $handler->display->display_options['relationships']['field_target_nodes_target_id']['field'] = 'field_target_nodes_target_id'; + $handler->display->display_options['relationships']['field_target_nodes_target_id']['required'] = TRUE; + /* Relationship: OG membership: OG membership from Node */ + $handler->display->display_options['relationships']['og_membership_rel']['id'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['table'] = 'node'; + $handler->display->display_options['relationships']['og_membership_rel']['field'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['relationship'] = 'field_target_nodes_target_id'; + $handler->display->display_options['relationships']['og_membership_rel']['required'] = TRUE; + /* Field: Message: Rendered Message */ + $handler->display->display_options['fields']['rendered_entity']['id'] = 'rendered_entity'; + $handler->display->display_options['fields']['rendered_entity']['table'] = 'views_entity_message'; + $handler->display->display_options['fields']['rendered_entity']['field'] = 'rendered_entity'; + $handler->display->display_options['fields']['rendered_entity']['label'] = ''; + $handler->display->display_options['fields']['rendered_entity']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['rendered_entity']['link_to_entity'] = 0; + $handler->display->display_options['fields']['rendered_entity']['display'] = 'view'; + $handler->display->display_options['fields']['rendered_entity']['view_mode'] = 'full'; + /* Field: Message: Timestamp */ + $handler->display->display_options['fields']['timestamp']['id'] = 'timestamp'; + $handler->display->display_options['fields']['timestamp']['table'] = 'message'; + $handler->display->display_options['fields']['timestamp']['field'] = 'timestamp'; + $handler->display->display_options['fields']['timestamp']['label'] = ''; + $handler->display->display_options['fields']['timestamp']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['timestamp']['date_format'] = 'time_ago_dynamic'; + /* Sort criterion: Message: Timestamp */ + $handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp'; + $handler->display->display_options['sorts']['timestamp']['table'] = 'message'; + $handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp'; + $handler->display->display_options['sorts']['timestamp']['order'] = 'DESC'; + /* Contextual filter: OG membership: Group ID */ + $handler->display->display_options['arguments']['gid']['id'] = 'gid'; + $handler->display->display_options['arguments']['gid']['table'] = 'og_membership'; + $handler->display->display_options['arguments']['gid']['field'] = 'gid'; + $handler->display->display_options['arguments']['gid']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['arguments']['gid']['default_action'] = 'not found'; + $handler->display->display_options['arguments']['gid']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['gid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['gid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['gid']['summary_options']['items_per_page'] = '25'; + /* Filter criterion: Content: Published or admin */ + $handler->display->display_options['filters']['status_extra']['id'] = 'status_extra'; + $handler->display->display_options['filters']['status_extra']['table'] = 'node'; + $handler->display->display_options['filters']['status_extra']['field'] = 'status_extra'; + $handler->display->display_options['filters']['status_extra']['relationship'] = 'field_target_nodes_target_id'; + /* Filter criterion: Message: Message category */ + $handler->display->display_options['filters']['type_category']['id'] = 'type_category'; + $handler->display->display_options['filters']['type_category']['table'] = 'message'; + $handler->display->display_options['filters']['type_category']['field'] = 'type_category'; + $handler->display->display_options['filters']['type_category']['value'] = array( + 'message_type' => 'message_type', + ); + /* Filter criterion: OG membership: Group_type */ + $handler->display->display_options['filters']['group_type']['id'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['table'] = 'og_membership'; + $handler->display->display_options['filters']['group_type']['field'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['filters']['group_type']['value'] = array( + 'node' => 'node', + ); + + /* Display: Content pane */ + $handler = $view->new_display('panel_pane', 'Content pane', 'panel_pane_1'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['pane_category']['name'] = 'Commons'; + $handler->display->display_options['pane_category']['weight'] = '0'; + $handler->display->display_options['allow']['use_pager'] = 0; + $handler->display->display_options['allow']['items_per_page'] = 'items_per_page'; + $handler->display->display_options['allow']['offset'] = 0; + $handler->display->display_options['allow']['link_to_view'] = 0; + $handler->display->display_options['allow']['more_link'] = 0; + $handler->display->display_options['allow']['path_override'] = 0; + $handler->display->display_options['allow']['title_override'] = 0; + $handler->display->display_options['allow']['exposed_form'] = 0; + $handler->display->display_options['allow']['fields_override'] = 0; + $handler->display->display_options['argument_input'] = array( + 'gid' => array( + 'type' => 'user', + 'context' => 'entity:comment.author', + 'context_optional' => 0, + 'panel' => '0', + 'fixed' => '', + 'label' => 'OG membership: Group ID', + ), + ); + $translatables['activity_group'] = array( + t('Master'), + t('Recent activity in this group'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Nobody has performed any activity in this group recently.'), + t('Content entity referenced from field_target_nodes'), + t('OG membership from node'), + t('All'), + t('Content pane'), + t('Commons'), + ); + $export['activity_group'] = $view; + + return $export; +} diff --git a/modules/commons/commons_body/commons_body.features.field_base.inc b/modules/commons/commons_body/commons_body.features.field_base.inc new file mode 100644 index 0000000..08b6813 --- /dev/null +++ b/modules/commons/commons_body/commons_body.features.field_base.inc @@ -0,0 +1,43 @@ + 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array( + 0 => 'node', + ), + 'field_name' => 'body', + 'foreign keys' => array( + 'format' => array( + 'columns' => array( + 'format' => 'format', + ), + 'table' => 'filter_format', + ), + ), + 'indexes' => array( + 'format' => array( + 0 => 'format', + ), + ), + 'locked' => 0, + 'module' => 'text', + 'settings' => array(), + 'translatable' => 0, + 'type' => 'text_with_summary', + ); + + return $field_bases; +} diff --git a/modules/commons/commons_body/commons_body.info b/modules/commons/commons_body/commons_body.info new file mode 100644 index 0000000..03c3d20 --- /dev/null +++ b/modules/commons/commons_body/commons_body.info @@ -0,0 +1,9 @@ +name = Commons Body Field +description = Provides a simple body field for re-use by various Commons content types +core = 7.x +package = Commons - Building blocks +dependencies[] = features +dependencies[] = field_sql_storage +dependencies[] = text +features[features_api][] = api:2 +features[field_base][] = body diff --git a/modules/commons/commons_body/commons_body.module b/modules/commons/commons_body/commons_body.module new file mode 100644 index 0000000..44788b0 --- /dev/null +++ b/modules/commons/commons_body/commons_body.module @@ -0,0 +1,5 @@ + 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'title_field', + 'foreign keys' => array( + 'format' => array( + 'columns' => array( + 'format' => 'format', + ), + 'table' => 'filter_format', + ), + ), + 'indexes' => array( + 'format' => array( + 0 => 'format', + ), + ), + 'locked' => 0, + 'module' => 'text', + 'settings' => array( + 'max_length' => 255, + ), + 'translatable' => 1, + 'type' => 'text', + ); + + return $field_bases; +} diff --git a/modules/commons/commons_bw/commons_bw.features.field_instance.inc b/modules/commons/commons_bw/commons_bw.features.field_instance.inc new file mode 100644 index 0000000..7189faf --- /dev/null +++ b/modules/commons/commons_bw/commons_bw.features.field_instance.inc @@ -0,0 +1,73 @@ +type)) { + commons_bw_field_definition($field_instances, $node_type->type); + } + } + + // Translatables + // Included for use with string extractors like potx. + t('Title'); + + return $field_instances; +} + +/** + * Creates field instance definitions for all node types. + */ +function commons_bw_field_definition(&$field_instances, $bundle) { + // Exported field_instance: 'node-[Bundle]-title_field' + $field_instances["node-$bundle-title_field"] = array( + 'bundle' => $bundle, + 'default_value' => NULL, + 'deleted' => '0', + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 12, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'display_in_partial_form' => !empty($display_in_partial_form[$bundle]), + 'entity_type' => 'node', + 'field_name' => 'title_field', + 'label' => 'Title', + 'required' => 1, + 'settings' => array( + 'hide_label' => array( + 'entity' => 0, + 'page' => 0, + ), + 'text_processing' => '0', + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'size' => '60', + ), + 'type' => 'text_textfield', + 'weight' => -5, + ), + ); +} diff --git a/modules/commons/commons_bw/commons_bw.info b/modules/commons/commons_bw/commons_bw.info new file mode 100644 index 0000000..2ce9fb3 --- /dev/null +++ b/modules/commons/commons_bw/commons_bw.info @@ -0,0 +1,13 @@ +name = Commons Tabbed Browsing Widget +core = 7.x +package = Commons - Building blocks +dependencies[] = commons_groups +dependencies[] = features +dependencies[] = og +dependencies[] = quicktabs +dependencies[] = quicktabs_tabstyles +dependencies[] = title +features[features_api][] = api:2 +features[field_base][] = title_field +files[] = includes/views/handlers/commons_bw_handler_node_partial_form.inc +; Views handlers diff --git a/modules/commons/commons_bw/commons_bw.install b/modules/commons/commons_bw/commons_bw.install new file mode 100644 index 0000000..a297a0c --- /dev/null +++ b/modules/commons/commons_bw/commons_bw.install @@ -0,0 +1,34 @@ + array( + 'field_base', 'field_instance', + ), + ); + features_revert($revert); + return array(); +} + +/** + * Make sure existing nodes titles are migrated to the title field. + * per http://drupal.org/node/1969088. + */ +function commons_bw_update_7302() { + foreach (node_type_get_types() as $node_type) { + // Set the title as "Replaced by title_field". + if (!title_field_replacement_enabled('node', $node_type->type, 'title')) { + title_field_replacement_toggle('node', $node_type->type, 'title'); + } + + // Migrate the titles to the title field. + title_field_replacement_batch_set('node', $node_type->type, 'title'); + } + + drupal_flush_all_caches(); +} diff --git a/modules/commons/commons_bw/commons_bw.module b/modules/commons/commons_bw/commons_bw.module new file mode 100644 index 0000000..35bf1f2 --- /dev/null +++ b/modules/commons/commons_bw/commons_bw.module @@ -0,0 +1,402 @@ +name == 'commons_bw') { + foreach (node_type_get_types() as $node_type) { + $type = $node_type->type; + if (commons_bw_node_auto_title_instance($type)) { + $info['features']['field_instance'][] = "node-$type-title_field"; + } + } + } +} + +/** + * Implements hook_ctools_plugin_directory(). + */ +function commons_bw_ctools_plugin_directory($module, $plugin) { + if ($module == 'ctools' && $plugin == 'content_types') { + return 'plugins/' . $plugin; + } +} + +/** + * Implements hook_views_api(). + */ +function commons_bw_views_api() { + return array( + 'api' => 3, + 'path' => drupal_get_path('module', 'commons_bw') . '/includes/views', + ); +} + +/** + * Implements hook_form_alter(). + */ +function commons_bw_form_alter(&$form, &$form_state, $form_id) { + // Implements tweaks to exposed filters and sorts per the Commons designs. + if ($form_id != 'views_exposed_form' || strpos($form['#id'],'views-exposed-form-commons-bw') !== 0) { + return; + } + + // Remove the sort order (eg, descending vs ascending). + $form['sort_order']['#access'] = FALSE; + + $form['sort_by']['#title'] = t('Sorted by'); +} + +/** + * Implements hook_forms(). + * + * The bundle is added to the partial node form ID, to prevent duplicate IDs on + * the same page, but all of the partial forms are built with the same function. + */ +function commons_bw_forms($form_id, $args) { + $forms = array(); + if (strpos($form_id, 'commons_bw_partial_node_form__') === 0) { + $forms[$form_id] = array( + 'callback' => 'commons_bw_partial_node_form', + ); + } + + return $forms; +} + +/** + * Partial node form for the browsing widget. + * + * @param $bundle + * The node bundle. + */ +function commons_bw_partial_node_form($form, &$form_state, $bundle, $group_id = NULL) { + global $user; + global $language; + + if (!$group_id) { + // Reset the og_field_widget_form cache because otherwise it ignores + // multiple tries to render the same group audience widget (We have the + // same group audience widget on the All and Posts tabs, when displaying + // this form without group context). + drupal_static_reset('og_field_widget_form'); + } + + if ($group_id) { + $form_state['group_id'] = $group_id; + } + + $instances = field_info_instances('node', $bundle); + + // Remove all fields except those marked as "display_in_partial_form". + foreach($instances as $field_name => $instance) { + if (empty($instance['display_in_partial_form'])) { + unset($instances[$field_name]); + } + } + // Make sure there's a field left to display. + if (empty($instances)) { + return $form; + } + + // Create a dummy node for field_attach_form(). + $node = new stdClass(); + $node->type = $bundle; + node_object_prepare($node); + + if (module_exists('locale')) { + if (locale_multilingual_node_type($node->type)) { + $node->language = $language->language; + } + else { + $default = language_default(); + $node->language = $default->language; + } + } + else { + $node->language = LANGUAGE_NONE; + } + + field_attach_form('node', $node, $form, $form_state, entity_language('node', $node)); + + foreach(element_children($form) as $field_name) { + if (empty($instances[$field_name])) { + $form[$field_name]['#access'] = FALSE; + } + } + + if (!empty($form['#metatags'])) { + unset($form['#metatags']); + } + + // When not in a group context, enable the group audience widget. + $form[OG_AUDIENCE_FIELD]['#weight'] = 100; + $form[OG_AUDIENCE_FIELD]['#access'] = !$group_id; + + // Form title. + $bundles = field_info_bundles('node'); + $form['title'] = array( + '#markup' => '

' . t('Create a @bundle', array('@bundle' => strtolower($bundles[$bundle]['label']))) . '

', + '#weight' => -50, + ); + + // Display the user's picture. + $wrapper = entity_metadata_wrapper('user', $user); + $path = empty($user->picture) ? variable_get('user_picture_default') : $wrapper->value()->picture->uri; + $form['user_picture'] = array( + '#theme' => 'image_style', + '#style_name' => '50x50_avatar', + '#path' => $path, + '#prefix' => '
', + '#suffix' => '
', + '#weight' => -20, + ); + + $form['actions'] = array( + '#type' => 'actions', + '#weight' => 200, + ); + $form['actions']['submit'] = array( + '#type' => 'submit', + '#value' => t('Save'), + ); + + // Add in some descriptive classes for css down the line. + $form['#attributes']['class'][] = 'node'; + $form['#attributes']['class'][] = 'commons-bw-partial-node-form'; + $form['#attributes']['class'][] = 'commons-bw-partial-node-form-' . $bundle; + + // Add a link to the full node form. + $form['full_form'] = array( + '#theme' => 'link', + '#text' => t('Go to full form'), + '#path' => 'node/add/' . str_replace('_', '-', $bundle), + '#options' => array( + 'attributes' => array('class' => array('full-form')), + 'html' => FALSE, + ), + '#weight' => 100, + ); + + if ($group_id) { + $form['full_form']['#options']['query'] = array(OG_AUDIENCE_FIELD => $group_id); + } + + // Add the commons_bw after build first, in case other pre-renders needs need + // to address fields by there CSS ID. + array_unshift($form['#pre_render'], 'commons_bw_partial_node_form_after_build'); + $form['#validate'][] = 'commons_bw_partial_node_form_validate'; + return $form; +} + +/** + * After-build call-back. See commons_bw_partial_node_form(). + */ +function commons_bw_partial_node_form_after_build($form) { + $bundle = $form['#bundle']; + // Add the node's bundle to the IDs of inputs, to avoid having duplicate IDs. + $id_suffix = '-' . str_replace('_', '-', $bundle); + + foreach(element_children($form) as $field_name) { + if (!empty($form[$field_name]['#language'])) { + $language = $form[$field_name]['#language']; + + if (!empty($form[$field_name][$language][0]['value']['#id'])) { + $form[$field_name][$language][0]['value']['#id'] .= $id_suffix; + } + + if (!empty($form[$field_name][$language][0]['default']['#id'])) { + $form[$field_name][$language][0]['default']['#id'] .= $id_suffix; + } + } + } + + // Set the form action to the form's tab. + $tabs = commons_bw_get_tab_definitions(); + // Search for the tab displaying the current bundle. + foreach ($tabs as $tab_id => $settings) { + if ($settings['bundle'] == $bundle) { + break; + } + } + $form['#action'] = url(current_path(), array('query' => array('qt-commons_bw' => $tab_id))); + + return $form; +} + +/** + * Validation handler; Attach the node validation to the partial node form. + */ +function commons_bw_partial_node_form_validate($form, $form_state) { + $node = $form['#entity']; + field_attach_validate('node', $node); + node_validate($node, $form, $form_state); + if ((!module_exists('commons_trusted_contacts') || (module_exists('commons_trusted_contacts') && !module_exists('og_access'))) && empty($form_state['group_id']) && empty($form_state['values'][OG_AUDIENCE_FIELD][LANGUAGE_NONE][0])) { + form_set_error(OG_AUDIENCE_FIELD, t('Please enter one or more groups where this content will be posted.')); + return FALSE; + } +} + +/** + * Submit handler; Create a node from the partial node form. + */ +function commons_bw_partial_node_form_submit($form, $form_state) { + $node = $form['#entity']; + node_submit($node); + // Mark the node as created with the partial form + $node->partial_node_form = TRUE; + field_attach_submit('node', $node, $form, $form_state); + + $wrapper = entity_metadata_wrapper('node', $node); + + // If the node has a body and doesn't has a title, create a title from the + // body. + if ((empty($wrapper->title_field) || !$wrapper->title_field->value()) && empty($node->title)) { + if (!empty($wrapper->body) && $wrapper->body->value()) { + $title = htmlspecialchars_decode($wrapper->body->value->value()); + // Strip tags and whitespaces. + $title = preg_replace('/[\t\n\r\0\x0B]/', '', strip_tags($title)); + // Shorten the title. + $node->title = truncate_utf8($title, 30, TRUE, TRUE); + } + } + + // Set the group audience. + if (!empty($form_state['group_id'])) { + $wrapper->{OG_AUDIENCE_FIELD}->set(array($form_state['group_id'])); + } + + $node->form_state = $form_state; + + $wrapper->save(); + + // Notify about the node creation. + $arguments = array('@type' => node_type_get_name($node), '%title' => $node->title); + drupal_set_message(t('@type %title has been created.', $arguments)); +} + +/** + * Implements hook_form_FORM_ID_alter(). + * + * Add a setting to group content fields, to determine whether they will be + * displayed on the mini node form of the browsing widget. + */ +function commons_bw_form_field_ui_field_edit_form_alter(&$form, &$form_state) { + if (!og_is_group_content_type($form['instance']['entity_type']['#value'], $form['instance']['bundle']['#value'])) { + return; + } + + // See if we're building for the first time, or getting pre-saved values. + $field_name = $form['#field']['field_name']; + if(!empty($form_state['field'][$field_name][LANGUAGE_NONE]['instance']['display_in_partial_form'])) { + $display_default = $form_state['field'][$field_name][LANGUAGE_NONE]['instance']['display_in_partial_form']; + } + else if (isset($form_state['build_info']['args'][0]['display_in_partial_form'])) { + $display_default = $form_state['build_info']['args'][0]['display_in_partial_form']; + } + else { + $display_default = FALSE; + } + + $form['instance']['display_in_partial_form'] = array( + '#type' => 'checkbox', + '#title' => t('Display in the browsing widget mini-form'), + '#default_value' => $display_default, + ); +} + +/** +* Get a list of modules that add content to a particular type of widget. +* The only currently supported widget type is 'group', but this +* could be extended to support other entities. +*/ +function commons_bw_get_tab_definitions($widget_type = 'group') { + $hook_name = 'commons_bw_' . $widget_type . '_widget'; + $tabs = module_invoke_all($hook_name); + drupal_alter($hook_name, $tabs); + return $tabs; +} + + +/** + * Helper function to determine whether Commons_BW should define a title + * field instance on behalf of a content type. + */ +function commons_bw_node_auto_title_instance($node_type) { + $commons_groups_entity_types = commons_groups_get_group_content_entity_types(); + $return = isset($commons_groups_entity_types['node'][$node_type]['auto_title_instance']) ? $commons_groups_entity_types['node'][$node_type]['auto_title_instance'] : TRUE; + return $return; +} +/** + * Provides a styled content creation dropdown widget for the 'all' + * tab of the group homepage browsing widget. + */ +function commons_bw_create_all_widget($group) { + $links = array(); + // Collect definitions from implementing modules. + $items = module_invoke_all('commons_bw_create_all_widget', $group); + uasort($items, 'element_sort'); + foreach ($items as $module => $item) { + $links[] = $item['link'] . ' ' . $item['text']; + // Populate the default content creation link. + if (isset($item['default']) && $item['default']) { + $default = $item; + } + } + $output = ''; + if (!empty($default)) { + $output .= $default['link'] . ''; + } + $output .= '
' . theme('item_list', array('items' => $links, 'type' => 'ul', 'attributes' => array('class' => 'commons-bw-create-all-widget-types'))) . '
'; + return $output; +} + +/** + * Generate a renderable group widget. + */ +function commons_bw_generate_group_widget($group = NULL) { + // The partial_node_form.js should be after quicktabs.js. + drupal_add_js(drupal_get_path('module', 'commons_bw') . '/js/partial_node_form.js', array('weight' => 100)); + + $settings = array('style' => 'Commons Pills', 'ajax' => FALSE, 'html' => TRUE); + // Load the default tab definitions. + $tabs = commons_bw_get_tab_definitions('group'); + foreach ($tabs as $key => $tab) { + // Populate the group argument. + $tabs[$key]['args'] = $group ? $group->nid : 0; + + // Add the result count for Tabs that are of the type 'view'; + if ($tab['type'] == 'view') { + $view = views_get_view($tab['vid']); + if (isset($tab['display'])) { + $view->set_display($tab['display']); + } + if ($group) { + $view->set_arguments(array($group->nid)); + } + $view->display_handler->options['filters']['flagged']['value'] = 'All'; + $view->get_total_rows = TRUE; + $view->execute(); + $tabs[$key]['title'] = $tabs[$key]['title'] . ' '. $view->total_rows . ''; + } + // Set the default tab. + if (isset($tabs[$key]['default']) && $tabs[$key]['default']) { + $settings['default_tab'] = $key; + } + } + + // Generate the Quicktabs instance. + return quicktabs_build_quicktabs('commons_bw', $settings, $tabs); +} + +/** + * Implements hook_quicktabs_tabstyles(). + */ +function commons_bw_quicktabs_tabstyles() { + $path = drupal_get_path('module', 'commons_bw'); + return array( + $path . '/plugins/quicktabs_styles/commons_pills/commons_pills.css' => t('Commons Pills'), + $path . '/plugins/quicktabs_styles/commons_tabs/commons_tabs.css' => t('Commons Tabs'), + ); +} diff --git a/modules/commons/commons_bw/includes/views/commons_bw.views.inc b/modules/commons/commons_bw/includes/views/commons_bw.views.inc new file mode 100644 index 0000000..8989587 --- /dev/null +++ b/modules/commons/commons_bw/includes/views/commons_bw.views.inc @@ -0,0 +1,18 @@ + t('Node partial form'), + 'help' => t('Display a minified node creation form.'), + 'area' => array( + 'handler' => 'commons_bw_handler_node_partial_form', + ), + ); + + return $data; +} diff --git a/modules/commons/commons_bw/includes/views/handlers/commons_bw_handler_node_partial_form.inc b/modules/commons/commons_bw/includes/views/handlers/commons_bw_handler_node_partial_form.inc new file mode 100644 index 0000000..f96b1c0 --- /dev/null +++ b/modules/commons/commons_bw/includes/views/handlers/commons_bw_handler_node_partial_form.inc @@ -0,0 +1,52 @@ + NULL); + return $options; + } + + function options_form(&$form, &$form_state) { + $bundles = og_get_all_group_content_bundle(); + + $form['bundle'] = array( + '#type' => 'select', + '#title' => t('Node type'), + '#options' => !empty($bundles['node']) ? $bundles['node'] : array(), + '#default_value' => $this->options['bundle'], + '#required' => TRUE, + ); + } + + function render($empty = FALSE) { + $cache = &drupal_static(__METHOD__, array()); + + $bundle = $this->options['bundle']; + $group_id = !empty($this->view->args[0]) ? $this->view->args[0] : NULL; + + // Verify content creation access. + $permission = "create $bundle content"; + if ($group_id && !og_user_access('node', $group_id, $permission)) { + return; + } + elseif (!user_access($permission)) { + return; + } + + // Avoid rendering a form for the same bundle twice; Instead, mark that it + // should be moved to this position from previously rendered form. + // See partial_node_form.js. + if (!empty($cache[$bundle])) { + return '
'; + } + $cache[$bundle] = TRUE; + + $form = drupal_get_form("commons_bw_partial_node_form__$bundle", $bundle, $group_id); + return render($form); + } +} diff --git a/modules/commons/commons_bw/js/partial_node_form.js b/modules/commons/commons_bw/js/partial_node_form.js new file mode 100644 index 0000000..2c4d1a8 --- /dev/null +++ b/modules/commons/commons_bw/js/partial_node_form.js @@ -0,0 +1,82 @@ +(function ($) { + +/** + * Handles presentation of multiple partial forms of the same node bundle; When + * showing a tab, check if it has a form's placeholder and if so, move the form + * to the current tab and move the placeholder to the former form's tab. + */ +Drupal.behaviors.commonsBwPartialNodeForm = { + attach: function (context, settings) { + $('.quicktabs-tabs a', context).click(function(){ + var $activeTab = $('#quicktabs-container-commons_bw .quicktabs-tabpage:not(.quicktabs-hide)', context); + // Check for a form placeholder. + var $placeholder = $activeTab.find('.partial-node-form-placeholder'); + if (!$placeholder.length) { + return; + } + + var $form = $('.commons-bw-partial-node-form-' + $placeholder.data('bundle'), context); + var $originalParent = $form.parent(); + // Replace the placeholder and the form. + $form.appendTo($placeholder.parent()); + $placeholder.appendTo($originalParent); + }); + } +} + +/** + * Expand a form when it is focused. + */ +Drupal.behaviors.commonsBwExpandableForm = { + attach: function (context, settings) { + $('.commons-bw-partial-node-form', context).once('commonsBwExpandableForm', function () { + // Assemble the variables. + var form = $(this), + toggleText = Drupal.t('Collapse the form'), + toggle = $('').attr({ + 'class': 'expandable-form-toggle element-hidden', + 'href': '#', + 'title': toggleText + }).append(toggleText), + triggerField = form.find('.trigger-field'), + fullFormLink = form.find('a.full-form'), + hideables = form.find('.hideable-field'), + errors = form.find('.error'); + + // Determine if the form has any errors. + if (!errors.length) { + // Forms with errors are shown expanded, so only add the toggle link to + // the top of forms which are error free. + form.prepend(toggle).addClass('expandable-form compact-form'); + + // Hide the hidden fields on load. + hideables.addClass('element-invisible'); + } + else { + // The full form link is only shown on collapsed forms so it is hidden + // for consistency. + fullFormLink.addClass('element-hidden'); + } + + // Make all hidden fields visible when the trigger field comes into + // focus. + triggerField.find('textarea, input').focus(function () { + form.addClass('expanded-form').removeClass('compact-form'); + toggle.removeClass('element-hidden'); + hideables.removeClass('element-invisible'); + fullFormLink.addClass('element-hidden'); + }); + + // Hide all the hidden fields when the trigger link is clicked. + toggle.click(function () { + form.addClass('compact-form').removeClass('expanded-form'); + toggle.addClass('element-hidden'); + hideables.addClass('element-invisible'); + fullFormLink.removeClass('element-hidden'); + return false; + }); + }); + } +} + +})(jQuery); diff --git a/modules/commons/commons_bw/plugins/content_types/commons_bw_group.inc b/modules/commons/commons_bw/plugins/content_types/commons_bw_group.inc new file mode 100644 index 0000000..271f7d3 --- /dev/null +++ b/modules/commons/commons_bw/plugins/content_types/commons_bw_group.inc @@ -0,0 +1,42 @@ + t('Commons Group Browsing widget'), + 'description' => t('Commons Group Browsing widget.'), + 'category' => t('Commons'), + 'single' => TRUE, + 'content type' => 'commons_bw_group', + 'all contexts' => TRUE, +); + +/** +* Output function for the '[content_type]' content type. +*/ +function commons_bw_commons_bw_group_content_type_render($subtype, $conf, $panel_args, $context) { + $context = array_shift($context); + $node = !empty($context->data) ? $context->data : NULL; + + $block = new stdClass(); + $block->title = ''; + $widget = commons_bw_generate_group_widget($node); + $block->content = drupal_render($widget['content']); + return $block; +} + +/** +* Returns an edit form for the custom type. +*/ +function commons_bw_commons_bw_group_content_type_edit_form($form, $form_state) { + return $form; +} + +/** +* Returns an edit form for the custom type. +*/ +function commons_bw_commons_bw_group_content_type_edit_form_submit($form, $form_state) { + return $form; +} diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/commons_pills.css b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/commons_pills.css new file mode 100644 index 0000000..4281fca --- /dev/null +++ b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/commons_pills.css @@ -0,0 +1,149 @@ +.quicktabs-style-commons-pills ul.quicktabs-tabs { + margin: 0 0 30px 0; + padding: 0; +} +.block-content .quicktabs-style-commons-pills ul.quicktabs-tabs { + padding: 0; +} +.quicktabs-style-commons-pills ul.quicktabs-tabs li { + display: inline-block; + padding: 0; + margin: 0 12px 0 0; +} +.quicktabs-style-commons-pills ul.quicktabs-tabs li a { + background-color: #f1f1f1; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + -ms-border-radius: 3px; + -o-border-radius: 3px; + border-radius: 3px; + padding: 3px 10px 3px 6px; + display: block; + color: #a5a3a3; +} +.quicktabs-style-commons-pills ul.quicktabs-tabs li a:hover { + text-decoration: none; +} +.quicktabs-style-commons-pills ul.quicktabs-tabs li a span { + color: #3f3d3d; + font-size: .7em; +} +.quicktabs-style-commons-pills ul.quicktabs-tabs li.active a { + background-color: #00568c; + color: #fff; + position: relative; +} +.quicktabs-style-commons-pills ul.quicktabs-tabs li.active a:after { + content: ''; + width: 0px; + height: 0px; + display: block; + border-style: solid; + border-width: 5px 7.5px 0 7.5px; + border-color: #00568c transparent transparent transparent; + position: absolute; + top: 100%; + left: 50%; + margin-left: -7.5px; +} +.quicktabs-style-commons-pills ul.quicktabs-tabs li.active a span { + color: #fff; +} + +#quicktabs-tab-commons_bw-commons_all:before { + content: ''; + background: url('images/icons-s2238b17da1.png') 0 -99px no-repeat; + width: 11px; + height: 11px; + display: inline-block; + margin-right: 3px; + position: relative; + top: 1px; +} +ul.quicktabs-style-commons-pills li.active #quicktabs-tab-commons_bw-commons_all:before { + background-position: 0 -163px; +} + +#quicktabs-tab-commons_bw-commons_posts:before { + content: ''; + background: url('images/icons-s2238b17da1.png') 0 -322px no-repeat; + width: 11px; + height: 11px; + display: inline-block; + margin-right: 3px; + position: relative; + top: 1px; +} +ul.quicktabs-style-commons-pills li.active #quicktabs-tab-commons_bw-commons_posts:before { + background-position: 0 -353px; +} + +#quicktabs-tab-commons_bw-commons_documents:before { + content: ''; + background: url('images/icons-s2238b17da1.png') 0 -384px no-repeat; + width: 9px; + height: 12px; + display: inline-block; + margin-right: 3px; + position: relative; + top: 1px; +} +ul.quicktabs-style-commons-pills li.active #quicktabs-tab-commons_bw-commons_documents:before { + background-position: 0 -416px; +} + +#quicktabs-tab-commons_bw-commons_q_a:before { + content: ''; + background: url('images/icons-s2238b17da1.png') 0 -66px no-repeat; + width: 13px; + height: 13px; + display: inline-block; + margin-right: 3px; + position: relative; + top: 1px; +} +ul.quicktabs-style-commons-pills li.active #quicktabs-tab-commons_bw-commons_q_a:before { + background-position: 0 -130px; +} + +#quicktabs-tab-commons_bw-commons_ideas:before { + content: ''; + background: url('images/icons-s2238b17da1.png') 0 -225px no-repeat; + width: 8px; + height: 13px; + display: inline-block; + margin-right: 3px; + position: relative; + top: 1px; +} +ul.quicktabs-style-commons-pills li.active #quicktabs-tab-commons_bw-commons_ideas:before { + background-position: 0 -289px; +} + +#quicktabs-tab-commons_bw-commons_wikis:before { + content: ''; + background: url('images/icons-s2238b17da1.png') 0 0 no-repeat; + width: 13px; + height: 13px; + display: inline-block; + margin-right: 3px; + position: relative; + top: 1px; +} +ul.quicktabs-style-commons-pills li.active #quicktabs-tab-commons_bw-commons_wikis:before { + background-position: 0 -33px; +} + +#quicktabs-tab-commons_bw-commons_polls:before { + content: ''; + background: url('images/icons-s2238b17da1.png') 0 -194px no-repeat; + width: 11px; + height: 11px; + display: inline-block; + margin-right: 3px; + position: relative; + top: 1px; +} +ul.quicktabs-style-commons-pills li.active #quicktabs-tab-commons_bw-commons_polls:before { + background-position: 0 -258px; +} diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/commons_pills.scss b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/commons_pills.scss new file mode 100644 index 0000000..b54b322 --- /dev/null +++ b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/commons_pills.scss @@ -0,0 +1,155 @@ +@import 'compass'; + +$icons: sprite-map('icons/*.png', $spacing: 20px); + +@mixin sprite_url_height_width($sprite_name, $image_name) { + background: sprite($sprite_name, $image_name) no-repeat; + width: image-width(sprite-file($sprite_name, $image_name)); + height: image-height(sprite-file($sprite_name, $image_name)); + display: inline-block; + margin-right: 3px; + position: relative; + top: 1px; +} + +@mixin sprite_url_position($sprite_name, $image_name) { + background-position: sprite-position($sprite_name, $image_name); +} + +$link_color: #a5a3a3; + +.quicktabs-style-commons-pills { + + ul.quicktabs-tabs { + margin: 0 0 30px 0; + padding: 0; + + .block-content & { + padding: 0; + } + + li { + display: inline-block; + padding: 0; + margin: 0 12px 0 0; + + a { + background-color: #f1f1f1; + @include border-radius(3px); + padding: 3px 10px 3px 6px; + display: block; + color: $link_color; + + &:hover { + text-decoration: none; + } + + span { + color: darken($link_color, 40%); + font-size: .7em; + } + } + + &.active a { + background-color: #00568c; + color: #fff; + position: relative; + + &:after { + content: ''; + width: 0px; + height: 0px; + display: block; + border-style: solid; + border-width: 5px 7.5px 0 7.5px; + border-color: #00568c transparent transparent transparent; + position: absolute; + top: 100%; + left: 50%; + margin-left: -7.5px; + } + + span { + color: #fff; + } + } + } + } +} + +#quicktabs-tab-commons_bw-commons_all { + &:before { + content: ''; + @include sprite_url_height_width($icons, all); + + ul.quicktabs-style-commons-pills li.active & { + @include sprite_url_position($icons, all-active); + } + } +} + +#quicktabs-tab-commons_bw-commons_posts { + &:before { + content: ''; + @include sprite_url_height_width($icons, posts); + + ul.quicktabs-style-commons-pills li.active & { + @include sprite_url_position($icons, posts-active); + } + } +} + +#quicktabs-tab-commons_bw-commons_documents { + &:before { + content: ''; + @include sprite_url_height_width($icons, docs); + + ul.quicktabs-style-commons-pills li.active & { + @include sprite_url_position($icons, docs-active); + } + } +} + +#quicktabs-tab-commons_bw-commons_q_a { + &:before { + content: ''; + @include sprite_url_height_width($icons, qa); + + ul.quicktabs-style-commons-pills li.active & { + @include sprite_url_position($icons, qa-active); + } + } +} + +#quicktabs-tab-commons_bw-commons_ideas { + &:before { + content: ''; + @include sprite_url_height_width($icons, ideas); + + ul.quicktabs-style-commons-pills li.active & { + @include sprite_url_position($icons, ideas-active); + } + } +} + +#quicktabs-tab-commons_bw-commons_wikis { + &:before { + content: ''; + @include sprite_url_height_width($icons, wikis); + + ul.quicktabs-style-commons-pills li.active & { + @include sprite_url_position($icons, wikis-active); + } + } +} + +#quicktabs-tab-commons_bw-commons_polls { + &:before { + content: ''; + @include sprite_url_height_width($icons, polls); + + ul.quicktabs-style-commons-pills li.active & { + @include sprite_url_position($icons, polls-active); + } + } +} diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/config.rb b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/config.rb new file mode 100644 index 0000000..78b78bf --- /dev/null +++ b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/config.rb @@ -0,0 +1,27 @@ +# Require any additional compass plugins here. + +# Set this to the root of your project when deployed: +http_path = "/" +css_dir = "/" +sass_dir = "/" +images_dir = "images" + +# output_style = :expanded or :nested or :compact or :compressed +output_style = :expanded +environment = :production + +relative_assets = true + +# To enable relative paths to assets via compass helper functions. Uncomment: +# relative_assets = true + +# To disable debugging comments that display the original location of your selectors. Uncomment: +# line_comments = false +color_output = false + + +# If you prefer the indented syntax, you might want to regenerate this +# project again passing --syntax sass, or you can uncomment this: +# preferred_syntax = :sass +# and then run: +# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons-s2238b17da1.png b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons-s2238b17da1.png new file mode 100644 index 0000000..68e7163 Binary files /dev/null and b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons-s2238b17da1.png differ diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/all-active.png b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/all-active.png new file mode 100644 index 0000000..da83e57 Binary files /dev/null and b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/all-active.png differ diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/all.png b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/all.png new file mode 100644 index 0000000..6d7fcae Binary files /dev/null and b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/all.png differ diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/docs-active.png b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/docs-active.png new file mode 100644 index 0000000..2dd6e5e Binary files /dev/null and b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/docs-active.png differ diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/docs.png b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/docs.png new file mode 100644 index 0000000..a93f71e Binary files /dev/null and b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/docs.png differ diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/ideas-active.png b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/ideas-active.png new file mode 100644 index 0000000..354b62b Binary files /dev/null and b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/ideas-active.png differ diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/ideas.png b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/ideas.png new file mode 100644 index 0000000..ab58f60 Binary files /dev/null and b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/ideas.png differ diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/polls-active.png b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/polls-active.png new file mode 100644 index 0000000..ac5b016 Binary files /dev/null and b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/polls-active.png differ diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/polls.png b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/polls.png new file mode 100644 index 0000000..da6c9ab Binary files /dev/null and b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/polls.png differ diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/posts-active.png b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/posts-active.png new file mode 100644 index 0000000..a9f6303 Binary files /dev/null and b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/posts-active.png differ diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/posts.png b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/posts.png new file mode 100644 index 0000000..92d02ee Binary files /dev/null and b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/posts.png differ diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/qa-active.png b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/qa-active.png new file mode 100644 index 0000000..b13d328 Binary files /dev/null and b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/qa-active.png differ diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/qa.png b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/qa.png new file mode 100644 index 0000000..33fc2b5 Binary files /dev/null and b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/qa.png differ diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/wikis-active.png b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/wikis-active.png new file mode 100644 index 0000000..a671665 Binary files /dev/null and b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/wikis-active.png differ diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/wikis.png b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/wikis.png new file mode 100644 index 0000000..1443adc Binary files /dev/null and b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_pills/images/icons/wikis.png differ diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_tabs/commons_tabs.css b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_tabs/commons_tabs.css new file mode 100644 index 0000000..93e8725 --- /dev/null +++ b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_tabs/commons_tabs.css @@ -0,0 +1,89 @@ +.quicktabs-style-commons-tabs ul.quicktabs-tabs { + margin: 0; + padding: 0; + position: relative; + top: 1px; +} +.block-content .quicktabs-style-commons-tabs ul.quicktabs-tabs { + padding: 0; +} +.quicktabs-style-commons-tabs ul.quicktabs-tabs li { + display: inline-block; + padding: 0; + margin: 0 5px 0 0; +} +.quicktabs-style-commons-tabs ul.quicktabs-tabs li a { + background-color: #dddddd; + border: 1px solid #dddddd; + -webkit-border-radius: 3px 3px 0 0; + -moz-border-radius: 3px 3px 0 0; + -ms-border-radius: 3px 3px 0 0; + -o-border-radius: 3px 3px 0 0; + border-radius: 3px 3px 0 0; + padding: 10px; + display: block; + font-size: 1.1em; + color: #2683b8; +} +.quicktabs-style-commons-tabs ul.quicktabs-tabs li a:hover { + text-decoration: none; +} +.quicktabs-style-commons-tabs ul.quicktabs-tabs li a span { + background: #dddddd; + font-size: 1.1em; + line-height: 1.1em; + color: #4d4d4d; + font-style: italic; + display: inline-block; + padding: 2px 6px; + border: 1px solid #c4c4c4; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + -ms-border-radius: 3px; + -o-border-radius: 3px; + border-radius: 3px; + margin-left: 2px; +} +.quicktabs-style-commons-tabs ul.quicktabs-tabs li.active a { + background-color: #f1f1f1; + color: #333333; + border-bottom-color: #f1f1f1; +} +.quicktabs-style-commons-tabs .quicktabs-tabpage { + border: 1px solid #dddddd; + background-color: #f1f1f1; + -webkit-border-radius: 0 3px 3px 3px; + -moz-border-radius: 0 3px 3px 3px; + -ms-border-radius: 0 3px 3px 3px; + -o-border-radius: 0 3px 3px 3px; + border-radius: 0 3px 3px 3px; + padding: 10px; +} +.quicktabs-style-commons-tabs table { + margin-top: 0; + border: none; +} +.quicktabs-style-commons-tabs td { + padding: 10px 7px; +} +.quicktabs-style-commons-tabs tbody tr { + border-top: none; +} +.quicktabs-style-commons-tabs tr { + background: none; +} +.quicktabs-style-commons-tabs tr.odd { + background: none; +} +.quicktabs-style-commons-tabs tr.even { + background: #ececec; +} +.quicktabs-style-commons-tabs tr.even, .quicktabs-style-commons-tabs tr.odd { + border-bottom: 1px dashed #dddddd; +} +.quicktabs-style-commons-tabs tr.even.views-row-last, .quicktabs-style-commons-tabs tr.odd.views-row-last { + border-bottom: none; +} +.quicktabs-style-commons-tabs tr.even td.active, .quicktabs-style-commons-tabs tr.odd td.active { + background: none; +} diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_tabs/commons_tabs.scss b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_tabs/commons_tabs.scss new file mode 100644 index 0000000..cf368b4 --- /dev/null +++ b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_tabs/commons_tabs.scss @@ -0,0 +1,108 @@ +@import 'compass'; + +$link_color: #2683B8; +$gray: #f1f1f1; +$gray_darker: #ececec; +$gray_darkest: #dddddd; +$black: #333333; + +.quicktabs-style-commons-tabs { + + ul.quicktabs-tabs { + margin: 0; + padding: 0; + position: relative; + top: 1px; + + .block-content & { + padding: 0; + } + + li { + display: inline-block; + padding: 0; + margin: 0 5px 0 0; + + a { + background-color: $gray_darkest; + border: 1px solid $gray_darkest; + @include border-radius(3px 3px 0 0); + padding: 10px; + display: block; + font-size: 1.1em; + color: $link_color; + + &:hover { + text-decoration: none; + } + + span { + background: $gray_darkest; + font-size: 1.1em; + line-height: 1.1em; + color: lighten($black, 10%); + font-style: italic; + display: inline-block; + padding: 2px 6px; + border: 1px solid darken($gray_darkest, 10%); + @include border-radius(3px); + margin-left: 2px; + } + } + + &.active a { + background-color: $gray; + color: $black; + border-bottom-color: $gray; + + span { + // color: #fff; + } + } + } + } + + .quicktabs-tabpage { + border: 1px solid $gray_darkest; + background-color: $gray; + @include border-radius(0 3px 3px 3px); + padding: 10px + } + + table { + margin-top: 0; + border: none; + } + + td { + padding: 10px 7px; + } + + tbody tr { + border-top: none; + } + + tr { + background: none; + + &.odd { + background: none; + } + + &.even { + background: $gray_darker; + } + + &.even, &.odd { + border-bottom: 1px dashed $gray_darkest; + + &.views-row-last { + border-bottom: none; + } + + & td.active { + background: none; + } + } + } +} diff --git a/modules/commons/commons_bw/plugins/quicktabs_styles/commons_tabs/config.rb b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_tabs/config.rb new file mode 100644 index 0000000..85c9626 --- /dev/null +++ b/modules/commons/commons_bw/plugins/quicktabs_styles/commons_tabs/config.rb @@ -0,0 +1,26 @@ +# Require any additional compass plugins here. + +# Set this to the root of your project when deployed: +http_path = "/" +css_dir = "/" +sass_dir = "/" + +# output_style = :expanded or :nested or :compact or :compressed +output_style = :expanded +environment = :production + +relative_assets = true + +# To enable relative paths to assets via compass helper functions. Uncomment: +# relative_assets = true + +# To disable debugging comments that display the original location of your selectors. Uncomment: +# line_comments = false +color_output = false + + +# If you prefer the indented syntax, you might want to regenerate this +# project again passing --syntax sass, or you can uncomment this: +# preferred_syntax = :sass +# and then run: +# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass diff --git a/modules/commons/commons_content_moderation/commons_content_moderation.features.inc b/modules/commons/commons_content_moderation/commons_content_moderation.features.inc new file mode 100644 index 0000000..3a75218 --- /dev/null +++ b/modules/commons/commons_content_moderation/commons_content_moderation.features.inc @@ -0,0 +1,115 @@ + "1"); + } +} + +/** + * Implements hook_views_api(). + */ +function commons_content_moderation_views_api($module = NULL, $api = NULL) { + return array("api" => "3.0"); +} + +/** + * Implements hook_flag_default_flags(). + */ +function commons_content_moderation_flag_default_flags() { + $flags = array(); + // Exported flag: "Comment inappropriate". + $flags['inappropriate_comment'] = array( + 'content_type' => 'comment', + 'title' => 'Comment inappropriate', + 'global' => 0, + 'types' => array( + 0 => 'comment_node_answer', + 1 => 'comment_node_event', + 2 => 'comment_node_group', + 3 => 'comment_node_page', + 4 => 'comment_node_post', + 5 => 'comment_node_question', + 6 => 'comment_node_wiki', + ), + 'flag_short' => 'Report as inappropriate', + 'flag_long' => 'Report this comment as inappropriate.', + 'flag_message' => '', + 'unflag_short' => 'Cancel report as inappropriate', + 'unflag_long' => 'Cancel reporting as inappropriate.', + 'unflag_message' => '', + 'unflag_denied_text' => '', + 'link_type' => 'confirm', + 'roles' => array( + 'flag' => array( + 0 => 2, + ), + 'unflag' => array( + 0 => 2, + ), + ), + 'weight' => 0, + 'show_on_form' => 0, + 'access_author' => 'comment_others', + 'show_on_comment' => 1, + 'flag_confirmation' => 'Are you sure you want to report this comment as inappropriate?', + 'unflag_confirmation' => 'Are you sure you want to cancel reporting this comment as inappropriate?', + 'module' => 'commons_content_moderation', + 'locked' => array( + 0 => 'name', + ), + 'api_version' => 2, + ); + // Exported flag: "Node inappropriate". + $flags['inappropriate_node'] = array( + 'content_type' => 'node', + 'title' => 'Node inappropriate', + 'global' => 0, + 'types' => array( + 0 => 'event', + 1 => 'group', + 2 => 'page', + 3 => 'post', + 4 => 'wiki', + ), + 'flag_short' => 'Report as inappropriate', + 'flag_long' => 'Report this content as inappropriate.', + 'flag_message' => '', + 'unflag_short' => 'Cancel report as inappropriate', + 'unflag_long' => 'Report this content as appropriate', + 'unflag_message' => '', + 'unflag_denied_text' => '', + 'link_type' => 'confirm', + 'roles' => array( + 'flag' => array( + 0 => 2, + ), + 'unflag' => array( + 0 => 2, + ), + ), + 'weight' => 0, + 'show_on_form' => 0, + 'access_author' => '', + 'show_on_page' => 1, + 'show_on_teaser' => 0, + 'show_contextual_link' => FALSE, + 'i18n' => 0, + 'flag_confirmation' => 'Are you sure you want to report this content as inappropriate?', + 'unflag_confirmation' => 'Are you sure you want cancel reporting this content as inappropriate?', + 'module' => 'commons_content_moderation', + 'locked' => array( + 0 => 'name', + ), + 'api_version' => 2, + ); + return $flags; + +} diff --git a/modules/commons/commons_content_moderation/commons_content_moderation.features.user_role.inc b/modules/commons/commons_content_moderation/commons_content_moderation.features.user_role.inc new file mode 100644 index 0000000..b1bff9e --- /dev/null +++ b/modules/commons/commons_content_moderation/commons_content_moderation.features.user_role.inc @@ -0,0 +1,20 @@ + 'content moderator', + 'weight' => 2, + ); + + return $roles; +} diff --git a/modules/commons/commons_content_moderation/commons_content_moderation.info b/modules/commons/commons_content_moderation/commons_content_moderation.info new file mode 100644 index 0000000..3dd7cef --- /dev/null +++ b/modules/commons/commons_content_moderation/commons_content_moderation.info @@ -0,0 +1,19 @@ +name = Commons Content moderation +description = Commons Content moderation +core = 7.x +package = Commons - Building Blocks +dependencies[] = ctools +dependencies[] = flag +dependencies[] = flag_abuse +dependencies[] = strongarm +dependencies[] = views +features[ctools][] = strongarm:strongarm:1 +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[flag][] = inappropriate_comment +features[flag][] = inappropriate_node +features[user_role][] = content moderator +features[variable][] = flag_abuse_flags +features[views_view][] = commons_content_moderation_reported_comments +features[views_view][] = commons_content_moderation_reported_nodes +features_exclude[dependencies][features] = features diff --git a/modules/commons/commons_content_moderation/commons_content_moderation.install b/modules/commons/commons_content_moderation/commons_content_moderation.install new file mode 100644 index 0000000..8076a95 --- /dev/null +++ b/modules/commons/commons_content_moderation/commons_content_moderation.install @@ -0,0 +1,19 @@ + array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Clear views cache to have content moderation view use new permission. + */ +function commons_content_moderation_update_7002() { + cache_clear_all('*', 'cache_views', TRUE); +} diff --git a/modules/commons/commons_content_moderation/commons_content_moderation.module b/modules/commons/commons_content_moderation/commons_content_moderation.module new file mode 100644 index 0000000..7078cb2 --- /dev/null +++ b/modules/commons/commons_content_moderation/commons_content_moderation.module @@ -0,0 +1,139 @@ + array( + 'type' => 'node', + 'label' => t("Delete content and block author's account."), + 'configurable' => FALSE, + 'behavior' => array(''), + 'triggers' => array(''), + ), + 'commons_content_moderation_delete_comment_block_user' => array( + 'type' => 'comment', + 'label' => t("Delete comment and block author's account."), + 'configurable' => FALSE, + 'behavior' => array(''), + 'triggers' => array(''), + ), + ); +} + +/** + * Delete content and block the content author. + * + * @param $node + * A node object. + * @param $context + * (optional) Array of additional information about what triggered the action. + * Not used for this action. + * + * @ingroup actions + */ +function commons_content_moderation_delete_node_block_user($node, $context = array()) { + // Don't block anonymous users or user 1. + if ($node->uid > 1) { + $author = user_load($node->uid); + + // Block the user if they aren't already. + if ($author->status) { + $author = user_save($author, array('status' => 0)); + watchdog('commons_content_moderation', 'Blocked user %name.', array('%name' => format_username($author))); + } + } + + // Report the content to Mollom when possible. + if (module_exists('mollom') && _mollom_flag_access('node', $node)) { + mollom_data_report('node', $node->nid, 'spam'); + } + + // Delete the node. + node_delete($node->nid); + watchdog('commons_content_moderation', 'Deleted @type %title.', array('@type' => node_type_get_name($node), '%title' => $node->title)); +} + +/** + * Delete comment and block the comment author. + * + * @param $comment + * A comment object. + * @param $context + * (optional) Array of additional information about what triggered the action. + * Not used for this action. + * + * @ingroup actions + */ +function commons_content_moderation_delete_comment_block_user($comment, $context = array()) { + // Don't block anonymous users or user 1. + if ($comment->uid > 1) { + $author = user_load($comment->uid); + + // Block the user if they aren't already. + if ($author->status) { + $author = user_save($author, array('status' => 0)); + watchdog('commons_content_moderation', 'Blocked user %name.', array('%name' => format_username($author))); + } + } + + // Report the content to Mollom when possible. + if (module_exists('mollom') && _mollom_flag_access('comment', $comment)) { + mollom_data_report('comment', $comment->cid, 'spam'); + } + + // Delete the comment. + comment_delete($comment->cid); + watchdog('commons_content_moderation', 'Deleted comment %title.', array('%title' => $comment->title)); +} + +/** + * Implements hook_views_default_views_alter(). + */ +function commons_content_moderation_views_default_views_alter(&$views) { + // Disable default node and comment abuse views in favor of Commons-specific + // views included with Commons Content Moderation. + foreach (array('all_flag_abuse_node', 'all_flag_abuse_comment') as $view_name) { + if (!empty($views[$view_name])) { + $views[$view_name]->disabled = TRUE; + } + } +} + +/** + * Implements hook_views_pre_build(). + */ +function commons_content_moderation_views_pre_build(&$view) { + // Disable bulk content moderation operations if the user does not have + // appropriate access. + if ($view->name == 'commons_content_moderation_reported_nodes' && !module_exists('actions_permissions') && (!user_access('administer content') || !user_access('administer users'))) { + unset($view->field['views_bulk_operations']); + unset($view->display_handler->handlers['field']['views_bulk_operations']); + } +} + +/** + * Implements hook_views_bulk_operations_form_alter(). + */ +function commons_content_moderation_views_bulk_operations_form_alter(&$form, $form_state, $vbo) { + // Only proceed if the 'delete_node_block_user' operation is available. + if (!isset($vbo->options['vbo_operations']['action::commons_content_moderation_delete_node_block_user'])) { + return; + } + + // Notify the user that the deleted content will be reported to Mollom. + if ($form_state['step'] == 'views_form_views_form' && $vbo->options['vbo_operations']['action::commons_content_moderation_delete_node_block_user']['selected'] == 1) { + if (module_exists('mollom') && _mollom_access('report to mollom')) { + $form['mollom_text'] = array( + '#markup' => '

' . t('Deleted content will be reported to Mollom.') . '

', + ); + } + } +} diff --git a/modules/commons/commons_content_moderation/commons_content_moderation.strongarm.inc b/modules/commons/commons_content_moderation/commons_content_moderation.strongarm.inc new file mode 100644 index 0000000..31bccba --- /dev/null +++ b/modules/commons/commons_content_moderation/commons_content_moderation.strongarm.inc @@ -0,0 +1,30 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'flag_abuse_flags'; + $strongarm->value = array( + 'inappropriate_node' => 'inappropriate_node', + 'inappropriate_comment' => 'inappropriate_comment', + 'commons_follow_user' => 0, + 'commons_follow_term' => 0, + 'commons_follow_group' => 0, + 'commons_follow_node' => 0, + 'bookmarks' => 0, + 'abuse_user' => 0, + ); + $export['flag_abuse_flags'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_content_moderation/commons_content_moderation.views_default.inc b/modules/commons/commons_content_moderation/commons_content_moderation.views_default.inc new file mode 100644 index 0000000..50f6eee --- /dev/null +++ b/modules/commons/commons_content_moderation/commons_content_moderation.views_default.inc @@ -0,0 +1,632 @@ +name = 'commons_content_moderation_reported_comments'; + $view->description = 'View for flag: Comment Abuse '; + $view->tag = 'flag.abuse'; + $view->base_table = 'comment'; + $view->human_name = 'Commons reported comments'; + $view->core = 0; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Defaults */ + $handler = $view->new_display('default', 'Defaults', 'default'); + $handler->display->display_options['title'] = 'Comments'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['access']['perm'] = 'administer nodes'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['pager']['options']['items_per_page'] = 25; + $handler->display->display_options['style_plugin'] = 'table'; + $handler->display->display_options['style_options']['columns'] = array( + 'subject' => 'subject', + 'title' => 'title', + 'count' => 'count', + 'last_updated' => 'last_updated', + 'name_2' => 'name_2', + 'entity_id' => 'entity_id', + ); + $handler->display->display_options['style_options']['default'] = '-1'; + $handler->display->display_options['style_options']['info'] = array( + 'subject' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'title' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'count' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'last_updated' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'name_2' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'entity_id' => array( + 'sortable' => 0, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + ); + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['text']['id'] = 'text'; + $handler->display->display_options['empty']['text']['table'] = 'views'; + $handler->display->display_options['empty']['text']['field'] = 'area'; + $handler->display->display_options['empty']['text']['content'] = 'No comments have been reported...'; + $handler->display->display_options['empty']['text']['format'] = 'plain_text'; + /* Relationship: Flags: inappropriate_comment */ + $handler->display->display_options['relationships']['flag_content_rel']['id'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel']['table'] = 'comment'; + $handler->display->display_options['relationships']['flag_content_rel']['field'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel']['flag'] = 'inappropriate_comment'; + $handler->display->display_options['relationships']['flag_content_rel']['user_scope'] = 'any'; + /* Relationship: Comment: Content */ + $handler->display->display_options['relationships']['nid']['id'] = 'nid'; + $handler->display->display_options['relationships']['nid']['table'] = 'comment'; + $handler->display->display_options['relationships']['nid']['field'] = 'nid'; + $handler->display->display_options['relationships']['nid']['required'] = TRUE; + /* Relationship: Flags: inappropriate_comment counter */ + $handler->display->display_options['relationships']['flag_count_rel']['id'] = 'flag_count_rel'; + $handler->display->display_options['relationships']['flag_count_rel']['table'] = 'comment'; + $handler->display->display_options['relationships']['flag_count_rel']['field'] = 'flag_count_rel'; + $handler->display->display_options['relationships']['flag_count_rel']['flag'] = 'inappropriate_comment'; + /* Field: Bulk operations: Comment */ + $handler->display->display_options['fields']['views_bulk_operations']['id'] = 'views_bulk_operations'; + $handler->display->display_options['fields']['views_bulk_operations']['table'] = 'comment'; + $handler->display->display_options['fields']['views_bulk_operations']['field'] = 'views_bulk_operations'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['display_type'] = '1'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['enable_select_all_pages'] = 1; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['force_single'] = 0; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '10'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_operations'] = array( + 'action::commons_content_moderation_delete_comment_block_user' => array( + 'selected' => 1, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::views_bulk_operations_delete_item' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::system_message_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::views_bulk_operations_script_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::flag_comment_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::views_bulk_operations_modify_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'settings' => array( + 'show_all_tokens' => 1, + 'display_values' => array( + '_all_' => '_all_', + ), + ), + 'postpone_processing' => 0, + ), + 'action::views_bulk_operations_argument_selector_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'settings' => array( + 'url' => '', + ), + ), + 'action::comment_publish_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::system_goto_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::comment_save_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::system_send_email_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::panelizer_set_status_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::comment_unpublish_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::comment_unpublish_by_keyword_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + ); + /* Field: Comment: Title */ + $handler->display->display_options['fields']['subject']['id'] = 'subject'; + $handler->display->display_options['fields']['subject']['table'] = 'comment'; + $handler->display->display_options['fields']['subject']['field'] = 'subject'; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['relationship'] = 'nid'; + $handler->display->display_options['fields']['title']['label'] = 'Comment on'; + /* Field: Comment: Author */ + $handler->display->display_options['fields']['name_2']['id'] = 'name_2'; + $handler->display->display_options['fields']['name_2']['table'] = 'comment'; + $handler->display->display_options['fields']['name_2']['field'] = 'name'; + $handler->display->display_options['fields']['name_2']['label'] = 'Comment Author'; + /* Field: Comment: Comment */ + $handler->display->display_options['fields']['entity_id']['id'] = 'entity_id'; + $handler->display->display_options['fields']['entity_id']['table'] = 'field_data_comment_body'; + $handler->display->display_options['fields']['entity_id']['field'] = 'comment_body'; + /* Sort criterion: Flags: Flagged time */ + $handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp'; + $handler->display->display_options['sorts']['timestamp']['table'] = 'flag_content'; + $handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp'; + $handler->display->display_options['sorts']['timestamp']['relationship'] = 'flag_content_rel'; + /* Filter criterion: Comment: Approved */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'comment'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = '1'; + + /* Display: Page: Reported comments */ + $handler = $view->new_display('page', 'Page: Reported comments', 'page_abuse_comment'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['path'] = 'admin/content/comment/reported'; + $handler->display->display_options['menu']['type'] = 'tab'; + $handler->display->display_options['menu']['title'] = 'Reported comments'; + $handler->display->display_options['menu']['weight'] = '0'; + $handler->display->display_options['menu']['context'] = 0; + $handler->display->display_options['tab_options']['type'] = 'tab'; + $handler->display->display_options['tab_options']['title'] = 'Reported comments'; + $handler->display->display_options['tab_options']['weight'] = '10'; + $translatables['commons_content_moderation_reported_comments'] = array( + t('Defaults'), + t('Comments'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('No comments have been reported...'), + t('flag'), + t('Content'), + t('counter'), + t('Comment'), + t('Title'), + t('Comment on'), + t('Comment Author'), + t('Page: Reported comments'), + ); + $export['commons_content_moderation_reported_comments'] = $view; + + $view = new view(); + $view->name = 'commons_content_moderation_reported_nodes'; + $view->description = 'View for flag: Node Abuse'; + $view->tag = 'flag.abuse'; + $view->base_table = 'node'; + $view->human_name = 'Commons reported nodes'; + $view->core = 0; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Defaults */ + $handler = $view->new_display('default', 'Defaults', 'default'); + $handler->display->display_options['title'] = 'Reported content'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['access']['perm'] = 'administer nodes'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['query']['options']['distinct'] = TRUE; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'none'; + $handler->display->display_options['style_plugin'] = 'table'; + $handler->display->display_options['style_options']['columns'] = array( + 'views_bulk_operations' => 'views_bulk_operations', + 'type' => 'type', + 'title' => 'title', + 'count' => 'count', + 'last_updated' => 'last_updated', + 'name' => 'name', + 'body' => 'body', + ); + $handler->display->display_options['style_options']['default'] = 'last_updated'; + $handler->display->display_options['style_options']['info'] = array( + 'views_bulk_operations' => array( + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'type' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'title' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'count' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'last_updated' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'name' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'body' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + ); + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['text']['id'] = 'area'; + $handler->display->display_options['empty']['text']['table'] = 'views'; + $handler->display->display_options['empty']['text']['field'] = 'area'; + $handler->display->display_options['empty']['text']['content'] = 'No content has been reported.'; + $handler->display->display_options['empty']['text']['format'] = '1'; + /* Relationship: Flags: inappropriate_node */ + $handler->display->display_options['relationships']['flag_content_rel']['id'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel']['table'] = 'node'; + $handler->display->display_options['relationships']['flag_content_rel']['field'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel']['label'] = 'abuse_node'; + $handler->display->display_options['relationships']['flag_content_rel']['flag'] = 'inappropriate_node'; + $handler->display->display_options['relationships']['flag_content_rel']['user_scope'] = 'any'; + /* Relationship: Content: Author */ + $handler->display->display_options['relationships']['uid']['id'] = 'uid'; + $handler->display->display_options['relationships']['uid']['table'] = 'node'; + $handler->display->display_options['relationships']['uid']['field'] = 'uid'; + $handler->display->display_options['relationships']['uid']['required'] = TRUE; + /* Relationship: Flags: inappropriate_node counter */ + $handler->display->display_options['relationships']['flag_count_rel']['id'] = 'flag_count_rel'; + $handler->display->display_options['relationships']['flag_count_rel']['table'] = 'node'; + $handler->display->display_options['relationships']['flag_count_rel']['field'] = 'flag_count_rel'; + $handler->display->display_options['relationships']['flag_count_rel']['flag'] = 'inappropriate_node'; + /* Field: Bulk operations: Content */ + $handler->display->display_options['fields']['views_bulk_operations']['id'] = 'views_bulk_operations'; + $handler->display->display_options['fields']['views_bulk_operations']['table'] = 'node'; + $handler->display->display_options['fields']['views_bulk_operations']['field'] = 'views_bulk_operations'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['display_type'] = '1'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['enable_select_all_pages'] = 1; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['force_single'] = 0; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '10'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_operations'] = array( + 'action::node_assign_owner_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::commons_content_moderation_delete_node_block_user' => array( + 'selected' => 1, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::views_bulk_operations_delete_item' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::system_message_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::views_bulk_operations_script_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::flag_node_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::node_make_sticky_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::node_make_unsticky_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::views_bulk_operations_modify_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'settings' => array( + 'show_all_tokens' => 1, + 'display_values' => array( + '_all_' => '_all_', + ), + ), + 'postpone_processing' => 0, + ), + 'action::views_bulk_operations_argument_selector_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'settings' => array( + 'url' => '', + ), + ), + 'action::node_promote_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::node_publish_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::system_goto_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::node_unpromote_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::node_save_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::system_send_email_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::panelizer_set_status_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::node_unpublish_action' => array( + 'selected' => 1, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + 'action::node_unpublish_by_keyword_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'postpone_processing' => 0, + ), + ); + /* Field: Content: Type */ + $handler->display->display_options['fields']['type']['id'] = 'type'; + $handler->display->display_options['fields']['type']['table'] = 'node'; + $handler->display->display_options['fields']['type']['field'] = 'type'; + $handler->display->display_options['fields']['type']['exclude'] = TRUE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + /* Field: Flags: Flag counter */ + $handler->display->display_options['fields']['count']['id'] = 'count'; + $handler->display->display_options['fields']['count']['table'] = 'flag_counts'; + $handler->display->display_options['fields']['count']['field'] = 'count'; + $handler->display->display_options['fields']['count']['relationship'] = 'flag_count_rel'; + $handler->display->display_options['fields']['count']['label'] = '# of Reports'; + /* Field: Flags: Time last flagged */ + $handler->display->display_options['fields']['last_updated']['id'] = 'last_updated'; + $handler->display->display_options['fields']['last_updated']['table'] = 'flag_counts'; + $handler->display->display_options['fields']['last_updated']['field'] = 'last_updated'; + $handler->display->display_options['fields']['last_updated']['relationship'] = 'flag_count_rel'; + $handler->display->display_options['fields']['last_updated']['label'] = 'Last reported'; + $handler->display->display_options['fields']['last_updated']['date_format'] = 'time ago'; + /* Field: User: Name */ + $handler->display->display_options['fields']['name']['id'] = 'name'; + $handler->display->display_options['fields']['name']['table'] = 'users'; + $handler->display->display_options['fields']['name']['field'] = 'name'; + $handler->display->display_options['fields']['name']['relationship'] = 'uid'; + $handler->display->display_options['fields']['name']['label'] = 'Author'; + /* Field: Content: Body */ + $handler->display->display_options['fields']['body']['id'] = 'body'; + $handler->display->display_options['fields']['body']['table'] = 'field_data_body'; + $handler->display->display_options['fields']['body']['field'] = 'body'; + $handler->display->display_options['fields']['body']['type'] = 'text_summary_or_trimmed'; + $handler->display->display_options['fields']['body']['settings'] = array( + 'trim_length' => '600', + ); + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = '0'; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + + /* Display: Page */ + $handler = $view->new_display('page', 'Page', 'page_1'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['path'] = 'admin/content/reported'; + $handler->display->display_options['menu']['type'] = 'tab'; + $handler->display->display_options['menu']['title'] = 'Reported content'; + $handler->display->display_options['menu']['weight'] = '0'; + $handler->display->display_options['menu']['name'] = 'management'; + $handler->display->display_options['menu']['context'] = 0; + $handler->display->display_options['tab_options']['title'] = 'Reported content'; + $handler->display->display_options['tab_options']['weight'] = ''; + $translatables['commons_content_moderation_reported_nodes'] = array( + t('Defaults'), + t('Reported content'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('No content has been reported.'), + t('abuse_node'), + t('author'), + t('counter'), + t('Content'), + t('Type'), + t('Title'), + t('# of Reports'), + t('.'), + t(','), + t('Last reported'), + t('Author'), + t('Body'), + t('Page'), + ); + $export['commons_content_moderation_reported_nodes'] = $view; + + return $export; +} diff --git a/modules/commons/commons_documents/commons_documents.features.field_base.inc b/modules/commons/commons_documents/commons_documents.features.field_base.inc new file mode 100644 index 0000000..0621f77 --- /dev/null +++ b/modules/commons/commons_documents/commons_documents.features.field_base.inc @@ -0,0 +1,45 @@ + 1, + 'cardinality' => -1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_document_file', + 'foreign keys' => array( + 'fid' => array( + 'columns' => array( + 'fid' => 'fid', + ), + 'table' => 'file_managed', + ), + ), + 'indexes' => array( + 'fid' => array( + 0 => 'fid', + ), + ), + 'locked' => 0, + 'module' => 'file', + 'settings' => array( + 'display_default' => 1, + 'display_field' => 0, + 'uri_scheme' => 'public', + ), + 'translatable' => 0, + 'type' => 'file', + ); + + return $field_bases; +} diff --git a/modules/commons/commons_documents/commons_documents.features.field_instance.inc b/modules/commons/commons_documents/commons_documents.features.field_instance.inc new file mode 100644 index 0000000..008013d --- /dev/null +++ b/modules/commons/commons_documents/commons_documents.features.field_instance.inc @@ -0,0 +1,107 @@ + 'document', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 2, + ), + 'teaser' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array( + 'trim_length' => 600, + ), + 'type' => 'text_summary_or_trimmed', + 'weight' => 1, + ), + ), + 'display_in_partial_form' => 1, + 'entity_type' => 'node', + 'field_name' => 'body', + 'label' => 'Body', + 'required' => FALSE, + 'settings' => array( + 'display_summary' => FALSE, + 'text_processing' => 1, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'module' => 'text', + 'settings' => array( + 'rows' => 20, + 'summary_rows' => 5, + ), + 'type' => 'text_textarea_with_summary', + 'weight' => 1, + ), + ); + + // Exported field_instance: 'node-document-field_document_file' + $field_instances['node-document-field_document_file'] = array( + 'bundle' => 'document', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'file', + 'settings' => array(), + 'type' => 'file_default', + 'weight' => 4, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'display_in_partial_form' => 1, + 'entity_type' => 'node', + 'field_name' => 'field_document_file', + 'label' => 'File', + 'required' => 1, + 'settings' => array( + 'description_field' => 1, + 'file_directory' => '', + 'file_extensions' => 'txt doc docx xls xlsx ppt pptx odt odp ods pdf', + 'max_filesize' => '', + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'file', + 'settings' => array( + 'progress_indicator' => 'throbber', + ), + 'type' => 'file_generic', + 'weight' => 2, + ), + ); + + // Translatables + // Included for use with string extractors like potx. + t('Body'); + t('File'); + + return $field_instances; +} diff --git a/modules/commons/commons_documents/commons_documents.features.inc b/modules/commons/commons_documents/commons_documents.features.inc new file mode 100644 index 0000000..68c0736 --- /dev/null +++ b/modules/commons/commons_documents/commons_documents.features.inc @@ -0,0 +1,38 @@ + "1"); + } +} + +/** + * Implements hook_views_api(). + */ +function commons_documents_views_api($module = NULL, $api = NULL) { + return array("api" => "3.0"); +} + +/** + * Implements hook_node_info(). + */ +function commons_documents_node_info() { + $items = array( + 'document' => array( + 'name' => t('Document'), + 'base' => 'node_content', + 'description' => t('Upload and display files or attachments to share with others.'), + 'has_title' => '1', + 'title_label' => t('Title'), + 'help' => '', + ), + ); + return $items; +} diff --git a/modules/commons/commons_documents/commons_documents.features.og_features_permission.inc b/modules/commons/commons_documents/commons_documents.features.og_features_permission.inc new file mode 100644 index 0000000..ab5b04c --- /dev/null +++ b/modules/commons/commons_documents/commons_documents.features.og_features_permission.inc @@ -0,0 +1,52 @@ + array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + // Exported og permission: 'node:group:delete any document content' + $permissions['node:group:delete any document content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + ), + ); + + // Exported og permission: 'node:group:delete own document content' + $permissions['node:group:delete own document content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + // Exported og permission: 'node:group:update any document content' + $permissions['node:group:update any document content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + ), + ); + + // Exported og permission: 'node:group:update own document content' + $permissions['node:group:update own document content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + return $permissions; +} diff --git a/modules/commons/commons_documents/commons_documents.features.user_permission.inc b/modules/commons/commons_documents/commons_documents.features.user_permission.inc new file mode 100644 index 0000000..f048d79 --- /dev/null +++ b/modules/commons/commons_documents/commons_documents.features.user_permission.inc @@ -0,0 +1,62 @@ + 'create document content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + // Exported permission: 'delete any document content'. + $permissions['delete any document content'] = array( + 'name' => 'delete any document content', + 'roles' => array( + 'administrator' => 'administrator', + ), + 'module' => 'node', + ); + + // Exported permission: 'delete own document content'. + $permissions['delete own document content'] = array( + 'name' => 'delete own document content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + // Exported permission: 'edit any document content'. + $permissions['edit any document content'] = array( + 'name' => 'edit any document content', + 'roles' => array( + 'administrator' => 'administrator', + ), + 'module' => 'node', + ); + + // Exported permission: 'edit own document content'. + $permissions['edit own document content'] = array( + 'name' => 'edit own document content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + return $permissions; +} diff --git a/modules/commons/commons_documents/commons_documents.info b/modules/commons/commons_documents/commons_documents.info new file mode 100644 index 0000000..4ab55b1 --- /dev/null +++ b/modules/commons/commons_documents/commons_documents.info @@ -0,0 +1,46 @@ +name = Commons Documents +core = 7.x +package = Commons - Content types +dependencies[] = commons_body +dependencies[] = commons_groups +dependencies[] = commons_topics +dependencies[] = ctools +dependencies[] = entityreference +dependencies[] = features +dependencies[] = file +dependencies[] = og +dependencies[] = og_ui +dependencies[] = strongarm +dependencies[] = views +dependencies[] = views_litepager +features[ctools][] = strongarm:strongarm:1 +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[field_base][] = field_document_file +features[field_instance][] = node-document-body +features[field_instance][] = node-document-field_document_file +features[node][] = document +features[og_features_permission][] = node:group:create document content +features[og_features_permission][] = node:group:delete any document content +features[og_features_permission][] = node:group:delete own document content +features[og_features_permission][] = node:group:update any document content +features[og_features_permission][] = node:group:update own document content +features[user_permission][] = create document content +features[user_permission][] = delete any document content +features[user_permission][] = delete own document content +features[user_permission][] = edit any document content +features[user_permission][] = edit own document content +features[variable][] = comment_anonymous_document +features[variable][] = comment_default_mode_document +features[variable][] = comment_default_per_page_document +features[variable][] = comment_document +features[variable][] = comment_form_location_document +features[variable][] = comment_preview_document +features[variable][] = comment_subject_field_document +features[variable][] = field_bundle_settings_node__document +features[variable][] = menu_options_document +features[variable][] = menu_parent_document +features[variable][] = node_options_document +features[variable][] = node_preview_document +features[variable][] = node_submitted_document +features[views_view][] = commons_bw_documents diff --git a/modules/commons/commons_documents/commons_documents.install b/modules/commons/commons_documents/commons_documents.install new file mode 100644 index 0000000..63b7865 --- /dev/null +++ b/modules/commons/commons_documents/commons_documents.install @@ -0,0 +1,89 @@ + array('field_instance'), + ); + features_revert($revert); + return array(); +} + +/** + * Disable default frontpage promotion of Document nodes. + */ +function commons_documents_update_7001() { + $revert = array( + 'commons_documents' => array('variable'), + ); + features_revert($revert); + return array(); +} + +/** + * Remove unused view displays. + */ +function commons_documents_update_7002() { + $revert = array( + 'commons_documents' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Standardize Browsing Widget views. + */ +function commons_documents_update_7003() { + $revert = array( + 'commons_documents' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Display sticky content at top of lists. + */ +function commons_documents_update_7004() { + $revert = array( + 'commons_documents' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Add .txt to the list of allowed file extensions. + */ +function commons_documents_update_7005() { + $revert = array( + 'commons_documents' => array('field_instance'), + ); + features_revert($revert); + return array(); +} + +/** + * Add links to node teasers in the browsing widget. + */ +function commons_documents_update_7006() { + $revert = array( + 'commons_documents' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Improve the browsing widget empty text. + */ +function commons_documents_update_7007() { + $revert = array( + 'commons_documents' => array('views_view'), + ); + features_revert($revert); + return array(); +} diff --git a/modules/commons/commons_documents/commons_documents.module b/modules/commons/commons_documents/commons_documents.module new file mode 100644 index 0000000..5d73e4b --- /dev/null +++ b/modules/commons/commons_documents/commons_documents.module @@ -0,0 +1,97 @@ + array( + 'document' => array( + 'is_group_content' => TRUE, + ), + ), + ); +} + +/** + * Implements hook_commons_bw_group_widget(). + */ +function commons_documents_commons_bw_group_widget() { + return array( + 'commons_documents' => array( + 'title' => t('Docs'), + 'type' => 'view', + 'vid' => 'commons_bw_documents', + 'display' => 'default', + 'weight' => 6, + 'bundle' => 'document', + ), + ); +} + +/** + * Implements hook_form_FROM_ID_alter(). + */ +function commons_documents_form_commons_bw_partial_node_form_alter(&$form, &$form_state) { + if (empty($form['#entity']) || $form['#entity']->type != 'document') { + return; + } + + $language = $form['body']['#language']; + $form['body'][$language][0]['#title_display'] = 'invisible'; + $form['body'][$language][0]['#required'] = TRUE; + $form['body'][$language][0]['#placeholder'] = t('Describe the document'); + $form['body'][$language][0]['#resizable'] = FALSE; + + // Set fields as hideable so the forms can be compacted. + $form['body']['#attributes']['class'][] = 'trigger-field'; + foreach (array('field_image', 'og_group_ref', 'field_document_file', 'actions') as $field) { + if (isset($form[$field])) { + $form[$field]['#attributes']['class'][] = 'hideable-field'; + } + } + + $form['#pre_render'][] = 'commons_documents_form_commons_bw_partial_node_form_after_build'; +} + +/** + * After-build call-back. + * See commons_documents_form_commons_bw_partial_node_form_alter(). + */ +function commons_documents_form_commons_bw_partial_node_form_after_build($form) { + $language = $form['body']['#language']; + $form['body'][$language][0]['#pre_render'] = array(); + $form['body'][$language][0]['format']['#access'] = FALSE; + $form['body'][$language][0]['value']['#rows'] = 3; + + return $form; +} + +/** + * Implements hook_views_default_views_alter(). + * + * Display documents on the browsing widget main view. + */ +function commons_documents_views_default_views_alter(&$views) { + if (!empty($views['commons_bw_all'])) { + $views['commons_bw_all']->display['default']->display_options['filters']['type']['value']['document'] = 'document'; + } +} + +/** + * Implements hook_views_pre_render(). + */ +function commons_documents_views_pre_render(&$view) { + // Improve the browsing widget empty text when displayed outside of a group. + // TODO: Enable og_context and check group context instead of looking for an + // empty first argument. + if (empty($view->args[0]) && $view->name == 'commons_bw_documents') { + $view->display_handler->handlers['empty']['area']->options['content'] = t('No documents have been created.'); + } +} diff --git a/modules/commons/commons_documents/commons_documents.strongarm.inc b/modules/commons/commons_documents/commons_documents.strongarm.inc new file mode 100644 index 0000000..bee3f8b --- /dev/null +++ b/modules/commons/commons_documents/commons_documents.strongarm.inc @@ -0,0 +1,119 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_anonymous_document'; + $strongarm->value = 0; + $export['comment_anonymous_document'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_mode_document'; + $strongarm->value = 1; + $export['comment_default_mode_document'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_per_page_document'; + $strongarm->value = '50'; + $export['comment_default_per_page_document'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_document'; + $strongarm->value = '2'; + $export['comment_document'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_form_location_document'; + $strongarm->value = 1; + $export['comment_form_location_document'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_preview_document'; + $strongarm->value = '1'; + $export['comment_preview_document'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_subject_field_document'; + $strongarm->value = 1; + $export['comment_subject_field_document'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_node__document'; + $strongarm->value = array( + 'view_modes' => array(), + 'extra_fields' => array( + 'form' => array( + 'title' => array( + 'weight' => '0', + ), + ), + 'display' => array(), + ), + ); + $export['field_bundle_settings_node__document'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_options_document'; + $strongarm->value = array( + 0 => 'main-menu', + ); + $export['menu_options_document'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_parent_document'; + $strongarm->value = 'main-menu:0'; + $export['menu_parent_document'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_options_document'; + $strongarm->value = array( + 0 => 'status', + ); + $export['node_options_document'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_preview_document'; + $strongarm->value = '1'; + $export['node_preview_document'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_submitted_document'; + $strongarm->value = 1; + $export['node_submitted_document'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_documents/commons_documents.views_default.inc b/modules/commons/commons_documents/commons_documents.views_default.inc new file mode 100644 index 0000000..79abadc --- /dev/null +++ b/modules/commons/commons_documents/commons_documents.views_default.inc @@ -0,0 +1,135 @@ +name = 'commons_bw_documents'; + $view->description = 'Commons Documents listing for the group browsing widget.'; + $view->tag = 'Commons Documents, Commons Browsing Widget'; + $view->base_table = 'node'; + $view->human_name = 'Commons Browsing Widget - Documents'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_ajax'] = TRUE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['query']['options']['query_comment'] = FALSE; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'lite'; + $handler->display->display_options['pager']['options']['items_per_page'] = '10'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '5'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'node'; + /* Header: Global: Node partial form */ + $handler->display->display_options['header']['commons_bw_node_partial_form']['id'] = 'commons_bw_node_partial_form'; + $handler->display->display_options['header']['commons_bw_node_partial_form']['table'] = 'views'; + $handler->display->display_options['header']['commons_bw_node_partial_form']['field'] = 'commons_bw_node_partial_form'; + $handler->display->display_options['header']['commons_bw_node_partial_form']['bundle'] = 'document'; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'No documents have been added to this group.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: OG membership: OG membership from Node */ + $handler->display->display_options['relationships']['og_membership_rel']['id'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['table'] = 'node'; + $handler->display->display_options['relationships']['og_membership_rel']['field'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['required'] = TRUE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Content: Sticky */ + $handler->display->display_options['sorts']['sticky']['id'] = 'sticky'; + $handler->display->display_options['sorts']['sticky']['table'] = 'node'; + $handler->display->display_options['sorts']['sticky']['field'] = 'sticky'; + $handler->display->display_options['sorts']['sticky']['order'] = 'DESC'; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + $handler->display->display_options['sorts']['created']['exposed'] = TRUE; + $handler->display->display_options['sorts']['created']['expose']['label'] = 'Post date'; + /* Contextual filter: OG membership: Group ID */ + $handler->display->display_options['arguments']['gid']['id'] = 'gid'; + $handler->display->display_options['arguments']['gid']['table'] = 'og_membership'; + $handler->display->display_options['arguments']['gid']['field'] = 'gid'; + $handler->display->display_options['arguments']['gid']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['arguments']['gid']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['gid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['gid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['gid']['summary_options']['items_per_page'] = '25'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'node'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['value'] = array( + 'document' => 'document', + ); + $handler->display->display_options['filters']['type']['group'] = 1; + /* Filter criterion: OG membership: Group_type */ + $handler->display->display_options['filters']['group_type']['id'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['table'] = 'og_membership'; + $handler->display->display_options['filters']['group_type']['field'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['filters']['group_type']['value'] = array( + 'node' => 'node', + ); + $handler->display->display_options['filters']['group_type']['group'] = 1; + $translatables['commons_bw_documents'] = array( + t('Master'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('No documents have been added to this group.'), + t('OG membership from node'), + t('following'), + t('Post date'), + t('most active'), + t('All'), + t('Following'), + ); + + $export['commons_bw_documents'] = $view; + + return $export; +} diff --git a/modules/commons/commons_events/README.txt b/modules/commons/commons_events/README.txt new file mode 100644 index 0000000..597bc2b --- /dev/null +++ b/modules/commons/commons_events/README.txt @@ -0,0 +1 @@ +See the 7.x-1.x branch. diff --git a/modules/commons/commons_events/commons_events.features.field_base.inc b/modules/commons/commons_events/commons_events.features.field_base.inc new file mode 100644 index 0000000..b8a0fa6 --- /dev/null +++ b/modules/commons/commons_events/commons_events.features.field_base.inc @@ -0,0 +1,240 @@ + 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_date', + 'foreign keys' => array(), + 'indexes' => array(), + 'locked' => 0, + 'module' => 'date', + 'settings' => array( + 'cache_count' => 4, + 'cache_enabled' => 0, + 'granularity' => array( + 'day' => 'day', + 'hour' => 'hour', + 'minute' => 'minute', + 'month' => 'month', + 'second' => 0, + 'year' => 'year', + ), + 'timezone_db' => 'UTC', + 'todate' => 'required', + 'tz_handling' => 'site', + ), + 'translatable' => 0, + 'type' => 'datetime', + ); + + // Exported field_base: 'field_location' + $field_bases['field_location'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_location', + 'foreign keys' => array(), + 'indexes' => array( + 'value' => array( + 0 => 'value', + ), + ), + 'locked' => 0, + 'module' => 'list', + 'settings' => array( + 'allowed_values' => array( + 'physical' => 'Physical Address', + 'online' => 'Online', + 'online_physical' => 'Online and Physical Address', + ), + 'allowed_values_function' => '', + ), + 'translatable' => 0, + 'type' => 'list_text', + ); + + // Exported field_base: 'field_logo' + $field_bases['field_logo'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_logo', + 'foreign keys' => array( + 'fid' => array( + 'columns' => array( + 'fid' => 'fid', + ), + 'table' => 'file_managed', + ), + ), + 'indexes' => array( + 'fid' => array( + 0 => 'fid', + ), + ), + 'locked' => 0, + 'module' => 'image', + 'settings' => array( + 'default_image' => 0, + 'uri_scheme' => 'public', + ), + 'translatable' => 0, + 'type' => 'image', + ); + + // Exported field_base: 'field_number_of_attendees' + $field_bases['field_number_of_attendees'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_number_of_attendees', + 'foreign keys' => array(), + 'indexes' => array(), + 'locked' => 0, + 'module' => 'number', + 'settings' => array(), + 'translatable' => 0, + 'type' => 'number_integer', + ); + + // Exported field_base: 'field_offsite_url' + $field_bases['field_offsite_url'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_offsite_url', + 'foreign keys' => array( + 'format' => array( + 'columns' => array( + 'format' => 'format', + ), + 'table' => 'filter_format', + ), + ), + 'indexes' => array( + 'format' => array( + 0 => 'format', + ), + ), + 'locked' => 0, + 'module' => 'text', + 'settings' => array( + 'max_length' => 255, + ), + 'translatable' => 0, + 'type' => 'text', + ); + + // Exported field_base: 'field_organizers' + $field_bases['field_organizers'] = array( + 'active' => 1, + 'cardinality' => -1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_organizers', + 'foreign keys' => array( + 'users' => array( + 'columns' => array( + 'target_id' => 'uid', + ), + 'table' => 'users', + ), + ), + 'indexes' => array( + 'target_id' => array( + 0 => 'target_id', + ), + ), + 'locked' => 0, + 'module' => 'entityreference', + 'settings' => array( + 'handler' => 'base', + 'handler_settings' => array( + 'behaviors' => array( + 'views-select-list' => array( + 'status' => 0, + ), + ), + 'sort' => array( + 'type' => 'none', + ), + 'target_bundles' => array(), + ), + 'target_type' => 'user', + ), + 'translatable' => 0, + 'type' => 'entityreference', + ); + + // Exported field_base: 'field_registration' + $field_bases['field_registration'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_registration', + 'foreign keys' => array( + 'registration_type' => array( + 'columns' => array( + 'registration_type' => 'name', + ), + 'table' => 'registration_type', + ), + ), + 'indexes' => array( + 'registration_type' => array( + 0 => 'registration_type', + ), + ), + 'locked' => 0, + 'module' => 'registration', + 'settings' => array(), + 'translatable' => 0, + 'type' => 'registration', + ); + + // Exported field_base: 'field_registration_type' + $field_bases['field_registration_type'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_registration_type', + 'foreign keys' => array(), + 'indexes' => array( + 'value' => array( + 0 => 'value', + ), + ), + 'locked' => 0, + 'module' => 'list', + 'settings' => array( + 'allowed_values' => array( + 'onsite' => 'On this site', + 'external' => 'On another site', + ), + 'allowed_values_function' => '', + ), + 'translatable' => 0, + 'type' => 'list_text', + ); + + return $field_bases; +} diff --git a/modules/commons/commons_events/commons_events.features.field_instance.inc b/modules/commons/commons_events/commons_events.features.field_instance.inc new file mode 100644 index 0000000..9526fd9 --- /dev/null +++ b/modules/commons/commons_events/commons_events.features.field_instance.inc @@ -0,0 +1,736 @@ + 'event', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 5, + ), + 'teaser' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array( + 'trim_length' => 600, + ), + 'type' => 'text_summary_or_trimmed', + 'weight' => 3, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'body', + 'label' => 'Description', + 'required' => 1, + 'settings' => array( + 'display_summary' => FALSE, + 'text_processing' => 1, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'rows' => 20, + 'summary_rows' => 5, + ), + 'type' => 'text_textarea_with_summary', + 'weight' => 1, + ), + ); + + // Exported field_instance: 'node-event-field_address' + $field_instances['node-event-field_address'] = array( + 'bundle' => 'event', + 'default_value' => array( + 0 => array( + 'element_key' => 'node|event|field_address|und|0', + 'thoroughfare' => '', + 'premise' => '', + 'locality' => '', + 'administrative_area' => '', + 'postal_code' => '', + 'country' => !empty($default_country) ? $default_country : 'US', + ), + ), + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'module' => 'addressfield_tokens', + 'settings' => array( + 'components' => array( + 'administrative_area' => 'administrative_area', + 'locality' => 'locality', + 'postal_code' => 'postal_code', + 'thoroughfare' => 'thoroughfare', + ), + 'separator' => ', ', + ), + 'type' => 'addressfield_components', + 'weight' => 2, + ), + 'teaser' => array( + 'label' => 'hidden', + 'module' => 'addressfield_tokens', + 'settings' => array( + 'components' => array( + 'administrative_area' => 'administrative_area', + 'locality' => 'locality', + 'postal_code' => 'postal_code', + 'thoroughfare' => 'thoroughfare', + ), + 'separator' => ', ', + ), + 'type' => 'addressfield_components', + 'weight' => 2, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_address', + 'label' => 'Address', + 'required' => 0, + 'settings' => array( + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'addressfield', + 'settings' => array( + 'available_countries' => array(), + 'format_handlers' => array( + 'address' => 'address', + 'address-hide-country' => 0, + 'organisation' => 0, + 'name-full' => 0, + 'name-oneline' => 0, + ), + ), + 'type' => 'addressfield_standard', + 'weight' => 8, + ), + ); + + // Exported field_instance: 'node-event-field_date' + $field_instances['node-event-field_date'] = array( + 'bundle' => 'event', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'module' => 'date', + 'settings' => array( + 'format_type' => 'event_datetime', + 'fromto' => 'both', + 'multiple_from' => '', + 'multiple_number' => '', + 'multiple_to' => '', + ), + 'type' => 'date_default', + 'weight' => 1, + ), + 'teaser' => array( + 'label' => 'hidden', + 'module' => 'date', + 'settings' => array( + 'format_type' => 'event_datetime', + 'fromto' => 'both', + 'multiple_from' => '', + 'multiple_number' => '', + 'multiple_to' => '', + ), + 'type' => 'date_default', + 'weight' => 1, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_date', + 'label' => 'Date', + 'required' => 1, + 'settings' => array( + 'default_value' => 'now', + 'default_value2' => 'same', + 'default_value_code' => '', + 'default_value_code2' => '', + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'date', + 'settings' => array( + 'increment' => 15, + 'input_format' => 'm/d/Y - H:i:s', + 'input_format_custom' => 'd M Y - h:i:s a', + 'label_position' => 'above', + 'text_parts' => array(), + 'year_range' => '-3:+3', + ), + 'type' => 'date_popup', + 'weight' => 5, + ), + ); + + // Exported field_instance: 'node-event-field_location' + $field_instances['node-event-field_location'] = array( + 'bundle' => 'event', + 'default_value' => array( + 0 => array( + 'value' => 'online_physical', + ), + ), + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 9, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_location', + 'label' => 'Location', + 'required' => 0, + 'settings' => array( + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'options', + 'settings' => array(), + 'type' => 'options_select', + 'weight' => 7, + ), + ); + + // Exported field_instance: 'node-event-field_logo' + $field_instances['node-event-field_logo'] = array( + 'bundle' => 'event', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'module' => 'image', + 'settings' => array( + 'image_link' => '', + 'image_style' => '50x50', + ), + 'type' => 'image', + 'weight' => 0, + ), + 'teaser' => array( + 'label' => 'hidden', + 'module' => 'image', + 'settings' => array( + 'image_link' => '', + 'image_style' => '50x50', + ), + 'type' => 'image', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_logo', + 'label' => 'Event logo', + 'required' => 0, + 'settings' => array( + 'alt_field' => 0, + 'default_image' => 0, + 'file_directory' => '', + 'file_extensions' => 'png gif jpg jpeg', + 'max_filesize' => '2 MB', + 'max_resolution' => '', + 'min_resolution' => '', + 'title_field' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'image', + 'settings' => array( + 'preview_image_style' => '50x50', + 'progress_indicator' => 'throbber', + ), + 'type' => 'image_image', + 'weight' => 9, + ), + ); + + // Exported field_instance: 'node-event-field_number_of_attendees' + $field_instances['node-event-field_number_of_attendees'] = array( + 'bundle' => 'event', + 'default_value' => array( + 0 => array( + 'value' => 0, + ), + ), + 'deleted' => 0, + 'description' => 'Enter 0 for unlimited', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 8, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_number_of_attendees', + 'label' => 'Maximum number of attendees', + 'required' => 1, + 'settings' => array( + 'max' => '', + 'min' => 0, + 'prefix' => '', + 'suffix' => '', + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 0, + 'module' => 'number', + 'settings' => array(), + 'type' => 'number', + 'weight' => 12, + ), + ); + + // Exported field_instance: 'node-event-field_offsite_url' + $field_instances['node-event-field_offsite_url'] = array( + 'bundle' => 'event', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 4, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_offsite_url', + 'label' => 'URL', + 'required' => 0, + 'settings' => array( + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'size' => 60, + ), + 'type' => 'text_textfield', + 'weight' => 3, + ), + ); + + // Exported field_instance: 'node-event-field_organizers' + $field_instances['node-event-field_organizers'] = array( + 'bundle' => 'event', + 'default_value' => NULL, + 'default_value_function' => '', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'entityreference', + 'settings' => array( + 'link' => FALSE, + ), + 'type' => 'hidden', + 'weight' => 12, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_organizers', + 'label' => 'Organizers', + 'required' => 1, + 'settings' => array( + 'behaviors' => array( + 'prepopulate' => array( + 'status' => 0, + ), + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete_tags', + 'weight' => 2, + ), + ); + + // Exported field_instance: 'node-event-field_registration' + $field_instances['node-event-field_registration'] = array( + 'bundle' => 'event', + 'default_value' => array( + 0 => array( + 'registration_type' => 'event', + ), + ), + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 10, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_registration', + 'label' => 'Registration bundle', + 'required' => 0, + 'settings' => array( + 'default_registration_settings' => array( + 'capacity' => 0, + 'reminder' => array( + 'reminder_settings' => array( + 'reminder_date' => '', + 'reminder_template' => '', + ), + 'send_reminder' => 0, + ), + 'scheduling' => array( + 'close' => '', + 'open' => '', + ), + 'settings' => array( + 'from_address' => 'admin@example.com', + 'multiple_registrations' => 0, + ), + 'status' => 1, + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 0, + 'module' => 'registration', + 'settings' => array(), + 'type' => 'registration_select', + 'weight' => 10, + ), + ); + + // Exported field_instance: 'node-event-field_registration_type' + $field_instances['node-event-field_registration_type'] = array( + 'bundle' => 'event', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 11, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_registration_type', + 'label' => 'Registration type', + 'required' => 0, + 'settings' => array( + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'options', + 'settings' => array(), + 'type' => 'options_select', + 'weight' => 11, + ), + ); + + // Exported field_instance: 'message-commons_events_event_node_created-field_message_rendered_body' + $field_instances['message-commons_events_event_node_created-field_message_rendered_body'] = array( + 'bundle' => 'commons_events_event_node_created', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 2, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 4, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 4, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_message_rendered_body', + 'label' => 'Body', + 'required' => 0, + 'settings' => array( + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'rows' => 5, + ), + 'type' => 'text_textarea', + 'weight' => 6, + ), + ); + + // Exported field_instance: 'message-commons_events_event_node_created-field_message_rendered_subject' + $field_instances['message-commons_events_event_node_created-field_message_rendered_subject'] = array( + 'bundle' => 'commons_events_event_node_created', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 3, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 3, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 3, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_message_rendered_subject', + 'label' => 'Subject', + 'required' => FALSE, + 'settings' => array( + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'module' => 'text', + 'settings' => array( + 'size' => 60, + ), + 'type' => 'text_textfield', + 'weight' => 8, + ), + ); + + + // Exported field_instance: 'message-commons_events_event_node_created-field_target_comments' + $field_instances['message-commons_events_event_node_created-field_target_comments'] = array( + 'bundle' => 'commons_events_event_node_created', + 'default_value' => NULL, + 'default_value_function' => '', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'entityreference', + 'settings' => array( + 'link' => FALSE, + ), + 'type' => 'entityreference_label', + 'weight' => 1, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 5, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 5, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_target_comments', + 'label' => 'Target comment', + 'required' => 1, + 'settings' => array( + 'behaviors' => array( + 'prepopulate' => array( + 'status' => 0, + ), + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 4, + ), + ); + + // Exported field_instance: 'message-commons_events_event_node_created-field_target_nodes' + $field_instances['message-commons_events_event_node_created-field_target_nodes'] = array( + 'bundle' => 'commons_events_event_node_created', + 'default_value' => NULL, + 'default_value_function' => '', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'entityreference', + 'settings' => array( + 'link' => FALSE, + ), + 'type' => 'entityreference_label', + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 6, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 6, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_target_nodes', + 'label' => 'Target nodes', + 'required' => 0, + 'settings' => array( + 'behaviors' => array( + 'prepopulate' => array( + 'status' => 0, + ), + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 2, + ), + ); + + // Translatables + // Included for use with string extractors like potx. + t('Address'); + t('Date'); + t('Description'); + t('Enter 0 for unlimited'); + t('Event logo'); + t('Location'); + t('Maximum number of attendees'); + t('Organizers'); + t('Registration bundle'); + t('Registration type'); + t('URL'); + + return $field_instances; +} diff --git a/modules/commons/commons_events/commons_events.features.inc b/modules/commons/commons_events/commons_events.features.inc new file mode 100644 index 0000000..816d0ff --- /dev/null +++ b/modules/commons/commons_events/commons_events.features.inc @@ -0,0 +1,178 @@ + "1"); + } + if ($module == "strongarm" && $api == "strongarm") { + return array("version" => "1"); + } +} + +/** + * Implements hook_views_api(). + */ +function commons_events_views_api($module = NULL, $api = NULL) { + return array("api" => "3.0"); +} + +/** + * Implements hook_node_info(). + */ +function commons_events_node_info() { + $items = array( + 'event' => array( + 'name' => t('Event'), + 'base' => 'node_content', + 'description' => t('Post information about planned activities or meetings.'), + 'has_title' => '1', + 'title_label' => t('Event title'), + 'help' => '', + ), + ); + return $items; +} + +/** + * Implements hook_default_registration_type(). + */ +function commons_events_default_registration_type() { + $items = array(); + $items['event'] = entity_import('registration_type', '{ + "name" : "event", + "label" : "Event", + "locked" : "0", + "weight" : "0", + "data" : null, + "rdf_mapping" : [] + }'); + return $items; +} + +/** + * Implements hook_rdf_default_mappings(). + */ +function commons_events_rdf_default_mappings() { + $schemaorg = array(); + + // Exported RDF mapping: event + $schemaorg['node']['event'] = array( + 'rdftype' => array( + 0 => 'schema:Event', + 1 => 'sioc:Item', + 2 => 'foaf:Document', + ), + 'title' => array( + 'predicates' => array( + 0 => 'schema:name', + ), + ), + 'created' => array( + 'predicates' => array( + 0 => 'dc:date', + 1 => 'dc:created', + ), + 'datatype' => 'xsd:dateTime', + 'callback' => 'date_iso8601', + ), + 'changed' => array( + 'predicates' => array( + 0 => 'dc:modified', + ), + 'datatype' => 'xsd:dateTime', + 'callback' => 'date_iso8601', + ), + 'body' => array( + 'predicates' => array( + 0 => 'content:encoded', + ), + ), + 'uid' => array( + 'predicates' => array( + 0 => 'sioc:has_creator', + ), + 'type' => 'rel', + ), + 'name' => array( + 'predicates' => array( + 0 => 'schema:name', + ), + ), + 'comment_count' => array( + 'predicates' => array( + 0 => 'sioc:num_replies', + ), + 'datatype' => 'xsd:integer', + ), + 'last_activity' => array( + 'predicates' => array( + 0 => 'sioc:last_activity_date', + ), + 'datatype' => 'xsd:dateTime', + 'callback' => 'date_iso8601', + ), + 'field_date' => array( + 'predicates' => array( + 0 => 'schema:startDate', + ), + ), + 'url' => array( + 'predicates' => array( + 0 => 'schema:url', + ), + 'type' => 'rel', + ), + 'field_location' => array( + 'predicates' => array(), + ), + 'field_address' => array( + 'predicates' => array( + 0 => 'schema:location', + ), + ), + ); + + return $schemaorg; +} + +/** + * Implements hook_default_message_type(). + */ +function commons_events_default_message_type() { + $items = array(); + $items['commons_events_event_node_created'] = entity_import('message_type', '{ + "name" : "commons_events_event_node_created", + "description" : "The notification sent when a user creates an event", + "argument_keys" : [], + "argument" : [], + "category" : "commons_notify", + "data" : { + "token options" : { "clear" : 0 }, + "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" } + }, + "language" : "", + "arguments" : null, + "message_text" : { "und" : [ + { + "value" : "New Event on [site:name]: [message:field-target-nodes:0:title_field]", + "format" : "plain_text", + "safe_value" : "\u003Cp\u003ENew Event on [site:name]: [message:field-target-nodes:0:title_field]\u003C\/p\u003E\n" + }, + { + "value" : "Hi [message:user:name],\r\n\r\n[message:field-target-nodes:0:author] created the event \u201c[message:field-target-nodes:0:title_field]\u201d on [site:name] [commons-groups:in-groups-text] on [message:field-target-nodes:0:created]:\r\n\r\nWhat: [message:field-target-nodes:0:title_field]\r\nWhen: [message:field-target-nodes:0:field_date]\r\nWhere (If applicable): [message:field-target-nodes:0:field_address]\r\n\r\n[message:field-target-nodes:0:body]\r\n\r\n\r\nPermalink: [message:field-target-nodes:0:url]\r\nAdd a comment at [message:field-target-nodes:0:url]#comment-form\r\n\r\nChange email notifications at [site:url]user\/[message:user:uid]\/notification-settings", + "format" : "plain_text", + "safe_value" : "\u003Cp\u003EHi [message:user:name],\u003C\/p\u003E\n\u003Cp\u003E[message:field-target-nodes:0:author] created the event \u201c[message:field-target-nodes:0:title_field]\u201d on [site:name] [commons-groups:in-groups-text] on [message:field-target-nodes:0:created]:\u003C\/p\u003E\n\u003Cp\u003EWhat: [message:field-target-nodes:0:title_field]\u003Cbr \/\u003E\nWhen: [message:field-target-nodes:0:field_date]\u003Cbr \/\u003E\nWhere (If applicable): [message:field-target-nodes:0:field_address]\u003C\/p\u003E\n\u003Cp\u003E[message:field-target-nodes:0:body]\u003C\/p\u003E\n\u003Cp\u003EPermalink: [message:field-target-nodes:0:url]\u003Cbr \/\u003E\nAdd a comment at [message:field-target-nodes:0:url]#comment-form\u003C\/p\u003E\n\u003Cp\u003EChange email notifications at [site:url]user\/[message:user:uid]\/notification-settings\u003C\/p\u003E\n" + } + ] + }, + "rdf_mapping" : [] + }'); + return $items; +} \ No newline at end of file diff --git a/modules/commons/commons_events/commons_events.features.menu_links.inc b/modules/commons/commons_events/commons_events.features.menu_links.inc new file mode 100644 index 0000000..1b1fc2a --- /dev/null +++ b/modules/commons/commons_events/commons_events.features.menu_links.inc @@ -0,0 +1,37 @@ + 'main-menu', + 'link_path' => 'events', + 'router_path' => 'events', + 'link_title' => 'Events', + 'options' => array( + 'attributes' => array(), + 'identifier' => 'main-menu:events', + ), + 'module' => 'menu', + 'hidden' => 0, + 'external' => 0, + 'has_children' => 0, + 'expanded' => 0, + 'weight' => 2, + 'customized' => 1, + ); + // Translatables + // Included for use with string extractors like potx. + t('Events'); + + + return $menu_links; +} diff --git a/modules/commons/commons_events/commons_events.features.og_features_permission.inc b/modules/commons/commons_events/commons_events.features.og_features_permission.inc new file mode 100644 index 0000000..5f1240b --- /dev/null +++ b/modules/commons/commons_events/commons_events.features.og_features_permission.inc @@ -0,0 +1,52 @@ + array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + // Exported og permission: 'node:group:delete any event content' + $permissions['node:group:delete any event content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + ), + ); + + // Exported og permission: 'node:group:delete own event content' + $permissions['node:group:delete own event content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + // Exported og permission: 'node:group:update any event content' + $permissions['node:group:update any event content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + ), + ); + + // Exported og permission: 'node:group:update own event content' + $permissions['node:group:update own event content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + return $permissions; +} diff --git a/modules/commons/commons_events/commons_events.features.user_permission.inc b/modules/commons/commons_events/commons_events.features.user_permission.inc new file mode 100644 index 0000000..40d60d0 --- /dev/null +++ b/modules/commons/commons_events/commons_events.features.user_permission.inc @@ -0,0 +1,94 @@ + 'create event content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + // Exported permission: 'create event registration'. + $permissions['create event registration'] = array( + 'name' => 'create event registration', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'registration', + ); + + // Exported permission: 'delete own event content'. + $permissions['delete own event content'] = array( + 'name' => 'delete own event content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + // Exported permission: 'delete own event registration'. + $permissions['delete own event registration'] = array( + 'name' => 'delete own event registration', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'registration', + ); + + // Exported permission: 'edit own event content'. + $permissions['edit own event content'] = array( + 'name' => 'edit own event content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + // Exported permission: 'update own event registration'. + $permissions['update own event registration'] = array( + 'name' => 'update own event registration', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'registration', + ); + + // Exported permission: 'view event registration'. + $permissions['view event registration'] = array( + 'name' => 'view event registration', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'registration', + ); + + // Exported permission: 'view own event registration'. + $permissions['view own event registration'] = array( + 'name' => 'view own event registration', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'registration', + ); + + return $permissions; +} diff --git a/modules/commons/commons_events/commons_events.info b/modules/commons/commons_events/commons_events.info new file mode 100644 index 0000000..e7dfba3 --- /dev/null +++ b/modules/commons/commons_events/commons_events.info @@ -0,0 +1,106 @@ +name = Commons Events +description = Provides the Event features for Drupal Commons. +core = 7.x +package = Commons - Content types +dependencies[] = addressfield +dependencies[] = addressfield_tokens +dependencies[] = block +dependencies[] = commons_body +dependencies[] = commons_follow_node +dependencies[] = commons_groups +dependencies[] = commons_notify +dependencies[] = commons_location +dependencies[] = commons_topics +dependencies[] = ctools +dependencies[] = date +dependencies[] = date_api +dependencies[] = date_popup +dependencies[] = date_views +dependencies[] = entity +dependencies[] = entityreference +dependencies[] = features +dependencies[] = field_sql_storage +dependencies[] = image +dependencies[] = list +dependencies[] = menu +dependencies[] = node +dependencies[] = number +dependencies[] = og +dependencies[] = options +dependencies[] = page_manager +dependencies[] = radioactivity +dependencies[] = registration +dependencies[] = registration_views +dependencies[] = strongarm +dependencies[] = taxonomy +dependencies[] = text +dependencies[] = views +dependencies[] = views_content +dependencies[] = views_load_more +features[ctools][] = page_manager:pages_default:1 +features[ctools][] = strongarm:strongarm:1 +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[field_base][] = field_date +features[field_base][] = field_location +features[field_base][] = field_logo +features[field_base][] = field_number_of_attendees +features[field_base][] = field_offsite_url +features[field_base][] = field_organizers +features[field_base][] = field_registration +features[field_base][] = field_registration_type +features[field_instance][] = node-event-body +features[field_instance][] = node-event-field_address +features[field_instance][] = node-event-field_date +features[field_instance][] = node-event-field_location +features[field_instance][] = node-event-field_logo +features[field_instance][] = node-event-field_number_of_attendees +features[field_instance][] = node-event-field_offsite_url +features[field_instance][] = node-event-field_organizers +features[field_instance][] = node-event-field_registration +features[field_instance][] = node-event-field_registration_type +features[field_instance][] = message-commons_events_event_node_created-field_message_rendered_body +features[field_instance][] = message-commons_events_event_node_created-field_message_rendered_subject +features[field_instance][] = message-commons_events_event_node_created-field_target_nodes +features[menu_links][] = main-menu:events +features[message_type][] = commons_events_event_node_created +features[node][] = event +features[og_features_permission][] = node:group:create event content +features[og_features_permission][] = node:group:delete any event content +features[og_features_permission][] = node:group:delete own event content +features[og_features_permission][] = node:group:update any event content +features[og_features_permission][] = node:group:update own event content +features[page_manager_pages][] = views_events_landing_page +features[registration_type][] = event +features[schemaorg][] = node-event +features[user_permission][] = create event content +features[user_permission][] = create event registration +features[user_permission][] = delete own event content +features[user_permission][] = delete own event registration +features[user_permission][] = edit own event content +features[user_permission][] = update own event registration +features[user_permission][] = view event registration +features[user_permission][] = view own event registration +features[variable][] = comment_anonymous_event +features[variable][] = comment_default_mode_event +features[variable][] = comment_default_per_page_event +features[variable][] = comment_event +features[variable][] = comment_form_location_event +features[variable][] = comment_preview_event +features[variable][] = comment_subject_field_event +features[variable][] = field_bundle_settings_node__event +features[variable][] = menu_options_event +features[variable][] = menu_parent_event +features[variable][] = node_options_event +features[variable][] = node_preview_event +features[variable][] = node_submitted_event +features[views_view][] = commons_events_event_attendee_list +features[views_view][] = commons_events_organizers +features[views_view][] = commons_events_upcoming +features[views_view][] = commons_events_user_upcoming_events +files[] = commons_events.features.inc +files[] = commons_events.features.field_base.inc +files[] = commons_events.features.field_instance.inc +files[] = commons_events.strongarm.inc +files[] = includes/commons_events.forms.inc +files[] = includes/commons_events.theme.inc diff --git a/modules/commons/commons_events/commons_events.install b/modules/commons/commons_events/commons_events.install new file mode 100644 index 0000000..803e4fa --- /dev/null +++ b/modules/commons/commons_events/commons_events.install @@ -0,0 +1,236 @@ +fields(array( + 'format' => 'M d Y, g:ia T', + 'type' => 'event_datetime', + 'locked' => 1, + )) + ->execute(); + + db_insert('date_format_type') + ->fields(array( + 'type' => 'event_datetime', + 'title' => 'Event Datetime', + 'locked' => 0, + )) + ->execute(); + + variable_set('date_format_event_datetime', 'M d Y, g:ia T'); +} + +/** + * Disable summary on Event nodes. + */ +function commons_events_update_7000() { + $revert = array( + 'commons_events' => array('field_instance'), + ); + features_revert($revert); + return array(); +} + +/** + * Switch attendee view and event logo to use 50x50 image style. + */ +function commons_events_update_7001() { + $revert = array( + 'commons_events' => array('views', 'node'), + ); + features_revert($revert); + return array(); +} + +/** + * Add the Organizers entity reference field to Events and update existing nodes + * with the event's creator as the default value. + */ +function commons_events_update_7002() { + // Revert node and views to use default implementations. This resets field + // weights to configuration due to new Organizers field. + $revert = array( + 'commons_events' => array('node'), + ); + features_revert($revert); + if (field_info_field('field_organizers') == NULL) { + // Create the field so we can update the default values for existing events. + module_load_include('inc', 'commons_events', 'commons_events.features.field_base'); + $fields = commons_events_field_default_field_bases(); + field_create_field($fields['field_organizers']); + } + if (field_info_instance('node', 'field_organizers', 'event') == NULL) { + // Create the instance on Events. + module_load_include('inc', 'commons_events', 'commons_events.features.field_instance'); + $instances = commons_events_field_default_field_instances(); + field_create_instance($instances['node-event-field_organizers']); + } + // Now update all existing Events to have the creator as the default organizer. + $events = new EntityFieldQuery(); + $events->entityCondition('entity_type', 'node') + ->entityCondition('bundle', 'event'); + $events = $events->execute(); + $events = entity_load('node', array_keys($events['node'])); + foreach($events as $nid => $event) { + if (!property_exists($event, 'field_organizers') || empty($event->field_organizers)) { + $event->field_organizers = array( + $event->language => array( + 0 => array( + 'target_id' => $event->uid + ) + ), + ); + node_save($event); + } + } + return array(); +} + +/** + * Change event teaser display to show logo, date, and address. + */ +function commons_events_update_7003() { + $revert = array( + 'commons_events' => array('field_instance'), + ); + features_revert($revert); + return array(); +} + +/** + * Create the event_datetime date format. + */ +function commons_events_update_7004() { + db_insert('date_formats') + ->fields(array( + 'format' => 'M d Y - g:ia T', + 'type' => 'event_datetime', + 'locked' => 1, + )) + ->execute(); + + db_insert('date_format_type') + ->fields(array( + 'type' => 'event_datetime', + 'title' => 'Event Datetime', + 'locked' => 0, + )) + ->execute(); + + variable_set('date_format_event_datetime', 'M d Y - g:ia T'); + + // Revert commons_events to make sure its referencing the event_datetime module. + $revert = array( + 'commons_events' => array('field_instance'), + 'commons_events' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Set event nodes to use site default country set during install as default. + */ +function commons_events_update_7005() { + $revert = array( + 'commons_events' => array('field_instance'), + ); + features_revert($revert); + return array(); +} + +/** + * Upcoming events view pane exposed sort should redirect to the view pane and + * not the feed. + */ +function commons_events_update_7006() { + $revert = array( + 'commons_events' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Change event displays to abbreviate state names. + */ +function commons_events_update_7007() { + $revert = array( + 'commons_events' => array('field_instance'), + ); + features_revert($revert); + return array(); +} + +/* + * Alter the event display formatter, it should be a ',' and not '-' + */ +/** + * Create the event_datetime date format. + */ +function commons_events_update_7008() { + db_update('date_formats') + ->fields(array( + 'format' => 'M d Y, g:ia T', + 'type' => 'event_datetime', + 'locked' => 1, + )) + ->condition('format', 'M d Y - g:ia T', '=') + ->condition('type', 'event_datetime', '=') + ->execute(); + + variable_set('date_format_event_datetime', 'M d Y, g:ia T'); + + // Revert commons_events to make sure its referencing the event_datetime module. + $revert = array( + 'commons_events' => array('field_instance'), + 'commons_events' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Need to force update so that Drupal sees the new hook_forms implementation. + */ +function commons_events_update_7009() { + cache_clear_all('module_implements', 'cache_bootstrap'); + return array(); +} + +/** + * Display current events in addition to upcoming events. + */ +function commons_events_update_7010() { + $revert = array( + 'commons_events' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Add empty text to Commons Events views. + */ +function commons_events_update_7011() { + $revert = array( + 'commons_events' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Add an event specific message_type feature. + */ +function commons_events_update_7012() { + $revert = array( + 'commons_events' => array('message_type', 'field_instance'), + ); + features_revert($revert); + return array(); +} \ No newline at end of file diff --git a/modules/commons/commons_events/commons_events.module b/modules/commons/commons_events/commons_events.module new file mode 100644 index 0000000..3bf1d19 --- /dev/null +++ b/modules/commons/commons_events/commons_events.module @@ -0,0 +1,649 @@ + array( + 'callback' => $form, + ), + ); + } + } +} + +/** + * Implements hook_menu_alter(). + */ +function commons_events_menu_alter(&$items) { + // Hide the "Register" tab since we expose an "Attend" button. + $items['node/%/register']['access callback'] = FALSE; +} + +/** + * Access callback for showing the Attendees tab. + */ +function commons_events_attendee_access($event_node) { + if ($event_node->type == 'event') { + return TRUE; + } + return FALSE; +} + +/** + * Page callback for full event attendee listing. + */ +function commons_events_event_attendees_page($event_node) { + return theme('commons_events_event_attendees', + array( + 'event_nid' => $event_node->nid, + 'display' => 'full', + )); +} + +/** + * Implements hook_theme(). + */ +function commons_events_theme($existing, $type, $theme, $path) { + return array( + 'commons_events_attending_event' => array( + 'variables' => array( + 'event' => NULL, + 'attendee_count' => NULL, + ), + 'file' => '/includes/commons_events.theme.inc', + ), + 'commons_events_event_attendees' => array( + 'variables' => array( + 'display' => NULL, + 'event_nid' => NULL, + ), + 'file' => '/includes/commons_events.theme.inc', + ), + 'commons_events_date_display_range_advanced' => array( + 'variables' => array( + 'date1' => NULL, + 'date2' => NULL, + 'timezone' => NULL, + 'dates' => NULL, + // HTML attributes that will be applied to both the start and end dates + // (unless overridden). + 'attributes' => array(), + // HTML attributes that will be applied to the start date only. + 'attributes_start' => array(), + // HTML attributes that will be applied to the end date only. + 'attributes_end' => array(), + 'rdf_mapping' => NULL, + 'add_rdf' => NULL, + ), + ), + 'commons_events_date_display_range_simple' => array( + 'variables' => array( + 'date1' => NULL, + 'date2' => NULL, + 'timezone' => NULL, + 'dates' => NULL, + // HTML attributes that will be applied to both the start and end dates + // (unless overridden). + 'attributes' => array(), + // HTML attributes that will be applied to the start date only. + 'attributes_start' => array(), + // HTML attributes that will be applied to the end date only. + 'attributes_end' => array(), + 'rdf_mapping' => NULL, + 'add_rdf' => NULL, + ), + ), + ); +} + +/** + * Implements hook_theme_registry_alter(). + * Gives us the ability to insert our pretty date formatter for the dates we choose below. + */ +function commons_events_theme_registry_alter(&$theme_registry) { + $theme_registry['date_display_range']['theme path'] = drupal_get_path('module', 'commons_events'); + $theme_registry['date_display_range']['function'] = 'theme_commons_events_date_display_range_advanced'; + $theme_registry['date_display_single']['theme path'] = drupal_get_path('module', 'commons_events'); + $theme_registry['date_display_single']['function'] = 'theme_commons_events_date_display_single'; +} + +/** + * Implements hook_element_info_alter(). + */ +function commons_events_element_info_alter(&$type) { + // Extend date_combo processing to alter the label text on the fields. + if (isset($type['date_combo'])) { + $type['date_combo']['#process'][] = 'commons_events_date_combo_element_process'; + } + + // Extend date_popup processing to remove the redundant descriptions on + // fields. + if (isset($type['date_popup'])) { + $type['date_popup']['#process'][] = 'commons_events_date_popup_element_process'; + } +} + +/** + * Process date_combo field output. + * + * This is an extension of the Date module's own processing. + * + * @see date_combo_element_process() + * @see commons_events_element_info_alter() + */ +function commons_events_date_combo_element_process($element, &$form_state, $form) { + $field = field_widget_field($element, $form_state); + + // Change the labels for from and to dates to something more meaningful. + if (!empty($field['settings']['todate'])) { + $element['value']['#title'] = t('Start date'); + $element['value2']['#title'] = t('End date'); + } + + return $element; +} + +/** + * Process date_popup field output. + * + * This is an extension of the Date module's own processing. + * + * @see date_popup_element_process() + * @see commons_events_element_info_alter() + */ +function commons_events_date_popup_element_process($element, &$form_state, $form) { + // If a date_popup field is part of a larger range widget, simplify the + // output. + if (!empty($element['#field']['settings']['todate'])) { + foreach (array('date', 'time') as $type) { + if (!empty($element[$type])) { + // The description and title are unnecessary. + unset($element[$type]['#description']); + $element[$type]['#title'] = ''; + } + } + } + return $element; +} + +/** + * Implements hook_entity_view_alter(). + */ +function commons_events_entity_view_alter(&$build, $type) { + if ($build['#entity_type'] == 'node' && $build['#bundle'] == 'event') { + + $build['attending'] = array( + 0 => theme('commons_events_attending_event', array( + 'event' => $build['#node'], + 'attendee_count' => commons_events_get_raw_attendee_count($build['#node']), + )), + '#weight' => -10, + ); + $vars = array( + 'event_nid' => $build['#node']->nid, + ); + // Don't show the address if the event location is only online. + $field_location = field_view_field('node', $build['#node'], 'field_location'); + if (isset($field_location['#items']['0']['value']) && $field_location['#items']['0']['value'] == 'online') { + unset($build['field_address']); + } + } +} + +/** + * Implements hook_form_FORM_ID_alter(). + */ +function commons_events_form_node_form_alter(&$form, &$form_state) { + if ($form_state['node']->type == 'event') { + $form['#attached']['css'] = array( + drupal_get_path('module', 'commons_events') . '/css/commons_events.css', + ); + $form['#attached']['js'] = array( + drupal_get_path('module', 'commons_events') . '/js/commons_events.js', + ); + // Remove the '-None-' option from all the dropdowns. + unset($form['field_location'][$form['field_location']['#language']]['#options']['_none']); + unset($form['field_registration_type'][$form['field_registration_type']['#language']]['#options']['_none']); + // Hide the Registration type field. + $form['field_registration']['#disabled'] = commons_events_event_type_disabled($form_state['node']); + // Address field should be hidden if event is only online. + $form['field_address']['#states'] = array( + 'invisible' => array( + ':input[name^="field_location"]' => array('value' => 'online'), + ), + ); + // Status and attendee limit are shown if registration is onsite. + $node_registration_status = 1; + if (isset($form_state['node']->nid)) { + $settings = registration_entity_settings('node', $form_state['node']->nid); + $node_registration_status = $settings['status']; + } + $form['field_status'] = array( + '#type' => 'select', + '#title' => t('Status'), + '#options' => array( + 1 => t('Open to new attendees'), + 0 => t('Closed'), + ), + '#default_value' => $node_registration_status, + '#states' => array( + 'visible' => array( + ':input[name^="field_registration_type"]' => array('value' => 'onsite'), + ), + ), + '#weight' => 10, + ); + $form['field_number_of_attendees']['#states'] = $form['field_status']['#states']; + $form['field_registration']['#states'] = $form['field_status']['#states']; + $form['field_number_of_attendees']['#states']['visible'][':input[name="field_status"]'] = array( + 'value' => 1, + ); + $form['field_number_of_attendees']['#weight'] = 11; + $form['#validate'] = array_merge(array('commons_events_node_form_validate'), $form['#validate']); + $form['#submit'][] = 'commons_events_node_form_submit'; + // Move registration settings into a fieldset so we can move the group. + $form['event_registration_settings'] = array( + '#type' => 'fieldset', + '#collapsible' => TRUE, + '#collapsed' => FALSE, + '#title' => t('Registration settings'), + '#group' => 'additional_settings', + '#weight' => -10, + ); + if (empty($form['field_organizers'][$form['field_organizers']['#language']]['#default_value'])) { + global $user; + $form['field_organizers'][$form['field_organizers']['#language']]['#default_value'] = format_username($user) . " (" . $user->uid . ")"; + } + $form['event_registration_settings']['field_organizers'] = $form['field_organizers']; + $form['event_registration_settings']['field_registration_type'] = $form['field_registration_type']; + $form['event_registration_settings']['field_status'] = $form['field_status']; + $form['event_registration_settings']['field_number_of_attendees'] = $form['field_number_of_attendees']; + unset($form['field_registration'][$form['field_registration']['#language']]['0']['registration_type']['#description']); + $form['event_registration_settings']['field_registration'] = $form['field_registration']; + $form['field_organizers'] = array('#language' => NULL); + $form['field_registration_type'] = array('#language' => NULL); + $form['field_status'] = array('#language' => NULL); + $form['field_number_of_attendees'] = array('#language' => NULL); + $form['field_registration'] = array('#language' => NULL); + } +} + +/** + * Implements hook_commons_entity_integration(). + */ +function commons_events_commons_entity_integration() { + return array( + 'node' => array( + 'event' => array( + 'is_group_content' => TRUE, + ), + ), + ); +} + +/** + * Custom node form validation handler. + */ +function commons_events_node_form_validate($form, &$form_state) { + $lng = (isset($form_state['language']) ? $form_state['language'] : LANGUAGE_NONE); + switch ($form_state['values']['field_registration_type'][$lng]['0']['value']) { + case 'onsite': + // Max attendees must be entered if the registration status is open and + // registration is done onsite. + if ((int) $form_state['values']['field_status'] == 1 + && (!is_numeric($form_state['values']['field_number_of_attendees'][$lng]['0']['value'])) + ) { + form_set_error('field_number_of_attendees', + t('Maximum number of attendees must be set for registrations to be accepted.')); + return FALSE; + } + break; + } + return TRUE; +} + +/** + * Custom node form submit handler. + */ +function commons_events_node_form_submit($form, $form_state) { + $node = $form_state['node']; + $lng = (isset($form_state['language']) ? $form_state['language'] : LANGUAGE_NONE); + if (isset($node->nid)) { + $settings = registration_entity_settings('node', $node->nid); + $settings['status'] = (int) $form_state['values']['field_status']; + if ($form_state['values']['field_registration_type'][$lng]['0']['value'] == 'external') { + $settings['status'] = 0; + } + if (!empty($form_state['values']['field_number_of_attendees'][$lng]['0']['value']) + && is_numeric($form_state['values']['field_number_of_attendees'][$lng]['0']['value']) + ) { + $settings['capacity'] = (int) $form_state['values']['field_number_of_attendees'][$lng]['0']['value']; + } + $settings['settings'] = serialize($settings['settings']); + registration_update_entity_settings('node', $node->nid, $settings); + // Automatically register the node creator for the event. + $registration_type = registration_get_entity_registration_type('node', $node); + $registration = entity_get_controller('registration')->create(array( + 'entity_type' => 'node', + 'entity_id' => $node->nid, + 'type' => $registration_type, + )); + if (!isset($node->uid)) { + global $user; + $uid = $user->uid; + } + else { + $uid = $node->uid; + } + if ($settings['status'] == 1 + && !registration_is_registered($registration, NULL, $uid) + ) { + $registration->user_uid = $uid; + $registration->author_uid = $uid; + $registration->state = NULL; + $registration->count = 1; + registration_save($registration); + } + } +} + +/** + * Implements hook_token_info(). + */ +function commons_events_token_info_alter(&$tokens) { + $tokens['tokens']['node']['attend-form'] = array( + 'name' => t('Attending event form'), + 'description' => t('Displays the appropriate form for attending or cancelling event attendance'), + ); +} + +/** + * Implements hook_commons_bw_create_all_widget(). + */ +function commons_events_commons_bw_create_all_widget($group) { + if (og_user_access('node', $group->nid, 'create event content')) { + $link = l(t('List an event'), 'node/add/event', + array( + 'attributes' => array('class' => 'commons-events-create'), + 'query' => array('og_group_ref' => $group->nid), + ) + ); + return array( + 'commons_events' => array( + 'link' => $link, + 'text' => t('Create in-person or online meetups'), + '#weight' => 6, + ), + ); + } +} + +/** + * Implements hook_tokens(). + */ +function commons_events_tokens($type, $tokens, array $data = array(), array $options = array()) { + $replacements = array(); + if ($type == 'node' && !empty($data['node'])) { + $event = $data['node']; + foreach ($tokens as $name => $original) { + if ($name == 'attend-form') { + $replacements[$original] = theme('commons_events_attending_event', array( + 'event' => $event, + 'attendee_count' => commons_events_get_raw_attendee_count($event), + )); + } + } + } + return $replacements; +} + +/** + * Generates the 'more' link for upcoming events in a specific group. + */ +function commons_events_upcoming_more_link($group_id) { + if (module_exists('commons_events_solr')) { + $options = array( + 'query' => array( + 'f[1]' => 'sm_og_group_ref:node:' . $group_id, + ), + ); + return l(t('more'), 'events', $options); + } + $options = array( + 'query' => array( + 'gid' => $group_id, + ), + ); + return l(t('more'), 'events', $options); +} + +/** + * Implements hook_views_post_execute(). + */ +function commons_events_views_post_execute(&$view) { + if ($view->name == 'commons_events_upcoming' + && $view->current_display == 'panel_pane_1' + ) { + $view->attachment_after = ''; + } + else { + if ($view->name == 'commons_events_upcoming' + && $view->current_display == 'panel_pane_2' + ) { + $view->attachment_before = '
' . format_plural(count($view->result), '1 event', '@count events') . '
'; + } + } +} + +/** + * Implements hook_block_info(). + */ +function commons_events_block_info() { + $blocks = array( + 'commons_events_create_event_link' => array( + 'info' => t('"Create an event" call to action'), + 'cache' => DRUPAL_CACHE_GLOBAL, + ), + 'commons_events_anonymous_login' => array( + 'info' => t('"Login to create an event" call to action'), + 'cache' => DRUPAL_CACHE_GLOBAL, + ), + ); + return $blocks; +} + +/** + * Implements hook_block_view(). + */ +function commons_events_block_view($delta = '') { + global $user; + if ($delta == 'commons_events_create_event_link' + && node_access('create', 'event') + ) { + $options = array( + 'query' => array( + 'destination' => 'events', + ), + ); + return array( + 'subject' => NULL, + 'content' => l(t('List an event'), 'node/add/event', $options), + ); + } + else { + if ($delta == 'commons_events_anonymous_login' + && empty($user->uid) + ) { + return array( + 'subject' => NULL, + 'content' => t('You must !login in order to list events.', array('!login' => l(t('log in'), 'user'))), + ); + } + } +} + +/** + * Returns specific HTML for a date element formatted with the event formatter M j Y - g:ia. + * + * We the do some awesome stuff with regular expressions to take all the + * different formats available to us and format it pretty. + */ +function theme_commons_events_date_display_range_simple($variables) { + // Use the regular date formatter if we are any other date format than below. + $date1 = $variables['dates']['value']['formatted_date']; + $date2 = $variables['dates']['value2']['formatted_date']; + $time1 = $variables['dates']['value']['formatted_time']; + $time2 = $variables['dates']['value2']['formatted_time']; + + $timezone = $variables['timezone']; + $attributes_start = $variables['attributes_start']; + $attributes_end = $variables['attributes_end']; + + if ($date1 == $date2) { + // Wrap the result with the attributes. + return t('!start-time - !end-time', array( + '!start-time' => '' . $time1 . '', + '!end-time' => '' . $time2 . $timezone . '', + )); + } + + // Wrap the result with the attributes. + return t('!start-date to !end-date, !start-time - !end-time', array( + '!start-date' => '' . $date1 . '', + '!end-date' => '' . $date2 . '', + '!start-time' => '' . $time1 . '', + '!end-time' => '' . $time2 . $timezone . '', + )); +} + +function theme_commons_events_date_display_single($variables) { + return $variables['date']; +} + +/** + * Returns specific HTML for a date element formatted with the event formatter. + * + * We parse the date segments and return it at the bottom, or use the simple + * formatter (above) if parts of the date are too complicated. + */ +function theme_commons_events_date_display_range_advanced($variables) { + $timezone = $variables['timezone']; + $attributes_start = $variables['attributes_start']; + $attributes_end = $variables['attributes_end']; + + // Time is always formatted the same. + $time1 = $variables['dates']['value']['formatted_time']; + $time2 = $variables['dates']['value2']['formatted_time']; + + // See date.theme line 168 -- regarding formatting time for same date events. + if ($variables['dates']['value']['formatted_date'] === $variables['dates']['value2']['formatted_date']) { + return theme('commons_events_date_display_range_simple', $variables); + } + // If the difference is over a year, use the simple formatter. + if ($variables['dates']['value']['db']['object']->difference($variables['dates']['value2']['db']['object'], 'years') > 0) { + return theme('commons_events_date_display_range_simple', $variables); + } + else { + if ($variables['dates']['value']['db']['object']->difference($variables['dates']['value2']['db']['object'], 'months') > 0) { + $variables['dates']['value']['db']['object']->limitGranularity(array('day', 'month')); + $variables['dates']['value2']['db']['object']->limitGranularity(array('day', 'month', 'year')); + + $date1 = $variables['dates']['value']['db']['object']->format($variables['dates']['format'], FALSE); + $date2 = $variables['dates']['value2']['db']['object']->format($variables['dates']['format'], FALSE); + } + else { + if ($variables['dates']['value']['db']['object']->difference($variables['dates']['value2']['db']['object'], 'days') > 0) { + // If the Day is before the month (Europe, etc) then switch the granularity. + if (strpos($variables['dates']['format'], 'M') != 0 || strpos($variables['dates']['format'], 'm') != 0 || + strpos($variables['dates']['format'], 'F') != 0 || strpos($variables['dates']['format'], 'n') != 0 + ) { + $variables['dates']['value']['db']['object']->limitGranularity(array('day')); + $variables['dates']['value2']['db']['object']->limitGranularity(array('day', 'month', 'year')); + } + else { + $variables['dates']['value']['db']['object']->limitGranularity(array('month', 'day')); + $variables['dates']['value2']['db']['object']->limitGranularity(array('day', 'year')); + } + + $date1 = $variables['dates']['value']['db']['object']->format($variables['dates']['format'], FALSE); + $date2 = $variables['dates']['value2']['db']['object']->format($variables['dates']['format'], FALSE); + + // If we are match 'D' or 'l', then we have a 'day' in there (eg Monday), + // we want the whole date because it looks funky otherwise. + if (strpbrk($variables['dates']['format'], 'Dl')) { + return theme('commons_events_date_display_range_simple', $variables); + } + } + else { + return theme('commons_events_date_display_range_simple', $variables); + } + } + } + // Wrap the result with the attributes. + return t('!start-date to !end-date, !start-time - !end-time', array( + '!start-date' => '' . $date1 . '', + '!end-date' => '' . $date2 . '', + '!start-time' => '' . $time1 . '', + '!end-time' => '' . $time2 . $timezone . '', + )); +} + +/** + * Implements commons_notify_message_selection_alter(). + */ +function commons_events_commons_notify_message_selection_alter(&$message_type, $hook, $node) { + // Provide a special message type that describes the event details + // when a new event node is created. + if ($hook == 'node_insert' && $node->type == 'event') { + $message_type = 'commons_events_event_node_created'; + } +} + +/** + * Check whether to allow switching the event's registration type. + * If there are registrations for the event, disallow changing the type. This + * keeps registrations for an event consistent. + */ +function commons_events_event_type_disabled($node) { + if (!isset($node->nid) || empty($node->nid)) { + return FALSE; + } + $registrations = db_select('registration', 'r') + ->fields('r') + ->condition('entity_type', 'node') + ->condition('entity_id', $node->nid) + ->countQuery() + ->execute() + ->fetchCol(); + if ($registrations[0] > 0) { + return TRUE; + } + return FALSE; +} + +/** + * Helper function go get the raw number of attendees. + */ +function commons_events_get_raw_attendee_count($node) { + $attendee_count = db_select('registration', 'r') + ->fields('r') + ->condition('entity_id', $node->nid) + ->condition('entity_type', 'node') + ->countQuery() + ->execute() + ->fetchField(); + + return $attendee_count; +} \ No newline at end of file diff --git a/modules/commons/commons_events/commons_events.pages_default.inc b/modules/commons/commons_events/commons_events.pages_default.inc new file mode 100644 index 0000000..659bc2e --- /dev/null +++ b/modules/commons/commons_events/commons_events.pages_default.inc @@ -0,0 +1,193 @@ +disabled = FALSE; /* Edit this to true to make a default page disabled initially */ + $page->api_version = 1; + $page->name = 'views_events_landing_page'; + $page->task = 'page'; + $page->admin_title = 'Views Events Landing Page'; + $page->admin_description = ''; + $page->path = 'events'; + $page->access = array( + 'type' => 'none', + 'settings' => NULL, + ); + $page->menu = array(); + $page->arguments = array(); + $page->conf = array( + 'admin_paths' => FALSE, + ); + $page->default_handlers = array(); + $handler = new stdClass(); + $handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */ + $handler->api_version = 1; + $handler->name = 'page_views_events_landing_page_panel_context'; + $handler->task = 'page'; + $handler->subtask = 'views_events_landing_page'; + $handler->handler = 'panel_context'; + $handler->weight = 0; + $handler->conf = array( + 'title' => 'Panel', + 'no_blocks' => 0, + 'pipeline' => 'ipe', + 'body_classes_to_remove' => '', + 'body_classes_to_add' => '', + 'css_id' => '', + 'css' => '', + 'contexts' => array(), + 'relationships' => array(), + ); + $display = new panels_display(); + $display->layout = 'two_66_33'; + $display->layout_settings = array(); + $display->panel_settings = array( + 'style_settings' => array( + 'default' => NULL, + 'two_66_33_top' => NULL, + 'two_66_33_first' => NULL, + 'two_66_33_second' => NULL, + 'two_66_33_bottom' => NULL, + ), + ); + $display->cache = array(); + $display->title = 'Events'; + $display->uuid = 'f084cd6c-0d66-7ca4-c971-3c5cf182d2ec'; + $display->content = array(); + $display->panels = array(); + $pane = new stdClass(); + $pane->pid = 'new-e72884a7-369b-1954-2d1f-d69207c4d6ff'; + $pane->panel = 'two_66_33_first'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_events_upcoming-panel_pane_2'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = 'e72884a7-369b-1954-2d1f-d69207c4d6ff'; + $display->content['new-e72884a7-369b-1954-2d1f-d69207c4d6ff'] = $pane; + $display->panels['two_66_33_first'][0] = 'new-e72884a7-369b-1954-2d1f-d69207c4d6ff'; + $pane = new stdClass(); + $pane->pid = 'new-b91ad246-669c-2e14-fd32-5728153b0ed8'; + $pane->panel = 'two_66_33_second'; + $pane->type = 'block'; + $pane->subtype = 'commons_events-commons_events_create_event_link'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 0, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = 'b91ad246-669c-2e14-fd32-5728153b0ed8'; + $display->content['new-b91ad246-669c-2e14-fd32-5728153b0ed8'] = $pane; + $display->panels['two_66_33_second'][0] = 'new-b91ad246-669c-2e14-fd32-5728153b0ed8'; + $pane = new stdClass(); + $pane->pid = 'new-d776b637-24a9-7e74-712c-8bc27d399c3e'; + $pane->panel = 'two_66_33_second'; + $pane->type = 'block'; + $pane->subtype = 'commons_events-commons_events_anonymous_login'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 0, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 1; + $pane->locks = array(); + $pane->uuid = 'd776b637-24a9-7e74-712c-8bc27d399c3e'; + $display->content['new-d776b637-24a9-7e74-712c-8bc27d399c3e'] = $pane; + $display->panels['two_66_33_second'][1] = 'new-d776b637-24a9-7e74-712c-8bc27d399c3e'; + $pane = new stdClass(); + $pane->pid = 'new-9118fc7d-3da5-cf54-5152-5d66043812b2'; + $pane->panel = 'two_66_33_second'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_events_user_upcoming_events-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 2; + $pane->locks = array(); + $pane->uuid = '9118fc7d-3da5-cf54-5152-5d66043812b2'; + $display->content['new-9118fc7d-3da5-cf54-5152-5d66043812b2'] = $pane; + $display->panels['two_66_33_second'][2] = 'new-9118fc7d-3da5-cf54-5152-5d66043812b2'; + $pane = new stdClass(); + $pane->pid = 'new-ef7caf29-a6a8-e654-5997-6b969eba407a'; + $pane->panel = 'two_66_33_second'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_events_user_upcoming_events-panel_pane_2'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 3; + $pane->locks = array(); + $pane->uuid = 'ef7caf29-a6a8-e654-5997-6b969eba407a'; + $display->content['new-ef7caf29-a6a8-e654-5997-6b969eba407a'] = $pane; + $display->panels['two_66_33_second'][3] = 'new-ef7caf29-a6a8-e654-5997-6b969eba407a'; + $pane = new stdClass(); + $pane->pid = 'new-80f087dc-fe84-7354-e19b-23e398080db9'; + $pane->panel = 'two_66_33_second'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_events_user_upcoming_events-panel_pane_3'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 4; + $pane->locks = array(); + $pane->uuid = '80f087dc-fe84-7354-e19b-23e398080db9'; + $display->content['new-80f087dc-fe84-7354-e19b-23e398080db9'] = $pane; + $display->panels['two_66_33_second'][4] = 'new-80f087dc-fe84-7354-e19b-23e398080db9'; + $display->hide_title = PANELS_TITLE_FIXED; + $display->title_pane = 'new-9118fc7d-3da5-cf54-5152-5d66043812b2'; + $handler->conf['display'] = $display; + $page->default_handlers[$handler->name] = $handler; + $pages['views_events_landing_page'] = $page; + + return $pages; + +} diff --git a/modules/commons/commons_events/commons_events.strongarm.inc b/modules/commons/commons_events/commons_events.strongarm.inc new file mode 100644 index 0000000..a613917 --- /dev/null +++ b/modules/commons/commons_events/commons_events.strongarm.inc @@ -0,0 +1,147 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_anonymous_event'; + $strongarm->value = 0; + $export['comment_anonymous_event'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_mode_event'; + $strongarm->value = 1; + $export['comment_default_mode_event'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_per_page_event'; + $strongarm->value = '50'; + $export['comment_default_per_page_event'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_event'; + $strongarm->value = '2'; + $export['comment_event'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_form_location_event'; + $strongarm->value = 1; + $export['comment_form_location_event'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_preview_event'; + $strongarm->value = '1'; + $export['comment_preview_event'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_subject_field_event'; + $strongarm->value = 1; + $export['comment_subject_field_event'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_node__event'; + $strongarm->value = array( + 'view_modes' => array( + 'teaser' => array( + 'custom_settings' => TRUE, + ), + 'full' => array( + 'custom_settings' => FALSE, + ), + 'rss' => array( + 'custom_settings' => FALSE, + ), + 'search_index' => array( + 'custom_settings' => FALSE, + ), + 'search_result' => array( + 'custom_settings' => FALSE, + ), + 'token' => array( + 'custom_settings' => FALSE, + ), + ), + 'extra_fields' => array( + 'form' => array( + 'title' => array( + 'weight' => '0', + ), + 'metatags' => array( + 'weight' => '15', + ), + 'path' => array( + 'weight' => '14', + ), + 'redirect' => array( + 'weight' => '13', + ), + ), + 'display' => array(), + ), + ); + $export['field_bundle_settings_node__event'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_options_event'; + $strongarm->value = array( + 0 => 'main-menu', + ); + $export['menu_options_event'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_parent_event'; + $strongarm->value = 'main-menu:0'; + $export['menu_parent_event'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_options_event'; + $strongarm->value = array( + 0 => 'status', + ); + $export['node_options_event'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_preview_event'; + $strongarm->value = '1'; + $export['node_preview_event'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_submitted_event'; + $strongarm->value = 1; + $export['node_submitted_event'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_events/commons_events.views_default.inc b/modules/commons/commons_events/commons_events.views_default.inc new file mode 100644 index 0000000..0fc6f36 --- /dev/null +++ b/modules/commons/commons_events/commons_events.views_default.inc @@ -0,0 +1,791 @@ +name = 'commons_events_event_attendee_list'; + $view->description = 'List attendees for a given event.'; + $view->tag = 'commons_events'; + $view->base_table = 'registration'; + $view->human_name = 'Commons Events - Event Attendee List'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Attendees'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'none'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['pager']['options']['items_per_page'] = '20'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '0'; + $handler->display->display_options['pager']['options']['quantity'] = '4'; + $handler->display->display_options['style_plugin'] = 'grid'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* Relationship: Registration: Registration to Node */ + $handler->display->display_options['relationships']['registration_related_node']['id'] = 'registration_related_node'; + $handler->display->display_options['relationships']['registration_related_node']['table'] = 'registration'; + $handler->display->display_options['relationships']['registration_related_node']['field'] = 'registration_related_node'; + /* Relationship: Registration: User */ + $handler->display->display_options['relationships']['user_uid']['id'] = 'user_uid'; + $handler->display->display_options['relationships']['user_uid']['table'] = 'registration'; + $handler->display->display_options['relationships']['user_uid']['field'] = 'user_uid'; + $handler->display->display_options['relationships']['user_uid']['required'] = TRUE; + /* Field: User: Picture */ + $handler->display->display_options['fields']['picture']['id'] = 'picture'; + $handler->display->display_options['fields']['picture']['table'] = 'users'; + $handler->display->display_options['fields']['picture']['field'] = 'picture'; + $handler->display->display_options['fields']['picture']['relationship'] = 'user_uid'; + $handler->display->display_options['fields']['picture']['label'] = ''; + $handler->display->display_options['fields']['picture']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['picture']['image_style'] = '50x50'; + /* Field: User: Name */ + $handler->display->display_options['fields']['name']['id'] = 'name'; + $handler->display->display_options['fields']['name']['table'] = 'users'; + $handler->display->display_options['fields']['name']['field'] = 'name'; + $handler->display->display_options['fields']['name']['relationship'] = 'user_uid'; + $handler->display->display_options['fields']['name']['label'] = ''; + $handler->display->display_options['fields']['name']['element_label_colon'] = FALSE; + /* Contextual filter: Content: Nid */ + $handler->display->display_options['arguments']['nid']['id'] = 'nid'; + $handler->display->display_options['arguments']['nid']['table'] = 'node'; + $handler->display->display_options['arguments']['nid']['field'] = 'nid'; + $handler->display->display_options['arguments']['nid']['relationship'] = 'registration_related_node'; + $handler->display->display_options['arguments']['nid']['default_action'] = 'empty'; + $handler->display->display_options['arguments']['nid']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25'; + + /* Display: Full Attendee List Block */ + $handler = $view->new_display('block', 'Full Attendee List Block', 'commons_events_full_attendee_list'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['defaults']['pager'] = FALSE; + $handler->display->display_options['pager']['type'] = 'none'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + + /* Display: Content pane */ + $handler = $view->new_display('panel_pane', 'Content pane', 'panel_pane_1'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['allow']['use_pager'] = 'use_pager'; + $handler->display->display_options['allow']['items_per_page'] = 'items_per_page'; + $handler->display->display_options['allow']['offset'] = 'offset'; + $handler->display->display_options['allow']['link_to_view'] = 0; + $handler->display->display_options['allow']['more_link'] = 0; + $handler->display->display_options['allow']['path_override'] = 0; + $handler->display->display_options['allow']['title_override'] = 0; + $handler->display->display_options['allow']['exposed_form'] = 0; + $handler->display->display_options['allow']['fields_override'] = 0; + $handler->display->display_options['argument_input'] = array( + 'null' => array( + 'type' => 'fixed', + 'context' => 'entity:comment.author', + 'context_optional' => 0, + 'panel' => '0', + 'fixed' => 'node', + 'label' => 'Global: Null', + ), + 'nid' => array( + 'type' => 'context', + 'context' => 'entity:node.nid', + 'context_optional' => 0, + 'panel' => '0', + 'fixed' => '', + 'label' => 'Content: Nid', + ), + ); + $translatables['commons_events_event_attendee_list'] = array( + t('Master'), + t('Attendees'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('node from Registration'), + t('User'), + t('All'), + t('Full Attendee List Block'), + t('Content pane'), + t('View panes'), + ); + $export['commons_events_event_attendee_list'] = $view; + + $view = new view(); + $view->name = 'commons_events_organizers'; + $view->description = 'Event organizer panel pane.'; + $view->tag = 'commons_events'; + $view->base_table = 'node'; + $view->human_name = 'Commons Events - Organizers'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Organizers'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'none'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['style_plugin'] = 'grid'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* Relationship: Entity Reference: Referenced Entity */ + $handler->display->display_options['relationships']['field_organizers_target_id']['id'] = 'field_organizers_target_id'; + $handler->display->display_options['relationships']['field_organizers_target_id']['table'] = 'field_data_field_organizers'; + $handler->display->display_options['relationships']['field_organizers_target_id']['field'] = 'field_organizers_target_id'; + $handler->display->display_options['relationships']['field_organizers_target_id']['required'] = TRUE; + /* Field: User: Picture */ + $handler->display->display_options['fields']['picture']['id'] = 'picture'; + $handler->display->display_options['fields']['picture']['table'] = 'users'; + $handler->display->display_options['fields']['picture']['field'] = 'picture'; + $handler->display->display_options['fields']['picture']['relationship'] = 'field_organizers_target_id'; + $handler->display->display_options['fields']['picture']['label'] = ''; + $handler->display->display_options['fields']['picture']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['picture']['image_style'] = '50x50'; + /* Contextual filter: Content: Nid */ + $handler->display->display_options['arguments']['nid']['id'] = 'nid'; + $handler->display->display_options['arguments']['nid']['table'] = 'node'; + $handler->display->display_options['arguments']['nid']['field'] = 'nid'; + $handler->display->display_options['arguments']['nid']['default_action'] = 'not found'; + $handler->display->display_options['arguments']['nid']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25'; + + /* Display: Content pane */ + $handler = $view->new_display('panel_pane', 'Content pane', 'panel_pane_1'); + $handler->display->display_options['argument_input'] = array( + 'nid' => array( + 'type' => 'context', + 'context' => 'entity:node.nid', + 'context_optional' => 0, + 'panel' => '0', + 'fixed' => '', + 'label' => 'Content: Nid', + ), + ); + $translatables['commons_events_organizers'] = array( + t('Master'), + t('Organizers'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('User entity referenced from field_organizers'), + t('All'), + t('Content pane'), + t('View panes'), + ); + $export['commons_events_organizers'] = $view; + + $view = new view(); + $view->name = 'commons_events_upcoming'; + $view->description = 'Display upcoming events site-wide, or per-group.'; + $view->tag = 'commons_events'; + $view->base_table = 'node'; + $view->human_name = 'Commons Events - Upcoming Events'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Events'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'load_more'; + $handler->display->display_options['pager']['options']['items_per_page'] = '5'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '0'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Field: Content: Date */ + $handler->display->display_options['fields']['field_date']['id'] = 'field_date'; + $handler->display->display_options['fields']['field_date']['table'] = 'field_data_field_date'; + $handler->display->display_options['fields']['field_date']['field'] = 'field_date'; + $handler->display->display_options['fields']['field_date']['label'] = ''; + $handler->display->display_options['fields']['field_date']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['field_date']['settings'] = array( + 'format_type' => 'event_datetime', + 'fromto' => 'both', + 'multiple_number' => '', + 'multiple_from' => '', + 'multiple_to' => '', + ); + /* Field: Registration Settings: Spaces used */ + $handler->display->display_options['fields']['capacity_used']['id'] = 'capacity_used'; + $handler->display->display_options['fields']['capacity_used']['table'] = 'node'; + $handler->display->display_options['fields']['capacity_used']['field'] = 'capacity_used'; + $handler->display->display_options['fields']['capacity_used']['label'] = ''; + $handler->display->display_options['fields']['capacity_used']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['capacity_used']['separator'] = ''; + $handler->display->display_options['fields']['capacity_used']['suffix'] = ' attendees'; + /* Field: Content: Comment count */ + $handler->display->display_options['fields']['comment_count']['id'] = 'comment_count'; + $handler->display->display_options['fields']['comment_count']['table'] = 'node_comment_statistics'; + $handler->display->display_options['fields']['comment_count']['field'] = 'comment_count'; + $handler->display->display_options['fields']['comment_count']['label'] = ''; + $handler->display->display_options['fields']['comment_count']['alter']['alter_text'] = TRUE; + $handler->display->display_options['fields']['comment_count']['alter']['text'] = '[comment_count] comments'; + $handler->display->display_options['fields']['comment_count']['element_label_colon'] = FALSE; + /* Sort criterion: Content: Date - start date (field_date) */ + $handler->display->display_options['sorts']['field_date_value']['id'] = 'field_date_value'; + $handler->display->display_options['sorts']['field_date_value']['table'] = 'field_data_field_date'; + $handler->display->display_options['sorts']['field_date_value']['field'] = 'field_date_value'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'node'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['value'] = array( + 'event' => 'event', + ); + /* Filter criterion: Content: Date - start date (field_date) */ + $handler->display->display_options['filters']['field_date_value']['id'] = 'field_date_value'; + $handler->display->display_options['filters']['field_date_value']['table'] = 'field_data_field_date'; + $handler->display->display_options['filters']['field_date_value']['field'] = 'field_date_value'; + $handler->display->display_options['filters']['field_date_value']['operator'] = '>='; + $handler->display->display_options['filters']['field_date_value']['form_type'] = 'date_text'; + $handler->display->display_options['filters']['field_date_value']['default_date'] = 'now'; + + /* Display: Feed */ + $handler = $view->new_display('feed', 'Feed', 'feed'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['style_plugin'] = 'rss'; + $handler->display->display_options['row_plugin'] = 'node_rss'; + $handler->display->display_options['path'] = 'events-upcoming.xml'; + $handler->display->display_options['displays'] = array( + 'default' => 'default', + 'page' => 'page', + ); + + /* Display: Global Block */ + $handler = $view->new_display('block', 'Global Block', 'commons_events_upcoming_global_block'); + $handler->display->display_options['defaults']['title'] = FALSE; + $handler->display->display_options['title'] = 'Upcoming events'; + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['defaults']['pager'] = FALSE; + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['pager']['options']['items_per_page'] = '5'; + $handler->display->display_options['defaults']['style_plugin'] = FALSE; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['defaults']['style_options'] = FALSE; + $handler->display->display_options['defaults']['row_plugin'] = FALSE; + $handler->display->display_options['row_plugin'] = 'fields'; + $handler->display->display_options['defaults']['row_options'] = FALSE; + + /* Display: Group pane */ + $handler = $view->new_display('panel_pane', 'Group pane', 'panel_pane_1'); + $handler->display->display_options['defaults']['title'] = FALSE; + $handler->display->display_options['title'] = 'Upcoming events'; + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['defaults']['pager'] = FALSE; + $handler->display->display_options['pager']['type'] = 'load_more'; + $handler->display->display_options['pager']['options']['items_per_page'] = '3'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '0'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['defaults']['style_plugin'] = FALSE; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['defaults']['style_options'] = FALSE; + $handler->display->display_options['defaults']['row_plugin'] = FALSE; + $handler->display->display_options['row_plugin'] = 'fields'; + $handler->display->display_options['row_options']['inline'] = array( + 'capacity_used' => 'capacity_used', + 'comment_count' => 'comment_count', + ); + $handler->display->display_options['defaults']['row_options'] = FALSE; + $handler->display->display_options['defaults']['relationships'] = FALSE; + /* Relationship: OG membership: OG membership from Node */ + $handler->display->display_options['relationships']['og_membership_rel']['id'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['table'] = 'node'; + $handler->display->display_options['relationships']['og_membership_rel']['field'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['required'] = TRUE; + $handler->display->display_options['defaults']['fields'] = FALSE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Field: Content: Date */ + $handler->display->display_options['fields']['field_date']['id'] = 'field_date'; + $handler->display->display_options['fields']['field_date']['table'] = 'field_data_field_date'; + $handler->display->display_options['fields']['field_date']['field'] = 'field_date'; + $handler->display->display_options['fields']['field_date']['label'] = ''; + $handler->display->display_options['fields']['field_date']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['field_date']['settings'] = array( + 'format_type' => 'event_datetime', + 'fromto' => 'both', + 'multiple_number' => '', + 'multiple_from' => '', + 'multiple_to' => '', + ); + /* Field: Registration Settings: Spaces used */ + $handler->display->display_options['fields']['capacity_used']['id'] = 'capacity_used'; + $handler->display->display_options['fields']['capacity_used']['table'] = 'node'; + $handler->display->display_options['fields']['capacity_used']['field'] = 'capacity_used'; + $handler->display->display_options['fields']['capacity_used']['label'] = ''; + $handler->display->display_options['fields']['capacity_used']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['capacity_used']['separator'] = ''; + $handler->display->display_options['fields']['capacity_used']['suffix'] = ' attendees,'; + /* Field: Content: Comment count */ + $handler->display->display_options['fields']['comment_count']['id'] = 'comment_count'; + $handler->display->display_options['fields']['comment_count']['table'] = 'node_comment_statistics'; + $handler->display->display_options['fields']['comment_count']['field'] = 'comment_count'; + $handler->display->display_options['fields']['comment_count']['label'] = ''; + $handler->display->display_options['fields']['comment_count']['alter']['alter_text'] = TRUE; + $handler->display->display_options['fields']['comment_count']['alter']['text'] = '[comment_count] comments'; + $handler->display->display_options['fields']['comment_count']['element_label_colon'] = FALSE; + $handler->display->display_options['defaults']['arguments'] = FALSE; + /* Contextual filter: OG membership: Group ID */ + $handler->display->display_options['arguments']['gid']['id'] = 'gid'; + $handler->display->display_options['arguments']['gid']['table'] = 'og_membership'; + $handler->display->display_options['arguments']['gid']['field'] = 'gid'; + $handler->display->display_options['arguments']['gid']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['arguments']['gid']['default_action'] = 'empty'; + $handler->display->display_options['arguments']['gid']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['gid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['gid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['gid']['summary_options']['items_per_page'] = '25'; + $handler->display->display_options['pane_category']['name'] = 'Commons'; + $handler->display->display_options['pane_category']['weight'] = '0'; + $handler->display->display_options['argument_input'] = array( + 'gid' => array( + 'type' => 'context', + 'context' => 'entity:node.nid', + 'context_optional' => 0, + 'panel' => '0', + 'fixed' => '', + 'label' => 'OG membership: Group ID', + ), + ); + + /* Display: Landing Page pane */ + $handler = $view->new_display('panel_pane', 'Landing Page pane', 'panel_pane_2'); + $handler->display->display_options['defaults']['title'] = FALSE; + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['defaults']['exposed_form'] = FALSE; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['exposed_form']['options']['expose_sort_order'] = FALSE; + $handler->display->display_options['exposed_form']['options']['autosubmit'] = TRUE; + $handler->display->display_options['defaults']['style_plugin'] = FALSE; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['defaults']['style_options'] = FALSE; + $handler->display->display_options['defaults']['row_plugin'] = FALSE; + $handler->display->display_options['row_plugin'] = 'node'; + $handler->display->display_options['defaults']['row_options'] = FALSE; + $handler->display->display_options['defaults']['header'] = FALSE; + $handler->display->display_options['defaults']['empty'] = FALSE; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'No events have been created yet.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + $handler->display->display_options['defaults']['sorts'] = FALSE; + /* Sort criterion: Content: Promoted to front page */ + $handler->display->display_options['sorts']['promote']['id'] = 'promote'; + $handler->display->display_options['sorts']['promote']['table'] = 'node'; + $handler->display->display_options['sorts']['promote']['field'] = 'promote'; + $handler->display->display_options['sorts']['promote']['exposed'] = TRUE; + $handler->display->display_options['sorts']['promote']['expose']['label'] = 'Featured'; + /* Sort criterion: Content: Date - start date (field_date) */ + $handler->display->display_options['sorts']['field_date_value']['id'] = 'field_date_value'; + $handler->display->display_options['sorts']['field_date_value']['table'] = 'field_data_field_date'; + $handler->display->display_options['sorts']['field_date_value']['field'] = 'field_date_value'; + $handler->display->display_options['sorts']['field_date_value']['exposed'] = TRUE; + $handler->display->display_options['sorts']['field_date_value']['expose']['label'] = 'Date'; + $handler->display->display_options['inherit_panels_path'] = '1'; + $translatables['commons_events_upcoming'] = array( + t('Master'), + t('Events'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('.'), + t(' attendees'), + t('[comment_count] comments'), + t(','), + t('Feed'), + t('Global Block'), + t('Upcoming events'), + t('Group pane'), + t('OG membership from node'), + t(' attendees,'), + t('All'), + t('Commons'), + t('Landing Page pane'), + t('No events have been created yet.'), + t('Featured'), + t('Date'), + t('View panes'), + ); + $export['commons_events_upcoming'] = $view; + + $view = new view(); + $view->name = 'commons_events_user_upcoming_events'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'Commons Events - User Upcoming Events'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'role'; + $handler->display->display_options['access']['role'] = array( + 2 => '2', + ); + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['pager']['options']['items_per_page'] = '2'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'node'; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'You are not attending any upcoming events.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: Registration: Node to Registration */ + $handler->display->display_options['relationships']['registration_rel']['id'] = 'registration_rel'; + $handler->display->display_options['relationships']['registration_rel']['table'] = 'node'; + $handler->display->display_options['relationships']['registration_rel']['field'] = 'registration_rel'; + $handler->display->display_options['relationships']['registration_rel']['required'] = TRUE; + /* Relationship: Registration: User */ + $handler->display->display_options['relationships']['user_uid']['id'] = 'user_uid'; + $handler->display->display_options['relationships']['user_uid']['table'] = 'registration'; + $handler->display->display_options['relationships']['user_uid']['field'] = 'user_uid'; + $handler->display->display_options['relationships']['user_uid']['relationship'] = 'registration_rel'; + $handler->display->display_options['relationships']['user_uid']['required'] = TRUE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + /* Contextual filter: Registration: User */ + $handler->display->display_options['arguments']['user_uid']['id'] = 'user_uid'; + $handler->display->display_options['arguments']['user_uid']['table'] = 'registration'; + $handler->display->display_options['arguments']['user_uid']['field'] = 'user_uid'; + $handler->display->display_options['arguments']['user_uid']['relationship'] = 'registration_rel'; + $handler->display->display_options['arguments']['user_uid']['default_action'] = 'empty'; + $handler->display->display_options['arguments']['user_uid']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['user_uid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['user_uid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['user_uid']['summary_options']['items_per_page'] = '25'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'node'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['value'] = array( + 'event' => 'event', + ); + + /* Display: Block */ + $handler = $view->new_display('block', 'Block', 'block'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + + /* Display: You're attending - pane */ + $handler = $view->new_display('panel_pane', 'You\'re attending - pane', 'panel_pane_1'); + $handler->display->display_options['defaults']['title'] = FALSE; + $handler->display->display_options['title'] = 'You\'re attending'; + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['defaults']['style_plugin'] = FALSE; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['defaults']['style_options'] = FALSE; + $handler->display->display_options['defaults']['row_plugin'] = FALSE; + $handler->display->display_options['row_plugin'] = 'fields'; + $handler->display->display_options['row_options']['inline'] = array( + 'capacity_used' => 'capacity_used', + 'comment_count' => 'comment_count', + ); + $handler->display->display_options['defaults']['row_options'] = FALSE; + $handler->display->display_options['defaults']['empty'] = FALSE; + $handler->display->display_options['defaults']['fields'] = FALSE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Field: Content: Address */ + $handler->display->display_options['fields']['field_address']['id'] = 'field_address'; + $handler->display->display_options['fields']['field_address']['table'] = 'field_data_field_address'; + $handler->display->display_options['fields']['field_address']['field'] = 'field_address'; + $handler->display->display_options['fields']['field_address']['label'] = ''; + $handler->display->display_options['fields']['field_address']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['field_address']['click_sort_column'] = 'country'; + $handler->display->display_options['fields']['field_address']['settings'] = array( + 'use_widget_handlers' => 1, + 'format_handlers' => array( + 'address' => 'address', + ), + ); + /* Field: Registration Settings: Spaces used */ + $handler->display->display_options['fields']['capacity_used']['id'] = 'capacity_used'; + $handler->display->display_options['fields']['capacity_used']['table'] = 'node'; + $handler->display->display_options['fields']['capacity_used']['field'] = 'capacity_used'; + $handler->display->display_options['fields']['capacity_used']['label'] = ''; + $handler->display->display_options['fields']['capacity_used']['alter']['alter_text'] = TRUE; + $handler->display->display_options['fields']['capacity_used']['alter']['text'] = '[capacity_used] attendees,'; + $handler->display->display_options['fields']['capacity_used']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['capacity_used']['separator'] = ''; + /* Field: Content: Comment count */ + $handler->display->display_options['fields']['comment_count']['id'] = 'comment_count'; + $handler->display->display_options['fields']['comment_count']['table'] = 'node_comment_statistics'; + $handler->display->display_options['fields']['comment_count']['field'] = 'comment_count'; + $handler->display->display_options['fields']['comment_count']['label'] = ''; + $handler->display->display_options['fields']['comment_count']['alter']['alter_text'] = TRUE; + $handler->display->display_options['fields']['comment_count']['alter']['text'] = '[comment_count] comments'; + $handler->display->display_options['fields']['comment_count']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['comment_count']['separator'] = ''; + $handler->display->display_options['defaults']['arguments'] = FALSE; + /* Contextual filter: Registration: User */ + $handler->display->display_options['arguments']['user_uid']['id'] = 'user_uid'; + $handler->display->display_options['arguments']['user_uid']['table'] = 'registration'; + $handler->display->display_options['arguments']['user_uid']['field'] = 'user_uid'; + $handler->display->display_options['arguments']['user_uid']['relationship'] = 'registration_rel'; + $handler->display->display_options['arguments']['user_uid']['default_action'] = 'default'; + $handler->display->display_options['arguments']['user_uid']['default_argument_type'] = 'current_user'; + $handler->display->display_options['arguments']['user_uid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['user_uid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['user_uid']['summary_options']['items_per_page'] = '25'; + + /* Display: You created - pane */ + $handler = $view->new_display('panel_pane', 'You created - pane', 'panel_pane_2'); + $handler->display->display_options['defaults']['title'] = FALSE; + $handler->display->display_options['title'] = 'You created'; + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['defaults']['style_plugin'] = FALSE; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['defaults']['style_options'] = FALSE; + $handler->display->display_options['defaults']['row_plugin'] = FALSE; + $handler->display->display_options['row_plugin'] = 'fields'; + $handler->display->display_options['row_options']['inline'] = array( + 'capacity_used' => 'capacity_used', + 'comment_count' => 'comment_count', + ); + $handler->display->display_options['defaults']['row_options'] = FALSE; + $handler->display->display_options['defaults']['empty'] = FALSE; + $handler->display->display_options['defaults']['relationships'] = FALSE; + $handler->display->display_options['defaults']['fields'] = FALSE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Field: Content: Address */ + $handler->display->display_options['fields']['field_address']['id'] = 'field_address'; + $handler->display->display_options['fields']['field_address']['table'] = 'field_data_field_address'; + $handler->display->display_options['fields']['field_address']['field'] = 'field_address'; + $handler->display->display_options['fields']['field_address']['label'] = ''; + $handler->display->display_options['fields']['field_address']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['field_address']['click_sort_column'] = 'country'; + $handler->display->display_options['fields']['field_address']['settings'] = array( + 'use_widget_handlers' => 1, + 'format_handlers' => array( + 'address' => 'address', + ), + ); + /* Field: Registration Settings: Spaces used */ + $handler->display->display_options['fields']['capacity_used']['id'] = 'capacity_used'; + $handler->display->display_options['fields']['capacity_used']['table'] = 'node'; + $handler->display->display_options['fields']['capacity_used']['field'] = 'capacity_used'; + $handler->display->display_options['fields']['capacity_used']['label'] = ''; + $handler->display->display_options['fields']['capacity_used']['alter']['alter_text'] = TRUE; + $handler->display->display_options['fields']['capacity_used']['alter']['text'] = '[capacity_used] attendees,'; + $handler->display->display_options['fields']['capacity_used']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['capacity_used']['separator'] = ''; + /* Field: Content: Comment count */ + $handler->display->display_options['fields']['comment_count']['id'] = 'comment_count'; + $handler->display->display_options['fields']['comment_count']['table'] = 'node_comment_statistics'; + $handler->display->display_options['fields']['comment_count']['field'] = 'comment_count'; + $handler->display->display_options['fields']['comment_count']['label'] = ''; + $handler->display->display_options['fields']['comment_count']['alter']['alter_text'] = TRUE; + $handler->display->display_options['fields']['comment_count']['alter']['text'] = '[comment_count] comments'; + $handler->display->display_options['fields']['comment_count']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['comment_count']['separator'] = ''; + $handler->display->display_options['defaults']['arguments'] = FALSE; + /* Contextual filter: Content: Author uid */ + $handler->display->display_options['arguments']['uid']['id'] = 'uid'; + $handler->display->display_options['arguments']['uid']['table'] = 'node'; + $handler->display->display_options['arguments']['uid']['field'] = 'uid'; + $handler->display->display_options['arguments']['uid']['default_action'] = 'default'; + $handler->display->display_options['arguments']['uid']['default_argument_type'] = 'current_user'; + $handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25'; + + /* Display: You follow - pane */ + $handler = $view->new_display('panel_pane', 'You follow - pane', 'panel_pane_3'); + $handler->display->display_options['defaults']['title'] = FALSE; + $handler->display->display_options['title'] = 'You follow'; + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['defaults']['style_plugin'] = FALSE; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['defaults']['style_options'] = FALSE; + $handler->display->display_options['defaults']['row_plugin'] = FALSE; + $handler->display->display_options['row_plugin'] = 'fields'; + $handler->display->display_options['row_options']['inline'] = array( + 'capacity_used' => 'capacity_used', + 'comment_count' => 'comment_count', + ); + $handler->display->display_options['defaults']['row_options'] = FALSE; + $handler->display->display_options['defaults']['empty'] = FALSE; + $handler->display->display_options['defaults']['relationships'] = FALSE; + /* Relationship: Flags: commons_follow_node */ + $handler->display->display_options['relationships']['flag_content_rel']['id'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel']['table'] = 'node'; + $handler->display->display_options['relationships']['flag_content_rel']['field'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel']['flag'] = 'commons_follow_node'; + $handler->display->display_options['defaults']['fields'] = FALSE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Field: Content: Address */ + $handler->display->display_options['fields']['field_address']['id'] = 'field_address'; + $handler->display->display_options['fields']['field_address']['table'] = 'field_data_field_address'; + $handler->display->display_options['fields']['field_address']['field'] = 'field_address'; + $handler->display->display_options['fields']['field_address']['label'] = ''; + $handler->display->display_options['fields']['field_address']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['field_address']['click_sort_column'] = 'country'; + $handler->display->display_options['fields']['field_address']['settings'] = array( + 'use_widget_handlers' => 1, + 'format_handlers' => array( + 'address' => 'address', + ), + ); + /* Field: Registration Settings: Spaces used */ + $handler->display->display_options['fields']['capacity_used']['id'] = 'capacity_used'; + $handler->display->display_options['fields']['capacity_used']['table'] = 'node'; + $handler->display->display_options['fields']['capacity_used']['field'] = 'capacity_used'; + $handler->display->display_options['fields']['capacity_used']['label'] = ''; + $handler->display->display_options['fields']['capacity_used']['alter']['alter_text'] = TRUE; + $handler->display->display_options['fields']['capacity_used']['alter']['text'] = '[capacity_used] attendees,'; + $handler->display->display_options['fields']['capacity_used']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['capacity_used']['separator'] = ''; + /* Field: Content: Comment count */ + $handler->display->display_options['fields']['comment_count']['id'] = 'comment_count'; + $handler->display->display_options['fields']['comment_count']['table'] = 'node_comment_statistics'; + $handler->display->display_options['fields']['comment_count']['field'] = 'comment_count'; + $handler->display->display_options['fields']['comment_count']['label'] = ''; + $handler->display->display_options['fields']['comment_count']['alter']['alter_text'] = TRUE; + $handler->display->display_options['fields']['comment_count']['alter']['text'] = '[comment_count] comments'; + $handler->display->display_options['fields']['comment_count']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['comment_count']['separator'] = ''; + $handler->display->display_options['defaults']['arguments'] = FALSE; + $translatables['commons_events_user_upcoming_events'] = array( + t('Master'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('You are not attending any upcoming events.'), + t('node being the Registration'), + t('User'), + t('All'), + t('Block'), + t('You\'re attending - pane'), + t('You\'re attending'), + t('[capacity_used] attendees,'), + t('.'), + t('[comment_count] comments'), + t('View panes'), + t('You created - pane'), + t('You created'), + t('You follow - pane'), + t('You follow'), + t('flag'), + ); + $export['commons_events_user_upcoming_events'] = $view; + + return $export; +} diff --git a/modules/commons/commons_events/css/commons_events.css b/modules/commons/commons_events/css/commons_events.css new file mode 100644 index 0000000..fd923e6 --- /dev/null +++ b/modules/commons/commons_events/css/commons_events.css @@ -0,0 +1,42 @@ +#edit-events-sidebar legend .summary { + width: 25em; + overflow: hidden; + line-height: 1em; + height: 1em; +} + +#edit-events-sidebar .fieldset-legend .fieldset-title { + display: block; +} + +#legend-registration-type:after { + content: ', '; +} + +.view-commons-events-event-attendee-list { + background-color: #fff; +} + +/** + * Fix fieldset margins for date and address field since they have weird + * spacing issues. + */ +#edit-field-date .fieldset-description { + display: none; +} +#edit-field-date .date-padding { + padding: 0px; +} +#edit-field-date .fieldset-wrapper .form-item:first-child, +#edit-field-date .form-item .form-item, +#edit-field-address .fieldset-wrapper .form-item:first-child, +#edit-field-address .form-item { + margin-top: 0em; +} + +form.commons-events-form-float { + float: right; +} +.commons-events-button { + margin-left: 5px; +} diff --git a/modules/commons/commons_events/includes/commons_events.forms.inc b/modules/commons/commons_events/includes/commons_events.forms.inc new file mode 100644 index 0000000..d7004b7 --- /dev/null +++ b/modules/commons/commons_events/includes/commons_events.forms.inc @@ -0,0 +1,121 @@ +nid, TRUE)) { + return array(); + } + if (!isset($registration)) { + $registration_type = registration_get_entity_registration_type('node', $event_node); + $registration = entity_get_controller('registration')->create(array( + 'entity_type' => 'node', + 'entity_id' => $event_node->nid, + 'type' => $registration_type, + )); + } + $form_state['registration'] = $registration; + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Attend'), + ); + $form['attending'] = array( + '#theme_wrappers' => array('container'), + '#attributes' => array( + 'class' => array('commons-event-status'), + ), + '#markup' => format_plural($attendee_count, '1 attendee', '@count attendees'), + ); + $form['#attached']['css'] = array( + drupal_get_path('module', 'commons_events') . '/css/commons_events.css', + ); + $form['#attributes'] = array('class' => array('commons-events-form-float')); + return $form; +} + +/** + * Validation handler for attending an event. + * Checks to make sure that space is available for attending, and that it + * didn't fill up after the page load. + */ +function commons_events_attend_event_form_validate($form, &$form_state) { + global $user; + if (!registration_status('node', $form_state['event_node']->nid, TRUE) + || !registration_has_room('node', $form_state['event_node']->nid)) { + form_set_error('submit', t('The event you are registering for is unavailable.')); + return FALSE; + } + else if (registration_is_registered($form_state['registration'], NULL, $user->uid)) { + form_set_error('submit', t('You are already registered for this event.')); + return FALSE; + } + return TRUE; +} + +/** + * Submission handler for attending an event. + */ +function commons_events_attend_event_form_submit($form, $form_state) { + global $user; + $registration = $form_state['registration']; + $registration->user_uid = $user->uid; + $registration->author_uid = $user->uid; + $registration->state = NULL; + $registration->count = 1; + if (registration_save($registration)) { + drupal_set_message(t('Your registration was saved.')); + commons_follow_node_follow_node($registration->entity_id, 'event', $user->uid); + } + else { + drupal_set_message(t('There was an error saving your registration.')); + } +} + +/** + * Form to cancel a registration for an event. + */ +function commons_events_cancel_event_form($form, &$form_state, $event) { + $form_state['event'] = $event; + $form['#attributes'] = array('class' => array('commons-events-form-float')); + $form['#attached']['css'] = array( + drupal_get_path('module', 'commons_events') . '/css/commons_events.css', + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Cancel'), + ); + $form['submit']['#attributes']['class'][] = 'commons-events-button'; + $form['attending'] = array( + '#theme_wrappers' => array('container'), + '#attributes' => array( + 'class' => array('commons-event-status'), + ), + '#markup' => t('You are attending.'), + ); + return $form; +} + +/** + * Event cancel attendance form submit handler. + */ +function commons_events_cancel_event_form_submit($form, $form_state) { + global $user; + $event = $form_state['event']; + $query = new EntityFieldQuery(); + $query->entityCondition('entity_type', 'registration') + ->propertyCondition('user_uid', $user->uid) + ->propertyCondition('entity_id', $event->nid) + ->propertyCondition('entity_type', 'node'); + $result = $query->execute(); + if (isset($result['registration'])) { + registration_delete_multiple(array_keys($result['registration'])); + drupal_set_message(t('Your registration has been cancelled.')); + } +} diff --git a/modules/commons/commons_events/includes/commons_events.theme.inc b/modules/commons/commons_events/includes/commons_events.theme.inc new file mode 100644 index 0000000..22a52b8 --- /dev/null +++ b/modules/commons/commons_events/includes/commons_events.theme.inc @@ -0,0 +1,55 @@ +create(array( + 'entity_type' => 'node', + 'entity_id' => $event->nid, + 'type' => $registration_type, + 'author_uid' => $user->uid, + )); + + if (!function_exists('commons_events_attend_event_form') + || !function_exists('commons_events_cancel_event_form')) { + module_load_include('inc', 'commons_events', 'includes/commons_events.forms'); + } + if (!registration_is_registered($registration, NULL, $user->uid) + && registration_access('create', $registration, $user, $registration->type) + && registration_status('node', $event->nid, TRUE)) { + return drupal_get_form('commons_events_attend_event_form_' . $event->nid, $event, $registration, $attendee_count); + } + else if (registration_is_registered($registration, NULL, $user->uid) && + registration_access('delete', $registration, $user, $registration->type)) { + return drupal_get_form('commons_events_cancel_event_form_' . $event->nid, $event); + } + return ""; +} + +/** + * Theme the event attendees list. + */ +function theme_commons_events_event_attendees($variables = array()) { + $title = '

' . t('Attendees') . '

'; + $event_nid = $variables['event_nid']; + if (!isset($variables['display']) + || $variables['display'] != 'full') { + return $title . views_embed_view('commons_events_event_attendee_list', 'default', $event_nid) + . '

' + . t('See all attendees') . '

'; + } + return $title . views_embed_view( + 'commons_events_event_attendee_list', + 'commons_events_full_attendee_list', + $event_nid); +} diff --git a/modules/commons/commons_events/js/commons_events.js b/modules/commons/commons_events/js/commons_events.js new file mode 100644 index 0000000..ba0ae77 --- /dev/null +++ b/modules/commons/commons_events/js/commons_events.js @@ -0,0 +1,18 @@ +(function ($) { + Drupal.behaviors.commons_events_update_registration_settings_legend = { + attach: function (context, settings) { + $(':input[name^="field_registration_type"]').change(function() { + $("[id^='edit-event-registration-settings'] .summary").text($(':input[name^="field_registration_type"] :selected').text()); + if ($(':input[name^="field_registration_type"]').val() == 'external') { + $(':input[name^="field_status"]').val('0').change(); + } + }); + $(':input[name^="field_status"]').change(function() { + var cur = $(':input[name^="field_registration_type"] :selected').text(); + $("[id^='edit-event-registration-settings'] .summary").text(cur + ', ' + $(':input[name="field_status"] :selected').text()); + }); + $(':input[name^="field_registration_type"]').change(); + $(':input[name^="field_status"]').change(); + } + }; +})(jQuery); diff --git a/modules/commons/commons_events/modules/commons_events_pages/commons_events_pages.features.inc b/modules/commons/commons_events/modules/commons_events_pages/commons_events_pages.features.inc new file mode 100644 index 0000000..ccd853e --- /dev/null +++ b/modules/commons/commons_events/modules/commons_events_pages/commons_events_pages.features.inc @@ -0,0 +1,17 @@ + "1"); + } + if ($module == "strongarm" && $api == "strongarm") { + return array("version" => "1"); + } +} diff --git a/modules/commons/commons_events/modules/commons_events_pages/commons_events_pages.info b/modules/commons/commons_events/modules/commons_events_pages/commons_events_pages.info new file mode 100644 index 0000000..d2db9b5 --- /dev/null +++ b/modules/commons/commons_events/modules/commons_events_pages/commons_events_pages.info @@ -0,0 +1,14 @@ +name = Commons Events Pages +description = Provides the panelized Event page feature. +core = 7.x +package = Commons - Landing pages +dependencies[] = commons_events +dependencies[] = panelizer +dependencies[] = strongarm +features[ctools][] = panelizer:panelizer:1 +features[ctools][] = strongarm:strongarm:1 +features[features_api][] = api:2 +features[panelizer_defaults][] = node:event:default +features[variable][] = panelizer_defaults_node_event +files[] = commons_events_pages.features.inc +files[] = commons_events_pages.strongarm.inc diff --git a/modules/commons/commons_events/modules/commons_events_pages/commons_events_pages.install b/modules/commons/commons_events/modules/commons_events_pages/commons_events_pages.install new file mode 100644 index 0000000..804bf68 --- /dev/null +++ b/modules/commons/commons_events/modules/commons_events_pages/commons_events_pages.install @@ -0,0 +1,9 @@ + array('page_manager_pages'))); + return array(); +} diff --git a/modules/commons/commons_events/modules/commons_events_pages/commons_events_pages.module b/modules/commons/commons_events/modules/commons_events_pages/commons_events_pages.module new file mode 100644 index 0000000..41e7844 --- /dev/null +++ b/modules/commons/commons_events/modules/commons_events_pages/commons_events_pages.module @@ -0,0 +1,7 @@ +disabled = FALSE; /* Edit this to true to make a default panelizer disabled initially */ + $panelizer->api_version = 1; + $panelizer->name = 'node:event:default'; + $panelizer->title = 'Default'; + $panelizer->panelizer_type = 'node'; + $panelizer->panelizer_key = 'event'; + $panelizer->no_blocks = FALSE; + $panelizer->css_id = ''; + $panelizer->css = ''; + $panelizer->pipeline = 'ipe'; + $panelizer->contexts = array(); + $panelizer->relationships = array(); + $panelizer->access = array(); + $panelizer->view_mode = 'page_manager'; + $panelizer->css_class = ''; + $panelizer->title_element = 'H2'; + $panelizer->link_to_entity = TRUE; + $panelizer->extra = array(); + $display = new panels_display(); + $display->layout = 'two_66_33'; + $display->layout_settings = array(); + $display->panel_settings = array( + 'style_settings' => array( + 'default' => NULL, + 'two_66_33_top' => NULL, + 'two_66_33_first' => NULL, + 'two_66_33_second' => NULL, + 'two_66_33_bottom' => NULL, + ), + ); + $display->cache = array(); + $display->title = '%node:title'; + $display->uuid = '0d63be4d-5605-1644-fd5c-3872c8b1d8b6'; + $display->content = array(); + $display->panels = array(); + $pane = new stdClass(); + $pane->pid = 'new-f259289a-8ef0-6aa4-2592-c59928474958'; + $pane->panel = 'two_66_33_first'; + $pane->type = 'node_content'; + $pane->subtype = 'node_content'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'links' => 1, + 'no_extras' => 0, + 'override_title' => 0, + 'override_title_text' => '', + 'identifier' => '', + 'link' => 0, + 'leave_node_title' => 1, + 'build_mode' => 'full', + 'context' => 'panelizer', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = 'f259289a-8ef0-6aa4-2592-c59928474958'; + $display->content['new-f259289a-8ef0-6aa4-2592-c59928474958'] = $pane; + $display->panels['two_66_33_first'][0] = 'new-f259289a-8ef0-6aa4-2592-c59928474958'; + $pane = new stdClass(); + $pane->pid = 'new-a2912068-e5e2-c804-b1ba-3260dc059c9b'; + $pane->panel = 'two_66_33_second'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_events_organizers-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'context' => array( + 0 => 'panelizer', + ), + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = 'a2912068-e5e2-c804-b1ba-3260dc059c9b'; + $display->content['new-a2912068-e5e2-c804-b1ba-3260dc059c9b'] = $pane; + $display->panels['two_66_33_second'][0] = 'new-a2912068-e5e2-c804-b1ba-3260dc059c9b'; + $pane = new stdClass(); + $pane->pid = 'new-aef85835-68a5-2494-b107-136f1cb92749'; + $pane->panel = 'two_66_33_second'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_events_event_attendee_list-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'use_pager' => 1, + 'pager_id' => '0', + 'items_per_page' => '20', + 'offset' => '0', + 'context' => array( + 0 => 'panelizer', + ), + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 1; + $pane->locks = array(); + $pane->uuid = 'aef85835-68a5-2494-b107-136f1cb92749'; + $display->content['new-aef85835-68a5-2494-b107-136f1cb92749'] = $pane; + $display->panels['two_66_33_second'][1] = 'new-aef85835-68a5-2494-b107-136f1cb92749'; + $display->hide_title = PANELS_TITLE_NONE; + $display->title_pane = '0'; + $panelizer->display = $display; + $export['node:event:default'] = $panelizer; + + return $export; +} diff --git a/modules/commons/commons_events/modules/commons_events_pages/commons_events_pages.strongarm.inc b/modules/commons/commons_events/modules/commons_events_pages/commons_events_pages.strongarm.inc new file mode 100644 index 0000000..d09ae51 --- /dev/null +++ b/modules/commons/commons_events/modules/commons_events_pages/commons_events_pages.strongarm.inc @@ -0,0 +1,40 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'panelizer_defaults_node_event'; + $strongarm->value = array( + 'status' => 1, + 'view modes' => array( + 'page_manager' => array( + 'status' => 1, + 'default' => 1, + 'choice' => 0, + ), + 'default' => array( + 'status' => 0, + 'default' => 0, + 'choice' => 0, + ), + 'teaser' => array( + 'status' => 0, + 'default' => 0, + 'choice' => 0, + ), + ), + ); + $export['panelizer_defaults_node_event'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.apachesolr_search_defaults.inc b/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.apachesolr_search_defaults.inc new file mode 100644 index 0000000..877d502 --- /dev/null +++ b/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.apachesolr_search_defaults.inc @@ -0,0 +1,37 @@ +disabled = FALSE; /* Edit this to true to make a default searcher disabled initially */ + $searcher->api_version = 3; + $searcher->page_id = 'solr_events'; + $searcher->label = 'Solr Events'; + $searcher->description = ''; + $searcher->search_path = 'events'; + $searcher->page_title = 'Events'; + $searcher->env_id = apachesolr_default_environment(); + $searcher->settings = array( + 'fq' => array( + 0 => 'bundle:event', + ), + 'apachesolr_search_custom_enable' => 1, + 'apachesolr_search_search_type' => 'custom', + 'apachesolr_search_search_box' => 0, + 'apachesolr_search_per_page' => '10', + 'apachesolr_search_browse' => 'results', + 'apachesolr_search_spellcheck' => 0, + 'apachesolr_search_allow_user_input' => 0, + ); + $export['solr_events'] = $searcher; + + return $export; +} diff --git a/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.features.inc b/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.features.inc new file mode 100644 index 0000000..92e5042 --- /dev/null +++ b/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.features.inc @@ -0,0 +1,26 @@ + "3"); + } + if ($module == "facetapi" && $api == "facetapi_defaults") { + return array("version" => "1"); + } + if ($module == "page_manager" && $api == "pages_default") { + return array("version" => "1"); + } + if ($module == "pm_existing_pages" && $api == "pm_existing_pages") { + return array("version" => "1"); + } + if ($module == "strongarm" && $api == "strongarm") { + return array("version" => "1"); + } +} diff --git a/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.info b/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.info new file mode 100644 index 0000000..4cc30fb --- /dev/null +++ b/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.info @@ -0,0 +1,21 @@ +name = Commons Events - Solr +description = Provides the Solr based faceted search for events +core = 7.x +package = Commons - Search +dependencies[] = apachesolr_search +dependencies[] = commons_events +dependencies[] = ctools +dependencies[] = facetapi +dependencies[] = page_manager +dependencies[] = pm_existing_pages +dependencies[] = strongarm +features[apachesolr_search_page][] = solr_events +features[ctools][] = apachesolr_search:apachesolr_search_defaults:3 +features[ctools][] = facetapi:facetapi_defaults:1 +features[ctools][] = page_manager:pages_default:1 +features[ctools][] = pm_existing_pages:pm_existing_pages:1 +features[ctools][] = strongarm:strongarm:1 +features[features_api][] = api:2 +features[page_manager_existing_pages][] = solr_events_search +features[page_manager_handlers][] = pm_existing_pages_solr_events_search_panel_context +features[variable][] = pm_existing_pages_disabled_solr_events_search diff --git a/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.install b/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.install new file mode 100644 index 0000000..3b84af9 --- /dev/null +++ b/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.install @@ -0,0 +1,43 @@ +fields(array('weight' => 5)) + ->condition('name', 'commons_events_solr') + ->execute(); +} + +/** + * Implements hook_enable(). + */ +function commons_events_solr_enable() { + module_load_include('inc', 'page_manager', 'plugins/tasks/page'); + $page = page_manager_page_load('views_events_landing_page'); + ctools_include('export'); + ctools_export_set_object_status($page, TRUE); + // Revert base Events feature so that the Events menu link is recreated. + features_revert(array('commons_events' => array('menu_links'))); + menu_cache_clear_all(); +} + +/** + * Implements hook_disable(). + */ +function commons_events_solr_disable() { + module_load_include('inc', 'page_manager', 'plugins/tasks/page'); + $page = page_manager_page_load('views_events_landing_page'); + ctools_include('export'); + ctools_export_set_object_status($page, FALSE); + // Revert base Events feature so that the Events menu link is recreated. + features_revert(array('commons_events' => array('menu_links'))); + menu_cache_clear_all(); +} diff --git a/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.module b/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.module new file mode 100644 index 0000000..48f0fe3 --- /dev/null +++ b/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.module @@ -0,0 +1,288 @@ +key(array('name' => $facet['name'])) + ->fields($facet) + ->execute(); + } +} + +/** + * Base facet definitions. + */ +function commons_events_solr_facet_definitions() { + $facets = array(); + + $facets[] = array( + 'name' => '::dm_field_date', + 'searcher' => commons_events_solr_search_environment(), + 'realm' => '', + 'facet' => 'dm_field_date', + 'enabled' => 1, + 'settings' => array( + 'operator' => 'and', + 'hard_limit' => '50', + 'dependencies' => array( + 'roles' => array(), + ), + 'facet_mincount' => 1, + 'facet_missing' => 0, + 'flatten' => 0, + 'query_type' => 'date_range', + ), + ); + $facets[] = array( + 'name' => ':block:dm_field_date', + 'searcher' => commons_events_solr_search_environment(), + 'realm' => 'block', + 'facet' => 'dm_field_date', + 'enabled' => 1, + 'settings' => array( + 'weight' => 0, + 'widget' => 'date_range', + 'filters' => array(), + 'active_sorts' => array( + 'active' => 'active', + 'indexed' => 'indexed', + 'count' => 0, + 'display' => 0, + ), + 'sort_weight' => array( + 'active' => -50, + 'indexed' => -49, + 'count' => 0, + 'display' => 0, + ), + 'sort_order' => array( + 'active' => 3, + 'indexed' => 4, + 'count' => 4, + 'display' => 4, + ), + 'empty_behavior' => 'none', + 'soft_limit' => 20, + 'nofollow' => 1, + 'show_expanded' => 0, + 'empty_text' => array( + 'value' => '', + 'format' => 'filtered_html', + ), + ), + ); + $facets[] = array( + 'name' => ':block:sm_field_location', + 'searcher' => commons_events_solr_search_environment(), + 'realm' => 'block', + 'facet' => 'sm_field_location', + 'enabled' => 1, + 'settings' => array( + 'weight' => 0, + 'widget' => 'facetapi_links', + 'filters' => array(), + 'active_sorts' => array( + 'active' => 'active', + 'count' => 'count', + 'display' => 'display', + ), + 'sort_weight' => array( + 'active' => -50, + 'count' => -49, + 'display' => -48, + ), + 'sort_order' => array( + 'active' => 3, + 'count' => 3, + 'display' => 4, + ), + 'empty_behavior' => 'none', + 'soft_limit' => 20, + 'nofollow' => 1, + 'show_expanded' => 0, + ), + ); + $facets[] = array( + 'name' => ':block:im_field_topics', + 'searcher' => commons_events_solr_search_environment(), + 'realm' => 'block', + 'facet' => 'im_field_topics', + 'enabled' => 1, + 'settings' => array( + 'weight' => 0, + 'widget' => 'facetapi_links', + 'filters' => array(), + 'active_sorts' => array( + 'active' => 'active', + 'count' => 'count', + 'display' => 'display', + 'indexed' => 0, + ), + 'sort_weight' => array( + 'active' => -50, + 'count' => -49, + 'display' => -48, + 'indexed' => 0, + ), + 'sort_order' => array( + 'active' => 3, + 'count' => 3, + 'display' => 4, + 'indexed' => 4, + ), + 'empty_behavior' => 'text', + 'soft_limit' => 20, + 'nofollow' => 1, + 'show_expanded' => 0, + 'empty_text' => array( + 'value' => 'None available', + 'format' => 'filtered_html', + ), + ), + ); + $facets[] = array( + 'name' => '::im_field_topics', + 'searcher' => commons_events_solr_search_environment(), + 'realm' => '', + 'facet' => 'im_field_topics', + 'enabled' => 0, + 'settings' => array( + 'operator' => 'and', + 'hard_limit' => 50, + 'dependencies' => array( + 'roles' => array(), + ), + 'facet_mintcount' => 1, + 'facet_missing' => 0, + 'flatten' => 0, + 'query_type' => 'term', + ), + ); + $facets[] = array( + 'name' => ':block:sm_og_group_ref', + 'searcher' => commons_search_solr_search_environment(), + 'realm' => 'block', + 'facet' => 'sm_og_group_ref', + 'enabled' => 1, + 'settings' => array( + 'weight' => 0, + 'widget' => 'facetapi_links', + 'filters' => array(), + 'active_sorts' => array( + 'active' => 'active', + 'count' => 'count', + 'display' => 'display', + ), + 'sort_weight' => array( + 'active' => -50, + 'count' => -49, + 'display' => -48, + ), + 'sort_order' => array( + 'active' => 3, + 'count' => 3, + 'display' => 4, + ), + 'empty_behavior' => 'none', + 'soft_limit' => 20, + 'nofollow' => 1, + 'show_expanded' => 0, + ), + ); + + return $facets; +} + +/** + * Get the panels subtype for the facet block. + */ +function commons_events_solr_panel_facet_subtype($facet_name) { + $facet_name = commons_events_solr_search_environment() . ':block:' . $facet_name; + return 'facetapi-' . facetapi_hash_delta($facet_name); +} + +/** + * Implements hook_theme_registry_alter(). + */ +function commons_events_solr_theme_registry_alter(&$registry) { + $registry['apachesolr_search_noresults']['function'] = 'commons_events_solr_apachesolr_search_noresults'; +} + +/** + * Implements hook_preprocess_hook(). + */ +function commons_events_solr_process_search_results(&$variables) { + if ($variables['search_page']['page_id'] == 'solr_events') { + $variables['title'] = format_plural(count($variables['results']), '1 event', '@count events'); + } +} + +/** + * Implements hook_form_alter(). + */ +function commons_events_solr_form_apachesolr_environment_edit_form_alter(&$form, &$form_state) { + $form['actions']['save']['#submit'][] = 'commons_events_solr_environment_form_submit'; +} + +/** + * Friendlier empty text when there are no events. + */ +function commons_events_solr_apachesolr_search_noresults() { + $destination = drupal_get_destination(); + if ($destination['destination'] != 'events') { + // Have to call the actual function since we overrode it to use the current + // function instead. + return theme_apachesolr_search_noresults(); + } + $options = array('!create' => 'create one'); + if (node_access('create', 'event')) { + $options['!create'] = l('create one', 'node/add/event'); + } + return t('There are no events. Be the first to !create!', $options); +} + +/** + * When the environment changes, create facets for that environment. + */ +function commons_events_solr_environment_form_submit($form, $form_state) { + if ($form_state['values']['make_default'] == 1) { + commons_events_solr_create_facets('apachesolr@' . $form_state['build_info']['args']['0']['env_id']); + // Need to clear caches so we can rebuild block definitions. + cache_clear_all('*', 'cache_block', TRUE); + cache_clear_all('*', 'cache_apachesolr', TRUE); + } +} + +/** + * Implements hook_node_presave to display a message warning the user that results won't occur immediately + */ +function commons_events_solr_node_presave($node) { + if ($node->type == 'event') { + drupal_set_message(t('Your event may take a few minutes to appear on the listing page.')); + } +} \ No newline at end of file diff --git a/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.pages_default.inc b/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.pages_default.inc new file mode 100644 index 0000000..3eacc22 --- /dev/null +++ b/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.pages_default.inc @@ -0,0 +1,271 @@ +disabled = FALSE; /* Edit this to true to make a default handler disabled initially */ + $handler->api_version = 1; + $handler->name = 'pm_existing_pages_solr_events_search_panel_context'; + $handler->task = 'pm_existing_pages'; + $handler->subtask = 'solr_events_search'; + $handler->handler = 'panel_context'; + $handler->weight = 0; + $handler->conf = array( + 'title' => 'Event Search', + 'no_blocks' => 0, + 'pipeline' => 'standard', + 'body_classes_to_remove' => '', + 'body_classes_to_add' => '', + 'css_id' => '', + 'css' => '', + 'contexts' => array(), + 'relationships' => array(), + ); + $display = new panels_display(); + $display->layout = 'three_25_50_25'; + $display->layout_settings = array(); + $display->panel_settings = array( + 'style_settings' => array( + 'default' => NULL, + 'three_25_50_25_top' => NULL, + 'three_25_50_25_first' => NULL, + 'three_25_50_25_second' => NULL, + 'three_25_50_25_third' => NULL, + 'three_25_50_25_bottom' => NULL, + ), + ); + $display->cache = array(); + $display->title = ''; + $display->uuid = 'bf4f354a-dc68-cab4-a139-49e172b1c4ed'; + $display->content = array(); + $display->panels = array(); + $pane = new stdClass(); + $pane->pid = 'new-2edbeade-1d05-fbd4-f526-68239a54433f'; + $pane->panel = 'three_25_50_25_first'; + $pane->type = 'block'; + $pane->subtype = commons_events_solr_panel_facet_subtype('sm_field_location'); + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 1, + 'override_title_text' => 'Attendance', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = '2edbeade-1d05-fbd4-f526-68239a54433f'; + $display->content['new-2edbeade-1d05-fbd4-f526-68239a54433f'] = $pane; + $display->panels['three_25_50_25_first'][0] = 'new-2edbeade-1d05-fbd4-f526-68239a54433f'; + $pane = new stdClass(); + $pane->pid = 'new-06093184-ccdb-9a84-1da8-e9f2dff0d882'; + $pane->panel = 'three_25_50_25_first'; + $pane->type = 'block'; + $pane->subtype = commons_events_solr_panel_facet_subtype('dm_field_date'); + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 1, + 'override_title_text' => 'Date', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 1; + $pane->locks = array(); + $pane->uuid = '06093184-ccdb-9a84-1da8-e9f2dff0d882'; + $display->content['new-06093184-ccdb-9a84-1da8-e9f2dff0d882'] = $pane; + $display->panels['three_25_50_25_first'][1] = 'new-06093184-ccdb-9a84-1da8-e9f2dff0d882'; + $pane = new stdClass(); + $pane->pid = 'new-c84b8b32-c6d5-9ce4-bdec-f2735c5045b8'; + $pane->panel = 'three_25_50_25_first'; + $pane->type = 'block'; + $pane->subtype = commons_events_solr_panel_facet_subtype('im_field_topics'); + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 1, + 'override_title_text' => 'Topic', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 2; + $pane->locks = array(); + $pane->uuid = 'c84b8b32-c6d5-9ce4-bdec-f2735c5045b8'; + $display->content['new-c84b8b32-c6d5-9ce4-bdec-f2735c5045b8'] = $pane; + $display->panels['three_25_50_25_first'][2] = 'new-c84b8b32-c6d5-9ce4-bdec-f2735c5045b8'; + $pane = new stdClass(); + $pane->pid = 'new-c46f0562-0218-76c4-b969-3abdc98f24fa'; + $pane->panel = 'three_25_50_25_first'; + $pane->type = 'block'; + $pane->subtype = commons_events_solr_panel_facet_subtype('sm_og_group_ref'); + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 1, + 'override_title_text' => 'Group', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 3; + $pane->locks = array(); + $pane->uuid = 'c46f0562-0218-76c4-b969-3abdc98f24fa'; + $display->content['new-c46f0562-0218-76c4-b969-3abdc98f24fa'] = $pane; + $display->panels['three_25_50_25_first'][3] = 'new-c46f0562-0218-76c4-b969-3abdc98f24fa'; + $pane = new stdClass(); + $pane->pid = 'new-ba67e9d1-00ed-07b4-49df-bff421094214'; + $pane->panel = 'three_25_50_25_second'; + $pane->type = 'pm_existing_pages'; + $pane->subtype = 'pm_existing_pages'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 0 => 'task_id', + 1 => 'pane_title_from_menu', + 'task_id' => 'solr_events_search', + 'pane_title_from_menu' => 0, + 'override_title' => 1, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = 'ba67e9d1-00ed-07b4-49df-bff421094214'; + $display->content['new-ba67e9d1-00ed-07b4-49df-bff421094214'] = $pane; + $display->panels['three_25_50_25_second'][0] = 'new-ba67e9d1-00ed-07b4-49df-bff421094214'; + $pane = new stdClass(); + $pane->pid = 'new-f5cb9927-def5-8f94-098b-ca9d83eaf9fa'; + $pane->panel = 'three_25_50_25_third'; + $pane->type = 'block'; + $pane->subtype = 'commons_events-commons_events_create_event_link'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 0, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = 'f5cb9927-def5-8f94-098b-ca9d83eaf9fa'; + $display->content['new-f5cb9927-def5-8f94-098b-ca9d83eaf9fa'] = $pane; + $display->panels['three_25_50_25_third'][0] = 'new-f5cb9927-def5-8f94-098b-ca9d83eaf9fa'; + $pane = new stdClass(); + $pane->pid = 'new-a9b484b9-8f95-46e4-d930-64dc3d093f3d'; + $pane->panel = 'three_25_50_25_third'; + $pane->type = 'block'; + $pane->subtype = 'commons_events-commons_events_anonymous_login'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 0, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 1; + $pane->locks = array(); + $pane->uuid = 'a9b484b9-8f95-46e4-d930-64dc3d093f3d'; + $display->content['new-a9b484b9-8f95-46e4-d930-64dc3d093f3d'] = $pane; + $display->panels['three_25_50_25_third'][1] = 'new-a9b484b9-8f95-46e4-d930-64dc3d093f3d'; + $pane = new stdClass(); + $pane->pid = 'new-ae313741-a577-f194-9dd7-868986d44baf'; + $pane->panel = 'three_25_50_25_third'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_events_user_upcoming_events-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 2; + $pane->locks = array(); + $pane->uuid = 'ae313741-a577-f194-9dd7-868986d44baf'; + $display->content['new-ae313741-a577-f194-9dd7-868986d44baf'] = $pane; + $display->panels['three_25_50_25_third'][2] = 'new-ae313741-a577-f194-9dd7-868986d44baf'; + $pane = new stdClass(); + $pane->pid = 'new-6c32c82b-82f2-97f4-55b1-bc38ddc2e4b6'; + $pane->panel = 'three_25_50_25_third'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_events_user_upcoming_events-panel_pane_2'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 3; + $pane->locks = array(); + $pane->uuid = '6c32c82b-82f2-97f4-55b1-bc38ddc2e4b6'; + $display->content['new-6c32c82b-82f2-97f4-55b1-bc38ddc2e4b6'] = $pane; + $display->panels['three_25_50_25_third'][3] = 'new-6c32c82b-82f2-97f4-55b1-bc38ddc2e4b6'; + $pane = new stdClass(); + $pane->pid = 'new-0e2c9d7d-abfe-e314-9dba-e9c8dae6fc74'; + $pane->panel = 'three_25_50_25_third'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_events_user_upcoming_events-panel_pane_3'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 4; + $pane->locks = array(); + $pane->uuid = '0e2c9d7d-abfe-e314-9dba-e9c8dae6fc74'; + $display->content['new-0e2c9d7d-abfe-e314-9dba-e9c8dae6fc74'] = $pane; + $display->panels['three_25_50_25_third'][4] = 'new-0e2c9d7d-abfe-e314-9dba-e9c8dae6fc74'; + $display->hide_title = PANELS_TITLE_NONE; + $display->title_pane = 'new-ba67e9d1-00ed-07b4-49df-bff421094214'; + $handler->conf['display'] = $display; + $export['pm_existing_pages_solr_events_search_panel_context'] = $handler; + + return $export; +} diff --git a/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.pm_existing_pages.inc b/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.pm_existing_pages.inc new file mode 100644 index 0000000..977ba04 --- /dev/null +++ b/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.pm_existing_pages.inc @@ -0,0 +1,22 @@ +api_version = 1; + $pm_existing_page->name = 'solr_events_search'; + $pm_existing_page->label = 'Solr Events Search'; + $pm_existing_page->context = ''; + $pm_existing_page->paths = 'events'; + $export['solr_events_search'] = $pm_existing_page; + + return $export; +} diff --git a/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.strongarm.inc b/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.strongarm.inc new file mode 100644 index 0000000..ec6ebe5 --- /dev/null +++ b/modules/commons/commons_events/modules/commons_events_solr/commons_events_solr.strongarm.inc @@ -0,0 +1,21 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'pm_existing_pages_disabled_solr_events_search'; + $strongarm->value = FALSE; + $export['pm_existing_pages_disabled_solr_events_search'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_events/profile_empty.png b/modules/commons/commons_events/profile_empty.png new file mode 100644 index 0000000..32402e6 Binary files /dev/null and b/modules/commons/commons_events/profile_empty.png differ diff --git a/modules/commons/commons_featured/commons_featured.features.inc b/modules/commons/commons_featured/commons_featured.features.inc new file mode 100644 index 0000000..5c9f7a8 --- /dev/null +++ b/modules/commons/commons_featured/commons_featured.features.inc @@ -0,0 +1,12 @@ + "3.0"); +} diff --git a/modules/commons/commons_featured/commons_featured.info b/modules/commons/commons_featured/commons_featured.info new file mode 100644 index 0000000..5edbd0e --- /dev/null +++ b/modules/commons/commons_featured/commons_featured.info @@ -0,0 +1,9 @@ +name = Commons Featured Content +description = Allows community managers to display certain pieces of content more prominently on the site. +core = 7.x +package = Commons - Building blocks +dependencies[] = views +dependencies[] = views_content +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[views_view][] = commons_featured diff --git a/modules/commons/commons_featured/commons_featured.module b/modules/commons/commons_featured/commons_featured.module new file mode 100644 index 0000000..ba68f13 --- /dev/null +++ b/modules/commons/commons_featured/commons_featured.module @@ -0,0 +1,17 @@ +name = 'commons_featured'; + $view->description = 'Display featured content on the site.'; + $view->tag = 'commons_featured'; + $view->base_table = 'node'; + $view->human_name = 'Commons Featured Content'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Featured on this site'; + $handler->display->display_options['use_more'] = TRUE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['pager']['options']['items_per_page'] = '3'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'node'; + /* Field: Content: Type */ + $handler->display->display_options['fields']['type']['id'] = 'type'; + $handler->display->display_options['fields']['type']['table'] = 'node'; + $handler->display->display_options['fields']['type']['field'] = 'type'; + $handler->display->display_options['fields']['type']['label'] = ''; + $handler->display->display_options['fields']['type']['exclude'] = TRUE; + $handler->display->display_options['fields']['type']['element_label_colon'] = FALSE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + $handler->display->display_options['fields']['title']['element_class'] = 'type-[type]'; + $handler->display->display_options['fields']['title']['element_label_colon'] = FALSE; + /* Field: Content: Date */ + $handler->display->display_options['fields']['field_date']['id'] = 'field_date'; + $handler->display->display_options['fields']['field_date']['table'] = 'field_data_field_date'; + $handler->display->display_options['fields']['field_date']['field'] = 'field_date'; + $handler->display->display_options['fields']['field_date']['label'] = ''; + $handler->display->display_options['fields']['field_date']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['field_date']['hide_empty'] = TRUE; + $handler->display->display_options['fields']['field_date']['settings'] = array( + 'format_type' => 'short', + 'fromto' => 'both', + 'multiple_number' => '', + 'multiple_from' => '', + 'multiple_to' => '', + ); + /* Field: Content: Address */ + $handler->display->display_options['fields']['field_address']['id'] = 'field_address'; + $handler->display->display_options['fields']['field_address']['table'] = 'field_data_field_address'; + $handler->display->display_options['fields']['field_address']['field'] = 'field_address'; + $handler->display->display_options['fields']['field_address']['label'] = ''; + $handler->display->display_options['fields']['field_address']['alter']['alter_text'] = TRUE; + $handler->display->display_options['fields']['field_address']['alter']['text'] = '[field_address-locality], [field_address-administrative_area]'; + $handler->display->display_options['fields']['field_address']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['field_address']['hide_empty'] = TRUE; + $handler->display->display_options['fields']['field_address']['hide_alter_empty'] = FALSE; + $handler->display->display_options['fields']['field_address']['click_sort_column'] = 'country'; + $handler->display->display_options['fields']['field_address']['settings'] = array( + 'use_widget_handlers' => 1, + 'format_handlers' => array( + 'address' => 'address', + ), + ); + /* Field: Registration Settings: Spaces used */ + $handler->display->display_options['fields']['capacity_used']['id'] = 'capacity_used'; + $handler->display->display_options['fields']['capacity_used']['table'] = 'node'; + $handler->display->display_options['fields']['capacity_used']['field'] = 'capacity_used'; + $handler->display->display_options['fields']['capacity_used']['label'] = ''; + $handler->display->display_options['fields']['capacity_used']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['capacity_used']['hide_empty'] = TRUE; + $handler->display->display_options['fields']['capacity_used']['empty_zero'] = TRUE; + $handler->display->display_options['fields']['capacity_used']['format_plural'] = TRUE; + $handler->display->display_options['fields']['capacity_used']['format_plural_singular'] = '@count attendee'; + $handler->display->display_options['fields']['capacity_used']['format_plural_plural'] = '@count attendees'; + /* Field: Content: Comment count */ + $handler->display->display_options['fields']['comment_count']['id'] = 'comment_count'; + $handler->display->display_options['fields']['comment_count']['table'] = 'node_comment_statistics'; + $handler->display->display_options['fields']['comment_count']['field'] = 'comment_count'; + $handler->display->display_options['fields']['comment_count']['label'] = ''; + $handler->display->display_options['fields']['comment_count']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['comment_count']['hide_empty'] = TRUE; + $handler->display->display_options['fields']['comment_count']['format_plural'] = TRUE; + $handler->display->display_options['fields']['comment_count']['format_plural_singular'] = '@count comment'; + $handler->display->display_options['fields']['comment_count']['format_plural_plural'] = '@count comments'; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = '1'; + /* Filter criterion: Content: Promoted to front page */ + $handler->display->display_options['filters']['promote']['id'] = 'promote'; + $handler->display->display_options['filters']['promote']['table'] = 'node'; + $handler->display->display_options['filters']['promote']['field'] = 'promote'; + $handler->display->display_options['filters']['promote']['value'] = '1'; + + /* Display: Page */ + $handler = $view->new_display('page', 'Page', 'commons_home_featured_page'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['defaults']['pager'] = FALSE; + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['pager']['options']['items_per_page'] = '15'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['defaults']['style_plugin'] = FALSE; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['defaults']['style_options'] = FALSE; + $handler->display->display_options['defaults']['row_plugin'] = FALSE; + $handler->display->display_options['row_plugin'] = 'node'; + $handler->display->display_options['defaults']['row_options'] = FALSE; + $handler->display->display_options['path'] = 'featured'; + $handler->display->display_options['menu']['title'] = 'Events'; + $handler->display->display_options['menu']['weight'] = '0'; + $handler->display->display_options['menu']['name'] = 'main-menu'; + $handler->display->display_options['menu']['context'] = 0; + + /* Display: Feed */ + $handler = $view->new_display('feed', 'Feed', 'commons_home_featured_feed'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['style_plugin'] = 'rss'; + $handler->display->display_options['row_plugin'] = 'node_rss'; + $handler->display->display_options['path'] = 'featured.xml'; + $handler->display->display_options['displays'] = array( + 'default' => 'default', + 'page' => 'page', + ); + $handler->display->display_options['sitename_title'] = 1; + + /* Display: Featured content */ + $handler = $view->new_display('panel_pane', 'Featured content', 'panel_pane_1'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['defaults']['style_plugin'] = FALSE; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['defaults']['style_options'] = FALSE; + $handler->display->display_options['defaults']['row_plugin'] = FALSE; + $handler->display->display_options['row_plugin'] = 'fields'; + $handler->display->display_options['row_options']['inline'] = array( + 'capacity_used' => 'capacity_used', + 'comment_count' => 'comment_count', + ); + $handler->display->display_options['row_options']['separator'] = ','; + $handler->display->display_options['row_options']['hide_empty'] = TRUE; + $handler->display->display_options['defaults']['row_options'] = FALSE; + $handler->display->display_options['pane_category']['name'] = 'Commons'; + $handler->display->display_options['pane_category']['weight'] = '0'; + $translatables['commons_featured'] = array( + t('Master'), + t('Featured on this site'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('[field_address-locality], [field_address-administrative_area]'), + t('.'), + t(','), + t('Page'), + t('Feed'), + t('Featured content'), + t('Commons'), + ); + $export['commons_featured'] = $view; + + return $export; +} diff --git a/modules/commons/commons_follow/commons-follow-otheruser-flag.tpl.php b/modules/commons/commons_follow/commons-follow-otheruser-flag.tpl.php new file mode 100644 index 0000000..7a028bd --- /dev/null +++ b/modules/commons/commons_follow/commons-follow-otheruser-flag.tpl.php @@ -0,0 +1,3 @@ + + + diff --git a/modules/commons/commons_follow/commons_follow.features.field_base.inc b/modules/commons/commons_follow/commons_follow.features.field_base.inc new file mode 100644 index 0000000..3e58098 --- /dev/null +++ b/modules/commons/commons_follow/commons_follow.features.field_base.inc @@ -0,0 +1,152 @@ + 1, + 'cardinality' => -1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_target_comments', + 'field_permissions' => array( + 'type' => 0, + ), + 'foreign keys' => array( + 'comment' => array( + 'columns' => array( + 'target_id' => 'cid', + ), + 'table' => 'comment', + ), + ), + 'indexes' => array( + 'target_id' => array( + 0 => 'target_id', + ), + ), + 'locked' => 0, + 'module' => 'entityreference', + 'settings' => array( + 'handler' => 'base', + 'handler_settings' => array( + 'behaviors' => array( + 'views-select-list' => array( + 'status' => 0, + ), + ), + 'sort' => array( + 'type' => 'none', + ), + 'target_bundles' => array(), + ), + 'handler_submit' => 'Change handler', + 'target_type' => 'comment', + ), + 'translatable' => 0, + 'type' => 'entityreference', + ); + + // Exported field_base: 'field_target_nodes' + $field_bases['field_target_nodes'] = array( + 'active' => 1, + 'cardinality' => -1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_target_nodes', + 'field_permissions' => array( + 'type' => 0, + ), + 'foreign keys' => array( + 'node' => array( + 'columns' => array( + 'target_id' => 'nid', + ), + 'table' => 'node', + ), + ), + 'indexes' => array( + 'target_id' => array( + 0 => 'target_id', + ), + ), + 'locked' => 0, + 'module' => 'entityreference', + 'settings' => array( + 'handler' => 'base', + 'handler_settings' => array( + 'behaviors' => array( + 'views-select-list' => array( + 'status' => 0, + ), + ), + 'sort' => array( + 'type' => 'none', + ), + 'target_bundles' => array(), + ), + 'handler_submit' => 'Change handler', + 'target_type' => 'node', + ), + 'translatable' => 0, + 'type' => 'entityreference', + ); + + // Exported field_base: 'field_target_users' + $field_bases['field_target_users'] = array( + 'active' => 1, + 'cardinality' => -1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_target_users', + 'field_permissions' => array( + 'type' => 0, + ), + 'foreign keys' => array( + 'users' => array( + 'columns' => array( + 'target_id' => 'uid', + ), + 'table' => 'users', + ), + ), + 'indexes' => array( + 'target_id' => array( + 0 => 'target_id', + ), + ), + 'locked' => 0, + 'module' => 'entityreference', + 'settings' => array( + 'handler' => 'base', + 'handler_settings' => array( + 'behaviors' => array( + 'views-select-list' => array( + 'status' => 0, + ), + ), + 'sort' => array( + 'direction' => 'ASC', + 'field' => 'og_user_group_ref:target_id', + 'property' => 'uid', + 'type' => 'none', + ), + 'target_bundles' => array(), + ), + 'handler_submit' => 'Change handler', + 'target_type' => 'user', + ), + 'translatable' => 0, + 'type' => 'entityreference', + ); + + return $field_bases; +} diff --git a/modules/commons/commons_follow/commons_follow.features.inc b/modules/commons/commons_follow/commons_follow.features.inc new file mode 100644 index 0000000..75926cd --- /dev/null +++ b/modules/commons/commons_follow/commons_follow.features.inc @@ -0,0 +1,46 @@ + "1"); + } +} + +/** + * Implements hook_image_default_styles(). + */ +function commons_follow_image_default_styles() { + $styles = array(); + + // Exported image style: 50x50_avatar. + $styles['50x50_avatar'] = array( + 'label' => '50x50_avatar', + 'name' => '50x50_avatar', + 'effects' => array( + 3 => array( + 'label' => 'Scale and crop', + 'help' => 'Scale and crop will maintain the aspect-ratio of the original image, then crop the larger dimension. This is most useful for creating perfectly square thumbnails without stretching the image.', + 'effect callback' => 'image_scale_and_crop_effect', + 'dimensions callback' => 'image_resize_dimensions', + 'form callback' => 'image_resize_form', + 'summary theme' => 'image_resize_summary', + 'module' => 'image', + 'name' => 'image_scale_and_crop', + 'data' => array( + 'width' => 50, + 'height' => 50, + ), + 'weight' => 1, + ), + ), + ); + + return $styles; +} diff --git a/modules/commons/commons_follow/commons_follow.info b/modules/commons/commons_follow/commons_follow.info new file mode 100644 index 0000000..b76b195 --- /dev/null +++ b/modules/commons/commons_follow/commons_follow.info @@ -0,0 +1,25 @@ +name = Commons Follow +description = Views and Field integration for Commons Following functionality. +core = 7.x +package = Commons - Building blocks +dependencies[] = ctools +dependencies[] = entityreference +dependencies[] = features +dependencies[] = field_sql_storage +dependencies[] = message_subscribe +dependencies[] = strongarm +features[ctools][] = strongarm:strongarm:1 +features[features_api][] = api:2 +features[field_base][] = field_target_comments +features[field_base][] = field_target_nodes +features[field_base][] = field_target_users +features[image][] = 50x50_avatar +features[variable][] = message_subscribe_flag_prefix +features_exclude[dependencies][image] = image +files[] = includes/views/commons_follow.views.inc +files[] = includes/views/handlers/commons_follow_handler_filter_follow.inc +files[] = includes/views/handlers/commons_follow_plugin_argument_default_node.inc +files[] = includes/views/handlers/commons_follow_plugin_argument_default_message.inc +files[] = includes/views/handlers/commons_follow_user_follow_filter.inc +files[] = includes/views/handlers/commons_follow_user_follow_filter_message.inc +files[] = includes/views/handlers/commons_follow_handler_field_ops.inc \ No newline at end of file diff --git a/modules/commons/commons_follow/commons_follow.module b/modules/commons/commons_follow/commons_follow.module new file mode 100644 index 0000000..094e346 --- /dev/null +++ b/modules/commons/commons_follow/commons_follow.module @@ -0,0 +1,326 @@ + array( + 'variables' => array( + 'is_flagged' => NULL, + 'link_text' => NULL, + 'flag_wrapper_classes' => NULL, + 'flag_classes' => NULL, + ), + 'template' => 'commons-follow-otheruser-flag', + ), + ); +} + +/** + * Implements hook_features_pipe_alter(). + * + */ +function commons_follow_features_pipe_alter(&$pipe, $data, $export) { + $commons_follow_fields = array( + 'field_target_users', 'field_target_nodes', 'field_target_comments', + ); + // Prevent Commons Follow fields from being piped in features + // when a content type includes those fields. + if (!empty($pipe['field_instance'])) { + foreach ($pipe['field_instance'] as $delta => $value) { + $args = explode('-', $value); + $field_name = $args[2]; + if (in_array($field_name, $commons_follow_fields)) { + unset($pipe['field_instance'][$delta]); + } + } + } + if (!empty($pipe['field_base'])) { + foreach ($pipe['field_base'] as $delta => $value) { + if (in_array($delta, $commons_follow_fields)) { + unset($pipe['field_base'][$delta]); + } + } + } +} + +/** + * Implements hook_views_default_views_alter(). + * + * Adding the "Following" filter to the group-browsing-widget views. + */ +function commons_follow_views_default_views_alter(&$views) { + // Add a "most active" exposed sort to Commons BW views. + foreach ($views as $view_id => $view) { + if (strpos($view_id, 'commons_bw_') !== 0) { + continue; + } + + $handler = $views[$view_id]->display['default']->handler; + + // Relationship to the "Following" flag. + $handler->display->display_options['relationships']['flag_content_rel']['id'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel']['table'] = 'node'; + $handler->display->display_options['relationships']['flag_content_rel']['field'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel']['ui_name'] = 'Following'; + $handler->display->display_options['relationships']['flag_content_rel']['label'] = 'following'; + $handler->display->display_options['relationships']['flag_content_rel']['required'] = 0; + $handler->display->display_options['relationships']['flag_content_rel']['flag'] = 'commons_follow_node'; + + // Exposed "Following" filter. + $handler->display->display_options['filters']['flagged']['id'] = 'flagged'; + $handler->display->display_options['filters']['flagged']['table'] = 'flag_content'; + $handler->display->display_options['filters']['flagged']['field'] = 'flagged'; + $handler->display->display_options['filters']['flagged']['relationship'] = 'flag_content_rel'; + $handler->display->display_options['filters']['flagged']['ui_name'] = 'Following'; + $handler->display->display_options['filters']['flagged']['value'] = '1'; + $handler->display->display_options['filters']['flagged']['exposed'] = TRUE; + $handler->display->display_options['filters']['flagged']['expose']['operator_id'] = ''; + $handler->display->display_options['filters']['flagged']['expose']['label'] = 'Following'; + $handler->display->display_options['filters']['flagged']['expose']['operator'] = 'flagged_op'; + $handler->display->display_options['filters']['flagged']['expose']['identifier'] = 'following'; + $handler->display->display_options['filters']['flagged']['expose']['required'] = FALSE; + } +} + +/** + * Implements hook_form_alter(). + */ +function commons_follow_form_alter(&$form, &$form_state, $form_id) { + if ($form_id != 'views_exposed_form' || strpos($form['#id'],'views-exposed-form-commons-bw') !== 0 || empty($form['following'])) { + return; + } + + $form['#info']['filter-flagged']['label'] = t('Limited to'); + + $form['following']['#options'] = array( + 'All' => t('All content'), + 1 => t("Content you're following"), + 0 => t("Content you're not following"), + ); +} + +/** + * Implements hook_flag_export_alter(). + */ +function commons_follow_flag_export_alter(&$flag) { + // We export $flag->types as an array in code, then dynamically change + // the values in commons_follow_flag_alter(). Prevent that from being + // overwritten with the dynamic values. + if (in_array($flag['name'], array('commons_follow_node', 'email_node'))) { + $flag['types'] = array(); + } +} + +/** + * Implements hook_flag_alter(). + */ +function commons_follow_flag_alter(&$flag) { + $commons_entity_integrations = commons_entity_integration_info(); + // Find Commons node types that should have follow integration and alter + // the commons_follow_node flag to allow following these node types. + // This is currently hard-coded to node entities and the + // commons_follow_node flag, but could be expanded to add the ability + // to follow other entities. + // The Commons follow flags for user, term and group already have the + // appropriate content types in their flag exports, whereas + // $flag->types for commons_follow_node is more likely + // to change between sites. + if (in_array($flag->name, array('commons_follow_node', 'email_node'))) { + if (!empty($commons_entity_integrations['node'])) { + // Exclude bundles that users should not be able to follow: + foreach ($commons_entity_integrations['node'] as $bundle => $options) { + if (isset($options['exclude_commons_follow']) && $options['exclude_commons_follow'] == TRUE) { + unset($commons_entity_integrations['node'][$bundle]); + } + } + // Add the remaining bundles as flaggable options + if (!empty($commons_entity_integrations['node'])) { + $flag->types += array_keys($commons_entity_integrations['node']); + } + } + } +} + +/** + * Get all node IDs relevant to what the user ordered. + * + * @param $account + * The user being checked. Defaults to the current user. + * @param $options + * Array. Includes options to alter the query. Options available are used + * within the hook implementations. + * + * @return + * Array of node IDs. + */ +function commons_follow_get_nids($account = NULL, $options = array()) { + if (empty($account)) { + global $user; + $account = clone $user; + } + + $nids = array(); + // We don't use module_invoke_all() is we want to retain the array keys, + // which are the user IDs. + foreach (module_implements('commons_follow_get_nids') as $module) { + $function = $module . '_commons_follow_get_nids'; + $result = $function($account, $options); + if (empty($result)) { + continue; + } + foreach ($result as $nid) { + $nids[$nid] = $nid; + } + } + return $nids; +} + + + +/** + * Get subscriptions flag IDs. + * + * @param $content_type + * Optional. The type of content for which to load the flags. Usually 'node'. + * @param $content_subtype + * Optional. The node type for which to load the flags. + * @param $account + * Optional. The user accont to filter available flags. If not set, all + * flags for will this node will be returned. + * @param $reset + * Optional. Reset the internal query cache. + * + * @return $flags + * An array of the structure [fid] = flag_object. + * + * @see flag_get_flags() + */ +function commons_follow_get_subscription_flags_ids($content_type = NULL, $content_subtype = NULL, $account = NULL, $reset = FALSE) { + if (!module_exists('message_subscribe')) { + // Requires message_subscribe module. + return; + } + $flags = message_subscribe_flag_get_flags($content_type, $content_subtype, $account, $reset); + + $flag_ids = array(); + foreach ($flags as $flag) { + $flag_ids[] = $flag->fid; + } + return $flag_ids; +} + +/** + * Implements hook_views_api(). + */ +function commons_follow_views_api() { + return array( + 'api' => 3, + 'path' => drupal_get_path('module', 'commons_follow') . '/includes/views', + ); +} + +/** +* Returns a list of Commons Follow Flag objects. +*/ +function commons_follow_get_flags() { + $flags = flag_get_flags(); + foreach ($flags as $key => $flag) { + if (substr($key, 0, 14) != 'commons_follow') { + unset($flags[$key]); + } + } + return $flags; +} + +/** +* Returns an array of Commons Follow flags keyed on the numeric flag ID. +*/ +function commons_follow_get_flag_ids() { + $flag_ids = array(); + $flags = commons_follow_get_flags(); + foreach ($flags as $key => $flag) { + $flag_ids[$flag->fid] = $key; + } + return $flag_ids; +} + +/** +* Returns a single flag ID based on a flag machine name. +*/ +function commons_follow_get_flag_id($name) { + $flag = flag_get_flag($name); + $return = $flag->fid; + return $flag->fid; +} +/** + * Get a list of all content that a user is following. + * @return + * An array keyed on the flag name with values corresponding to the IDs + * of the flagged entities. + */ +function commons_follow_get_followed_content($account = array()) { + if (empty($account)) { + global $user; + $account = $user; + } + $results = array(); + $flag_ids = commons_follow_get_flag_ids(); + // Get a list of everything that the user is following. + $result = db_query("SELECT fid, content_id FROM {flag_content} WHERE fid IN (:fids) AND uid = :uid", array(':fids' => array_keys($flag_ids), ':uid' => $account->uid)); + foreach ($result as $this_result) { + $results[$flag_ids[$this_result->fid]][] = $this_result->content_id; + } + + return $results; +} + +/** +* Find a list of message IDs that correspond to events that the current user +* is following. +*/ +function commons_follow_get_followed_message_ids($account = NULL) { + $followed_mids = array(); + // Allow the module with this flag namespace to return a list of + // followed MIDs. + $followed_content = commons_follow_get_followed_content($account); + $followed_mids = array(); + foreach ($followed_content as $key => $content) { + $function = $key . '_commons_follow_get_message_ids'; + if (function_exists($function)) { + $function($followed_mids, $followed_content); + } + } + return $followed_mids; +} + +function commons_follow_views_data_alter(&$data) { + $data['flag_content']['ops']['field']['handler'] = 'commons_follow_handler_field_ops'; +} + +function commons_follow_views_query_alter(&$view, &$query) { + // Only act on the notifications page. + if (arg(2) != 'notification-settings') { + return; + } + global $user; + $prefix = variable_get('message_subscribe_flag_prefix', 'subscribe') . '_'; + if(strpos($view->name, $prefix) === 0 && isset($view->args[0]) && $user->uid != $view->args[0]) { + $flag_content_keys = array_keys($query->table_queue); + foreach($flag_content_keys AS $key) { + if(strpos($key, 'flag_content') === 0) { + //Convert the Send Email Query + $join = $query->table_queue[$key]['join']; + $join->extra[1] = array( + 'field' => 'uid', + 'value' => $view->args[0], + 'numeric' => TRUE, + ); + $query->table_queue[$key]['join'] = $join; + } + } + } +} \ No newline at end of file diff --git a/modules/commons/commons_follow/commons_follow.strongarm.inc b/modules/commons/commons_follow/commons_follow.strongarm.inc new file mode 100644 index 0000000..999ad58 --- /dev/null +++ b/modules/commons/commons_follow/commons_follow.strongarm.inc @@ -0,0 +1,21 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'message_subscribe_flag_prefix'; + $strongarm->value = 'commons_follow'; + $export['message_subscribe_flag_prefix'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_follow/commons_follow_group/commons_follow_group.features.inc b/modules/commons/commons_follow/commons_follow_group/commons_follow_group.features.inc new file mode 100644 index 0000000..badb5fd --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_group/commons_follow_group.features.inc @@ -0,0 +1,97 @@ + "1"); + } +} + +/** + * Implements hook_flag_default_flags(). + */ +function commons_follow_group_flag_default_flags() { + $flags = array(); + // Exported flag: "Groups". + $flags['commons_follow_group'] = array( + 'content_type' => 'node', + 'title' => 'Groups', + 'global' => 0, + 'types' => array( + 0 => 'group', + ), + 'flag_short' => 'Follow', + 'flag_long' => '', + 'flag_message' => '', + 'unflag_short' => 'Following', + 'unflag_long' => '', + 'unflag_message' => 'Not following', + 'unflag_denied_text' => '', + 'link_type' => 'toggle', + 'roles' => array( + 'flag' => array( + 0 => 2, + ), + 'unflag' => array( + 0 => 2, + ), + ), + 'weight' => 0, + 'show_on_form' => 0, + 'access_author' => '', + 'show_on_page' => 1, + 'show_on_teaser' => 1, + 'show_contextual_link' => FALSE, + 'i18n' => 0, + 'module' => 'commons_follow_group', + 'locked' => array( + 0 => 'name', + ), + 'api_version' => 2, + ); + // Exported flag: "Commons Follow (Groups - Email)". + $flags['email_group'] = array( + 'content_type' => 'node', + 'title' => 'Commons Follow (Groups - Email)', + 'global' => 0, + 'types' => array( + 0 => 'group', + ), + 'flag_short' => 'Receive email updates', + 'flag_long' => '', + 'flag_message' => '', + 'unflag_short' => 'Don\'t receive email updates', + 'unflag_long' => '', + 'unflag_message' => '', + 'unflag_denied_text' => '', + 'link_type' => 'toggle', + 'roles' => array( + 'flag' => array( + 0 => 2, + ), + 'unflag' => array( + 0 => 2, + ), + ), + 'weight' => -11, + 'show_on_form' => 0, + 'access_author' => '', + 'show_on_page' => 0, + 'show_on_teaser' => 0, + 'show_contextual_link' => FALSE, + 'i18n' => 0, + 'module' => 'commons_follow_group', + 'locked' => array( + 0 => 'name', + ), + 'api_version' => 2, + ); + return $flags; + +} diff --git a/modules/commons/commons_follow/commons_follow_group/commons_follow_group.info b/modules/commons/commons_follow/commons_follow_group/commons_follow_group.info new file mode 100644 index 0000000..aacc282 --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_group/commons_follow_group.info @@ -0,0 +1,13 @@ +name = Commons Follow (Groups) +description = Lets users follow individual organic groups. +core = 7.x +package = Commons - Building blocks +dependencies[] = ctools +dependencies[] = flag +dependencies[] = og +dependencies[] = strongarm +features[ctools][] = strongarm:strongarm:1 +features[features_api][] = api:2 +features[flag][] = commons_follow_group +features[flag][] = email_group +features[variable][] = message_subscribe_og diff --git a/modules/commons/commons_follow/commons_follow_group/commons_follow_group.install b/modules/commons/commons_follow/commons_follow_group/commons_follow_group.install new file mode 100644 index 0000000..aaa0894 --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_group/commons_follow_group.install @@ -0,0 +1,9 @@ + array('flag'))); + return array(); +} \ No newline at end of file diff --git a/modules/commons/commons_follow/commons_follow_group/commons_follow_group.module b/modules/commons/commons_follow/commons_follow_group/commons_follow_group.module new file mode 100644 index 0000000..5c36100 --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_group/commons_follow_group.module @@ -0,0 +1,151 @@ +range(0, $options['range']); + } + + $result = $query + ->condition('fid', $flag_ids, 'IN') + ->condition('uid', $account->uid, '=') + ->condition('content_type', 'node', '=') + ->condition('content_id', $gids['node'], 'IN') + ->fields('f',array('content_id')) + ->execute() + ->fetchAll(); + + if (empty($result)) { + return array(); + } + + $nids = array(); + foreach($result as $row) { + $nids[] = $row->content_id; + } + + // Get the groups' content IDs. + $query = new EntityFieldQuery(); + $result = $query + ->entityCondition('entity_type', 'og_membership') + ->propertyCondition('group_type', 'node') + ->propertyCondition('gid', $nids, 'IN') + ->propertyCondition('entity_type', 'node', '=') + ->execute(); + + if (empty($result['og_membership'])) { + return array(); + } + + // Keep array structure. + $nids = array(); + $og_memberships = og_membership_load_multiple(array_keys($result['og_membership'])); + foreach ($og_memberships as $og_membership) { + $nid = $og_membership->etid; + $nids[$nid] = $nid; + } + + return $nids; +} + +/** +* Implements hook_node_view_alter(). +*/ +function commons_follow_group_node_view_alter(&$build) { + // Prevent users from following group nodes under the + // commons_follow_node flag. + // Instead, they should be followed using the commons_follow_group flag. + if (og_is_group_type('node', $build['#node']->type)) { + if (!empty($build['links']['flag']['#links']['flag-commons_follow_node'])) { + unset($build['links']['flag']['#links']['flag-commons_follow_node']); + } + } +} + +/** +* Implements hook_commons_follow_get_message_ids(). +*/ +function commons_follow_group_commons_follow_get_message_ids(&$followed_mids, $followed_content = array()) { + // Generate a list of message IDs where the target nodes are followed by + // the current user. + $result = db_query("SELECT m.mid AS mid FROM {message} m INNER JOIN {field_data_field_target_nodes} tn ON m.mid=tn.entity_id INNER JOIN {og_membership} om ON tn.field_target_nodes_target_id=om.etid WHERE om.entity_type = 'node' AND om.gid IN (:gids)", array(':gids' => array_values($followed_content['commons_follow_group']))); + foreach ($result as $this_result) { + $followed_mids[] = $this_result->mid; + } +} + +/** + * Implements hook_node_insert(). + */ +function commons_follow_group_node_insert($node) { + if ($node->type != 'group') { + return; + } + // The owner of the content automatically follows the content + $account = user_load($node->uid); + $flag = flag_get_flag('commons_follow_group'); + $flag->flag('flag', $node->nid, $account); +} + + +/** + * Implements hook_og_membership_insert(). + * Invoked from hook_entity_insert(). + */ +function commons_follow_group_og_membership_insert(OgMembership $og_membership) { + commons_follow_group_sync_flag_to_group_membership($og_membership); +} + +/** + * Implements hook_og_membership_update(). + * Invoked from hook_entity_update(). + */ +function commons_follow_group_og_membership_update(OgMembership $og_membership) { + commons_follow_group_sync_flag_to_group_membership($og_membership); +} + +/** + * Implements hook_og_membership_delete(). + * Invoked from hook_entity_delete(). + */ +function commons_follow_group_og_membership_delete(OgMembership $og_membership) { + // The user should unfollow the group when her membership is deleted. + if ($og_membership->entity_type == 'user' && $og_membership->field_name == 'og_user_node') { + $account = user_load($og_membership->etid); + flag('unflag', 'commons_follow_group', $og_membership->gid, $account); + } +} + +// function flag($action, $flag_name, $content_id, $account = NULL) { + +function commons_follow_group_sync_flag_to_group_membership($og_membership) { + if ($og_membership->entity_type == 'user' && $og_membership->field_name == 'og_user_node') { + $account = user_load($og_membership->etid); + // The membership is approved. The user should follow the group. + if ($og_membership->state == 1) { + flag('flag', 'commons_follow_group', $og_membership->gid, $account); + } + // The membership is not approved. The user should not follow the group. + else { + flag('unflag', 'commons_follow_group', $og_membership->gid, $account); + } + } +} diff --git a/modules/commons/commons_follow/commons_follow_group/commons_follow_group.strongarm.inc b/modules/commons/commons_follow/commons_follow_group/commons_follow_group.strongarm.inc new file mode 100644 index 0000000..bc60cbc --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_group/commons_follow_group.strongarm.inc @@ -0,0 +1,21 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'message_subscribe_og'; + $strongarm->value = 'subscribe_node_email:default'; + $export['message_subscribe_og'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_follow/commons_follow_node/commons_follow_node.features.inc b/modules/commons/commons_follow/commons_follow_node/commons_follow_node.features.inc new file mode 100644 index 0000000..1f8e294 --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_node/commons_follow_node.features.inc @@ -0,0 +1,91 @@ + "3.0"); +} + +/** + * Implements hook_flag_default_flags(). + */ +function commons_follow_node_flag_default_flags() { + $flags = array(); + // Exported flag: "Other content you follow". + $flags['commons_follow_node'] = array( + 'content_type' => 'node', + 'title' => 'Other content', + 'global' => 0, + 'types' => array(), + 'flag_short' => 'Follow', + 'flag_long' => '', + 'flag_message' => '', + 'unflag_short' => 'Following', + 'unflag_long' => '', + 'unflag_message' => 'Not following', + 'unflag_denied_text' => '', + 'link_type' => 'toggle', + 'roles' => array( + 'flag' => array( + 0 => 2, + ), + 'unflag' => array( + 0 => 2, + ), + ), + 'weight' => -10, + 'show_on_form' => 0, + 'access_author' => '', + 'show_on_page' => 1, + 'show_on_teaser' => 1, + 'show_contextual_link' => FALSE, + 'i18n' => 0, + 'module' => 'commons_follow_node', + 'locked' => array( + 0 => 'name', + ), + 'api_version' => 2, + ); + // Exported flag: "Email content". + $flags['email_node'] = array( + 'content_type' => 'node', + 'title' => 'Email content', + 'global' => 0, + 'types' => array(), + 'flag_short' => 'Send Email', + 'flag_long' => '', + 'flag_message' => '', + 'unflag_short' => 'Don\'t send Email', + 'unflag_long' => '', + 'unflag_message' => '', + 'unflag_denied_text' => '', + 'link_type' => 'toggle', + 'roles' => array( + 'flag' => array( + 0 => 2, + ), + 'unflag' => array( + 0 => 2, + ), + ), + 'weight' => 0, + 'show_on_form' => 0, + 'access_author' => '', + 'show_on_page' => 0, + 'show_on_teaser' => 0, + 'show_contextual_link' => 0, + 'i18n' => 0, + 'module' => 'commons_follow_node', + 'locked' => array( + 0 => 'name', + ), + 'api_version' => 2, + ); + return $flags; + +} diff --git a/modules/commons/commons_follow/commons_follow_node/commons_follow_node.info b/modules/commons/commons_follow/commons_follow_node/commons_follow_node.info new file mode 100644 index 0000000..91d481d --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_node/commons_follow_node.info @@ -0,0 +1,13 @@ +name = Commons Follow (Individual nodes) +description = Lets users follow individual nodes. +core = 7.x +package = Commons - Building blocks +dependencies[] = ctools +dependencies[] = flag +dependencies[] = views_litepager +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[flag][] = commons_follow_node +features[flag][] = email_node +features[views_view][] = commons_follow_node +features_exclude[dependencies][views] = views diff --git a/modules/commons/commons_follow/commons_follow_node/commons_follow_node.install b/modules/commons/commons_follow/commons_follow_node/commons_follow_node.install new file mode 100644 index 0000000..6d08f0c --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_node/commons_follow_node.install @@ -0,0 +1,21 @@ + array('flag'))); + return array(); +} + +/** + * Update profile notification page to show an account's following views + * Not the current users following view. + */ +function commons_follow_node_update_3501() { + $revert = array( + 'commons_follow_node' => array('views_view'), + ); + features_revert($revert); + return array(); +} \ No newline at end of file diff --git a/modules/commons/commons_follow/commons_follow_node/commons_follow_node.module b/modules/commons/commons_follow/commons_follow_node/commons_follow_node.module new file mode 100644 index 0000000..463e4ea --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_node/commons_follow_node.module @@ -0,0 +1,86 @@ +range(0, $options['range']); + } + + $result = $query + ->condition('fid', $flag_ids, 'IN') + ->condition('uid', $account->uid, '=') + ->condition('content_type', 'node', '=') + ->fields('f',array('content_id')) + ->execute() + ->fetchAll(); + $nids = array(); + foreach($result as $row) { + $nids[] = (integer) $row->content_id; + } + + return $nids; +} + +/** +* Implements hook_commons_follow_get_message_ids(). +*/ +function commons_follow_node_commons_follow_get_message_ids(&$followed_mids, $followed_content = array()) { + // Generate a list of message IDs where the target nodes are followed by + // the current user. + $result = db_query("SELECT m.mid AS mid FROM {message} m INNER JOIN {field_data_field_target_nodes} tn ON m.mid=tn.entity_id WHERE tn.field_target_nodes_target_id IN (:nids)", array(':nids' => array_values($followed_content['commons_follow_node']))); + foreach ($result as $this_result) { + $followed_mids[] = $this_result->mid; + } +} + +/** + * Implements hook_node_insert(). + */ +function commons_follow_node_node_insert($node) { + // The owner of the content automatically follows the content + commons_follow_node_follow_node($node->nid, $node->type, $node->uid); +} + +/** + * Implements hook_comment_insert(). + */ +function commons_follow_node_comment_insert($comment) { + // The user who comment a node automatically follows that content + $content_type = str_replace('comment_node_', '', $comment->node_type); + commons_follow_node_follow_node($comment->nid, $content_type, $comment->uid); +} + +/** + * Let a user to follow a node. + * + * @see commons_follow_node_comment_insert + * @see commons_follow_node_node_insert + */ +function commons_follow_node_follow_node($nid, $content_type, $user_id = NULL) { + $flag = flag_get_flag('commons_follow_node'); + + // Check if this content type use the "Individual nodes" flag + if (in_array($content_type, $flag->types)) { + $account = isset($user_id) ? user_load($user_id) : NULL; + $flag->flag('flag', $nid, $account); + } +} diff --git a/modules/commons/commons_follow/commons_follow_node/commons_follow_node.views_default.inc b/modules/commons/commons_follow/commons_follow_node/commons_follow_node.views_default.inc new file mode 100644 index 0000000..8db8038 --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_node/commons_follow_node.views_default.inc @@ -0,0 +1,167 @@ +name = 'commons_follow_node'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'Nodes a user follows'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_ajax'] = TRUE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['query']['options']['distinct'] = TRUE; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'lite'; + $handler->display->display_options['pager']['options']['items_per_page'] = '20'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '2'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['style_plugin'] = 'table'; + $handler->display->display_options['style_options']['columns'] = array( + 'title' => 'title', + 'ops_1' => 'ops_1', + 'ops' => 'ops', + ); + $handler->display->display_options['style_options']['default'] = '-1'; + $handler->display->display_options['style_options']['info'] = array( + 'title' => array( + 'sortable' => 0, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'ops_1' => array( + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'ops' => array( + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + ); + $handler->display->display_options['style_options']['sticky'] = TRUE; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'You\'re not following anything of this type.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: Flags: commons_follow_node */ + $handler->display->display_options['relationships']['flag_content_rel']['id'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel']['table'] = 'node'; + $handler->display->display_options['relationships']['flag_content_rel']['field'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel']['flag'] = 'commons_follow_node'; + $handler->display->display_options['relationships']['flag_content_rel']['user_scope'] = 'any'; + /* Relationship: Flags: email_node */ + $handler->display->display_options['relationships']['flag_content_rel_1']['id'] = 'flag_content_rel_1'; + $handler->display->display_options['relationships']['flag_content_rel_1']['table'] = 'node'; + $handler->display->display_options['relationships']['flag_content_rel_1']['field'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel_1']['label'] = 'email_flag'; + $handler->display->display_options['relationships']['flag_content_rel_1']['required'] = 0; + $handler->display->display_options['relationships']['flag_content_rel_1']['flag'] = 'email_node'; + $handler->display->display_options['relationships']['flag_content_rel_1']['user_scope'] = 'any'; + /* Relationship: Flags: User */ + $handler->display->display_options['relationships']['uid']['id'] = 'uid'; + $handler->display->display_options['relationships']['uid']['table'] = 'flag_content'; + $handler->display->display_options['relationships']['uid']['field'] = 'uid'; + $handler->display->display_options['relationships']['uid']['relationship'] = 'flag_content_rel'; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Field: Flags: Flag link */ + $handler->display->display_options['fields']['ops_1']['id'] = 'ops_1'; + $handler->display->display_options['fields']['ops_1']['table'] = 'flag_content'; + $handler->display->display_options['fields']['ops_1']['field'] = 'ops'; + $handler->display->display_options['fields']['ops_1']['relationship'] = 'flag_content_rel_1'; + $handler->display->display_options['fields']['ops_1']['label'] = 'Send email?'; + $handler->display->display_options['fields']['ops_1']['element_label_colon'] = FALSE; + /* Field: Flags: Flag link */ + $handler->display->display_options['fields']['ops']['id'] = 'ops'; + $handler->display->display_options['fields']['ops']['table'] = 'flag_content'; + $handler->display->display_options['fields']['ops']['field'] = 'ops'; + $handler->display->display_options['fields']['ops']['relationship'] = 'flag_content_rel'; + $handler->display->display_options['fields']['ops']['label'] = ''; + $handler->display->display_options['fields']['ops']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['ops']['link_type'] = 'toggle'; + /* Sort criterion: Flags: Flagged time */ + $handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp'; + $handler->display->display_options['sorts']['timestamp']['table'] = 'flag_content'; + $handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp'; + $handler->display->display_options['sorts']['timestamp']['relationship'] = 'flag_content_rel'; + $handler->display->display_options['sorts']['timestamp']['order'] = 'DESC'; + /* Contextual filter: User: Uid */ + $handler->display->display_options['arguments']['uid']['id'] = 'uid'; + $handler->display->display_options['arguments']['uid']['table'] = 'users'; + $handler->display->display_options['arguments']['uid']['field'] = 'uid'; + $handler->display->display_options['arguments']['uid']['relationship'] = 'uid'; + $handler->display->display_options['arguments']['uid']['default_action'] = 'default'; + $handler->display->display_options['arguments']['uid']['default_argument_type'] = 'user'; + $handler->display->display_options['arguments']['uid']['default_argument_options']['user'] = FALSE; + $handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25'; + $handler->display->display_options['arguments']['uid']['specify_validation'] = TRUE; + $handler->display->display_options['arguments']['uid']['validate']['type'] = 'user'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'node'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['operator'] = 'not empty'; + $handler->display->display_options['filters']['type']['value'] = array(); + $translatables['commons_follow_node'] = array( + t('Master'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('You\'re not following anything of this type.'), + t('flag'), + t('email_flag'), + t('Title'), + t('Send email?'), + ); + $export['commons_follow_node'] = $view; + + return $export; +} diff --git a/modules/commons/commons_follow/commons_follow_term/commons_follow_term.features.inc b/modules/commons/commons_follow/commons_follow_term/commons_follow_term.features.inc new file mode 100644 index 0000000..4b10c15 --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_term/commons_follow_term.features.inc @@ -0,0 +1,89 @@ + "3.0"); +} + +/** + * Implements hook_flag_default_flags(). + */ +function commons_follow_term_flag_default_flags() { + $flags = array(); + // Exported flag: "Topics you follow". + $flags['commons_follow_term'] = array( + 'content_type' => 'taxonomy_term', + 'title' => 'Topics', + 'global' => 0, + 'types' => array( + 0 => 'topics', + ), + 'flag_short' => 'Follow', + 'flag_long' => '', + 'flag_message' => '', + 'unflag_short' => 'Following', + 'unflag_long' => '', + 'unflag_message' => 'Not following', + 'unflag_denied_text' => '', + 'link_type' => 'toggle', + 'roles' => array( + 'flag' => array( + 0 => 2, + ), + 'unflag' => array( + 0 => 2, + ), + ), + 'weight' => -8, + 'show_on_entity' => 1, + 'show_on_form' => 0, + 'access_author' => '', + 'module' => 'commons_follow_term', + 'locked' => array( + 0 => 'name', + ), + 'api_version' => 2, + ); + // Exported flag: "Email term". + $flags['email_term'] = array( + 'content_type' => 'taxonomy_term', + 'title' => 'Email term', + 'global' => 0, + 'types' => array( + 0 => 'topics', + ), + 'flag_short' => 'Send Email', + 'flag_long' => '', + 'flag_message' => '', + 'unflag_short' => 'Don\'t send Email', + 'unflag_long' => '', + 'unflag_message' => '', + 'unflag_denied_text' => '', + 'link_type' => 'toggle', + 'roles' => array( + 'flag' => array( + 0 => 2, + ), + 'unflag' => array( + 0 => 2, + ), + ), + 'weight' => 0, + 'show_on_entity' => 1, + 'show_on_form' => 0, + 'access_author' => '', + 'module' => 'commons_follow_term', + 'locked' => array( + 0 => 'name', + ), + 'api_version' => 2, + ); + return $flags; + +} diff --git a/modules/commons/commons_follow/commons_follow_term/commons_follow_term.info b/modules/commons/commons_follow/commons_follow_term/commons_follow_term.info new file mode 100644 index 0000000..cc99417 --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_term/commons_follow_term.info @@ -0,0 +1,13 @@ +name = Commons Follow (Taxonomy terms) +description = Lets users follow individual taxonomy terms +core = 7.x +package = Commons - Building blocks +dependencies[] = flag +dependencies[] = views +dependencies[] = views_litepager +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[flag][] = commons_follow_term +features[flag][] = email_term +features[views_view][] = commons_follow_taxonomy_term +features_exclude[dependencies][ctools] = ctools diff --git a/modules/commons/commons_follow/commons_follow_term/commons_follow_term.install b/modules/commons/commons_follow/commons_follow_term/commons_follow_term.install new file mode 100644 index 0000000..77c4c76 --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_term/commons_follow_term.install @@ -0,0 +1,29 @@ + array('flag'))); + return array(); +} + +/** + * Update email_term flag to allow terms in Topics vocabulary to be flagged. + */ +function commons_follow_term_update_3102() { + features_revert(array('commons_follow_term' => array('flag'))); + return array(); +} + +/** + * Update profile notification page to show an account's following views + * Not the current users following view. + */ +function commons_follow_term_update_3501() { + $revert = array( + 'commons_follow_term' => array('views_view'), + ); + features_revert($revert); + return array(); +} \ No newline at end of file diff --git a/modules/commons/commons_follow/commons_follow_term/commons_follow_term.module b/modules/commons/commons_follow/commons_follow_term/commons_follow_term.module new file mode 100644 index 0000000..2eb4b56 --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_term/commons_follow_term.module @@ -0,0 +1,75 @@ +condition('fid', $flag_ids, 'IN') + ->condition('uid', $account->uid, '=') + ->condition('content_type', 'taxonomy_term', '=') + ->fields('f',array('content_id')) + ->execute() + ->fetchAll(); + + if (empty($result)) { + // No term flags. + return array(); + } + + $tids = array(); + foreach($result as $row) { + $tids[] = (integer) $row->content_id; + } + + // Get IDs of nodes tagged by the specified terms. + $query = db_select('taxonomy_index', 't'); + + if (!empty($options['range'])) { + $query->range(0, $options['range']); + } + + $result = $query + ->addTag('node_access') + ->condition('tid', $tids, 'IN') + ->fields('t',array('nid')) + ->groupBy('nid') + ->execute() + ->fetchAll(); + + // Return the node IDs. + $nids = array(); + foreach($result as $row) { + $nids[] = (integer) $row->nid; + } + + return $nids; +} + +/** +* Implements hook_commons_follow_get_message_ids(). +*/ +function commons_follow_term_commons_follow_get_message_ids(&$followed_mids, $followed_content = array()) { + // Generate a list of message IDs where the target nodes are followed by + // the current user. + $result = db_query("SELECT m.mid AS mid FROM {message} m INNER JOIN {field_data_field_target_nodes} tn ON m.mid=tn.entity_id INNER JOIN {field_data_field_topics} ft ON ft.entity_id=tn.field_target_nodes_target_id WHERE ft.field_topics_tid IN (:tids) AND tn.entity_type = 'node'", array(':tids' => array_values($followed_content['commons_follow_term']))); + foreach ($result as $this_result) { + $followed_mids[] = $this_result->mid; + } +} diff --git a/modules/commons/commons_follow/commons_follow_term/commons_follow_term.views_default.inc b/modules/commons/commons_follow/commons_follow_term/commons_follow_term.views_default.inc new file mode 100644 index 0000000..21e785a --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_term/commons_follow_term.views_default.inc @@ -0,0 +1,154 @@ +name = 'commons_follow_taxonomy_term'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'taxonomy_term_data'; + $view->human_name = 'Topics a user follows'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_ajax'] = TRUE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'lite'; + $handler->display->display_options['pager']['options']['items_per_page'] = '20'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '6'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['style_plugin'] = 'table'; + $handler->display->display_options['style_options']['columns'] = array( + 'name' => 'name', + 'ops_1' => 'ops_1', + 'ops' => 'ops', + ); + $handler->display->display_options['style_options']['default'] = '-1'; + $handler->display->display_options['style_options']['info'] = array( + 'name' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'ops_1' => array( + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'ops' => array( + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + ); + $handler->display->display_options['style_options']['sticky'] = TRUE; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'You aren\'t following any topics.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: Flags: commons_follow_term */ + $handler->display->display_options['relationships']['flag_content_rel']['id'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel']['table'] = 'taxonomy_term_data'; + $handler->display->display_options['relationships']['flag_content_rel']['field'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel']['flag'] = 'commons_follow_term'; + $handler->display->display_options['relationships']['flag_content_rel']['user_scope'] = 'any'; + /* Relationship: Flags: email_term */ + $handler->display->display_options['relationships']['flag_content_rel_1']['id'] = 'flag_content_rel_1'; + $handler->display->display_options['relationships']['flag_content_rel_1']['table'] = 'taxonomy_term_data'; + $handler->display->display_options['relationships']['flag_content_rel_1']['field'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel_1']['label'] = 'email_flag'; + $handler->display->display_options['relationships']['flag_content_rel_1']['required'] = 0; + $handler->display->display_options['relationships']['flag_content_rel_1']['flag'] = 'email_term'; + $handler->display->display_options['relationships']['flag_content_rel_1']['user_scope'] = 'any'; + /* Relationship: Flags: User */ + $handler->display->display_options['relationships']['uid']['id'] = 'uid'; + $handler->display->display_options['relationships']['uid']['table'] = 'flag_content'; + $handler->display->display_options['relationships']['uid']['field'] = 'uid'; + $handler->display->display_options['relationships']['uid']['relationship'] = 'flag_content_rel'; + /* Field: Taxonomy term: Name */ + $handler->display->display_options['fields']['name']['id'] = 'name'; + $handler->display->display_options['fields']['name']['table'] = 'taxonomy_term_data'; + $handler->display->display_options['fields']['name']['field'] = 'name'; + $handler->display->display_options['fields']['name']['label'] = 'Topic'; + $handler->display->display_options['fields']['name']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['name']['alter']['ellipsis'] = FALSE; + $handler->display->display_options['fields']['name']['link_to_taxonomy'] = TRUE; + /* Field: Flags: Flag link */ + $handler->display->display_options['fields']['ops_1']['id'] = 'ops_1'; + $handler->display->display_options['fields']['ops_1']['table'] = 'flag_content'; + $handler->display->display_options['fields']['ops_1']['field'] = 'ops'; + $handler->display->display_options['fields']['ops_1']['relationship'] = 'flag_content_rel_1'; + $handler->display->display_options['fields']['ops_1']['label'] = 'Send email?'; + /* Field: Flags: Flag link */ + $handler->display->display_options['fields']['ops']['id'] = 'ops'; + $handler->display->display_options['fields']['ops']['table'] = 'flag_content'; + $handler->display->display_options['fields']['ops']['field'] = 'ops'; + $handler->display->display_options['fields']['ops']['relationship'] = 'flag_content_rel'; + $handler->display->display_options['fields']['ops']['label'] = ''; + $handler->display->display_options['fields']['ops']['element_label_colon'] = FALSE; + /* Sort criterion: Flags: Flagged time */ + $handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp'; + $handler->display->display_options['sorts']['timestamp']['table'] = 'flag_content'; + $handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp'; + $handler->display->display_options['sorts']['timestamp']['relationship'] = 'flag_content_rel'; + $handler->display->display_options['sorts']['timestamp']['order'] = 'DESC'; + $translatables['commons_follow_taxonomy_term'] = array( + /* Contextual filter: User: Uid */ + t('Master'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('You aren\'t following any topics.'), + t('flag'), + t('email_flag'), + t('Topic'), + t('Send email?'), + ); + $handler->display->display_options['arguments']['uid']['id'] = 'uid'; + $handler->display->display_options['arguments']['uid']['table'] = 'users'; + $handler->display->display_options['arguments']['uid']['field'] = 'uid'; + $handler->display->display_options['arguments']['uid']['relationship'] = 'uid'; + $handler->display->display_options['arguments']['uid']['default_action'] = 'default'; + $handler->display->display_options['arguments']['uid']['default_argument_type'] = 'user'; + $handler->display->display_options['arguments']['uid']['default_argument_options']['user'] = FALSE; + $handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25'; + $handler->display->display_options['arguments']['uid']['specify_validation'] = TRUE; + $handler->display->display_options['arguments']['uid']['validate']['type'] = 'user'; + $handler->display->display_options['arguments']['uid']['validate_options']['type'] = 'either'; + $export['commons_follow_taxonomy_term'] = $view; + + return $export; +} diff --git a/modules/commons/commons_follow/commons_follow_ui/commons_follow_ui.commons_utility_links.inc b/modules/commons/commons_follow/commons_follow_ui/commons_follow_ui.commons_utility_links.inc new file mode 100644 index 0000000..172c3cb --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_ui/commons_follow_ui.commons_utility_links.inc @@ -0,0 +1,25 @@ + 'user/' . $account->uid . '/notification-settings', + 'title' => t('Settings'), + 'weight' => 10, + ); + } + + return $links; +} diff --git a/modules/commons/commons_follow/commons_follow_ui/commons_follow_ui.info b/modules/commons/commons_follow/commons_follow_ui/commons_follow_ui.info new file mode 100644 index 0000000..12d6a77 --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_ui/commons_follow_ui.info @@ -0,0 +1,7 @@ +name = "Commons Follow UI" +description = "User interface for the Commons Follow functionality" +core = 7.x +package = Commons - Building blocks +dependencies[] = commons_follow +dependencies[] = message_subscribe_ui +dependencies[] = quicktabs diff --git a/modules/commons/commons_follow/commons_follow_ui/commons_follow_ui.module b/modules/commons/commons_follow/commons_follow_ui/commons_follow_ui.module new file mode 100644 index 0000000..6a900b5 --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_ui/commons_follow_ui.module @@ -0,0 +1,120 @@ + 'Notification settings', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('commons_follow_ui_notification_settings_form', 1), + 'access callback' => 'message_subscribe_ui_tab_access', + 'access arguments' => array(1), + 'file' => 'commons_follow_ui.pages.inc', + 'type' => MENU_LOCAL_TASK, + ); + + return $items; +} + +/** + * Implements hook_form_FORM_ID_alter. + */ +function commons_follow_ui_form_edit_profile_user_profile_form_alter(&$form, &$form_state, $form_id) { + // We have a dedicated form for the "Send email by default" checkbox. + // Hide it from the user profile edit form. + $form['message_subscribe_email']['#access'] = FALSE; +} + +/* + * Generates the Quicktab content for the subscription UI + */ +function commons_follow_ui_generate_tabs($account) { + $tabs = array(); + + // Create a separate tab for each subscribe flag. + foreach (array_keys(message_subscribe_flag_get_flags(NULL, NULL, $account, FALSE)) as $flag_name) { + // Grab the view object of a message subscribe page. + if ($view = message_subscribe_ui_get_view($account, $flag_name)) { + $tabs[$flag_name] = array( + 'title' => commons_follow_ui_tab_title($account, $flag_name), + 'contents' => array( + '#markup' => $view->preview(), + ), + ); + } + } + + if (!empty($tabs)) { + // Sort the tabs alphabetically. + ksort($tabs); + + $settings = array( + 'style' => 'Commons Tabs', + 'ajax' => FALSE, + 'html' => TRUE, + 'default_tab' => 'commons_follow_group', + ); + + $tabs = quicktabs_build_quicktabs('commons_follow_ui', $settings, $tabs); + } + + return $tabs; +} + +/** + * Title callback; Return the flag name and flagging count. + * + * Replaces message_subscribe_ui_tab_title(). + * + * @param $account + * The user object. + * @param $flag_name + * (optional) The flag name. The first subscribe flag will be used by default. + * + * @return + * A translated string containing the flag name and flagging count. + */ +function commons_follow_ui_tab_title($account, $flag_name = NULL) { + if (!$flag_name) { + // We are inside /message-subscribe so get the first flag. + $flag_name = key(message_subscribe_flag_get_flags()); + } + $flag = flag_get_flag($flag_name); + + $count = 0; + // Get the message subscribe count from the page view. + if ($view = message_subscribe_ui_get_view($account, $flag_name)) { + $view->get_total_rows = TRUE; + $view->preview(); + $count = $view->total_rows; + } + + return t('@flag @count', array('@flag' => $flag->get_title(), '@count' => $count)); +} diff --git a/modules/commons/commons_follow/commons_follow_ui/commons_follow_ui.pages.inc b/modules/commons/commons_follow/commons_follow_ui/commons_follow_ui.pages.inc new file mode 100644 index 0000000..167bf2c --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_ui/commons_follow_ui.pages.inc @@ -0,0 +1,60 @@ + 'value', + '#value' => $account->uid, + ); + + $form['explanation'] = array( + '#markup' => '

' . t("Control how you are notified of new content and activity. When you follow a group, topic, user, or other content, you'll see updates in your content and activity streams, and you will automatically get email updates unlesss you disable emails or unfollow.") . '

', + ); + + $form['message_subscribe_email'] = array( + '#type' => 'checkbox', + '#title' => t('Send email notifications by default.'), + '#description' => t("If checked, you'll automatically sign up for email notifications when you follow something. Leave unchecked to default to signing up only for activity stream notifications"), + '#ajax' => array( + 'callback' => 'commons_follow_message_subscribe_email_setting_submit', + ), + '#default_value' => isset($account->message_subscribe_email[LANGUAGE_NONE][0]['value']) ? $account->message_subscribe_email[LANGUAGE_NONE][0]['value'] : FALSE, + ); + + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Save email notification settings'), + '#attributes' => array( + 'class' => array('js-hide'), + ), + ); + + $tabs = commons_follow_ui_generate_tabs($account); + + $form['tabs'] = array( + '#markup' => drupal_render($tabs), + ); + + $form['#submit'][] = 'commons_follow_message_subscribe_email_setting_submit'; + + return $form; +} + +/** + * Submit handler for commons_follow_ui_notification_settings_form(). + */ +function commons_follow_message_subscribe_email_setting_submit($form, &$form_state) { + // Save any changes to the email notifications setting. + if ($form_state['values']['message_subscribe_email'] != $form['message_subscribe_email']['#default_value']) { + $account = user_load($form_state['values']['uid']); + $account->message_subscribe_email[LANGUAGE_NONE][0]['value'] = $form_state['values']['message_subscribe_email']; + user_save($account); + } +} diff --git a/modules/commons/commons_follow/commons_follow_user/commons_follow_user.features.field_instance.inc b/modules/commons/commons_follow/commons_follow_user/commons_follow_user.features.field_instance.inc new file mode 100644 index 0000000..2861d26 --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_user/commons_follow_user.features.field_instance.inc @@ -0,0 +1,64 @@ + 'commons_follow_user_user_followed', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_target_users', + 'label' => 'Target users', + 'required' => 0, + 'settings' => array( + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 1, + ), + ); + + // Translatables + // Included for use with string extractors like potx. + t('Target users'); + + return $field_instances; +} diff --git a/modules/commons/commons_follow/commons_follow_user/commons_follow_user.features.inc b/modules/commons/commons_follow/commons_follow_user/commons_follow_user.features.inc new file mode 100644 index 0000000..6eb397f --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_user/commons_follow_user.features.inc @@ -0,0 +1,128 @@ + "1"); + } +} + +/** + * Implements hook_views_api(). + */ +function commons_follow_user_views_api($module = NULL, $api = NULL) { + return array("api" => "3.0"); +} + +/** + * Implements hook_flag_default_flags(). + */ +function commons_follow_user_flag_default_flags() { + $flags = array(); + // Exported flag: "People". + $flags['commons_follow_user'] = array( + 'content_type' => 'user', + 'title' => 'People', + 'global' => 0, + 'types' => array(), + 'flag_short' => 'Follow', + 'flag_long' => '', + 'flag_message' => '', + 'unflag_short' => 'Following', + 'unflag_long' => '', + 'unflag_message' => 'Not following', + 'unflag_denied_text' => '', + 'link_type' => 'toggle', + 'roles' => array( + 'flag' => array( + 0 => 2, + ), + 'unflag' => array( + 0 => 2, + ), + ), + 'weight' => -13, + 'show_on_form' => 0, + 'access_author' => '', + 'show_on_profile' => 1, + 'access_uid' => 'others', + 'module' => 'commons_follow_user', + 'locked' => array( + 0 => 'name', + ), + 'api_version' => 2, + ); + // Exported flag: "Email user". + $flags['email_user'] = array( + 'content_type' => 'user', + 'title' => 'Email user', + 'global' => 0, + 'types' => array(), + 'flag_short' => 'Send Email', + 'flag_long' => '', + 'flag_message' => '', + 'unflag_short' => 'Don\'t send Email', + 'unflag_long' => '', + 'unflag_message' => '', + 'unflag_denied_text' => '', + 'link_type' => 'toggle', + 'roles' => array( + 'flag' => array( + 0 => 2, + ), + 'unflag' => array( + 0 => 2, + ), + ), + 'weight' => 0, + 'show_on_form' => 0, + 'access_author' => '', + 'show_on_profile' => 0, + 'access_uid' => '', + 'module' => 'commons_follow_user', + 'locked' => array( + 0 => 'name', + ), + 'api_version' => 2, + ); + return $flags; + +} + +/** + * Implements hook_default_message_type(). + */ +function commons_follow_user_default_message_type() { + $items = array(); + $items['commons_follow_user_user_followed'] = entity_import('message_type', '{ + "name" : "commons_follow_user_user_followed", + "description" : "commons_follow_user_user_followed", + "argument_keys" : [], + "argument" : [], + "category" : "message_type", + "data" : { "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" } }, + "language" : "", + "arguments" : null, + "message_text" : { "und" : [ + { + "value" : "[message:user:picture]", + "format" : "filtered_html", + "safe_value" : "[message:user:picture]" + }, + { + "value" : "\\u003Ca href=\\u0022[message:user:url:absolute]\\u0022\\u003E[message:user:name]\\u003C\\/a\\u003E is now following \\u003Ca href=\\u0022[message:field-target-users:0:url]\\u0022\\u003E[message:field-target-users:0:name]\\u003C\\/a\\u003E", + "format" : "full_html", + "safe_value" : "\\u003Ca href=\\u0022[message:user:url:absolute]\\u0022\\u003E[message:user:name]\\u003C\\/a\\u003E is now following \\u003Ca href=\\u0022[message:field-target-users:0:url]\\u0022\\u003E[message:field-target-users:0:name]\\u003C\\/a\\u003E" + } + ] + }, + "rdf_mapping" : [] + }'); + return $items; +} diff --git a/modules/commons/commons_follow/commons_follow_user/commons_follow_user.info b/modules/commons/commons_follow/commons_follow_user/commons_follow_user.info new file mode 100644 index 0000000..947d59d --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_user/commons_follow_user.info @@ -0,0 +1,21 @@ +name = Commons Follow (Users) +description = Lets users follow other users. +core = 7.x +package = Commons - Building blocks +dependencies[] = commons_follow +dependencies[] = entityreference +dependencies[] = flag +dependencies[] = message +dependencies[] = views +dependencies[] = views_content +dependencies[] = views_litepager +dependencies[] = views_load_more +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[field_instance][] = message-commons_follow_user_user_followed-field_target_users +features[flag][] = commons_follow_user +features[flag][] = email_user +features[message_type][] = commons_follow_user_user_followed +features[views_view][] = commons_follow_user +features[views_view][] = commons_follow_user_followers +features[views_view][] = commons_follow_user_following diff --git a/modules/commons/commons_follow/commons_follow_user/commons_follow_user.install b/modules/commons/commons_follow/commons_follow_user/commons_follow_user.install new file mode 100644 index 0000000..e5e35a5 --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_user/commons_follow_user.install @@ -0,0 +1,29 @@ + array('flag'))); + return array(); +} + +/** + * Correct a typo in the title of the follows view. + */ +function commons_follow_user_update_3102() { + features_revert(array('commons_follow_user' => array('views_view'))); + return array(); +} + +/** + * Update profile notification page to show an account's following views + * Not the current users following view. + */ +function commons_follow_user_update_3501() { + $revert = array( + 'commons_follow_user' => array('views_view'), + ); + features_revert($revert); + return array(); +} \ No newline at end of file diff --git a/modules/commons/commons_follow/commons_follow_user/commons_follow_user.module b/modules/commons/commons_follow/commons_follow_user/commons_follow_user.module new file mode 100644 index 0000000..1f8222d --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_user/commons_follow_user.module @@ -0,0 +1,138 @@ +condition('fid', $flag_ids, 'IN') + ->condition('uid', $account->uid, '=') + ->condition('content_type', 'user', '=') + ->fields('f',array('content_id')) + ->execute() + ->fetchAll(); + + if (empty($result)) { + // No user flags. + return array(); + } + + $uids = array(); + foreach($result as $row) { + $uids[] = (integer) $row->content_id; + } + + // Get the user's node IDs. + $query = new EntityFieldQuery(); + + if (!empty($options['range'])) { + $query->range(0, $options['range']); + } + + $result = $query + ->entityCondition('entity_type', 'node') + ->propertyCondition('uid', $uids, 'IN') + ->execute(); + + $nids = array(); + if (!empty($result['node'])) { + foreach ($result['node'] as $nid => $row) { + $nids[] = $nid; + } + } + + + return $nids; +} + +/** +* Implements hook_system_info_alter(). +*/ +function commons_follow_user_system_info_alter(&$info, $file, $type) { + // If Message.module is enabled, we'll define our "User follows another user" + // message type and will need to add to it an instance of field_target_users. + if ($file->name == 'commons_follow_user' && module_exists('message')) { + $info['features']['field_instance'][] = 'message-commons_follow_user_user_followed-field_target_users'; + $info['features']['message_type'][] = 'commons_follow_user_user_followed'; + } +} + +/** + * Implements hook_flag(). + */ +function commons_follow_user_flag($op, $flag, $content_id, $account, $fcid) { + // Display an activity stream message when a user follows another user. + if (module_exists('commons_activity_streams') && $flag->name == 'commons_follow_user' && $op == 'flag') { + $followed_user = user_load($content_id); + // Don't generate a message for flagging blocked users. + if (!$followed_user->status) { + return; + } + // Todo: Check module_exists() before creating the message. + if (commons_follow_user_existing_follow_message($account->uid, array($followed_user->uid))) { + // If this user previously followed the target user, don't generate a duplicate message. + return; + } + $message = message_create('commons_follow_user_user_followed', array(), $account); + $wrapper = entity_metadata_wrapper('message', $message); + $wrapper->field_target_users[] = $followed_user->uid; + $wrapper->save(); + } +} + +/** +* Indicate whether there is an existing message about a given user following +* a target user. +*/ +function commons_follow_user_existing_follow_message($acting_uid, $target_uids) { + $query = new EntityFieldQuery(); + $query->entityCondition('entity_type', 'message', '=') + ->propertyCondition('uid', $acting_uid) + ->propertyCondition('type', 'commons_follow_user_user_followed', '=') + ->fieldCondition('field_target_users', 'target_id', $target_uids, 'IN') + ->execute(); + + return !empty($query->ordered_results); +} + + +/** +* Implements hook_commons_follow_get_message_ids(). +*/ +function commons_follow_user_commons_follow_get_message_ids(&$followed_mids, $followed_content = array()) { + // If the user isn't following any other users, we've nothing to do here. + if (empty($followed_content['commons_follow_user'])) { + return; + } + // Generate a list of message IDs where message.uid OR any of the referenced + // target users are ones that the current user is following. + $result = db_query("SELECT m.mid AS mid + FROM {message} m + LEFT JOIN {field_data_field_target_users} tu ON m.mid=tu.entity_id + WHERE tu.field_target_users_target_id IN(:uids) + OR m.uid IN (:uids)", + array(':uids' => array_values($followed_content['commons_follow_user']))); + foreach ($result as $this_result) { + $followed_mids[] = $this_result->mid; + } +} \ No newline at end of file diff --git a/modules/commons/commons_follow/commons_follow_user/commons_follow_user.views_default.inc b/modules/commons/commons_follow/commons_follow_user/commons_follow_user.views_default.inc new file mode 100644 index 0000000..fa18e54 --- /dev/null +++ b/modules/commons/commons_follow/commons_follow_user/commons_follow_user.views_default.inc @@ -0,0 +1,437 @@ +name = 'commons_follow_user'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'users'; + $view->human_name = 'Users that a user follows'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_ajax'] = TRUE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['access']['perm'] = 'access user profiles'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'lite'; + $handler->display->display_options['pager']['options']['items_per_page'] = '20'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '4'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['style_plugin'] = 'table'; + $handler->display->display_options['style_options']['columns'] = array( + 'name' => 'name', + 'ops_1' => 'ops_1', + 'ops' => 'ops', + ); + $handler->display->display_options['style_options']['default'] = '-1'; + $handler->display->display_options['style_options']['info'] = array( + 'name' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'ops_1' => array( + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'ops' => array( + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + ); + $handler->display->display_options['style_options']['sticky'] = TRUE; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'You aren\'t following anyone.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: Flags: commons_follow_user */ + $handler->display->display_options['relationships']['flag_content_rel']['id'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel']['table'] = 'users'; + $handler->display->display_options['relationships']['flag_content_rel']['field'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel']['flag'] = 'commons_follow_user'; + $handler->display->display_options['relationships']['flag_content_rel']['user_scope'] = 'any'; + /* Relationship: Flags: email_user */ + $handler->display->display_options['relationships']['flag_content_rel_1']['id'] = 'flag_content_rel_1'; + $handler->display->display_options['relationships']['flag_content_rel_1']['table'] = 'users'; + $handler->display->display_options['relationships']['flag_content_rel_1']['field'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel_1']['label'] = 'flag_user'; + $handler->display->display_options['relationships']['flag_content_rel_1']['required'] = 0; + $handler->display->display_options['relationships']['flag_content_rel_1']['flag'] = 'email_user'; + $handler->display->display_options['relationships']['flag_content_rel_1']['user_scope'] = 'any'; + /* Relationship: Flags: User */ + $handler->display->display_options['relationships']['uid']['id'] = 'uid'; + $handler->display->display_options['relationships']['uid']['table'] = 'flag_content'; + $handler->display->display_options['relationships']['uid']['field'] = 'uid'; + $handler->display->display_options['relationships']['uid']['relationship'] = 'flag_content_rel'; + /* Field: User: Name */ + $handler->display->display_options['fields']['name']['id'] = 'name'; + $handler->display->display_options['fields']['name']['table'] = 'users'; + $handler->display->display_options['fields']['name']['field'] = 'name'; + $handler->display->display_options['fields']['name']['label'] = 'Person'; + $handler->display->display_options['fields']['name']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['name']['alter']['ellipsis'] = FALSE; + /* Field: Flags: Flag link */ + $handler->display->display_options['fields']['ops_1']['id'] = 'ops_1'; + $handler->display->display_options['fields']['ops_1']['table'] = 'flag_content'; + $handler->display->display_options['fields']['ops_1']['field'] = 'ops'; + $handler->display->display_options['fields']['ops_1']['relationship'] = 'flag_content_rel_1'; + $handler->display->display_options['fields']['ops_1']['label'] = 'Send email?'; + /* Field: Flags: Flag link */ + $handler->display->display_options['fields']['ops']['id'] = 'ops'; + $handler->display->display_options['fields']['ops']['table'] = 'flag_content'; + $handler->display->display_options['fields']['ops']['field'] = 'ops'; + $handler->display->display_options['fields']['ops']['relationship'] = 'flag_content_rel'; + $handler->display->display_options['fields']['ops']['label'] = ''; + $handler->display->display_options['fields']['ops']['element_label_colon'] = FALSE; + /* Sort criterion: Flags: Flagged time */ + $handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp'; + $handler->display->display_options['sorts']['timestamp']['table'] = 'flag_content'; + $handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp'; + $handler->display->display_options['sorts']['timestamp']['relationship'] = 'flag_content_rel'; + $handler->display->display_options['sorts']['timestamp']['order'] = 'DESC'; + /* Contextual filter: User: Uid */ + $handler->display->display_options['arguments']['uid']['id'] = 'uid'; + $handler->display->display_options['arguments']['uid']['table'] = 'users'; + $handler->display->display_options['arguments']['uid']['field'] = 'uid'; + $handler->display->display_options['arguments']['uid']['relationship'] = 'uid'; + $handler->display->display_options['arguments']['uid']['default_action'] = 'default'; + $handler->display->display_options['arguments']['uid']['default_argument_type'] = 'user'; + $handler->display->display_options['arguments']['uid']['default_argument_options']['user'] = FALSE; + $handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25'; + $handler->display->display_options['arguments']['uid']['specify_validation'] = TRUE; + $handler->display->display_options['arguments']['uid']['validate']['type'] = 'user'; + $handler->display->display_options['arguments']['uid']['validate_options']['type'] = 'either'; + /* Filter criterion: User: Active */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'users'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = '1'; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + $translatables['commons_follow_user'] = array( + t('Master'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('You aren\'t following anyone.'), + t('flag'), + t('flag_user'), + t('Person'), + t('Send email?'), + ); + $export['commons_follow_user'] = $view; + + $view = new view(); + $view->name = 'commons_follow_user_followers'; + $view->description = 'Display a list of users that are following a particular user.'; + $view->tag = 'Commons'; + $view->base_table = 'users'; + $view->human_name = 'Commons Follow - User\'s followers'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Followers'; + $handler->display->display_options['use_ajax'] = TRUE; + $handler->display->display_options['use_more'] = TRUE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['use_more_text'] = 'Show all followers'; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['access']['perm'] = 'access user profiles'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['pager']['options']['items_per_page'] = '16'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['style_plugin'] = 'grid'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'This person has no followers.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: Flags: commons_follow_user */ + $handler->display->display_options['relationships']['flag_content_rel']['id'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel']['table'] = 'users'; + $handler->display->display_options['relationships']['flag_content_rel']['field'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel']['label'] = 'Commons Follow (Users)'; + $handler->display->display_options['relationships']['flag_content_rel']['flag'] = 'commons_follow_user'; + $handler->display->display_options['relationships']['flag_content_rel']['user_scope'] = 'any'; + /* Relationship: Flags: User */ + $handler->display->display_options['relationships']['uid']['id'] = 'uid'; + $handler->display->display_options['relationships']['uid']['table'] = 'flag_content'; + $handler->display->display_options['relationships']['uid']['field'] = 'uid'; + $handler->display->display_options['relationships']['uid']['relationship'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['uid']['required'] = TRUE; + /* Field: User: Name */ + $handler->display->display_options['fields']['name']['id'] = 'name'; + $handler->display->display_options['fields']['name']['table'] = 'users'; + $handler->display->display_options['fields']['name']['field'] = 'name'; + $handler->display->display_options['fields']['name']['relationship'] = 'uid'; + $handler->display->display_options['fields']['name']['label'] = ''; + $handler->display->display_options['fields']['name']['element_label_colon'] = FALSE; + /* Field: User: Picture */ + $handler->display->display_options['fields']['picture']['id'] = 'picture'; + $handler->display->display_options['fields']['picture']['table'] = 'users'; + $handler->display->display_options['fields']['picture']['field'] = 'picture'; + $handler->display->display_options['fields']['picture']['relationship'] = 'uid'; + $handler->display->display_options['fields']['picture']['label'] = ''; + $handler->display->display_options['fields']['picture']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['picture']['image_style'] = '50x50_avatar'; + /* Sort criterion: Flags: Flagged time */ + $handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp'; + $handler->display->display_options['sorts']['timestamp']['table'] = 'flag_content'; + $handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp'; + $handler->display->display_options['sorts']['timestamp']['relationship'] = 'flag_content_rel'; + $handler->display->display_options['sorts']['timestamp']['order'] = 'DESC'; + /* Contextual filter: Flags: Content ID */ + $handler->display->display_options['arguments']['content_id']['id'] = 'content_id'; + $handler->display->display_options['arguments']['content_id']['table'] = 'flag_content'; + $handler->display->display_options['arguments']['content_id']['field'] = 'content_id'; + $handler->display->display_options['arguments']['content_id']['relationship'] = 'flag_content_rel'; + $handler->display->display_options['arguments']['content_id']['default_action'] = 'default'; + $handler->display->display_options['arguments']['content_id']['default_argument_type'] = 'user'; + $handler->display->display_options['arguments']['content_id']['default_argument_options']['user'] = FALSE; + $handler->display->display_options['arguments']['content_id']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['content_id']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['content_id']['summary_options']['items_per_page'] = '25'; + $handler->display->display_options['arguments']['content_id']['specify_validation'] = TRUE; + $handler->display->display_options['arguments']['content_id']['validate']['type'] = 'flag_flaggable_user'; + /* Filter criterion: User: Active */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'users'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = '1'; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + + /* Display: Content pane */ + $handler = $view->new_display('panel_pane', 'Content pane', 'panel_pane_1'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['pane_category']['name'] = 'Commons'; + $handler->display->display_options['pane_category']['weight'] = '0'; + + /* Display: Page */ + $handler = $view->new_display('page', 'Page', 'page_1'); + $handler->display->display_options['defaults']['title'] = FALSE; + $handler->display->display_options['title'] = 'People who follow %1'; + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['defaults']['use_more'] = FALSE; + $handler->display->display_options['defaults']['use_more_always'] = FALSE; + $handler->display->display_options['defaults']['use_more_always'] = FALSE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['defaults']['use_more_text'] = FALSE; + $handler->display->display_options['use_more_text'] = 'Show all followers'; + $handler->display->display_options['defaults']['pager'] = FALSE; + $handler->display->display_options['pager']['type'] = 'load_more'; + $handler->display->display_options['pager']['options']['items_per_page'] = '40'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '0'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['path'] = 'user/%/followers'; + $translatables['commons_follow_user_followers'] = array( + t('Master'), + t('Followers'), + t('Show all followers'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('This person has no followers.'), + t('Commons Follow (Users)'), + t('Flag user'), + t('All'), + t('Content pane'), + t('more'), + t('Commons'), + t('Page'), + t('People who follow %1'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + ); + $export['commons_follow_user_followers'] = $view; + + $view = new view(); + $view->name = 'commons_follow_user_following'; + $view->description = 'A list of users followed by a particular user.'; + $view->tag = 'Commons_follow'; + $view->base_table = 'users'; + $view->human_name = 'Commons Follow - Users that a particular user is following'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Following'; + $handler->display->display_options['use_ajax'] = TRUE; + $handler->display->display_options['use_more'] = TRUE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['use_more_text'] = 'Show all following'; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['access']['perm'] = 'access user profiles'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['pager']['options']['items_per_page'] = '16'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['style_plugin'] = 'grid'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['label'] = 'No results summary'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'This person isn\'t following anyone.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + $handler->display->display_options['empty']['area']['tokenize'] = TRUE; + /* Relationship: Flags: commons_follow_user */ + $handler->display->display_options['relationships']['flag_content_rel']['id'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel']['table'] = 'users'; + $handler->display->display_options['relationships']['flag_content_rel']['field'] = 'flag_content_rel'; + $handler->display->display_options['relationships']['flag_content_rel']['label'] = 'Commons Follow (Users)'; + $handler->display->display_options['relationships']['flag_content_rel']['flag'] = 'commons_follow_user'; + $handler->display->display_options['relationships']['flag_content_rel']['user_scope'] = 'any'; + /* Field: User: Name */ + $handler->display->display_options['fields']['name']['id'] = 'name'; + $handler->display->display_options['fields']['name']['table'] = 'users'; + $handler->display->display_options['fields']['name']['field'] = 'name'; + $handler->display->display_options['fields']['name']['label'] = ''; + $handler->display->display_options['fields']['name']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['name']['alter']['ellipsis'] = FALSE; + /* Field: User: Picture */ + $handler->display->display_options['fields']['picture']['id'] = 'picture'; + $handler->display->display_options['fields']['picture']['table'] = 'users'; + $handler->display->display_options['fields']['picture']['field'] = 'picture'; + $handler->display->display_options['fields']['picture']['label'] = ''; + $handler->display->display_options['fields']['picture']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['picture']['image_style'] = '50x50_avatar'; + /* Sort criterion: Flags: Flagged time */ + $handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp'; + $handler->display->display_options['sorts']['timestamp']['table'] = 'flag_content'; + $handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp'; + $handler->display->display_options['sorts']['timestamp']['relationship'] = 'flag_content_rel'; + $handler->display->display_options['sorts']['timestamp']['order'] = 'DESC'; + /* Contextual filter: Flags: User uid */ + $handler->display->display_options['arguments']['uid']['id'] = 'uid'; + $handler->display->display_options['arguments']['uid']['table'] = 'flag_content'; + $handler->display->display_options['arguments']['uid']['field'] = 'uid'; + $handler->display->display_options['arguments']['uid']['relationship'] = 'flag_content_rel'; + $handler->display->display_options['arguments']['uid']['default_action'] = 'default'; + $handler->display->display_options['arguments']['uid']['default_argument_type'] = 'user'; + $handler->display->display_options['arguments']['uid']['default_argument_options']['user'] = FALSE; + $handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25'; + $handler->display->display_options['arguments']['uid']['validate']['type'] = 'user'; + /* Filter criterion: User: Active */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'users'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = '1'; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + + /* Display: Content pane */ + $handler = $view->new_display('panel_pane', 'Content pane', 'panel_pane_1'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['pane_category']['name'] = 'Commons'; + $handler->display->display_options['pane_category']['weight'] = '0'; + + /* Display: Page */ + $handler = $view->new_display('page', 'Page', 'page_1'); + $handler->display->display_options['defaults']['title'] = FALSE; + $handler->display->display_options['title'] = 'People %1 follows'; + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['defaults']['use_more'] = FALSE; + $handler->display->display_options['defaults']['use_more_always'] = FALSE; + $handler->display->display_options['defaults']['use_more_always'] = FALSE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['defaults']['use_more_text'] = FALSE; + $handler->display->display_options['use_more_text'] = 'Show all following'; + $handler->display->display_options['defaults']['pager'] = FALSE; + $handler->display->display_options['pager']['type'] = 'load_more'; + $handler->display->display_options['pager']['options']['items_per_page'] = '40'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '0'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['path'] = 'user/%/following'; + $translatables['commons_follow_user_following'] = array( + t('Master'), + t('Following'), + t('Show all following'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('No results summary'), + t('This person isn\'t following anyone.'), + t('Commons Follow (Users)'), + t('All'), + t('Content pane'), + t('more'), + t('Commons'), + t('Page'), + t('People %1 follows'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + ); + $export['commons_follow_user_following'] = $view; + + return $export; +} diff --git a/modules/commons/commons_follow/includes/views/commons_follow.views.inc b/modules/commons/commons_follow/includes/views/commons_follow.views.inc new file mode 100644 index 0000000..0eaea15 --- /dev/null +++ b/modules/commons/commons_follow/includes/views/commons_follow.views.inc @@ -0,0 +1,52 @@ + array( + 'commons_follow_node' => array( + 'title' => t('The node IDs the user is subscribed to'), + 'handler' => 'commons_follow_plugin_argument_default_node', + ), + 'commons_follow_message' => array( + 'title' => t('The message IDs the user is subscribed to'), + 'handler' => 'commons_follow_plugin_argument_default_message', + ), + ), + ); +} + +/** + * Implements hook_views_data(). + */ +function commons_follow_views_data() { + $data['node']['cf_user_follow'] = array( + 'title' => t('User Follow'), // The item it appears as on the UI, + 'help' => t('Whether the user is following this content.'), // The help that appears on the UI, + 'real field' => 'nid', + // Information for displaying a title as a field + 'filter' => array( + 'handler' => 'commons_follow_user_follow_filter', + 'label' => t('Following'), + 'type' => 'yes-no', + ), + ); + + $data['message']['cf_user_follow_message'] = array( + 'title' => t('User Follow'), // The item it appears as on the UI, + 'help' => t('Whether the user is following items related to this message.'), // The help that appears on the UI, + 'real field' => 'mid', + // Information for displaying a title as a field + 'filter' => array( + 'handler' => 'commons_follow_user_follow_filter_message', + 'label' => t('Following'), + 'type' => 'yes-no', + ), + ); + + return $data; +} diff --git a/modules/commons/commons_follow/includes/views/handlers/commons_follow_handler_field_ops.inc b/modules/commons/commons_follow/includes/views/handlers/commons_follow_handler_field_ops.inc new file mode 100644 index 0000000..3770782 --- /dev/null +++ b/modules/commons/commons_follow/includes/views/handlers/commons_follow_handler_field_ops.inc @@ -0,0 +1,62 @@ +view->args[0]) && $user->uid != $this->view->args[0]) { + + if (!($flag = $this->get_flag())) { + // get_flag() itself will print a more detailed message. + return t('Missing flag'); + } + $content_id = $values->{$this->aliases['content_id']}; + $is_flagged = $values->{$this->aliases['is_flagged']}; + + if (empty($this->flag_applies[$content_id])) { + // Flag does not apply to this content. + return; + } + + if (!empty($this->options['link_type'])) { + $flag->link_type = $this->options['link_type']; + } + + $variables = array(); + $action = $is_flagged ? 'unflag' : 'flag'; + $variables['flag_css_name'] = str_replace('_', '-', $flag->name); + + $flag_wrapper_classes_array = array(); + $flag_wrapper_classes_array[] = 'flag-wrapper'; + $flag_wrapper_classes_array[] = 'flag-' . $variables['flag_css_name']; + $flag_wrapper_classes_array[] = 'flag-' . $variables['flag_css_name'] . '-' . $content_id; + $variables['flag_wrapper_classes'] = implode(' ',$flag_wrapper_classes_array); + + $flag_classes_array = array(); + $flag_classes_array[] = 'flag'; + $flag_classes_array[] = $action . '-action'; + $flag_classes_array[] = 'flag-link-' . $flag->link_type; + $variables['flag_classes'] = implode(' ', $flag_classes_array); + $variables['is_flagged'] = $action; + $variables['link_text'] = $flag->get_label($action . '_short', $content_id); + + return theme('commons_follow_otheruser_flag', $variables); + } + else { + return parent::render($values); + } + +// return $flag->theme($is_flagged ? 'unflag' : 'flag', $content_id); + } +} diff --git a/modules/commons/commons_follow/includes/views/handlers/commons_follow_plugin_argument_default_message.inc b/modules/commons/commons_follow/includes/views/handlers/commons_follow_plugin_argument_default_message.inc new file mode 100644 index 0000000..0cc1a2a --- /dev/null +++ b/modules/commons/commons_follow/includes/views/handlers/commons_follow_plugin_argument_default_message.inc @@ -0,0 +1,21 @@ +view->argument as $argument_name => $argument) { + if ($argument->options['default_argument_type'] == 'commons_follow_node') { + // The argument that toggles 'following' or 'not following' display. + $this->view->argument[$argument_name]->options['not'] = !$this->value; + break; + } + } + } +} \ No newline at end of file diff --git a/modules/commons/commons_follow/includes/views/handlers/commons_follow_user_follow_filter_message.inc b/modules/commons/commons_follow/includes/views/handlers/commons_follow_user_follow_filter_message.inc new file mode 100644 index 0000000..eb63d2b --- /dev/null +++ b/modules/commons/commons_follow/includes/views/handlers/commons_follow_user_follow_filter_message.inc @@ -0,0 +1,23 @@ +value == 0) { + foreach ($this->view->argument as $argument_name => $argument) { + if ($argument->options['default_argument_type'] == 'commons_follow_message') { + $this->view->argument[$argument_name]->options['not'] = !$this->value; + } + } + } + } +} diff --git a/modules/commons/commons_groups/commons_groups.features.field_base.inc b/modules/commons/commons_groups/commons_groups.features.field_base.inc new file mode 100644 index 0000000..f60237e --- /dev/null +++ b/modules/commons/commons_groups/commons_groups.features.field_base.inc @@ -0,0 +1,287 @@ + '1', + 'cardinality' => '1', + 'deleted' => '0', + 'entity_types' => array(), + 'field_name' => 'group_access', + 'foreign keys' => array(), + 'indexes' => array( + 'value' => array( + 0 => 'value', + ), + ), + 'locked' => '0', + 'module' => 'list', + 'no_ui' => TRUE, + 'settings' => array( + 'allowed_values' => array( + 0 => 'Public - accessible to all site users', + 1 => 'Private - accessible only to group members', + ), + 'allowed_values_function' => '', + ), + 'translatable' => '0', + 'type' => 'list_boolean', + ); + + // Exported field_base: 'group_content_access' + $field_bases['group_content_access'] = array( + 'active' => '1', + 'cardinality' => '1', + 'deleted' => '0', + 'entity_types' => array(), + 'field_name' => 'group_content_access', + 'foreign keys' => array(), + 'indexes' => array( + 'value' => array( + 0 => 'value', + ), + ), + 'locked' => '0', + 'module' => 'list', + 'no_ui' => TRUE, + 'settings' => array( + 'allowed_values' => array( + 0 => 'Use group defaults', + 1 => 'Public - accessible to all site users', + 2 => 'Private - accessible only to group members', + ), + 'allowed_values_function' => '', + ), + 'translatable' => '0', + 'type' => 'list_integer', + ); + + // Exported field_base: 'field_og_access_default_value' + $field_bases['field_og_access_default_value'] = array( + 'active' => '1', + 'cardinality' => '1', + 'deleted' => '0', + 'entity_types' => array(), + 'field_name' => 'field_og_access_default_value', + 'foreign keys' => array(), + 'indexes' => array( + 'value' => array( + 0 => 'value', + ), + ), + 'locked' => '0', + 'module' => 'list', + 'settings' => array( + 'allowed_values' => array( + 0 => '', + 1 => '', + ), + 'allowed_values_function' => '', + ), + 'translatable' => '0', + 'type' => 'list_boolean', + ); + + // Exported field_base: 'field_og_subscribe_settings' + $field_bases['field_og_subscribe_settings'] = array( + 'active' => '1', + 'cardinality' => '1', + 'deleted' => '0', + 'entity_types' => array(), + 'field_name' => 'field_og_subscribe_settings', + 'foreign keys' => array(), + 'indexes' => array( + 'value' => array( + 0 => 'value', + ), + ), + 'locked' => '0', + 'module' => 'list', + 'settings' => array( + 'allowed_values' => array( + 'anyone' => 'Any site member can contribute', + 'approval' => 'Joining requires admin approval', + 'invitation' => 'Joining requires an invitation', + ), + 'allowed_values_function' => '', + ), + 'translatable' => '0', + 'type' => 'list_text', + ); + + // Alter the "approval" description when og_access is on. + if (module_exists('og_access')) { + $field_bases['field_og_subscribe_settings']['settings']['allowed_values']['invitation'] = 'Joining requires an invitation. The group and content is hidden from non-members.'; + } + + // Exported field_base: 'group_group' + $field_bases['group_group'] = array( + 'active' => '1', + 'cardinality' => '1', + 'deleted' => '0', + 'entity_types' => array(), + 'field_name' => 'group_group', + 'foreign keys' => array(), + 'indexes' => array( + 'value' => array( + 0 => 'value', + ), + ), + 'locked' => '0', + 'module' => 'list', + 'settings' => array( + 'allowed_values' => array( + 0 => 'Not a group', + 1 => 'Group', + ), + 'allowed_values_function' => '', + ), + 'translatable' => '0', + 'type' => 'list_boolean', + ); + +// Exported field_base: 'og_group_ref' + $field_bases['og_group_ref'] = array( + 'active' => '1', + 'cardinality' => '-1', + 'deleted' => '0', + 'entity_types' => array(), + 'description' => 'Separate group names with commas', + 'field_name' => 'og_group_ref', + 'foreign keys' => array( + 'node' => array( + 'columns' => array( + 'target_id' => 'nid', + ), + 'table' => 'node', + ), + ), + 'indexes' => array( + 'target_id' => array( + 0 => 'target_id', + ), + ), + 'locked' => '0', + 'module' => 'entityreference', + 'settings' => array( + 'handler' => 'og_commons', + 'handler_settings' => array( + 'behaviors' => array( + 'og_behavior' => array( + 'status' => TRUE, + ), + 'views-select-list' => array( + 'status' => 0, + ), + ), + 'membership_type' => 'og_membership_type_default', + 'sort' => array( + 'type' => 'none', + ), + 'target_bundles' => array(), + ), + 'handler_submit' => 'Change handler', + 'target_type' => 'node', + ), + 'target_type' => 'node', + 'translatable' => '0', + 'type' => 'entityreference', + ); + + + // Exported field_base: 'og_membership_request' + $field_bases['og_membership_request'] = array( + 'active' => '1', + 'cardinality' => '1', + 'deleted' => '0', + 'entity_types' => array( + 0 => 'og_membership', + ), + 'field_name' => 'og_membership_request', + 'foreign keys' => array( + 'format' => array( + 'columns' => array( + 'format' => 'format', + ), + 'table' => 'filter_format', + ), + ), + 'indexes' => array( + 'format' => array( + 0 => 'format', + ), + ), + 'locked' => '0', + 'module' => 'text', + 'settings' => array(), + 'translatable' => '0', + 'type' => 'text_long', + ); + + // Exported field_base: 'field_group_logo' + $field_bases['field_group_logo'] = array( + 'active' => '1', + 'cardinality' => '1', + 'deleted' => '0', + 'entity_types' => array(), + 'field_name' => 'field_group_logo', + 'foreign keys' => array( + 'fid' => array( + 'columns' => array( + 'fid' => 'fid', + ), + 'table' => 'file_managed', + ), + ), + 'indexes' => array( + 'fid' => array( + 0 => 'fid', + ), + ), + 'locked' => '0', + 'module' => 'image', + 'settings' => array( + 'default_image' => 0, + 'uri_scheme' => 'public', + ), + 'translatable' => '0', + 'type' => 'image', + ); + + // Exported field_base: 'og_roles_permissions' + $field_bases['og_roles_permissions'] = array( + 'active' => '1', + 'cardinality' => '1', + 'deleted' => '0', + 'entity_types' => array(), + 'field_name' => 'og_roles_permissions', + 'foreign keys' => array(), + 'indexes' => array( + 'value' => array( + 0 => 'value', + ), + ), + 'locked' => '0', + 'module' => 'list', + 'settings' => array( + 'allowed_values' => array( + 0 => 'Use default roles and permissions', + 1 => 'Override default roles and permissions', + ), + 'allowed_values_function' => '', + ), + 'translatable' => '0', + 'type' => 'list_boolean', + ); + + return $field_bases; +} diff --git a/modules/commons/commons_groups/commons_groups.features.field_instance.inc b/modules/commons/commons_groups/commons_groups.features.field_instance.inc new file mode 100644 index 0000000..0144c87 --- /dev/null +++ b/modules/commons/commons_groups/commons_groups.features.field_instance.inc @@ -0,0 +1,536 @@ + $bundles) { + foreach(array_keys($bundles) as $bundle) { + commons_groups_field_definition($field_instances, $entity_type, $bundle); + } + } + } + $group_bundles = og_get_all_group_bundle(); + + if (empty($group_bundles['node'])) { + // Make sure group_bundles contains at least the group node bundle, in order + // to create the group audience field for it when installing the profile. + $group_bundles['node'] = array('group' => TRUE); + } + foreach(array_keys($group_bundles['node']) as $bundle) { + commons_groups_field_definition_group($field_instances, 'node', $bundle); + } + + // Exported field_instance: 'og_membership-og_membership_type_default-og_membership_request' + $field_instances['og_membership-og_membership_type_default-og_membership_request'] = array( + 'bundle' => 'og_membership_type_default', + 'default_value' => NULL, + 'deleted' => '0', + 'description' => 'This is the text a user may send to the group administrators.', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 0, + ), + ), + 'entity_type' => 'og_membership', + 'field_name' => 'og_membership_request', + 'label' => 'Request message', + 'required' => FALSE, + 'settings' => array( + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'module' => 'text', + 'settings' => array( + 'rows' => 5, + ), + 'type' => 'text_textarea', + 'weight' => 0, + ), + ); + + // Translatables + // Included for use with string extractors like potx. + t('Determine if this is an OG group.'); + t('Group'); + t('Group membership'); + t('Group visibility'); + t('Group content visibility'); + t('Group roles and permissions'); + t('Request message'); + t('This is the text a user may send to the group administrators.'); + t('Group Logo'); + t('Hide contributed content from non-members'); + t('Privacy settings'); + + return $field_instances; +} + +function commons_groups_field_definition_group(&$field_instances, $entity_type, $bundle) { + // Exported field_instance: 'node-group-field_og_subscribe_settings' + $field_instances["$entity_type-$bundle-field_og_subscribe_settings"] = array( + 'bundle' => $bundle, + 'default_value' => array( + 0 => array( + 'value' => 'anyone', + ), + ), + 'deleted' => '0', + 'description' => t("These privacy settings will not change the visibility of content that has already posted into this group. It takes effect only for content created after the group is saved with new privacy settings."), + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'list', + 'settings' => array(), + 'type' => 'list_default', + 'weight' => 4, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_og_subscribe_settings', + 'label' => 'Privacy settings', + 'required' => 1, + 'settings' => array( + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'options', + 'settings' => array(), + 'type' => 'options_buttons', + 'weight' => '41', + ), + ); + + // Exported field_instance: 'node-group-field_og_access_default_value' + $field_instances["$entity_type-$bundle-field_og_access_default_value"] = array( + 'bundle' => $bundle, + 'default_value' => array( + 0 => array( + 'value' => 0, + ), + ), + 'deleted' => '0', + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 5, + ), + 'teaser' => array( + 'label' => 'hidden', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_og_access_default_value', + 'label' => 'Hide contributed content from non-members', + 'required' => 0, + 'settings' => array( + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'options', + 'settings' => array( + 'display_label' => 1, + ), + 'type' => 'options_onoff', + 'weight' => '42', + ), + ); + + // Exported field_instance: 'node-group-og_roles_permissions' + $field_instances["$entity_type-$bundle-og_roles_permissions"] = array( + 'bundle' => $bundle, + 'default_value' => array( + 0 => array( + 'value' => 1, + ), + ), + 'deleted' => '0', + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'list', + 'settings' => array(), + 'type' => 'list_default', + 'weight' => 1, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'og_roles_permissions', + 'label' => 'Group roles and permissions', + 'required' => TRUE, + 'settings' => array( + 'user_register_form' => FALSE, + ), + 'view modes' => array( + 'full' => array( + 'custom settings' => FALSE, + 'label' => 'Full', + 'type' => 'list_default', + ), + 'teaser' => array( + 'custom settings' => FALSE, + 'label' => 'Teaser', + 'type' => 'list_default', + ), + ), + 'widget' => array( + 'module' => 'options', + 'settings' => array(), + 'type' => 'options_select', + 'weight' => 1, + ), + ); + // Exported field_instance: 'node-group-body' + $field_instances["$entity_type-$bundle-body"] = array( + 'bundle' => $bundle, + 'default_value' => NULL, + 'deleted' => '0', + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 1, + ), + 'teaser' => array( + 'label' => 'hidden', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'body', + 'label' => 'Description', + 'required' => 0, + 'settings' => array( + 'display_summary' => 0, + 'text_processing' => '1', + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'rows' => '20', + 'summary_rows' => 5, + ), + 'type' => 'text_textarea_with_summary', + 'weight' => '4', + ), + ); + + // Exported field_instance: 'node-group-group_group' + $field_instances["$entity_type-$bundle-" . OG_GROUP_FIELD] = array( + 'bundle' => $bundle, + 'default_value' => array( + 0 => array( + 'value' => 1, + ), + ), + 'deleted' => '0', + 'description' => 'Determine if this is an OG group.', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'module' => 'commons_groups', + 'settings' => array( + 'field_name' => '0', + ), + 'type' => 'commons_groups_group_subscribe', + 'weight' => '0', + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'display_label' => 1, + 'entity_type' => 'node', + 'field_name' => OG_GROUP_FIELD, + 'label' => 'Group', + 'required' => FALSE, + 'settings' => array( + 'user_register_form' => FALSE, + ), + 'view modes' => array( + 'full' => array( + 'custom settings' => FALSE, + 'label' => 'Full', + 'type' => 'og_group_subscribe', + ), + 'teaser' => array( + 'custom settings' => FALSE, + 'label' => 'Teaser', + 'type' => 'og_group_subscribe', + ), + ), + 'widget' => array( + 'module' => 'options', + 'settings' => array( + 'display_label' => 0, + 'og_hide' => TRUE, + ), + 'type' => 'options_onoff', + 'weight' => 0, + ), + ); + + // Exported field_instance: 'node-group-group_access' + $field_instances["$entity_type-$bundle-group_access"] = array( + 'bundle' => $bundle, + 'default_value' => array( + 0 => array( + 'value' => 0, + ), + ), + 'deleted' => '0', + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 4, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'group_access', + 'label' => 'Group visibility', + 'required' => TRUE, + 'settings' => array( + 'user_register_form' => FALSE, + ), + 'view modes' => array( + 'full' => array( + 'label' => 'above', + 'type' => 'options_onoff', + ), + 'teaser' => array( + 'label' => 'above', + 'type' => 'options_onoff', + ), + ), + 'widget' => array( + 'module' => 'options', + 'settings' => array(), + 'type' => 'options_buttons', + 'weight' => 41, + ), + 'widget_type' => 'options_select', + ); + + // Exported field_instance: 'node-group-field_group_logo' + $field_instances["$entity_type-$bundle-field_group_logo"] = array( + 'bundle' => $bundle, + 'deleted' => '0', + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'module' => 'image', + 'settings' => array( + 'image_link' => '', + 'image_style' => '50x50', + ), + 'type' => 'image', + 'weight' => '0', + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_group_logo', + 'label' => 'Group Logo', + 'required' => 0, + 'settings' => array( + 'alt_field' => 0, + 'default_image' => 0, + 'file_directory' => '', + 'file_extensions' => 'png gif jpg jpeg', + 'max_filesize' => '20mb', + 'max_resolution' => '', + 'min_resolution' => '30x30', + 'title_field' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'image', + 'settings' => array( + 'preview_image_style' => 'thumbnail', + 'progress_indicator' => 'throbber', + ), + 'type' => 'image_image', + 'weight' => '5', + ), + ); +} + +function commons_groups_field_definition(&$field_instances, $entity_type, $bundle) { + // Exported field_instance: 'node-post-og_group_ref' + $field_instances["$entity_type-$bundle-og_group_ref"] = array( + 'bundle' => $bundle, + 'default_value' => NULL, + 'default_value_function' => 'commons_groups_entityreference_default_value', + 'deleted' => '0', + 'description' => 'Separate group names with commas', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'og_ui', + 'settings' => array(), + 'type' => 'og_list_default', + 'weight' => 11, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => $entity_type, + 'field_name' => 'og_group_ref', + 'label' => 'Groups', + 'required' => 0, + 'settings' => array( + 'behaviors' => array( + 'og_widget' => array( + 'admin' => array( + 'widget_type' => 'entityreference_autocomplete_tags', + ), + 'default' => array( + 'widget_type' => 'entityreference_autocomplete_tags', + ), + 'status' => TRUE, + ), + 'prepopulate' => array( + 'action' => 'none', + 'fallback' => 'none', + 'og_context' => 0, + 'skip_perm' => '0', + 'status' => 1, + ), + ), + 'user_register_form' => FALSE, + ), + 'view modes' => array( + 'full' => array( + 'custom settings' => FALSE, + 'label' => 'Full', + 'type' => 'og_list_default', + ), + 'teaser' => array( + 'custom settings' => FALSE, + 'label' => 'Teaser', + 'type' => 'og_list_default', + ), + ), + 'widget' => array( + 'active' => 0, + 'module' => 'og', + 'settings' => array(), + 'type' => 'og_complex', + 'weight' => 5, + ), + ); + + // Exported field_instance: '[entity]-[bundle]-group_content_access' + $field_instances["$entity_type-$bundle-group_content_access"] = array( + 'bundle' => $bundle, + 'default_value' => array( + 0 => array( + 'value' => 0, + ), + ), + 'deleted' => '0', + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 5, + ), + 'teaser' => array( + 'label' => 'hidden', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => $entity_type, + 'field_name' => 'group_content_access', + 'label' => 'Group content visibility', + 'required' => TRUE, + 'settings' => array( + 'user_register_form' => FALSE, + ), + 'view modes' => array( + 'full' => array( + 'label' => 'above', + 'type' => 'list_default', + ), + 'teaser' => array( + 'label' => 'above', + 'type' => 'list_default', + ), + ), + 'widget' => array( + 'module' => 'options', + 'settings' => array(), + 'type' => 'options_select', + 'weight' => 16, + ), + 'widget_type' => 'options_select', + ); +} diff --git a/modules/commons/commons_groups/commons_groups.features.inc b/modules/commons/commons_groups/commons_groups.features.inc new file mode 100644 index 0000000..b3aab7a --- /dev/null +++ b/modules/commons/commons_groups/commons_groups.features.inc @@ -0,0 +1,93 @@ + "1"); + } +} + +/** + * Implements hook_views_api(). + */ +function commons_groups_views_api($module = NULL, $api = NULL) { + return array("api" => "3.0"); +} + +/** + * Implements hook_image_default_styles(). + */ +function commons_groups_image_default_styles() { + $styles = array(); + + // Exported image style: 35x35. + $styles['35x35'] = array( + 'label' => '35x35', + 'name' => '35x35', + 'effects' => array( + 1 => array( + 'label' => 'Scale and crop', + 'help' => 'Scale and crop will maintain the aspect-ratio of the original image, then crop the larger dimension. This is most useful for creating perfectly square thumbnails without stretching the image.', + 'effect callback' => 'image_scale_and_crop_effect', + 'dimensions callback' => 'image_resize_dimensions', + 'form callback' => 'image_resize_form', + 'summary theme' => 'image_resize_summary', + 'module' => 'image', + 'name' => 'image_scale_and_crop', + 'data' => array( + 'width' => 35, + 'height' => 35, + ), + 'weight' => 1, + ), + ), + ); + + // Exported image style: 50x50. + $styles['50x50'] = array( + 'label' => '50x50', + 'name' => '50x50', + 'effects' => array( + 2 => array( + 'label' => 'Scale and crop', + 'help' => 'Scale and crop will maintain the aspect-ratio of the original image, then crop the larger dimension. This is most useful for creating perfectly square thumbnails without stretching the image.', + 'effect callback' => 'image_scale_and_crop_effect', + 'dimensions callback' => 'image_resize_dimensions', + 'form callback' => 'image_resize_form', + 'summary theme' => 'image_resize_summary', + 'module' => 'image', + 'name' => 'image_scale_and_crop', + 'data' => array( + 'width' => 50, + 'height' => 50, + ), + 'weight' => 1, + ), + ), + ); + + return $styles; +} + +/** + * Implements hook_node_info(). + */ +function commons_groups_node_info() { + $items = array( + 'group' => array( + 'name' => t('Group'), + 'base' => 'node_content', + 'description' => t('Use groups to contain people and content related by a shared interest or purpose.'), + 'has_title' => '1', + 'title_label' => t('Group name'), + 'help' => '', + ), + ); + return $items; +} diff --git a/modules/commons/commons_groups/commons_groups.features.user_permission.inc b/modules/commons/commons_groups/commons_groups.features.user_permission.inc new file mode 100644 index 0000000..ec080a3 --- /dev/null +++ b/modules/commons/commons_groups/commons_groups.features.user_permission.inc @@ -0,0 +1,40 @@ + $group_info) { + // Exported permission: 'create group content'. + $permissions["create $bundle content"] = array( + 'name' => "create $bundle content", + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + // Exported permission: 'edit own group content'. + $permissions["edit own $bundle content"] = array( + 'name' => "edit own $bundle content", + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + } + } + + return $permissions; +} diff --git a/modules/commons/commons_groups/commons_groups.info b/modules/commons/commons_groups/commons_groups.info new file mode 100644 index 0000000..59a4f2a --- /dev/null +++ b/modules/commons/commons_groups/commons_groups.info @@ -0,0 +1,74 @@ +name = Commons Groups +description = Commons Organic Groups Functionality +core = 7.x +package = Commons - Building blocks +dependencies[] = commons_body +dependencies[] = commons_bw +dependencies[] = commons_topics +dependencies[] = ctools +dependencies[] = date +dependencies[] = entity +dependencies[] = entityreference +dependencies[] = entityreference_prepopulate +dependencies[] = features +dependencies[] = image +dependencies[] = link +dependencies[] = list +dependencies[] = message +dependencies[] = node +dependencies[] = og +dependencies[] = og_ui +dependencies[] = options +dependencies[] = radioactivity +dependencies[] = strongarm +dependencies[] = taxonomy +dependencies[] = text +dependencies[] = views +dependencies[] = views_content +dependencies[] = views_litepager +dependencies[] = views_load_more +features[ctools][] = strongarm:strongarm:1 +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[field_base][] = field_group_logo +features[field_base][] = field_og_access_default_value +features[field_base][] = field_og_subscribe_settings +features[field_base][] = group_access +features[field_base][] = group_content_access +features[field_base][] = group_group +features[field_base][] = og_group_ref +features[field_base][] = og_membership_request +features[field_base][] = og_roles_permissions +features[field_instance][] = node-group-body +features[field_instance][] = node-group-group_group +features[field_instance][] = og_membership-og_membership_type_default-og_membership_request +features[image][] = 35x35 +features[image][] = 50x50 +features[node][] = group +features[user_permission][] = create group content +features[user_permission][] = edit own group content +features[variable][] = comment_anonymous_group +features[variable][] = comment_default_mode_group +features[variable][] = comment_default_per_page_group +features[variable][] = comment_form_location_group +features[variable][] = comment_group +features[variable][] = comment_preview_group +features[variable][] = comment_subject_field_group +features[variable][] = field_bundle_settings_node__group +features[variable][] = menu_options_group +features[variable][] = menu_parent_group +features[variable][] = node_options_group +features[variable][] = node_preview_group +features[variable][] = node_submitted_group +features[variable][] = og_group_manager_default_rids_node_group +features[variable][] = pathauto_node_group_pattern +features[variable][] = pathauto_node_pattern +features[views_view][] = commons_bw_all +features[views_view][] = commons_contributors_group +features[views_view][] = commons_group_moderation +features[views_view][] = commons_groups_contributors +features[views_view][] = commons_groups_directory +features[views_view][] = commons_groups_recent_content +features[views_view][] = commons_groups_user_groups +features_exclude[field][node-group-group_group] = node-group-group_group +features_exclude[field][node-group-group_access] = node-group-group_access diff --git a/modules/commons/commons_groups/commons_groups.install b/modules/commons/commons_groups/commons_groups.install new file mode 100644 index 0000000..bee25d7 --- /dev/null +++ b/modules/commons/commons_groups/commons_groups.install @@ -0,0 +1,212 @@ + array('variable'))); + return array(); +} +/** +* Grant users the "group organizer" role after she's created a group. +*/ +function commons_groups_update_3101() { + // We've updated the og_group_manager_default_rids_node_group variable. + features_revert(array('commons_groups' => array('variable'))); + return array(); +} + +/** +* Ensure that the anonymous users is not listed as a group member, +* per http://drupal.org/node/1910874. +*/ +function commons_groups_update_3102() { + $delete = db_delete('og_users_roles') + ->condition('uid', 0, '=') + ->execute(); + return array(); +} + +/** +* Grant authenticated users permission to create group nodes +* per http://drupal.org/node/1936714. +*/ +function commons_groups_update_3103() { + features_revert(array('commons_groups' => array('user_permission'))); + return array(); +} + +/** +* Grant authenticated users permission to create group nodes +* per http://drupal.org/node/1936714. +*/ +function commons_groups_update_3104() { + features_revert(array('commons_groups' => array('field_base', 'field_instance'))); + return array(); +} + +/** + * Change the OG Organizer role back to Administrator member. + * See http://drupal.org/node/1940150 for more information. + */ +function commons_groups_update_3105() { + $result = db_update('og_role') + ->fields(array('name' => 'administrator member')) + ->condition('rid', 3, '=') + ->execute(); + return array(); +} + +/** + * Update contributor view to show the titles per the interactive prototype. + * (http://drupal.org/node/1821808). + */ +function commons_groups_update_3106() { + $revert = array( + 'commons_groups' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Give group owners the organizer role for their own group + */ +function commons_groups_update_3107() { + // Ensure that the group creator is also listed as an organizer. + $group_nodes = db_select('node', 'n') + ->fields('n', array('nid', 'uid')) + ->condition('n.type', 'group','=') + ->execute() + ->fetchAll(); + $organizer_role = db_select('og_role', 'o') + ->fields('o', array('rid')) + ->condition('o.group_bundle', 'group') + ->condition('o.name', 'administrator member') + ->execute() + ->fetchField(); + + foreach($group_nodes as $record) { + if (!empty($organizer_role)) { + og_role_grant('node', $record->nid, $record->uid, $organizer_role); + } + } + return array(); +} + +/** + * Update the og_group_ref and group privacy fields per + * http://drupal.org/node/1961296. + */ +function commons_groups_update_3108() { + $revert = array( + 'commons_groups' => array('field_instance', 'views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Update the group_group field per http://drupal.org/node/1948224 and + * disable the deprecated Commons Group Privacy module + * per https://drupal.org/node/1961296. + */ +function commons_groups_update_3109() { + // Commons Group Privacy was deprecated in https://drupal.org/node/1961296. + module_disable('commons_group_privacy', TRUE); + $revert = array( + 'commons_groups' => array('field_base', 'field_instance'), + ); + features_revert($revert); + return array(); +} + +/** + * Update the og group filter inside views per + * http://drupal.org/node/2037417. + */ +function commons_groups_update_3110() { + $revert = array( + 'commons_groups' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Set commons_groups to display need update message for those upgrading from 3.2 + * and revert the view to add the update display + * See https://drupal.org/node/2059857#comment-7733465 + */ +function commons_groups_update_3111() { + variable_set('commons_groups_needs_update', TRUE); + $revert = array( + 'commons_groups' => array('views_view'), + ); + features_revert($revert); + // Ensure that the menu callback from our new Views display is active. + menu_rebuild(); + return array(); +} + +/** + * Update the og group filter inside views per + * http://drupal.org/node/2037417. + */ +function commons_groups_update_3112() { + $revert = array( + 'commons_radioactivity' => array('views_view'), + 'commons_activity_streams' => array('views_view'), + 'commons_groups' => array('views_view'), + 'commons_polls' => array('views_view'), + 'commons_posts' => array('views_view'), + 'commons_wikis' => array('views_view'), + 'commons_q_a' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Standardize Browsing Widget views. + */ +function commons_groups_update_3113() { + $revert = array( + 'commons_groups' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Display sticky content at top of lists. + */ +function commons_groups_update_3114() { + $revert = array( + 'commons_groups' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Add empty text to Commons Groups views. + */ +function commons_groups_update_3115() { + $revert = array( + 'commons_groups' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Improve the browsing widget empty text. + */ +function commons_groups_update_3116() { + $revert = array( + 'commons_groups' => array('views_view'), + ); + features_revert($revert); + return array(); +} diff --git a/modules/commons/commons_groups/commons_groups.module b/modules/commons/commons_groups/commons_groups.module new file mode 100644 index 0000000..133307f --- /dev/null +++ b/modules/commons/commons_groups/commons_groups.module @@ -0,0 +1,1163 @@ + array('field_base'))); + features_revert(array('commons_groups' => array('field_instance'))); + } +} + +/** + * Implements hook_help(). + * Used for the 3.2 -> 3.3 migration to warn users who have out-of-date groups + * to make sure they update the group privacy settings. + * See https://drupal.org/node/2059857 for more information + */ +function commons_groups_help($path, $arg) { + if (variable_get('commons_groups_needs_update', FALSE)) { + $message = '

' . t("Drupal Commons 3.3 added a new, required field to control group privacy. Please edit your group(s) select one of the privacy options. Once all groups are + set, an administrator can dismiss the update notice.") . '

'; + if ($path == 'admin/content/groups/update') { + return $message; + } + elseif ($arg[0] == 'node' && $arg[2] == 'edit') { + $node = menu_get_object(); + if($node->type == 'group' && empty($node->field_og_subscribe_settings)) { + return $message; + } + } + if (user_access('edit any group content')) { + $message = t("Group privacy settings !updated.", array('!updated' => l('need to be updated', 'admin/content/groups/update'))); + drupal_set_message($message, 'warning', FALSE); + } + } +} + +/** + * Implements hook_entity_view(). + */ +function commons_groups_entity_view($entity, $type, $view_mode, $langcode) { + // Set a breadcrumb for nodes in groups. We currently assume that + // nodes are groups. + if ($view_mode == 'full' && !empty($entity->og_group_ref[LANGUAGE_NONE][0]['target_id']) && $type != 'user') { + $breadcrumb = array(); + $breadcrumb[] = l(t('Home'), NULL); + $breadcrumb[] = l(t('Groups'), 'groups'); + $group = node_load($entity->og_group_ref[LANGUAGE_NONE][0]['target_id']); + if (node_access('view', $group)) { + $breadcrumb[] = l($group->title, 'node/' . $group->nid); + } + drupal_set_breadcrumb($breadcrumb); + } +} + + +/** + * Implements hook_form_FORM_ID_alter(). + * + * Alter the privacy settings fields. + */ +function commons_groups_form_node_form_alter(&$form, &$form_state) { + $groups = og_get_all_group_bundle(); + + if (isset($groups['node']) && in_array($form_state['node']->type, array_keys($groups['node']))) { + // The group privacy settings are not required. + $form['field_og_subscribe_settings'][LANGUAGE_NONE]['#required'] = FALSE; + + if (module_exists('og_access')) { + // Display private content checkbox only when "Joining requires approval" + // is selected. + $form['field_og_access_default_value']['#states'] = array( + 'visible' => array( + ':input[name="field_og_subscribe_settings[' . LANGUAGE_NONE . ']"]' => array('value' => 'approval'), + ), + ); + + $form['#after_build'] = array('commons_groups_form_group_node_after_build'); + } + + $form['#attached']['css'] = array( + drupal_get_path('module', 'commons_groups') . '/css/commons_groups.css', + ); + + // The group access is set on commons_groups_node_presave(). + $form['group_access'][LANGUAGE_NONE]['#required'] = FALSE; + $form['group_access']['#access'] = FALSE; + } +} + +/** + * After build callback for the group node form. + * + * Display the private content checkbox inside the privacy settings field. + */ +function commons_groups_form_group_node_after_build($form, $form_state) { + $form['field_og_subscribe_settings'][LANGUAGE_NONE]['approval']['#suffix'] = render($form['field_og_access_default_value']); + + return $form; +} + +/** + * Update the group permission field. + * + * @param $role + * The OG role object of which the permissions are being changed. + * @param $permissions + * The anonymous user permissions of the group. + */ +function _commons_groups_update_group_permissions($role, $permissions) { + $updated_roles = &drupal_static(__FUNCTION__); + if (!empty($updated_roles[$role->rid])) { + // Avoid updating a group subscription twice on the same request. + return; + } + + if (!empty($permissions['subscribe without approval'])) { + $subscribe_type = 'anyone'; + } + elseif (!empty($permissions['subscribe'])) { + $subscribe_type = 'approval'; + } + else { + $subscribe_type = 'invitation'; + } + + $wrapper = entity_metadata_wrapper($role->group_type, $role->gid); + if ($wrapper->field_og_subscribe_settings->value() != $subscribe_type) { + // Mark that the group's permissions were already handled on this request, + // to avoid saving the group entity more than once. + $updated_roles[$role->rid] = TRUE; + + $wrapper->field_og_subscribe_settings->set($subscribe_type); + $wrapper->save(); + } +} + +/** + * Implements hook_menu_alter(). + */ +function commons_groups_menu_alter(&$items) { + // Provide a more informative title. + if (isset($items['node/%/group'])) { + $items['node/%/group']['title'] = t('Administer group'); + } +} + +/* + * Implements hook_menu + * Used with commons_groups_help and the commons groups update view to turn off + * the warning message to update groups + */ +function commons_groups_menu() { + $items['admin/content/groups/update/toggle'] = array( + 'title' => 'Toggle Groups Update', + 'page callback' => 'commons_groups_update_toggle', + 'access arguments' => array('edit any group content'), + 'type' => MENU_CALLBACK, + ); + return $items; +} + +/* + * Ajax callback page to toggle the group update status to off + * See https://drupal.org/node/2059857 for more information + */ +function commons_groups_update_toggle() { + variable_set('commons_groups_needs_update', FALSE); + return TRUE; +} + +/** + * Implements hook_block_info(). + */ +function commons_groups_block_info() { + $blocks['commons_groups_create_group'] = array( + 'info' => t('"Create a group" call to action'), + 'cache' => DRUPAL_NO_CACHE, + ); + return $blocks; +} + +/** + * Implements hook_block_view(). + */ +function commons_groups_block_view() { + $block['subject'] = ''; + if (node_access('create', 'group')) { + $block['content'] = l(t('Create a group'), 'node/add/group'); + } + else { + $block['content'] = ''; + } + return $block; +} + +/** + * Implements hook_features_pipe_alter(). + */ +function commons_groups_features_pipe_alter(&$pipe, $data, $export) { + // Prevent Commons Groups related fields from being piped in features + // when a content type includes those fields. + if (!empty($pipe['field_instance'])) { + foreach ($pipe['field_instance'] as $delta => $value) { + $args = explode('-', $value); + $field_name = $args[2]; + $excluded_fields = array('og_group_ref', 'field_og_access_default_value', + 'field_og_subscribe_settings', 'og_roles_permissions', 'group_access', 'field_group_logo', 'group_group', 'body'); + if (in_array($field_name, $excluded_fields)) { + unset($pipe['field_instance'][$delta]); + } + } + } + if (!empty($pipe['field_base'])) { + foreach ($pipe['field_base'] as $delta => $value) { + if ($delta == 'og_group_ref') { + unset($pipe['field_base'][$delta]); + } + } + } +} + +/** + * Implements hook_commons_entity_integration(). + */ +function commons_groups_commons_entity_integration() { + return array( + 'node' => array( + 'group' => array( + 'is_group_content' => FALSE, + 'is_group' => TRUE, + 'exclude_commons_follow' => TRUE, + ), + ), + ); +} + +/** + * Implements hook_views_pre_view(). + * By default, all views should have a group_type filter that looks at only nodes. + * This function allows those views to also show group content on the front page + * regardless of their entity type. + * See https://drupal.org/node/2037417 for more info. + */ +function commons_groups_views_pre_view(&$view, &$display_id, &$args) { + // We check to see if a group id argument is set in the view, and if no arguments + // are being passed to the view. If so, the group_type filter is irrelevant. + if (isset($view->display_handler->options['arguments']['gid']) && empty($args)) { + if (isset($view->display_handler->options['filters']['group_type'])) { + $filters = $view->display_handler->get_option('filters'); + unset($filters['group_type']); + $view->display_handler->override_option('filters', $filters); + } + } +} + +function commons_groups_group_contributors_count_topics($group) { + // Format the count of contributors. + $output = ''; + $view = views_get_view('commons_contributors_group'); + if (!empty($view)) { + $view->set_display('panel_pane_1'); + $view->set_arguments(array($group->nid)); + $view->get_total_rows = TRUE; + $view->execute(); + // If there are no contributors with avatars, return an empty string + // rather than displaying '0 contributors'. + if (empty($view->total_rows)) { + return ''; + } + $contributors_count = $view->total_rows; + $output .= l(format_plural($contributors_count, '1 contributor', '@count contributors'), 'node/' . $group->nid . '/contributors'); + } + // Format the list of topics: + if (!empty($group->field_topics[LANGUAGE_NONE])) { + foreach ($group->field_topics[LANGUAGE_NONE] as $item) { + $tids[] = $item['tid']; + } + $topics = taxonomy_term_load_multiple($tids); + $topics_text = ' discussing the @topics '; + $t_args = array('@topics' => format_plural(count($topics), 'topic', 'topics')); + foreach ($topics as $topic) { + $topics_text .= '!topic-' . $topic->tid; + if ($topic == end($topics)) { + $topics_text .= '.'; + } + else { + $topics_text .= ', '; + } + $t_args['!topic-' . $topic->tid] = l(t($topic->name), 'taxonomy/term/' . $topic->tid); + } + $output .= t($topics_text, $t_args); + } + return $output; +} + +/* set commons_Groups form alter to happen after views bulk operations */ +function commons_groups_module_implements_alter(&$implementations, $hook) { + if ($hook == 'form_alter') { + $group = $implementations['commons_groups']; + unset($implementations['commons_groups']); + $implementations['commons_groups'] = $group; + } +} + +/** + * Implements hook_form_alter(). + */ +function commons_groups_form_alter(&$form, &$form_state, $form_id) { + if ($form_id == 'views_exposed_form' && strstr($form['#id'], 'views-exposed-form-commons-groups-directory')) { + $form['groups-keys']['#attributes'] = array( + 'placeholder' => t('Separate keywords with commas'), + ); + } + if ((strstr($form_id, 'views_form_commons_group_moderation_page'))) { + $form['select']['action::views_bulk_operations_delete_item']['#weight'] = 9; + } + if ($form_id == 'group_node_form' && is_null($form['nid']['#value'])) { + $form['actions']['submit']['#submit'][] = 'commons_groups_group_submission_message'; + } + // Redirect the user back to the group homepage after submitting + // a node within a group. + if (isset($form['#node']) && substr($form_id, -10) == '_node_form') { + // Hide the "Group content visibility" field to simplify the node form. + if (!empty($form['group_content_access']['#access'])) { + $form['group_content_access']['#access'] = FALSE; + } + // Set a human-friendly page title. + if (empty($form['#node']->nid)) { + $types = node_type_get_types(); + $type = $form['#node']->type; + // Use 'a' or 'an' appropriately. + $vowels = array('a', 'e', 'i', 'o', 'u'); + $verb = strtolower(in_array($type[0], $vowels)) ? 'Create an' : 'Create a'; + drupal_set_title(t("$verb @name", array('@name' => $types[$type]->name)), PASS_THROUGH); + } + // Customizations to the node form for entitites that are group content. + $group_content_entity_types = commons_groups_get_group_content_entity_types(); + if (isset($group_content_entity_types['node'][$form['#node']->type])) { + $form['actions']['submit']['#submit'][] = 'commons_groups_node_in_group_submit'; + } + } + if (in_array($form_id, array('og_ui_admin_global_permissions', 'og_ui_admin_permissions'))) { + $group_content_entity_types = commons_groups_get_group_content_entity_types(); + if (!empty($group_content_entity_types)) { + // @TODO: Improve this message to be more specific and/or + // reflect these changes in the checkboxes. + $message = 'In addition to the permissions listed here, the Commons Groups module grants non-group members the ability to post content into groups where content in the group is public.'; + drupal_set_message(t($message), 'warning'); + } + } + // Hide internal fields that the user should not be able to edit directly. + if ($form_id == 'edit_profile_user_profile_form' || substr($form_id, -10) === '_node_form') { + $internal_fields = array('field_unread_invitations', 'field_unread_messages', 'user_trusted_contacts', 'og_user_group_ref', 'group_access'); + foreach ($internal_fields as $field_name) { + if(isset($form[$field_name])) { + $form[$field_name]['#access'] = FALSE; + } + } + } + // Disable Trusted Contacts field if commons_trusted_contacts is disabled. + $group_content_entity_types = commons_groups_get_group_content_entity_types(); + if (isset($form['#node']->type) && isset($group_content_entity_types['node'][$form['#node']->type])) { + if (isset($form['og_user_group_ref']) && !module_exists('commons_trusted_contacts')) { + $form['og_user_group_ref']['#access'] = FALSE; + } + } +} + +/** + * Submit handler called if the form is for a node enabled as group content. + */ +function commons_groups_node_in_group_submit(&$form, &$form_state) { + if (isset($form_state['values']['og_group_ref'][LANGUAGE_NONE][0])) { + $group = $form_state['values']['og_group_ref'][LANGUAGE_NONE][0]['target_id']; + $form_state['redirect'] = 'node/' . $group; + } +} + +/** + * Implements hook_system_info_alter(). + */ +function commons_groups_system_info_alter(&$info, $file, $type) { + // Commons Groups dynamically adds the og_group_ref field to + // content types that request it by altering the + // commons_groups_entity_types variable. + // We must add a corresponding line for each field instance + // to commons_groups.info so that Features is aware of the instance + // and can successfully revert the field_instance component back + // to its default state. + if ($file->name == 'commons_groups') { + $group_bundles = og_get_all_group_bundle(); + if (!empty($group_bundles['node'])) { + foreach ($group_bundles['node'] as $bundle => $name) { + // These field instances should be added to groups regardless of + // whether og_access.module is enabled. + $info['features']['field_instance'][] = "node-$bundle-field_og_access_default_value"; + $info['features']['field_instance'][] = "node-$bundle-field_og_subscribe_settings"; + $info['features']['field_instance'][] = "node-$bundle-og_roles_permissions"; + $info['features']['field_instance'][] = "node-$bundle-body"; + $info['features']['field_instance'][] = "node-$bundle-group_group"; + + // These fields are only necessary when og_access.module is enabled. + $info['features']['field_instance'][] = "node-$bundle-group_access"; + $info['features']['field_instance'][] = "node-$bundle-field_group_logo"; + + // Add default strongarm settings. + $info['features']['variable'][] = "comment_anonymous_$bundle"; + $info['features']['variable'][] = "comment_default_mode_$bundle"; + $info['features']['variable'][] = "comment_default_per_page_$bundle"; + $info['features']['variable'][] = "comment_form_location_$bundle"; + $info['features']['variable'][] = "comment_$bundle"; + $info['features']['variable'][] = "comment_preview_$bundle"; + $info['features']['variable'][] = "comment_subject_field_$bundle"; + $info['features']['variable'][] = "field_bundle_settings_node__$bundle"; + } + } + $group_content_entity_types = commons_groups_get_group_content_entity_types(); + if (!empty($group_content_entity_types)) { + foreach ($group_content_entity_types as $entity_type => $bundles) { + foreach (array_keys($bundles) as $bundle) { + $info['features']['field_instance'][] = "$entity_type-$bundle-og_group_ref"; + $info['features']['field_instance'][] = "$entity_type-$bundle-group_content_access"; + } + } + } + + // Commons specific group variables. + $commons_groups = commons_groups_get_group_types(); + if (isset($commons_groups['node'])) { + foreach ($commons_groups['node'] as $bundle => $group_info) { + $info['features']['variable'][] = "node_options_$bundle"; + $info['features']['variable'][] = "node_preview_$bundle"; + $info['features']['variable'][] = "node_submitted_$bundle"; + $info['features']['variable'][] = "og_group_manager_default_rids_node_$bundle"; + } + } + } +} + +/** + * Implements hook_default_message_type_alter(). + */ +function commons_groups_default_message_type_alter(&$defaults) { + foreach (array('commons_activity_streams_comment_created', 'commons_activity_streams_node_created') as $name) { + if (!empty($defaults[$name])) { + $defaults[$name]->message_text[LANGUAGE_NONE][2] = commons_groups_message_partial_default(); + } + } +} + + +/** + * Implements hook_og_user_access_alter(). + * + * Deny create permissions from non-members on "non-public" groups (i.e. groups + * that don't allow joining without approval). + */ +function commons_groups_og_user_access_alter(&$perm, $context) { + $account = $context['account']; + $group_type = $context['group_type']; + $group = $context['group']; + + if ($group_type != 'node') { + return; + } + // The purpose of this function is to grant permissions to create content + // in a group to non-members of the group, when the group's privacy settings + // (field_og_subscribe_settings) is set to "Anyone can contribute". + if (og_is_member($group_type, $group->nid, 'user', $account, array(OG_STATE_ACTIVE, OG_STATE_PENDING, OG_STATE_BLOCKED))) { + // The user is a group member, so comply to the OG permissions. + return; + } + + $wrapper = entity_metadata_wrapper($group_type, $group); + $access_create = $account->uid && $wrapper->field_og_subscribe_settings->value() == 'anyone'; + + // Make sure user can view group (i.e. it's not private). + $commons_groups_entity_types = commons_groups_get_group_content_entity_types(); + foreach (array_keys($commons_groups_entity_types['node']) as $type) { + $perm["create $type content"] = $access_create; + } +} + + +/** + * Implements of hook_token_info(). + */ +function commons_groups_token_info() { + $types = array(); + $tokens = array(); + + // Commons Groups tokens. + $types['commons-groups'] = array( + 'name' => t('Commons Groups'), + 'description' => t('Tokens related to the Groups functionality in Drupal Commons.'), + 'needs-data' => 'node', + ); + $tokens['commons-groups']['in-groups-text'] = array( + 'name' => t('"In groups" text'), + 'description' => t('The text (starting with "in the groups") indicating which groups a peice of content belongs to.'), + ); + $tokens['node']['commons-groups-group-contributors-count-topics'] = array( + 'name' => t('Commons Groups: Group contributor count and topics'), + 'description' => t('Displays text showing the number of contributors and the topics associated with a group node.'), + ); + return array( + 'types' => $types, + 'tokens' => $tokens, + ); +} + + +/** + * Implements hook_tokens(). + */ +function commons_groups_tokens($type, $tokens, $data = array(), $options = array()) { + $replacements = array(); + if ($type == 'node' && !empty($data['node'])) { + $group = $data['node']; + + foreach ($tokens as $name => $original) { + if ($name == 'commons-groups-group-contributors-count-topics') { + $replacements[$original] = commons_groups_group_contributors_count_topics($group); + return $replacements; + } + } + } + if ($type == 'commons-groups') { + if (!empty($tokens['in-groups-text'])) { + // Build a list of groups associated with this message. + $text = ''; + $target_nids = array(); + $related_groups = array(); + $related_gids = array(); + + // First, build an array of target nodes associated with the message. + foreach ($data['message']->field_target_nodes[LANGUAGE_NONE] as $key => $value) { + $target_nids[] = $value['target_id']; + } + // If there are no target nodes, the in-groups-text token should be empty. + if (empty($target_nids)) { + $replacements['[commons-groups:in-groups-text]'] = $text; + return $replacements; + } + // Build a list of groups associated with the target nodes. + // For now, we assume that the group type is node. + foreach ($target_nids as $key => $nid) { + $og_memberships_this_target = og_get_entity_groups('node', $nid); + if (!empty($og_memberships_this_target['node'])) { + $og_memberships_this_target = $og_memberships_this_target['node']; + foreach ($og_memberships_this_target as $membership_id => $gid) { + $related_gids[] = $gid; + } + } + } + // If no groups are associated with any of the targett nodes, + // then we have no "in the groups" text. + if (empty($related_gids)) { + $replacements['[commons-groups:in-groups-text]'] = ''; + return $replacements; + } + + $related_groups = entity_load('node', $related_gids); + // Key the array of groups in a predictable way. + $related_groups = array_values($related_groups); + // Generate the appropriate text depending on the number of groups + // associated with the message: + $replacements['[commons-groups:in-groups-text]'] = commons_groups_related_groups_text($related_groups); + return $replacements; + } + } +} + +function commons_groups_message_partial_default() { + $partial = array( + 'value' => '[commons-groups:in-groups-text]', + 'format' => 'full_html', + 'safe_value' => '[commons-groups:in-groups-text]', + ); + return $partial; +} + +/** + * Build the related-groups text for nodes. + * + * @param $related_groups + * Array of groups referenced by the node. + * + * @return + * String containing the related groups. + */ +function commons_groups_related_groups_text($related_groups) { + // In 1 group: "in the x group" + if (count($related_groups) == 1) { + return t(' in the !group group', array('!group' => l($related_groups[0]->title, 'node/' . $related_groups[0]->nid))); + } + + // In 2 groups: "in the x and y groups" + if (count($related_groups) == 2) { + return t(' in the !group-0 and !group-1 groups', array( + '!group-0' => l($related_groups[0]->title, 'node/' . $related_groups[0]->nid), + '!group-1' => l($related_groups[1]->title, 'node/' . $related_groups[1]->nid), + )); + } + + // In more than 2 groups: "in the x, y and z groups" + if (count($related_groups) > 2) { + // Separate the last group. + $last_group = array_pop($related_groups); + $text = ' in the '; + // Prepare tokens for t() for each of the other groups. + foreach ($related_groups as $key => $this_group) { + $text .= "!group-$key, "; + $t_args["!group-$key"] = l($this_group->title, 'node/' . $this_group->nid); + } + // Prepare the last group token. + $text .= " and !group-$last_group->nid groups."; + $t_args["!group-$last_group->nid"] = l($last_group->title, 'node/' . $last_group->nid); + // Prepare the full text with all of the groups and their tokens: + return t($text, $t_args); + } +} + +function commons_groups_group_submission_message($form, &$form_state) { + if ($form_state['values']['status'] !== 1) { + drupal_set_message(t('Thanks for your group submission! This group has entered the moderation queue and will be reviewed shortly.')); + } +} + +/** + * Default value function for the og_group_ref reference field. + * This function is assigned to the field with the default_value_function + * property defined in our instances of the og_group_ref field, + * which takes place in commons_groups_field_definition(). + */ +function commons_groups_entityreference_default_value($entity_type, $entity, $field, $instance, $langcode) { + + $items = array(); + $field_name = $field['field_name']; + + if (empty($_GET[$field_name]) || !is_string($_GET[$field_name])) { + return $items; + } + + if (empty($instance['settings']['behaviors']['prepopulate']['status'])) { + return $items; + } + + $ids = explode(',', $_GET[$field_name]); + // Check access to the provided entities. + $target_type = $field['settings']['target_type']; + entity_load($target_type, $ids); + // Remove group nodes hidden by the node access system. + foreach ($ids as $target_id) { + $target = entity_load_single($target_type, $target_id); + if (entity_access('view', $target_type, $target) + && og_is_group_type($target_type, $target->type) + && (og_user_access($target_type, $target_id, "create $entity->type content") || og_user_access($target_type, $target_id, "update any $entity->type content")) + ) { + $items[] = array('target_id' => $target_id); + } + } + return $items; +} + +/** + * Implements hook_strongarm_alter(). + */ +function commons_groups_strongarm_alter(&$items) { + // Expose the Group content type for integration with Commons Radioactivity. + if (isset($items['commons_radioactivity_entity_types'])) { + $items['commons_radioactivity_entity_types']->value['node']['group'] = 1; + } +} + +function commons_groups_default_rules_configuration_alter(&$configs) { + // Disable default OG new content notifications. + // The language doesn't correspond to Commons' open groups model and we use + // commons_follow and commons_follow_notify for new content notifications. + if (isset($configs['rules_og_member_active'])) { + $configs['rules_og_member_active']->active = FALSE; + } +} + +/** + * Implements hook_node_presave(). + * + * When the node's group is private, force the group content to be private. + */ +function commons_groups_node_presave($node) { + if (!module_exists('og_access')) { + return; + } + + $wrapper = entity_metadata_wrapper('node', $node); + + if (og_is_group('node', $node)) { + // Determine whether the group is private according to the subscription + // field. + $private = $wrapper->field_og_subscribe_settings->value() == 'invitation'; + $wrapper->{OG_ACCESS_FIELD}->set((int)$private); + return; + } + + if (!og_is_group_content_type('node', $node->type)) { + return; + } + + + // Check whether any of the groups are private. + $private = FALSE; + foreach (array_keys(og_get_group_audience_fields('node', $node->type)) as $field) { + if (empty($node->$field)) { + continue; + } + + foreach ($wrapper->$field as $group_wrapper) { + if (empty($group_wrapper->field_og_access_default_value)) { + continue; + } + + if ($group_wrapper->field_og_access_default_value->value() == TRUE) { + // Once a private group was found, there's no need to continue. + $private = TRUE; + break 2; + } + } + } + + if ($private) { + $wrapper->{OG_CONTENT_ACCESS_FIELD}->set(OG_CONTENT_ACCESS_PRIVATE); + } +} + +/** + * Implements hook_node_update(). + */ +function commons_groups_node_update($node) { + $account = user_load($node->uid); + commons_groups_first_contribution($account, $node); + + if (og_is_group('node', $node)) { + commons_groups_set_group_permissions($node); + } +} + +/** + * Implements hook_node_insert(). + */ +function commons_groups_node_insert($node) { + $account = user_load($node->uid); + commons_groups_first_contribution($account, $node); + + if (og_is_group('node', $node)) { + // When creating a new group, this hook happens before OG creates the + // group specific roles. Therefore we create the roles here before altering + // them in commons_groups_set_group_permissions(). + og_roles_override('node', $node->type, $node->nid); + commons_groups_set_group_permissions($node); + } +} + +/** + * Set the group's permissions according to field_og_subscribe_settings. + * + * @param $node + * A group node. + */ +function commons_groups_set_group_permissions($node) { + // Avoid updating a group subscription twice on the same request. + $updated_nodes = & drupal_static(__FUNCTION__); + if (!empty($updated_nodes[$node->nid])) { + return; + } + $updated_nodes[$node->nid] = TRUE; + + $wrapper = entity_metadata_wrapper('node', $node); + $permission = $wrapper->field_og_subscribe_settings->value(); + $og_roles = og_roles('node', $node->type, $node->nid); + $anon_rid = array_search(OG_ANONYMOUS_ROLE, $og_roles); + + $permissions = array( + 'subscribe' => $permission == 'approval', + 'subscribe without approval' => $permission == 'anyone', + ); + + // Check if the permissions needs to be changed. + $changed = FALSE; + $old_permissions = og_role_permissions(array($anon_rid => OG_ANONYMOUS_ROLE)); + foreach ($permissions as $permission => $value) { + if (empty($old_permissions[$anon_rid][$permission]) || $old_permissions[$anon_rid][$permission] != $value) { + $changed = TRUE; + } + } + + // Only change the permissions when neccessary. + if ($changed) { + og_role_change_permissions($anon_rid, $permissions); + } +} + +/** + * Returns an array of entity types that are enabled via Commons Groups. + */ +function commons_groups_get_group_content_entity_types() { + // Find all Commons Entity integrations. + $commons_entity_integrations = commons_entity_integration_info(); + if (empty($commons_entity_integrations)) { + return array(); + } + + foreach ($commons_entity_integrations as $entity_type => $integration) { + foreach ($integration as $bundle => $options) { + if (isset($options['is_group_content']) && $options['is_group_content'] == FALSE) { + unset($commons_entity_integrations[$entity_type][$bundle]); + } + } + // If an entity type has no integrations, don't return it. + if (empty($commons_entity_integrations[$entity_type])) { + unset($commons_entity_integrations[$entity_type]); + } + } + + return $commons_entity_integrations; +} + +/** + * Returns an array of entity types that are defined as a group. + */ +function commons_groups_get_group_types() { + // Find all Commons Entity integrations. + $commons_groups = array(); + $commons_entity_integrations = commons_entity_integration_info(); + if (empty($commons_entity_integrations)) { + return array(); + } + + foreach ($commons_entity_integrations as $entity_type => $integration) { + foreach ($integration as $bundle => $options) { + if (isset($options['is_group']) && $options['is_group'] == TRUE) { + $commons_groups[$entity_type][$bundle] = $commons_entity_integrations[$entity_type][$bundle]; + } + } + } + + return $commons_groups; +} + +/** + * When a user first creates content within a group, + * grant her the contributor role within that group. + */ +function commons_groups_first_contribution($account, $node) { + // Find the groups that this piece of content belongs to. + $groups = og_get_entity_groups('node', $node); + // @todo: Make it work also with user-groups. + if (!empty($groups['node'])) { + $node_groups = array_values($groups['node']); + // Find the groups that the node author belongs to. + $account_groups = og_get_groups_by_user($account, 'node'); + if (!$account_groups) { + $account_groups = array(); + } + // For groups where this user is not already a member, add her to the group. + // Anonymous users should never be added to a group automatically + if ($account->uid == 0) { + return; + } + $new_groups = array_diff($node_groups, $account_groups); + if (!empty($new_groups)) { + foreach ($new_groups as $new_group_nid) { + og_group('node', $new_group_nid, array('entity' => $account->uid)); + } + } + } +} + +/** + * Implements hook_commons_bw_group_widget(). + */ +function commons_groups_commons_bw_group_widget() { + return array( + 'commons_all' => array( + 'title' => t('All'), + 'type' => 'view', + 'vid' => 'commons_bw_all', + 'display' => 'default', + 'weight' => -10, + 'default' => 1, + 'bundle' => 'post', + ), + ); +} + +/** + * Implements hook_preprocess_node(). + */ +function commons_groups_preprocess_node(&$variables) { + $variables['user_picture'] = ''; + if (variable_get('user_pictures', 0)) { + $node = $variables['node']; + $account = user_load($node->uid); + + if (!empty($account->picture)) { + // @TODO: Ideally this function would only be passed file objects, but + // since there's a lot of legacy code that JOINs the {users} table to + // {node} or {comments} and passes the results into this function if we + // a numeric value in the picture field we'll assume it's a file id + // and load it for them. Once we've got user_load_multiple() and + // comment_load_multiple() functions the user module will be able to load + // the picture files in mass during the object's load process. + if (is_numeric($account->picture)) { + $account->picture = file_load($account->picture); + } + if (!empty($account->picture->uri)) { + $filepath = $account->picture->uri; + } + } + elseif (variable_get('user_picture_default', '')) { + $filepath = variable_get('user_picture_default', ''); + } + + if (isset($filepath)) { + if (module_exists('image') && file_valid_uri($filepath)) { + $alt = t("@user's picture", array('@user' => format_username($account))); + + $render = array( + '#theme' => 'image_formatter', + '#image_style' => '50x50', + '#item' => array( + 'uri' => $filepath, + 'alt' => $alt, + ), + '#path' => array( + 'path' => 'user/' . $account->uid, + 'options' => array( + 'attributes' => array( + 'title' => t("View @user's profile.", array('@user' => format_username($account))), + 'class' => array('user-picture'), + ), + ), + ), + ); + + // Use a unique image style for user pictures in post information. + $variables['user_picture'] = drupal_render($render); + } + } + } +} + +/** + * Implements hook_preprocess_views_view_grid(). + */ +function commons_groups_preprocess_views_view_grid(&$variables, $hook) { + // Change the displayed role name in the group contributors block to + // "Organizers". + if ($variables['view']->name == 'commons_contributors_group' && !empty($variables['title']) && $variables['title'] == 'administrator member') { + $variables['title'] = t('Organizers'); + } +} + +/** + * Implements hook_field_access(). + */ +function commons_groups_field_access($op, $field, $entity_type, $entity, $account) { + $field_name = $field['field_name']; + switch ($field_name) { + case 'og_roles_permissions': + return FALSE; + + case 'field_og_access_default_value': + return $op == 'edit' && module_exists('og_access'); + + case 'field_og_subscribe_settings': + return $op == 'edit'; + } + + if (module_exists('og_access') && in_array($field_name, array(OG_CONTENT_ACCESS_FIELD, OG_ACCESS_FIELD))) { + return FALSE; + } +} + +/** + * Implements hook_field_formatter_info(). + */ +function commons_groups_field_formatter_info() { + return array( + 'commons_groups_group_subscribe' => array( + 'label' => t('Commons groups subscribe link'), + 'field types' => array('list_boolean'), + 'settings' => array( + 'field_name' => FALSE, + ), + ), + ); +} + +/** + * Implements hook_field_formatter_view(). + */ +function commons_groups_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { + global $user; + $account = clone $user; + + if ($display['type'] != 'commons_groups_group_subscribe') { + return; + } + + if (!og_is_group($entity_type, $entity)) { + return; + } + + if (!empty($entity->uid) && ($entity->uid == $account->uid)) { + // User is the group manager. + $element[0] = array('#markup' => t('You are the group manager')); + return $element; + } + + list($id, , $bundle) = entity_extract_ids($entity_type, $entity); + + // The user has a pending membership request. Let her know that + // her request is pending review. + if (og_is_member($entity_type, $id, 'user', $account, array(OG_STATE_PENDING))) { + $element[0] = array('#markup' => '
' . t('Your membership request is pending review by a group organizer.') . '
'); + return $element; + } + // If user is blocked, they should not be able to apply for membership. + if (og_is_member($entity_type, $id, 'user', $account, array(OG_STATE_BLOCKED))) { + return; + } + if (og_is_member($entity_type, $id, 'user', $account)) { + // The user has an active membership. She can leave the group. + // For groups where anyone can contribute without joining, don't display + // a "Leave" link since users never went through + // the separate step of joining. + if (og_is_member($entity_type, $id, 'user', $account, array(OG_STATE_ACTIVE)) && $entity->field_og_subscribe_settings[LANGUAGE_NONE][0]['value'] != 'anyone') { + $links['title'] = t('Leave group'); + $links['href'] = "group/$entity_type/$id/unsubscribe"; + } + } + else { + // Check if user can subscribe to the field. + if (empty($settings['field_name']) && $audience_field_name = og_get_best_group_audience_field('user', $account, $entity_type, $bundle)) { + $settings['field_name'] = $audience_field_name; + } + if (!$settings['field_name']) { + return; + } + + $field_info = field_info_field($settings['field_name']); + + // Check if entity is referencable. + if ($field_info['settings']['target_type'] != $entity_type) { + // Group type doesn't match. + return; + } + if (!empty($field_info['settings']['handler_settings']['target_bundles']) && !in_array($bundle, $field_info['settings']['handler_settings']['target_bundles'])) { + // Bundles don't match. + return; + } + + if (!og_check_field_cardinality('user', $account, $settings['field_name'])) { + $element[0] = array('#markup' => format_plural($field_info['cardinality'], 'You are already registered to another group', 'You are already registered to @count groups')); + return $element; + } + + $url = "group/$entity_type/$id/subscribe"; + if ($settings['field_name']) { + $url .= '/' . $settings['field_name']; + } + // Set the needs update hook if we end up with a group call that is missing + // the subscribe settings. We also check the variable first, because we + // don't want to reset the variable cache if we don't have to. + // See https://drupal.org/node/2059857#comment-7733465 for more info. + if (empty($entity->field_og_subscribe_settings)) { + if (!variable_get('commons_groups_needs_update', FALSE)) { + variable_set('commons_groups_needs_update', TRUE); + } + } + // Don't display join link on public groups. + else { + if ($entity->field_og_subscribe_settings[LANGUAGE_NONE][0]['value'] != 'anyone') { + if ($entity->field_og_subscribe_settings[LANGUAGE_NONE][0]['value'] == 'approval') { + $subscription_type = t('Moderated group'); + $links['title'] = t('Join group'); + if ($account->uid) { + $links['href'] = $url; + } + else { + $links['href'] = 'user/login'; + $links['options'] = array('query' => array('destination' => $url)); + } + } + else { + $element[0] = array('#markup' => '
' . t('Invite-only group') . '
'); + return $element; + } + } + } + } + if (!empty($links['title'])) { + $links += array('options' => array()); + $element[0] = array( + '#type' => 'link', + '#title' => $links['title'], + '#href' => $links['href'], + '#options' => $links['options'], + ); + + if (!empty($subscription_type)) { + $element[0]['#prefix'] = '
' . $subscription_type . '
'; + } + + return $element; + } +} + +/** + * Implements hook_views_pre_render(). + */ +function commons_groups_views_pre_render(&$view) { + // Improve the browsing widget empty text when displayed outside of a group. + // TODO: Enable og_context and check group context instead of looking for an + // empty first argument. + if (empty($view->args[0]) && $view->name == 'commons_bw_all') { + $view->display_handler->handlers['empty']['area']->options['content'] = t('Nobody has posted yet.'); + } +} diff --git a/modules/commons/commons_groups/commons_groups.strongarm.inc b/modules/commons/commons_groups/commons_groups.strongarm.inc new file mode 100644 index 0000000..42321f3 --- /dev/null +++ b/modules/commons/commons_groups/commons_groups.strongarm.inc @@ -0,0 +1,179 @@ + $group_info) { + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = "comment_anonymous_$bundle"; + $strongarm->value = 0; + $export["comment_anonymous_$bundle"] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = "comment_default_mode_$bundle"; + $strongarm->value = 1; + $export["comment_default_mode_$bundle"] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = "comment_default_per_page_$bundle"; + $strongarm->value = '50'; + $export["comment_default_per_page_$bundle"] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = "comment_form_location_$bundle"; + $strongarm->value = 1; + $export["comment_form_location_$bundle"] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = "comment_$bundle"; + $strongarm->value = '0'; + $export["comment_$bundle"] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = "comment_preview_$bundle"; + $strongarm->value = '1'; + $export["comment_preview_$bundle"] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = "comment_subject_field_$bundle"; + $strongarm->value = 1; + $export["comment_subject_field_$bundle"] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = "field_bundle_settings_node__$bundle"; + $strongarm->value = array( + 'view_modes' => array( + 'teaser' => array( + 'custom_settings' => TRUE, + ), + 'full' => array( + 'custom_settings' => FALSE, + ), + 'rss' => array( + 'custom_settings' => FALSE, + ), + 'search_index' => array( + 'custom_settings' => FALSE, + ), + 'search_result' => array( + 'custom_settings' => FALSE, + ), + 'diff_standard' => array( + 'custom_settings' => FALSE, + ), + 'token' => array( + 'custom_settings' => FALSE, + ), + ), + 'extra_fields' => array( + 'form' => array( + 'title' => array( + 'weight' => '-5', + ), + ), + 'display' => array(), + ), + ); + $export["field_bundle_settings_node__$bundle"] = $strongarm; + } + } + + // Add some additional default settings if the node implements the commons + // Specific entity integrations hook. + if (isset($commons_groups['node'])) { + foreach ($commons_groups['node'] as $bundle => $group_info) { + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = "node_options_$bundle"; + $strongarm->value = array( + 0 => 'revision', + ); + $export["node_options_$bundle"] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = "node_preview_$bundle"; + $strongarm->value = '1'; + $export["node_preview_$bundle"] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = "node_submitted_$bundle"; + $strongarm->value = 0; + $export["node_submitted_$bundle"] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = "og_group_manager_default_rids_node_$bundle"; + $strongarm->value = array( + 3 => '3', + ); + $export["og_group_manager_default_rids_node_$bundle"] = $strongarm; + } + } + + // These following settings are ONLY for the group content type. + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = "pathauto_node_group_pattern"; + $strongarm->value = 'groups/[node:title]'; + $export["pathauto_node_group_pattern"] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_options_group'; + $strongarm->value = array( + 0 => 'main-menu', + ); + $export['menu_options_group'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_parent_group'; + $strongarm->value = 'main-menu:0'; + $export['menu_parent_group'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'pathauto_node_pattern'; + $strongarm->value = 'groups/[node:og-group-ref:0:title]/[node:title]'; + $export['pathauto_node_pattern'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_groups/commons_groups.views_default.inc b/modules/commons/commons_groups/commons_groups.views_default.inc new file mode 100644 index 0000000..455073c --- /dev/null +++ b/modules/commons/commons_groups/commons_groups.views_default.inc @@ -0,0 +1,1386 @@ +name = 'commons_bw_all'; + $view->description = 'Commons all content listing for the group browsing widget.'; + $view->tag = 'Commons Browsing Widget'; + $view->base_table = 'node'; + $view->human_name = 'Commons Browsing Widget - All'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_ajax'] = TRUE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['query']['options']['query_comment'] = FALSE; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'lite'; + $handler->display->display_options['pager']['options']['items_per_page'] = '10'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '1'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'node'; + /* Header: Global: Node partial form */ + $handler->display->display_options['header']['commons_bw_node_partial_form']['id'] = 'commons_bw_node_partial_form'; + $handler->display->display_options['header']['commons_bw_node_partial_form']['table'] = 'views'; + $handler->display->display_options['header']['commons_bw_node_partial_form']['field'] = 'commons_bw_node_partial_form'; + $handler->display->display_options['header']['commons_bw_node_partial_form']['bundle'] = 'post'; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'Nobody has posted into this group yet.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: OG membership: OG membership from Node */ + $handler->display->display_options['relationships']['og_membership_rel']['id'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['table'] = 'node'; + $handler->display->display_options['relationships']['og_membership_rel']['field'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['required'] = TRUE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Content: Sticky */ + $handler->display->display_options['sorts']['sticky']['id'] = 'sticky'; + $handler->display->display_options['sorts']['sticky']['table'] = 'node'; + $handler->display->display_options['sorts']['sticky']['field'] = 'sticky'; + $handler->display->display_options['sorts']['sticky']['order'] = 'DESC'; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + $handler->display->display_options['sorts']['created']['exposed'] = TRUE; + $handler->display->display_options['sorts']['created']['expose']['label'] = 'most recent'; + /* Contextual filter: OG membership: Group ID */ + $handler->display->display_options['arguments']['gid']['id'] = 'gid'; + $handler->display->display_options['arguments']['gid']['table'] = 'og_membership'; + $handler->display->display_options['arguments']['gid']['field'] = 'gid'; + $handler->display->display_options['arguments']['gid']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['arguments']['gid']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['gid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['gid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['gid']['summary_options']['items_per_page'] = '25'; + $handler->display->display_options['arguments']['gid']['specify_validation'] = TRUE; + $handler->display->display_options['arguments']['gid']['validate']['type'] = 'og'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'node'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['value'] = array(); + /* Filter criterion: OG membership: Group_type */ + $handler->display->display_options['filters']['group_type']['id'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['table'] = 'og_membership'; + $handler->display->display_options['filters']['group_type']['field'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['filters']['group_type']['value'] = array( + 'node' => 'node', + ); + $translatables['commons_bw_all'] = array( + t('Master'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('Nobody has posted into this group yet.'), + t('OG membership from node'), + t('following'), + t('most recent'), + t('most active'), + t('All'), + t('Following'), + ); + $export['commons_bw_all'] = $view; + + $view = new view(); + $view->name = 'commons_contributors_group'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'users'; + $view->human_name = 'Commons Contributors - Group'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Group contributors'; + $handler->display->display_options['use_more'] = TRUE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['access']['perm'] = 'access user profiles'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['query']['options']['distinct'] = TRUE; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['pager']['options']['items_per_page'] = '16'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['style_plugin'] = 'grid'; + $handler->display->display_options['style_options']['columns'] = '7'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* Relationship: OG membership: OG membership from User */ + $handler->display->display_options['relationships']['og_membership_rel']['id'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['table'] = 'users'; + $handler->display->display_options['relationships']['og_membership_rel']['field'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['required'] = TRUE; + /* Field: User: Picture */ + $handler->display->display_options['fields']['picture']['id'] = 'picture'; + $handler->display->display_options['fields']['picture']['table'] = 'users'; + $handler->display->display_options['fields']['picture']['field'] = 'picture'; + $handler->display->display_options['fields']['picture']['label'] = ''; + $handler->display->display_options['fields']['picture']['element_label_colon'] = FALSE; + /* Sort criterion: User: Created date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'users'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + /* Contextual filter: OG membership: Group ID */ + $handler->display->display_options['arguments']['gid']['id'] = 'gid'; + $handler->display->display_options['arguments']['gid']['table'] = 'og_membership'; + $handler->display->display_options['arguments']['gid']['field'] = 'gid'; + $handler->display->display_options['arguments']['gid']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['arguments']['gid']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['gid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['gid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['gid']['summary_options']['items_per_page'] = '25'; + $handler->display->display_options['arguments']['gid']['specify_validation'] = TRUE; + $handler->display->display_options['arguments']['gid']['validate']['type'] = 'og'; + /* Filter criterion: User: Active */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'users'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = '1'; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: OG membership: State */ + $handler->display->display_options['filters']['state']['id'] = 'state'; + $handler->display->display_options['filters']['state']['table'] = 'og_membership'; + $handler->display->display_options['filters']['state']['field'] = 'state'; + $handler->display->display_options['filters']['state']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['filters']['state']['value'] = array( + 1 => '1', + ); + /* Filter criterion: OG membership: Group_type */ + $handler->display->display_options['filters']['group_type']['id'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['table'] = 'og_membership'; + $handler->display->display_options['filters']['group_type']['field'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['filters']['group_type']['value'] = array( + 'node' => 'node', + ); + + /* Display: group teaser */ + $handler = $view->new_display('panel_pane', 'group teaser', 'panel_pane_1'); + $handler->display->display_options['defaults']['title'] = FALSE; + $handler->display->display_options['title'] = 'Recent contributors'; + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['defaults']['pager'] = FALSE; + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['pager']['options']['items_per_page'] = '14'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['defaults']['fields'] = FALSE; + /* Field: User: Name */ + $handler->display->display_options['fields']['name']['id'] = 'name'; + $handler->display->display_options['fields']['name']['table'] = 'users'; + $handler->display->display_options['fields']['name']['field'] = 'name'; + $handler->display->display_options['fields']['name']['label'] = ''; + $handler->display->display_options['fields']['name']['exclude'] = TRUE; + $handler->display->display_options['fields']['name']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['name']['link_to_user'] = FALSE; + /* Field: User: Picture */ + $handler->display->display_options['fields']['picture']['id'] = 'picture'; + $handler->display->display_options['fields']['picture']['table'] = 'users'; + $handler->display->display_options['fields']['picture']['field'] = 'picture'; + $handler->display->display_options['fields']['picture']['label'] = ''; + $handler->display->display_options['fields']['picture']['exclude'] = TRUE; + $handler->display->display_options['fields']['picture']['alter']['text'] = '[picture][name]'; + $handler->display->display_options['fields']['picture']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['picture']['link_photo_to_profile'] = FALSE; + $handler->display->display_options['fields']['picture']['image_style'] = '35x35'; + /* Field: User: Uid */ + $handler->display->display_options['fields']['uid']['id'] = 'uid'; + $handler->display->display_options['fields']['uid']['table'] = 'users'; + $handler->display->display_options['fields']['uid']['field'] = 'uid'; + $handler->display->display_options['fields']['uid']['label'] = ''; + $handler->display->display_options['fields']['uid']['exclude'] = TRUE; + $handler->display->display_options['fields']['uid']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['uid']['link_to_user'] = FALSE; + /* Field: Global: Custom text */ + $handler->display->display_options['fields']['nothing']['id'] = 'nothing'; + $handler->display->display_options['fields']['nothing']['table'] = 'views'; + $handler->display->display_options['fields']['nothing']['field'] = 'nothing'; + $handler->display->display_options['fields']['nothing']['label'] = ''; + $handler->display->display_options['fields']['nothing']['alter']['text'] = '[picture][name]'; + $handler->display->display_options['fields']['nothing']['alter']['make_link'] = TRUE; + $handler->display->display_options['fields']['nothing']['alter']['path'] = 'user/[uid]'; + $handler->display->display_options['fields']['nothing']['alter']['absolute'] = TRUE; + $handler->display->display_options['fields']['nothing']['element_label_colon'] = FALSE; + $handler->display->display_options['argument_input'] = array( + 'gid' => array( + 'type' => 'context', + 'context' => 'entity:node.nid', + 'context_optional' => 0, + 'panel' => '0', + 'fixed' => '', + 'label' => 'OG membership: Group ID', + ), + ); + + /* Display: group homepage */ + $handler = $view->new_display('panel_pane', 'group homepage', 'panel_pane_2'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['defaults']['style_plugin'] = FALSE; + $handler->display->display_options['style_plugin'] = 'grid'; + $handler->display->display_options['style_options']['grouping'] = array( + 0 => array( + 'field' => 'og_roles', + 'rendered' => 1, + 'rendered_strip' => 0, + ), + ); + $handler->display->display_options['defaults']['style_options'] = FALSE; + $handler->display->display_options['defaults']['row_plugin'] = FALSE; + $handler->display->display_options['row_plugin'] = 'fields'; + $handler->display->display_options['defaults']['row_options'] = FALSE; + $handler->display->display_options['defaults']['fields'] = FALSE; + /* Field: User: Picture */ + $handler->display->display_options['fields']['picture']['id'] = 'picture'; + $handler->display->display_options['fields']['picture']['table'] = 'users'; + $handler->display->display_options['fields']['picture']['field'] = 'picture'; + $handler->display->display_options['fields']['picture']['label'] = ''; + $handler->display->display_options['fields']['picture']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['picture']['image_style'] = '50x50'; + /* Field: OG membership: OG user roles in group */ + $handler->display->display_options['fields']['og_roles']['id'] = 'og_roles'; + $handler->display->display_options['fields']['og_roles']['table'] = 'og_membership'; + $handler->display->display_options['fields']['og_roles']['field'] = 'og_roles'; + $handler->display->display_options['fields']['og_roles']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['fields']['og_roles']['label'] = ''; + $handler->display->display_options['fields']['og_roles']['exclude'] = TRUE; + $handler->display->display_options['fields']['og_roles']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['og_roles']['empty'] = 'Contributors'; + $handler->display->display_options['argument_input'] = array( + 'gid' => array( + 'type' => 'context', + 'context' => 'entity:node.nid', + 'context_optional' => 0, + 'panel' => '0', + 'fixed' => '', + 'label' => 'OG membership: Group ID', + ), + ); + + /* Display: Page */ + $handler = $view->new_display('page', 'Page', 'page_1'); + $handler->display->display_options['defaults']['title'] = FALSE; + $handler->display->display_options['title'] = 'Contributors to %1'; + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['path'] = 'node/%/contributors'; + $translatables['commons_contributors_group'] = array( + t('Master'), + t('Group contributors'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('OG membership from user'), + t('All'), + t('group teaser'), + t('Recent contributors'), + t('[picture][name]'), + t('View panes'), + t('group homepage'), + t('Contributors'), + t('Page'), + t('Contributors to %1'), + ); + $export['commons_contributors_group'] = $view; + + $view = new view(); + $view->name = 'commons_group_moderation'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'Commons Group Moderation'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Commons Group Moderation'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['access']['perm'] = 'edit any group content'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['pager']['options']['items_per_page'] = '25'; + $handler->display->display_options['style_plugin'] = 'table'; + $handler->display->display_options['style_options']['columns'] = array( + 'views_bulk_operations' => 'views_bulk_operations', + 'title' => 'title', + 'name' => 'name', + 'changed' => 'changed', + 'edit_node' => 'edit_node', + 'delete_node' => 'edit_node', + ); + $handler->display->display_options['style_options']['default'] = 'changed'; + $handler->display->display_options['style_options']['info'] = array( + 'views_bulk_operations' => array( + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'title' => array( + 'sortable' => 0, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'name' => array( + 'sortable' => 0, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'changed' => array( + 'sortable' => 0, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'edit_node' => array( + 'align' => '', + 'separator' => ' ', + 'empty_column' => 0, + ), + 'delete_node' => array( + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + ); + /* Relationship: Content: Author */ + $handler->display->display_options['relationships']['uid']['id'] = 'uid'; + $handler->display->display_options['relationships']['uid']['table'] = 'node'; + $handler->display->display_options['relationships']['uid']['field'] = 'uid'; + /* Field: Bulk operations: Content */ + $handler->display->display_options['fields']['views_bulk_operations']['id'] = 'views_bulk_operations'; + $handler->display->display_options['fields']['views_bulk_operations']['table'] = 'node'; + $handler->display->display_options['fields']['views_bulk_operations']['field'] = 'views_bulk_operations'; + $handler->display->display_options['fields']['views_bulk_operations']['label'] = 'Update Actions'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['display_type'] = '1'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['enable_select_all_pages'] = 1; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['force_single'] = 0; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '10'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_operations'] = array( + 'action::node_assign_owner_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::commons_content_moderation_delete_node_block_user' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::views_bulk_operations_delete_item' => array( + 'selected' => 1, + 'postpone_processing' => 0, + 'skip_confirmation' => 1, + 'override_label' => 1, + 'label' => 'Delete Item(s)', + ), + 'action::views_bulk_operations_script_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::flag_node_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::node_make_sticky_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::node_make_unsticky_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::views_bulk_operations_modify_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'settings' => array( + 'show_all_tokens' => 1, + 'display_values' => array( + '_all_' => '_all_', + ), + ), + ), + 'action::views_bulk_operations_argument_selector_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'settings' => array( + 'url' => '', + ), + ), + 'action::node_promote_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::node_publish_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 1, + 'override_label' => 1, + 'label' => 'Publish', + ), + 'action::node_unpromote_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::node_save_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::system_send_email_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::panelizer_set_status_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::node_unpublish_action' => array( + 'selected' => 1, + 'postpone_processing' => 0, + 'skip_confirmation' => 1, + 'override_label' => 1, + 'label' => 'Unpublish', + ), + 'action::node_unpublish_by_keyword_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::pathauto_node_update_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 1, + 'override_label' => 0, + 'label' => '', + ), + ); + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Field: User: Name */ + $handler->display->display_options['fields']['name']['id'] = 'name'; + $handler->display->display_options['fields']['name']['table'] = 'users'; + $handler->display->display_options['fields']['name']['field'] = 'name'; + $handler->display->display_options['fields']['name']['relationship'] = 'uid'; + $handler->display->display_options['fields']['name']['label'] = 'User'; + $handler->display->display_options['fields']['name']['element_label_colon'] = FALSE; + /* Field: Content: Updated date */ + $handler->display->display_options['fields']['changed']['id'] = 'changed'; + $handler->display->display_options['fields']['changed']['table'] = 'node'; + $handler->display->display_options['fields']['changed']['field'] = 'changed'; + $handler->display->display_options['fields']['changed']['label'] = 'Updated'; + $handler->display->display_options['fields']['changed']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['changed']['date_format'] = 'short'; + /* Field: Content: Edit link */ + $handler->display->display_options['fields']['edit_node']['id'] = 'edit_node'; + $handler->display->display_options['fields']['edit_node']['table'] = 'views_entity_node'; + $handler->display->display_options['fields']['edit_node']['field'] = 'edit_node'; + $handler->display->display_options['fields']['edit_node']['label'] = 'Operations'; + $handler->display->display_options['fields']['edit_node']['element_label_colon'] = FALSE; + /* Field: Content: Delete link */ + $handler->display->display_options['fields']['delete_node']['id'] = 'delete_node'; + $handler->display->display_options['fields']['delete_node']['table'] = 'views_entity_node'; + $handler->display->display_options['fields']['delete_node']['field'] = 'delete_node'; + $handler->display->display_options['fields']['delete_node']['label'] = ''; + $handler->display->display_options['fields']['delete_node']['element_label_colon'] = FALSE; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = '1'; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator_id'] = ''; + $handler->display->display_options['filters']['status']['expose']['label'] = 'Active'; + $handler->display->display_options['filters']['status']['expose']['operator'] = 'status_op'; + $handler->display->display_options['filters']['status']['expose']['identifier'] = 'status'; + $handler->display->display_options['filters']['status']['expose']['required'] = TRUE; + $handler->display->display_options['filters']['status']['expose']['remember_roles'] = array( + 2 => '2', + 1 => 0, + 3 => 0, + 4 => 0, + ); + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'node'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['value'] = array( + 'group' => 'group', + ); + + /* Display: Proposed */ + $handler = $view->new_display('page', 'Proposed', 'page'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['defaults']['fields'] = FALSE; + /* Field: Bulk operations: Content */ + $handler->display->display_options['fields']['views_bulk_operations']['id'] = 'views_bulk_operations'; + $handler->display->display_options['fields']['views_bulk_operations']['table'] = 'node'; + $handler->display->display_options['fields']['views_bulk_operations']['field'] = 'views_bulk_operations'; + $handler->display->display_options['fields']['views_bulk_operations']['label'] = 'Update Actions'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['display_type'] = '1'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['enable_select_all_pages'] = 1; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['force_single'] = 0; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '10'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_operations'] = array( + 'action::node_assign_owner_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::commons_content_moderation_delete_node_block_user' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::views_bulk_operations_delete_item' => array( + 'selected' => 1, + 'postpone_processing' => 0, + 'skip_confirmation' => 1, + 'override_label' => 1, + 'label' => 'Delete Item(s)', + ), + 'action::views_bulk_operations_script_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::flag_node_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::node_make_sticky_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::node_make_unsticky_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::views_bulk_operations_modify_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'settings' => array( + 'show_all_tokens' => 1, + 'display_values' => array( + '_all_' => '_all_', + ), + ), + ), + 'action::views_bulk_operations_argument_selector_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'settings' => array( + 'url' => '', + ), + ), + 'action::node_promote_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::node_publish_action' => array( + 'selected' => 1, + 'postpone_processing' => 0, + 'skip_confirmation' => 1, + 'override_label' => 1, + 'label' => 'Publish', + ), + 'action::node_unpromote_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::node_save_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::system_send_email_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::panelizer_set_status_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::node_unpublish_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 1, + 'override_label' => 1, + 'label' => 'Unpublish', + ), + 'action::node_unpublish_by_keyword_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::pathauto_node_update_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 1, + 'override_label' => 0, + 'label' => '', + ), + ); + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Field: User: Name */ + $handler->display->display_options['fields']['name']['id'] = 'name'; + $handler->display->display_options['fields']['name']['table'] = 'users'; + $handler->display->display_options['fields']['name']['field'] = 'name'; + $handler->display->display_options['fields']['name']['relationship'] = 'uid'; + $handler->display->display_options['fields']['name']['label'] = 'User'; + $handler->display->display_options['fields']['name']['element_label_colon'] = FALSE; + /* Field: Content: Updated date */ + $handler->display->display_options['fields']['changed']['id'] = 'changed'; + $handler->display->display_options['fields']['changed']['table'] = 'node'; + $handler->display->display_options['fields']['changed']['field'] = 'changed'; + $handler->display->display_options['fields']['changed']['label'] = 'Updated'; + $handler->display->display_options['fields']['changed']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['changed']['date_format'] = 'short'; + /* Field: Content: Edit link */ + $handler->display->display_options['fields']['edit_node']['id'] = 'edit_node'; + $handler->display->display_options['fields']['edit_node']['table'] = 'views_entity_node'; + $handler->display->display_options['fields']['edit_node']['field'] = 'edit_node'; + $handler->display->display_options['fields']['edit_node']['label'] = 'Operations'; + $handler->display->display_options['fields']['edit_node']['element_label_colon'] = FALSE; + /* Field: Content: Delete link */ + $handler->display->display_options['fields']['delete_node']['id'] = 'delete_node'; + $handler->display->display_options['fields']['delete_node']['table'] = 'views_entity_node'; + $handler->display->display_options['fields']['delete_node']['field'] = 'delete_node'; + $handler->display->display_options['fields']['delete_node']['label'] = ''; + $handler->display->display_options['fields']['delete_node']['element_label_colon'] = FALSE; + $handler->display->display_options['defaults']['filter_groups'] = FALSE; + $handler->display->display_options['defaults']['filters'] = FALSE; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = '0'; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator_id'] = ''; + $handler->display->display_options['filters']['status']['expose']['label'] = 'Active'; + $handler->display->display_options['filters']['status']['expose']['operator'] = 'status_op'; + $handler->display->display_options['filters']['status']['expose']['identifier'] = 'status'; + $handler->display->display_options['filters']['status']['expose']['required'] = TRUE; + $handler->display->display_options['filters']['status']['expose']['remember_roles'] = array( + 2 => '2', + 1 => 0, + 3 => 0, + 4 => 0, + ); + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'node'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['value'] = array( + 'group' => 'group', + ); + $handler->display->display_options['path'] = 'admin/content/groups/proposed'; + $handler->display->display_options['menu']['type'] = 'default tab'; + $handler->display->display_options['menu']['title'] = 'Proposed Groups'; + $handler->display->display_options['menu']['description'] = 'Proposed Group Moderation'; + $handler->display->display_options['menu']['weight'] = '0'; + $handler->display->display_options['menu']['context'] = 0; + $handler->display->display_options['tab_options']['type'] = 'tab'; + $handler->display->display_options['tab_options']['title'] = 'Groups'; + $handler->display->display_options['tab_options']['description'] = 'Groups Moderation'; + $handler->display->display_options['tab_options']['weight'] = '0'; + + /* Display: Published Groups */ + $handler = $view->new_display('page', 'Published Groups', 'page_1'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['defaults']['filter_groups'] = FALSE; + $handler->display->display_options['defaults']['filters'] = FALSE; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = '1'; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator_id'] = ''; + $handler->display->display_options['filters']['status']['expose']['label'] = 'Active'; + $handler->display->display_options['filters']['status']['expose']['operator'] = 'status_op'; + $handler->display->display_options['filters']['status']['expose']['identifier'] = 'status'; + $handler->display->display_options['filters']['status']['expose']['required'] = TRUE; + $handler->display->display_options['filters']['status']['expose']['remember_roles'] = array( + 2 => '2', + 1 => 0, + 3 => 0, + 4 => 0, + ); + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'node'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['value'] = array( + 'group' => 'group', + ); + $handler->display->display_options['path'] = 'admin/content/groups/published'; + $handler->display->display_options['menu']['type'] = 'tab'; + $handler->display->display_options['menu']['title'] = 'Published'; + $handler->display->display_options['menu']['description'] = 'Manage Published Groups'; + $handler->display->display_options['menu']['weight'] = '0'; + $handler->display->display_options['menu']['context'] = 0; + + /* Display: Group Update */ + $handler = $view->new_display('page', 'Group Update', 'page_2'); + $handler->display->display_options['defaults']['use_ajax'] = FALSE; + $handler->display->display_options['use_ajax'] = TRUE; + $handler->display->display_options['defaults']['empty'] = FALSE; + /* No results behavior: Global: Unfiltered text */ + $handler->display->display_options['empty']['area_text_custom']['id'] = 'area_text_custom'; + $handler->display->display_options['empty']['area_text_custom']['table'] = 'views'; + $handler->display->display_options['empty']['area_text_custom']['field'] = 'area_text_custom'; + $handler->display->display_options['empty']['area_text_custom']['label'] = 'No Results Toggle'; + $handler->display->display_options['empty']['area_text_custom']['empty'] = TRUE; + $handler->display->display_options['empty']['area_text_custom']['content'] = 'All groups are updated. Remove group update message'; + $handler->display->display_options['defaults']['fields'] = FALSE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Field: User: Name */ + $handler->display->display_options['fields']['name']['id'] = 'name'; + $handler->display->display_options['fields']['name']['table'] = 'users'; + $handler->display->display_options['fields']['name']['field'] = 'name'; + $handler->display->display_options['fields']['name']['relationship'] = 'uid'; + $handler->display->display_options['fields']['name']['label'] = 'User'; + $handler->display->display_options['fields']['name']['element_label_colon'] = FALSE; + /* Field: Content: Updated date */ + $handler->display->display_options['fields']['changed']['id'] = 'changed'; + $handler->display->display_options['fields']['changed']['table'] = 'node'; + $handler->display->display_options['fields']['changed']['field'] = 'changed'; + $handler->display->display_options['fields']['changed']['label'] = 'Updated'; + $handler->display->display_options['fields']['changed']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['changed']['date_format'] = 'short'; + /* Field: Content: Edit link */ + $handler->display->display_options['fields']['edit_node']['id'] = 'edit_node'; + $handler->display->display_options['fields']['edit_node']['table'] = 'views_entity_node'; + $handler->display->display_options['fields']['edit_node']['field'] = 'edit_node'; + $handler->display->display_options['fields']['edit_node']['label'] = 'Operations'; + $handler->display->display_options['fields']['edit_node']['element_label_colon'] = FALSE; + /* Field: Content: Delete link */ + $handler->display->display_options['fields']['delete_node']['id'] = 'delete_node'; + $handler->display->display_options['fields']['delete_node']['table'] = 'views_entity_node'; + $handler->display->display_options['fields']['delete_node']['field'] = 'delete_node'; + $handler->display->display_options['fields']['delete_node']['label'] = ''; + $handler->display->display_options['fields']['delete_node']['element_label_colon'] = FALSE; + $handler->display->display_options['defaults']['filter_groups'] = FALSE; + $handler->display->display_options['defaults']['filters'] = FALSE; + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'node'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['value'] = array( + 'group' => 'group', + ); + /* Filter criterion: Content: Privacy settings (field_og_subscribe_settings) */ + $handler->display->display_options['filters']['field_og_subscribe_settings_value']['id'] = 'field_og_subscribe_settings_value'; + $handler->display->display_options['filters']['field_og_subscribe_settings_value']['table'] = 'field_data_field_og_subscribe_settings'; + $handler->display->display_options['filters']['field_og_subscribe_settings_value']['field'] = 'field_og_subscribe_settings_value'; + $handler->display->display_options['filters']['field_og_subscribe_settings_value']['operator'] = 'empty'; + $handler->display->display_options['path'] = 'admin/content/groups/update'; + $handler->display->display_options['menu']['title'] = 'Needs Update'; + $handler->display->display_options['menu']['weight'] = '10'; + $handler->display->display_options['menu']['context'] = 0; + $handler->display->display_options['menu']['context_only_inline'] = 0; + $translatables['commons_group_moderation'] = array( + t('Master'), + t('Commons Group Moderation'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('author'), + t('Update Actions'), + t('Title'), + t('User'), + t('Updated'), + t('Operations'), + t('Active'), + t('Proposed'), + t('Published Groups'), + ); + $export['commons_group_moderation'] = $view; + + $view = new view(); + $view->name = 'commons_groups_contributors'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'users'; + $view->human_name = 'Commons Contributors - Sitewide'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Contributors'; + $handler->display->display_options['use_more'] = TRUE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['access']['perm'] = 'access user profiles'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['query']['options']['distinct'] = TRUE; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['pager']['options']['items_per_page'] = '16'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['style_plugin'] = 'grid'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'Nobody has contributed any site content yet.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: OG membership: OG membership from User */ + $handler->display->display_options['relationships']['og_membership_rel']['id'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['table'] = 'users'; + $handler->display->display_options['relationships']['og_membership_rel']['field'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['required'] = TRUE; + /* Field: User: Picture */ + $handler->display->display_options['fields']['picture']['id'] = 'picture'; + $handler->display->display_options['fields']['picture']['table'] = 'users'; + $handler->display->display_options['fields']['picture']['field'] = 'picture'; + $handler->display->display_options['fields']['picture']['label'] = ''; + $handler->display->display_options['fields']['picture']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['picture']['image_style'] = '50x50'; + /* Sort criterion: User: Created date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'users'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + /* Filter criterion: User: Active */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'users'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = '1'; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: OG membership: State */ + $handler->display->display_options['filters']['state']['id'] = 'state'; + $handler->display->display_options['filters']['state']['table'] = 'og_membership'; + $handler->display->display_options['filters']['state']['field'] = 'state'; + $handler->display->display_options['filters']['state']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['filters']['state']['value'] = array( + 1 => '1', + ); + /* Filter criterion: OG membership: Group_type */ + $handler->display->display_options['filters']['group_type']['id'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['table'] = 'og_membership'; + $handler->display->display_options['filters']['group_type']['field'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['filters']['group_type']['value'] = array( + 'node' => 'node', + ); + + /* Display: Content pane */ + $handler = $view->new_display('panel_pane', 'Content pane', 'panel_pane_1'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['pane_title'] = 'Contributors (Site-wide)'; + $handler->display->display_options['pane_category']['name'] = 'Commons'; + $handler->display->display_options['pane_category']['weight'] = '0'; + $translatables['commons_groups_contributors'] = array( + t('Master'), + t('Contributors'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('OG membership from user'), + t('Content pane'), + t('Contributors (Site-wide)'), + t('Commons'), + ); + $export['commons_groups_contributors'] = $view; + + $view = new view(); + $view->name = 'commons_groups_directory'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'commons_groups_directory'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Groups'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'load_more'; + $handler->display->display_options['pager']['options']['items_per_page'] = '10'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '0'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'node'; + $handler->display->display_options['row_options']['links'] = FALSE; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'No groups have been created yet.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Field: Group (group_group) */ + $handler->display->display_options['filters']['group_group_value']['id'] = 'group_group_value'; + $handler->display->display_options['filters']['group_group_value']['table'] = 'field_data_group_group'; + $handler->display->display_options['filters']['group_group_value']['field'] = 'group_group_value'; + $handler->display->display_options['filters']['group_group_value']['value'] = array( + 1 => '1', + ); + /* Filter criterion: Search: Search Terms */ + $handler->display->display_options['filters']['keys']['id'] = 'keys'; + $handler->display->display_options['filters']['keys']['table'] = 'search_index'; + $handler->display->display_options['filters']['keys']['field'] = 'keys'; + $handler->display->display_options['filters']['keys']['exposed'] = TRUE; + $handler->display->display_options['filters']['keys']['expose']['operator_id'] = 'keys_op'; + $handler->display->display_options['filters']['keys']['expose']['label'] = 'Limit to'; + $handler->display->display_options['filters']['keys']['expose']['operator'] = 'keys_op'; + $handler->display->display_options['filters']['keys']['expose']['identifier'] = 'groups-keys'; + $handler->display->display_options['filters']['keys']['expose']['remember_roles'] = array( + 2 => '2', + 1 => 0, + ); + + /* Display: Feed */ + $handler = $view->new_display('feed', 'Feed', 'feed'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['style_plugin'] = 'rss'; + $handler->display->display_options['row_plugin'] = 'node_rss'; + $handler->display->display_options['path'] = 'commons-groups-directory.xml'; + $handler->display->display_options['displays'] = array( + 'default' => 'default', + 'page' => 'page', + ); + + /* Display: Content pane */ + $handler = $view->new_display('panel_pane', 'Content pane', 'panel_pane_1'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['pane_category']['name'] = 'Commons'; + $handler->display->display_options['pane_category']['weight'] = '0'; + $handler->display->display_options['inherit_panels_path'] = '1'; + $translatables['commons_groups_directory'] = array( + t('Master'), + t('Groups'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('No groups have been created yet.'), + t('Limit to'), + t('Feed'), + t('Content pane'), + t('Commons'), + ); + $export['commons_groups_directory'] = $view; + + $view = new view(); + $view->name = 'commons_groups_recent_content'; + $view->description = 'Shows titles of the 5 most recent pieces of content in a group.'; + $view->tag = 'Commons'; + $view->base_table = 'node'; + $view->human_name = 'Commons Groups: Recent group content'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Commons Groups: Recent content'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['pager']['options']['items_per_page'] = '5'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* Relationship: OG membership: OG membership from Node */ + $handler->display->display_options['relationships']['og_membership_rel']['id'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['table'] = 'node'; + $handler->display->display_options['relationships']['og_membership_rel']['field'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['required'] = TRUE; + /* Field: Content: Type */ + $handler->display->display_options['fields']['type']['id'] = 'type'; + $handler->display->display_options['fields']['type']['table'] = 'node'; + $handler->display->display_options['fields']['type']['field'] = 'type'; + $handler->display->display_options['fields']['type']['label'] = ''; + $handler->display->display_options['fields']['type']['exclude'] = TRUE; + $handler->display->display_options['fields']['type']['element_label_colon'] = FALSE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + $handler->display->display_options['fields']['title']['element_class'] = 'type-[type]'; + $handler->display->display_options['fields']['title']['element_label_colon'] = FALSE; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + /* Contextual filter: OG membership: Group ID */ + $handler->display->display_options['arguments']['gid']['id'] = 'gid'; + $handler->display->display_options['arguments']['gid']['table'] = 'og_membership'; + $handler->display->display_options['arguments']['gid']['field'] = 'gid'; + $handler->display->display_options['arguments']['gid']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['arguments']['gid']['default_action'] = 'not found'; + $handler->display->display_options['arguments']['gid']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['gid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['gid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['gid']['summary_options']['items_per_page'] = '25'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: OG membership: Group_type */ + $handler->display->display_options['filters']['group_type']['id'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['table'] = 'og_membership'; + $handler->display->display_options['filters']['group_type']['field'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['filters']['group_type']['value'] = array( + 'node' => 'node', + ); + + /* Display: Block */ + $handler = $view->new_display('block', 'Block', 'block'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $translatables['commons_groups_recent_content'] = array( + t('Master'), + t('Commons Groups: Recent content'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Nobody has contributed any site content yet.'), + t('OG membership from node'), + t('All'), + t('Block'), + ); + $export['commons_groups_recent_content'] = $view; + + $view = new view(); + $view->name = 'commons_groups_user_groups'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'og_membership'; + $view->human_name = 'Commons Groups: Groups that a user contributes to'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'none'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'load_more'; + $handler->display->display_options['pager']['options']['items_per_page'] = '3'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '0'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'This person hasn\'t contributed to any groups yet.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: OG membership: Group Node from OG membership */ + $handler->display->display_options['relationships']['og_membership_related_node_group']['id'] = 'og_membership_related_node_group'; + $handler->display->display_options['relationships']['og_membership_related_node_group']['table'] = 'og_membership'; + $handler->display->display_options['relationships']['og_membership_related_node_group']['field'] = 'og_membership_related_node_group'; + $handler->display->display_options['relationships']['og_membership_related_node_group']['required'] = TRUE; + /* Field: Content: Group Logo */ + $handler->display->display_options['fields']['field_group_logo']['id'] = 'field_group_logo'; + $handler->display->display_options['fields']['field_group_logo']['table'] = 'field_data_field_group_logo'; + $handler->display->display_options['fields']['field_group_logo']['field'] = 'field_group_logo'; + $handler->display->display_options['fields']['field_group_logo']['relationship'] = 'og_membership_related_node_group'; + $handler->display->display_options['fields']['field_group_logo']['label'] = ''; + $handler->display->display_options['fields']['field_group_logo']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['field_group_logo']['click_sort_column'] = 'fid'; + $handler->display->display_options['fields']['field_group_logo']['settings'] = array( + 'image_style' => 'thumbnail', + 'image_link' => 'content', + ); + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['relationship'] = 'og_membership_related_node_group'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['element_label_colon'] = FALSE; + /* Field: Field: Group */ + $handler->display->display_options['fields']['group_group']['id'] = 'group_group'; + $handler->display->display_options['fields']['group_group']['table'] = 'field_data_group_group'; + $handler->display->display_options['fields']['group_group']['field'] = 'group_group'; + $handler->display->display_options['fields']['group_group']['relationship'] = 'og_membership_related_node_group'; + $handler->display->display_options['fields']['group_group']['label'] = ''; + $handler->display->display_options['fields']['group_group']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['group_group']['type'] = 'commons_groups_group_subscribe'; + $handler->display->display_options['fields']['group_group']['settings'] = array( + 'field_name' => '0', + ); + /* Contextual filter: OG membership: Entity id */ + $handler->display->display_options['arguments']['etid']['id'] = 'etid'; + $handler->display->display_options['arguments']['etid']['table'] = 'og_membership'; + $handler->display->display_options['arguments']['etid']['field'] = 'etid'; + $handler->display->display_options['arguments']['etid']['default_action'] = 'not found'; + $handler->display->display_options['arguments']['etid']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['etid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['etid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['etid']['summary_options']['items_per_page'] = '25'; + /* Filter criterion: OG membership: Entity_type */ + $handler->display->display_options['filters']['entity_type']['id'] = 'entity_type'; + $handler->display->display_options['filters']['entity_type']['table'] = 'og_membership'; + $handler->display->display_options['filters']['entity_type']['field'] = 'entity_type'; + $handler->display->display_options['filters']['entity_type']['value'] = 'user'; + + /* Display: Content pane */ + $handler = $view->new_display('panel_pane', 'Content pane', 'panel_pane_1'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['argument_input'] = array( + 'etid' => array( + 'type' => 'context', + 'context' => 'user_edit_form.uid', + 'context_optional' => 0, + 'panel' => '0', + 'fixed' => '', + 'label' => 'OG membership: Entity id', + ), + ); + $translatables['commons_groups_user_groups'] = array( + t('Master'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('This person hasn\'t contributed to any groups yet.'), + t('Group node from OG membership'), + t('All'), + t('Content pane'), + t('View panes'), + ); + $export['commons_groups_user_groups'] = $view; + + return $export; +} diff --git a/modules/commons/commons_groups/css/commons_groups.css b/modules/commons/commons_groups/css/commons_groups.css new file mode 100644 index 0000000..db04154 --- /dev/null +++ b/modules/commons/commons_groups/css/commons_groups.css @@ -0,0 +1 @@ +#edit-field-og-access-default-value { margin-left: 20px; } diff --git a/modules/commons/commons_groups/modules/commons_groups_directory/commons_groups_directory.features.inc b/modules/commons/commons_groups/modules/commons_groups_directory/commons_groups_directory.features.inc new file mode 100644 index 0000000..41a3f22 --- /dev/null +++ b/modules/commons/commons_groups/modules/commons_groups_directory/commons_groups_directory.features.inc @@ -0,0 +1,21 @@ + "1"); + } +} + +/** + * Implements hook_views_api(). + */ +function commons_groups_directory_views_api($module = NULL, $api = NULL) { + return array("api" => "3.0"); +} diff --git a/modules/commons/commons_groups/modules/commons_groups_directory/commons_groups_directory.info b/modules/commons/commons_groups/modules/commons_groups_directory/commons_groups_directory.info new file mode 100644 index 0000000..5bb77a3 --- /dev/null +++ b/modules/commons/commons_groups/modules/commons_groups_directory/commons_groups_directory.info @@ -0,0 +1,13 @@ +name = Commons Groups Directory +description = The site-wide directory of groups +core = 7.x +package = Commons - Landing pages +dependencies[] = commons_activity_streams_groups +dependencies[] = commons_radioactivity_groups +dependencies[] = ctools +dependencies[] = page_manager +dependencies[] = views_content +features[ctools][] = page_manager:pages_default:1 +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[page_manager_pages][] = groups_directory diff --git a/modules/commons/commons_groups/modules/commons_groups_directory/commons_groups_directory.module b/modules/commons/commons_groups/modules/commons_groups_directory/commons_groups_directory.module new file mode 100644 index 0000000..48e6fec --- /dev/null +++ b/modules/commons/commons_groups/modules/commons_groups_directory/commons_groups_directory.module @@ -0,0 +1,7 @@ +disabled = FALSE; /* Edit this to true to make a default page disabled initially */ + $page->api_version = 1; + $page->name = 'groups_directory'; + $page->task = 'page'; + $page->admin_title = 'Groups Directory'; + $page->admin_description = 'A directory of groups.'; + $page->path = 'groups'; + $page->access = array( + 'type' => 'none', + 'settings' => NULL, + ); + $page->menu = array( + 'type' => 'normal', + 'title' => 'Groups', + 'name' => 'main-menu', + 'weight' => '-1', + 'parent' => array( + 'type' => 'none', + 'title' => '', + 'name' => 'navigation', + 'weight' => '-1', + ), + ); + $page->arguments = array(); + $page->conf = array( + 'admin_paths' => FALSE, + ); + $page->default_handlers = array(); + $handler = new stdClass(); + $handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */ + $handler->api_version = 1; + $handler->name = 'page_groups_directory_panel_context'; + $handler->task = 'page'; + $handler->subtask = 'groups_directory'; + $handler->handler = 'panel_context'; + $handler->weight = 0; + $handler->conf = array( + 'title' => 'Panel', + 'no_blocks' => 0, + 'pipeline' => 'ipe', + 'body_classes_to_remove' => '', + 'body_classes_to_add' => '', + 'css_id' => '', + 'css' => '', + 'contexts' => array(), + 'relationships' => array(), + ); + $display = new panels_display(); + $display->layout = 'two_66_33'; + $display->layout_settings = array(); + $display->panel_settings = array( + 'style_settings' => array( + 'default' => NULL, + 'top' => NULL, + 'left' => NULL, + 'right' => NULL, + 'bottom' => NULL, + 'two_66_33_top' => NULL, + 'two_66_33_first' => NULL, + 'two_66_33_second' => NULL, + 'two_66_33_bottom' => NULL, + ), + ); + $display->cache = array(); + $display->title = 'Groups'; + $display->uuid = 'b342a293-2541-cc64-1577-839054c92368'; + $display->content = array(); + $display->panels = array(); + $pane = new stdClass(); + $pane->pid = 'new-bf6c6f1b-08a6-3874-7186-c955c763c092'; + $pane->panel = 'two_66_33_first'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_groups_directory-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = 'bf6c6f1b-08a6-3874-7186-c955c763c092'; + $display->content['new-bf6c6f1b-08a6-3874-7186-c955c763c092'] = $pane; + $display->panels['two_66_33_first'][0] = 'new-bf6c6f1b-08a6-3874-7186-c955c763c092'; + $pane = new stdClass(); + $pane->pid = 'new-ab237aa5-5ae7-8fb4-e1ce-20c776a6950b'; + $pane->panel = 'two_66_33_second'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_radioactivity_groups_most_active-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = 'ab237aa5-5ae7-8fb4-e1ce-20c776a6950b'; + $display->content['new-ab237aa5-5ae7-8fb4-e1ce-20c776a6950b'] = $pane; + $display->panels['two_66_33_second'][0] = 'new-ab237aa5-5ae7-8fb4-e1ce-20c776a6950b'; + $pane = new stdClass(); + $pane->pid = 'new-3db36521-fb53-58a4-c9e2-137a2dacee07'; + $pane->panel = 'two_66_33_top'; + $pane->type = 'block'; + $pane->subtype = 'commons_groups-commons_groups_create_group'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 0, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = '3db36521-fb53-58a4-c9e2-137a2dacee07'; + $display->content['new-3db36521-fb53-58a4-c9e2-137a2dacee07'] = $pane; + $display->panels['two_66_33_top'][0] = 'new-3db36521-fb53-58a4-c9e2-137a2dacee07'; + $display->hide_title = PANELS_TITLE_FIXED; + $display->title_pane = 'new-bf6c6f1b-08a6-3874-7186-c955c763c092'; + $handler->conf['display'] = $display; + $page->default_handlers[$handler->name] = $handler; + $pages['groups_directory'] = $page; + + return $pages; + +} diff --git a/modules/commons/commons_groups/modules/commons_groups_pages/commons_groups_pages.features.inc b/modules/commons/commons_groups/modules/commons_groups_pages/commons_groups_pages.features.inc new file mode 100644 index 0000000..4d103b2 --- /dev/null +++ b/modules/commons/commons_groups/modules/commons_groups_pages/commons_groups_pages.features.inc @@ -0,0 +1,17 @@ + "1"); + } + if ($module == "strongarm" && $api == "strongarm") { + return array("version" => "1"); + } +} diff --git a/modules/commons/commons_groups/modules/commons_groups_pages/commons_groups_pages.info b/modules/commons/commons_groups/modules/commons_groups_pages/commons_groups_pages.info new file mode 100644 index 0000000..fdcc25f --- /dev/null +++ b/modules/commons/commons_groups/modules/commons_groups_pages/commons_groups_pages.info @@ -0,0 +1,17 @@ +name = Commons Group Homepages +description = Provides a default home page for groups +core = 7.x +package = Commons - Landing pages +dependencies[] = commons_activity_streams +dependencies[] = commons_bw +dependencies[] = commons_follow_group +dependencies[] = commons_radioactivity_groups +dependencies[] = ctools +dependencies[] = panelizer +dependencies[] = strongarm +features[ctools][] = panelizer:panelizer:1 +features[ctools][] = strongarm:strongarm:1 +features[features_api][] = api:2 +features[panelizer_defaults][] = node:group:default +features[panelizer_defaults][] = node:group:default:teaser +features[variable][] = panelizer_defaults_node_group diff --git a/modules/commons/commons_groups/modules/commons_groups_pages/commons_groups_pages.install b/modules/commons/commons_groups/modules/commons_groups_pages/commons_groups_pages.install new file mode 100644 index 0000000..73dd290 --- /dev/null +++ b/modules/commons/commons_groups/modules/commons_groups_pages/commons_groups_pages.install @@ -0,0 +1,22 @@ + array('panelizer_defaults'), + ); + features_revert($revert); + return array(); +} diff --git a/modules/commons/commons_groups/modules/commons_groups_pages/commons_groups_pages.module b/modules/commons/commons_groups/modules/commons_groups_pages/commons_groups_pages.module new file mode 100644 index 0000000..defdc24 --- /dev/null +++ b/modules/commons/commons_groups/modules/commons_groups_pages/commons_groups_pages.module @@ -0,0 +1,56 @@ +name == 'commons_groups_pages') { + $group_bundles = og_get_all_group_bundle(); + if (!empty($group_bundles['node'])) { + foreach ($group_bundles['node'] as $bundle => $name) { + // These field instances should be added to groups regardless of + // whether og_access.module is enabled. + $info['features']['panelizer_defaults'][] = "node:$bundle:default"; + $info['features']['panelizer_defaults'][] = "node:$bundle:default:teaser"; + $info['features']['variable'][] = "panelizer_defaults_node_$bundle"; + } + } + } +} + +/* + * Implements hook_features_pipe_alter(). + */ +function commons_groups_pages_features_pipe_alter(&$pipe, $data, $export) { + // Prevent Commons Groups related fields from being piped in features + // when a content type includes those fields. + if (!empty($pipe['panelizer_defaults'])) { + + foreach ($pipe['panelizer_defaults'] as $delta => $value) { + $args = explode(':', $value); + $group_name = $args[1]; + + $group_bundles = og_get_all_group_bundle(); + if (isset($group_bundles['node']) && isset($group_bundles['node']['group'])) { + unset($group_bundles['node']['group']); + } + $excluded_groups = array_keys($group_bundles); + if (in_array($group_name, $excluded_groups)) { + unset($pipe['field_instance'][$delta]); + } + } + } +} \ No newline at end of file diff --git a/modules/commons/commons_groups/modules/commons_groups_pages/commons_groups_pages.panelizer.inc b/modules/commons/commons_groups/modules/commons_groups_pages/commons_groups_pages.panelizer.inc new file mode 100644 index 0000000..0431bfb --- /dev/null +++ b/modules/commons/commons_groups/modules/commons_groups_pages/commons_groups_pages.panelizer.inc @@ -0,0 +1,456 @@ + $name) { + $panelizer = new stdClass(); + $panelizer->disabled = FALSE; /* Edit this to true to make a default panelizer disabled initially */ + $panelizer->api_version = 1; + $panelizer->name = "node:$bundle:default"; + $panelizer->title = 'Default'; + $panelizer->panelizer_type = 'node'; + $panelizer->panelizer_key = $bundle; + $panelizer->no_blocks = FALSE; + $panelizer->css_id = ''; + $panelizer->css = ''; + $panelizer->pipeline = 'ipe'; + $panelizer->contexts = array(); + $panelizer->relationships = array(); + $panelizer->access = array(); + $panelizer->view_mode = 'page_manager'; + $panelizer->css_class = ''; + $panelizer->title_element = 'H2'; + $panelizer->link_to_entity = TRUE; + $panelizer->extra = ''; + $display = new panels_display(); + $display->layout = 'two_66_33'; + $display->layout_settings = array(); + $display->panel_settings = array( + 'style_settings' => array( + 'default' => NULL, + 'top' => NULL, + 'left' => NULL, + 'right' => NULL, + 'bottom' => NULL, + 'two_66_33_top' => NULL, + 'two_66_33_first' => NULL, + 'two_66_33_second' => NULL, + 'two_66_33_bottom' => NULL, + ), + ); + $display->cache = array(); + $display->title = '%node:title'; + $display->uuid = '819deb2a-c56c-2214-558d-c52460a89778'; + $display->content = array(); + $display->panels = array(); + $pane = new stdClass(); + $pane->pid = 'new-10f12c5b-679e-d294-b1bd-9aac845800f5'; + $pane->panel = 'two_66_33_first'; + $pane->type = 'node_content'; + $pane->subtype = 'node_content'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'links' => 1, + 'no_extras' => 0, + 'override_title' => 1, + 'override_title_text' => '', + 'identifier' => '', + 'link' => 0, + 'leave_node_title' => 0, + 'build_mode' => 'full', + 'context' => 'panelizer', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = '10f12c5b-679e-d294-b1bd-9aac845800f5'; + $display->content['new-10f12c5b-679e-d294-b1bd-9aac845800f5'] = $pane; + $display->panels['two_66_33_first'][0] = 'new-10f12c5b-679e-d294-b1bd-9aac845800f5'; + $pane = new stdClass(); + $pane->pid = 'new-80b62348-7cee-e304-5d65-0ce1b6bbb216'; + $pane->panel = 'two_66_33_first'; + $pane->type = 'commons_bw_group'; + $pane->subtype = 'commons_bw_group'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 0, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 1; + $pane->locks = array(); + $pane->uuid = '80b62348-7cee-e304-5d65-0ce1b6bbb216'; + $display->content['new-80b62348-7cee-e304-5d65-0ce1b6bbb216'] = $pane; + $display->panels['two_66_33_first'][1] = 'new-80b62348-7cee-e304-5d65-0ce1b6bbb216'; + $pane = new stdClass(); + $pane->pid = 'new-13120946-03a1-bfc4-2d74-f39dd758ebce'; + $pane->panel = 'two_66_33_second'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_events_upcoming-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'context' => array( + 0 => 'panelizer', + ), + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = '13120946-03a1-bfc4-2d74-f39dd758ebce'; + $display->content['new-13120946-03a1-bfc4-2d74-f39dd758ebce'] = $pane; + $display->panels['two_66_33_second'][0] = 'new-13120946-03a1-bfc4-2d74-f39dd758ebce'; + $pane = new stdClass(); + $pane->pid = 'new-a7009535-0e2a-2c94-edd2-4ecc953c4ca2'; + $pane->panel = 'two_66_33_second'; + $pane->type = 'views_panes'; + $pane->subtype = 'activity_group-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'items_per_page' => '4', + 'arguments' => array( + 'gid' => '%node:nid', + ), + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 1; + $pane->locks = array(); + $pane->uuid = 'a7009535-0e2a-2c94-edd2-4ecc953c4ca2'; + $display->content['new-a7009535-0e2a-2c94-edd2-4ecc953c4ca2'] = $pane; + $display->panels['two_66_33_second'][1] = 'new-a7009535-0e2a-2c94-edd2-4ecc953c4ca2'; + $pane = new stdClass(); + $pane->pid = 'new-ba735f2b-4734-7724-098d-1925c6a4bb47'; + $pane->panel = 'two_66_33_second'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_radioactivity_groups_active_in_group-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'arguments' => array( + 'gid' => '%node:nid', + ), + 'context' => array( + 0 => 'panelizer', + ), + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 2; + $pane->locks = array(); + $pane->uuid = 'ba735f2b-4734-7724-098d-1925c6a4bb47'; + $display->content['new-ba735f2b-4734-7724-098d-1925c6a4bb47'] = $pane; + $display->panels['two_66_33_second'][2] = 'new-ba735f2b-4734-7724-098d-1925c6a4bb47'; + $pane = new stdClass(); + $pane->pid = 'new-52796f83-93dd-2cf4-41aa-33520dc31e5f'; + $pane->panel = 'two_66_33_second'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_contributors_group-panel_pane_2'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'context' => array( + 0 => 'panelizer', + ), + ); + $pane->cache = array( + 'method' => 'simple', + 'settings' => array( + 'lifetime' => '15', + 'granularity' => 'context', + ), + ); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 3; + $pane->locks = array(); + $pane->uuid = '52796f83-93dd-2cf4-41aa-33520dc31e5f'; + $display->content['new-52796f83-93dd-2cf4-41aa-33520dc31e5f'] = $pane; + $display->panels['two_66_33_second'][3] = 'new-52796f83-93dd-2cf4-41aa-33520dc31e5f'; + $display->hide_title = PANELS_TITLE_FIXED; + $display->title_pane = '0'; + $panelizer->display = $display; + $export["node:$bundle:default"] = $panelizer; + + $panelizer = new stdClass(); + $panelizer->disabled = FALSE; /* Edit this to true to make a default panelizer disabled initially */ + $panelizer->api_version = 1; + $panelizer->name = "node:$bundle:default:teaser"; + $panelizer->title = 'Default'; + $panelizer->panelizer_type = 'node'; + $panelizer->panelizer_key = "$bundle"; + $panelizer->no_blocks = FALSE; + $panelizer->css_id = ''; + $panelizer->css = ''; + $panelizer->pipeline = 'standard'; + $panelizer->contexts = array(); + $panelizer->relationships = array(); + $panelizer->access = array(); + $panelizer->view_mode = 'teaser'; + $panelizer->css_class = ''; + $panelizer->title_element = 'H2'; + $panelizer->link_to_entity = TRUE; + $panelizer->extra = array(); + $display = new panels_display(); + $display->layout = 'one'; + $display->layout_settings = array(); + $display->panel_settings = array( + 'style_settings' => array( + 'default' => NULL, + 'one_main' => NULL, + ), + ); + $display->cache = array(); + $display->title = '%node:title'; + $display->uuid = '2880dc3a-9be6-dc34-a563-b9748d152f92'; + $display->content = array(); + $display->panels = array(); + $pane = new stdClass(); + $pane->pid = 'new-026f9d2d-fd0e-d794-1971-47eb628a7f6e'; + $pane->panel = 'one_main'; + $pane->type = 'entity_field'; + $pane->subtype = 'node:group_group'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'label' => 'hidden', + 'formatter' => 'commons_groups_group_subscribe', + 'delta_limit' => 0, + 'delta_offset' => '0', + 'delta_reversed' => FALSE, + 'formatter_settings' => array(), + 'context' => 'panelizer', + 'override_title' => 0, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = '026f9d2d-fd0e-d794-1971-47eb628a7f6e'; + $display->content['new-026f9d2d-fd0e-d794-1971-47eb628a7f6e'] = $pane; + $display->panels['one_main'][0] = 'new-026f9d2d-fd0e-d794-1971-47eb628a7f6e'; + $pane = new stdClass(); + $pane->pid = 'new-13859111-e3fa-5e54-a93c-57f09d719e38'; + $pane->panel = 'one_main'; + $pane->type = 'token'; + $pane->subtype = 'node:commons-groups-group-contributors-count-topics'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'sanitize' => 0, + 'context' => 'panelizer', + 'override_title' => 0, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 1; + $pane->locks = array(); + $pane->uuid = '13859111-e3fa-5e54-a93c-57f09d719e38'; + $display->content['new-13859111-e3fa-5e54-a93c-57f09d719e38'] = $pane; + $display->panels['one_main'][1] = 'new-13859111-e3fa-5e54-a93c-57f09d719e38'; + $pane = new stdClass(); + $pane->pid = 'new-f7a3719c-d7be-f024-ed91-c8c0df943df4'; + $pane->panel = 'one_main'; + $pane->type = 'token'; + $pane->subtype = 'node:flag-commons-follow-group-link'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'sanitize' => 0, + 'context' => 'panelizer', + 'override_title' => 1, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 2; + $pane->locks = array(); + $pane->uuid = 'f7a3719c-d7be-f024-ed91-c8c0df943df4'; + $display->content['new-f7a3719c-d7be-f024-ed91-c8c0df943df4'] = $pane; + $display->panels['one_main'][2] = 'new-f7a3719c-d7be-f024-ed91-c8c0df943df4'; + $pane = new stdClass(); + $pane->pid = 'new-926a99b3-8e75-aa14-2542-16f2ab9e70b3'; + $pane->panel = 'one_main'; + $pane->type = 'entity_field'; + $pane->subtype = 'node:field_group_logo'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'label' => 'hidden', + 'formatter' => 'image', + 'delta_limit' => 0, + 'delta_offset' => '0', + 'delta_reversed' => FALSE, + 'formatter_settings' => array( + 'image_style' => '50x50', + 'image_link' => 'content', + ), + 'context' => 'panelizer', + 'override_title' => 0, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 3; + $pane->locks = array(); + $pane->uuid = '926a99b3-8e75-aa14-2542-16f2ab9e70b3'; + $display->content['new-926a99b3-8e75-aa14-2542-16f2ab9e70b3'] = $pane; + $display->panels['one_main'][3] = 'new-926a99b3-8e75-aa14-2542-16f2ab9e70b3'; + $pane = new stdClass(); + $pane->pid = 'new-c22911c5-3c21-75b4-c5f3-80efb733956b'; + $pane->panel = 'one_main'; + $pane->type = 'entity_field'; + $pane->subtype = 'node:body'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'label' => 'hidden', + 'formatter' => 'text_summary_or_trimmed', + 'delta_limit' => 0, + 'delta_offset' => '0', + 'delta_reversed' => FALSE, + 'formatter_settings' => array( + 'trim_length' => '600', + ), + 'context' => 'panelizer', + 'override_title' => 0, + 'override_title_text' => 'Por que no se ve?', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 4; + $pane->locks = array(); + $pane->uuid = 'c22911c5-3c21-75b4-c5f3-80efb733956b'; + $display->content['new-c22911c5-3c21-75b4-c5f3-80efb733956b'] = $pane; + $display->panels['one_main'][4] = 'new-c22911c5-3c21-75b4-c5f3-80efb733956b'; + $pane = new stdClass(); + $pane->pid = 'new-cb706c02-36e8-a414-c9f5-c34bf15861ca'; + $pane->panel = 'one_main'; + $pane->type = 'views'; + $pane->subtype = 'commons_groups_recent_content'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_pager_settings' => 0, + 'use_pager' => 0, + 'nodes_per_page' => '5', + 'pager_id' => '0', + 'offset' => '0', + 'more_link' => 0, + 'feed_icons' => 0, + 'panel_args' => 0, + 'link_to_view' => 0, + 'args' => '', + 'url' => '', + 'display' => 'block', + 'context' => array( + 0 => 'panelizer.nid', + ), + 'override_title' => 1, + 'override_title_text' => 'Recent content', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 5; + $pane->locks = array(); + $pane->uuid = 'cb706c02-36e8-a414-c9f5-c34bf15861ca'; + $display->content['new-cb706c02-36e8-a414-c9f5-c34bf15861ca'] = $pane; + $display->panels['one_main'][5] = 'new-cb706c02-36e8-a414-c9f5-c34bf15861ca'; + $pane = new stdClass(); + $pane->pid = 'new-6c3207ac-19f3-8184-11ba-e3aee789a9c8'; + $pane->panel = 'one_main'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_contributors_group-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'context' => array( + 0 => 'panelizer', + ), + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 6; + $pane->locks = array(); + $pane->uuid = '6c3207ac-19f3-8184-11ba-e3aee789a9c8'; + $display->content['new-6c3207ac-19f3-8184-11ba-e3aee789a9c8'] = $pane; + $display->panels['one_main'][6] = 'new-6c3207ac-19f3-8184-11ba-e3aee789a9c8'; + $display->hide_title = PANELS_TITLE_FIXED; + $display->title_pane = '0'; + $panelizer->display = $display; + $export["node:$bundle:default:teaser"] = $panelizer; + } + } + + + return $export; +} diff --git a/modules/commons/commons_groups/modules/commons_groups_pages/commons_groups_pages.strongarm.inc b/modules/commons/commons_groups/modules/commons_groups_pages/commons_groups_pages.strongarm.inc new file mode 100644 index 0000000..8de19ca --- /dev/null +++ b/modules/commons/commons_groups/modules/commons_groups_pages/commons_groups_pages.strongarm.inc @@ -0,0 +1,46 @@ + $name) { + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = "panelizer_defaults_node_$bundle"; + $strongarm->value = array( + 'status' => 1, + 'view modes' => array( + 'page_manager' => array( + 'status' => 1, + 'default' => 1, + 'choice' => 0, + ), + 'default' => array( + 'status' => 0, + 'default' => 0, + 'choice' => 0, + ), + 'teaser' => array( + 'status' => 1, + 'default' => 1, + 'choice' => 0, + ), + ), + ); + $export["panelizer_defaults_node_$bundle"] = $strongarm; + } + } + + return $export; +} diff --git a/modules/commons/commons_groups/plugins/entityreference/selection/OgCommonsSelectionHandler.class.php b/modules/commons/commons_groups/plugins/entityreference/selection/OgCommonsSelectionHandler.class.php new file mode 100644 index 0000000..05dfcf4 --- /dev/null +++ b/modules/commons/commons_groups/plugins/entityreference/selection/OgCommonsSelectionHandler.class.php @@ -0,0 +1,83 @@ +field['settings']['target_type']; + + if (empty($this->instance['field_mode']) || $group_type != 'node' || user_is_anonymous()) { + return parent::buildEntityFieldQuery($match, $match_operator); + } + + $handler = EntityReference_SelectionHandler_Generic::getInstance($this->field, $this->instance, $this->entity_type, $this->entity); + $query = $handler->buildEntityFieldQuery($match, $match_operator); + + // Show only the entities that are active groups. + $query->fieldCondition(OG_GROUP_FIELD, 'value', 1); + $query->fieldCondition('field_og_subscribe_settings', 'value', 'anyone'); + + // Add this property to make sure we will have the {node} table later on in + // OgCommonsSelectionHandler::entityFieldQueryAlter(). + $query->propertyCondition('nid', 0, '>'); + + $query->addMetaData('entityreference_selection_handler', $this); + + // FIXME: http://drupal.org/node/1325628 + unset($query->tags['node_access']); + + $query->addTag('entity_field_access'); + $query->addTag('og'); + + return $query; + } + + /** + * Overrides OgSelectionHandler::entityFieldQueryAlter(). + * + * Add the user's groups along with the rest of the "public" groups. + */ + public function entityFieldQueryAlter(SelectQueryInterface $query) { + $gids = og_get_entity_groups(); + if (empty($gids['node'])) { + return; + } + + $conditions = &$query->conditions(); + // Find the condition for the "field_data_field_privacy_settings" query, and + // the one for the "node.nid", so we can later db_or() them. + $public_condition = array(); + foreach ($conditions as $key => $condition) { + if ($key !== '#conjunction' && is_string($condition['field'])) { + if (strpos($condition['field'], 'field_data_field_og_subscribe_settings') === 0) { + $public_condition = $condition; + unset($conditions[$key]); + } + + if ($condition['field'] === 'node.nid') { + unset($conditions[$key]); + } + } + } + + if (!$public_condition) { + return; + } + + $or = db_or(); + $or->condition($public_condition['field'], $public_condition['value'], $public_condition['operator']); + $or->condition('node.nid', $gids['node'], 'IN'); + $query->condition($or); + } +} diff --git a/modules/commons/commons_groups/plugins/entityreference/selection/og_commons.inc b/modules/commons/commons_groups/plugins/entityreference/selection/og_commons.inc new file mode 100644 index 0000000..55fc029 --- /dev/null +++ b/modules/commons/commons_groups/plugins/entityreference/selection/og_commons.inc @@ -0,0 +1,6 @@ + t('Commons OG'), + 'class' => 'OgCommonsSelectionHandler', +); diff --git a/modules/commons/commons_images/commons_images.default_breakpoint_group.inc b/modules/commons/commons_images/commons_images.default_breakpoint_group.inc new file mode 100644 index 0000000..a5492eb --- /dev/null +++ b/modules/commons/commons_images/commons_images.default_breakpoint_group.inc @@ -0,0 +1,90 @@ +disabled = FALSE; /* Edit this to true to make a default breakpoint_group disabled initially */ + $breakpoint_group->api_version = 1; + $breakpoint_group->machine_name = 'commons_default'; + $breakpoint_group->name = 'Commons default'; + $breakpoint_group->breakpoints = $breakpoints; + $breakpoint_group->type = 'module'; + $breakpoint_group->overridden = 0; + $export['commons_default'] = $breakpoint_group; + + // Breakpoints. + $breakpoints = array(); + $breakpoints[] = 'breakpoints.theme.commons_origins.commons small portrait'; + $breakpoints[] = 'breakpoints.theme.commons_origins.commons small landscape'; + $breakpoints[] = 'breakpoints.theme.commons_origins.commons medium portrait'; + $breakpoints[] = 'breakpoints.theme.commons_origins.commons medium landscape'; + $breakpoints[] = 'breakpoints.theme.commons_origins.commons large'; + + // Breakpoint group. + $breakpoint_group = new stdClass(); + $breakpoint_group->disabled = FALSE; /* Edit this to true to make a default breakpoint_group disabled initially */ + $breakpoint_group->api_version = 1; + $breakpoint_group->machine_name = 'commons_full'; + $breakpoint_group->name = 'Commons full'; + $breakpoint_group->breakpoints = $breakpoints; + $breakpoint_group->type = 'module'; + $breakpoint_group->overridden = 0; + $export['commons_full'] = $breakpoint_group; + + // Breakpoints. + $breakpoints = array(); + $breakpoints[] = 'breakpoints.theme.commons_origins.commons small portrait'; + $breakpoints[] = 'breakpoints.theme.commons_origins.commons small landscape'; + $breakpoints[] = 'breakpoints.theme.commons_origins.commons medium portrait'; + $breakpoints[] = 'breakpoints.theme.commons_origins.commons medium landscape'; + $breakpoints[] = 'breakpoints.theme.commons_origins.commons large'; + + // Breakpoint group. + $breakpoint_group = new stdClass(); + $breakpoint_group->disabled = FALSE; /* Edit this to true to make a default breakpoint_group disabled initially */ + $breakpoint_group->api_version = 1; + $breakpoint_group->machine_name = 'commons_origins'; + $breakpoint_group->name = 'Commons Origins'; + $breakpoint_group->breakpoints = $breakpoints; + $breakpoint_group->type = 'theme'; + $breakpoint_group->overridden = 0; + $export['commons_origins'] = $breakpoint_group; + + // Breakpoints. + $breakpoints = array(); + $breakpoints[] = 'breakpoints.theme.commons_origins.commons small portrait'; + $breakpoints[] = 'breakpoints.theme.commons_origins.commons small landscape'; + $breakpoints[] = 'breakpoints.theme.commons_origins.commons medium portrait'; + $breakpoints[] = 'breakpoints.theme.commons_origins.commons medium landscape'; + $breakpoints[] = 'breakpoints.theme.commons_origins.commons large'; + + // Breakpoint group. + $breakpoint_group = new stdClass(); + $breakpoint_group->disabled = FALSE; /* Edit this to true to make a default breakpoint_group disabled initially */ + $breakpoint_group->api_version = 1; + $breakpoint_group->machine_name = 'commons_teaser'; + $breakpoint_group->name = 'Commons teaser'; + $breakpoint_group->breakpoints = $breakpoints; + $breakpoint_group->type = 'module'; + $breakpoint_group->overridden = 0; + $export['commons_teaser'] = $breakpoint_group; + + return $export; +} diff --git a/modules/commons/commons_images/commons_images.default_breakpoints.inc b/modules/commons/commons_images/commons_images.default_breakpoints.inc new file mode 100644 index 0000000..fbda730 --- /dev/null +++ b/modules/commons/commons_images/commons_images.default_breakpoints.inc @@ -0,0 +1,89 @@ +disabled = FALSE; /* Edit this to true to make a default breakpoint disabled initially */ + $breakpoint->api_version = 1; + $breakpoint->machine_name = 'breakpoints.theme.commons_origins.commons large'; + $breakpoint->name = 'Commons large'; + $breakpoint->breakpoint = 'only screen and (min-width:935px)'; + $breakpoint->source = 'commons_origins'; + $breakpoint->source_type = 'theme'; + $breakpoint->status = 1; + $breakpoint->weight = 4; + $breakpoint->multipliers = array( + '1x' => '1x', + ); + $export['breakpoints.theme.commons_origins.commons large'] = $breakpoint; + + $breakpoint = new stdClass(); + $breakpoint->disabled = FALSE; /* Edit this to true to make a default breakpoint disabled initially */ + $breakpoint->api_version = 1; + $breakpoint->machine_name = 'breakpoints.theme.commons_origins.commons medium landscape'; + $breakpoint->name = 'Commons medium landscape'; + $breakpoint->breakpoint = 'only screen and (min-width:769px) and (max-width:934px'; + $breakpoint->source = 'commons_origins'; + $breakpoint->source_type = 'theme'; + $breakpoint->status = 1; + $breakpoint->weight = 3; + $breakpoint->multipliers = array( + '1x' => '1x', + ); + $export['breakpoints.theme.commons_origins.commons medium landscape'] = $breakpoint; + + $breakpoint = new stdClass(); + $breakpoint->disabled = FALSE; /* Edit this to true to make a default breakpoint disabled initially */ + $breakpoint->api_version = 1; + $breakpoint->machine_name = 'breakpoints.theme.commons_origins.commons medium portrait'; + $breakpoint->name = 'Commons medium portrait'; + $breakpoint->breakpoint = 'only screen and (min-width:481px) and (max-width:768px)'; + $breakpoint->source = 'commons_origins'; + $breakpoint->source_type = 'theme'; + $breakpoint->status = 1; + $breakpoint->weight = 2; + $breakpoint->multipliers = array( + '1x' => '1x', + ); + $export['breakpoints.theme.commons_origins.commons medium portrait'] = $breakpoint; + + $breakpoint = new stdClass(); + $breakpoint->disabled = FALSE; /* Edit this to true to make a default breakpoint disabled initially */ + $breakpoint->api_version = 1; + $breakpoint->machine_name = 'breakpoints.theme.commons_origins.commons small landscape'; + $breakpoint->name = 'Commons small landscape'; + $breakpoint->breakpoint = 'only screen and (min-width:321px) and (max-width:480px)'; + $breakpoint->source = 'commons_origins'; + $breakpoint->source_type = 'theme'; + $breakpoint->status = 1; + $breakpoint->weight = 1; + $breakpoint->multipliers = array( + '1x' => '1x', + ); + $export['breakpoints.theme.commons_origins.commons small landscape'] = $breakpoint; + + $breakpoint = new stdClass(); + $breakpoint->disabled = FALSE; /* Edit this to true to make a default breakpoint disabled initially */ + $breakpoint->api_version = 1; + $breakpoint->machine_name = 'breakpoints.theme.commons_origins.commons small portrait'; + $breakpoint->name = 'Commons small portrait'; + $breakpoint->breakpoint = 'only screen and (max-width:320px)'; + $breakpoint->source = 'commons_origins'; + $breakpoint->source_type = 'theme'; + $breakpoint->status = 1; + $breakpoint->weight = 0; + $breakpoint->multipliers = array( + '1x' => '1x', + ); + $export['breakpoints.theme.commons_origins.commons small portrait'] = $breakpoint; + + return $export; +} diff --git a/modules/commons/commons_images/commons_images.default_picture_mapping.inc b/modules/commons/commons_images/commons_images.default_picture_mapping.inc new file mode 100644 index 0000000..e91e30f --- /dev/null +++ b/modules/commons/commons_images/commons_images.default_picture_mapping.inc @@ -0,0 +1,101 @@ +disabled = FALSE; /* Edit this to true to make a default picture_mapping disabled initially */ + $picture_mapping->api_version = 1; + $picture_mapping->machine_name = 'commons_default'; + $picture_mapping->breakpoint_group = 'commons_default'; + $picture_mapping->mapping = array( + 'breakpoints.theme.commons_origins.commons small portrait' => array( + '1x' => 'commons-default-small', + '1.5x' => 'commons-default-small-1_5x', + ), + 'breakpoints.theme.commons_origins.commons small landscape' => array( + '1x' => 'commons-default-small', + '1.5x' => 'commons-default-small-1_5x', + ), + 'breakpoints.theme.commons_origins.commons medium portrait' => array( + '1x' => 'commons-default-medium', + '1.5x' => 'commons-default-medium-1_5x', + ), + 'breakpoints.theme.commons_origins.commons medium landscape' => array( + '1x' => 'commons-default-medium', + '1.5x' => 'commons-default-medium-1_5x', + ), + 'breakpoints.theme.commons_origins.commons large' => array( + '1x' => 'commons-default-large', + '1.5x' => 'commons-default-large-1_5x', + ), + ); + $export['commons_default'] = $picture_mapping; + + $picture_mapping = new stdClass(); + $picture_mapping->disabled = FALSE; /* Edit this to true to make a default picture_mapping disabled initially */ + $picture_mapping->api_version = 1; + $picture_mapping->machine_name = 'commons_full'; + $picture_mapping->breakpoint_group = 'commons_full'; + $picture_mapping->mapping = array( + 'breakpoints.theme.commons_origins.commons small portrait' => array( + '1x' => 'commons-full-small', + '1.5x' => 'commons-full-small-1_5x', + ), + 'breakpoints.theme.commons_origins.commons small landscape' => array( + '1x' => 'commons-full-small', + '1.5x' => 'commons-full-small-1_5x', + ), + 'breakpoints.theme.commons_origins.commons medium portrait' => array( + '1x' => 'commons-full-medium', + '1.5x' => 'commons-full-medium-1_5x', + ), + 'breakpoints.theme.commons_origins.commons medium landscape' => array( + '1x' => 'commons-full-medium', + '1.5x' => 'commons-full-medium-1_5x', + ), + 'breakpoints.theme.commons_origins.commons large' => array( + '1x' => 'commons-full-large', + '1.5x' => 'commons-full-large-1_5x', + ), + ); + $export['commons_full'] = $picture_mapping; + + $picture_mapping = new stdClass(); + $picture_mapping->disabled = FALSE; /* Edit this to true to make a default picture_mapping disabled initially */ + $picture_mapping->api_version = 1; + $picture_mapping->machine_name = 'commons_teaser'; + $picture_mapping->breakpoint_group = 'commons_teaser'; + $picture_mapping->mapping = array( + 'breakpoints.theme.commons_origins.commons small portrait' => array( + '1x' => 'commons-teaser-small', + '1.5x' => 'commons-teaser-small-1_5x', + ), + 'breakpoints.theme.commons_origins.commons small landscape' => array( + '1x' => 'commons-teaser-small', + '1.5x' => 'commons-teaser-small-1_5x', + ), + 'breakpoints.theme.commons_origins.commons medium portrait' => array( + '1x' => 'commons-teaser-medium', + '1.5x' => 'commons-teaser-medium-1_5', + ), + 'breakpoints.theme.commons_origins.commons medium landscape' => array( + '1x' => 'commons-teaser-medium', + '1.5x' => 'commons-teaser-medium-1_5', + ), + 'breakpoints.theme.commons_origins.commons large' => array( + '1x' => 'commons-teaser-large', + '1.5x' => 'commons-teaser-large-1_5x', + ), + ); + $export['commons_teaser'] = $picture_mapping; + + return $export; +} diff --git a/modules/commons/commons_images/commons_images.features.inc b/modules/commons/commons_images/commons_images.features.inc new file mode 100644 index 0000000..48d70d2 --- /dev/null +++ b/modules/commons/commons_images/commons_images.features.inc @@ -0,0 +1,455 @@ + "1"); + } + if ($module == "breakpoints" && $api == "default_breakpoints") { + return array("version" => "1"); + } + if ($module == "picture" && $api == "default_picture_mapping") { + return array("version" => "1"); + } +} + +/** + * Implements hook_image_default_styles(). + */ +function commons_images_image_default_styles() { + $styles = array(); + + // Exported image style: commons-default-large. + $styles['commons-default-large'] = array( + 'name' => 'commons-default-large', + 'label' => 'Commons default large', + 'effects' => array( + 18 => array( + 'label' => 'Scale', + 'help' => 'Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.', + 'effect callback' => 'image_scale_effect', + 'dimensions callback' => 'image_scale_dimensions', + 'form callback' => 'image_scale_form', + 'summary theme' => 'image_scale_summary', + 'module' => 'image', + 'name' => 'image_scale', + 'data' => array( + 'width' => 536, + 'height' => 600, + 'upscale' => 0, + ), + 'weight' => 1, + ), + ), + ); + + // Exported image style: commons-default-large-1_5x. + $styles['commons-default-large-1_5x'] = array( + 'name' => 'commons-default-large-1_5x', + 'label' => 'Commons default large 1.5x', + 'effects' => array( + 19 => array( + 'label' => 'Scale', + 'help' => 'Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.', + 'effect callback' => 'image_scale_effect', + 'dimensions callback' => 'image_scale_dimensions', + 'form callback' => 'image_scale_form', + 'summary theme' => 'image_scale_summary', + 'module' => 'image', + 'name' => 'image_scale', + 'data' => array( + 'width' => 804, + 'height' => 900, + 'upscale' => 0, + ), + 'weight' => 1, + ), + ), + ); + + // Exported image style: commons-default-medium. + $styles['commons-default-medium'] = array( + 'name' => 'commons-default-medium', + 'label' => 'Commons default medium', + 'effects' => array( + 18 => array( + 'label' => 'Scale', + 'help' => 'Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.', + 'effect callback' => 'image_scale_effect', + 'dimensions callback' => 'image_scale_dimensions', + 'form callback' => 'image_scale_form', + 'summary theme' => 'image_scale_summary', + 'module' => 'image', + 'name' => 'image_scale', + 'data' => array( + 'width' => 536, + 'height' => 600, + 'upscale' => 0, + ), + 'weight' => 1, + ), + ), + ); + + // Exported image style: commons-default-medium-1_5x. + $styles['commons-default-medium-1_5x'] = array( + 'name' => 'commons-default-medium-1_5x', + 'label' => 'Commons default medium 1.5x', + 'effects' => array( + 19 => array( + 'label' => 'Scale', + 'help' => 'Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.', + 'effect callback' => 'image_scale_effect', + 'dimensions callback' => 'image_scale_dimensions', + 'form callback' => 'image_scale_form', + 'summary theme' => 'image_scale_summary', + 'module' => 'image', + 'name' => 'image_scale', + 'data' => array( + 'width' => 804, + 'height' => 900, + 'upscale' => 0, + ), + 'weight' => 1, + ), + ), + ); + + // Exported image style: commons-default-small. + $styles['commons-default-small'] = array( + 'name' => 'commons-default-small', + 'label' => 'Commons default small', + 'effects' => array( + 20 => array( + 'label' => 'Scale', + 'help' => 'Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.', + 'effect callback' => 'image_scale_effect', + 'dimensions callback' => 'image_scale_dimensions', + 'form callback' => 'image_scale_form', + 'summary theme' => 'image_scale_summary', + 'module' => 'image', + 'name' => 'image_scale', + 'data' => array( + 'width' => 456, + 'height' => 500, + 'upscale' => 0, + ), + 'weight' => 1, + ), + ), + ); + + // Exported image style: commons-default-small-1_5x. + $styles['commons-default-small-1_5x'] = array( + 'name' => 'commons-default-small-1_5x', + 'label' => 'Commons default small 1.5x', + 'effects' => array( + 21 => array( + 'label' => 'Scale', + 'help' => 'Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.', + 'effect callback' => 'image_scale_effect', + 'dimensions callback' => 'image_scale_dimensions', + 'form callback' => 'image_scale_form', + 'summary theme' => 'image_scale_summary', + 'module' => 'image', + 'name' => 'image_scale', + 'data' => array( + 'width' => 684, + 'height' => 750, + 'upscale' => 0, + ), + 'weight' => 1, + ), + ), + ); + + // Exported image style: commons-full-large. + $styles['commons-full-large'] = array( + 'name' => 'commons-full-large', + 'label' => 'Commons full large', + 'effects' => array( + 22 => array( + 'label' => 'Scale', + 'help' => 'Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.', + 'effect callback' => 'image_scale_effect', + 'dimensions callback' => 'image_scale_dimensions', + 'form callback' => 'image_scale_form', + 'summary theme' => 'image_scale_summary', + 'module' => 'image', + 'name' => 'image_scale', + 'data' => array( + 'width' => 916, + 'height' => '', + 'upscale' => 0, + ), + 'weight' => 1, + ), + ), + ); + + // Exported image style: commons-full-large-1_5x. + $styles['commons-full-large-1_5x'] = array( + 'name' => 'commons-full-large-1_5x', + 'label' => 'Commons full large 1.5x', + 'effects' => array( + 23 => array( + 'label' => 'Scale', + 'help' => 'Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.', + 'effect callback' => 'image_scale_effect', + 'dimensions callback' => 'image_scale_dimensions', + 'form callback' => 'image_scale_form', + 'summary theme' => 'image_scale_summary', + 'module' => 'image', + 'name' => 'image_scale', + 'data' => array( + 'width' => 1374, + 'height' => '', + 'upscale' => 0, + ), + 'weight' => 1, + ), + ), + ); + + // Exported image style: commons-full-medium. + $styles['commons-full-medium'] = array( + 'name' => 'commons-full-medium', + 'label' => 'Commons full medium', + 'effects' => array( + 24 => array( + 'label' => 'Scale', + 'help' => 'Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.', + 'effect callback' => 'image_scale_effect', + 'dimensions callback' => 'image_scale_dimensions', + 'form callback' => 'image_scale_form', + 'summary theme' => 'image_scale_summary', + 'module' => 'image', + 'name' => 'image_scale', + 'data' => array( + 'width' => 768, + 'height' => '', + 'upscale' => 0, + ), + 'weight' => 1, + ), + ), + ); + + // Exported image style: commons-full-medium-1_5. + $styles['commons-full-medium-1_5'] = array( + 'name' => 'commons-full-medium-1_5', + 'label' => 'Commons full medium 1.5', + 'effects' => array( + 25 => array( + 'label' => 'Scale', + 'help' => 'Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.', + 'effect callback' => 'image_scale_effect', + 'dimensions callback' => 'image_scale_dimensions', + 'form callback' => 'image_scale_form', + 'summary theme' => 'image_scale_summary', + 'module' => 'image', + 'name' => 'image_scale', + 'data' => array( + 'width' => 1152, + 'height' => '', + 'upscale' => 0, + ), + 'weight' => 1, + ), + ), + ); + + // Exported image style: commons-full-small. + $styles['commons-full-small'] = array( + 'name' => 'commons-full-small', + 'label' => 'Commons full small', + 'effects' => array( + 20 => array( + 'label' => 'Scale', + 'help' => 'Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.', + 'effect callback' => 'image_scale_effect', + 'dimensions callback' => 'image_scale_dimensions', + 'form callback' => 'image_scale_form', + 'summary theme' => 'image_scale_summary', + 'module' => 'image', + 'name' => 'image_scale', + 'data' => array( + 'width' => 456, + 'height' => 500, + 'upscale' => 0, + ), + 'weight' => 1, + ), + ), + ); + + // Exported image style: commons-full-small-1_5x. + $styles['commons-full-small-1_5x'] = array( + 'name' => 'commons-full-small-1_5x', + 'label' => 'Commons full small 1.5x', + 'effects' => array( + 21 => array( + 'label' => 'Scale', + 'help' => 'Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.', + 'effect callback' => 'image_scale_effect', + 'dimensions callback' => 'image_scale_dimensions', + 'form callback' => 'image_scale_form', + 'summary theme' => 'image_scale_summary', + 'module' => 'image', + 'name' => 'image_scale', + 'data' => array( + 'width' => 684, + 'height' => 750, + 'upscale' => 0, + ), + 'weight' => 1, + ), + ), + ); + + // Exported image style: commons-teaser-large. + $styles['commons-teaser-large'] = array( + 'name' => 'commons-teaser-large', + 'label' => 'Commons teaser large', + 'effects' => array( + 16 => array( + 'label' => 'Scale and Smart Crop', + 'help' => 'Similar to "Scale And Crop", but preserves the portion of the image with the most entropy.', + 'effect callback' => 'smartcrop_scale_effect', + 'form callback' => 'image_scale_form', + 'summary theme' => 'image_scale_summary', + 'module' => 'smartcrop', + 'name' => 'smartcrop_scale_and_crop', + 'data' => array( + 'width' => 124, + 'height' => 124, + 'upscale' => 1, + ), + 'weight' => 1, + ), + ), + ); + + // Exported image style: commons-teaser-large-1_5x. + $styles['commons-teaser-large-1_5x'] = array( + 'name' => 'commons-teaser-large-1_5x', + 'label' => 'Commons teaser large 1.5x', + 'effects' => array( + 17 => array( + 'label' => 'Scale and Smart Crop', + 'help' => 'Similar to "Scale And Crop", but preserves the portion of the image with the most entropy.', + 'effect callback' => 'smartcrop_scale_effect', + 'form callback' => 'image_scale_form', + 'summary theme' => 'image_scale_summary', + 'module' => 'smartcrop', + 'name' => 'smartcrop_scale_and_crop', + 'data' => array( + 'width' => 186, + 'height' => 186, + 'upscale' => 1, + ), + 'weight' => 1, + ), + ), + ); + + // Exported image style: commons-teaser-medium. + $styles['commons-teaser-medium'] = array( + 'name' => 'commons-teaser-medium', + 'label' => 'Commons teaser medium', + 'effects' => array( + 14 => array( + 'label' => 'Scale and Smart Crop', + 'help' => 'Similar to "Scale And Crop", but preserves the portion of the image with the most entropy.', + 'effect callback' => 'smartcrop_scale_effect', + 'form callback' => 'image_scale_form', + 'summary theme' => 'image_scale_summary', + 'module' => 'smartcrop', + 'name' => 'smartcrop_scale_and_crop', + 'data' => array( + 'width' => 72, + 'height' => 72, + 'upscale' => 1, + ), + 'weight' => 1, + ), + ), + ); + + // Exported image style: commons-teaser-medium-1_5x. + $styles['commons-teaser-medium-1_5x'] = array( + 'name' => 'commons-teaser-medium-1_5x', + 'label' => 'Commons teaser medium 1.5x', + 'effects' => array( + 15 => array( + 'label' => 'Scale and Smart Crop', + 'help' => 'Similar to "Scale And Crop", but preserves the portion of the image with the most entropy.', + 'effect callback' => 'smartcrop_scale_effect', + 'form callback' => 'image_scale_form', + 'summary theme' => 'image_scale_summary', + 'module' => 'smartcrop', + 'name' => 'smartcrop_scale_and_crop', + 'data' => array( + 'width' => 108, + 'height' => 108, + 'upscale' => 1, + ), + 'weight' => 1, + ), + ), + ); + + // Exported image style: commons-teaser-small. + $styles['commons-teaser-small'] = array( + 'name' => 'commons-teaser-small', + 'label' => 'Commons teaser small', + 'effects' => array( + 12 => array( + 'label' => 'Scale and Smart Crop', + 'help' => 'Similar to "Scale And Crop", but preserves the portion of the image with the most entropy.', + 'effect callback' => 'smartcrop_scale_effect', + 'form callback' => 'image_scale_form', + 'summary theme' => 'image_scale_summary', + 'module' => 'smartcrop', + 'name' => 'smartcrop_scale_and_crop', + 'data' => array( + 'width' => 54, + 'height' => 54, + 'upscale' => 1, + ), + 'weight' => 1, + ), + ), + ); + + // Exported image style: commons-teaser-small-1_5x. + $styles['commons-teaser-small-1_5x'] = array( + 'name' => 'commons-teaser-small-1_5x', + 'label' => 'Commons teaser small 1.5x', + 'effects' => array( + 13 => array( + 'label' => 'Scale and Smart Crop', + 'help' => 'Similar to "Scale And Crop", but preserves the portion of the image with the most entropy.', + 'effect callback' => 'smartcrop_scale_effect', + 'form callback' => 'image_scale_form', + 'summary theme' => 'image_scale_summary', + 'module' => 'smartcrop', + 'name' => 'smartcrop_scale_and_crop', + 'data' => array( + 'width' => 81, + 'height' => 81, + 'upscale' => 1, + ), + 'weight' => 1, + ), + ), + ); + + return $styles; +} diff --git a/modules/commons/commons_images/commons_images.info b/modules/commons/commons_images/commons_images.info new file mode 100644 index 0000000..6afb9f2 --- /dev/null +++ b/modules/commons/commons_images/commons_images.info @@ -0,0 +1,45 @@ +name = Commons Images +description = Image styles used in the Commons distribution +core = 7.x +package = Commons - Building blocks +project = commons_images +dependencies[] = breakpoints +dependencies[] = ctools +dependencies[] = file_entity +dependencies[] = image +dependencies[] = picture +dependencies[] = smartcrop +features[breakpoint_group][] = commons_default +features[breakpoint_group][] = commons_full +features[breakpoint_group][] = commons_origins +features[breakpoint_group][] = commons_teaser +features[breakpoints][] = breakpoints.theme.commons_origins.commons large +features[breakpoints][] = breakpoints.theme.commons_origins.commons medium landscape +features[breakpoints][] = breakpoints.theme.commons_origins.commons medium portrait +features[breakpoints][] = breakpoints.theme.commons_origins.commons small landscape +features[breakpoints][] = breakpoints.theme.commons_origins.commons small portrait +features[ctools][] = breakpoints:default_breakpoint_group:1 +features[ctools][] = breakpoints:default_breakpoints:1 +features[ctools][] = picture:default_picture_mapping:1 +features[features_api][] = api:2 +features[image][] = commons-default-large +features[image][] = commons-default-large-1_5x +features[image][] = commons-default-medium +features[image][] = commons-default-medium-1_5x +features[image][] = commons-default-small +features[image][] = commons-default-small-1_5x +features[image][] = commons-full-large +features[image][] = commons-full-large-1_5x +features[image][] = commons-full-medium +features[image][] = commons-full-medium-1_5 +features[image][] = commons-full-small +features[image][] = commons-full-small-1_5x +features[image][] = commons-teaser-large +features[image][] = commons-teaser-large-1_5x +features[image][] = commons-teaser-medium +features[image][] = commons-teaser-medium-1_5x +features[image][] = commons-teaser-small +features[image][] = commons-teaser-small-1_5x +features[picture_mapping][] = commons_default +features[picture_mapping][] = commons_full +features[picture_mapping][] = commons_teaser diff --git a/modules/commons/commons_images/commons_images.module b/modules/commons/commons_images/commons_images.module new file mode 100644 index 0000000..f3ec52e --- /dev/null +++ b/modules/commons/commons_images/commons_images.module @@ -0,0 +1,76 @@ +name, 'image__default__') !== false) { + $display = clone $file_display; + $name = str_replace('image__default__', 'image__full__', $display->name); + $display->name = $name; + $file_displays[$name] = $display; + } + } + + // Default images should be displayed using the 'default' picture group. + if (isset($file_displays['image__default__file_field_image'])) { + $file_displays['image__default__file_field_image']->status = FALSE; + } + + $file_display = new stdClass(); + $file_display->api_version = 1; + $file_display->name = 'image__default__file_field_picture'; + $file_display->weight = 1; + $file_display->status = TRUE; + $file_display->settings = array( + 'picture_group' => 'commons_default', + 'fallback_image_style' => 'commons-default-small', + 'image_link' => 'content', + 'colorbox' => 'commons_default', + ); + $file_displays['image__default__file_field_picture'] = $file_display; + + // Full images should be displayed using the 'full' picture group. + if (isset($file_displays['image__full__file_field_image'])) { + $file_displays['image__full__file_field_image']->status = FALSE; + } + + $file_display = new stdClass(); + $file_display->api_version = 1; + $file_display->name = 'image__full__file_field_picture'; + $file_display->weight = 1; + $file_display->status = TRUE; + $file_display->settings = array( + 'picture_group' => 'commons_full', + 'fallback_image_style' => 'commons-full-small', + 'image_link' => '', + 'colorbox' => 'commons_full', + ); + $file_displays['image__full__file_field_picture'] = $file_display; + + // Teaser images should be displayed using the 'teaser' picture group. + if (isset($file_displays['image__teaser__file_field_image'])) { + $file_displays['image__teaser__file_field_image']->status = FALSE; + } + + $file_display = new stdClass(); + $file_display->api_version = 1; + $file_display->name = 'image__teaser__file_field_picture'; + $file_display->weight = -1; + $file_display->status = TRUE; + $file_display->settings = array( + 'picture_group' => 'commons_teaser', + 'fallback_image_style' => 'commons-teaser-small', + 'image_link' => '', + 'colorbox' => 'commons_teaser', + ); + $file_displays['image__teaser__file_field_picture'] = $file_display; +} diff --git a/modules/commons/commons_kissmetrics/commons_kissmetrics.info b/modules/commons/commons_kissmetrics/commons_kissmetrics.info new file mode 100644 index 0000000..db4f71f --- /dev/null +++ b/modules/commons/commons_kissmetrics/commons_kissmetrics.info @@ -0,0 +1,31 @@ +name = Commons KISSmetrics +description = Integrates with KISSmetrics to tracks Commons-specific user metrics and actions. +core = 7.x +package = Commons - Building blocks +dependencies[] = comment +dependencies[] = entity +dependencies[] = flag +dependencies[] = kissmetrics +dependencies[] = og +dependencies[] = privatemsg_rules +dependencies[] = rules +dependencies[] = voting_rules +features[features_api][] = api:2 +features[rules_config][] = rules_commons_kissmetrics_collect_referenced_groups +features[rules_config][] = rules_commons_kissmetrics_user_adds_a_trusted_contact +features[rules_config][] = rules_commons_kissmetrics_user_approves_a_trusted_contact +features[rules_config][] = rules_commons_kissmetrics_user_creates_content +features[rules_config][] = rules_commons_kissmetrics_user_edits_profile +features[rules_config][] = rules_commons_kissmetrics_user_edits_wiki +features[rules_config][] = rules_commons_kissmetrics_user_flags_content_as_inappropriate +features[rules_config][] = rules_commons_kissmetrics_user_follows_content +features[rules_config][] = rules_commons_kissmetrics_user_follows_group +features[rules_config][] = rules_commons_kissmetrics_user_follows_topic +features[rules_config][] = rules_commons_kissmetrics_user_follows_user +features[rules_config][] = rules_commons_kissmetrics_user_likes_content +features[rules_config][] = rules_commons_kissmetrics_user_logs_in +features[rules_config][] = rules_commons_kissmetrics_user_logs_out +features[rules_config][] = rules_commons_kissmetrics_user_posts_comment +features[rules_config][] = rules_commons_kissmetrics_user_registers +features[rules_config][] = rules_commons_kissmetrics_user_replies_to_private_message_thread +features[rules_config][] = rules_commons_kissmetrics_user_starts_new_private_message_thread diff --git a/modules/commons/commons_kissmetrics/commons_kissmetrics.module b/modules/commons/commons_kissmetrics/commons_kissmetrics.module new file mode 100644 index 0000000..44788b0 --- /dev/null +++ b/modules/commons/commons_kissmetrics/commons_kissmetrics.module @@ -0,0 +1,5 @@ + 'Button label', + * 'href' => 'Link href', + * 'value' => 20, + * 'votes' => 6, + * ), + * ) + * - $results: Array with voting results + * array( + * 'rating' => 12, // Average rating + * 'options' => array( // Votes per option. Only available when value_type == 'options' + * 1 => 234, + * 2 => 34, + * ), + * 'count' => 23, // Number of votes + * 'up' => 2, // Number of up votes. Only available for thumbs up / down. + * 'down' => 3, // Number of down votes. Only available for thumbs up / down. + * 'up_percent' => 40, // Percentage of up votes. Only available for thumbs up / down. + * 'down_percent' => 60, // Percentage of down votes. Only available for thumbs up / down. + * 'user_vote' => 80, // Value for user vote. Only available when user has voted. + * ) + * - $mode: Display mode. + * - $just_voted: Indicator whether the user has just voted (boolean). + * - $content_type: "node" or "comment". + * - $content_id: Node or comment id. + * - $buttons: Array with themed buttons (built in preprocess function). + * - $info: String with user readable information (built in preprocess function). + */ +?> + +' . $results['count'] . ''; ?> diff --git a/modules/commons/commons_like/commons_like.features.field_instance.inc b/modules/commons/commons_like/commons_like.features.field_instance.inc new file mode 100644 index 0000000..1ff8c39 --- /dev/null +++ b/modules/commons/commons_like/commons_like.features.field_instance.inc @@ -0,0 +1,63 @@ + 'commons_like_user_likes_node', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_target_nodes', + 'label' => 'Target nodes', + 'required' => FALSE, + 'settings' => array( + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 2, + ), + ); + + // Translatables + // Included for use with string extractors like potx. + t('Target nodes'); + + return $field_instances; +} diff --git a/modules/commons/commons_like/commons_like.features.inc b/modules/commons/commons_like/commons_like.features.inc new file mode 100644 index 0000000..16f1761 --- /dev/null +++ b/modules/commons/commons_like/commons_like.features.inc @@ -0,0 +1,46 @@ + "1"); + } +} + +/** + * Implements hook_default_message_type(). + */ +function commons_like_default_message_type() { + $items = array(); + $items['commons_like_user_likes_node'] = entity_import('message_type', '{ + "name" : "commons_like_user_likes_node", + "description" : "Commons like: User likes a node", + "argument_keys" : [], + "argument" : [], + "category" : "message_type", + "data" : { "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" } }, + "language" : "", + "arguments" : null, + "message_text" : { "und" : [ + { + "value" : "[message:user:picture]", + "format" : "full_html", + "safe_value" : "[message:user:picture]" + }, + { + "value" : "\\u003Ca href=\\u0022[message:user:url:absolute]\\u0022\\u003E[message:user:name]\\u003C\\/a\\u003E liked the [message:field-target-nodes:0:type] \\u003Ca href=\\u0022[message:field-target-nodes:0:url]\\u0022\\u003E[message:field-target-nodes:0:title_field]\\u003C\\/a\\u003E", + "format" : "full_html", + "safe_value" : "\\u003Ca href=\\u0022[message:user:url:absolute]\\u0022\\u003E[message:user:name]\\u003C\\/a\\u003E liked the [message:field-target-nodes:0:type] \\u003Ca href=\\u0022[message:field-target-nodes:0:url]\\u0022\\u003E[message:field-target-nodes:0:title_field]\\u003C\\/a\\u003E" + } + ] + }, + "rdf_mapping" : [] + }'); + return $items; +} diff --git a/modules/commons/commons_like/commons_like.info b/modules/commons/commons_like/commons_like.info new file mode 100644 index 0000000..a40f432 --- /dev/null +++ b/modules/commons/commons_like/commons_like.info @@ -0,0 +1,15 @@ +name = Commons Like +description = Community members can indicate that they like content and comments. +core = 7.x +package = Commons - Building blocks +dependencies[] = entityreference +dependencies[] = features +dependencies[] = message +dependencies[] = rate +dependencies[] = strongarm +dependencies[] = votingapi +features[ctools][] = strongarm:strongarm:1 +features[features_api][] = api:2 +features[field_instance][] = message-commons_like_user_likes_node-field_target_nodes +features[message_type][] = commons_like_user_likes_node +features[variable][] = rate_widgets \ No newline at end of file diff --git a/modules/commons/commons_like/commons_like.install b/modules/commons/commons_like/commons_like.install new file mode 100644 index 0000000..2bf9f50 --- /dev/null +++ b/modules/commons/commons_like/commons_like.install @@ -0,0 +1,12 @@ + array('variable'), + ); + features_revert($revert); + return array(); +} diff --git a/modules/commons/commons_like/commons_like.module b/modules/commons/commons_like/commons_like.module new file mode 100644 index 0000000..49f6f2e --- /dev/null +++ b/modules/commons/commons_like/commons_like.module @@ -0,0 +1,134 @@ +value)) { + foreach($items['rate_widgets']->value as $key => $widget) { + if ($widget->name == 'commons_like') { + $commons_entity_integrations = commons_entity_integration_info(); + if (!empty($commons_entity_integrations['node'])) { + foreach ($commons_entity_integrations['node'] as $bundle => $options) { + if (!isset($options['exclude_rate']) || $options['exclude_rate'] != TRUE) { + $items['rate_widgets']->value[$key]->node_types[] = $bundle; + } + if (!isset($options['exclude_rate_comments']) || $options['exclude_rate_comments'] != TRUE) { + $items['rate_widgets']->value[$key]->comment_types[] = $bundle; + } + } + } + } + } + } +} + +/** + * Implements hook_votingapi_insert(). + * Create a message when a user likes a node. + */ +function commons_like_votingapi_insert($votes) { + foreach ($votes as $vote) { + if ($vote['tag'] == 'commons_like' && $vote['entity_type'] == 'node') { + $node = node_load($vote['entity_id']); + $message = message_create('commons_like_user_likes_node', array('uid' => $vote['uid'], 'timestamp' => $vote['timestamp'])); + $wrapper = entity_metadata_wrapper('message', $message); + $wrapper->field_target_nodes[] = $node; + $wrapper->save(); + } + } +} + +/** + * Implements hook_votingapi_delete(). + * Delete a message when a user unlikes a node. + */ +function commons_like_votingapi_delete($votes) { + foreach ($votes as $vote) { + if (isset($vote['tag']) && $vote['tag'] == 'commons_like' && $vote['entity_type'] == 'node') { + if (module_exists('commons_activity_streams') && $mids = commons_like_existing_node_like_messages($vote['uid'], array($vote['entity_id']))) { + message_delete_multiple($mids); + } + } + } +} + +/** + * Indicate whether there is an existing message about a given user + * liking a specific node. + */ +function commons_like_existing_node_like_messages($acting_uid, $target_nids) { + $query = new EntityFieldQuery(); + $query->entityCondition('entity_type', 'message', '=') + ->propertyCondition('uid', $acting_uid) + ->propertyCondition('type', 'commons_like_user_likes_node', '=') + ->fieldCondition('field_target_nodes', 'target_id', $target_nids, 'IN') + ->execute(); + + if (!empty($query->ordered_results)) { + $mids = array(); + foreach($query->ordered_results as $result) { + $mids[] = $result->entity_id; + } + return $mids; + } + return FALSE; +} + +/** + * Implements hook_theme(). + */ +function commons_like_theme() { + return array( + 'rate_template_commons_like' => array( + 'variables' => array('links' => NULL, 'results' => NULL, 'mode' => NULL, 'just_voted' => FALSE, 'content_type' => NULL, 'content_id' => NULL, 'display_options' => NULL), + 'template' => 'commons-like', + ), + ); +} + +/** + * Implements hook_rate_templates(). + */ +function commons_like_rate_templates() { + $templates = array(); + + $templates['commons_like'] = new stdClass(); + $templates['commons_like']->value_type = 'points'; + $templates['commons_like']->options = array( + array(1, 'like'), + ); + $templates['commons_like']->theme = 'rate_template_commons_like'; + $templates['commons_like']->css = drupal_get_path('module', 'commons_like') . '/commons-like.css'; + $templates['commons_like']->customizable = FALSE; + $templates['commons_like']->translate = TRUE; + $templates['commons_like']->use_source_translation = TRUE; + $templates['commons_like']->template_title = t('Commons like'); + + return $templates; +} + +/** + * Preprocess function for the commons_like template. + */ +function commons_like_preprocess_rate_template_commons_like(&$variables) { + $variables['like_button'] = theme('rate_button', array('text' => $variables['links'][0]['text'], 'href' => $variables['links'][0]['href'], 'class' => 'rate-commons-like-btn')); +} diff --git a/modules/commons/commons_like/commons_like.strongarm.inc b/modules/commons/commons_like/commons_like.strongarm.inc new file mode 100644 index 0000000..7a98e8b --- /dev/null +++ b/modules/commons/commons_like/commons_like.strongarm.inc @@ -0,0 +1,60 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'rate_widgets'; + $strongarm->value = array( + 1 => (object) array( + 'name' => 'commons_like', + 'tag' => 'commons_like', + 'title' => 'Like', + 'node_types' => array( + ), + 'comment_types' => array( + ), + 'options' => array( + 0 => array( + 0 => 1, + 1 => 'like', + ), + ), + 'template' => 'commons_like', + 'node_display' => '2', + 'teaser_display' => FALSE, + 'comment_display' => '2', + 'node_display_mode' => '1', + 'teaser_display_mode' => '1', + 'comment_display_mode' => '1', + 'roles' => array( + 2 => '2', + 1 => 0, + ), + 'allow_voting_by_author' => 0, + 'noperm_behaviour' => '3', + 'displayed' => '2', + 'displayed_just_voted' => '1', + 'description' => '', + 'description_in_compact' => TRUE, + 'delete_vote_on_second_click' => '1', + 'value_type' => 'points', + 'theme' => 'rate_template_commons_like', + 'css' => 'profiles/commons/modules/contrib/commons_like/commons-like.css', + 'translate' => TRUE, + 'use_source_translation' => TRUE, + ), + ); + $export['rate_widgets'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_like/config.rb b/modules/commons/commons_like/config.rb new file mode 100644 index 0000000..1983ae6 --- /dev/null +++ b/modules/commons/commons_like/config.rb @@ -0,0 +1,25 @@ +# Require any additional compass plugins here. + +# Set this to the root of your project when deployed: +http_path = "/" +css_dir = "/" +sass_dir = "/" +images_dir = "images" + + +output_style = :expanded +environment = :production + +# To enable relative paths to assets via compass helper functions. Uncomment: +relative_assets = true + +# To disable debugging comments that display the original location of your selectors. Uncomment: +# line_comments = false +color_output = false + + +# If you prefer the indented syntax, you might want to regenerate this +# project again passing --syntax sass, or you can uncomment this: +# preferred_syntax = :sass +# and then run: +# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass diff --git a/modules/commons/commons_like/images/like.png b/modules/commons/commons_like/images/like.png new file mode 100644 index 0000000..4204463 Binary files /dev/null and b/modules/commons/commons_like/images/like.png differ diff --git a/modules/commons/commons_location/commons_location.features.field_base.inc b/modules/commons/commons_location/commons_location.features.field_base.inc new file mode 100644 index 0000000..565a109 --- /dev/null +++ b/modules/commons/commons_location/commons_location.features.field_base.inc @@ -0,0 +1,30 @@ + 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_address', + 'foreign keys' => array(), + 'indexes' => array(), + 'locked' => 0, + 'module' => 'addressfield', + 'settings' => array(), + 'translatable' => 0, + 'type' => 'addressfield', + ); + + return $field_bases; +} diff --git a/modules/commons/commons_location/commons_location.info b/modules/commons/commons_location/commons_location.info new file mode 100644 index 0000000..c9a9974 --- /dev/null +++ b/modules/commons/commons_location/commons_location.info @@ -0,0 +1,9 @@ +name = Commons Location +description = Provide a field definition for locations. +core = 7.x +package = Commons - Building Blocks +dependencies[] = addressfield +dependencies[] = features +dependencies[] = field_sql_storage +features[features_api][] = api:2 +features[field_base][] = field_address diff --git a/modules/commons/commons_location/commons_location.module b/modules/commons/commons_location/commons_location.module new file mode 100644 index 0000000..5476b39 --- /dev/null +++ b/modules/commons/commons_location/commons_location.module @@ -0,0 +1,5 @@ + 1, + 'cardinality' => -1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_media', + 'foreign keys' => array( + 'fid' => array( + 'columns' => array( + 'fid' => 'fid', + ), + 'table' => 'file_managed', + ), + ), + 'indexes' => array( + 'fid' => array( + 0 => 'fid', + ), + ), + 'locked' => 0, + 'module' => 'file', + 'settings' => array( + 'display_default' => 0, + 'display_field' => 0, + 'uri_scheme' => 'public', + ), + 'translatable' => 0, + 'type' => 'file', + ); + + return $field_bases; +} diff --git a/modules/commons/commons_media/commons_media.features.field_instance.inc b/modules/commons/commons_media/commons_media.features.field_instance.inc new file mode 100644 index 0000000..91e86d0 --- /dev/null +++ b/modules/commons/commons_media/commons_media.features.field_instance.inc @@ -0,0 +1,98 @@ + $bundles) { + foreach ($bundles as $bundle => $integrations) { + if (!empty($integrations['media'])) { + commons_media_field_definition($field_instances, $entity_type, $bundle); + } + } + } + } + + return $field_instances; +} + +function commons_media_field_definition(&$field_instances, $entity_type, $bundle) { + // Exported field_instance: 'entity-bundle-field_media' + $field_instances["$entity_type-$bundle-field_media"] = array( + 'bundle' => $bundle, + 'deleted' => 0, + 'description' => 'Attach an image or video.', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'module' => 'file_entity', + 'settings' => array( + 'file_view_mode' => 'default', + ), + 'type' => 'file_rendered', + 'weight' => 0, + ), + 'teaser' => array( + 'label' => 'hidden', + 'module' => 'file_entity', + 'settings' => array( + 'file_view_mode' => 'teaser', + ), + 'type' => 'file_rendered', + 'weight' => 0, + ), + ), + 'display_in_partial_form' => 1, + 'entity_type' => 'node', + 'field_name' => 'field_media', + 'label' => 'Media', + 'required' => 0, + 'settings' => array( + 'description_field' => 0, + 'file_directory' => 'media', + 'file_extensions' => 'jpg jpeg gif png oembed mov mp4 m4v mpeg avi ogv webp webm', + 'max_filesize' => '', + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'media', + 'settings' => array( + 'allowed_schemes' => array( + 'oembed' => 'oembed', + 'public' => 'public', + ), + 'allowed_types' => array( + 'audio' => 0, + 'document' => 0, + 'image' => 'image', + 'video' => 'video', + ), + 'browser_plugins' => array( + 'media_default--media_browser_1' => 0, + 'media_default--media_browser_my_files' => 0, + 'media_internet' => 'media_internet', + 'upload' => 'upload', + ), + 'progress_indicator' => 'throbber', + ), + 'type' => 'media_generic', + 'weight' => 2, + ), + ); + + // Translatables + // Included for use with string extractors like potx. + t('Attach an image or video.'); + t('Media'); + + return $field_instances; +} diff --git a/modules/commons/commons_media/commons_media.features.inc b/modules/commons/commons_media/commons_media.features.inc new file mode 100644 index 0000000..b77b46f --- /dev/null +++ b/modules/commons/commons_media/commons_media.features.inc @@ -0,0 +1,14 @@ + "1"); + } +} diff --git a/modules/commons/commons_media/commons_media.features.user_permission.inc b/modules/commons/commons_media/commons_media.features.user_permission.inc new file mode 100644 index 0000000..e7a5c77 --- /dev/null +++ b/modules/commons/commons_media/commons_media.features.user_permission.inc @@ -0,0 +1,64 @@ + 'access media browser', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'media', + ); + + // Exported permission: 'add media from remote sources'. + $permissions['add media from remote sources'] = array( + 'name' => 'add media from remote sources', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'media_internet', + ); + + // Exported permission: 'create files'. + $permissions['create files'] = array( + 'name' => 'create files', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'file_entity', + ); + + // Exported permission: 'delete own image files'. + $permissions['delete own image files'] = array( + 'name' => 'delete own image files', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'file_entity', + ); + + // Exported permission: 'delete own video files'. + $permissions['delete own video files'] = array( + 'name' => 'delete own video files', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'file_entity', + ); + + return $permissions; +} diff --git a/modules/commons/commons_media/commons_media.info b/modules/commons/commons_media/commons_media.info new file mode 100644 index 0000000..276462e --- /dev/null +++ b/modules/commons/commons_media/commons_media.info @@ -0,0 +1,24 @@ +name = Commons Media +description = Provides media handling capabilities. +core = 7.x +package = Commons - Building blocks +dependencies[] = ctools +dependencies[] = features +dependencies[] = file +dependencies[] = file_entity +dependencies[] = media +dependencies[] = media_internet +dependencies[] = media_oembed +dependencies[] = strongarm +features[ctools][] = strongarm:strongarm:1 +features[features_api][] = api:2 +features[field_base][] = field_media +features[user_permission][] = access media browser +features[user_permission][] = add media from remote sources +features[user_permission][] = create files +features[user_permission][] = delete own image files +features[user_permission][] = delete own video files +features[variable][] = file_entity_file_upload_wizard_skip_fields +features[variable][] = file_entity_file_upload_wizard_skip_file_type +features[variable][] = file_entity_file_upload_wizard_skip_scheme +features[variable][] = media_dialog_theme diff --git a/modules/commons/commons_media/commons_media.install b/modules/commons/commons_media/commons_media.install new file mode 100644 index 0000000..e813ba7 --- /dev/null +++ b/modules/commons/commons_media/commons_media.install @@ -0,0 +1,28 @@ + array('user_permission', 'variable'), + ); + features_revert($revert); + return array(); +} + +/** + * Configure File Entity upload wizard settings. + */ +function commons_media_update_7301() { + $revert = array( + 'commons_media' => array('variable'), + ); + features_revert($revert); + return array(); +} diff --git a/modules/commons/commons_media/commons_media.module b/modules/commons/commons_media/commons_media.module new file mode 100644 index 0000000..6a06b1f --- /dev/null +++ b/modules/commons/commons_media/commons_media.module @@ -0,0 +1,293 @@ +name == 'commons_media') { + $entity_integrations = commons_entity_integration_info(); + + if (!empty($entity_integrations)) { + foreach ($entity_integrations as $entity_type => $bundles) { + foreach ($bundles as $bundle => $integrations) { + if (!empty($integrations['media'])) { + $info['features']['field_instance'][] = "$entity_type-$bundle-field_media"; + } + } + } + } + } +} + +/** + * Implements hook_menu_alter(). + */ +function commons_media_menu_alter(&$items) { + // Use a tweaked AJAX page callback for managed_file and media elements in + // order to bypass a core issue that occurs when more than one browsing widget + // tab contains a managed_file or media file field widget. + if (isset($items['file/ajax'])) { + $items['file/ajax']['page callback'] = 'commons_ajax_upload'; + } + if (isset($items['media/ajax'])) { + $items['media/ajax']['page callback'] = 'commons_ajax_upload'; + } +} + +/** + * Menu callback; Shared Ajax callback for managed_file and media elements. + * + * Identical to the Ajax callback used by file.module and media.module except + * with the $form_build_id != $_POST['form_build_id'] check removed in order to + * prevent errors when more than one browsing widget tab contains a managed_file + * or media file field widget. + * + * @see file_ajax_upload() + * @see media_ajax_upload() + */ +function commons_ajax_upload() { + $form_parents = func_get_args(); + $form_build_id = (string) array_pop($form_parents); + + if (empty($_POST['form_build_id'])) { + // Invalid request. + drupal_set_message(t('An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (@size) that this server supports.', array('@size' => format_size(file_upload_max_size()))), 'error'); + $commands = array(); + $commands[] = ajax_command_replace(NULL, theme('status_messages')); + return array('#type' => 'ajax', '#commands' => $commands); + } + + list($form, $form_state, $form_id, $form_build_id, $commands) = ajax_get_form(); + + if (!$form) { + // Invalid form_build_id. + drupal_set_message(t('An unrecoverable error occurred. Use of this form has expired. Try reloading the page and submitting again.'), 'error'); + $commands = array(); + $commands[] = ajax_command_replace(NULL, theme('status_messages')); + return array('#type' => 'ajax', '#commands' => $commands); + } + + // Get the current element and count the number of files. + $current_element = $form; + foreach ($form_parents as $parent) { + $current_element = $current_element[$parent]; + } + $current_file_count = isset($current_element['#file_upload_delta']) ? $current_element['#file_upload_delta'] : 0; + + // Process user input. $form and $form_state are modified in the process. + drupal_process_form($form['#form_id'], $form, $form_state); + + // Retrieve the element to be rendered. + foreach ($form_parents as $parent) { + $form = $form[$parent]; + } + + // Add the special Ajax class if a new file was added. + if (isset($form['#file_upload_delta']) && $current_file_count < $form['#file_upload_delta']) { + $form[$current_file_count]['#attributes']['class'][] = 'ajax-new-content'; + } + // Otherwise just add the new content class on a placeholder. + else { + $form['#suffix'] .= ''; + } + + $output = theme('status_messages') . drupal_render($form); + $js = drupal_add_js(); + $settings = call_user_func_array('array_merge_recursive', $js['settings']['data']); + + $commands[] = ajax_command_replace(NULL, $output, $settings); + return array('#type' => 'ajax', '#commands' => $commands); +} + +/** + * Implements hook_element_info_alter(). + */ +function commons_media_element_info_alter(&$type) { + $type['media']['#process'][] = 'commons_media_simplify_media_buttons'; +} + +/** + * Extra #process callback which simplifies the media element buttons. + */ +function commons_media_simplify_media_buttons($element, $edit, &$form_state) { + // Remove extraneous elements. + $element['#title_display'] = 'invisible'; + + return $element; +} + +/** + * Implements hook_page_build(). + */ +function commons_media_page_build(&$page) { + $page['page_bottom']['commons_media']['#attached']['css'] = array( + drupal_get_path('module', 'commons_media') . '/commons_media.css' => array( + 'every_page' => TRUE, + ), + ); +} + +/** + * Implements hook_filter_default_formats_alter(). + */ +function commons_media_filter_default_formats_alter(&$formats) { + if (module_exists('media_wysiwyg')) { + // Allow markup from remote media. + $formats['filtered_html']['filters']['filter_html']['settings']['allowed_html'] = '

    1. '; + + // Enable the media filter. + $formats['filtered_html']['filters'] += array( + 'media_filter' => array( + 'status' => 1, + 'weight' => 2, + ), + ); + } +} + +/** + * Implements hook_ckeditor_profile_defaults(). + */ +function commons_media_ckeditor_profile_defaults_alter(&$profiles) { + if (module_exists('media_wysiwyg')) { + // Disable the advanced content filter. + $profiles['Advanced']['settings']['allowed_content'] = 'f'; + + // Add the media button. + $profiles['Advanced']['settings']['toolbar'] = '[ + [\'Format\'], + [\'Bold\',\'Italic\',\'Strike\'], + [\'NumberedList\',\'BulletedList\',\'Indent\',\'Outdent\',\'Blockquote\'], + [\'Link\',\'Unlink\',\'Media\'] + ]'; + + // Load the media plugin. + $profiles['Advanced']['settings']['loadPlugins'] += array( + 'media' => array( + 'default' => 'f', + 'desc' => 'Plugin for inserting images from Drupal media module', + 'name' => 'media', + 'path' => '%plugin_dir%media/', + ), + ); + } +} + +/** + * Implements hook_form_FORM_ID_alter(). + */ +function commons_media_form_file_entity_add_upload_alter(&$form, &$form_state, $form_id) { + // Automatically upload selected files. + if ($form['#step'] == 1) { + $form['#attached']['js'][] = drupal_get_path('module', 'commons_media') . '/commons_media_autoupload.js'; + } +} + +/** + * Implements hook_form_FORM_ID_alter(). + */ +function commons_media_form_media_internet_add_alter(&$form, &$form_state, $form_id) { + if (isset($form['embed_code'])) { + $form['embed_code']['#description'] = t('Enter a URL or link to the media you would like to embed, such as a video or image. You can upload video from a range of providers, such as YouTube, Flickr or Vimeo.'); + } +} + +/** + * Implements hook_media_format_form_prepare_alter(). + */ +function commons_media_media_wysiwyg_format_form_prepare_alter(&$form, &$form_state, $media) { + // Remove the ability to override field values through WYSIWYG. + $form['options']['fields']['#access'] = FALSE; + + // Attach JavaScript to automatically embed files. + $form['#attached']['js'][] = drupal_get_path('module', 'commons_media') . '/commons_media_autoembed.js'; +} + +/** + * Implements hook_entity_presave(). + */ +function commons_media_entity_presave($entity, $type) { + // Only proceed if the private file system has been configured. + if (!variable_get('file_private_path', FALSE)) { + return; + } + + list($entity_id, $entity_vid, $entity_bundle) = entity_extract_ids($type, $entity); + + // Only proceed if the entity has been configured as group content. + if (!og_is_group_content_type($type, $entity_bundle)) { + return; + } + + // Loop over all the file and image fields attached to this entity. + foreach (_commons_media_get_file_and_image_fields($entity, $type) as $field_name) { + // Iterate over the items arrays for each language. + foreach (array_keys($entity->{$field_name}) as $langcode) { + $items = isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : array(); + + // Ensure that the private file system is used when attaching files to + // private group content. + foreach ($items as $delta => $item) { + // Move files to the private file system if the content is private. + if ($entity->group_content_access[LANGUAGE_NONE][0]['value'] == 2) { + $source_file = file_load($item['fid']); + + // Only move public files. + if (file_uri_scheme($source_file->uri) == 'public') { + $usage = file_usage_list($source_file); + + // Only move files that aren't currently in use. + if (empty($usage)) { + $scheme = 'private://'; + $uri = file_stream_wrapper_uri_normalize($scheme . $source_file->filename); + file_move($source_file, $uri, FILE_EXISTS_RENAME); + } + } + } + } + } + } +} + +/** + * Returns an array of image field names from a specific entity. + * + * @param $entity + * The entity variable passed through hook_entity_presave(). + * @param $type + * The entity type variable passed through hook_entity_presave(). + * + * @return array + * An array of file and image field names or an empty array if none are found. + */ +function _commons_media_get_file_and_image_fields($entity, $type) { + $collected_fields = array(); + + // Determine the list of instances to iterate on. + list(, , $bundle) = entity_extract_ids($type, $entity); + $instances = field_info_instances($type, $bundle); + $fields = field_info_fields(); + + // Iterate through the instances and collect results. + foreach ($instances as $instance) { + $field_name = $instance['field_name']; + + // Only collect file and image fields. + if ($fields[$field_name]['type'] == 'file' || $fields[$field_name]['type'] == 'image') { + if (isset($entity->{$field_name})) { + $collected_fields[] = $field_name; + } + } + } + + return $collected_fields; +} diff --git a/modules/commons/commons_media/commons_media.private_files.inc b/modules/commons/commons_media/commons_media.private_files.inc new file mode 100644 index 0000000..0721b78 --- /dev/null +++ b/modules/commons/commons_media/commons_media.private_files.inc @@ -0,0 +1,126 @@ + $entity_count) { + // Move files to the private file system if the content is private. + if ($entity->group_content_access[LANGUAGE_NONE][0]['value'] == 2) { + if ($source_file = file_load($fid)) { + + // Only move public files. + if (file_uri_scheme($source_file->uri) == 'public') { + $usage = file_usage_list($source_file); + + // Only move files that aren't currently in use. + if (empty($usage)) { + $scheme = 'private://'; + $uri = file_stream_wrapper_uri_normalize($scheme . $source_file->filename); + file_move($source_file, $uri, FILE_EXISTS_RENAME); + } + } + } + } + } +} + +/** + * Utility function to get the file count in this entity + * + * @param type $entity + * @param type $entity_type + * @return int + */ +function commons_media_entity_field_count_files($entity_type, $entity) { + $entity_files = array(); + + foreach (commons_media_filter_parse_from_fields($entity_type, $entity) as $file_reference) { + if (empty($entity_files[$file_reference['fid']])) { + $entity_files[$file_reference['fid']] = 1; + } + else { + $entity_files[$file_reference['fid']]++; + } + } + + return $entity_files; +} + +/** + * Parse file references from an entity's text fields and return them as an array. + */ +function commons_media_filter_parse_from_fields($entity_type, $entity) { + $file_references = array(); + + foreach (media_wysiwyg_filter_fields_with_text_filtering($entity_type, $entity) as $field_name) { + if ($field_items = field_get_items($entity_type, $entity, $field_name)) { + foreach ($field_items as $field_item) { + preg_match_all(MEDIA_WYSIWYG_TOKEN_REGEX, $field_item['value'], $matches); + + foreach ($matches[0] as $tag) { + $tag = str_replace(array('[[', ']]'), '', $tag); + $tag_info = drupal_json_decode($tag); + + if (isset($tag_info['fid']) && $tag_info['type'] == 'media') { + $file_references[] = $tag_info; + } + } + + preg_match_all(MEDIA_WYSIWYG_TOKEN_REGEX, $field_item['value'], $matches_alt); + + foreach ($matches_alt[0] as $tag) { + $tag = urldecode($tag); + $tag_info = drupal_json_decode($tag); + + if (isset($tag_info['fid']) && $tag_info['type'] == 'media') { + $file_references[] = $tag_info; + } + } + } + } + } + + return $file_references; +} diff --git a/modules/commons/commons_media/commons_media.strongarm.inc b/modules/commons/commons_media/commons_media.strongarm.inc new file mode 100644 index 0000000..50fa0a5 --- /dev/null +++ b/modules/commons/commons_media/commons_media.strongarm.inc @@ -0,0 +1,42 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'file_entity_file_upload_wizard_skip_fields'; + $strongarm->value = 0; + $export['file_entity_file_upload_wizard_skip_fields'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'file_entity_file_upload_wizard_skip_file_type'; + $strongarm->value = 1; + $export['file_entity_file_upload_wizard_skip_file_type'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'file_entity_file_upload_wizard_skip_scheme'; + $strongarm->value = 1; + $export['file_entity_file_upload_wizard_skip_scheme'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'media_dialog_theme'; + $strongarm->value = 'ember'; + $export['media_dialog_theme'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_media/commons_media_autoembed.js b/modules/commons/commons_media/commons_media_autoembed.js new file mode 100644 index 0000000..bd64f21 --- /dev/null +++ b/modules/commons/commons_media/commons_media_autoembed.js @@ -0,0 +1,10 @@ +(function ($) { + +Drupal.behaviors.autoEmbed = { + attach: function (context, settings) { + // Automatically click the submit button to embed the file. + $('.button.fake-ok').click(); + } +}; + +})(jQuery); diff --git a/modules/commons/commons_media/commons_media_autoupload.js b/modules/commons/commons_media/commons_media_autoupload.js new file mode 100644 index 0000000..31a32d6 --- /dev/null +++ b/modules/commons/commons_media/commons_media_autoupload.js @@ -0,0 +1,20 @@ +(function ($) { + +Drupal.behaviors.autoUpload = { + attach: function (context, settings) { + // Loop through all of the managed file form elements on the page. + $('.form-managed-file').each(function(index, element) { + // Hide/show the file upload/remove button if a file is not present. + if ($(this).children('span.file').length == 0 ) { + $(this).children('input.form-submit').hide(); + }; + + // Automatically upload the file if a file is selected. + $(this).delegate('input.form-file', 'change', function() { + $(this).siblings('input.form-submit').mousedown(); + }); + }); + } +}; + +})(jQuery); diff --git a/modules/commons/commons_misc/commons_misc.features.inc b/modules/commons/commons_misc/commons_misc.features.inc new file mode 100644 index 0000000..f2ea822 --- /dev/null +++ b/modules/commons/commons_misc/commons_misc.features.inc @@ -0,0 +1,17 @@ + "1"); + } + if ($module == "strongarm" && $api == "strongarm") { + return array("version" => "1"); + } +} diff --git a/modules/commons/commons_misc/commons_misc.features.user_permission.inc b/modules/commons/commons_misc/commons_misc.features.user_permission.inc new file mode 100644 index 0000000..1376ff2 --- /dev/null +++ b/modules/commons/commons_misc/commons_misc.features.user_permission.inc @@ -0,0 +1,77 @@ + 'access comments', + 'roles' => array( + 'administrator' => 'administrator', + 'anonymous user' => 'anonymous user', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'comment', + ); + + // Exported permission: 'access content'. + $permissions['access content'] = array( + 'name' => 'access content', + 'roles' => array( + 'administrator' => 'administrator', + 'anonymous user' => 'anonymous user', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + // Exported permission: 'access user profiles'. + $permissions['access user profiles'] = array( + 'name' => 'access user profiles', + 'roles' => array( + 'administrator' => 'administrator', + 'anonymous user' => 'anonymous user', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'user', + ); + + // Exported permission: 'post comments'. + $permissions['post comments'] = array( + 'name' => 'post comments', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'comment', + ); + + // Exported permission: 'skip comment approval'. + $permissions['skip comment approval'] = array( + 'name' => 'skip comment approval', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'comment', + ); + + // Exported permission: 'view own unpublished content'. + $permissions['view own unpublished content'] = array( + 'name' => 'view own unpublished content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + return $permissions; +} diff --git a/modules/commons/commons_misc/commons_misc.features.user_role.inc b/modules/commons/commons_misc/commons_misc.features.user_role.inc new file mode 100644 index 0000000..354ec88 --- /dev/null +++ b/modules/commons/commons_misc/commons_misc.features.user_role.inc @@ -0,0 +1,20 @@ + 'administrator', + 'weight' => 10, + ); + + return $roles; +} diff --git a/modules/commons/commons_misc/commons_misc.info b/modules/commons/commons_misc/commons_misc.info new file mode 100644 index 0000000..c6d9557 --- /dev/null +++ b/modules/commons/commons_misc/commons_misc.info @@ -0,0 +1,26 @@ +name = Commons Miscellaneous Configuration +description = Various suggested bits of configuration for Commons sites. +core = 7.x +package = Commons - Building blocks +dependencies[] = comment +dependencies[] = ctools +dependencies[] = features +dependencies[] = node +dependencies[] = strongarm +dependencies[] = user +features[ctools][] = page_manager:pages_default:1 +features[ctools][] = strongarm:strongarm:1 +features[features_api][] = api:2 +features[page_manager_handlers][] = node_view_panel_context +features[user_permission][] = access comments +features[user_permission][] = access content +features[user_permission][] = access user profiles +features[user_permission][] = post comments +features[user_permission][] = skip comment approval +features[user_permission][] = view own unpublished content +features[user_role][] = administrator +features[variable][] = navbar_libraries_variants +features[variable][] = theme_adaptivetheme_settings +features[variable][] = theme_commons_origins_settings +features[variable][] = user_register +features_exclude[dependencies][page_manager] = page_manager diff --git a/modules/commons/commons_misc/commons_misc.install b/modules/commons/commons_misc/commons_misc.install new file mode 100644 index 0000000..b8ab941 --- /dev/null +++ b/modules/commons/commons_misc/commons_misc.install @@ -0,0 +1,67 @@ +name = 'administrator'; + $role->weight = 10; + user_role_save($role); + } + + // Grant user 1 the 'administrator' role. + user_multiple_role_edit(array(1), 'add_role', $role->rid); + + // Set the 'administrator' role as the 'administrator role'. + variable_set('user_admin_role', $role->rid); +} + +/** + * Enable legacy IE settings for Commons Origins. + */ +function commons_misc_update_7000() { + // Pull the existing settings for Commons Origins so that any changes by the + // user are preserved. + $settings = variable_get('theme_commons_origins_settings', array()); + + // Prevent IE from falling into compatibility mode. + $settings['chrome_edge'] = 1; + + // Enable cleartype in IE. + $settings['clear_type'] = 1; + + // Save the new Commons Origins settings. + variable_set('theme_commons_origins_settings', $settings); +} + +/** + * Assign the administrator role a larger weight. + */ +function commons_misc_update_7001() { + $revert = array( + 'commons_misc' => array('user_role'), + ); + features_revert($revert); + return array(); +} + +/** + * Configure navbar to use the source version of Modernizr since it isn't + * currently possible to include a minified version of the library. + */ +function commons_misc_update_7002() { + $revert = array( + 'commons_misc' => array('variable'), + ); + features_revert($revert); + return array(); +} diff --git a/modules/commons/commons_misc/commons_misc.module b/modules/commons/commons_misc/commons_misc.module new file mode 100644 index 0000000..c2df42c --- /dev/null +++ b/modules/commons/commons_misc/commons_misc.module @@ -0,0 +1,74 @@ +nid)) { + $form['revision_information']['#access'] = FALSE; + } +} + +/** + * Implements hook_form_FORM_ID_alter(). + */ +function commons_misc_form_system_theme_settings_alter(&$form, &$form_state, $form_id) { + $themes_list = list_themes(TRUE); + + // Filter down to just the commons_origins theme: + // If commons_origins theme exists + // If commons_origins is enabled + // If we're not on the general settings tab -- because args aren't set yet + // And we're on the commons_origin settings page, then show the color palette + if (isset($themes_list['commons_origins']) + && $themes_list['commons_origins']->status == 1 + && !empty($form_state['build_info']['args']) + && $form_state['build_info']['args'][0] == 'commons_origins') { + // Add the color palette selection form to the apperance settings form. + require_once(drupal_get_path('theme', 'commons_origins') . '/commons_origins.palettes.inc'); + commons_origins_palettes_form($form); + } +} + +/** + * Implements hook_navbar(). + */ +function commons_misc_navbar() { + $items = array(); + + // Add a link to the official commons documentation. + $items['documentation'] = array( + '#type' => 'navbar_item', + 'tab' => array( + '#type' => 'link', + '#title' => t('Documentation'), + '#href' => 'https://docs.acquia.com/commons', + '#options' => array( + 'attributes' => array( + 'title' => t('Commons Documentation'), + 'class' => array('icon', 'icon-help'), + 'target' => '_blank', + ), + ), + ), + '#weight' => 20, + ); + + return $items; +} diff --git a/modules/commons/commons_misc/commons_misc.pages_default.inc b/modules/commons/commons_misc/commons_misc.pages_default.inc new file mode 100644 index 0000000..6ebca4b --- /dev/null +++ b/modules/commons/commons_misc/commons_misc.pages_default.inc @@ -0,0 +1,84 @@ +disabled = FALSE; /* Edit this to true to make a default handler disabled initially */ + $handler->api_version = 1; + $handler->name = 'node_view_panel_context'; + $handler->task = 'node_view'; + $handler->subtask = ''; + $handler->handler = 'panel_context'; + $handler->weight = -98; + $handler->conf = array( + 'title' => 'Fallback panel', + 'no_blocks' => 0, + 'pipeline' => 'ipe', + 'body_classes_to_remove' => '', + 'body_classes_to_add' => '', + 'css_id' => '', + 'css' => '', + 'contexts' => array(), + 'relationships' => array(), + ); + $display = new panels_display(); + $display->layout = 'two_66_33'; + $display->layout_settings = array(); + $display->panel_settings = array( + 'style_settings' => array( + 'default' => NULL, + 'two_66_33_top' => NULL, + 'two_66_33_first' => NULL, + 'two_66_33_second' => NULL, + 'two_66_33_bottom' => NULL, + ), + ); + $display->cache = array(); + $display->title = ''; + $display->uuid = 'da99dbdb-5ba9-9ab4-7944-b91485cd4086'; + $display->content = array(); + $display->panels = array(); + $pane = new stdClass(); + $pane->pid = 'new-deed05d0-e6bb-9b94-9d09-499090d1e5d3'; + $pane->panel = 'two_66_33_first'; + $pane->type = 'node_content'; + $pane->subtype = 'node_content'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'links' => 1, + 'no_extras' => 0, + 'override_title' => 1, + 'override_title_text' => '', + 'identifier' => 'fallback', + 'link' => 0, + 'leave_node_title' => 1, + 'build_mode' => 'full', + 'context' => 'argument_entity_id:node_1', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = 'deed05d0-e6bb-9b94-9d09-499090d1e5d3'; + $display->content['new-deed05d0-e6bb-9b94-9d09-499090d1e5d3'] = $pane; + $display->panels['two_66_33_first'][0] = 'new-deed05d0-e6bb-9b94-9d09-499090d1e5d3'; + $display->hide_title = PANELS_TITLE_FIXED; + $display->title_pane = 'new-deed05d0-e6bb-9b94-9d09-499090d1e5d3'; + $handler->conf['display'] = $display; + $export['node_view_panel_context'] = $handler; + + return $export; +} diff --git a/modules/commons/commons_misc/commons_misc.strongarm.inc b/modules/commons/commons_misc/commons_misc.strongarm.inc new file mode 100644 index 0000000..53ef917 --- /dev/null +++ b/modules/commons/commons_misc/commons_misc.strongarm.inc @@ -0,0 +1,324 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'theme_adaptivetheme_settings'; + $strongarm->value = array( + 'toggle_logo' => 1, + 'toggle_name' => 1, + 'toggle_slogan' => 1, + 'toggle_node_user_picture' => 1, + 'toggle_comment_user_picture' => 1, + 'toggle_comment_user_verification' => 1, + 'toggle_favicon' => 1, + 'toggle_main_menu' => 1, + 'toggle_secondary_menu' => 1, + 'default_logo' => 1, + 'logo_path' => '', + 'logo_upload' => '', + 'default_favicon' => 1, + 'favicon_path' => '', + 'favicon_upload' => '', + 'bigscreen_layout' => 'three_col_grail', + 'bigscreen_sidebar_unit' => '%', + 'bigscreen_sidebar_first' => '25', + 'bigscreen_sidebar_second' => '25', + 'bigscreen_page_unit' => '%', + 'bigscreen_page_width' => '100', + 'bigscreen_set_max_width' => '1', + 'bigscreen_max_width_unit' => 'px', + 'bigscreen_max_width' => '1140', + 'bigscreen_media_query' => 'only screen and (min-width:1025px)', + 'tablet_landscape_layout' => 'three_col_grail', + 'tablet_landscape_sidebar_unit' => '%', + 'tablet_landscape_sidebar_first' => '20', + 'tablet_landscape_sidebar_second' => '20', + 'tablet_landscape_page_unit' => '%', + 'tablet_landscape_page_width' => '100', + 'tablet_landscape_media_query' => 'only screen and (min-width:769px) and (max-width:1024px)', + 'tablet_portrait_layout' => 'one_col_vert', + 'tablet_portrait_sidebar_unit' => '%', + 'tablet_portrait_sidebar_first' => '50', + 'tablet_portrait_sidebar_second' => '50', + 'tablet_portrait_page_unit' => '%', + 'tablet_portrait_page_width' => '100', + 'tablet_portrait_media_query' => 'only screen and (min-width:481px) and (max-width:768px)', + 'smartphone_landscape_layout' => 'one_col_vert', + 'smartphone_landscape_sidebar_unit' => '%', + 'smartphone_landscape_sidebar_first' => '50', + 'smartphone_landscape_sidebar_second' => '50', + 'smartphone_landscape_media_query' => 'only screen and (min-width:321px) and (max-width:480px)', + 'smartphone_landscape_page_width' => '100', + 'smartphone_landscape_page_unit' => '%', + 'smartphone_portrait_media_query' => 'only screen and (max-width:320px)', + 'smartphone_portrait_page_width' => '', + 'smartphone_portrait_page_unit' => '', + 'smartphone_portrait_sidebar_first' => '', + 'smartphone_portrait_sidebar_second' => '', + 'smartphone_portrait_sidebar_unit' => '', + 'smartphone_portrait_layout' => '', + 'bigscreen_two_brick' => 'two-brick', + 'bigscreen_two_66_33' => 'two-66-33', + 'bigscreen_two_50' => 'two-50', + 'bigscreen_two_33_66' => 'two-33-66', + 'bigscreen_three_50_25_25' => 'three-50-25-25', + 'bigscreen_three_3x33' => 'three-3x33', + 'bigscreen_three_25_50_25' => 'three-25-50-25', + 'bigscreen_three_25_25_50' => 'three-25-25-50', + 'bigscreen_four_4x25' => 'four-4x25', + 'bigscreen_five_5x20' => 'five-5x20-2x3-grid', + 'bigscreen_six_6x16' => 'six-6x16-3x2-grid', + 'bigscreen_three_inset_right' => 'three-inset-right', + 'bigscreen_three_inset_left' => 'three-inset-left', + 'tablet_landscape_two_brick' => 'two-brick', + 'tablet_landscape_two_66_33' => 'two-66-33', + 'tablet_landscape_two_50' => 'two-50', + 'tablet_landscape_two_33_66' => 'two-33-66', + 'tablet_landscape_three_50_25_25' => 'three-50-25-25', + 'tablet_landscape_three_3x33' => 'three-3x33', + 'tablet_landscape_three_25_50_25' => 'three-25-50-25', + 'tablet_landscape_three_25_25_50' => 'three-25-25-50', + 'tablet_landscape_four_4x25' => 'four-4x25', + 'tablet_landscape_five_5x20' => 'five-5x20-2x3-grid', + 'tablet_landscape_six_6x16' => 'six-6x16-3x2-grid', + 'tablet_landscape_three_inset_right' => 'three-inset-right', + 'tablet_landscape_three_inset_left' => 'three-inset-left', + 'tablet_portrait_two_brick' => 'two-brick', + 'tablet_portrait_two_66_33' => 'two-66-33', + 'tablet_portrait_two_50' => 'two-50', + 'tablet_portrait_two_33_66' => 'two-33-66', + 'tablet_portrait_three_50_25_25' => 'three-50-25-25-stack-top', + 'tablet_portrait_three_3x33' => 'three-3x33-stack-top', + 'tablet_portrait_three_25_50_25' => 'three-25-50-25-stack-top', + 'tablet_portrait_three_25_25_50' => 'three-25-25-50-stack-top', + 'tablet_portrait_four_4x25' => 'four-4x25-2x2-grid', + 'tablet_portrait_five_5x20' => 'five-5x20-1x2x2-grid', + 'tablet_portrait_six_6x16' => 'six-6x16-2x3-grid', + 'tablet_portrait_three_inset_right' => 'three-inset-right-wrap', + 'tablet_portrait_three_inset_left' => 'three-inset-left-wrap', + 'smartphone_landscape_two_brick' => 'two-brick-stack', + 'smartphone_landscape_two_66_33' => 'two-66-33-stack', + 'smartphone_landscape_two_50' => 'two-50-stack', + 'smartphone_landscape_two_33_66' => 'two-33-66-stack', + 'smartphone_landscape_three_50_25_25' => 'three-50-25-25-stack', + 'smartphone_landscape_three_3x33' => 'three-3x33-stack', + 'smartphone_landscape_three_25_50_25' => 'three-25-50-25-stack', + 'smartphone_landscape_three_25_25_50' => 'three-25-25-50-stack', + 'smartphone_landscape_four_4x25' => 'four-4x25-stack', + 'smartphone_landscape_five_5x20' => 'five-5x20-stack', + 'smartphone_landscape_six_6x16' => 'six-6x16-stack', + 'smartphone_landscape_three_inset_right' => 'three-inset-right-stack', + 'smartphone_landscape_three_inset_left' => 'three-inset-left-stack', + 'enable_custom_media_queries' => '1', + 'global_default_layout_toggle' => '0', + 'global_default_layout' => 'smartphone-portrait', + 'global_files_path' => 'public_files', + 'custom_files_path' => '', + 'disable_responsive_styles' => '0', + 'load_html5js' => '1', + 'load_onmediaqueryjs' => '0', + 'load_ltie8css' => '0', + 'load_respondjs' => '0', + 'load_scalefixjs' => '0', + 'adaptivetheme_meta_viewport' => 'width=device-width, initial-scale=1', + 'adaptivetheme_meta_mobileoptimized' => 'width', + 'adaptivetheme_meta_handheldfriendly' => 'true', + 'adaptivetheme_meta_apple_mobile_web_app_capable' => 'yes', + 'chrome_edge' => '0', + 'clear_type' => '0', + 'expose_regions' => '0', + 'show_window_size' => '0', + 'atcore_version_test' => 0, + 'load_all_panels' => '0', + 'load_all_panels_no_sidebars' => '0', + 'enable_extensions' => '0', + 'enable_font_settings' => '0', + 'enable_heading_settings' => '0', + 'enable_image_settings' => '0', + 'enable_apple_touch_icons' => '0', + 'enable_exclude_css' => '0', + 'enable_custom_css' => '0', + 'enable_context_regions' => '0', + 'enable_float_region_blocks' => '0', + 'enable_markup_overides' => '0', + 'at-settings__active_tab' => '', + 'at_core' => '7.x-3.x', + ); + $export['theme_adaptivetheme_settings'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'theme_commons_origins_settings'; + $strongarm->value = array( + 'toggle_logo' => 1, + 'toggle_name' => 1, + 'toggle_slogan' => 1, + 'toggle_node_user_picture' => 1, + 'toggle_comment_user_picture' => 1, + 'toggle_comment_user_verification' => 1, + 'toggle_favicon' => 1, + 'toggle_main_menu' => 1, + 'toggle_secondary_menu' => 1, + 'default_logo' => 1, + 'logo_path' => '', + 'logo_upload' => '', + 'default_favicon' => 1, + 'favicon_path' => '', + 'favicon_upload' => '', + 'bigscreen_layout' => 'three_col_grail', + 'bigscreen_sidebar_unit' => 'px', + 'bigscreen_sidebar_first' => '285', + 'bigscreen_sidebar_second' => '285', + 'bigscreen_page_unit' => 'px', + 'bigscreen_page_width' => '935', + 'bigscreen_set_max_width' => 1, + 'bigscreen_max_width_unit' => 'px', + 'bigscreen_max_width' => '935', + 'bigscreen_media_query' => 'only screen and (min-width:935px)', + 'tablet_landscape_layout' => 'three_col_grail', + 'tablet_landscape_sidebar_unit' => '%', + 'tablet_landscape_sidebar_first' => '20', + 'tablet_landscape_sidebar_second' => '20', + 'tablet_landscape_page_unit' => '%', + 'tablet_landscape_page_width' => '100', + 'tablet_landscape_media_query' => 'only screen and (min-width:769px) and (max-width:934px)', + 'tablet_portrait_layout' => 'one_col_vert', + 'tablet_portrait_sidebar_unit' => '%', + 'tablet_portrait_sidebar_first' => '50', + 'tablet_portrait_sidebar_second' => '50', + 'tablet_portrait_page_unit' => '%', + 'tablet_portrait_page_width' => '100', + 'tablet_portrait_media_query' => 'only screen and (min-width:481px) and (max-width:768px)', + 'smartphone_landscape_layout' => 'one_col_vert', + 'smartphone_landscape_sidebar_unit' => '%', + 'smartphone_landscape_sidebar_first' => '50', + 'smartphone_landscape_sidebar_second' => '50', + 'smartphone_landscape_media_query' => 'only screen and (min-width:321px) and (max-width:480px)', + 'smartphone_landscape_page_width' => '100', + 'smartphone_landscape_page_unit' => '%', + 'smartphone_portrait_media_query' => 'only screen and (max-width:320px)', + 'smartphone_portrait_page_width' => '100', + 'smartphone_portrait_page_unit' => '%', + 'smartphone_portrait_sidebar_first' => '100', + 'smartphone_portrait_sidebar_second' => '100', + 'smartphone_portrait_sidebar_unit' => '%', + 'smartphone_portrait_layout' => 'one_col_stack', + 'bigscreen_two_brick' => 'two-brick', + 'bigscreen_two_66_33' => 'two-66-33', + 'bigscreen_two_50' => 'two-50', + 'bigscreen_two_33_66' => 'two-33-66', + 'bigscreen_three_50_25_25' => 'three-50-25-25', + 'bigscreen_three_3x33' => 'three-3x33', + 'bigscreen_three_25_50_25' => 'three-25-50-25', + 'bigscreen_three_25_25_50' => 'three-25-25-50', + 'bigscreen_four_4x25' => 'four-4x25', + 'bigscreen_five_5x20' => 'five-5x20-2x3-grid', + 'bigscreen_six_6x16' => 'six-6x16-3x2-grid', + 'bigscreen_three_inset_right' => 'three-inset-right', + 'bigscreen_three_inset_left' => 'three-inset-left', + 'tablet_landscape_two_brick' => 'two-brick', + 'tablet_landscape_two_66_33' => 'two-66-33', + 'tablet_landscape_two_50' => 'two-50', + 'tablet_landscape_two_33_66' => 'two-33-66', + 'tablet_landscape_three_50_25_25' => 'three-50-25-25', + 'tablet_landscape_three_3x33' => 'three-3x33', + 'tablet_landscape_three_25_50_25' => 'three-25-50-25', + 'tablet_landscape_three_25_25_50' => 'three-25-25-50', + 'tablet_landscape_four_4x25' => 'four-4x25', + 'tablet_landscape_five_5x20' => 'five-5x20-2x3-grid', + 'tablet_landscape_six_6x16' => 'six-6x16-3x2-grid', + 'tablet_landscape_three_inset_right' => 'three-inset-right', + 'tablet_landscape_three_inset_left' => 'three-inset-left', + 'tablet_portrait_two_brick' => 'two-brick', + 'tablet_portrait_two_66_33' => 'two-66-33', + 'tablet_portrait_two_50' => 'two-50', + 'tablet_portrait_two_33_66' => 'two-33-66', + 'tablet_portrait_three_50_25_25' => 'three-50-25-25-stack-top', + 'tablet_portrait_three_3x33' => 'three-3x33-stack-top', + 'tablet_portrait_three_25_50_25' => 'three-25-50-25-stack-top', + 'tablet_portrait_three_25_25_50' => 'three-25-25-50-stack-top', + 'tablet_portrait_four_4x25' => 'four-4x25-2x2-grid', + 'tablet_portrait_five_5x20' => 'five-5x20-1x2x2-grid', + 'tablet_portrait_six_6x16' => 'six-6x16-2x3-grid', + 'tablet_portrait_three_inset_right' => 'three-inset-right-wrap', + 'tablet_portrait_three_inset_left' => 'three-inset-left-wrap', + 'smartphone_landscape_two_brick' => 'two-brick-stack', + 'smartphone_landscape_two_66_33' => 'two-66-33-stack', + 'smartphone_landscape_two_50' => 'two-50-stack', + 'smartphone_landscape_two_33_66' => 'two-33-66-stack', + 'smartphone_landscape_three_50_25_25' => 'three-50-25-25-stack', + 'smartphone_landscape_three_3x33' => 'three-3x33-stack', + 'smartphone_landscape_three_25_50_25' => 'three-25-50-25-stack', + 'smartphone_landscape_three_25_25_50' => 'three-25-25-50-stack', + 'smartphone_landscape_four_4x25' => 'four-4x25-stack', + 'smartphone_landscape_five_5x20' => 'five-5x20-stack', + 'smartphone_landscape_six_6x16' => 'six-6x16-stack', + 'smartphone_landscape_three_inset_right' => 'three-inset-right-stack', + 'smartphone_landscape_three_inset_left' => 'three-inset-left-stack', + 'enable_custom_media_queries' => 1, + 'global_default_layout_toggle' => 0, + 'global_default_layout' => 'smartphone-portrait', + 'global_files_path' => 'public_files', + 'custom_files_path' => '', + 'disable_responsive_styles' => 0, + 'load_html5js' => 1, + 'load_onmediaqueryjs' => 0, + 'load_ltie8css' => 0, + 'load_respondjs' => 0, + 'load_scalefixjs' => 0, + 'adaptivetheme_meta_viewport' => 'width=device-width, initial-scale=1', + 'adaptivetheme_meta_mobileoptimized' => 'width', + 'adaptivetheme_meta_handheldfriendly' => 'true', + 'adaptivetheme_meta_apple_mobile_web_app_capable' => 'yes', + 'chrome_edge' => 1, + 'clear_type' => 1, + 'expose_regions' => 0, + 'show_window_size' => 0, + 'atcore_version_test' => 0, + 'load_all_panels' => 0, + 'load_all_panels_no_sidebars' => 0, + 'enable_extensions' => 0, + 'enable_font_settings' => 0, + 'enable_heading_settings' => 0, + 'enable_image_settings' => 0, + 'enable_apple_touch_icons' => 0, + 'enable_exclude_css' => 0, + 'enable_custom_css' => 0, + 'enable_context_regions' => 0, + 'enable_float_region_blocks' => 0, + 'enable_markup_overides' => 0, + 'at-settings__active_tab' => 'edit-bigscreen', + 'at_core' => '7.x-3.x', + ); + $export['theme_commons_origins_settings'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'navbar_libraries_variants'; + $strongarm->value = array( + 'modernizr' => 'source', + ); + $export['navbar_libraries_variants'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'user_register'; + $strongarm->value = '1'; + $export['user_register'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_notices/commons_notices.features.field_instance.inc b/modules/commons/commons_notices/commons_notices.features.field_instance.inc new file mode 100644 index 0000000..99a6cc3 --- /dev/null +++ b/modules/commons/commons_notices/commons_notices.features.field_instance.inc @@ -0,0 +1,62 @@ + 'notice', + 'default_value' => NULL, + 'deleted' => '0', + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 0, + ), + 'teaser' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array( + 'trim_length' => 600, + ), + 'type' => 'text_summary_or_trimmed', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'body', + 'label' => 'Body', + 'required' => FALSE, + 'settings' => array( + 'display_summary' => FALSE, + 'text_processing' => 1, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'module' => 'text', + 'settings' => array( + 'rows' => 20, + 'summary_rows' => 5, + ), + 'type' => 'text_textarea_with_summary', + 'weight' => -4, + ), + ); + + // Translatables + // Included for use with string extractors like potx. + t('Body'); + + return $field_instances; +} diff --git a/modules/commons/commons_notices/commons_notices.features.inc b/modules/commons/commons_notices/commons_notices.features.inc new file mode 100644 index 0000000..bc5e24e --- /dev/null +++ b/modules/commons/commons_notices/commons_notices.features.inc @@ -0,0 +1,39 @@ + "1"); + } +} + +/** + * Implements hook_views_api(). + */ +function commons_notices_views_api() { + return array("version" => "3.0"); +} + +/** + * Implements hook_node_info(). + */ +function commons_notices_node_info() { + $items = array( + 'notice' => array( + 'name' => t('Notice'), + 'base' => 'node_content', + 'description' => 'Display an administrative alert for your website users, such as planned system maintenance.', + 'has_title' => '1', + 'title_label' => t('Title'), + 'help' => '', + ), + ); + return $items; +} diff --git a/modules/commons/commons_notices/commons_notices.info b/modules/commons/commons_notices/commons_notices.info new file mode 100644 index 0000000..db2c418 --- /dev/null +++ b/modules/commons/commons_notices/commons_notices.info @@ -0,0 +1,29 @@ +name = Commons Notices +core = 7.x +package = Commons - Content types +php = 5.2.4 +dependencies[] = commons_body +dependencies[] = ctools +dependencies[] = features +dependencies[] = node +dependencies[] = strongarm +dependencies[] = text +dependencies[] = views +features[ctools][] = strongarm:strongarm:1 +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:1 +features[field_instance][] = node-notice-body +features[node][] = notice +features[variable][] = comment_anonymous_notice +features[variable][] = comment_default_mode_notice +features[variable][] = comment_default_per_page_notice +features[variable][] = comment_form_location_notice +features[variable][] = comment_notice +features[variable][] = comment_preview_notice +features[variable][] = comment_subject_field_notice +features[variable][] = menu_options_notice +features[variable][] = menu_parent_notice +features[variable][] = node_options_notice +features[variable][] = node_preview_notice +features[variable][] = node_submitted_notice +features[views_view][] = commons_notices_latest_notices diff --git a/modules/commons/commons_notices/commons_notices.install b/modules/commons/commons_notices/commons_notices.install new file mode 100644 index 0000000..69ea93e --- /dev/null +++ b/modules/commons/commons_notices/commons_notices.install @@ -0,0 +1,12 @@ + array('field_instance'), + ); + features_revert($revert); + return array(); +} \ No newline at end of file diff --git a/modules/commons/commons_notices/commons_notices.module b/modules/commons/commons_notices/commons_notices.module new file mode 100644 index 0000000..f19998c --- /dev/null +++ b/modules/commons/commons_notices/commons_notices.module @@ -0,0 +1,7 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_anonymous_notice'; + $strongarm->value = 0; + $export['comment_anonymous_notice'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_mode_notice'; + $strongarm->value = 1; + $export['comment_default_mode_notice'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_per_page_notice'; + $strongarm->value = '50'; + $export['comment_default_per_page_notice'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_form_location_notice'; + $strongarm->value = 1; + $export['comment_form_location_notice'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_notice'; + $strongarm->value = '0'; + $export['comment_notice'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_preview_notice'; + $strongarm->value = '1'; + $export['comment_preview_notice'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_subject_field_notice'; + $strongarm->value = 1; + $export['comment_subject_field_notice'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_options_notice'; + $strongarm->value = array( + 0 => 'main-menu', + ); + $export['menu_options_notice'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_parent_notice'; + $strongarm->value = 'main-menu:0'; + $export['menu_parent_notice'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_options_notice'; + $strongarm->value = array( + 0 => 'status', + 1 => 'promote', + ); + $export['node_options_notice'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_preview_notice'; + $strongarm->value = '1'; + $export['node_preview_notice'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_submitted_notice'; + $strongarm->value = 0; + $export['node_submitted_notice'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_notices/commons_notices.views_default.inc b/modules/commons/commons_notices/commons_notices.views_default.inc new file mode 100644 index 0000000..9f90785 --- /dev/null +++ b/modules/commons/commons_notices/commons_notices.views_default.inc @@ -0,0 +1,118 @@ +name = 'commons_notices_latest_notices'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'Commons Notices - Latest Notices'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Community Notices'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['query']['options']['query_comment'] = FALSE; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'node'; + $handler->display->display_options['row_options']['links'] = FALSE; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['content'] = 'There are no results.'; + $handler->display->display_options['empty']['area']['format'] = 'plain_text'; + /* Relationship: OG membership: OG membership from Node */ + $handler->display->display_options['relationships']['og_membership_rel']['id'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['table'] = 'node'; + $handler->display->display_options['relationships']['og_membership_rel']['field'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['required'] = TRUE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + $handler->display->display_options['sorts']['created']['exposed'] = TRUE; + $handler->display->display_options['sorts']['created']['expose']['label'] = 'Post date'; + /* Contextual filter: OG membership: Group ID */ + $handler->display->display_options['arguments']['gid']['id'] = 'gid'; + $handler->display->display_options['arguments']['gid']['table'] = 'og_membership'; + $handler->display->display_options['arguments']['gid']['field'] = 'gid'; + $handler->display->display_options['arguments']['gid']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['arguments']['gid']['default_action'] = 'empty'; + $handler->display->display_options['arguments']['gid']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['gid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['gid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['gid']['summary_options']['items_per_page'] = '25'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type_1']['id'] = 'type_1'; + $handler->display->display_options['filters']['type_1']['table'] = 'node'; + $handler->display->display_options['filters']['type_1']['field'] = 'type'; + $handler->display->display_options['filters']['type_1']['value'] = array( + 'notice' => 'notice', + ); + $handler->display->display_options['filters']['type_1']['group'] = 1; + + /* Display: Latest Notices Block */ + $handler = $view->new_display('block', 'Latest Notices Block', 'block_2'); + $handler->display->display_options['defaults']['title'] = FALSE; + $handler->display->display_options['title'] = 'Latest Notices'; + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $translatables['commons_notices_latest_notices'] = array( + t('Master'), + t('Community Notices'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('There are no results.'), + t('OG membership from node'), + t('Post date'), + t('All'), + t('Latest Notices Block'), + t('Latest Notices'), + ); + $export['commons_notices_latest_notices'] = $view; + + return $export; +} diff --git a/modules/commons/commons_notify/commons_notify.features.field_base.inc b/modules/commons/commons_notify/commons_notify.features.field_base.inc new file mode 100644 index 0000000..0e8596e --- /dev/null +++ b/modules/commons/commons_notify/commons_notify.features.field_base.inc @@ -0,0 +1,98 @@ + 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_message_rendered_body', + 'foreign keys' => array( + 'format' => array( + 'columns' => array( + 'format' => 'format', + ), + 'table' => 'filter_format', + ), + ), + 'indexes' => array( + 'format' => array( + 0 => 'format', + ), + ), + 'locked' => 0, + 'module' => 'text', + 'settings' => array(), + 'translatable' => 0, + 'type' => 'text_long', + ); + + // Exported field_base: 'field_message_rendered_subject' + $field_bases['field_message_rendered_subject'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_message_rendered_subject', + 'foreign keys' => array( + 'format' => array( + 'columns' => array( + 'format' => 'format', + ), + 'table' => 'filter_format', + ), + ), + 'indexes' => array( + 'format' => array( + 0 => 'format', + ), + ), + 'locked' => 0, + 'module' => 'text', + 'settings' => array( + 'max_length' => 255, + ), + 'translatable' => 0, + 'type' => 'text', + ); + + // Exported field_base: 'message_subscribe_email' + $field_bases['message_subscribe_email'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array( + 0 => 'user', + ), + 'field_name' => 'message_subscribe_email', + 'foreign keys' => array(), + 'indexes' => array( + 'value' => array( + 0 => 'value', + ), + ), + 'locked' => 0, + 'module' => 'list', + 'settings' => array( + 'allowed_values' => array( + 0 => 'Don\'t email', + 1 => 'Email', + ), + 'allowed_values_function' => '', + ), + 'translatable' => 0, + 'type' => 'list_boolean', + ); + + return $field_bases; +} diff --git a/modules/commons/commons_notify/commons_notify.features.field_instance.inc b/modules/commons/commons_notify/commons_notify.features.field_instance.inc new file mode 100644 index 0000000..d03df1f --- /dev/null +++ b/modules/commons/commons_notify/commons_notify.features.field_instance.inc @@ -0,0 +1,786 @@ + 'commons_notify_comment_created', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 2, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 4, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 4, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_message_rendered_body', + 'label' => 'Body', + 'required' => 0, + 'settings' => array( + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'rows' => 5, + ), + 'type' => 'text_textarea', + 'weight' => 6, + ), + ); + + // Exported field_instance: 'message-commons_notify_comment_created-field_message_rendered_subject' + $field_instances['message-commons_notify_comment_created-field_message_rendered_subject'] = array( + 'bundle' => 'commons_notify_comment_created', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 3, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 3, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 3, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_message_rendered_subject', + 'label' => 'Subject', + 'required' => FALSE, + 'settings' => array( + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'module' => 'text', + 'settings' => array( + 'size' => 60, + ), + 'type' => 'text_textfield', + 'weight' => 8, + ), + ); + + // Exported field_instance: 'message-commons_notify_comment_created-field_target_comments' + $field_instances['message-commons_notify_comment_created-field_target_comments'] = array( + 'bundle' => 'commons_notify_comment_created', + 'default_value' => NULL, + 'default_value_function' => '', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'entityreference', + 'settings' => array( + 'link' => FALSE, + ), + 'type' => 'entityreference_label', + 'weight' => 1, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 5, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 5, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_target_comments', + 'label' => 'Target comment', + 'required' => 1, + 'settings' => array( + 'behaviors' => array( + 'prepopulate' => array( + 'status' => 0, + ), + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 4, + ), + ); + + // Exported field_instance: 'message-commons_notify_comment_created-field_target_nodes' + $field_instances['message-commons_notify_comment_created-field_target_nodes'] = array( + 'bundle' => 'commons_notify_comment_created', + 'default_value' => NULL, + 'default_value_function' => '', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'entityreference', + 'settings' => array( + 'link' => FALSE, + ), + 'type' => 'entityreference_label', + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 6, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 6, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_target_nodes', + 'label' => 'Target nodes', + 'required' => 0, + 'settings' => array( + 'behaviors' => array( + 'prepopulate' => array( + 'status' => 0, + ), + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 2, + ), + ); + + // Exported field_instance: 'message-commons_notify_comment_created_no_groups-field_message_rendered_body' + $field_instances['message-commons_notify_comment_created_no_groups-field_message_rendered_body'] = array( + 'bundle' => 'commons_notify_comment_created_no_groups', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 2, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 4, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 4, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_message_rendered_body', + 'label' => 'Body', + 'required' => 0, + 'settings' => array( + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'rows' => 5, + ), + 'type' => 'text_textarea', + 'weight' => 6, + ), + ); + + // Exported field_instance: 'message-commons_notify_comment_created_no_groups-field_message_rendered_subject' + $field_instances['message-commons_notify_comment_created_no_groups-field_message_rendered_subject'] = array( + 'bundle' => 'commons_notify_comment_created_no_groups', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 3, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 3, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 3, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_message_rendered_subject', + 'label' => 'Subject', + 'required' => FALSE, + 'settings' => array( + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'module' => 'text', + 'settings' => array( + 'size' => 60, + ), + 'type' => 'text_textfield', + 'weight' => 8, + ), + ); + + + // Exported field_instance: 'message-commons_notify_comment_created_no_groups-field_target_comments' + $field_instances['message-commons_notify_comment_created_no_groups-field_target_comments'] = array( + 'bundle' => 'commons_notify_comment_created_no_groups', + 'default_value' => NULL, + 'default_value_function' => '', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'entityreference', + 'settings' => array( + 'link' => FALSE, + ), + 'type' => 'entityreference_label', + 'weight' => 1, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 5, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 5, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_target_comments', + 'label' => 'Target comment', + 'required' => 1, + 'settings' => array( + 'behaviors' => array( + 'prepopulate' => array( + 'status' => 0, + ), + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 4, + ), + ); + + // Exported field_instance: 'message-commons_notify_comment_created_no_groups-field_target_nodes' + $field_instances['message-commons_notify_comment_created_no_groups-field_target_nodes'] = array( + 'bundle' => 'commons_notify_comment_created_no_groups', + 'default_value' => NULL, + 'default_value_function' => '', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'entityreference', + 'settings' => array( + 'link' => FALSE, + ), + 'type' => 'entityreference_label', + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 6, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 6, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_target_nodes', + 'label' => 'Target nodes', + 'required' => 0, + 'settings' => array( + 'behaviors' => array( + 'prepopulate' => array( + 'status' => 0, + ), + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 2, + ), + ); + + // Exported field_instance: 'message-commons_notify_node_created-field_message_rendered_body' + $field_instances['message-commons_notify_node_created-field_message_rendered_body'] = array( + 'bundle' => 'commons_notify_node_created', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 1, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 3, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_message_rendered_body', + 'label' => 'Body', + 'required' => FALSE, + 'settings' => array( + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'module' => 'text', + 'settings' => array( + 'rows' => 5, + ), + 'type' => 'text_textarea', + 'weight' => 4, + ), + ); + + // Exported field_instance: 'message-commons_notify_node_created-field_message_rendered_subject' + $field_instances['message-commons_notify_node_created-field_message_rendered_subject'] = array( + 'bundle' => 'commons_notify_node_created', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 2, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 3, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 1, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_message_rendered_subject', + 'label' => 'Subject', + 'required' => 0, + 'settings' => array( + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'size' => 255, + ), + 'type' => 'text_textfield', + 'weight' => 3, + ), + ); + + // Exported field_instance: 'message-commons_notify_node_created-field_target_nodes' + $field_instances['message-commons_notify_node_created-field_target_nodes'] = array( + 'bundle' => 'commons_notify_node_created', + 'default_value' => NULL, + 'default_value_function' => '', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 3, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 4, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 4, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_target_nodes', + 'label' => 'Target nodes', + 'required' => 1, + 'settings' => array( + 'behaviors' => array( + 'prepopulate' => array( + 'status' => 0, + ), + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 2, + ), + ); + + // Exported field_instance: 'message-commons_notify_node_created_no_groups-field_message_rendered_body' + $field_instances['message-commons_notify_node_created_no_groups-field_message_rendered_body'] = array( + 'bundle' => 'commons_notify_node_created_no_groups', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 1, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_message_rendered_body', + 'label' => 'Body', + 'required' => 0, + 'settings' => array( + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'rows' => 5, + ), + 'type' => 'text_textarea', + 'weight' => 2, + ), + ); + + // Exported field_instance: 'message-commons_notify_node_created_no_groups-field_message_rendered_subject' + $field_instances['message-commons_notify_node_created_no_groups-field_message_rendered_subject'] = array( + 'bundle' => 'commons_notify_node_created_no_groups', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 2, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_message_rendered_subject', + 'label' => 'Subject', + 'required' => 0, + 'settings' => array( + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'size' => 60, + ), + 'type' => 'text_textfield', + 'weight' => 3, + ), + ); + + // Exported field_instance: 'message-commons_notify_node_created_no_groups-field_target_nodes' + $field_instances['message-commons_notify_node_created_no_groups-field_target_nodes'] = array( + 'bundle' => 'commons_notify_node_created_no_groups', + 'default_value' => NULL, + 'default_value_function' => '', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'entityreference', + 'settings' => array( + 'link' => FALSE, + ), + 'type' => 'entityreference_label', + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_target_nodes', + 'label' => 'Target nodes', + 'required' => 1, + 'settings' => array( + 'behaviors' => array( + 'prepopulate' => array( + 'status' => 0, + ), + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 0, + ), + ); + + // Exported field_instance: 'message_type-commons_notify-message_text' + $field_instances['message_type-commons_notify-message_text'] = array( + 'bundle' => 'commons_notify', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => 'This is the text of all messages of this type.', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 0, + ), + ), + 'entity_type' => 'message_type', + 'field_name' => 'message_text', + 'label' => 'Message text', + 'required' => TRUE, + 'settings' => array( + 'text_processing' => 1, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'module' => 'text', + 'settings' => array( + 'rows' => 5, + ), + 'type' => 'text_textarea', + 'weight' => 0, + ), + ); + + // Exported field_instance: 'user-user-message_subscribe_email' + $field_instances['user-user-message_subscribe_email'] = array( + 'bundle' => 'user', + 'default_value' => array( + 0 => array( + 'value' => 1, + ), + ), + 'deleted' => 0, + 'description' => 'Email option will be checked automatically when subscribing to something.', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'list', + 'settings' => array(), + 'type' => 'list_default', + 'weight' => 9, + ), + ), + 'display_label' => 1, + 'entity_type' => 'user', + 'field_name' => 'message_subscribe_email', + 'label' => 'Email subscriptions', + 'required' => FALSE, + 'settings' => array( + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'module' => 'options', + 'settings' => array( + 'display_label' => 0, + ), + 'type' => 'options_onoff', + 'weight' => 0, + ), + ); + + // Translatables + // Included for use with string extractors like potx. + t('Body'); + t('Email option will be checked automatically when subscribing to something.'); + t('Email subscriptions'); + t('Message text'); + t('Subject'); + t('Target comment'); + t('Target nodes'); + t('This is the text of all messages of this type.'); + + return $field_instances; +} diff --git a/modules/commons/commons_notify/commons_notify.features.inc b/modules/commons/commons_notify/commons_notify.features.inc new file mode 100644 index 0000000..529cbef --- /dev/null +++ b/modules/commons/commons_notify/commons_notify.features.inc @@ -0,0 +1,135 @@ + "1"); + } +} + +/** + * Implements hook_default_message_type(). + */ +function commons_notify_default_message_type() { + $items = array(); + $items['commons_notify_comment_created'] = entity_import('message_type', '{ + "name" : "commons_notify_comment_created", + "description" : "Commons Notify: Comment created", + "argument_keys" : [], + "argument" : [], + "category" : "commons_notify", + "data" : { "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" } }, + "language" : "", + "arguments" : null, + "message_text" : { "und" : [ + { + "value" : "New comment on [message:field-target-nodes:0:title_field] in [message:field-target-nodes:0:og-group-ref:0:title]: [message:field-target-nodes:0:title_field]", + "format" : "plain_text", + "safe_value" : "\\u003Cp\\u003ENew comment on [message:field-target-nodes:0:title_field] in [message:field-target-nodes:0:og-group-ref:0:title]: [message:field-target-nodes:0:title_field]\\u003C\\/p\\u003E\\n" + }, + { + "value" : "Hi [message:user:name],\\r\\n\\r\\n[message:field-target-comments:0:author] commented on [message:field-target-nodes:0:title_field] [commons-groups:in-groups-text]:\\r\\n\\r\\n[message:field-target-comments:0:body]\\r\\n\\r\\nRead \\u0026 respond: [message:field-target-comments:0:url]\\r\\nUpdate your notification settings: [site:url]\\/user\\/[message:user:uid]\\/notification-settings", + "format" : "plain_text", + "safe_value" : "\\u003Cp\\u003EHi [message:user:name],\\u003C\\/p\\u003E\\n\\u003Cp\\u003E[message:field-target-comments:0:author] commented on [message:field-target-nodes:0:title_field] [commons-groups:in-groups-text]:\\u003C\\/p\\u003E\\n\\u003Cp\\u003E[message:field-target-comments:0:body]\\u003C\\/p\\u003E\\n\\u003Cp\\u003ERead \\u0026amp; respond: [message:field-target-comments:0:url]\\u003Cbr \\/\\u003E\\nUpdate your notification settings: [site:url]\\/user\\/[message:user:uid]\\/notification-settings\\u003C\\/p\\u003E\\n" + } + ] + }, + "rdf_mapping" : [] + }'); + $items['commons_notify_comment_created_no_groups'] = entity_import('message_type', '{ + "name" : "commons_notify_comment_created_no_groups", + "description" : "Commons Notify: Comment created no groups", + "argument_keys" : [], + "argument" : [], + "category" : "commons_notify", + "data" : { + "token options" : { "clear" : 0 }, + "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" } + }, + "language" : "", + "arguments" : null, + "message_text" : { "und" : [ + { + "value" : "New comment on [message:field-target-nodes:0:title_field] ", + "format" : "plain_text", + "safe_value" : "\\u003Cp\\u003ENew comment on [message:field-target-nodes:0:title_field]\\u003C\\/p\\u003E\\n" + }, + { + "value" : "Hi [message:user:name],\\r\\n\\r\\n[message:field-target-comments:0:author] commented on [message:field-target-nodes:0:title_field]:\\r\\n\\r\\n[message:field-target-comments:0:body]\\r\\n\\r\\nRead \\u0026 respond: [message:field-target-comments:0:url]\\r\\nUpdate your notification settings: [site:url]\\/notification-settings", + "format" : "plain_text", + "safe_value" : "\\u003Cp\\u003EHi [message:user:name],\\u003C\\/p\\u003E\\n\\u003Cp\\u003E[message:field-target-comments:0:author] commented on [message:field-target-nodes:0:title_field]:\\u003C\\/p\\u003E\\n\\u003Cp\\u003E[message:field-target-comments:0:body]\\u003C\\/p\\u003E\\n\\u003Cp\\u003ERead \\u0026amp; respond: [message:field-target-comments:0:url]\\u003Cbr \\/\\u003E\\nUpdate your notification settings: [site:url]\\/notification-settings\\u003C\\/p\\u003E\\n" + } + ] + }, + "rdf_mapping" : [] + }'); + $items['commons_notify_node_created'] = entity_import('message_type', '{ + "name" : "commons_notify_node_created", + "description" : "The notification sent when a user creates a node.", + "argument_keys" : [], + "argument" : [], + "category" : "commons_notify", + "data" : { "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" } }, + "language" : "", + "arguments" : null, + "message_text" : { "und" : [ + { + "value" : "New [message:field-target-nodes:0:content-type] in [message:field-target-nodes:0:og-group-ref:0:title]: [message:field-target-nodes:0:title_field]", + "format" : "plain_text", + "safe_value" : "\\u003Cp\\u003ENew [message:field-target-nodes:0:content-type] in [message:field-target-nodes:0:og-group-ref:0:title]: [message:field-target-nodes:0:title_field]\\u003C\\/p\\u003E\\n" + }, + { + "value" : "Hi [message:user:name],\\r\\n\\r\\n[message:field-target-nodes:0:author] created the [message:field-target-nodes:0:content-type] \\u201c[message:field-target-nodes:0:title_field]\\u201d on [site:name] [commons-groups:in-groups-text] on [message:field-target-nodes:0:created]:\\r\\n\\r\\n[message:field-target-nodes:0:body]\\r\\n\\r\\n\\r\\nPermalink: [message:field-target-nodes:0:url]\\r\\nAdd a comment at [message:field-target-nodes:0:url]#comment-form\\r\\n\\r\\nChange email notifications at [site:url]user\\/[message:user:uid]\\/notification-settings", + "format" : "plain_text", + "safe_value" : "\\u003Cp\\u003EHi [message:user:name],\\u003C\\/p\\u003E\\n\\u003Cp\\u003E[message:field-target-nodes:0:author] created the [message:field-target-nodes:0:content-type] \\u201c[message:field-target-nodes:0:title_field]\\u201d on [site:name] [commons-groups:in-groups-text] on [message:field-target-nodes:0:created]:\\u003C\\/p\\u003E\\n\\u003Cp\\u003E[message:field-target-nodes:0:body]\\u003C\\/p\\u003E\\n\\u003Cp\\u003EPermalink: [message:field-target-nodes:0:url]\\u003Cbr \\/\\u003E\\nAdd a comment at [message:field-target-nodes:0:url]#comment-form\\u003C\\/p\\u003E\\n\\u003Cp\\u003EChange email notifications at [site:url]user\\/[message:user:uid]\\/notification-settings\\u003C\\/p\\u003E\\n" + } + ] + }, + "rdf_mapping" : [] + }'); + $items['commons_notify_node_created_no_groups'] = entity_import('message_type', '{ + "name" : "commons_notify_node_created_no_groups", + "description" : "The notification sent when a user creates a node that is not in any groups", + "argument_keys" : [], + "argument" : [], + "category" : "commons_notify", + "data" : { "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" } }, + "language" : "", + "arguments" : null, + "message_text" : { "und" : [ + { + "value" : "New [message:field-target-nodes:0:content-type] on [site:name]: [message:field-target-nodes:0:title_field]", + "format" : "plain_text", + "safe_value" : "\\u003Cp\\u003ENew [message:field-target-nodes:0:content-type] on [site:name]: [message:field-target-nodes:0:title_field]\\u003C\\/p\\u003E\\n" + }, + { + "value" : "Hi [message:user:name],\\r\\n\\r\\n[message:field-target-nodes:0:author] created the [message:field-target-nodes:0:content-type] \\u201c[message:field-target-nodes:0:title_field]\\u201d on [site:name] [commons-groups:in-groups-text] on [message:field-target-nodes:0:created]:\\r\\n\\r\\n[message:field-target-nodes:0:body]\\r\\n\\r\\n\\r\\nPermalink: [message:field-target-nodes:0:url]\\r\\nAdd a comment at [message:field-target-nodes:0:url]#comment-form\\r\\n\\r\\nChange email notifications at [site:url]user\\/[message:user:uid]\\/notification-settings", + "format" : "plain_text", + "safe_value" : "\\u003Cp\\u003EHi [message:user:name],\\u003C\\/p\\u003E\\n\\u003Cp\\u003E[message:field-target-nodes:0:author] created the [message:field-target-nodes:0:content-type] \\u201c[message:field-target-nodes:0:title_field]\\u201d on [site:name] [commons-groups:in-groups-text] on [message:field-target-nodes:0:created]:\\u003C\\/p\\u003E\\n\\u003Cp\\u003E[message:field-target-nodes:0:body]\\u003C\\/p\\u003E\\n\\u003Cp\\u003EPermalink: [message:field-target-nodes:0:url]\\u003Cbr \\/\\u003E\\nAdd a comment at [message:field-target-nodes:0:url]#comment-form\\u003C\\/p\\u003E\\n\\u003Cp\\u003EChange email notifications at [site:url]user\\/[message:user:uid]\\/notification-settings\\u003C\\/p\\u003E\\n" + } + ] + }, + "rdf_mapping" : [] + }'); + return $items; +} + +/** + * Implements hook_default_message_type_category(). + */ +function commons_notify_default_message_type_category() { + $items = array(); + $items['commons_notify'] = entity_import('message_type_category', '{ + "category" : "commons_notify", + "description" : "Commons Notify", + "language" : "und", + "rdf_mapping" : [] + }'); + return $items; +} diff --git a/modules/commons/commons_notify/commons_notify.info b/modules/commons/commons_notify/commons_notify.info new file mode 100644 index 0000000..1e5688a --- /dev/null +++ b/modules/commons/commons_notify/commons_notify.info @@ -0,0 +1,50 @@ +name = Commons Notify +core = 7.x +package = Commons - Building blocks +dependencies[] = commons_follow +dependencies[] = ctools +dependencies[] = entity +dependencies[] = entityreference +dependencies[] = features +dependencies[] = list +dependencies[] = message +dependencies[] = message_subscribe +dependencies[] = message_subscribe_email +dependencies[] = number +dependencies[] = options +dependencies[] = strongarm +dependencies[] = text +features[ctools][] = strongarm:strongarm:1 +features[features_api][] = api:2 +features[field_base][] = field_message_rendered_body +features[field_base][] = field_message_rendered_subject +features[field_base][] = message_subscribe_email +features[field_instance][] = message-commons_notify_comment_created-field_message_rendered_body +features[field_instance][] = message-commons_notify_comment_created-field_message_rendered_subject +features[field_instance][] = message-commons_notify_comment_created-field_target_comments +features[field_instance][] = message-commons_notify_comment_created-field_target_nodes +features[field_instance][] = message-commons_notify_comment_created_no_groups-field_message_rendered_body +features[field_instance][] = message-commons_notify_comment_created_no_groups-field_message_rendered_subject +features[field_instance][] = message-commons_notify_comment_created_no_groups-field_target_comments +features[field_instance][] = message-commons_notify_comment_created_no_groups-field_target_nodes +features[field_instance][] = message-commons_notify_node_created-field_message_rendered_body +features[field_instance][] = message-commons_notify_node_created-field_message_rendered_subject +features[field_instance][] = message-commons_notify_node_created-field_target_nodes +features[field_instance][] = message-commons_notify_node_created_no_groups-field_message_rendered_body +features[field_instance][] = message-commons_notify_node_created_no_groups-field_message_rendered_subject +features[field_instance][] = message-commons_notify_node_created_no_groups-field_target_nodes +features[field_instance][] = message_type-commons_notify-message_text +features[field_instance][] = user-user-message_subscribe_email +features[message_type][] = commons_notify_comment_created +features[message_type][] = commons_notify_comment_created_no_groups +features[message_type][] = commons_notify_node_created +features[message_type][] = commons_notify_node_created_no_groups +features[message_type_category][] = commons_notify +features[variable][] = field_bundle_settings_message__commons_notify_comment_created +features[variable][] = field_bundle_settings_message__commons_notify_comment_created_no_groups +features[variable][] = field_bundle_settings_message__commons_notify_node_created +features[variable][] = field_bundle_settings_message__commons_notify_node_created_no_groups +features[variable][] = message_subscribe_default_notifiers +features_exclude[field_base][message_text] = message_text +features_exclude[field_base][field_target_nodes] = field_target_nodes +features_exclude[field_base][field_target_comments] = field_target_comments diff --git a/modules/commons/commons_notify/commons_notify.install b/modules/commons/commons_notify/commons_notify.install new file mode 100644 index 0000000..ba5b31a --- /dev/null +++ b/modules/commons/commons_notify/commons_notify.install @@ -0,0 +1,33 @@ + array('field_base', 'field_instance'))); + return array(); +} + +/** + * Ensure that users' email subscription preferences are honored. + */ +function commons_notify_update_7302() { + features_revert(array('commons_notify' => array('variable'))); + return array(); +} + +/** + * Correct the user notification settings URL. + */ +function commons_notify_update_7303() { + features_revert(array('commons_notify' => array('message_type'))); + return array(); +} + +/** + * Add message notify for comments that have no group. + */ +function commons_notify_update_7304() { + features_revert(array('commons_notify' => array('message_type'))); + return array(); +} diff --git a/modules/commons/commons_notify/commons_notify.module b/modules/commons/commons_notify/commons_notify.module new file mode 100644 index 0000000..2cfcc7d --- /dev/null +++ b/modules/commons/commons_notify/commons_notify.module @@ -0,0 +1,103 @@ +resetCache(array($node->nid)); + if (!isset($node->og_group_ref[LANGUAGE_NONE][0]['target_id'])) { + $message_type = 'commons_notify_node_created_no_groups'; + } + // Allow other modules to specify an alternative messagge type to use. + $hook = 'node_insert'; + drupal_alter('commons_notify_message_selection', $message_type, $hook, $node); + $account = user_load($node->uid); + $message = message_create($message_type, array('uid' => $account->uid, 'timestamp' => $node->created)); + // Save reference to the node in the node reference field. + $wrapper = entity_metadata_wrapper('message', $message); + // We use a multiple value field in case we wish to use the same + // field for grouping messages in the future + // (eg http://drupal.org/node/1757060). + $wrapper->field_target_nodes[] = $node; + $wrapper->save(); + $options = array( + 'rendered fields' => array( + 'message_notify_email_subject' => 'field_message_rendered_subject', + 'message_notify_email_body' => 'field_message_rendered_body', + ), + ); + message_subscribe_send_message('node', $node, $message, array('email' => $options)); +} + +/** + * Implements hook_comment_insert(). + */ +function commons_notify_comment_insert($comment) { + $account = user_load($comment->uid); + $node = node_load($comment->nid); + $message_type = 'commons_notify_comment_created'; + $hook = 'comment_insert'; + if (!isset($node->og_group_ref[LANGUAGE_NONE][0]['target_id'])) { + $message_type = 'commons_notify_comment_created_no_groups'; + } + drupal_alter('commons_notify_message_selection', $message_type, $hook, $comment); + $message = message_create($message_type, array('uid' => $account->uid, 'timestamp' => $comment->created)); + // Save reference to the node in the node reference field, and the + // "publish" state (i.e. if the node is published or unpublished). + $wrapper = entity_metadata_wrapper('message', $message); + $wrapper->field_target_nodes[] = $node; + $wrapper->field_target_comments[] = $comment; + + // The message should be published only if the node and the comment are + // both published. + // @todo: Deal with message publishing/unpublishing. + /* + $published = $node->status && $comment->status; + $wrapper->field_published->set($published); + */ + $wrapper->save(); + $options = array( + 'rendered fields' => array( + 'message_notify_email_subject' => 'field_message_rendered_subject', + 'message_notify_email_body' => 'field_message_rendered_body', + ), + ); + message_subscribe_send_message('comment', $comment, $message, array('email' => $options)); +} diff --git a/modules/commons/commons_notify/commons_notify.strongarm.inc b/modules/commons/commons_notify/commons_notify.strongarm.inc new file mode 100644 index 0000000..7908a70 --- /dev/null +++ b/modules/commons/commons_notify/commons_notify.strongarm.inc @@ -0,0 +1,157 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_message__commons_notify_comment_created'; + $strongarm->value = array( + 'view_modes' => array(), + 'extra_fields' => array( + 'form' => array(), + 'display' => array( + 'message__message_text__0' => array( + 'message_notify_email_subject' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + ), + 'message__message_text__1' => array( + 'message_notify_email_subject' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + ), + ), + ), + ); + $export['field_bundle_settings_message__commons_notify_comment_created'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_message__commons_notify_comment_created_no_groups'; + $strongarm->value = array( + 'view_modes' => array(), + 'extra_fields' => array( + 'form' => array(), + 'display' => array( + 'message__message_text__0' => array( + 'message_notify_email_subject' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + ), + 'message__message_text__1' => array( + 'message_notify_email_subject' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + ), + ), + ), + ); + $export['field_bundle_settings_message__commons_notify_comment_created_no_groups'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_message__commons_notify_node_created'; + $strongarm->value = array( + 'view_modes' => array(), + 'extra_fields' => array( + 'form' => array(), + 'display' => array( + 'message__message_text__0' => array( + 'message_notify_email_subject' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + ), + 'message__message_text__1' => array( + 'message_notify_email_subject' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + ), + ), + ), + ); + $export['field_bundle_settings_message__commons_notify_node_created'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_message__commons_notify_node_created_no_groups'; + $strongarm->value = array( + 'view_modes' => array(), + 'extra_fields' => array( + 'form' => array(), + 'display' => array( + 'message__message_text__0' => array( + 'message_notify_email_subject' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + ), + 'message__message_text__1' => array( + 'message_notify_email_subject' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + ), + ), + ), + ); + $export['field_bundle_settings_message__commons_notify_node_created_no_groups'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'message_subscribe_default_notifiers'; + $strongarm->value = array(); + $export['message_subscribe_default_notifiers'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_pages/commons_pages.features.field_instance.inc b/modules/commons/commons_pages/commons_pages.features.field_instance.inc new file mode 100644 index 0000000..2caa003 --- /dev/null +++ b/modules/commons/commons_pages/commons_pages.features.field_instance.inc @@ -0,0 +1,62 @@ + 'page', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 0, + ), + 'teaser' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array( + 'trim_length' => 600, + ), + 'type' => 'text_summary_or_trimmed', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'body', + 'label' => 'Body', + 'required' => FALSE, + 'settings' => array( + 'display_summary' => FALSE, + 'text_processing' => 1, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'module' => 'text', + 'settings' => array( + 'rows' => 20, + 'summary_rows' => 5, + ), + 'type' => 'text_textarea_with_summary', + 'weight' => -4, + ), + ); + + // Translatables + // Included for use with string extractors like potx. + t('Body'); + + return $field_instances; +} diff --git a/modules/commons/commons_pages/commons_pages.features.inc b/modules/commons/commons_pages/commons_pages.features.inc new file mode 100644 index 0000000..a5472aa --- /dev/null +++ b/modules/commons/commons_pages/commons_pages.features.inc @@ -0,0 +1,31 @@ + "1"); + } +} + +/** + * Implements hook_node_info(). + */ +function commons_pages_node_info() { + $items = array( + 'page' => array( + 'name' => t('Page'), + 'base' => 'node_content', + 'description' => t('Use basic pages for your static content, such as an \'About us\' page.'), + 'has_title' => '1', + 'title_label' => t('Title'), + 'help' => '', + ), + ); + return $items; +} diff --git a/modules/commons/commons_pages/commons_pages.info b/modules/commons/commons_pages/commons_pages.info new file mode 100644 index 0000000..432107d --- /dev/null +++ b/modules/commons/commons_pages/commons_pages.info @@ -0,0 +1,27 @@ +name = Commons Pages +core = 7.x +package = Commons - Content types +dependencies[] = commons_body +dependencies[] = commons_bw +dependencies[] = ctools +dependencies[] = features +dependencies[] = node +dependencies[] = strongarm +dependencies[] = text +features[ctools][] = strongarm:strongarm:1 +features[features_api][] = api:2 +features[field_instance][] = node-page-body +features[node][] = page +features[variable][] = comment_anonymous_page +features[variable][] = comment_default_mode_page +features[variable][] = comment_default_per_page_page +features[variable][] = comment_form_location_page +features[variable][] = comment_page +features[variable][] = comment_preview_page +features[variable][] = comment_subject_field_page +features[variable][] = menu_options_page +features[variable][] = menu_parent_page +features[variable][] = node_options_page +features[variable][] = node_preview_page +features[variable][] = node_submitted_page +features[variable][] = pathauto_node_page_pattern diff --git a/modules/commons/commons_pages/commons_pages.install b/modules/commons/commons_pages/commons_pages.install new file mode 100644 index 0000000..2a9a148 --- /dev/null +++ b/modules/commons/commons_pages/commons_pages.install @@ -0,0 +1,12 @@ + array('field_instance'), + ); + features_revert($revert); + return array(); +} \ No newline at end of file diff --git a/modules/commons/commons_pages/commons_pages.module b/modules/commons/commons_pages/commons_pages.module new file mode 100644 index 0000000..483d145 --- /dev/null +++ b/modules/commons/commons_pages/commons_pages.module @@ -0,0 +1,31 @@ +value)) { + foreach($items['rate_widgets']->value as $key => $widget) { + if ($widget->name == 'commons_like') { + if (!in_array('document', $items['rate_widgets']->value[$key]->node_types)) { + $items['rate_widgets']->value[$key]->node_types[] = 'page'; + } + if (!in_array('document', $items['rate_widgets']->value[$key]->comment_types)) { + $items['rate_widgets']->value[$key]->comment_types[] = 'page'; + } + } + } + } + // Expose the Page content type for integration with Commons Groups. + if (isset($items['commons_groups_entity_types'])) { + $items['commons_groups_entity_types']->value['node']['page'] = 1; + } +} diff --git a/modules/commons/commons_pages/commons_pages.strongarm.inc b/modules/commons/commons_pages/commons_pages.strongarm.inc new file mode 100644 index 0000000..5a33e76 --- /dev/null +++ b/modules/commons/commons_pages/commons_pages.strongarm.inc @@ -0,0 +1,109 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_anonymous_page'; + $strongarm->value = 0; + $export['comment_anonymous_page'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_mode_page'; + $strongarm->value = 1; + $export['comment_default_mode_page'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_per_page_page'; + $strongarm->value = '50'; + $export['comment_default_per_page_page'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_form_location_page'; + $strongarm->value = 1; + $export['comment_form_location_page'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_page'; + $strongarm->value = '0'; + $export['comment_page'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_preview_page'; + $strongarm->value = '1'; + $export['comment_preview_page'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_subject_field_page'; + $strongarm->value = 1; + $export['comment_subject_field_page'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_options_page'; + $strongarm->value = array( + 0 => 'main-menu', + ); + $export['menu_options_page'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_parent_page'; + $strongarm->value = 'main-menu:0'; + $export['menu_parent_page'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_options_page'; + $strongarm->value = array( + 0 => 'status', + ); + $export['node_options_page'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_preview_page'; + $strongarm->value = '1'; + $export['node_preview_page'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_submitted_page'; + $strongarm->value = 0; + $export['node_submitted_page'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'pathauto_node_page_pattern'; + $strongarm->value = 'content/[node:title]'; + $export['pathauto_node_page_pattern'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_polls/commons_polls.features.field_instance.inc b/modules/commons/commons_polls/commons_polls.features.field_instance.inc new file mode 100644 index 0000000..9ba1622 --- /dev/null +++ b/modules/commons/commons_polls/commons_polls.features.field_instance.inc @@ -0,0 +1,64 @@ + 'poll', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 2, + ), + 'teaser' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array( + 'trim_length' => 600, + ), + 'type' => 'text_summary_or_trimmed', + 'weight' => 1, + ), + ), + 'display_in_partial_form' => 1, + 'entity_type' => 'node', + 'field_name' => 'body', + 'label' => 'Body', + 'required' => 0, + 'settings' => array( + 'display_summary' => 0, + 'text_processing' => 1, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'rows' => 20, + 'summary_rows' => 5, + ), + 'type' => 'text_textarea_with_summary', + 'weight' => 2, + ), + ); + + // Translatables + // Included for use with string extractors like potx. + t('Body'); + + return $field_instances; +} diff --git a/modules/commons/commons_polls/commons_polls.features.inc b/modules/commons/commons_polls/commons_polls.features.inc new file mode 100644 index 0000000..a8ce91e --- /dev/null +++ b/modules/commons/commons_polls/commons_polls.features.inc @@ -0,0 +1,21 @@ + "1"); + } +} + +/** + * Implements hook_views_api(). + */ +function commons_polls_views_api($module = NULL, $api = NULL) { + return array("api" => "3.0"); +} diff --git a/modules/commons/commons_polls/commons_polls.features.og_features_permission.inc b/modules/commons/commons_polls/commons_polls.features.og_features_permission.inc new file mode 100644 index 0000000..e10f92a --- /dev/null +++ b/modules/commons/commons_polls/commons_polls.features.og_features_permission.inc @@ -0,0 +1,52 @@ + array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + // Exported og permission: 'node:group:delete any poll content' + $permissions['node:group:delete any poll content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + ), + ); + + // Exported og permission: 'node:group:delete own poll content' + $permissions['node:group:delete own poll content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + // Exported og permission: 'node:group:update any poll content' + $permissions['node:group:update any poll content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + ), + ); + + // Exported og permission: 'node:group:update own poll content' + $permissions['node:group:update own poll content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + return $permissions; +} diff --git a/modules/commons/commons_polls/commons_polls.features.user_permission.inc b/modules/commons/commons_polls/commons_polls.features.user_permission.inc new file mode 100644 index 0000000..aa3ee3d --- /dev/null +++ b/modules/commons/commons_polls/commons_polls.features.user_permission.inc @@ -0,0 +1,82 @@ + 'cancel own vote', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'poll', + ); + + // Exported permission: 'create poll content'. + $permissions['create poll content'] = array( + 'name' => 'create poll content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + // Exported permission: 'delete any poll content'. + $permissions['delete any poll content'] = array( + 'name' => 'delete any poll content', + 'roles' => array( + 'administrator' => 'administrator', + ), + 'module' => 'node', + ); + + // Exported permission: 'delete own poll content'. + $permissions['delete own poll content'] = array( + 'name' => 'delete own poll content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + // Exported permission: 'edit any poll content'. + $permissions['edit any poll content'] = array( + 'name' => 'edit any poll content', + 'roles' => array( + 'administrator' => 'administrator', + ), + 'module' => 'node', + ); + + // Exported permission: 'edit own poll content'. + $permissions['edit own poll content'] = array( + 'name' => 'edit own poll content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + // Exported permission: 'vote on polls'. + $permissions['vote on polls'] = array( + 'name' => 'vote on polls', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'poll', + ); + + return $permissions; +} diff --git a/modules/commons/commons_polls/commons_polls.info b/modules/commons/commons_polls/commons_polls.info new file mode 100644 index 0000000..c049736 --- /dev/null +++ b/modules/commons/commons_polls/commons_polls.info @@ -0,0 +1,46 @@ +name = Commons Polls +description = Commons poll content type +core = 7.x +package = Commons - Content types +dependencies[] = commons_body +dependencies[] = commons_topics +dependencies[] = ctools +dependencies[] = entityreference +dependencies[] = features +dependencies[] = og +dependencies[] = og_ui +dependencies[] = poll +dependencies[] = radioactivity +dependencies[] = strongarm +dependencies[] = views +dependencies[] = views_litepager +features[ctools][] = strongarm:strongarm:1 +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[field_instance][] = node-poll-body +features[og_features_permission][] = node:group:create poll content +features[og_features_permission][] = node:group:delete any poll content +features[og_features_permission][] = node:group:delete own poll content +features[og_features_permission][] = node:group:update any poll content +features[og_features_permission][] = node:group:update own poll content +features[user_permission][] = cancel own vote +features[user_permission][] = create poll content +features[user_permission][] = delete any poll content +features[user_permission][] = delete own poll content +features[user_permission][] = edit any poll content +features[user_permission][] = edit own poll content +features[user_permission][] = vote on polls +features[variable][] = comment_anonymous_poll +features[variable][] = comment_default_mode_poll +features[variable][] = comment_default_per_page_poll +features[variable][] = comment_form_location_poll +features[variable][] = comment_poll +features[variable][] = comment_preview_poll +features[variable][] = comment_subject_field_poll +features[variable][] = field_bundle_settings_node__poll +features[variable][] = menu_options_poll +features[variable][] = menu_parent_poll +features[variable][] = node_options_poll +features[variable][] = node_preview_poll +features[variable][] = node_submitted_poll +features[views_view][] = commons_bw_polls diff --git a/modules/commons/commons_polls/commons_polls.install b/modules/commons/commons_polls/commons_polls.install new file mode 100644 index 0000000..661fbef --- /dev/null +++ b/modules/commons/commons_polls/commons_polls.install @@ -0,0 +1,67 @@ + array('field_instance'), + ); + features_revert($revert); + return array(); +} + +/** + * Grant users the ability to vote on polls. + */ +function commons_polls_update_7001() { + $revert = array( + 'commons_polls' => array('user_permission'), + ); + features_revert($revert); + return array(); +} + +/** + * Standardize Browsing Widget views. + */ +function commons_polls_update_7002() { + $revert = array( + 'commons_polls' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Display sticky content at top of lists. + */ +function commons_polls_update_7003() { + $revert = array( + 'commons_polls' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Add links to node teasers in the browsing widget. + */ +function commons_polls_update_7004() { + $revert = array( + 'commons_polls' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Improve the browsing widget empty text. + */ +function commons_polls_update_7005() { + $revert = array( + 'commons_polls' => array('views_view'), + ); + features_revert($revert); + return array(); +} diff --git a/modules/commons/commons_polls/commons_polls.module b/modules/commons/commons_polls/commons_polls.module new file mode 100644 index 0000000..d3f07ee --- /dev/null +++ b/modules/commons/commons_polls/commons_polls.module @@ -0,0 +1,171 @@ + array( + 'poll' => array( + 'media' => TRUE, + 'is_group_content' => TRUE, + ), + ), + ); +} + +/** + * Implements hook_commons_bw_group_widget(). + */ +function commons_polls_commons_bw_group_widget() { + return array( + 'commons_polls' => array( + 'title' => t('Polls'), + 'type' => 'view', + 'vid' => 'commons_bw_polls', + 'display' => 'default', + 'weight' => 10, + 'bundle' => 'poll', + ), + ); +} + +/** +* Implements hook_strongarm_alter(). +*/ + function commons_polls_strongarm_alter(&$items) { + // Expose the poll content type for 'liking' via the Commons_like module + // by altering the configuration for the Rate.module widget that it provides. + if (!empty($items['rate_widgets']->value)) { + foreach($items['rate_widgets']->value as $key => $widget) { + if ($widget->name == 'commons_like') { + if (!in_array('poll', $items['rate_widgets']->value[$key]->node_types)) { + $items['rate_widgets']->value[$key]->node_types[] = 'poll'; + } + if (!in_array('poll', $items['rate_widgets']->value[$key]->comment_types)) { + $items['rate_widgets']->value[$key]->comment_types[] = 'poll'; + } + } + } + } + // Expose the poll content type for integration with Commons Radioactivity + // and Commons Groups. + foreach (array('commons_radioactivity_entity_types', 'commons_groups_entity_types') as $key) { + if (isset($items[$key])) { + $items[$key]->value['node']['poll'] = 1; + } + } +} + +/** + * Implements hook_views_default_views_alter(). + * + * Display polls on the browsing widget main view. + */ +function commons_polls_views_default_views_alter(&$views) { + if (!empty($views['commons_bw_all'])) { + $views['commons_bw_all']->display['default']->display_options['filters']['type']['value']['poll'] = 'poll'; + } +} + +/** + * Implements hook_form_FROM_ID_alter(). + */ +function commons_polls_form_commons_bw_partial_node_form_alter(&$form, &$form_state) { + if (empty($form['#entity']) || $form['#entity']->type != 'poll') { + return; + } + + $language = $form['body']['#language']; + $form['body'][$language][0]['#title_display'] = 'invisible'; + $form['body'][$language][0]['#required'] = TRUE; + $form['body'][$language][0]['#placeholder'] = t('Enter a question, e.g. "What is your favorite color?"'); + $form['body'][$language][0]['#resizable'] = FALSE; + $form['body']['#weight'] = -10; + + // Prepare the form for collapsing. + $form['body']['#attributes']['class'][] = 'trigger-field'; + foreach (array('field_media', 'field_image', 'og_group_ref', 'choice_wrapper', 'actions') as $field) { + if (isset($form[$field])) { + $form[$field]['#attributes']['class'][] = 'hideable-field'; + } + } + + // Add the poll choices widget. + $form['choice_wrapper'] = array( + '#tree' => FALSE, + '#weight' => -4, + '#prefix' => '

      ', + '#suffix' => '
      ', + ); + + // Container for just the poll choices. + $form['choice_wrapper']['choice'] = array( + '#prefix' => '
      ', + '#suffix' => '
      ', + '#theme' => 'poll_choices', + ); + + for ($delta = 0; $delta < 10; $delta++) { + $form['choice_wrapper']['choice'][$delta] = _poll_choice_form($delta, NULL, '', 0, $delta); + + if ($delta >= 2) { + $form['choice_wrapper']['choice'][$delta]['#attributes'] = array('class' => array('hidden')); + } + } + + $form['choice_wrapper']['add_choice'] = array( + '#markup' => '
      ' . t('Add more choices') . '', + ); + + $form['#attached']['js'] = array(drupal_get_path('module', 'commons_polls') . '/js/commons_polls_partial_form.js'); + + $form['actions']['submit']['#value'] = t('Create'); + + $form['#pre_render'][] = 'commons_polls_form_commons_bw_partial_node_form_after_build'; + + // Submit handler to process the choices. + array_unshift($form['#submit'], 'commons_polls_form_commons_bw_partial_node_form_submit'); +} + +/** + * Submit handler. + * Set poll settings on the node. + */ +function commons_polls_form_commons_bw_partial_node_form_submit(&$form, &$form_state) { + $node = $form['#entity']; + $node->choice = $form_state['values']['choice']; + $node->runtime = 0; + $node->active = TRUE; +} + +/** + * After-build call-back. + * See commons_polls_form_commons_bw_partial_node_form_alter(). + */ +function commons_polls_form_commons_bw_partial_node_form_after_build($form) { + $language = $form['body']['#language']; + $form['body'][$language][0]['#pre_render'] = array(); + $form['body'][$language][0]['format']['#access'] = FALSE; + $form['body'][$language][0]['value']['#rows'] = 3; + + return $form; +} + +/** + * Implements hook_views_pre_render(). + */ +function commons_polls_views_pre_render(&$view) { + // Improve the browsing widget empty text when displayed outside of a group. + // TODO: Enable og_context and check group context instead of looking for an + // empty first argument. + if (empty($view->args[0]) && $view->name == 'commons_bw_polls') { + $view->display_handler->handlers['empty']['area']->options['content'] = t('No polls have been created.'); + } +} diff --git a/modules/commons/commons_polls/commons_polls.strongarm.inc b/modules/commons/commons_polls/commons_polls.strongarm.inc new file mode 100644 index 0000000..37d558f --- /dev/null +++ b/modules/commons/commons_polls/commons_polls.strongarm.inc @@ -0,0 +1,120 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_anonymous_poll'; + $strongarm->value = 0; + $export['comment_anonymous_poll'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_mode_poll'; + $strongarm->value = 1; + $export['comment_default_mode_poll'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_per_page_poll'; + $strongarm->value = '50'; + $export['comment_default_per_page_poll'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_form_location_poll'; + $strongarm->value = 1; + $export['comment_form_location_poll'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_poll'; + $strongarm->value = '2'; + $export['comment_poll'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_preview_poll'; + $strongarm->value = '1'; + $export['comment_preview_poll'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_subject_field_poll'; + $strongarm->value = 1; + $export['comment_subject_field_poll'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_node__poll'; + $strongarm->value = array( + 'view_modes' => array(), + 'extra_fields' => array( + 'form' => array( + 'title' => array( + 'weight' => '-5', + ), + ), + 'display' => array(), + ), + ); + $export['field_bundle_settings_node__poll'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_options_poll'; + $strongarm->value = array( + 0 => 'main-menu', + ); + $export['menu_options_poll'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_parent_poll'; + $strongarm->value = 'main-menu:0'; + $export['menu_parent_poll'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_options_poll'; + $strongarm->value = array( + 0 => 'status', + 1 => 'revision', + ); + $export['node_options_poll'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_preview_poll'; + $strongarm->value = '1'; + $export['node_preview_poll'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_submitted_poll'; + $strongarm->value = 1; + $export['node_submitted_poll'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_polls/commons_polls.views_default.inc b/modules/commons/commons_polls/commons_polls.views_default.inc new file mode 100644 index 0000000..fdc0e3f --- /dev/null +++ b/modules/commons/commons_polls/commons_polls.views_default.inc @@ -0,0 +1,133 @@ +name = 'commons_bw_polls'; + $view->description = 'Commons Polls listing for the group browsing widget.'; + $view->tag = 'Commons Polls, Commons Browsing Widget'; + $view->base_table = 'node'; + $view->human_name = 'Commons Browsing Widget - Polls'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_ajax'] = TRUE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['query']['options']['query_comment'] = FALSE; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'lite'; + $handler->display->display_options['pager']['options']['items_per_page'] = '10'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '6'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'node'; + /* Header: Global: Node partial form */ + $handler->display->display_options['header']['commons_bw_node_partial_form']['id'] = 'commons_bw_node_partial_form'; + $handler->display->display_options['header']['commons_bw_node_partial_form']['table'] = 'views'; + $handler->display->display_options['header']['commons_bw_node_partial_form']['field'] = 'commons_bw_node_partial_form'; + $handler->display->display_options['header']['commons_bw_node_partial_form']['bundle'] = 'poll'; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'No polls have been added to this group.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: OG membership: OG membership from Node */ + $handler->display->display_options['relationships']['og_membership_rel']['id'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['table'] = 'node'; + $handler->display->display_options['relationships']['og_membership_rel']['field'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['required'] = TRUE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Content: Sticky */ + $handler->display->display_options['sorts']['sticky']['id'] = 'sticky'; + $handler->display->display_options['sorts']['sticky']['table'] = 'node'; + $handler->display->display_options['sorts']['sticky']['field'] = 'sticky'; + $handler->display->display_options['sorts']['sticky']['order'] = 'DESC'; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + $handler->display->display_options['sorts']['created']['exposed'] = TRUE; + $handler->display->display_options['sorts']['created']['expose']['label'] = 'most recent'; + /* Contextual filter: OG membership: Group ID */ + $handler->display->display_options['arguments']['gid']['id'] = 'gid'; + $handler->display->display_options['arguments']['gid']['table'] = 'og_membership'; + $handler->display->display_options['arguments']['gid']['field'] = 'gid'; + $handler->display->display_options['arguments']['gid']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['arguments']['gid']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['gid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['gid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['gid']['summary_options']['items_per_page'] = '25'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'node'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['value'] = array( + 'poll' => 'poll', + ); + /* Filter criterion: OG membership: Group_type */ + $handler->display->display_options['filters']['group_type']['id'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['table'] = 'og_membership'; + $handler->display->display_options['filters']['group_type']['field'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['filters']['group_type']['value'] = array( + 'node' => 'node', + ); + $translatables['commons_bw_polls'] = array( + t('Master'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('No polls have been added to this group.'), + t('OG membership from node'), + t('following'), + t('most recent'), + t('most active'), + t('All'), + t('Following'), + ); + + $export['commons_bw_polls'] = $view; + + return $export; +} diff --git a/modules/commons/commons_polls/js/commons_polls_partial_form.js b/modules/commons/commons_polls/js/commons_polls_partial_form.js new file mode 100644 index 0000000..968225c --- /dev/null +++ b/modules/commons/commons_polls/js/commons_polls_partial_form.js @@ -0,0 +1,19 @@ +(function ($) { + + // Handle the "Add more choices" link on the partial poll node form. + Drupal.behaviors.commons_polls_partial_form = { + attach: function(context) { + $('#add-choice').click(function(event) { + event.preventDefault(); + var $hiddenRows = $('#poll-choice-table tr.hidden', context); + // Remove the add choices link when revealing the last available row. + if ($hiddenRows.length == 1) { + this.remove(); + } + // Reveal the first hidden choice. + $hiddenRows.first().show('fast').removeClass('hidden'); + }); + } + } + +})(jQuery); diff --git a/modules/commons/commons_posts/commons_posts.features.field_instance.inc b/modules/commons/commons_posts/commons_posts.features.field_instance.inc new file mode 100644 index 0000000..66591ac --- /dev/null +++ b/modules/commons/commons_posts/commons_posts.features.field_instance.inc @@ -0,0 +1,117 @@ + 'commons_posts_post_created', + 'default_value' => NULL, + 'default_value_function' => '', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_target_nodes', + 'label' => 'Target nodes', + 'required' => 1, + 'settings' => array( + 'behaviors' => array( + 'prepopulate' => array( + 'status' => 0, + ), + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 2, + ), + ); + + // Exported field_instance: 'node-post-body' + $field_instances['node-post-body'] = array( + 'bundle' => 'post', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 2, + ), + 'teaser' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array( + 'trim_length' => 600, + ), + 'type' => 'text_summary_or_trimmed', + 'weight' => 1, + ), + ), + 'display_in_partial_form' => 1, + 'entity_type' => 'node', + 'field_name' => 'body', + 'label' => 'Body', + 'required' => 0, + 'settings' => array( + 'display_summary' => 0, + 'text_processing' => 1, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'rows' => 20, + 'summary_rows' => 5, + ), + 'type' => 'text_textarea_with_summary', + 'weight' => 2, + ), + ); + + // Translatables + // Included for use with string extractors like potx. + t('Body'); + t('Target nodes'); + + return $field_instances; +} diff --git a/modules/commons/commons_posts/commons_posts.features.inc b/modules/commons/commons_posts/commons_posts.features.inc new file mode 100644 index 0000000..46180d3 --- /dev/null +++ b/modules/commons/commons_posts/commons_posts.features.inc @@ -0,0 +1,75 @@ + "1"); + } +} + +/** + * Implements hook_views_api(). + */ +function commons_posts_views_api($module = NULL, $api = NULL) { + return array("api" => "3.0"); +} + +/** + * Implements hook_default_message_type(). + */ +function commons_posts_default_message_type() { + $items = array(); + $items['commons_posts_post_created'] = entity_import('message_type', '{ + "name" : "commons_posts_post_created", + "description" : "Commons Posts - Post Created", + "argument_keys" : [], + "argument" : [], + "category" : "message_type", + "data" : { "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" } }, + "language" : "", + "arguments" : null, + "message_text" : { "und" : [ + { + "value" : "[message:user:picture:35x35]", + "format" : "filtered_html", + "safe_value" : "[message:user:picture:35x35]" + }, + { + "value" : "\\u003Ca href=\\u0022[message:user:url:absolute]\\u0022\\u003E[message:user:name]\\u003C\\/a\\u003E posted \\u003Ca href=\\u0022[message:field-target-nodes:0:url]\\u0022\\u003E[message:field-target-nodes:0:title_field]\\u003C\\/a\\u003E", + "format" : "full_html", + "safe_value" : "\\u003Ca href=\\u0022[message:user:url:absolute]\\u0022\\u003E[message:user:name]\\u003C\\/a\\u003E posted \\u003Ca href=\\u0022[message:field-target-nodes:0:url]\\u0022\\u003E[message:field-target-nodes:0:title_field]\\u003C\\/a\\u003E" + }, + { + "value" : "[commons-groups:in-groups-text]", + "format" : "filtered_html", + "safe_value" : "[commons-groups:in-groups-text]" + } + ] + }, + "rdf_mapping" : [] + }'); + return $items; +} + +/** + * Implements hook_node_info(). + */ +function commons_posts_node_info() { + $items = array( + 'post' => array( + 'name' => t('Post'), + 'base' => 'node_content', + 'description' => t('Start a conversation or share some information.'), + 'has_title' => '1', + 'title_label' => t('Title'), + 'help' => '', + ), + ); + return $items; +} diff --git a/modules/commons/commons_posts/commons_posts.features.og_features_permission.inc b/modules/commons/commons_posts/commons_posts.features.og_features_permission.inc new file mode 100644 index 0000000..932956b --- /dev/null +++ b/modules/commons/commons_posts/commons_posts.features.og_features_permission.inc @@ -0,0 +1,52 @@ + array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + // Exported og permission: 'node:group:delete any post content' + $permissions['node:group:delete any post content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + ), + ); + + // Exported og permission: 'node:group:delete own post content' + $permissions['node:group:delete own post content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + // Exported og permission: 'node:group:update any post content' + $permissions['node:group:update any post content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + ), + ); + + // Exported og permission: 'node:group:update own post content' + $permissions['node:group:update own post content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + return $permissions; +} diff --git a/modules/commons/commons_posts/commons_posts.features.user_permission.inc b/modules/commons/commons_posts/commons_posts.features.user_permission.inc new file mode 100644 index 0000000..f3eccb2 --- /dev/null +++ b/modules/commons/commons_posts/commons_posts.features.user_permission.inc @@ -0,0 +1,62 @@ + 'create post content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + // Exported permission: 'delete any post content'. + $permissions['delete any post content'] = array( + 'name' => 'delete any post content', + 'roles' => array( + 'administrator' => 'administrator', + ), + 'module' => 'node', + ); + + // Exported permission: 'delete own post content'. + $permissions['delete own post content'] = array( + 'name' => 'delete own post content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + // Exported permission: 'edit any post content'. + $permissions['edit any post content'] = array( + 'name' => 'edit any post content', + 'roles' => array( + 'administrator' => 'administrator', + ), + 'module' => 'node', + ); + + // Exported permission: 'edit own post content'. + $permissions['edit own post content'] = array( + 'name' => 'edit own post content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + return $permissions; +} diff --git a/modules/commons/commons_posts/commons_posts.info b/modules/commons/commons_posts/commons_posts.info new file mode 100644 index 0000000..2b84e7c --- /dev/null +++ b/modules/commons/commons_posts/commons_posts.info @@ -0,0 +1,52 @@ +name = Commons Posts +description = Commons Post content type +core = 7.x +package = Commons - Content types +dependencies[] = commons_body +dependencies[] = commons_bw +dependencies[] = commons_topics +dependencies[] = ctools +dependencies[] = entity +dependencies[] = entityreference +dependencies[] = features +dependencies[] = node +dependencies[] = og +dependencies[] = og_ui +dependencies[] = radioactivity +dependencies[] = strongarm +dependencies[] = taxonomy +dependencies[] = text +dependencies[] = views +dependencies[] = views_litepager +features[ctools][] = strongarm:strongarm:1 +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[field_instance][] = message-commons_posts_post_created-field_target_nodes +features[field_instance][] = node-post-body +features[message_type][] = commons_posts_post_created +features[node][] = post +features[og_features_permission][] = node:group:create post content +features[og_features_permission][] = node:group:delete any post content +features[og_features_permission][] = node:group:delete own post content +features[og_features_permission][] = node:group:update any post content +features[og_features_permission][] = node:group:update own post content +features[user_permission][] = create post content +features[user_permission][] = delete any post content +features[user_permission][] = delete own post content +features[user_permission][] = edit any post content +features[user_permission][] = edit own post content +features[variable][] = comment_anonymous_post +features[variable][] = comment_default_mode_post +features[variable][] = comment_default_per_page_post +features[variable][] = comment_form_location_post +features[variable][] = comment_post +features[variable][] = comment_preview_post +features[variable][] = comment_subject_field_post +features[variable][] = field_bundle_settings_message__commons_posts_post_created +features[variable][] = field_bundle_settings_node__post +features[variable][] = menu_options_post +features[variable][] = menu_parent_post +features[variable][] = node_options_post +features[variable][] = node_preview_post +features[variable][] = node_submitted_post +features[views_view][] = commons_bw_posts diff --git a/modules/commons/commons_posts/commons_posts.install b/modules/commons/commons_posts/commons_posts.install new file mode 100644 index 0000000..b39a48c --- /dev/null +++ b/modules/commons/commons_posts/commons_posts.install @@ -0,0 +1,78 @@ + array('field_instance'), + ); + features_revert($revert); + return array(); +} + +/** + * Provide a new "User posted [title]" message type for posts. + */ +function commons_posts_update_7001() { + $revert = array( + 'commons_posts' => array('message_type', 'field_instance'), + ); + features_revert($revert); + return array(); +} + +/** + * Remove extra markup from message type for posts. + */ +function commons_posts_update_7002() { + $revert = array( + 'commons_posts' => array('message_type'), + ); + features_revert($revert); + return array(); +} + +/** + * Standardize Browsing Widget views. + */ +function commons_posts_update_7003() { + $revert = array( + 'commons_posts' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Display sticky content at top of lists. + */ +function commons_posts_update_7004() { + $revert = array( + 'commons_posts' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Add links to node teasers in the browsing widget. + */ +function commons_posts_update_7005() { + $revert = array( + 'commons_posts' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Improve the browsing widget empty text. + */ +function commons_posts_update_7006() { + $revert = array( + 'commons_posts' => array('views_view'), + ); + features_revert($revert); + return array(); +} diff --git a/modules/commons/commons_posts/commons_posts.module b/modules/commons/commons_posts/commons_posts.module new file mode 100644 index 0000000..fe6772f --- /dev/null +++ b/modules/commons/commons_posts/commons_posts.module @@ -0,0 +1,156 @@ + array( + 'post' => array( + 'media' => TRUE, + 'is_group_content' => TRUE, + ), + ), + ); +} + +/** +* Implements hook_commons_bw_group_widget(). +*/ +function commons_posts_commons_bw_group_widget() { + return array( + 'commons_posts' => array( + 'title' => t('Posts'), + 'type' => 'view', + 'vid' => 'commons_bw_posts', + 'display' => 'default', + 'weight' => -1, + 'bundle' => 'post', + ), + ); +} + +/** + * Implements hook_commons_bw_create_all_widget(). + */ +function commons_posts_commons_bw_create_all_widget($group) { + if (og_user_access('node', $group->nid, 'create post content')) { + $link = l(t('Create a post'),'node/add/post', + array('attributes' => array('class' => 'commons-posts-create'), 'query' => array('og_group_ref' => $group->nid)) + ); + return array( + 'commons_posts' => array( + 'default' => TRUE, + 'link' => $link, + 'text' => t('Foster a topic through commenting'), + '#weight' => -1, + ), + ); + } +} + +/** + * Implements hook_form_FROM_ID_alter(). + */ +function commons_posts_form_commons_bw_partial_node_form_alter(&$form, &$form_state) { + if (empty($form['#entity']) || $form['#entity']->type != 'post') { + return; + } + + $language = $form['body']['#language']; + $form['body'][$language][0]['#title_display'] = 'invisible'; + $form['body'][$language][0]['#required'] = TRUE; + $form['body'][$language][0]['#placeholder'] = t("What's on your mind?"); + $form['body'][$language][0]['#resizable'] = FALSE; + + // Set fields as hideable so the forms can be compacted. + $form['body']['#attributes']['class'][] = 'trigger-field'; + foreach (array('field_media', 'field_image', 'og_group_ref', 'choice_wrapper', 'actions') as $field) { + if (isset($form[$field])) { + $form[$field]['#attributes']['class'][] = 'hideable-field'; + } + } + + $form['actions']['submit']['#value'] = t('Post'); + $form['#pre_render'][] = 'commons_posts_form_commons_bw_partial_node_form_after_build'; +} + +/** + * After-build call-back. + * See commons_posts_form_commons_bw_partial_node_form_alter(). + */ +function commons_posts_form_commons_bw_partial_node_form_after_build($form) { + $language = $form['body']['#language']; + $form['body'][$language][0]['#pre_render'] = array(); + $form['body'][$language][0]['format']['#access'] = FALSE; + $form['body'][$language][0]['value']['#rows'] = 3; + + return $form; +} + + +/** + * Implements commons_activity_streams_message_selection_alter(). + */ +function commons_posts_commons_activity_streams_message_selection_alter(&$message_type, $hook, $node) { + // Use a "User posted [title]" format activity stream message. + if ($hook == 'node_insert' && $node->type == 'post') { + $message_type = 'commons_posts_post_created'; + } +} + +/** +* Implements hook_strongarm_alter(). +*/ + function commons_posts_strongarm_alter(&$items) { + // Expose the Post content type for 'liking' via the Commons_like module + // by altering the configuration for the Rate.module widget that it provides. + if (!empty($items['rate_widgets']->value)) { + foreach($items['rate_widgets']->value as $key => $widget) { + if ($widget->name == 'commons_like') { + if (!in_array('post', $items['rate_widgets']->value[$key]->node_types)) { + $items['rate_widgets']->value[$key]->node_types[] = 'post'; + } + if (!in_array('post', $items['rate_widgets']->value[$key]->comment_types)) { + $items['rate_widgets']->value[$key]->comment_types[] = 'post'; + } + } + } + } + // Expose the post content type for integration with Commons Radioactivity + // and Commons Groups. + foreach (array('commons_radioactivity_entity_types', 'commons_groups_entity_types') as $key) { + if (isset($items[$key])) { + $items[$key]->value['node']['post'] = 1; + } + } +} + +/** + * Implements hook_views_default_views_alter(). + * + * Display posts on the browsing widget main view. + */ +function commons_posts_views_default_views_alter(&$views) { + if (!empty($views['commons_bw_all'])) { + $views['commons_bw_all']->display['default']->display_options['filters']['type']['value']['post'] = 'post'; + } +} + +/** + * Implements hook_views_pre_render(). + */ +function commons_posts_views_pre_render(&$view) { + // Improve the browsing widget empty text when displayed outside of a group. + // TODO: Enable og_context and check group context instead of looking for an + // empty first argument. + if (empty($view->args[0]) && $view->name == 'commons_bw_posts') { + $view->display_handler->handlers['empty']['area']->options['content'] = t('No posts have been created.'); + } +} diff --git a/modules/commons/commons_posts/commons_posts.strongarm.inc b/modules/commons/commons_posts/commons_posts.strongarm.inc new file mode 100644 index 0000000..e178963 --- /dev/null +++ b/modules/commons/commons_posts/commons_posts.strongarm.inc @@ -0,0 +1,184 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_anonymous_post'; + $strongarm->value = 0; + $export['comment_anonymous_post'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_mode_post'; + $strongarm->value = 1; + $export['comment_default_mode_post'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_per_page_post'; + $strongarm->value = '50'; + $export['comment_default_per_page_post'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_form_location_post'; + $strongarm->value = 1; + $export['comment_form_location_post'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_post'; + $strongarm->value = '2'; + $export['comment_post'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_preview_post'; + $strongarm->value = '1'; + $export['comment_preview_post'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_subject_field_post'; + $strongarm->value = 1; + $export['comment_subject_field_post'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_message__commons_posts_post_created'; + $strongarm->value = array( + 'view_modes' => array( + 'message_notify_email_subject' => array( + 'custom_settings' => TRUE, + ), + 'message_notify_email_body' => array( + 'custom_settings' => TRUE, + ), + 'full' => array( + 'custom_settings' => FALSE, + ), + 'diff_standard' => array( + 'custom_settings' => FALSE, + ), + 'token' => array( + 'custom_settings' => FALSE, + ), + ), + 'extra_fields' => array( + 'form' => array(), + 'display' => array( + 'message__message_text__0' => array( + 'message_notify_email_subject' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + 'default' => array( + 'weight' => '0', + 'visible' => TRUE, + ), + ), + 'message__message_text__1' => array( + 'message_notify_email_subject' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + 'default' => array( + 'weight' => '1', + 'visible' => TRUE, + ), + ), + 'message__message_text__2' => array( + 'default' => array( + 'weight' => '2', + 'visible' => TRUE, + ), + ), + ), + ), + ); + $export['field_bundle_settings_message__commons_posts_post_created'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_node__post'; + $strongarm->value = array( + 'view_modes' => array(), + 'extra_fields' => array( + 'form' => array( + 'title' => array( + 'weight' => '-5', + ), + ), + 'display' => array(), + ), + ); + $export['field_bundle_settings_node__post'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_options_post'; + $strongarm->value = array( + 0 => 'main-menu', + ); + $export['menu_options_post'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_parent_post'; + $strongarm->value = 'main-menu:0'; + $export['menu_parent_post'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_options_post'; + $strongarm->value = array( + 0 => 'status', + 1 => 'revision', + ); + $export['node_options_post'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_preview_post'; + $strongarm->value = '1'; + $export['node_preview_post'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_submitted_post'; + $strongarm->value = 1; + $export['node_submitted_post'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_posts/commons_posts.views_default.inc b/modules/commons/commons_posts/commons_posts.views_default.inc new file mode 100644 index 0000000..89b786b --- /dev/null +++ b/modules/commons/commons_posts/commons_posts.views_default.inc @@ -0,0 +1,132 @@ +name = 'commons_bw_posts'; + $view->description = 'Commons Posts listing for the group browsing widget.'; + $view->tag = 'Commons Posts, Commons Browsing Widget'; + $view->base_table = 'node'; + $view->human_name = 'Commons Browsing Widget - Posts'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_ajax'] = TRUE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['query']['options']['query_comment'] = FALSE; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'lite'; + $handler->display->display_options['pager']['options']['items_per_page'] = '10'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '2'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'node'; + /* Header: Global: Node partial form */ + $handler->display->display_options['header']['commons_bw_node_partial_form']['id'] = 'commons_bw_node_partial_form'; + $handler->display->display_options['header']['commons_bw_node_partial_form']['table'] = 'views'; + $handler->display->display_options['header']['commons_bw_node_partial_form']['field'] = 'commons_bw_node_partial_form'; + $handler->display->display_options['header']['commons_bw_node_partial_form']['bundle'] = 'post'; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'No posts have been added to this group.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: OG membership: OG membership from Node */ + $handler->display->display_options['relationships']['og_membership_rel']['id'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['table'] = 'node'; + $handler->display->display_options['relationships']['og_membership_rel']['field'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['required'] = TRUE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Content: Sticky */ + $handler->display->display_options['sorts']['sticky']['id'] = 'sticky'; + $handler->display->display_options['sorts']['sticky']['table'] = 'node'; + $handler->display->display_options['sorts']['sticky']['field'] = 'sticky'; + $handler->display->display_options['sorts']['sticky']['order'] = 'DESC'; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + $handler->display->display_options['sorts']['created']['exposed'] = TRUE; + $handler->display->display_options['sorts']['created']['expose']['label'] = 'most recent'; + /* Contextual filter: OG membership: Group ID */ + $handler->display->display_options['arguments']['gid']['id'] = 'gid'; + $handler->display->display_options['arguments']['gid']['table'] = 'og_membership'; + $handler->display->display_options['arguments']['gid']['field'] = 'gid'; + $handler->display->display_options['arguments']['gid']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['arguments']['gid']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['gid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['gid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['gid']['summary_options']['items_per_page'] = '25'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'node'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['value'] = array( + 'post' => 'post', + ); + /* Filter criterion: OG membership: Group_type */ + $handler->display->display_options['filters']['group_type']['id'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['table'] = 'og_membership'; + $handler->display->display_options['filters']['group_type']['field'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['filters']['group_type']['value'] = array( + 'node' => 'node', + ); + $translatables['commons_bw_posts'] = array( + t('Master'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('No posts have been added to this group.'), + t('OG membership from node'), + t('following'), + t('most recent'), + t('most active'), + t('All'), + t('Following'), + ); + $export['commons_bw_posts'] = $view; + + return $export; +} diff --git a/modules/commons/commons_profile_base/commons_profile_base.features.field_base.inc b/modules/commons/commons_profile_base/commons_profile_base.features.field_base.inc new file mode 100644 index 0000000..340ffe8 --- /dev/null +++ b/modules/commons/commons_profile_base/commons_profile_base.features.field_base.inc @@ -0,0 +1,99 @@ + '1', + 'cardinality' => '1', + 'deleted' => '0', + 'entity_types' => array(), + 'field_name' => 'field_bio', + 'foreign keys' => array( + 'format' => array( + 'columns' => array( + 'format' => 'format', + ), + 'table' => 'filter_format', + ), + ), + 'indexes' => array( + 'format' => array( + 0 => 'format', + ), + ), + 'locked' => '0', + 'module' => 'text', + 'settings' => array(), + 'translatable' => '0', + 'type' => 'text_long', + ); + + // Exported field_base: 'field_name_first' + $field_bases['field_name_first'] = array( + 'active' => '1', + 'cardinality' => '1', + 'deleted' => '0', + 'entity_types' => array(), + 'field_name' => 'field_name_first', + 'foreign keys' => array( + 'format' => array( + 'columns' => array( + 'format' => 'format', + ), + 'table' => 'filter_format', + ), + ), + 'indexes' => array( + 'format' => array( + 0 => 'format', + ), + ), + 'locked' => '0', + 'module' => 'text', + 'settings' => array( + 'max_length' => '40', + ), + 'translatable' => '0', + 'type' => 'text', + ); + + // Exported field_base: 'field_name_last' + $field_bases['field_name_last'] = array( + 'active' => '1', + 'cardinality' => '1', + 'deleted' => '0', + 'entity_types' => array(), + 'field_name' => 'field_name_last', + 'foreign keys' => array( + 'format' => array( + 'columns' => array( + 'format' => 'format', + ), + 'table' => 'filter_format', + ), + ), + 'indexes' => array( + 'format' => array( + 0 => 'format', + ), + ), + 'locked' => '0', + 'module' => 'text', + 'settings' => array( + 'max_length' => '80', + ), + 'translatable' => '0', + 'type' => 'text', + ); + + return $field_bases; +} diff --git a/modules/commons/commons_profile_base/commons_profile_base.features.field_instance.inc b/modules/commons/commons_profile_base/commons_profile_base.features.field_instance.inc new file mode 100644 index 0000000..864cfb3 --- /dev/null +++ b/modules/commons/commons_profile_base/commons_profile_base.features.field_instance.inc @@ -0,0 +1,122 @@ + 'user', + 'default_value' => NULL, + 'deleted' => '0', + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 8, + ), + ), + 'entity_type' => 'user', + 'field_name' => 'field_bio', + 'label' => 'Bio', + 'required' => 0, + 'settings' => array( + 'text_processing' => '0', + 'user_register_form' => 0, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'rows' => '5', + ), + 'type' => 'text_textarea', + 'weight' => '5', + ), + ); + + // Exported field_instance: 'user-user-field_name_first' + $field_instances['user-user-field_name_first'] = array( + 'bundle' => 'user', + 'default_value' => NULL, + 'deleted' => '0', + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 2, + ), + ), + 'entity_type' => 'user', + 'field_name' => 'field_name_first', + 'label' => 'First Name', + 'required' => 0, + 'settings' => array( + 'text_processing' => '0', + 'user_register_form' => 1, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'size' => '60', + ), + 'type' => 'text_textfield', + 'weight' => '3', + ), + ); + + // Exported field_instance: 'user-user-field_name_last' + $field_instances['user-user-field_name_last'] = array( + 'bundle' => 'user', + 'default_value' => NULL, + 'deleted' => '0', + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 3, + ), + ), + 'entity_type' => 'user', + 'field_name' => 'field_name_last', + 'label' => 'Last Name', + 'required' => 0, + 'settings' => array( + 'text_processing' => '0', + 'user_register_form' => 1, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'size' => '60', + ), + 'type' => 'text_textfield', + 'weight' => '4', + ), + ); + + // Translatables + // Included for use with string extractors like potx. + t('Bio'); + t('First Name'); + t('Last Name'); + + return $field_instances; +} diff --git a/modules/commons/commons_profile_base/commons_profile_base.features.inc b/modules/commons/commons_profile_base/commons_profile_base.features.inc new file mode 100644 index 0000000..94b5c81 --- /dev/null +++ b/modules/commons/commons_profile_base/commons_profile_base.features.inc @@ -0,0 +1,15 @@ + "1"); + } +} diff --git a/modules/commons/commons_profile_base/commons_profile_base.info b/modules/commons/commons_profile_base/commons_profile_base.info new file mode 100644 index 0000000..3ae9767 --- /dev/null +++ b/modules/commons/commons_profile_base/commons_profile_base.info @@ -0,0 +1,24 @@ +name = Commons Profile Base +description = Provides a base set of profile fields for user profiles. +core = 7.x +package = Commons - Building blocks +dependencies[] = ctools +dependencies[] = features +dependencies[] = strongarm +dependencies[] = text +features[ctools][] = strongarm:strongarm:1 +features[features_api][] = api:2 +features[field_base][] = field_bio +features[field_base][] = field_name_first +features[field_base][] = field_name_last +features[field_instance][] = user-user-field_bio +features[field_instance][] = user-user-field_name_first +features[field_instance][] = user-user-field_name_last +features[variable][] = realname_pattern +features[variable][] = user_mail_register_admin_created_body +features[variable][] = user_mail_register_no_approval_required_body +features[variable][] = user_mail_status_activated_body +features[variable][] = user_picture_dimensions +features[variable][] = user_picture_file_size +features[variable][] = user_picture_style +features[variable][] = user_pictures diff --git a/modules/commons/commons_profile_base/commons_profile_base.install b/modules/commons/commons_profile_base/commons_profile_base.install new file mode 100644 index 0000000..c8541cc --- /dev/null +++ b/modules/commons/commons_profile_base/commons_profile_base.install @@ -0,0 +1,23 @@ + array('variable'), + ); + features_revert($revert); + return array(); +} + +/** + * Replace tokens with their raw equivalents in user registration emails. + */ +function commons_profile_base_update_7001() { + $revert = array( + 'commons_profile_base' => array('variable'), + ); + features_revert($revert); + return array(); +} diff --git a/modules/commons/commons_profile_base/commons_profile_base.module b/modules/commons/commons_profile_base/commons_profile_base.module new file mode 100644 index 0000000..8e68057 --- /dev/null +++ b/modules/commons/commons_profile_base/commons_profile_base.module @@ -0,0 +1,119 @@ + array('variable'))); + } +} + +/** + * Implements hook_modules_disabled(). + * + * Restore default user registration emails. + */ +function commons_profile_base_modules_disabled($modules) { + if (in_array('realname', $modules)) { + features_revert(array('commons_profile_base' => array('variable'))); + } +} + +/** + * Implements hook_strongarm_alter(). + */ +function commons_profile_base_strongarm_alter(&$items) { + // The default user registration emails include tokens which display user + // names as realnames. Realnames cannot be used for logging in or resetting + // passwords which leads to confusion. + // Replace the tokens with their raw equivalents so user emails display + // usernames instead of realnames. + if (module_exists('realname')) { + if (isset($items['user_mail_register_admin_created_body'])) { + $items['user_mail_register_admin_created_body']->value = '[user:name-raw], + +A site administrator at [site:name] has created an account for you. You may now log in by clicking this link or copying and pasting it to your browser: + +[user:one-time-login-url] + +This link can only be used once to log in and will lead you to a page where you can set your password. + +After setting your password, you will be able to log in at [site:login-url] in the future using: + +username: [user:name-raw] +password: Your password + +-- [site:name] team'; + } + if (isset($items['user_mail_register_no_approval_required_body'])) { + $items['user_mail_register_no_approval_required_body']->value = '[user:name-raw], + +Thank you for registering at [site:name]. You may now log in by clicking this link or copying and pasting it to your browser: + +[user:one-time-login-url] + +This link can only be used once to log in and will lead you to a page where you can set your password. + +After setting your password, you will be able to log in at [site:login-url] in the future using: + +username: [user:name-raw] +password: Your password + +-- [site:name] team'; + } + if (isset($items['user_mail_status_activated_body'])) { + $items['user_mail_status_activated_body']->value = '[user:name], + +Your account at [site:name] has been activated. + +You may now log in by clicking this link or copying and pasting it into your browser: + +[user:one-time-login-url] + +This link can only be used once to log in and will lead you to a page where you can set your password. + +After setting your password, you will be able to log in at [site:login-url] in the future using: + +username: [user:name-raw] +password: Your password + +-- [site:name] team'; + } + } +} diff --git a/modules/commons/commons_profile_base/commons_profile_base.strongarm.inc b/modules/commons/commons_profile_base/commons_profile_base.strongarm.inc new file mode 100644 index 0000000..dd25435 --- /dev/null +++ b/modules/commons/commons_profile_base/commons_profile_base.strongarm.inc @@ -0,0 +1,111 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'realname_pattern'; + $strongarm->value = '[user:field-name-first] [user:field-name-last]'; + $export['realname_pattern'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'user_mail_register_admin_created_body'; + $strongarm->value = '[user:name], + +A site administrator at [site:name] has created an account for you. You may now log in by clicking this link or copying and pasting it to your browser: + +[user:one-time-login-url] + +This link can only be used once to log in and will lead you to a page where you can set your password. + +After setting your password, you will be able to log in at [site:login-url] in the future using: + +username: [user:name] +password: Your password + +-- [site:name] team'; + $export['user_mail_register_admin_created_body'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'user_mail_register_no_approval_required_body'; + $strongarm->value = '[user:name], + +Thank you for registering at [site:name]. You may now log in by clicking this link or copying and pasting it to your browser: + +[user:one-time-login-url] + +This link can only be used once to log in and will lead you to a page where you can set your password. + +After setting your password, you will be able to log in at [site:login-url] in the future using: + +username: [user:name] +password: Your password + +-- [site:name] team'; + $export['user_mail_register_no_approval_required_body'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'user_mail_status_activated_body'; + $strongarm->value = '[user:name], + +Your account at [site:name] has been activated. + +You may now log in by clicking this link or copying and pasting it into your browser: + +[user:one-time-login-url] + +This link can only be used once to log in and will lead you to a page where you can set your password. + +After setting your password, you will be able to log in at [site:login-url] in the future using: + +username: [user:name] +password: Your password + +-- [site:name] team'; + $export['user_mail_status_activated_body'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'user_pictures'; + $strongarm->value = '1'; + $export['user_pictures'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'user_picture_dimensions'; + $strongarm->value = '1024x1024'; + $export['user_picture_dimensions'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'user_picture_file_size'; + $strongarm->value = '800'; + $export['user_picture_file_size'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'user_picture_style'; + $strongarm->value = 'thumbnail'; + $export['user_picture_style'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_profile_social/commons_profile_social.features.field_base.inc b/modules/commons/commons_profile_social/commons_profile_social.features.field_base.inc new file mode 100644 index 0000000..953e171 --- /dev/null +++ b/modules/commons/commons_profile_social/commons_profile_social.features.field_base.inc @@ -0,0 +1,104 @@ + '1', + 'cardinality' => '1', + 'deleted' => '0', + 'entity_types' => array(), + 'field_name' => 'field_facebook_url', + 'foreign keys' => array(), + 'indexes' => array(), + 'locked' => '0', + 'module' => 'link', + 'settings' => array( + 'attributes' => array( + 'class' => '', + 'rel' => '', + 'target' => 'default', + ), + 'display' => array( + 'url_cutoff' => 80, + ), + 'enable_tokens' => 1, + 'title' => 'optional', + 'title_maxlength' => 128, + 'title_value' => '', + 'url' => 0, + ), + 'translatable' => '0', + 'type' => 'link_field', + ); + + // Exported field_base: 'field_linkedin_url' + $field_bases['field_linkedin_url'] = array( + 'active' => '1', + 'cardinality' => '1', + 'deleted' => '0', + 'entity_types' => array(), + 'field_name' => 'field_linkedin_url', + 'foreign keys' => array(), + 'indexes' => array(), + 'locked' => '0', + 'module' => 'link', + 'settings' => array( + 'attributes' => array( + 'class' => '', + 'rel' => '', + 'target' => 'default', + ), + 'display' => array( + 'url_cutoff' => 80, + ), + 'enable_tokens' => 1, + 'title' => 'optional', + 'title_maxlength' => 128, + 'title_value' => '', + 'url' => 0, + ), + 'translatable' => '0', + 'type' => 'link_field', + ); + + // Exported field_base: 'field_twitter_url' + $field_bases['field_twitter_url'] = array( + 'active' => '1', + 'cardinality' => '1', + 'deleted' => '0', + 'entity_types' => array(), + 'field_name' => 'field_twitter_url', + 'foreign keys' => array(), + 'indexes' => array(), + 'locked' => '0', + 'module' => 'link', + 'settings' => array( + 'attributes' => array( + 'class' => '', + 'rel' => '', + 'target' => 'default', + ), + 'display' => array( + 'url_cutoff' => 80, + ), + 'enable_tokens' => 1, + 'title' => 'optional', + 'title_maxlength' => 128, + 'title_value' => '', + 'url' => 0, + ), + 'translatable' => '0', + 'type' => 'link_field', + ); + + return $field_bases; +} diff --git a/modules/commons/commons_profile_social/commons_profile_social.features.field_instance.inc b/modules/commons/commons_profile_social/commons_profile_social.features.field_instance.inc new file mode 100644 index 0000000..a43f441 --- /dev/null +++ b/modules/commons/commons_profile_social/commons_profile_social.features.field_instance.inc @@ -0,0 +1,175 @@ + 'user', + 'default_value' => array( + 0 => array( + 'title' => '', + 'url' => '', + ), + ), + 'deleted' => '0', + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'link', + 'settings' => array(), + 'type' => 'link_default', + 'weight' => 6, + ), + ), + 'entity_type' => 'user', + 'field_name' => 'field_facebook_url', + 'label' => 'Facebook URL', + 'required' => 0, + 'settings' => array( + 'attributes' => array( + 'class' => 'facebook-url', + 'configurable_title' => 0, + 'rel' => 'nofollow', + 'target' => 'default', + 'title' => '', + ), + 'display' => array( + 'url_cutoff' => '80', + ), + 'enable_tokens' => 0, + 'title' => 'none', + 'title_maxlength' => '128', + 'title_value' => '', + 'url' => 0, + 'user_register_form' => 0, + 'validate_url' => 1, + ), + 'widget' => array( + 'active' => 0, + 'module' => 'link', + 'settings' => array(), + 'type' => 'link_field', + 'weight' => '6', + ), + ); + + // Exported field_instance: 'user-user-field_linkedin_url' + $field_instances['user-user-field_linkedin_url'] = array( + 'bundle' => 'user', + 'default_value' => array( + 0 => array( + 'url' => '', + ), + ), + 'deleted' => '0', + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'link', + 'settings' => array(), + 'type' => 'link_default', + 'weight' => 5, + ), + ), + 'entity_type' => 'user', + 'field_name' => 'field_linkedin_url', + 'label' => 'LinkedIn URL', + 'required' => 0, + 'settings' => array( + 'attributes' => array( + 'class' => 'linkedin-url', + 'configurable_title' => 0, + 'rel' => 'nofollow', + 'target' => 'default', + 'title' => '', + ), + 'display' => array( + 'url_cutoff' => '80', + ), + 'enable_tokens' => 0, + 'title' => 'none', + 'title_maxlength' => '128', + 'title_value' => '', + 'url' => 0, + 'user_register_form' => 0, + 'validate_url' => 1, + ), + 'widget' => array( + 'active' => 0, + 'module' => 'link', + 'settings' => array(), + 'type' => 'link_field', + 'weight' => '7', + ), + ); + + // Exported field_instance: 'user-user-field_twitter_url' + $field_instances['user-user-field_twitter_url'] = array( + 'bundle' => 'user', + 'default_value' => array( + 0 => array( + 'title' => '', + 'url' => '', + ), + ), + 'deleted' => '0', + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'link', + 'settings' => array(), + 'type' => 'link_default', + 'weight' => 7, + ), + ), + 'entity_type' => 'user', + 'field_name' => 'field_twitter_url', + 'label' => 'Twitter URL', + 'required' => 0, + 'settings' => array( + 'attributes' => array( + 'class' => 'twitter-url', + 'configurable_title' => 0, + 'rel' => 'nofollow', + 'target' => 'default', + 'title' => '', + ), + 'display' => array( + 'url_cutoff' => '80', + ), + 'enable_tokens' => 1, + 'title' => 'none', + 'title_maxlength' => '128', + 'title_value' => '', + 'url' => 0, + 'user_register_form' => 0, + 'validate_url' => 1, + ), + 'widget' => array( + 'active' => 0, + 'module' => 'link', + 'settings' => array(), + 'type' => 'link_field', + 'weight' => '8', + ), + ); + + // Translatables + // Included for use with string extractors like potx. + t('Facebook URL'); + t('LinkedIn URL'); + t('Twitter URL'); + + return $field_instances; +} diff --git a/modules/commons/commons_profile_social/commons_profile_social.info b/modules/commons/commons_profile_social/commons_profile_social.info new file mode 100644 index 0000000..484a492 --- /dev/null +++ b/modules/commons/commons_profile_social/commons_profile_social.info @@ -0,0 +1,14 @@ +name = Commons Profile (Social fields) +description = Provides a set of link fields to the user's profile for the user's Facebook, Linkedin and Twitter accounts. +core = 7.x +package = Commons - Building blocks +dependencies[] = features +dependencies[] = field_sql_storage +dependencies[] = link +features[features_api][] = api:1 +features[field_base][] = field_facebook_url +features[field_base][] = field_linkedin_url +features[field_base][] = field_twitter_url +features[field_instance][] = user-user-field_facebook_url +features[field_instance][] = user-user-field_linkedin_url +features[field_instance][] = user-user-field_twitter_url \ No newline at end of file diff --git a/modules/commons/commons_profile_social/commons_profile_social.install b/modules/commons/commons_profile_social/commons_profile_social.install new file mode 100644 index 0000000..f0d48fd --- /dev/null +++ b/modules/commons/commons_profile_social/commons_profile_social.install @@ -0,0 +1,10 @@ + array('field_instance'), + ); + features_revert($revert); +} \ No newline at end of file diff --git a/modules/commons/commons_profile_social/commons_profile_social.module b/modules/commons/commons_profile_social/commons_profile_social.module new file mode 100644 index 0000000..44788b0 --- /dev/null +++ b/modules/commons/commons_profile_social/commons_profile_social.module @@ -0,0 +1,5 @@ + + +
      + ' . $results['rating'] . ' ' . format_plural($results['rating'], 'point', 'points') . '
      '; + + if ($display_options['description']) { + print '
      ' . $display_options['description'] . '
      '; + } + ?> + +
      +
      + +
      +
      + +
      +
      + diff --git a/modules/commons/commons_q_a/commons_q_a.features.field_base.inc b/modules/commons/commons_q_a/commons_q_a.features.field_base.inc new file mode 100644 index 0000000..c8e30b8 --- /dev/null +++ b/modules/commons/commons_q_a/commons_q_a.features.field_base.inc @@ -0,0 +1,57 @@ + 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_related_question', + 'foreign keys' => array( + 'node' => array( + 'columns' => array( + 'target_id' => 'nid', + ), + 'table' => 'node', + ), + ), + 'indexes' => array( + 'target_id' => array( + 0 => 'target_id', + ), + ), + 'locked' => 0, + 'module' => 'entityreference', + 'settings' => array( + 'handler' => 'base', + 'handler_settings' => array( + 'behaviors' => array( + 'views-select-list' => array( + 'status' => 0, + ), + ), + 'sort' => array( + 'type' => 'none', + ), + 'target_bundles' => array( + 'question' => 'question', + ), + ), + 'target_type' => 'node', + ), + 'translatable' => 0, + 'type' => 'entityreference', + ); + + return $field_bases; +} diff --git a/modules/commons/commons_q_a/commons_q_a.features.field_instance.inc b/modules/commons/commons_q_a/commons_q_a.features.field_instance.inc new file mode 100644 index 0000000..adacf7b --- /dev/null +++ b/modules/commons/commons_q_a/commons_q_a.features.field_instance.inc @@ -0,0 +1,267 @@ + 'commons_q_a_question_answered', + 'default_value' => NULL, + 'default_value_function' => '', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_target_nodes', + 'label' => 'Target nodes', + 'required' => 1, + 'settings' => array( + 'behaviors' => array( + 'prepopulate' => array( + 'status' => 0, + ), + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 2, + ), + ); + + // Exported field_instance: 'message-commons_q_a_question_asked-field_target_nodes' + $field_instances['message-commons_q_a_question_asked-field_target_nodes'] = array( + 'bundle' => 'commons_q_a_question_asked', + 'default_value' => NULL, + 'default_value_function' => '', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 3, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_target_nodes', + 'label' => 'Target nodes', + 'required' => 1, + 'settings' => array( + 'behaviors' => array( + 'prepopulate' => array( + 'status' => 0, + ), + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 2, + ), + ); + + // Exported field_instance: 'node-answer-body' + $field_instances['node-answer-body'] = array( + 'bundle' => 'answer', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 0, + ), + 'teaser' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array( + 'trim_length' => 600, + ), + 'type' => 'text_summary_or_trimmed', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'body', + 'label' => 'Body', + 'required' => FALSE, + 'settings' => array( + 'display_summary' => FALSE, + 'text_processing' => 1, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'module' => 'text', + 'settings' => array( + 'rows' => 20, + 'summary_rows' => 5, + ), + 'type' => 'text_textarea_with_summary', + 'weight' => -4, + ), + ); + + // Exported field_instance: 'node-answer-field_related_question' + $field_instances['node-answer-field_related_question'] = array( + 'bundle' => 'answer', + 'default_value' => NULL, + 'default_value_function' => 'entityreference_prepopulate_field_default_value', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'entityreference', + 'settings' => array( + 'link' => FALSE, + ), + 'type' => 'entityreference_label', + 'weight' => 12, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_related_question', + 'label' => 'Related question', + 'required' => 1, + 'settings' => array( + 'behaviors' => array( + 'prepopulate' => array( + 'action' => 'disable', + 'fallback' => 'form_error', + 'og_context' => 0, + 'skip_perm' => 0, + 'status' => 1, + ), + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 4, + ), + ); + + // Exported field_instance: 'node-question-body' + $field_instances['node-question-body'] = array( + 'bundle' => 'question', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 2, + ), + 'teaser' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array( + 'trim_length' => 600, + ), + 'type' => 'text_summary_or_trimmed', + 'weight' => 1, + ), + ), + 'display_in_partial_form' => 1, + 'entity_type' => 'node', + 'field_name' => 'body', + 'label' => 'Body', + 'required' => 0, + 'settings' => array( + 'display_summary' => 0, + 'text_processing' => 1, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'rows' => 20, + 'summary_rows' => 5, + ), + 'type' => 'text_textarea_with_summary', + 'weight' => 1, + ), + ); + + // Translatables + // Included for use with string extractors like potx. + t('Body'); + t('Related question'); + t('Target nodes'); + + return $field_instances; +} diff --git a/modules/commons/commons_q_a/commons_q_a.features.inc b/modules/commons/commons_q_a/commons_q_a.features.inc new file mode 100644 index 0000000..f230f42 --- /dev/null +++ b/modules/commons/commons_q_a/commons_q_a.features.inc @@ -0,0 +1,115 @@ + "1"); + } + if ($module == "strongarm" && $api == "strongarm") { + return array("version" => "1"); + } +} + +/** + * Implements hook_views_api(). + */ +function commons_q_a_views_api($module = NULL, $api = NULL) { + return array("api" => "3.0"); +} + +/** + * Implements hook_default_message_type(). + */ +function commons_q_a_default_message_type() { + $items = array(); + $items['commons_q_a_question_answered'] = entity_import('message_type', '{ + "name" : "commons_q_a_question_answered", + "description" : "Commons Q\\u0026A: Question Answered", + "argument_keys" : [], + "argument" : [], + "category" : "message_type", + "data" : { "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" } }, + "language" : "", + "arguments" : null, + "message_text" : { "und" : [ + { + "value" : "[message:user:picture:35x35]", + "format" : "filtered_html", + "safe_value" : "[message:user:picture:35x35]" + }, + { + "value" : "\\u003Ca href=\\u0022[message:user:url:absolute]\\u0022\\u003E[message:user:name]\\u003C\\/a\\u003E answered the question \\u003Cem\\u003E[message:field-target-nodes:0:field-related-question:title]\\u003C\\/em\\u003E with \\u0022\\u003Ca href=\\u0022[message:field-target-nodes:0:field-related-question:url]#node-[message:field-target-nodes:0:nid]\\u0022\\u003E[message:field-target-nodes:0:title_field]\\u003C\\/a\\u003E\\u0022", + "format" : "full_html", + "safe_value" : "\\u003Ca href=\\u0022[message:user:url:absolute]\\u0022\\u003E[message:user:name]\\u003C\\/a\\u003E answered the question \\u003Cem\\u003E[message:field-target-nodes:0:field-related-question:title]\\u003C\\/em\\u003E with \\u0022\\u003Ca href=\\u0022[message:field-target-nodes:0:field-related-question:url]#node-[message:field-target-nodes:0:nid]\\u0022\\u003E[message:field-target-nodes:0:title_field]\\u003C\\/a\\u003E\\u0022" + }, + { + "value" : "[commons-groups:in-groups-text]", + "format" : "full_html", + "safe_value" : "[commons-groups:in-groups-text]" + } + ] + }, + "rdf_mapping" : [] + }'); + $items['commons_q_a_question_asked'] = entity_import('message_type', '{ + "name" : "commons_q_a_question_asked", + "description" : "Commons Q\\u0026A: Question Asked", + "argument_keys" : [], + "argument" : [], + "category" : "message_type", + "data" : { "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" } }, + "language" : "", + "arguments" : null, + "message_text" : { "und" : [ + { + "value" : "[message:user:picture:35x35]", + "format" : "filtered_html", + "safe_value" : "[message:user:picture:35x35]" + }, + { + "value" : "\\u003Ca href=\\u0022[message:user:url:absolute]\\u0022\\u003E[message:user:name]\\u003C\\/a\\u003E asked the question \\u003Ca href=\\u0022[message:field-target-nodes:0:url]\\u0022\\u003E[message:field-target-nodes:0:title_field]\\u003C\\/a\\u003E", + "format" : "full_html", + "safe_value" : "\\u003Ca href=\\u0022[message:user:url:absolute]\\u0022\\u003E[message:user:name]\\u003C\\/a\\u003E asked the question \\u003Ca href=\\u0022[message:field-target-nodes:0:url]\\u0022\\u003E[message:field-target-nodes:0:title_field]\\u003C\\/a\\u003E" + }, + { + "value" : "[commons-groups:in-groups-text]", + "format" : "full_html", + "safe_value" : "[commons-groups:in-groups-text]" + } + ] + }, + "rdf_mapping" : [] + }'); + return $items; +} + +/** + * Implements hook_node_info(). + */ +function commons_q_a_node_info() { + $items = array( + 'answer' => array( + 'name' => t('Answer'), + 'base' => 'node_content', + 'description' => t('Use answers for responses to Question content, which can be rated by user votes.'), + 'has_title' => '1', + 'title_label' => t('Title'), + 'help' => '', + ), + 'question' => array( + 'name' => t('Question'), + 'base' => 'node_content', + 'description' => t('Ask a question to receive answers from other community members'), + 'has_title' => '1', + 'title_label' => t('Title'), + 'help' => '', + ), + ); + return $items; +} diff --git a/modules/commons/commons_q_a/commons_q_a.features.og_features_permission.inc b/modules/commons/commons_q_a/commons_q_a.features.og_features_permission.inc new file mode 100644 index 0000000..a21c58e --- /dev/null +++ b/modules/commons/commons_q_a/commons_q_a.features.og_features_permission.inc @@ -0,0 +1,90 @@ + array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + // Exported og permission: 'node:group:create question content' + $permissions['node:group:create question content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + // Exported og permission: 'node:group:delete any answer content' + $permissions['node:group:delete any answer content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + ), + ); + + // Exported og permission: 'node:group:delete any question content' + $permissions['node:group:delete any question content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + ), + ); + + // Exported og permission: 'node:group:delete own answer content' + $permissions['node:group:delete own answer content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + // Exported og permission: 'node:group:delete own question content' + $permissions['node:group:delete own question content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + // Exported og permission: 'node:group:update any answer content' + $permissions['node:group:update any answer content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + ), + ); + + // Exported og permission: 'node:group:update any question content' + $permissions['node:group:update any question content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + ), + ); + + // Exported og permission: 'node:group:update own answer content' + $permissions['node:group:update own answer content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + // Exported og permission: 'node:group:update own question content' + $permissions['node:group:update own question content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + return $permissions; +} diff --git a/modules/commons/commons_q_a/commons_q_a.features.user_permission.inc b/modules/commons/commons_q_a/commons_q_a.features.user_permission.inc new file mode 100644 index 0000000..758a4bb --- /dev/null +++ b/modules/commons/commons_q_a/commons_q_a.features.user_permission.inc @@ -0,0 +1,110 @@ + 'create answer content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + // Exported permission: 'create question content'. + $permissions['create question content'] = array( + 'name' => 'create question content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + // Exported permission: 'delete any answer content'. + $permissions['delete any answer content'] = array( + 'name' => 'delete any answer content', + 'roles' => array( + 'administrator' => 'administrator', + ), + 'module' => 'node', + ); + + // Exported permission: 'delete any question content'. + $permissions['delete any question content'] = array( + 'name' => 'delete any question content', + 'roles' => array( + 'administrator' => 'administrator', + ), + 'module' => 'node', + ); + + // Exported permission: 'delete own answer content'. + $permissions['delete own answer content'] = array( + 'name' => 'delete own answer content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + // Exported permission: 'delete own question content'. + $permissions['delete own question content'] = array( + 'name' => 'delete own question content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + // Exported permission: 'edit any answer content'. + $permissions['edit any answer content'] = array( + 'name' => 'edit any answer content', + 'roles' => array( + 'administrator' => 'administrator', + ), + 'module' => 'node', + ); + + // Exported permission: 'edit any question content'. + $permissions['edit any question content'] = array( + 'name' => 'edit any question content', + 'roles' => array( + 'administrator' => 'administrator', + ), + 'module' => 'node', + ); + + // Exported permission: 'edit own answer content'. + $permissions['edit own answer content'] = array( + 'name' => 'edit own answer content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + // Exported permission: 'edit own question content'. + $permissions['edit own question content'] = array( + 'name' => 'edit own question content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + return $permissions; +} diff --git a/modules/commons/commons_q_a/commons_q_a.info b/modules/commons/commons_q_a/commons_q_a.info new file mode 100644 index 0000000..93e0a00 --- /dev/null +++ b/modules/commons/commons_q_a/commons_q_a.info @@ -0,0 +1,96 @@ +name = Commons Q&A +description = Allows community members to ask questions and vote for the best answers +core = 7.x +package = Commons - Content types +dependencies[] = commons_topics +dependencies[] = ctools +dependencies[] = entity +dependencies[] = entityreference +dependencies[] = features +dependencies[] = field_sql_storage +dependencies[] = og_ui +dependencies[] = options +dependencies[] = strongarm +dependencies[] = text +dependencies[] = views +dependencies[] = views_content +dependencies[] = views_litepager +features[ctools][] = panelizer:panelizer:1 +features[ctools][] = strongarm:strongarm:1 +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[field_base][] = field_related_question +features[field_instance][] = message-commons_q_a_question_answered-field_target_nodes +features[field_instance][] = message-commons_q_a_question_asked-field_target_nodes +features[field_instance][] = node-answer-body +features[field_instance][] = node-answer-field_related_question +features[field_instance][] = node-question-body +features[message_type][] = commons_q_a_question_answered +features[message_type][] = commons_q_a_question_asked +features[node][] = answer +features[node][] = question +features[og_features_permission][] = node:group:create answer content +features[og_features_permission][] = node:group:create question content +features[og_features_permission][] = node:group:delete any answer content +features[og_features_permission][] = node:group:delete any question content +features[og_features_permission][] = node:group:delete own answer content +features[og_features_permission][] = node:group:delete own question content +features[og_features_permission][] = node:group:update any answer content +features[og_features_permission][] = node:group:update any question content +features[og_features_permission][] = node:group:update own answer content +features[og_features_permission][] = node:group:update own question content +features[user_permission][] = create answer content +features[user_permission][] = create question content +features[user_permission][] = delete any answer content +features[user_permission][] = delete any question content +features[user_permission][] = delete own answer content +features[user_permission][] = delete own question content +features[user_permission][] = edit any answer content +features[user_permission][] = edit any question content +features[user_permission][] = edit own answer content +features[user_permission][] = edit own question content +features[variable][] = comment_anonymous_answer +features[variable][] = comment_anonymous_question +features[variable][] = comment_answer +features[variable][] = comment_default_mode_answer +features[variable][] = comment_default_mode_question +features[variable][] = comment_default_per_page_answer +features[variable][] = comment_default_per_page_question +features[variable][] = comment_form_location_answer +features[variable][] = comment_form_location_question +features[variable][] = comment_preview_answer +features[variable][] = comment_preview_question +features[variable][] = comment_question +features[variable][] = comment_subject_field_answer +features[variable][] = comment_subject_field_question +features[variable][] = field_bundle_settings_message__commons_q_a_question_answered +features[variable][] = field_bundle_settings_message__commons_q_a_question_asked +features[variable][] = field_bundle_settings_node__answer +features[variable][] = field_bundle_settings_node__question +features[variable][] = menu_options_answer +features[variable][] = menu_options_question +features[variable][] = menu_parent_answer +features[variable][] = menu_parent_question +features[variable][] = node_options_answer +features[variable][] = node_options_question +features[variable][] = node_preview_answer +features[variable][] = node_preview_question +features[variable][] = node_submitted_answer +features[variable][] = node_submitted_question +features[variable][] = pathauto_node_answer_pattern +features[views_view][] = commons_bw_q_a +features[views_view][] = commons_question_answers +features_exclude[dependencies][message] = message +features_exclude[dependencies][commons_trusted_contacts] = commons_trusted_contacts +features_exclude[field][message-commons_q_a_question_answered-field_target_nodes] = message-commons_q_a_question_answered-field_target_nodes +features_exclude[field_base][og_group_ref_other_groups] = og_group_ref_other_groups +features_exclude[field_base][og_group_ref] = og_group_ref +features_exclude[field_base][field_body] = field_body +features_exclude[field_base][field_radioactivity] = field_radioactivity +features_exclude[field_base][body] = body +features_exclude[field_base][field_target_nodes] = field_target_nodes +features_exclude[field_instance][node-answer-og_group_ref_other_groups] = node-answer-og_group_ref_other_groups +features_exclude[field_instance][node-question-og_group_ref_other_groups] = node-question-og_group_ref_other_groups +features_exclude[field_instance][og_group_ref] = og_group_ref +features_exclude[field_instance][node-answer-og_group_ref] = node-answer-og_group_ref +features_exclude[field_instance][node-question-og_group_ref] = node-question-og_group_ref diff --git a/modules/commons/commons_q_a/commons_q_a.install b/modules/commons/commons_q_a/commons_q_a.install new file mode 100644 index 0000000..aa6ec72 --- /dev/null +++ b/modules/commons/commons_q_a/commons_q_a.install @@ -0,0 +1,149 @@ + array('variable'), + ); + features_revert($revert); + return array(); +} + +/** + * Disable comments on Question nodes. Don't feature answers by default + * (http://drupal.org/node/1921498). + */ +function commons_q_a_update_3101() { + $revert = array( + 'commons_q_a' => array('variable'), + ); + features_revert($revert); + return array(); +} + +/** + * Disable summary on Question/Answer nodes. + */ +function commons_q_a_update_3102() { + $revert = array( + 'commons_q_a' => array('field_instance'), + ); + features_revert($revert); + return array(); +} + +/** + * Update the Commons Q&A widget per http://drupal.org/node/1940644. + */ +function commons_q_a_update_3103() { + // The Commons Q&A widget is defined via a hook_strongarm_alter() + // implementation altering rate_widgets variable, defined by commons_like. + $revert = array( + 'commons_like' => array('variable'), + ); + features_revert($revert); + return array(); +} + +/** + * Disable comments on Answer nodes. + */ +function commons_q_a_update_3104() { + $revert = array( + 'commons_q_a' => array('variable'), + ); + features_revert($revert); + return array(); +} + +/** + * Link the 'Answer added' activity stream message to the Answer node as + * displayed on the question per http://drupal.org/node/1946120. + */ +function commons_q_a_update_3105() { + $revert = array( + 'commons_q_a' => array('field_instance', 'message_type', 'variable'), + ); + features_revert($revert); + return array(); +} + +/** + * Use the standard user picture image size. + */ +function commons_q_a_update_3106() { + $revert = array( + 'commons_q_a' => array('message_type'), + ); + features_revert($revert); + return array(); +} + +/** + * Remove the "Like" widget from answer nodes, since they have a +/- widget. + * Related issue: https://drupal.org/node/1935312. + */ +function commons_q_a_update_3107() { + $revert = array( + 'commons_like' => array('variable'), + ); + features_revert($revert); + return array(); +} + +/** + * Standardize Browsing Widget views. + */ +function commons_q_a_update_3108() { + $revert = array( + 'commons_q_a' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Display sticky content at top of lists. + */ +function commons_q_a_update_3109() { + $revert = array( + 'commons_q_a' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Indicate in the view that empty answers text is overridden by commons_q_a. + */ +function commons_q_a_update_3110() { + $revert = array( + 'commons_q_a' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Change the Answer URL alias to be a subpath of the question. + */ +function commons_q_a_update_3111() { + $revert = array( + 'commons_q_a' => array('variable'), + ); + features_revert($revert); + return array(); +} + +/** + * Improve the browsing widget empty text. + */ +function commons_q_a_update_3112() { + $revert = array( + 'commons_q_a' => array('views_view'), + ); + features_revert($revert); + return array(); +} diff --git a/modules/commons/commons_q_a/commons_q_a.module b/modules/commons/commons_q_a/commons_q_a.module new file mode 100644 index 0000000..3fc37fd --- /dev/null +++ b/modules/commons/commons_q_a/commons_q_a.module @@ -0,0 +1,464 @@ + array( + 'question' => array( + 'media' => TRUE, + 'is_group_content' => TRUE, + ), + 'answer' => array( + 'exclude_topics' => TRUE, + 'exclude_rate' => TRUE, + 'is_group_content' => TRUE, + ), + ), + ); +} + +/** + * Implements hook_commons_bw_group_widget(). + */ +function commons_q_a_commons_bw_group_widget() { + return array( + 'commons_q_a' => array( + 'title' => t('Q & A'), + 'type' => 'view', + 'vid' => 'commons_bw_q_a', + 'display' => 'default', + 'weight' => 5, + 'bundle' => 'question', + ), + ); +} + +/** + * Implements hook_theme(). + */ +function commons_q_a_theme() { + return array( + 'rate_template_commons_thumbs_up_down' => array( + 'variables' => array('links' => NULL, 'results' => NULL, 'mode' => NULL, 'just_voted' => FALSE, 'content_type' => NULL, 'content_id' => NULL, 'display_options' => NULL), + 'template' => 'commons-thumbs-up-down', + ), + ); +} + +/** + * Implements hook_node_view(). + * + * Provides an answer button to bring a user down to the answer form. + */ +function commons_q_a_node_view($node, $view_mode) { + if ($node->type == 'question' && $view_mode == 'full') { + // Remove add comment link. + unset($node->content['links']['comment']); + // Add the answer link below. + if (commons_q_a_check_answer_access($node)) { + $node->content['links']['answer'] = array( + '#theme' => 'links__node__answer', + '#links' => array( + 'answer-add' => array( + 'title' => t('Answer'), + 'attributes' => array( + 'title' => t('Answer this question'), + ), + 'href' => 'node/' . $node->nid, + 'fragment' => 'answer', + ), + ), + ); + } + return $node; + } +} + +/** + * Implements hook_form_FROM_ID_alter(). + */ +function commons_q_a_form_commons_bw_partial_node_form_alter(&$form, &$form_state) { + if (empty($form['#entity']) || $form['#entity']->type != 'question') { + return; + } + + $form['title']['#markup'] = '

      ' . t('Ask a question') . '

      '; + + $language = $form['body']['#language']; + $form['body'][$language][0]['#title_display'] = 'invisible'; + $form['body'][$language][0]['#required'] = TRUE; + $form['body'][$language][0]['#placeholder'] = t('Ask anything. Let the community answer openly.'); + $form['body'][$language][0]['#resizable'] = FALSE; + + // Set fields as hideable so the forms can be compacted. + $form['body']['#attributes']['class'][] = 'trigger-field'; + foreach (array('field_media', 'field_image', 'og_group_ref', 'choice_wrapper', 'actions') as $field) { + if (isset($form[$field])) { + $form[$field]['#attributes']['class'][] = 'hideable-field'; + } + } + + $form['actions']['submit']['#value'] = t('Ask'); + $form['#pre_render'][] = 'commons_q_a_form_commons_bw_partial_node_form_after_build'; +} + +/** + * After-build call-back. + * See commons_q_a_form_commons_bw_partial_node_form_alter(). + */ +function commons_q_a_form_commons_bw_partial_node_form_after_build($form) { + $language = $form['body']['#language']; + $form['body'][$language][0]['#pre_render'] = array(); + $form['body'][$language][0]['format']['#access'] = FALSE; + $form['body'][$language][0]['value']['#rows'] = 3; + + return $form; +} + +/** + * Implements hook_views_default_views_alter(). + * + * Display questions on the browsing widget main view. + */ +function commons_q_a_views_default_views_alter(&$views) { + if (!empty($views['commons_bw_all'])) { + $views['commons_bw_all']->display['default']->display_options['filters']['type']['value']['question'] = 'question'; + } +} + +/* + * Run an access check to see if the current user can create answer nodes based + * off of the question node. + */ +function commons_q_a_check_answer_access($question) { + $group_ref = array(); + if (!empty($question->og_group_ref[LANGUAGE_NONE])) { + foreach ($question->og_group_ref[LANGUAGE_NONE] as $key => $value) { + // Check to see the user has access to the group the question is in, only attach to those groups they have permission to post in. + if (og_user_access('node', $value['target_id'], 'create answer content')) { + $group_ref[] = $value['target_id']; + return TRUE; + } + } + } + // If user belongs to no groups, or no groups are assigned to the Question, check node_access for user. + else { + if (node_access('create', 'answer')) { + return TRUE; + } + } + return FALSE; +} + +/** + * Implements hook_views_pre_render(). + */ +function commons_q_a_views_pre_render(&$view) { + // Improve the browsing widget empty text when displayed outside of a group. + // TODO: Enable og_context and check group context instead of looking for an + // empty first argument. + if (empty($view->args[0]) && $view->name == 'commons_bw_q_a') { + $view->display_handler->handlers['empty']['area']->options['content'] = t('No questions have been created.'); + } + + if ($view->name == 'commons_question_answers' && !empty($view->args[0])) { + // If the user has access to post into any of the groups associated + // with the question, embed a simplified answer node form. + global $user; + + if (user_is_anonymous()) { + $account = drupal_anonymous_user(); + } + else { + $account = $user; + } + + $question_nid = $view->args[0]; + $question = node_load($question_nid); + + $answer_access = commons_q_a_check_answer_access($question); + // Check global user access before showing the answer form. + if ($answer_access) { + $view->empty['area']->options['content'] = t("This question hasn't been answered yet. You can be the first to answer it!"); + module_load_include('inc', 'node', 'node.pages'); + $types = node_type_get_types(); + $node = (object) array( + 'uid' => $account->uid, + 'name' => (isset($account->name) ? $account->name : ''), + 'type' => 'answer', 'language' => LANGUAGE_NONE + ); + // Prepopulate the Related question field + // with Entityreference Prepopulate, which looks strictly at $_GET. + $_GET['field_related_question'] = $view->args[0]; + if (!empty($group_ref)) { + $_GET['og_group_ref'] = implode(',', $group_ref); + } + $answer_form = drupal_get_form('answer_node_form', $node); + $answer_form['header'] = array( + '#markup' => '

      ' . t('Add a new answer') . '

      ', + '#weight' => -10, + ); + // Hide any vertical tabs that might be present. + $answer_form['additional_settings']['#access'] = FALSE; + // Hide the Related question field. + $answer_form['field_related_question']['#access'] = FALSE; + // Add the form to the attachment_after part of the view, + $view->attachment_after .= drupal_render($answer_form); + // We only need to add the form once if the user has access to + // post questions into any of the groups associated with the parent. + return; + } + // Tell Anonymous users to login. + elseif ($account->uid === 0) { + $view->empty['area']->options['content'] = t("This question hasn't been answered yet. !create to be the first to answer it!", array('!create' => l(t("Login or create an account"), 'user'))); + return; + } + // If the user is not anonymous, but cannot answer the question. Don't tell + // them they should be the first to answer it. + else { + $view->empty['area']->options['content'] = t("This question hasn't been answered yet."); + return; + } + } +} + +/* + * Implements hook_module_implements_alter(). + * Set commons_q_a form alter to happen after node so the title doesn't get reset. + */ +function commons_q_a_module_implements_alter(&$implementations, $hook) { + if ($hook == 'form_alter') { + $group = $implementations['commons_q_a']; + unset($implementations['commons_q_a']); + $implementations['commons_q_a'] = $group; + } +} + +/** +* Implements hook_form_alter(). +*/ +function commons_q_a_form_alter(&$form, &$form_state, $form_id) { + // Unset the groups audience field. Answers programatically inherit + // the group membership of their respective questions. + if ($form_id == 'answer_node_form') { + $form['og_group_ref']['#access'] = FALSE; + $form['actions']['submit']['#submit'][] = 'commons_q_a_answer_submit'; + // Ensure that the answer node inherits group membership from the + // parent question by preventing users from changing the audience through + // the Trusted Contacts toggle when commons_trusted_contacts.module + // is enabled. + $form_state['hide_audience_toggle'] = TRUE; + } + if ($form_id == 'question_node_form' && empty($form['#node']->nid)) { + drupal_set_title(t('Ask a question')); + } + if ($form_id == 'comment_node_question_form' || $form_id == 'comment_node_answer_form') { + $form['container'] = array( + '#type' => 'fieldset', + '#title' => t('Add new comment'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#weight' => 2, + ); + $form['container']['author'] = $form['author']; + $form['container']['comment_body'] = $form['comment_body']; + $form['container']['actions'] = $form['actions']; + unset($form['author']); + unset($form['subject']); // We don't need a subject, they're pointless within comments. + unset($form['comment_body']); + unset($form['actions']); + } +} + +/** + * Implements hook_field_attach_submit(). + */ +function commons_q_a_field_attach_submit($entity_type, &$entity, $form, &$form_state) { + // Questions should inherit the group membership of the related question. + if ($entity_type == 'node' && $entity->type == 'answer' && empty($entity->nid)) { + $question = node_load($entity->field_related_question[LANGUAGE_NONE][0]['target_id']); + $entity->og_group_ref = $question->og_group_ref; + } +} + +/** + * Implements hook_commons_bw_create_all_widget(). + */ +function commons_q_a_commons_bw_create_all_widget($group) { + if (og_user_access('node', $group->nid, 'create question content')) { + $link = l(t('Ask a question'),'node/add/question', + array('attributes' => array('class' => 'commons-q-a-create'), 'query' => array('og_group_ref' => $group->nid)) + ); + return array( + 'commons_q_a' => array( + 'link' => $link, + 'text' => t('Learn the best answer'), + '#weight' => 5, + ), + ); + } +} + +/** + * Submit handler for the submit button on the answer node form. + */ +function commons_q_a_answer_submit($form, &$form_state) { + // Redirect the user back to the related question. + $form_state['redirect'] = 'node/' . $form_state['values']['field_related_question'][LANGUAGE_NONE][0]['target_id']; +} + +/** + * Implements commons_activity_streams_message_selection_alter(). + */ +function commons_q_a_commons_activity_streams_message_selection_alter(&$message_type, $hook, $node) { + // Provide a special message type that uses "User asked the question" + // phrasing when a new question node is created. + if ($hook == 'node_insert' && $node->type == 'question') { + $message_type = 'commons_q_a_question_asked'; + } + + // Provide a special message type that uses "User answered the question" + // phrasing when a new answer node is created. + if ($hook == 'node_insert' && $node->type == 'answer') { + $message_type = 'commons_q_a_question_answered'; + } +} + +/** + * Preprocess function for the commons_like template. + */ +function commons_q_a_preprocess_rate_template_commons_thumbs_up_down(&$variables) { + extract($variables); + + $up_classes = 'rate-number-up-down-btn-up'; + $down_classes = 'rate-number-up-down-btn-down'; + if (isset($results['user_vote'])) { + switch ($results['user_vote']) { + case $links[0]['value']: + $up_classes .= ' rate-voted'; + break; + case $links[1]['value']: + $down_classes .= ' rate-voted'; + break; + } + } + + $variables['up_button'] = theme('rate_button', array('text' => $links[0]['text'], 'href' => $links[0]['href'], 'class' => $up_classes)); + $variables['down_button'] = theme('rate_button', array('text' => $links[1]['text'], 'href' => $links[1]['href'], 'class' => $down_classes)); + if ($results['rating'] > 0) { + $score = $results['rating']; + $score_class = 'positive'; + } + elseif ($results['rating'] < 0) { + $score = $results['rating']; + $score_class = 'negative'; + } + else { + $score = 0; + $score_class = 'neutral'; + } + $variables['score'] = $score; + $variables['score_class'] = $score_class; + + $info = array(); + if ($mode == RATE_CLOSED) { + $info[] = t('Voting is closed.'); + } + if ($mode != RATE_COMPACT && $mode != RATE_COMPACT_DISABLED) { + if (isset($results['user_vote'])) { + $info[] = t('You voted \'@option\'.', array('@option' => $results['user_vote'] == 1 ? $links[0]['text'] : $links[1]['text'])); + } + } + $variables['info'] = implode(' ', $info); +} + +/** + * Implements hook_rate_templates(). + */ +function commons_q_a_rate_templates() { + $templates = array(); + + $templates['commons_thumbs_up_down'] = new stdClass(); + $templates['commons_thumbs_up_down']->value_type = 'points'; + $templates['commons_thumbs_up_down']->options = array( + array(1, 'up'), + array(-1, 'down'), + ); + $templates['commons_thumbs_up_down']->theme = 'rate_template_commons_thumbs_up_down'; + $templates['commons_thumbs_up_down']->css = drupal_get_path('module', 'commons_q_a') . '/commons-thumbs-up-down.css'; + $templates['commons_thumbs_up_down']->customizable = FALSE; + $templates['commons_thumbs_up_down']->translate = TRUE; + $templates['commons_thumbs_up_down']->use_source_translation = TRUE; + $templates['commons_thumbs_up_down']->template_title = t('Commons Thumbs up / down'); + + return $templates; +} + +/** + * Implements hook_strongarm_alter(). + */ + function commons_q_a_strongarm_alter(&$items) { + // Add Rate module widget configuration used for thumbs up/down + // rating of answers. + if (!empty($items['rate_widgets']->value)) { + $items['rate_widgets']->value[] = commons_q_a_rate_widget(); + } +} + + +/** + * Return a Rate module widget configuration used for thumbs up/down + * rating of answers. + */ +function commons_q_a_rate_widget() { + return (object) array( + 'name' => 'commons_answer', + 'tag' => 'commons_thumbs_up_down', + 'title' => 'Answer', + 'node_types' => array( + 0 => 'answer', + ), + 'comment_types' => array(), + 'options' => array( + 0 => array( + 0 => 1, + 1 => 'up', + ), + 1 => array( + 0 => -1, + 1 => 'down', + ), + ), + 'template' => 'commons_thumbs_up_down', + 'node_display' => '2', + 'teaser_display' => FALSE, + 'comment_display' => '2', + 'node_display_mode' => '1', + 'teaser_display_mode' => '1', + 'comment_display_mode' => '1', + 'roles' => array( + 2 => '2', + 1 => 0, + ), + 'allow_voting_by_author' => 1, + 'noperm_behaviour' => '3', + 'displayed' => '1', + 'displayed_just_voted' => '1', + 'description' => '', + 'description_in_compact' => TRUE, + 'delete_vote_on_second_click' => '1', + 'value_type' => 'points', + 'theme' => 'rate_template_commons_thumbs_up_down', + 'css' => 'profiles/commons/modules/contrib/commons_q_a/commons-thumbs-up-down.css', + 'translate' => TRUE, + 'use_source_translation' => TRUE, + ); +} diff --git a/modules/commons/commons_q_a/commons_q_a.strongarm.inc b/modules/commons/commons_q_a/commons_q_a.strongarm.inc new file mode 100644 index 0000000..f800d2b --- /dev/null +++ b/modules/commons/commons_q_a/commons_q_a.strongarm.inc @@ -0,0 +1,330 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_anonymous_answer'; + $strongarm->value = 0; + $export['comment_anonymous_answer'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_anonymous_question'; + $strongarm->value = 0; + $export['comment_anonymous_question'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_answer'; + $strongarm->value = '0'; + $export['comment_answer'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_mode_answer'; + $strongarm->value = 1; + $export['comment_default_mode_answer'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_mode_question'; + $strongarm->value = 1; + $export['comment_default_mode_question'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_per_page_answer'; + $strongarm->value = '50'; + $export['comment_default_per_page_answer'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_per_page_question'; + $strongarm->value = '50'; + $export['comment_default_per_page_question'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_form_location_answer'; + $strongarm->value = 1; + $export['comment_form_location_answer'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_form_location_question'; + $strongarm->value = 1; + $export['comment_form_location_question'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_preview_answer'; + $strongarm->value = '1'; + $export['comment_preview_answer'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_preview_question'; + $strongarm->value = '1'; + $export['comment_preview_question'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_question'; + $strongarm->value = '0'; + $export['comment_question'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_subject_field_answer'; + $strongarm->value = 0; + $export['comment_subject_field_answer'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_subject_field_question'; + $strongarm->value = 0; + $export['comment_subject_field_question'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_message__commons_q_a_question_answered'; + $strongarm->value = array( + 'view_modes' => array( + 'message_notify_email_subject' => array( + 'custom_settings' => TRUE, + ), + 'message_notify_email_body' => array( + 'custom_settings' => TRUE, + ), + 'full' => array( + 'custom_settings' => FALSE, + ), + 'diff_standard' => array( + 'custom_settings' => FALSE, + ), + 'token' => array( + 'custom_settings' => FALSE, + ), + ), + 'extra_fields' => array( + 'form' => array(), + 'display' => array( + 'message__message_text__0' => array( + 'message_notify_email_subject' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + 'default' => array( + 'weight' => '0', + 'visible' => TRUE, + ), + ), + 'message__message_text__1' => array( + 'message_notify_email_subject' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + 'default' => array( + 'weight' => '1', + 'visible' => TRUE, + ), + ), + 'message__message_text__2' => array( + 'default' => array( + 'weight' => '2', + 'visible' => TRUE, + ), + ), + ), + ), + ); + $export['field_bundle_settings_message__commons_q_a_question_answered'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_message__commons_q_a_question_asked'; + $strongarm->value = array( + 'view_modes' => array(), + 'extra_fields' => array( + 'form' => array(), + 'display' => array( + 'message__message_text__0' => array( + 'message_notify_email_subject' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + ), + 'message__message_text__1' => array( + 'message_notify_email_subject' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + ), + ), + ), + ); + $export['field_bundle_settings_message__commons_q_a_question_asked'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_node__answer'; + $strongarm->value = array( + 'view_modes' => array(), + 'extra_fields' => array( + 'form' => array( + 'title' => array( + 'weight' => '-5', + ), + ), + 'display' => array(), + ), + ); + $export['field_bundle_settings_node__answer'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_node__question'; + $strongarm->value = array( + 'view_modes' => array(), + 'extra_fields' => array( + 'form' => array( + 'title' => array( + 'weight' => '0', + ), + ), + 'display' => array(), + ), + ); + $export['field_bundle_settings_node__question'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_options_answer'; + $strongarm->value = array( + 0 => 'main-menu', + ); + $export['menu_options_answer'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_options_question'; + $strongarm->value = array( + 0 => 'main-menu', + ); + $export['menu_options_question'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_parent_answer'; + $strongarm->value = 'main-menu:0'; + $export['menu_parent_answer'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_parent_question'; + $strongarm->value = 'main-menu:0'; + $export['menu_parent_question'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_options_answer'; + $strongarm->value = array( + 0 => 'status', + ); + $export['node_options_answer'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_options_question'; + $strongarm->value = array( + 0 => 'status', + 1 => 'revision', + ); + $export['node_options_question'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_preview_answer'; + $strongarm->value = '1'; + $export['node_preview_answer'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_preview_question'; + $strongarm->value = '1'; + $export['node_preview_question'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_submitted_answer'; + $strongarm->value = 1; + $export['node_submitted_answer'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_submitted_question'; + $strongarm->value = 1; + $export['node_submitted_question'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = "pathauto_node_answer_pattern"; + $strongarm->value = 'groups/[node:og-group-ref:0:title-field]/[node:field-related-question:title-field]/[node:title-field]'; + $export["pathauto_node_answer_pattern"] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_q_a/commons_q_a.views_default.inc b/modules/commons/commons_q_a/commons_q_a.views_default.inc new file mode 100644 index 0000000..33d6be9 --- /dev/null +++ b/modules/commons/commons_q_a/commons_q_a.views_default.inc @@ -0,0 +1,241 @@ +name = 'commons_bw_q_a'; + $view->description = 'Commons Q&A listing for the group browsing widget.'; + $view->tag = 'Commons Q&A, Commons Browsing Widget'; + $view->base_table = 'node'; + $view->human_name = 'Commons Browsing Widget - Q&A'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_ajax'] = TRUE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'lite'; + $handler->display->display_options['pager']['options']['items_per_page'] = '10'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '3'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'entity'; + $handler->display->display_options['row_options']['view_mode'] = 'teaser'; + /* Header: Global: Node partial form */ + $handler->display->display_options['header']['commons_bw_node_partial_form']['id'] = 'commons_bw_node_partial_form'; + $handler->display->display_options['header']['commons_bw_node_partial_form']['table'] = 'views'; + $handler->display->display_options['header']['commons_bw_node_partial_form']['field'] = 'commons_bw_node_partial_form'; + $handler->display->display_options['header']['commons_bw_node_partial_form']['bundle'] = 'question'; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'No questions have been added to this group.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: OG membership: OG membership from Node */ + $handler->display->display_options['relationships']['og_membership_rel']['id'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['table'] = 'node'; + $handler->display->display_options['relationships']['og_membership_rel']['field'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['required'] = TRUE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Content: Sticky */ + $handler->display->display_options['sorts']['sticky']['id'] = 'sticky'; + $handler->display->display_options['sorts']['sticky']['table'] = 'node'; + $handler->display->display_options['sorts']['sticky']['field'] = 'sticky'; + $handler->display->display_options['sorts']['sticky']['order'] = 'DESC'; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + $handler->display->display_options['sorts']['created']['exposed'] = TRUE; + $handler->display->display_options['sorts']['created']['expose']['label'] = 'most recent'; + /* Contextual filter: OG membership: Group ID */ + $handler->display->display_options['arguments']['gid']['id'] = 'gid'; + $handler->display->display_options['arguments']['gid']['table'] = 'og_membership'; + $handler->display->display_options['arguments']['gid']['field'] = 'gid'; + $handler->display->display_options['arguments']['gid']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['arguments']['gid']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['gid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['gid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['gid']['summary_options']['items_per_page'] = '25'; + $handler->display->display_options['arguments']['gid']['break_phrase'] = TRUE; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'node'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['value'] = array( + 'question' => 'question', + ); + /* Filter criterion: OG membership: Group_type */ + $handler->display->display_options['filters']['group_type']['id'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['table'] = 'og_membership'; + $handler->display->display_options['filters']['group_type']['field'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['filters']['group_type']['value'] = array( + 'node' => 'node', + ); + $translatables['commons_bw_q_a'] = array( + t('Master'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('No questions have been asked in this group.'), + t('OG membership from node'), + t('following'), + t('most recent'), + t('most active'), + t('All'), + t('Following'), + ); + $export['commons_bw_q_a'] = $view; + + $view = new view(); + $view->name = 'commons_question_answers'; + $view->description = ''; + $view->tag = 'Commons Q&A'; + $view->base_table = 'node'; + $view->human_name = 'Answers to a question'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Answers'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'entity'; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'This Empty text is overridden in commons_q_a.module'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + /* Contextual filter: Content: Related question (field_related_question) */ + $handler->display->display_options['arguments']['field_related_question_target_id']['id'] = 'field_related_question_target_id'; + $handler->display->display_options['arguments']['field_related_question_target_id']['table'] = 'field_data_field_related_question'; + $handler->display->display_options['arguments']['field_related_question_target_id']['field'] = 'field_related_question_target_id'; + $handler->display->display_options['arguments']['field_related_question_target_id']['default_action'] = 'empty'; + $handler->display->display_options['arguments']['field_related_question_target_id']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['field_related_question_target_id']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['field_related_question_target_id']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['field_related_question_target_id']['summary_options']['items_per_page'] = '25'; + $handler->display->display_options['arguments']['field_related_question_target_id']['specify_validation'] = TRUE; + $handler->display->display_options['arguments']['field_related_question_target_id']['validate']['type'] = 'node'; + $handler->display->display_options['arguments']['field_related_question_target_id']['validate_options']['types'] = array( + 'question' => 'question', + ); + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'node'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['value'] = array( + 'answer' => 'answer', + ); + + /* Display: Content pane */ + $handler = $view->new_display('panel_pane', 'Content pane', 'panel_pane_1'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['pane_category']['name'] = 'Commons'; + $handler->display->display_options['pane_category']['weight'] = '0'; + $handler->display->display_options['argument_input'] = array( + 'field_related_question_target_id' => array( + 'type' => 'context', + 'context' => 'entity:node.nid', + 'context_optional' => 0, + 'panel' => '0', + 'fixed' => '', + 'label' => 'Content: Related Question (field_related_question)', + ), + ); + $handler->display->display_options['inherit_panels_path'] = '1'; + $translatables['commons_question_answers'] = array( + t('Master'), + t('Answers'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('This Empty text is overridden in commons_q_a.module'), + t('All'), + t('Content pane'), + t('Commons'), + ); + $export['commons_question_answers'] = $view; + + return $export; +} diff --git a/modules/commons/commons_q_a/config.rb b/modules/commons/commons_q_a/config.rb new file mode 100644 index 0000000..ae8fc12 --- /dev/null +++ b/modules/commons/commons_q_a/config.rb @@ -0,0 +1,20 @@ +# Require any additional compass plugins here. + +# Set this to the root of your project when deployed: +http_path = "/" +css_dir = "/" +sass_dir = "/" +images_dir = "images" + +# output_style = :expanded or :nested or :compact or :compressed +output_style = :expanded + +relative_assets = true + +# line_comments and debug_info can be activated by setting the environment +# flag to "development" +line_comments = (environment == :development) ? true : false + +sass_options = { + :debug_info => (environment == :development) ? true : false +} diff --git a/modules/commons/commons_q_a/modules/commons_q_a_pages/commons_q_a_pages.features.inc b/modules/commons/commons_q_a/modules/commons_q_a_pages/commons_q_a_pages.features.inc new file mode 100644 index 0000000..7abcc63 --- /dev/null +++ b/modules/commons/commons_q_a/modules/commons_q_a_pages/commons_q_a_pages.features.inc @@ -0,0 +1,17 @@ + "1"); + } + if ($module == "strongarm" && $api == "strongarm") { + return array("version" => "1"); + } +} diff --git a/modules/commons/commons_q_a/modules/commons_q_a_pages/commons_q_a_pages.info b/modules/commons/commons_q_a/modules/commons_q_a_pages/commons_q_a_pages.info new file mode 100644 index 0000000..deb6d34 --- /dev/null +++ b/modules/commons/commons_q_a/modules/commons_q_a_pages/commons_q_a_pages.info @@ -0,0 +1,13 @@ +name = Commons Q&A Pages +description = Page layout settings for individual Question and Answe pages +core = 7.x +package = Commons - Landing pages +dependencies[] = ctools +dependencies[] = panelizer +dependencies[] = strongarm +features[ctools][] = panelizer:panelizer:1 +features[ctools][] = strongarm:strongarm:1 +features[features_api][] = api:2 +features[panelizer_defaults][] = node:question:default +features[variable][] = panelizer_defaults_node_answer +features[variable][] = panelizer_defaults_node_question diff --git a/modules/commons/commons_q_a/modules/commons_q_a_pages/commons_q_a_pages.module b/modules/commons/commons_q_a/modules/commons_q_a_pages/commons_q_a_pages.module new file mode 100644 index 0000000..0c6267f --- /dev/null +++ b/modules/commons/commons_q_a/modules/commons_q_a_pages/commons_q_a_pages.module @@ -0,0 +1,7 @@ +disabled = FALSE; /* Edit this to true to make a default panelizer disabled initially */ + $panelizer->api_version = 1; + $panelizer->name = 'node:question:default'; + $panelizer->title = 'Default'; + $panelizer->panelizer_type = 'node'; + $panelizer->panelizer_key = 'question'; + $panelizer->no_blocks = FALSE; + $panelizer->css_id = ''; + $panelizer->css = ''; + $panelizer->pipeline = 'standard'; + $panelizer->contexts = array(); + $panelizer->relationships = array(); + $panelizer->access = array(); + $panelizer->view_mode = 'page_manager'; + $panelizer->css_class = ''; + $panelizer->title_element = 'H2'; + $panelizer->link_to_entity = TRUE; + $panelizer->extra = ''; + $display = new panels_display(); + $display->layout = 'two_66_33'; + $display->layout_settings = array(); + $display->panel_settings = array( + 'style_settings' => array( + 'default' => NULL, + 'two_66_33_top' => NULL, + 'two_66_33_first' => NULL, + 'two_66_33_second' => NULL, + 'two_66_33_bottom' => NULL, + ), + ); + $display->cache = array(); + $display->title = '%node:title'; + $display->uuid = '2c245308-3234-c5b4-91e7-f5fe2f9da43d'; + $display->content = array(); + $display->panels = array(); + $pane = new stdClass(); + $pane->pid = 'new-41485caa-aed0-2114-ad9d-9c94d4087ce4'; + $pane->panel = 'two_66_33_first'; + $pane->type = 'node_content'; + $pane->subtype = 'node_content'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'links' => 1, + 'no_extras' => 0, + 'override_title' => 0, + 'override_title_text' => '', + 'identifier' => '', + 'link' => 0, + 'leave_node_title' => 1, + 'build_mode' => 'full', + 'context' => 'panelizer', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = '41485caa-aed0-2114-ad9d-9c94d4087ce4'; + $display->content['new-41485caa-aed0-2114-ad9d-9c94d4087ce4'] = $pane; + $display->panels['two_66_33_first'][0] = 'new-41485caa-aed0-2114-ad9d-9c94d4087ce4'; + $pane = new stdClass(); + $pane->pid = 'new-2e482384-35e1-4b64-a169-0972690b6228'; + $pane->panel = 'two_66_33_first'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_question_answers-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'context' => array( + 0 => 'panelizer', + ), + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 1; + $pane->locks = array(); + $pane->uuid = '2e482384-35e1-4b64-a169-0972690b6228'; + $display->content['new-2e482384-35e1-4b64-a169-0972690b6228'] = $pane; + $display->panels['two_66_33_first'][1] = 'new-2e482384-35e1-4b64-a169-0972690b6228'; + $display->hide_title = PANELS_TITLE_FIXED; + $display->title_pane = '0'; + $panelizer->display = $display; + $export['node:question:default'] = $panelizer; + + return $export; +} diff --git a/modules/commons/commons_q_a/modules/commons_q_a_pages/commons_q_a_pages.strongarm.inc b/modules/commons/commons_q_a/modules/commons_q_a_pages/commons_q_a_pages.strongarm.inc new file mode 100644 index 0000000..122d6cc --- /dev/null +++ b/modules/commons/commons_q_a/modules/commons_q_a_pages/commons_q_a_pages.strongarm.inc @@ -0,0 +1,66 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'panelizer_defaults_node_answer'; + $strongarm->value = array( + 'status' => 0, + 'view modes' => array( + 'page_manager' => array( + 'status' => 0, + 'default' => 0, + 'choice' => 0, + ), + 'default' => array( + 'status' => 0, + 'default' => 0, + 'choice' => 0, + ), + 'teaser' => array( + 'status' => 0, + 'default' => 0, + 'choice' => 0, + ), + ), + ); + $export['panelizer_defaults_node_answer'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'panelizer_defaults_node_question'; + $strongarm->value = array( + 'status' => 1, + 'view modes' => array( + 'page_manager' => array( + 'status' => 1, + 'default' => 1, + 'choice' => 0, + ), + 'default' => array( + 'status' => 0, + 'default' => 0, + 'choice' => 0, + ), + 'teaser' => array( + 'status' => 0, + 'default' => 0, + 'choice' => 0, + ), + ), + ); + $export['panelizer_defaults_node_question'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_radioactivity/commons_radioactivity.features.field_base.inc b/modules/commons/commons_radioactivity/commons_radioactivity.features.field_base.inc new file mode 100644 index 0000000..cc53940 --- /dev/null +++ b/modules/commons/commons_radioactivity/commons_radioactivity.features.field_base.inc @@ -0,0 +1,34 @@ + 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_radioactivity', + 'foreign keys' => array(), + 'indexes' => array( + 'energy' => array( + 0 => 'radioactivity_energy', + ), + ), + 'locked' => 0, + 'module' => 'radioactivity', + 'settings' => array(), + 'translatable' => 0, + 'type' => 'radioactivity', + ); + + return $field_bases; +} diff --git a/modules/commons/commons_radioactivity/commons_radioactivity.features.field_instance.inc b/modules/commons/commons_radioactivity/commons_radioactivity.features.field_instance.inc new file mode 100644 index 0000000..03574bc --- /dev/null +++ b/modules/commons/commons_radioactivity/commons_radioactivity.features.field_instance.inc @@ -0,0 +1,72 @@ + $bundles) { + foreach (array_keys($bundles) as $bundle) { + commons_radioactivity_field_definition($field_instances, $entity_type, $bundle); + } + } + } + return $field_instances; +} + +/** + * Contains a field definition export for the Radioactivity field for re-use + * across content types. + */ +function commons_radioactivity_field_definition(&$field_instances, $entity_type, $bundle) { + $field_instances["$entity_type-$bundle-field_radioactivity"] = array( + 'bundle' => $bundle, + 'default_value' => array( + 0 => array( + 'radioactivity_energy' => '8', + ), + ), + 'deleted' => '0', + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'radioactivity', + 'settings' => array( + 'energy' => 10, + 'type' => 'none', + 'accuracy' => '100', + ), + 'type' => 'radioactivity_combo_formatter', + 'weight' => 3, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => $entity_type, + 'field_name' => 'field_radioactivity', + 'label' => 'Radioactivity', + 'required' => 0, + 'settings' => array( + 'history_limit' => 8, + 'profile' => "commons_ra_$entity_type", + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 0, + 'module' => 'radioactivity', + 'settings' => array(), + 'type' => 'radioactivity_basic_widget', + 'weight' => '3', + )); +} \ No newline at end of file diff --git a/modules/commons/commons_radioactivity/commons_radioactivity.features.inc b/modules/commons/commons_radioactivity/commons_radioactivity.features.inc new file mode 100644 index 0000000..82ef197 --- /dev/null +++ b/modules/commons/commons_radioactivity/commons_radioactivity.features.inc @@ -0,0 +1,24 @@ + "1"); + } + if ($module == "strongarm" && $api == "strongarm") { + return array("version" => "1"); + } +} + +/** + * Implements hook_views_api(). + */ +function commons_radioactivity_views_api($module = NULL, $api = NULL) { + return array("api" => "3.0"); +} diff --git a/modules/commons/commons_radioactivity/commons_radioactivity.info b/modules/commons/commons_radioactivity/commons_radioactivity.info new file mode 100644 index 0000000..e3f4551 --- /dev/null +++ b/modules/commons/commons_radioactivity/commons_radioactivity.info @@ -0,0 +1,18 @@ +name = Commons Radioactivity +description = Helps to identify interesting content by automatically determining a decaying radioactivity value for individual pieces of conte +core = 7.x +package = Commons - Building blocks +dependencies[] = ctools +dependencies[] = features +dependencies[] = field_sql_storage +dependencies[] = radioactivity +dependencies[] = strongarm +dependencies[] = views +features[ctools][] = radioactivity:radioactivity_decay_profile:1 +features[ctools][] = strongarm:strongarm:1 +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[field_base][] = field_radioactivity +features[radioactivity_decay_profile][] = commons_ra_node +features[variable][] = commons_radioactivity_entity_types +features[views_view][] = commons_radioactivity_admin diff --git a/modules/commons/commons_radioactivity/commons_radioactivity.module b/modules/commons/commons_radioactivity/commons_radioactivity.module new file mode 100644 index 0000000..7a5cfe4 --- /dev/null +++ b/modules/commons/commons_radioactivity/commons_radioactivity.module @@ -0,0 +1,203 @@ +name == 'commons_radioactivity') { + $commons_radioactivity_entity_types = commons_radioactivity_get_radioactive_entity_types(); + if (!empty($commons_radioactivity_entity_types)) { + foreach ($commons_radioactivity_entity_types as $entity_type => $bundles) { + foreach(array_keys($bundles) as $bundle) { + $info['features']['field_instance'][] = "$entity_type-$bundle-field_radioactivity"; + } + } + } + } +} + +/** + * Implements hook_views_default_views_alter(). + */ +function commons_radioactivity_views_default_views_alter(&$views) { + // Add a "most active" exposed sort to Commons BW views. + foreach ($views as $view_id => $view) { + if (strpos($view_id, 'commons_bw_') === 0) { + $views[$view_id]->display['default']->display_options['sorts']['field_radioactivity_radioactivity_energy']['id'] = 'field_radioactivity_radioactivity_energy'; + $views[$view_id]->display['default']->display_options['sorts']['field_radioactivity_radioactivity_energy']['table'] = 'field_data_field_radioactivity'; + $views[$view_id]->display['default']->display_options['sorts']['field_radioactivity_radioactivity_energy']['field'] = 'field_radioactivity_radioactivity_energy'; + $views[$view_id]->display['default']->display_options['sorts']['field_radioactivity_radioactivity_energy']['order'] = 'DESC'; + $views[$view_id]->display['default']->display_options['sorts']['field_radioactivity_radioactivity_energy']['exposed'] = TRUE; + $views[$view_id]->display['default']->display_options['sorts']['field_radioactivity_radioactivity_energy']['expose']['label'] = 'most active'; + } + } +} + +/** + * Implements hook_features_pipe_alter(). + * + */ +function commons_radioactivity_features_pipe_alter(&$pipe, $data, $export) { + // Prevent Commons Radioactivity fields from being piped in features + // when a content type includes those fields. + if (!empty($pipe['field_instance'])) { + foreach ($pipe['field_instance'] as $delta => $value) { + $args = explode('-', $value); + $field_name = $args[2]; + if ($field_name == 'field_radioactivity') { + unset($pipe['field_instance'][$delta]); + } + } + } + if (!empty($pipe['field_base'])) { + foreach ($pipe['field_base'] as $delta => $value) { + if ($delta == 'field_radioactivity') { + unset($pipe['field_base'][$delta]); + } + } + } +} + +/** +* Returns an array of entity types that are enabled via Commons Radioactivity. +*/ +function commons_radioactivity_get_radioactive_entity_types() { + // Find all Commons Entity integrations. + $commons_entity_integrations = commons_entity_integration_info(); + if (empty($commons_entity_integrations)) { + return array(); + } + + foreach ($commons_entity_integrations as $entity_type => $integration) { + foreach ($integration as $bundle => $options) { + if (isset($options['radioactivity_exclude']) && $options['radioactivity_exclude'] == TRUE) { + unset($commons_entity_integrations[$entity_type][$bundle]); + } + } + // If an entity type has no integrations, don't return it. + if (empty($commons_entity_integrations[$entity_type])) { + unset($commons_entity_integrations[$entity_type]); + } + } + + return $commons_entity_integrations; + +} +/** +* Helper function to create Radioactivity incidents for nodes. +*/ +function commons_radioactivity_incident_node($node, $value) { + $profile = radioactivity_get_field_profile('node', $node->type, 'field_radioactivity'); + + // Return if radioactivity doesn't exist or hasn't been created for the node yet + if (empty($node->field_radioactivity)) { + return; + } + // Prevent groups from going negative in energy. + if ($node->type == 'group' && $node->field_radioactivity[LANGUAGE_NONE][0]['radioactivity_energy'] + $value < 0) { + return; + } + if ($profile && $profile->storageObject) { + $profile->storageObject->addIncident(new RadioactivityIncident('node', $node->type, 'field_radioactivity', LANGUAGE_NONE, $node->nid, $value, time())); + } + // If this node is a member of groups, generate an incident for each group. + if (!empty($node->og_group_ref)) { + commons_radioactivity_incident_groups($node, $value); + } +} + +/** +* Helper function to create Radioactivity incidents for groups +* to which a node belongs. +*/ +function commons_radioactivity_incident_groups($node, $value) { + $gids = array(); + foreach ($node->og_group_ref[LANGUAGE_NONE] as $field) { + $gids[] = $field['target_id']; + } + // @Todo: We may wish to instead simply select the types of these groups. + $groups = node_load_multiple($gids); + foreach ($groups as $group) { + commons_radioactivity_incident_node($group, $value); + } +} + +/** +* When a node is moved between groups, create incidents that offset +* the change in radioactivity for the former and newly containing groups. +*/ +function commons_radioactivity_process_node_group_membership_change($node) { + $gids_original = array(); + $gids_updated = array(); + $groups_removed = array(); + $groups_added = array(); + // Collect any gids from the original node. + if (!empty($node->original->og_group_ref[LANGUAGE_NONE])) { + foreach ($node->original->og_group_ref[LANGUAGE_NONE] as $key => $field) { + $gids_original[] = $field['target_id']; + } + } + // Collect any gids from the updated node. + if (!empty($node->og_group_ref[LANGUAGE_NONE])) { + foreach ($node->og_group_ref[LANGUAGE_NONE] as $key => $field) { + $gids_updated[] = $field['target_id']; + } + } + + // Find the gids that are being removed from the node with this update. + $gids_removed = array_diff($gids_original, $gids_updated); + // Find the gids that are being added to the node with this update. + $gids_added = array_diff($gids_updated, $gids_original); + + if (!empty($gids_removed)) { + $groups_removed = entity_load_multiple_by_name('node', $gids_removed); + // Add negative incidents for groups that are no longer associated + // with this node. + foreach ($groups_removed as $key => $group) { + // We create an incident equal to the negative current value of this node. + commons_radioactivity_incident_node($group, -1 * $node->field_radioactivity[LANGUAGE_NONE][0]['radioactivity_energy']); + } + } + // Add positive incidents for groups that are newly associated with this node. + if (!empty($gids_added)) { + $groups_added = entity_load_multiple_by_name('node', $gids_added); + foreach ($groups_added as $key => $group) { + commons_radioactivity_incident_node($group, $node->field_radioactivity[LANGUAGE_NONE][0]['radioactivity_energy']); + } + } +} diff --git a/modules/commons/commons_radioactivity/commons_radioactivity.radioactivity_decay_profile.inc b/modules/commons/commons_radioactivity/commons_radioactivity.radioactivity_decay_profile.inc new file mode 100644 index 0000000..6f73af9 --- /dev/null +++ b/modules/commons/commons_radioactivity/commons_radioactivity.radioactivity_decay_profile.inc @@ -0,0 +1,27 @@ +disabled = FALSE; /* Edit this to true to make a default radioactivity_decay_profile disabled initially */ + $radioactivity_decay_profile->api_version = 1; + $radioactivity_decay_profile->machine_name = 'commons_ra_node'; + $radioactivity_decay_profile->name = 'Commons Radioactivity (nodes)'; + $radioactivity_decay_profile->description = ''; + $radioactivity_decay_profile->enable_decay = 1; + $radioactivity_decay_profile->granularity = '60'; + $radioactivity_decay_profile->half_life = 21600; + $radioactivity_decay_profile->cut_off = '0.1'; + $radioactivity_decay_profile->storage = 'Live'; + $export['commons_ra_node'] = $radioactivity_decay_profile; + + return $export; +} diff --git a/modules/commons/commons_radioactivity/commons_radioactivity.strongarm.inc b/modules/commons/commons_radioactivity/commons_radioactivity.strongarm.inc new file mode 100644 index 0000000..71389df --- /dev/null +++ b/modules/commons/commons_radioactivity/commons_radioactivity.strongarm.inc @@ -0,0 +1,28 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'commons_radioactivity_entity_types'; + $strongarm->value = array( + 'node' => array( + 'group' => 1, + 'poll' => 1, + 'post' => 1, + 'wiki' => 1, + ), + ); + $export['commons_radioactivity_entity_types'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_radioactivity/commons_radioactivity.views_default.inc b/modules/commons/commons_radioactivity/commons_radioactivity.views_default.inc new file mode 100644 index 0000000..46325a7 --- /dev/null +++ b/modules/commons/commons_radioactivity/commons_radioactivity.views_default.inc @@ -0,0 +1,181 @@ +name = 'commons_radioactivity_admin'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'Commons Radioactivity Admin'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Commons Radioactivity Administrative page'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['access']['perm'] = 'administer content types'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['pager']['options']['items_per_page'] = '20'; + $handler->display->display_options['style_plugin'] = 'table'; + $handler->display->display_options['style_options']['columns'] = array( + 'title' => 'title', + 'type' => 'type', + 'name' => 'name', + 'field_radioactivity' => 'field_radioactivity', + 'created' => 'created', + 'last_updated' => 'last_updated', + ); + $handler->display->display_options['style_options']['default'] = 'field_radioactivity'; + $handler->display->display_options['style_options']['info'] = array( + 'title' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'type' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'name' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'field_radioactivity' => array( + 'sortable' => 1, + 'default_sort_order' => 'desc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'created' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'last_updated' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + ); + /* Relationship: Content: Author */ + $handler->display->display_options['relationships']['uid']['id'] = 'uid'; + $handler->display->display_options['relationships']['uid']['table'] = 'node'; + $handler->display->display_options['relationships']['uid']['field'] = 'uid'; + $handler->display->display_options['relationships']['uid']['required'] = TRUE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Field: Content: Type */ + $handler->display->display_options['fields']['type']['id'] = 'type'; + $handler->display->display_options['fields']['type']['table'] = 'node'; + $handler->display->display_options['fields']['type']['field'] = 'type'; + /* Field: User: Name */ + $handler->display->display_options['fields']['name']['id'] = 'name'; + $handler->display->display_options['fields']['name']['table'] = 'users'; + $handler->display->display_options['fields']['name']['field'] = 'name'; + $handler->display->display_options['fields']['name']['relationship'] = 'uid'; + $handler->display->display_options['fields']['name']['label'] = 'Author'; + /* Field: Content: Radioactivity */ + $handler->display->display_options['fields']['field_radioactivity']['id'] = 'field_radioactivity'; + $handler->display->display_options['fields']['field_radioactivity']['table'] = 'field_data_field_radioactivity'; + $handler->display->display_options['fields']['field_radioactivity']['field'] = 'field_radioactivity'; + $handler->display->display_options['fields']['field_radioactivity']['click_sort_column'] = 'radioactivity_energy'; + $handler->display->display_options['fields']['field_radioactivity']['settings'] = array( + 'energy' => '0', + 'type' => 'energy', + ); + /* Field: Content: Post date */ + $handler->display->display_options['fields']['created']['id'] = 'created'; + $handler->display->display_options['fields']['created']['table'] = 'node'; + $handler->display->display_options['fields']['created']['field'] = 'created'; + $handler->display->display_options['fields']['created']['label'] = 'Created'; + $handler->display->display_options['fields']['created']['date_format'] = 'short'; + /* Field: Content: Updated/commented date */ + $handler->display->display_options['fields']['last_updated']['id'] = 'last_updated'; + $handler->display->display_options['fields']['last_updated']['table'] = 'node_comment_statistics'; + $handler->display->display_options['fields']['last_updated']['field'] = 'last_updated'; + $handler->display->display_options['fields']['last_updated']['label'] = 'Last update/comment'; + $handler->display->display_options['fields']['last_updated']['date_format'] = 'short'; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Content: Radioactivity (field_radioactivity:radioactivity_energy) */ + $handler->display->display_options['filters']['field_radioactivity_radioactivity_energy']['id'] = 'field_radioactivity_radioactivity_energy'; + $handler->display->display_options['filters']['field_radioactivity_radioactivity_energy']['table'] = 'field_data_field_radioactivity'; + $handler->display->display_options['filters']['field_radioactivity_radioactivity_energy']['field'] = 'field_radioactivity_radioactivity_energy'; + $handler->display->display_options['filters']['field_radioactivity_radioactivity_energy']['operator'] = '>'; + $handler->display->display_options['filters']['field_radioactivity_radioactivity_energy']['value']['value'] = '0'; + + /* Display: Page */ + $handler = $view->new_display('page', 'Page', 'page'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['path'] = 'commons-radioactivity-admin'; + $translatables['commons_radioactivity_admin'] = array( + t('Master'), + t('Commons Radioactivity Administrative page'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('author'), + t('Title'), + t('Type'), + t('Author'), + t('Radioactivity'), + t('Created'), + t('Last update/comment'), + t('Page'), + ); + $export['commons_radioactivity_admin'] = $view; + + return $export; +} diff --git a/modules/commons/commons_radioactivity/commons_radioactivity_groups/commons_radioactivity_groups.features.inc b/modules/commons/commons_radioactivity/commons_radioactivity_groups/commons_radioactivity_groups.features.inc new file mode 100644 index 0000000..fd3ce07 --- /dev/null +++ b/modules/commons/commons_radioactivity/commons_radioactivity_groups/commons_radioactivity_groups.features.inc @@ -0,0 +1,12 @@ + "3.0"); +} diff --git a/modules/commons/commons_radioactivity/commons_radioactivity_groups/commons_radioactivity_groups.info b/modules/commons/commons_radioactivity/commons_radioactivity_groups/commons_radioactivity_groups.info new file mode 100644 index 0000000..54e8dd2 --- /dev/null +++ b/modules/commons/commons_radioactivity/commons_radioactivity_groups/commons_radioactivity_groups.info @@ -0,0 +1,12 @@ +name = Commons Radioactivity Groups +description = Views integration for Group radioactivity +core = 7.x +package = Commons - Building Blocks +dependencies[] = commons_radioactivity +dependencies[] = og +dependencies[] = views_content +dependencies[] = views_field_view +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[views_view][] = commons_radioactivity_groups_active_in_group +features[views_view][] = commons_radioactivity_groups_most_active diff --git a/modules/commons/commons_radioactivity/commons_radioactivity_groups/commons_radioactivity_groups.install b/modules/commons/commons_radioactivity/commons_radioactivity_groups/commons_radioactivity_groups.install new file mode 100644 index 0000000..cb52424 --- /dev/null +++ b/modules/commons/commons_radioactivity/commons_radioactivity_groups/commons_radioactivity_groups.install @@ -0,0 +1,12 @@ + array('views_view'), + ); + features_revert($revert); + return array(); +} diff --git a/modules/commons/commons_radioactivity/commons_radioactivity_groups/commons_radioactivity_groups.module b/modules/commons/commons_radioactivity/commons_radioactivity_groups/commons_radioactivity_groups.module new file mode 100644 index 0000000..4a0d282 --- /dev/null +++ b/modules/commons/commons_radioactivity/commons_radioactivity_groups/commons_radioactivity_groups.module @@ -0,0 +1,33 @@ +og_group_ref) || !isset($node->field_radioactivity[LANGUAGE_NONE][0]['radioactivity_energy'])) { + return; + } + commons_radioactivity_incident_groups($node, $node->field_radioactivity[LANGUAGE_NONE][0]['radioactivity_energy']); +} + +/** +* Implements hook_node_update(). +*/ +function commons_radioactivity_groups_node_update($node) { + // If there are no groups associated with this node + // then there's nothing to do here. + if (!isset($node->og_group_ref)) { + return; + } + if ($node->og_group_ref !== $node->original->og_group_ref) { + commons_radioactivity_process_node_group_membership_change($node); + } +} \ No newline at end of file diff --git a/modules/commons/commons_radioactivity/commons_radioactivity_groups/commons_radioactivity_groups.views_default.inc b/modules/commons/commons_radioactivity/commons_radioactivity_groups/commons_radioactivity_groups.views_default.inc new file mode 100644 index 0000000..5b412f5 --- /dev/null +++ b/modules/commons/commons_radioactivity/commons_radioactivity_groups/commons_radioactivity_groups.views_default.inc @@ -0,0 +1,239 @@ +name = 'commons_radioactivity_groups_active_in_group'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'Commons Radioactivity - Active content in a group'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Active in this group'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* Relationship: OG membership: OG membership from Node */ + $handler->display->display_options['relationships']['og_membership_rel']['id'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['table'] = 'node'; + $handler->display->display_options['relationships']['og_membership_rel']['field'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['required'] = TRUE; + /* Field: Content: Type */ + $handler->display->display_options['fields']['type']['id'] = 'type'; + $handler->display->display_options['fields']['type']['table'] = 'node'; + $handler->display->display_options['fields']['type']['field'] = 'type'; + $handler->display->display_options['fields']['type']['label'] = ''; + $handler->display->display_options['fields']['type']['exclude'] = TRUE; + $handler->display->display_options['fields']['type']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['type']['machine_name'] = TRUE; + /* Field: Content: Nid */ + $handler->display->display_options['fields']['nid']['id'] = 'nid'; + $handler->display->display_options['fields']['nid']['table'] = 'node'; + $handler->display->display_options['fields']['nid']['field'] = 'nid'; + $handler->display->display_options['fields']['nid']['label'] = ''; + $handler->display->display_options['fields']['nid']['exclude'] = TRUE; + $handler->display->display_options['fields']['nid']['element_label_colon'] = FALSE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + $handler->display->display_options['fields']['title']['element_class'] = 'type-[type]'; + $handler->display->display_options['fields']['title']['element_label_colon'] = FALSE; + /* Field: Global: View */ + $handler->display->display_options['fields']['view']['id'] = 'view'; + $handler->display->display_options['fields']['view']['table'] = 'views'; + $handler->display->display_options['fields']['view']['field'] = 'view'; + $handler->display->display_options['fields']['view']['label'] = ''; + $handler->display->display_options['fields']['view']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['view']['hide_empty'] = TRUE; + $handler->display->display_options['fields']['view']['view'] = 'commons_groups_recent_content'; + $handler->display->display_options['fields']['view']['arguments'] = '[!nid]'; + /* Sort criterion: Content: Radioactivity (field_radioactivity:radioactivity_energy) */ + $handler->display->display_options['sorts']['field_radioactivity_radioactivity_energy']['id'] = 'field_radioactivity_radioactivity_energy'; + $handler->display->display_options['sorts']['field_radioactivity_radioactivity_energy']['table'] = 'field_data_field_radioactivity'; + $handler->display->display_options['sorts']['field_radioactivity_radioactivity_energy']['field'] = 'field_radioactivity_radioactivity_energy'; + $handler->display->display_options['sorts']['field_radioactivity_radioactivity_energy']['order'] = 'DESC'; + /* Contextual filter: OG membership: Group ID */ + $handler->display->display_options['arguments']['gid']['id'] = 'gid'; + $handler->display->display_options['arguments']['gid']['table'] = 'og_membership'; + $handler->display->display_options['arguments']['gid']['field'] = 'gid'; + $handler->display->display_options['arguments']['gid']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['arguments']['gid']['default_action'] = 'not found'; + $handler->display->display_options['arguments']['gid']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['gid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['gid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['gid']['summary_options']['items_per_page'] = '25'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Content: Radioactivity (field_radioactivity:radioactivity_energy) */ + $handler->display->display_options['filters']['field_radioactivity_radioactivity_energy']['id'] = 'field_radioactivity_radioactivity_energy'; + $handler->display->display_options['filters']['field_radioactivity_radioactivity_energy']['table'] = 'field_data_field_radioactivity'; + $handler->display->display_options['filters']['field_radioactivity_radioactivity_energy']['field'] = 'field_radioactivity_radioactivity_energy'; + $handler->display->display_options['filters']['field_radioactivity_radioactivity_energy']['operator'] = '>='; + $handler->display->display_options['filters']['field_radioactivity_radioactivity_energy']['value']['value'] = '.1'; + /* Filter criterion: OG membership: Group_type */ + $handler->display->display_options['filters']['group_type']['id'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['table'] = 'og_membership'; + $handler->display->display_options['filters']['group_type']['field'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['filters']['group_type']['value'] = array( + 'node' => 'node', + ); + + /* Display: Content pane */ + $handler = $view->new_display('panel_pane', 'Content pane', 'panel_pane_1'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['pane_category']['name'] = 'Commons'; + $handler->display->display_options['pane_category']['weight'] = '0'; + $handler->display->display_options['argument_input'] = array( + 'gid' => array( + 'type' => 'context', + 'context' => 'entity:node.nid', + 'context_optional' => 0, + 'panel' => '0', + 'fixed' => '', + 'label' => 'OG membership: Group ID', + ), + ); + $translatables['commons_radioactivity_groups_active_in_group'] = array( + t('Master'), + t('Active in this group'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('OG membership from node'), + t('All'), + t('Content pane'), + t('Commons'), + ); + $export['commons_radioactivity_groups_active_in_group'] = $view; + + $view = new view(); + $view->name = 'commons_radioactivity_groups_most_active'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'Most Active Groups'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Most active groups'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['pager']['options']['items_per_page'] = '3'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* Field: Content: Nid */ + $handler->display->display_options['fields']['nid']['id'] = 'nid'; + $handler->display->display_options['fields']['nid']['table'] = 'node'; + $handler->display->display_options['fields']['nid']['field'] = 'nid'; + $handler->display->display_options['fields']['nid']['label'] = ''; + $handler->display->display_options['fields']['nid']['exclude'] = TRUE; + $handler->display->display_options['fields']['nid']['element_label_colon'] = FALSE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Field: Global: View */ + $handler->display->display_options['fields']['view']['id'] = 'view'; + $handler->display->display_options['fields']['view']['table'] = 'views'; + $handler->display->display_options['fields']['view']['field'] = 'view'; + $handler->display->display_options['fields']['view']['label'] = ''; + $handler->display->display_options['fields']['view']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['view']['hide_empty'] = TRUE; + $handler->display->display_options['fields']['view']['view'] = 'commons_groups_recent_content'; + $handler->display->display_options['fields']['view']['arguments'] = '[!nid]'; + /* Sort criterion: Content: Radioactivity (field_radioactivity:radioactivity_energy) */ + $handler->display->display_options['sorts']['field_radioactivity_radioactivity_energy']['id'] = 'field_radioactivity_radioactivity_energy'; + $handler->display->display_options['sorts']['field_radioactivity_radioactivity_energy']['table'] = 'field_data_field_radioactivity'; + $handler->display->display_options['sorts']['field_radioactivity_radioactivity_energy']['field'] = 'field_radioactivity_radioactivity_energy'; + $handler->display->display_options['sorts']['field_radioactivity_radioactivity_energy']['order'] = 'DESC'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Field: Group (group_group) */ + $handler->display->display_options['filters']['group_group_value']['id'] = 'group_group_value'; + $handler->display->display_options['filters']['group_group_value']['table'] = 'field_data_group_group'; + $handler->display->display_options['filters']['group_group_value']['field'] = 'group_group_value'; + $handler->display->display_options['filters']['group_group_value']['value'] = array( + 1 => '1', + ); + /* Filter criterion: Content: Radioactivity (field_radioactivity:radioactivity_energy) */ + $handler->display->display_options['filters']['field_radioactivity_radioactivity_energy']['id'] = 'field_radioactivity_radioactivity_energy'; + $handler->display->display_options['filters']['field_radioactivity_radioactivity_energy']['table'] = 'field_data_field_radioactivity'; + $handler->display->display_options['filters']['field_radioactivity_radioactivity_energy']['field'] = 'field_radioactivity_radioactivity_energy'; + $handler->display->display_options['filters']['field_radioactivity_radioactivity_energy']['operator'] = '>='; + $handler->display->display_options['filters']['field_radioactivity_radioactivity_energy']['value']['value'] = '.1'; + + /* Display: Content pane */ + $handler = $view->new_display('panel_pane', 'Content pane', 'panel_pane_1'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['pane_category']['name'] = 'Commons'; + $handler->display->display_options['pane_category']['weight'] = '0'; + $translatables['commons_radioactivity_groups_most_active'] = array( + t('Master'), + t('Most active groups'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Content pane'), + t('Commons'), + ); + $export['commons_radioactivity_groups_most_active'] = $view; + + return $export; +} diff --git a/modules/commons/commons_radioactivity/includes/incidents/commons_radioactivity.incidents_comment.inc b/modules/commons/commons_radioactivity/includes/incidents/commons_radioactivity.incidents_comment.inc new file mode 100644 index 0000000..9d4f96a --- /dev/null +++ b/modules/commons/commons_radioactivity/includes/incidents/commons_radioactivity.incidents_comment.inc @@ -0,0 +1,60 @@ +status) { + return; + } + $node = node_load($comment->nid); + // A user's comment on her own node should not add radioactivity. + if ($node->uid == $comment->uid) { + return; + } + commons_radioactivity_incident_node($node, COMMONS_RADIOACTIVITY_COMMENT); +} + +/** +* Implements hook_comment_insert(). +* Increase Radioactivity when a node recieves a comment. +*/ +function commons_radioactivity_comment_delete($comment) { + // Deleting a comment that wasn't published shouldn't affect radioactivity. + if (!$comment->status) { + return; + } + $node = node_load($comment->nid); + // This comment didn't add radioactivity originally, so we don't need to + // offset any with its deletion. + if ($node->uid == $comment->uid) { + return; + } + commons_radioactivity_incident_node($node, -1 * COMMONS_RADIOACTIVITY_COMMENT); +} + +/** +* Implements hook_comment_update(). +* Change radioactivity when a comment is published or unpuiblished. +*/ +function commons_radioactivity_comment_update($comment) { + // $comment_change will be equal to 1 if we're changing the publishing status + // of the comment. + $comment_change = $comment->status + $comment->original->status; + // Is this comment's published status changing? + if ($comment_change == 1) { + $node = node_load($comment->nid); + switch ($comment->status) { + // The comment is being unpublished. + case 0: + commons_radioactivity_comment_delete($comment); + break; + // The comment is being published. + case 1; + commons_radioactivity_comment_insert($comment); + break; + } + } +} \ No newline at end of file diff --git a/modules/commons/commons_radioactivity/includes/incidents/commons_radioactivity.incidents_flag.inc b/modules/commons/commons_radioactivity/includes/incidents/commons_radioactivity.incidents_flag.inc new file mode 100644 index 0000000..c2d6794 --- /dev/null +++ b/modules/commons/commons_radioactivity/includes/incidents/commons_radioactivity.incidents_flag.inc @@ -0,0 +1,28 @@ +name, array('commons_follow_node', 'commons_follow_group'))) { + + $node = node_load($content_id); + + if ($op == 'flag') { + // A user following her own node shouldn't add to its radioactivity. + if ($node->uid == $account->uid) { + return; + } + commons_radioactivity_incident_node($node, COMMONS_RADIOACTIVITY_FLAG_NODE); + } + + if ($op == 'unflag') { + // A user unfollowing her own node shouldn't add to its radioactivity. + if ($node->uid == $account->uid) { + return; + } + commons_radioactivity_incident_node($node, -1 * COMMONS_RADIOACTIVITY_FLAG_NODE); + } + } +} diff --git a/modules/commons/commons_radioactivity/includes/incidents/commons_radioactivity.incidents_votingapi.inc b/modules/commons/commons_radioactivity/includes/incidents/commons_radioactivity.incidents_votingapi.inc new file mode 100644 index 0000000..a075ccb --- /dev/null +++ b/modules/commons/commons_radioactivity/includes/incidents/commons_radioactivity.incidents_votingapi.inc @@ -0,0 +1,34 @@ +uid != $vote['uid']) { + commons_radioactivity_incident_node($node, COMMONS_RADIOACTIVITY_LIKE); + } + } + } +} + +/** +* Implements hook_votingapi_insert(). +* Decrease Radioactivity when a "Like" is cancelled. +*/ +function commons_radioactivity_votingapi_delete($votes) { + foreach ($votes as $vote) { + if (isset($vote['tag']) && $vote['tag'] == 'commons_like' && $vote['entity_type'] == 'node') { + $node = node_load($vote['entity_id']); + // A user's vote on her own node did not increase radioactivity, so + // we don't need to offset it when the vote is deleted. + if ($node->uid != $vote['uid']) { + commons_radioactivity_incident_node($node, -1 * COMMONS_RADIOACTIVITY_LIKE); + } + } + } +} diff --git a/modules/commons/commons_search/commons_search.features.inc b/modules/commons/commons_search/commons_search.features.inc new file mode 100644 index 0000000..61b7b0e --- /dev/null +++ b/modules/commons/commons_search/commons_search.features.inc @@ -0,0 +1,26 @@ + "1"); + } + list($module, $api) = func_get_args(); + if ($module == "strongarm" && $api == "strongarm") { + return array("version" => "1"); + } +} + +/** + * Implements hook_views_api(). + */ +function commons_search_views_api() { + return array("api" => "3.0"); +} diff --git a/modules/commons/commons_search/commons_search.features.menu_links.inc b/modules/commons/commons_search/commons_search.features.menu_links.inc new file mode 100644 index 0000000..7246f98 --- /dev/null +++ b/modules/commons/commons_search/commons_search.features.menu_links.inc @@ -0,0 +1,36 @@ + 'main-menu', + 'link_path' => 'search', + 'router_path' => 'search', + 'link_title' => 'Search', + 'options' => array( + 'attributes' => array(), + ), + 'module' => 'menu', + 'hidden' => 0, + 'external' => 0, + 'has_children' => 0, + 'expanded' => 0, + 'weight' => 3, + 'customized' => 1, + ); + // Translatables + // Included for use with string extractors like potx. + t('Search'); + + + return $menu_links; +} diff --git a/modules/commons/commons_search/commons_search.features.user_permission.inc b/modules/commons/commons_search/commons_search.features.user_permission.inc new file mode 100644 index 0000000..86974d4 --- /dev/null +++ b/modules/commons/commons_search/commons_search.features.user_permission.inc @@ -0,0 +1,47 @@ + 'search content', + 'roles' => array( + 'administrator' => 'administrator', + 'anonymous user' => 'anonymous user', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'search', + ); + + // Exported permission: use advanced search. + $permissions['use advanced search'] = array( + 'name' => 'use advanced search', + 'roles' => array( + 'administrator' => 'administrator', + 'anonymous user' => 'anonymous user', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'search', + ); + + // Exported permission: use custom search. + $permissions['use custom search'] = array( + 'name' => 'use custom search', + 'roles' => array( + 'administrator' => 'administrator', + 'anonymous user' => 'anonymous user', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'custom_search', + ); + + return $permissions; +} diff --git a/modules/commons/commons_search/commons_search.info b/modules/commons/commons_search/commons_search.info new file mode 100644 index 0000000..a1789c7 --- /dev/null +++ b/modules/commons/commons_search/commons_search.info @@ -0,0 +1,63 @@ +name = Commons Search +description = Provide the global search block. +core = 7.x +package = Commons - Search +dependencies[] = ctools +dependencies[] = custom_search +dependencies[] = features +dependencies[] = search +dependencies[] = strongarm +dependencies[] = views +dependencies[] = views_load_more +stylesheets[all][] = css/commons_search.css +features[ctools][] = panelizer:panelizer:1 +features[ctools][] = strongarm:strongarm:1 +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:1 +features[menu_links][] = main-menu:search +features[user_permission][] = search content +features[user_permission][] = use advanced search +features[user_permission][] = use custom search +features[variable][] = custom_search_any_force +features[variable][] = custom_search_any_restricts +features[variable][] = custom_search_content_types_region +features[variable][] = custom_search_content_types_weight +features[variable][] = custom_search_criteria_negative_display +features[variable][] = custom_search_criteria_negative_label +features[variable][] = custom_search_criteria_negative_region +features[variable][] = custom_search_criteria_negative_weight +features[variable][] = custom_search_criteria_or_display +features[variable][] = custom_search_criteria_or_label +features[variable][] = custom_search_criteria_or_region +features[variable][] = custom_search_criteria_or_weight +features[variable][] = custom_search_criteria_phrase_display +features[variable][] = custom_search_criteria_phrase_label +features[variable][] = custom_search_criteria_phrase_region +features[variable][] = custom_search_criteria_phrase_weight +features[variable][] = custom_search_custom_paths_region +features[variable][] = custom_search_custom_paths_weight +features[variable][] = custom_search_delta +features[variable][] = custom_search_image +features[variable][] = custom_search_image_path +features[variable][] = custom_search_label +features[variable][] = custom_search_label_visibility +features[variable][] = custom_search_max_length +features[variable][] = custom_search_node_types +features[variable][] = custom_search_node_types_excluded +features[variable][] = custom_search_order +features[variable][] = custom_search_paths +features[variable][] = custom_search_paths_selector +features[variable][] = custom_search_paths_selector_label +features[variable][] = custom_search_paths_selector_label_visibility +features[variable][] = custom_search_search_box_region +features[variable][] = custom_search_search_box_weight +features[variable][] = custom_search_size +features[variable][] = custom_search_submit_button_region +features[variable][] = custom_search_submit_button_weight +features[variable][] = custom_search_submit_text +features[variable][] = custom_search_text +features[variable][] = custom_search_type_selector +features[variable][] = custom_search_type_selector_all +features[variable][] = custom_search_type_selector_label +features[variable][] = custom_search_type_selector_label_visibility +features[views_view][] = group_search \ No newline at end of file diff --git a/modules/commons/commons_search/commons_search.install b/modules/commons/commons_search/commons_search.install new file mode 100644 index 0000000..5b26689 --- /dev/null +++ b/modules/commons/commons_search/commons_search.install @@ -0,0 +1,8 @@ + t('Site'), + 'c-user' => t('Users'), + ); + $group = FALSE; + $node = current_path(); + if ((strrpos($node, 'node/') !== FALSE || strrpos($node, 'group/') !== FALSE) + && is_numeric(substr($node, strrpos($node, '/') + 1)) + ) { + // If we're on a page that looks like a group node, see if it is actually + // a group node. + $node = node_load(substr($node, strrpos($node, '/') + 1)); + if (!empty($node)) { + $group = ($node->type == 'group'); + } + } + if ($group) { + // Current page is a group node, so add group search option to the + // dropdown menu and set the current group id. + $form['custom_search_types']['#options']['o-commons_search'] = t('This group'); + $form['custom_search_types']["#default_value"] = 'o-commons_search'; + $form_state['search_group_id'] = $node->nid; + } + if (arg(0) == 'search') { + // If we've already searched, refill the search box with the current + // search keywords. + $form['search_block_form']['#default_value'] = check_plain(arg(2)); + } + $keys = arg(2); + if (!module_exists('commons_search_solr') && !empty($keys)) { + // Remove the search keys from the form action only if we're using core search. + $form['#action'] = str_replace("/" . check_plain(arg(2)), '', $form['#action']); + } + } +} + +/** + * Search form submit handler. + * Add group id filter if appropriate. + */ +function commons_search_search_form_submit($form, &$form_state) { + if ($form_state['values']['custom_search_types'] == 'o-commons_search' + && isset($form_state['search_group_id']) + ) { + $keys = $form_state['values']['search_block_form']; + if (module_exists('apachesolr_search')) { + // Add on a filter to the solr query to only list results within the + // specified group. + $qm = (strpos($form_state['redirect'], '?') !== FALSE ? '' : '?'); + $form_state['redirect'] .= $qm . '&f[1]=sm_og_group_ref:node:' . $form_state['search_group_id']; + } + else { + // Using core search to search within a group doesn't work, so we simply + // use a view with exposed search terms to do the searching. + drupal_goto('search/group/' . $form_state['search_group_id'], array('query' => array('keys' => $keys))); + } + } + else { + if ($form_state['values']['custom_search_types'] == 'c-user') { + // Force update the redirect on User search since Custom Search is weird. + $keys = check_plain($form_state['values']['search_block_form']); + $form_state['redirect'] = 'search/user/' . $keys; + } + } +} + +function commons_search_process_search_result(&$variables) { +} +/** + * Implements hook_preprocess_hook(). + */ +function commons_search_process_search_results(&$variables) { + $variables['result_count'] = count($variables['results']); + if (isset($variables['response']) + && isset($variables['response']->request) + && preg_match('/sm_og_group_ref:"node:([0-9]+)"&/', urldecode($variables['response']->request), $match) + ) { + $group = node_load($match[1]); + $title = t('Search within !group', array('!group' => '' . $group->title . '')); + $variables['title'] = $title; + } +} + +/** + * Implements hook_theme_registry_alter(). + */ +function commons_search_theme_registry_alter(&$theme_registry) { + // Remove AT breadcrumb preprocess since it adds raw RDFa data into the title. + $theme_registry['breadcrumb']['preprocess functions'] = array_flip($theme_registry['breadcrumb']['preprocess functions']); + unset($theme_registry['breadcrumb']['preprocess functions']['adaptivetheme_preprocess_breadcrumb']); + $theme_registry['breadcrumb']['preprocess functions'] = array_flip($theme_registry['breadcrumb']['preprocess functions']); +} diff --git a/modules/commons/commons_search/commons_search.strongarm.inc b/modules/commons/commons_search/commons_search.strongarm.inc new file mode 100644 index 0000000..5b4734d --- /dev/null +++ b/modules/commons/commons_search/commons_search.strongarm.inc @@ -0,0 +1,353 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_any_force'; + $strongarm->value = 1; + $export['custom_search_any_force'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_any_restricts'; + $strongarm->value = 0; + $export['custom_search_any_restricts'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_content_types_region'; + $strongarm->value = 'block'; + $export['custom_search_content_types_region'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_content_types_weight'; + $strongarm->value = '0'; + $export['custom_search_content_types_weight'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_criteria_negative_display'; + $strongarm->value = 0; + $export['custom_search_criteria_negative_display'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_criteria_negative_label'; + $strongarm->value = 'Containing none of the words'; + $export['custom_search_criteria_negative_label'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_criteria_negative_region'; + $strongarm->value = 'block'; + $export['custom_search_criteria_negative_region'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_criteria_negative_weight'; + $strongarm->value = '8'; + $export['custom_search_criteria_negative_weight'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_criteria_or_display'; + $strongarm->value = 0; + $export['custom_search_criteria_or_display'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_criteria_or_label'; + $strongarm->value = 'Containing any of the words'; + $export['custom_search_criteria_or_label'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_criteria_or_region'; + $strongarm->value = 'block'; + $export['custom_search_criteria_or_region'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_criteria_or_weight'; + $strongarm->value = '6'; + $export['custom_search_criteria_or_weight'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_criteria_phrase_display'; + $strongarm->value = 0; + $export['custom_search_criteria_phrase_display'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_criteria_phrase_label'; + $strongarm->value = 'Containing the phrase'; + $export['custom_search_criteria_phrase_label'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_criteria_phrase_region'; + $strongarm->value = 'block'; + $export['custom_search_criteria_phrase_region'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_criteria_phrase_weight'; + $strongarm->value = '7'; + $export['custom_search_criteria_phrase_weight'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_custom_paths_region'; + $strongarm->value = 'block'; + $export['custom_search_custom_paths_region'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_custom_paths_weight'; + $strongarm->value = '9'; + $export['custom_search_custom_paths_weight'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_delta'; + $strongarm->value = ''; + $export['custom_search_delta'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_image'; + $strongarm->value = ''; + $export['custom_search_image'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_image_path'; + $strongarm->value = ''; + $export['custom_search_image_path'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_label'; + $strongarm->value = ''; + $export['custom_search_label'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_label_visibility'; + $strongarm->value = 1; + $export['custom_search_label_visibility'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_max_length'; + $strongarm->value = '128'; + $export['custom_search_max_length'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_node_types'; + $strongarm->value = array( + 'document' => 0, + 'event' => 0, + 'group' => 0, + 'notice' => 0, + 'page' => 0, + 'post' => 0, + 'wiki' => 0, + ); + $export['custom_search_node_types'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_node_types_excluded'; + $strongarm->value = array( + 'document' => 0, + 'event' => 0, + 'group' => 0, + 'notice' => 0, + 'page' => 0, + 'post' => 0, + 'wiki' => 0, + ); + $export['custom_search_node_types_excluded'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_order'; + $strongarm->value = array( + 'search_box' => array( + 'sort' => '-1', + 'region' => 'block', + ), + 'criteria_or' => array( + 'sort' => '6', + 'region' => 'block', + ), + 'criteria_phrase' => array( + 'sort' => '7', + 'region' => 'block', + ), + 'criteria_negative' => array( + 'sort' => '8', + 'region' => 'block', + ), + 'custom_paths' => array( + 'sort' => '9', + 'region' => 'block', + ), + 'submit_button' => array( + 'sort' => '10', + 'region' => 'block', + ), + 'content_types' => array( + 'sort' => '0', + 'region' => 'block', + ), + ); + $export['custom_search_order'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_paths'; + $strongarm->value = ''; + $export['custom_search_paths'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_paths_selector'; + $strongarm->value = 'select'; + $export['custom_search_paths_selector'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_paths_selector_label'; + $strongarm->value = 'Customize your search'; + $export['custom_search_paths_selector_label'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_paths_selector_label_visibility'; + $strongarm->value = 0; + $export['custom_search_paths_selector_label_visibility'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_search_box_region'; + $strongarm->value = 'block'; + $export['custom_search_search_box_region'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_search_box_weight'; + $strongarm->value = '-1'; + $export['custom_search_search_box_weight'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_size'; + $strongarm->value = '15'; + $export['custom_search_size'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_submit_button_region'; + $strongarm->value = 'block'; + $export['custom_search_submit_button_region'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_submit_button_weight'; + $strongarm->value = '10'; + $export['custom_search_submit_button_weight'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_submit_text'; + $strongarm->value = 'Search'; + $export['custom_search_submit_text'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_text'; + $strongarm->value = ''; + $export['custom_search_text'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_type_selector'; + $strongarm->value = 'select'; + $export['custom_search_type_selector'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_type_selector_all'; + $strongarm->value = 'Site'; + $export['custom_search_type_selector_all'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_type_selector_label'; + $strongarm->value = 'Search for'; + $export['custom_search_type_selector_label'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_type_selector_label_visibility'; + $strongarm->value = 0; + $export['custom_search_type_selector_label_visibility'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_search/commons_search.views_default.inc b/modules/commons/commons_search/commons_search.views_default.inc new file mode 100644 index 0000000..010c402 --- /dev/null +++ b/modules/commons/commons_search/commons_search.views_default.inc @@ -0,0 +1,124 @@ +name = 'group_search'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'Group Search'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Search within group'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['exposed_form']['options']['expose_sort_order'] = FALSE; + $handler->display->display_options['exposed_form']['options']['autosubmit'] = TRUE; + $handler->display->display_options['pager']['type'] = 'load_more'; + $handler->display->display_options['pager']['options']['items_per_page'] = '10'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '0'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'node'; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'No results found.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: OG membership: OG membership from Node */ + $handler->display->display_options['relationships']['og_membership_rel']['id'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['table'] = 'node'; + $handler->display->display_options['relationships']['og_membership_rel']['field'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['required'] = TRUE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Search: Score */ + $handler->display->display_options['sorts']['score']['id'] = 'score'; + $handler->display->display_options['sorts']['score']['table'] = 'search_index'; + $handler->display->display_options['sorts']['score']['field'] = 'score'; + $handler->display->display_options['sorts']['score']['order'] = 'DESC'; + /* Contextual filter: OG membership: Group ID */ + $handler->display->display_options['arguments']['gid']['id'] = 'gid'; + $handler->display->display_options['arguments']['gid']['table'] = 'og_membership'; + $handler->display->display_options['arguments']['gid']['field'] = 'gid'; + $handler->display->display_options['arguments']['gid']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['arguments']['gid']['default_action'] = 'empty'; + $handler->display->display_options['arguments']['gid']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['gid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['gid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['gid']['summary_options']['items_per_page'] = '25'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Search: Search Terms */ + $handler->display->display_options['filters']['keys']['id'] = 'keys'; + $handler->display->display_options['filters']['keys']['table'] = 'search_index'; + $handler->display->display_options['filters']['keys']['field'] = 'keys'; + $handler->display->display_options['filters']['keys']['exposed'] = TRUE; + $handler->display->display_options['filters']['keys']['expose']['operator_id'] = 'keys_op'; + $handler->display->display_options['filters']['keys']['expose']['label'] = 'Search Terms'; + $handler->display->display_options['filters']['keys']['expose']['operator'] = 'keys_op'; + $handler->display->display_options['filters']['keys']['expose']['identifier'] = 'keys'; + $handler->display->display_options['filters']['keys']['expose']['remember_roles'] = array( + 2 => '2', + 1 => 0, + ); + + /* Display: Page */ + $handler = $view->new_display('page', 'Page', 'page_1'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['path'] = 'search/group/%'; + $translatables['group_search'] = array( + t('Master'), + t('Search within group'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('No results found.'), + t('OG membership from node'), + t('All'), + t('Search Terms'), + t('Page'), + ); + $export['group_search'] = $view; + + return $export; +} diff --git a/modules/commons/commons_search/css/commons_search.css b/modules/commons/commons_search/css/commons_search.css new file mode 100644 index 0000000..6885430 --- /dev/null +++ b/modules/commons/commons_search/css/commons_search.css @@ -0,0 +1,3 @@ +div.view-group-search div.view-filters { + /*display: none;*/ +} \ No newline at end of file diff --git a/modules/commons/commons_search/modules/commons_search_core/commons_search_core.facetapi_defaults.inc b/modules/commons/commons_search/modules/commons_search_core/commons_search_core.facetapi_defaults.inc new file mode 100644 index 0000000..fdd4884 --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_core/commons_search_core.facetapi_defaults.inc @@ -0,0 +1,331 @@ +disabled = FALSE; /* Edit this to true to make a default facet disabled initially */ + $facet->api_version = 1; + $facet->name = 'search::author'; + $facet->searcher = 'search'; + $facet->realm = ''; + $facet->facet = 'author'; + $facet->enabled = FALSE; + $facet->settings = array( + 'operator' => 'and', + 'hard_limit' => '50', + 'dependencies' => array( + 'roles' => array(), + ), + 'facet_mincount' => 1, + 'facet_missing' => 0, + 'flatten' => 0, + 'query_type' => 'term', + ); + $export['search::author'] = $facet; + + $facet = new stdClass(); + $facet->disabled = FALSE; /* Edit this to true to make a default facet disabled initially */ + $facet->api_version = 1; + $facet->name = 'search::bundle'; + $facet->searcher = 'search'; + $facet->realm = ''; + $facet->facet = 'bundle'; + $facet->enabled = FALSE; + $facet->settings = array( + 'operator' => 'and', + 'hard_limit' => '50', + 'dependencies' => array( + 'roles' => array(), + ), + 'facet_mincount' => 1, + 'facet_missing' => 0, + 'flatten' => 0, + 'query_type' => 'term', + ); + $export['search::bundle'] = $facet; + + $facet = new stdClass(); + $facet->disabled = FALSE; /* Edit this to true to make a default facet disabled initially */ + $facet->api_version = 1; + $facet->name = 'search::changed'; + $facet->searcher = 'search'; + $facet->realm = ''; + $facet->facet = 'changed'; + $facet->enabled = FALSE; + $facet->settings = array( + 'operator' => 'and', + 'hard_limit' => '50', + 'dependencies' => array( + 'roles' => array(), + ), + 'facet_mincount' => 1, + 'facet_missing' => 0, + 'flatten' => 0, + 'query_type' => 'date_range', + ); + $export['search::changed'] = $facet; + + $facet = new stdClass(); + $facet->disabled = FALSE; /* Edit this to true to make a default facet disabled initially */ + $facet->api_version = 1; + $facet->name = 'search::created'; + $facet->searcher = 'search'; + $facet->realm = ''; + $facet->facet = 'created'; + $facet->enabled = FALSE; + $facet->settings = array( + 'operator' => 'and', + 'hard_limit' => '50', + 'dependencies' => array( + 'roles' => array(), + 'bundle' => 'none', + 'bundle_selected' => array(), + ), + 'facet_mincount' => 1, + 'facet_missing' => 0, + 'flatten' => 0, + 'query_type' => 'date_range', + ); + $export['search::created'] = $facet; + + $facet = new stdClass(); + $facet->disabled = FALSE; /* Edit this to true to make a default facet disabled initially */ + $facet->api_version = 1; + $facet->name = 'search::field_topics'; + $facet->searcher = 'search'; + $facet->realm = ''; + $facet->facet = 'field_topics'; + $facet->enabled = FALSE; + $facet->settings = array( + 'operator' => 'and', + 'hard_limit' => '50', + 'dependencies' => array( + 'roles' => array(), + ), + 'facet_mincount' => 1, + 'facet_missing' => 0, + 'flatten' => 0, + 'query_type' => 'term', + ); + $export['search::field_topics'] = $facet; + + $facet = new stdClass(); + $facet->disabled = FALSE; /* Edit this to true to make a default facet disabled initially */ + $facet->api_version = 1; + $facet->name = 'search:block:author'; + $facet->searcher = 'search'; + $facet->realm = 'block'; + $facet->facet = 'author'; + $facet->enabled = TRUE; + $facet->settings = array( + 'weight' => 0, + 'widget' => 'facetapi_links', + 'filters' => array(), + 'active_sorts' => array( + 'active' => 'active', + 'count' => 'count', + 'display' => 'display', + 'indexed' => 0, + ), + 'sort_weight' => array( + 'active' => '-50', + 'count' => '-49', + 'display' => '-48', + 'indexed' => '0', + ), + 'sort_order' => array( + 'active' => '3', + 'count' => '3', + 'display' => '4', + 'indexed' => '4', + ), + 'empty_behavior' => 'text', + 'soft_limit' => '20', + 'nofollow' => 1, + 'show_expanded' => 0, + 'empty_text' => array( + 'value' => 'None available.', + 'format' => 'filtered_html', + ), + 'submit_realm' => 'Save and go back to realm settings', + ); + $export['search:block:author'] = $facet; + + $facet = new stdClass(); + $facet->disabled = FALSE; /* Edit this to true to make a default facet disabled initially */ + $facet->api_version = 1; + $facet->name = 'search:block:bundle'; + $facet->searcher = 'search'; + $facet->realm = 'block'; + $facet->facet = 'bundle'; + $facet->enabled = TRUE; + $facet->settings = array( + 'weight' => 0, + 'widget' => 'facetapi_links', + 'filters' => array(), + 'active_sorts' => array( + 'active' => 'active', + 'count' => 'count', + 'display' => 'display', + 'indexed' => 0, + ), + 'sort_weight' => array( + 'active' => '-50', + 'count' => '-49', + 'display' => '-48', + 'indexed' => '0', + ), + 'sort_order' => array( + 'active' => '3', + 'count' => '3', + 'display' => '4', + 'indexed' => '4', + ), + 'empty_behavior' => 'text', + 'soft_limit' => '20', + 'nofollow' => 1, + 'show_expanded' => 0, + 'empty_text' => array( + 'value' => 'No options available', + 'format' => 'filtered_html', + ), + 'submit_realm' => 'Save and go back to realm settings', + ); + $export['search:block:bundle'] = $facet; + + $facet = new stdClass(); + $facet->disabled = FALSE; /* Edit this to true to make a default facet disabled initially */ + $facet->api_version = 1; + $facet->name = 'search:block:changed'; + $facet->searcher = 'search'; + $facet->realm = 'block'; + $facet->facet = 'changed'; + $facet->enabled = TRUE; + $facet->settings = array( + 'weight' => 0, + 'widget' => 'date_range', + 'filters' => array(), + 'active_sorts' => array( + 'active' => 'active', + 'indexed' => 'indexed', + 'count' => 0, + 'display' => 0, + ), + 'sort_weight' => array( + 'active' => '-50', + 'indexed' => '-49', + 'count' => '0', + 'display' => '0', + ), + 'sort_order' => array( + 'active' => '3', + 'indexed' => '4', + 'count' => '4', + 'display' => '4', + ), + 'empty_behavior' => 'none', + 'soft_limit' => '20', + 'nofollow' => 1, + 'show_expanded' => 0, + 'empty_text' => array( + 'value' => '', + 'format' => 'filtered_html', + ), + 'submit_realm' => 'Save and go back to realm settings', + ); + $export['search:block:changed'] = $facet; + + $facet = new stdClass(); + $facet->disabled = FALSE; /* Edit this to true to make a default facet disabled initially */ + $facet->api_version = 1; + $facet->name = 'search:block:created'; + $facet->searcher = 'search'; + $facet->realm = 'block'; + $facet->facet = 'created'; + $facet->enabled = TRUE; + $facet->settings = array( + 'weight' => 0, + 'widget' => 'date_range', + 'filters' => array(), + 'active_sorts' => array( + 'active' => 'active', + 'indexed' => 'indexed', + 'count' => 0, + 'display' => 0, + ), + 'sort_weight' => array( + 'active' => '-50', + 'indexed' => '-49', + 'count' => '0', + 'display' => '0', + ), + 'sort_order' => array( + 'active' => '3', + 'indexed' => '4', + 'count' => '4', + 'display' => '4', + ), + 'empty_behavior' => 'text', + 'soft_limit' => '20', + 'nofollow' => 1, + 'show_expanded' => 0, + 'empty_text' => array( + 'value' => 'None available', + 'format' => 'filtered_html', + ), + 'submit_realm' => 'Save and go back to realm settings', + ); + $export['search:block:created'] = $facet; + + $facet = new stdClass(); + $facet->disabled = FALSE; /* Edit this to true to make a default facet disabled initially */ + $facet->api_version = 1; + $facet->name = 'search:block:field_topics'; + $facet->searcher = 'search'; + $facet->realm = 'block'; + $facet->facet = 'field_topics'; + $facet->enabled = TRUE; + $facet->settings = array( + 'weight' => 0, + 'widget' => 'facetapi_links', + 'filters' => array(), + 'active_sorts' => array( + 'active' => 'active', + 'count' => 'count', + 'display' => 'display', + 'indexed' => 0, + ), + 'sort_weight' => array( + 'active' => '-50', + 'count' => '-49', + 'display' => '-48', + 'indexed' => '0', + ), + 'sort_order' => array( + 'active' => '3', + 'count' => '3', + 'display' => '4', + 'indexed' => '4', + ), + 'empty_behavior' => 'text', + 'soft_limit' => '20', + 'nofollow' => 1, + 'show_expanded' => 0, + 'empty_text' => array( + 'value' => 'No options available', + 'format' => 'filtered_html', + ), + 'submit_realm' => 'Save and go back to realm settings', + ); + $export['search:block:field_topics'] = $facet; + + return $export; +} diff --git a/modules/commons/commons_search/modules/commons_search_core/commons_search_core.features.inc b/modules/commons/commons_search/modules/commons_search_core/commons_search_core.features.inc new file mode 100644 index 0000000..b131a18 --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_core/commons_search_core.features.inc @@ -0,0 +1,23 @@ + "1"); + } + list($module, $api) = func_get_args(); + if ($module == "page_manager" && $api == "pages_default") { + return array("version" => "1"); + } + list($module, $api) = func_get_args(); + if ($module == "strongarm" && $api == "strongarm") { + return array("version" => "1"); + } +} diff --git a/modules/commons/commons_search/modules/commons_search_core/commons_search_core.info b/modules/commons/commons_search/modules/commons_search_core/commons_search_core.info new file mode 100644 index 0000000..e0fc12f --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_core/commons_search_core.info @@ -0,0 +1,31 @@ +name = Commons Search Core +description = Core search with facets. +core = 7.x +package = Commons - Search +dependencies[] = commons_search +dependencies[] = date_facets +dependencies[] = facetapi +dependencies[] = page_manager +dependencies[] = search_facetapi +dependencies[] = strongarm +features[ctools][] = facetapi:facetapi_defaults:1 +features[ctools][] = page_manager:pages_default:1 +features[ctools][] = strongarm:strongarm:1 +features[facetapi][] = search::author +features[facetapi][] = search::bundle +features[facetapi][] = search::changed +features[facetapi][] = search::created +features[facetapi][] = search::field_topics +features[facetapi][] = search:block:author +features[facetapi][] = search:block:bundle +features[facetapi][] = search:block:changed +features[facetapi][] = search:block:created +features[facetapi][] = search:block:field_topics +features[features_api][] = api:1 +features[page_manager_handlers][] = search_search_facetapi_panel_context +features[page_manager_handlers][] = search_search_facetapi_panel_context_2 +features[variable][] = page_manager_search_disabled_search_facetapi +features[variable][] = custom_search_other +features[variable][] = search_active_modules +features[variable][] = search_default_module +features_exclude[dependencies][ctools] = ctools diff --git a/modules/commons/commons_search/modules/commons_search_core/commons_search_core.install b/modules/commons/commons_search/modules/commons_search_core/commons_search_core.install new file mode 100644 index 0000000..41ae876 --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_core/commons_search_core.install @@ -0,0 +1,39 @@ + 'search_facetapi', + 'user' => 'user', + 'node' => 0, + )); + // Set custom search active search modules. + variable_set('custom_search_other', array( + 'search_facetapi' => 'search_facetapi', + 'user' => 'user', + )); + // Set default search module for Core. + variable_set('search_default_module', 'search_facetapi'); + cache_clear_all('*', 'cache_block', TRUE); +} + +/** + * Revert the core search page to have a single column variant when no search + * has happened and the normal two column variant when a search has happened. + */ +function commons_search_core_update_7001() { + $revert = array( + 'commons_search_core' => array('page_manager_handlers'), + ); + features_revert($revert); +} diff --git a/modules/commons/commons_search/modules/commons_search_core/commons_search_core.module b/modules/commons/commons_search/modules/commons_search_core/commons_search_core.module new file mode 100644 index 0000000..4f12897 --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_core/commons_search_core.module @@ -0,0 +1,7 @@ +disabled = FALSE; /* Edit this to true to make a default handler disabled initially */ + $handler->api_version = 1; + $handler->name = 'search_search_facetapi_panel_context'; + $handler->task = 'search'; + $handler->subtask = 'search_facetapi'; + $handler->handler = 'panel_context'; + $handler->weight = 0; + $handler->conf = array( + 'title' => 'Non-empty keywords, two column', + 'no_blocks' => 0, + 'pipeline' => 'ipe', + 'body_classes_to_remove' => '', + 'body_classes_to_add' => '', + 'css_id' => '', + 'css' => '', + 'contexts' => array(), + 'relationships' => array(), + 'access' => array( + 'plugins' => array( + 0 => array( + 'name' => 'string_length', + 'settings' => array( + 'operator' => '>', + 'length' => '0', + ), + 'context' => 'argument_string_1', + 'not' => FALSE, + ), + ), + 'logic' => 'and', + ), + ); + $display = new panels_display(); + $display->layout = 'two_33_66'; + $display->layout_settings = array(); + $display->panel_settings = array( + 'style_settings' => array( + 'default' => NULL, + 'two_33_66_top' => NULL, + 'two_33_66_first' => NULL, + 'two_33_66_second' => NULL, + 'two_33_66_bottom' => NULL, + ), + ); + $display->cache = array(); + $display->title = ''; + $display->uuid = '2d31d4ab-5756-44a4-f984-8107b8587b40'; + $display->content = array(); + $display->panels = array(); + $pane = new stdClass(); + $pane->pid = 'new-4be3b380-7f67-ecf4-6974-607450056b42'; + $pane->panel = 'two_33_66_first'; + $pane->type = 'block'; + $pane->subtype = 'facetapi-yz9XmKQdPPifJdPJudYeRDV3PpGykc25'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 1, + 'override_title_text' => 'Topics', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = '4be3b380-7f67-ecf4-6974-607450056b42'; + $display->content['new-4be3b380-7f67-ecf4-6974-607450056b42'] = $pane; + $display->panels['two_33_66_first'][0] = 'new-4be3b380-7f67-ecf4-6974-607450056b42'; + $pane = new stdClass(); + $pane->pid = 'new-19883d03-0e72-1f84-4d13-5daf49510352'; + $pane->panel = 'two_33_66_first'; + $pane->type = 'block'; + $pane->subtype = 'facetapi-NjamMRlUSiv6J1uYtpZ6KmDlsOuSofFX'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 1, + 'override_title_text' => 'Type', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 1; + $pane->locks = array(); + $pane->uuid = '19883d03-0e72-1f84-4d13-5daf49510352'; + $display->content['new-19883d03-0e72-1f84-4d13-5daf49510352'] = $pane; + $display->panels['two_33_66_first'][1] = 'new-19883d03-0e72-1f84-4d13-5daf49510352'; + $pane = new stdClass(); + $pane->pid = 'new-d8cfd787-a04d-ef94-dda0-a486cf0e46be'; + $pane->panel = 'two_33_66_first'; + $pane->type = 'block'; + $pane->subtype = 'facetapi-lyyyTQZmDqHX6b30Dx4mzfY6gEOR5Y0j'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 1, + 'override_title_text' => 'Author', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 2; + $pane->locks = array(); + $pane->uuid = 'd8cfd787-a04d-ef94-dda0-a486cf0e46be'; + $display->content['new-d8cfd787-a04d-ef94-dda0-a486cf0e46be'] = $pane; + $display->panels['two_33_66_first'][2] = 'new-d8cfd787-a04d-ef94-dda0-a486cf0e46be'; + $pane = new stdClass(); + $pane->pid = 'new-3c939ace-59f2-5ea4-5da0-d1450d651449'; + $pane->panel = 'two_33_66_first'; + $pane->type = 'block'; + $pane->subtype = 'facetapi-gw7MYX93nFUXP6kzts1Eay6QpCVVSaOt'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 1, + 'override_title_text' => 'Date created', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 3; + $pane->locks = array(); + $pane->uuid = '3c939ace-59f2-5ea4-5da0-d1450d651449'; + $display->content['new-3c939ace-59f2-5ea4-5da0-d1450d651449'] = $pane; + $display->panels['two_33_66_first'][3] = 'new-3c939ace-59f2-5ea4-5da0-d1450d651449'; + $pane = new stdClass(); + $pane->pid = 'new-95278c06-53e1-a984-4139-71b99c4d3ddf'; + $pane->panel = 'two_33_66_first'; + $pane->type = 'block'; + $pane->subtype = 'facetapi-BFZ195FyIkWBzXNTaq3jevkbxSWXJpMb'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 1, + 'override_title_text' => 'Date changed', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 4; + $pane->locks = array(); + $pane->uuid = '95278c06-53e1-a984-4139-71b99c4d3ddf'; + $display->content['new-95278c06-53e1-a984-4139-71b99c4d3ddf'] = $pane; + $display->panels['two_33_66_first'][4] = 'new-95278c06-53e1-a984-4139-71b99c4d3ddf'; + $pane = new stdClass(); + $pane->pid = 'new-2ed6ed31-b23a-50d4-dd1c-dd2eae53cedb'; + $pane->panel = 'two_33_66_second'; + $pane->type = 'search_result'; + $pane->subtype = 'search_result'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'type' => 'search_facetapi', + 'log' => 0, + 'override_empty' => 0, + 'empty_title' => '', + 'empty' => '', + 'empty_format' => 'plain_text', + 'override_no_key' => 0, + 'no_key_title' => '', + 'no_key' => '', + 'no_key_format' => 'plain_text', + 'context' => 'argument_string_1', + 'override_title' => 1, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = '2ed6ed31-b23a-50d4-dd1c-dd2eae53cedb'; + $display->content['new-2ed6ed31-b23a-50d4-dd1c-dd2eae53cedb'] = $pane; + $display->panels['two_33_66_second'][0] = 'new-2ed6ed31-b23a-50d4-dd1c-dd2eae53cedb'; + $pane = new stdClass(); + $pane->pid = 'new-74dd20d4-0d10-dea4-019a-808cfe544eac'; + $pane->panel = 'two_33_66_top'; + $pane->type = 'search_form'; + $pane->subtype = 'search_form'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'type' => 'search_facetapi', + 'form' => 'simple', + 'path_type' => 'default', + 'path' => '', + 'override_prompt' => 0, + 'prompt' => '', + 'context' => 'argument_string_1', + 'override_title' => 0, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = '74dd20d4-0d10-dea4-019a-808cfe544eac'; + $display->content['new-74dd20d4-0d10-dea4-019a-808cfe544eac'] = $pane; + $display->panels['two_33_66_top'][0] = 'new-74dd20d4-0d10-dea4-019a-808cfe544eac'; + $display->hide_title = PANELS_TITLE_PANE; + $display->title_pane = 'new-2ed6ed31-b23a-50d4-dd1c-dd2eae53cedb'; + $handler->conf['display'] = $display; + $export['search_search_facetapi_panel_context'] = $handler; + + $handler = new stdClass(); + $handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */ + $handler->api_version = 1; + $handler->name = 'search_search_facetapi_panel_context_2'; + $handler->task = 'search'; + $handler->subtask = 'search_facetapi'; + $handler->handler = 'panel_context'; + $handler->weight = 1; + $handler->conf = array( + 'title' => 'Empty keywords, single column', + 'no_blocks' => 0, + 'pipeline' => 'ipe', + 'body_classes_to_remove' => '', + 'body_classes_to_add' => '', + 'css_id' => '', + 'css' => '', + 'contexts' => array(), + 'relationships' => array(), + 'access' => array( + 'plugins' => array( + 0 => array( + 'name' => 'string_length', + 'settings' => array( + 'operator' => '=', + 'length' => '0', + ), + 'context' => 'argument_string_1', + 'not' => FALSE, + ), + ), + 'logic' => 'and', + ), + ); + $display = new panels_display(); + $display->layout = 'one'; + $display->layout_settings = array(); + $display->panel_settings = array( + 'style_settings' => array( + 'default' => NULL, + 'two_33_66_top' => NULL, + 'two_33_66_first' => NULL, + 'two_33_66_second' => NULL, + 'two_33_66_bottom' => NULL, + 'one_main' => NULL, + ), + ); + $display->cache = array(); + $display->title = ''; + $display->uuid = '34b80be5-404f-b7d4-b167-a3be8362179a'; + $display->content = array(); + $display->panels = array(); + $pane = new stdClass(); + $pane->pid = 'new-c690489f-a85f-a4a4-050c-f542d996de37'; + $pane->panel = 'one_main'; + $pane->type = 'search_form'; + $pane->subtype = 'search_form'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'type' => 'search_facetapi', + 'form' => 'simple', + 'path_type' => 'default', + 'path' => '', + 'override_prompt' => 0, + 'prompt' => '', + 'context' => 'argument_string_1', + 'override_title' => 0, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = 'c690489f-a85f-a4a4-050c-f542d996de37'; + $display->content['new-c690489f-a85f-a4a4-050c-f542d996de37'] = $pane; + $display->panels['one_main'][0] = 'new-c690489f-a85f-a4a4-050c-f542d996de37'; + $display->hide_title = PANELS_TITLE_PANE; + $display->title_pane = '0'; + $handler->conf['display'] = $display; + $export['search_search_facetapi_panel_context_2'] = $handler; + + return $export; +} diff --git a/modules/commons/commons_search/modules/commons_search_core/commons_search_core.strongarm.inc b/modules/commons/commons_search/modules/commons_search_core/commons_search_core.strongarm.inc new file mode 100644 index 0000000..c7ba10b --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_core/commons_search_core.strongarm.inc @@ -0,0 +1,48 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'page_manager_search_disabled_search_facetapi'; + $strongarm->value = FALSE; + $export['page_manager_search_disabled_search_facetapi'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'search_active_modules'; + $strongarm->value = array( + 'search_facetapi' => 'search_facetapi', + 'user' => 0, + 'node' => 0, + ); + $export['search_active_modules'] = $strongarm; + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'search_default_module'; + $strongarm->value = 'search_facetapi'; + $export['search_default_module'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_other'; + $strongarm->value = array( + 'search_facetapi' => 'search_facetapi', + 'user' => 'user', + ); + $export['custom_search_other'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.apachesolr_search_defaults.inc b/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.apachesolr_search_defaults.inc new file mode 100644 index 0000000..1bf367f --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.apachesolr_search_defaults.inc @@ -0,0 +1,36 @@ +disabled = FALSE; /* Edit this to true to make a default searcher disabled initially */ + $searcher->api_version = 3; + $searcher->page_id = 'core_search'; + $searcher->label = 'Core Search'; + $searcher->description = 'Core Search'; + $searcher->search_path = 'search/site'; + $searcher->page_title = 'Site'; + $searcher->env_id = apachesolr_default_environment(); + $searcher->settings = array( + 'fq' => array(), + 'apachesolr_search_custom_enable' => FALSE, + 'apachesolr_search_search_type' => 'custom', + 'apachesolr_search_search_box' => TRUE, + 'apachesolr_search_per_page' => 10, + 'apachesolr_search_browse' => 'blocks', + 'apachesolr_search_spellcheck' => TRUE, + 'apachesolr_search_allow_user_input' => FALSE, + 'apachesolr_search_not_removable' => TRUE, + ); + $export['core_search'] = $searcher; + + return $export; +} diff --git a/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.features.inc b/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.features.inc new file mode 100644 index 0000000..b97d1fd --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.features.inc @@ -0,0 +1,26 @@ + "3"); + } + if ($module == "facetapi" && $api == "facetapi_defaults") { + return array("version" => "1"); + } + if ($module == "page_manager" && $api == "pages_default") { + return array("version" => "1"); + } + if ($module == "pm_existing_pages" && $api == "pm_existing_pages") { + return array("version" => "1"); + } + if ($module == "strongarm" && $api == "strongarm") { + return array("version" => "1"); + } +} \ No newline at end of file diff --git a/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.info b/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.info new file mode 100644 index 0000000..0be45c0 --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.info @@ -0,0 +1,29 @@ +name = Commons Search Solr +description = Site search using Apache Solr server. +core = 7.x +package = Commons - Search +dependencies[] = apachesolr +dependencies[] = apachesolr_proximity +dependencies[] = apachesolr_search +dependencies[] = commons_search +dependencies[] = ctools +dependencies[] = date_facets +dependencies[] = facetapi +dependencies[] = page_manager +dependencies[] = pm_existing_pages +dependencies[] = strongarm +features[apachesolr_search_page][] = core_search +features[ctools][] = apachesolr_search:apachesolr_search_defaults:3 +features[ctools][] = facetapi:facetapi_defaults:1 +features[ctools][] = page_manager:pages_default:1 +features[ctools][] = pm_existing_pages:pm_existing_pages:1 +features[ctools][] = strongarm:strongarm:1 +features[features_api][] = api:2 +features[page_manager_existing_pages][] = solr_search +features[page_manager_handlers][] = pm_existing_pages_solr_search_panel_context +features[variable][] = apachesolr_search_default_search_page +features[variable][] = custom_search_other +features[variable][] = page_manager_search_disabled_apachesolr_search +features[variable][] = pm_existing_pages_disabled_solr_search +features[variable][] = search_active_modules +features[variable][] = search_default_module diff --git a/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.install b/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.install new file mode 100644 index 0000000..c1d8e1f --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.install @@ -0,0 +1,33 @@ + array('variable', 'apachesolr_search_page')); + features_revert($revert); + cache_clear_all(); + commons_search_solr_create_facets(); +} + +/** + * Set default environment to display facet blocks in configured regions. + */ +function commons_search_solr_update_7001() { + $revert = array( + 'commons_search_solr' => array('apachesolr_search_page'), + ); + features_revert($revert); +} diff --git a/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.module b/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.module new file mode 100644 index 0000000..91f175c --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.module @@ -0,0 +1,499 @@ +key(array('name' => $facet['name'])) + ->fields($facet) + ->execute(); + } +} + +/** + * Base facet definitions. + */ +function commons_search_solr_facet_definitions() { + $facets = array(); + + // Node author facet. + $facets[] = array( + 'name' => ':block:author', + 'searcher' => commons_search_solr_search_environment(), + 'realm' => 'block', + 'facet' => 'author', + 'enabled' => 1, + 'settings' => array( + 'weight' => 0, + 'widget' => 'facetapi_links', + 'filters' => array(), + 'active_sorts' => array( + 'active' => 'active', + 'count' => 'count', + 'display' => 'display', + ), + 'sort_weight' => array( + 'active' => -50, + 'count' => -49, + 'display' => -48, + ), + 'sort_order' => array( + 'active' => 3, + 'count' => 3, + 'display' => 4, + ), + 'empty_behavior' => 'none', + 'soft_limit' => 20, + 'nofollow' => 1, + 'show_expanded' => 0, + ), + ); + + // Node type facet. + $facets[] = array( + 'name' => ':block:bundle', + 'searcher' => commons_search_solr_search_environment(), + 'realm' => 'block', + 'facet' => 'bundle', + 'enabled' => 1, + 'settings' => array( + 'weight' => 0, + 'widget' => 'facetapi_links', + 'filters' => array(), + 'active_sorts' => array( + 'active' => 'active', + 'count' => 'count', + 'display' => 'display', + ), + 'sort_weight' => array( + 'active' => -50, + 'count' => -49, + 'display' => -48, + ), + 'sort_order' => array( + 'active' => 3, + 'count' => 3, + 'display' => 4, + ), + 'empty_behavior' => 'none', + 'soft_limit' => 20, + 'nofollow' => 1, + 'show_expanded' => 0, + ), + ); + + // Node changed date facet. + $facets[] = array( + 'name' => ':block:changed', + 'searcher' => commons_search_solr_search_environment(), + 'realm' => 'block', + 'facet' => 'changed', + 'enabled' => 1, + 'settings' => array( + 'weight' => 0, + 'widget' => 'date_range', + 'filters' => array(), + 'active_sorts' => array( + 'active' => 'active', + 'indexed' => 'indexed', + 'count' => 0, + 'display' => 0, + ), + 'sort_weight' => array( + 'active' => -50, + 'indexed' => -49, + 'count' => 0, + 'display' => 0, + ), + 'sort_order' => array( + 'active' => 3, + 'indexed' => 4, + 'count' => 4, + 'display' => 4, + ), + 'empty_behavior' => 'none', + 'soft_limit' => 20, + 'nofollow' => 1, + 'show_expanded' => 0, + 'empty_text' => array( + 'value' => '', + 'format' => 'filtered_html', + ), + ), + ); + $facets[] = array( + 'name' => '::changed', + 'searcher' => commons_search_solr_search_environment(), + 'realm' => '', + 'facet' => 'changed', + 'enabled' => 0, + 'settings' => array( + 'operator' => 'and', + 'hard_limit' => 50, + 'dependencies' => array( + 'roles' => array(), + ), + 'facet_mincount' => 1, + 'facet_missing' => 0, + 'flatten' => 0, + 'query_type' => 'date_range', + ), + ); + + // Node created date facet. + $facets[] = array( + 'name' => ':block:created', + 'searcher' => commons_search_solr_search_environment(), + 'realm' => 'block', + 'facet' => 'created', + 'enabled' => 1, + 'settings' => array( + 'weight' => 0, + 'widget' => 'date_range', + 'filters' => array(), + 'active_sorts' => array( + 'active' => 'active', + 'indexed' => 'indexed', + 'count' => 0, + 'display' => 0, + ), + 'sort_weight' => array( + 'active' => -50, + 'indexed' => -49, + 'count' => 0, + 'display' => 0, + ), + 'sort_order' => array( + 'active' => 3, + 'indexed' => 4, + 'count' => 4, + 'display' => 4, + ), + 'empty_behavior' => 'none', + 'soft_limit' => 20, + 'nofollow' => 1, + 'show_expanded' => 0, + 'empty_text' => array( + 'value' => '', + 'format' => 'filtered_html', + ), + ), + ); + $facets[] = array( + 'name' => '::created', + 'searcher' => commons_search_solr_search_environment(), + 'realm' => '', + 'facet' => 'created', + 'enabled' => 0, + 'settings' => array( + 'operator' => 'and', + 'hard_limit' => 50, + 'dependencies' => array( + 'roles' => array(), + ), + 'facet_mincount' => 1, + 'facet_missing' => 0, + 'flatten' => 0, + 'query_type' => 'date_range', + ), + ); + + // Node field_date facet. + $facets[] = array( + 'name' => ':block:dm_field_date', + 'searcher' => commons_search_solr_search_environment(), + 'realm' => 'block', + 'facet' => 'dm_field_date', + 'enabled' => 1, + 'settings' => array( + 'weight' => 0, + 'widget' => 'date_range', + 'filters' => array(), + 'active_sorts' => array( + 'active' => 'active', + 'indexed' => 'indexed', + 'count' => 0, + 'display' => 0, + ), + 'sort_weight' => array( + 'active' => -50, + 'indexed' => -49, + 'count' => 0, + 'display' => 0, + ), + 'sort_order' => array( + 'active' => 3, + 'indexed' => 4, + 'count' => 4, + 'display' => 4, + ), + 'empty_behavior' => 'none', + 'soft_limit' => 20, + 'nofollow' => 1, + 'show_expanded' => 0, + 'empty_text' => array( + 'value' => '', + 'format' => 'filtered_html', + ), + ), + ); + $facets[] = array( + 'name' => '::dm_field_date', + 'searcher' => commons_search_solr_search_environment(), + 'realm' => '', + 'facet' => 'dm_field_date', + 'enabled' => 0, + 'settings' => array( + 'operator' => 'and', + 'hard_limit' => 50, + 'dependencies' => array( + 'roles' => array(), + ), + 'facet_mincount' => 1, + 'facet_missing' => 0, + 'flatten' => 0, + 'query_type' => 'date_range', + ), + ); + + // Node field_topics facet. + $facets[] = array( + 'name' => ':block:im_field_topics', + 'searcher' => commons_search_solr_search_environment(), + 'realm' => 'block', + 'facet' => 'im_field_topics', + 'enabled' => 1, + 'settings' => array( + 'weight' => 0, + 'widget' => 'facetapi_links', + 'filters' => array(), + 'active_sorts' => array( + 'active' => 'active', + 'count' => 'count', + 'display' => 'display', + 'indexed' => 0, + ), + 'sort_weight' => array( + 'active' => -50, + 'count' => -49, + 'display' => -48, + 'indexed' => 0, + ), + 'sort_order' => array( + 'active' => 3, + 'count' => 3, + 'display' => 4, + 'indexed' => 4, + ), + 'empty_behavior' => 'text', + 'soft_limit' => 20, + 'nofollow' => 1, + 'show_expanded' => 0, + 'empty_text' => array( + 'value' => 'None available', + 'format' => 'filtered_html', + ), + ), + ); + $facets[] = array( + 'name' => '::im_field_topics', + 'searcher' => commons_search_solr_search_environment(), + 'realm' => '', + 'facet' => 'im_field_topics', + 'enabled' => 0, + 'settings' => array( + 'operator' => 'and', + 'hard_limit' => 50, + 'dependencies' => array( + 'roles' => array(), + ), + 'facet_mintcount' => 1, + 'facet_missing' => 0, + 'flatten' => 0, + 'query_type' => 'term', + ), + ); + + // Node field_location facet. + $facets[] = array( + 'name' => ':block:sm_field_location', + 'searcher' => commons_search_solr_search_environment(), + 'realm' => 'block', + 'facet' => 'sm_field_location', + 'enabled' => 1, + 'settings' => array( + 'weight' => 0, + 'widget' => 'facetapi_links', + 'filters' => array(), + 'active_sorts' => array( + 'active' => 'active', + 'count' => 'count', + 'display' => 'display', + ), + 'sort_weight' => array( + 'active' => -50, + 'count' => -49, + 'display' => -48, + ), + 'sort_order' => array( + 'active' => 3, + 'count' => 3, + 'display' => 4, + ), + 'empty_behavior' => 'none', + 'soft_limit' => 20, + 'nofollow' => 1, + 'show_expanded' => 0, + ), + ); + + // Node group reference facet. + $facets[] = array( + 'name' => ':block:sm_og_group_ref', + 'searcher' => commons_search_solr_search_environment(), + 'realm' => 'block', + 'facet' => 'sm_og_group_ref', + 'enabled' => 1, + 'settings' => array( + 'weight' => 0, + 'widget' => 'facetapi_links', + 'filters' => array(), + 'active_sorts' => array( + 'active' => 'active', + 'count' => 'count', + 'display' => 'display', + ), + 'sort_weight' => array( + 'active' => -50, + 'count' => -49, + 'display' => -48, + ), + 'sort_order' => array( + 'active' => 3, + 'count' => 3, + 'display' => 4, + ), + 'empty_behavior' => 'none', + 'soft_limit' => 20, + 'nofollow' => 1, + 'show_expanded' => 0, + ), + ); + return $facets; +} + +/** + * Get the panels subtype for the facet block. + */ +function commons_search_solr_panel_facet_subtype($facet_name) { + return 'facetapi-' . facetapi_hash_delta($facet_name); +} + +/** + * Implements hook_form_alter(). + */ +function commons_search_solr_form_apachesolr_environment_edit_form_alter(&$form, &$form_state) { + $form['actions']['save']['#submit'][] = 'commons_search_solr_environment_form_submit'; +} + +/** + * When the environment changes, create facets for that environment. + */ +function commons_search_solr_environment_form_submit($form, $form_state) { + if ($form_state['values']['make_default'] == 1) { + commons_search_solr_create_facets('apachesolr@' . $form_state['build_info']['args']['0']['env_id']); + // Need to clear caches so we can rebuild block definitions. + cache_clear_all('*', 'cache_block', TRUE); + cache_clear_all('*', 'cache_apachesolr', TRUE); + } +} + +/** + * Implements hook_modules_enabled(). + */ +function commons_search_solr_modules_enabled($modules) { + if (in_array('acquia_search', $modules)) { + // If Acquia Search is enabled later, we need to force update our facets, + // otherwise our Events Solr page has no facets. + commons_search_solr_create_facets(ACQUIA_SEARCH_ENVIRONMENT_ID); + } + if (in_array('commons_search_solr_user', $modules)) { + // We disable core user search with of Solr user search, via the + // search_active_modules variable which is exporter by commons_search_solr + // and altered in commons_search_solr_user_strongarm_alter(). + $revert = array('commons_search_solr' => array('variable')); + features_revert($revert); + } +} + + +/** + * Feature module hook. Invoked on a Feature module after that module is + * enabled. + * + * @param $component + * String name of the component that has just been enabled. + */ +function commons_search_solr_post_features_enable_feature($component) { + if ($component == 'apachesolr_search_page') { + features_revert(array('commons_search_solr' => array('apachesolr_search_page'))); + } +} + + +/** + * Implements hook_modules_disabled(). + */ +function commons_search_solr_modules_disabled($modules) { + if (in_array('commons_search_solr_user', $modules)) { + // We disable core user search with of Solr user search, via the + // search_active_modules variable which is exporter by commons_search_solr + // and altered in commons_search_solr_user_strongarm_alter(). + $revert = array('commons_search_solr' => array('variable')); + features_revert($revert); + } +} + +/** + * Implements hook_apachesolr_process_results(). + */ +function commons_search_solr_apachesolr_process_results(&$results, DrupalSolrQueryInterface $query) { + foreach($results AS $rkey => $result) { + if ($results[$rkey]['fields']['entity_type'] == 'node') { + if ($node = node_load($results[$rkey]['fields']['entity_id'])) { + $node_view = node_view($node, 'teaser'); + $results[$rkey]['snippet'] = drupal_render($node_view); + } + } + if ($results[$rkey]['fields']['entity_type'] == 'user') { + if ($account = user_load($results[$rkey]['fields']['entity_id'])) { + $user_view = user_view($account, 'search_results'); + $results[$rkey]['snippet'] = drupal_render($user_view); + } + } + } +} diff --git a/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.pages_default.inc b/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.pages_default.inc new file mode 100644 index 0000000..7f76c67 --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.pages_default.inc @@ -0,0 +1,213 @@ +disabled = FALSE; /* Edit this to true to make a default handler disabled initially */ + $handler->api_version = 1; + $handler->name = 'pm_existing_pages_solr_search_panel_context'; + $handler->task = 'pm_existing_pages'; + $handler->subtask = 'solr_search'; + $handler->handler = 'panel_context'; + $handler->weight = 0; + $handler->conf = array( + 'title' => 'search', + 'no_blocks' => 0, + 'pipeline' => 'standard', + 'body_classes_to_remove' => '', + 'body_classes_to_add' => '', + 'css_id' => '', + 'css' => '', + 'contexts' => array(), + 'relationships' => array(), + ); + $display = new panels_display(); + $display->layout = 'two_33_66'; + $display->layout_settings = array(); + $display->panel_settings = array( + 'style_settings' => array( + 'default' => NULL, + 'two_33_66_top' => NULL, + 'two_33_66_first' => NULL, + 'two_33_66_second' => NULL, + 'two_33_66_bottom' => NULL, + ), + ); + $display->cache = array(); + $display->title = ''; + $display->uuid = '06329041-e13c-1174-ed2a-d4a50d0aa4d2'; + $display->content = array(); + $display->panels = array(); + $pane = new stdClass(); + $pane->pid = 'new-463814d4-a8ba-7b94-c9d5-77faae3cea01'; + $pane->panel = 'two_33_66_first'; + $pane->type = 'block'; + $pane->subtype = commons_search_solr_panel_facet_subtype(commons_search_solr_search_environment() . ':block:sm_og_group_ref'); + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 1, + 'override_title_text' => t('Groups'), + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = '463814d4-a8ba-7b94-c9d5-77faae3cea01'; + $display->content['new-463814d4-a8ba-7b94-c9d5-77faae3cea01'] = $pane; + $display->panels['two_33_66_first'][0] = 'new-463814d4-a8ba-7b94-c9d5-77faae3cea01'; + $pane = new stdClass(); + $pane->pid = 'new-7accd7bf-9b29-ce34-8de0-528f3a89ba02'; + $pane->panel = 'two_33_66_first'; + $pane->type = 'block'; + $pane->subtype = commons_search_solr_panel_facet_subtype(commons_search_solr_search_environment() . ':block:im_field_topics'); + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 1, + 'override_title_text' => t('Topics'), + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 1; + $pane->locks = array(); + $pane->uuid = '7accd7bf-9b29-ce34-8de0-528f3a89ba02'; + $display->content['new-7accd7bf-9b29-ce34-8de0-528f3a89ba02'] = $pane; + $display->panels['two_33_66_first'][1] = 'new-7accd7bf-9b29-ce34-8de0-528f3a89ba02'; + $pane = new stdClass(); + $pane->pid = 'new-0ff4a758-76a3-1944-29fe-a19ae7f1abd1'; + $pane->panel = 'two_33_66_first'; + $pane->type = 'block'; + $pane->subtype = commons_search_solr_panel_facet_subtype(commons_search_solr_search_environment() . ':block:bundle'); + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 1, + 'override_title_text' => t('Type'), + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 2; + $pane->locks = array(); + $pane->uuid = '0ff4a758-76a3-1944-29fe-a19ae7f1abd1'; + $display->content['new-0ff4a758-76a3-1944-29fe-a19ae7f1abd1'] = $pane; + $display->panels['two_33_66_first'][2] = 'new-0ff4a758-76a3-1944-29fe-a19ae7f1abd1'; + $pane = new stdClass(); + $pane->pid = 'new-971af469-d142-9b34-4d91-7d2b2b06d750'; + $pane->panel = 'two_33_66_first'; + $pane->type = 'block'; + $pane->subtype = commons_search_solr_panel_facet_subtype(commons_search_solr_search_environment() . ':block:author'); + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 1, + 'override_title_text' => t('Author'), + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 3; + $pane->locks = array(); + $pane->uuid = '971af469-d142-9b34-4d91-7d2b2b06d750'; + $display->content['new-971af469-d142-9b34-4d91-7d2b2b06d750'] = $pane; + $display->panels['two_33_66_first'][3] = 'new-971af469-d142-9b34-4d91-7d2b2b06d750'; + $pane = new stdClass(); + $pane->pid = 'new-9580c1e3-390b-0954-65a6-3804ab628265'; + $pane->panel = 'two_33_66_first'; + $pane->type = 'block'; + $pane->subtype = commons_search_solr_panel_facet_subtype(commons_search_solr_search_environment() . ':block:created'); + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 1, + 'override_title_text' => t('Date created'), + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 4; + $pane->locks = array(); + $pane->uuid = '9580c1e3-390b-0954-65a6-3804ab628265'; + $display->content['new-9580c1e3-390b-0954-65a6-3804ab628265'] = $pane; + $display->panels['two_33_66_first'][4] = 'new-9580c1e3-390b-0954-65a6-3804ab628265'; + $pane = new stdClass(); + $pane->pid = 'new-036759bf-aab4-5b04-8d88-81e0debf0e23'; + $pane->panel = 'two_33_66_first'; + $pane->type = 'block'; + $pane->subtype = commons_search_solr_panel_facet_subtype(commons_search_solr_search_environment() . ':block:changed'); + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 1, + 'override_title_text' => t('Date changed'), + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 5; + $pane->locks = array(); + $pane->uuid = '036759bf-aab4-5b04-8d88-81e0debf0e23'; + $display->content['new-036759bf-aab4-5b04-8d88-81e0debf0e23'] = $pane; + $display->panels['two_33_66_first'][5] = 'new-036759bf-aab4-5b04-8d88-81e0debf0e23'; + $pane = new stdClass(); + $pane->pid = 'new-da122a41-c889-4be4-519a-f29568f411ef'; + $pane->panel = 'two_33_66_second'; + $pane->type = 'pm_existing_pages'; + $pane->subtype = 'pm_existing_pages'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 0 => 'task_id', + 1 => 'pane_title_from_menu', + 'task_id' => 'solr_search', + 'pane_title_from_menu' => 0, + 'override_title' => 1, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = 'da122a41-c889-4be4-519a-f29568f411ef'; + $display->content['new-da122a41-c889-4be4-519a-f29568f411ef'] = $pane; + $display->panels['two_33_66_second'][0] = 'new-da122a41-c889-4be4-519a-f29568f411ef'; + $display->hide_title = PANELS_TITLE_NONE; + $display->title_pane = '0'; + $handler->conf['display'] = $display; + $export['pm_existing_pages_solr_search_panel_context'] = $handler; + + return $export; +} diff --git a/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.pm_existing_pages.inc b/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.pm_existing_pages.inc new file mode 100644 index 0000000..e1e6787 --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.pm_existing_pages.inc @@ -0,0 +1,23 @@ +api_version = 1; + $pm_existing_page->name = 'solr_search'; + $pm_existing_page->label = 'ApacheSolr site search'; + $pm_existing_page->context = ''; + $pm_existing_page->paths = 'search/site +search/site/%'; + $export['solr_search'] = $pm_existing_page; + + return $export; +} diff --git a/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.strongarm.inc b/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.strongarm.inc new file mode 100644 index 0000000..ee2a643 --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_solr/commons_search_solr.strongarm.inc @@ -0,0 +1,61 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'apachesolr_search_default_search_page'; + $strongarm->value = 'core_search'; + $export['apachesolr_search_default_search_page'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'custom_search_other'; + $strongarm->value = array( + 'apachesolr_search' => 'apachesolr_search', + 'user' => 'user', + ); + $export['custom_search_other'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'page_manager_search_disabled_apachesolr_search'; + $strongarm->value = TRUE; + $export['page_manager_search_disabled_apachesolr_search'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'pm_existing_pages_disabled_solr_search'; + $strongarm->value = FALSE; + $export['pm_existing_pages_disabled_solr_search'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'search_active_modules'; + $strongarm->value = array( + 'apachesolr_search' => 'apachesolr_search', + ); + $export['search_active_modules'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'search_default_module'; + $strongarm->value = 'apachesolr_search'; + $export['search_default_module'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_search/modules/commons_search_solr_user/commons-search-solr-user-results.tpl.php b/modules/commons/commons_search/modules/commons_search_solr_user/commons-search-solr-user-results.tpl.php new file mode 100644 index 0000000..2fe9ad2 --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_solr_user/commons-search-solr-user-results.tpl.php @@ -0,0 +1,23 @@ + + +
      > + >
      + > + + + diff --git a/modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.apachesolr_search_defaults.inc b/modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.apachesolr_search_defaults.inc new file mode 100644 index 0000000..c30b96f --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.apachesolr_search_defaults.inc @@ -0,0 +1,37 @@ +disabled = FALSE; /* Edit this to true to make a default searcher disabled initially */ + $searcher->api_version = 3; + $searcher->page_id = 'user_search'; + $searcher->label = 'User Search'; + $searcher->description = 'User Search'; + $searcher->search_path = 'people'; + $searcher->page_title = 'People'; + $searcher->env_id = apachesolr_default_environment(); + $searcher->settings = array( + 'fq' => array( + 0 => 'entity_type:user', + ), + 'apachesolr_search_custom_enable' => 1, + 'apachesolr_search_search_type' => 'custom', + 'apachesolr_search_per_page' => 12, + 'apachesolr_search_browse' => 'none', + 'apachesolr_search_spellcheck' => 1, + 'apachesolr_search_search_box' => 1, + 'apachesolr_search_allow_user_input' => 0, + ); + $export['user_search'] = $searcher; + + return $export; +} diff --git a/modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.features.inc b/modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.features.inc new file mode 100644 index 0000000..0d862f2 --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.features.inc @@ -0,0 +1,15 @@ + "3"); + } +} diff --git a/modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.features.menu_links.inc b/modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.features.menu_links.inc new file mode 100644 index 0000000..55be9a1 --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.features.menu_links.inc @@ -0,0 +1,36 @@ + 'main-menu', + 'link_path' => 'people', + 'router_path' => 'people', + 'link_title' => 'People', + 'options' => array( + 'attributes' => array(), + ), + 'module' => 'menu', + 'hidden' => 0, + 'external' => 0, + 'has_children' => 0, + 'expanded' => 0, + 'weight' => 5, + 'customized' => 1, + ); + // Translatables + // Included for use with string extractors like potx. + t('People'); + + + return $menu_links; +} diff --git a/modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.info b/modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.info new file mode 100644 index 0000000..b5c8055 --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.info @@ -0,0 +1,14 @@ +name = Commons Search Solr User +description = Provides user entity indexing capabilities to Apache Solr, and search functionality +core = 7.x +package = Commons - Search +dependencies[] = apachesolr_search +dependencies[] = apachesolr_user +dependencies[] = commons_search_solr +dependencies[] = ctools +dependencies[] = features +dependencies[] = menu +features[apachesolr_search_page][] = user_search +features[ctools][] = apachesolr_search:apachesolr_search_defaults:3 +features[features_api][] = api:1 +features[menu_links][] = main-menu:people \ No newline at end of file diff --git a/modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.install b/modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.install new file mode 100644 index 0000000..6a55be5 --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.install @@ -0,0 +1,55 @@ +fields(array( + 'weight' => 150, + )) + ->condition('name', 'commons_search_solr_user') + ->execute(); +} + +/** + * Implements hook_enable(). + */ +function commons_search_solr_user_enable() { + // Commons_search_solr_user alters the search_active_modules variable + // defined by commons_search_solr. Now that it's disabled, let's revert it. + $revert = array('commons_search_solr' => array('variable')); + features_revert($revert); + // We need to tell Solr to index users. + db_merge('apachesolr_index_bundles') + ->key(array( + 'env_id' => apachesolr_default_environment(), + 'entity_type' => 'user', + 'bundle' => 'user', + )) + ->fields(array( + 'env_id' => apachesolr_default_environment(), + 'entity_type' => 'user', + 'bundle' => 'user', + )) + ->execute(); + + // Make sure the user search page was created so we can modify it. Do this manually + // Because features revert isn't reliable in all cases, we load the export and do the save. + module_load_include('inc', 'commons_search_solr_user', 'commons_search_solr_user.apachesolr_search_defaults'); + $default_search_page = commons_search_solr_user_apachesolr_search_default_searchers(); + apachesolr_search_page_save(get_object_vars($default_search_page['user_search'])); + + // Revert the trusted contacts module if its enabled, since we need to + // re-apply the search options that come with the feature. + if (module_exists('commons_trusted_contacts')) { + $revert = array( + 'commons_trusted_contacts' => array('field_instance'), + ); + features_revert($revert); + } +} diff --git a/modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.module b/modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.module new file mode 100644 index 0000000..d003bfe --- /dev/null +++ b/modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.module @@ -0,0 +1,369 @@ +uid, 'commons_follow_user'); + foreach ($flagging_users as $uid => $flaginfo) { + // Add each flag to the document index, as an integer multiple value field. + $document->setMultiValue('im_flag_commons_follow_user', $uid); + } + + if (!empty($entity->field_name_first)) { + $document->addField('tes_firstname', $entity->field_name_first[LANGUAGE_NONE][0]['value']); + } + if (!empty($entity->field_name_last)) { + $document->addField('tes_lastname', $entity->field_name_last[LANGUAGE_NONE][0]['value']); + } + $document->addField('tes_username', $entity->name); +} + +function commons_search_solr_user_apachesolr_query_alter($query) { + global $user; + // Search in partial usernames. + $query->addParam('qf', 'tes_firstname'); + $query->addParam('qf', 'tes_lastname'); + $query->addParam('qf', 'tes_username'); + + if (isset($_GET['flagged']) && $flagged = check_plain($_GET['flagged'])) { + $query->addFilter('im_flag_commons_follow_user', $user->uid); + } +} + +/** + * Implements hook_theme(). + */ +function commons_search_solr_user_theme($existing, $type, $theme, $path) { + return array( + 'commons_search_solr_user_results' => array( + 'variables' => array( + 'title' => '', + 'results' => array(), + ), + 'template' => 'commons-search-solr-user-results', + ), + ); +} + +/** + * Implements hook_strongarm_alter(). + */ +function commons_search_solr_user_strongarm_alter(&$items) { + // Commons_search_solr_user replaces core user search, so remove it + // from the list of active search modules. + if (!empty($items['search_active_modules']->value['user'])) { + unset($items['search_active_modules']->value['user']); + } +} + +/** + * Implements hook_apachesolr_search_page_alter(). + * We override the default search page for people here when no results are entered. + * This gives us a default people listing which we can filter to who we are following. + */ +function commons_search_solr_user_apachesolr_search_page_alter(&$build, $search_page) { + global $user; + if ($search_page['page_id'] == 'user_search' + && isset($build['search_results']['#markup']) + && empty($build['search_form']['basic']['keys']['#default_value']) + ) { + // If the #markup item is set, it usually means we have no Solr results. + // So lets just fetch all users that are active, and display those. + + // First check to see if the flagged key is set. If so we don't want to query + // Using EFQ because flags aren't entities. + $limit = isset($search_page['settings']['apachesolr_search_per_page']) ? $search_page['settings']['apachesolr_search_per_page'] : 12; + $flagged = (isset($_GET['flagged']) && is_numeric($_GET['flagged'])) ? check_plain($_GET['flagged']) : 0; + + $out_results = array(); + if ($flagged && $flag = flag_get_flag('commons_follow_user')) { + // Get the count of flagged users for a particular account. + $fl_results = db_select('flag_content', 'f') + ->fields('f', array('content_id', 'uid')) + ->condition('f.content_type', 'user', '=') + ->condition('f.uid', $user->uid, '=') + ->condition('f.fid', $flag->fid, '=') + ->extend('PagerDefault')->limit($limit) + ->addTag('commons_search_solr_user_people') + ->addMetaData('flagged', $flagged) + ->execute(); + while ($record = $fl_results->fetchAssoc()) { + $out_results[] = user_view(user_load($record['content_id']), 'search_results'); + } + $build['pager'] = array('#theme' => 'pager'); + } + + // If we aren't dealing with followed users, use the standard EFQ format and query + // all users. + else { + $users = new EntityFieldQuery(); + $results = $users->entityCondition('entity_type', 'user') + ->propertyCondition('status', 1) + ->addTag('commons_search_solr_user_people') + ->pager($limit, 1) + ->execute(); + $user_ids = array_keys($results['user']); + foreach ($user_ids as $uid) { + $out_results[] = user_view(user_load($uid), 'search_results');($user_ids); + } + $build['pager'] = array( + // As nice as it would be to make this use #theme, it is a bit more + // trouble than it is worth to process $user->pager to conform to + // renderable array standards. A custom theme suggestion should work + // for most, if not all, situations for theme overrides. + '#markup' => theme('pager__commons_search_solr_user', $users->pager), + ); + } + + // Build renderable arrays for display. + if (!empty($out_results)) { + $build['search_results'] = array( + '#theme' => 'commons_search_solr_user_results', + '#title' => t('People directory'), + '#results' => $out_results, + ); + } + } +} + +/** + * Implements hook_user_view_alter(). + */ +function commons_search_solr_user_user_view_alter(&$build) { + if ($build['#view_mode'] == 'search_results') { + // Add the user name linked to the profile. + $build['username'] = array( + '#theme' => 'username', + '#account' => $build['#account'], + '#prefix' => '

      ', + '#suffix' => '

      ', + '#weight' => 0, + ); + + // Add the user image linked to the profile. + $user_picture_uri = !empty($build['#account']->picture) ? $build['#account']->picture->uri : variable_get('user_picture_default', ''); + + $build['user_picture'] = array( + '#theme' => 'image_formatter', + '#item' => array( + 'uri' => $user_picture_uri, + 'alt' => t('Profile image'), + ), + '#image_style' => '50x50', + '#path' => array( + 'path' => 'user/' . $build['#account']->uid, + 'options' => array( + 'attributes' => array( + 'class' => array('user-picture'), + ), + ), + ), + '#weight' => 1, + ); + + // Add a section of associated groups. + if (!empty($build['#account']->og_user_node[LANGUAGE_NONE])) { + $groups = array(); + foreach ($build['#account']->og_user_node[LANGUAGE_NONE] AS $og_node) { + if ($gnode = node_load($og_node['target_id'])) { + $groups['group-item group-' . $gnode->nid] = array( + 'title' => $gnode->title, + 'href' => 'node/' . $gnode->nid, + 'attributes' => array( + 'class' => array('group-link'), + ), + ); + } + } + $build['group_membership'] = array( + '#theme' => 'links__profile_groups', + '#links' => $groups, + '#heading' => array( + 'text' => t('Recently contributed to'), + 'level' => 'h5', + 'class' => array('associated-groups-title'), + ), + '#attributes' => array( + 'class' => array( + 'associated-groups' + ), + ), + '#weight' => 3, + ); + } + + // Strip out unnecessary formatting from the actions and push them to the + // bottom of the display. + if (isset($build['flags'])) { + // Remove the reported user if it exists + if (isset($build['flags']['abuse_user'])) { + unset($build['flags']['abuse_user']); + } + + unset($build['flags']['#type']); + foreach ($build['flags'] as $key => &$data) { + if (substr($key, 0, 1) != '#' && isset($data['#type'])) { + unset($data['#type']); + } + } + + $build['flags']['#weight'] = 4; + } + + // Hide the history. + if (isset($build['summary'])) { + $build['summary']['#access'] = FALSE; + } + } +} + +/** + * Implements hook_entity_info_alter(). + */ +function commons_search_solr_user_entity_info_alter(&$entity_info) { + // Create a search results display mode for user entities. + $entity_info['user']['view modes']['search_results'] = array( + 'label' => t('Search results'), + 'custom settings' => TRUE, + ); +} + +/** + * Implements hook_form_FORM_ID_alter(). + */ +function commons_search_solr_user_form_alter(&$form, &$form_state, $form_id) { + if ($form_id == 'search_block_form') { + unset($form['custom_search_types']['#options']['c-user']); + $form['custom_search_types']['#options']['s-user'] = t('People'); + if (strtolower(arg(0)) == 'people') { + $form['search_block_form']['#default_value'] = urldecode(arg(1)); + $other_options = $form['custom_search_types']['#options']; + $form['custom_search_types']['#options'] = array_merge(array('s-user' => t('People')), $other_options); + } + //We want to override the #submit with our own, the other submits aren't relevant for the user page + $form['#submit'][]= 'commons_search_solr_user_search_submit'; + } +} + +function commons_search_solr_user_form_apachesolr_search_custom_page_search_form_alter(&$form, &$form_state) { + if ($form['#search_page']['page_id'] == 'user_search') { + $form['#attributes']['class'][] = 'user-search-form'; + if (!user_is_anonymous()) { + $form['basic']['flagged'] = array( + '#type' => 'checkbox', + '#title' => t('Following'), + '#default_value' => (empty($_GET['flagged']) ? FALSE : TRUE), + '#attributes' => array('onclick' => 'this.form.submit();'), + ); + } + $form['basic']['retain-filters']['#type'] = 'hidden'; + $form['basic']['retain-filters']['#value'] = 0; + $form['basic']['keys']['#title'] = t('Limit to'); + $form['basic']['submit']['#value'] = t('Search'); + $form['basic']['submit']['#weight'] = 10; + $form['#submit'][] = 'commons_search_solr_user_user_search_submit'; + } +} + +function commons_search_solr_user_user_search_submit($form, &$form_state) { + $form_state['redirect']['1']['query']['flagged'] = $form_state['values']['flagged']; +} + +/** + * Submit handler that handles only the redirection to our Solr user directory. + */ +function commons_search_solr_user_search_submit($form, &$form_state) { + if ($form_state['values']['custom_search_types'] == 's-user') { + $user_search_page = apachesolr_search_page_load('user_search'); + $keys = '/' . $form_state['values']['search_block_form']; + $form_state['redirect'] = $user_search_page['search_path'] . $keys; + } +} + +/** + * Implements hook_module_implements_alter(). + * This puts the solr_user hook at the end of the form_alters for custom search + * Otherwise the form_alter will get overridden by the other plethora of search + * modules. + */ +function commons_search_solr_user_module_implements_alter(&$modules, $hook) { + switch ($hook) { + case 'form_alter': + // Move this module to be last for form alterations. + $module = $modules['commons_search_solr_user']; + unset($modules['commons_search_solr_user']); + $modules['commons_search_solr_user'] = $module; + break; + } +} + +/** + * Preprocess user profile. + * + * @param array $variables + */ +function commons_search_solr_user_preprocess_user_profile(&$variables, $hook) { + if ($variables['elements']['#view_mode'] == 'search_results') { + $variables['theme_hook_suggestions'][] = 'user_profile__search_results'; + } +} + +/** + * Implements hook_preprocess_commons_search_solr_user_results(). + */ +function commons_search_solr_user_preprocess_commons_search_solr_user_results(&$variables, $hook) { + // Add classed to the results header. + $variables['title_attributes_array']['class'][] = 'user-search-results-title'; + // Add a class to the results wrapper. + $variables['content_attributes_array']['class'][] = 'user-search-results-content'; + + // Populate the content array. + $variables['content'] = array(); + if (!empty($variables['results'])) { + $variables['content']['results'] = $variables['results']; + } +} + +/** + * Implements hook_process_hook(). + */ +function commons_search_solr_user_process_search_results(&$variables, $hook) { + if ($variables['search_page']['page_id'] == 'user_search') { + // We set the title to be blank so it doesn't display 'Search results'. + $variables['title'] = ' '; + } +} + +/** + * Feature module hook. Invoked on a Feature module after that module is + * enabled. + * + * @param $component + * String name of the component that has just been enabled. + */ +function commons_search_solr_user_post_features_enable_feature($component) { + if ($component == 'apachesolr_search_page') { + $revert = array( + 'commons_search_solr_user' => array('apachesolr_search_page'), + ); + features_revert($revert); + + // We must clear the menu cache before trying to set a link, otherwise the menu + // system won't show the people link because it doesn't think the page exists + // even though the link exists in the menu. + drupal_static_reset('apachesolr_search_load_all_search_pages'); + + $revert = array( + 'commons_search_solr_user' => array('menu_links'), + ); + features_revert($revert); + } +} diff --git a/modules/commons/commons_site_homepage/commons_site_homepage.features.inc b/modules/commons/commons_site_homepage/commons_site_homepage.features.inc new file mode 100644 index 0000000..2c9f02a --- /dev/null +++ b/modules/commons/commons_site_homepage/commons_site_homepage.features.inc @@ -0,0 +1,24 @@ + "1"); + } + if ($module == "strongarm" && $api == "strongarm") { + return array("version" => "1"); + } +} + +/** + * Implements hook_views_api(). + */ +function commons_site_homepage_views_api($module = NULL, $api = NULL) { + return array("api" => "3.0"); +} diff --git a/modules/commons/commons_site_homepage/commons_site_homepage.info b/modules/commons/commons_site_homepage/commons_site_homepage.info new file mode 100644 index 0000000..60f9e39 --- /dev/null +++ b/modules/commons/commons_site_homepage/commons_site_homepage.info @@ -0,0 +1,21 @@ +name = Commons Site Homepage +description = Provides a homepage for the site for anonymous and authenticated users +core = 7.x +package = Commons - Landing pages +dependencies[] = commons_activity_streams +dependencies[] = commons_featured +dependencies[] = commons_follow +dependencies[] = commons_radioactivity_groups +dependencies[] = entity +dependencies[] = page_manager +dependencies[] = strongarm +dependencies[] = views +dependencies[] = views_litepager +features[ctools][] = page_manager:pages_default:1 +features[ctools][] = strongarm:strongarm:1 +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[page_manager_pages][] = commons_home +features[variable][] = site_frontpage +features[views_view][] = commons_homepage_content +features_exclude[dependencies][views_content] = views_content diff --git a/modules/commons/commons_site_homepage/commons_site_homepage.install b/modules/commons/commons_site_homepage/commons_site_homepage.install new file mode 100644 index 0000000..23564ab --- /dev/null +++ b/modules/commons/commons_site_homepage/commons_site_homepage.install @@ -0,0 +1,15 @@ + array( + 'page_manager_pages', + ), + ); + features_revert($revert); + return array(); +} \ No newline at end of file diff --git a/modules/commons/commons_site_homepage/commons_site_homepage.module b/modules/commons/commons_site_homepage/commons_site_homepage.module new file mode 100644 index 0000000..4210348 --- /dev/null +++ b/modules/commons/commons_site_homepage/commons_site_homepage.module @@ -0,0 +1,140 @@ + $name) { + if ($type != 'All') { + $form['type']['#options'][$type] = t(strtolower(substr($name, 0, 1)) . substr($name,1) . 's'); + } + } + } +} + +function commons_homepage_user_register_login_submit($form, &$form_state) { + $form_state['redirect'] = variable_get('site_frontpage', 'home'); +} + +/** + * Implements hook_block_info(). + */ +function commons_site_homepage_block_info() { + $blocks['commons_site_homepage'] = array( + 'info' => t('Commons anonymous homepage sign up/log in buttons'), + 'cache' => DRUPAL_NO_CACHE, + ); + + return $blocks; +} + +/** + * Implements hook_block_view(). + */ +function commons_site_homepage_block_view($delta = '') { + $block = array(); + + switch ($delta) { + case 'commons_site_homepage': + // The block does not have a default title. + $block['subject'] = NULL; + + $links = array(); + + // Display a 'sign up' link if visitors can create accounts. + if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) { + $links[] = array( + 'title' => t('Sign up'), + 'href' => 'user/register', + 'attributes' => array( + 'class' => array('commons-sign-up'), + ), + ); + } + + // Always display a 'log in' link. + $links[] = array( + 'title' => t('Log in'), + 'href' => 'user/login', + 'attributes' => array( + 'class' => array('commons-login'), + ), + ); + + $block['content'] = array( + '#theme' => 'links', + '#links' => $links, + '#attributes' => array( + 'class' => array('links', 'inline'), + ), + ); + break; + } + + return $block; +} + +/** + * Implements hook_default_page_manager_pages_alter(). + */ +function commons_site_homepage_default_page_manager_pages_alter(&$items) { + if (isset($items['commons_home'])) { + $items['commons_home']->default_handlers['page_commons_home_panel_context_2']->conf['display']->content['new-2ab570f0-8498-44f4-e9d0-9977e3d8d4df']->configuration['title'] = variable_get('commons_anonymous_welcome_title', t('The open-source alternative for enterprise-scale business software')); + $items['commons_home']->default_handlers['page_commons_home_panel_context_2']->conf['display']->content['new-2ab570f0-8498-44f4-e9d0-9977e3d8d4df']->configuration['body'] = variable_get('commons_anonymous_welcome_body', t('Enable social networking to create productive interactions. Whether your community is public or private, Commons does it!')); + + $pane = new stdClass(); + $pane->pid = 'new-94106ddd-1278-0954-c5ba-b59ff1b9bf49'; + $pane->panel = 'three_33_first'; + $pane->type = 'views'; + $pane->subtype = 'commons_events_upcoming'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_pager_settings' => 0, + 'use_pager' => 0, + 'nodes_per_page' => '5', + 'pager_id' => '0', + 'offset' => '0', + 'more_link' => 0, + 'feed_icons' => 0, + 'panel_args' => 0, + 'link_to_view' => 0, + 'args' => '', + 'url' => '', + 'display' => 'commons_events_upcoming_global_block', + 'override_title' => 0, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 1; + $pane->locks = array(); + $pane->uuid = '94106ddd-1278-0954-c5ba-b59ff1b9bf49'; + $items['commons_home']->default_handlers['page_commons_home_panel_context_2']->conf['display']->content['new-94106ddd-1278-0954-c5ba-b59ff1b9bf49'] = $pane; + $items['commons_home']->default_handlers['page_commons_home_panel_context_2']->conf['display']->panels['three_33_first'][1] = 'new-94106ddd-1278-0954-c5ba-b59ff1b9bf49'; + } +} diff --git a/modules/commons/commons_site_homepage/commons_site_homepage.pages_default.inc b/modules/commons/commons_site_homepage/commons_site_homepage.pages_default.inc new file mode 100644 index 0000000..213f998 --- /dev/null +++ b/modules/commons/commons_site_homepage/commons_site_homepage.pages_default.inc @@ -0,0 +1,356 @@ +disabled = FALSE; /* Edit this to true to make a default page disabled initially */ + $page->api_version = 1; + $page->name = 'commons_home'; + $page->task = 'page'; + $page->admin_title = 'Home'; + $page->admin_description = 'Site home page for anonymous and authenticated users.'; + $page->path = 'home'; + $page->access = array( + 'type' => 'none', + 'settings' => NULL, + ); + $page->menu = array( + 'type' => 'normal', + 'title' => 'Home', + 'weight' => '-10', + 'name' => 'main-menu', + 'parent' => array( + 'type' => 'none', + 'title' => '', + 'weight' => 0, + 'name' => 'navigation', + ), + ); + $page->arguments = array(); + $page->conf = array(); + $page->default_handlers = array(); + $handler = new stdClass(); + $handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */ + $handler->api_version = 1; + $handler->name = 'page_commons_home_panel_context'; + $handler->task = 'page'; + $handler->subtask = 'commons_home'; + $handler->handler = 'panel_context'; + $handler->weight = 0; + $handler->conf = array( + 'title' => 'Home (authenticated)', + 'no_blocks' => 0, + 'pipeline' => 'ipe', + 'body_classes_to_remove' => '', + 'body_classes_to_add' => '', + 'css_id' => '', + 'css' => '', + 'contexts' => array(), + 'relationships' => array(), + 'access' => array( + 'plugins' => array( + 0 => array( + 'name' => 'role', + 'settings' => array( + 'rids' => array( + 0 => 2, + ), + ), + 'context' => 'logged-in-user', + 'not' => FALSE, + ), + ), + 'logic' => 'and', + ), + ); + $display = new panels_display(); + $display->layout = 'two_66_33'; + $display->layout_settings = array(); + $display->panel_settings = array( + 'style_settings' => array( + 'default' => NULL, + 'two_66_33_top' => NULL, + 'two_66_33_first' => NULL, + 'two_66_33_second' => NULL, + 'two_66_33_bottom' => NULL, + ), + ); + $display->cache = array(); + $display->title = 'What\'s going on?'; + $display->uuid = '84741210-79de-a174-5d6f-8ebfcb061f03'; + $display->content = array(); + $display->panels = array(); + $pane = new stdClass(); + $pane->pid = 'new-97c7ce09-3cb1-6b34-a940-8fda43e609cc'; + $pane->panel = 'two_66_33_first'; + $pane->type = 'commons_bw_group'; + $pane->subtype = 'commons_bw_group'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = '97c7ce09-3cb1-6b34-a940-8fda43e609cc'; + $display->content['new-97c7ce09-3cb1-6b34-a940-8fda43e609cc'] = $pane; + $display->panels['two_66_33_first'][0] = 'new-97c7ce09-3cb1-6b34-a940-8fda43e609cc'; + $pane = new stdClass(); + $pane->pid = 'new-b20add8c-2daf-4684-45f3-212d60c7f31e'; + $pane->panel = 'two_66_33_second'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_activity_streams_activity-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = 'b20add8c-2daf-4684-45f3-212d60c7f31e'; + $display->content['new-b20add8c-2daf-4684-45f3-212d60c7f31e'] = $pane; + $display->panels['two_66_33_second'][0] = 'new-b20add8c-2daf-4684-45f3-212d60c7f31e'; + $pane = new stdClass(); + $pane->pid = 'new-da301a84-b9a5-8664-cd4b-1e84d7dd9f42'; + $pane->panel = 'two_66_33_second'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_featured-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 1; + $pane->locks = array(); + $pane->uuid = 'da301a84-b9a5-8664-cd4b-1e84d7dd9f42'; + $display->content['new-da301a84-b9a5-8664-cd4b-1e84d7dd9f42'] = $pane; + $display->panels['two_66_33_second'][1] = 'new-da301a84-b9a5-8664-cd4b-1e84d7dd9f42'; + $pane = new stdClass(); + $pane->pid = 'new-895dfc63-a30f-f734-3185-c40c407b4af0'; + $pane->panel = 'two_66_33_second'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_groups_contributors-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 2; + $pane->locks = array(); + $pane->uuid = '895dfc63-a30f-f734-3185-c40c407b4af0'; + $display->content['new-895dfc63-a30f-f734-3185-c40c407b4af0'] = $pane; + $display->panels['two_66_33_second'][2] = 'new-895dfc63-a30f-f734-3185-c40c407b4af0'; + $display->hide_title = PANELS_TITLE_FIXED; + $display->title_pane = '0'; + $handler->conf['display'] = $display; + $page->default_handlers[$handler->name] = $handler; + $handler = new stdClass(); + $handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */ + $handler->api_version = 1; + $handler->name = 'page_commons_home_panel_context_2'; + $handler->task = 'page'; + $handler->subtask = 'commons_home'; + $handler->handler = 'panel_context'; + $handler->weight = 1; + $handler->conf = array( + 'title' => 'Home (anonymous)', + 'no_blocks' => 0, + 'pipeline' => 'standard', + 'body_classes_to_remove' => '', + 'body_classes_to_add' => '', + 'css_id' => '', + 'css' => '', + 'contexts' => array(), + 'relationships' => array(), + 'access' => array( + 'plugins' => array( + 0 => array( + 'name' => 'role', + 'settings' => array( + 'rids' => array( + 0 => 1, + ), + ), + 'context' => 'logged-in-user', + 'not' => FALSE, + ), + ), + 'logic' => 'and', + ), + ); + $display = new panels_display(); + $display->layout = 'three_3x33'; + $display->layout_settings = array(); + $display->panel_settings = array( + 'style_settings' => array( + 'default' => NULL, + 'two_66_33_top' => NULL, + 'two_66_33_first' => NULL, + 'two_66_33_second' => NULL, + 'two_66_33_bottom' => NULL, + 'three_33_top' => NULL, + 'three_33_first' => NULL, + 'three_33_second' => NULL, + 'three_33_third' => NULL, + 'three_33_bottom' => NULL, + ), + ); + $display->cache = array(); + $display->title = ''; + $display->uuid = 'afa005f6-cf15-78e4-d53d-8885db3cde39'; + $display->content = array(); + $display->panels = array(); + $pane = new stdClass(); + $pane->pid = 'new-0ae8e5a2-44f6-8584-21f2-8be6e340e62f'; + $pane->panel = 'three_33_first'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_groups_contributors-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = '0ae8e5a2-44f6-8584-21f2-8be6e340e62f'; + $display->content['new-0ae8e5a2-44f6-8584-21f2-8be6e340e62f'] = $pane; + $display->panels['three_33_first'][0] = 'new-0ae8e5a2-44f6-8584-21f2-8be6e340e62f'; + $pane = new stdClass(); + $pane->pid = 'new-b6e290b7-1d2b-5db4-a181-28befdcde628'; + $pane->panel = 'three_33_second'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_radioactivity_groups_most_active-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = 'b6e290b7-1d2b-5db4-a181-28befdcde628'; + $display->content['new-b6e290b7-1d2b-5db4-a181-28befdcde628'] = $pane; + $display->panels['three_33_second'][0] = 'new-b6e290b7-1d2b-5db4-a181-28befdcde628'; + $pane = new stdClass(); + $pane->pid = 'new-800b2f8a-307f-0e14-4174-626a1c5c4cd9'; + $pane->panel = 'three_33_third'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_featured-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = '800b2f8a-307f-0e14-4174-626a1c5c4cd9'; + $display->content['new-800b2f8a-307f-0e14-4174-626a1c5c4cd9'] = $pane; + $display->panels['three_33_third'][0] = 'new-800b2f8a-307f-0e14-4174-626a1c5c4cd9'; + $pane = new stdClass(); + $pane->pid = 'new-58e71a00-2b87-ab64-31c5-4fdc9e99a2d4'; + $pane->panel = 'three_33_third'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_activity_streams_activity-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 1; + $pane->locks = array(); + $pane->uuid = '58e71a00-2b87-ab64-31c5-4fdc9e99a2d4'; + $display->content['new-58e71a00-2b87-ab64-31c5-4fdc9e99a2d4'] = $pane; + $display->panels['three_33_third'][1] = 'new-58e71a00-2b87-ab64-31c5-4fdc9e99a2d4'; + $pane = new stdClass(); + $pane->pid = 'new-7d40d7ca-0ea5-9a54-4d1f-8b6240e72bf0'; + $pane->panel = 'three_33_top'; + $pane->type = 'block'; + $pane->subtype = 'commons_site_homepage-commons_site_homepage'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'override_title' => 0, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = '7d40d7ca-0ea5-9a54-4d1f-8b6240e72bf0'; + $display->content['new-7d40d7ca-0ea5-9a54-4d1f-8b6240e72bf0'] = $pane; + $display->panels['three_33_top'][0] = 'new-7d40d7ca-0ea5-9a54-4d1f-8b6240e72bf0'; + $pane = new stdClass(); + $pane->pid = 'new-2ab570f0-8498-44f4-e9d0-9977e3d8d4df'; + $pane->panel = 'three_33_top'; + $pane->type = 'custom'; + $pane->subtype = 'custom'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'admin_title' => 'Anonymous homepage welcome text', + 'title' => 'Welcome to our community', + 'body' => 'Share your thoughts, find answers to your questions.', + 'format' => 'filtered_html', + 'substitute' => TRUE, + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 1; + $pane->locks = array(); + $pane->uuid = '2ab570f0-8498-44f4-e9d0-9977e3d8d4df'; + $display->content['new-2ab570f0-8498-44f4-e9d0-9977e3d8d4df'] = $pane; + $display->panels['three_33_top'][1] = 'new-2ab570f0-8498-44f4-e9d0-9977e3d8d4df'; + $display->hide_title = PANELS_TITLE_NONE; + $display->title_pane = '0'; + $handler->conf['display'] = $display; + $page->default_handlers[$handler->name] = $handler; + $pages['commons_home'] = $page; + + return $pages; + +} diff --git a/modules/commons/commons_site_homepage/commons_site_homepage.strongarm.inc b/modules/commons/commons_site_homepage/commons_site_homepage.strongarm.inc new file mode 100644 index 0000000..52ec3d3 --- /dev/null +++ b/modules/commons/commons_site_homepage/commons_site_homepage.strongarm.inc @@ -0,0 +1,21 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'site_frontpage'; + $strongarm->value = 'home'; + $export['site_frontpage'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_site_homepage/commons_site_homepage.variable.inc b/modules/commons/commons_site_homepage/commons_site_homepage.variable.inc new file mode 100644 index 0000000..012fb5d --- /dev/null +++ b/modules/commons/commons_site_homepage/commons_site_homepage.variable.inc @@ -0,0 +1,40 @@ + t('Commons Site Homepage'), + 'description' => t("Text that will be shown on your community's homepage to help new visitors understand what your community is about and why they should join."), + ); + + return $groups; +} + +/** + * Implements hook_variable_info(). + */ +function commons_site_homepage_variable_info($options) { + $variable['commons_anonymous_welcome_title'] = array( + 'type' => 'string', + 'title' => t('Welcome headline', array(), $options), + 'description' => t('A short description of the community that visitors can understand at a glance.'), + 'default' => 'The open-source alternative for enterprise-scale business software', + 'group' => 'commons_site_homepage', + ); + $variable['commons_anonymous_welcome_body'] = array( + 'type' => 'string', + 'title' => t('Welcome body text', array(), $options), + 'description' => t('A couple of sentences elaborating about your community.'), + 'default' => 'Enable social networking to create productive interactions. Whether your community is public or private, Commons does it!', + 'group' => 'commons_site_homepage', + ); + + return $variable; +} diff --git a/modules/commons/commons_site_homepage/commons_site_homepage.views_default.inc b/modules/commons/commons_site_homepage/commons_site_homepage.views_default.inc new file mode 100644 index 0000000..9984858 --- /dev/null +++ b/modules/commons/commons_site_homepage/commons_site_homepage.views_default.inc @@ -0,0 +1,173 @@ +name = 'commons_homepage_content'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'commons_homepage_content'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_ajax'] = TRUE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['exposed_form']['options']['expose_sort_order'] = FALSE; + $handler->display->display_options['pager']['type'] = 'lite'; + $handler->display->display_options['pager']['options']['items_per_page'] = '4'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '1'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'entity'; + $handler->display->display_options['row_options']['view_mode'] = 'teaser'; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'No content matched the filters you selected.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Content: Updated date */ + $handler->display->display_options['sorts']['changed']['id'] = 'changed'; + $handler->display->display_options['sorts']['changed']['table'] = 'node'; + $handler->display->display_options['sorts']['changed']['field'] = 'changed'; + $handler->display->display_options['sorts']['changed']['order'] = 'DESC'; + $handler->display->display_options['sorts']['changed']['exposed'] = TRUE; + $handler->display->display_options['sorts']['changed']['expose']['label'] = 'last updated first'; + /* Sort criterion: Content: Radioactivity (field_radioactivity:radioactivity_energy) */ + $handler->display->display_options['sorts']['field_radioactivity_radioactivity_energy']['id'] = 'field_radioactivity_radioactivity_energy'; + $handler->display->display_options['sorts']['field_radioactivity_radioactivity_energy']['table'] = 'field_data_field_radioactivity'; + $handler->display->display_options['sorts']['field_radioactivity_radioactivity_energy']['field'] = 'field_radioactivity_radioactivity_energy'; + $handler->display->display_options['sorts']['field_radioactivity_radioactivity_energy']['order'] = 'DESC'; + $handler->display->display_options['sorts']['field_radioactivity_radioactivity_energy']['exposed'] = TRUE; + $handler->display->display_options['sorts']['field_radioactivity_radioactivity_energy']['expose']['label'] = 'most active'; + /* Contextual filter: Content: Nid */ + $handler->display->display_options['arguments']['nid']['id'] = 'nid'; + $handler->display->display_options['arguments']['nid']['table'] = 'node'; + $handler->display->display_options['arguments']['nid']['field'] = 'nid'; + $handler->display->display_options['arguments']['nid']['default_action'] = 'default'; + $handler->display->display_options['arguments']['nid']['default_argument_type'] = 'commons_follow_node'; + $handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25'; + $handler->display->display_options['arguments']['nid']['specify_validation'] = TRUE; + $handler->display->display_options['arguments']['nid']['validate']['fail'] = 'empty'; + $handler->display->display_options['arguments']['nid']['break_phrase'] = TRUE; + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'node'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['group'] = 1; + $handler->display->display_options['filters']['type']['exposed'] = TRUE; + $handler->display->display_options['filters']['type']['expose']['operator_id'] = 'type_op'; + $handler->display->display_options['filters']['type']['expose']['label'] = 'Showing'; + $handler->display->display_options['filters']['type']['expose']['operator'] = 'type_op'; + $handler->display->display_options['filters']['type']['expose']['identifier'] = 'type'; + $handler->display->display_options['filters']['type']['expose']['remember'] = TRUE; + $handler->display->display_options['filters']['type']['expose']['remember_roles'] = array( + 2 => '2', + 1 => 0, + 3 => 0, + ); + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Content: User Follow */ + $handler->display->display_options['filters']['cf_user_follow']['id'] = 'cf_user_follow'; + $handler->display->display_options['filters']['cf_user_follow']['table'] = 'node'; + $handler->display->display_options['filters']['cf_user_follow']['field'] = 'cf_user_follow'; + $handler->display->display_options['filters']['cf_user_follow']['value'] = '0'; + $handler->display->display_options['filters']['cf_user_follow']['exposed'] = TRUE; + $handler->display->display_options['filters']['cf_user_follow']['expose']['operator_id'] = ''; + $handler->display->display_options['filters']['cf_user_follow']['expose']['label'] = 'I\'m'; + $handler->display->display_options['filters']['cf_user_follow']['expose']['operator'] = 'cf_user_follow_op'; + $handler->display->display_options['filters']['cf_user_follow']['expose']['identifier'] = 'following'; + $handler->display->display_options['filters']['cf_user_follow']['expose']['required'] = TRUE; + $handler->display->display_options['filters']['cf_user_follow']['expose']['remember'] = TRUE; + $handler->display->display_options['filters']['cf_user_follow']['expose']['remember_roles'] = array( + 2 => '2', + 1 => 0, + 3 => 0, + ); + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type_1']['id'] = 'type_1'; + $handler->display->display_options['filters']['type_1']['table'] = 'node'; + $handler->display->display_options['filters']['type_1']['field'] = 'type'; + $handler->display->display_options['filters']['type_1']['operator'] = 'not in'; + $handler->display->display_options['filters']['type_1']['value'] = array( + 'group' => 'group', + ); + + /* Display: Content pane */ + $handler = $view->new_display('panel_pane', 'Content pane', 'panel_pane_1'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['pane_title'] = 'What\'s going on?'; + $handler->display->display_options['pane_category']['name'] = 'Commons'; + $handler->display->display_options['pane_category']['weight'] = '0'; + $handler->display->display_options['allow']['use_pager'] = 0; + $handler->display->display_options['allow']['items_per_page'] = 0; + $handler->display->display_options['allow']['offset'] = 0; + $handler->display->display_options['allow']['link_to_view'] = 0; + $handler->display->display_options['allow']['more_link'] = 0; + $handler->display->display_options['allow']['path_override'] = 0; + $handler->display->display_options['allow']['title_override'] = 0; + $handler->display->display_options['allow']['exposed_form'] = 0; + $handler->display->display_options['allow']['fields_override'] = 0; + $handler->display->display_options['inherit_panels_path'] = '1'; + $translatables['commons_homepage_content'] = array( + t('Master'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('No content matched the filters you selected.'), + t('last updated first'), + t('most active'), + t('All'), + t('Showing'), + t('I\'m'), + t('Content pane'), + t('What\'s going on?'), + t('Commons'), + ); + $export['commons_homepage_content'] = $view; + + return $export; +} diff --git a/modules/commons/commons_social_sharing/commons_social_sharing.features.inc b/modules/commons/commons_social_sharing/commons_social_sharing.features.inc new file mode 100644 index 0000000..4dc0370 --- /dev/null +++ b/modules/commons/commons_social_sharing/commons_social_sharing.features.inc @@ -0,0 +1,14 @@ + "1"); + } +} diff --git a/modules/commons/commons_social_sharing/commons_social_sharing.info b/modules/commons/commons_social_sharing/commons_social_sharing.info new file mode 100644 index 0000000..a16a207 --- /dev/null +++ b/modules/commons/commons_social_sharing/commons_social_sharing.info @@ -0,0 +1,18 @@ +name = Commons Social Sharing +description = Provide links to share content to external social services such as Facebook and Google+ +core = 7.x +package = Commons - Building blocks +dependencies[] = ctools +dependencies[] = sharethis +dependencies[] = strongarm +features[ctools][] = strongarm:strongarm:1 +features[features_api][] = api:2 +features[variable][] = sharethis_button_option +features[variable][] = sharethis_comments +features[variable][] = sharethis_late_load +features[variable][] = sharethis_location +features[variable][] = sharethis_node_option +features[variable][] = sharethis_option_extras +features[variable][] = sharethis_teaser_option +features[variable][] = sharethis_weight +features[variable][] = sharethis_widget_option diff --git a/modules/commons/commons_social_sharing/commons_social_sharing.module b/modules/commons/commons_social_sharing/commons_social_sharing.module new file mode 100644 index 0000000..928a28b --- /dev/null +++ b/modules/commons/commons_social_sharing/commons_social_sharing.module @@ -0,0 +1,7 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'sharethis_button_option'; + $strongarm->value = 'stbc_vcount'; + $export['sharethis_button_option'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'sharethis_comments'; + $strongarm->value = 0; + $export['sharethis_comments'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'sharethis_late_load'; + $strongarm->value = 0; + $export['sharethis_late_load'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'sharethis_location'; + $strongarm->value = 'links'; + $export['sharethis_location'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'sharethis_node_option'; + $strongarm->value = 'group,page,post,0,0,0,0,0,0'; + $export['sharethis_node_option'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'sharethis_option_extras'; + $strongarm->value = array( + 'Facebook Like:fblike' => 'Facebook Like:fblike', + 'Google Plus One:plusone' => 0, + ); + $export['sharethis_option_extras'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'sharethis_teaser_option'; + $strongarm->value = 1; + $export['sharethis_teaser_option'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'sharethis_weight'; + $strongarm->value = '10'; + $export['sharethis_weight'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'sharethis_widget_option'; + $strongarm->value = 'st_multi'; + $export['sharethis_widget_option'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_topics/commons_topics.features.field_base.inc b/modules/commons/commons_topics/commons_topics.features.field_base.inc new file mode 100644 index 0000000..d43d7b9 --- /dev/null +++ b/modules/commons/commons_topics/commons_topics.features.field_base.inc @@ -0,0 +1,48 @@ + 1, + 'cardinality' => -1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_topics', + 'foreign keys' => array( + 'tid' => array( + 'columns' => array( + 'tid' => 'tid', + ), + 'table' => 'taxonomy_term_data', + ), + ), + 'indexes' => array( + 'tid' => array( + 0 => 'tid', + ), + ), + 'locked' => 0, + 'module' => 'taxonomy', + 'settings' => array( + 'allowed_values' => array( + 0 => array( + 'vocabulary' => 'topics', + 'parent' => 0, + ), + ), + ), + 'translatable' => 0, + 'type' => 'taxonomy_term_reference', + ); + + return $field_bases; +} diff --git a/modules/commons/commons_topics/commons_topics.features.field_instance.inc b/modules/commons/commons_topics/commons_topics.features.field_instance.inc new file mode 100644 index 0000000..9bed7dd --- /dev/null +++ b/modules/commons/commons_topics/commons_topics.features.field_instance.inc @@ -0,0 +1,66 @@ + $bundles) { + foreach(array_keys($bundles) as $bundle) { + commons_topics_field_definition($field_instances, $entity_type, $bundle); + } + } + } + + return $field_instances; +} + +function commons_topics_field_definition(&$field_instances, $entity_type, $bundle) { + // Exported field_instance: 'ENTITY_TYPE-BUNDLE-field_topics' + $field_instances["$entity_type-$bundle-field_topics"] = array( + 'bundle' => $bundle, + 'default_value' => NULL, + 'deleted' => '0', + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'taxonomy', + 'settings' => array(), + 'type' => 'taxonomy_term_reference_link', + 'weight' => '6', + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => $entity_type, + 'field_name' => 'field_topics', + 'label' => 'Topics', + 'required' => 0, + 'settings' => array( + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 0, + 'module' => 'taxonomy', + 'settings' => array( + 'autocomplete_path' => 'taxonomy/autocomplete', + 'size' => 60, + ), + 'type' => 'taxonomy_autocomplete', + 'weight' => '13', + ), + ); +} diff --git a/modules/commons/commons_topics/commons_topics.features.taxonomy.inc b/modules/commons/commons_topics/commons_topics.features.taxonomy.inc new file mode 100644 index 0000000..1ca8d6f --- /dev/null +++ b/modules/commons/commons_topics/commons_topics.features.taxonomy.inc @@ -0,0 +1,36 @@ + array( + 'name' => 'Topics', + 'machine_name' => 'topics', + 'description' => '', + 'hierarchy' => 0, + 'module' => 'taxonomy', + 'weight' => 0, + 'rdf_mapping' => array( + 'rdftype' => array( + 0 => 'skos:ConceptScheme', + ), + 'name' => array( + 'predicates' => array( + 0 => 'dc:title', + ), + ), + 'description' => array( + 'predicates' => array( + 0 => 'rdfs:comment', + ), + ), + ), + ), + ); +} diff --git a/modules/commons/commons_topics/commons_topics.info b/modules/commons/commons_topics/commons_topics.info new file mode 100644 index 0000000..7546f1a --- /dev/null +++ b/modules/commons/commons_topics/commons_topics.info @@ -0,0 +1,8 @@ +name = Commons Topics +core = 7.x +package = Commons - Building blocks +dependencies[] = features +dependencies[] = taxonomy +features[features_api][] = api:2 +features[field_base][] = field_topics +features[taxonomy][] = topics diff --git a/modules/commons/commons_topics/commons_topics.module b/modules/commons/commons_topics/commons_topics.module new file mode 100644 index 0000000..b4dc6dd --- /dev/null +++ b/modules/commons/commons_topics/commons_topics.module @@ -0,0 +1,87 @@ +name == 'commons_topics') { + $commons_topics_entity_types = commons_topics_get_entity_types_with_topics(); + if (!empty($commons_topics_entity_types)) { + foreach ($commons_topics_entity_types as $entity_type => $bundles) { + foreach(array_keys($bundles) as $bundle) { + $info['features']['field_instance'][] = "$entity_type-$bundle-field_topics"; + } + } + } + } +} + +/** + * Implements hook_form_FORM_ID_alter(); + */ +function commons_topics_form_node_form_alter(&$form, &$form_state) { + if (isset($form['field_topics'])) { + $form['topics_wrapper'] = array( + '#type' => 'fieldset', + '#title' => t('Topics'), + '#collapsible' => TRUE, + '#collapsed' => FALSE, + '#group' => 'additional_settings', + '#weight' => -15, + ); + $form['topics_wrapper']['field_topics'] = $form['field_topics']; + $form['field_topics'] = array('#language' => NULL); + $form['#attached']['js'] = array( + drupal_get_path('module', 'commons_topics') . '/js/commons_topics.js', + ); + } +} + +/** + * Returns an array of entity types that are enabled via Commons. + */ +function commons_topics_get_entity_types_with_topics() { + // Find all Commons Entity integrations. + $commons_entity_integrations = commons_entity_integration_info(); + if (empty($commons_entity_integrations)) { + return array(); + } + + foreach ($commons_entity_integrations as $entity_type => $integration) { + foreach ($integration as $bundle => $options) { + if (isset($options['exclude_topics']) && $options['exclude_topics'] == TRUE) { + unset($commons_entity_integrations[$entity_type][$bundle]); + } + } + // If an entity type has no integrations, don't return it. + if (empty($commons_entity_integrations[$entity_type])) { + unset($commons_entity_integrations[$entity_type]); + } + } + + return $commons_entity_integrations; +} + +/** + * Implements hook_features_pipe_alter(). + */ +function commons_topics_features_pipe_alter(&$pipe, $data, $export) { + if (!empty($pipe['field_instance'])) { + foreach ($pipe['field_instance'] as $delta => $value) { + $args = explode('-', $value); + $field_name = $args[2]; + if ($field_name == 'field_topics') { + unset($pipe['field_instance'][$delta]); + } + } + } +} diff --git a/modules/commons/commons_topics/js/commons_topics.js b/modules/commons/commons_topics/js/commons_topics.js new file mode 100644 index 0000000..8d7c175 --- /dev/null +++ b/modules/commons/commons_topics/js/commons_topics.js @@ -0,0 +1,15 @@ +(function ($) { + Drupal.behaviors.commons_topics_update_legend = { + attach: function (context, settings) { + $(':input[name^="field_topics"]').change(function() { + if ($(':input[name^="field_topics"]').val() == "") { + $("[id^='edit-topics-wrapper'] .summary").text(Drupal.t("No topics")); + } + else { + $("[id^='edit-topics-wrapper'] .summary").text($(':input[name^="field_topics"]').val()); + } + }); + $(':input[name^="field_topics"]').change(); + } + }; +})(jQuery); diff --git a/modules/commons/commons_trusted_contacts/commons_trusted_contacts.commons_utility_links.inc b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.commons_utility_links.inc new file mode 100644 index 0000000..3ffe7ea --- /dev/null +++ b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.commons_utility_links.inc @@ -0,0 +1,57 @@ +uid)); + + // Check for unread messages. + $unread_messages = privatemsg_unread_count($account); + + // Provide a default mailbox icon pointing to the private messages UI when + // there are no unread messages or invitations. + if (empty($unread_invitations) && empty($unread_messages)) { + $links['no-unread-messages'] = array( + 'href' => 'user/' . $user->uid . '/contacts', + 'query' => array('qt-commons_trusted_contacts' => 'messages'), + 'title' => t('No unread messages'), + 'weight' => -9, + ); + } + + // Add a link to the user's invitations. + if ($unread_invitations) { + $links['unread-invitations']= array( + 'href' => 'user/' . $user->uid . '/contacts', + 'query' => array('qt-commons_trusted_contacts' => 'invitations'), + 'title' => format_plural($unread_invitations, '1 invitation', '@count invitations'), + 'weight' => -8, + ); + } + + // Add a link to the user's unread messages. + if ($unread_messages) { + $links['unread-messages']= array( + 'href' => 'user/' . $user->uid . '/contacts', + 'query' => array('qt-commons_trusted_contacts' => 'messages'), + 'title' => format_plural($unread_messages, '1 message', '@count messages'), + 'weight' => -7, + ); + } + } + + return $links; +} diff --git a/modules/commons/commons_trusted_contacts/commons_trusted_contacts.features.field_base.inc b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.features.field_base.inc new file mode 100644 index 0000000..3edeb77 --- /dev/null +++ b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.features.field_base.inc @@ -0,0 +1,335 @@ + 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_approving_user', + 'foreign keys' => array( + 'users' => array( + 'columns' => array( + 'target_id' => 'uid', + ), + 'table' => 'users', + ), + ), + 'indexes' => array( + 'target_id' => array( + 0 => 'target_id', + ), + ), + 'locked' => 0, + 'module' => 'entityreference', + 'settings' => array( + 'handler' => 'base', + 'handler_settings' => array( + 'behaviors' => array( + 'views-select-list' => array( + 'status' => 0, + ), + ), + 'sort' => array( + 'type' => 'none', + ), + 'target_bundles' => array(), + ), + 'target_type' => 'user', + ), + 'translatable' => 0, + 'type' => 'entityreference', + ); + + // Exported field_base: 'field_confirmation' + $field_bases['field_confirmation'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_confirmation', + 'foreign keys' => array(), + 'indexes' => array( + 'value' => array( + 0 => 'value', + ), + ), + 'locked' => 0, + 'module' => 'list', + 'settings' => array( + 'allowed_values' => array( + 0 => '', + 1 => '', + ), + 'allowed_values_function' => '', + ), + 'translatable' => 0, + 'type' => 'list_boolean', + ); + + // Exported field_base: 'field_membership_token' + $field_bases['field_membership_token'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_membership_token', + 'foreign keys' => array( + 'format' => array( + 'columns' => array( + 'format' => 'format', + ), + 'table' => 'filter_format', + ), + ), + 'indexes' => array( + 'format' => array( + 0 => 'format', + ), + ), + 'locked' => 0, + 'module' => 'text', + 'settings' => array( + 'max_length' => 100, + ), + 'translatable' => 0, + 'type' => 'text', + ); + + // Exported field_base: 'field_my_request' + $field_bases['field_my_request'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_my_request', + 'foreign keys' => array(), + 'indexes' => array( + 'value' => array( + 0 => 'value', + ), + ), + 'locked' => 0, + 'module' => 'list', + 'settings' => array( + 'allowed_values' => array( + 0 => 0, + 1 => 1, + ), + 'allowed_values_function' => '', + ), + 'translatable' => 0, + 'type' => 'list_boolean', + ); + + // Exported field_base: 'field_original_og_membership' + $field_bases['field_original_og_membership'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_original_og_membership', + 'foreign keys' => array( + 'og_membership' => array( + 'columns' => array( + 'target_id' => 'id', + ), + 'table' => 'og_membership', + ), + ), + 'indexes' => array( + 'target_id' => array( + 0 => 'target_id', + ), + ), + 'locked' => 0, + 'module' => 'entityreference', + 'settings' => array( + 'handler' => 'base', + 'handler_settings' => array( + 'behaviors' => array( + 'views-select-list' => array( + 'status' => 0, + ), + ), + 'sort' => array( + 'type' => 'none', + ), + 'target_bundles' => array( + 'trusted_contacts' => 'trusted_contacts', + ), + ), + 'target_type' => 'og_membership', + ), + 'translatable' => 0, + 'type' => 'entityreference', + ); + + // Exported field_base: 'field_requesting_user' + $field_bases['field_requesting_user'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_requesting_user', + 'foreign keys' => array( + 'users' => array( + 'columns' => array( + 'target_id' => 'uid', + ), + 'table' => 'users', + ), + ), + 'indexes' => array( + 'target_id' => array( + 0 => 'target_id', + ), + ), + 'locked' => 0, + 'module' => 'entityreference', + 'settings' => array( + 'handler' => 'base', + 'handler_settings' => array( + 'behaviors' => array( + 'views-select-list' => array( + 'status' => 0, + ), + ), + 'sort' => array( + 'type' => 'none', + ), + 'target_bundles' => array(), + ), + 'target_type' => 'user', + ), + 'translatable' => 0, + 'type' => 'entityreference', + ); + + // Exported field_base: 'field_response_date' + $field_bases['field_response_date'] = array( + 'active' => 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_response_date', + 'foreign keys' => array(), + 'indexes' => array(), + 'locked' => 0, + 'module' => 'date', + 'settings' => array( + 'cache_count' => 4, + 'cache_enabled' => 0, + 'granularity' => array( + 'day' => 'day', + 'hour' => 'hour', + 'minute' => 'minute', + 'month' => 'month', + 'second' => 'second', + 'year' => 'year', + ), + 'timezone_db' => 'UTC', + 'todate' => '', + 'tz_handling' => 'site', + ), + 'translatable' => 0, + 'type' => 'datestamp', + ); + + // Exported field_base: 'og_user_group_ref' + $field_bases['og_user_group_ref'] = array( + 'active' => 1, + 'cardinality' => -1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'og_user_group_ref', + 'foreign keys' => array( + 'users' => array( + 'columns' => array( + 'target_id' => 'uid', + ), + 'table' => 'users', + ), + ), + 'indexes' => array( + 'target_id' => array( + 0 => 'target_id', + ), + ), + 'locked' => 0, + 'module' => 'entityreference', + 'settings' => array( + 'handler' => 'og', + 'handler_settings' => array( + 'behaviors' => array( + 'og_behavior' => array( + 'status' => TRUE, + ), + ), + 'membership_type' => 'og_membership_type_default', + 'target_bundles' => array( + 'user' => 'user', + ), + ), + 'handler_submit' => 'Change handler', + 'target_type' => 'user', + ), + 'translatable' => 0, + 'type' => 'entityreference', + ); + + // Exported field_base: 'user_trusted_contacts' + $field_bases['user_trusted_contacts'] = array( + 'active' => 1, + 'cardinality' => -1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'user_trusted_contacts', + 'foreign keys' => array( + 'users' => array( + 'columns' => array( + 'target_id' => 'uid', + ), + 'table' => 'users', + ), + ), + 'indexes' => array( + 'target_id' => array( + 0 => 'target_id', + ), + ), + 'locked' => 0, + 'module' => 'entityreference', + 'settings' => array( + 'handler' => 'og', + 'handler_settings' => array( + 'behaviors' => array( + 'og_behavior' => array( + 'status' => TRUE, + ), + ), + 'membership_type' => 'trusted_contacts', + 'sort' => array( + 'type' => 'none', + ), + 'target_bundles' => array(), + ), + 'handler_submit' => 'Change handler', + 'target_type' => 'user', + ), + 'translatable' => 0, + 'type' => 'entityreference', + ); + + return $field_bases; +} diff --git a/modules/commons/commons_trusted_contacts/commons_trusted_contacts.features.field_instance.inc b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.features.field_instance.inc new file mode 100644 index 0000000..f5be65e --- /dev/null +++ b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.features.field_instance.inc @@ -0,0 +1,592 @@ + 'trusted_contact_request_approved', + 'default_value' => NULL, + 'default_value_function' => '', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'entityreference', + 'settings' => array( + 'link' => FALSE, + ), + 'type' => 'entityreference_label', + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_approving_user', + 'label' => 'Approving user', + 'required' => 1, + 'settings' => array( + 'behaviors' => array( + 'prepopulate' => array( + 'status' => 0, + ), + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 1, + ), + ); + + // Exported field_instance: 'message-trusted_contact_request_pending-field_requesting_user' + $field_instances['message-trusted_contact_request_pending-field_requesting_user'] = array( + 'bundle' => 'trusted_contact_request_pending', + 'default_value' => NULL, + 'default_value_function' => '', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'entityreference', + 'settings' => array( + 'link' => FALSE, + ), + 'type' => 'entityreference_label', + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_requesting_user', + 'label' => 'Requesting User', + 'required' => 1, + 'settings' => array( + 'behaviors' => array( + 'prepopulate' => array( + 'status' => 0, + ), + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 1, + ), + ); + + // Exported field_instance: 'og_membership-trusted_contacts-field_confirmation' + $field_instances['og_membership-trusted_contacts-field_confirmation'] = array( + 'bundle' => 'trusted_contacts', + 'default_value' => array( + 0 => array( + 'value' => 0, + ), + ), + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'list', + 'settings' => array(), + 'type' => 'list_default', + 'weight' => 0, + ), + ), + 'entity_type' => 'og_membership', + 'field_name' => 'field_confirmation', + 'label' => 'Confirmation', + 'required' => 0, + 'settings' => array( + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'options', + 'settings' => array( + 'display_label' => 0, + ), + 'type' => 'options_onoff', + 'weight' => 1, + ), + ); + + // Exported field_instance: 'og_membership-trusted_contacts-field_membership_token' + $field_instances['og_membership-trusted_contacts-field_membership_token'] = array( + 'bundle' => 'trusted_contacts', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 4, + ), + ), + 'entity_type' => 'og_membership', + 'field_name' => 'field_membership_token', + 'label' => 'Membership Token', + 'required' => 1, + 'settings' => array( + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'size' => 60, + ), + 'type' => 'text_textfield', + 'weight' => 5, + ), + ); + + // Exported field_instance: 'og_membership-trusted_contacts-field_my_request' + $field_instances['og_membership-trusted_contacts-field_my_request'] = array( + 'bundle' => 'trusted_contacts', + 'default_value' => array( + 0 => array( + 'value' => 0, + ), + ), + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'list', + 'settings' => array(), + 'type' => 'list_default', + 'weight' => 3, + ), + ), + 'entity_type' => 'og_membership', + 'field_name' => 'field_my_request', + 'label' => 'My request', + 'required' => 0, + 'settings' => array( + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'options', + 'settings' => array( + 'display_label' => 0, + ), + 'type' => 'options_onoff', + 'weight' => 4, + ), + ); + + // Exported field_instance: 'og_membership-trusted_contacts-field_original_og_membership' + $field_instances['og_membership-trusted_contacts-field_original_og_membership'] = array( + 'bundle' => 'trusted_contacts', + 'default_value' => NULL, + 'default_value_function' => '', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'entityreference', + 'settings' => array( + 'link' => FALSE, + ), + 'type' => 'entityreference_label', + 'weight' => 2, + ), + ), + 'entity_type' => 'og_membership', + 'field_name' => 'field_original_og_membership', + 'label' => 'Original OG Membership', + 'required' => 0, + 'settings' => array( + 'behaviors' => array( + 'prepopulate' => array( + 'status' => 0, + ), + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 3, + ), + ); + + // Exported field_instance: 'og_membership-trusted_contacts-field_response_date' + $field_instances['og_membership-trusted_contacts-field_response_date'] = array( + 'bundle' => 'trusted_contacts', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'date', + 'settings' => array( + 'format_type' => 'long', + 'fromto' => 'both', + 'multiple_from' => '', + 'multiple_number' => '', + 'multiple_to' => '', + ), + 'type' => 'date_default', + 'weight' => 1, + ), + ), + 'entity_type' => 'og_membership', + 'field_name' => 'field_response_date', + 'label' => 'Response date', + 'required' => 0, + 'settings' => array( + 'default_value' => 'now', + 'default_value2' => 'same', + 'default_value_code' => '', + 'default_value_code2' => '', + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'date', + 'settings' => array( + 'increment' => 15, + 'input_format' => 'm/d/Y - H:i:s', + 'input_format_custom' => '', + 'label_position' => 'above', + 'text_parts' => array(), + 'year_range' => '-3:+3', + ), + 'type' => 'date_popup', + 'weight' => 2, + ), + ); + + // Exported field_instance: 'user-user-user_trusted_contacts' + $field_instances['user-user-user_trusted_contacts'] = array( + 'bundle' => 'user', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 4, + ), + 'search_results' => array( + 'custom settings' => TRUE, + 'label' => 'hidden', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 16, + ), + ), + 'entity_type' => 'user', + 'field_name' => 'user_trusted_contacts', + 'label' => 'User Trusted Contacts', + 'required' => FALSE, + 'settings' => array( + 'behaviors' => array( + 'og_widget' => array( + 'admin' => array( + 'widget_type' => 'entityreference_autocomplete', + ), + 'default' => array( + 'widget_type' => 'entityreference_autocomplete', + ), + 'status' => TRUE, + ), + ), + 'user_register_form' => FALSE, + ), + 'view modes' => array( + 'full' => array( + 'custom settings' => FALSE, + 'label' => 'hidden', + 'type' => 'hidden', + ), + 'teaser' => array( + 'custom settings' => FALSE, + 'label' => 'hidden', + 'type' => 'hidden', + ), + ), + 'widget' => array( + 'module' => 'og', + 'settings' => array(), + 'type' => 'og_complex', + 'weight' => '2', + ), + ); + + // Exported field_instance: 'user-user-group_group' + $field_instances['user-user-group_group'] = array( + 'bundle' => 'user', + 'default_value' => array( + 0 => array( + 'value' => 1, + ), + ), + 'deleted' => '0', + 'description' => 'Determine if this is an OG group.', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'module' => 'commons_trusted_contacts', + 'settings' => array( + 'allowed_values' => array( + 0 => 'Not a group', + 1 => 'Group', + ), + 'allowed_values_function' => '', + ), + 'type' => 'trusted_contact', + 'weight' => '3', + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'display_label' => 1, + 'entity_type' => 'user', + 'field_name' => 'group_group', + 'label' => 'Group', + 'required' => FALSE, + 'settings' => array( + 'user_register_form' => FALSE, + ), + 'view modes' => array( + 'full' => array( + 'custom settings' => FALSE, + 'label' => 'Full', + 'type' => 'og_group_subscribe', + ), + 'teaser' => array( + 'custom settings' => FALSE, + 'label' => 'Teaser', + 'type' => 'og_group_subscribe', + ), + ), + 'widget' => array( + 'module' => 'options', + 'settings' => array( + 'display_label' => 0, + 'og_hide' => TRUE, + ), + 'type' => 'options_onoff', + 'weight' => 0, + ), + ); + + // Exported field_instance: 'user-user-group_access' + $field_instances['user-user-group_access'] = array( + 'bundle' => 'user', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'list', + 'settings' => array(), + 'type' => 'list_default', + 'weight' => 13, + ), + ), + 'display_in_partial_form' => 0, + 'entity_type' => 'user', + 'field_name' => 'group_access', + 'label' => 'Group visibility', + 'required' => 1, + 'settings' => array( + 'user_register_form' => 0, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'options', + 'settings' => array(), + 'type' => 'options_buttons', + 'weight' => 13, + ), + ); + // Provide appropriate settings for our fields when users are + // indexed by Solr. ApacheSolr_User uses the 'search_index' view mode + // to render the user document for indexing. Since this view mode doesn't + // exist in Commons, the 'default' view mode is used. We need to ensure + // that this does not include the names of the user's trusted contacts, so + // that a search for users named "Jane Smith" doesn't include a result for + // each user who calls Jane a contact. + if (module_exists('commons_search_solr_user')) { + $field_instances['user-user-group_group']['view modes']['search_results'] = array( + 'label' => 'hidden', + 'module' => 'commons_trusted_contacts', + 'settings' => array(), + 'type' => 'trusted_contact', + ); + $field_instances['user-user-group_group']['display']['search_results'] = array( + 'label' => 'hidden', + 'module' => 'commons_trusted_contacts', + 'settings' => array( + 'allowed_values' => array( + 0 => 'Not a group', + 1 => 'Group', + ), + 'allowed_values_function' => '', + ), + 'type' => 'trusted_contact', + 'weight' => 17, + ); + $field_instances['user-user-user_trusted_contacts']['display']['search_results'] = array( + 'label' => 'hidden', + 'custom settings' => TRUE, + 'type' => 'hidden', + 'weight' => 16, + ); + } + + $group_content_entity_types = commons_groups_get_group_content_entity_types(); + foreach(array_keys($group_content_entity_types['node']) as $type) { + commons_trusted_contacts_field_definition_group($field_instances, 'node', $type); + } + + // Translatables + // Included for use with string extractors like potx. + t('Approving user'); + t('Confirmation'); + t('Membership Token'); + t('My request'); + t('Original OG Membership'); + t('Requesting User'); + t('Response date'); + t('User Trusted Contacts'); + + return $field_instances; +} + +function commons_trusted_contacts_field_definition_group(&$field_instances, $entity_type, $bundle) { + // Exported field_instance: 'node-post-og_user_group_ref' + $field_instances["$entity_type-$bundle-og_user_group_ref"] = array( + 'bundle' => $bundle, + 'default_value' => NULL, + 'default_value_function' => 'commons_groups_entityreference_default_value', + 'deleted' => '0', + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'inline', + 'module' => 'og_ui', + 'settings' => array(), + 'type' => 'og_list_default', + 'weight' => 11, + ), + 'teaser' => array( + 'label' => 'inline', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => $entity_type, + 'field_name' => 'og_user_group_ref', + 'label' => 'Visible to trusted contacts of', + 'required' => 0, + 'settings' => array( + 'behaviors' => array( + 'og_widget' => array( + 'admin' => array( + 'widget_type' => 'entityreference_autocomplete_tags', + ), + 'default' => array( + 'widget_type' => 'entityreference_autocomplete_tags', + ), + 'status' => TRUE, + ), + 'prepopulate' => array( + 'status' => 0, + ), + ), + 'user_register_form' => FALSE, + ), + 'view modes' => array( + 'full' => array( + 'custom settings' => FALSE, + 'label' => 'Full', + 'type' => 'og_list_default', + ), + 'teaser' => array( + 'custom settings' => FALSE, + 'label' => 'Teaser', + 'type' => 'og_list_default', + ), + ), + 'widget' => array( + 'active' => 0, + 'module' => 'og', + 'settings' => array(), + 'type' => 'og_complex', + 'weight' => 5, + ), + ); + +} diff --git a/modules/commons/commons_trusted_contacts/commons_trusted_contacts.features.inc b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.features.inc new file mode 100644 index 0000000..b8b2f51 --- /dev/null +++ b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.features.inc @@ -0,0 +1,92 @@ + "1"); + } +} + +/** + * Implements hook_views_api(). + */ +function commons_trusted_contacts_views_api() { + return array("api" => "3.0"); +} + +/** + * Implements hook_default_message_type(). + */ +function commons_trusted_contacts_default_message_type() { + $items = array(); + $items['trusted_contact_request_approved'] = entity_import('message_type', '{ + "name" : "trusted_contact_request_approved", + "description" : "Trusted-Contact request approved", + "argument_keys" : [], + "argument" : [], + "category" : "commons_notify", + "data" : { "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" } }, + "language" : "", + "arguments" : null, + "message_text" : { "und" : [ + { + "value" : "\\u003Cp\\u003E[message:field-approving-user:name] approved your Trusted-Contact request.\\u003C\\/p\\u003E\\r\\n", + "format" : "full_html", + "safe_value" : "\\u003Cp\\u003E[message:field-approving-user:name] approved your Trusted-Contact request.\\u003C\\/p\\u003E\\n" + }, + { + "value" : "\\u003Cp\\u003E[message:field-approving-user:name] approved your Trusted-Contact request.\\u003C\\/p\\u003E\\r\\n\\r\\n\\u003Cp\\u003ELearn more at:\\u0026nbsp;\\u003Cspan style=\\u0022font-size: 13.333333015441895px;\\u0022\\u003E[message:field-approving-user:url:absolute]\\u003C\\/span\\u003E\\u003C\\/p\\u003E\\r\\n", + "format" : "full_html", + "safe_value" : "\\u003Cp\\u003E[message:field-approving-user:name] approved your Trusted-Contact request.\\u003C\\/p\\u003E\\n\\n\\u003Cp\\u003ELearn more at:\\u0026nbsp;\\u003Cspan style=\\u0022font-size: 13.333333015441895px;\\u0022\\u003E[message:field-approving-user:url:absolute]\\u003C\\/span\\u003E\\u003C\\/p\\u003E\\n" + } + ] + }, + "rdf_mapping" : [] + }'); + $items['trusted_contact_request_pending'] = entity_import('message_type', '{ + "name" : "trusted_contact_request_pending", + "description" : "Trusted-Contact request pending", + "argument_keys" : [], + "argument" : [], + "category" : "commons_notify", + "data" : { "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" } }, + "language" : "", + "arguments" : null, + "message_text" : { "und" : [ + { + "value" : "\\u003Cp\\u003EYou have a Trusted-Contact request pending from [message:field-requesting-user:name]\\u003C\\/p\\u003E\\r\\n", + "format" : "full_html", + "safe_value" : "\\u003Cp\\u003EYou have a Trusted-Contact request pending from [message:field-requesting-user:name]\\u003C\\/p\\u003E\\n" + }, + { + "value" : "\\u003Cp\\u003EHello,\\u003C\\/p\\u003E\\r\\n\\r\\n\\u003Cp\\u003EYou have a Trusted-Contact request pending from [message:field-requesting-user:name]\\u003C\\/p\\u003E\\r\\n\\r\\n\\u003Cp\\u003EYou may approve or ignore.\\u003C\\/p\\u003E\\r\\n\\r\\n\\u003Cp\\u003E\\u003Ca href=\\u0022@{approve-url}\\u0022\\u003EApprove\\u003C\\/a\\u003E | \\u003Ca href=\\u0022@{ignore-url}\\u0022\\u003EIgnore\\u003C\\/a\\u003E\\u003C\\/p\\u003E\\r\\n", + "format" : "full_html", + "safe_value" : "\\u003Cp\\u003EHello,\\u003C\\/p\\u003E\\n\\n\\u003Cp\\u003EYou have a Trusted-Contact request pending from [message:field-requesting-user:name]\\u003C\\/p\\u003E\\n\\n\\u003Cp\\u003EYou may approve or ignore.\\u003C\\/p\\u003E\\n\\n\\u003Cp\\u003E\\u003Ca href=\\u0022@{approve-url}\\u0022\\u003EApprove\\u003C\\/a\\u003E | \\u003Ca href=\\u0022@{ignore-url}\\u0022\\u003EIgnore\\u003C\\/a\\u003E\\u003C\\/p\\u003E\\n" + } + ] + }, + "rdf_mapping" : [] + }'); + return $items; +} + +/** + * Implements hook_default_og_membership_type(). + */ +function commons_trusted_contacts_default_og_membership_type() { + $items = array(); + $items['trusted_contacts'] = entity_import('og_membership_type', '{ + "name" : "trusted_contacts", + "description" : "Trusted Contacts", + "language" : "", + "rdf_mapping" : [] + }'); + return $items; +} diff --git a/modules/commons/commons_trusted_contacts/commons_trusted_contacts.features.user_permission.inc b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.features.user_permission.inc new file mode 100644 index 0000000..b820a79 --- /dev/null +++ b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.features.user_permission.inc @@ -0,0 +1,44 @@ + 'delete privatemsg', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'privatemsg', + ); + + // Exported permission: read privatemsg. + $permissions['read privatemsg'] = array( + 'name' => 'read privatemsg', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'privatemsg', + ); + + // Exported permission: write privatemsg. + $permissions['write privatemsg'] = array( + 'name' => 'write privatemsg', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'privatemsg', + ); + + return $permissions; +} diff --git a/modules/commons/commons_trusted_contacts/commons_trusted_contacts.info b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.info new file mode 100644 index 0000000..4c658b6 --- /dev/null +++ b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.info @@ -0,0 +1,54 @@ +name = Commons Trusted Contacts +description = Commons Trusted Contacts Functionality +core = 7.x +package = Commons - Building blocks +dependencies[] = commons_groups +dependencies[] = ctools +dependencies[] = date +dependencies[] = entity +dependencies[] = entityreference +dependencies[] = features +dependencies[] = list +dependencies[] = message +dependencies[] = og +dependencies[] = og_ui +dependencies[] = options +dependencies[] = privatemsg +dependencies[] = strongarm +dependencies[] = text +dependencies[] = views +features[ctools][] = strongarm:strongarm:1 +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[field_base][] = field_approving_user +features[field_base][] = field_confirmation +features[field_base][] = field_membership_token +features[field_base][] = field_my_request +features[field_base][] = field_original_og_membership +features[field_base][] = field_requesting_user +features[field_base][] = field_response_date +features[field_base][] = og_user_group_ref +features[field_base][] = user_trusted_contacts +features[field_instance][] = message-trusted_contact_request_approved-field_approving_user +features[field_instance][] = message-trusted_contact_request_pending-field_requesting_user +features[field_instance][] = og_membership-trusted_contacts-field_confirmation +features[field_instance][] = og_membership-trusted_contacts-field_membership_token +features[field_instance][] = og_membership-trusted_contacts-field_my_request +features[field_instance][] = og_membership-trusted_contacts-field_original_og_membership +features[field_instance][] = og_membership-trusted_contacts-field_response_date +features[field_instance][] = user-user-user_trusted_contacts +features[field_instance][] = user-user-group_access +features[message_type][] = trusted_contact_request_approved +features[message_type][] = trusted_contact_request_pending +features[og_membership_type][] = trusted_contacts +features[user_permission][] = delete privatemsg +features[user_permission][] = read privatemsg +features[user_permission][] = write privatemsg +features[variable][] = field_bundle_settings_message__trusted_contact_request_approved +features[variable][] = field_bundle_settings_message__trusted_contact_request_pending +features[variable][] = privatemsg_display_profile_links +features[views_view][] = trusted_contacts +features[views_view][] = trusted_contacts_invitations +features_exclude[field][message-trusted_contact_request_approved-field_approving_user] = message-trusted_contact_request_approved-field_approving_user +features_exclude[field][message-trusted_contact_request_pending-field_requesting_user] = message-trusted_contact_request_pending-field_requesting_user +files[] = views/handlers/commons_groups_handler_send_message.inc diff --git a/modules/commons/commons_trusted_contacts/commons_trusted_contacts.install b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.install new file mode 100644 index 0000000..b00c346 --- /dev/null +++ b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.install @@ -0,0 +1,87 @@ +entityCondition('entity_type', 'user') + // Ignore the anonymous user. + ->propertyCondition('uid', 0, '<>') + ->count() + ->execute(); + + // Count the current number of user groups. + $query = new EntityFieldQuery(); + $group_count = $query + ->entityCondition('entity_type', 'user') + ->fieldCondition(OG_GROUP_FIELD, 'value', 1, '=') + ->count() + ->execute(); + + // Check if there are more users than "group" users. + if ($user_count > $group_count) { + $requirements['commons_trusted_contacts_users_updated']['title'] = t('Trusted contacts'); + $requirements['commons_trusted_contacts_users_updated']['severity'] = REQUIREMENT_ERROR; + $requirements['commons_trusted_contacts_users_updated']['description'] = t('Some users need an update. !link.', array('!link' => l(t('Upgrade users'), 'admin/people/trusted-contacts-upgrade'))); + $requirements['commons_trusted_contacts_users_updated']['value'] = t('Users upgrade needed'); + } + } + + return $requirements; +} + + +/** + * Implements hook_install(). + */ +function commons_trusted_contacts_install() { + // Do not inform the user about new messages on login. + variable_set('privatemsg_display_loginmessage', FALSE); +} + +/** + * Implements hook_uninstall(). + */ +function commons_trusted_contacts_uninstall() { + variable_delete('commons_trusted_contacts_restrict_messaging'); +} + +/** + * Use absolute URLs for pending invitation emails. + */ +function commons_trusted_contacts_update_3100() { + $revert = array( + 'commons_trusted_contacts' => array('message_type'), + ); + features_revert($revert); + return array(); +} + +/** + * Change the background options widget to use autocomplete instead + * See https://drupal.org/node/2151637 for more info + */ +function commons_trusted_contacts_update_3101() { + $revert = array( + 'commons_trusted_contacts' => array('field_instance', 'field_base'), + ); + features_revert($revert); + return array(); +} + +/** + * Set the limit for trusted contacts to unlimited for existing sites. + */ +function commons_trusted_contacts_update_3102() { + + variable_set('commons_trusted_contacts_limit', 0); + return array(); +} \ No newline at end of file diff --git a/modules/commons/commons_trusted_contacts/commons_trusted_contacts.module b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.module new file mode 100644 index 0000000..f860433 --- /dev/null +++ b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.module @@ -0,0 +1,1296 @@ +name == 'commons_trusted_contacts') { + // This field base for group_group is defined in Commons Groups. + $info['features']['field_instance'][] = "user-user-group_group"; + $group_content_entity_types = commons_groups_get_group_content_entity_types(); + foreach (array_keys($group_content_entity_types['node']) as $bundle) { + $info['features']['field_instance'][] = "node-$bundle-og_user_group_ref"; + } + } +} + +/** + * Implements hook_user_presave(). + * + */ +function commons_trusted_contacts_user_presave(&$edit, $account, $category) { + // Ensure that a value is always set for the user's group_access field, + // so that the user remains public while content shared with the user's + // trusted contacts group is private. If the value of $user->group_access + // is not set, og_access.module will throw an exception in + // _og_access_verify_access_field_existence(). + if (empty($edit['group_access'][LANGUAGE_NONE])) { + $edit['group_access'][LANGUAGE_NONE][0]['value'] = 0; + } +} +/** + * Implements hook_pathauto_alias_alter + * Since all content by default goes into 'groups/group-name/node-name', we want + * to do something different with private user posts. Thus we alter the alias + * to be users/user-name/feed/node-title + */ +function commons_trusted_contacts_pathauto_alias_alter(&$alias, &$context) { + // We're only looking for nodes and non-groups to alter, if it isn't a node return. + if ($context['module'] != 'node') { + return; + } + + // Check to see if the node belongs to a group (aka og_user_group_ref) and alter + // the alias appropriately. + if (og_get_group_type('node', $context['data']['node']->type, 'group content') + && !empty($context['data']['node']->og_user_group_ref[LANGUAGE_NONE]) + ) { + $alias = token_replace('users/[node:og-user-group-ref:0:name]/trusted-content/[node:title]', $context['data'], array( + 'sanitize' => FALSE, + 'clear' => TRUE, + 'callback' => 'pathauto_clean_token_values', + 'language' => (object) array('language' => $context['language']), + 'pathauto' => TRUE, + )); + } +} + +/** + * Implements hook_menu(). + */ +function commons_trusted_contacts_menu() { + $items = array(); + + $items['admin/people/trusted-contacts-upgrade'] = array( + 'page callback' => 'commons_trusted_contacts_users_upgrade_batch_init', + 'access arguments' => array('administer site configuration'), + 'type' => MENU_CALLBACK, + ); + + $items['request-trust/%user/%/%'] = array( + 'page callback' => 'commons_trusted_contacts_request_trust', + 'page arguments' => array(1, 3), + 'access callback' => 'commons_trusted_contacts_request_trust_access', + 'access arguments' => array(1,2), + 'type' => MENU_CALLBACK, + ); + + $items['un-trust/%user/%/%'] = array( + 'page callback' => 'commons_trusted_contacts_un_trust', + 'page arguments' => array(1, 3), + 'access callback' => 'commons_trusted_contacts_un_trust_access', + 'access arguments' => array(1, 2), + 'type' => MENU_CALLBACK, + ); + + $items['approve-trust/%entity_object/%'] = array( + 'load arguments' => array('og_membership'), + 'page callback' => 'commons_trusted_contacts_approve_trust', + 'page arguments' => array(1), + 'access callback' => 'commons_trusted_contacts_approve_trust_access', + 'access arguments' => array(1, 2), + 'type' => MENU_CALLBACK, + ); + + $items['ignore-trust/%entity_object/%'] = array( + 'load arguments' => array('og_membership'), + 'page callback' => 'commons_trusted_contacts_ignore_trust', + 'page arguments' => array(1), + 'access callback' => 'commons_trusted_contacts_ignore_trust_access', + 'access arguments' => array(1, 2), + 'type' => MENU_CALLBACK, + ); + + $items['user/%user/contacts/messages/popup/%user'] = array( + 'page callback' => 'drupal_get_form', + 'page arguments' => array('commons_trusted_contacts_messages_popup', 5), + 'access callback' => 'commons_trusted_contacts_privatemsg_write_access', + 'access arguments' => array(5), + 'type' => MENU_CALLBACK, + ); + + $items['user/%user/contacts'] = array( + 'title' => t('Private Messages & Invitations'), + 'page callback' => 'commons_trusted_contacts_tab', + 'access callback' => 'commons_trusted_contacts_tab_access', + 'access arguments' => array(1), + 'type' => MENU_LOCAL_TASK, + ); + + return $items; +} + +/** + * Access callback for trusted contacts related pages; + */ +function commons_trusted_contacts_tab_access($account) { + global $user; + + if (user_access('administer group')) { + // Admin user. + return TRUE; + } + + if ($user->uid == $account->uid) { + // User's own pages. + return TRUE; + } + + return FALSE; +} + +/** + * Implements hook_menu_alter(). + */ +function commons_trusted_contacts_menu_alter(&$items) { + // Remove the groups UI for user entities. + $items['user/%/group']['access callback'] = FALSE; + + // Make sure only Trusted-Contacts send messages to each other. + // By default, PrivateMsg module only checks user permissions. + $items['messages/new']['access callback'] = 'commons_trusted_contacts_privatemsg_write_access'; + $items['messages/new']['access arguments'] = array(2); + + // Remove original private messages pages. + unset($items['messages']); + unset($items['messages/list']); +} + +/** + * Implements hook_admin_paths(). + */ +function commons_trusted_contacts_admin_paths() { + $paths = array( + 'user/*/contacts/messages/popup/*' => TRUE, + ); + + return $paths; +} + +/** + * Implements hook_module_implements_alter(). + */ +function commons_trusted_contacts_module_implements_alter(&$implementations, $hook) { + // We need to alter form elements added by the Views Bulk Operations module. + // VBO is is alphabetically subsequent to commons_trusted_contacts + // and has the same weight, so we need this alter to ensure that + // our hook_form_alter() implementation runs after VBO, so that the + // elements VBO adds are already present when we alter the form. + if ($hook == 'form_alter') { + $group = $implementations['commons_trusted_contacts']; + unset($implementations['commons_trusted_contacts']); + $implementations['commons_trusted_contacts'] = $group; + } + if ($hook == 'node_presave') { + $group = $implementations['commons_trusted_contacts']; + unset($implementations['commons_trusted_contacts']); + $implementations['commons_trusted_contacts'] = $group; + } +} + +/** + * Implements hook_form_user_admin_settings_alter(). + */ +function commons_trusted_contacts_form_user_admin_settings_alter(&$form, &$form_state) { + $form['commons_trusted_contacts'] = array( + '#type' => 'fieldset', + '#title' => t('Commons Trusted Contacts'), + '#weight' => 0, + '#description' => t("Important! Lowering this number will restrict users over the new limit from adding or approving any trusted contacts until they go below it."), + ); + $form['commons_trusted_contacts']['commons_trusted_contacts_limit'] = array( + '#type' => 'textfield', + '#title' => t('Maximum number of trusted contacts per user'), + '#default_value' => variable_get('commons_trusted_contacts_limit', 1000), + '#description' => t('This setting defaults to 1000 maximum contacts for performance reasons, and should be sufficient for most sites. Set to 0 for no limit.'), + ); + $form['commons_trusted_contacts']['commons_trusted_contacts_global_messaging'] = array( + '#type' => 'checkbox', + '#title' => t('Allow users to message each other regardless if they are a trusted contact'), + '#default_value' => variable_get('commons_trusted_contacts_global_messaging', FALSE), + ); +} + +/** + * Implements hook_form_alter(). + */ +function commons_trusted_contacts_form_alter(&$form, &$form_state, $form_id) { + // Don't allow users to change the recipient of a private message. + // In combination with commons_trusted_contacts_privatemsg_write_access(), + // we prevent users from sending private messages to users who are not their + // trusted contacts. + if ($form_id == 'privatemsg_new') { + $form['recipient']['#access'] = FALSE; + } + // Hide the Approve/Ignore buttons when there are no pending trusted + // contact requests. + if ($form_id == 'views_form_trusted_contacts_invitations_default') { + if (empty($form_state['build_info']['args'][0]->result)) { + $form['select']['#access'] = FALSE; + } + } + // Hide the Break Contact button when a user has no trusted contacts. + if ($form_id == 'views_form_trusted_contacts_default') { + if (empty($form_state['build_info']['args'][0]->result)) { + $form['select']['#access'] = FALSE; + } + } + if ($form_id == 'privatemsg_list') { + // Load privatemsg.pages.inc and ensure it is automatically reloaded if + // this form is rebuilt via AJAX or other means. + form_load_include($form_state, 'inc', 'privatemsg', 'privatemsg.pages'); + } +} + +/** + * Page callback; Trusted contacts related pages. + */ +function commons_trusted_contacts_tab() { + global $user; + $account = $user; + $tabs = array(); + + $view = views_get_view('trusted_contacts'); + $view->get_total_rows = TRUE; + $view->execute(); + $tabs['contacts'] = array( + 'title' => t('Trusted Contacts') . ' ' . $view->total_rows . '', + 'contents' => views_embed_view('trusted_contacts'), + ); + + module_load_include('inc', 'privatemsg', 'privatemsg.pages'); + + $tabs['messages'] = array( + 'title' => t('Messages') . ' ' . privatemsg_unread_count($account) . '', + 'contents' => privatemsg_list_page(), + ); + + + $tabs['invitations'] = array( + 'title' => t('Invitations') . ' ' . count(commons_trusted_contacts_get_pending_invitations($account->uid)) . '', + 'contents' => views_embed_view('trusted_contacts_invitations'), + ); + + $settings = array( + 'style' => 'Commons Tabs', + 'ajax' => FALSE, + 'html' => TRUE, + 'default_tab' => 'invitations', + ); + + return quicktabs_build_quicktabs('commons_trusted_contacts', $settings, $tabs); +} + +/** + * Implement hook_field_formatter_info(). + */ +function commons_trusted_contacts_field_formatter_info() { + return array( + 'trusted_contact' => array( + 'label' => t('Trusted Contact'), + 'field types' => array('list_boolean'), + 'settings' => array( + 'field_name' => FALSE, + ), + ), + 'approve_ignore' => array( + 'label' => t('Approve/Ignore request'), + 'field types' => array('text'), + ), + ); +} + +/** + * Implements hook_field_formatter_view(). + * + * This is a copy of og_field_formatter_view() which was adapted for the + * "Trusted Contacts" functionality, so most changes are around the phrasing, + * and allowing users to send private messages. + * + * @see og_field_formatter_view() + */ +function commons_trusted_contacts_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { + global $user; + + $element = array(); + $element[0] = array( + '#type' => 'container', + '#attributes' => array(), + ); + $links = array(); + $settings = $display['settings']; + + switch ($display['type']) { + case 'trusted_contact': + $account = clone $user; + if (!og_is_group($entity_type, $entity)) { + return; + } + + // Hide the trust link from anonymous and users without subscribe access. + list($id, , $bundle) = entity_extract_ids($entity_type, $entity); + $user_is_active_member = og_is_member($entity_type, $id, 'user', $account, array(OG_STATE_ACTIVE)); + if (!$account->uid || !og_user_access('user', $entity->uid, 'subscribe') && !$user_is_active_member) { + return; + } + + if (!empty($entity->uid) && ($entity->uid == $account->uid)) { + // User is the group manager. + return; + } + + + if (variable_get('commons_trusted_contacts_global_messaging', FALSE) || $user_is_active_member) { + $link = array('#type' => 'link'); + $link['#title'] = t('Message'); + $link['#href'] = 'user/' . $user->uid . '/contacts/messages/popup/' . $id; + // without an #options array template.php doesn't assign classes + $link['#options'] = array(); + $element[0][] = $link; + } + if (og_is_member($entity_type, $id, 'user', $account, array(OG_STATE_BLOCKED))) { + // If user is blocked, they should not be able to apply for + // membership. + return; + } + elseif (og_is_member($entity_type, $id, 'user', $account, array(OG_STATE_PENDING))) { + // If user is pending, they should not be able to apply for + // membership. + $link = array( + '#theme' => 'html_tag__request_pending', + '#tag' => 'span', + '#value' => t('Awaiting confirmation'), + '#attributes' => array( + 'class' => array('trusted-request-pending'), + ), + ); + $element[0][] = $link; + } + elseif (!og_is_member($entity_type, $id, 'user', $account, array(OG_STATE_ACTIVE))) { + // Check if user can subscribe to the field. + if (empty($settings['field_name']) && $audience_field_name = og_get_best_group_audience_field('user', $account, $entity_type, $bundle)) { + $settings['field_name'] = $audience_field_name; + } + if (!$settings['field_name']) { + return; + } + + $field_info = field_info_field($settings['field_name']); + + // Check if entity is referencable. + if ($field_info['settings']['target_type'] != $entity_type) { + // Group type doesn't match. + return; + } + if (!empty($field_info['settings']['handler_settings']['target_bundles']) && !in_array($bundle, $field_info['settings']['handler_settings']['target_bundles'])) { + // Bundles don't match. + return; + } + + if (!og_check_field_cardinality('user', $account, $settings['field_name'])) { + $element[0] = array('#markup' => format_plural($field_info['cardinality'], 'You are already registered to another group', 'You are already registered to @count groups')); + return $element; + } + + $token = drupal_get_token('request' . ':' . $id . ':' . $account->uid); + $url = "request-trust/$id/$token/nojs"; + + $link = array('#type' => 'link'); + $link['#title'] = t('Add as trusted contact'); + if ($account->uid) { + $link['#href'] = $url; + $link['#options'] = array( + 'attributes' => array( + 'class' => array('use-ajax'), + 'id' => 'user-' . $entity->uid + ) + ); + $element[0][] = $link; + + // Ensure that the drupal.ajax and jquery.form libraries are always + // loaded for AJAX toggle links. + $element['#attached'] = array( + 'library' => array( + array('system', 'drupal.ajax'), + array('system', 'jquery.form'), + ), + ); + } + else { + $link = array('#type' => 'link'); + $link['#href'] = 'user/login'; + $link['#options'] = array('query' => array('destination' => $url)); + $element[0][] = $link; + } + } + + // If we provided any links in the container + if (count(element_children($element[0]))) { + return $element; + } + // User didn't have permissions. + break; + + case 'approve_ignore': + + $approve = l(t('Approve'), 'approve-trust/' . $entity->id . '/' . $items[0]['value']); + $ignore = l(t('Ignore'), 'ignore-trust/' . $entity->id . '/' . $items[0]['value']); + + $element[0] = array( + '#markup' => $approve . ' ' . $ignore, + ); + return $element; + } +} + +/** + * Implements hook_og_membership_insert(). + * + * Trusted Contacts are 2 users that are members on each other's groups. + * Whenever a user joins another user's group as a Trusted Contact, the second + * user must also become a member on the first user's group. + */ +function commons_trusted_contacts_og_membership_insert(OgMembership $og_membership) { + if ($og_membership->type != 'trusted_contacts' || $og_membership->group_type != 'user') { + // Not a Trusted-Contact membership type. + return; + } + + if (!empty($og_membership->_skip_membership_insert)) { + // Prevent recursion. + return; + } + + if ($og_membership->gid == $og_membership->etid) { + // A user was created. + return; + } + + // We're using a custom token because Drupal provides a token that relies on + // logged-in user, and here we want the token to be used by the responding + // user when approving/ignoring the logged-in user's request. + $token = md5(rand(100000000, 9999999999)); + + $wrapper = entity_metadata_wrapper('og_membership', $og_membership); + $wrapper->field_my_request->set(1); + $wrapper->field_membership_token->set($token); + + $values = array( + 'entity' => $og_membership->gid, + 'field_name' => 'user_trusted_contacts', + 'state' => $og_membership->state, + ); + + // Get a non-saved OG Membership object. + $og_membership2 = og_group('user', $og_membership->etid, $values, FALSE); + + $wrapper2 = entity_metadata_wrapper('og_membership', $og_membership2); + $wrapper2->field_original_og_membership->set($og_membership); + $wrapper2->field_my_request->set(0); + $wrapper2->field_membership_token->set($token); + + // Prevent recursion. + $og_membership2->_skip_membership_insert = TRUE; + $wrapper2->save(); + + + // Make sure OG membership is updated, and not re-inserted. + unset($og_membership->is_new); + $og_membership->_skip_membership_update = TRUE; + $wrapper->save(); +} + +/** + * Implements hook_og_membership_update(). + * + * Trusted Contacts are 2 users that are members on each other's groups. + * Whenever one of the OG memberships is updated, the other membership must be + * updated accordingly. + */ +function commons_trusted_contacts_og_membership_update(OgMembership $og_membership) { + if ($og_membership->type != 'trusted_contacts' || $og_membership->group_type != 'user') { + // Not a Trusted-Contact membership type. + return; + } + + if (!empty($og_membership->_skip_membership_update)) { + // Prevent recursion. + return; + } + + $wrapper = entity_metadata_wrapper('og_membership', $og_membership); + + $wrapper_original = entity_metadata_wrapper('og_membership', $og_membership->original); + + // Set the second OG Membership according to the first one. + // As we are referencing the requesting user to the requested user, we want to + // keep everything synced. + $query = new EntityFieldQuery(); + $return = $query + ->entityCondition('entity_type', 'og_membership') + ->propertyCondition('group_type', 'user') + ->propertyCondition('entity_type', 'user') + ->propertyCondition('etid', $og_membership->gid) + ->propertyCondition('gid', $og_membership->etid) + ->execute(); + + // Membership not found, return but throw an error to watchdog. + if (!isset($return['og_membership'])) { + watchdog('commons_trusted_contacts', "Warning: expected trusted contact link not found between " . $og_membership->gid . " and " . $og_membership->etid, WATCHDOG_WARNING); + return; + } + + $membership_id = key($return['og_membership']); + + $wrapper2 = entity_metadata_wrapper('og_membership', $membership_id); + $og_membership2 = $wrapper2->value(); + + if ($wrapper->state->value() != $wrapper_original->state->value()) { + // State was changed. + $wrapper2->state->set($wrapper->state->value()); + + if ($wrapper_original->state->value() == OG_STATE_PENDING) { + // Responding to a Trusted-Contact request. + $confirmation = $wrapper->state->value() == OG_STATE_ACTIVE; + $wrapper->field_confirmation->set($confirmation); + $wrapper->field_response_date->set(time()); + + // Prevent recursion. + $og_membership->_skip_membership_update = TRUE; + + // Clone the Og membership, as in EntityAPIController::save() the + // entity->original property is removed. However since are re-saving the + // same updated entity, we want to make sure it doesn't happen on the + // original one, thus causing notices for example in + // og_og_membership_update() + $og_membership_clone = clone $og_membership; + $og_membership_clone->save(); + + // Subtract 1 from unread invitations count. + $account = user_load($og_membership->gid); + } + } + + if ($wrapper->field_confirmation->value() != $wrapper_original->field_confirmation->value()) { + // Confirmation was changed. + $wrapper2->field_confirmation->set($wrapper->field_confirmation->value()); + } + + if ($wrapper->field_response_date->value() != $wrapper_original->field_response_date->value()) { + // Response Date was changed. + $wrapper2->field_response_date->set($wrapper->field_response_date->value()); + } + + // Prevent recursion. + $og_membership2->_skip_membership_update = TRUE; + $wrapper2->save(); +} + +/** + * Implements hook_og_membership_delete(). + * + * Trusted Contacts are 2 users that are members on each other's groups. + * Whenever one of the OG memberships is deleted, the other membership must be + * deleted too. + */ +function commons_trusted_contacts_og_membership_delete(OgMembership $og_membership) { + if ($og_membership->type != 'trusted_contacts' || $og_membership->group_type != 'user') { + // Not a Trusted-Contact membership type. + return; + } + + if (!og_is_member('user', $og_membership->etid, 'user', $og_membership->gid)) { + // Prevent recursion. + return; + } + + // Delete the "opposite" OG membership too. + og_ungroup('user', $og_membership->etid, 'user', $og_membership->gid); +} + +/** + * Menu callback; Creates a Trusted-Contact Invitation. + * + * Adding two users to each-other's groups, and setting the memberships' states + * to 'Pending'. + * + * @param $account + * The group in which the logged-in user wants to join. + */ +function commons_trusted_contacts_request_trust($account, $ajax) { + global $user; + $requestor = $user; + + if ($account->uid == $user->uid) { + // Users cannot join their own group. + return; + } + if (!commons_trusted_contacts_check_limit($requestor, $account, $ajax)) { + return; + } + + // This actually adds 2 OG memberships - one for each user. + $og_membership = og_group('user', $account, array( + 'field_name' => 'user_trusted_contacts', + 'state' => OG_STATE_PENDING, + )); + + // Notify. + + $wrapper = entity_metadata_wrapper('og_membership', $og_membership); + $token = $wrapper->field_membership_token->value(); + $options = array('absolute' => TRUE); + $arguments = array( + '@{approve-url}' => url('approve-trust/' . $og_membership->id . '/' . $token, $options), + '@{ignore-url}' => url('ignore-trust/' . $og_membership->id . '/' . $token, $options), + ); + $message = message_create('trusted_contact_request_pending', array( + 'uid' => $account->uid, + 'arguments' => $arguments, + )); + + $wrapper = entity_metadata_wrapper('message', $message); + $wrapper->field_requesting_user->set($requestor); + $wrapper->save(); + + message_notify_send_message($message); + + // Ajax + + if ($ajax == 'ajax') { + $commands = array(); + $element = array( + 'element' => array( + '#value' => t('Awaiting confirmation'), + '#tag' => 'span', + '#attributes' => array( + 'class' => array('trusted-request-pending'), + ), + ), + ); + // We trip due to https://api.drupal.org/comment/32698#comment-32698 + $commands[] = ajax_command_replace('#user-' . $account->uid, trim(theme('html_tag__request_pending', $element))); + $page = array('#type' => 'ajax', '#commands' => $commands); + ajax_deliver($page); + } + else { + drupal_goto('user/' . $og_membership->gid); + } +} + +/** + * Menu callback; "Breaks" a Trusted-Contact relation between two users by + * ungrouping each of them from the other's group. + * + * @param $account + * The account which the logged-in user wants to break contact with. + */ +function commons_trusted_contacts_un_trust($account, $ajax) { + global $user; + + // This actually deletes 2 OG memberships, one for each user, + // in commons_trusted_contacts_og_membership_delete(). + og_ungroup('user', $account->uid); + + // Ajax + + if ($ajax == 'ajax') { + $token = drupal_get_token('request' . ':' . $account->uid . ':' . $user->uid); + $new = l(t('Trusted Contact'), 'request-trust/' . $account->uid . '/' . $token . '/nojs', array('attributes' => array('class' => array('use-ajax')))); + + $commands = array(); + $commands[] = ajax_command_replace(".field-name-group-group a", $new); + $page = array('#type' => 'ajax', '#commands' => $commands); + ajax_deliver($page); + } + else { + drupal_goto('user/' . $account->uid); + } +} + +/** + * Menu callback; Approving a Trusted-Contact Invitation by setting each user's + * membership state to 'Active'. + * + * @param $og_membership + * The membership in which the logged-in user is the group and the requesting + * user is the member. + */ +function commons_trusted_contacts_approve_trust(OgMembership $og_membership) { + global $user; + + if ($og_membership->gid != $user->uid) { + // Users can only approve their requests. + return; + } + + // Get approving user. + $account = user_load($og_membership->gid); + + if (!commons_trusted_contacts_check_limit($account, $og_membership->etid)) { + return; + } + + // This actually changes both OG memberships - one for each user. + $wrapper = entity_metadata_wrapper('og_membership', $og_membership); + $wrapper->state->set(OG_STATE_ACTIVE); + $wrapper->save(); + + // Notify. + + $message = message_create('trusted_contact_request_approved', array('uid' => $og_membership->etid)); + + $wrapper = entity_metadata_wrapper('message', $message); + $wrapper->field_approving_user->set($account); + $wrapper->save(); + + message_notify_send_message($message); + + // Redirect to Invitations screen. + drupal_goto('user/' . $user->uid . '/contacts', array('query' => array('qt-commons_trusted_contacts' => 'invitations'))); +} + +/** + * Menu callback; Ignoring a Trusted-Contact Invitation. + * + * Setting each user's membership state to 'Blocked'. + * + * @param $og_membership + * The membership in which the logged-in user is the group and the requesting + * user is the member. + */ +function commons_trusted_contacts_ignore_trust(OgMembership $og_membership) { + global $user; + + if ($og_membership->gid != $user->uid) { + // Users can only ignore their requests. + return; + } + + // This actually changes both OG memberships - one for each user. + $wrapper = entity_metadata_wrapper('og_membership', $og_membership); + $wrapper->state->set(OG_STATE_BLOCKED); + $wrapper->save(); + + // Redirect to Invitations screen. + drupal_goto('user/' . $user->uid . '/contacts', array('query' => array('qt-commons_trusted_contacts' => 'invitations'))); +} + +/** + * Internal check to see if a user or its contact has gone over the limit. + * + * @param $requestor The current user checking the limit. + * @param $requestee The user of the other side of the relationship. + * @param bool $ajax To use ajax or not. + * @return bool - False for over the limit, True for under the limit. + */ +function commons_trusted_contacts_check_limit($requestor, $requestee, $ajax = FALSE) { + // Validate that neither the requesting user nor the target user has exceeded + // her trusted contacts limit. + if ($contacts_limit = variable_get('commons_trusted_contacts_limit', 1000)) { + $requestor_groups = og_get_entity_groups('user', $requestor, array(OG_STATE_ACTIVE), 'user_trusted_contacts'); + $requestee_groups = og_get_entity_groups('user', $requestee, array(OG_STATE_ACTIVE), 'user_trusted_contacts'); + + // This should always be set, because the user is a member of their own group. + // But we know funky things can happen, so lets add a check just in case. + $requestor_memberships = $requestor_groups['user'] ? count($requestor_groups['user']) : 0; + $requestee_memberships = $requestee_groups['user'] ? count($requestee_groups['user']) : 0; + + $message = ''; + $exceeds_limit = FALSE; + + // We use greater than because the membership count includes the user. + if ($requestor_memberships > $contacts_limit) { + $exceeds_limit = TRUE; + + drupal_set_message( + t('You have exceeded the limit of @limit trusted contacts. Before you can add more contacts, you must remove some of your existing contacts.', + array( + '@limit' => $contacts_limit, + '@remove-contacts-link' => url('user/' . $requestor->uid . '/contacts', + array( + 'query' => array( + 'qt-commons_trusted_contacts' => 'contacts', + ), + 'fragment' => 'qt-commons_trusted_contacts', + ) + ), + ) + ) + ); + } + if ($requestee_memberships > $contacts_limit) { + $exceeds_limit = TRUE; + + drupal_set_message(t('@requestee has exceeded the limit of @limit trusted contacts and cannot accept any more contacts at this time.', + array( + '@requestee' => $requestee->name, + '@limit' => $contacts_limit, + )) + ); + } + if ($exceeds_limit) { + if ($ajax == 'ajax') { + $commands = array(); + $commands[] = ajax_command_append('#messages', theme('status_messages')); + $page = array('#type' => 'ajax', '#commands' => $commands); + ajax_deliver($page); + } + else { + drupal_goto(); + } + return FALSE; + } + } + return TRUE; +} + +/** + * Access callback for creating a Trusted-Contact request; Makes sure that the + * token is correct. + * + * @param $account + * The group in which the logged-in user wants to join. + */ +function commons_trusted_contacts_request_trust_access($account, $token) { + global $user; + + return drupal_valid_token($token, 'request' . ':' . $account->uid . ':' . $user->uid) && user_is_logged_in(); +} + +/** + * Access callback for breaking a Trusted-Contact relation; Makes sure that the + * token is correct. + * + * @param $account + * The account which the logged-in user wants to break contact with. + */ +function commons_trusted_contacts_un_trust_access($account, $token) { + global $user; + + return drupal_valid_token($token, 'untrust' . ':' . $account->uid . ':' . $user->uid) && user_is_logged_in(); +} + +/** + * Access callback for approving an invitation; Makes sure that the token is + * correct. + * + * @param $og_membership + * The membership in which the logged-in user is the group and the requesting + * user is the member. + */ +function commons_trusted_contacts_approve_trust_access(OgMembership $og_membership, $token) { + $wrapper = entity_metadata_wrapper('og_membership', $og_membership); + + return ($wrapper->field_membership_token->value() == $token) && user_is_logged_in(); +} + +/** + * Access callback for ignoring an invitation; Makes sure that the token is + * correct. + * + * @param $og_membership + * The membership in which the logged-in user is the group and the requesting + * user is the member. + */ +function commons_trusted_contacts_ignore_trust_access(OgMembership $og_membership, $token) { + $wrapper = entity_metadata_wrapper('og_membership', $og_membership); + + return $wrapper->field_membership_token->value() == $token && user_is_logged_in(); +} + +/** + * Returns whether or not two users are trusted contacts. + * + * @param $uid + * User ID. + * + * @param $account + * Optional; Other user's object. If not provided, current user will be used. + */ +function commons_group_is_trusted_contact($uid, $account = NULL) { + if (empty($account)) { + global $user; + $account = $user; + } + + return og_is_member('user', $uid, 'user', $account, array(OG_STATE_ACTIVE)); +} + +/** + * Access callback for writing a private message to another user; + * Checks permissions and makes sure that the given user and the logged-in user + * are Trusted-Contacts. + * + * @param $uid + * Addressee's user object or User ID. + */ +function commons_trusted_contacts_privatemsg_write_access($account) { + global $user; + + if (user_access('administer group')) { + // Always allow admin to send private messages. + return TRUE; + } + + $uid = isset($account->uid) ? $account->uid : $account; + + return (privatemsg_user_access('write privatemsg') && (commons_group_is_trusted_contact($uid) || variable_get('commons_trusted_contacts_global_messaging', FALSE))); +} + +/** + * Implements hook_form_FORM_ID_alter(). + */ +function commons_trusted_contacts_form_privatemsg_new_alter(&$form, &$form_state) { + global $user; + + // According to design, 'body' field should be 'plain_text' by default. + $form['body']['#format'] = 'plain_text'; + + // Alter markup of 'Cancel' button so it will link to our URL instead of the + // default one. + $form['actions']['cancel'] = array( + '#type' => 'link', + '#title' => t('Cancel'), + '#href' => 'user/' . $user->uid . '/contacts', + '#options' => array( + 'query' => array('qt-commons_trusted_contacts' => 'messages'), + ), + ); +} + +/** + * Implements hook_form_FORM_ID_alter(). + * + * Alter destination of 'Delete' button so it will link to our URL instead of + * the default one. + */ +function commons_trusted_contacts_form_privatemsg_delete_alter(&$form, &$form_state) { + global $user; + + if ($form['delete_destination']['#value'] == 'messages') { + // TODO: Redirect to the messages quick-tab. + $form['delete_destination']['#value'] = 'user/' . $user->uid . '/contacts'; + } +} + + +/** + * Implements hook_form_FORM_ID_alter(). + * + * Adds the audience type widget to the partial node form. + */ +function commons_trusted_contacts_form_commons_bw_partial_node_form_alter(&$form, &$form_state) { + if (!empty($form_state['group_id'])) { + return; + } + + if (!module_exists('og_access')) { + return; + } + commons_trusted_contacts_form_add_privacy_toggle($form, $form_state); + $form['#validate'][] = 'commons_trusted_contacts_partial_node_form_validate'; +} + +/** + * Adds privacy toggle to a node edit/add form. + */ +function commons_trusted_contacts_form_add_privacy_toggle(&$form, &$form_state) { + $is_group_content = FALSE; + if (!empty($form[OG_AUDIENCE_FIELD][LANGUAGE_NONE][0]['default']['#default_value']) || !empty($form[OG_AUDIENCE_FIELD][LANGUAGE_NONE][0]['admin']['#default_value'])) { + $is_group_content = TRUE; + } + $form['group_audience_type'] = array( + '#type' => 'radios', + '#title' => t('Post to'), + '#title_display' => 'invisible', + '#default_value' => $is_group_content ? 'custom' : 'private', + '#options' => array( + 'custom' => t('Post to specific groups'), + 'private' => t('Post privately to all trusted contacts'), + ), + '#weight' => 70, + '#attributes' => array( + 'class' => array('hideable-field'), + ), + '#access' => empty($form_state['hide_audience_toggle']), + // Normally Form API states (https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_process_states/7) + // Would be used here, but it does not support loading multiple similar + // forms on the same page. This is why a simple javascript files is needed + // to perform the task of hiding the groups fields. + '#attached' => array( + 'js' => array( + drupal_get_path('module', 'commons_trusted_contacts') . '/scripts/commons-trusted-contacts.js', + ), + ), + ); +} + +/** + * Implements hook_form_FORM_ID_alter() + * Adds Privacy selection to full form for node/add or node/edit. + */ +function commons_trusted_contacts_form_node_form_alter(&$form, &$form_state) { + // Act only on Commons Groups group content entities. + $group_content_entity_types = commons_groups_get_group_content_entity_types(); + if (!isset($group_content_entity_types['node'][$form['#node']->type])) { + return; + } + if (empty($form['og_user_group_ref']) || !module_exists('og_access') || og_is_group_type('node', $form_state['node']->type)) { + return; + } + + // Add the privacy toggle. + commons_trusted_contacts_form_add_privacy_toggle($form, $form_state); + + // Change the weight for groups to show under the group toggle. + $form['og_group_ref']['#weight'] = $form['group_audience_type']['#weight'] + 1; + + // For content types without user group reference fields, show a public option. + // Otherwise, the toggle would look odd for 'specific groups' and then not have + // any groups showing below it. + if (empty($form[OG_AUDIENCE_FIELD])) { + $form['group_audience_type']['#options']['custom'] = t('Post site-wide'); + } +} + +/** + * Validation handler; Make sure that a group is selected in case the + * group_audience_type is set to "Specific groups". + */ +function commons_trusted_contacts_partial_node_form_validate($form, $form_state) { + if ($form_state['values']['group_audience_type'] == 'custom' && empty($form_state['values'][OG_AUDIENCE_FIELD][LANGUAGE_NONE][0])) { + form_set_error(OG_AUDIENCE_FIELD, t('Please enter one more groups where this content will be posted.')); + return FALSE; + } +} + +/** + * Implements hook_node_presave(). + * + * Override the group fields. + */ +function commons_trusted_contacts_node_presave($node) { + if (!module_exists('og_access') || og_is_group('node', $node)) { + return; + } + // Act only on Commons Groups group content entities. + $group_content_entity_types = commons_groups_get_group_content_entity_types(); + if (!isset($group_content_entity_types['node'][$node->type])) { + return; + } + // We're posting from the short form on the site-wide homepage. + if (isset($node->form_state['values']['group_audience_type'])) { + $group_audience_type = $node->form_state['values']['group_audience_type']; + } + // We're posting from the full node creation form. + if (isset($node->group_audience_type)) { + $group_audience_type = $node->group_audience_type; + } + + $wrapper = entity_metadata_wrapper('node', $node); + // The content is submitted to the author's trusted contacts group, rather + // than to specific groups. + if (isset($group_audience_type) && $group_audience_type == 'private') { + $wrapper->og_user_group_ref->set(array($node->uid)); + $wrapper->group_content_access->set(OG_CONTENT_ACCESS_PRIVATE); + + // Remove any existing selected groups. + $wrapper->{OG_AUDIENCE_FIELD}->set(array()); + } + // The content is submitted to specific groups. + else if (!empty($node->{OG_AUDIENCE_FIELD}[LANGUAGE_NONE])) { + // Extract group IDs from selection. + $group_ids = array(); + foreach ($node->{OG_AUDIENCE_FIELD}[LANGUAGE_NONE] as $group) { + $group_ids[] = $group['target_id']; + } + $wrapper->{OG_AUDIENCE_FIELD}->set($group_ids); + $wrapper->og_user_group_ref->set(array()); + } +} + +/** + * Implements hook_action_info(). + * + * @see views_bulk_operations_action_info() + */ +function commons_trusted_contacts_action_info() { + $actions = array(); + $files = commons_trusted_contacts_operations_load_action_includes(); + foreach ($files as $filename) { + $action_info_fn = 'commons_trusted_contacts_' . str_replace('.', '_', basename($filename, '.inc')) . '_info'; + $action_info = call_user_func($action_info_fn); + if (is_array($action_info)) { + $actions += $action_info; + } + } + + return $actions; +} + +/** + * Loads the VBO actions placed in their own include files. + * + * @return + * An array of containing filenames of the included actions. + * + * @see views_bulk_operations_load_action_includes() + */ +function commons_trusted_contacts_operations_load_action_includes() { + static $loaded = FALSE; + + $path = drupal_get_path('module', 'commons_trusted_contacts') . '/includes/actions/'; + $files = array( + 'set_state_active.action.inc', + 'set_state_blocked.action.inc', + 'mark_as_read.action.inc', + ); + + if (!$loaded) { + foreach ($files as $file) { + include_once $path . $file; + } + $loaded = TRUE; + } + + return $files; +} + +/** + * Menu callback; Write Private Message popup form. + * + * @param $account + * The addressee's account. + */ +function commons_trusted_contacts_messages_popup($form, &$form_state, $account) { + global $user; + + // Include original functions. + module_load_include('inc', 'privatemsg', 'privatemsg.pages'); + + $form = privatemsg_new($form, $form_state, $account->uid, 'New private message from ' . $user->name); + + $form['actions'] = array('#type' => 'actions'); + + $form['actions']['submit'] = array( + '#type' => 'submit', + '#value' => t('Send'), + ); + + $wrapper = entity_metadata_wrapper('user', $account); + $picture_path = empty($account->picture) ? variable_get('user_picture_default') : $wrapper->value()->picture->uri; + + $form['user_picture'] = array( + '#theme' => 'image_style', + '#style_name' => '50x50_avatar', + '#path' => $picture_path, + '#prefix' => '
      ', + '#suffix' => '
      ', + '#weight' => -50, + ); + + $form['body']['#format'] = 'plain_text'; + + unset($form['token']); + + $form['subject']['#type'] = 'hidden'; + + $form['recipient']['#type'] = 'hidden'; + + drupal_set_title(t('Direct Message @recipient', array('@recipient' => format_username($account)))); + + return $form; +} + +/** + * Helper function to get all of the pending invitations for a given + * recipient user. Returns an array of OG memberships. + */ +function commons_trusted_contacts_get_pending_invitations($uid) { + $query = new EntityFieldQuery(); + $return = $query + ->entityCondition('entity_type', 'og_membership') + ->propertyCondition('group_type', 'user') + ->propertyCondition('entity_type', 'user') + ->propertyCondition('gid', $uid) + ->propertyCondition('etid', $uid, '!=') + ->propertyCondition('state', OG_STATE_PENDING) + ->propertyCondition('type', 'trusted_contacts') + ->fieldCondition('field_my_request', 'value', 1) + ->execute(); + return !empty($return['og_membership']) ? $return['og_membership'] : array(); +} + + +/** + * Menu callback; Batch for setting users as groups. + */ +function commons_trusted_contacts_users_upgrade_batch_init() { + // Fetch all users. + $query = new EntityFieldQuery; + $result = $query->entityCondition('entity_type', 'user') + ->propertyCondition('uid', 0, '<>') + ->execute(); + $uids = array_keys($result['user']); + + // Remove the users that are already set as group. + $ignore_uids = og_get_all_group('user'); + $uids = array_diff($uids, $ignore_uids); + + // Build the operations array. + $uids_chunks = array_chunk($uids, variable_get('commons_trusted_contacts_upgrade_batch_size', 200)); + $operations = array(); + foreach ($uids_chunks as $uids) { + $operations[] = array( + 'commons_trusted_contacts_batch_worker', + array($uids) + ); + } + + $batch = array( + 'title' => t('Upgrading users...'), + 'operations' => array(), + 'init_message' => t('Commencing'), + 'progress_message' => t('Processed @current out of @total.'), + 'error_message' => t('An error occurred during processing'), + 'finished' => 'commons_trusted_contacts_batch_finished', + 'operations' => $operations, + ); + + batch_set($batch); + batch_process(''); +} + +/** + * Batch callback; Set users as groups. + */ +function commons_trusted_contacts_batch_worker($uids, &$context) { + foreach ($uids as $uid) { + $wrapper = entity_metadata_wrapper('user', $uid); + $wrapper->{OG_GROUP_FIELD}->set(TRUE); + $wrapper->save(); + + $context['results']['processed']++; + } +} + +/** + * Batch callback; "Finished" message. + */ +function commons_trusted_contacts_batch_finished($success, $results, $operations) { + if ($success) { + $message = format_plural($results['processed'], t('One user processed.'), t('@count users processed.')); + } + else { + $message = t('Error encountered while upgrading users.'); + } + + drupal_set_message($message); +} diff --git a/modules/commons/commons_trusted_contacts/commons_trusted_contacts.strongarm.inc b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.strongarm.inc new file mode 100644 index 0000000..748743f --- /dev/null +++ b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.strongarm.inc @@ -0,0 +1,89 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_message__trusted_contact_request_approved'; + $strongarm->value = array( + 'view_modes' => array(), + 'extra_fields' => array( + 'form' => array(), + 'display' => array( + 'message__message_text__0' => array( + 'message_notify_email_subject' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + ), + 'message__message_text__1' => array( + 'message_notify_email_subject' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + ), + ), + ), + ); + $export['field_bundle_settings_message__trusted_contact_request_approved'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_message__trusted_contact_request_pending'; + $strongarm->value = array( + 'view_modes' => array(), + 'extra_fields' => array( + 'form' => array(), + 'display' => array( + 'message__message_text__0' => array( + 'message_notify_email_subject' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + ), + 'message__message_text__1' => array( + 'message_notify_email_subject' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + ), + ), + ), + ); + $export['field_bundle_settings_message__trusted_contact_request_pending'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'privatemsg_display_profile_links'; + $strongarm->value = '0'; + $export['privatemsg_display_profile_links'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_trusted_contacts/commons_trusted_contacts.views.inc b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.views.inc new file mode 100644 index 0000000..10e1e28 --- /dev/null +++ b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.views.inc @@ -0,0 +1,17 @@ + t('Send Message'), + 'help' => t('Views handler.'), + 'real field' => 'etid', + 'field' => array( + 'handler' => 'commons_trusted_contacts_handler_send_message', + ), + ); + + return $data; +} diff --git a/modules/commons/commons_trusted_contacts/commons_trusted_contacts.views_default.inc b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.views_default.inc new file mode 100644 index 0000000..e03e61a --- /dev/null +++ b/modules/commons/commons_trusted_contacts/commons_trusted_contacts.views_default.inc @@ -0,0 +1,416 @@ +name = 'trusted_contacts'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'og_membership'; + $view->human_name = 'Trusted Contacts'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Trusted Contacts'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'none'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['pager']['options']['items_per_page'] = '10'; + $handler->display->display_options['style_plugin'] = 'table'; + $handler->display->display_options['style_options']['columns'] = array( + 'field_name_first' => 'field_name_first', + 'field_name_last' => 'field_name_first', + ); + $handler->display->display_options['style_options']['default'] = '-1'; + $handler->display->display_options['style_options']['info'] = array( + 'field_name_first' => array( + 'sortable' => 0, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'field_name_last' => array( + 'sortable' => 0, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + ); + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['label'] = 'No Contacts'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'You have no trusted contacts.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: OG membership: Group User from OG membership */ + $handler->display->display_options['relationships']['og_membership_related_user_group']['id'] = 'og_membership_related_user_group'; + $handler->display->display_options['relationships']['og_membership_related_user_group']['table'] = 'og_membership'; + $handler->display->display_options['relationships']['og_membership_related_user_group']['field'] = 'og_membership_related_user_group'; + /* Relationship: OG membership: User from OG membership */ + $handler->display->display_options['relationships']['og_membership_related_user']['id'] = 'og_membership_related_user'; + $handler->display->display_options['relationships']['og_membership_related_user']['table'] = 'og_membership'; + $handler->display->display_options['relationships']['og_membership_related_user']['field'] = 'og_membership_related_user'; + /* Field: Bulk operations: OG membership */ + $handler->display->display_options['fields']['views_bulk_operations']['id'] = 'views_bulk_operations'; + $handler->display->display_options['fields']['views_bulk_operations']['table'] = 'og_membership'; + $handler->display->display_options['fields']['views_bulk_operations']['field'] = 'views_bulk_operations'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['display_type'] = '1'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['enable_select_all_pages'] = 1; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['force_single'] = 0; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '10'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_operations'] = array( + 'action::views_bulk_operations_delete_item' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::views_bulk_operations_script_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::views_bulk_operations_modify_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'settings' => array( + 'show_all_tokens' => 1, + 'display_values' => array( + '_all_' => '_all_', + ), + ), + ), + 'action::og_set_state_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::og_user_roles_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::views_bulk_operations_argument_selector_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'settings' => array( + 'url' => '', + ), + ), + 'action::og_membership_delete_action' => array( + 'selected' => 1, + 'postpone_processing' => 0, + 'skip_confirmation' => 1, + 'override_label' => 1, + 'label' => 'Break Contact', + ), + 'action::system_send_email_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::commons_groups_set_state_active_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::commons_groups_set_state_blocked_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::panelizer_set_status_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + ); + /* Field: User: Name */ + $handler->display->display_options['fields']['name']['id'] = 'name'; + $handler->display->display_options['fields']['name']['table'] = 'users'; + $handler->display->display_options['fields']['name']['field'] = 'name'; + $handler->display->display_options['fields']['name']['relationship'] = 'og_membership_related_user'; + $handler->display->display_options['fields']['name']['label'] = 'Contact'; + $handler->display->display_options['fields']['name']['element_label_colon'] = FALSE; + /* Field: OG membership: Response date */ + $handler->display->display_options['fields']['field_response_date']['id'] = 'field_response_date'; + $handler->display->display_options['fields']['field_response_date']['table'] = 'field_data_field_response_date'; + $handler->display->display_options['fields']['field_response_date']['field'] = 'field_response_date'; + $handler->display->display_options['fields']['field_response_date']['label'] = 'Contact since'; + $handler->display->display_options['fields']['field_response_date']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['field_response_date']['type'] = 'format_interval'; + $handler->display->display_options['fields']['field_response_date']['settings'] = array( + 'interval' => '2', + 'interval_display' => 'time ago', + ); + /* Field: OG membership: Send Message */ + $handler->display->display_options['fields']['send_message']['id'] = 'send_message'; + $handler->display->display_options['fields']['send_message']['table'] = 'og_membership'; + $handler->display->display_options['fields']['send_message']['field'] = 'send_message'; + $handler->display->display_options['fields']['send_message']['label'] = ''; + $handler->display->display_options['fields']['send_message']['element_label_colon'] = FALSE; + /* Contextual filter: User: Uid */ + $handler->display->display_options['arguments']['uid']['id'] = 'uid'; + $handler->display->display_options['arguments']['uid']['table'] = 'users'; + $handler->display->display_options['arguments']['uid']['field'] = 'uid'; + $handler->display->display_options['arguments']['uid']['relationship'] = 'og_membership_related_user_group'; + $handler->display->display_options['arguments']['uid']['default_action'] = 'default'; + $handler->display->display_options['arguments']['uid']['default_argument_type'] = 'current_user'; + $handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25'; + /* Contextual filter: User: Uid */ + $handler->display->display_options['arguments']['uid_1']['id'] = 'uid_1'; + $handler->display->display_options['arguments']['uid_1']['table'] = 'users'; + $handler->display->display_options['arguments']['uid_1']['field'] = 'uid'; + $handler->display->display_options['arguments']['uid_1']['relationship'] = 'og_membership_related_user'; + $handler->display->display_options['arguments']['uid_1']['default_action'] = 'default'; + $handler->display->display_options['arguments']['uid_1']['default_argument_type'] = 'current_user'; + $handler->display->display_options['arguments']['uid_1']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['uid_1']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['uid_1']['summary_options']['items_per_page'] = '25'; + $handler->display->display_options['arguments']['uid_1']['not'] = TRUE; + /* Filter criterion: OG membership: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'og_membership'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['value'] = array( + 'trusted_contacts' => 'trusted_contacts', + ); + /* Filter criterion: OG membership: State */ + $handler->display->display_options['filters']['state']['id'] = 'state'; + $handler->display->display_options['filters']['state']['table'] = 'og_membership'; + $handler->display->display_options['filters']['state']['field'] = 'state'; + $handler->display->display_options['filters']['state']['value'] = array( + 1 => '1', + ); + $export['trusted_contacts'] = $view; + + $view = new view(); + $view->name = 'trusted_contacts_invitations'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'og_membership'; + $view->human_name = 'Trusted Contacts Invitations'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Invitations'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'none'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['pager']['options']['items_per_page'] = '10'; + $handler->display->display_options['style_plugin'] = 'table'; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['label'] = 'No Invitations'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'You have no pending invitations.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: OG membership: Group User from OG membership */ + $handler->display->display_options['relationships']['og_membership_related_user_group']['id'] = 'og_membership_related_user_group'; + $handler->display->display_options['relationships']['og_membership_related_user_group']['table'] = 'og_membership'; + $handler->display->display_options['relationships']['og_membership_related_user_group']['field'] = 'og_membership_related_user_group'; + /* Relationship: OG membership: User from OG membership */ + $handler->display->display_options['relationships']['og_membership_related_user']['id'] = 'og_membership_related_user'; + $handler->display->display_options['relationships']['og_membership_related_user']['table'] = 'og_membership'; + $handler->display->display_options['relationships']['og_membership_related_user']['field'] = 'og_membership_related_user'; + /* Field: Bulk operations: OG membership */ + $handler->display->display_options['fields']['views_bulk_operations']['id'] = 'views_bulk_operations'; + $handler->display->display_options['fields']['views_bulk_operations']['table'] = 'og_membership'; + $handler->display->display_options['fields']['views_bulk_operations']['field'] = 'views_bulk_operations'; + $handler->display->display_options['fields']['views_bulk_operations']['label'] = ''; + $handler->display->display_options['fields']['views_bulk_operations']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['display_type'] = '1'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['enable_select_all_pages'] = 0; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['force_single'] = 0; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '10'; + $handler->display->display_options['fields']['views_bulk_operations']['vbo_operations'] = array( + 'action::views_bulk_operations_delete_item' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::views_bulk_operations_script_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::views_bulk_operations_modify_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'settings' => array( + 'show_all_tokens' => 1, + 'display_values' => array( + '_all_' => '_all_', + ), + ), + ), + 'action::og_set_state_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::og_user_roles_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::views_bulk_operations_argument_selector_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'settings' => array( + 'url' => '', + ), + ), + 'action::og_membership_delete_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::system_send_email_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::commons_trusted_contacts_set_state_active_action' => array( + 'selected' => 1, + 'postpone_processing' => 0, + 'skip_confirmation' => 1, + 'override_label' => 1, + 'label' => 'Approve', + ), + 'action::commons_trusted_contacts_set_state_blocked_action' => array( + 'selected' => 1, + 'postpone_processing' => 0, + 'skip_confirmation' => 1, + 'override_label' => 1, + 'label' => 'Ignore', + ), + 'action::panelizer_set_status_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + ); + /* Field: User: Name */ + $handler->display->display_options['fields']['name']['id'] = 'name'; + $handler->display->display_options['fields']['name']['table'] = 'users'; + $handler->display->display_options['fields']['name']['field'] = 'name'; + $handler->display->display_options['fields']['name']['relationship'] = 'og_membership_related_user'; + $handler->display->display_options['fields']['name']['label'] = 'Contact'; + $handler->display->display_options['fields']['name']['element_label_colon'] = FALSE; + /* Field: OG membership: Membership Token */ + $handler->display->display_options['fields']['field_membership_token']['id'] = 'field_membership_token'; + $handler->display->display_options['fields']['field_membership_token']['table'] = 'field_data_field_membership_token'; + $handler->display->display_options['fields']['field_membership_token']['field'] = 'field_membership_token'; + $handler->display->display_options['fields']['field_membership_token']['label'] = ''; + $handler->display->display_options['fields']['field_membership_token']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['field_membership_token']['type'] = 'approve_ignore'; + /* Field: OG membership: Created */ + $handler->display->display_options['fields']['created']['id'] = 'created'; + $handler->display->display_options['fields']['created']['table'] = 'og_membership'; + $handler->display->display_options['fields']['created']['field'] = 'created'; + $handler->display->display_options['fields']['created']['label'] = 'Recieved'; + $handler->display->display_options['fields']['created']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['created']['date_format'] = 'time ago'; + /* Contextual filter: User: Uid */ + $handler->display->display_options['arguments']['uid']['id'] = 'uid'; + $handler->display->display_options['arguments']['uid']['table'] = 'users'; + $handler->display->display_options['arguments']['uid']['field'] = 'uid'; + $handler->display->display_options['arguments']['uid']['relationship'] = 'og_membership_related_user_group'; + $handler->display->display_options['arguments']['uid']['default_action'] = 'default'; + $handler->display->display_options['arguments']['uid']['default_argument_type'] = 'current_user'; + $handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25'; + /* Filter criterion: OG membership: State */ + $handler->display->display_options['filters']['state']['id'] = 'state'; + $handler->display->display_options['filters']['state']['table'] = 'og_membership'; + $handler->display->display_options['filters']['state']['field'] = 'state'; + $handler->display->display_options['filters']['state']['value'] = array( + 2 => '2', + ); + /* Filter criterion: OG membership: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'og_membership'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['value'] = array( + 'trusted_contacts' => 'trusted_contacts', + ); + /* Filter criterion: OG membership: My request (field_my_request) */ + $handler->display->display_options['filters']['field_my_request_value']['id'] = 'field_my_request_value'; + $handler->display->display_options['filters']['field_my_request_value']['table'] = 'field_data_field_my_request'; + $handler->display->display_options['filters']['field_my_request_value']['field'] = 'field_my_request_value'; + $handler->display->display_options['filters']['field_my_request_value']['value'] = array( + 1 => '1', + ); + $export['trusted_contacts_invitations'] = $view; + + return $export; +} diff --git a/modules/commons/commons_trusted_contacts/includes/actions/mark_as_read.action.inc b/modules/commons/commons_trusted_contacts/includes/actions/mark_as_read.action.inc new file mode 100644 index 0000000..64b0b6e --- /dev/null +++ b/modules/commons/commons_trusted_contacts/includes/actions/mark_as_read.action.inc @@ -0,0 +1,20 @@ + array( + 'type' => 'privatemsg_message', + 'label' => t('Mark as read'), + 'configurable' => FALSE, + )); +} + +function commons_trusted_contacts_mark_as_read_action($privatemsg_message) { + db_update('pm_index') + ->fields(array('is_new' => PRIVATEMSG_READ)) + ->condition('mid', $privatemsg_message->mid) + ->execute(); +} diff --git a/modules/commons/commons_trusted_contacts/includes/actions/set_state_active.action.inc b/modules/commons/commons_trusted_contacts/includes/actions/set_state_active.action.inc new file mode 100644 index 0000000..c8c8341 --- /dev/null +++ b/modules/commons/commons_trusted_contacts/includes/actions/set_state_active.action.inc @@ -0,0 +1,28 @@ + array( + 'type' => 'og_membership', + 'label' => t('Set Membership state to Active'), + 'configurable' => FALSE, + )); +} + +function commons_trusted_contacts_set_state_active_action($og_membership) { + if ($og_membership->state == OG_STATE_ACTIVE) { + return; + } + + // Don't process the group manager, if exists. + $group = entity_load_single($og_membership->group_type, $og_membership->gid); + if (!empty($group->uid) && $group->uid == $og_membership->etid && $og_membership->entity_type == 'user') { + return; + } + + $og_membership->state = OG_STATE_ACTIVE; + $og_membership->save(); +} diff --git a/modules/commons/commons_trusted_contacts/includes/actions/set_state_blocked.action.inc b/modules/commons/commons_trusted_contacts/includes/actions/set_state_blocked.action.inc new file mode 100644 index 0000000..791a502 --- /dev/null +++ b/modules/commons/commons_trusted_contacts/includes/actions/set_state_blocked.action.inc @@ -0,0 +1,28 @@ + array( + 'type' => 'og_membership', + 'label' => t('Set Membership state to Blocked'), + 'configurable' => FALSE, + )); +} + +function commons_trusted_contacts_set_state_blocked_action($og_membership) { + if ($og_membership->state == OG_STATE_BLOCKED) { + return; + } + + // Don't process the group manager, if exists. + $group = entity_load_single($og_membership->group_type, $og_membership->gid); + if (!empty($group->uid) && $group->uid == $og_membership->etid && $og_membership->entity_type == 'user') { + return; + } + + $og_membership->state = OG_STATE_BLOCKED; + $og_membership->save(); +} diff --git a/modules/commons/commons_trusted_contacts/scripts/commons-trusted-contacts.js b/modules/commons/commons_trusted_contacts/scripts/commons-trusted-contacts.js new file mode 100644 index 0000000..04c0877 --- /dev/null +++ b/modules/commons/commons_trusted_contacts/scripts/commons-trusted-contacts.js @@ -0,0 +1,37 @@ +(function ($) { + +/** + * Initially hide the group selection and make it visible when the custom + * audience radio is selected. + */ +Drupal.behaviors.commonsAudienceToggle = { + attach: function (context, settings) { + $('.commons-bw-partial-node-form, .node-form', context).once('commonsAudienceToggle', function(){ + // Load items into simple variables to make things a bit easier to read. + var form = $(this), + groupReference = form.find('.field-name-og-group-ref'), + radioToggle = form.find('input[name=group_audience_type]'); + + // Hide the group selection on load only if custom is not selected. + if ($('input:radio[name=group_audience_type]:checked').val() != 'custom') { + groupReference.addClass('element-hidden'); + } + + // When the "custom" audience radio is selected, make the group selection + // visible. + radioToggle.change(function () { + var radio = $(this), + radioValue = radio.val(); + + if (radioValue == 'custom' && radio.is(':checked')) { + groupReference.removeClass('element-hidden'); + } + else { + groupReference.addClass('element-hidden'); + } + }); + }); + } +} + +})(jQuery); diff --git a/modules/commons/commons_trusted_contacts/views/handlers/commons_groups_handler_send_message.inc b/modules/commons/commons_trusted_contacts/views/handlers/commons_groups_handler_send_message.inc new file mode 100644 index 0000000..cc78eff --- /dev/null +++ b/modules/commons/commons_trusted_contacts/views/handlers/commons_groups_handler_send_message.inc @@ -0,0 +1,10 @@ +uid . '/contacts/messages/popup/' . $values->og_membership_etid); + } +} diff --git a/modules/commons/commons_trusted_contacts/views/handlers/commons_trusted_contacts_handler_send_message.inc b/modules/commons/commons_trusted_contacts/views/handlers/commons_trusted_contacts_handler_send_message.inc new file mode 100644 index 0000000..cc78eff --- /dev/null +++ b/modules/commons/commons_trusted_contacts/views/handlers/commons_trusted_contacts_handler_send_message.inc @@ -0,0 +1,10 @@ +uid . '/contacts/messages/popup/' . $values->og_membership_etid); + } +} diff --git a/modules/commons/commons_user_profile_pages/commons_user_profile_pages.features.inc b/modules/commons/commons_user_profile_pages/commons_user_profile_pages.features.inc new file mode 100644 index 0000000..f73c07a --- /dev/null +++ b/modules/commons/commons_user_profile_pages/commons_user_profile_pages.features.inc @@ -0,0 +1,14 @@ + "1"); + } +} diff --git a/modules/commons/commons_user_profile_pages/commons_user_profile_pages.info b/modules/commons/commons_user_profile_pages/commons_user_profile_pages.info new file mode 100644 index 0000000..e6b9782 --- /dev/null +++ b/modules/commons/commons_user_profile_pages/commons_user_profile_pages.info @@ -0,0 +1,13 @@ +name = Commons User Profile Pages +description = Exports a default user profile page, powered by the Panels module. +core = 7.x +package = Commons - Landing pages +dependencies[] = commons_activity_streams +dependencies[] = commons_follow +dependencies[] = commons_profile_base +dependencies[] = commons_profile_social +dependencies[] = ctools +dependencies[] = page_manager +features[ctools][] = page_manager:pages_default:1 +features[features_api][] = api:2 +features[page_manager_handlers][] = user_view_panel_context diff --git a/modules/commons/commons_user_profile_pages/commons_user_profile_pages.install b/modules/commons/commons_user_profile_pages/commons_user_profile_pages.install new file mode 100644 index 0000000..7e0ce9e --- /dev/null +++ b/modules/commons/commons_user_profile_pages/commons_user_profile_pages.install @@ -0,0 +1,20 @@ + array('page_manager_handlers'))); + return array(); +} diff --git a/modules/commons/commons_user_profile_pages/commons_user_profile_pages.module b/modules/commons/commons_user_profile_pages/commons_user_profile_pages.module new file mode 100644 index 0000000..fe9fb12 --- /dev/null +++ b/modules/commons/commons_user_profile_pages/commons_user_profile_pages.module @@ -0,0 +1,37 @@ + array('pages_default'), + ); + features_revert($revert); + return array(); + } +} + +/* + * Implements hook_modules_disabled(). + */ +function commons_user_profile_pages_modules_disabled($modules) { + // Disable the panel that relies on trusted contacts to show group_group data + // within the user profile. + if (in_array('commons_trusted_contacts', $modules)) { + $revert = array( + 'commons_user_profile_pages' => array('pages_default'), + ); + features_revert($revert); + return array(); + } +} \ No newline at end of file diff --git a/modules/commons/commons_user_profile_pages/commons_user_profile_pages.pages_default.inc b/modules/commons/commons_user_profile_pages/commons_user_profile_pages.pages_default.inc new file mode 100644 index 0000000..245e1ac --- /dev/null +++ b/modules/commons/commons_user_profile_pages/commons_user_profile_pages.pages_default.inc @@ -0,0 +1,332 @@ +disabled = FALSE; /* Edit this to true to make a default handler disabled initially */ + $handler->api_version = 1; + $handler->name = 'user_view_panel_context'; + $handler->task = 'user_view'; + $handler->subtask = ''; + $handler->handler = 'panel_context'; + $handler->weight = -99; + $handler->conf = array( + 'title' => 'User profile', + 'no_blocks' => 0, + 'pipeline' => 'ipe', + 'body_classes_to_remove' => '', + 'body_classes_to_add' => '', + 'css_id' => '', + 'css' => '', + 'contexts' => array(), + 'relationships' => array(), + ); + $display = new panels_display(); + $display->layout = 'three_3x33'; + $display->layout_settings = array(); + $display->panel_settings = array( + 'style_settings' => array( + 'default' => NULL, + 'three_33_top' => NULL, + 'three_33_first' => NULL, + 'three_33_second' => NULL, + 'three_33_third' => NULL, + 'three_33_bottom' => NULL, + ), + ); + $display->cache = array(); + $display->title = ''; + $display->uuid = '8b3ae903-c1dc-bcc4-71b3-a1bdd65c494d'; + $display->content = array(); + $display->panels = array(); + $pane = new stdClass(); + $pane->pid = 'new-cde013ca-1d6e-1e14-9171-8ccb1331008f'; + $pane->panel = 'three_33_first'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_activity_streams_user_activity-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'context' => array( + 0 => 'argument_entity_id:user_1', + ), + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = 'cde013ca-1d6e-1e14-9171-8ccb1331008f'; + $display->content['new-cde013ca-1d6e-1e14-9171-8ccb1331008f'] = $pane; + $display->panels['three_33_first'][0] = 'new-cde013ca-1d6e-1e14-9171-8ccb1331008f'; + $pane = new stdClass(); + $pane->pid = 'new-f4cdb777-e56d-b974-4953-9b5f2dc9b594'; + $pane->panel = 'three_33_second'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_groups_user_groups-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'context' => array( + 0 => 'argument_entity_id:user_1', + ), + 'override_title' => 1, + 'override_title_text' => 'Groups %user:field_name_first contributes to', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = 'f4cdb777-e56d-b974-4953-9b5f2dc9b594'; + $display->content['new-f4cdb777-e56d-b974-4953-9b5f2dc9b594'] = $pane; + $display->panels['three_33_second'][0] = 'new-f4cdb777-e56d-b974-4953-9b5f2dc9b594'; + $pane = new stdClass(); + $pane->pid = 'new-2183ff7a-9286-81a4-39fb-25b7d4973c3b'; + $pane->panel = 'three_33_third'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_follow_user_following-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = '2183ff7a-9286-81a4-39fb-25b7d4973c3b'; + $display->content['new-2183ff7a-9286-81a4-39fb-25b7d4973c3b'] = $pane; + $display->panels['three_33_third'][0] = 'new-2183ff7a-9286-81a4-39fb-25b7d4973c3b'; + $pane = new stdClass(); + $pane->pid = 'new-b0ac54f1-a0c8-a334-a53d-47581e23257d'; + $pane->panel = 'three_33_third'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_follow_user_followers-panel_pane_1'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array(); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 1; + $pane->locks = array(); + $pane->uuid = 'b0ac54f1-a0c8-a334-a53d-47581e23257d'; + $display->content['new-b0ac54f1-a0c8-a334-a53d-47581e23257d'] = $pane; + $display->panels['three_33_third'][1] = 'new-b0ac54f1-a0c8-a334-a53d-47581e23257d'; + $pane = new stdClass(); + $pane->pid = 'new-d3fbb9db-cd0f-b8f4-1572-0e80c4a66c83'; + $pane->panel = 'three_33_top'; + $pane->type = 'user_picture'; + $pane->subtype = 'user_picture'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'context' => 'argument_entity_id:user_1', + 'override_title' => 1, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = 'd3fbb9db-cd0f-b8f4-1572-0e80c4a66c83'; + $display->content['new-d3fbb9db-cd0f-b8f4-1572-0e80c4a66c83'] = $pane; + $display->panels['three_33_top'][0] = 'new-d3fbb9db-cd0f-b8f4-1572-0e80c4a66c83'; + $pane = new stdClass(); + $pane->pid = 'new-918d67a4-4642-0364-a570-10f387184ae1'; + $pane->panel = 'three_33_top'; + $pane->type = 'entity_field'; + $pane->subtype = 'user:field_bio'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'label' => 'hidden', + 'formatter' => 'text_default', + 'delta_limit' => 0, + 'delta_offset' => '0', + 'delta_reversed' => FALSE, + 'formatter_settings' => array(), + 'context' => 'argument_entity_id:user_1', + 'override_title' => 0, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 1; + $pane->locks = array(); + $pane->uuid = '918d67a4-4642-0364-a570-10f387184ae1'; + $display->content['new-918d67a4-4642-0364-a570-10f387184ae1'] = $pane; + $display->panels['three_33_top'][1] = 'new-918d67a4-4642-0364-a570-10f387184ae1'; + $pane = new stdClass(); + $pane->pid = 'new-b51e0fa8-7402-1104-3597-9bd7665546ae'; + $pane->panel = 'three_33_top'; + $pane->type = 'entity_field'; + $pane->subtype = 'user:field_facebook_url'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'label' => 'hidden', + 'formatter' => 'link_default', + 'delta_limit' => 0, + 'delta_offset' => '0', + 'delta_reversed' => FALSE, + 'formatter_settings' => array(), + 'context' => 'argument_entity_id:user_1', + 'override_title' => 0, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 2; + $pane->locks = array(); + $pane->uuid = 'b51e0fa8-7402-1104-3597-9bd7665546ae'; + $display->content['new-b51e0fa8-7402-1104-3597-9bd7665546ae'] = $pane; + $display->panels['three_33_top'][2] = 'new-b51e0fa8-7402-1104-3597-9bd7665546ae'; + $pane = new stdClass(); + $pane->pid = 'new-20f47a2e-7cb8-a944-8944-3f15009131f7'; + $pane->panel = 'three_33_top'; + $pane->type = 'entity_field'; + $pane->subtype = 'user:field_linkedin_url'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'label' => 'hidden', + 'formatter' => 'link_default', + 'delta_limit' => 0, + 'delta_offset' => '0', + 'delta_reversed' => FALSE, + 'formatter_settings' => array(), + 'context' => 'argument_entity_id:user_1', + 'override_title' => 0, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 3; + $pane->locks = array(); + $pane->uuid = '20f47a2e-7cb8-a944-8944-3f15009131f7'; + $display->content['new-20f47a2e-7cb8-a944-8944-3f15009131f7'] = $pane; + $display->panels['three_33_top'][3] = 'new-20f47a2e-7cb8-a944-8944-3f15009131f7'; + $pane = new stdClass(); + $pane->pid = 'new-ac8d8150-6ff4-8654-c594-9c46cfe746d3'; + $pane->panel = 'three_33_top'; + $pane->type = 'entity_field'; + $pane->subtype = 'user:field_twitter_url'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'label' => 'hidden', + 'formatter' => 'link_default', + 'delta_limit' => 0, + 'delta_offset' => '0', + 'delta_reversed' => FALSE, + 'formatter_settings' => array(), + 'context' => 'argument_entity_id:user_1', + 'override_title' => 0, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 4; + $pane->locks = array(); + $pane->uuid = 'ac8d8150-6ff4-8654-c594-9c46cfe746d3'; + $display->content['new-ac8d8150-6ff4-8654-c594-9c46cfe746d3'] = $pane; + $display->panels['three_33_top'][4] = 'new-ac8d8150-6ff4-8654-c594-9c46cfe746d3'; + $pane = new stdClass(); + $pane->pid = 'new-67c3df7b-1a3b-db24-f974-a3b27f8988d9'; + $pane->panel = 'three_33_top'; + $pane->type = 'token'; + $pane->subtype = 'user:flag-commons-follow-user-link'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'sanitize' => 1, + 'context' => 'argument_entity_id:user_1', + 'override_title' => 1, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 5; + $pane->locks = array(); + $pane->uuid = '67c3df7b-1a3b-db24-f974-a3b27f8988d9'; + $display->content['new-67c3df7b-1a3b-db24-f974-a3b27f8988d9'] = $pane; + $display->panels['three_33_top'][5] = 'new-67c3df7b-1a3b-db24-f974-a3b27f8988d9'; + $pane = new stdClass(); + $pane->pid = 'new-38b23f27-878a-f264-dd90-e55305d0f70c'; + $pane->panel = 'three_33_top'; + $pane->type = 'entity_field'; + $pane->subtype = 'user:group_group'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'label' => 'hidden', + 'formatter' => 'trusted_contact', + 'delta_limit' => 0, + 'delta_offset' => '0', + 'delta_reversed' => FALSE, + 'formatter_settings' => array(), + 'context' => 'argument_entity_id:user_1', + 'override_title' => 0, + 'override_title_text' => '', + ); + $pane->cache = array(); + $pane->style = array(); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 6; + $pane->locks = array(); + $pane->uuid = '38b23f27-878a-f264-dd90-e55305d0f70c'; + $display->content['new-38b23f27-878a-f264-dd90-e55305d0f70c'] = $pane; + $display->panels['three_33_top'][6] = 'new-38b23f27-878a-f264-dd90-e55305d0f70c'; + $display->hide_title = PANELS_TITLE_FIXED; + $display->title_pane = '0'; + $handler->conf['display'] = $display; + $export['user_view_panel_context'] = $handler; + + return $export; +} diff --git a/modules/commons/commons_utility_links/commons_utility_links.api.php b/modules/commons/commons_utility_links/commons_utility_links.api.php new file mode 100644 index 0000000..ac904e8 --- /dev/null +++ b/modules/commons/commons_utility_links/commons_utility_links.api.php @@ -0,0 +1,68 @@ + 'user/' . $account->uid . '/find_friends', + 'title' => t('Find friends'), + ); + } + + return $links; +} + +/** + * Perform alterations on utility links. + * + * @param $links + * An associative array of utility links whose keys are used as its CSS class. + * Each link should be itself an array, with the same elements used in + * theme_links(), except for the addition of a 'weight' element that is used + * for ordering the links. + * + * @see theme_links() + * @see hook_commons_utility_links() + */ +function hook_commons_utility_links_alter(&$links) { + // Change the title of the user account link from the user's name to + // 'Account'. + $links['name']['title'] = t('Account'); +} + +/** + * @} End of "addtogroup hooks". + */ diff --git a/modules/commons/commons_utility_links/commons_utility_links.commons_utility_links.inc b/modules/commons/commons_utility_links/commons_utility_links.commons_utility_links.inc new file mode 100644 index 0000000..e4825be --- /dev/null +++ b/modules/commons/commons_utility_links/commons_utility_links.commons_utility_links.inc @@ -0,0 +1,42 @@ + 'user', + 'title' => format_username($account), + 'weight' => -10, + ); + $links['logout'] = array( + 'href' => 'user/logout', + 'title' => t('Log out'), + 'weight' => 9, + ); + } + else { + if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) { + $links['signup'] = array( + 'href' => 'user/register', + 'title' => t('Sign up'), + 'weight' => -10, + ); + } + $links['login'] = array( + 'href' => 'user/login', + 'title' => t('Log in'), + 'weight' => -9, + ); + } + + return $links; +} diff --git a/modules/commons/commons_utility_links/commons_utility_links.info b/modules/commons/commons_utility_links/commons_utility_links.info new file mode 100644 index 0000000..bf991bf --- /dev/null +++ b/modules/commons/commons_utility_links/commons_utility_links.info @@ -0,0 +1,3 @@ +core = 7.x +name = Commons Utility links block +package = "Commons - Building blocks" \ No newline at end of file diff --git a/modules/commons/commons_utility_links/commons_utility_links.install b/modules/commons/commons_utility_links/commons_utility_links.install new file mode 100644 index 0000000..39607b3 --- /dev/null +++ b/modules/commons/commons_utility_links/commons_utility_links.install @@ -0,0 +1,56 @@ + 'commons_utility_links', + 'delta' => 'commons_utility_links', + 'theme' => 'commons_origins', + 'visibility' => 0, + 'region' => 'header', + 'status' => 1, + 'pages' => '0', + 'cache' => DRUPAL_NO_CACHE, + 'title' => '', + ); + drupal_write_record('block', $utility_block); + + db_update('block') + ->fields(array('region' => 'header')) + ->fields(array('cache' => DRUPAL_NO_CACHE)) + ->condition('delta', 'commons_utility_links') + ->condition('module', 'commons_utility_links') + ->condition('theme', 'commons_origins') + ->execute(); +} + +/** + * Remove utility_links block, and enable commons_utility_links, that never caches. + */ +function commons_utility_links_update_7301() { + db_delete('block') + ->condition('module', 'commons_utility_links') + ->condition('delta', 'utility_links') + ->execute(); + + db_update('block') + ->fields(array( + 'cache' => DRUPAL_NO_CACHE, + 'region' => 'header', + 'status' => 1, + 'title' => '', + )) + ->condition('delta', 'commons_utility_links') + ->condition('module', 'commons_utility_links') + ->condition('theme', 'commons_origins') + ->execute(); + cache_clear_all('*', 'cache_block', TRUE); +} diff --git a/modules/commons/commons_utility_links/commons_utility_links.module b/modules/commons/commons_utility_links/commons_utility_links.module new file mode 100644 index 0000000..e8c2f5c --- /dev/null +++ b/modules/commons/commons_utility_links/commons_utility_links.module @@ -0,0 +1,56 @@ + 'commons_utility_links')); +} + +/** + * Implements hook_block_info(). + */ +function commons_utility_links_block_info() { + $blocks['commons_utility_links'] = array( + 'info' => t('Commons utility links'), + 'cache' => DRUPAL_NO_CACHE, + 'visibility' => 0, + 'status' => 1, + 'pages' => 0, + 'weight' => 1, + ); + + return $blocks; +} + +/** + * Implements hook_block_view(). + */ +function commons_utility_links_block_view($delta = '') { + $block = array(); + + // Gather all of the available utility links. + $links = module_invoke_all('commons_utility_links'); + drupal_alter('commons_utility_links', $links); + + if (!empty($links)) { + // Sort the links by weight before rendering them. + uasort($links, 'drupal_sort_weight'); + + $block['subject'] = NULL; + $block['content'] = array( + '#theme' => 'links__commons_utility_links', + '#links' => $links, + '#attributes' => array( + 'class' => array('commons-utility-links'), + ), + ); + } + + return $block; +} diff --git a/modules/commons/commons_wikis/commons_wikis.features.field_instance.inc b/modules/commons/commons_wikis/commons_wikis.features.field_instance.inc new file mode 100644 index 0000000..56f04cd --- /dev/null +++ b/modules/commons/commons_wikis/commons_wikis.features.field_instance.inc @@ -0,0 +1,162 @@ + 'commons_wikis_wiki_updated', + 'default_value' => NULL, + 'default_value_function' => '', + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 3, + ), + 'message_notify_email_body' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'message_notify_email_subject' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'message', + 'field_name' => 'field_target_nodes', + 'label' => 'Target nodes', + 'required' => 0, + 'settings' => array( + 'behaviors' => array( + 'prepopulate' => array( + 'status' => 0, + ), + ), + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'entityreference', + 'settings' => array( + 'match_operator' => 'CONTAINS', + 'path' => '', + 'size' => 60, + ), + 'type' => 'entityreference_autocomplete', + 'weight' => 2, + ), + ); + + // Exported field_instance: 'node-wiki-body' + $field_instances['node-wiki-body'] = array( + 'bundle' => 'wiki', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 0, + ), + 'teaser' => array( + 'label' => 'hidden', + 'module' => 'text', + 'settings' => array( + 'trim_length' => 600, + ), + 'type' => 'text_summary_or_trimmed', + 'weight' => 1, + ), + ), + 'display_in_partial_form' => 1, + 'entity_type' => 'node', + 'field_name' => 'body', + 'label' => 'Body', + 'required' => 1, + 'settings' => array( + 'display_summary' => 0, + 'text_processing' => 1, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'rows' => 20, + 'summary_rows' => 5, + ), + 'type' => 'text_textarea_with_summary', + 'weight' => 1, + ), + ); + + // Exported field_instance: 'node-wiki-title_field' + $field_instances['node-wiki-title_field'] = array( + 'bundle' => 'wiki', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => '', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 12, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'display_in_partial_form' => 1, + 'entity_type' => 'node', + 'field_name' => 'title_field', + 'label' => 'Title', + 'required' => 1, + 'settings' => array( + 'hide_label' => array( + 'entity' => 0, + 'page' => 0, + ), + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'size' => 60, + ), + 'type' => 'text_textfield', + 'weight' => -5, + ), + ); + + // Translatables + // Included for use with string extractors like potx. + t('Body'); + t('Target nodes'); + t('Title'); + + return $field_instances; +} diff --git a/modules/commons/commons_wikis/commons_wikis.features.inc b/modules/commons/commons_wikis/commons_wikis.features.inc new file mode 100644 index 0000000..13fd5b9 --- /dev/null +++ b/modules/commons/commons_wikis/commons_wikis.features.inc @@ -0,0 +1,78 @@ + "1"); + } + if ($module == "strongarm" && $api == "strongarm") { + return array("version" => "1"); + } +} + +/** + * Implements hook_views_api(). + */ +function commons_wikis_views_api($module = NULL, $api = NULL) { + return array("api" => "3.0"); +} + +/** + * Implements hook_default_message_type(). + */ +function commons_wikis_default_message_type() { + $items = array(); + $items['commons_wikis_wiki_updated'] = entity_import('message_type', '{ + "name" : "commons_wikis_wiki_updated", + "description" : "Message when a wiki page has been updated.", + "argument_keys" : [], + "argument" : [], + "category" : "message_type", + "data" : { "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" } }, + "language" : "", + "arguments" : null, + "message_text" : { "und" : [ + { + "value" : "[message:user:picture:35x35]", + "format" : "full_html", + "safe_value" : "[message:user:picture:35x35]" + }, + { + "value" : "\\u003Ca href=\\u0022[message:user:url:absolute]\\u0022\\u003E[message:user:name]\\u003C\\/a\\u003E has updated the \\u003Ca href=\\u0022[message:field-target-nodes:0:url]\\u0022\\u003E[message:field-target-nodes:0:title_field]\\u003C\\/a\\u003E wiki page", + "format" : "full_html", + "safe_value" : "\\u003Ca href=\\u0022[message:user:url:absolute]\\u0022\\u003E[message:user:name]\\u003C\\/a\\u003E has updated the \\u003Ca href=\\u0022[message:field-target-nodes:0:url]\\u0022\\u003E[message:field-target-nodes:0:title_field]\\u003C\\/a\\u003E wiki page" + }, + { + "value" : "[commons-groups:in-groups-text]", + "format" : "full_html", + "safe_value" : "[commons-groups:in-groups-text]" + } + ] + }, + "rdf_mapping" : [] + }'); + return $items; +} + +/** + * Implements hook_node_info(). + */ +function commons_wikis_node_info() { + $items = array( + 'wiki' => array( + 'name' => t('Wiki'), + 'base' => 'node_content', + 'description' => t('Create a collaborative document, allowing users to add, delete, or revise content. Provides document version controls.'), + 'has_title' => '1', + 'title_label' => t('Title'), + 'help' => '', + ), + ); + return $items; +} diff --git a/modules/commons/commons_wikis/commons_wikis.features.og_features_permission.inc b/modules/commons/commons_wikis/commons_wikis.features.og_features_permission.inc new file mode 100644 index 0000000..aa0cfb0 --- /dev/null +++ b/modules/commons/commons_wikis/commons_wikis.features.og_features_permission.inc @@ -0,0 +1,53 @@ + array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + // Exported og permission: 'node:group:delete any wiki content' + $permissions['node:group:delete any wiki content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + ), + ); + + // Exported og permission: 'node:group:delete own wiki content' + $permissions['node:group:delete own wiki content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + // Exported og permission: 'node:group:update any wiki content' + $permissions['node:group:update any wiki content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + // Exported og permission: 'node:group:update own wiki content' + $permissions['node:group:update own wiki content'] = array( + 'roles' => array( + 'administrator member' => 'administrator member', + 'member' => 'member', + ), + ); + + return $permissions; +} diff --git a/modules/commons/commons_wikis/commons_wikis.features.user_permission.inc b/modules/commons/commons_wikis/commons_wikis.features.user_permission.inc new file mode 100644 index 0000000..456a93f --- /dev/null +++ b/modules/commons/commons_wikis/commons_wikis.features.user_permission.inc @@ -0,0 +1,53 @@ + 'create wiki content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + // Exported permission: 'delete own wiki content'. + $permissions['delete own wiki content'] = array( + 'name' => 'delete own wiki content', + 'roles' => array( + 'administrator' => 'administrator', + ), + 'module' => 'node', + ); + + // Exported permission: 'edit any wiki content'. + $permissions['edit any wiki content'] = array( + 'name' => 'edit any wiki content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + // Exported permission: 'edit own wiki content'. + $permissions['edit own wiki content'] = array( + 'name' => 'edit own wiki content', + 'roles' => array( + 'administrator' => 'administrator', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'node', + ); + + return $permissions; +} diff --git a/modules/commons/commons_wikis/commons_wikis.info b/modules/commons/commons_wikis/commons_wikis.info new file mode 100644 index 0000000..f478856 --- /dev/null +++ b/modules/commons/commons_wikis/commons_wikis.info @@ -0,0 +1,63 @@ +name = Commons Wikis +description = Provides the wiki functionality for Drupal Commons +core = 7.x +package = Commons - Content types +dependencies[] = commons_body +dependencies[] = commons_groups +dependencies[] = commons_topics +dependencies[] = ctools +dependencies[] = entity +dependencies[] = entityreference +dependencies[] = features +dependencies[] = message +dependencies[] = node +dependencies[] = og +dependencies[] = og_ui +dependencies[] = page_manager +dependencies[] = radioactivity +dependencies[] = strongarm +dependencies[] = taxonomy +dependencies[] = text +dependencies[] = views +dependencies[] = views_content +dependencies[] = views_litepager +features[ctools][] = page_manager:pages_default:1 +features[ctools][] = strongarm:strongarm:1 +features[ctools][] = views:views_default:3.0 +features[features_api][] = api:2 +features[field_instance][] = message-commons_wikis_wiki_updated-field_target_nodes +features[field_instance][] = node-wiki-body +features[field_instance][] = node-wiki-title_field +features[message_type][] = commons_wikis_wiki_updated +features[node][] = wiki +features[og_features_permission][] = node:group:create wiki content +features[og_features_permission][] = node:group:delete any wiki content +features[og_features_permission][] = node:group:delete own wiki content +features[og_features_permission][] = node:group:update any wiki content +features[og_features_permission][] = node:group:update own wiki content +features[user_permission][] = create wiki content +features[user_permission][] = delete own wiki content +features[user_permission][] = edit any wiki content +features[user_permission][] = edit own wiki content +features[variable][] = additional_settings__active_tab_wiki +features[variable][] = comment_anonymous_wiki +features[variable][] = comment_default_mode_wiki +features[variable][] = comment_default_per_page_wiki +features[variable][] = comment_form_location_wiki +features[variable][] = comment_preview_wiki +features[variable][] = comment_subject_field_wiki +features[variable][] = comment_wiki +features[variable][] = enable_revisions_page_wiki +features[variable][] = field_bundle_settings_message__commons_wikis_wiki_updated +features[variable][] = field_bundle_settings_node__wiki +features[variable][] = menu_options_wiki +features[variable][] = menu_parent_wiki +features[variable][] = node_options_wiki +features[variable][] = node_preview_wiki +features[variable][] = node_submitted_wiki +features[variable][] = save_continue_wiki +features[variable][] = show_diff_inline_wiki +features[variable][] = show_preview_changes_wiki +features[views_view][] = commons_bw_wikis +features[views_view][] = commons_wikis_contributor_list +features_exclude[dependencies][commons_trusted_contacts] = commons_trusted_contacts diff --git a/modules/commons/commons_wikis/commons_wikis.install b/modules/commons/commons_wikis/commons_wikis.install new file mode 100644 index 0000000..b35cade --- /dev/null +++ b/modules/commons/commons_wikis/commons_wikis.install @@ -0,0 +1,96 @@ + array('field_instance'), + ); + features_revert($revert); + return array(); +} + +/** + * Update Wiki message type to remove error messages. + */ +function commons_wikis_update_7001() { + $revert = array( + 'commons_wikis' => array('message_type', 'variable'), + ); + features_revert($revert); + return array(); +} + +/** + * Update Wiki message type to show user picture as 35x35 image style. + */ +function commons_wikis_update_7002() { + $revert = array( + 'commons_wikis' => array('message_type'), + ); + features_revert($revert); + return array(); +} + +/** + * Place Topics label above terms on Wiki pages. + */ +function commons_wikis_update_7003() { + $revert = array( + 'commons_wikis' => array('field_instance'), + ); + features_revert($revert); + return array(); +} + +/** + * Remove extra markup from message type for wikis. + */ +function commons_wikis_update_7004() { + $revert = array( + 'commons_wikis' => array('message_type'), + ); + features_revert($revert); + return array(); +} + +/** + * Clear views cache to have contributor view use new permission. + */ +function commons_wikis_update_7005() { + cache_clear_all('*', 'cache_views', TRUE); +} + +/** + * Standardize Browsing Widget views. + */ +function commons_wikis_update_7006() { + $revert = array( + 'commons_wikis' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Display sticky content at top of lists. + */ +function commons_wikis_update_7007() { + $revert = array( + 'commons_wikis' => array('views_view'), + ); + features_revert($revert); + return array(); +} + +/** + * Improve the browsing widget empty text. + */ +function commons_wikis_update_7008() { + $revert = array( + 'commons_wikis' => array('views_view'), + ); + features_revert($revert); + return array(); +} diff --git a/modules/commons/commons_wikis/commons_wikis.module b/modules/commons/commons_wikis/commons_wikis.module new file mode 100644 index 0000000..7ba2211 --- /dev/null +++ b/modules/commons/commons_wikis/commons_wikis.module @@ -0,0 +1,234 @@ + array( + 'wiki' => array( + 'auto_title_instance' => FALSE, + 'is_group_content' => TRUE, + ), + ), + ); +} + +/** + * Implements hook_commons_bw_group_widget(). + */ +function commons_wikis_commons_bw_group_widget() { + return array( + 'commons_wikis' => array( + 'title' => t('Wikis'), + 'type' => 'view', + 'vid' => 'commons_bw_wikis', + 'display' => 'default', + 'weight' => 8, + 'bundle' => 'wiki', + ), + ); +} + +/** +* Implements hook_module_implements_alter(). +*/ +function commons_wikis_module_implements_alter(&$implementations, $hook) { + // We need to override access control for revision view callbacks + // in order to give all users permission to view wiki node revisions. + if ($hook == 'menu_alter') { + $group = $implementations['commons_wikis']; + unset($implementations['commons_wikis']); + $implementations['commons_wikis'] = $group; + } +} + +/** + * Implements hook_commons_bw_create_all_widget(). + */ +function commons_wikis_commons_bw_create_all_widget($group) { + if (og_user_access('node', $group->nid, 'create wiki content')) { + $link = l(t('Start a wiki'), 'node/add/wiki', + array('attributes' => array('class' => 'commons-wikis-create'), 'query' => array('og_group_ref' => $group->nid)) + ); + return array( + 'commons_wikis' => array( + 'link' => $link, + 'text' => t('Collaborate on a document'), + '#weight' => 8, + ), + ); + } +} + +/** + * Implements hook_menu_alter(). + */ +function commons_wikis_menu_alter(&$items) { + // Alter the two node menu revision items and change the + // access callback to our custom one. + $items['node/%node/revisions']['access arguments'][] = $items['node/%node/revisions']['access callback']; + $items['node/%node/revisions']['access callback'] = 'commons_wikis_user_revision_access'; + + $items['node/%node/revisions/%/view']['access arguments'][] = $items['node/%node/revisions']['access callback']; + $items['node/%node/revisions/%/view']['access callback'] = 'commons_wikis_user_revision_access'; +} + +/** + * Implements hook_views_default_views_alter(). + * + * Display wikis on the browsing widget main view. + */ +function commons_wikis_views_default_views_alter(&$views) { + if (!empty($views['commons_bw_all'])) { + $views['commons_bw_all']->display['default']->display_options['filters']['type']['value']['wiki'] = 'wiki'; + } +} + +/** + * Custom access callback for viewing revision info. + */ +function commons_wikis_user_revision_access($node = NULL, $old_callback = '_node_revision_access') { + // Only use custom revision access for wikis. Access to other content types + // should be handled by the standard callback. + if ($node->type == 'wiki') { + // The content was posted to specific groups. + if (isset($node->og_group_ref[LANGUAGE_NONE][0]['target_id'])) { + return og_user_access('node', $node->og_group_ref[LANGUAGE_NONE][0]['target_id'], 'update any wiki content'); + } + // The content was posted privately to all trusted contacts. + elseif (isset($node->og_user_group_ref[LANGUAGE_NONE][0]['target_id'])) { + return og_user_access('user', $node->og_user_group_ref[LANGUAGE_NONE][0]['target_id'], 'update any wiki content'); + } + } + return $old_callback($node, 'view'); +} + +/** + * Implements hook_og_user_access_alter(). + */ +function commons_wikis_og_user_access_alter(&$temp_perm, $context) { + // Only alter if we're dealing with updating wiki content. + if ($context['string'] != 'update any wiki content') { + return; + } + + $account = $context['account']; + $group = $context['group']; + $group_type = $context['group_type']; + + $wrapper = entity_metadata_wrapper($group_type, $group); + $entity_id = $wrapper->getIdentifier(); + + $group_content_restricted = (bool) !isset($wrapper->field_og_subscribe_settings) || (isset($wrapper->field_og_subscribe_settings) && $wrapper->field_og_subscribe_settings->value() != 'anyone'); + $user_is_member = (bool) og_is_member($group_type, $entity_id, 'user', $account, array(OG_STATE_ACTIVE)); + + // Allow group members to be able to edit any wiki content within the group. + // Also grant access to non-members if both the group and content is public. + if (user_access('edit any wiki content', $account) && (!$group_content_restricted || $user_is_member)) { + $temp_perm['update any wiki content'] = TRUE; + } +} + +/** + * Implements hook_form_FROM_ID_alter(). + */ +function commons_wikis_form_commons_bw_partial_node_form_alter(&$form, &$form_state) { + if (empty($form['#entity']) || $form['#entity']->type != 'wiki') { + return; + } + + $language = $form['title_field']['#language']; + $form['title_field'][$language][0]['value']['#title_display'] = 'invisible'; + $form['title_field'][$language][0]['value']['#placeholder'] = t('Enter a Wiki title'); + + $language = $form['body']['#language']; + $form['body'][$language][0]['#title_display'] = 'invisible'; + $form['body'][$language][0]['#resizable'] = FALSE; + + // Set fields as hideable so the forms can be compacted. + $form['title_field']['#attributes']['class'][] = 'trigger-field'; + foreach (array('body', 'og_group_ref', 'actions') as $field) { + if (isset($form[$field])) { + $form[$field]['#attributes']['class'][] = 'hideable-field'; + } + } + + $form['actions']['submit']['#value'] = t('Create'); + $form['#pre_render'][] = 'commons_wikis_form_commons_bw_partial_node_form_after_build'; +} + +/** + * After-build call-back. + * See commons_wikis_form_commons_bw_partial_node_form_alter(). + */ +function commons_wikis_form_commons_bw_partial_node_form_after_build($form) { + $language = $form['body']['#language']; + $form['body'][$language][0]['format']['#access'] = FALSE; + $form['body'][$language][0]['value']['#rows'] = 10; + + return $form; +} + +/** + * Implements hook_strongarm_alter(). + */ + function commons_wikis_strongarm_alter(&$items) { + // Expose the wiki content type for 'liking' via the Commons_like module + // by altering the configuration for the Rate.module widget that it provides. + if (!empty($items['rate_widgets']->value)) { + foreach($items['rate_widgets']->value as $key => $widget) { + if ($widget->name == 'commons_like') { + if (!in_array('wiki', $items['rate_widgets']->value[$key]->node_types)) { + $items['rate_widgets']->value[$key]->node_types[] = 'wiki'; + } + if (!in_array('wiki', $items['rate_widgets']->value[$key]->comment_types)) { + $items['rate_widgets']->value[$key]->comment_types[] = 'wiki'; + } + } + } + } + // Expose the wiki content type for integration with Commons Radioactivity + // and Commons Groups. + foreach (array('commons_radioactivity_entity_types', 'commons_groups_entity_types') as $key) { + if (isset($items[$key])) { + $items[$key]->value['node']['wiki'] = 1; + } + } +} + +/** + * Implements hook_node_update(). + */ +function commons_wikis_node_update($node) { + if ($node->type == 'wiki' && module_exists('message')) { + global $user; + commons_groups_first_contribution($user, $node); + $message = message_create('commons_wikis_wiki_updated', array('uid' => $user->uid, 'timestamp' => REQUEST_TIME)); + $wrapper = entity_metadata_wrapper('message', $message); + // Save reference to the node in the node reference field. + // We use a multiple value field in case we wish to use the same + // field for grouping messages in the future + // (eg http://drupal.org/node/1757060). + $wrapper->field_target_nodes[] = $node; + $wrapper->save(); + } +} + +/** + * Implements hook_views_pre_render(). + */ +function commons_wikis_views_pre_render(&$view) { + // Improve the browsing widget empty text when displayed outside of a group. + // TODO: Enable og_context and check group context instead of looking for an + // empty first argument. + if (empty($view->args[0]) && $view->name == 'commons_bw_wikis') { + $view->display_handler->handlers['empty']['area']->options['content'] = t('No wikis have been created.'); + } +} diff --git a/modules/commons/commons_wikis/commons_wikis.strongarm.inc b/modules/commons/commons_wikis/commons_wikis.strongarm.inc new file mode 100644 index 0000000..d76fb68 --- /dev/null +++ b/modules/commons/commons_wikis/commons_wikis.strongarm.inc @@ -0,0 +1,208 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'additional_settings__active_tab_wiki'; + $strongarm->value = 'edit-workflow'; + $export['additional_settings__active_tab_wiki'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_anonymous_wiki'; + $strongarm->value = 0; + $export['comment_anonymous_wiki'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_mode_wiki'; + $strongarm->value = 1; + $export['comment_default_mode_wiki'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_default_per_page_wiki'; + $strongarm->value = '50'; + $export['comment_default_per_page_wiki'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_form_location_wiki'; + $strongarm->value = 1; + $export['comment_form_location_wiki'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_preview_wiki'; + $strongarm->value = '1'; + $export['comment_preview_wiki'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_subject_field_wiki'; + $strongarm->value = 1; + $export['comment_subject_field_wiki'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'comment_wiki'; + $strongarm->value = '2'; + $export['comment_wiki'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'enable_revisions_page_wiki'; + $strongarm->value = 1; + $export['enable_revisions_page_wiki'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_message__commons_wikis_wiki_updated'; + $strongarm->value = array( + 'view_modes' => array(), + 'extra_fields' => array( + 'form' => array(), + 'display' => array( + 'message__message_text__0' => array( + 'message_notify_email_subject' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + ), + 'message__message_text__1' => array( + 'message_notify_email_subject' => array( + 'visible' => FALSE, + 'weight' => 0, + ), + 'message_notify_email_body' => array( + 'visible' => TRUE, + 'weight' => 0, + ), + ), + ), + ), + ); + $export['field_bundle_settings_message__commons_wikis_wiki_updated'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'field_bundle_settings_node__wiki'; + $strongarm->value = array( + 'view_modes' => array( + 'teaser' => array( + 'custom_settings' => TRUE, + ), + 'full' => array( + 'custom_settings' => FALSE, + ), + 'rss' => array( + 'custom_settings' => FALSE, + ), + 'search_index' => array( + 'custom_settings' => FALSE, + ), + 'search_result' => array( + 'custom_settings' => FALSE, + ), + 'token' => array( + 'custom_settings' => FALSE, + ), + ), + 'extra_fields' => array( + 'form' => array( + 'title' => array( + 'weight' => '0', + ), + ), + 'display' => array(), + ), + ); + $export['field_bundle_settings_node__wiki'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_options_wiki'; + $strongarm->value = array( + 0 => 'main-menu', + ); + $export['menu_options_wiki'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'menu_parent_wiki'; + $strongarm->value = 'main-menu:0'; + $export['menu_parent_wiki'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_options_wiki'; + $strongarm->value = array( + 0 => 'status', + 1 => 'revision', + ); + $export['node_options_wiki'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_preview_wiki'; + $strongarm->value = '1'; + $export['node_preview_wiki'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'node_submitted_wiki'; + $strongarm->value = 1; + $export['node_submitted_wiki'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'save_continue_wiki'; + $strongarm->value = 'Save and add fields'; + $export['save_continue_wiki'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'show_diff_inline_wiki'; + $strongarm->value = 0; + $export['show_diff_inline_wiki'] = $strongarm; + + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'show_preview_changes_wiki'; + $strongarm->value = 1; + $export['show_preview_changes_wiki'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_wikis/commons_wikis.views_default.inc b/modules/commons/commons_wikis/commons_wikis.views_default.inc new file mode 100644 index 0000000..3807929 --- /dev/null +++ b/modules/commons/commons_wikis/commons_wikis.views_default.inc @@ -0,0 +1,269 @@ +name = 'commons_bw_wikis'; + $view->description = 'Commons Wikis listing for the group browsing widget.'; + $view->tag = 'Commons Wikis, Commons Browsing Widget'; + $view->base_table = 'node'; + $view->human_name = 'Commons Browsing Widget - Wikis'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_ajax'] = TRUE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'lite'; + $handler->display->display_options['pager']['options']['items_per_page'] = '10'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['pager']['options']['id'] = '4'; + $handler->display->display_options['pager']['options']['quantity'] = '9'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'entity'; + $handler->display->display_options['row_options']['view_mode'] = 'teaser'; + /* Header: Global: Node partial form */ + $handler->display->display_options['header']['commons_bw_node_partial_form']['id'] = 'commons_bw_node_partial_form'; + $handler->display->display_options['header']['commons_bw_node_partial_form']['table'] = 'views'; + $handler->display->display_options['header']['commons_bw_node_partial_form']['field'] = 'commons_bw_node_partial_form'; + $handler->display->display_options['header']['commons_bw_node_partial_form']['bundle'] = 'wiki'; + /* No results behavior: Global: Text area */ + $handler->display->display_options['empty']['area']['id'] = 'area'; + $handler->display->display_options['empty']['area']['table'] = 'views'; + $handler->display->display_options['empty']['area']['field'] = 'area'; + $handler->display->display_options['empty']['area']['empty'] = TRUE; + $handler->display->display_options['empty']['area']['content'] = 'No wikis have been added to this group.'; + $handler->display->display_options['empty']['area']['format'] = 'filtered_html'; + /* Relationship: OG membership: OG membership from Node */ + $handler->display->display_options['relationships']['og_membership_rel']['id'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['table'] = 'node'; + $handler->display->display_options['relationships']['og_membership_rel']['field'] = 'og_membership_rel'; + $handler->display->display_options['relationships']['og_membership_rel']['required'] = TRUE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Field: Content: Body */ + $handler->display->display_options['fields']['body']['id'] = 'body'; + $handler->display->display_options['fields']['body']['table'] = 'field_data_body'; + $handler->display->display_options['fields']['body']['field'] = 'body'; + $handler->display->display_options['fields']['body']['label'] = ''; + $handler->display->display_options['fields']['body']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['body']['type'] = 'text_summary_or_trimmed'; + $handler->display->display_options['fields']['body']['settings'] = array( + 'trim_length' => '600', + ); + /* Field: Content: Comment count */ + $handler->display->display_options['fields']['comment_count']['id'] = 'comment_count'; + $handler->display->display_options['fields']['comment_count']['table'] = 'node_comment_statistics'; + $handler->display->display_options['fields']['comment_count']['field'] = 'comment_count'; + $handler->display->display_options['fields']['comment_count']['label'] = ''; + $handler->display->display_options['fields']['comment_count']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['comment_count']['empty'] = 'No comments'; + $handler->display->display_options['fields']['comment_count']['empty_zero'] = TRUE; + $handler->display->display_options['fields']['comment_count']['hide_alter_empty'] = FALSE; + $handler->display->display_options['fields']['comment_count']['separator'] = ''; + $handler->display->display_options['fields']['comment_count']['suffix'] = ' comments'; + /* Sort criterion: Content: Sticky */ + $handler->display->display_options['sorts']['sticky']['id'] = 'sticky'; + $handler->display->display_options['sorts']['sticky']['table'] = 'node'; + $handler->display->display_options['sorts']['sticky']['field'] = 'sticky'; + $handler->display->display_options['sorts']['sticky']['order'] = 'DESC'; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + $handler->display->display_options['sorts']['created']['exposed'] = TRUE; + $handler->display->display_options['sorts']['created']['expose']['label'] = 'most recent'; + /* Contextual filter: OG membership: Group ID */ + $handler->display->display_options['arguments']['gid']['id'] = 'gid'; + $handler->display->display_options['arguments']['gid']['table'] = 'og_membership'; + $handler->display->display_options['arguments']['gid']['field'] = 'gid'; + $handler->display->display_options['arguments']['gid']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['arguments']['gid']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['gid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['gid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['gid']['summary_options']['items_per_page'] = '25'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'node'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['value'] = array( + 'wiki' => 'wiki', + ); + /* Filter criterion: OG membership: Group_type */ + $handler->display->display_options['filters']['group_type']['id'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['table'] = 'og_membership'; + $handler->display->display_options['filters']['group_type']['field'] = 'group_type'; + $handler->display->display_options['filters']['group_type']['relationship'] = 'og_membership_rel'; + $handler->display->display_options['filters']['group_type']['value'] = array( + 'node' => 'node', + ); + $translatables['commons_bw_wikis'] = array( + t('Master'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('No wikis have been added to this group.'), + t('OG membership from node'), + t('following'), + t('No comments'), + t('.'), + t(' comments'), + t('most recent'), + t('most active'), + t('All'), + t('Following'), + ); + $export['commons_bw_wikis'] = $view; + + $view = new view(); + $view->name = 'commons_wikis_contributor_list'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node_revision'; + $view->human_name = 'Commons Wikis - Contributor List'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Contributors'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['query']['options']['distinct'] = TRUE; + $handler->display->display_options['query']['options']['pure_distinct'] = TRUE; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'some'; + $handler->display->display_options['pager']['options']['items_per_page'] = '4'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* Relationship: Content revision: User */ + $handler->display->display_options['relationships']['uid']['id'] = 'uid'; + $handler->display->display_options['relationships']['uid']['table'] = 'node_revision'; + $handler->display->display_options['relationships']['uid']['field'] = 'uid'; + /* Field: User: Picture */ + $handler->display->display_options['fields']['picture']['id'] = 'picture'; + $handler->display->display_options['fields']['picture']['table'] = 'users'; + $handler->display->display_options['fields']['picture']['field'] = 'picture'; + $handler->display->display_options['fields']['picture']['relationship'] = 'uid'; + $handler->display->display_options['fields']['picture']['label'] = ''; + $handler->display->display_options['fields']['picture']['exclude'] = TRUE; + $handler->display->display_options['fields']['picture']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['picture']['image_style'] = '50x50'; + /* Field: User: Name */ + $handler->display->display_options['fields']['name']['id'] = 'name'; + $handler->display->display_options['fields']['name']['table'] = 'users'; + $handler->display->display_options['fields']['name']['field'] = 'name'; + $handler->display->display_options['fields']['name']['relationship'] = 'uid'; + $handler->display->display_options['fields']['name']['label'] = ''; + $handler->display->display_options['fields']['name']['exclude'] = TRUE; + $handler->display->display_options['fields']['name']['element_label_colon'] = FALSE; + /* Field: User: Uid */ + $handler->display->display_options['fields']['uid']['id'] = 'uid'; + $handler->display->display_options['fields']['uid']['table'] = 'users'; + $handler->display->display_options['fields']['uid']['field'] = 'uid'; + $handler->display->display_options['fields']['uid']['relationship'] = 'uid'; + $handler->display->display_options['fields']['uid']['label'] = ''; + $handler->display->display_options['fields']['uid']['exclude'] = TRUE; + $handler->display->display_options['fields']['uid']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['uid']['link_to_user'] = FALSE; + /* Field: Global: Custom text */ + $handler->display->display_options['fields']['nothing']['id'] = 'nothing'; + $handler->display->display_options['fields']['nothing']['table'] = 'views'; + $handler->display->display_options['fields']['nothing']['field'] = 'nothing'; + $handler->display->display_options['fields']['nothing']['label'] = ''; + $handler->display->display_options['fields']['nothing']['alter']['text'] = '[picture][name]'; + $handler->display->display_options['fields']['nothing']['alter']['make_link'] = TRUE; + $handler->display->display_options['fields']['nothing']['alter']['path'] = 'user/[uid]'; + $handler->display->display_options['fields']['nothing']['alter']['absolute'] = TRUE; + $handler->display->display_options['fields']['nothing']['element_label_colon'] = FALSE; + /* Contextual filter: Content revision: Nid */ + $handler->display->display_options['arguments']['nid']['id'] = 'nid'; + $handler->display->display_options['arguments']['nid']['table'] = 'node_revision'; + $handler->display->display_options['arguments']['nid']['field'] = 'nid'; + $handler->display->display_options['arguments']['nid']['default_action'] = 'empty'; + $handler->display->display_options['arguments']['nid']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25'; + /* Filter criterion: User: Active */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'users'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['relationship'] = 'uid'; + $handler->display->display_options['filters']['status']['value'] = '1'; + + /* Display: Content pane */ + $handler = $view->new_display('panel_pane', 'Content pane', 'commons_wikis_contributor_pane'); + $handler->display->display_options['defaults']['hide_admin_links'] = FALSE; + $handler->display->display_options['pane_category']['name'] = 'Commons'; + $handler->display->display_options['pane_category']['weight'] = '0'; + $handler->display->display_options['argument_input'] = array( + 'nid' => array( + 'type' => 'context', + 'context' => 'entity:node.nid', + 'context_optional' => 0, + 'panel' => '0', + 'fixed' => '', + 'label' => 'Content: Nid', + ), + ); + $translatables['commons_wikis_contributor_list'] = array( + t('Master'), + t('Contributors'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('revision user'), + t('[picture][name]'), + t('All'), + t('Content pane'), + t('Commons'), + ); + $export['commons_wikis_contributor_list'] = $view; + + return $export; +} diff --git a/modules/commons/commons_wikis/modules/commons_wikis_pages/commons_wikis_pages.features.inc b/modules/commons/commons_wikis/modules/commons_wikis_pages/commons_wikis_pages.features.inc new file mode 100644 index 0000000..42d5e2e --- /dev/null +++ b/modules/commons/commons_wikis/modules/commons_wikis_pages/commons_wikis_pages.features.inc @@ -0,0 +1,17 @@ + "1"); + } + if ($module == "strongarm" && $api == "strongarm") { + return array("version" => "1"); + } +} diff --git a/modules/commons/commons_wikis/modules/commons_wikis_pages/commons_wikis_pages.info b/modules/commons/commons_wikis/modules/commons_wikis_pages/commons_wikis_pages.info new file mode 100644 index 0000000..79e7c9a --- /dev/null +++ b/modules/commons/commons_wikis/modules/commons_wikis_pages/commons_wikis_pages.info @@ -0,0 +1,13 @@ +name = Commons Wikis Home +description = Provides the panelizer feature for Wikis. +core = 7.x +package = Commons - Landing pages +dependencies[] = commons_wikis +dependencies[] = ctools +dependencies[] = panelizer +dependencies[] = strongarm +features[ctools][] = panelizer:panelizer:1 +features[ctools][] = strongarm:strongarm:1 +features[features_api][] = api:2 +features[panelizer_defaults][] = node:wiki:default +features[variable][] = panelizer_defaults_node_wiki diff --git a/modules/commons/commons_wikis/modules/commons_wikis_pages/commons_wikis_pages.install b/modules/commons/commons_wikis/modules/commons_wikis_pages/commons_wikis_pages.install new file mode 100644 index 0000000..b1b9659 --- /dev/null +++ b/modules/commons/commons_wikis/modules/commons_wikis_pages/commons_wikis_pages.install @@ -0,0 +1,12 @@ + array('panelizer_defaults'), + ); + features_revert($revert); + return array(); +} \ No newline at end of file diff --git a/modules/commons/commons_wikis/modules/commons_wikis_pages/commons_wikis_pages.module b/modules/commons/commons_wikis/modules/commons_wikis_pages/commons_wikis_pages.module new file mode 100644 index 0000000..77fae1e --- /dev/null +++ b/modules/commons/commons_wikis/modules/commons_wikis_pages/commons_wikis_pages.module @@ -0,0 +1,7 @@ +disabled = FALSE; /* Edit this to true to make a default panelizer disabled initially */ + $panelizer->api_version = 1; + $panelizer->name = 'node:wiki:default'; + $panelizer->title = 'Default'; + $panelizer->panelizer_type = 'node'; + $panelizer->panelizer_key = 'wiki'; + $panelizer->no_blocks = FALSE; + $panelizer->css_id = ''; + $panelizer->css = ''; + $panelizer->pipeline = 'ipe'; + $panelizer->contexts = array(); + $panelizer->relationships = array(); + $panelizer->access = ''; + $panelizer->view_mode = ''; + $panelizer->css_class = ''; + $panelizer->title_element = 'H2'; + $panelizer->link_to_entity = TRUE; + $panelizer->extra = ''; + $display = new panels_display(); + $display->layout = 'two_66_33'; + $display->layout_settings = array(); + $display->panel_settings = array( + 'style_settings' => array( + 'default' => NULL, + 'center' => NULL, + 'two_66_33_top' => NULL, + 'two_66_33_first' => NULL, + 'two_66_33_second' => NULL, + 'two_66_33_bottom' => NULL, + ), + ); + $display->cache = array(); + $display->title = '%node:title'; + $display->uuid = 'bc4d1b4e-c149-dbf4-c1d9-20655cf95f31'; + $display->content = array(); + $display->panels = array(); + $pane = new stdClass(); + $pane->pid = 'new-8006578b-1091-e734-6d38-3c6a8052ccbd'; + $pane->panel = 'two_66_33_first'; + $pane->type = 'node_content'; + $pane->subtype = 'node_content'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'links' => 1, + 'no_extras' => 0, + 'override_title' => 0, + 'override_title_text' => '', + 'identifier' => '', + 'link' => 0, + 'leave_node_title' => 0, + 'build_mode' => 'full', + 'context' => 'panelizer', + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = '8006578b-1091-e734-6d38-3c6a8052ccbd'; + $display->content['new-8006578b-1091-e734-6d38-3c6a8052ccbd'] = $pane; + $display->panels['two_66_33_first'][0] = 'new-8006578b-1091-e734-6d38-3c6a8052ccbd'; + $pane = new stdClass(); + $pane->pid = 'new-bab0455d-e26a-6974-bd77-1e04bb5aece9'; + $pane->panel = 'two_66_33_second'; + $pane->type = 'views_panes'; + $pane->subtype = 'commons_wikis_contributor_list-commons_wikis_contributor_pane'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'context' => array( + 0 => 'panelizer', + ), + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = 'bab0455d-e26a-6974-bd77-1e04bb5aece9'; + $display->content['new-bab0455d-e26a-6974-bd77-1e04bb5aece9'] = $pane; + $display->panels['two_66_33_second'][0] = 'new-bab0455d-e26a-6974-bd77-1e04bb5aece9'; + $display->hide_title = PANELS_TITLE_FIXED; + $display->title_pane = '0'; + $panelizer->display = $display; + $export['node:wiki:default'] = $panelizer; + + return $export; +} diff --git a/modules/commons/commons_wikis/modules/commons_wikis_pages/commons_wikis_pages.strongarm.inc b/modules/commons/commons_wikis/modules/commons_wikis_pages/commons_wikis_pages.strongarm.inc new file mode 100644 index 0000000..7790003 --- /dev/null +++ b/modules/commons/commons_wikis/modules/commons_wikis_pages/commons_wikis_pages.strongarm.inc @@ -0,0 +1,25 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'panelizer_defaults_node_wiki'; + $strongarm->value = array( + 'status' => 1, + 'default' => 1, + 'choice' => 0, + ); + $export['panelizer_defaults_node_wiki'] = $strongarm; + + return $export; +} diff --git a/modules/commons/commons_wysiwyg/commons_wysiwyg.features.ckeditor_profile.inc b/modules/commons/commons_wysiwyg/commons_wysiwyg.features.ckeditor_profile.inc new file mode 100644 index 0000000..9974e8a --- /dev/null +++ b/modules/commons/commons_wysiwyg/commons_wysiwyg.features.ckeditor_profile.inc @@ -0,0 +1,77 @@ + array( + 'name' => 'Advanced', + 'settings' => array( + 'ss' => 2, + 'default' => 't', + 'show_toggle' => 't', + 'uicolor' => 'default', + 'uicolor_user' => 'default', + 'toolbar' => '[ + [\'Format\'],[\'Bold\',\'Italic\',\'Strike\'],[\'NumberedList\',\'BulletedList\',\'Indent\',\'Outdent\',\'Blockquote\'],[\'Link\',\'Unlink\',\'Image\'] +]', + 'expand' => 't', + 'width' => '100%', + 'lang' => 'en', + 'auto_lang' => 't', + 'language_direction' => 'default', + 'enter_mode' => 'p', + 'shift_enter_mode' => 'br', + 'font_format' => 'p;div;pre;address;h1;h2;h3;h4;h5;h6', + 'custom_formatting' => 'f', + 'formatting' => array( + 'custom_formatting_options' => array( + 'indent' => 'indent', + 'breakBeforeOpen' => 'breakBeforeOpen', + 'breakAfterOpen' => 'breakAfterOpen', + 'breakAfterClose' => 'breakAfterClose', + 'breakBeforeClose' => 0, + 'pre_indent' => 0, + ), + ), + 'css_mode' => 'theme', + 'css_path' => '', + 'css_style' => 'theme', + 'styles_path' => '', + 'filebrowser' => 'none', + 'filebrowser_image' => '', + 'filebrowser_flash' => '', + 'UserFilesPath' => '%b%f/', + 'UserFilesAbsolutePath' => '%d%b%f/', + 'forcePasteAsPlainText' => 'f', + 'html_entities' => 'f', + 'scayt_autoStartup' => 'f', + 'theme_config_js' => 'f', + 'js_conf' => '', + 'loadPlugins' => array( + 'drupalbreaks' => array( + 'name' => 'drupalbreaks', + 'desc' => 'Plugin for inserting Drupal teaser and page breaks.', + 'path' => '%plugin_dir%drupalbreaks/', + 'buttons' => array( + 'DrupalBreak' => array( + 'label' => 'DrupalBreak', + 'icon' => 'images/drupalbreak.png', + ), + ), + 'default' => 't', + ), + ), + ), + 'input_formats' => array( + 'filtered_html' => 'Filtered HTML', + ), + ), + ); + return $data; +} diff --git a/modules/commons/commons_wysiwyg/commons_wysiwyg.features.filter.inc b/modules/commons/commons_wysiwyg/commons_wysiwyg.features.filter.inc new file mode 100644 index 0000000..2ef3661 --- /dev/null +++ b/modules/commons/commons_wysiwyg/commons_wysiwyg.features.filter.inc @@ -0,0 +1,44 @@ + 'filtered_html', + 'name' => 'Filtered HTML', + 'cache' => 1, + 'status' => 1, + 'weight' => 0, + 'filters' => array( + 'filter_html' => array( + 'weight' => 1, + 'status' => 1, + 'settings' => array( + 'allowed_html' => '

        1. ', + 'filter_html_help' => 1, + 'filter_html_nofollow' => 0, + ), + ), + ), + ); + + // Exported format: Full HTML. + $formats['full_html'] = array( + 'format' => 'full_html', + 'name' => 'Full HTML', + 'cache' => 1, + 'status' => 1, + 'weight' => 1, + 'filters' => array(), + ); + + return $formats; +} diff --git a/modules/commons/commons_wysiwyg/commons_wysiwyg.features.inc b/modules/commons/commons_wysiwyg/commons_wysiwyg.features.inc new file mode 100644 index 0000000..05a4b04 --- /dev/null +++ b/modules/commons/commons_wysiwyg/commons_wysiwyg.features.inc @@ -0,0 +1,3 @@ + 'use text format filtered_html', + 'roles' => array( + 'administrator' => 'administrator', + 'anonymous user' => 'anonymous user', + 'authenticated user' => 'authenticated user', + ), + 'module' => 'filter', + ); + + return $permissions; +} diff --git a/modules/commons/commons_wysiwyg/commons_wysiwyg.info b/modules/commons/commons_wysiwyg/commons_wysiwyg.info new file mode 100644 index 0000000..a4e5358 --- /dev/null +++ b/modules/commons/commons_wysiwyg/commons_wysiwyg.info @@ -0,0 +1,13 @@ +name = Commons WYSIWYG +description = Provides a rich text editor for content creation. +core = 7.x +package = Commons - Building blocks +dependencies[] = ckeditor +dependencies[] = features +dependencies[] = filter +dependencies[] = strongarm +features[ckeditor_profile][] = Advanced +features[features_api][] = api:2 +features[filter][] = filtered_html +features[filter][] = full_html +features[user_permission][] = use text format filtered_html diff --git a/modules/commons/commons_wysiwyg/commons_wysiwyg.install b/modules/commons/commons_wysiwyg/commons_wysiwyg.install new file mode 100644 index 0000000..01e80d9 --- /dev/null +++ b/modules/commons/commons_wysiwyg/commons_wysiwyg.install @@ -0,0 +1,25 @@ + array('ckeditor_profile'), + ); + features_revert($revert); + return array(); +} + +/** + * Update our CKEditor profile to help resolve issues editing + * text areas on iPad per https://drupal.org/node/2030087. + */ +function commons_wysiwyg_update_3101() { + $revert = array( + 'commons_wysiwyg' => array('ckeditor_profile'), + ); + features_revert($revert); + return array(); +} diff --git a/modules/commons/commons_wysiwyg/commons_wysiwyg.module b/modules/commons/commons_wysiwyg/commons_wysiwyg.module new file mode 100644 index 0000000..98f2347 --- /dev/null +++ b/modules/commons/commons_wysiwyg/commons_wysiwyg.module @@ -0,0 +1,22 @@ +