kit_cms 2.3.16 → 2.3.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/assets/images/kit/toolbar/bold.png +0 -0
- data/app/assets/images/kit/toolbar/formatted.png +0 -0
- data/app/assets/images/kit/toolbar/image.png +0 -0
- data/app/assets/images/kit/toolbar/link.png +0 -0
- data/app/assets/images/kit/toolbar/list.png +0 -0
- data/app/assets/images/kit/toolbar/numbered_list.png +0 -0
- data/app/assets/images/kit/toolbar/preview.png +0 -0
- data/app/assets/images/kit/toolbar/quote.png +0 -0
- data/app/assets/images/kit/toolbar/redo.png +0 -0
- data/app/assets/images/kit/toolbar/underline.png +0 -0
- data/app/assets/images/kit/toolbar/undo.png +0 -0
- data/app/assets/images/kit/toolbar/video.png +0 -0
- data/app/assets/javascripts/codemirror/editor.js +183 -0
- data/app/assets/javascripts/codemirror/markdown.js +475 -0
- data/app/assets/javascripts/jquery.contextmenu.js +7 -7
- data/app/assets/javascripts/kit/kit.js +0 -1
- data/app/assets/javascripts/kit/markdown.js +1 -37
- data/app/assets/javascripts/kit/tree.js +18 -10
- data/app/assets/javascripts/kit/utilities.js +1 -1
- data/app/assets/stylesheets/codemirror/editor.css +3 -3
- data/app/assets/stylesheets/codemirror/theme.css +76 -1
- data/app/assets/stylesheets/kit/calendar.css +58 -97
- data/app/assets/stylesheets/kit/cms/cms.css +19 -0
- data/app/assets/stylesheets/kit/cms/dsc_tree.css +4 -0
- data/app/assets/stylesheets/kit/forums.css +30 -0
- data/app/assets/stylesheets/kit/kit.css +0 -1
- data/app/controllers/admin/dashboard_controller.rb +11 -2
- data/app/controllers/admin/page_templates_controller.rb +14 -1
- data/app/controllers/admin/user_controller.rb +2 -3
- data/app/controllers/category_controller.rb +5 -6
- data/app/controllers/form_controller.rb +1 -1
- data/app/controllers/forum_controller.rb +2 -2
- data/app/controllers/kit_controller.rb +2 -2
- data/app/controllers/pages_controller.rb +24 -0
- data/app/controllers/user/passwords_controller.rb +2 -0
- data/app/controllers/user/registrations_controller.rb +1 -4
- data/app/controllers/user/sessions_controller.rb +2 -0
- data/app/controllers/user/unlocks_controller.rb +2 -0
- data/app/controllers/user_controller.rb +1 -1
- data/app/helpers/calendar_helper.rb +4 -1
- data/app/helpers/kit_helper.rb +3 -3
- data/app/mailers/notification.rb +3 -3
- data/app/models/activity.rb +5 -2
- data/app/models/calendar.rb +1 -1
- data/app/models/category.rb +18 -4
- data/app/models/experiment.rb +2 -0
- data/app/models/form_submission.rb +2 -2
- data/app/models/html_asset.rb +3 -0
- data/app/models/mapping.rb +1 -0
- data/app/models/user.rb +1 -1
- data/app/views/admin/blocks/_form.html.haml +1 -1
- data/app/views/admin/dashboard/user_comments.html.haml +19 -8
- data/app/views/admin/experiments/show.html.haml +1 -1
- data/app/views/admin/form/_form.html.haml +8 -0
- data/app/views/admin/page_templates/_form.html.haml +1 -1
- data/app/views/admin/views/_form.html.haml +4 -4
- data/app/views/calendar/_calendar_scripts.js.erb +2 -2
- data/app/views/calendar/_month.html.haml +58 -27
- data/app/views/category/_select_options.html.erb +1 -1
- data/app/views/form/_show.html.haml +9 -1
- data/app/views/forum/_add_post.html.haml +3 -2
- data/app/views/forum/_mod_thread.js.erb +2 -2
- data/app/views/forum/_post_scripts.js.erb +1 -2
- data/app/views/forum/thread.html.haml +4 -0
- data/app/views/layouts/_application.html.erb +1 -0
- data/app/views/layouts/minimal.html.erb +2 -2
- data/app/views/notification/form_submission.text.erb +2 -0
- data/app/views/pages/_form.html.haml +7 -8
- data/app/views/pages/_page_scripts.js.erb +1 -3
- data/app/views/pages/_page_template_script.js.erb +28 -0
- data/app/views/pages/cookie_text.html.haml +1 -1
- data/app/views/pages/info.html.erb +2 -2
- data/app/views/pages/page_template.html.haml +40 -0
- data/app/views/utility/_cm_editor.html.erb +34 -5
- data/app/views/utility/_cm_toolbar_markdown.html.haml +49 -0
- data/config/initializers/devise_extender.rb +9 -0
- data/config/initializers/html_assets.rb +4 -0
- data/config/initializers/quiet_asserts.rb +1 -1
- data/config/routes.rb +2 -0
- metadata +21 -3
| @@ -508,3 +508,33 @@ div#forums div.watch a { | |
| 508 508 | 
             
            div#forums div#threads div.mod_actions {
         | 
