| 1 |
<?php |
<?php |
| 2 |
// $Id: versioncontrol_release.module,v 1.8 2009/03/09 04:36:22 jpetso Exp $ |
// $Id: versioncontrol_release.module,v 1.9 2009/03/09 04:46:28 jpetso Exp $ |
| 3 |
/** |
/** |
| 4 |
* @file |
* @file |
| 5 |
* Version Control / Release Node integration - Integrates release nodes |
* Version Control / Release Node integration - Integrates release nodes |
| 127 |
* Return an array of labels that are still unused for the given project, |
* Return an array of labels that are still unused for the given project, |
| 128 |
* with the label_id of each label array used as array key. |
* with the label_id of each label array used as array key. |
| 129 |
*/ |
*/ |
| 130 |
function versioncontrol_release_get_possible_labels($project_nid) { |
function versioncontrol_release_get_possible_labels($project_node) { |
| 131 |
|
if (!versioncontrol_project_node_uses_versioncontrol($project_node)) { |
| 132 |
|
return array(); |
| 133 |
|
} |
| 134 |
|
$project = $project_node->versioncontrol_project; |
| 135 |
|
$repository = versioncontrol_get_repository($project['repo_id']); |
| 136 |
|
|
| 137 |
|
if (empty($repository)) { |
| 138 |
|
return array(); |
| 139 |
|
} |
| 140 |
|
$directory_item = versioncontrol_get_item($repository, $project['directory']); |
| 141 |
|
|
| 142 |
|
if (empty($directory_item)) { |
| 143 |
|
return array(); |
| 144 |
|
} |
| 145 |
|
$parallel_items = versioncontrol_get_parallel_items($repository, $directory_item); |
| 146 |
|
|
| 147 |
|
if (empty($parallel_items)) { |
| 148 |
|
return array(); |
| 149 |
|
} |
| 150 |
$result = db_query('SELECT DISTINCT(label.label_id), label.name, |
$result = db_query('SELECT DISTINCT(label.label_id), label.name, |
| 151 |
label.repo_id, label.type |
label.repo_id, label.type, rlabel.release_nid |
| 152 |
FROM {versioncontrol_labels} label |
FROM {versioncontrol_labels} label |
|
INNER JOIN {versioncontrol_operation_labels} oplabel |
|
|
ON label.label_id = oplabel.label_id |
|
|
INNER JOIN {versioncontrol_project_operations} projop |
|
|
ON oplabel.vc_op_id = projop.vc_op_id |
|
| 153 |
LEFT JOIN {versioncontrol_release_labels} rlabel |
LEFT JOIN {versioncontrol_release_labels} rlabel |
| 154 |
ON projop.nid = rlabel.project_nid |
ON label.label_id = rlabel.label_id |
| 155 |
AND label.label_id = rlabel.label_id |
WHERE rlabel.project_nid = %d |
|
WHERE projop.nid = %d |
|
|
AND rlabel.label_id IS NULL |
|
| 156 |
ORDER BY label.type DESC, label.name DESC', |
ORDER BY label.type DESC, label.name DESC', |
| 157 |
$project_nid); |
$project_node->nid); |
| 158 |
$labels = array(); |
$db_labels = array(); |
| 159 |
while ($label = db_fetch_array($result)) { |
$released_labels = array(); |
| 160 |
$labels[$label['label_id']] = $label; |
|
| 161 |
|
while ($dblabel = db_fetch_object($result)) { |
| 162 |
|
$db_labels[$dblabel->repo_id][$dblabel->type][$dblabel->name] = $dblabel->label_id; |
| 163 |
|
if (!empty($dblabel->release_nid)) { |
| 164 |
|
$released_labels[$dblabel->label_id] = TRUE; |
| 165 |
|
} |
| 166 |
|
} |
| 167 |
|
foreach ($parallel_items as $item) { |
| 168 |
|
$label = versioncontrol_get_item_selected_label($repository, $item); |
| 169 |
|
if (!empty($label)) { |
| 170 |
|
if (isset($db_labels[$label['repo_id']][$label['type']][$label['name']])) { |
| 171 |
|
$label['label_id'] = $db_labels[$label['repo_id']][$label['type']][$label['name']]; |
| 172 |
|
} |
| 173 |
|
else { |
| 174 |
|
$label = versioncontrol_ensure_label($repository, $label); |
| 175 |
|
} |
| 176 |
|
if (!isset($released_labels[$label['label_id']])) { |
| 177 |
|
$labels[$label['label_id']] = $label; |
| 178 |
|
} |
| 179 |
|
} |
| 180 |
} |
} |
| 181 |
return $labels; |
return $labels; |
| 182 |
} |
} |
| 284 |
unset($form['validate_version']); |
unset($form['validate_version']); |
| 285 |
|
|
| 286 |
// Gather possible values for a label selector. |
// Gather possible values for a label selector. |
| 287 |
$possible_labels = versioncontrol_release_get_possible_labels($project_node->nid); |
$possible_labels = versioncontrol_release_get_possible_labels($project_node); |
| 288 |
$tags_t = t('Tags'); |
$tags_t = t('Tags'); |
| 289 |
$branches_t = t('Branches'); |
$branches_t = t('Branches'); |
| 290 |
$label_options = array(); |
$label_options = array(); |
| 703 |
|
|
| 704 |
if ($allow_branch_switch) { |
if ($allow_branch_switch) { |
| 705 |
$fields = array('version_major', 'version_minor', 'version_patch', 'version_extra'); |
$fields = array('version_major', 'version_minor', 'version_patch', 'version_extra'); |
| 706 |
$possible_labels = versioncontrol_release_get_possible_labels($project_node->nid); |
$possible_labels = versioncontrol_release_get_possible_labels($project_node); |
| 707 |
$possible_labels[$release_label['label_id']] = $release_label; |
$possible_labels[$release_label['label_id']] = $release_label; |
| 708 |
|
|
| 709 |
if (!user_access('administer projects')) { |
if (!user_access('administer projects')) { |