myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [2810] branches/rails2: cd branches/rails2 ; svn


From: noreply
Subject: [myexperiment-hackers] [2810] branches/rails2: cd branches/rails2 ; svn merge -r 2771:2809 ^/trunk
Date: Wed, 16 Nov 2011 05:54:51 -0500 (EST)

Revision
2810
Author
dgc
Date
2011-11-16 05:54:50 -0500 (Wed, 16 Nov 2011)

Log Message

cd branches/rails2 ; svn merge -r 2771:2809 ^/trunk

Modified Paths

Added Paths

Removed Paths

Diff

Modified: branches/rails2/app/controllers/application_controller.rb (2809 => 2810)


--- branches/rails2/app/controllers/application_controller.rb	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/controllers/application_controller.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -15,7 +15,7 @@
 
   WhiteListHelper.tags.merge %w(table tr td th div span)
   
-  before_filter :set_configuration
+  #before_filter :set_configuration
 
   include AuthenticatedSystem
   before_filter :login_from_cookie
@@ -740,10 +740,14 @@
 
     def create_search_results_table(search_query, models)
 
-      solr_results = models.first.multi_solr_search(search_query,
-          :models         => models,
-          :results_format => :ids,
-          :limit          => Conf.max_search_size)
+      begin
+        solr_results = models.first.multi_solr_search(search_query,
+            :models         => models,
+            :results_format => :ids,
+            :limit          => Conf.max_search_size)
+      rescue
+        return false
+      end
 
       conn =  ActiveRecord::Base.connection
 
@@ -763,6 +767,8 @@
  
         conn.execute("INSERT INTO search_results VALUES #{insert_part}")
       end
+
+      true
     end
 
     def drop_search_results_table
@@ -1010,10 +1016,16 @@
 
     group_by = "contributions.contributable_type, contributions.contributable_id"
 
+    query_problem = false
+
     if params["query"]
       drop_search_results_table
-      create_search_results_table(params["query"], [Workflow, Blob, Pack, User, Network, Service])
-      joins.push(:search) unless opts[:arbitrary_models]
+      if create_search_results_table(params["query"], [Workflow, Blob, Pack, User, Network, Service])
+        joins.push(:search) unless opts[:arbitrary_models]
+      else
+        params["query"] = nil
+        query_problem = true
+      end
     end
 
     if opts[:arbitrary_models] && params[:query]
@@ -1157,8 +1169,26 @@
       :reset_filters_url       => reset_filters_url,
       :cancel_filter_query_url => cancel_filter_query_url,
       :filter_query_url        => build_url(params, opts, opts[:filters], [:filter]),
-      :summary                 => summary
+      :summary                 => summary,
+      :query_problem           => query_problem
     }
   end
+
+  #Applies the layout for the Network with the given network_id to the object (contributable)
+  def update_layout(object,network_id)
+    if network_id.blank?
+      object.contribution.layout = nil
+      object.contribution.save
+    else
+      network = Network.find(network_id.to_i)
+      # Have to call .reload on permissions or the cached permissions from before "update_policy" was called are used
+      if network && find_permission_for_contributor(object.contribution.policy.permissions.reload, "Network", network_id.to_i)
+        object.contribution.layout = network.layout_name
+        object.contribution.save
+      else
+        object.errors.add_to_base("You may only choose layouts for groups that this #{object.class.name.downcase} is shared with.")
+      end
+    end
+
+  end
 end
-

Modified: branches/rails2/app/controllers/blobs_controller.rb (2809 => 2810)


--- branches/rails2/app/controllers/blobs_controller.rb	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/controllers/blobs_controller.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -150,6 +150,7 @@
           @blob.contribution.update_attributes(params[:contribution])
         
           policy_err_msg = update_policy(@blob, params)
+          update_layout(@blob, params[:layout])
         
           update_credits(@blob, params)
           update_attributions(@blob, params)
@@ -195,6 +196,7 @@
         policy_err_msg = update_policy(@blob, params)
         update_credits(@blob, params)
         update_attributions(@blob, params)
+        update_layout(@blob, params[:layout])
         
         if policy_err_msg.blank?
           flash[:notice] = 'File was successfully updated.'

Modified: branches/rails2/app/controllers/feedback_controller.rb (2809 => 2810)


--- branches/rails2/app/controllers/feedback_controller.rb	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/controllers/feedback_controller.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -23,7 +23,7 @@
     else
       if captcha_valid?(params[:feedback][:captcha_id], params[:feedback][:captcha_validation])
     
-        from_user = params[:from] + ' (' + (!params[:email].blank? ? params[:email] : 'no email') + ')';
+        from_user = ( params[:from].blank? ? 'no from': params[:from] ) + ' (' + (!params[:email].blank? ? params[:email] : 'no email') + ')';
         Mailer.deliver_feedback(from_user, params[:subject], params[:content])
     
         respond_to do |format|
@@ -33,7 +33,7 @@
       else
         respond_to do |format|
           flash[:error] = 'Your feedback has not been submitted. CAPTCHA was not entered correctly.'
-          format.html { redirect_to "/feedback?from="+params[:from]+"&email="+params[:email]+"&subject="+params[:subject]+"&content="+params[:content] }
+          format.html { redirect_to "/feedback?from="+String(params[:from])+"&email="+String(params[:email])+"&subject="+String(params[:subject])+"&content="+String(params[:content]) }
         end
       end
     end

Modified: branches/rails2/app/controllers/memberships_controller.rb (2809 => 2810)


--- branches/rails2/app/controllers/memberships_controller.rb	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/controllers/memberships_controller.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -155,10 +155,10 @@
       end
       
       respond_to do |format|
+
         if @membership.save
-          
-          # Take into account network's "auto accept" setting
-          if (@membership.network.auto_accept)
+          # Take into account network's new member policy setting
+          if (@membership.network.open?)
             @membership.accept!
             
             begin
@@ -170,7 +170,7 @@
             end
             
             flash[:notice] = 'You have successfully joined the Group.'
-          else
+          elsif (@membership.network.membership_by_request?)
             @membership.user_establish!
             
             begin

Modified: branches/rails2/app/controllers/networks_controller.rb (2809 => 2810)


--- branches/rails2/app/controllers/networks_controller.rb	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/controllers/networks_controller.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -46,9 +46,9 @@
   
   # POST /networks/1;membership_invite
   def membership_invite
-            
-    if (@membership = Membership.new(:user_id => params[:user_id], :network_id => @network.id, :message => params[:membership][:message]) unless Membership.find_by_user_id_and_network_id(params[:user_id], @network.id) or Network.find(@network.id).owner? params[:user_id])
-      
+    @membership = Membership.new(:user_id => params[:user_id], :network_id => @network.id, :message => params[:membership][:message], :invited_by => current_user)
+
+    unless address@hidden || Membership.find_by_user_id_and_network_id(params[:user_id], @network.id) || Network.find(@network.id).owner?(params[:user_id])
       @membership.user_established_at = nil
       @membership.network_established_at = nil
       if @membership.message.blank?
@@ -450,10 +450,11 @@
   end
   
   def find_network_auth_admin
-    begin
-      @network = Network.find(params[:id], :include => [ :owner, :memberships ])
-      raise unless @network.administrator?(current_user.id)
-    rescue ActiveRecord::RecordNotFound
+    if @network = Network.find_by_id(params[:id], :include => [ :owner, :memberships ])
+      unless @network.administrator?(current_user.id)
+        error("You must be a group administrator to invite people","")
+      end
+    else
       error("Group not found (id not authorized)", "is invalid (not owner)")
     end
   end

Modified: branches/rails2/app/controllers/packs_controller.rb (2809 => 2810)


--- branches/rails2/app/controllers/packs_controller.rb	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/controllers/packs_controller.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -127,6 +127,7 @@
         
         # update policy
         policy_err_msg = update_policy(@pack, params)
+        update_layout(@pack, params[:layout])
         
         if policy_err_msg.blank?
           flash[:notice] = 'Pack was successfully created.'
@@ -155,6 +156,7 @@
       if @pack.update_attributes(params[:pack])
         @pack.refresh_tags(convert_tags_to_gem_format(params[:pack][:tag_list]), current_user) if params[:pack][:tag_list]
         policy_err_msg = update_policy(@pack, params)
+        update_layout(@pack, params[:layout])
         
         if policy_err_msg.blank?
           flash[:notice] = 'Pack was successfully updated.'

Modified: branches/rails2/app/controllers/pictures_controller.rb (2809 => 2810)


--- branches/rails2/app/controllers/pictures_controller.rb	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/controllers/pictures_controller.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -5,8 +5,9 @@
 
 class PicturesController < ApplicationController
   before_filter :login_required, :except => [:index, :show]
-  
-  before_filter :find_picture, : [:show]
+
+  before_filter :find_user, :except => [:show]
+
   before_filter :find_pictures, : [:index]
   before_filter :find_picture_auth, : [:select, :edit, :update, :destroy]
   
@@ -16,14 +17,12 @@
     if @picture.select!
       # create and save picture selection record
       PictureSelection.create(:user => current_user, :picture => @picture)
-      
-      respond_to do |format|
-        flash[:notice] = 'Picture was successfully selected as profile picture.'
-        format.html { redirect_to user_pictures_url(@picture.owner) }
-      end
-    else
-      error("Picture already selected", "already selected")
     end
+
+    respond_to do |format|
+      flash[:notice] = 'Picture was successfully selected as profile picture.'
+      format.html { redirect_to user_pictures_url(@picture.owner) }
+    end
   end
   
   # GET /users/1/pictures
