Skip to content

Commit

Permalink
anlagen restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
maggsta committed Jul 8, 2010
1 parent 6321574 commit 41eac90
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 23 deletions.
12 changes: 10 additions & 2 deletions apps/frontend/modules/anlage/actions/actions.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ class anlageActions extends sfActions
{
public function executeIndex(sfWebRequest $request)
{
$this->anlage = Doctrine::getTable('Anlage');
if($this->getUser()->hasCredential('admin')) {
$anlage = Doctrine::getTable('Anlage');
$q = $anlage->getAll();
}
else {
$q = Doctrine_Query::create()
->from('Anlage a, a.Stunde s, s.Zim z, z.sfGuardUser u')
->where('u.username = ?', $this->getUser()->getUsername());
}
$this->pager = new sfDoctrinePager(
'Anlage',
sfConfig::get('app_max_anlagen')
);
$this->pager->setQuery($this->anlage->getAll());
$this->pager->setQuery($q);
$this->pager->setPage($request->getParameter('page', 1));
$this->pager->init();
}
Expand Down
8 changes: 1 addition & 7 deletions apps/frontend/modules/zim/templates/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@
<tbody>
<?php echo $form->renderHiddenFields() ?>
<?php echo $form['name']->renderRow() ?>
<?php /*
<tr>
<td> <?php echo $form['name']->renderLabelName() ?></td>
<td> <?php echo $form['name'] ?></td>
<td> <?php echo $form['name']->renderError() ?></td>
</tr>
*/?>
<?php echo $form['user_id']->renderRow() ?>
<?php echo $form['ziele']->renderRow() ?>
<?php echo $form['zielGruppe']->renderRow() ?>
<?php echo $form['roterFaden']->renderRow() ?>
Expand Down
7 changes: 7 additions & 0 deletions apps/frontend/modules/zim/templates/showSuccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@

<table>
<thead>
<tr>
<th><b>Bearbeiter</b></th>
</tr>
<tr>
<td><?php echo $zim->getSfGuardUser() ?></td>
</tr>

<tr>
<th><b>Ziele</b></th>
</tr>
Expand Down
4 changes: 3 additions & 1 deletion config/doctrine/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ Zim:
actAs: { Timestampable: ~ }
columns:
name: { type: string(255), notnull: true }
user_id: { type: integer }
ziele: { type: string(10000) }
zielGruppe: { type: string(255) }
roterFaden: { type: string(10000) }

relations:
sfGuardUser: { local: user_id, foreign: id, foreignAlias: sfGuardUser }
2 changes: 1 addition & 1 deletion data/sql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CREATE TABLE anhang (id INTEGER PRIMARY KEY AUTOINCREMENT, path VARCHAR(255) NOT
CREATE TABLE anlage (id INTEGER PRIMARY KEY AUTOINCREMENT, kuerzel VARCHAR(255) NOT NULL, zeit INTEGER, ziel VARCHAR(1000), methode VARCHAR(1000), material VARCHAR(1000), tip VARCHAR(1000), kurzinhalt VARCHAR(1000), inhalt VARCHAR(10000), rolle_tm VARCHAR(1000), stunde_id INTEGER, lnr INTEGER NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL);
CREATE TABLE bild (id INTEGER PRIMARY KEY AUTOINCREMENT, lnr INTEGER NOT NULL, name VARCHAR(255) NOT NULL, path VARCHAR(255) NOT NULL, caption VARCHAR(1000), anlage_id INTEGER NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL);
CREATE TABLE stunde (id INTEGER PRIMARY KEY AUTOINCREMENT, lnr INTEGER NOT NULL, name VARCHAR(255) NOT NULL, zim_id INTEGER NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL);
CREATE TABLE zim (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(255) NOT NULL, ziele VARCHAR(10000), zielgruppe VARCHAR(255), roterfaden VARCHAR(10000), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL);
CREATE TABLE zim (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(255) NOT NULL, user_id INTEGER, ziele VARCHAR(10000), zielgruppe VARCHAR(255), roterfaden VARCHAR(10000), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL);
CREATE TABLE sf_guard_group (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(255) UNIQUE, description VARCHAR(1000), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL);
CREATE TABLE sf_guard_group_permission (group_id INTEGER, permission_id INTEGER, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(group_id, permission_id));
CREATE TABLE sf_guard_permission (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(255) UNIQUE, description VARCHAR(1000), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL);
Expand Down
3 changes: 3 additions & 0 deletions lib/filter/doctrine/base/BaseZimFormFilter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function setup()
{
$this->setWidgets(array(
'name' => new sfWidgetFormFilterInput(array('with_empty' => false)),
'user_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser'), 'add_empty' => true)),
'ziele' => new sfWidgetFormFilterInput(),
'zielGruppe' => new sfWidgetFormFilterInput(),
'roterFaden' => new sfWidgetFormFilterInput(),
Expand All @@ -23,6 +24,7 @@ public function setup()

$this->setValidators(array(
'name' => new sfValidatorPass(array('required' => false)),
'user_id' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('sfGuardUser'), 'column' => 'id')),
'ziele' => new sfValidatorPass(array('required' => false)),
'zielGruppe' => new sfValidatorPass(array('required' => false)),
'roterFaden' => new sfValidatorPass(array('required' => false)),
Expand All @@ -49,6 +51,7 @@ public function getFields()
return array(
'id' => 'Number',
'name' => 'Text',
'user_id' => 'ForeignKey',
'ziele' => 'Text',
'zielGruppe' => 'Text',
'roterFaden' => 'Text',
Expand Down
1 change: 1 addition & 0 deletions lib/form/doctrine/ZimForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function configure()
$this->widgetSchema['ziele'] = new isicsWidgetFormTinyMCE(array('tiny_options' => sfConfig::get('app_tiny_mce_my_settings')));
$this->widgetSchema['roterFaden'] = new isicsWidgetFormTinyMCE(array('tiny_options' => sfConfig::get('app_tiny_mce_my_settings')));

$this->widgetSchema['userId'] = new sfWidgetFormDoctrineChoice(array('model' => 'sfGuardUser', 'add_empty' => true));
}

public function saveEmbeddedForms($con = null, $forms = null)
Expand Down
2 changes: 2 additions & 0 deletions lib/form/doctrine/base/BaseZimForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function setup()
$this->setWidgets(array(
'id' => new sfWidgetFormInputHidden(),
'name' => new sfWidgetFormInputText(),
'user_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser'), 'add_empty' => true)),
'ziele' => new sfWidgetFormTextarea(),
'zielGruppe' => new sfWidgetFormInputText(),
'roterFaden' => new sfWidgetFormTextarea(),
Expand All @@ -27,6 +28,7 @@ public function setup()
$this->setValidators(array(
'id' => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
'name' => new sfValidatorString(array('max_length' => 255)),
'user_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser'), 'required' => false)),
'ziele' => new sfValidatorString(array('max_length' => 10000, 'required' => false)),
'zielGruppe' => new sfValidatorString(array('max_length' => 255, 'required' => false)),
'roterFaden' => new sfValidatorString(array('max_length' => 10000, 'required' => false)),
Expand Down
33 changes: 23 additions & 10 deletions lib/model/doctrine/base/BaseZim.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,27 @@
* This class has been auto-generated by the Doctrine ORM Framework
*
* @property string $name
* @property integer $user_id
* @property string $ziele
* @property string $zielGruppe
* @property string $roterFaden
* @property sfGuardUser $sfGuardUser
* @property Doctrine_Collection $Stunden
*
* @method string getName() Returns the current record's "name" value
* @method string getZiele() Returns the current record's "ziele" value
* @method string getZielGruppe() Returns the current record's "zielGruppe" value
* @method string getRoterFaden() Returns the current record's "roterFaden" value
* @method Doctrine_Collection getStunden() Returns the current record's "Stunden" collection
* @method Zim setName() Sets the current record's "name" value
* @method Zim setZiele() Sets the current record's "ziele" value
* @method Zim setZielGruppe() Sets the current record's "zielGruppe" value
* @method Zim setRoterFaden() Sets the current record's "roterFaden" value
* @method Zim setStunden() Sets the current record's "Stunden" collection
* @method string getName() Returns the current record's "name" value
* @method integer getUserId() Returns the current record's "user_id" value
* @method string getZiele() Returns the current record's "ziele" value
* @method string getZielGruppe() Returns the current record's "zielGruppe" value
* @method string getRoterFaden() Returns the current record's "roterFaden" value
* @method sfGuardUser getSfGuardUser() Returns the current record's "sfGuardUser" value
* @method Doctrine_Collection getStunden() Returns the current record's "Stunden" collection
* @method Zim setName() Sets the current record's "name" value
* @method Zim setUserId() Sets the current record's "user_id" value
* @method Zim setZiele() Sets the current record's "ziele" value
* @method Zim setZielGruppe() Sets the current record's "zielGruppe" value
* @method Zim setRoterFaden() Sets the current record's "roterFaden" value
* @method Zim setSfGuardUser() Sets the current record's "sfGuardUser" value
* @method Zim setStunden() Sets the current record's "Stunden" collection
*
* @package openZIM
* @subpackage model
Expand All @@ -37,6 +43,9 @@ public function setTableDefinition()
'notnull' => true,
'length' => 255,
));
$this->hasColumn('user_id', 'integer', null, array(
'type' => 'integer',
));
$this->hasColumn('ziele', 'string', 10000, array(
'type' => 'string',
'length' => 10000,
Expand All @@ -54,6 +63,10 @@ public function setTableDefinition()
public function setUp()
{
parent::setUp();
$this->hasOne('sfGuardUser', array(
'local' => 'user_id',
'foreign' => 'id'));

$this->hasMany('Stunde as Stunden', array(
'local' => 'id',
'foreign' => 'zim_id'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,68 @@
* @property timestamp $last_login
* @property Doctrine_Collection $groups
* @property Doctrine_Collection $permissions
* @property Doctrine_Collection $sfGuardUserPermission
* @property Doctrine_Collection $sfGuardUserGroup
* @property Doctrine_Collection $sfGuardUser
*
* @method integer getId() Returns the current record's "id" value
* @method string getUsername() Returns the current record's "username" value
* @method string getAlgorithm() Returns the current record's "algorithm" value
* @method string getSalt() Returns the current record's "salt" value
* @method string getPassword() Returns the current record's "password" value
* @method boolean getIsActive() Returns the current record's "is_active" value
* @method boolean getIsSuperAdmin() Returns the current record's "is_super_admin" value
* @method timestamp getLastLogin() Returns the current record's "last_login" value
* @method Doctrine_Collection getGroups() Returns the current record's "groups" collection
* @method Doctrine_Collection getPermissions() Returns the current record's "permissions" collection
* @method Doctrine_Collection getSfGuardUserPermission() Returns the current record's "sfGuardUserPermission" collection
* @method Doctrine_Collection getSfGuardUserGroup() Returns the current record's "sfGuardUserGroup" collection
* @method sfGuardRememberKey getRememberKeys() Returns the current record's "RememberKeys" value
* @method Doctrine_Collection getSfGuardUser() Returns the current record's "sfGuardUser" collection
* @method sfGuardUser setId() Sets the current record's "id" value
* @method sfGuardUser setUsername() Sets the current record's "username" value
* @method sfGuardUser setAlgorithm() Sets the current record's "algorithm" value
* @method sfGuardUser setSalt() Sets the current record's "salt" value
* @method sfGuardUser setPassword() Sets the current record's "password" value
* @method sfGuardUser setIsActive() Sets the current record's "is_active" value
* @method sfGuardUser setIsSuperAdmin() Sets the current record's "is_super_admin" value
* @method sfGuardUser setLastLogin() Sets the current record's "last_login" value
* @method sfGuardUser setGroups() Sets the current record's "groups" collection
* @method sfGuardUser setPermissions() Sets the current record's "permissions" collection
* @method sfGuardUser setSfGuardUserPermission() Sets the current record's "sfGuardUserPermission" collection
* @method sfGuardUser setSfGuardUserGroup() Sets the current record's "sfGuardUserGroup" collection
* @method sfGuardUser setRememberKeys() Sets the current record's "RememberKeys" value
* @method sfGuardUser setSfGuardUser() Sets the current record's "sfGuardUser" collectionPermission
* @property Doctrine_Collection $sfGuardUser
*
* @method integer getId() Returns the current record's "id" value
* @method string getUsername() Returns the current record's "username" value
* @method string getAlgorithm() Returns the current record's "algorithm" value
* @method string getSalt() Returns the current record's "salt" value
* @method string getPassword() Returns the current record's "password" value
* @method boolean getIsActive() Returns the current record's "is_active" value
* @method boolean getIsSuperAdmin() Returns the current record's "is_super_admin" value
* @method timestamp getLastLogin() Returns the current record's "last_login" value
* @method Doctrine_Collection getGroups() Returns the current record's "groups" collection
* @method Doctrine_Collection getPermissions() Returns the current record's "permissions" collection
* @method Doctrine_Collection getSfGuardUserPermission() Returns the current record's "sfGuardUserPermission" collection
* @method Doctrine_Collection getSfGuardUserGroup() Returns the current record's "sfGuardUserGroup" collection
* @method sfGuardRememberKey getRememberKeys() Returns the current record's "RememberKeys" value
* @method Doctrine_Collection getSfGuardUser() Returns the current record's "sfGuardUser" collection
* @method sfGuardUser setId() Sets the current record's "id" value
* @method sfGuardUser setUsername() Sets the current record's "username" value
* @method sfGuardUser setAlgorithm() Sets the current record's "algorithm" value
* @method sfGuardUser setSalt() Sets the current record's "salt" value
* @method sfGuardUser setPassword() Sets the current record's "password" value
* @method sfGuardUser setIsActive() Sets the current record's "is_active" value
* @method sfGuardUser setIsSuperAdmin() Sets the current record's "is_super_admin" value
* @method sfGuardUser setLastLogin() Sets the current record's "last_login" value
* @method sfGuardUser setGroups() Sets the current record's "groups" collection
* @method sfGuardUser setPermissions() Sets the current record's "permissions" collection
* @method sfGuardUser setSfGuardUserPermission() Sets the current record's "sfGuardUserPermission" collection
* @method sfGuardUser setSfGuardUserGroup() Sets the current record's "sfGuardUserGroup" collection
* @method sfGuardUser setRememberKeys() Sets the current record's "RememberKeys" value
* @method sfGuardUser setSfGuardUser() Sets the current record's "sfGuardUser" collectionGroup
* @property sfGuardRememberKey $RememberKeys
* @property Doctrine_Collection $sfGuardUser
*
* @method integer getId() Returns the current record's "id" value
* @method string getUsername() Returns the current record's "username" value
Expand All @@ -32,6 +91,7 @@
* @method Doctrine_Collection getSfGuardUserPermission() Returns the current record's "sfGuardUserPermission" collection
* @method Doctrine_Collection getSfGuardUserGroup() Returns the current record's "sfGuardUserGroup" collection
* @method sfGuardRememberKey getRememberKeys() Returns the current record's "RememberKeys" value
* @method Doctrine_Collection getSfGuardUser() Returns the current record's "sfGuardUser" collection
* @method sfGuardUser setId() Sets the current record's "id" value
* @method sfGuardUser setUsername() Sets the current record's "username" value
* @method sfGuardUser setAlgorithm() Sets the current record's "algorithm" value
Expand All @@ -45,6 +105,7 @@
* @method sfGuardUser setSfGuardUserPermission() Sets the current record's "sfGuardUserPermission" collection
* @method sfGuardUser setSfGuardUserGroup() Sets the current record's "sfGuardUserGroup" collection
* @method sfGuardUser setRememberKeys() Sets the current record's "RememberKeys" value
* @method sfGuardUser setSfGuardUser() Sets the current record's "sfGuardUser" collection
*
* @package openZIM
* @subpackage model
Expand Down Expand Up @@ -128,6 +189,10 @@ public function setUp()
'local' => 'id',
'foreign' => 'user_id'));

$this->hasMany('Zim as sfGuardUser', array(
'local' => 'id',
'foreign' => 'user_id'));

$timestampable0 = new Doctrine_Template_Timestampable(array(
));
$this->actAs($timestampable0);
Expand Down

0 comments on commit 41eac90

Please sign in to comment.