xforum 0.0.36 → 0.0.37

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 723d2b7e15ed355c4c29a21eceba9c67516bd6cb
4
- data.tar.gz: bb2fc6d3f57b5750d34c1b7f3369c91b844a8af8
3
+ metadata.gz: 3a1dcc8a188dcd60a90b395dadeaa8f10cbd0b96
4
+ data.tar.gz: ae3817460faacdb80c2a6212ffab8d845dce3b0c
5
5
  SHA512:
6
- metadata.gz: 5344d51f12484427790faa3a8ffc1c459c373e8b78e6b7352c535e2908ae2b514615d6243b79006746d2fdf2645ce4d35dc3c80ee4758629f6ecdaa4de4a178e
7
- data.tar.gz: c629248f8e54077b472928636adae34425b304b74ac16dd98c5f636255214abac908b16221fd2badd7de3de8086dc561bb77919f8f784bd691408edd2d2c9c60
6
+ metadata.gz: b39c6b96be1cf67148c0ef84ce5d3886420742aec30ed74e12a96be0af2c4e15624258b898581582da3ec31b726339b746043a62ce0b7b3d7ccf8a00c2950d6a
7
+ data.tar.gz: dc5bff780515da4db1ad790402963bdb434560fc01c587b6f9463621a224a330b35d99b0cbc9826b5af097046bf1c9563ee590ed013aaaeae41351a4ca355657
@@ -36,8 +36,23 @@ jQuery ->
36
36
  doRestrictCategory(event.target)
37
37
  $('#restrict-topic').click ->
38
38
  doRestrictTopic(event.target)
39
+ $('#user_email').dblclick ->
40
+ addEmail(event.target)
39
41
  #todo add reason selection for rejecion (forum and user privilages)
40
42
 
43
+ clearEmail=->
44
+ document.getElementById('forum_selected_emails').innerHTML=''
45
+
46
+ addEmail=(which)->
47
+ email_list=document.getElementById('forum_selected_emails')
48
+ emails=email_list.innerHTML
49
+ email=which.innerHTML
50
+ if emails.search(email)>=0
51
+ emails=emails.replace(email+',\n','')
52
+ else
53
+ emails=emails+email+',\n'
54
+ email_list.innerHTML=emails
55
+
41
56
  doRestrictCategory=(button)->
42
57
  if button.value== button.dataset.restrict
43
58
  button.value=button.dataset.submit
@@ -46,6 +61,7 @@ doRestrictCategory=(button)->
46
61
  button.value= button.dataset.restrict
47
62
  hideMe({id:'forum-restricted-list'})
48
63
  request={function:'forum admin action'}
64
+ request.new_category = $('#forum-add-admin-category').val()
49
65
  request.forum_action='restrict category'
50
66
  request.user_list=$('#forum-restricted-list').val()
51
67
  request.category=$('#forum-category-admin').val()
@@ -60,8 +76,10 @@ doRestrictTopic=(button)->
60
76
  button.value= button.dataset.restrict
61
77
  request={function:'forum admin action'}
62
78
  request.forum_action='restrict topic'
63
- request.category=$('#forum-topic-admin').val()
79
+ request.topic=$('#forum-topic-admin').val()
80
+ request.category=$('#forum-category-admin').val()
64
81
  request.user_list=$('#forum-restricted-list').val()
82
+ request.new_topic = $('#forum-add-admin-topic').val()
65
83
  hideMe({id:'forum-restricted-list'})
66
84
  hideMe({id:'forum-admin-topic'})
67
85
  $.post('xforum/forum_ajax',request)
@@ -116,6 +134,7 @@ doButtonAction = (which)->
116
134
  window.doAdminStuff = ->
117
135
  document.getElementById('forum-senate').dataset.admining = 'true'
118
136
  setAdminDisplay()
137
+ clearEmail()
119
138
  $.post('xforum/forum_ajax',{function:'get list',by_name:false, list:'admin-actions'},loadList)