| 509 509 | 
             
              width: 600px;
         | 
| 510 510 | 
             
            }
         | 
| 511 | 
            +
             | 
| 512 | 
            +
            div.markdown_preview {
         | 
| 513 | 
            +
              background-color: white;
         | 
| 514 | 
            +
              padding: 10px;
         | 
| 515 | 
            +
              }
         | 
| 516 | 
            +
             | 
| 517 | 
            +
            div.modal_markdown_preview div.ui-dialog-content {
         | 
| 518 | 
            +
              border: thin black solid;
         | 
| 519 | 
            +
              font-family: Arial, "sans serif";
         | 
| 520 | 
            +
            }
         | 
| 521 | 
            +
             | 
| 522 | 
            +
            div.modal_markdown_preview div.ui-dialog-titlebar {
         | 
| 523 | 
            +
              height: 20px;  
         | 
| 524 | 
            +
              padding: 10px;
         | 
| 525 | 
            +
              color: white;
         | 
| 526 | 
            +
              background-color: #444;
         | 
| 527 | 
            +
              font-family: Arial, "sans serif";
         | 
| 528 | 
            +
              
         | 
| 529 | 
            +
            }
         | 
| 530 | 
            +
             | 
| 531 | 
            +
            div.modal_markdown_preview div.ui-dialog-titlebar span.ui-icon-closethick {
         | 
| 532 | 
            +
              float: right;
         | 
| 533 | 
            +
            }
         | 
| 534 | 
            +
             | 
| 535 | 
            +
            div.ui-widget-overlay {
         | 
| 536 | 
            +
              opacity: 0.2;
         | 
| 537 | 
            +
              background-color: black;
         | 
| 538 | 
            +
            }
         | 
| 539 | 
            +
             | 
| 540 | 
            +
             | 
| @@ -5,10 +5,17 @@ class Admin::DashboardController < AdminController | |
| 5 5 | 
             
                comment = Comment.sys(_sid).where(:id=>params[:id]).first
         | 
| 6 6 |  | 
| 7 7 | 
             
                if comment
         | 
| 8 | 
            -
                   | 
| 8 | 
            +
                  if params[:delete]
         | 
| 9 | 
            +
                    comment.destroy
         | 
| 10 | 
            +
                    render :js=>"$('tr.comment_#{comment.id}').remove();"
         | 
| 11 | 
            +
                  else
         | 
| 12 | 
            +
                    comment.update_attributes(params[:comment])
         | 
| 13 | 
            +
                    render :js=>"updated(#{comment.id}, #{comment.is_moderated}, #{comment.is_visible});"
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
                  return
         | 
| 9 16 | 
             
                end
         | 
| 10 17 |  | 
| 11 | 
            -
                render :js=>" | 
| 18 | 
            +
                render :js=>""
         | 
| 12 19 | 
             
              end
         | 
| 13 20 |  | 
| 14 21 | 
             
              def user_comments
         | 
