xforum 0.0.377 → 0.0.378

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ece98c3b431521e44c2a1d790696102977f8a02
4
- data.tar.gz: c85eccdd20ddfe8d299650d4bd8d9a9ec643b591
3
+ metadata.gz: dae03aab9ce8e977a3e0f3bfb93302f79ae22c19
4
+ data.tar.gz: 4aaef04977c9b85b089b2d97ec9edbb26ecd729b
5
5
  SHA512:
6
- metadata.gz: 2d7c3f3b22d85f99184e955db7e4b6b46e00416e4dbafa2401e24d3bc5955b34b3cbb77f0d7a0b130bf33ed4bbd6cce545a534f2eab7d7303719ed0d4bbc23ba
7
- data.tar.gz: 7a606bca17df8ddcb1a9ddeaf8804ae774f723ebf2caa3b7f00881fe6c21ef028c5af78b1404d5656edf339c45a7c73ea858bf84a9c2374692718e460b4dc6b7
6
+ metadata.gz: a53991fdedd1e62337305e941e3ff82325040d9938ac4fb34fc87e3fd94f3eca4f5067e1c0b58235db3b97c64ead9d1a5b0cea85910a8fa82c817fc494841a81
7
+ data.tar.gz: c1b5e4a2da97b07d458eedba08faa24813c62a46f98ff013770b4b0645df160f6583d47d0cf4e56753e5a3539b697cff68f453051d69b5448eb3d4bc3cb9e81f
@@ -241,12 +241,14 @@ doAction = ->
241
241
  request.new_list_name = $('#forum-new-list').val()
242
242
  request.distribution_list = $('#forum-distribution-lists').val()
243
243
  request.the_list=$('#forum-every-list').val()
244
- request.list_type=$('forum-list-type').val()
244
+ request.list_type=$('#forum-list-type').val()
245
245
  request.forum_action = $('#forum-actions').val()
246
246
  document.getElementById('forum-actions').selectedIndex=0
247
247
  setAdminDisplay()
248
248
  $("forum-email-body").val('')
249
249
  $.post('xforum/forum_ajax',request)
250
+ doAdminStuff()
251
+ hideActionViews()
250
252
 
251
253
  setAdminView = (which_one)->
252
254
  switch(which_one.dataset.view)
@@ -5,7 +5,7 @@ module Xforum
5
5
  class ForumsController < ApplicationController
6
6
 
7
7
  def the_page
8
- gon.forum_user=[]
8
+
9
9
  end
10
10
 
11
11
  def forum_ajax
@@ -24,22 +24,29 @@ module Xforum
24
24
 
25
25
  def self.restrict_me(params,user)
26
26
  if user.forum_admin?
27
- (params[:new_category].nil? || params[:new_category]=='') ?
28
- category=Category.find_by(name: params[:category]) :
29
- category=Category.create(name: params[:new_category], user_id: user.id)
30
- category.restricted= !category.restricted
31
- category.save
32
- invitation=PeopleList.find_or_create_by(category_id:category.id,list:'invitation')
33
- invitation.people= PeopleList.find_by(id:params[:user_list]).people
34
- invitation.save
27
+ category=Category.find_by(name: params[:category])
28
+ unless category.nil?
29
+ unless params[:user_list].nil? || params[:user_list]=='select list'
30
+ people_list=PeopleList.find_by(id:params[:user_list])
31
+ if people_list.category_id.nil? && people_list.list =='invitation'
32
+ people_list.update(category_id:category.id )
33
+ else
34
+ new_list=people_list.clone
35
+ new_list.name=category.name+'-invitees'
36
+ new_list.list='invitation'
37
+ new_list.category_id=category.id
38
+ end
39
+ end
40
+ category.update(restricted:!category.restricted)
41
+ end
35
42
  end
36
43
  end
37
44
 
38
45
  def self.get_suggestions(params,user)
39
- data= Category.where(suggestion:true).pluck(:name, :user_id,:id)
40
- data=ForumAssist.named_array(data, [:suggestion, :user,:id]) unless data.empty?
41
- data=ForumAssist.add_user_name(data.clone) unless data.empty?
42
- user.forum_admin? ? {data: data, list: 'forum-category-prososals-list'} : {response: 'nothing doing'}
46
+ data= Category.where(suggestion:true).pluck(:name, :user_id,:id)
47
+ data=ForumAssist.named_array(data, [:suggestion, :user,:id]) unless data.empty?
48
+ data=ForumAssist.add_user_name(data.clone) unless data.empty?
49
+ user.forum_admin? ? {data: data, list: 'forum-category-prososals-list'} : {response: 'nothing doing'}
43
50
  end