120
139
  $.post('xforum/forum_ajax',{function:'get list',by_name:false, list:'forum-distribution-lists'},loadList)
121
140
  $.post('xforum/forum_ajax',{function:'get list',by_name:true, list:'admin-emails'},loadList)
@@ -136,6 +155,7 @@ setAdminDisplay=->
136
155
  showMe({id:'forum-distribution-span'})
137
156
  hideMe({id:'forum-moderator-add-span'})
138
157
  hideMe({id:'forum-restricted-list'})
158
+ hideMe({name:'forum-act-on-admin-selector'})
139
159
  document.getElementById('forum-new-distribution-list').value=''
140
160
 
141
161
  turnLanguage=(toggle)->
@@ -174,6 +194,7 @@ setTagView = ->
174
194
  $('#user-tag').focus()
175
195
 
176
196
  checkActionSetup = (which)->
197
+ showMe({name:'forum-act-on-admin-selector'})
177
198
  switch which.value
178
199
  when 'create distribution'
179
200
  setDistributionListView()
@@ -200,6 +221,7 @@ doAction = ->
200
221
  request.new_list_name = $('#forum-new-distribution-list').val()
201
222
  request.distribution_list = $('#forum-distribution-lists').val()
202
223
  request.forum_action = $('#forum-actions').val()
224
+ request.emails=document.getElementById('forum_selected_emails').innerHTML
203
225
  document.getElementById('forum-actions').selectedIndex=0
204
226
  setAdminDisplay()
205
227
  $("forum-email-body").val('')
@@ -248,7 +270,7 @@ deleteForumObject = (which_one)->
248
270
 
249
271
  addOptionTo = (which_one,item)->
250
272
  switch which_one
251
- when 'category'
273
+ when 'category', 'categories'
252
274
  pushOption($('[name=category_admin]'),{item:item,value:item},0)
253
275
  pushOption($('[name=category]'),{item:item,value:item},2)
254
276
  when 'language'
@@ -268,7 +290,9 @@ addCategory = (which,user)->
268
290
  new_category = $('#forum-add-admin-category').val()
269
291
  unless new_category == ''
270
292
  addListEntry('forum-admins-category-list',{item:new_category})
271
- $.post('xforum/forum_ajax',{function:'add to list',list:'category',new_item:new_category,user:$('#forum-add-admin-user').val()})
293
+ request={function:'add to list',list:'category',new_item:new_category}
294
+ request.user=$('#forum-add-admin-user').val()
295
+ $.post('xforum/forum_ajax',request)
272
296
  addOptionTo('forum-category',new_category)
273
297
  addCancel({obj:which})
274
298
 
@@ -371,7 +395,7 @@ window.loadAdminsList = (params)->
371
395
  which = 'forum-admins-topic-list'
372
396
  short = 0
373
397
  shift = true
374
- when 'category'
398
+ when 'category' , 'categories'
375
399
  which = 'forum-admins-category-list'
376
400
  short = 1
377
401
  shift = true
