<?php
-require_once('../env.inc.php');
+require_once '../env.inc.php';
require_once $gfwww.'include/pre.php';
require_once($gfcommon.'tracker/ArtifactType.class.php');
require_once($gfcommon.'tracker/Artifact.class.php');
/**
* findType - get the type of a field from its name, value, and vocabulary : default 0 (text box), otherwise 1 (select box) or 2 (multi choice field)
- * @param string Name of the field
- * @param string|array Value of the field
- * @param $vocabulary Vocabulary of a tracker
+ * @param string $fieldName Name of the field
+ * @param string|array $fieldValue Value of the field
+ * @param string $vocabulary Vocabulary of a tracker
+ * @return int
*/
function findType($fieldName, $fieldValue, $vocabulary){
- if(is_array($fieldValue)){
+ if (is_array($fieldValue)){
return ARTIFACT_EXTRAFIELDTYPE_MULTISELECT;
- }
- elseif(array_key_exists($fieldName, $vocabulary)){
-
+ } elseif(array_key_exists($fieldName, $vocabulary)) {
return ARTIFACT_EXTRAFIELDTYPE_SELECT;
- }
- else {
+ } else {
return ARTIFACT_EXTRAFIELDTYPE_TEXT;
}
- return true;
}
/**
* createFieldElements - Add elements (choices) to an extra field
- * @param ArtifactExtraField The artifact extra field where the choices should be added
- * @param array The choices to be declared for the specified extra field
- * @return false if failed
+ * @param ArtifactExtraField $aef The artifact extra field where the choices should be added
+ * @param array $vocabulary The choices to be declared for the specified extra field
+ * @return bool false if failed
*/
function createFieldElements($aef, $vocabulary){
//TODO:Add each element to tracker extra field
/**
* createFields - Create the custom fields for the specified ArtifactType
- * @param ArtifactType The artifact type to be modified
- * @param array Vocabulary and artifacts for the ArtifactType
- * @return false if failed
+ * @param ArtifactType $at The artifact type to be modified
+ * @param array $data Vocabulary and artifacts for the ArtifactType
+ * @return bool false if failed
*/
function createFields($at, $data){
global $NOT_EXTRA_FIELDS;
/**
* createTracker - Create a specific tracker from data in the specified group
- * @param string Tracker type (bugs, support, ...)
- * @param Group The group which the tracker belongs to
- * @param array Tracker data from JSON
- * @return ArtifactType the tracker created
+ * @param string $tracker Tracker type (bugs, support, ...)
+ * @param Group $group The group which the tracker belongs to
+ * @param array $data Tracker data from JSON
+ * @return ArtifactType the tracker created
*/
function createTracker($tracker, $group, $data){
/**
* deleteTrackers - Delete all existing default trackers from a projet
- * @param Group A Group object
+ * @param Group $group A Group object
*/
function deleteTrackers($group){
$res = db_query_params ('SELECT group_artifact_id FROM artifact_group_list
/**
* addComments - Add followup comments to an Artifact Object
- * @param Artifact the artifact object where history should be added
- * @param array the artifact's data in json format (an array)
+ * @param Artifact $artifact the artifact object where history should be added
+ * @param array $jsonArtifact the artifact's data in json format (an array)
*/
function addComments($artifact, $jsonArtifact){
foreach($jsonArtifact['comments'] as $c){
$time = strtotime($c['date']);
- $uid =&user_get_object_by_name($c['submitter'])->getID();
+ $uid = user_get_object_by_name($c['submitter'])->getID();
$importData = array('time' => $time, 'user' => $uid);
$artifact->addMessage($c['comment'],false,false, $importData);
}
/**
* addHistory - Add history of changes to an Artifact Object
- * @param Artifact the artifact object where history should be added
- * @param array the artifact's data in json format (an array)
+ * @param Artifact $artifact the artifact object where history should be added
+ * @param array $jsonArtifact the artifact's data in json format (an array)
*/
function addHistory($artifact, $jsonArtifact){
foreach($jsonArtifact['history'] as $h){
$time = strtotime($h['date']);
- $uid =&user_get_object_by_name($h['by'])->getID();
+ $uid = user_get_object_by_name($h['by'])->getID();
$importData = array('time' => $time, 'user' => $uid);
//hack!!
$old = $h['old'];
if($h['field']=='assigned_to'){
if($old!='none'){
- $old =&user_get_object_by_name($old)->getID();
+ $old = user_get_object_by_name($old)->getID();
} else {
$old = 100;
}
}
}
-
function addFiles($artifact, $jsonArtifact){
foreach($jsonArtifact['attachments'] as $a){
$fs = filesize($path);
-
$finfo = new finfo(FILEINFO_MIME, "/usr/share/misc/magic"); // Retourne le type mime
if (!$finfo) {
echo "error opening fileinfo";
$ftype = $finfo->file($path);
$time = strtotime($a['date']);
- $uid =&user_get_object_by_name($a['by'])->getID();
+ $uid = user_get_object_by_name($a['by'])->getID();
$importData = array('user' => $uid, 'time' => $time);
//we have no descriptions for files => None
}
}
-
/**
* createArtifacts - Create all the artifacts for an ArtifactType from an array of data.
- * @param ArtifactType The ArtifactType object which the artifacts to be added belong to.
- * @param array The data of all the artifacts of the current Type (dictionary)
+ * @param ArtifactType $at The ArtifactType object which the artifacts to be added belong to.
+ * @param array $data The data of all the artifacts of the current Type (dictionary)
* @param $hashrn
* @param $hashlogin
*/
//include $GLOBALS['gfcommon'].'import/import_arrays.php';
$extra_fields_ids = $at->getExtraFields();
-
foreach($extra_fields_ids as $extraField => $val){
$extras[$val[2]] = $extraField;
}
//create the artif here with $extra_fields_array as extra fields
//new dBug($extra_fields_array);
//get user id
- $uid =&user_get_object_by_name($artifact['submitter'])->getID();
+ $uid = user_get_object_by_name($artifact['submitter'])->getID();
//TODO:Search in hash table for corresponding mail for id, lookup object by mail, get ID
//get time from epoch
$timestamp = strtotime($artifact['date']);
//TODO:get the id of the assigned_to user, in the meantime -> Nobody (100)
-
//assigned to : real name dans le pluck
if($artifact['assigned_to']=='Nobody'){
$assigned_to = 100;
} else {
$m = $hashrn[$artifact['assigned_to']];
- $assigned_to =&user_get_object_by_mail($m)->getID();
+ $assigned_to = user_get_object_by_email($m)->getID();
//new dBug(array($m,$assigned_to));
}
}
/**
* tracker_fill - Create trackers from an array in a given group
- * @param array Trackers part of a JSON pluck, including label, artifacts, vocabulary...
- * @param int Group id of the group where the trackers should be added
+ * @param array $trackers Trackers part of a JSON pluck, including label, artifacts, vocabulary...
+ * @param int $group_id Group id of the group where the trackers should be added
+ * @param array $users
*/
function tracker_fill($trackers, $group_id, $users){
- $group =& group_get_object($group_id);
+ $group = group_get_object($group_id);
if (!$group || !is_object($group)) {
print "error retrieving group from id";
- } else if ($group->isError()) {
+ } elseif ($group->isError()) {
print "error";
}
//Tracker creation
foreach ($trackers as $data){
-
$at = createTracker($data['type'], $group, $data);
createArtifacts($at, $data['artifacts'], $hashrn, $hashlogin);
}
}
-
-?>