lib/puppet/provider/macauthdb/default.rb
def sql_update_mechanisms_map(dbconn, the_rule, mechanisms)
    delete = "DELETE FROM mechanisms_map WHERE r_id = ?"
    self.class.exec_sql_statement(dbconn, delete, the_rule['id'])

    unless mechanisms.empty?
      mechs = mechanisms.map do |value|
        plugin, param = value.split(':')
        query = %Q{SELECT * FROM mechanisms WHERE plugin = ? and param = ?}
        self.class.exec_sql_statement(dbconn, query, [plugin, param]).last
      end
      mapping = "INSERT INTO mechanisms_map VALUES (?,?,?)"
      mechs.each_with_index do |mech, i|
        row = [the_rule['id'], mech[0], i]
        self.class.exec_sql_statement(dbconn, mapping, row)
      end
    end
  end
# Update the mechanisms_map table with the modified list of mechanisms
Update the mechanisms_map table with the modified list of mechanisms
Update the mechanisms_map table with the modified list of mechanisms
def sql_update_mechanisms_map(dbconn, the_rule, mechanisms)
    delete = "DELETE FROM mechanisms_map WHERE r_id = ?"
    self.class.exec_sql_statement(dbconn, delete, the_rule['id'])
    unless mechanisms.empty?
      mechs = mechanisms.map do |value|
        plugin, param = value.split(':')
        query = %Q{SELECT * FROM mechanisms WHERE plugin = ? and param = ?}
        self.class.exec_sql_statement(dbconn, query, [plugin, param]).last
      end
      mapping = "INSERT INTO mechanisms_map VALUES (?,?,?)"
      mechs.each_with_index do |mech, i|
        row = [the_rule['id'], mech[0], i]
        self.class.exec_sql_statement(dbconn, mapping, row)
      end
    end
  end
def sql_update_mechanisms_map ( dbconn , the_rule , mechanisms ) delete = "DELETE FROM mechanisms_map WHERE r_id = ?" self . class . exec_sql_statement ( dbconn , delete , the_rule [ 'id' ] ) unless mechanisms . empty? mechs = mechanisms . map do | value | plugin , param = value . split ( ':' ) query = %Q{SELECT * FROM mechanisms WHERE plugin = ? and param = ?} self . class . exec_sql_statement ( dbconn , query , [ plugin , param ] ) . last end mapping = "INSERT INTO mechanisms_map VALUES (?,?,?)" mechs . each_with_index do | mech , i | row = [ the_rule [ 'id' ] , mech [ 0 ] , i ] self . class . exec_sql_statement ( dbconn , mapping , row ) end end end
Update the mechanisms_map table with the modified list of mechanisms
Update the mechanisms_map table with the modified list of mechanisms
dbconn
the_rule
mechanisms