@@ -61,7 +60,7 @@
     
     send_cached_data("public/pictures/show/#{width.to_i}x#{height.to_i}/#{params[:id].to_i}.jpg",
         :type => 'image/jpeg', :disposition => 'inline') {
-
+      find_picture
       img = Magick::Image.from_blob(@picture.data).first
       img = img.change_geometry("#{width}x#{height}>") do |c, r, i| i.resize(c, r) end
 
@@ -77,12 +76,6 @@
     @picture = Picture.new
   end
 
-  # GET /users/1/pictures/1;edit
-  # GET /pictures/1;edit
-  def edit
-    
-  end
-
   # POST /users/1/pictures
   # POST /pictures
   def create
@@ -102,19 +95,6 @@
     end
   end
 
-  # PUT /users/1/pictures/1
-  # PUT /pictures/1
-  def update
-    respond_to do |format|
-      if @picture.update_attributes(params[:picture])
-        flash[:notice] = 'Picture was successfully updated.'
-        format.html { redirect_to user_pictures_url(@picture.user_id) }
-      else
-        format.html { render :action ="" "edit" }
-      end
-    end
-  end
-
   # DELETE /users/1/pictures/1
   # DELETE /pictures/1
   def destroy
@@ -130,39 +110,25 @@
 protected
 
   def find_pictures
-    if params[:user_id]
-      @pictures = Picture.find(:all, :conditions => ["user_id = ?", params[:user_id]])
+    if @user
+      @pictures = @user.pictures
     elsif logged_in?
       redirect_to user_pictures_url(current_user)
-    else
-      error("Please supply a User ID", "not supplied", :user_id)
     end
   end
   
   def find_picture
-    if params[:id]
-      if picture = Picture.find(:first, :conditions => ["id = ?", params[:id]])
-        @picture = picture
-      else
-        error("Picture not found (id not found)", "is invalid (not found)")
-      end
-    else
-      error("Please supply an ID", "not supplied")
-    end
+    @picture = Picture.find(params[:id])
   end
 
   def find_picture_auth
-    if params[:user_id]
-      begin
-        @picture = Picture.find(params[:id], :conditions => ["user_id = ?", params[:user_id]])
-      rescue ActiveRecord::RecordNotFound
-        error("Picture not found (id not authorized)", "is invalid (not owner)")
-      end
-    else
-      error("Please supply a User ID", "not supplied", :user_id)
-    end
+    @picture = Picture.find(params[:id], :conditions => ["user_id = ?", current_user.id])
   end
 
+  def find_user
+    @user = User.find_by_id(params[:user_id])
+  end
+
 private
   
   def error(notice, message, attr=:id)

Modified: branches/rails2/app/controllers/workflows_controller.rb (2809 => 2810)


--- branches/rails2/app/controllers/workflows_controller.rb	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/controllers/workflows_controller.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -343,10 +343,12 @@
         end
 
         policy_err_msg = update_policy(@workflow, params)
-    
+
         # Credits and Attributions:
         update_credits(@workflow, params)
         update_attributions(@workflow, params)
+
+        update_layout(@workflow, params[:layout])
         
         # Refresh the types handler list of types if a new type was supplied this time.
         WorkflowTypesHandler.refresh_all_known_types! if params[:workflow][:type] == 'other'
@@ -501,7 +503,7 @@
         end
       end
     end
-    
+
     params[:workflow][:license_id] = nil if params[:workflow][:license_id] && params[:workflow][:license_id] == "0"
 
     respond_to do |format|
@@ -521,6 +523,8 @@
         update_credits(@workflow, params)
         update_attributions(@workflow, params)
 
+        update_layout(@workflow, params[:layout])
+
         if policy_err_msg.blank?
           flash[:notice] = 'Workflow was successfully updated.'
           format.html { redirect_to workflow_url(@workflow) }
@@ -690,6 +694,7 @@
       
       if Authorization.is_authorized?(action_name, nil, workflow, current_user)
         @latest_version_number = workflow.current_version
+
         @workflow = workflow
         if params[:version]
           if (viewing = @workflow.find_version(params[:version]))
@@ -854,6 +859,28 @@
   
 private
 
+
+  #Upon specifying a group to share with, prompts the user whether or not they want to apply the groups'
+  # custom skin
+
+  def check_sharing_with_branded_group(new_groups)
+    @groups_with_custom_layouts = nil
+    new_shared_with_groups = nil
+
+    # check if "shared with" groups has been changed in the update
+    if action == "create" && params[:group_sharing]
+      new_shared_with_groups = params[:group_sharing].keys
+    elsif action == "update" && (@shared_with_groups_pre_update != @workflow.shared_with_networks)
+      new_shared_with_groups = (@workflow.shared_with_networks - @shared_with_groups_pre_update).map { |n| n.ids }
+    end
+
+    if new_shared_with_groups && !params[:workflow][:skin]
+      # check whether an added/removed group had styling options available
+      group_ids = Conf.virtual_hosts.values.map {|v| v['group_id']} & new_shared_with_groups
+      @groups_with_custom_layouts = Network.find(group_ids)
+    end
+  end
+
   def error(notice, message, attr=:id)
     flash[:error] = notice
     (err = Workflow.new.errors).add(attr, message)

Modified: branches/rails2/app/helpers/application_helper.rb (2809 => 2810)


--- branches/rails2/app/helpers/application_helper.rb	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/helpers/application_helper.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -7,20 +7,8 @@
 module ApplicationHelper
   require 'country_codes'
   
-  def my_page?(contributor_id, contributor_type="User")
-    #logged_in? and current_user.id.to_i == contributor_id.to_i and current_user.class.to_s == contributor_type.to_s
-
-    return false unless logged_in?
-    
-    case contributor_type.to_s
-    when "User"
-      return current_user.id.to_i == contributor_id.to_i
-    when "Network"
-      return false unless Network.find(:first, :conditions => ["id = ? AND user_id = ?", contributor_id, current_user.id])
-      return true
-    else
-      return false
-    end
+  def my_page?(contributor)
+    logged_in? && contributor == current_user
   end
   
   def mine?(thing)
@@ -799,7 +787,7 @@
   def expand_image(margin_left="0.3em")
     image_tag "folds/unfold.png", :style => "margin-left: #{margin_left}; vertical-align: middle;", :alt => 'Expand'
   end
-  
+  
   def user_tags_for_thing(taggable, user_id)
     return [] if taggable.nil? or user_id.nil? 
     
@@ -827,7 +815,7 @@
 
     return tags
   end
-
+
   def highlight_all(text, string)
     rtn = text
     
@@ -1605,4 +1593,21 @@
 
     result
   end
+
+  #Selects layout for contributables/groups or uses site's default
+  def configure_layout
+    contributable = (@workflow || @pack || @blog_post || @blob)
+    layout = nil
+
+    if params["layout_preview"]
+      layout = Conf.layouts[params["layout_preview"]]
+    elsif contributable && contributable.contribution
+      layout = Conf.layouts[contributable.contribution.layout]
+    elsif @network
+      layout = @network.layout
+    end
+
+    @layout = layout || {"layout" => Conf.page_template, "stylesheets" => [Conf.stylesheet]}
+  end
+
 end

Modified: branches/rails2/app/models/membership.rb (2809 => 2810)


--- branches/rails2/app/models/membership.rb	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/models/membership.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -8,8 +8,12 @@
 
   belongs_to :network
 
+  belongs_to :invited_by, :class_name => "User", :foreign_key => "inviter_id"
+
   validates_presence_of :user_id, :network_id
 
+  validate :membership_allowed
+
 #  validates_each :user_id do |model, attr, value|
 #    model.errors.add attr, "already member" if model.network.member? value
 #  end
@@ -69,4 +73,13 @@
     end
   end
 
+  private
+
+  def membership_allowed
+    #Can only invite people in a closed group if you're an administrator
+    if self.network.invitation_only? && !self.network.administrators.include?(self.invited_by)
+      errors.add_to_base("This group is not open to membership requests.")
+    end
+  end
+
 end

Modified: branches/rails2/app/models/network.rb (2809 => 2810)


--- branches/rails2/app/models/network.rb	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/models/network.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -182,4 +182,49 @@
     # filter out blogs until they've gone completely
     c.select do |x| x.class != Blog end
   end
+
+  # New member policy
+  # Adapter from #3 of: http://zargony.com/2008/04/28/five-tips-for-developing-rails-applications
+  NEW_MEMBER_POLICY_OPTIONS = [
+                                [:open,"Open to anyone"],
+                                [:by_request,"Membership by request"],
+                                [:invitation_only,"Invitation only"]
+                              ]
+
+  validates_inclusion_of :new_member_policy, :in => NEW_MEMBER_POLICY_OPTIONS.map {|o| o[0]}
+
+  def new_member_policy
+    read_attribute(:new_member_policy).to_sym
+  end
+
+  def new_member_policy=(value)
+    write_attribute(:new_member_policy, value.to_s)
+  end
+
+  def open?
+    new_member_policy == :open
+  end
+
+  def membership_by_request?
+    new_member_policy == :by_request
+  end
+
+  def invitation_only?
+    new_member_policy == :invitation_only
+  end
+
+  #Returns the layout defined for this network in settings.yml > layouts:
+  def layout_name
+    Conf.layouts.each do |k,v|
+      if v["network_id"] == id
+        return k
+      end
+    end
+
+    return nil
+  end
+
+  def layout
+    Conf.layouts[layout_name]
+  end
 end

Modified: branches/rails2/app/models/pack.rb (2809 => 2810)


--- branches/rails2/app/models/pack.rb	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/models/pack.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -150,7 +150,7 @@
       end +
       cgi.div("class" => "pack_description") do
         cgi.h3 {"Description"} +
-        cgi.p { (self.description.nil? || self.description.empty? ? "none" : self.description ) }
+        cgi.p { (self.description_html.nil? || self.description_html.empty? ? "none" : self.description_html ) }
       end
     end
     

Modified: branches/rails2/app/models/workflow.rb (2809 => 2810)


--- branches/rails2/app/models/workflow.rb	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/models/workflow.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -55,12 +55,12 @@
 
   has_previews
 
-  explicit_versioning(:version_column => "current_version", 
+  explicit_versioning(:version_column => "current_version",
                       :extra_attributes => ["image", "svg"],
                       :white_list_columns => ["body"]) do
     
     format_attribute :body
-    
+
     belongs_to :content_blob
     belongs_to :content_type
 

Modified: branches/rails2/app/views/blog_posts/_post.rhtml (2809 => 2810)


--- branches/rails2/app/views/blog_posts/_post.rhtml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/views/blog_posts/_post.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -1,7 +1,7 @@
 <p>
   <b><%=h post.title %></b> (<%=datetime post.created_at, false %>)
   
-  <% if my_page?(post.blog.contribution.contributor_id, post.blog.contribution.contributor_type) %>
+  <% if my_page?(post.blog.contribution.contributor) %>
      <%= icon "edit", edit_blog_blog_post_path(post.blog, post) %>
      <%= icon "destroy", blog_blog_post_path(post.blog, post), nil, :confirm => "Are you sure?", :method => "delete" %>
   <% end %>

Modified: branches/rails2/app/views/blog_posts/show.rhtml (2809 => 2810)


--- branches/rails2/app/views/blog_posts/show.rhtml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/views/blog_posts/show.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -1,3 +1,9 @@
+<% if logged_in? && Authorization.is_authorized?("edit", nil, @blog_post.blog, current_user) %>
+  <ul class="sectionIcons">
+    <li><%= link_to 'Edit Blog Post', edit_blog_post_path(@blog_post.blog, @blog_post) %></li>
+  </ul>
+<% end %>
+
 <p>
   <b>Blog:</b>
   <%=h @blog_post.blog_id %>

Deleted: branches/rails2/app/views/blogs/_subnav.rhtml ( => )


Modified: branches/rails2/app/views/content/_index.rhtml
===================================================================
--- branches/rails2/app/views/content/_index.rhtml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/views/content/_index.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -77,6 +77,11 @@
             <% end %>
             <input class="submit" type="submit" value="Search"></input>
           </div>
+          <% if @pivot[:query_problem] %>
+            <div class="search_query_problem">
+              There was a problem with your search query.
+            </div>
+          <% end %>
           <% if params[:query] && controller.class != SearchController %>
             <div class="remove_search_query">
               <%= link_to("Remove search query", url_for(request.query_parameters.merge({ "query", nil }))) -%>

Modified: branches/rails2/app/views/contributions/_sharing_form.rhtml (2809 => 2810)


--- branches/rails2/app/views/contributions/_sharing_form.rhtml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/views/contributions/_sharing_form.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -144,25 +144,76 @@
 		<!-- Explicit Group Permissions -->
 		<p><strong>Share with my Groups:</strong></p>
 
-		<div id="group_sharing_box" class="box_editing" style="padding-left: 1em; font-size: 93%;">
-      <% for n in (current_user.networks + current_user.networks_owned) %>
-          <p>
-          	<% perm = find_permission_for_contributor(perms, "Network", n.id) if edit -%>
-						<label for="" n.id %>">
-							<input <%= 'checked' if perm %> style="margin-right: 0.3em;"
-          		value="<%= n.id %>" type="checkbox" name="group_sharing[<%= n.id %>][id]" id="cb_group_sharing_<%= n.id %>" />
-						  <%= h(n.title) %>
-						</label>
-						<select name="group_sharing[<%= n.id %>][level]" style="font-size: 85%; margin: 0 0.5em;">
-							<option value="0" <%= 'selected="selected"' if perm and perm.level == 0 %>>View only</option>
-							<option value="1" <%= 'selected="selected"' if !edit or !perm or (perm and perm.level == 1) %>>View and Download only</option>
-							<option value="2" <%= 'selected="selected"' if perm and perm.level == 2 %>>View, Download and Update</option>
-						</select>
-					</p>
-        <% end %>
-		</div>
+    <div id="group_sharing_box" class="box_editing" style="padding-left: 1em; font-size: 93%;">
+      <% applicable_networks = (current_user.networks + current_user.networks_owned) %>
+      <% applicable_networks.each do |n| %>
+        <p>
+          <% perm = find_permission_for_contributor(perms, "Network", n.id) if edit -%>
+          <label for="" n.id %>">
+            <input class="group_sharing" <%= 'checked' if perm %> style="margin-right: 0.3em;"
+                   value="<%= n.id %>" type="checkbox" name="group_sharing[<%= n.id %>][id]" id="cb_group_sharing_<%= n.id %>"
+                    this.checked);"/>
+            <%= h(n.title) %>
+          </label>
+          <select name="group_sharing[<%= n.id %>][level]" style="font-size: 85%; margin: 0 0.5em;">
+            <option value="0" <%= 'selected="selected"' if perm and perm.level == 0 %>>View only</option>
+            <option value="1" <%= 'selected="selected"' if !edit or !perm or (perm and perm.level == 1) %>>View and Download only</option>
+            <option value="2" <%= 'selected="selected"' if perm and perm.level == 2 %>>View, Download and Update</option>
+          </select>
+        </p>
+      <% end %>
+      <br/>
+      <% if %w(Workflow Pack File).include?(c_type) %>
+        <div id="layout_options_box">
+          <strong>Layout:</strong>
+          <div class="box_infotext" style="margin: 1em 0">
+            <p>
+              One or more of the groups you have elected to share this <%= c_type -%> with have custom layouts specified.
+              To apply a group's custom layout to this <%= c_type -%>'s page, choose one from the list below or select
+              "Default" to keep the <%= Conf.sitename -%> default layout. This setting can be changed at any time by
+              visiting the 'edit' page.
+            </p>
+          </div>
+          <% selected_option = (Conf.layouts[contributable.contribution.layout]["network_id"] unless
+              contributable.contribution.nil? || contributable.contribution.layout.nil?) %>
+          <%= select_tag "layout", "<option value="">Default</option>" +
+              options_from_collection_for_select(applicable_networks.select {|n| n.layout_name}, 'id','title', selected_option) %>
+          <%# TODO: In Rails 2, have a link that allows a user to preview the selected layout using polymorphic_path %>
+        </div>
+      <% end %>
+    </div>
   </div>
 </div>
 
 <script>update_sharing(<%= @sharing_mode %>)</script>
+<script type="text/_javascript_">
+
+  function toggle_layout_option(id, enable) {
+    var option = $$('select#layout option[value=' + id + ']').first();
+
+    //If a "share with group" box is unticked, and that group's layout is selected, go to default.
+    if(!enable){
+      if($('layout').selectedIndex == option.index){
+        $('layout').selectedIndex = 0;
+      }
+    }
+
+    //Disable/enable option in dropdown menu
+    option.disabled = !enable;
+
+    //If all options except "default" are disabled, hide the layout option box
+    if($$('select#layout option[disabled]').size() == ($$('select#layout option').size() - 1)) {
+      $('layout_options_box').hide();
+    }
+    else {
+      $('layout_options_box').show();
+    }
+  }
+
+  //Initial state
+  $$('input.group_sharing').each (function (box) {
+    toggle_layout_option(box.value, box.checked);
+  });
+</script>
+
 <% if update_perms -%><script>update_updating(<%= @updating_mode %>)</script><% end -%>

Modified: branches/rails2/app/views/friendships/index.rhtml (2809 => 2810)


--- branches/rails2/app/views/friendships/index.rhtml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/views/friendships/index.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -1,6 +1,6 @@
 <% if @user %>
 
-  <% if my_page? @user.id %>
+  <% if my_page? @user %>
     
     <% unless @user.friendships_pending.empty? %>
       <h2>You need to respond to</h2>

Modified: branches/rails2/app/views/friendships/show.rhtml (2809 => 2810)


--- branches/rails2/app/views/friendships/show.rhtml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/views/friendships/show.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -1,6 +1,6 @@
 <h1>Friendship</h1>
 
-<% display_user = !my_page?(@friendship.user_id) %>
+<% display_user = !my_page?(@friendship.user) %>
 <% display_user_instance = display_user ? @friendship.user : @friendship.friend %>
 
 
@@ -33,7 +33,7 @@
 				      <b>Accepted at:</b><br/>
 			        <%=datetime @friendship.accepted_at %>
 		        </p>
-		      <% elsif my_page? @friendship.friend_id %>
+		      <% elsif my_page? @friendship.friend %>
 		        <% if @friendship.message %>
 						  <p style="margin-top: 1.5em; font-size: 93%; text-align: center;">
 							  <b>Message from user:</b><br/>
@@ -55,7 +55,7 @@
 <br/>
 <center>
   <div class="box_currentuser_specific" style="width: 500px; padding-bottom: 0;">
-    <% if my_page? @friendship.friend_id %>
+    <% if my_page? @friendship.friend %>
 			<p style="color: #990000; font-size: 108%; text-align: center; padding-top: 0.5em;">
 			  <b><i>Your confirmation needed</i></b><br/>
 			</p>

Copied: branches/rails2/app/views/layouts/_alerts.rhtml (from rev 2809, trunk/app/views/layouts/_alerts.rhtml) (0 => 2810)


--- branches/rails2/app/views/layouts/_alerts.rhtml	                        (rev 0)
+++ branches/rails2/app/views/layouts/_alerts.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -0,0 +1,14 @@
+<% if flash[:error] %>
+  <div id="error_flash" class="box_standout">
+    <%= link_to_function image_tag("close.gif", :style => "float: right;"),
+                         visual_effect(:toggle_slide, "error_flash", :duration => 0.3) %>
+    <%= white_list flash[:error] %>
+  </div>
+<% end %>
+<% if flash[:notice] %>
+  <div id="notice_flash" class="box_standout">
+    <%= link_to_function image_tag("close.gif", :style => "float: right;"),
+                         visual_effect(:toggle_slide, "notice_flash", :duration => 0.3) %>
+    <%= white_list flash[:notice] %>
+  </div>
+<% end %>
\ No newline at end of file

Copied: branches/rails2/app/views/layouts/_elico.rhtml (from rev 2809, trunk/app/views/layouts/_elico.rhtml) (0 => 2810)


--- branches/rails2/app/views/layouts/_elico.rhtml	                        (rev 0)
+++ branches/rails2/app/views/layouts/_elico.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -0,0 +1,49 @@
+<%# Defines a new header, then calls main myExperiment layout %>
+
+<% content_for :header do %>
+</div>
+
+<div id="elico_header">
+  <div class="logo">
+    <div style="float: left; margin-bottom: 0.5em">
+      <img src="" style="float: left; vertical-align: middle; width: 60px; height: 60px"/>
+      <div style="float: left; margin-top: 1em; margin-left: 1em">
+        <div style="font-size: 220%; font-weight: bold; vertical-align: middle">Data Mining Portal</div>
+        <div style="margin: 0.5em 0 0 1em">
+          on <%= link_to image_tag("/images/logo_tiny.png", :style=>"-moz-border-radius: 2px; border-radius: 2px; vertical-align: middle;border: 1px solid white"), "/" -%>
+        </div>
+      </div>
+    </div>
+    <div style="float: right; font-size: 120%; margin-top: 1.5em">
+      e-Laboratory for Interdisciplinary Collaborative Data Mining
+    </div>
+    <br class="clearer"/>
+  </div>
+  <div id="elico_links_bar">
+    <div id="inner">
+      <div style="float: left;" class="links">
+        <%= link_to "About", "http://www.e-lico.eu/?q=node/4", :target => '_blank' %> |
+        <%= link_to "Mailing List", "http://lists.e-lico.eu/mailman/listinfo/dm-myexperiment", :target => '_blank' %> |
+        <%= link_to "Publications", "http://www.e-lico.eu/?q=publications", :target => '_blank' %>
+      </div>
+      <div style="float: right;" class="links">
+        <%= render :partial => 'layouts/user_links' %>
+      </div>
+      <br class="clearer"/>
+    </div>
+  </div>
+</div>
+
+<div id="doc2" class="yui-t4" style="*overflow: visible; *height: auto">
+  <div id="hd">
+    <div id="myexp_tabs">
+      <%= render :partial => 'layouts/tab_bar' %>
+    </div>
+    <div id="myexp_searchbar">
+      <%= render :partial => "layouts/search" %>
+    </div>
+  </div>
+<% end %>
+
+<%# TODO: In rails 2, this can possibly be removed, and the layout specified when rendering the partial in application.rhtml %>
+<%= render :partial => "layouts/myexperiment" %>

Modified: branches/rails2/app/views/layouts/_footer.rhtml (2809 => 2810)


--- branches/rails2/app/views/layouts/_footer.rhtml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/views/layouts/_footer.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -47,4 +47,3 @@
 		</tr>
 	</table>
 </div>
-

Modified: branches/rails2/app/views/layouts/_myexperiment.rhtml (2809 => 2810)


--- branches/rails2/app/views/layouts/_myexperiment.rhtml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/views/layouts/_myexperiment.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -1,121 +1,106 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-  <head>
-    <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
-    <%= t :site => "#{Conf.sitename} &#45; #{controller_visible_name(controller.controller_name.humanize)}", :separator => "&#45;" %>
-<% if @lod_rdf %>    <link rel="alternate" href="" @lod_rdf -%>" type="application/rdf+xml" title="RDF+XML" /><% end %>
-<% if @lod_xml %>    <link rel="alternate" href="" @lod_xml -%>" type="application/xml" title="REST XML" /><% end %>
-    <link rel="shortcut icon" href="" type="image/x-icon"/>
-    <%= stylesheet_link_tag 'reset-fonts-grids' %>
-    <%= stylesheet_link_tag 'base-min' %>
-    <%= stylesheet_link_tag 'acts_as_taggable_stylesheet' %>
-    <%= stylesheet_link_tag 'star_rating' %>
-    <%= stylesheet_link_tag Conf.stylesheet %>
-    <%= stylesheet_link_tag 'gadgets' %>
-    
-    <% if controller.action_name.downcase == "timeline" %>
-      <script src="" type="text/_javascript_"></script>
-    <% end -%>
-    
-    <%= _javascript__include_tag :defaults %>
-    <%= _javascript__include_tag "boxover.js" %>
-    
-    <%= render :partial => "layouts/feed_link_tags" %>
+<head>
+  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
+  <%= t :site => "#{Conf.sitename} &#45; #{controller_visible_name(controller.controller_name.humanize)}", :separator => "&#45;" %>
+  <% if @lod_rdf %><link rel="alternate" href="" @lod_rdf -%>" type="application/rdf+xml" title="RDF+XML" /><% end %>
+  <% if @lod_xml %><link rel="alternate" href="" @lod_xml -%>" type="application/xml" title="REST XML" /><% end %>
+  <link rel="shortcut icon" href="" type="image/x-icon"/>
+  <%= stylesheet_link_tag 'reset-fonts-grids', 'base-min', 'acts_as_taggable_stylesheet', 'star_rating', 'gadgets', address@hidden"stylesheets"] %>
+  <%= _javascript__include_tag :defaults, "boxover.js" %>
 
