Sha256: bafa05df0573677535fa5f02eb63da53bf00f9748cea86fe28970bd6d77c9240
Contents?: true
Size: 1.48 KB
Versions: 29
Compression:
Stored size: 1.48 KB
Contents
module Xforum class Hyperlink < ActiveRecord::Base require 'json' belongs_to :forum has_many :translations, dependent: :destroy def self.add_one(params) the_link=Hyperlink.where(link_address:params[:link_address],forum_id:params[:forum_id]).first_or_create{ |link| link.link_address= params[:link_address] link.link_text=params[:link_text] link.forum_id= params[:forum_id] } Hyperlink.where(link_address:params[:link_address],forum_id:params[:forum_id]).update_all(link_text:params[:link_text]) unless params[:link_translation].nil? || params[:link_translation] == '' Translation.where(hyperlink_id:the_link.id,language_id:Language.get_me(params)).first_or_create{|link| link.hyperlink_id=the_link.id link.language_id=Language.get_me(params) link.content= params[:link_translation] } Translation.where(hyperlink_id:the_link.id,language_id:Language.get_me(params)).update_all(content:params[:link_translation]) end {todo:'nothing'} end def self.add_set(params,forum_id) (0...params[:link_ref].to_i).each { |i| data=params['link-'+i.to_s] data[:forum_id]=forum_id Hyperlink.add_one(data) } end def self.get_links(forum_id) alist=Hyperlink.where(forum_id:forum_id).pluck(:link_address,:link_text,:id) unless alist.empty? ForumAssist.named_array(alist,[:link_address,:link_text,:id]) end end end end
Version data entries
29 entries across 29 versions & 1 rubygems