コード例 #1
0
function db_getfieldslist($strSQL)
{
	global $conn;
	$res=array();
	$rs=db_query($strSQL,$conn);
	for($i=0;$i<db_numfields($rs);$i++)
	{
		$res[$i]=array("fieldname"=>db_fieldname($rs,$i),"type"=>202,"is_nullable"=>0);
	}
	return $res;
}
コード例 #2
0
function db_getfieldslist($strSQL)
{
	global $conn;
	$res=array();
	$rs=db_query($strSQL,$conn);
	for($i=0;$i<db_numfields($rs);$i++)
	{
		$ntype=$rs->Fields[$i]->Type;
		$res[$i]=array("fieldname"=>db_fieldname($rs,$i),"type"=>$ntype,"not_null"=>0);
	}
	return $res;
}
コード例 #3
0
function db_fetch_array($rs, $assoc = 1)
{
    global $mssql_dmy;
    if ($rs->EOF()) {
        return false;
    }
    try {
        $ret = array();
        for ($i = 0; $i < db_numfields($rs); $i++) {
            if (IsBinaryType($rs->Fields[$i]->Type) && $rs->Fields[$i]->Type != 128) {
                $str = "";
                if ($rs->Fields[$i]->ActualSize) {
                    $val = $rs->Fields[$i]->GetChunk($rs->Fields[$i]->ActualSize);
                    $str = str_pad("", count($val));
                    $j = 0;
                    foreach ($val as $byte) {
                        $str[$j++] = chr($byte);
                    }
                }
                if ($assoc) {
                    $ret[$rs->Fields[$i]->Name] = $str;
                } else {
                    $ret[$i] = $str;
                }
            } else {
                $value = $rs->Fields[$i]->Value;
                if (is_null($value)) {
                    $val = NULL;
                } else {
                    if (isdatefieldtype($rs->Fields[$i]->Type)) {
                        $value = localdatetime2db((string) $rs->Fields[$i]->Value, $mssql_dmy);
                    }
                    if (IsNumberType($rs->Fields[$i]->Type)) {
                        $val = floatval($value);
                    } else {
                        $val = strval($value);
                    }
                }
                if ($assoc) {
                    $ret[$rs->Fields[$i]->Name] = $val;
                } else {
                    $ret[$i] = $val;
                }
            }
        }
        $rs->MoveNext();
    } catch (com_exception $e) {
        trigger_error($e->getMessage(), E_USER_ERROR);
    }
    return $ret;
}
コード例 #4
0
ファイル: index.php プロジェクト: nterray/tuleap
function ShowResultsGroupSurveys($result)
{
    global $group_id, $Language;
    $survey =& SurveySingleton::instance();
    $rows = db_numrows($result);
    $cols = db_numfields($result);
    $title_arr = array();
    $title_arr[] = $Language->getText('survey_index', 's_id');
    $title_arr[] = $Language->getText('survey_index', 's_tit');
    echo html_build_list_table_top($title_arr);
    for ($j = 0; $j < $rows; $j++) {
        echo "<tr class=\"" . html_get_alt_row_color($j) . "\">\n";
        echo "<TD><A HREF=\"survey.php?group_id={$group_id}&survey_id=" . db_result($result, $j, "survey_id") . "\">" . db_result($result, $j, "survey_id") . "</TD>";
        printf("<TD>%s</TD>\n", $survey->getSurveyTitle(db_result($result, $j, 'survey_title')));
        echo "</tr>";
    }
    echo "</table>";
    //</TD></TR></TABLE>");
}
コード例 #5
0
ファイル: index.php プロジェクト: BackupTheBerlios/berlios
 function ShowResultsGroupSurveys($result)
 {
     global $group_id;
     $rows = db_numrows($result);
     $cols = db_numfields($result);
     $title_arr = array();
     $title_arr[] = 'Survey ID';
     $title_arr[] = 'Survey Title';
     echo html_build_list_table_top($title_arr);
     for ($j = 0; $j < $rows; $j++) {
         echo "<tr BGCOLOR=\"" . html_get_alt_row_color($j) . "\">\n";
         echo "<TD><A HREF=\"survey.php?group_id={$group_id}&survey_id=" . db_result($result, $j, "survey_id") . "\">" . sprintf("%06d", db_result($result, $j, "survey_id")) . "</A></TD>";
         for ($i = 1; $i < $cols; $i++) {
             printf("<TD WIDTH=\"99%%\">%s</TD>\n", db_result($result, $j, $i));
         }
         echo "</tr>";
     }
     echo "</table>";
     //</TD></TR></TABLE>");
 }
コード例 #6
0
 function ShowResultComments($result)
 {
     global $survey_id;
     $rows = db_numrows($result);
     $cols = db_numfields($result);
     echo "<h3>{$rows} Found</h3>";
     $title_arr = array();
     $title_arr[] = 'User ID';
     $title_arr[] = 'Response';
     echo html_build_list_table_top($title_arr);
     for ($j = 0; $j < $rows; $j++) {
         echo "<tr BGCOLOR=\"" . html_get_alt_row_color($j) . "\">\n";
         for ($i = 0; $i < $cols; $i++) {
             printf("<TD>%s</TD>\n", db_result($result, $j, $i));
         }
         echo "</tr>";
     }
     echo "</table>";
     //</TD></TR></TABLE>";
 }
コード例 #7
0
function db_getfieldslist($strSQL)
{
	global $conn;
	$res=array();
	$rs=db_query($strSQL,$conn);
	for($i=0;$i<db_numfields($rs);$i++)
	{
		$stype=mysql_field_type($rs,$i);
		if($stype=="blob")
		{
			$flags=mysql_field_flags($rs,$i);
			if(strpos($flags,"binary")===false)
				$stype="text";
		}

		$ntype=db_fieldtypenum($stype);
		$arr=mysql_fetch_field($rs,$i);
		$res[$i]=array("fieldname"=>db_fieldname($rs,$i),"type"=>$ntype,"not_null"=>0);
	}
	return $res;
}
コード例 #8
0
 function ShowResultsEditQuestion($result)
 {
     global $group_id;
     $rows = db_numrows($result);
     $cols = db_numfields($result);
     echo "<h3>{$rows} Found</h3>";
     $title_arr = array();
     $title_arr[] = 'Question ID';
     $title_arr[] = 'Question';
     $title_arr[] = 'Type';
     echo html_build_list_table_top($title_arr);
     for ($j = 0; $j < $rows; $j++) {
         echo "<tr BGCOLOR=\"" . html_get_alt_row_color($j) . "\">\n";
         echo "<TD><A HREF=\"edit_question.php?group_id={$group_id}&question_id=" . db_result($result, $j, "question_id") . "\">" . sprintf("%06d", db_result($result, $j, "question_id")) . "</A></TD>\n";
         for ($i = 1; $i < $cols; $i++) {
             printf("<TD>%s</TD>\n", db_result($result, $j, $i));
         }
         echo "</tr>";
     }
     echo "</table>";
     //</TD></TR></TABLE>");
 }
