Example #1
0
 /**
  * save a new connection or update an old connection
  * @param string $old_name
  * @param DoceboConnector $connection
  **/
 function save_connection($old_name, $connection)
 {
     //		$name = Docebo::db()->escape($connection->get_name());
     //		$description = Docebo::db()->escape($connection->get_description());
     $name = $connection->get_name();
     $description = $connection->get_description();
     $type = Get::filter($connection->get_type_name(), DOTY_ALPHANUM);
     $params = $connection->get_config();
     $str_params = urlencode(serialize($params));
     $lang =& $this->get_lang();
     if (strlen(trim($name)) == 0) {
         $this->last_error = $lang->def('_OPERATION_FAILURE');
         return FALSE;
     }
     if ($old_name === '') {
         $query = "INSERT INTO " . $GLOBALS['prefix_fw'] . "_connection" . "(name,description,type,params)" . " VALUES " . "('{$name}','{$description}','{$type}','{$str_params}')";
     } else {
         $query = "UPDATE " . $GLOBALS['prefix_fw'] . "_connection SET" . " name = '" . $name . "'," . " description = '" . $description . "'," . " type = '{$type}'," . " params = '{$str_params}' " . " WHERE name = '" . $old_name . "'";
     }
     //echo $query; die();
     if (sql_query($query)) {
         return TRUE;
     } else {
         $this->last_error = mysql_error();
         return FALSE;
     }
 }