/** * @brief Add bucket_pk array and string to Children array. * @param $TreeInfo * @param &$Children * @param $BucketDefArray * @return updated $Children */ function AddBucketStr($TreeInfo, &$Children, $BucketDefArray) { if (!is_array($Children)) { return; } $agent_pk = $TreeInfo['agent_pk']; foreach ($Children as &$Child) { $Child['bucketarray'] = GetFileBuckets($TreeInfo['nomosagent_pk'], $TreeInfo['bucketagent_pk'], $Child['uploadtree_pk'], $TreeInfo['bucketpool_pk']); $Child['bucketstr'] = GetFileBuckets_string($TreeInfo['nomosagent_pk'], $TreeInfo['bucketagent_pk'], $Child['uploadtree_pk'], $BucketDefArray, ",", True); } }
/** * \brief Get string of $delimiter delimited bucket names for the given inputs. * Args are same as GetFileBuckets(). * * \param $nomosagent_pk * \param $bucketagent_pk * \param $uploadtree_pk * \param $bucketDefArray is array of bucket_def records indexed by bucket_pk * see initBucketDefArray(). * \param $delimiter is delimiter string to use to seperate bucket names. * \param $color if True, the string is returned as html with bucket names * color coded. * * \return string of $delimiter delimited bucket names for the given inputs. */ function GetFileBuckets_string($nomosagent_pk, $bucketagent_pk, $uploadtree_pk, $bucketDefArray, $delimiter, $color) { $outstr = ""; $defrec = current($bucketDefArray); $bucketpool_pk = $defrec['bucketpool_fk']; $BuckArray = GetFileBuckets($nomosagent_pk, $bucketagent_pk, $uploadtree_pk, $bucketpool_pk); if (empty($BuckArray)) { return ""; } /* convert array of bucket_pk's to array of bucket names */ $BuckNames = array(); foreach ($BuckArray as $bucket_pk) { $BuckNames[$bucket_pk] = $bucketDefArray[$bucket_pk]['bucket_name']; } /* sort $BuckArray */ natcasesort($BuckNames); $first = true; foreach ($BuckNames as $bucket_name) { if ($first) { $first = false; } else { $outstr .= $delimiter . " "; } if ($color) { $bucket_pk = array_search($bucket_name, $BuckNames); $bucket_color = $bucketDefArray[$bucket_pk]['bucket_color']; $outstr .= "<span style='background-color:{$bucket_color}'>"; $outstr .= $bucket_name; $outstr .= "</span>"; } else { $outstr .= $bucket_name; } } return $outstr; }