Commit 21d5712f authored by Aaron Wells's avatar Aaron Wells
Browse files

Removing end-of-line whitespace

As vetted in the May 2014 dev meeting
http://meetbot.mahara.org/mahara-dev/2014/mahara-dev.2014-05-01-08.01.log.html

Change-Id: I353ed74d69a5346fbe4e8e521e5c349dbe8dcbac
parent e46afb22
......@@ -21,7 +21,7 @@ function db_table_name($name) {
}
/**
* Searches through a query for strings looking like {name}, to replace with
* Searches through a query for strings looking like {name}, to replace with
* correctly quoted and prefixed table names
*
* @param string $sql The SQL to replace the placeholders in
......@@ -47,7 +47,7 @@ function _db_quote_table_placeholders_callback($matches) {
* @return string
*/
function db_quote_identifier($identifier) {
// Currently, postgres and mysql (in postgres compat. mode) both support
// Currently, postgres and mysql (in postgres compat. mode) both support
// the sql standard "
if (strpos($identifier, '"') !== false) {
return $identifier;
......@@ -127,7 +127,7 @@ function column_collation_is_default($table, $column) {
*/
function execute_sql($command, $values=null) {
global $db;
if (!is_a($db, 'ADOConnection')) {
throw new SQLException('Database connection is not available ');
}
......@@ -179,7 +179,7 @@ function record_exists($table, $field1=null, $value1=null, $field2=null, $value2
* Test whether any records exists in a table which match a particular WHERE clause.
*
* This function returns true if at least one record is returned
*
*
* @param string $table The database table to be checked against.
* @param string $select A fragment of SQL to be used in a WHERE clause in the SQL call.
* @param array $values When using prepared statements, this is the value array (optional).
......@@ -317,7 +317,7 @@ function get_record_sql($sql, $values=null) {
if ($recordcount == 0) { // Found no records
return false;
}
else if ($recordcount == 1) { // Found one record
else if ($recordcount == 1) { // Found one record
return (object)$rs->fields;
}
else { // Error: found more than one record
......@@ -469,7 +469,7 @@ function get_recordset_sql($sql, $values=null, $limitfrom=null, $limitnum=null)
catch (ADODB_Exception $e) {
throw new SQLException(create_sql_exception_message($e, $sql, $values));
}
return $rs;
}
......@@ -518,7 +518,7 @@ function recordset_to_assoc($rs) {
if ($records = $rs->GetAssoc(true)) {
foreach ($records as $key => $record) {
$record[$firstcolumn->name] = $key;
$objects[$key] = (object) $record;
$objects[$key] = (object) $record;
}
return $objects;
} else {
......@@ -765,7 +765,7 @@ function get_records_sql_menu($sql,$values=null) {
function get_field($table, $field, $field1=null, $value1=null, $field2=null, $value2=null, $field3=null, $value3=null) {
$select = where_clause_prepared($field1, $field2, $field3);
$values = where_values_prepared($value1, $value2, $value3);
return get_field_sql('SELECT ' . $field . ' FROM ' . db_table_name($table) . ' ' . $select, $values);
}
......@@ -808,7 +808,7 @@ function get_field_sql($sql, $values=null) {
function get_column($table, $field, $field1=null, $value1=null, $field2=null, $value2=null, $field3=null, $value3=null) {
$select = where_clause_prepared($field1, $field2, $field3);
$values = where_values_prepared($value1, $value2, $value3);
return get_column_sql('SELECT ' . $field . ' FROM ' . db_table_name($table) . ' ' . $select, $values);
}
......@@ -937,8 +937,8 @@ function delete_records_select($table, $select='',$values=null) {
}
/**
* @todo <nigel> This function does nothing delete specific. The functionality
* it has with the $values parameter should be merged with the execute_sql
* @todo <nigel> This function does nothing delete specific. The functionality
* it has with the $values parameter should be merged with the execute_sql
* function
*/
function delete_records_sql($sql, $values=null) {
......@@ -976,15 +976,15 @@ function delete_records_sql($sql, $values=null) {
*/
function insert_record($table, $dataobject, $primarykey=false, $returnpk=false) {
// $INSERTRECORD_NOCACHE is yet another work around of dmllib/adodb's ineptitude.
// It's all nice to cache the table columns lookup, but what if the table
// columns change over the life of the page load? This happens when an
// upgrade is running. All of a sudden, the table_column cache is out of
// It's all nice to cache the table columns lookup, but what if the table
// columns change over the life of the page load? This happens when an
// upgrade is running. All of a sudden, the table_column cache is out of
// date and we can't insert new data properly.
// Temporary solution: set INSERTRECORD_NOCACHE to true before your calls
// Temporary solution: set INSERTRECORD_NOCACHE to true before your calls
// that need a new lookup, and unset it afterwards
global $db, $INSERTRECORD_NOCACHE;
static $table_columns;
// Determine all the fields in the table
if (empty($INSERTRECORD_NOCACHE) && is_array($table_columns) && array_key_exists($table, $table_columns)) {
$columns = $table_columns[$table];
......@@ -995,7 +995,7 @@ function insert_record($table, $dataobject, $primarykey=false, $returnpk=false)
}
$table_columns[$table] = $columns;
}
if (!empty($primarykey)) {
unset($dataobject->{$primarykey});
if (!empty($returnpk) && is_postgres()) {
......@@ -1058,9 +1058,9 @@ function insert_record($table, $dataobject, $primarykey=false, $returnpk=false)
}
// This only gets triggered with non-Postgres databases
// however we have some postgres fallback in case we failed
// however we have some postgres fallback in case we failed
// to find the sequence.
$id = $db->Insert_ID();
$id = $db->Insert_ID();
if (is_postgres()) {
// try to get the primary key based on id
......@@ -1073,7 +1073,7 @@ function insert_record($table, $dataobject, $primarykey=false, $returnpk=false)
throw new SQLException('WTF: somehow got more than one record when searching for a primary key');
}
catch (ADODB_Exception $e) {
throw new SQLException("Trying to get pk from oid failed: "
throw new SQLException("Trying to get pk from oid failed: "
. $e->getMessage() . " sql was $oidsql");
}
}
......@@ -1082,7 +1082,7 @@ function insert_record($table, $dataobject, $primarykey=false, $returnpk=false)
}
/**
* Inserts a record, only if the record does not already exist.
* Inserts a record, only if the record does not already exist.
* If the record DOES exist, it is updated.
*
* @uses $db
......@@ -1116,7 +1116,7 @@ function ensure_record_exists($table, $whereobject, $dataobject, $primarykey=fal
else {
// @TODO maybe some mysql specific stuff here
}
db_begin();
if ($exists = get_record_select($table, $where, $values)) {
if ($returnpk) {
......@@ -1147,7 +1147,7 @@ function ensure_record_exists($table, $whereobject, $dataobject, $primarykey=fal
* @param string $table The database table to be checked against.
* @param array $dataobject An object with contents equal to fieldname=>fieldvalue. Must have an entry for 'id' to map to the table specified.
* @param mixed $where defines the WHERE part of the upgrade. Can be string (key) or array (keys) or hash (keys/values).
* If the first two, values are expected to be in $dataobject.
* If the first two, values are expected to be in $dataobject.
* @return bool
* @throws SQLException
*/
......@@ -1161,7 +1161,7 @@ function update_record($table, $dataobject, $where=null) {
if (empty($where)) {
$where = 'id';
if (!isset($dataobject->id) ) {
if (!isset($dataobject->id) ) {
// nothing to put in the where clause and we don't want to update everything
throw new SQLException('update_record called with no where clause and no ID');
}
......@@ -1171,7 +1171,7 @@ function update_record($table, $dataobject, $where=null) {
$wherevalues = array();
$values = array();
if (is_string($where)) {
if (is_string($where)) {
// treat it like a stack (ie, field in dataobject)
$where = array($where);
}
......@@ -1199,7 +1199,7 @@ function update_record($table, $dataobject, $where=null) {
}
static $table_columns;
// Determine all the fields in the table
if (is_array($table_columns) && isset($table_columns[$table])) {
$columns = $table_columns[$table];
......@@ -1251,7 +1251,7 @@ function update_record($table, $dataobject, $where=null) {
}
$sql = 'UPDATE '. db_table_name($table) .' SET '. $update .' WHERE ' . $whereclause;
try {
try {
$stmt = $db->Prepare($sql);
$rs = $db->Execute($stmt,array_merge($values, $wherevalues));
return true;
......@@ -1294,7 +1294,7 @@ function where_clause($field1='', $value1='', $field2='', $value2='', $field3=''
/**
* Prepares a SQL WHERE clause to select records where the given fields match some values.
* Uses ? as placeholders for prepared statments
*
*
* @param string $field1 the first field to check (optional).
* @param string $field2 the second field to check (optional).
* @param string $field3 the third field to check (optional).
......@@ -1310,12 +1310,12 @@ function where_clause_prepared($field1='', $field2='', $field3='') {
$select .= " AND \"$field3\" = ? ";
}
}
}
}
return $select;
}
/*
* Useful helper function to only push optional values into the array
* Useful helper function to only push optional values into the array
* for prepared statements to avoid empty slots.
* all parameters are optional.
*
......@@ -1361,7 +1361,7 @@ function column_type($table, $column) {
* This function will execute an array of SQL commands, returning
* true/false if any error is found and stopping/continue as desired.
* It's widely used by all the ddllib.php functions
*
*
* @private
* @param array sqlarr array of sql statements to execute
* @param boolean continue to specify if must continue on error (true) or stop (false)
......@@ -1401,7 +1401,7 @@ function execute_sql_arr($sqlarr, $continue=true, $feedback=true) {
* Unix integer timestamp or an ISO format Y-m-d H:i:s. Uses the fmtTimeStamp
* field, which holds the format to use. If null or false or '' is passed in,
* it will be converted to an SQL null.
*
*
* Returns the timestamp as a quoted string.
*
* @param ts a timestamp in Unix date time format.
......@@ -1411,7 +1411,7 @@ function execute_sql_arr($sqlarr, $continue=true, $feedback=true) {
function db_format_timestamp($ts) {
global $db;
// Otherwise $db->BindTimeStamp() returns the string 'null', which is not
// Otherwise $db->BindTimeStamp() returns the string 'null', which is not
// what we want
if (empty($ts)) {
return null;
......@@ -1422,7 +1422,7 @@ function db_format_timestamp($ts) {
/**
* Given a field name, this returns a function call suitable for the current
* database to return a unix timestamp
*
*
* @param field the field to apply the function to
* @param as what to name the field (optional, defaults to $field). If false,
* no naming is done.
......@@ -1493,7 +1493,7 @@ function is_mysql() {
/**
* function to convert an array to
* an array of placeholders (?)
* an array of placeholders (?)
* with the right number of values
*
* @param array $array input array
......@@ -1508,7 +1508,7 @@ $GLOBALS['_TRANSACTION_LEVEL'] = 0;
/**
* This function starts a smart transaction
*
*
*/
function db_begin() {
global $db;
......@@ -1593,14 +1593,14 @@ function increment_perf_db_cached($db, $secs2cache, $sql, $inputarray) {
}
/**
* Gives the caller the ability to disable logging of SQL exceptions in the
* Gives the caller the ability to disable logging of SQL exceptions in the
* SQLException constructor.
*
* This is only used by the config loading code to prevent spurious errors
* about the config table not existing going to the logs. If you are going to
* This is only used by the config loading code to prevent spurious errors
* about the config table not existing going to the logs. If you are going to
* use this function, you had better have a very good reason!
*
* @param bool $status Whether to ignore logging exceptions or not. If null,
* @param bool $status Whether to ignore logging exceptions or not. If null,
* you can retrieve the current value of this setting
*/
function db_ignore_sql_exceptions($status=null) {
......@@ -1622,7 +1622,7 @@ function db_ignore_sql_exceptions($status=null) {
/**
* Returns the SQL keyword required to do LIKE in a case insensitive fashion.
*
* MySQL, as long as you use a case insensitive collation (as is the default),
* MySQL, as long as you use a case insensitive collation (as is the default),
* uses LIKE for this, while real databases use ILIKE.
*/
function db_ilike() {
......
......@@ -461,28 +461,28 @@ function is_image_file($path) {
* If the file with the ID exists but not of the correct size, this function
* will make a copy that is resized to the correct size.
*
* @param string $path The base path in dataroot where the image is stored. For
* example, 'artefact/file/profileicons/' for profile
* @param string $path The base path in dataroot where the image is stored. For
* example, 'artefact/file/profileicons/' for profile
* icons
* @param int $id The ID of the image to return. Is typically the ID of an
* @param int $id The ID of the image to return. Is typically the ID of an
* artefact
* @param mixed $size The size the image should be.
*
* As a two element hash with 'w' and 'h' keys:
* - If 'w' and 'h' are not empty, the image will be
* - If 'w' and 'h' are not empty, the image will be
* exactly that size
* - If just 'w' is not empty, the image will be that wide,
* and the height will be set to make the image scale
* - If just 'w' is not empty, the image will be that wide,
* and the height will be set to make the image scale
* correctly
* - If just 'h' is not empty, the image will be that high,
* and the width will be set to make the image scale
* - If just 'h' is not empty, the image will be that high,
* and the width will be set to make the image scale
* correctly
* - If neither are set or the parameter is not set, the
* - If neither are set or the parameter is not set, the
* image will not be resized
*
* As a number, the path returned will have the largest side being
* As a number, the path returned will have the largest side being
* the length specified.
* @return string The path on disk where the appropriate file resides, or false
* @return string The path on disk where the appropriate file resides, or false
* if an appropriate file could not be located or generated
*/
function get_dataroot_image_path($path, $id, $size=null) {
......@@ -500,8 +500,8 @@ function get_dataroot_image_path($path, $id, $size=null) {
// Work out the location of the original image
$originalimage = $imagepath . '/originals/' . ($id % 256) . "/$id";
// If the original has been deleted, then don't show any image, even a cached one.
// delete_image only deletes the original, not any cached ones, so we have
// If the original has been deleted, then don't show any image, even a cached one.
// delete_image only deletes the original, not any cached ones, so we have
// to make sure the original is still around
if (!is_readable($originalimage)) {
return false;
......@@ -608,8 +608,8 @@ function get_dataroot_image_path($path, $id, $size=null) {
$newih = imagecreatetruecolor($newdimensions['w'], $newdimensions['h']);
if ($originalmimetype == 'image/png' || $originalmimetype == 'image/gif') {
// Create a new destination image which is completely
// transparent and turn off alpha blending for it, so that when
// Create a new destination image which is completely
// transparent and turn off alpha blending for it, so that when
// the PNG source file is copied, the alpha channel is retained.
// Thanks to http://alexle.net/archives/131
......@@ -620,8 +620,8 @@ function get_dataroot_image_path($path, $id, $size=null) {
imagesavealpha($newih, true);
}
else {
// imagecopyresized is faster, but results in noticeably worse image quality.
// Given the images are resized only once each time they're
// imagecopyresized is faster, but results in noticeably worse image quality.
// Given the images are resized only once each time they're
// made, I suggest you just leave the good quality one in place
imagecopyresampled($newih, $oldih, 0, 0, 0, 0, $newdimensions['w'], $newdimensions['h'], $oldx, $oldy);
//imagecopyresized($newih, $oldih, 0, 0, 0, 0, $newdimensions['w'], $newdimensions['h'], $oldx, $oldy);
......@@ -640,8 +640,8 @@ function get_dataroot_image_path($path, $id, $size=null) {
}
/**
* Given the old dimensions of an image and a size object as obtained from
* get_imagesize_parameters(), calculates what the new size of the image should
* Given the old dimensions of an image and a size object as obtained from
* get_imagesize_parameters(), calculates what the new size of the image should
* be
*
* @param int $oldx The width of the image to calculate the new size for
......@@ -756,12 +756,12 @@ function rmdirr($dirname)
if (!file_exists($dirname)) {
return false;
}
// Simple delete for a file
if (is_file($dirname) || is_link($dirname)) {
return unlink($dirname);
}
// Loop through the folder
$dir = dir($dirname);
while (false !== $entry = $dir->read()) {
......@@ -769,11 +769,11 @@ function rmdirr($dirname)
if ($entry == '.' || $entry == '..') {
continue;
}
// Recurse
rmdirr($dirname . '/' . $entry);
}
// Clean up
$dir->close();
return rmdir($dirname);
......
......@@ -34,8 +34,8 @@ function pieform_element_artefactchooser(Pieform $form, $element) {
$formname = $form->get_name();
$smarty->assign('blockinstance', substr($formname, strpos($formname, '_') + 1));
// Save the pagination javascript for later, when it is asked for. This is
// messy, but can't be helped until Pieforms goes to a more OO way of
// Save the pagination javascript for later, when it is asked for. This is
// messy, but can't be helped until Pieforms goes to a more OO way of
// managing stuff.
$pagination_js = $pagination['javascript'];
$pagination_js .= "\nvar acSelectArtefacts = " . json_encode($artefactdata) . "\n";
......@@ -113,8 +113,8 @@ function pieform_element_artefactchooser_set_attributes($element) {
}
/**
* Extension by Mahara. This api function returns the javascript required to
* set up the element, assuming the element has been placed in the page using
* Extension by Mahara. This api function returns the javascript required to
* set up the element, assuming the element has been placed in the page using
* javascript. This feature is used in the views interface.
*
* In theory, this could go upstream to pieforms itself
......@@ -131,7 +131,7 @@ function pieform_element_artefactchooser_views_js(Pieform $form, $element) {
$pagination_js = 'var p = ' . $pagination_js;
// TODO: This is quite a lot of javascript to be sending inline, especially the ArtefactChooserData
// TODO: This is quite a lot of javascript to be sending inline, especially the ArtefactChooserData
// class.
if (!empty($element['selectone'])) {
......@@ -304,7 +304,7 @@ EOF;
if (empty($element['selectone'])) {
$pagination_js .=<<<EOF
/**
* Manages the problem of changing pages in the artefact chooser losing what
* Manages the problem of changing pages in the artefact chooser losing what
* things were selected/not selected
*/
function ArtefactChooserData() {
......@@ -319,11 +319,11 @@ function ArtefactChooserData() {
}
/**
* Puts two containers into the DOM, that will each contain hidden form elements
* - one for all the elements on the current page of results, and one for
* Puts two containers into the DOM, that will each contain hidden form elements
* - one for all the elements on the current page of results, and one for
* the currently selected options.
*
* Clears out existing containers instead of making new ones, if containers
* Clears out existing containers instead of making new ones, if containers
* already exist. This happens when changing tabs on the artefact chooser
*/
this.insertElementContainers = function() {
......@@ -367,8 +367,8 @@ function ArtefactChooserData() {
}
/**
* Find all hidden onpage inputs, and move them to the container, otherwise
* destroy them if they're already in there (which happens if we go to a
* Find all hidden onpage inputs, and move them to the container, otherwise
* destroy them if they're already in there (which happens if we go to a
* page we've already seen)
*/
this.scrapeForOnpage = function() {
......@@ -431,7 +431,7 @@ function ArtefactChooserData() {
}
/**
* Ensures that the element we have been given is in the list of selected
* Ensures that the element we have been given is in the list of selected
* elements
*/
this.ensureSelectedElement = function(element) {
......@@ -451,7 +451,7 @@ function ArtefactChooserData() {
}
/**
* Ensures that the element we have been given is NOT in the list of
* Ensures that the element we have been given is NOT in the list of
* selected elements
*/
this.removeSelectedElement = function(element) {
......@@ -464,8 +464,8 @@ function ArtefactChooserData() {
}
/**
* Called when the user browses back to a page they have already seen. They
* may have added/removed what they have checked on that page, so we need
* Called when the user browses back to a page they have already seen. They
* may have added/removed what they have checked on that page, so we need
* to syncronise the display with their choices
*/
this.syncroniseCheckboxStateFromContainer = function() {
......@@ -481,15 +481,15 @@ function ArtefactChooserData() {
});
}
// Contains hidden elements representing every artefact we have seen,
// Contains hidden elements representing every artefact we have seen,
// regardless of whether it has been selected
this.seenElementsContainer = null;
// Contains hidden elements representing every artefact that has been
// Contains hidden elements representing every artefact that has been
// selected on any page we have seen
this.selectedElementsContainer = null;
// Pagination offsets we have already seen. We have always seen offset 0
// Pagination offsets we have already seen. We have always seen offset 0
// when we begin.
this.seenOffsets = [0];
......
......@@ -44,7 +44,7 @@ function pieform_element_emaillist(Pieform $form, $element) {
if (!isset($value['default'])) {
$value['default'] = '';
}
if (is_array($value) && count($value)) {
$smarty->assign('validated', $value['validated']);
$smarty->assign('unvalidated', $value['unvalidated']);
......
......@@ -15,7 +15,7 @@ require_once 'form/elements/wysiwyg.php';
* Renders a textarea, but with extra javascript to turn it into a wysiwyg
* textarea.
*
* This version has far less controls - though that is configured in
* This version has far less controls - though that is configured in
* lib/web.php
*
* @param array $element The element to render
......@@ -42,8 +42,8 @@ function pieform_element_tinywysiwyg_get_value(Pieform $form, $element) {
}
/**
* Extension by Mahara. This api function returns the javascript required to
* set up the element, assuming the element has been placed in the page using
* Extension by Mahara. This api function returns the javascript required to
* set up the element, assuming the element has been placed in the page using
* javascript. This feature is used in the views interface.
*
* In theory, this could go upstream to pieforms itself
......
......@@ -123,7 +123,7 @@ function pieform_element_viewacl(Pieform $form, $element) {
}
$mygroups[] = $group;
}
$faves = array();
foreach (get_user_favorites($USER->get('id')) as $u) {
$fave = array(
......
......@@ -10,7 +10,7 @@
*/
/**
* Provides a control that allows the user to input where in a list they want
* Provides a control that allows the user to input where in a list they want
* to put something. Handy for indicating the order of some objects.
*
* @param Pieform $form The form to render the element for
......@@ -67,8 +67,8 @@ function pieform_element_weight_get_value(Pieform $form, $element) {
$value = $element['defaultvalue'];
}
// How should we return the value? In theory, there could be several ways
// in which the caller wants the data to be returned. For now, only one
// How should we return the value? In theory, there could be several ways
// in which the caller wants the data to be returned. For now, only one
// "policy" is implemented
switch ($element['returnpolicy']) {
case 'renumber-from-zero':
......
......@@ -19,9 +19,9 @@ defined('INTERNAL') || die();
* If the user is not in the group, this returns false.
*
* @param mixed $groupid ID of the group to check
* @param mixed $userid ID of the user to check. Defaults to the logged in
* @param mixed $userid ID of the user to check. Defaults to the logged in
* user.
* @return mixed The role the user has in the group, or false if they
* @return mixed The role the user has in the group, or false if they
* have no role in the group
*/
function group_user_access($groupid, $userid=null, $refresh=null) {
......@@ -44,7 +44,7 @@ function group_user_access($groupid, $userid=null, $refresh=null) {
/**
* Returns whether the given user is the only administrator in the given group.
*
* If the user isn't in the group, or they're not an admin, or there is another admin, false
* If the user isn't in the group, or they're not an admin, or there is another admin, false
* is returned.
*
* @param int $groupid The ID of the group to check
......@@ -66,10 +66,10 @@ function group_is_only_admin($groupid, $userid=null) {
}
/**
* Returns whether the given user is allowed to change their role to the
* Returns whether the given user is allowed to change their role to the
* requested role in the given group.
*
* This function is checking whether _role changes_ are allowed, not if a user
* This function is checking whether _role changes_ are allowed, not if a user
* is allowed to be added to a group.
*
* @param int $groupid The ID of the group to check
......@@ -99,8 +99,8 @@ function group_can_change_role($groupid, $userid, $role) {
* @param int $groupid The ID of the group
* @param int $userid The ID of the user whose role needs changing
* @param string $role The role the user wishes to switch to
* @throws AccessDeniedException If the specified role change is not allowed.
* Check with group_can_change_role first if you
* @throws AccessDeniedException If the specified role change is not allowed.
* Check with group_can_change_role first if you
* need to.
*/
function group_change_role($groupid, $userid, $role) {
......@@ -235,7 +235,7 @@ function group_role_can_access_report($group, $role) {
}
/**
* Returns whether a user is allowed to assess views that have been submitted
* Returns whether a user is allowed to assess views that have been submitted
* to the given group.
*
* @param int $groupid ID of group
......@@ -263,10 +263,10 @@ function group_user_can_assess_submitted_views($groupid, $userid) {
/**
* Creates a group.
*
* All group creation should be done through this function, as the
* All group creation should be done through this function, as the
* implementation of group creation may change over time.
*
* @param array $data Data required to create the group. The following
* @param array $data Data required to create the group. The following
* key/value pairs can be specified: