Class: WordpressAccount

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/wordpress_account.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new_by_user(params, current_user) ⇒ Object


35
36
37
38
39
40
41
42
# File 'app/models/wordpress_account.rb', line 35

def self.new_by_user(params, current_user)    
   = self.new(params)
  .user_id = current_user.id
  .organization_id = current_user.organization_id
  .active = true
  .blog_password = SecPass::encrypt(.blog_password)
  
end

.post(message, account) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/models/wordpress_account.rb', line 7

def self.post(message, )
  begin
    require "xmlrpc/client"
    bloguser = .blog_user
    blogpass = .blog_password    # Post Links To Blog Via XMLRPC

    .site_url = .site_url.gsub("http://", "") 
    .site_url = .site_url.gsub("https://", "") 
    server = XMLRPC::Client.new( "#{.site_url}", "/xmlrpc.php")
    newPost = Hash.new
    newPost['title'] = "#{message['title']}"
    newPost['description'] = message['content']
    result = server.call("metaWeblog.newPost",1,bloguser,blogpass,newPost,true)

  rescue XMLRPC::FaultException => e
    puts "XMLRPC Error: "
    puts e.faultCode
    puts e.faultString
  rescue StandardError => e
    puts e.to_s
  end
end

Instance Method Details

#show_wordpress_label_methodObject

show the user email in the admin UI instead of the user id


31
32
33
# File 'app/models/wordpress_account.rb', line 31

def show_wordpress_label_method
  "#{self.site_url}"
end