@@ -14,8 +14,8 @@ function showPageName() {
14
14
  function checkPage(page) {
15
15
  "use strict";
16
16
  var path;
17
- path = window.location.href.split("/").pop();
18
- return (path === "" || path === page || path === page + '#' || path.length === 2);
17
+ path = window.location.href;
18
+ return path.indexOf(page) >= 0;
19
19
  }
20
20
 
21
21
  function whatsup1(message) {
@@ -55,12 +55,7 @@ $blue: #a0a0ff;
55
55
  margin-left:75px;
56
56
  margin-top:10px;
57
57
  }
58
- input{
59
- border: 1px solid rgb(187, 187, 187);
60
- width: 95%;
61
- padding: 10px;
62
- margin-bottom: 15px;
63
- }
58
+
64
59
  .senate-row{
65
60
  padding:0;
66
61
  }
@@ -41,7 +41,7 @@ module Xforum
41
41
  render json: Translation.get_translations(params)
42
42
  when 'add to list'
43
43
  case params[:list]
44
- when 'category'
44
+ when 'category' ,'categories'
45
45
  response= Category.add_category(params, current_user)
46
46
  when 'topic'
47
47
  response= Topic.add_topic(params, current_user)
@@ -85,7 +85,7 @@ module Xforum
85
85
  render json: Topic.subscribe(params[:topic], current_user)
86
86
  when 'get suggestions'
87
87
  case params[:list]
88
- when 'category'
88
+ when 'category' , 'categories'
89
89
  response= Category.get_suggestions(params, current_user)
90
90
  when 'topic'
91
91
  response= Topic.get_suggestions(params, current_user)
@@ -8,7 +8,7 @@ module Xforum
8
8
 
9
9
  def self.add_category(params,user)
10
10
  params[:user.id]=user.id if params[:user_id] == 'me'
11
- user.forum_admin? ? id= Category.create(name:params[:new_item],user_id:user.id,suggestion:false).id : id='not happening'
11
+ user.forum_admin? ? id= Category.create(name:params[:new_item],user_id:user.id).id : id='not happening'
12
12
  {id:id}
13
13
  end
14
14
 
@@ -24,7 +24,9 @@ module Xforum
24
24
 
25
25
  def self.restrict_me(params,user)
26
26
  if user.forum_admin?
27
- category=Category.find_by(name:params[:category])
27
+ params[:new_category].nil? ?
28
+ category=Category.find_by(name: params[:category]) :
29
+ category=Category.create(name: params[:new_category], user_id: user.id)
28
30
  category.restricted= !category.restricted
29
31
  category.save
30
32
  invitation=PeopleList.find_or_create_by(category_id:category.id,list:'invitation')
@@ -59,6 +61,7 @@ module Xforum
59
61
  Category.create(name:'request new category',closed:false,suggestion:false)
60
62
  Category.create(name:'select category',closed:false,suggestion:false)
61
63
  end
64
+
62
65
  params[:hold_test]=='true' ?
63
66
  category_list= Category.grab({closed:false,suggestion:false},[:id,:name,:closed,:restricted],{}) :
64
67
  category_list= Category.grab('all',[:id,:name,:closed,:restricted],{})
@@ -13,10 +13,13 @@ module Xforum
13
13
  def self.do_admin_action(params,user)
14
14
  params[:users1]=[] if params[:users1].nil?
15
15
  params[:users2]=[] if params[:users2].nil?
16
- user_ids=(params[:users1] + params[:users2])
17
- user_ids.uniq!
18
- (0...user_ids.size).each{|i| user_ids[i]=user_ids[i].to_i}
19
- user_ids.delete(0)
16
+ user_ids=[]
17
+ unless params[:emails].nil?
18
+ people_emails=params[:emails].split(",\n")
19
+ people_emails.each{|email|user_ids.push(User.where(email:email).pluck(:id)[0] ) }
20
+ (0...user_ids.size).each{|i| user_ids[i]=user_ids[i].to_i}
21
+ user_ids.delete(0)
22
+ end
20
23
  case params[:forum_action]
21
24
  when 'suspend posting'
22
25
  users_ids.each { |user_id| Xforum.user_class.where(id: user_id).update_all(forum_posting_priviages: false) }
@@ -1,4 +1,9 @@
1
-
1
+ # forum belongs_to
2
+ # topic belongs_to
3
+ # category belongs_to
4
+ # name, string limit:20
5
+ # list, string limit:20
6
+ # people, binary default:[]
2
7
  module Xforum
3
8
  class PeopleList < ActiveRecord::Base
4
9
  require 'json'
@@ -35,11 +40,11 @@ module Xforum
35
40
  people
36
41
  end
37
42
 
38
- def self.manage_list(params, user_ids)
43
+ def self.manage_list(params,user_ids)
39
44
  case params[:forum_action]
40
45
  when 'create distribution'
41
46
  PeopleList.find_or_create_by(name:params[:new_list_name], list:'distribution list'){|list|
42
- list.people=params[:people].to_json
47
+ list.people=user_ids.to_json
43
48
  }
44
49
  when 'add to distribution'
45
50
  alist= user_ids
@@ -80,9 +85,9 @@ module Xforum
80
85
  end
81
86
 
82
87
  def self.get_forum_emails(params, user)
83
- user.forum_admin? ? alist=Xforum.user_class.all.pluck(:email, :id) : alist= []
88
+ user.forum_admin? ? alist=Xforum.user_class.all.order(:email).pluck(:email, :id) : alist= []
84
89
  alist.unshift([I18n.t('xForum.select_none'), 'select none', 0])
85
- {list_data: ForumAssist.named_array(alist, [:value, :item]), name: 'forum-user-email'}
90
+ {list_data:ForumAssist.named_array(alist, [:value, :item]), name: 'forum-user-email'}
86
91
  end
87
92
 
88
93
  def self.get_forum_users(params, user)
@@ -91,10 +96,10 @@ module Xforum
91
96
  {list_data: ForumAssist.named_array(alist, [:value, :item]), name: 'forum-user-tag'}
92
97
  end
93
98
 
94
- def self.check_restrictions(alist,user_id, list_type)
95
- blist=alist.clone
99
+ def self.check_restrictions(blist,user, list_type)
100
+ alist=blist.clone #so you can do list.each and delete items
96
101
  blist.each { |record|
97
- list.delete(record) if record[:restricted] && PeopleList.check_invitation(record[:id], user_id,list_type)
102
+ alist.delete(record) if record[:restricted] && PeopleList.check_invitation(record[:id], user.id,list_type)
98
103
  }
99
104
  alist
100
105
  end
@@ -102,12 +107,11 @@ module Xforum
102
107
  def self.check_invitation(id,user_id,list_type)
103
108
  case list_type
104
109
  when 'topic'
105
- JSON.load(PeopleList.where(topic_id:id,list:'invitation').people).include(user_id.to_s)
106
- when 'category'
107
- JSON.load(PeopleList.where(category_id:id,list:'invitation').people).include(user_id.to_s)
110
+ !JSON.load(PeopleList.where(topic_id:id,list:'invitation')[0].people).include?(user_id.to_s)
111
+ when 'category', 'categories'
112
+ !JSON.load(PeopleList.where(category_id:id,list:'invitation')[0].people).include?(user_id.to_s)
108
113
  when 'forum'
109
- JSON.load(PeopleList.where(forum_id:id,list:'invitation').people).include(user_id.to_s)
110
-
114
+ !JSON.load(PeopleList.where(forum_id:id,list:'invitation')[0].people).include?(user_id.to_s)
111
115
  end
112
116
  end
113
117
  def self.get_forum_distribution_lists(params,user)
@@ -20,7 +20,6 @@ module Xforum
20
20
  def self.topics(params,user)
21
21
  Topic.create(name:'select topic') if Topic.find_by(name:'select topic').nil?
22
22
  Topic.create(name:'request new topic') if Topic.find_by(name:'request new topic').nil?
23
-
24
23
  unless params[:category] == 'select category'
25
24
  category_id=Category.where(name:params[:category]).pluck(:id)[0]
26
25
  params[:hold_test]=='true' ?
@@ -50,10 +49,17 @@ module Xforum
50
49
 
51
50
  def self.restrict_me(params,user)
52
51
  if user.forum_admin?
53
- topic=Topic.find_by(name:params[:topic])
54
- topic.restricted= !topic.restricted
52
+ if params[:new_topic].nil?
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)
59
+ end
55
60
  invitation=PeopleList.find_or_create_by(topic_id:topic.id,list:'invitation')