44
51
 
45
52
  def self.edit_category(params,user)
@@ -43,34 +43,40 @@ module Xforum
43
43
 
44
44
  def self.senate(params,user)
45
45
  if params[:topic]== 'select topic'
46
+ return
47
+ end
48
+ topic=Topic.where(name:params[:topic]).pluck(:id)[0]
49
+ category=Category.find_by(topic_id:topic.id)
50
+ if (category.private || !user.forum_admin?) && PeopleList.check_invitation(category.name,category.id, user.id, 'category')
51
+ {to_do:'nothing'}
52
+ elsif (topic.restricted && !user.forum_admin?) && PeopleList.check_invitation(topic.name,topic.id, user.id, 'topic')
46
53
  {to_do:'nothing'}
47
54
  else
48
- topic_id=Topic.where(name:params[:topic]).pluck(:id)[0]
49
55
  index=Forum.clear_user_topic(user.id,topic_id)
50
56
  the_list=[]
51
57
  plucking= [:id, :parent, :content, :user_id,:owner_name,:state,:restricted,:tag,:has_photo]
52
58
  plucking_names= [:id, :parent, :content,:owner,:owner_name,:comment_state,:restricted,:tag,:has_photo,:needs_translation,:empty_list] #we're going to append empty list to the reply
53
- moderator=PeopleList.check_people({topic:topic_id,user_id:user.id,list:'moderator'}) || user.forum_admin?
59
+ moderator=PeopleList.check_people({topic:topic.id,user_id:user.id,list:'moderator'}) || user.forum_admin?
54
60
  if params[:review]=='true' && moderator
55
- test=Forum.where(topic_id:topic_id,state:'new').pluck(:id)
61
+ test=Forum.where(topic_id:topic.id,state:'new').pluck(:id)
56
62
  unless test.empty?
57
- item1=ForumAssist.named_array(Translation.get_localized_forum(Language.get_me(params),{lookup:{topic_id:topic_id},plucking:plucking,size:0}),plucking_names)
63
+ item1=ForumAssist.named_array(Translation.get_localized_forum(Language.get_me(params),{lookup:{topic_id:topic.id},plucking:plucking,size:0}),plucking_names)
58
64
  item1.store(:moderator,true)
59
65
  item1.store(:review,true)
60
- new_list= ForumAssist.named_array( Translation.get_localized_forum(Language.get_me(params),{lookup:{topic_id:topic_id,state:'new'},ordering:([:topic_id]),plucking:plucking,size:'all'}),plucking_names )
66
+ new_list= ForumAssist.named_array( Translation.get_localized_forum(Language.get_me(params),{lookup:{topic_id:topic.id,state:'new'},ordering:([:topic_id]),plucking:plucking,size:'all'}),plucking_names )
61
67
  new_list.unshift(item1)
62
68
  the_list=new_list
63
69
  end
64
70
  else
65
- senate_list=ForumAssist.named_array(Translation.get_localized_forum(Language.get_me(params),{lookup:{topic_id:topic_id,hold:false},ordering:[:parent,:created_at],plucking:plucking,size:'all'}), plucking_names )
71
+ senate_list=ForumAssist.named_array(Translation.get_localized_forum(Language.get_me(params),{lookup:{topic_id:topic.id,hold:false},ordering:[:parent,:created_at],plucking:plucking,size:'all'}), plucking_names )
66
72
  if senate_list.nil? || senate_list.empty?
67
73
  []
68
74
  else
69
- voting=Topic.grab({id:topic_id},[:vote,:votes],{})[0]
75
+ voting=Topic.grab({id:topic.id},[:vote,:votes],{})[0]
70
76
  voting[:vote] ? votes=Topic.count_votes(JSON.load(voting[:votes])) : votes=0
71
77
  parent=Forum.look_for_key(senate_list,:parent,0)
72
78
  new_list=[]
73
- subscribed=PeopleList.check_people({topic:topic_id,user_id:user.id,list:'subscribers'})
79
+ subscribed=PeopleList.check_people({topic:topic.id,user_id:user.id,list:'subscribers'})
74
80
  parent=set_new_senate_entry(senate_list,new_list,parent,user.id, {moderator:moderator,vote:voting[:vote],votes:votes,subscribed:subscribed,admin:user.forum_admin?}) unless parent.nil?
75
81
  Forum.is_child_there?(senate_list,new_list,0,parent,user.id) #push first child