-    <% if @extra_head_content %>
-      <%= @extra_head_content -%>
-    <% end %>
+  <% if controller.action_name.downcase == "timeline" %>
+    <script src="" type="text/_javascript_"></script>
+  <% end -%>
 
-  </head>
-  <body>
-    <div id="doc2" class="yui-t4">
-      <div id="hd">
-          <div id="myexp_header">
-            <div class="logo">
+  <%= render :partial => "layouts/feed_link_tags" %>
+
+  <%= yield :head_options -%>
+</head>
+<body>
+
+<div id="doc2" class="yui-t4">
+
+  <%# TODO: Rails 2: '@content_for_x' has changed to 'content_for?(:x)' in later versions of rails %>
+  <% if @content_for_header %>
+    <%= yield :header %>
+  <% else %>
+    <div id="hd">
+      <div id="myexp_header">
+        <div class="logo">
+          <% if @content_for_logo %>
+            <%= yield :logo %>
+          <% else %>
             <%= link_to image_tag(Conf.site_logo), "/" %>
+          <% end %>
+          <div id="site_info_links" class="links">
+            <% if @content_for_site_info_links %>
+              <%= yield :site_info_links %>
+            <% else %>
+              <%= render :partial => 'layouts/site_info_links' %>
+            <% end %>
           </div>
