Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Commit

Permalink
- CHANGES IN DB LAYOUT
Browse files Browse the repository at this point in the history
- fix for Bug #838190 'RESTORE-PASSWORD: 404 error with restore URL'
- improvements in PlayerScores and Top10Players portlet
- bug fixing ZenTag
- changes in metadatagames css
  • Loading branch information
novazembla committed Sep 3, 2011
1 parent d89b0e0 commit a22b5bc
Show file tree
Hide file tree
Showing 16 changed files with 207 additions and 189 deletions.
Binary file added documentation/mg_database_schema_v0.5.5.mwb
Binary file not shown.
5 changes: 5 additions & 0 deletions www/protected/components/PlayerScores.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public function init() {

protected function renderContent() {
if ($user_id = Yii::app()->user->id) {
$games = GamesModule::getPlayerScores($user_id);

if (is_null($games))
$games = array();

$this->render('playerScores', array(
'games' => GamesModule::getPlayerScores($user_id)
));
Expand Down
7 changes: 6 additions & 1 deletion www/protected/components/Top10Players.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ public function init() {
}

protected function renderContent() {
$players = GamesModule::getTopPlayers();

if (is_null($players))
$players = array();

$this->render('top10players', array(
'players' => GamesModule::getTopPlayers()
'players' => $players
));
}
}
2 changes: 1 addition & 1 deletion www/protected/config/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
'urlFormat'=>'path',
'rules'=>array(
'user/login/restore-password' => 'user/recovery/recovery',

'user/login/restore-password/<activekey:.+>/<email:.+>' => 'user/recovery/recovery/<activekey>/<email>',
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
Expand Down
11 changes: 6 additions & 5 deletions www/protected/data/mg.mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ CREATE TABLE IF NOT EXISTS `user` (
`username` VARCHAR(32) NOT NULL ,
`password` VARCHAR(128) NOT NULL ,
`email` VARCHAR(128) NOT NULL ,
`activkey` VARCHAR(128) NOT NULL DEFAULT '' ,
`activekey` VARCHAR(128) NOT NULL DEFAULT '' ,
`lastvisit` DATETIME NULL ,
`role` VARCHAR(45) NOT NULL DEFAULT 'player' ,
`status` INT(1) NOT NULL DEFAULT '0' ,
Expand Down Expand Up @@ -198,6 +198,7 @@ CREATE TABLE IF NOT EXISTS `image` (
`name` VARCHAR(254) NOT NULL ,
`size` INT(11) NOT NULL ,
`mime_type` VARCHAR(45) NOT NULL ,
`batch_id` VARCHAR(45) NOT NULL DEFAULT 'BATCH-001' ,
`last_access` DATETIME NULL ,
`locked` INT(1) NOT NULL DEFAULT 0 ,
`created` DATETIME NOT NULL ,
Expand Down Expand Up @@ -708,10 +709,10 @@ COMMIT;
-- Data for table `user`
-- -----------------------------------------------------
START TRANSACTION;
INSERT INTO `user` (`id`, `username`, `password`, `email`, `activkey`, `lastvisit`, `role`, `status`, `edited_count`, `created`, `modified`) VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', '[email protected]', '9a24eff8c15a6a141ece27eb6947da0f', NULL, 'admin', 1, 0, '2011-01-01 12:00', '2011-01-01 12:00');
INSERT INTO `user` (`id`, `username`, `password`, `email`, `activkey`, `lastvisit`, `role`, `status`, `edited_count`, `created`, `modified`) VALUES (2, 'dbmanager', 'a945e003507368542f40f13b3076ca6f', '[email protected]', 'b58e465dcb47f8459439cf54535bc8ae', NULL, 'dbmanager', 1, 0, '2011-01-01 12:00', '2011-01-01 12:00');
INSERT INTO `user` (`id`, `username`, `password`, `email`, `activkey`, `lastvisit`, `role`, `status`, `edited_count`, `created`, `modified`) VALUES (3, 'editor', '5aee9dbd2a188839105073571bee1b1f', '[email protected]', '52c200c7ca710d13f2ba1bea3788723c', NULL, 'editor', 1, 0, '2011-01-01 12:00', '2011-01-01 12:00');
INSERT INTO `user` (`id`, `username`, `password`, `email`, `activkey`, `lastvisit`, `role`, `status`, `edited_count`, `created`, `modified`) VALUES (4, 'player', '912af0dff974604f1321254ca8ff38b6', '[email protected]', 'd3f33d7d0e80bbe3004adc82fc9e779c', NULL, 'player', 1, 0, '2011-01-01 12:00', '2011-01-01 12:00');
INSERT INTO `user` (`id`, `username`, `password`, `email`, `activekey`, `lastvisit`, `role`, `status`, `edited_count`, `created`, `modified`) VALUES (1, 'admin', '21232f297a57a5a743894a0e4a801fc3', '[email protected]', '9a24eff8c15a6a141ece27eb6947da0f', NULL, 'admin', 1, 0, '2011-01-01 12:00', '2011-01-01 12:00');
INSERT INTO `user` (`id`, `username`, `password`, `email`, `activekey`, `lastvisit`, `role`, `status`, `edited_count`, `created`, `modified`) VALUES (2, 'dbmanager', 'a945e003507368542f40f13b3076ca6f', '[email protected]', 'b58e465dcb47f8459439cf54535bc8ae', NULL, 'dbmanager', 1, 0, '2011-01-01 12:00', '2011-01-01 12:00');
INSERT INTO `user` (`id`, `username`, `password`, `email`, `activekey`, `lastvisit`, `role`, `status`, `edited_count`, `created`, `modified`) VALUES (3, 'editor', '5aee9dbd2a188839105073571bee1b1f', '[email protected]', '52c200c7ca710d13f2ba1bea3788723c', NULL, 'editor', 1, 0, '2011-01-01 12:00', '2011-01-01 12:00');
INSERT INTO `user` (`id`, `username`, `password`, `email`, `activekey`, `lastvisit`, `role`, `status`, `edited_count`, `created`, `modified`) VALUES (4, 'player', '912af0dff974604f1321254ca8ff38b6', '[email protected]', 'd3f33d7d0e80bbe3004adc82fc9e779c', NULL, 'player', 1, 0, '2011-01-01 12:00', '2011-01-01 12:00');

COMMIT;

Expand Down
8 changes: 4 additions & 4 deletions www/protected/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public function rules() {
array('status, edited_count', 'numerical', 'integerOnly'=>true),
array('username', 'length', 'max'=>32),
array('email', 'email'),
array('password, email, activkey', 'length', 'max'=>128),
array('password, email, activekey', 'length', 'max'=>128),
array('role', 'length', 'max'=>45),
array('role', 'checkRoleAccess'),
array('activkey, lastvisit, role, status, edited_count, created, modified', 'default', 'setOnEmpty' => true, 'value' => null),
array('id, username, password, email, activkey, lastvisit, role, status, edited_count, created, modified', 'safe', 'on'=>'search'),
array('activekey, lastvisit, role, status, edited_count, created, modified', 'default', 'setOnEmpty' => true, 'value' => null),
array('id, username, password, email, activekey, lastvisit, role, status, edited_count, created, modified', 'safe', 'on'=>'search'),
);
}

Expand Down Expand Up @@ -75,7 +75,7 @@ public function scopes()
'condition'=>'role=\'admin\'',
),
'notsafe'=>array(
'select' => 'id, username, password, email, activkey, edited_count, created, modified, lastvisit, role, status',
'select' => 'id, username, password, email, activekey, edited_count, created, modified, lastvisit, role, status',
),
);
}
Expand Down
12 changes: 6 additions & 6 deletions www/protected/models/_base/BaseUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @property string $username
* @property string $password
* @property string $email
* @property string $activkey
* @property string $activekey
* @property string $lastvisit
* @property string $role
* @property integer $status
Expand Down Expand Up @@ -50,11 +50,11 @@ public function rules() {
array('username, password, email, created, modified', 'required'),
array('status, edited_count', 'numerical', 'integerOnly'=>true),
array('username', 'length', 'max'=>32),
array('password, email, activkey', 'length', 'max'=>128),
array('password, email, activekey', 'length', 'max'=>128),
array('role', 'length', 'max'=>45),
array('lastvisit', 'safe'),
array('activkey, lastvisit, role, status, edited_count', 'default', 'setOnEmpty' => true, 'value' => null),
array('id, username, password, email, activkey, lastvisit, role, status, edited_count, created, modified', 'safe', 'on'=>'search'),
array('activekey, lastvisit, role, status, edited_count', 'default', 'setOnEmpty' => true, 'value' => null),
array('id, username, password, email, activekey, lastvisit, role, status, edited_count, created, modified', 'safe', 'on'=>'search'),
);
}

