Helping with php-virt-control development

(technical point of view, for sending patches please see Contributions)

Translate php-virt-control

If you want to translate php-virt-control project to your language or any language not supported yet that you know you may enable the Translator mode in your php-virt-project installation.
After login, you will be able to translate all of the strings and generate a new PHP script having all the necessary formatting and everything. You have to download this file manually and put
it to your lang project subdirectory to be able to see your language on the Settings page of your installation.

Please keep in mind that all the language versions are available for all valid php-virt-control users that can login to your php-virt-control instance.

Also, please refer to the Contributions page to see information how to send a new translation to the list to be merged with the project. As php-virt-control is an open-source project your
contribution will be noted unless you ask for not showing your name in the commits or elsewhere.

If you cannot see the Translator mode in your installation you have to enable it. It can be easily enabled by changing line:

define('ENABLE_TRANSLATOR_MODE', false);
in init.php file of your project's installation root directory.

Implement new database type

If you would like to implement a new database layer to be used in the php-virt-control project you can create a new database file in the classes/layers subdirectory.
The naming should be either the way that filename will be the name of the database system the handler is for or the class name inside in form of Database$HANDLERNAME, e.g. DatabaseMySQL.
The case of the letters doesn't matter as it's converted and compared as lowercase.
However, there are several functions that have to be public as they are being called from other, application, classes.

The necessary functions are as follows:

  Class constructor
  Takes $cfg as an argument, this variable have information about server/host, username and password, database name and debugging option
function __construct($cfg)

  Method name: isConnected()
  Description: This method check whether the database layer is connected or not
  Return value: true on connected, false otherwise

function isConnected()

  Method name: setup()
  Description: Try setup provided by the arguments to connect to database
  Arguments: server - database server/host
             user - username to connect to database
             password - password to connect to database
             dbname - database name to connect to
  Return value: true on credentials being valid, false otherwise

function setup($server, $user, $password, $dbname = 'mysql')

  Method name: createNewUser()
  Description: Create a new database system user
  Arguments: username - username of the new user
             password - password for the new user
             host - hostname/server to allow access from (as for MySQL privileges)
             canOverride - flag whether to change password (true) if user exists or fail (false)
  Return value: true on success, false otherwise

function createNewUser($username, $password, $host = false, $canOverride = false)

  Method name: createDatabase()
  Description: Create a database on the database server
  Arguments: dbname - database name
             username - user to add select, insert, update, delete and create/drop privileges for this database
                        false means to add privileges to all users
             host - hostname to allow user to access database from
  Return value: true on success, false otherwise
function createDatabase($dbname, $username = false, $host = false)

  Method name: query()
  Description: Run a database query on a database server/system
  Arguments: query - query string to run on a system
  Return value: Database query resource or false

function query($query)

  Method name: lastInsertID()
  Description: Get ID of last inserted entry
  Arguments: res - optional resource argument, will use latest if omitted
  Return value: insert id

function lastInsertID($res = false)

  Method name: select()
  Description: Select data from a database table
  Arguments: tabName - name of the table to format & run query on
             conditions - conditions for the selection statement
             fields - fields to select
             mods - mods to apply (order, group etc.)
  Return value: array of resulting data

function select($tabName, $conditions, $fields, $mods = false)

  Method name: insert()
  Description: Insert data to a database table
  Arguments: tabName - table name to insert to
             fields - fields to insert in format $field[key]='value'
             pk - primary key to use, optional
  Return value: true on success, false otherwise

function insert($tabName, $fields, $pk = false)

  Method name: update()
  Description: Update data in the database table
  Arguments: tabName - name of table to update
             fields - fields to update ($field[key]='value' format)
             conditions - conditions what fields to update ($field[key]='value')
             autoEscape - optional, automatically escape characters
  Return value: true on success, false otherwise

function update($tabName, $fields, $conditions, $autoEscape = true)

  Method name: delete()
  Description: Delete data from database table
  Arguments: tabName - name of table to delete from
             conditions - conditions what entries to delete
  Return value: true on success, false otherwise

function delete($tabName, $conditions)

  Method name: numRows()
  Description: Get number of rows returned by query
  Arguments: res - optional query resource, will use latest if not supplied
  Return value: number of rows returned in last query

function numRows($res = false)

  Method name: fieldByName()
  Description: Get database field by name
  Arguments: field_name - name of the field to get
             res - optional query resource to get from, will use latest if not supplied
  Return value: field value or false on error

function fieldByName($field_name, $res = false)

  Method name: fetchAssoc()
  Description: Get field data to associative field
  Arguments: res - optional query resource to get from, will use latest if not supplied
  Return value: data array

function fetchAssoc($res = false)

  Method name: close()
  Description: Close the connection to database server/system

function close()