-          <div class="links">
-            <div style="text-align: left; float: left; width: 34%; padding-top: 6px;">
-              <span><b><%= link_to "About", "http://wiki.myexperiment.org/", :target => '_blank' %></b></span>
-              <span>&nbsp;|&nbsp;</span>
-              <span><b><%= link_to "Mailing List", "http://lists.nongnu.org/mailman/listinfo/myexperiment-discuss", :target => '_blank' %></b></span>
-              <span>&nbsp;|&nbsp;</span>
-              <span><b><%= link_to "Publications", "http://wiki.myexperiment.org/index.php/Papers", :target => '_blank' %></b></span>
-            </div>
-            <div style="text-align: right; float: right; width: 64%;">
-              <% if logged_in? -%>
-                <span><b><%= signout_link -%></b></span>
-              <% else -%>
-                <span><b><%= icon "login", new_session_url, nil, nil, "Log in" -%></b></span>
-                <span>&nbsp;|&nbsp;</span>
-                <span><b><%= icon "user", new_user_url, nil, nil, "Register" -%></b></span>
-              <% end %>
-              <span>&nbsp;|&nbsp;</span>
-              <span><b><%= icon "feedback", "/feedback", nil, nil, "Give us Feedback" -%></b></span>
-              <span>&nbsp;|&nbsp;</span>
-              <span><b><%= icon "user-invite", invite_users_path, nil, nil, "Invite" -%></b></span>
-            </div>
-            <div class="clearer">&nbsp;</div>
-          </div>
-          <div class="clearer">&nbsp;</div>
         </div>
-        <div>
-          <ul class="tabnav">
-                                          <% Conf.main_tabs.each do |tab| %>
-                                            <li <%= (tab['controller'] && controller.controller_name.match(tab['controller'])) ? 'id="selected_tabnav"' : '' %>>
-                                              <%= link_to(tab['label'], tab['link']) -%>
-                                            </li>
-                                          <% end %>
-          </ul>
+        <div id="user_links" class="links">
+          <%= render :partial => 'layouts/user_links' %>
         </div>
-          <div id="myexp_searchbar"><%= render :partial => "layouts/search" %></div>
+        <br class="clearer"/>
       </div>
-      <div id="bd">
-        <div id="yui-main"> 
-            <div class="yui-b">
-              <div id="myexp_breadcrumbs_bar">
-                <%= render :partial => "layouts/breadcrumbs_bar" %>
-              </div>
-              <div id="myexp_content">
-                <% if flash[:error] %>
-                  <div id="error_flash" class="box_standout" style="color: red; font-weight: bold; margin-bottom: 1.5em; line-height: 1.4;">
-                    <%= link_to_function image_tag("close.gif", :style => "float: right;"), 
-                                         visual_effect(:toggle_slide, "error_flash", :duration => 0.3) %>
-                    <%= white_list flash[:error] %>
-                  </div>
-                <% end %>
-                <% if flash[:notice] %>
-                  <div id="notice_flash" class="box_standout" style="color: green; font-weight: bold; margin-bottom: 1.5em; line-height: 1.4;">
-                    <%= link_to_function image_tag("close.gif", :style => "float: right;"), 
-                                         visual_effect(:toggle_slide, "notice_flash", :duration => 0.3) %>
-                    <%= white_list flash[:notice] %>
-                  </div>
-                <% end %>
-                
-                <%= render :partial => "subnav" %>
-                
-                <%= yield :layout %>
-            </div>
+      <div id="myexp_tabs">
+        <%= render :partial => 'layouts/tab_bar' %>
+      </div>
+      <div id="myexp_searchbar">
+        <%= render :partial => "layouts/search" %>
+      </div>
+    </div>
+  <% end %>
+
+
+  <% if @content_for_body %>
+    <%= yield :body %>
+  <% else %>
+    <div id="bd">
+      <div id="yui-main">
+        <div class="yui-b">
+          <div id="myexp_breadcrumbs_bar">
+            <%= render :partial => "layouts/breadcrumbs_bar" %>
           </div>
+          <div id="myexp_content">
+            <%= render :partial => 'layouts/alerts' %>
+
+            <%= yield :layout %>
+
+          </div>
         </div>
-        <div id="myexp_sidebar" class="yui-b">
-          <%= render :partial => "layouts/sidebar" %>
-        </div>
       </div>
+      <div id="myexp_sidebar" class="yui-b">
+        <%= render :partial => "layouts/sidebar" %>
+      </div>
+    </div>
+  <% end %>
+
+
+  <% if @content_for_footer %>
+    <%= yield :footer %>
+  <% else %>
       <% cache(:controller => 'global_cache', :action ="" 'footer') do -%>
         <div id="ft">
           <%= render :partial => "layouts/footer" %>
         </div>
-      <% end -%>
-      
-      <%= render :partial => "layouts/debug" if Conf.show_debug %> 
-    </div>
-    
-    <%= _javascript__include_tag "tabs.js" %>
-    <%= _javascript__include_tag "folds.js" %>
-    
-    <%= render :partial => "layouts/web_analytics" if Conf.google_web_analytics["enable"] %>
-  </body>
+      <br class="clearer"/>
+    <% end -%>
+  <% end %>
+
+
+  <%= render :partial => "layouts/debug" if Conf.show_debug %>
+</div>
+
+<%= _javascript__include_tag "tabs.js" %>
+<%= _javascript__include_tag "folds.js" %>
+
+<%= render :partial => "layouts/web_analytics" if Conf.google_web_analytics["enable"] %>
+
+</body>
 </html>

Copied: branches/rails2/app/views/layouts/_site_info_links.rhtml (from rev 2809, trunk/app/views/layouts/_site_info_links.rhtml) (0 => 2810)


--- branches/rails2/app/views/layouts/_site_info_links.rhtml	                        (rev 0)
+++ branches/rails2/app/views/layouts/_site_info_links.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -0,0 +1,3 @@
+<%= link_to "About", "http://wiki.myexperiment.org/", :target => '_blank' %> |
+<%= link_to "Mailing List", "http://lists.nongnu.org/mailman/listinfo/myexperiment-discuss", :target => '_blank' %> |
+<%= link_to "Publications", "http://wiki.myexperiment.org/index.php/Papers", :target => '_blank' %>
\ No newline at end of file

Copied: branches/rails2/app/views/layouts/_tab_bar.rhtml (from rev 2809, trunk/app/views/layouts/_tab_bar.rhtml) (0 => 2810)


--- branches/rails2/app/views/layouts/_tab_bar.rhtml	                        (rev 0)
+++ branches/rails2/app/views/layouts/_tab_bar.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -0,0 +1,5 @@
+<div class="tabnav">
+  <% Conf.main_tabs.each do |tab| %>
+    <%= link_to(tab['label'], tab['link'], :class => "tab", :id => (tab['controller'] && controller.controller_name.match(tab['controller'])) ? 'selected_tabnav' : '') -%>
+  <% end %>
+</div>

Copied: branches/rails2/app/views/layouts/_user_links.rhtml (from rev 2809, trunk/app/views/layouts/_user_links.rhtml) (0 => 2810)


--- branches/rails2/app/views/layouts/_user_links.rhtml	                        (rev 0)
+++ branches/rails2/app/views/layouts/_user_links.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -0,0 +1,8 @@
+<% if logged_in? -%>
+  <%= signout_link -%> |
+<% else -%>
+  <%= icon "login", new_session_url, nil, nil, "Log in" -%> |
+  <%= icon "user", new_user_url, nil, nil, "Register" -%> |
+<% end %>
+<%= icon "feedback", "/feedback", nil, nil, "Give us Feedback" -%> |
+<%= icon "user-invite", invite_users_path, nil, nil, "Invite" -%>
\ No newline at end of file

Modified: branches/rails2/app/views/layouts/application.rhtml (2809 => 2810)


--- branches/rails2/app/views/layouts/application.rhtml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/views/layouts/application.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -1 +1,2 @@
-<%= render :partial => Conf.page_template %>
+<% configure_layout %>
+<%= render :partial => @layout["layout"] %>
\ No newline at end of file

Modified: branches/rails2/app/views/memberships/_table.rhtml (2809 => 2810)


--- branches/rails2/app/views/memberships/_table.rhtml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/views/memberships/_table.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -25,7 +25,7 @@
     <td><%= "<b>" unless membership.accepted? %><%=datetime membership.created_at, false %><%= "</b>" unless membership.accepted? %></td>
     <td><%= "<b>" unless membership.accepted? %><%=datetime(membership.accepted_at, false) || "Pending" %><%= "</b>" unless membership.accepted? %></td>
     <td class="actions">
-      <% if my_page? membership.user.id or (logged_in? and membership.network.administrator?(current_user.id)) %>
+      <% if my_page? membership.user or (logged_in? and membership.network.administrator?(current_user.id)) %>
         <%= icon "show", user_membership_path(membership.user_id, membership), nil, nil, "View" %>
 				<% if membership.accepted? %>
 					<%= icon "destroy", user_membership_path(membership.user_id, membership), nil, { :confirm => "Are you sure?", :method => :delete }, "Remove" %>

Modified: branches/rails2/app/views/memberships/index.rhtml (2809 => 2810)


--- branches/rails2/app/views/memberships/index.rhtml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/views/memberships/index.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -1,6 +1,6 @@
 <% if @user %>
 
-	<% if my_page? @user.id %>
+	<% if my_page? @user %>
 
 		<h1>My Memberships</h1>
 

Modified: branches/rails2/app/views/memberships/new.rhtml (2809 => 2810)


--- branches/rails2/app/views/memberships/new.rhtml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/views/memberships/new.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -1,60 +1,45 @@
 <h1>New Membership Request</h1>
+<div style="margin: auto; width: 500px">
 
-<%= error_messages_for :membership %>
+  <%= error_messages_for :membership %>
 
-<% form_for(:membership, :url ="" user_memberships_path(params[:user_id]), :html => {:id => 'memb_request_form'}) do |f| %>
-	<%= f.hidden_field :user_id, :value => current_user.id %>
+  <% form_for(:membership, :url ="" user_memberships_path(params[:user_id]), :html => {:id => 'memb_request_form'}) do |f| %>
+    <%= f.hidden_field :user_id, :value => current_user.id %>
 
-	<center>
-		<div class="box_standout" style="line-height: 1.6; width: 400px;">
-			<% if params[:network_id] -%>
-				<%= f.hidden_field :network_id, :value => @network.id %>
+    <div class="box_standout">
+      <% if params[:network_id] -%>
+        <%= f.hidden_field :network_id, :value => @network.id %>
 
-				<b>Send a request to join the group:</b>
-				<br/>
-				<%= link_to_function h(@network.title) + expand_image, 
-				                     visual_effect(:toggle_blind, "group_box", :duration => 0.3) -%>
-				 <br/>
-				<small>(Administrator: <%= name @network.user_id -%>)</small>
-			<% else -%>
-				<b>Select group:</b><br/>
-				<%= select_tag "membership[network_id]", options_from_collection_for_select(Network.find(:all, :order => "title ASC"), :id.to_i, :title), :style => "width: 360px; margin-top: 0.3em; margin-bottom: 0.5em" %>
-			<% end -%>
-		</div>
-	</center>
+        <b>Send a request to join the group:</b>
+        <br/>
+        <%= link_to_function h(@network.title) + expand_image,
+                             visual_effect(:toggle_blind, "group_box", :duration => 0.3) -%>
+        <br/>
+        <small>(Administrator: <%= name @network.user_id -%>)</small>
+      <% else -%>
+        <b>Select group:</b><br/>
+        <%= select_tag "membership[network_id]", options_from_collection_for_select(Network.find(:all, :order => "title ASC", :conditions => ["new_member_policy != 'invitation_only'"]), :id.to_i, :title), :style => "width: 360px; margin-top: 0.3em; margin-bottom: 0.5em" %>
+      <% end -%>
+    </div>
 
-	<br/>
+    <div class="box_currentuser_specific" style="margin: 1em 0">
+      <%= info_icon_with_tooltip("This message is optional: if you leave it blank, your request will be sent without it") %>
+      <b>Message to group administrator:</b>
+      <br/>
+      <%= text_area_tag "membership[message]", "", :rows => 4, :style => "width: 370px; font-size: 93%;" -%>
+    </div>
 
-	<center>
-		<div class="box_currentuser_specific" style="text-align: center; width: 400px; font-size: 93%; padding-bottom: 1em;">
-			<center>
-				<table>
-					<tr>
-						<td style="line-height: 2; text-align: left;">
-							<%= info_icon_with_tooltip("This message is optional: if you leave it blank, your request will be sent without it") %>
-							<b>Message to group administrator:</b>
-							<br/>
-							<%= text_area_tag "membership[message]", "", :rows => 4, :style => "width: 370px; font-size: 93%;" -%>
-						</td>
-					</tr>
-				</table>
-			</center>
-		</div>
-	</center>
+    <div style="text-align: center">
+      <%= submit_tag "Send membership request", :id => "send", :style => 'width: 180px;', : "$('cancel').disabled=true;this.disabled=true;this.value='Sending your request...';this.form.submit();"  %>
+      <% cancel_links_to = params[:network_id] ? url_for(:controller => 'networks', :action ="" 'show', :id => @network.id) : url_for(:controller => 'networks', :action ="" 'index') %>
+      <input type="submit" id="cancel" value="Return to Group" style="width: 180px"  cancel_links_to -%>';return false;" />
+    </div>
 
-	<br/>
+    <% if params[:network_id] -%>
+      <div id="group_box" style="display: none; margin-top: 3em;">
+        <%= render :partial => "networks/table", :locals => { :collection => [ @network ] } %>
+      </div>
+    <% end %>
 
-	<center>
-		<%= submit_tag "Send membership request", :id => "send", :style => 'width: 180px;', : "$('cancel').disabled=true;this.disabled=true;this.value='Sending your request...';this.form.submit();"  %>
-
-		<% cancel_links_to = params[:network_id] ? url_for(:controller => 'networks', :action ="" 'show', :id => @network.id) : url_for(:controller => 'networks', :action ="" 'index') %>
-		<input type="submit" id="cancel" value="Return to Group" style="width: 180px"  cancel_links_to -%>';return false;" />
-	</center>
-
-	<% if params[:network_id] -%>
-		<div id="group_box" style="display: none; margin-top: 3em;">
-			<%= render :partial => "networks/table", :locals => { :collection => [ @network ] } %>
-		</div>
-	<% end %>
-
-<% end %>
+  <% end %>
+</div>

Modified: branches/rails2/app/views/networks/_form.rhtml (2809 => 2810)


--- branches/rails2/app/views/networks/_form.rhtml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/views/networks/_form.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -29,13 +29,12 @@
   </fieldset>
 
   <fieldset>
-    <legend>Auto Accept Join Requests</legend>
+    <legend>New Membership Policy</legend>
     <p>
-    	You can configure this group to automatically accept requests from users to join.
+    	You can specify a policy on how new members can join this group.
 		</p>
     <p>
-      <%= form.check_box :auto_accept %>
-      <b>Auto Accept Join Requests</b><br />
+      <%= form.select :new_member_policy, Network::NEW_MEMBER_POLICY_OPTIONS.map {|o| [o[1],o[0]]} %>
     </p>
   </fieldset>
   

Modified: branches/rails2/app/views/networks/_table.rhtml (2809 => 2810)


--- branches/rails2/app/views/networks/_table.rhtml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/views/networks/_table.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -76,7 +76,7 @@
 			          <% if cur_membership %>
 			            <%= icon('network-leave', user_membership_path(cur_membership.user_id, cur_membership) + "?return_to=" + groups_path, nil, { :confirm => "Are you sure want to leave this group?", :method => :delete }, 'Leave Group') %>
 			          <% end %>
-							<% elsif !current_user.membership_pending?(network.id) %>
+							<% elsif !current_user.membership_pending?(network.id) && !network.invitation_only? %>
 							  <!-- not an admin, not a member yet and hasn't got pending request -->
 								<%= request_membership_link(current_user.id, network.id) %>
 							<% end %>

Modified: branches/rails2/app/views/networks/invite.rhtml (2809 => 2810)


--- branches/rails2/app/views/networks/invite.rhtml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/views/networks/invite.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -4,86 +4,93 @@
   Here you can invite users to this group. The options are:<br/>
 </p>
 
-<% # choose, which of the DIVs will be shown & which radio button ticked -%>
-<% # on first load, has default value -%>
+<%# choose, which of the DIVs will be shown & which radio button ticked -%>
+<%# on first load, has default value -%>
 <% invite_existing_selected = invite_existing_selected?(params[:radio_choice]) -%>
 
-<label for="" radio_button_tag ("radio_invite", "existing", invite_existing_selected, : "$('radio_invite_new').checked=false;$('div_invite_existing').show();$('div_invite_new').hide();return true;" ) -%>Invite an existing <%= Conf.sitename %> user to your group</label><br/>
-<label for="" style="margin-top: 0.3em;"><%= radio_button_tag ("radio_invite", "new", !invite_existing_selected, : "$('radio_invite_existing').checked=false;$('div_invite_existing').hide();$('div_invite_new').show();return true;" ) -%>Invite someone to join <%= Conf.sitename %> and your group</label>
+<label for=""
+  <%= radio_button_tag ("radio_invite", "existing", invite_existing_selected, : "$('radio_invite_new').checked=false;$('div_invite_existing').show();$('div_invite_new').hide();return true;" ) -%>
+  Invite an existing <%= Conf.sitename %> user to your group
+</label>
+<br/>
+<label for=""
+  <%= radio_button_tag ("radio_invite", "new", !invite_existing_selected, : "$('radio_invite_existing').checked=false;$('div_invite_existing').hide();$('div_invite_new').show();return true;" ) -%>
+  Invite someone to join <%= Conf.sitename -%> and your group
+</label>
 
