Changeset 79 for trunk/apps
- Timestamp:
- 10/09/08 14:39:31 (2 years ago)
- Files:
-
- trunk/apps/main/config/filters.yml (modified) (1 diff)
- trunk/apps/main/config/routing.yml (modified) (1 diff)
- trunk/apps/main/lib/myUser.class.php (modified) (2 diffs)
- trunk/apps/main/modules/jobs/actions/actions.class.php (modified) (6 diffs)
- trunk/apps/main/modules/jobs/templates/_form.php (modified) (5 diffs)
- trunk/apps/main/modules/jobs/templates/addSuccess.php (modified) (1 diff)
- trunk/apps/main/modules/jobs/templates/editSuccess.php (modified) (1 diff)
- trunk/apps/main/modules/mail/actions/actions.class.php (modified) (5 diffs)
- trunk/apps/main/templates/_messages.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/apps/main/config/filters.yml
r48 r79 12 12 class: conditionalCacheFilter 13 13 14 highlight:15 class: sfLuceneHighlightFilter14 #highlight: 15 # class: sfLuceneHighlightFilter 16 16 17 17 cache: ~ trunk/apps/main/config/routing.yml
r75 r79 203 203 job_add: 204 204 url: /job/add 205 param: { module: jobs, action: add}205 param: { module: jobs, action: edit } 206 206 207 207 job_edit: trunk/apps/main/lib/myUser.class.php
r66 r79 27 27 return parent::getGuardUser(); 28 28 } 29 29 30 30 /** 31 * Returns current session storage instance 31 * Returns current session storage instance 32 32 * 33 33 * @return sfSessionStorage … … 36 36 { 37 37 return $this->storage; 38 } 39 40 /** 41 * Retrieves related user companies 42 * 43 * @return array 44 */ 45 public function getRelatedCompanies() 46 { 47 return $this->getGuardUser()->getCompaniesArray($this->isAdmin() ? 'all' : 'related'); 38 48 } 39 49 trunk/apps/main/modules/jobs/actions/actions.class.php
r75 r79 9 9 { 10 10 11 public function executeAdd() 12 { 13 $this->job = new Job(); 14 if ($this->getRequest()->getMethod() == sfRequest::POST) 15 { 16 $this->updateFromRequest(); 11 public function executeEdit($request) 12 { 13 if (!is_null($request->getParameter('slug'))) 14 { 15 $this->job = $this->getFromSlug(); 16 17 if (!$this->getUser()->isAdmin() && $this->job->getContactId() != $this->getUser()->getId()) 18 { 19 $this->getUser()->setFlash('warning', $this->__('You are not allowed to edit this record')); 20 $this->redirect('@job_page?slug='.$this->job->getSlug()); 21 } 22 } 23 else 24 { 25 $this->job = new Job(); 26 $this->setTemplate('add'); 27 } 28 29 $this->job->setContactId($this->getUser()->getId()); 30 $this->form = new JobForm($this->job, array('userCompanies' => $this->getUser()->getRelatedCompanies())); 31 32 if ($request->isMethod('post') && $this->form->bindAndSave($request->getParameter('job'))) 33 { 17 34 parent::purgeObjectRelatedCache($this->job); 18 $this->getUser()->setFlash('notice', $this->getI18N()->__('Job offer published')); 19 $this->redirect('@job_page?slug='.$this->job->getSlug()); 20 } 21 } 22 23 public function executeEdit() 24 { 25 $this->job = $this->getFromSlug(); 26 27 if (!$this->getUser()->isAdmin() && $this->job->getContactId() != $this->getUser()->getId()) 28 { 29 $this->getUser()->setFlash('warning', $this->getI18N()->__('You are not allowed to edit this record')); 30 $this->redirect('@job_page?slug='.$this->job->getSlug()); 31 } 32 33 if ($this->getRequest()->getMethod() == sfRequest::POST) 34 { 35 $this->updateFromRequest(); 36 parent::purgeObjectRelatedCache($this->job); 37 $this->getUser()->setFlash('notice', $this->getI18N()->__('Job offer has been updated')); 38 $this->redirect('@job_page?slug='.$this->job->getSlug()); 35 36 $this->getUser()->setFlash('notice', $this->__('Job offer has been updated')); 37 $this->redirect('@job_page?slug='.$this->form->getObject()->getSlug()); 39 38 } 40 39 } … … 48 47 if (!is_null($this->job->getExpiresAt()) && $this->job->getExpiresAt(null) < time()) 49 48 { 50 $this->getUser()->setFlash('warning', $this-> getI18N()->__('This job offer is perempted'));49 $this->getUser()->setFlash('warning', $this->__('This job offer is perempted')); 51 50 } 52 51 } … … 57 56 if (!$this->getUser()->isAdmin() && $this->getUser()->getId() != $this->job->getContactId()) 58 57 { 59 $this->getUser()->setFlash('warning', $this-> getI18N()->__('You are not allowed to delete this job offer'));58 $this->getUser()->setFlash('warning', $this->__('You are not allowed to delete this job offer')); 60 59 } 61 60 else … … 63 62 parent::purgeObjectRelatedCache($this->job); 64 63 $this->job->delete(); 65 $this->getUser()->setFlash('notice', $this-> getI18N()->__('Job offer has been deleted'));64 $this->getUser()->setFlash('notice', $this->__('Job offer has been deleted')); 66 65 } 67 66 $this->redirect('@jobs_home'); … … 150 149 } 151 150 152 public function handleErrorAdd()153 {154 $this->job = new Job();155 return sfView::SUCCESS;156 }157 158 public function handleErrorEdit()159 {160 $this->job = $this->getFromSlug();161 return sfView::SUCCESS;162 }163 164 151 protected function renderHomeAsFeed(Criteria $c) 165 152 { … … 221 208 $this->feed = $feed; 222 209 } 223 224 protected function updateFromRequest()225 {226 $job_data = $this->getRequestParameter('job', array());227 if (!isset($job_data['teleworking']))228 {229 $job_data['teleworking'] = false;230 }231 if (isset($job_data['expires_at']) && $job_data['expires_at'] == '')232 {233 unset($job_data['expires_at']);234 }235 try236 {237 if (!$this->getUser()->isAdmin() or ($this->getUser()->isAdmin() && $this->job->isNew()))238 {239 $this->job->setContactId($this->getUser()->getId());240 }241 $this->job->fromArray($job_data, BasePeer::TYPE_FIELDNAME);242 return $this->job->save();243 }244 catch (Exception $e)245 {246 $this->getRequest()->setError('errors', $this->getI18N()->__('Unable to save this record'));247 sfContext::getInstance()->getLogger()->err('Blocking error at job save time: '.$e->getMessage());248 return sfView::SUCCESS;249 }250 }251 210 } trunk/apps/main/modules/jobs/templates/_form.php
r64 r79 10 10 </p> 11 11 12 <form action="<?php echo url_for($form_route) ?>" method="post" enctype="multipart/form-data">12 <form action="<?php echo url_for($form_route) ?>" method="post"> 13 13 <div class="fiftypercent"> 14 14 <fieldset> 15 15 <legend><?php echo __('Basic informations') ?></legend> 16 16 <div class="form-row required"> 17 < label for="title"><?php echo __('Job title') ?></label>18 <?php echo object_input_tag($job, 'getTitle', 'name=job[title]', $sf_params->get('job[title]')) ?>19 <?php echo form_error('job[title]') ?>17 <?php echo $form['title']->renderLabel(__('Job title')) ?> 18 <?php echo $form['title']->render() ?> 19 <?php echo $form['title']->renderError() ?> 20 20 </div> 21 21 <div class="form-row required"> 22 < label for="summary"><?php echo __('Summary') ?></label>23 <?php echo object_textarea_tag($job, 'getSummary', 'name=job[summary] rows=13', $sf_params->get('job[summary]')) ?>24 <?php echo form_error('job[summary]') ?>22 <?php echo $form['summary']->renderLabel(__('Summary')) ?> 23 <?php echo $form['summary']->render() ?> 24 <?php echo $form['summary']->renderError() ?> 25 25 </div> 26 26 <div class="form-row"> 27 < label for="budget"><?php echo __('Budget') ?></label>28 <?php echo object_input_tag($job, 'getBudget', 'name=job[budget]', $sf_params->get('job[budget]')) ?>29 <?php echo form_error('job[budget]') ?>27 <?php echo $form['budget']->renderLabel(__('Budget')) ?> 28 <?php echo $form['budget']->render() ?> 29 <?php echo $form['budget']->renderError() ?> 30 30 </div> 31 31 <div class="form-row"> 32 <?php echo object_checkbox_tag($job, 'getTeleworking', 'name=job[teleworking]', $sf_params->get('job[teleworking]')) ?> 33 <label for="teleworking" class="inline"> 34 <?php echo __('Possible teleworking?') ?> 35 </label> 36 <?php echo form_error('job[teleworking]') ?> 32 <?php echo $form['teleworking']->render() ?> 33 <?php echo $form['teleworking']->renderLabel(__('Possible teleworking?'), array('class' => 'inline')) ?> 34 <?php echo $form['teleworking']->renderError() ?> 37 35 </div> 38 36 </fieldset> … … 42 40 <legend><?php echo __('Contact informations') ?></legend> 43 41 <div class="form-row"> 44 <label for="company_id"><?php echo __('Is the job offered by a company you\'re related to?') ?></label> 45 <?php echo select_tag('job[company_id]', 46 options_for_select($sf_user->getGuardUser()->getCompaniesArray($sf_user->isAdmin() ? 'all' : 'related'), 47 $sf_request->getParameter('job[company_id]', $job->getCompanyId()), 48 array('include_custom' => __('No')))) ?> 49 <?php echo form_error('job[company_id]') ?> 42 <?php echo $form['company_id']->renderLabel(__('Is the job offered by a company you\'re related to?')) ?> 43 <?php echo $form['company_id']->render() ?> 44 <?php echo $form['company_id']->renderError() ?> 50 45 <p class="form-help"> 51 46 <?php echo __('If you don\'t select a company you will be directly contacted by applicants.') ?> 52 47 <?php echo __('Your company is not listed above? %add_link%.', 53 array('%add_link%' => link_to(__('Add it now'), 54 '@company_add'))) ?> 48 array('%add_link%' => link_to(__('Add it now'), '@company_add'))) ?> 55 49 </p> 56 50 </div> … … 61 55 <legend><?php echo __('Localization') ?></legend> 62 56 <div class="form-row"> 63 < label for="city"><?php echo __('City') ?></label>64 <?php echo object_input_tag($job, 'getCity', 'name=job[city]', $sf_params->get('job[city]')) ?>65 <?php echo form_error('job[city]') ?>57 <?php echo $form['city']->renderLabel(__('City')) ?> 58 <?php echo $form['city']->render() ?> 59 <?php echo $form['city']->renderError() ?> 66 60 <div class="form_help"> 67 61 <?php echo __('Please enter only one city name. If you have job offers on distinct locations, please post one job offer per location.') ?> … … 69 63 </div> 70 64 <div class="form-row"> 71 < label for="state"><?php echo __('State (if applicable)') ?></label>72 <?php echo object_input_tag($job, 'getState', 'name=job[state]', $sf_params->get('job[state]')) ?>73 <?php echo form_error('job[state]') ?>65 <?php echo $form['state']->renderLabel(__('State (if applicable)')) ?> 66 <?php echo $form['state']->render() ?> 67 <?php echo $form['state']->renderError() ?> 74 68 </div> 75 69 <div class="form-row"> 76 < label for="country"><?php echo __('Country') ?></label>77 <?php echo object_select_country_tag($job, 'getCountry', 'name=job[country] include_custom='.__('Select a country'), $sf_params->getRawValue()->get('job[country]')) ?>78 <?php echo form_error('job[country]') ?>70 <?php echo $form['country']->renderLabel(__('Country')) ?> 71 <?php echo $form['country']->render() ?> 72 <?php echo $form['country']->renderError() ?> 79 73 </div> 80 74 <div class="form-row"> 81 <label for="expires_at"><?php echo __('Job offer expiration date (yyyy-mm-dd)') ?></label> 82 <?php echo object_input_date_tag($job, 'getExpiresAt', 'name=job[expires_at] format=Y-MM-dd rich=true class=date_select', $sf_params->get('job[expires_at]')) ?> 83 <?php echo form_error('job[expires_at]') ?> 75 <div class="date_select"> 76 <?php echo $form['expires_at']->renderLabel(__('Job offer expiration date (yyyy-mm-dd)')) ?> 77 <?php echo $form['expires_at']->render() ?> 78 <?php echo $form['expires_at']->renderError() ?> 79 </div> 84 80 </div> 85 81 </fieldset> … … 87 83 <div class="form-row" style="text-align:center;clear:left;"> 88 84 <p> 89 <?php echo submit_tag($submit_label) ?> 85 <?php echo $form['_csrf_token'] ?> 86 <?php echo $form['id'] ?> 87 <input type="submit" value="<?php echo $submit_label ?>"/> 90 88 </p> 91 89 </div> trunk/apps/main/modules/jobs/templates/addSuccess.php
r2 r79 5 5 6 6 <?php include_partial('jobs/form', 7 array('job' => $job, 7 array('job' => $form->getObject(), 8 'form' => $form, 8 9 'title' => $page_title, 9 10 'form_route' => '@job_add', trunk/apps/main/modules/jobs/templates/editSuccess.php
r2 r79 5 5 6 6 <?php include_partial('jobs/form', 7 array('job' => $job, 7 array('job' => $form->getObject(), 8 'form' => $form, 8 9 'title' => $page_title, 9 'form_route' => '@job_edit?slug='.$ job->getSlug(),10 'form_route' => '@job_edit?slug='.$form->getObject()->getSlug(), 10 11 'submit_label' => __('Update this job offer'))) ?> trunk/apps/main/modules/mail/actions/actions.class.php
r56 r79 8 8 class mailActions extends myActions 9 9 { 10 10 11 11 public function executeContact(sfWebRequest $request) 12 12 { 13 13 $this->message = $request->getAttribute('message'); 14 14 } 15 15 16 16 public function executeForgotPassword(sfWebRequest $request) 17 17 { 18 18 $this->password = $request->getAttribute('password'); 19 19 } 20 20 21 21 public function executeRegister(sfWebRequest $request) 22 22 { … … 24 24 $this->activation = $request->getAttribute('activation'); 25 25 } 26 26 27 27 public function executeResendActivation(sfWebRequest $request) 28 28 { 29 29 $this->activation = $request->getAttribute('activation'); 30 30 } 31 31 32 32 public function executeCompanyContact(sfWebRequest $request) 33 33 { … … 36 36 $this->company = $request->getAttribute('company'); 37 37 } 38 38 39 39 public function executePersonContact(sfWebRequest $request) 40 40 { … … 43 43 $this->message = $request->getAttribute('message'); 44 44 } 45 45 46 46 public function executeRecommendationReceived(sfWebRequest $request) 47 47 { … … 50 50 $this->recommendation = $request->getAttribute('recommendation'); 51 51 } 52 52 53 public function executeTest() 54 { 55 56 } 57 53 58 } trunk/apps/main/templates/_messages.php
r75 r79 6 6 <?php echo $activeForm->renderGlobalErrors() ?> 7 7 </div> 8 <?php elseif (count($activeForm->getErrorSchema()) ): ?>8 <?php elseif (count($activeForm->getErrorSchema()) > 0): ?> 9 9 <div class="global-form-errors"> 10 10 <h4><?php echo __('Errors have been encountered') ?></h4>
