<?php 
class Dragandrop
{
    private $table = "_plugin_dragandrop";
    
    private $database = DB_WARPIT_WEBCATI_BASE;
    
    private $data;
    
    private $db;
    
    public function __construct($db)
    {
        $this->db = $db;
    }
    
    public function load($idProject, $idQuestion)
    {
        $sql = "SELECT * FROM " . $this->database . "." . $this->table . "
            WHERE id_question = " . $idQuestion . " AND id_project = " . $idProject . " AND deleted = 0";
         $res= $this->db->SQLexecute($sql);
         $this->data = $this->db->fetchAssoc($res);
         
         if(empty($this->data))
         {
            $sql = "SELECT * FROM " .  $this->database . "._Plugin_label
            WHERE id_plugin = 7";
            $res= $this->db->SQLexecute($sql);
            while ($dat = $this->db->fetchAssoc($res)) {  
                $this->data[$dat['name']] = $dat['default_value'];
            }
         }
    }
    
    public function getVal($key)
    {
        return $this->data[$key];
    }
    
	public function getData()
    {
        return $this->data;
    }
}

?>