Issue 91: Create feature to disable a repo
This commit is contained in:
parent
feb001ed8e
commit
4febdda65f
@ -86,6 +86,12 @@ class IDF_Form_ProjectConf extends Pluf_Form
|
|||||||
'initial' => $this->project->enableads,
|
'initial' => $this->project->enableads,
|
||||||
'widget' => 'Pluf_Form_Widget_CheckboxInput',
|
'widget' => 'Pluf_Form_Widget_CheckboxInput',
|
||||||
));
|
));
|
||||||
|
$this->fields['disabled'] = new Pluf_Form_Field_Boolean(
|
||||||
|
array('required' => false,
|
||||||
|
'label' => __('Disable Project'),
|
||||||
|
'initial' => $this->project->disabled,
|
||||||
|
'widget' => 'Pluf_Form_Widget_CheckboxInput',
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
$this->fields['enableads'] = new Pluf_Form_Field_Boolean(
|
$this->fields['enableads'] = new Pluf_Form_Field_Boolean(
|
||||||
array('required' => false,
|
array('required' => false,
|
||||||
@ -94,6 +100,7 @@ class IDF_Form_ProjectConf extends Pluf_Form
|
|||||||
'widget' => 'Pluf_Form_Widget_CheckboxInput',
|
'widget' => 'Pluf_Form_Widget_CheckboxInput',
|
||||||
'widget_attrs' => array('disabled' => 'disabled')
|
'widget_attrs' => array('disabled' => 'disabled')
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
$tags = $this->project->get_tags_list();
|
$tags = $this->project->get_tags_list();
|
||||||
for ($i=1;$i<7;$i++) {
|
for ($i=1;$i<7;$i++) {
|
||||||
@ -228,8 +235,10 @@ class IDF_Form_ProjectConf extends Pluf_Form
|
|||||||
$this->project->description = $this->cleaned_data['description'];
|
$this->project->description = $this->cleaned_data['description'];
|
||||||
$this->project->batchAssoc('IDF_Tag', $tagids);
|
$this->project->batchAssoc('IDF_Tag', $tagids);
|
||||||
$this->project->syntaxtheme = $this->cleaned_data["syntaxtheme"];
|
$this->project->syntaxtheme = $this->cleaned_data["syntaxtheme"];
|
||||||
if ($this->user->administrator)
|
if ($this->user->administrator) {
|
||||||
$this->project->enableads = $this->cleaned_data['enableads'];
|
$this->project->enableads = $this->cleaned_data['enableads'];
|
||||||
|
$this->project->disabled = $this->cleaned_data["disabled"];
|
||||||
|
}
|
||||||
$this->project->update();
|
$this->project->update();
|
||||||
|
|
||||||
$conf = $this->project->getConf();
|
$conf = $this->project->getConf();
|
||||||
|
@ -40,6 +40,8 @@ class IDF_Middleware_GoogleAds
|
|||||||
*/
|
*/
|
||||||
function process_response($request, $response)
|
function process_response($request, $response)
|
||||||
{
|
{
|
||||||
|
if (isset($response) && !isset($response->status_code))
|
||||||
|
return $response;
|
||||||
if (!Pluf::f('google_ads', false)) {
|
if (!Pluf::f('google_ads', false)) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ function IDF_Migrations_30SyntaxHighlightTheme_up()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function IDF_Migrations_28OTPKey_down()
|
function IDF_Migrations_30SyntaxHighlightTheme_down()
|
||||||
{
|
{
|
||||||
$table = Pluf::factory('IDF_Project')->getSqlTable();
|
$table = Pluf::factory('IDF_Project')->getSqlTable();
|
||||||
|
|
||||||
|
36
indefero/src/IDF/Migrations/31DisableProject.php
Normal file
36
indefero/src/IDF/Migrations/31DisableProject.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function IDF_Migrations_31DisableProject_up()
|
||||||
|
{
|
||||||
|
$table = Pluf::factory('IDF_Project')->getSqlTable();
|
||||||
|
|
||||||
|
$sql = array();
|
||||||
|
|
||||||
|
$sql["MySQL"] = "ALTER TABLE " . $table . " ADD COLUMN `disabled` int(11) NULL AFTER `current_activity`;";
|
||||||
|
|
||||||
|
$db = Pluf::db();
|
||||||
|
$engine = Pluf::f('db_engine');
|
||||||
|
if (!isset($sql[$engine])) {
|
||||||
|
throw new Exception('SQLite complex migration not supported.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->execute($sql[$engine]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function IDF_Migrations_31DisableProject_down()
|
||||||
|
{
|
||||||
|
$table = Pluf::factory('IDF_Project')->getSqlTable();
|
||||||
|
|
||||||
|
$sql = array();
|
||||||
|
|
||||||
|
$sql["MySQL"] = "ALTER TABLE " . $table . " DROP COLUMN `disabled`;";
|
||||||
|
|
||||||
|
$db = Pluf::db();
|
||||||
|
$engine = Pluf::f('db_engine');
|
||||||
|
if (!isset($sql[$engine])) {
|
||||||
|
throw new Exception('SQLite complex migration not supported.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->execute($sql[$engine]);
|
||||||
|
}
|
@ -34,6 +34,10 @@ class IDF_Precondition
|
|||||||
*/
|
*/
|
||||||
static public function baseAccess($request)
|
static public function baseAccess($request)
|
||||||
{
|
{
|
||||||
|
if ($request->user->administrator)
|
||||||
|
return true;
|
||||||
|
if ($request->project->disabled)
|
||||||
|
return false;
|
||||||
if (!$request->project->private) {
|
if (!$request->project->private) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,14 @@ class IDF_Project extends Pluf_Model
|
|||||||
'default' => 1,
|
'default' => 1,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
'disabled' =>
|
||||||
|
array(
|
||||||
|
'type' => 'Pluf_DB_Field_Integer',
|
||||||
|
'blank' => false,
|
||||||
|
'verbose' => __('disabled'),
|
||||||
|
'default' => 0,
|
||||||
|
),
|
||||||
|
|
||||||
'syntaxtheme' =>
|
'syntaxtheme' =>
|
||||||
array(
|
array(
|
||||||
'type' => 'Pluf_DB_Field_Text',
|
'type' => 'Pluf_DB_Field_Text',
|
||||||
|
@ -393,6 +393,15 @@ class IDF_Views
|
|||||||
|
|
||||||
// anonymous users can only see non-private projects
|
// anonymous users can only see non-private projects
|
||||||
$false = Pluf_DB_BooleanToDb(false, $db);
|
$false = Pluf_DB_BooleanToDb(false, $db);
|
||||||
|
$true = Pluf_DB_BooleanToDb(true, $db);
|
||||||
|
|
||||||
|
$dbpfx = $db->pfx;
|
||||||
|
$disabled_results = $db->select("SELECT id FROM ${dbpfx}idf_projects WHERE disabled = $true");
|
||||||
|
$disabled_ids = [];
|
||||||
|
foreach($disabled_results as $id) {
|
||||||
|
$disabled_ids[] = $id['id'];
|
||||||
|
}
|
||||||
|
|
||||||
$sql_results = $db->select(
|
$sql_results = $db->select(
|
||||||
'SELECT id FROM '.$db->pfx.'idf_projects '.
|
'SELECT id FROM '.$db->pfx.'idf_projects '.
|
||||||
'WHERE '.$db->qn('private').'='.$false
|
'WHERE '.$db->qn('private').'='.$false
|
||||||
@ -400,8 +409,12 @@ class IDF_Views
|
|||||||
|
|
||||||
$ids = array();
|
$ids = array();
|
||||||
foreach ($sql_results as $id) {
|
foreach ($sql_results as $id) {
|
||||||
|
if (!in_array($id['id'], $disabled_ids)) {
|
||||||
$ids[] = $id['id'];
|
$ids[] = $id['id'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// registered users may additionally see private projects with which
|
// registered users may additionally see private projects with which
|
||||||
// they're somehow affiliated
|
// they're somehow affiliated
|
||||||
@ -418,7 +431,7 @@ class IDF_Views
|
|||||||
$rows = Pluf::factory('Pluf_RowPermission')->getList(array('filter' => $permSql->gen()));
|
$rows = Pluf::factory('Pluf_RowPermission')->getList(array('filter' => $permSql->gen()));
|
||||||
if ($rows->count() > 0) {
|
if ($rows->count() > 0) {
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
if (in_array($row->model_id, $ids))
|
if (in_array($row->model_id, $ids) || in_array($row->model_id, $disabled_ids))
|
||||||
continue;
|
continue;
|
||||||
$ids[] = $row->model_id;
|
$ids[] = $row->model_id;
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,12 @@
|
|||||||
<td>{if $form.f.enableads.errors}{$form.f.enableads.fieldErrors}{/if}
|
<td>{if $form.f.enableads.errors}{$form.f.enableads.fieldErrors}{/if}
|
||||||
{$form.f.enableads|unsafe}
|
{$form.f.enableads|unsafe}
|
||||||
</td>
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>{$form.f.disabled.labelTag}:</th>
|
||||||
|
<td>{if $form.f.disabled.errors}{$form.f.disabled.fieldErrors}{/if}
|
||||||
|
{$form.f.disabled|unsafe}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{$form.f.syntaxtheme.labelTag}:</th>
|
<th>{$form.f.syntaxtheme.labelTag}:</th>
|
||||||
|
@ -42,6 +42,8 @@ class Pluf_Middleware_Stats
|
|||||||
*/
|
*/
|
||||||
function process_response($request, $response)
|
function process_response($request, $response)
|
||||||
{
|
{
|
||||||
|
if (isset($response) && !isset($response->status_code))
|
||||||
|
return $response;
|
||||||
if (!in_array($response->status_code,
|
if (!in_array($response->status_code,
|
||||||
array(200, 201, 202, 203, 204, 205, 206, 404, 501))) {
|
array(200, 201, 202, 203, 204, 205, 206, 404, 501))) {
|
||||||
return $response;
|
return $response;
|
||||||
|
Loading…
Reference in New Issue
Block a user