-<% # just one from the two of following DIVs will be shown at any one time; -%>
-<% # this represents one of two options - either to invite existing or new users to the group -%>
+<%# just one from the two of following DIVs will be shown at any one time; -%>
+<%# this represents one of two options - either to invite existing or new users to the group -%>
 
 <div id="div_invite_existing" class="box_editing" style="<%= !invite_existing_selected ? "display: none;" : "" -%>margin: 1em 0em 1em 0em;">
   <fieldset>
-  	<legend>Invite an existing <%= Conf.sitename %> user to your group</legend>
-	  <p class="box_infotext" style="margin: 0.4em 0em 0.7em 0em" >
+    <legend>Invite an existing <%= Conf.sitename %> user to your group</legend>
+    <p class="box_infotext" style="margin: 0.4em 0em 0.7em 0em" >
       Select a name from the list, type in a message to the user and click "Invite".
     </p>
 
     <% form_tag(membership_invite_group_path(@network), :method => :post) do %>
       <table cellpadding="0" cellspacing="0">
-			<tr>
-				<td>&nbsp;</td>
-				<td style="text-align: left;">User:</td>
-			  <td style="text-align: left;"><%= select_tag :user_id, options_from_collection_for_select(User.find(:all, :order => "name ASC"), :id.to_i, :name), :style => "width: 400px;" -%></td>
-			</tr>
-			<tr style="vertical-align: top;">
-				<td><%= info_icon_with_tooltip("This message is optional: if you leave it blank, your invitation will be sent without it") -%></td>
-				<td style="text-align: left;">Message:</td>
-				<td style="text-align: left;"><%= text_area_tag "membership[message]", "", :rows => 4, :style => "width: 400px" -%></td>
-      </tr>
-			<tr>
-				<td colspan="3" style="text-align: center;"><%= submit_tag "Send Invitation", :disable_with => 'Sending Invitation...' %></td>
-			</tr>
-			</table>		  		
-		<% end %>
-	</fieldset>
+        <tr>
+          <td>&nbsp;</td>
+          <td style="text-align: left;">User:</td>
+          <td style="text-align: left;"><%= select_tag :user_id, options_from_collection_for_select(User.find(:all, :order => "name ASC"), :id.to_i, :name), :style => "width: 400px;" -%></td>
+        </tr>
+        <tr style="vertical-align: top;">
+          <td><%= info_icon_with_tooltip("This message is optional: if you leave it blank, your invitation will be sent without it") -%></td>
+          <td style="text-align: left;">Message:</td>
+          <td style="text-align: left;"><%= text_area_tag "membership[message]", "", :rows => 4, :style => "width: 400px" -%></td>
+        </tr>
+        <tr>
+          <td colspan="3" style="text-align: center;"><%= submit_tag "Send Invitation", :disable_with => 'Sending Invitation...' %></td>
+        </tr>
+      </table>
+    <% end %>
+  </fieldset>
 </div>
 
 <div id="div_invite_new" class="box_editing" style="<%= invite_existing_selected ? "display: none;" : "" -%>margin: 1em 0em 1em 0em;">
-	<fieldset>
-  	<legend>Invite someone to join <%= Conf.sitename %> and your group</legend>
-	  <p class="box_infotext" style="margin: 0.4em 0em 1em 0em" >
+  <fieldset>
+    <legend>Invite someone to join <%= Conf.sitename %> and your group</legend>
+    <p class="box_infotext" style="margin: 0.4em 0em 1em 0em" >
       Type in email addresses you want to send invitations to, personal message to new users and click "Invite".
     </p>