コード例 #9
0
function ShowResultComments($result)
{
    global $survey_id;
    $rows = db_numrows($result);
    $cols = db_numfields($result);
    echo "<h3>{$rows} Found</h3>";
    echo "<table border=\"0\">\n";
    /*  Create  the  headers  */
    echo "<tr class=\"tableheading\">\n";
    for ($i = 0; $i < $cols; $i++) {
        echo "<th>" . db_fieldname($result, $i) . "</th>\n";
    }
    echo "</tr>";
    for ($j = 0; $j < $rows; $j++) {
        echo "<tr class=\"" . $HTML->boxGetAltRowStyle($j) . "\">\n";
        for ($i = 0; $i < $cols; $i++) {
            echo "<td>" . db_result($result, $j, $i) . "</td>\n";
        }
        echo "</tr>";
    }
    echo "</table>";
    //</td></tr></table>";
}
コード例 #10
0
function ShowResultsEditQuestion($result)
{
    global $group_id;
    $rows = db_numrows($result);
    $cols = db_numfields($result);
    echo "<h3>" . sprintf(ngettext('%1$s question found', '%1$s questions found', $rows), $rows) . "</h3>";
    echo "<table border=\"0\">\n";
    /*  Create  the  headers  */
    echo "<tr class=\"tableheading\">\n";
    for ($i = 0; $i < $cols; $i++) {
        echo "<th>" . db_fieldname($result, $i) . "</th>\n";
    }
    echo "</tr>";
    for ($j = 0; $j < $rows; $j++) {
        echo "<tr " . $GLOBALS['HTML']->boxGetAltRowStyle($j) . ">\n";
        echo "<td><a href=\"edit_question.php?group_id={$group_id}&amp;question_id=" . db_result($result, $j, "question_id") . "\">" . db_result($result, $j, "question_id") . "</a></td>\n";
        for ($i = 1; $i < $cols; $i++) {
            echo "<td>" . db_result($result, $j, $i) . "</td>\n";
        }
        echo "</tr>";
    }
    echo "</table>";
    //</td></tr></table>");
}
コード例 #11
0
function getFieldNamesByHeaders($fields)
{
    global $strTableName, $conn, $strOriginalTableName, $ext;
    // check fields in column headers
    // check that we have labes in column headers
    $fieldsNotFoundArr = array();
    $fNamesArr = array();
    $fNamesFromQuery = GetFieldsList($strTableName);
    $fieldLabelError = false;
    $labelFieldsNotFoundArr = array();
    for ($j = 0; $j < count($fields); $j++) {
        $labelNotFound = true;
        for ($i = 0; $i < count($fNamesFromQuery); $i++) {
            if ($ext == ".CSV") {
                $label = GoodFieldName($fNamesFromQuery[$i]);
            } else {
                $label = GetFieldLabel(GoodFieldName($strTableName), GoodFieldName($fNamesFromQuery[$i]));
            }
            if ($fields[$j] == $label) {
                $fNamesArr[$j] = $fNamesFromQuery[$i];
                $labelNotFound = false;
                break;
            }
        }
        if ($labelNotFound) {
            $fieldLabelError = true;
            $labelFieldsNotFoundArr[] = $fields[$j];
        }
    }
    // if field names are not labels, than compare them with fields from query
    $fieldsListError = false;
    $queryFieldsNotFoundArr = array();
    if ($fieldLabelError) {
        $fieldFromListNotFound = true;
        $fNamesArr = array();
        for ($j = 0; $j < count($fields); $j++) {
            $fieldNotFound = true;
            for ($i = 0; $i < count($fNamesFromQuery); $i++) {
                if ($fields[$j] == $fNamesFromQuery[$i]) {
                    $fNamesArr[$j] = $fNamesFromQuery[$i];
                    $fieldNotFound = false;
                    $fieldFromListNotFound = false;
                    break;
                }
            }
            if ($fieldNotFound) {
                $fieldsListError = true;
                $queryFieldsNotFoundArr[] = $fields[$j];
            }
        }
    }
    // if field list not lables or fields from query, than compare fields from DB
    $fieldsDbError = false;
    $dbFieldsNotFoundArr = array();
    if ($fieldLabelError && $fieldsListError) {
        $fNamesArr = array();
        $strSQL = "select * from " . AddTableWrappers($strOriginalTableName);
        $rs = db_query($strSQL, $conn);
        $dbFieldNum = db_numfields($rs);
        for ($j = 0; $j < count($fields); $j++) {
            $fieldFromDBNotFound = true;
            for ($i = 0; $i < $dbFieldNum; $i++) {
                $fNameFromDB = db_fieldname($rs, $i);
                if ($fields[$j] == $fNameFromDB) {
                    $fNamesArr[$j] = $fNameFromDB;
                    $fieldFromDBNotFound = false;
                    break;
                }
            }
            if ($fieldFromDBNotFound) {
                $fieldsDbError = true;
                $dbFieldsNotFoundArr[] = $fields[$j];
            }
        }
    }
    // if fields are not labels, fields from list and fields from table
    if ($fieldLabelError && $fieldsListError && $fieldsDbError) {
        if (count($labelFieldsNotFoundArr) < count($dbFieldsNotFoundArr) && count($labelFieldsNotFoundArr) < count($queryFieldsNotFoundArr)) {
            $fieldsNotFoundArr = $labelFieldsNotFoundArr;
        } elseif (count($dbFieldsNotFoundArr) < count($labelFieldsNotFoundArr) && count($dbFieldsNotFoundArr) < count($queryFieldsNotFoundArr)) {
            $fieldsNotFoundArr = $dbFieldsNotFoundArr;
        } elseif (count($queryFieldsNotFoundArr) < count($labelFieldsNotFoundArr) && count($queryFieldsNotFoundArr) < count($dbFieldsNotFoundArr)) {
            $fieldsNotFoundArr = $queryFieldsNotFoundArr;
        } elseif (count($queryFieldsNotFoundArr) == count($labelFieldsNotFoundArr) && count($queryFieldsNotFoundArr) == count($dbFieldsNotFoundArr)) {
            $fieldsNotFoundArr = $dbFieldsNotFoundArr;
        }
        echo "Import didn't succeed, couldn't find followind fields: " . implode(", ", $fieldsNotFoundArr);
        exit;
    } else {
        return $fNamesArr;
    }
}
コード例 #12
0
ファイル: utils.php プロジェクト: neymanna/fusionforge
/**
 * ShowResultSet() - Show a generic result set
 * Very simple, plain way to show a generic result set
 *
 * @param	int		The result set ID
 * @param	string	The title of the result set
 * @param	bool	The option to turn URL's into links
 * @param	bool	The option to display headers
 * @param	array	The db field name -> label mapping
 * @param	array   Don't display these cols
 *
 */