76
82
  new_list.delete_if {|record|
@@ -79,7 +85,7 @@ module Xforum
79
85
  case record[:state]
80
86
  when 'reject' then test= true
81
87
  when 'new'
82
- ENV['XFORUM_NEW_RULE']=='no' || Topic.where(id:topic_id).is_moderated
88
+ ENV['XFORUM_NEW_RULE']=='no' || Topic.where(id:topic.id).is_moderated
83
89
  else test=false
84
90
  end
85
91
  end
@@ -67,12 +67,13 @@ module Xforum
67
67
  alist.unshift([I18n.t('xForum.select_none'), 'select none', 0])
68
68
  {list_data:ForumAssist.named_array(alist, [:value, :item]), name:params[:list]}
69
69
  end
70
- def self.get_people_list(params)
71
- which=PeopleList.get_which_owner(params)
72
- params.merge!(which)
73
- people_object=PeopleList.make_a_list(params)
74
- list=JSON.load(people_object.people)
75
- list.nil? ? [] : list
70
+ def self.get_voter_list(params)
71
+ unless params[:topic_id].nil?
72
+ people_list=PeopleList.find_or_create_by(topic_id:params[:topic_id],list:'voters'){ |me|
73
+ me.name=Topic.where(id:topic_id).pluck(:name)[0] +'-voters'
74
+ }
75
+ JSON.load(people_list.people)
76
+ end
76
77
  end
77
78
 
78
79
  def self.make_a_list(params)
@@ -80,7 +81,7 @@ module Xforum
80
81
  joe.topic_id=params[:topic_id] unless params[:topic_id].nil?
81
82
  joe.category_id=params[:topic_id] unless params[:category_id].nil?
82
83
  joe.forum_id =params[:topic_id] unless params[:forum_id].nil?
83
- joe.list = params[:list]
84
+ joe.list ='voters'
84
85
  }
85
86
  end
86
87
 
@@ -96,7 +97,6 @@ module Xforum
96
97
  end
97
98
  end
98
99
 
99
-
100
100
  def self.get_forum_users(params, user)
101
101
  user.forum_admin? ? alist = Xforum.user_class.all.order(:forum_post_name).pluck(:forum_post_name, :id) : alist =[]
102
102
  alist.unshift([I18n.t('xForum.select_none'), 'select none', 0])
@@ -109,35 +109,65 @@ module Xforum
109
109
  def self.check_restrictions(blist, user, list_type)
110
110
  alist=blist.clone #so you can do list.each and delete items
111
111
  blist.each { |record|
112
- alist.delete(record) if record[:restricted] && PeopleList.check_invitation(record[:id], user.id,list_type)
112
+ skip=false
113
+ case list_type
114
+ when 'topic'
115
+ category= Category.find_by(id:record[:category_id])
116
+ when 'category','categories'
117
+ category= Category.find_by(id:record[:id])
118
+ end
119
+ if !category.nil? && category.restricted
120
+ if PeopleList.check_invitation(record[:name],category.id, user.id, 'category')
121
+ alist.delete(record)
122
+ skip=true
123
+ end
124
+ end
125
+ unless skip
126
+ alist.delete(record) if record[:restricted] && PeopleList.check_invitation(record[:name],record[:id], user.id, list_type)
127
+ end
113
128
  }
114
129
  alist
115
130
  end
116
131
 
117
- def self.check_invitation(id,user_id,list_type)
132
+ def self.check_invitation(name,id,user_id,list_type)
118
133
  case list_type
119
134
  when 'topic'
120
- !JSON.load(PeopleList.where(topic_id:id,list:'invitation')[0].people).include?(user_id)
135
+ people_list=PeopleList.find_by(topic_id:id,list:'invitation')
121
136
  when 'category', 'categories'
122
- !JSON.load(PeopleList.where(category_id:id,list:'invitation')[0].people).include?(user_id)
137
+ people_list=PeopleList.find_by(category_id:id,list:'invitation')
123
138
  when 'forum'
124
- !JSON.load(PeopleList.where(forum_id:id,list:'invitation')[0].people).include?(user_id)
139
+ people_list=PeopleList.find_by(forum_id:id,list:'invitation')
125
140
  else
126
- true
141
+ nil
127
142
  end
143
+ people_list.nil? ? false : !JSON.load(people_list.people).include?(user_id)
128
144
  end
145
+
129
146
  def self.get_forum_people_lists(params,user)
130
147
  case params[:list]
131
148
  when 'forum-distribution-lists'
132
- alist=PeopleList.where(list:'distribution list').pluck(:name, :id)
149
+ alist=PeopleList.grab({list:'distribution'},[:id,:name,:private,:people],{})
133
150
  when 'forum-restricted-list'