-		
-		<% form_tag (membership_invite_external_group_path(@network), :method => :post) do %>
-		  <%= hidden_field_tag "radio_choice", "" -%>
-			<table>
-		  	<tr>
-		  		<td style="text-align: left;">
-					  <% remaining_allowance, allowance_finishes = ActivityLimit.remaining_allowance(current_user, "group_invite") -%>
-			      <%= info_icon_with_tooltip("To include several email addresses, use commas or semicolons to separate them.<br/>#{remaining_allowance ? "Please note that your current allowance is to send invitations to #{remaining_allowance} unique, valid, non-blank address(es) in the list; the allowance #{allowance_finishes ? "will be renewed after #{allowance_finishes.strftime("%H:%M on %d/%m/%Y")}" : "will not be reset"}." : "Please note that limitations on the number of invitations to be sent may apply."}") %>
+
+    <% form_tag (membership_invite_external_group_path(@network), :method => :post) do %>
+      <%= hidden_field_tag "radio_choice", "" -%>
+      <table>
+        <tr>
+          <td style="text-align: left;">
+            <% remaining_allowance, allowance_finishes = ActivityLimit.remaining_allowance(current_user, "group_invite") -%>
+            <%= info_icon_with_tooltip("To include several email addresses, use commas or semicolons to separate them.<br/>#{remaining_allowance ? "Please note that your current allowance is to send invitations to #{remaining_allowance} unique, valid, non-blank address(es) in the list; the allowance #{allowance_finishes ? "will be renewed after #{allowance_finishes.strftime("%H:%M on %d/%m/%Y")}" : "will not be reset"}." : "Please note that limitations on the number of invitations to be sent may apply."}") %>
             Email address(es) to send invitations to:<br/>
             <% email_addresses_val = ((params[:invitations].nil? || params[:invitations][:address_list].nil?) ? "" : params[:invitations][:address_list]) %>
             <%= text_field_tag "invitations[address_list]", email_addresses_val, :style => "width: 500px; margin-bottom: 0.8em;" -%><br/>
-            
+
             <%= info_icon_with_tooltip("This message is optional: if you leave it blank, default one will be sent") %>
             Personal message to include with the invitation(s):<br/>
             <% msg_text_val = ((params[:invitations].nil? || params[:invitations][:msg_text].nil?) ? "" : params[:invitations][:msg_text]) %>
             <%= text_area_tag "invitations[msg_text]", msg_text_val, :rows => 4, :style => "width: 500px" -%><br/>
-          
-					  <table style="margin-top: 1.5em;">
-							<tr>
-								<td>
-						      <% c = prepare_captcha :type => :image -%>
-									<%= captcha_image_tag c -%>
-								</td>
-								<td style="vertical-align: middle;">
-								  <%= captcha_hidden_field c, 'invitations' -%>
-									<%= captcha_label 'invitations', 'Type in the text from the image on the left:' -%><br/>
-					        <%= captcha_text_field 'invitations', :size => 40 -%>
-								</td>
-							</tr>
-						</table>
-					</td>
-			  </tr>
-			  <tr>
-			  	<td style="text-align: center;"><%= submit_tag "Send Invitations", :id => "send_button", : "if($('invitations[address_list]').value=='') { alert('Please enter email address(es) that you want to send user invitations to.');$('invitations[address_list]').focus();return(false); } else { $('radio_choice').value=($('radio_invite_existing').checked ? 'existing' : 'new');this.disabled=true;this.value='Sending...';this.form.submit(); }" -%></td>
-				</tr>
-			</table>
-		<% end %>
-		
-		</fieldset>
+
+            <table style="margin-top: 1.5em;">
+              <tr>
+                <td>
+                  <% c = prepare_captcha :type => :image -%>
+                  <%= captcha_image_tag c -%>
+                </td>
+                <td style="vertical-align: middle;">
+                  <%= captcha_hidden_field c, 'invitations' -%>
+                  <%= captcha_label 'invitations', 'Type in the text from the image on the left:' -%><br/>
+                  <%= captcha_text_field 'invitations', :size => 40 -%>
+                </td>
+              </tr>
+            </table>
+          </td>
+        </tr>
+        <tr>
+          <td style="text-align: center;"><%= submit_tag "Send Invitations", :id => "send_button", : "if($('invitations[address_list]').value=='') { alert('Please enter email address(es) that you want to send user invitations to.');$('invitations[address_list]').focus();return(false); } else { $('radio_choice').value=($('radio_invite_existing').checked ? 'existing' : 'new');this.disabled=true;this.value='Sending...';this.form.submit(); }" -%></td>
+        </tr>
+      </table>
+    <% end %>
+
+  </fieldset>
 </div>

Modified: branches/rails2/app/views/networks/show.rhtml (2809 => 2810)


--- branches/rails2/app/views/networks/show.rhtml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/views/networks/show.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -10,9 +10,7 @@
 				<span style="text-align: left;"><b>You have been invited to join this group. Awaiting your <%= link_to "confirmation", user_membership_path(current_user, Membership.find(:first, :conditions => ['network_id = ? AND user_id = ?', @network, current_user])) -%>.</b></span>
 			</div>
 		<% end %>
-	<% end %>
 
-<% if logged_in? %>
   <ul class="sectionIcons">
     <% unless mine? @network %>
 		  <% if @network.member? current_user.id  %>
@@ -20,7 +18,7 @@
 			  <% if cur_membership %>
 			    <li><%= icon('network-leave', user_membership_path(cur_membership.user_id, cur_membership), nil, { :confirm => "Are you sure want to leave this group?", :method => :delete }, 'Leave Group') %></li>
 			  <% end %>
-			<% elsif !current_user.membership_pending?(@network.id) %>
+			<% elsif !current_user.membership_pending?(@network.id) && address@hidden %>
 			  <li class="with_sep_bottom"><%= request_membership_link(current_user.id, @network.id) %></li>  
 			<% end %>
 		<% end %>
@@ -96,10 +94,12 @@
 	<% if mine? @network %>
 		<br/>
 		<div class="box_currentuser_specific">
-			<% if @network.auto_accept %>
-				You have set this Group to automatically accept all Membership Requests
-			<% else %>
-				You have set this Group to send you all Membership Requests for confirmation first
+			<% if @network.open? %>
+				You have set this Group to automatically accept all membership requests.
+			<% elsif @network.membership_by_request? %>
+				You have set this Group to require membership requests to be approved by a group administrator.
+      <% else %>
+        You have set this Group to be closed to membership requests unless invited by a group administrator.
 			<% end %>
 		</div>
 	<% end %>
@@ -118,7 +118,6 @@
 		</div>
 		<p class="heading">
 			Members
-			<a name="group_members"></a>
 		</p>
 		<div>
 			<%= render :partial => "networks/members", :locals => { :collection => others, :size => 60 } %>

Deleted: branches/rails2/app/views/pictures/_subnav.rhtml (2809 => 2810)


--- branches/rails2/app/views/pictures/_subnav.rhtml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/views/pictures/_subnav.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -1,16 +0,0 @@
-<% case controller.action_name.to_s; when "index" %>
-
-  <!-- no subnav options -->
-
-<% when "show" %>
-
-  <ul class="sectionIcons">
-o    <li><%= link_to 'Edit Picture', edit_user_picture_path(@picture.user_id, @picture) %></li>
-    <li><%= link_to 'Remove Picture', user_picture_path(@picture.user_id, @picture), :confirm => 'Are you sure?', :method => :delete %></li>
-  </ul>
-
-<% else %>
-
-  <!-- no subnav options -->
-
-<% end %>

Deleted: branches/rails2/app/views/pictures/edit.rhtml (2809 => 2810)


--- branches/rails2/app/views/pictures/edit.rhtml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/views/pictures/edit.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -1,9 +0,0 @@
-<h1>Editing Picture</h1>
-
-<%= error_messages_for :picture %>
-
-<% form_for(:picture, :url ="" user_picture_path(@picture.user_id, @picture), :html => { :method => :put }) do |f| %>
-  <p>
-    <%= submit_tag "Update", :disable_with => "Updating..." %>
-  </p>
-<% end %>

Modified: branches/rails2/app/views/pictures/index.rhtml (2809 => 2810)


--- branches/rails2/app/views/pictures/index.rhtml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/app/views/pictures/index.rhtml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -1,58 +1,46 @@
-<% if params[:user_id] %>
-  <h1>Profile Pictures</h1>
-<% end %>
+<h1>Profile Pictures</h1>
 
-<% if my_page? params[:user_id] %>
+<% if my_page? @user %>
   <ul class="sectionIcons">
-		<li><%= icon('profile', user_path(current_user), nil, nil, 'Return to Profile')%></li>
+    <li><%= icon('profile', user_path(current_user), nil, nil, 'Return to Profile')%></li>
     <li><%= icon('avatar', new_user_picture_path(current_user), nil, nil, 'Upload New Picture')%></li>
   </ul>
 <% end %>
 
 <% unless @pictures.empty? %>
 
-<br/>
+  <br/>
 
-<table class="alt_table">
-  
-<% odd_row = false -%>
-<% for picture in @pictures %>
-<% if Authorization.is_authorized?("view", nil, picture, current_user) %>
-  <tr class="<%= (odd_row = !odd_row) ? "odd_row" : "even_row" %>">
-    <td width="150">
-      <% if picture.selected? %> 
-        <%= image_tag("people.png", :size => "60x60", :text => "current profile pic") %><br/>
-        Current
+  <table class="alt_table">
+
+    <% odd_row = false -%>
+    <% for picture in @pictures %>
+      <% if Authorization.is_authorized?("view", nil, picture, current_user) %>
+        <tr class="<%= (odd_row = !odd_row) ? "odd_row" : "even_row" %>">
+          <td width="150">
+            <% if picture.selected? %>
+              <%= image_tag("people.png", :size => "60x60", :text => "current profile pic") %><br/>
+              Current
+            <% end %>
+          </td>
+          <td>
+            <%= image_tag avatar_url(picture.id, 100), :class => 'framed' %>
+          </td>
+          <td class="actions">
+            <% if my_page? picture.owner %>
+              <% unless picture.selected? %>
+                <%= icon "picture", select_user_picture_path(picture.user_id, picture), nil, nil, "Make Profile Pic" %>
+              <% end %>
+              <%= icon "destroy", user_picture_path(picture.user_id, picture), nil, { :confirm => 'Are you sure?', :method => :delete }, "Delete"  %>
+            <% end %>
+          </td>
+        </tr>
       <% end %>
-    </td>
-    <% unless params[:user_id] %>
-      <td width="150">
-        <font size="18"><%=h picture.user_id %></font>
-      </td>
     <% end %>
-    <td>
-      <% if false %>
-        <%= image_tag(url_for_file_column(picture, "data", "large")) %>
-      <% end %>
-      <%= image_tag avatar_url(picture.id, 100), :class => 'framed' %>
-    </td>
-    <td class="actions">
-      <% if my_page? picture.user_id %>
-				<% unless picture.selected? %>
-					<%= icon "picture", select_user_picture_path(picture.user_id, picture), nil, nil, "Make Profile Pic" %>
-				<% end %>
-				<%= icon "destroy", user_picture_path(picture.user_id, picture), nil, { :confirm => 'Are you sure?', :method => :delete }, "Delete"  %>
-			<% end %>
-    </td>
-  </tr>
-<% end %>
-<% end %>
-</table>
+  </table>
 
 <% else %>
 
-<p>No pictures yet!</p>
+  <p>No pictures yet!</p>
 
 <% end %>
-
-<br />

Modified: branches/rails2/config/base_schema.xml (2809 => 2810)


--- branches/rails2/config/base_schema.xml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/config/base_schema.xml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -19,6 +19,7 @@
     <column type="string"   name="label"/>
     <column type="integer"  name="content_type_id"/>
     <column type="integer"  name="license_id"/>
+    <column type="string"   name="layout"/>
 
     <index>
       <column name="contributable_id"/>

Modified: branches/rails2/config/default_settings.yml (2809 => 2810)


--- branches/rails2/config/default_settings.yml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/config/default_settings.yml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -457,3 +457,23 @@
 
 recaptcha_private:
 
+# Layouts - Gives a custom theme to a group and, when specified by the uploader, other contributions that are
+#           shared with that group
+#
+#     network_id: the ID of the group to be skinned
+#     stylesheets: a list of stylesheets to be used
+#     layout: a path to the page layout. Defines the overall structure of the page,
+#     environment: the environment for which this layout should apply (test/development/production). If not specified,
+#                  will be loaded in all environments. (OPTIONAL)
+#
+#
+#     Example:
+#
+#layouts:
+#
+#     example_layout:
+#       network_id: 123
+#       stylesheets:
+#         - styles
+#         - custom_stylesheet
+#       layout: layouts/myexperiment

Modified: branches/rails2/config/environment.rb (2809 => 2810)


--- branches/rails2/config/environment.rb	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/config/environment.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -111,3 +111,15 @@
 
 load 'config/environment_private.rb' if FileTest.exist?('config/environment_private.rb')
 
+# Fix for Ruby 1.8.7 when using Rails < 2.2
+module ActionView
+  module Helpers
+    module TextHelper
+      def truncate(text, length = 30, truncate_string = "...")
+        if text.nil? then return end
+        l = length - truncate_string.chars.to_a.size
+        (text.chars.to_a.size > length ? text.chars.to_a[0...l].join + truncate_string : text).to_s
+      end
+    end
+  end
+end

Modified: branches/rails2/config/tables.xml


(Binary files differ)

Copied: branches/rails2/db/migrate/092_add_new_member_policy_to_networks.rb (from rev 2809, trunk/db/migrate/092_add_new_member_policy_to_networks.rb) (0 => 2810)


--- branches/rails2/db/migrate/092_add_new_member_policy_to_networks.rb	                        (rev 0)
+++ branches/rails2/db/migrate/092_add_new_member_policy_to_networks.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -0,0 +1,32 @@
+class AddNewMemberPolicyToNetworks < ActiveRecord::Migration
+  def self.up
+    add_column :networks, :new_member_policy, :string, :default => "open"
+
+    Network.find(:all).each do |n|
+      if n.attributes["auto_accept"] == true
+        n.new_member_policy = :open
+      else
+        n.new_member_policy = :by_request
+      end
+      n.save
+    end
+
+    remove_column :networks, :auto_accept
+  end
+
+  #Will lose info on whether a network is invite only
+  def self.down
+    add_column :networks, :auto_accept, :boolean, :default => false
+
+    Network.find(:all).each do |n|
+      if n.attributes["new_member_policy"] == "open"
+        n.auto_accept = true
+      else
+        n.auto_accept = false
+      end
+      n.save
+    end
+
+    remove_column :networks, :new_member_policy
+  end
+end

Copied: branches/rails2/db/migrate/093_add_invited_by_to_memberships.rb (from rev 2809, trunk/db/migrate/093_add_invited_by_to_memberships.rb) (0 => 2810)


--- branches/rails2/db/migrate/093_add_invited_by_to_memberships.rb	                        (rev 0)
+++ branches/rails2/db/migrate/093_add_invited_by_to_memberships.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -0,0 +1,9 @@
+class AddInvitedByToMemberships < ActiveRecord::Migration
+  def self.up
+    add_column :networks, :inviter_id, :integer
+  end
+
+  def self.down
+    remove_column :networks, :inviter_id
+  end
+end

Modified: branches/rails2/lib/conf.rb (2809 => 2810)


--- branches/rails2/lib/conf.rb	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/lib/conf.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -169,6 +169,12 @@
     self.fetch_entry('recaptcha_private')
   end
 
+  def self.layouts
+    #TODO: Perhaps implement code that can load different/extra settings files based on current environment
+    layouts = self.fetch_entry('layouts')
+    layouts ? layouts.delete_if {|k,v| v["environment"] && (v["environment"] != ENV["RAILS_ENV"])} : {}
+  end
+
   # This method is required to create an administrator in the test fixtures
 
   def self.admins=(value)

Modified: branches/rails2/lib/rest.rb (2809 => 2810)


--- branches/rails2/lib/rest.rb	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/lib/rest.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -967,22 +967,27 @@
     # Handle the preview and svg images.  If there's a preview supplied, use
     # it.  Otherwise auto-generate one if we can.
 
-    if preview.nil? and content
-      metadata = Workflow.extract_metadata(:type => ob.content_type.title, :data ="" content)
-      preview = metadata["image"].read if metadata["image"]
-    end
+    begin
+      if preview.nil? and content
+        metadata = Workflow.extract_metadata(:type => ob.content_type.title, :data ="" content)
+        preview = metadata["image"].read if metadata["image"]
+      end
 
-    if preview
-      ob.image = preview
-    end
+      if preview
+        ob.image = preview
+      end
 
-    if svg.nil? and content
-      metadata = Workflow.extract_metadata(:type => ob.content_type.title, :data ="" content)
-      svg = metadata["image"].read if metadata["image"]
-    end
+      if svg.nil? and content
+        metadata = Workflow.extract_metadata(:type => ob.content_type.title, :data ="" content)
+        svg = metadata["image"].read if metadata["image"]
+      end
 
-    if svg
-      ob.svg = svg
+      if svg
+        ob.svg = svg
+      end
+
+    rescue
+      return rest_response(500, :reason => "Unable to extract metadata")
     end
 
     success = if (action == 'create' and opts[:query]['id'])
@@ -1466,9 +1471,12 @@
   attributes['query'] = search_query
   attributes['type'] = opts[:query]['type'] if models.length == 1
 
-  obs = paginated_search_index(search_query, models, num, page, opts[:user])
-
-  produce_rest_list(opts[:req_uri], opts[:rules], opts[:query], obs, 'search', attributes, opts[:user])
+  begin
+    obs = paginated_search_index(search_query, models, num, page, opts[:user])
+    produce_rest_list(opts[:req_uri], opts[:rules], opts[:query], obs, 'search', attributes, opts[:user])
+  rescue
+    rest_response(400, :reason => "Invalid search query")
+  end
 end
 
 def user_count(opts)
@@ -2137,6 +2145,10 @@
 # Call dispatcher
 
 def rest_call_request(req_uri, format, rules, user, query)
-  eval("#{rules['Function']}(:req_uri => req_uri, :format => format, :rules => rules, :user => user, :query => query)")
+  begin
+    eval("#{rules['Function']}(:req_uri => req_uri, :format => format, :rules => rules, :user => user, :query => query)")
+  rescue
+    return rest_response(500)
+  end
 end
 

Copied: branches/rails2/public/images/elico_back1.png (from rev 2809, trunk/public/images/elico_back1.png)


(Binary files differ)

Copied: branches/rails2/public/images/elico_back2.png (from rev 2809, trunk/public/images/elico_back2.png)


(Binary files differ)

Copied: branches/rails2/public/images/elico_back3.png (from rev 2809, trunk/public/images/elico_back3.png)


(Binary files differ)

Copied: branches/rails2/public/images/elico_back4.png (from rev 2809, trunk/public/images/elico_back4.png)


(Binary files differ)

Copied: branches/rails2/public/images/elico_logo_white.png (from rev 2809, trunk/public/images/elico_logo_white.png)


(Binary files differ)

Copied: branches/rails2/public/images/logo_tiny.png (from rev 2809, trunk/public/images/logo_tiny.png)


(Binary files differ)

Copied: branches/rails2/public/stylesheets/elico.css (from rev 2809, trunk/public/stylesheets/elico.css) (0 => 2810)


--- branches/rails2/public/stylesheets/elico.css	                        (rev 0)
+++ branches/rails2/public/stylesheets/elico.css	2011-11-16 10:54:50 UTC (rev 2810)
@@ -0,0 +1,59 @@
+/* Stylesheet for the e-LICO layout. Requires main myExperiment stylesheet. */
+
+body  {
+	background: #cfd5dd;
+}
+
+#myexp_searchbar, #myexp_sidebar, a.tab:hover, #selected_tabnav, .pagination a  {
+  background: #4d597e;
+}
+
+#elico_header
+{
+  background: url("/images/elico_back1.png") repeat-x scroll center top #2C3966;
+}
+
+#elico_links_bar
+{
+  width: 73.074em;
+  height: 32px;
+  margin: 0 auto;
+  padding: 0 1em;
+}
+
+#elico_links_bar #inner
+{
+  border: 1px solid #7D89BE;
+  background: #4D597E;
+  margin: 0 -1em;
+  padding: 0 1em;
+}
+
+.logo {
+  width: 73.074em;
+  float: none;
+  text-align: left;
+  color: white;
+  margin: 0 auto;
+  padding-top: 0.5em;
+}
+
+.links {
+  height: 2em;
+  padding: 0.5em;
+}
+
+.links a {
+  color: white;
+}
+
+/* IE7 fixes */
+#doc2 {
+  *overflow: hidden;
+  *height: 0px;
+}
+
+#elico_links_bar #inner {
+  *height: 100%;
+}
+/* end of IE7 fixes */

