* Copyright 2004, Anthony J. Pugliese
* Copyright 2009, Roland Mas
*
- * This file is part of FusionForge.
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
*
- * FusionForge is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2 of the License,
- * or (at your option) any later version.
- *
- * FusionForge is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with FusionForge; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
require_once $gfcommon.'include/Error.class.php';
class ArtifactExtraField extends Error {
- /**
+ /**
* The artifact type object.
*
* @var object $ArtifactType.
* @return boolean success.
*/
function ArtifactExtraField(&$ArtifactType, $data=false) {
- $this->Error();
+ $this->Error();
//was ArtifactType legit?
if (!$ArtifactType || !is_object($ArtifactType)) {
/**
* create - create a row in the table that stores box names for a
- * a tracker. This function is only used to create rows for boxes
+ * a tracker. This function is only used to create rows for boxes
* configured by the admin.
*
* @param string Name of the extra field.
}
if (!$field_type) {
$this->setError("Type of custom field not selected");
- return false;
+ return false;
}
if (!forge_check_perm ('tracker_admin', $this->ArtifactType->Group->getID())) {
$this->setPermissionDeniedError();
return false;
}
}
-
+
if ($is_required) {
$is_required=1;
} else {
$is_required=0;
- }
-
+ }
+
if (!($alias = $this->generateAlias($alias,$name))) {
return false;
}
-
+
db_begin();
- $result = db_query_params ('INSERT INTO artifact_extra_field_list (group_artifact_id,field_name,field_type,attribute1,attribute2,is_required,alias)
+ $result = db_query_params ('INSERT INTO artifact_extra_field_list (group_artifact_id,field_name,field_type,attribute1,attribute2,is_required,alias)
VALUES ($1,$2,$3,$4,$5,$6,$7)',
array ($this->ArtifactType->getID(),
htmlspecialchars($name),
//
// Must insert some default 100 rows for the data table so None queries will work right
//
- $resdefault = db_query_params ('INSERT INTO artifact_extra_field_data(artifact_id,field_data,extra_field_id)
+ $resdefault = db_query_params ('INSERT INTO artifact_extra_field_data(artifact_id,field_data,extra_field_id)
SELECT artifact_id,100,$1 FROM artifact WHERE group_artifact_id=$2',
array ($id,
$this->ArtifactType->getID())) ;
$this->id=$id;
$res = db_query_params ('SELECT * FROM artifact_extra_field_list WHERE extra_field_id=$1',
array ($id)) ;
-
+
if (!$res || db_numrows($res) < 1) {
$this->setError('ArtifactExtraField: Invalid ArtifactExtraField ID');
return false;
function &getArtifactType() {
return $this->ArtifactType;
}
-
+
/**
* getID - get this ArtifactExtraField ID.
*
* @return string type.
*/
function getTypeName() {
- $arr=&$this->getAvailableTypes();
+ $arr = $this->getAvailableTypes();
return $arr[$this->data_array['field_type']];
}
10=>_('Integer')
);
}
-
+
/**
* getAlias - the alias that is used for this field
*
function getAlias() {
return $this->data_array['alias'];
}
-
+
/**
* getAvailableValues - Get the list of available values for this extra field
*
}
/**
- * update - update a row in the table used to store box names
+ * update - update a row in the table used to store box names
* for a tracker. This function is only to update rowsf
* for boxes configured by
* the admin.
$this->setError(_('a field name is required'));
return false;
}
- $res = db_query_params ('SELECT field_name FROM artifact_extra_field_list
+ $res = db_query_params ('SELECT field_name FROM artifact_extra_field_list
WHERE field_name=$1 AND group_artifact_id=$2 AND extra_field_id !=$3',
array($name,
$this->ArtifactType->getID(),
} else {
$is_required=0;
}
-
+
if (!($alias = $this->generateAlias($alias,$name))) {
return false;
- }
+ }
- $result = db_query_params ('UPDATE artifact_extra_field_list
+ $result = db_query_params ('UPDATE artifact_extra_field_list
SET field_name=$1,
attribute1=$2,
attribute2=$3,
*/
function delete($sure, $really_sure) {
if (!$sure || !$really_sure) {
- $this->setMissingParamsError();
+ $this->setMissingParamsError(_('Please tick all checkboxes.'));
return false;
}
if (!forge_check_perm ('tracker_admin', $this->ArtifactType->Group->getID())) {
}
}
-
+
/**
* Validate an alias.
* Note that this function does not check for conflicts.
// these are reserved alias names
static $reserved_alias = array(
"project",
- "type",
"priority",
"assigned_to",
+ "submitted_by",
+ "open_date",
+ "close_date",
"summary",
- "details"
+ "details",
+ "last_modified_date"
);
if (strlen($alias) == 0) return true; // empty alias
// invalid chars?
if (preg_match("/[^[:alnum:]_@\\-]/", $alias)) {
- $this->setError(_('The alias contains invalid characters. Only letters, numbers, hypens (-), arobase (@) and underscores (_) allowed.'));
+ $this->setError(_('The alias contains invalid characters. Only letters, numbers, hypens (-), at sign (@) and underscores (_) allowed.'));
return false;
} else if (in_array($alias, $reserved_alias)) { // alias is reserved?
$this->setError(sprintf(_('\'%1$s\' is a reserved alias. Please provide another name.'), $alias));
return false;
}
-
+
return true;
}
-
+
/**
* Generate an alias for this field. The alias can be entered by the user or
* be generated automatically from the name of the field.
$alias = strtolower(trim($alias));
if (strlen($alias) == 0) { // no alias was entered, generate alias from $name
$name = strtolower(trim($name));
- // Convert the original name to a valid alias (i.e., if the extra field is
+ // Convert the original name to a valid alias (i.e., if the extra field is
// called "Quality test", make an alias called "quality_test").
// The alias can be seen as a "unix name" for this field
$alias = preg_replace("/ /", "_", $name);
} elseif (!$this->validateAlias($alias)) {
// alias is invalid...
return false;
- }
+ }
// check if the name conflicts with another alias in the same artifact type
// in that case append a serial number to the alias
$serial = 1;
- $conflict = false;
+ $conflict = false;
do {
if ($this->data_array['extra_field_id']) {
$res = db_query_params ('SELECT * FROM artifact_extra_field_list
return true;
}
- function alphaorderValues($element_id) {
+ function alphaorderValues() {
$res = db_query_params ('SELECT element_id FROM artifact_extra_field_elements WHERE extra_field_id=$1 ORDER BY element_name ASC',
array($this->getID()));