134
- alist=PeopleList.where(list:'invitation').pluck(:name, :id)
151
+ alist=PeopleList.grab({list:'invitation'},[:id,:name,:private,:people],{})
135
152
  when 'forum-every-list'
136
- alist=PeopleList.where(private:false).pluck(:name, :id)
153
+ alist=PeopleList.grab('all',[:id,:name,:private,:people],{})
137
154
  else
138
155
  end if user.forum_admin?
139
- alist.unshift([I18n.t('xForum.select_list'), 'select list', 0]) unless alist.nil?
140
- {list_data: ForumAssist.named_array(alist, [:value, :item]), id:params[:list]}
156
+ if alist.nil? || alist.empty?
157
+ []
158
+ else
159
+ blist=alist.clone
160
+ alist.each{|record|
161
+ blist.delete(record) if record[:private] && !JSON.load(record[:people]).include?(user.id)
162
+ }
163
+ clist=[]
164
+ blist.each{|record|
165
+ clist.push({value:record[:name],item:record[:id]})
166
+ }
167
+ clist.unshift({value:I18n.t('xForum.select_list'),item:'select list'})
168
+
169
+ {list_data:clist, id:params[:list]}
170
+ end
141
171
  end
142
172
 
143
173
  def self.get_this_list(user,params)
@@ -145,6 +175,7 @@ module Xforum
145
175
  {list:JSON.load(PeopleList.find_by(id:params[:list_id].to_i).people)}
146
176
  end
147
177
  end
178
+
148
179
  def self.is_a_moderator?(user_id)
149
180
  the_lists=PeopleList.where(list: 'moderator').pluck(:people)
150
181
  moderators=[]
@@ -157,11 +188,11 @@ module Xforum
157
188
 
158
189
  def self.make_invitation(params, forum_id, user)
159
190
  invitees=PeopleList.get_people_id_list(user.id, params[:invitees])
160
- peoplelist=PeopleList.where(list: 'invitation', owner_id: forum_id).first_or_create { |invitation|
191
+ people_list=PeopleList.where(list: 'invitation', owner_id: forum_id).first_or_create { |invitation|
161
192
  invitation.owner_id=forum_id
162
193
  invitation.list='invitation'
163
194
  }
164
- peoplelist.invite_these_guys(invitees)
195
+ people_list.invite_these_guys(invitees)
165
196
  end
166
197
 
167
198
  def self.add_to_list(params,users)
@@ -171,8 +202,8 @@ module Xforum
171
202
  new.owner_id=params[:owner]
172
203
  }
173
204
  else
