Changeset 79
- Timestamp:
- 10/09/08 14:39:31 (9 months 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)
- trunk/lib/form/JobForm.class.php (modified) (2 diffs)
- trunk/lib/model/Job.php (modified) (7 diffs)
- trunk/lib/utils/SymfoniansTestBrowser.class.php (modified) (1 diff)
- trunk/lib/validator/sfValidatorSchemaLicence.class.php (modified) (1 diff)
- trunk/plugins (modified) (1 prop)
- trunk/test/functional/main/applicationsActionsTest.php (modified) (1 diff)
- trunk/web (modified) (1 prop)
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> trunk/lib/form/JobForm.class.php
r75 r79 9 9 { 10 10 /** 11 * @var array of Company 12 */ 13 protected $userCompanies = array(); 14 15 /** 16 * Constructor 17 * 18 * @param Job $job 19 * @param array $userCompanies 20 */ 21 public function __construct(Job $job, $options = array(), $CSRFSecret = null) 22 { 23 if (isset($options['userCompanies'])) 24 { 25 $this->userCompanies = $options['userCompanies']; 26 unset($options['userCompanies']); 27 } 28 29 parent::__construct($job, $options, $CSRFSecret); 30 } 31 32 /** 11 33 * Form configuration 12 34 * … … 14 36 public function configure() 15 37 { 38 // Unset unused widgets 39 unset($this['created_at'], 40 $this['updated_at'], 41 $this['contact_id'], 42 $this['slug']); 43 44 $this->initWidgets(); 45 $this->initValidators(); 46 } 47 48 /** 49 * Intitialize widgets 50 * 51 */ 52 public function initWidgets() 53 { 54 $this->widgetSchema['country'] = new ExtendedWidgetFormI18nSelectCountry(array('culture' => $this->culture, 'add_label_option' => __('Select a country'))); 55 $this->widgetSchema['expires_at'] = new sfWidgetFormI18nDate(array('culture' => $this->culture)); 56 } 57 58 /** 59 * Initialize validators 60 * 61 */ 62 public function initValidators() 63 { 64 $this->validatorSchema['country'] = new sfValidatorI18nChoiceCountry(array('culture' => $this->culture, 'required' => false)); 65 $this->validatorSchema['expires_at'] = new sfValidatorDate(array('required' => false)); 16 66 } 17 67 } trunk/lib/model/Job.php
r49 r79 4 4 * 5 5 * @package lib.model 6 */ 6 */ 7 7 class Job extends BaseJob 8 8 { 9 9 10 10 protected $place = null; 11 11 12 12 public function getCountryName() 13 13 { … … 18 18 } 19 19 } 20 20 21 21 public function getIsActive() 22 22 { 23 23 return !$this->getExpiresAt() or $this->getExpiresAt(null) > time(); 24 24 } 25 25 26 26 public function getPlace() 27 27 { … … 56 56 return $this->place; 57 57 } 58 58 59 59 public function getOwnerName() 60 60 { … … 72 72 } 73 73 } 74 74 75 75 public function save($con = null) 76 76 { … … 78 78 $modified = $this->isModified(); 79 79 $affectedRows = parent::save($con); 80 80 81 81 if ($this->getCompanyId() && !$this->getCompany()->getAllowContact()) 82 82 { 83 83 $this->getCompany()->setAllowContact(true); 84 84 $this->getCompany()->save(); 85 //sfContext::getInstance()->getLogger()->info(sprintf('Company "%s" has now email contact enabled',86 // $this->getCompany()->getName()));87 85 } 88 86 89 87 // Create "company created" event object 90 88 if ($modified) … … 116 114 $event->save(); 117 115 } 118 116 119 117 return $affectedRows; 120 118 } … … 125 123 'to' => JobPeer::SLUG); 126 124 127 sfPropelBehavior::add('Job', 128 array('sfPropelActAsSluggableBehavior' => 129 array('columns' => $columns_map, 130 'separator' => '-', 125 sfPropelBehavior::add('Job', 126 array('sfPropelActAsSluggableBehavior' => 127 array('columns' => $columns_map, 128 'separator' => '-', 131 129 'permanent' => true), 132 'sfPropelActAsLocalizableBehavior' => 130 'sfPropelActAsLocalizableBehavior' => 133 131 array('location_getter' => 'getPlace'))); 134 132 trunk/lib/utils/SymfoniansTestBrowser.class.php
r75 r79 157 157 { 158 158 self::$test->comment('Loading fixtures...'); 159 160 $t = new sfPropelLoadDataTask(self::$configuration->getEventDispatcher(), new sfAnsiColorFormatter()); 161 $t->run(array('application' => self::$configuration->getApplication())); 162 163 self::$test->comment('Fixtures loaded.'); 159 160 try 161 { 162 $t = new sfPropelLoadDataTask(self::$configuration->getEventDispatcher(), new sfAnsiColorFormatter()); 163 $t->run(array('application' => self::$configuration->getApplication())); 164 165 self::$test->comment('Fixtures loaded.'); 166 } 167 catch (PropelException $e) 168 { 169 self::$test->fail('Unable to load fixtures: '.$e->getMessage()); 170 } 164 171 } 165 172 trunk/lib/validator/sfValidatorSchemaLicence.class.php
r75 r79 13 13 protected function doClean($values) 14 14 { 15 //parent::doClean($values);16 17 $errorSchema = new sfValidatorErrorSchema($this);18 19 15 if ($values['is_opensource'] && 0 === strlen(trim($values['licence']))) 20 16 { trunk/plugins
- Property svn:externals changed from
sfPropelAlternativeSchemaPlugin http://svn.symfony-project.com/plugins/sfPropelAlternativeSchemaPlugin
sfWebBrowserPlugin http://svn.symfony-project.com/plugins/sfWebBrowserPlugin
sfPagerNavigationPlugin http://svn.symfony-project.com/plugins/sfPagerNavigationPlugin
sfFeed2Plugin http://svn.symfony-project.com/plugins/sfFeed2Plugin
sfPropelMigrationsLightPlugin http://svn.symfony-project.com/plugins/sfPropelMigrationsLightPlugin/trunk/
sfSwiftPlugin http://svn.symfony-project.com/plugins/sfSwiftPlugin/trunk
sfLucenePlugin http://svn.symfony-project.com/plugins/sfLucenePlugin/branches/1.1
sfGuardPlugin http://svn.symfony-project.com/plugins/sfGuardPlugin/branches/1.1
sfFormExtraPlugin http://svn.symfony-project.com/plugins/sfFormExtraPlugin/
sfPropelActAsTaggableBehaviorPlugin http://svn.symfony-project.com/plugins/sfPropelActAsTaggableBehaviorPlugin/trunk/
to
sfPropelAlternativeSchemaPlugin http://svn.symfony-project.com/plugins/sfPropelAlternativeSchemaPlugin
sfWebBrowserPlugin http://svn.symfony-project.com/plugins/sfWebBrowserPlugin
sfPagerNavigationPlugin http://svn.symfony-project.com/plugins/sfPagerNavigationPlugin
sfFeed2Plugin http://svn.symfony-project.com/plugins/sfFeed2Plugin
sfPropelMigrationsLightPlugin http://svn.symfony-project.com/plugins/sfPropelMigrationsLightPlugin/trunk/
sfSwiftPlugin http://svn.symfony-project.com/plugins/sfSwiftPlugin/trunk
sfGuardPlugin http://svn.symfony-project.com/plugins/sfGuardPlugin/branches/1.1
sfFormExtraPlugin http://svn.symfony-project.com/plugins/sfFormExtraPlugin/
sfPropelActAsTaggableBehaviorPlugin http://svn.symfony-project.com/plugins/sfPropelActAsTaggableBehaviorPlugin/trunk/
- Property svn:externals changed from
trunk/test/functional/main/applicationsActionsTest.php
r75 r79 173 173 isRequestParameter('action', 'home')-> 174 174 isRequestParameter('page', 2)-> 175 checkResponseElement('p.navigation a', '/1/')->175 checkResponseElement('p.navigation', '/1/')-> 176 176 click('1')-> 177 177 isStatusCode(200)-> trunk/web
- Property svn:externals changed from
sf http://svn.symfony-project.com/branches/1.1/data/web/sf
sfLucenePlugin http://svn.symfony-project.com/plugins/sfLucenePlugin/branches/1.1/web
to
sf http://svn.symfony-project.com/branches/1.1/data/web/sf
- Property svn:externals changed from
