Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion controller/contribution/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ protected function generate_navigation($page)
if ($this->contrib->contrib_demo)
{
$demo_menu = array();
$allowed_branches = $this->contrib->type->get_allowed_branches(true);
$allowed_branches = $this->contrib->get_approved_branches();
krsort($allowed_branches);
$is_external = $this->contrib->contrib_status != ext::TITANIA_CONTRIB_APPROVED || !$this->contrib->options['demo'];

Expand Down
7 changes: 4 additions & 3 deletions controller/contribution/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function manage($contrib_type, $contrib)
);
$this->settings['custom'] = $this->contrib->get_custom_fields();

foreach ($this->contrib->type->get_allowed_branches(true) as $branch => $name)
foreach ($this->contrib->get_approved_branches() as $branch => $name)
{
$this->settings['demo'][$branch] = $this->contrib->get_demo_url($branch);
}
Expand All @@ -145,7 +145,7 @@ public function manage($contrib_type, $contrib)
));
$demos = $this->request->variable('demo', array(0 => ''));

foreach ($this->contrib->type->get_allowed_branches(true) as $branch => $name)
foreach ($this->contrib->get_approved_branches() as $branch => $name)
{
if (isset($demos[$branch]))
{
Expand All @@ -155,7 +155,8 @@ public function manage($contrib_type, $contrib)

$this->contrib->post_data($this->message);
$this->contrib->__set_array(array(
'contrib_demo' => ($this->can_edit_demo) ? json_encode($this->settings['demo']) : $this->contrib->contrib_demo,
// Preserve stored URLs for branches not open for editing.
'contrib_demo' => ($this->can_edit_demo) ? json_encode($this->settings['demo'] + $this->contrib->get_demo_urls()) : $this->contrib->contrib_demo,
'contrib_limited_support' => $this->settings['limited_support'],
));
}
Expand Down
38 changes: 33 additions & 5 deletions includes/objects/contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,38 @@ public function get_url($page = '', $parameters = array())
return $this->controller_helper->route($controller, $parameters);
}

/**
* Get the branches for which the contribution has an approved revision.
*
* @return array Branch names limited to the branches that have an approved
* revision, keyed by branch - example: 31 => 'phpBB 3.1.x'
*/
public function get_approved_branches()
{
$this->get_download();

return array_intersect_key(
$this->type->get_allowed_branches(true),
$this->download
);
}

/**
* Get all stored demo URLs.
*
* @return array Demo URLs keyed by branch - example: 31 => 'http://...'
*/
public function get_demo_urls()
{
if (empty($this->contrib_demo))
{
return array();
}
$demos = json_decode($this->contrib_demo, true);

return (is_array($demos)) ? $demos : array();
}

/**
* Get demo URL.
*
Expand All @@ -1045,11 +1077,7 @@ public function get_url($page = '', $parameters = array())
*/
public function get_demo_url($branch, $integrated_url = false)
{
if (empty($this->contrib_demo))
{
return '';
}
$demos = json_decode($this->contrib_demo, true);
$demos = $this->get_demo_urls();

if (empty($demos[$branch]))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ <h3>{{ lang('OPTIONS') }}</h3>
<textarea class="inputbox" name="nonactive_coauthors" id="nonactive_coauthors" rows="2" cols="20">{{ NONACTIVE_COAUTHORS }}</textarea>
</dd>
</dl>
{% if S_CAN_EDIT_DEMO %}
{% if S_CAN_EDIT_DEMO and loops.demo|length %}
<dl>
<dt><label for="demo_url">{{ lang('DEMO_URL') ~ lang('COLON') }}</label><br /><span>{{ lang('DEMO_URL_EXPLAIN') }}</span></dt>
<dd>
Expand Down