Fixed issue 9, do not show the deprecated files by default.
This commit is contained in:
parent
ee88dbed86
commit
14811beeba
@ -287,13 +287,21 @@ class IDF_Project extends Pluf_Model
|
|||||||
'LEFT JOIN '.$what_t.' ON idf_issue_id='.$what_t.'.id '."\n".
|
'LEFT JOIN '.$what_t.' ON idf_issue_id='.$what_t.'.id '."\n".
|
||||||
'WHERE idf_tag_id IS NOT NULL AND '.$what_t.'.status IN (%s) AND '.$what_t.'.project='.$this->id.' GROUP BY '.$tag_t.'.id, '.$tag_t.'.class, '.$tag_t.'.name ORDER BY '.$tag_t.'.class ASC, '.$tag_t.'.name ASC',
|
'WHERE idf_tag_id IS NOT NULL AND '.$what_t.'.status IN (%s) AND '.$what_t.'.project='.$this->id.' GROUP BY '.$tag_t.'.id, '.$tag_t.'.class, '.$tag_t.'.name ORDER BY '.$tag_t.'.class ASC, '.$tag_t.'.name ASC',
|
||||||
implode(', ', $ostatus));
|
implode(', ', $ostatus));
|
||||||
} else {
|
} elseif ($what == 'downloads') {
|
||||||
|
$dep_ids = IDF_Views_Download::getDeprecatedFilesIds($this);
|
||||||
|
$extra = '';
|
||||||
|
if (count($dep_ids) and $what == 'downloads') {
|
||||||
|
$extra = ' AND idf_upload_id NOT IN ('.implode(', ', $dep_ids).') ';
|
||||||
|
}
|
||||||
|
if (count($dep_ids) and $what != 'downloads') {
|
||||||
|
$extra = ' AND idf_upload_id IN ('.implode(', ', $dep_ids).') ';
|
||||||
|
}
|
||||||
$what_t = Pluf::factory('IDF_Upload')->getSqlTable();
|
$what_t = Pluf::factory('IDF_Upload')->getSqlTable();
|
||||||
$asso_t = $this->_con->pfx.'idf_tag_idf_upload_assoc';
|
$asso_t = $this->_con->pfx.'idf_tag_idf_upload_assoc';
|
||||||
$sql = 'SELECT '.$tag_t.'.id AS id, COUNT(*) AS nb_use FROM '.$tag_t.' '."\n".
|
$sql = 'SELECT '.$tag_t.'.id AS id, COUNT(*) AS nb_use FROM '.$tag_t.' '."\n".
|
||||||
'LEFT JOIN '.$asso_t.' ON idf_tag_id='.$tag_t.'.id '."\n".
|
'LEFT JOIN '.$asso_t.' ON idf_tag_id='.$tag_t.'.id '."\n".
|
||||||
'LEFT JOIN '.$what_t.' ON idf_upload_id='.$what_t.'.id '."\n".
|
'LEFT JOIN '.$what_t.' ON idf_upload_id='.$what_t.'.id '."\n".
|
||||||
'WHERE idf_tag_id IS NOT NULL AND '.$what_t.'.project='.$this->id.' GROUP BY '.$tag_t.'.id, '.$tag_t.'.class, '.$tag_t.'.name ORDER BY '.$tag_t.'.class ASC, '.$tag_t.'.name ASC';
|
'WHERE idf_tag_id IS NOT NULL '.$extra.' AND '.$what_t.'.project='.$this->id.' GROUP BY '.$tag_t.'.id, '.$tag_t.'.class, '.$tag_t.'.name ORDER BY '.$tag_t.'.class ASC, '.$tag_t.'.name ASC';
|
||||||
}
|
}
|
||||||
$tags = array();
|
$tags = array();
|
||||||
foreach ($this->_con->select($sql) as $idc) {
|
foreach ($this->_con->select($sql) as $idc) {
|
||||||
|
@ -51,7 +51,15 @@ class IDF_Views_Download
|
|||||||
$pag->summary = __('This table shows the files to download.');
|
$pag->summary = __('This table shows the files to download.');
|
||||||
$pag->action = array('IDF_Views_Download::index', array($prj->shortname));
|
$pag->action = array('IDF_Views_Download::index', array($prj->shortname));
|
||||||
$pag->edit_action = array('IDF_Views_Download::view', 'shortname', 'id');
|
$pag->edit_action = array('IDF_Views_Download::view', 'shortname', 'id');
|
||||||
$pag->forced_where = new Pluf_SQL('project=%s', array($prj->id));
|
$sql = 'project=%s';
|
||||||
|
$ptags = self::getDownloadTags($prj);
|
||||||
|
$dtag = array_pop($ptags); // The last tag is the deprecated tag.
|
||||||
|
$ids = self::getDeprecatedFilesIds($prj);
|
||||||
|
if (count($ids)) {
|
||||||
|
$sql .= ' AND id NOT IN ('.implode(',', $ids).')';
|
||||||
|
}
|
||||||
|
$pag->forced_where = new Pluf_SQL($sql, array($prj->id));
|
||||||
|
|
||||||
$list_display = array(
|
$list_display = array(
|
||||||
'file' => __('File'),
|
'file' => __('File'),
|
||||||
array('summary', 'IDF_Views_Download_SummaryAndLabels', __('Summary')),
|
array('summary', 'IDF_Views_Download_SummaryAndLabels', __('Summary')),
|
||||||
@ -69,6 +77,8 @@ class IDF_Views_Download
|
|||||||
'page_title' => $title,
|
'page_title' => $title,
|
||||||
'downloads' => $pag,
|
'downloads' => $pag,
|
||||||
'tags' => $tags,
|
'tags' => $tags,
|
||||||
|
'deprecated' => count($ids),
|
||||||
|
'dlabel' => $dtag,
|
||||||
),
|
),
|
||||||
$request);
|
$request);
|
||||||
|
|
||||||
@ -246,6 +256,8 @@ class IDF_Views_Download
|
|||||||
$title = sprintf(__('%1$s Downloads with Label %2$s'), (string) $prj,
|
$title = sprintf(__('%1$s Downloads with Label %2$s'), (string) $prj,
|
||||||
(string) $tag);
|
(string) $tag);
|
||||||
// Paginator to paginate the downloads
|
// Paginator to paginate the downloads
|
||||||
|
$ptags = self::getDownloadTags($prj);
|
||||||
|
$dtag = array_pop($ptags); // The last tag is the deprecated tag.
|
||||||
$pag = new Pluf_Paginator(new IDF_Upload());
|
$pag = new Pluf_Paginator(new IDF_Upload());
|
||||||
$pag->model_view = 'join_tags';
|
$pag->model_view = 'join_tags';
|
||||||
$pag->class = 'recent-issues';
|
$pag->class = 'recent-issues';
|
||||||
@ -273,6 +285,7 @@ class IDF_Views_Download
|
|||||||
'label' => $tag,
|
'label' => $tag,
|
||||||
'downloads' => $pag,
|
'downloads' => $pag,
|
||||||
'tags' => $tags,
|
'tags' => $tags,
|
||||||
|
'dlabel' => $dtag,
|
||||||
),
|
),
|
||||||
$request);
|
$request);
|
||||||
}
|
}
|
||||||
@ -289,6 +302,25 @@ class IDF_Views_Download
|
|||||||
IDF_Form_UploadConf::init_predefined);
|
IDF_Form_UploadConf::init_predefined);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get deprecated file ids.
|
||||||
|
*
|
||||||
|
* @return array Ids of the deprecated files.
|
||||||
|
*/
|
||||||
|
public static function getDeprecatedFilesIds($project)
|
||||||
|
{
|
||||||
|
$ptags = self::getDownloadTags($project);
|
||||||
|
$dtag = array_pop($ptags); // The last tag is the deprecated tag.
|
||||||
|
$sql = new Pluf_SQL('project=%s AND idf_tag_id=%s', array($project->id,
|
||||||
|
$dtag->id));
|
||||||
|
$ids = array();
|
||||||
|
foreach (Pluf::factory('IDF_Upload')->getList(array('filter' => $sql->gen(), 'view' => 'join_tags'))
|
||||||
|
as $file) {
|
||||||
|
$ids[] = (int) $file->id;
|
||||||
|
}
|
||||||
|
return $ids;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,10 +10,16 @@
|
|||||||
{block context}
|
{block context}
|
||||||
<p><strong>{trans 'Number of files:'}</strong> {$downloads.nb_items}</p>
|
<p><strong>{trans 'Number of files:'}</strong> {$downloads.nb_items}</p>
|
||||||
{assign $class = ''}{assign $i = 0}
|
{assign $class = ''}{assign $i = 0}
|
||||||
<p class="smaller">{foreach $tags as $label}
|
{if !$label or $label.id != $dlabel.id}
|
||||||
{aurl 'url', 'IDF_Views_Download::listLabel', array($project.shortname, $label.id)}
|
<p class="smaller">{foreach $tags as $lab}
|
||||||
{if $class != $label.class}{if $i != 0}<br />{/if}<strong class="label">{$label.class}:</strong> {/if}
|
{aurl 'url', 'IDF_Views_Download::listLabel', array($project.shortname, $lab.id)}
|
||||||
<a href="{$url}" class="label">{$label.name}</a>,{assign $i = $i + 1}{assign $class = $label.class}{/foreach}</p>
|
{if $class != $lab.class}{if $i != 0}<br />{/if}<strong class="label">{$lab.class}:</strong> {/if}
|
||||||
|
<a href="{$url}" class="label">{$lab.name}</a>,{assign $i = $i + 1}{assign $class = $lab.class}{/foreach}</p>
|
||||||
|
{/if}
|
||||||
|
{if $deprecated > 0}
|
||||||
|
{aurl 'url', 'IDF_Views_Download::listLabel', array($project.shortname, $dlabel.id)}
|
||||||
|
<p class="helptext">{blocktrans}See <a href="{$url}">the deprecated files</a>.{/blocktrans}</p>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{/block}
|
{/block}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user