Merge branch 'develop' of https://github.com/dev-fsociety/DFS-2016 into develop
This commit is contained in:
src
Controller
Model
Table
Template
webroot/css
@ -65,7 +65,13 @@ class AppController extends Controller
|
||||
'logoutRedirect' => [
|
||||
'controller' => 'Users',
|
||||
'action' => 'login'
|
||||
],
|
||||
'unauthorizedRedirect' => [
|
||||
'controller' => 'Categories',
|
||||
'action' => 'index'
|
||||
]
|
||||
|
||||
// --> DON'T FORGET TO CHANGE THE REDIRECTION TOWARDS "CATEGORIES -> INDEX" TO A REAL HOMEPAGE
|
||||
]);
|
||||
|
||||
$this->Auth->deny();
|
||||
|
@ -145,6 +145,19 @@ class UsersController extends AppController
|
||||
'contain' => []
|
||||
]);
|
||||
|
||||
if($user['role'] != 2)
|
||||
{
|
||||
if($user['role'] === 0)
|
||||
{
|
||||
return $this->redirect(['action' => 'editOrganisation', $id]);
|
||||
}
|
||||
|
||||
if($user['role'] === 1)
|
||||
{
|
||||
return $this->redirect(['action' => 'editDonor', $id]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
$user = $this->Users->patchEntity($user, $this->request->data);
|
||||
|
||||
@ -171,6 +184,19 @@ class UsersController extends AppController
|
||||
'contain' => []
|
||||
]);
|
||||
|
||||
if($user['role'] != 1)
|
||||
{
|
||||
if($user['role'] === 0)
|
||||
{
|
||||
return $this->redirect(['action' => 'editOrganisation', $id]);
|
||||
}
|
||||
|
||||
if($user['role'] === 2)
|
||||
{
|
||||
return $this->redirect(['action' => 'editRefugee', $id]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
$user = $this->Users->patchEntity($user, $this->request->data);
|
||||
|
||||
@ -203,6 +229,19 @@ class UsersController extends AppController
|
||||
'contain' => []
|
||||
]);
|
||||
|
||||
if($user['role'] != 0)
|
||||
{
|
||||
if($user['role'] === 1)
|
||||
{
|
||||
return $this->redirect(['action' => 'editDonor', $id]);
|
||||
}
|
||||
|
||||
if($user['role'] === 2)
|
||||
{
|
||||
return $this->redirect(['action' => 'editRefugee', $id]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
$user = $this->Users->patchEntity($user, $this->request->data);
|
||||
|
||||
@ -278,7 +317,7 @@ class UsersController extends AppController
|
||||
{
|
||||
if(isset($user))
|
||||
{
|
||||
if(in_array($this->request->action, ['edit', 'delete', 'view']))
|
||||
if(in_array($this->request->action, ['editOrganisation', 'editDonor', 'editRefugee', 'delete', 'view']))
|
||||
{
|
||||
if((int)$this->request->params['pass'][0] === $user['id'])
|
||||
{
|
||||
@ -287,6 +326,8 @@ class UsersController extends AppController
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
return parent::isAuthorized($user);
|
||||
}
|
||||
@ -294,6 +335,7 @@ class UsersController extends AppController
|
||||
public function beforeFilter(Event $event)
|
||||
{
|
||||
parent::beforeFilter($event);
|
||||
|
||||
$this->Auth->allow(['logout', 'subscribeRefugee', 'subscribeDonor']);
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,11 @@ class UsersTable extends Table
|
||||
|
||||
$validator
|
||||
->requirePresence('phone', 'create')
|
||||
->allowEmpty('phone');
|
||||
->allowEmpty('phone')
|
||||
/*->add('phone', 'validFormat', [
|
||||
'rule' => ['custom', '^0[0-79][0-9]{8}$'],
|
||||
'message' => 'Please enter a valid phone number.']
|
||||
)*/;
|
||||
|
||||
$validator
|
||||
->requirePresence('description', 'create')
|
||||
|
@ -1,9 +1,33 @@
|
||||
|
||||
<?php
|
||||
<h1 class="text-center" style="color: #444; margin-top: 2%; margin-bottom:2%;">Please select an item below</h1>
|
||||
|
||||
debug($category);
|
||||
|
||||
foreach ($items as $item) {
|
||||
debug($item);
|
||||
}
|
||||
?>
|
||||
<div class="large-1 medium-1 columns"><br></div>
|
||||
<div class="columns small-up-10 medium-up-10 large-10">
|
||||
<?php $counter = 0;?>
|
||||
<?php foreach ($items as $item): ?>
|
||||
<!-- if right camp -->
|
||||
<?php $sclass = "square square-color" . (string)($counter%4) ?>
|
||||
<div class="row">
|
||||
<div class="column large-3 medium-3 small-3 text-center square-container">
|
||||
<div class="<?php echo $sclass; ?>">
|
||||
<div class="square-content"><?= h($item->name) ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column large-3 medium-3 small-3 text-center">
|
||||
<div class="cat-desc">
|
||||
<?= h($item->category) ?>
|
||||
<?= $this->Text->autoParagraph(h($item->description)); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column large-3 medium-3 small-3 text-center">
|
||||
<div class="cat-desc">
|
||||
<a href="#" class="button large radius">Hot+1</a>
|
||||
<br> <?= $this->Number->format($item->hot) ?> <br>
|
||||
<a href="#" class="button large radius">Get some <?= h($item->name) ?> !</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php $counter++;?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="large-1 medium-1 columns"><br></div>
|
||||
|
@ -1,7 +1,9 @@
|
||||
|
||||
<nav class="large-3 medium-4 columns" id="actions-sidebar">
|
||||
<ul class="side-nav">
|
||||
<li class="heading"><?= __('Actions') ?></li>
|
||||
<li><?= $this->Html->link(__('New Item'), ['action' => 'add']) ?></li>
|
||||
<li><?= $this->Html->link(__('Show Item List'), ['action' => 'list']) ?></li>
|
||||
<li><?= $this->Html->link(__('List Categories'), ['controller' => 'Categories', 'action' => 'index']) ?></li>
|
||||
<li><?= $this->Html->link(__('New Category'), ['controller' => 'Categories', 'action' => 'add']) ?></li>
|
||||
<li><?= $this->Html->link(__('List Needs'), ['controller' => 'Needs', 'action' => 'index']) ?></li>
|
||||
@ -10,6 +12,7 @@
|
||||
<li><?= $this->Html->link(__('New Offer'), ['controller' => 'Offers', 'action' => 'add']) ?></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<div class="items index large-9 medium-8 columns content">
|
||||
<h3><?= __('Items') ?></h3>
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
@ -48,4 +51,3 @@
|
||||
</ul>
|
||||
<p><?= $this->Paginator->counter() ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,29 +0,0 @@
|
||||
<nav class="large-3 medium-4 columns" id="actions-sidebar">
|
||||
<ul class="side-nav">
|
||||
<li class="heading"><?= __('Actions') ?></li>
|
||||
<li><?= $this->Html->link(__('List Users'), ['action' => 'index']) ?></li>
|
||||
<li><?= $this->Html->link(__('List Needs'), ['controller' => 'Needs', 'action' => 'index']) ?></li>
|
||||
<li><?= $this->Html->link(__('New Need'), ['controller' => 'Needs', 'action' => 'add']) ?></li>
|
||||
<li><?= $this->Html->link(__('List Offers'), ['controller' => 'Offers', 'action' => 'index']) ?></li>
|
||||
<li><?= $this->Html->link(__('New Offer'), ['controller' => 'Offers', 'action' => 'add']) ?></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="users form large-9 medium-8 columns content">
|
||||
<?= $this->Form->create($user) ?>
|
||||
<fieldset>
|
||||
<legend><?= __('Add User') ?></legend>
|
||||
<?php
|
||||
echo $this->Form->input('username');
|
||||
echo $this->Form->input('password');
|
||||
echo $this->Form->input('role');
|
||||
echo $this->Form->input('firstname');
|
||||
echo $this->Form->input('name');
|
||||
echo $this->Form->input('email', ['required'=>false]);
|
||||
echo $this->Form->input('phone');
|
||||
echo $this->Form->input('description');
|
||||
echo $this->Form->input('camp_id', ['options' => $camps]);
|
||||
?>
|
||||
</fieldset>
|
||||
<?= $this->Form->button(__('Submit')) ?>
|
||||
<?= $this->Form->end() ?>
|
||||
</div>
|
@ -1,34 +0,0 @@
|
||||
<nav class="large-3 medium-4 columns" id="actions-sidebar">
|
||||
<ul class="side-nav">
|
||||
<li class="heading"><?= __('Actions') ?></li>
|
||||
<li><?= $this->Form->postLink(
|
||||
__('Delete'),
|
||||
['action' => 'delete', $user->id],
|
||||
['confirm' => __('Are you sure you want to delete # {0}?', $user->id)]
|
||||
)
|
||||
?></li>
|
||||
<li><?= $this->Html->link(__('List Users'), ['action' => 'index']) ?></li>
|
||||
<li><?= $this->Html->link(__('List Needs'), ['controller' => 'Needs', 'action' => 'index']) ?></li>
|
||||
<li><?= $this->Html->link(__('New Need'), ['controller' => 'Needs', 'action' => 'add']) ?></li>
|
||||
<li><?= $this->Html->link(__('List Offers'), ['controller' => 'Offers', 'action' => 'index']) ?></li>
|
||||
<li><?= $this->Html->link(__('New Offer'), ['controller' => 'Offers', 'action' => 'add']) ?></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="users form large-9 medium-8 columns content">
|
||||
<?= $this->Form->create($user) ?>
|
||||
<fieldset>
|
||||
<legend><?= __('Edit User') ?></legend>
|
||||
<?php
|
||||
echo $this->Form->input('username');
|
||||
echo $this->Form->input('password');
|
||||
echo $this->Form->input('role');
|
||||
echo $this->Form->input('firstname');
|
||||
echo $this->Form->input('name');
|
||||
echo $this->Form->input('email');
|
||||
echo $this->Form->input('phone');
|
||||
echo $this->Form->input('description');
|
||||
?>
|
||||
</fieldset>
|
||||
<?= $this->Form->button(__('Submit')) ?>
|
||||
<?= $this->Form->end() ?>
|
||||
</div>
|
@ -1,7 +1,7 @@
|
||||
<div class="log-in-form medium-6 medium-centered large-4 large-centered columns">
|
||||
<?= $this->Form->create($user) ?>
|
||||
<fieldset>
|
||||
<h4 class="text-center"> Edit your profile (organisation) </h4>
|
||||
<h4 class="text-center"> Edit your profile (organization) </h4>
|
||||
<?php
|
||||
echo $this->Form->input('username');
|
||||
echo $this->Form->input('password');
|
||||
@ -12,7 +12,7 @@
|
||||
echo $this->Form->input('description', ['required'=>false]);
|
||||
?>
|
||||
</fieldset>
|
||||
<a type="submit" class="button expanded">
|
||||
<a type="submit" class="button expanded">
|
||||
<?= $this->Form->button(__('Submit')) ?>
|
||||
</a>
|
||||
<?= $this->Form->end() ?>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<div class="log-in-form medium-6 medium-centered large-4 large-centered columns">
|
||||
<?= $this->Form->create($user) ?>
|
||||
<fieldset>
|
||||
<h4 class="text-center"> Edit your profile </h4>
|
||||
<h4 class="text-center"> Edit your profile (refugee) </h4>
|
||||
<?php
|
||||
echo $this->Form->input('username');
|
||||
echo $this->Form->input('password');
|
||||
@ -12,8 +12,6 @@
|
||||
echo $this->Form->input('description', ['required'=>false]);
|
||||
?>
|
||||
</fieldset>
|
||||
<a type="submit" class="button expanded">
|
||||
<?= $this->Form->button(__('Submit')) ?>
|
||||
</a>
|
||||
<?= $this->Form->submit(__('Submit'), ['class' => 'button']) ?>
|
||||
<?= $this->Form->end() ?>
|
||||
</div>
|
||||
|
@ -193,3 +193,13 @@ div.message.error:before {
|
||||
div.message.hidden {
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.row .square-container {
|
||||
margin-top: 0%;
|
||||
}
|
||||
|
||||
.cat-desc {
|
||||
margin-top: 20%;
|
||||
font-size: 2em;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user