174
- a_list=PeopleList.where(list: 'distribution list', name: params[:list]).first_or_create { |new|
175
- new.list = 'distribution list'
205
+ a_list=PeopleList.where(list: 'distribution', name: params[:list]).first_or_create { |new|
206
+ new.list = 'distribution'
176
207
  new.name = params[:list]
177
208
  }
178
209
  end
@@ -23,12 +23,12 @@ module Xforum
23
23
  unless params[:category] == 'select category'
24
24
  category_id=Category.where(name:params[:category]).pluck(:id)[0]
25
25
  params[:hold_test]=='true' ?
26
- topics=Topic.grab({category_id:category_id,closed:false,suggestion:false}, [:id,:name,:state,:restricted,:closed,:is_moderated],{swap:{name: :item}}) :
27
- topics=Topic.grab({category_id:category_id}, [:id,:name,:state,:restricted,:closed,:is_moderated],{swap:{name: :item}})
26
+ topics=Topic.grab({category_id:category_id,closed:false,suggestion:false}, [:id,:name,:state,:category_id,:restricted,:closed,:is_moderated],{swap:{name: :item}}) :
27
+ topics=Topic.grab({category_id:category_id}, [:id,:name,:state,:category_id,:restricted,:closed,:is_moderated],{swap:{name: :item}})
28
28
  topics=[] if topics[0][:id].nil?
29
29
  topics=PeopleList.check_restrictions(topics,user,'topic')
30
- a=Topic.grab({name:'select topic'},[:id,:name,:state,:restricted,:closed],{swap:{name: :item}})[0]
31
- b=Topic.grab({name:'request new topic'}, [:id,:name,:state,:restricted,:closed],{swap:{name: :item}})[0]
30
+ a=Topic.grab({name:'select topic'},[:id,:name,:state,:category_id,:restricted,:closed],{swap:{name: :item}})[0]
31
+ b=Topic.grab({name:'request new topic'}, [:id,:name, :category_id,:state,:restricted,:closed],{swap:{name: :item}})[0]
32
32
  topics.unshift(a)
33
33
  topics.push(b)
34
34
  {list_data:Translation.translate_list(topics,params[:language],'topic'),id:params[:list]}
@@ -49,17 +49,19 @@ module Xforum
49
49
 
50
50
  def self.restrict_me(params,user)
51
51
  if user.forum_admin?
52
- if params[:new_topic].nil? || params[:new_topic]==''
53
- topic=Topic.find_by(name:params[:topic])
54
- topic.restricted= !topic.restricted
55
- else
56
- category=Category.where(name:params[:category]).pluck(:id)[0]
57
- topic=Topic.create(name:params[:new_topic],user_id:user.id,category_id:category,restricted:true)
58
- Forum.add_comment({topic:params[:new_topic],comment:params[:new_topic],parent:0},user)
52
+ topic=topic.find_by(name:params[:topic])
53
+ unless topic.nil?
54
+ unless params[:user_list].nil? || params[:user_list]=='select list'
55
+ people_list=PeopleList.find_by(id:params[:user_list])
56
+ if people_list.topic_id.nil? && people_list.list=='invitation'
57
+ people_list.update(topic_id:topic.id )
58
+ else
59
+ new_list=people_list.clone
60
+ new_list.update(name:topic.name+'-invitees',list:'invitation',topic_id:topic.id)
61
+ end
62
+ end
63
+ topic.update(restricted:!topic.restricted)
59
64
  end
60
- invitation=PeopleList.find_or_create_by(topic_id:topic.id,list:'invitation')
61
- invitation.people= PeopleList.find_by(id:params[:user_list]).people
62
- invitation.save
63
65
  end
64
66
  end
65
67
 
@@ -95,7 +97,7 @@ module Xforum
95
97
 
96
98
  def self.cast_vote(topic,user,vote)
97
99
  topic_record=Topic.find_by(name:topic)
98
- voters=PeopleList.get_people_list({topic:topic_record.id,list:'voters'})
100
+ voters=PeopleList.get_voter_list({topic:topic_record.id,list:'voters'})
99
101
  votes=JSON.load(topic_record.votes)
100
102
  if voters.empty?
101
103
  index=nil
@@ -22,8 +22,7 @@
22
22
  <%=select_tag(:forum,options_for_select(@every_list), id:'forum-every-list', class:'forum-select')%> <br>
23
23
  <span id="editing-every-list-entries">
24
24
  <br><label><%=t('xForum.new_list_name')%></label> <input type="text" id='forum-new-list' class="admin-edit-field" >
25
- <br><label><%=t('xForum.new_list_type')%></label> <input type="text" id='forum-list-type' class="admin-edit-field" >
26
-
25
+ <br><label><%=t('xForum.new_list_type')%></label> <%= select_tag(:forum, options_for_select(@list_types), id:'forum-list-type', class: 'forum-select') %>
27
26
  </span>
28
27
 
29
28
  <label><%=t('xForum.user_email')%></label>
@@ -4,6 +4,7 @@
4
4
  <%@user_tags=[] %>
5
5
  <%@user_email=[]%>
6
6
  <%@every_list=[] %>
7
+ <%@list_types=['invitation','distribution']%>
7
8
  <%if Xforum::Language.first.nil? then Xforum::Language.init_language_set end %>
8
9
  <%unless ENV['XFORUM_LANGUAGES'].nil? then @languages= Xforum::Language.languages({active:'true',list:'forum-language'})[:list_data] end %>
9
10
  <%@aphoto= 'photo' %>
@@ -1,5 +1,5 @@
1
1
  class AddPrivateToPeopleLists < ActiveRecord::Migration
2
2
  def change
3
- add_column :xforum_people_lists,:private, :boolean, default:false
3
+ add_column :xforum_categories,:private, :boolean, default:false
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module Xforum
2
- VERSION = '0.0.377'
2
+ VERSION = '0.0.378'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xforum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.377
4
+ version: 0.0.378
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert D Blanton
@@ -252,7 +252,7 @@ files:
252
252
  - db/migrate/20140603_change_suggestion_default.rb
253
253
  - db/migrate/20140604_add_has_video_to_photo.rb
254
254
  - db/migrate/20140813300_add_is_moderated_to_category_topics.rb
255
- - db/migrate/20140826100001_add_private_to_people_lists.rb
255
+ - db/migrate/20140826100002_add_private_to_people_lists.rb
256
256
  - lib/active_record_extension.rb
257
257
  - lib/tasks/xforum_tasks.rake
258
258
  - lib/xforum.rb