Expand All @@ -81,7 +81,7 @@ public function attributeLabels() {
'username' => Yii::t('app', 'Username'),
'password' => Yii::t('app', 'Password'),
'email' => Yii::t('app', 'Email'),
'activkey' => Yii::t('app', 'Activkey'),
'activekey' => Yii::t('app', 'Activation Key'),
'lastvisit' => Yii::t('app', 'Lastvisit'),
'role' => Yii::t('app', 'Role'),
'status' => Yii::t('app', 'Status'),
Expand All @@ -103,7 +103,7 @@ public function search() {
$criteria->compare('username', $this->username, true);
$criteria->compare('password', $this->password, true);
$criteria->compare('email', $this->email, true);
$criteria->compare('activkey', $this->activkey, true);
$criteria->compare('activekey', $this->activekey, true);
$criteria->compare('lastvisit', $this->lastvisit, true);
$criteria->compare('role', $this->role, true);
$criteria->compare('status', $this->status);
Expand Down
4 changes: 2 additions & 2 deletions www/protected/modules/admin/controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function actionCreate()
if(isset($_POST['User']))
{
$model->attributes=$_POST['User'];
$model->activkey=UserModule::encrypting(microtime().$model->password);
$model->activekey=UserModule::encrypting(microtime().$model->password);
$model->created = date('Y-m-d H:i:s');
$model->modified = date('Y-m-d H:i:s');
$model->lastvisit=date('Y-m-d H:i:s');
Expand Down Expand Up @@ -128,7 +128,7 @@ public function actionUpdate()
$old_password = User::model()->notsafe()->findByPk($model->id);
if ($old_password->password!=$model->password) {
$model->password=UserModule::encrypting($model->password);
$model->activkey=UserModule::encrypting(microtime().$model->password);
$model->activekey=UserModule::encrypting(microtime().$model->password);
}

$relatedData = array(
Expand Down
244 changes: 122 additions & 122 deletions www/protected/modules/admin/views/user/view.php
Original file line number Diff line number Diff line change
@@ -1,122 +1,122 @@
<?php
$this->breadcrumbs=array(
Yii::t('app', 'Admin')=>array('/admin'),
UserModule::t('Users')=>array('/admin/user'),
$model->username,
);

$this->menu=array(
array('label'=>Yii::t('app', 'Manage') . ' ' . $model->label(2), 'url'=>array('admin')),
array('label'=>Yii::t('app', 'Create') . ' ' . $model->label(), 'url'=>array('create')),
array('label'=>Yii::t('app', 'Update') . ' ' . $model->label(), 'url'=>array('update', 'id' => $model->id)),
array('label'=>Yii::t('app', 'Delete') . ' ' . $model->label(), 'url'=>'#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm'=>'Are you sure you want to delete this user?')),
);
?>

<?php

$attributes = array(
'id',
'username',
);

$profileFields=ProfileField::model()->forOwner()->sort()->findAll();
if ($profileFields) {
foreach($profileFields as $field) {
array_push($attributes,array(
'label' => UserModule::t($field->title),
'name' => $field->varname,
'type'=>'raw',
'value' => (($field->widgetView($model->profile))?$field->widgetView($model->profile):(($field->range)?Profile::range($field->range,$model->profile->getAttribute($field->varname)):$model->profile->getAttribute($field->varname))),
));
}
}
// xxx the order of the fields might want to be changed.
array_push($attributes,
'password',
'email',
'activkey',
'created',
'modified',
array(
'name' => 'edited_count',
'value' => $model->edited_count . " (xxx this functionality is not yet active)",
),
array(
'name' => 'lastvisit',
'value' => (($model->lastvisit)?$model->lastvisit:UserModule::t('Not visited'))
),
array(
'name' => 'role',
'value' => $model->role,
),
array(
'name' => 'status',
'value' => User::itemAlias("UserStatus",$model->status),
)
);
?>

<h1><?php echo Yii::t('app', 'View') . ' ' . GxHtml::encode($model->label()) . ' ' . GxHtml::encode(GxHtml::valueEx($model)); ?></h1>

<?php $this->widget('zii.widgets.CDetailView', array(
'data' => $model,
'attributes' => $attributes
)); ?>

<h2><?php echo GxHtml::encode($model->getRelationLabel('log')); ?></h2>
<?php
echo GxHtml::openTag('ul');
if (count($model->logs) == 0) {
echo "<li>no item(s) assigned</li>";
}

foreach($model->logs as $relatedModel) {
echo GxHtml::openTag('li');
echo GxHtml::link(GxHtml::encode(GxHtml::valueEx($relatedModel)), array('log/view', 'id' => GxActiveRecord::extractPkValue($relatedModel, true)));
echo GxHtml::closeTag('li');
}
echo GxHtml::closeTag('ul');
?><h2><?php echo GxHtml::encode($model->getRelationLabel('session')); ?></h2>
<?php
echo GxHtml::openTag('ul');

if (count($model->sessions) == 0) {
echo "<li>no item(s) assigned</li>";
}

foreach($model->sessions as $relatedModel) {
echo GxHtml::openTag('li');
echo GxHtml::link(GxHtml::encode(GxHtml::valueEx($relatedModel)), array('sessions/view', 'id' => GxActiveRecord::extractPkValue($relatedModel, true)));
echo GxHtml::closeTag('li');
}
echo GxHtml::closeTag('ul');
?><h2><?php echo GxHtml::encode($model->getRelationLabel('game')); ?></h2>
<?php
echo GxHtml::openTag('ul');

if (count($model->games) == 0) {
echo "<li>no item(s) assigned</li>";
}

foreach($model->games as $relatedModel) {
echo GxHtml::openTag('li');
echo GxHtml::link(GxHtml::encode(GxHtml::valueEx($relatedModel)), array('games/view', 'id' => GxActiveRecord::extractPkValue($relatedModel, true)));
echo GxHtml::closeTag('li');
}
echo GxHtml::closeTag('ul');
?><h2><?php echo GxHtml::encode($model->getRelationLabel('subjectMatter')); ?></h2>
<?php
echo GxHtml::openTag('ul');

if (count($model->subjectMatters) == 0) {
echo "<li>no item(s) assigned</li>";
}

foreach($model->subjectMatters as $relatedModel) {
echo GxHtml::openTag('li');
echo GxHtml::link(GxHtml::encode(GxHtml::valueEx($relatedModel)), array('subjectMatters/view', 'id' => GxActiveRecord::extractPkValue($relatedModel, true)));
echo GxHtml::closeTag('li');
}
echo GxHtml::closeTag('ul');
?>
<?php
$this->breadcrumbs=array(
Yii::t('app', 'Admin')=>array('/admin'),
UserModule::t('Users')=>array('/admin/user'),
$model->username,
);

$this->menu=array(
array('label'=>Yii::t('app', 'Manage') . ' ' . $model->label(2), 'url'=>array('admin')),
array('label'=>Yii::t('app', 'Create') . ' ' . $model->label(), 'url'=>array('create')),
array('label'=>Yii::t('app', 'Update') . ' ' . $model->label(), 'url'=>array('update', 'id' => $model->id)),
array('label'=>Yii::t('app', 'Delete') . ' ' . $model->label(), 'url'=>'#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm'=>'Are you sure you want to delete this user?')),
);
?>

<?php

$attributes = array(
'id',
'username',
);

$profileFields=ProfileField::model()->forOwner()->sort()->findAll();
if ($profileFields) {
foreach($profileFields as $field) {
array_push($attributes,array(
'label' => UserModule::t($field->title),
'name' => $field->varname,
'type'=>'raw',
'value' => (($field->widgetView($model->profile))?$field->widgetView($model->profile):(($field->range)?Profile::range($field->range,$model->profile->getAttribute($field->varname)):$model->profile->getAttribute($field->varname))),
));
}
}
// xxx the order of the fields might want to be changed.
array_push($attributes,
'password',
'email',
'activekey',
'created',
'modified',
array(
'name' => 'edited_count',
'value' => $model->edited_count . " (xxx this functionality is not yet active)",
),
array(
'name' => 'lastvisit',
'value' => (($model->lastvisit)?$model->lastvisit:UserModule::t('Not visited'))
),
array(
'name' => 'role',
'value' => $model->role,
),
array(
'name' => 'status',
'value' => User::itemAlias("UserStatus",$model->status),
)
);
?>

<h1><?php echo Yii::t('app', 'View') . ' ' . GxHtml::encode($model->label()) . ' ' . GxHtml::encode(GxHtml::valueEx($model)); ?></h1>

<?php $this->widget('zii.widgets.CDetailView', array(
'data' => $model,
'attributes' => $attributes
)); ?>

<h2><?php echo GxHtml::encode($model->getRelationLabel('log')); ?></h2>
<?php
echo GxHtml::openTag('ul');
if (count($model->logs) == 0) {
echo "<li>no item(s) assigned</li>";
}

foreach($model->logs as $relatedModel) {
echo GxHtml::openTag('li');
echo GxHtml::link(GxHtml::encode(GxHtml::valueEx($relatedModel)), array('log/view', 'id' => GxActiveRecord::extractPkValue($relatedModel, true)));
echo GxHtml::closeTag('li');
}
echo GxHtml::closeTag('ul');
?><h2><?php echo GxHtml::encode($model->getRelationLabel('session')); ?></h2>
<?php
echo GxHtml::openTag('ul');

if (count($model->sessions) == 0) {
echo "<li>no item(s) assigned</li>";
}

foreach($model->sessions as $relatedModel) {
echo GxHtml::openTag('li');
echo GxHtml::link(GxHtml::encode(GxHtml::valueEx($relatedModel)), array('sessions/view', 'id' => GxActiveRecord::extractPkValue($relatedModel, true)));
echo GxHtml::closeTag('li');
}
echo GxHtml::closeTag('ul');
?><h2><?php echo GxHtml::encode($model->getRelationLabel('game')); ?></h2>
<?php
echo GxHtml::openTag('ul');

if (count($model->games) == 0) {
echo "<li>no item(s) assigned</li>";
}

foreach($model->games as $relatedModel) {
echo GxHtml::openTag('li');
echo GxHtml::link(GxHtml::encode(GxHtml::valueEx($relatedModel)), array('games/view', 'id' => GxActiveRecord::extractPkValue($relatedModel, true)));
echo GxHtml::closeTag('li');
}
echo GxHtml::closeTag('ul');
?><h2><?php echo GxHtml::encode($model->getRelationLabel('subjectMatter')); ?></h2>
<?php
echo GxHtml::openTag('ul');

if (count($model->subjectMatters) == 0) {
echo "<li>no item(s) assigned</li>";
}

foreach($model->subjectMatters as $relatedModel) {
echo GxHtml::openTag('li');
echo GxHtml::link(GxHtml::encode(GxHtml::valueEx($relatedModel)), array('subjectMatters/view', 'id' => GxActiveRecord::extractPkValue($relatedModel, true)));
echo GxHtml::closeTag('li');
}
echo GxHtml::closeTag('ul');
?>
Loading

0 comments on commit a22b5bc

Please sign in to comment.