56
- invitation.people= PeopleList.find_by(name:params[:user_list],list:'distribution').people
61
+ invitation.people= PeopleList.find_by(id:params[:user_list]).people
62
+ invitation.save
57
63
  end
58
64
  end
59
65
 
@@ -88,7 +88,7 @@ module Xforum
88
88
  alist.each.each {|entry|
89
89
  translation=Translation.find_by(forum_id:entry[:id],language_id:language) unless language.nil?
90
90
  case list_name
91
- when 'category'
91
+ when 'category' , 'categories'
92
92
  entry.store(:item,Category.where(id:entry[:id]).pluck(:name)[0] )
93
93
  entry.store(:value,entry[:item])
94
94
  when 'topic'
@@ -7,23 +7,23 @@
7
7
  <%=select_tag(:users,options_for_select(@forum_actions ), id:'forum-actions', class:'forum-select')%>
8
8
  <input class='red-ellipse comment-btn' type='button' id= "forum-admin-button" name ='forum-act-on-admin-selector' value= "<%= t('xForum.Submit')%>" >
9
9
  </span>
10
- <span class="col-md-3">
11
- <label> <%= t('xForum.User_Name') %> </label> <br><br>
12
-
13
- <button class="cool-selector" name="forum-user-tag-show"><input class= 'silver-selector' type='button' id= 'forum-admin-button' name='forum-user-tag-choose' value="<%= t('xForum.select_user')%>"></button>
14
- <span id='forum-user-tag-span'><%=select_tag(:users,options_for_select(@user_tags ), multiple:true, name:'forum-user-tag',size:6, class:'forum-select')%></span>
15
- </span>
16
- <span class="col-md-3">
10
+ <span class="col-md-5">
17
11
  <label> <%= t('xForum.User_Email')%> </label> <br><br>
18
12
  <button class="cool-selector" name="forum-user-email-show"><input class= 'silver-selector' type='button' id= 'forum-admin-button' name='forum-user-email-choose' value="<%= t('xForum.select_user')%>"></button>
19
13
  <span id='forum-user-email-span'><%=select_tag(:user_email,options_for_select(@user_email), multiple:true, size:6, name:'forum-user-email', class:'forum-select')%></span>
20
- </span>
21
- <span class="col-md-3">
14
+
15
+ <label> <%= t('xForum.User_Name') %> </label> <br><br>
16
+ <button class="cool-selector" name="forum-user-tag-show"><input class= 'silver-selector' type='button' id= 'forum-admin-button' name='forum-user-tag-choose' value="<%= t('xForum.select_user')%>"></button>
17
+ <span id='forum-user-tag-span'><%=select_tag(:users,options_for_select(@user_tags ), multiple:true, name:'forum-user-tag',size:6, class:'forum-select')%></span>
18
+ </span>
19
+ <span class="col-md-4">
22
20
  <span id="forum-distribution-span">
23
21
  <label> <%= t('xForum.Distribuiton_List_Name')%> </label> <br><br>
24
22
  <%=select_tag(:forum,options_for_select(@distribution_lists), id:'forum-distribution-lists', class:'forum-select')%>
25
23
  <label><%=t('xForum.New')%></label> <input type="text" id='forum-new-distribution-list' class="admin-edit-field" >
26
- </span>
24
+ <label><%=t('xFrorum.User_Email')%></label>
25
+ <%=text_area_tag(:forum_selected_emails )%>
26
+ </span>
27
27
  <span id="forum-moderator-add-span">
28
28
  <label> <%= t('xForum.Add_Topic_Monitor')%> </label> <br><br>
29
29
  <%= select_tag(:forum, options_for_select(@categories),id:'forum-category-monitor', class: 'forum-select') %>
@@ -1,3 +1,3 @@
1
1
  module Xforum
2
- VERSION = '0.0.36'
2
+ VERSION = '0.0.37'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xforum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.36
4
+ version: 0.0.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert D Blanton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-23 00:00:00.000000000 Z
11
+ date: 2014-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3