Skip to content

Commit

Permalink
Merge pull request #8 from yupe/master
Browse files Browse the repository at this point in the history
Обновляемся до репы
  • Loading branch information
im-kulikov committed Jan 3, 2013
2 parents a3b2e0a + d4e8b4f commit bdbfec5
Show file tree
Hide file tree
Showing 9 changed files with 952 additions and 860 deletions.
1,714 changes: 857 additions & 857 deletions framework/YiiBase.php

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions protected/modules/blog/BlogModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public function getDependencies()
{
return array(
'user',
'category'
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Add category relations to blog
*/
class m121231_184100_blog_category extends CDbMigration
{
public function safeUp()
{
$db = $this->getDbConnection();

// blog
$tableName = $db->tablePrefix.'blog';

$this->addColumn($tableName, 'category_id', 'integer DEFAULT NULL');

$this->createIndex("blog_category_idx",$tableName,"category_id", false);
$this->addForeignKey("blog_category_fk",$tableName,'category_id',$db->tablePrefix.'category','id','SET NULL','CASCADE');
}

public function safeDown()
{
$db = $this->getDbConnection();
$tableName = $db->tablePrefix.'blog';
$this->dropForeignKey("blog_category_fk", $tableName);
$this->dropIndex("blog_category_idx", $tableName);
$this->dropColumn($tableName,'category_id');
}
}
1 change: 0 additions & 1 deletion protected/modules/user/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ public function rules()
);
}


/**
* @return array customized attribute labels (name=>label)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ public function safeUp()
public function safeDown()
{
$db = $this->getDbConnection();

// remove foreign keys prior to table drop to avoid loop
// wiki_page_link
$this->dropForeignKey("wiki_link_page_from_fk",$db->tablePrefix.'wiki_link');
$this->dropForeignKey("wiki_link_page_to_fk",$db->tablePrefix.'wiki_link');

// wiki_page_revision
$this->dropForeignKey("wiki_page_revision_pagefk",$db->tablePrefix.'wiki_page_revision');
$this->dropForeignKey("wiki_page_revision_fk",$db->tablePrefix.'wiki_page_revision');

// wiki_page
$this->dropForeignKey("wiki_page_user_fk",$db->tablePrefix.'wiki_page');

$this->dropTable($db->tablePrefix.'wiki_page_revision');
$this->dropTable($db->tablePrefix.'wiki_link');
$this->dropTable($db->tablePrefix.'wiki_page');
Expand Down
13 changes: 13 additions & 0 deletions protected/modules/yupe/controllers/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,17 @@ public function actionHelp()
{
$this->render('help');
}

public function actionModupdate($name=null)
{
if($name && ($module=Yii::app()->getModule($name)))
{
$updates = Yii::app()->migrator->checkForUpdates(array($name=>$module));
$this->render('modupdate', array( 'updates' => $updates, 'module' => $module));
return;
}

$this->render('modupdate_index', array());

}
}
20 changes: 20 additions & 0 deletions protected/modules/yupe/extensions/migrator/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,24 @@ protected function getNewMigrations($module)
return $migrations;
}

/*
* Check each modules for new migrations
*
*/
public function checkForUpdates($modules)
{
// check for table
$db=$this->getDbConnection();
if($db->schema->getTable($db->tablePrefix.$this->migrationTable)===null)
$this->createMigrationHistoryTable();

$updates = array();

foreach($modules as $mid=>$module)
if ($a=$this->getNewMigrations($mid))
$updates[$mid]=$a;

return $updates;
}

}
15 changes: 13 additions & 2 deletions protected/modules/yupe/views/backend/_moduleslist.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<?php if (count($modules)): ?>
<?php

if (count($modules))
{
$updates = Yii::app()->migrator->checkForUpdates($modules);
?>

<div class="page-header">
<h6>
<?php echo Yii::t('yupe', 'Модули разработанные специально для "{app}"', array(
Expand Down Expand Up @@ -79,10 +85,15 @@
: CHtml::link('<i class="icon-ok-sign" title="' . Yii::t('yupe', 'Включить') . '">&nbsp;</i>', $url + array('status' => '1'))
)
: '';
if (isset($updates[$module->id]))
echo CHtml::link('<i class="icon-refresh" title="' . Yii::t('yupe', 'Есть {n} обновление базы!|Есть {n} обновления базы!|Есть {n} обновлений базы!',count($updates[$module->id])) . '">&nbsp;</i>', array('/yupe/backend/modupdate','name' => $module->id));
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php
}
?>
7 changes: 7 additions & 0 deletions protected/modules/yupe/views/backend/modupdate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
if (isset($updates[$module->id]) && ($updates=$updates[$module->id]))
foreach($updates as $u)
{
//$date = substr()
print_r($u);
}

0 comments on commit bdbfec5

Please sign in to comment.