| @@ -423,7 +430,9 @@ class Admin::DashboardController < AdminController | |
| 423 430 | 
             
                @activity = @activity.includes(:user)
         | 
| 424 431 | 
             
                end
         | 
| 425 432 | 
             
                @activity = @activity.where(["category = ?", params[:cat]]) if params[:cat]
         | 
| 433 | 
            +
                @activity = @activity.sys(_sid)
         | 
| 426 434 | 
             
                @activity = @activity.order("created_at desc").page(params[:page]).per(100)
         | 
| 435 | 
            +
                
         | 
| 427 436 |  | 
| 428 437 | 
             
                if request.xhr?
         | 
| 429 438 | 
             
                  render :partial=>"activity_list"
         | 
| @@ -1,6 +1,18 @@ | |
| 1 1 | 
             
            class Admin::PageTemplatesController < AdminController
         | 
| 2 2 | 
             
              layout "cms"
         | 
| 3 | 
            -
             | 
| 3 | 
            +
             | 
| 4 | 
            +
              def mapping
         | 
| 5 | 
            +
                template = PageTemplate.sys(_sid).where(:id=>params[:id]).first
         | 
| 6 | 
            +
                page = template.pages.first
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                if page==nil
         | 
| 9 | 
            +
                  render :js=>"$('#error_explanation').html('You must have already created at least one page with the \'#{template.name}\' template to use it for this page.').show();"
         | 
| 10 | 
            +
                  return
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                render :json=>page.current_content.map { |field| field.field_name }
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 4 16 | 
             
              def pages
         | 
| 5 17 | 
             
               @page_template = PageTemplate.sys(_sid).where(:id=>params[:id]).first
         | 
| 6 18 |  | 
| @@ -27,6 +39,7 @@ class Admin::PageTemplatesController < AdminController | |
| 27 39 | 
             
                  @page_template.is_default = 1
         | 
| 28 40 | 
             
                end
         | 
| 29 41 | 
             
                @page_template.user_id = current_user.id
         | 
| 42 | 
            +
                @page_template.system_id = _sid
         | 
| 30 43 | 
             
                if @page_template.save
         | 
| 31 44 | 
             
                  Activity.add(_sid, "Created Page Template '#{@page_template.name}'", current_user.id, "Page Template")
         | 
| 32 45 | 
             
                  redirect_to [:admin, @page_template], :notice => "Successfully created page template."
         | 
| @@ -284,13 +284,12 @@ class Admin::UserController < AdminController | |
| 284 284 | 
             
              def stream_csv(users)
         | 
| 285 285 | 
             
                filename = params[:action] + ".csv"    
         | 
| 286 286 |  | 
| 287 | 
            -
                #this is required if you want this to work with IE		
         | 
| 288 287 | 
             
                csv_headers(filename)
         | 
| 289 288 |  | 
| 290 289 | 
             
                csv_string = CSV.generate do |csv|
         | 
| 291 | 
            -
                  csv << ["id","email","groups"]
         | 
| 290 | 
            +
                  csv << ["id","email","groups", "attributes"]
         | 
| 292 291 | 
             
                  users.each do |u|
         | 
| 293 | 
            -
                    csv << [u.id, u.email, u.groups.join(", ")]
         | 
| 292 | 
            +
                    csv << [u.id, u.email, u.groups.join(", "), u.user_attribute_values.map {|uav| "#{uav.user_attribute.name}:#{uav.value}"}.join(',')]
         | 
| 294 293 | 
             
                  end
         | 
| 295 294 | 
             
                end
         | 
| 296 295 | 
             
                render :text => csv_string 
         | 
| @@ -207,9 +207,8 @@ class CategoryController < KitController | |
| 207 207 | 
             
                end
         | 
| 208 208 |  | 
| 209 209 | 
             
                if @categories.size>0 
         | 