function ShowResultSet($result, $title = '', $linkify = false, $displayHeaders = true, $headerMapping = array(), $excludedCols = array())
{
    global $group_id, $HTML;
    if ($result) {
        $rows = db_numrows($result);
        $cols = db_numfields($result);
        echo '<table border="0" width="100%">';
        /*  Create  the  headers  */
        $headersCellData = array();
        $colsToKeep = array();
        for ($i = 0; $i < $cols; $i++) {
            $fieldName = db_fieldname($result, $i);
            if (in_array($fieldName, $excludedCols)) {
                continue;
            }
            $colsToKeep[] = $i;
            if (isset($headerMapping[$fieldName])) {
                if (is_array($headerMapping[$fieldName])) {
                    $headersCellData[] = $headerMapping[$fieldName];
                } else {
                    $headersCellData[] = array($headerMapping[$fieldName]);
                }
            } else {
                $headersCellData[] = array($fieldName);
            }
        }
        /*  Create the title  */
        if (strlen($title) > 0) {
            $titleCellData = array();
            $titleCellData[] = array($title, 'colspan="' . count($headersCellData) . '"');
            echo $HTML->multiTableRow('', $titleCellData, TRUE);
        }
        /* Display the headers */
        if ($displayHeaders) {
            echo $HTML->multiTableRow('', $headersCellData, TRUE);
        }
        /*  Create the rows  */
        for ($j = 0; $j < $rows; $j++) {
            echo '<tr ' . $HTML->boxGetAltRowStyle($j) . '>';
            for ($i = 0; $i < $cols; $i++) {
                if (in_array($i, $colsToKeep)) {
                    if ($linkify && $i == 0) {
                        $link = '<a href="' . getStringFromServer('PHP_SELF') . '?';
                        $linkend = '</a>';
                        if ($linkify == "bug_cat") {
                            $link .= 'group_id=' . $group_id . '&amp;bug_cat_mod=y&amp;bug_cat_id=' . db_result($result, $j, 'bug_category_id') . '">';
                        } else {
                            if ($linkify == "bug_group") {
                                $link .= 'group_id=' . $group_id . '&amp;bug_group_mod=y&amp;bug_group_id=' . db_result($result, $j, 'bug_group_id') . '">';
                            } else {
                                if ($linkify == "patch_cat") {
                                    $link .= 'group_id=' . $group_id . '&amp;patch_cat_mod=y&amp;patch_cat_id=' . db_result($result, $j, 'patch_category_id') . '">';
                                } else {
                                    if ($linkify == "support_cat") {
                                        $link .= 'group_id=' . $group_id . '&amp;support_cat_mod=y&amp;support_cat_id=' . db_result($result, $j, 'support_category_id') . '">';
                                    } else {
                                        if ($linkify == "pm_project") {
                                            $link .= 'group_id=' . $group_id . '&amp;project_cat_mod=y&amp;project_cat_id=' . db_result($result, $j, 'group_project_id') . '">';
                                        } else {
                                            $link = $linkend = '';
                                        }
                                    }
                                }
                            }
                        }
                    } else {
                        $link = $linkend = '';
                    }
                    echo '<td>' . $link . db_result($result, $j, $i) . $linkend . '</td>';
                }
            }
            echo '</tr>';
        }
        echo '</table>';
    } else {
        echo db_error();
    }
}
コード例 #13
0
ファイル: utils.php プロジェクト: pombredanne/tuleap
function ShowResultSet($result, $title = "Untitled", $linkify = false, $showheaders = true)
{
    global $group_id, $HTML;
    /*
    	Very simple, plain way to show a generic result set
    	Accepts a result set and title
    	Makes certain items into HTML links
    */
    if ($result) {
        $rows = db_numrows($result);
        $cols = db_numfields($result);
        echo '
			<TABLE BORDER="0" WIDTH="100%">';
        /*  Create the title  */
        echo '
		<TR class="boxtitle">
		<TD COLSPAN="' . $cols . '" class="boxitem"><B>' . $title . '</B></TD></TR>';
        if ($showheaders) {
            /*  Create  the  headers  */
            echo '<tr>';
            for ($i = 0; $i < $cols; $i++) {
                echo '<td><B>' . db_fieldname($result, $i) . '</B></TD>';
            }
            echo '</tr>';
        }
        /*  Create the rows  */
        for ($j = 0; $j < $rows; $j++) {
            echo '<TR class="' . html_get_alt_row_color($j + 1) . '">';
            for ($i = 0; $i < $cols; $i++) {
                if ($linkify && $i == 0) {
                    $link = '<A HREF="?';
                    $linkend = '</A>';
                    if ($linkify == "bug_cat") {
                        $link .= 'group_id=' . $group_id . '&bug_cat_mod=y&bug_cat_id=' . db_result($result, $j, 'bug_category_id') . '">';
                    } else {
                        if ($linkify == "bug_group") {
                            $link .= 'group_id=' . $group_id . '&bug_group_mod=y&bug_group_id=' . db_result($result, $j, 'bug_group_id') . '">';
                        } else {
                            if ($linkify == "patch_cat") {
                                $link .= 'group_id=' . $group_id . '&patch_cat_mod=y&patch_cat_id=' . db_result($result, $j, 'patch_category_id') . '">';
                            } else {
                                if ($linkify == "support_cat") {
                                    $link .= 'group_id=' . $group_id . '&support_cat_mod=y&support_cat_id=' . db_result($result, $j, 'support_category_id') . '">';
                                } else {
                                    if ($linkify == "pm_project") {
                                        $link .= 'group_id=' . $group_id . '&project_cat_mod=y&project_cat_id=' . db_result($result, $j, 'group_project_id') . '">';
                                    } else {
                                        $link = $linkend = '';
                                    }
                                }
                            }
                        }
                    }
                } else {
                    $link = $linkend = '';
                }
                echo '<td>' . $link . db_result($result, $j, $i) . $linkend . '</td>';
            }
            echo '</tr>';
        }
        echo '</table>';
    } else {
        echo db_error();
    }
}
コード例 #14
0
}
echo "\n";
/*
	Now show the customer rows
*/
$sql = "SELECT DISTINCT customer_id FROM responses WHERE survey_id='{$survey_id}'";
$result = db_query($sql);
$rows = db_numrows($result);
for ($i = 0; $i < $rows; $i++) {
    /*
    	Get this customer's info
    */
    $sql = "SELECT DISTINCT cust_id,first_name,people.last_name,people.email,people.email2,people.phone," . "people.beeper,people.cell,people.yes_interested,responses.response_year," . "responses.response_month,responses.response_day FROM people,responses " . "WHERE cust_id='" . db_result($result, $i, "customer_id") . "' AND cust_id=responses.customer_id";
    $result2 = db_query($sql);
    if (db_numrows($result2) > 0) {
        $cols = db_numfields($result2);
        for ($i2 = 0; $i2 < $cols; $i2++) {
            echo strip_commas(db_result($result2, 0, $i2)) . ",";
        }
        /*
        	Get this customer's responses. may have to be ordered by original question order
        */
        $sql = "SELECT response FROM responses WHERE customer_id='" . db_result($result, $i, "customer_id") . "' AND survey_id='{$survey_id}'";
        $result3 = db_query($sql);
        $rows3 = db_numrows($result3);
        for ($i3 = 0; $i3 < $rows3; $i3++) {
            echo strip_commas(db_result($result3, $i3, "response")) . ",";
        }
        /*
        	End of this customer
        */
コード例 #15
0
ファイル: tracker.php プロジェクト: nterray/tuleap
 /**
  * artifacttype_to_soap : return the soap ArtifactType structure giving an PHP ArtifactType Object.
  * @access private
  * 
  * WARNING : We check the permissions here : only the readable trackers and the readable fields are returned.
  *
  * @param Object{ArtifactType} $at the artifactType to convert.
  * @return the SOAPArtifactType corresponding to the ArtifactType Object
  */
 function artifacttype_to_soap($at)
 {
     global $ath;
     $user_id = UserManager::instance()->getCurrentUser()->getId();
     $return = array();
     // number of opend artifact are not part of ArtifactType, so we have to get it with ArtifactTypeFactory (could need some refactoring maybe)
     $atf = new ArtifactTypeFactory($at->getGroup());
     $arr_count = $atf->getStatusIdCount($at->getID());
     if ($arr_count) {
         $open_count = array_key_exists('open_count', $arr_count) ? $arr_count['open_count'] : -1;
         $count = array_key_exists('count', $arr_count) ? $arr_count['count'] : -1;
     } else {
         $open_count = -1;
         $count = -1;
     }
     $field_sets = array();
     $ath = new ArtifactType($at->getGroup(), $at->getID());
     if (!$ath || !is_object($ath)) {
         return new SoapFault(get_artifact_type_fault, 'ArtifactType could not be created', 'getArtifactTypes');
     }
     if ($ath->isError()) {
         return new SoapFault(get_artifact_type_fault, $ath->getErrorMessage(), 'getArtifactTypes');
     }
     // Check if this tracker is valid (not deleted)
     if (!$ath->isValid()) {
         return new SoapFault(get_artifact_type_fault, 'This tracker is no longer valid.', 'getArtifactTypes');
     }
     // Check if the user can view this tracker
     if ($ath->userCanView($user_id)) {
         $art_fieldset_fact = new ArtifactFieldSetFactory($at);
         if (!$art_fieldset_fact || !is_object($art_fieldset_fact)) {
             return new SoapFault(get_artifact_field_factory_fault, 'Could Not Get ArtifactFieldSetFactory', 'getFieldSets');
         } elseif ($art_fieldset_fact->isError()) {
             return new SoapFault(get_artifact_field_factory_fault, $art_fieldset_fact->getErrorMessage(), 'getFieldSets');
         }
         $result_fieldsets = $art_fieldset_fact->getAllFieldSetsContainingUsedFields();
         foreach ($result_fieldsets as $fieldset_id => $result_fieldset) {
             $fields = array();
             $fields_in_fieldset = $result_fieldset->getAllUsedFields();
             $group_id = $at->Group->getID();
             $group_artifact_id = $at->getID();
             while (list($key, $field) = each($fields_in_fieldset)) {
                 if ($field->userCanRead($group_id, $group_artifact_id, $user_id)) {
                     $availablevalues = array();
                     $result = $field->getFieldPredefinedValues($at->getID(), false, false, false, false);
                     $rows = db_numrows($result);
                     $cols = db_numfields($result);
                     for ($j = 0; $j < $rows; $j++) {
                         $field_status = $cols > 2 ? db_result($result, $j, 6) : '';
                         // we don't send hidden values (status == 'H')
                         if ($field_status != 'H') {
                             $availablevalues[] = array('field_id' => $field->getID(), 'group_artifact_id' => $at->getID(), 'value_id' => db_result($result, $j, 0), 'value' => SimpleSanitizer::unsanitize(db_result($result, $j, 1)), 'description' => SimpleSanitizer::unsanitize($cols > 2 ? db_result($result, $j, 4) : ''), 'order_id' => $cols > 2 ? db_result($result, $j, 5) : 0, 'status' => $field_status);
                         }
                     }
                     // For bound-values select boxes, we add the none value.
                     if (($field->isMultiSelectBox() || $field->isSelectBox()) && $field->isBound()) {
                         $availablevalues[] = array('field_id' => $field->getID(), 'group_artifact_id' => $at->getID(), 'value_id' => 100, 'value' => 'None', 'description' => '', 'order_id' => 10, 'status' => 'P');
                     }
                     if ($field->isMultiSelectBox()) {
                         $defaultvalue = implode(",", $field->getDefaultValue());
                     } else {
                         $defaultvalue = $field->getDefaultValue();
                     }
                     $fields[] = array('field_id' => $field->getID(), 'group_artifact_id' => $at->getID(), 'field_set_id' => $field->getFieldSetID(), 'field_name' => SimpleSanitizer::unsanitize($field->getName()), 'data_type' => $field->getDataType(), 'display_type' => $field->getDisplayType(), 'display_size' => $field->getDisplaySize(), 'label' => SimpleSanitizer::unsanitize($field->getLabel()), 'description' => SimpleSanitizer::unsanitize($field->getDescription()), 'scope' => $field->getScope(), 'required' => $field->getRequired(), 'empty_ok' => $field->getEmptyOk(), 'keep_history' => $field->getKeepHistory(), 'special' => $field->getSpecial(), 'value_function' => implode(",", $field->getValueFunction()), 'available_values' => $availablevalues, 'default_value' => $defaultvalue, 'user_can_submit' => $field->userCanSubmit($group_id, $group_artifact_id, $user_id), 'user_can_read' => $field->userCanRead($group_id, $group_artifact_id, $user_id), 'user_can_update' => $field->userCanUpdate($group_id, $group_artifact_id, $user_id), 'is_standard_field' => $field->isStandardField());
                 }
             }
             $field_sets[] = array('field_set_id' => $result_fieldset->getID(), 'group_artifact_id' => $result_fieldset->getArtifactTypeID(), 'name' => SimpleSanitizer::unsanitize($result_fieldset->getName()), 'label' => SimpleSanitizer::unsanitize($result_fieldset->getLabel()), 'description' => SimpleSanitizer::unsanitize($result_fieldset->getDescription()), 'description_text' => SimpleSanitizer::unsanitize($result_fieldset->getDescriptionText()), 'rank' => $result_fieldset->getRank(), 'fields' => $fields);
         }
         // We add the field dependencies
         $field_dependencies = artifactrules_to_soap($at);
         $sql = "SELECT COALESCE(sum(af.filesize) / 1024,NULL,0) as total_file_size" . " FROM artifact_file af, artifact a, artifact_group_list agl" . " WHERE (af.artifact_id = a.artifact_id)" . " AND (a.group_artifact_id = agl.group_artifact_id)" . " AND (agl.group_artifact_id =" . db_ei($at->getID()) . ")";
         $result = db_query($sql);
         $return = array('group_artifact_id' => $at->data_array['group_artifact_id'], 'group_id' => $at->data_array['group_id'], 'name' => SimpleSanitizer::unsanitize($at->data_array['name']), 'description' => SimpleSanitizer::unsanitize($at->data_array['description']), 'item_name' => $at->data_array['item_name'], 'open_count' => $at->userHasFullAccess() ? $open_count : -1, 'total_count' => $at->userHasFullAccess() ? $count : -1, 'total_file_size' => db_result($result, 0, 0), 'field_sets' => $field_sets, 'field_dependencies' => $field_dependencies);
     }
     return $return;
 }
コード例 #16
0
ファイル: admin_table.php プロジェクト: neymanna/fusionforge
/**
 *	admin_table_show() - display the specified table, sorted by the primary key, with links to add, edit, and delete
 *
 *	@param $table - the table to act on
 *	@param $unit - the name of the "units" described by the table's records
 *	@param $primary_key - the primary key of the table
 */
function admin_table_show($table, $unit, $primary_key)
{
    global $HTML;
    $result = db_query("SELECT * FROM {$table} ORDER BY {$primary_key}");
    if ($result) {
        $rows = db_numrows($result);
        $cols = db_numfields($result);
        $cell_data = array();
        $cell_data[] = array(ucwords(getUnitLabel($unit)) . ' <a href="' . getStringFromServer('PHP_SELF') . '?function=add">[' . _('add new') . ']</a>', 'colspan="' . ($cols + 1) . '"');
        echo '<table border="0" width="100%">';
        echo $HTML->multiTableRow('', $cell_data, TRUE);
        echo '
			<tr><td width="5%"></td>';
        for ($i = 0; $i < $cols; $i++) {
            echo '<td><strong>' . db_fieldname($result, $i) . '</strong></td>';
        }
        echo '</tr>';
        for ($j = 0; $j < $rows; $j++) {
            echo '<tr ' . $HTML->boxGetAltRowStyle($j) . '>';
            $id = db_result($result, $j, 0);
            echo '<td><a href="' . getStringFromServer('PHP_SELF') . '?function=edit&amp;id=' . $id . '">[' . _('Edit') . ']</a>';
            echo '<a href="' . getStringFromServer('PHP_SELF') . '?function=confirmdelete&amp;id=' . $id . '">[' . _('Delete') . ']</a> </td>';
            for ($i = 0; $i < $cols; $i++) {
                echo '<td>' . db_result($result, $j, $i) . '</td>';
            }
            echo '</tr>';
        }
        echo '</table>';
    } else {
        echo db_error();
    }
}