community_engine 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +15 -0
- data/.gitmodules +0 -0
- data/.travis.yml +9 -0
- data/CHANGELOG +118 -0
- data/Gemfile +3 -0
- data/LICENSE +30 -0
- data/README.markdown +188 -0
- data/Rakefile +54 -0
- data/UPGRADING.markdown +93 -0
- data/about.yml +7 -0
- data/app/assets/images/auth/facebook_32.png +0 -0
- data/app/assets/images/auth/facebook_64.png +0 -0
- data/app/assets/images/auth/google_32.png +0 -0
- data/app/assets/images/auth/google_64.png +0 -0
- data/app/assets/images/auth/linked_in_32.png +0 -0
- data/app/assets/images/auth/linked_in_64.png +0 -0
- data/app/assets/images/auth/open_id_32.png +0 -0
- data/app/assets/images/auth/remove.png +0 -0
- data/app/assets/images/auth/twitter_32.png +0 -0
- data/app/assets/images/auth/twitter_64.png +0 -0
- data/app/assets/images/bg_h6btn.gif +0 -0
- data/app/assets/images/bg_navbar.gif +0 -0
- data/app/assets/images/clearbits/bg_rounded.gif +0 -0
- data/app/assets/images/clearbits/comment.gif +0 -0
- data/app/assets/images/clearbits/lock.gif +0 -0
- data/app/assets/images/clearbits/smile.gif +0 -0
- data/app/assets/images/close.gif +0 -0
- data/app/assets/images/cropper/marqueeHoriz.gif +0 -0
- data/app/assets/images/cropper/marqueeVert.gif +0 -0
- data/app/assets/images/feed.png +0 -0
- data/app/assets/images/icon_missing_medium.gif +0 -0
- data/app/assets/images/icon_missing_thumb.gif +0 -0
- data/app/assets/images/icons/31.png +0 -0
- data/app/assets/images/icons/52.png +0 -0
- data/app/assets/images/icons/accept.png +0 -0
- data/app/assets/images/icons/activity_default.png +0 -0
- data/app/assets/images/icons/add.png +0 -0
- data/app/assets/images/icons/book.png +0 -0
- data/app/assets/images/icons/bullet_arrow_down.png +0 -0
- data/app/assets/images/icons/bullet_arrow_down_50.png +0 -0
- data/app/assets/images/icons/clipping.png +0 -0
- data/app/assets/images/icons/comment.png +0 -0
- data/app/assets/images/icons/comments.png +0 -0
- data/app/assets/images/icons/date.png +0 -0
- data/app/assets/images/icons/delete.png +0 -0
- data/app/assets/images/icons/email.png +0 -0
- data/app/assets/images/icons/email_edit.png +0 -0
- data/app/assets/images/icons/email_go.png +0 -0
- data/app/assets/images/icons/email_open.png +0 -0
- data/app/assets/images/icons/group_go.png +0 -0
- data/app/assets/images/icons/heart.png +0 -0
- data/app/assets/images/icons/heart_add.png +0 -0
- data/app/assets/images/icons/heart_off.png +0 -0
- data/app/assets/images/icons/ical.gif +0 -0
- data/app/assets/images/icons/page_white.png +0 -0
- data/app/assets/images/icons/page_white_magnify.png +0 -0
- data/app/assets/images/icons/picture.png +0 -0
- data/app/assets/images/icons/poll.png +0 -0
- data/app/assets/images/icons/post.png +0 -0
- data/app/assets/images/icons/printer.png +0 -0
- data/app/assets/images/icons/rss.png +0 -0
- data/app/assets/images/icons/slides.png +0 -0
- data/app/assets/images/icons/tag_blue.png +0 -0
- data/app/assets/images/icons/user.png +0 -0
- data/app/assets/images/icons/user_add.png +0 -0
- data/app/assets/images/icons/user_edit.png +0 -0
- data/app/assets/images/icons/user_go.png +0 -0
- data/app/assets/images/icons/vote.png +0 -0
- data/app/assets/images/icons/world.png +0 -0
- data/app/assets/images/icons/wrench.png +0 -0
- data/app/assets/images/logo.gif +0 -0
- data/app/assets/images/reply_background.png +0 -0
- data/app/assets/images/search.gif +0 -0
- data/app/assets/images/spinner.gif +0 -0
- data/app/assets/images/spinner_black.gif +0 -0
- data/app/assets/images/spinner_bounce.gif +0 -0
- data/app/assets/images/swf/choose.png +0 -0
- data/app/assets/images/swf/line_grapher.swf +0 -0
- data/app/assets/images/swf/swfupload.swf +0 -0
- data/app/assets/images/thumb.gif +0 -0
- data/app/assets/javascripts/builder.js +136 -0
- data/app/assets/javascripts/calendarview.js +839 -0
- data/app/assets/javascripts/community_engine.js +20 -0
- data/app/assets/javascripts/cropper.css +182 -0
- data/app/assets/javascripts/cropper.js +566 -0
- data/app/assets/javascripts/forum.js +73 -0
- data/app/assets/javascripts/lightbox.js +151 -0
- data/app/assets/javascripts/prototip-min.js +27 -0
- data/app/assets/javascripts/rails.js +202 -0
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/css/advimage.css +84 -0
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/editor_plugin.js +52 -0
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/editor_plugin_src.js +45 -0
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/image.htm +180 -0
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/img/sample.gif +0 -0
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/js/functions.js +508 -0
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/langs/en.js +3 -0
- data/app/assets/javascripts/tinymce/plugins/curblyadvimage/langs/en_dlg.js +43 -0
- data/app/assets/stylesheets/community_engine.css +6 -0
- data/app/assets/stylesheets/forum.css +605 -0
- data/app/assets/stylesheets/lightbox.css +38 -0
- data/app/assets/stylesheets/prototip.css +73 -0
- data/app/assets/stylesheets/reset-fonts-grids.css +8 -0
- data/app/assets/stylesheets/screen.css +977 -0
- data/app/controllers/activities_controller.rb +38 -0
- data/app/controllers/admin_controller.rb +80 -0
- data/app/controllers/ads_controller.rb +85 -0
- data/app/controllers/albums_controller.rb +106 -0
- data/app/controllers/authorizations_controller.rb +41 -0
- data/app/controllers/base_controller.rb +151 -0
- data/app/controllers/categories_controller.rb +118 -0
- data/app/controllers/clippings_controller.rb +192 -0
- data/app/controllers/comment_sweeper.rb +35 -0
- data/app/controllers/comments_controller.rb +179 -0
- data/app/controllers/event_sweeper.rb +24 -0
- data/app/controllers/events_controller.rb +173 -0
- data/app/controllers/favorite_sweeper.rb +29 -0
- data/app/controllers/favorites_controller.rb +36 -0
- data/app/controllers/forums_controller.rb +71 -0
- data/app/controllers/friendships_controller.rb +126 -0
- data/app/controllers/homepage_features_controller.rb +68 -0
- data/app/controllers/invitations_controller.rb +46 -0
- data/app/controllers/messages_controller.rb +95 -0
- data/app/controllers/metro_areas_controller.rb +68 -0
- data/app/controllers/moderators_controller.rb +26 -0
- data/app/controllers/monitorships_controller.rb +20 -0
- data/app/controllers/page_sweeper.rb +33 -0
- data/app/controllers/pages_controller.rb +70 -0
- data/app/controllers/password_resets_controller.rb +52 -0
- data/app/controllers/photo_manager_controller.rb +11 -0
- data/app/controllers/photos_controller.rb +189 -0
- data/app/controllers/post_sweeper.rb +36 -0
- data/app/controllers/posts_controller.rb +252 -0
- data/app/controllers/rsvps_controller.rb +77 -0
- data/app/controllers/sb_posts_controller.rb +149 -0
- data/app/controllers/sessions_controller.rb +34 -0
- data/app/controllers/sitemap_controller.rb +21 -0
- data/app/controllers/statistics_controller.rb +34 -0
- data/app/controllers/taggable_sweeper.rb +38 -0
- data/app/controllers/tags_controller.rb +104 -0
- data/app/controllers/theme_controller.rb +60 -0
- data/app/controllers/topics_controller.rb +122 -0
- data/app/controllers/users_controller.rb +426 -0
- data/app/controllers/vote_sweeper.rb +16 -0
- data/app/controllers/votes_controller.rb +24 -0
- data/app/helpers/base_helper.rb +290 -0
- data/app/helpers/forums_helper.rb +31 -0
- data/app/helpers/friendships_helper.rb +16 -0
- data/app/helpers/monitorships_helper.rb +2 -0
- data/app/helpers/posts_helper.rb +17 -0
- data/app/helpers/sitemap_helper.rb +7 -0
- data/app/helpers/users_helper.rb +6 -0
- data/app/models/ad.rb +43 -0
- data/app/models/album.rb +12 -0
- data/app/models/asset.rb +3 -0
- data/app/models/authorization.rb +60 -0
- data/app/models/category.rb +20 -0
- data/app/models/choice.rb +13 -0
- data/app/models/clipping.rb +78 -0
- data/app/models/clipping_image.rb +9 -0
- data/app/models/comment.rb +122 -0
- data/app/models/country.rb +24 -0
- data/app/models/event.rb +61 -0
- data/app/models/facebook_profile.rb +32 -0
- data/app/models/facebook_publisher.rb +45 -0
- data/app/models/favorite.rb +47 -0
- data/app/models/forum.rb +22 -0
- data/app/models/friendship.rb +64 -0
- data/app/models/friendship_status.rb +3 -0
- data/app/models/homepage_feature.rb +15 -0
- data/app/models/invitation.rb +36 -0
- data/app/models/message.rb +84 -0
- data/app/models/message_thread.rb +33 -0
- data/app/models/metro_area.rb +16 -0
- data/app/models/moderatorship.rb +8 -0
- data/app/models/monitorship.rb +6 -0
- data/app/models/page.rb +8 -0
- data/app/models/photo.rb +83 -0
- data/app/models/poll.rb +39 -0
- data/app/models/post.rb +201 -0
- data/app/models/role.rb +5 -0
- data/app/models/rsvp.rb +24 -0
- data/app/models/sb_post.rb +67 -0
- data/app/models/state.rb +4 -0
- data/app/models/topic.rb +72 -0
- data/app/models/twitter_profile.rb +20 -0
- data/app/models/user.rb +483 -0
- data/app/models/user_notifier.rb +140 -0
- data/app/models/user_session.rb +14 -0
- data/app/models/vote.rb +19 -0
- data/app/views/activities/_activity.html.haml +56 -0
- data/app/views/activities/_icon.html.haml +14 -0
- data/app/views/activities/_unhandled_item.html.haml +1 -0
- data/app/views/activities/destroy.js.rjs +1 -0
- data/app/views/activities/index.html.haml +16 -0
- data/app/views/activities/network.html.haml +14 -0
- data/app/views/admin/comments.html.haml +71 -0
- data/app/views/admin/events.html.haml +33 -0
- data/app/views/admin/messages.html.haml +4 -0
- data/app/views/admin/users.html.haml +69 -0
- data/app/views/ads/edit.html.haml +46 -0
- data/app/views/ads/index.html.haml +43 -0
- data/app/views/ads/new.html.haml +44 -0
- data/app/views/ads/show.html.haml +36 -0
- data/app/views/albums/_form.html.haml +14 -0
- data/app/views/albums/edit.html.haml +16 -0
- data/app/views/albums/new.html.haml +15 -0
- data/app/views/albums/show.html.haml +32 -0
- data/app/views/base/_homepage_banner_message.html.haml +19 -0
- data/app/views/base/advertise.html.haml +8 -0
- data/app/views/base/plaxo.html.haml +5 -0
- data/app/views/base/site_index.html.haml +35 -0
- data/app/views/categories/_tips.html.haml +11 -0
- data/app/views/categories/edit.html.haml +34 -0
- data/app/views/categories/index.html.haml +30 -0
- data/app/views/categories/new.html.haml +9 -0
- data/app/views/categories/show.html.haml +45 -0
- data/app/views/clippings/_clipping.html.haml +18 -0
- data/app/views/clippings/_images.html.haml +3 -0
- data/app/views/clippings/_meta.html.haml +26 -0
- data/app/views/clippings/edit.html.haml +26 -0
- data/app/views/clippings/index.html.haml +35 -0
- data/app/views/clippings/load_images_from_uri.js.rjs +1 -0
- data/app/views/clippings/new.html.haml +29 -0
- data/app/views/clippings/new_clipping.html.haml +91 -0
- data/app/views/clippings/show.html.haml +56 -0
- data/app/views/clippings/site_index.html.haml +34 -0
- data/app/views/comments/_comment.html.haml +42 -0
- data/app/views/comments/_comment_form.html.haml +50 -0
- data/app/views/comments/_edit_form.html.haml +29 -0
- data/app/views/comments/create.js.rjs +20 -0
- data/app/views/comments/edit.js.rjs +7 -0
- data/app/views/comments/index.html.haml +23 -0
- data/app/views/comments/update.js.rjs +9 -0
- data/app/views/events/_event.html.haml +32 -0
- data/app/views/events/_subscribe.html.haml +7 -0
- data/app/views/events/edit.html.haml +34 -0
- data/app/views/events/index.html.haml +22 -0
- data/app/views/events/new.html.haml +32 -0
- data/app/views/events/show.html.haml +29 -0
- data/app/views/facebook/_fb_require.html.haml +11 -0
- data/app/views/favorites/_favorite.html.haml +5 -0
- data/app/views/favorites/create.js.rjs +17 -0
- data/app/views/favorites/destroy.js.rjs +14 -0
- data/app/views/favorites/index.html.haml +10 -0
- data/app/views/favorites/show.html.haml +13 -0
- data/app/views/forums/_form.html.haml +21 -0
- data/app/views/forums/edit.html.haml +11 -0
- data/app/views/forums/index.html.haml +70 -0
- data/app/views/forums/new.html.haml +9 -0
- data/app/views/forums/show.html.haml +85 -0
- data/app/views/friendships/_friendship.html.haml +16 -0
- data/app/views/friendships/_friendships.html.erb +14 -0
- data/app/views/friendships/accepted.html.haml +13 -0
- data/app/views/friendships/denied.html.haml +8 -0
- data/app/views/friendships/index.html.erb +3 -0
- data/app/views/friendships/index.xml.builder +29 -0
- data/app/views/friendships/pending.html.haml +7 -0
- data/app/views/friendships/show.html.haml +12 -0
- data/app/views/homepage_features/edit.html.haml +31 -0
- data/app/views/homepage_features/index.html.haml +30 -0
- data/app/views/homepage_features/new.html.haml +30 -0
- data/app/views/homepage_features/show.html.haml +29 -0
- data/app/views/invitations/index.html.erb +16 -0
- data/app/views/invitations/new.html.haml +33 -0
- data/app/views/layouts/application.html.haml +59 -0
- data/app/views/messages/_form.html.haml +24 -0
- data/app/views/messages/_inbox.html.haml +41 -0
- data/app/views/messages/_sent.html.haml +34 -0
- data/app/views/messages/_sidebar_nav.html.haml +9 -0
- data/app/views/messages/index.html.haml +8 -0
- data/app/views/messages/new.html.haml +10 -0
- data/app/views/messages/show.html.haml +40 -0
- data/app/views/metro_areas/edit.html.haml +16 -0
- data/app/views/metro_areas/index.html.haml +28 -0
- data/app/views/metro_areas/new.html.haml +16 -0
- data/app/views/metro_areas/show.html.haml +22 -0
- data/app/views/moderators/_toggle.html.erb +14 -0
- data/app/views/moderators/create.js.rjs +5 -0
- data/app/views/moderators/destroy.js.rjs +1 -0
- data/app/views/monitorships/create.js.rjs +4 -0
- data/app/views/monitorships/destroy.js.rjs +4 -0
- data/app/views/pages/_form.html.haml +25 -0
- data/app/views/pages/edit.html.haml +16 -0
- data/app/views/pages/edit.html.haml~ +16 -0
- data/app/views/pages/index.html.haml +34 -0
- data/app/views/pages/index.html.haml~ +28 -0
- data/app/views/pages/new.html.haml +14 -0
- data/app/views/pages/show.html.haml +8 -0
- data/app/views/pages/show.html.haml~ +6 -0
- data/app/views/password_resets/edit.html.haml +16 -0
- data/app/views/password_resets/new.html.haml +13 -0
- data/app/views/photo_manager/index.html.haml +49 -0
- data/app/views/photos/_manage_photos.html.haml +14 -0
- data/app/views/photos/_show_image_list.html.haml +24 -0
- data/app/views/photos/edit.html.haml +39 -0
- data/app/views/photos/index.html.haml +28 -0
- data/app/views/photos/index.xml.builder +9 -0
- data/app/views/photos/manage_photos.js.rjs +5 -0
- data/app/views/photos/new.html.haml +51 -0
- data/app/views/photos/recent.html.haml +8 -0
- data/app/views/photos/show.html.haml +53 -0
- data/app/views/polls/_edit.html.haml +15 -0
- data/app/views/polls/_excerpt.html.haml +4 -0
- data/app/views/polls/_new.html.haml +10 -0
- data/app/views/polls/_poll_ui.html.haml +37 -0
- data/app/views/polls/_polls_sidebar.html.haml +8 -0
- data/app/views/posts/_author_profile.html.haml +21 -0
- data/app/views/posts/_favorited_post.html.haml +10 -0
- data/app/views/posts/_post.html.haml +29 -0
- data/app/views/posts/_send_to_friend.html.erb +29 -0
- data/app/views/posts/_sidebar_post.html.haml +1 -0
- data/app/views/posts/edit.html.haml +48 -0
- data/app/views/posts/featured.html.haml +19 -0
- data/app/views/posts/index.html.haml +23 -0
- data/app/views/posts/manage.html.haml +66 -0
- data/app/views/posts/new.html.haml +67 -0
- data/app/views/posts/popular.html.haml +35 -0
- data/app/views/posts/preview.html.haml +27 -0
- data/app/views/posts/recent.html.haml +29 -0
- data/app/views/posts/show.html.haml +85 -0
- data/app/views/rsvps/edit.html.haml +9 -0
- data/app/views/rsvps/new.html.haml +9 -0
- data/app/views/sb_posts/_dummy_forum_post.html.erb +13 -0
- data/app/views/sb_posts/_edit.html.erb +31 -0
- data/app/views/sb_posts/_post.xml.builder +10 -0
- data/app/views/sb_posts/_reply_form.html.haml +37 -0
- data/app/views/sb_posts/_sb_post.html.haml +34 -0
- data/app/views/sb_posts/create.js.rjs +16 -0
- data/app/views/sb_posts/edit.html.erb +13 -0
- data/app/views/sb_posts/edit.js.rjs +6 -0
- data/app/views/sb_posts/index.html.haml +55 -0
- data/app/views/sb_posts/index.xml.builder +20 -0
- data/app/views/sb_posts/monitored.html.erb +55 -0
- data/app/views/sb_posts/monitored.xml.builder +15 -0
- data/app/views/sb_posts/update.js.rjs +5 -0
- data/app/views/sessions/new.html.haml +27 -0
- data/app/views/shared/_admin_nav.html.haml +19 -0
- data/app/views/shared/_bio_help.html.haml +4 -0
- data/app/views/shared/_box.html.haml +3 -0
- data/app/views/shared/_contact.html.haml +5 -0
- data/app/views/shared/_explore.html.haml +9 -0
- data/app/views/shared/_footer_content.html.haml +13 -0
- data/app/views/shared/_header.html.haml +42 -0
- data/app/views/shared/_location_chooser.html.haml +21 -0
- data/app/views/shared/_login_sidebar.html.haml +14 -0
- data/app/views/shared/_messages.html.haml +8 -0
- data/app/views/shared/_scripts_and_styles.html.haml +12 -0
- data/app/views/shared/_user_menu.html.haml +21 -0
- data/app/views/sitemap/index.html.haml +21 -0
- data/app/views/sitemap/index.xml.builder +28 -0
- data/app/views/statistics/activities.xml.builder +33 -0
- data/app/views/statistics/index.html.haml +56 -0
- data/app/views/tags/edit.html.haml +19 -0
- data/app/views/tags/index.html.haml +25 -0
- data/app/views/tags/manage.html.haml +37 -0
- data/app/views/tags/show.html.haml +65 -0
- data/app/views/topics/_form.html.haml +28 -0
- data/app/views/topics/_recent_topics_sidebar.haml +22 -0
- data/app/views/topics/edit.html.haml +10 -0
- data/app/views/topics/new.html.haml +21 -0
- data/app/views/topics/show.html.haml +107 -0
- data/app/views/topics/show.xml.builder +15 -0
- data/app/views/user_notifier/activation.text.erb +11 -0
- data/app/views/user_notifier/comment_notice.text.erb +8 -0
- data/app/views/user_notifier/follow_up_comment_notice.text.erb +15 -0
- data/app/views/user_notifier/follow_up_comment_notice_anonymous.text.erb +18 -0
- data/app/views/user_notifier/forgot_username.text.erb +8 -0
- data/app/views/user_notifier/friendship_accepted.text.erb +8 -0
- data/app/views/user_notifier/friendship_request.text.erb +8 -0
- data/app/views/user_notifier/message_notification.text.erb +14 -0
- data/app/views/user_notifier/new_forum_post_notice.text.erb +14 -0
- data/app/views/user_notifier/password_reset_instructions.text.erb +10 -0
- data/app/views/user_notifier/post_recommendation.text.erb +32 -0
- data/app/views/user_notifier/signup_invitation.text.erb +14 -0
- data/app/views/user_notifier/signup_notification.text.erb +16 -0
- data/app/views/users/_dashboard_nav.html.haml +40 -0
- data/app/views/users/_omniauth_connect.html.haml +21 -0
- data/app/views/users/_profile_completeness.html.haml +21 -0
- data/app/views/users/_profile_user_info_sidebar.html.haml +50 -0
- data/app/views/users/_search_options.html.haml +10 -0
- data/app/views/users/_sidebar_user.html.haml +8 -0
- data/app/views/users/_user.html.haml +31 -0
- data/app/views/users/crop_profile_photo.html.haml +40 -0
- data/app/views/users/dashboard.html.haml +44 -0
- data/app/views/users/edit.html.haml +75 -0
- data/app/views/users/edit_account.html.haml +64 -0
- data/app/views/users/forgot_username.html.haml +13 -0
- data/app/views/users/index.html.haml +18 -0
- data/app/views/users/invite.html.haml +31 -0
- data/app/views/users/new.html.haml +54 -0
- data/app/views/users/resend_activation.html.haml +13 -0
- data/app/views/users/show.html.haml +103 -0
- data/app/views/users/signup_completed.html.haml +8 -0
- data/app/views/users/statistics.html.haml +28 -0
- data/app/views/users/upload_profile_photo.html.haml +15 -0
- data/app/views/users/welcome_about.html.haml +66 -0
- data/app/views/users/welcome_invite.html.haml +33 -0
- data/app/views/users/welcome_photo.html.haml +29 -0
- data/app/views/votes/create.js.rjs +6 -0
- data/community_engine.gemspec +55 -0
- data/config/application_config.rb +162 -0
- data/config/initializers/cropper.rb +19 -0
- data/config/initializers/mce_options.rb +40 -0
- data/config/initializers/recaptcha_constants.rb +6 -0
- data/config/initializers/white_list.rb +7 -0
- data/config/locales/de-DE.yml +1271 -0
- data/config/locales/en.yml +1658 -0
- data/config/locales/es-AR.yml +758 -0
- data/config/locales/es-ES.yml +340 -0
- data/config/locales/es-MX.yml +672 -0
- data/config/locales/fr-FR.yml +1509 -0
- data/config/locales/ja-JP.yml +1321 -0
- data/config/locales/ru-RU.yml +97 -0
- data/config/locales/sr-CP.yml +89 -0
- data/config/locales/sv-SE.yml +1320 -0
- data/config/routes.rb +242 -0
- data/db/migrate/001_create_users.rb +26 -0
- data/db/migrate/002_add_activation_code_to_user.rb +11 -0
- data/db/migrate/003_create_photos.rb +22 -0
- data/db/migrate/004_add_tag_support.rb +21 -0
- data/db/migrate/005_create_friendships.rb +14 -0
- data/db/migrate/006_add_comments_tables.rb +18 -0
- data/db/migrate/007_create_friendship_statuses.rb +13 -0
- data/db/migrate/008_add_friendship_statuses.rb +14 -0
- data/db/migrate/009_create_clippings.rb +16 -0
- data/db/migrate/010_create_invitations.rb +14 -0
- data/db/migrate/011_create_homepage_features.rb +22 -0
- data/db/migrate/012_create_posts.rb +19 -0
- data/db/migrate/013_create_states.rb +13 -0
- data/db/migrate/014_add_states.rb +11 -0
- data/db/migrate/015_create_metro_areas.rb +15 -0
- data/db/migrate/016_add_metro_areas.rb +295 -0
- data/db/migrate/017_add_sessions_table.rb +20 -0
- data/db/migrate/018_create_categories.rb +11 -0
- data/db/migrate/019_change_comment_to_text_field.rb +10 -0
- data/db/migrate/020_create_login_slug.rb +9 -0
- data/db/migrate/021_add_category_names.rb +8 -0
- data/db/migrate/023_add_denied_friendship_status.rb +13 -0
- data/db/migrate/024_add_notification_preferences.rb +13 -0
- data/db/migrate/025_create_countries.rb +11 -0
- data/db/migrate/026_add_countries.rb +230 -0
- data/db/migrate/027_add_us_to_existing_metro_areas.rb +9 -0
- data/db/migrate/028_add_country_id_to_users.rb +9 -0
- data/db/migrate/029_add_us_to_users_with_states.rb +14 -0
- data/db/migrate/030_add_users_counter_cache.rb +9 -0
- data/db/migrate/031_news_to_talk.rb +10 -0
- data/db/migrate/033_featured_users.rb +9 -0
- data/db/migrate/034_add_last_login.rb +9 -0
- data/db/migrate/035_track_emailed.rb +9 -0
- data/db/migrate/036_create_skills.rb +11 -0
- data/db/migrate/037_create_offerings.rb +12 -0
- data/db/migrate/038_add_zag_to_users.rb +13 -0
- data/db/migrate/039_create_activities_table.rb +17 -0
- data/db/migrate/040_add_category_tips.rb +9 -0
- data/db/migrate/041_create_events_table.rb +19 -0
- data/db/migrate/042_add_privacy_to_users.rb +10 -0
- data/db/migrate/043_sql_session_store_setup.rb +39 -0
- data/db/migrate/044_category_improvements.rb +11 -0
- data/db/migrate/045_adding_indexes.rb +39 -0
- data/db/migrate/046_adding_ads.rb +20 -0
- data/db/migrate/047_add_polls.rb +30 -0
- data/db/migrate/049_add_activities_count.rb +9 -0
- data/db/migrate/050_create_initial_schema.rb +73 -0
- data/db/migrate/051_add_audience_limitation_to_ads.rb +9 -0
- data/db/migrate/052_create_assets.rb +21 -0
- data/db/migrate/053_create_favoritables.rb +23 -0
- data/db/migrate/054_add_published_as_to_posts.rb +13 -0
- data/db/migrate/055_add_published_at_to_posts.rb +15 -0
- data/db/migrate/056_create_roles.rb +28 -0
- data/db/migrate/057_add_more_indexes.rb +19 -0
- data/db/migrate/058_add_anonymous_commenting_fields.rb +15 -0
- data/db/migrate/059_create_messages.rb +16 -0
- data/db/migrate/060_still_more_indexes.rb +19 -0
- data/db/migrate/061_postgres_compatibility_changes.rb +9 -0
- data/db/migrate/062_add_notify_to_comments.rb +11 -0
- data/db/migrate/063_create_albums.rb +15 -0
- data/db/migrate/064_add_album_id_to_photos.rb +9 -0
- data/db/migrate/065_add_view_count_to_albums.rb +9 -0
- data/db/migrate/066_add_view_count_to_photos.rb +9 -0
- data/db/migrate/067_create_static_pages.rb +22 -0
- data/db/migrate/068_create_rsvps.rb +13 -0
- data/db/migrate/069_create_pages.rb +29 -0
- data/db/migrate/070_add_pages.rb +11 -0
- data/db/migrate/071_authlogic_compatibility_changes.rb +43 -0
- data/db/migrate/072_add_allow_rsvp_to_events.rb +9 -0
- data/db/migrate/073_add_taggings_count_to_tags.rb +9 -0
- data/db/migrate/074_add_threading_to_messages.rb +19 -0
- data/db/migrate/075_add_anonymous_forum_posting.rb +16 -0
- data/db/migrate/076_add_comment_notification_toggle.rb +9 -0
- data/db/migrate/077_paperclip_changes.rb +36 -0
- data/db/migrate/078_create_authorizations.rb +20 -0
- data/db/migrate/079_create_slugs.rb +18 -0
- data/db/sample/users.rb +55 -0
- data/generators/ce_plugin/USAGE +7 -0
- data/generators/ce_plugin/ce_plugin_generator.rb +25 -0
- data/generators/ce_plugin/templates/README +13 -0
- data/generators/ce_plugin/templates/desert_routes.rb +3 -0
- data/generators/ce_plugin/templates/init.rb +8 -0
- data/generators/ce_plugin/templates/plugin.rb +1 -0
- data/generators/plugin_migration/plugin_migration_generator.rb +101 -0
- data/generators/plugin_migration/templates/plugin_migration.erb +13 -0
- data/lang/TRANSLATION.markdown +32 -0
- data/lib/community_engine/authenticated_system.rb +167 -0
- data/lib/community_engine/authenticated_test_helper.rb +113 -0
- data/lib/community_engine/community_engine_sha1_crypto_method.rb +12 -0
- data/lib/community_engine/engine.rb +39 -0
- data/lib/community_engine/engines_extensions.rb +7 -0
- data/lib/community_engine/i18n_extensions.rb +31 -0
- data/lib/community_engine/localized_application.rb +83 -0
- data/lib/community_engine/rails_asset_extensions.rb +131 -0
- data/lib/community_engine/url_upload.rb +15 -0
- data/lib/community_engine/version.rb +10 -0
- data/lib/community_engine/viewable.rb +12 -0
- data/lib/community_engine.rb +34 -0
- data/lib/tag_hacks.rb +24 -0
- data/lib/tasks/community_engine_tasks.rake +87 -0
- data/public/favicon.ico +0 -0
- data/sample_files/s3.yml +17 -0
- data/test/fixtures/ads.yml +13 -0
- data/test/fixtures/albums.yml +16 -0
- data/test/fixtures/categories.yml +16 -0
- data/test/fixtures/clippings.yml +15 -0
- data/test/fixtures/comments.yml +55 -0
- data/test/fixtures/countries.yml +13 -0
- data/test/fixtures/events.yml +61 -0
- data/test/fixtures/files/Granite.bmp +0 -0
- data/test/fixtures/files/library.jpg +0 -0
- data/test/fixtures/forums.yml +10 -0
- data/test/fixtures/friendship_statuses.yml +10 -0
- data/test/fixtures/friendships.yml +15 -0
- data/test/fixtures/homepage_features.yml +13 -0
- data/test/fixtures/invitations.yml +5 -0
- data/test/fixtures/messages.yml +24 -0
- data/test/fixtures/metro_areas.yml +24 -0
- data/test/fixtures/moderatorships.yml +4 -0
- data/test/fixtures/monitorships.yml +10 -0
- data/test/fixtures/pages.yml +26 -0
- data/test/fixtures/photos.yml +29 -0
- data/test/fixtures/posts.yml +49 -0
- data/test/fixtures/roles.yml +9 -0
- data/test/fixtures/rsvps.yml +7 -0
- data/test/fixtures/sb_posts.yml +90 -0
- data/test/fixtures/states.yml +7 -0
- data/test/fixtures/taggings.yml +15 -0
- data/test/fixtures/tags.yml +11 -0
- data/test/fixtures/topics.yml +63 -0
- data/test/fixtures/users.yml +222 -0
- data/test/functional/activities_controller_test.rb +62 -0
- data/test/functional/admin_controller_test.rb +60 -0
- data/test/functional/ads_controller_test.rb +51 -0
- data/test/functional/albums_controller_test.rb +120 -0
- data/test/functional/base_controller_test.rb +27 -0
- data/test/functional/categories_controller_test.rb +51 -0
- data/test/functional/clippings_controller_test.rb +123 -0
- data/test/functional/comments_controller_test.rb +215 -0
- data/test/functional/events_controller_test.rb +104 -0
- data/test/functional/favorites_controller_test.rb +53 -0
- data/test/functional/forums_controller_test.rb +95 -0
- data/test/functional/friendships_controller_test.rb +98 -0
- data/test/functional/homepage_features_controller_test.rb +69 -0
- data/test/functional/invitations_controller_test.rb +45 -0
- data/test/functional/messages_controller_test.rb +154 -0
- data/test/functional/metro_areas_controller_test.rb +63 -0
- data/test/functional/moderators_controller_test.rb +22 -0
- data/test/functional/monitorships_controller_test.rb +72 -0
- data/test/functional/pages_controller_test.rb +95 -0
- data/test/functional/password_reset_controller_test.rb +34 -0
- data/test/functional/photo_manager_controller_test.rb +21 -0
- data/test/functional/photos_controller_test.rb +203 -0
- data/test/functional/posts_controller_test.rb +224 -0
- data/test/functional/rsvps_controller_test.rb +92 -0
- data/test/functional/sb_posts_controller_test.rb +193 -0
- data/test/functional/sessions_controller_test.rb +55 -0
- data/test/functional/sitemap_controller_test.rb +9 -0
- data/test/functional/statistics_controller_test.rb +18 -0
- data/test/functional/tags_controller_test.rb +52 -0
- data/test/functional/theme_controller_test.rb +11 -0
- data/test/functional/topics_controller_test.rb +201 -0
- data/test/functional/users_controller_test.rb +460 -0
- data/test/functional/votes_controller_test.rb +27 -0
- data/test/test_helper.rb +103 -0
- data/test/testapp/.gitignore +4 -0
- data/test/testapp/README +256 -0
- data/test/testapp/Rakefile +7 -0
- data/test/testapp/app/controllers/application_controller.rb +3 -0
- data/test/testapp/app/helpers/application_helper.rb +2 -0
- data/test/testapp/config/application.rb +45 -0
- data/test/testapp/config/application_config.rb +1 -0
- data/test/testapp/config/boot.rb +10 -0
- data/test/testapp/config/database.yml +22 -0
- data/test/testapp/config/environment.rb +6 -0
- data/test/testapp/config/environments/development.rb +25 -0
- data/test/testapp/config/environments/production.rb +49 -0
- data/test/testapp/config/environments/test.rb +35 -0
- data/test/testapp/config/initializers/backtrace_silencers.rb +7 -0
- data/test/testapp/config/initializers/inflections.rb +10 -0
- data/test/testapp/config/initializers/mime_types.rb +5 -0
- data/test/testapp/config/initializers/secret_token.rb +7 -0
- data/test/testapp/config/initializers/session_store.rb +8 -0
- data/test/testapp/config/locales/en.yml +5 -0
- data/test/testapp/config/routes.rb +3 -0
- data/test/testapp/config.ru +4 -0
- data/test/testapp/db/schema.rb +456 -0
- data/test/testapp/db/seeds.rb +7 -0
- data/test/testapp/doc/README_FOR_APP +2 -0
- data/test/testapp/lib/tasks/.gitkeep +0 -0
- data/test/testapp/public/404.html +26 -0
- data/test/testapp/public/422.html +26 -0
- data/test/testapp/public/500.html +26 -0
- data/test/testapp/public/favicon.ico +0 -0
- data/test/testapp/public/images/rails.png +0 -0
- data/test/testapp/public/robots.txt +5 -0
- data/test/testapp/script/rails +6 -0
- data/test/testapp/test/performance/browsing_test.rb +9 -0
- data/test/testapp/test/test_helper.rb +13 -0
- data/test/testapp/vendor/plugins/.gitkeep +0 -0
- data/test/unit/ad_test.rb +34 -0
- data/test/unit/asset_test.rb +15 -0
- data/test/unit/authorization_test.rb +55 -0
- data/test/unit/category_test.rb +22 -0
- data/test/unit/choice_test.rb +9 -0
- data/test/unit/clipping_image_test.rb +17 -0
- data/test/unit/clipping_test.rb +52 -0
- data/test/unit/comment_test.rb +107 -0
- data/test/unit/country_test.rb +15 -0
- data/test/unit/event_test.rb +75 -0
- data/test/unit/favorite_test.rb +71 -0
- data/test/unit/forum_test.rb +23 -0
- data/test/unit/friendship_status_test.rb +10 -0
- data/test/unit/friendship_test.rb +38 -0
- data/test/unit/homepage_feature_test.rb +10 -0
- data/test/unit/invitation_test.rb +27 -0
- data/test/unit/message_test.rb +49 -0
- data/test/unit/message_thread_test.rb +80 -0
- data/test/unit/metro_area_test.rb +10 -0
- data/test/unit/moderatorship_test.rb +30 -0
- data/test/unit/monitorships_test.rb +38 -0
- data/test/unit/page_test.rb +25 -0
- data/test/unit/photo_test.rb +42 -0
- data/test/unit/poll_test.rb +25 -0
- data/test/unit/post_test.rb +212 -0
- data/test/unit/rsvp_test.rb +33 -0
- data/test/unit/sb_post_test.rb +152 -0
- data/test/unit/state_test.rb +10 -0
- data/test/unit/tag_test.rb +22 -0
- data/test/unit/topic_test.rb +111 -0
- data/test/unit/user_notifier_test.rb +108 -0
- data/test/unit/user_test.rb +259 -0
- data/test/unit/vote_test.rb +9 -0
- data/vendor/plugins/activity_tracker/README +4 -0
- data/vendor/plugins/activity_tracker/Rakefile +22 -0
- data/vendor/plugins/activity_tracker/generators/activity_migration/USAGE +13 -0
- data/vendor/plugins/activity_tracker/generators/activity_migration/activity_migration_generator.rb +11 -0
- data/vendor/plugins/activity_tracker/generators/activity_migration/templates/migration.rb +17 -0
- data/vendor/plugins/activity_tracker/init.rb +1 -0
- data/vendor/plugins/activity_tracker/install.rb +1 -0
- data/vendor/plugins/activity_tracker/lib/activity.rb +40 -0
- data/vendor/plugins/activity_tracker/lib/activity_tracker.rb +80 -0
- data/vendor/plugins/activity_tracker/tasks/activity_tracker_tasks.rake +4 -0
- data/vendor/plugins/activity_tracker/test/abstract_unit.rb +47 -0
- data/vendor/plugins/activity_tracker/test/activity_tracker_test.rb +48 -0
- data/vendor/plugins/activity_tracker/test/database.yml +18 -0
- data/vendor/plugins/activity_tracker/test/debug.log +3329 -0
- data/vendor/plugins/activity_tracker/test/fixtures/test_post.rb +5 -0
- data/vendor/plugins/activity_tracker/test/fixtures/test_posts.yml +3 -0
- data/vendor/plugins/activity_tracker/test/fixtures/test_user.rb +4 -0
- data/vendor/plugins/activity_tracker/test/fixtures/test_users.yml +6 -0
- data/vendor/plugins/activity_tracker/test/schema.rb +21 -0
- data/vendor/plugins/activity_tracker/uninstall.rb +1 -0
- data/vendor/plugins/acts_as_list/README +23 -0
- data/vendor/plugins/acts_as_list/init.rb +3 -0
- data/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +256 -0
- data/vendor/plugins/acts_as_list/test/list_test.rb +332 -0
- data/vendor/plugins/acts_as_publishable/README +3 -0
- data/vendor/plugins/acts_as_publishable/Rakefile +22 -0
- data/vendor/plugins/acts_as_publishable/generators/publishing/publishing_generator.rb +34 -0
- data/vendor/plugins/acts_as_publishable/generators/publishing/templates/migration.rb +13 -0
- data/vendor/plugins/acts_as_publishable/init.rb +3 -0
- data/vendor/plugins/acts_as_publishable/install.rb +3 -0
- data/vendor/plugins/acts_as_publishable/lib/acts_as_publishable.rb +81 -0
- data/vendor/plugins/acts_as_publishable/test/acts_as_publishable_test.rb +8 -0
- data/vendor/plugins/acts_as_publishable/uninstall.rb +1 -0
- data/vendor/plugins/auto_complete/README +23 -0
- data/vendor/plugins/auto_complete/Rakefile +22 -0
- data/vendor/plugins/auto_complete/init.rb +2 -0
- data/vendor/plugins/auto_complete/lib/auto_complete.rb +47 -0
- data/vendor/plugins/auto_complete/lib/auto_complete_macros_helper.rb +143 -0
- data/vendor/plugins/auto_complete/test/auto_complete_test.rb +67 -0
- data/vendor/plugins/enumerations_mixin/LICENSE +20 -0
- data/vendor/plugins/enumerations_mixin/README_ENUMERATIONS +163 -0
- data/vendor/plugins/enumerations_mixin/init.rb +21 -0
- data/vendor/plugins/enumerations_mixin/lib/active_record/acts/enumerated.rb +177 -0
- data/vendor/plugins/enumerations_mixin/lib/active_record/aggregations/has_enumerated.rb +60 -0
- data/vendor/plugins/enumerations_mixin/lib/active_record/virtual_enumerations.rb +68 -0
- data/vendor/plugins/enumerations_mixin/virtual_enumerations_sample.rb +76 -0
- data/vendor/plugins/prototype_legacy_helper/README.markdown +13 -0
- data/vendor/plugins/prototype_legacy_helper/init.rb +1 -0
- data/vendor/plugins/prototype_legacy_helper/lib/prototype_legacy_helper.rb +432 -0
- data/vendor/plugins/prototype_legacy_helper/test/test_prototype_helper.rb +297 -0
- data/vendor/plugins/resource_feeder/README +4 -0
- data/vendor/plugins/resource_feeder/Rakefile +22 -0
- data/vendor/plugins/resource_feeder/init.rb +2 -0
- data/vendor/plugins/resource_feeder/lib/resource_feeder/atom.rb +71 -0
- data/vendor/plugins/resource_feeder/lib/resource_feeder/rss.rb +71 -0
- data/vendor/plugins/resource_feeder/lib/resource_feeder.rb +2 -0
- data/vendor/plugins/resource_feeder/test/atom_feed_test.rb +85 -0
- data/vendor/plugins/resource_feeder/test/rss_feed_test.rb +61 -0
- data/vendor/plugins/resource_feeder/test/test_helper.rb +60 -0
- data/vendor/plugins/respond_to_parent/MIT-LICENSE +20 -0
- data/vendor/plugins/respond_to_parent/README +47 -0
- data/vendor/plugins/respond_to_parent/Rakefile +22 -0
- data/vendor/plugins/respond_to_parent/init.rb +1 -0
- data/vendor/plugins/respond_to_parent/install.rb +1 -0
- data/vendor/plugins/respond_to_parent/lib/responds_to_parent.rb +70 -0
- data/vendor/plugins/respond_to_parent/test/responds_to_parent_test.rb +10 -0
- data/vendor/plugins/respond_to_parent/test/test_helper.rb +6 -0
- data/vendor/plugins/respond_to_parent/uninstall.rb +1 -0
- data/vendor/plugins/tiny_mce/CHANGELOG_PLUGIN.rdoc +91 -0
- data/vendor/plugins/tiny_mce/CHANGELOG_TINYMCE +1226 -0
- data/vendor/plugins/tiny_mce/DEV_UPGRADE_NOTES.rdoc +12 -0
- data/vendor/plugins/tiny_mce/init.rb +2 -0
- data/vendor/plugins/tiny_mce/install.rb +18 -0
- data/vendor/plugins/tiny_mce/lib/tiny_mce/base.rb +33 -0
- data/vendor/plugins/tiny_mce/lib/tiny_mce/configuration.rb +114 -0
- data/vendor/plugins/tiny_mce/lib/tiny_mce/exceptions.rb +14 -0
- data/vendor/plugins/tiny_mce/lib/tiny_mce/helpers.rb +43 -0
- data/vendor/plugins/tiny_mce/lib/tiny_mce/railtie.rb +13 -0
- data/vendor/plugins/tiny_mce/lib/tiny_mce/spell_checker.rb +67 -0
- data/vendor/plugins/tiny_mce/lib/tiny_mce/valid_tinymce_langs.yml +25 -0
- data/vendor/plugins/tiny_mce/lib/tiny_mce/valid_tinymce_options.yml +167 -0
- data/vendor/plugins/tiny_mce/lib/tiny_mce.rb +24 -0
- data/vendor/plugins/white_list/README +35 -0
- data/vendor/plugins/white_list/Rakefile +22 -0
- data/vendor/plugins/white_list/init.rb +35 -0
- data/vendor/plugins/white_list/lib/white_list_helper.rb +61 -0
- data/vendor/plugins/white_list/test/white_list_test.rb +120 -0
- metadata +1073 -0
data/app/models/user.rb
ADDED
@@ -0,0 +1,483 @@
|
|
1
|
+
require 'digest/sha1'
|
2
|
+
|
3
|
+
class User < ActiveRecord::Base
|
4
|
+
include UrlUpload
|
5
|
+
include FacebookProfile
|
6
|
+
include TwitterProfile
|
7
|
+
|
8
|
+
include Rakismet::Model
|
9
|
+
rakismet_attrs :author => :login, :comment_type => 'registration', :content => :description, :user_ip => :last_login_ip, :author_email => :email
|
10
|
+
attr_protected :admin, :featured, :role_id, :akismet_attrs
|
11
|
+
|
12
|
+
has_friendly_id :login, :use_slug => true, :cache_column => 'login_slug'
|
13
|
+
|
14
|
+
MALE = 'M'
|
15
|
+
FEMALE = 'F'
|
16
|
+
|
17
|
+
acts_as_authentic do |c|
|
18
|
+
c.crypto_provider = CommunityEngineSha1CryptoMethod
|
19
|
+
|
20
|
+
c.validates_length_of_password_field_options = { :within => 6..20, :if => :password_required? }
|
21
|
+
c.validates_length_of_password_confirmation_field_options = { :within => 6..20, :if => :password_required? }
|
22
|
+
|
23
|
+
c.validates_length_of_login_field_options = { :minimum => 5, :unless => :omniauthed? }
|
24
|
+
c.validates_format_of_login_field_options = { :with => /^[\sA-Za-z0-9_-]+$/, :unless => :omniauthed? }
|
25
|
+
|
26
|
+
c.validates_length_of_email_field_options = { :within => 3..100, :if => :email_required? }
|
27
|
+
c.validates_format_of_email_field_options = { :with => /^([^@\s]+)@((?:[-a-z0-9A-Z]+\.)+[a-zA-Z]{2,})$/, :if => :email_required? }
|
28
|
+
end
|
29
|
+
|
30
|
+
acts_as_taggable
|
31
|
+
acts_as_commentable
|
32
|
+
has_enumerated :role
|
33
|
+
tracks_unlinked_activities [:logged_in, :invited_friends, :updated_profile, :joined_the_site]
|
34
|
+
|
35
|
+
#callbacks
|
36
|
+
before_create :make_activation_code
|
37
|
+
after_create :update_last_login
|
38
|
+
after_create :deliver_signup_notification
|
39
|
+
before_save :whitelist_attributes
|
40
|
+
after_save :recount_metro_area_users
|
41
|
+
after_destroy :recount_metro_area_users
|
42
|
+
|
43
|
+
#validation
|
44
|
+
validates_presence_of :metro_area, :if => Proc.new { |user| user.state }
|
45
|
+
validates_uniqueness_of :login
|
46
|
+
validates_exclusion_of :login, :in => configatron.reserved_logins
|
47
|
+
|
48
|
+
validate :valid_birthday, :if => :requires_valid_birthday?
|
49
|
+
validate :check_spam
|
50
|
+
|
51
|
+
#associations
|
52
|
+
has_many :authorizations, :dependent => :destroy
|
53
|
+
has_many :posts, :order => "published_at desc", :dependent => :destroy
|
54
|
+
has_many :photos, :order => "created_at desc", :dependent => :destroy
|
55
|
+
has_many :invitations, :dependent => :destroy
|
56
|
+
has_many :rsvps, :dependent => :destroy
|
57
|
+
has_many :albums, :dependent => :destroy
|
58
|
+
|
59
|
+
#friendship associations
|
60
|
+
has_many :friendships, :class_name => "Friendship", :foreign_key => "user_id", :dependent => :destroy
|
61
|
+
has_many :accepted_friendships, :class_name => "Friendship", :conditions => ['friendship_status_id = ?', 2]
|
62
|
+
has_many :pending_friendships, :class_name => "Friendship", :conditions => ['initiator = ? AND friendship_status_id = ?', false, 1]
|
63
|
+
has_many :friendships_initiated_by_me, :class_name => "Friendship", :foreign_key => "user_id", :conditions => ['initiator = ?', true], :dependent => :destroy
|
64
|
+
has_many :friendships_not_initiated_by_me, :class_name => "Friendship", :foreign_key => "user_id", :conditions => ['initiator = ?', false], :dependent => :destroy
|
65
|
+
has_many :occurances_as_friend, :class_name => "Friendship", :foreign_key => "friend_id", :dependent => :destroy
|
66
|
+
|
67
|
+
#forums
|
68
|
+
has_many :moderatorships, :dependent => :destroy
|
69
|
+
has_many :forums, :through => :moderatorships, :order => 'forums.name'
|
70
|
+
has_many :sb_posts, :dependent => :destroy
|
71
|
+
has_many :topics, :dependent => :destroy
|
72
|
+
has_many :monitorships, :dependent => :destroy
|
73
|
+
has_many :monitored_topics, :through => :monitorships, :conditions => ['monitorships.active = ?', true], :order => 'topics.replied_at desc', :source => :topic
|
74
|
+
|
75
|
+
belongs_to :avatar, :class_name => "Photo", :foreign_key => "avatar_id", :inverse_of => :user_as_avatar
|
76
|
+
belongs_to :metro_area, :counter_cache => true
|
77
|
+
belongs_to :state
|
78
|
+
belongs_to :country
|
79
|
+
has_many :comments_as_author, :class_name => "Comment", :foreign_key => "user_id", :order => "created_at desc", :dependent => :destroy
|
80
|
+
has_many :comments_as_recipient, :class_name => "Comment", :foreign_key => "recipient_id", :order => "created_at desc", :dependent => :destroy
|
81
|
+
has_many :clippings, :order => "created_at desc", :dependent => :destroy
|
82
|
+
has_many :favorites, :order => "created_at desc", :dependent => :destroy
|
83
|
+
|
84
|
+
#messages
|
85
|
+
has_many :all_sent_messages, :class_name => "Message", :foreign_key => "sender_id", :dependent => :destroy
|
86
|
+
has_many :sent_messages,
|
87
|
+
:class_name => 'Message',
|
88
|
+
:foreign_key => 'sender_id',
|
89
|
+
:order => "messages.created_at DESC",
|
90
|
+
:conditions => ["messages.sender_deleted = ?", false]
|
91
|
+
|
92
|
+
has_many :received_messages,
|
93
|
+
:class_name => 'Message',
|
94
|
+
:foreign_key => 'recipient_id',
|
95
|
+
:order => "message.created_at DESC",
|
96
|
+
:conditions => ["message.recipient_deleted = ?", false]
|
97
|
+
has_many :message_threads_as_recipient, :class_name => "MessageThread", :foreign_key => "recipient_id"
|
98
|
+
|
99
|
+
#named scopes
|
100
|
+
scope :recent, order('users.created_at DESC')
|
101
|
+
scope :featured, where(:featured_writer => true)
|
102
|
+
scope :active, where("users.activated_at IS NOT NULL")
|
103
|
+
scope :vendors, where(:vendor => true)
|
104
|
+
|
105
|
+
|
106
|
+
accepts_nested_attributes_for :avatar
|
107
|
+
attr_accessible :avatar_id, :company_name, :country_id, :description, :email,
|
108
|
+
:firstname, :fullname, :gender, :lastname, :login, :metro_area_id,
|
109
|
+
:middlename, :notify_comments, :notify_community_news,
|
110
|
+
:notify_friend_requests, :password, :password_confirmation,
|
111
|
+
:profile_public, :state_id, :stylesheet, :time_zone, :vendor, :zip, :avatar_attributes, :birthday
|
112
|
+
|
113
|
+
attr_accessor :authorizing_from_omniauth
|
114
|
+
|
115
|
+
## Class Methods
|
116
|
+
|
117
|
+
def self.find_by_login_or_email(login)
|
118
|
+
self.where(:login => login).first || self.where(:email => login).first
|
119
|
+
end
|
120
|
+
|
121
|
+
def self.find_country_and_state_from_search_params(search)
|
122
|
+
country = Country.find(search['country_id']) if !search['country_id'].blank?
|
123
|
+
state = State.find(search['state_id']) if !search['state_id'].blank?
|
124
|
+
metro_area = MetroArea.find(search['metro_area_id']) if !search['metro_area_id'].blank?
|
125
|
+
|
126
|
+
if metro_area && metro_area.country
|
127
|
+
country ||= metro_area.country
|
128
|
+
state ||= metro_area.state
|
129
|
+
search['country_id'] = metro_area.country.id if metro_area.country
|
130
|
+
search['state_id'] = metro_area.state.id if metro_area.state
|
131
|
+
end
|
132
|
+
|
133
|
+
states = country ? country.states.sort_by{|s| s.name} : []
|
134
|
+
if states.any?
|
135
|
+
metro_areas = state ? state.metro_areas.all(:order => "name") : []
|
136
|
+
else
|
137
|
+
metro_areas = country ? country.metro_areas : []
|
138
|
+
end
|
139
|
+
|
140
|
+
return [metro_areas, states]
|
141
|
+
end
|
142
|
+
|
143
|
+
def self.prepare_params_for_search(params)
|
144
|
+
search = {}.merge(params)
|
145
|
+
search['metro_area_id'] = params[:metro_area_id] || nil
|
146
|
+
search['state_id'] = params[:state_id] || nil
|
147
|
+
search['country_id'] = params[:country_id] || nil
|
148
|
+
search
|
149
|
+
end
|
150
|
+
|
151
|
+
def self.build_conditions_for_search(search)
|
152
|
+
user = User.arel_table
|
153
|
+
users = User.active
|
154
|
+
if search['country_id'] && !(search['metro_area_id'] || search['state_id'])
|
155
|
+
users = users.where(user[:country_id].eq(search['country_id']))
|
156
|
+
end
|
157
|
+
if search['state_id'] && !search['metro_area_id']
|
158
|
+
users = users.where(user[:state_id].eq(search['state_id']))
|
159
|
+
end
|
160
|
+
if search['metro_area_id']
|
161
|
+
users = users.where(user[:metro_area_id].eq(search['metro_area_id']))
|
162
|
+
end
|
163
|
+
if search['login']
|
164
|
+
users = users.where('`users`.login LIKE ?', "%#{search['login']}%")
|
165
|
+
end
|
166
|
+
if search['vendor']
|
167
|
+
users = users.where(user[:vendor].eq(true))
|
168
|
+
end
|
169
|
+
if search['description']
|
170
|
+
users = users.where('`users`.description LIKE ?', "%#{search['description']}%")
|
171
|
+
end
|
172
|
+
users
|
173
|
+
end
|
174
|
+
|
175
|
+
def self.find_by_activity(options = {})
|
176
|
+
options.reverse_merge! :limit => 30, :require_avatar => true, :since => 7.days.ago
|
177
|
+
|
178
|
+
activities = Activity.since(options[:since]).find(:all,
|
179
|
+
:select => 'activities.user_id, count(*) as count',
|
180
|
+
:group => 'activities.user_id',
|
181
|
+
:conditions => "#{options[:require_avatar] ? ' users.avatar_id IS NOT NULL AND ' : ''} users.activated_at IS NOT NULL",
|
182
|
+
:order => 'count DESC',
|
183
|
+
:joins => "LEFT JOIN users ON users.id = activities.user_id",
|
184
|
+
:limit => options[:limit]
|
185
|
+
)
|
186
|
+
activities.map{|a| find(a.user_id) }
|
187
|
+
end
|
188
|
+
|
189
|
+
def self.find_featured
|
190
|
+
self.featured
|
191
|
+
end
|
192
|
+
|
193
|
+
def self.search_conditions_with_metros_and_states(params)
|
194
|
+
search = prepare_params_for_search(params)
|
195
|
+
|
196
|
+
metro_areas, states = find_country_and_state_from_search_params(search)
|
197
|
+
|
198
|
+
users = build_conditions_for_search(search)
|
199
|
+
return users, search, metro_areas, states
|
200
|
+
end
|
201
|
+
|
202
|
+
|
203
|
+
def self.recent_activity(options = {})
|
204
|
+
options.reverse_merge! :per_page => 10, :page => 1
|
205
|
+
Activity.recent.joins("LEFT JOIN users ON users.id = activities.user_id").where('users.activated_at IS NOT NULL').select('activities.*').page(options[:page]).per(options[:per_page])
|
206
|
+
end
|
207
|
+
|
208
|
+
def self.currently_online
|
209
|
+
User.find(:all, :conditions => ["sb_last_seen_at > ?", Time.now.utc-5.minutes])
|
210
|
+
end
|
211
|
+
|
212
|
+
def self.search(query, options = {})
|
213
|
+
with_scope :find => { :conditions => build_search_conditions(query) } do
|
214
|
+
find :all, options
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
def self.build_search_conditions(query)
|
219
|
+
query
|
220
|
+
end
|
221
|
+
|
222
|
+
## End Class Methods
|
223
|
+
|
224
|
+
|
225
|
+
## Instance Methods
|
226
|
+
|
227
|
+
def moderator_of?(forum)
|
228
|
+
moderatorships.count(:all, :conditions => ['forum_id = ?', (forum.is_a?(Forum) ? forum.id : forum)]) == 1
|
229
|
+
end
|
230
|
+
|
231
|
+
def monitoring_topic?(topic)
|
232
|
+
monitored_topics.find_by_id(topic.id)
|
233
|
+
end
|
234
|
+
|
235
|
+
def to_xml(options = {})
|
236
|
+
options[:except] ||= []
|
237
|
+
super
|
238
|
+
end
|
239
|
+
|
240
|
+
def recount_metro_area_users
|
241
|
+
return unless self.metro_area
|
242
|
+
ma = self.metro_area
|
243
|
+
ma.users_count = User.count(:conditions => ["metro_area_id = ?", ma.id])
|
244
|
+
ma.save
|
245
|
+
end
|
246
|
+
|
247
|
+
def this_months_posts
|
248
|
+
self.posts.find(:all, :conditions => ["published_at > ?", DateTime.now.to_time.at_beginning_of_month])
|
249
|
+
end
|
250
|
+
|
251
|
+
def last_months_posts
|
252
|
+
self.posts.find(:all, :conditions => ["published_at > ? and published_at < ?", DateTime.now.to_time.at_beginning_of_month.months_ago(1), DateTime.now.to_time.at_beginning_of_month])
|
253
|
+
end
|
254
|
+
|
255
|
+
def avatar_photo_url(size = :original)
|
256
|
+
if avatar
|
257
|
+
avatar.photo.url(size)
|
258
|
+
elsif facebook?
|
259
|
+
facebook_authorization.picture_url
|
260
|
+
elsif twitter?
|
261
|
+
twitter_authorization.picture_url
|
262
|
+
else
|
263
|
+
case size
|
264
|
+
when :thumb
|
265
|
+
configatron.photo.missing_thumb.to_s
|
266
|
+
else
|
267
|
+
configatron.photo.missing_medium.to_s
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
def deactivate
|
273
|
+
return if admin? #don't allow admin deactivation
|
274
|
+
User.transaction do
|
275
|
+
update_attribute(:activated_at, nil)
|
276
|
+
update_attribute(:activation_code, make_activation_code)
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
def activate
|
281
|
+
User.transaction do
|
282
|
+
update_attribute(:activated_at, Time.now.utc)
|
283
|
+
update_attribute(:activation_code, nil)
|
284
|
+
end
|
285
|
+
UserNotifier.activation(self).deliver
|
286
|
+
end
|
287
|
+
|
288
|
+
def active?
|
289
|
+
activation_code.nil? && !activated_at.nil?
|
290
|
+
end
|
291
|
+
|
292
|
+
def valid_invite_code?(code)
|
293
|
+
code == invite_code
|
294
|
+
end
|
295
|
+
|
296
|
+
def invite_code
|
297
|
+
Digest::SHA1.hexdigest("#{self.id}--#{self.email}--#{self.password_salt}")
|
298
|
+
end
|
299
|
+
|
300
|
+
def location
|
301
|
+
metro_area && metro_area.name || ""
|
302
|
+
end
|
303
|
+
|
304
|
+
def full_location
|
305
|
+
"#{metro_area.name if self.metro_area}#{" , #{self.country.name}" if self.country}"
|
306
|
+
end
|
307
|
+
|
308
|
+
def reset_password
|
309
|
+
new_password = newpass(8)
|
310
|
+
self.password = new_password
|
311
|
+
self.password_confirmation = new_password
|
312
|
+
return self.valid?
|
313
|
+
end
|
314
|
+
|
315
|
+
def newpass( len )
|
316
|
+
chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
|
317
|
+
new_password = ""
|
318
|
+
1.upto(len) { |i| new_password << chars[rand(chars.size-1)] }
|
319
|
+
return new_password
|
320
|
+
end
|
321
|
+
|
322
|
+
def owner
|
323
|
+
self
|
324
|
+
end
|
325
|
+
|
326
|
+
def staff?
|
327
|
+
featured_writer?
|
328
|
+
end
|
329
|
+
|
330
|
+
def can_request_friendship_with(user)
|
331
|
+
!self.eql?(user) && !self.friendship_exists_with?(user)
|
332
|
+
end
|
333
|
+
|
334
|
+
def friendship_exists_with?(friend)
|
335
|
+
Friendship.find(:first, :conditions => ["user_id = ? AND friend_id = ?", self.id, friend.id])
|
336
|
+
end
|
337
|
+
|
338
|
+
def deliver_signup_notification
|
339
|
+
UserNotifier.signup_notification(self).deliver
|
340
|
+
end
|
341
|
+
|
342
|
+
def update_last_login
|
343
|
+
self.track_activity(:logged_in) if self.active? && self.last_login_at.nil? || (self.last_login_at && self.last_login_at < Time.now.beginning_of_day)
|
344
|
+
self.update_attribute(:last_login_at, Time.now)
|
345
|
+
end
|
346
|
+
|
347
|
+
def has_reached_daily_friend_request_limit?
|
348
|
+
friendships_initiated_by_me.count(:conditions => ['created_at > ?', Time.now.beginning_of_day]) >= Friendship.daily_request_limit
|
349
|
+
end
|
350
|
+
|
351
|
+
def network_activity(page = {}, since = 1.week.ago)
|
352
|
+
page.reverse_merge! :per_page => 10, :page => 1
|
353
|
+
friend_ids = self.friends_ids
|
354
|
+
metro_area_people_ids = self.metro_area ? self.metro_area.users.map(&:id) : []
|
355
|
+
|
356
|
+
ids = ((friends_ids | metro_area_people_ids) - [self.id])[0..100] #don't pull TOO much activity for now
|
357
|
+
|
358
|
+
Activity.recent.since(since).by_users(ids).page(page[:page]).per(page[:per_page])
|
359
|
+
end
|
360
|
+
|
361
|
+
def comments_activity(page = {}, since = 1.week.ago)
|
362
|
+
page.reverse_merge :per_page => 10, :page => 1
|
363
|
+
|
364
|
+
Activity.recent.since(since).where('comments.recipient_id = ? AND activities.user_id != ?', self.id, self.id).joins("LEFT JOIN comments ON comments.id = activities.item_id AND activities.item_type = 'Comment'").page(page[:per_page]).per(page[:page])
|
365
|
+
end
|
366
|
+
|
367
|
+
def friends_ids
|
368
|
+
return [] if accepted_friendships.empty?
|
369
|
+
accepted_friendships.map{|fr| fr.friend_id }
|
370
|
+
end
|
371
|
+
|
372
|
+
def recommended_posts(since = 1.week.ago)
|
373
|
+
return [] if tags.empty?
|
374
|
+
rec_posts = Post.tagged_with(tags.map(&:name)).where(['posts.user_id != ? AND published_at > ?', self.id, since ])
|
375
|
+
rec_posts = rec_posts.order('published_at DESC').limit(10)
|
376
|
+
rec_posts
|
377
|
+
end
|
378
|
+
|
379
|
+
def display_name
|
380
|
+
login
|
381
|
+
end
|
382
|
+
|
383
|
+
def admin?
|
384
|
+
role && role.eql?(Role[:admin])
|
385
|
+
end
|
386
|
+
|
387
|
+
def moderator?
|
388
|
+
role && role.eql?(Role[:moderator])
|
389
|
+
end
|
390
|
+
|
391
|
+
def member?
|
392
|
+
role && role.eql?(Role[:member])
|
393
|
+
end
|
394
|
+
|
395
|
+
def male?
|
396
|
+
gender && gender.eql?(MALE)
|
397
|
+
end
|
398
|
+
|
399
|
+
def female
|
400
|
+
gender && gender.eql?(FEMALE)
|
401
|
+
end
|
402
|
+
|
403
|
+
def update_last_seen_at
|
404
|
+
User.update_all ['sb_last_seen_at = ?', Time.now.utc], ['id = ?', self.id]
|
405
|
+
self.sb_last_seen_at = Time.now.utc
|
406
|
+
end
|
407
|
+
|
408
|
+
def unread_messages?
|
409
|
+
unread_message_count > 0 ? true : false
|
410
|
+
end
|
411
|
+
|
412
|
+
def unread_message_count
|
413
|
+
message_threads_as_recipient.count(:conditions => ["messages.recipient_id = ? AND messages.recipient_deleted = ? AND read_at IS NULL", self.id, false], :include => :message)
|
414
|
+
end
|
415
|
+
|
416
|
+
def deliver_password_reset_instructions!
|
417
|
+
reset_perishable_token!
|
418
|
+
UserNotifier.password_reset_instructions(self).deliver
|
419
|
+
end
|
420
|
+
|
421
|
+
def valid_birthday
|
422
|
+
date = configatron.min_age.years.ago
|
423
|
+
errors.add(:birthday, "must be before #{date.strftime("%Y-%m-%d")}") unless birthday && (birthday.to_date <= date.to_date)
|
424
|
+
end
|
425
|
+
|
426
|
+
def self.find_or_create_from_authorization(auth)
|
427
|
+
user = User.find_or_initialize_by_email(:email => auth.email)
|
428
|
+
user.login ||= auth.nickname
|
429
|
+
|
430
|
+
if user.new_record?
|
431
|
+
new_password = user.newpass(8)
|
432
|
+
user.password = new_password
|
433
|
+
user.password_confirmation = new_password
|
434
|
+
end
|
435
|
+
|
436
|
+
user.authorizing_from_omniauth = true
|
437
|
+
|
438
|
+
if user.save
|
439
|
+
user.activate unless user.active?
|
440
|
+
user.reset_persistence_token!
|
441
|
+
end
|
442
|
+
user
|
443
|
+
end
|
444
|
+
|
445
|
+
def check_spam
|
446
|
+
if !configatron.akismet_key.nil? && self.spam?
|
447
|
+
self.errors.add(:base, :user_spam_error.l)
|
448
|
+
end
|
449
|
+
end
|
450
|
+
|
451
|
+
|
452
|
+
## End Instance Methods
|
453
|
+
|
454
|
+
protected
|
455
|
+
|
456
|
+
def make_activation_code
|
457
|
+
self.activation_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )
|
458
|
+
end
|
459
|
+
|
460
|
+
# before filters
|
461
|
+
def whitelist_attributes
|
462
|
+
self.login = self.login.strip
|
463
|
+
self.description = white_list(self.description )
|
464
|
+
self.stylesheet = white_list(self.stylesheet )
|
465
|
+
end
|
466
|
+
|
467
|
+
def password_required?
|
468
|
+
crypted_password.blank? || !password.blank?
|
469
|
+
end
|
470
|
+
|
471
|
+
def email_required?
|
472
|
+
!omniauthed?
|
473
|
+
end
|
474
|
+
|
475
|
+
def requires_valid_birthday?
|
476
|
+
!omniauthed?
|
477
|
+
end
|
478
|
+
|
479
|
+
def omniauthed?
|
480
|
+
authorizing_from_omniauth || authorizations.any?
|
481
|
+
end
|
482
|
+
|
483
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
class UserNotifier < ActionMailer::Base
|
2
|
+
include ActionView::Helpers::TextHelper
|
3
|
+
include ActionView::Helpers::SanitizeHelper
|
4
|
+
extend ActionView::Helpers::SanitizeHelper::ClassMethods # Required for rails 2.2
|
5
|
+
include BaseHelper
|
6
|
+
|
7
|
+
default_url_options[:host] = configatron.app_host
|
8
|
+
default :from => "#{:the_team.l(:site => configatron.community_name, :email => configatron.support_email)}"
|
9
|
+
|
10
|
+
def signup_invitation(email, user, message)
|
11
|
+
|
12
|
+
@recipients = "#{email}"
|
13
|
+
@subject = "#{:would_like_you_to_join.l(:user => user.login, :site => configatron.community_name)}"
|
14
|
+
@sent_on = Time.now
|
15
|
+
@user = user
|
16
|
+
@url = signup_by_id_url(user, user.invite_code)
|
17
|
+
@message = message
|
18
|
+
|
19
|
+
mail(:to => @recipients, :subject => @subject)
|
20
|
+
end
|
21
|
+
|
22
|
+
def friendship_request(friendship)
|
23
|
+
setup_email(friendship.friend)
|
24
|
+
@subject += "#{:would_like_to_be_friends_with_you_on.l(:user => friendship.user.login, :site => configatron.community_name)}"
|
25
|
+
@url = pending_user_friendships_url(friendship.friend)
|
26
|
+
@requester = friendship.user
|
27
|
+
mail(:to => @recipients, :subject => @subject)
|
28
|
+
end
|
29
|
+
|
30
|
+
def friendship_accepted(friendship)
|
31
|
+
setup_email(friendship.user)
|
32
|
+
@subject += "#{:friendship_request_accepted.l}"
|
33
|
+
@requester = friendship.user
|
34
|
+
@friend = friendship.friend
|
35
|
+
@url = user_url(friendship.friend)
|
36
|
+
mail(:to => @recipients, :subject => @subject)
|
37
|
+
end
|
38
|
+
|
39
|
+
def comment_notice(comment)
|
40
|
+
setup_email(comment.recipient)
|
41
|
+
@subject += "#{:has_something_to_say_to_you_on.l(:user => comment.username, :site => configatron.community_name)}"
|
42
|
+
@url = commentable_url(comment)
|
43
|
+
@comment = comment
|
44
|
+
@commenter = comment.user
|
45
|
+
mail(:to => @recipients, :subject => @subject)
|
46
|
+
end
|
47
|
+
|
48
|
+
def follow_up_comment_notice(user, comment)
|
49
|
+
setup_email(user)
|
50
|
+
@subject += "#{:has_commented_on_something_that_you_also_commented_on.l(:user => comment.username, :item => comment.commentable_type)}"
|
51
|
+
@url = commentable_url(comment)
|
52
|
+
@comment = comment
|
53
|
+
@commenter = comment.user
|
54
|
+
mail(:to => @recipients, :subject => @subject)
|
55
|
+
end
|
56
|
+
|
57
|
+
def follow_up_comment_notice_anonymous(email, comment)
|
58
|
+
@recipients = "#{email}"
|
59
|
+
|
60
|
+
@subject = "[#{configatron.community_name}] "
|
61
|
+
@sent_on = Time.now
|
62
|
+
@subject += "#{:has_commented_on_something_that_you_also_commented_on.l(:user => comment.username, :item => comment.commentable_type)}"
|
63
|
+
@url = commentable_url(comment)
|
64
|
+
@comment = comment
|
65
|
+
|
66
|
+
@unsubscribe_link = url_for(:controller => 'comments', :action => 'unsubscribe', :comment_id => comment.id, :token => comment.token_for(email), :email => email)
|
67
|
+
mail(:to => @recipients, :subject => @subject)
|
68
|
+
end
|
69
|
+
|
70
|
+
def new_forum_post_notice(user, post)
|
71
|
+
setup_email(user)
|
72
|
+
@subject += "#{:has_posted_in_a_thread_you_are_monitoring.l(:user => post.username)}"
|
73
|
+
@url = "#{forum_topic_url(:forum_id => post.topic.forum, :id => post.topic, :page => post.topic.last_page)}##{post.dom_id}"
|
74
|
+
@post = post
|
75
|
+
@author = post.username
|
76
|
+
mail(:to => @recipients, :subject => @subject)
|
77
|
+
end
|
78
|
+
|
79
|
+
def signup_notification(user)
|
80
|
+
setup_email(user)
|
81
|
+
@subject += "#{:please_activate_your_new_account.l(:site => configatron.community_name)}"
|
82
|
+
@url = "#{home_url}users/activate/#{user.activation_code}"
|
83
|
+
mail(:to => @recipients, :subject => @subject)
|
84
|
+
end
|
85
|
+
|
86
|
+
def message_notification(message)
|
87
|
+
setup_email(message.recipient)
|
88
|
+
@subject += "#{:sent_you_a_private_message.l(:user => message.sender.login)}"
|
89
|
+
@message = message
|
90
|
+
mail(:to => @recipients, :subject => @subject)
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
def post_recommendation(name, email, post, message = nil, current_user = nil)
|
95
|
+
@recipients = "#{email}"
|
96
|
+
@sent_on = Time.now
|
97
|
+
|
98
|
+
@subject = "#{:check_out_this_story_on.l(:site => configatron.community_name)}"
|
99
|
+
@name = name
|
100
|
+
@title = post.title
|
101
|
+
@post = post
|
102
|
+
@signup_link = (current_user ? signup_by_id_url(current_user, current_user.invite_code) : signup_url )
|
103
|
+
@message = message
|
104
|
+
@url = user_post_url(post.user, post)
|
105
|
+
@description = truncate_words(post.post, 100, @url )
|
106
|
+
mail(:to => @recipients, :subject => @subject)
|
107
|
+
end
|
108
|
+
|
109
|
+
def activation(user)
|
110
|
+
setup_email(user)
|
111
|
+
@subject += "#{:your_account_has_been_activated.l(:site => configatron.community_name)}"
|
112
|
+
@url = home_url
|
113
|
+
mail(:to => @recipients, :subject => @subject)
|
114
|
+
end
|
115
|
+
|
116
|
+
def password_reset_instructions(user)
|
117
|
+
setup_email(user)
|
118
|
+
@subject += "#{:user_information.l(:site => configatron.community_name)}"
|
119
|
+
@edit_password_reset_url = edit_password_reset_url(user.perishable_token)
|
120
|
+
|
121
|
+
mail(:to => @recipients, :subject => @subject)
|
122
|
+
end
|
123
|
+
|
124
|
+
def forgot_username(user)
|
125
|
+
setup_email(user)
|
126
|
+
@subject += "#{:user_information.l(:site => configatron.community_name)}"
|
127
|
+
mail(:to => @recipients, :subject => @subject)
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
protected
|
132
|
+
def setup_email(user)
|
133
|
+
@recipients = "#{user.email}"
|
134
|
+
|
135
|
+
@subject = "[#{configatron.community_name}] "
|
136
|
+
@sent_on = Time.now
|
137
|
+
@user = user
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class UserSession < Authlogic::Session::Base
|
2
|
+
find_by_login_method :find_by_login_or_email
|
3
|
+
remember_me_for 2.weeks
|
4
|
+
remember_me false
|
5
|
+
after_create :update_user_activity
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def update_user_activity
|
10
|
+
controller.session[:last_active] = self.record.sb_last_seen_at
|
11
|
+
controller.session[:topics] = controller.session[:forums] = {}
|
12
|
+
self.record.update_last_seen_at
|
13
|
+
end
|
14
|
+
end
|
data/app/models/vote.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
class Vote < ActiveRecord::Base
|
2
|
+
validates_presence_of :user_id
|
3
|
+
validates_presence_of :poll
|
4
|
+
validates_presence_of :choice
|
5
|
+
validates_uniqueness_of :user_id, :scope => :poll_id, :message => 'has already voted.'
|
6
|
+
|
7
|
+
belongs_to :poll
|
8
|
+
belongs_to :user
|
9
|
+
belongs_to :choice, :counter_cache => true
|
10
|
+
|
11
|
+
after_save :update_poll_votes_count
|
12
|
+
|
13
|
+
def update_poll_votes_count
|
14
|
+
votes_count = Choice.sum(:votes_count, :conditions => {:poll_id => self.poll_id})
|
15
|
+
self.poll.votes_count = votes_count
|
16
|
+
self.poll.save!
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|