| 210 | 
            -
                  html = render_to_string(:partial=>"select_options | 
| 211 | 
            -
             | 
| 212 | 
            -
                  render :js => "$('#page_category_id').html('#{html}'); $('#category_warning').html('');"
         | 
| 210 | 
            +
                  html = render_to_string(:partial=>"select_options").strip
         | 
| 211 | 
            +
                  render :js => "$('#page_category_id').html('#{html}'); $('#category_warning').html(''); "
         | 
| 213 212 | 
             
                else
         | 
| 214 213 | 
             
                  render :js => "$('#page_category_id').html(''); $('#category_warning').html('No match found');"
         | 
| 215 214 | 
             
                end
         | 
| @@ -267,7 +266,7 @@ class CategoryController < KitController | |
| 267 266 | 
             
              def grant_permission(category_id, group_id, mode)
         | 
| 268 267 | 
             
                  cg = CategoryGroup.sys(_sid).where(:category_id=>category_id).where(:group_id=>group_id).first
         | 
| 269 268 | 
             
                  unless cg
         | 
| 270 | 
            -
                    cg = CategoryGroup.new(: | 
| 269 | 
            +
                    cg = CategoryGroup.new(:category_id=>category_id, :group_id=>group_id)
         | 
| 271 270 | 
             
                  end
         | 
| 272 271 | 
             
                  if mode=='read'
         | 
| 273 272 | 
             
                    cg.can_read = 1
         | 
| @@ -280,9 +279,9 @@ class CategoryController < KitController | |
| 280 279 |  | 
| 281 280 | 
             
              def revoke_permission(category_id, group_id, mode)
         | 
| 282 281 | 
             
                  if mode=='read'
         | 
| 283 | 
            -
                    CategoryGroup.delete_all([" | 
| 282 | 
            +
                    CategoryGroup.delete_all(["category_id = ? and group_id = ?", _sid, category_id, group_id])      
         | 
| 284 283 | 
             
                  else
         | 
| 285 | 
            -
                    cg = CategoryGroup. | 
| 284 | 
            +
                    cg = CategoryGroup.where(:category_id=>category_id).where(:group_id=>group_id).first
         | 
| 286 285 | 
             
                    if cg
         | 
| 287 286 | 
             
                      cg.can_write = 0
         | 
| 288 287 | 
             
                      cg.save
         | 
| @@ -85,7 +85,7 @@ class FormController < KitController | |
| 85 85 |  | 
| 86 86 | 
             
                if @form.notify.not_blank?
         | 
| 87 87 | 
             
                  @form.notify.split(',').each do |recipient|
         | 
| 88 | 
            -
                    Notification.form_submission( | 
| 88 | 
            +
                    Notification.form_submission(sub_id, _sid, recipient).deliver
         | 
| 89 89 | 
             
                  end
         | 
| 90 90 | 
             
                end
         | 
| 91 91 |  | 
| @@ -345,7 +345,7 @@ class ForumController < KitController | |
| 345 345 | 
             
                  @thread.last_post_by_user_display_name = current_user.display_name
         | 
| 346 346 | 
             
                  @thread.last_post_at = Time.now
         | 
| 347 347 | 
             
                  @thread.save
         | 
| 348 | 
            -
                  @thread.topic.post_count += 1
         | 
| 348 | 
            +
                  @thread.topic.post_count += 1 rescue 1
         | 
| 349 349 | 
             
                  @thread.topic.last_thread_id = @thread.id
         | 
| 350 350 | 
             
                  @thread.topic.last_post_at = Time.now
         | 
| 351 351 | 
             
                  @thread.topic.last_post_id = @post.id
         | 
| @@ -545,7 +545,7 @@ class ForumController < KitController | |
| 545 545 | 
             
                  @post.created_by_user.notes << UserNote.new(:category=>"Forum", :description=>"Removed all posts for spamming", :created_by_id=>current_user)
         | 
| 546 546 | 
             
                  TopicPost.delete_all_by_user(_sid, @post.created_by_user_id, current_user)
         | 
| 547 547 | 
             
                else
         | 
| 548 | 
            -
                  @post.created_by_user.user_notes << UserNote.new(:category=>"Forum", :description=>"Had <a href='#{@post.link}'>post</a> #{params[:delete]=='0' ? '' : 'un'}deleted", :created_by_id=>current_user)
         | 
| 548 | 
            +
                  @post.created_by_user.user_notes << UserNote.new(:category=>"Forum", :description=>"Had <a href='#{@post.link}'>post</a> #{params[:delete]=='0' ? '' : 'un'}deleted", :created_by_id=>current_user.id)
         | 
| 549 549 | 
             
                end
         | 
| 550 550 |  | 
| 551 551 | 
             
                render :js=>"done_delete(#{@post.id}, #{@post.is_visible});"
         | 
| @@ -239,7 +239,7 @@ HERE | |
| 239 239 | 
             
                    inline_template = "<div id='page_#{page.id}' class='template_#{error_template.id}'>\n\n" + error_template.body + "\n\n</div>"
         | 
| 240 240 | 
             
                    render :inline=>inline_template, :layout=>error_template.layout.path, :type=>error_template.template_type || 'erb'
         | 
| 241 241 | 
             
                  else
         | 
| 242 | 
            -
                    render "error/application", :layout=>Preference.getCached(_sid, "error_layout") || " | 
| 242 | 
            +
                    render "error/application", :layout=>Preference.getCached(_sid, "error_layout") || "application", :status=>status
         | 
| 243 243 | 
             
                  end
         | 
| 244 244 | 
             
                end
         | 
| 245 245 |  | 
| @@ -337,7 +337,7 @@ HERE | |
| 337 337 | 
             
                  end
         | 
| 338 338 | 
             
                end
         | 
| 339 339 |  | 
| 340 | 
            -
                render "form/show", :layout=> | 
| 340 | 
            +
                render "form/show", :layout=>((form.respond_to?(:layout) && form.layout) ? form.layout : 'application')
         | 
| 341 341 | 
             
              end    
         | 
| 342 342 |  | 
| 343 343 | 
             
              def captcha_okay?
         | 
| @@ -439,6 +439,30 @@ class PagesController < KitController | |
| 439 439 | 
             
                @terms = @page.terms
         | 
| 440 440 | 
             
              end
         | 
| 441 441 |  | 
| 442 | 
            +
              def page_template
         | 
| 443 | 
            +
                if request.put?
         | 
| 444 | 
            +
                  page = Page.sys(_sid).where(:id=>params[:id]).first
         | 
| 445 | 
            +
                  return unless page
         | 
| 446 | 
            +
                  notice = nil 
         | 
| 447 | 
            +
                  if page.page_template_id != params[:page][:page_template_id]
         | 
| 448 | 
            +
                    new_template = PageTemplate.sys(_sid).where(:id=>params[:page][:page_template_id]).first
         | 
| 449 | 
            +
                    if new_template
         | 
| 450 | 
            +
                      lookup = {}
         | 
| 451 | 
            +
                      page.page_template_id = params[:page][:page_template_id]
         | 
| 452 | 
            +
                      page.save
         | 
| 453 | 
            +
                      params.each do |param_name, new_name|
         | 
| 454 | 
            +
                        if param_name =~ /^f_(.+)$/
         | 
| 455 | 
            +
                          old_name = $1
         | 
| 456 | 
            +
                          PageContent.connection.execute("update page_contents set field_name = '#{new_name}' where field_name = '#{old_name}' and page_id = #{page.id}")
         | 
| 457 | 
            +
                        end
         | 
| 458 | 
            +
                      end
         | 
| 459 | 
            +
                      notice = 'Changes saved'
         | 
| 460 | 
            +
                    end
         | 
| 461 | 
            +
                  end
         | 
| 462 | 
            +
                  redirect_to "/page/#{params[:id]}/info", :notice=>notice
         | 
| 463 | 
            +
                end 
         | 
| 464 | 
            +
              end
         | 
| 465 | 
            +
             | 
| 442 466 | 
             
              def info    
         | 
| 443 467 | 
             
                if params[:sitemap] && request.post?
         | 
| 444 468 | 
             
                  @page.skip_history
         | 
| @@ -14,10 +14,6 @@ class User::RegistrationsController < Devise::RegistrationsController | |
| 14 14 | 
             
                return path.to_s
         | 
| 15 15 | 
             
              end
         | 
| 16 16 |  | 
| 17 | 
            -
              def stylesheets
         | 
| 18 | 
            -
                "xxxx"
         | 
| 19 | 
            -
              end
         | 
| 20 | 
            -
             | 
| 21 17 | 
             
              def create
         | 
| 22 18 | 
             
                self.kit_template = "user/register" 
         | 
| 23 19 | 
             
                build_resource
         | 
| @@ -62,6 +58,7 @@ class User::RegistrationsController < Devise::RegistrationsController | |
| 62 58 | 
             
                @page_title = "Sign Up"
         | 
| 63 59 | 
             
                self.kit_template = "user/register"
         | 
| 64 60 |  | 
| 61 | 
            +
                session[:captcha_okay] = true
         | 
| 65 62 | 
             
                if params[:return_to]
         | 
| 66 63 | 
             
                  session[:return_to] = params[:return_to]
         | 
| 67 64 | 
             
                elsif url = Preference.get_cached(_sid, "url_after_sign_up")
         | 
| @@ -168,7 +168,9 @@ module CalendarHelper | |
| 168 168 | 
             
                last_region_id = nil 
         | 
| 169 169 | 
             
                first = true
         | 
| 170 170 | 
             
                op = "{ "
         | 
| 171 | 
            +
                at_least_one = false
         | 
| 171 172 | 
             
                Subregion.order("regions.name, subregions.name").includes(:region).each do |sr| 
         | 
| 173 | 
            +
                  at_least_one = true
         | 
| 172 174 | 
             
                  if sr.region_id != last_region_id 
         | 
| 173 175 | 
             
                    if !first
         | 
| 174 176 | 
             
                      op += "],\r\n"
         | 
| @@ -180,7 +182,8 @@ module CalendarHelper | |
| 180 182 | 
             
                  end
         | 
| 181 183 | 
             
                  op += "[ \"#{sr.name}\", #{sr.id} ], "
         | 
| 182 184 | 
             
                end
         | 
| 183 | 
            -
                op += "] | 
| 185 | 
            +
                op += "]" if at_least_one
         | 
| 186 | 
            +
                op += "}"
         | 
| 184 187 |  | 
| 185 188 | 
             
                return op.html_safe
         | 
| 186 189 | 
             
              end
         | 
    
        data/app/helpers/kit_helper.rb
    CHANGED
    
    | @@ -96,7 +96,7 @@ module KitHelper | |
| 96 96 | 
             
                s = stylesheets 
         | 
| 97 97 | 
             
                rescue Exception => e
         | 
| 98 98 | 
             
                  s = ['application'] 
         | 
| 99 | 
            -
                  logger. | 
| 99 | 
            +
                  logger.info "#{e.message}"
         | 
| 100 100 | 
             
                end
         | 
| 101 101 | 
             
                (additional + s).each do |name|
         | 
| 102 102 | 
             
                  next if name.is_blank?
         | 
| @@ -142,12 +142,12 @@ module KitHelper | |
| 142 142 | 
             
                link_to_function label, "submit_form(this)", options
         | 
| 143 143 | 
             
              end
         | 
| 144 144 |  | 
| 145 | 
            -
              def cm_editor(mode, object, field, form, form_field = nil)
         | 
| 145 | 
            +
              def cm_editor(mode, object, field, form, form_field = nil, options = {})
         | 
| 146 146 | 
             
                form_field ||= "#{object}_#{field}"
         | 
| 147 147 |  | 
| 148 148 | 
             
                mode = 'htmlmixed' if mode == 'html'
         | 
| 149 149 | 
             
                mode = 'css' if mode == 'sass' || mode == 'scss'
         | 
| 150 | 
            -
                render :partial=>'utility/cm_editor', :locals=>{:mode=>mode, :field=>field, :form_field=>form_field, :form=>form}
         | 
| 150 | 
            +
                render :partial=>'utility/cm_editor', :locals=>{:mode=>mode, :field=>field, :form_field=>form_field, :form=>form, :options=>options}
         | 
| 151 151 | 
             
              end
         | 
| 152 152 |  | 
| 153 153 | 
             
              def hide_if(bool)
         | 
    
        data/app/mailers/notification.rb
    CHANGED
    
    | @@ -30,9 +30,9 @@ class Notification < ActionMailer::Base | |
| 30 30 | 
             
                mail :from=>isfrom(sid),:subject=>"Event #{event.id} occurred: #{event.name}",  :to => Preference.getCached(sid, 'notify:event')
         | 
| 31 31 | 
             
              end
         | 
| 32 32 |  | 
| 33 | 
            -
              def form_submission( | 
| 34 | 
            -
                @sub =  | 
| 35 | 
            -
             | 
| 33 | 
            +
              def form_submission(submission_id,sid, recipient)
         | 
| 34 | 
            +
                @sub = FormSubmission.find(submission_id)
         | 
| 35 | 
            +
                @sid = sid
         | 
| 36 36 | 
             
                mail :subject=>"#{Preference.getCached(sid,'app_name')} #{@sub.form.title} Submission",
         | 
| 37 37 | 
             
                       :to=>recipient, :from=>isfrom(sid)
         | 
| 38 38 | 
             
              end
         | 
    
        data/app/models/activity.rb
    CHANGED
    
    | @@ -3,8 +3,11 @@ class Activity < ActiveRecord::Base | |
| 3 3 | 
             
              belongs_to :user
         | 
| 4 4 |  | 
| 5 5 | 
             
              attr_accessible :system_id, :name, :user_id, :category, :description
         | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 6 | 
            +
             | 
| 7 | 
            +
             | 
| 8 | 
            +
              def self.add(sys_id, name, user_or_user_id=0, category='', description='')
         | 
| 9 | 
            +
                user_or_user_id = 0 if user_or_user_id == nil
         | 
| 10 | 
            +
                Activity.create(:user_id=>user_or_user_id.is_a?(Integer) ? user_or_user_id : user_or_user_id.id, :system_id=>sys_id, :name=>name, :category=>category, :description=>description).save
         | 
| 8 11 | 
             
              end
         | 
| 9 12 |  | 
| 10 13 | 
             
            end
         | 
    
        data/app/models/calendar.rb
    CHANGED
    
    | @@ -6,7 +6,7 @@ class Calendar < ActiveRecord::Base | |
| 6 6 | 
             
              validates :name, :presence=>true, :uniqueness=>true, :length=>{:minimum=>1, :maximum=>200}
         | 
| 7 7 |  | 
| 8 8 | 
             
              def entries_between(start_date, end_date, filter, position = nil, distance = nil) 
         | 
| 9 | 
            -
                e = self.calendar_entries.where(["(start_date  | 
| 9 | 
            +
                e = self.calendar_entries.where(["(start_date <= ? and end_date >= ?)", end_date, start_date]).includes({:location=>:subregion})
         | 
| 10 10 |  | 
| 11 11 | 
             
                if filter =~ /subregions.name/
         | 
| 12 12 | 
             
                  e = e.joins({:location=>:subregion})
         | 
    
        data/app/models/category.rb
    CHANGED
    
    | @@ -91,7 +91,21 @@ class Category < KitIndexed | |
| 91 91 |  | 
| 92 92 | 
             
              # all categories, in depth order (root at the top)
         | 
| 93 93 | 
             
              def self.tree_by_depth(sid)
         | 
| 94 | 
            -
                Category.sys(sid).includes(:category_groups).all.sort  | 
| 94 | 
            +
                Category.sys(sid).includes(:category_groups).all.sort do |a,b| 
         | 
| 95 | 
            +
                  if a.depth < b.depth
         | 
| 96 | 
            +
                    -1
         | 
| 97 | 
            +
                  elsif a.depth > b.depth
         | 
| 98 | 
            +
                    1
         | 
| 99 | 
            +
                  else
         | 
| 100 | 
            +
                    if a.name < b.name
         | 
| 101 | 
            +
                      -1
         | 
| 102 | 
            +
                    elsif a.name > b.name
         | 
| 103 | 
            +
                      1
         | 
| 104 | 
            +
                    else
         | 
| 105 | 
            +
                      0
         | 
| 106 | 
            +
                    end
         | 
| 107 | 
            +
                  end
         | 
| 108 | 
            +
                end
         | 
| 95 109 | 
             
              end
         | 
| 96 110 |  | 
| 97 111 | 
             
              # all categories, in a hash keyed by parent_id
         | 
| @@ -109,7 +123,7 @@ class Category < KitIndexed | |
| 109 123 | 
             
              # all categories, in a hash keyed by category_id, with "parent_of" attribute populated with a list of child categories AND child documents
         | 
| 110 124 | 
             
              def self.tree_with_children(sid)
         | 
| 111 125 | 
             
                lookup = { }
         | 
| 112 | 
            -
                cats = Category.sys(sid).all
         | 
| 126 | 
            +
                cats = Category.sys(sid).order(:name).all
         | 
| 113 127 |  | 
| 114 128 | 
             
                cats.each do |cat|
         | 
| 115 129 | 
             
                  cat.parent_of = []
         | 
| @@ -122,7 +136,7 @@ class Category < KitIndexed | |
| 122 136 | 
             
                  lookup[cat.parent_id].parent_of << cat
         | 
| 123 137 | 
             
                end
         | 
| 124 138 |  | 
| 125 | 
            -
                Page.sys(sid).includes(:status).find_each do |page|
         | 
| 139 | 
            +
                Page.sys(sid).order(:name).includes(:status).find_each do |page|
         | 
| 126 140 | 
             
                  lookup[page.category_id].parent_of << page
         | 
| 127 141 | 
             
                end
         | 
| 128 142 |  | 
| @@ -168,7 +182,7 @@ class Category < KitIndexed | |
| 168 182 | 
             
              def self.build_permission_cache(sid)
         | 
| 169 183 | 
             
                @@perms_cache[sid] = {}
         | 
| 170 184 | 
             
                all_groups = {}
         | 
| 171 | 
            -
                Group.all.collect { |g| all_groups[g.id] = g.name }
         | 
| 185 | 
            +
                Group.where(:system_id=>sid).all.collect { |g| all_groups[g.id] = g.name }
         | 
| 172 186 | 
             
                Category.tree_by_depth(sid).each do |cat|
         | 
| 173 187 | 
             
                  permissions = @@perms_cache[sid][cat.parent_id] ? @@perms_cache[sid][cat.parent_id].clone : { :read_groups=>{}, :write_groups=>{} } # start with permissions of parent
         | 
| 174 188 |  | 
    
        data/app/models/experiment.rb
    CHANGED
    
    
| @@ -2,9 +2,9 @@ class FormSubmission  < KitIndexed | |
| 2 2 |  | 
| 3 3 | 
             
              FormSubmission.do_indexing :FormSubmission, [
         | 
| 4 4 | 
             
                {:name=>"id", :index=>:not_analyzed, :include_in_all=>false},
         | 
| 5 | 
            -
                {:name=>"location", :type => 'geo_point', :as=>'"#{self.lat}, #{self.lon}"' },
         | 
| 5 | 
            +
                {:name=>"location", :type => 'geo_point', :as=>'"#{self.lat ? self.lat : 0}, #{self.lon ? self.lon : 0}"' },
         | 
| 6 6 | 
             
                {:name=>"created_at", :index=>:not_analyzed, :include_in_all=>false},
         | 
| 7 | 
            -
                {:name=>"marked", :index=>:not_analyzed, :include_in_all=>false},
         | 
| 7 | 
            +
                {:name=>"marked", :as=>"self.marked ? self.marked : 0", :index=>:not_analyzed, :include_in_all=>false},
         | 
| 8 8 | 
             
                {:name=>"system_id", :index=>:not_analyzed, :include_in_all=>false},
         | 
| 9 9 | 
             
                {:name=>"email", :boost=>50 , :as=>"self.user ? self.user.email : ''"},
         | 
| 10 10 | 
             
                {:name=>"form_id", :boost=>100, :as=>"self.form_id", :include_in_all=>false},
         |