Skip to content

Commit

Permalink
[Jobs] deny to create a job if no email is given, first correction
Browse files Browse the repository at this point in the history
(#5806)
  • Loading branch information
mathias-weitz-cross-solutions committed May 11, 2015
1 parent d3dcc32 commit ec40971
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
7 changes: 4 additions & 3 deletions module/Jobs/src/Jobs/Controller/ManageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ protected function save($parameter = array())
$serviceLocator = $this->getServiceLocator();
$user = $this->auth()->getUser();
if (empty($user->info->email)) {
return $this->getErrorViewModel('no-parent');
return $this->getErrorViewModel('no-parent', array('cause' => 'noEmail'));
}
$translator = $serviceLocator->get('translator');
/** @var \Zend\Http\Request $request */
$request = $this->getRequest();
$isAjax = $request->isXmlHttpRequest();
Expand Down Expand Up @@ -424,11 +425,11 @@ public function templateAction() {
return new JsonModel(array());
}

protected function getErrorViewModel($script)
protected function getErrorViewModel($script, $parameter = array())
{
$this->getResponse()->setStatusCode(500);

$model = new ViewModel();
$model = new ViewModel($parameter);
$model->setTemplate("jobs/error/$script");

return $model;
Expand Down
20 changes: 15 additions & 5 deletions module/Jobs/view/error/no-parent.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,20 @@

<h1><?php echo $this->translate('Sorry, you may not create jobs.'); ?></h1>

<p><?php echo sprintf(
$this->translate('Before you are able to create jobs, you have to %screate your main organization%s first.'),
'<a href="' . $this->url('lang/my-organization', array(), true) . '">',
'</a>'
)
<p><?php
if ($this->cause == 'noEmail') {
echo sprintf(
$this->translate('Before you are able to create jobs, you have to %screate an email%s first.'),
'<a href="' . $this->url('lang/my', array('action' => 'profile'), true) . '">',
'</a>'
);
}
else {
echo sprintf(
$this->translate('Before you are able to create jobs, you have to %screate your main organization%s first.'),
'<a href="' . $this->url('lang/my-organization', array(), true) . '">',
'</a>'
);
}
?></p>

0 comments on commit ec40971

Please sign in to comment.