Modified: branches/rails2/public/stylesheets/styles.css (2809 => 2810)


--- branches/rails2/public/stylesheets/styles.css	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/public/stylesheets/styles.css	2011-11-16 10:54:50 UTC (rev 2810)
@@ -7,7 +7,7 @@
    http://developer.yahoo.com/yui/fonts/#fontsize
 */
 body {
-	background: #8e8e8e url('/images/body-bg.gif') repeat-y center;
+	background: #8e8e8e;
 	/* Only need to define one font here because the 
 	   YUI Fonts CSS provides a degradation path
 	   (see: http://developer.yahoo.com/yui/fonts/) */
@@ -127,24 +127,36 @@
 
 #doc2 {
 	background-color: #FFFFFF;
+  padding: 0 1em;
 }
 
 #myexp_header {
-	margin: 1em 0.5em 0 0.5em;
+	margin: 0em 0.5em;
 }
 
-#myexp_header .logo {
+#hd
+{
+  padding-top: 1em;
+}
+
+.logo {
 	float: left;
 	width: 300px;
 }
 
-#myexp_header .links {
-	float: right;
-	width: 600px;
-	font-size: 93%;
+.links {
 	color: #999999;
+  font-weight: bold;
 }
 
+#site_info_links {
+  margin: 0.5em 0;
+}
+
+#user_links {
+  float: right;
+}
+
 #myexp_searchbar {
 	height: 20px;
 	text-align: center;
@@ -179,7 +191,7 @@
 /* Begin Footer styles */
 
 #ft {
-	margin: 2em 0;
+	margin-top: 2em;
 	border: 0px dotted #999999;
 	border-width: 1px 0 1px 0;
 	color: #333333;
@@ -284,6 +296,8 @@
 }
 
 /* begin css tabs nav */
+
+/* TODO: Remove me?
 .tabnav {
 	text-align: center;
 	font-weight: bolder;
@@ -330,8 +344,34 @@
 	background-color: #317eff;
 	background-image: none;
 	color: #FFFFFF;
+}   */
+
+.tabnav
+{
+  text-align: center;
+  margin: 0;
+  padding:  0;
 }
 
+a.tab {
+  display: inline-block;
+	padding: 4px 12px;
+	margin-left: 3px;
+	border-style: solid;
+  border-color: #BBBBBB;
+  border-width: 1px 1px 0px 1px;
+	text-decoration: none;
+	background: url('/images/tab-bg.png') top repeat-x #EDEDED;
+  color: #333333;
+	font-weight: bolder;
+	font-size: 108%;
+}
+
+a.tab:hover, #selected_tabnav {
+	color: #FFFFFF;
+	background: #317eff;
+}
+
 /* end css tabs nav */ 
 
 /* begin css breadcrumbs */
@@ -781,6 +821,7 @@
 	padding: 0.5em;
 	margin-bottom: 1.5em;
 	background-color: #F5F5F5;
+  margin: 0 auto 1.5em auto;
 }
 
 #errorExplanation h2 {
@@ -2246,6 +2287,11 @@
   top: -1px;
 }
 
+.pivot .search_query_problem {
+  color: red;
+	font-style: italic;
+}
+
 .truncate {
   white-space: nowrap;
 }
@@ -2279,3 +2325,16 @@
   vertical-align: middle;
 }
 
+#error_flash {
+  color: red;
+  font-weight: bold;
+  margin-bottom: 1.5em;
+  line-height: 1.4;
+}
+
+#notice_flash {
+  color: green;
+  font-weight: bold;
+  margin-bottom: 1.5em;
+  line-height: 1.4;
+}
\ No newline at end of file

Modified: branches/rails2/test/fixtures/networks.yml (2809 => 2810)


--- branches/rails2/test/fixtures/networks.yml	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/test/fixtures/networks.yml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -22,3 +22,10 @@
   unique_name: network
   created_at: 2007-12-05 15:45:59
   updated_at: 2007-12-05 15:45:59
+
+exclusive_network:
+  title: An Invite Only Network
+  unique_name: invite_only
+  created_at: 2007-12-05 15:45:59
+  updated_at: 2007-12-05 15:45:59
+  new_member_policy: :invitation_only

Copied: branches/rails2/test/fixtures/ontologies.yml (from rev 2809, trunk/test/fixtures/ontologies.yml) (0 => 2810)


--- branches/rails2/test/fixtures/ontologies.yml	                        (rev 0)
+++ branches/rails2/test/fixtures/ontologies.yml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -0,0 +1,12 @@
+
+test_ontology_1:
+  id: 1
+  user_id: 1
+  prefix: test_prefix
+  uri: http://www.example.com/ontologies/1
+  title: Test ontology
+  description: This is a test ontology.
+  description_html: <p>This is a test ontology.</p>
+  created_at: 2008-02-14 20:19:18
+  updated_at: 2008-02-14 20:19:18
+

Copied: branches/rails2/test/fixtures/predicates.yml (from rev 2809, trunk/test/fixtures/predicates.yml) (0 => 2810)


--- branches/rails2/test/fixtures/predicates.yml	                        (rev 0)
+++ branches/rails2/test/fixtures/predicates.yml	2011-11-16 10:54:50 UTC (rev 2810)
@@ -0,0 +1,13 @@
+
+test_predicate_1:
+  id: 1
+  title: Test predicate
+  description: This is a test predicate.
+  description_html: <p>This is a test predicate.</p>
+  phrase: is a test phrase with 
+  ontology_id: 1
+  equivalent_to: 
+  created_at: 2008-02-14 20:19:18
+  updated_at: 2008-02-14 20:19:18
+
+

Modified: branches/rails2/test/functional/announcements_controller_test.rb (2809 => 2810)


--- branches/rails2/test/functional/announcements_controller_test.rb	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/test/functional/announcements_controller_test.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -31,7 +31,7 @@
     assert_response :redirect
     assert_equal "Only administrators have access to create, update and delete announcements.", flash[:error]
 
-    follow_redirect
+    get :index
     assert_response :success
     assert_template 'index'
   end
@@ -43,7 +43,7 @@
     assert_response :redirect
     assert_equal "Only administrators have access to create, update and delete announcements.", flash[:error]
 
-    follow_redirect
+    get :index
     assert_response :success
     assert_template 'index'
   end

Modified: branches/rails2/test/functional/memberships_controller_test.rb (2809 => 2810)


--- branches/rails2/test/functional/memberships_controller_test.rb	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/test/functional/memberships_controller_test.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -65,4 +65,10 @@
     assert_redirected_to group_path(networks(:another_network).id )
     assert_equal old_count-1, Membership.count
   end
+
+  def test_cannot_join_invitation_only_group
+    assert_no_difference 'Membership.count' do
+      post :create, :user_id => users(:john).id, :network_id => networks(:exclusive_network).id
+    end
+  end
 end

Modified: branches/rails2/test/functional/networks_controller_test.rb (2809 => 2810)


--- branches/rails2/test/functional/networks_controller_test.rb	2011-11-16 01:18:23 UTC (rev 2809)
+++ branches/rails2/test/functional/networks_controller_test.rb	2011-11-16 10:54:50 UTC (rev 2810)
@@ -26,7 +26,7 @@
     old_count = Network.count
 
     login_as(:john)
-    post :create, :network => { :user_id => '990', :title => 'test network', :unique_name => 'test_network', :auto_accept => '0', :description => "..." }
+    post :create, :network => { :user_id => '990', :title => 'test network', :unique_name => 'test_network', :new_member_policy => 'open', :description => "..." }
 
     assert_equal old_count+1, Network.count    
     assert_redirected_to group_path(assigns(:network))
@@ -47,7 +47,7 @@
   def test_should_update_network
     login_as(:john)
     put :update, :id => 1, 
-                 :network => { :user_id => '990', :title => 'test network', :unique_name => 'update_network', :auto_accept => '0', :description => ".?."}
+                 :network => { :user_id => '990', :title => 'test network', :unique_name => 'update_network', :new_member_policy => 'open', :description => ".?."}
 
     assert_redirected_to group_path(assigns(:network))
   end

reply via email to

[Prev in Thread] Current Thread [Next in Thread]