public function executeDelete(sfWebRequest $request) { $request->checkCSRFProtection(); $this->forward404Unless($JobeetJob = JobeetJobPeer::retrieveByPk($request->getParameter('id')), sprintf('Object JobeetJob does not exist (%s).', $request->getParameter('id'))); $JobeetJob->delete(); $this->redirect('job/index'); }
public function executeListDeleteNeverActivated(sfWebRequest $request) { $nb = JobeetJobPeer::cleanup(60); if ($nb) { $this->getUser()->setFlash('notice', sprintf('%d never activated jobs have been deleted successfully.', $nb)); } else { $this->getUser()->setFlash('notice', 'No job to delete.'); } $this->redirect('jobeet_job'); }
public function executeBatchExtend(sfWebRequest $request) { $ids = $request->getParameter('ids'); $jobs = JobeetJobPeer::retrieveByPks($ids); foreach ($jobs as $job) { $job->extend(true); } $this->getUser()->setFlash('notice', 'El trabajo seleccionado fue extendido satisfactoriamente'); $this->redirect('@jobeet_job'); }
/** * Returns the number of related JobeetJob objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related JobeetJob objects. * @throws PropelException */ public function countJobeetJobs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(JobeetCategoryPeer::DATABASE_NAME); } else { $criteria = clone $criteria; } if ($distinct) { $criteria->setDistinct(); } $count = null; if ($this->collJobeetJobs === null) { if ($this->isNew()) { $count = 0; } else { $criteria->add(JobeetJobPeer::CATEGORY_ID, $this->id); $count = JobeetJobPeer::doCount($criteria, $con); } } else { // criteria has no effect for a new object if (!$this->isNew()) { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return count of the collection. $criteria->add(JobeetJobPeer::CATEGORY_ID, $this->id); if (!isset($this->lastJobeetJobCriteria) || !$this->lastJobeetJobCriteria->equals($criteria)) { $count = JobeetJobPeer::doCount($criteria, $con); } else { $count = count($this->collJobeetJobs); } } else { $count = count($this->collJobeetJobs); } } $this->lastJobeetJobCriteria = $criteria; return $count; }
protected function addSortCriteria($criteria) { if (array(null, null) == ($sort = $this->getSort())) { return; } $column = JobeetJobPeer::translateFieldName($sort[0], BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME); if ('asc' == $sort[1]) { $criteria->addAscendingOrderByColumn($column); } else { $criteria->addDescendingOrderByColumn($column); } }
<?php include dirname(__FILE__) . '/../../bootstrap/Propel.php'; $t = new lime_test(3); $t->comment('->getCompanySlug()'); $job = JobeetJobPeer::doSelectOne(new Criteria()); $t->is($job->getCompanySlug(), Jobeet::slugify($job->getCompany()), '->getCompanySlug() return the slug for the company'); $t->comment('->save()'); $job = create_job(); $job->save(); $expiresAt = date('Y-m-d', time() + 86400 * sfConfig::get('app_active_days')); $t->is($job->getExpiresAt('Y-m-d'), $expiresAt, '->save() updates expires_at if not set'); $job = create_job(array('expires_at' => '2008-08-08')); $job->save(); $t->is($job->getExpiresAt('Y-m-d'), '2008-08-08', '->save() does not update expires_at if set'); function create_job($defaults = array()) { static $category = null; if (is_null($category)) { $category = JobeetCategoryPeer::doSelectOne(new Criteria()); } $job = new JobeetJob(); $job->fromArray(array_merge(array('category_id' => $category->getId(), 'company' => 'Sensio Labs', 'position' => 'Senior Tester', 'location' => 'Paris, France', 'description' => 'Testing is fun', 'how_to_apply' => 'Send e-Mail', 'email' => '*****@*****.**', 'token' => rand(1111, 9999), 'is_activated' => true), $defaults), BasePeer::TYPE_FIELDNAME); return $job; }
public function getJobByPosition($position) { $criteria = new Criteria(); $criteria->add(JobeetJobPeer::POSITION, $position); return JobeetJobPeer::doSelectOne($criteria); }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(JobeetJobPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(JobeetJobPeer::DATABASE_NAME); $criteria->add(JobeetJobPeer::ID, $pks, Criteria::IN); $objs = JobeetJobPeer::doSelect($criteria, $con); } return $objs; }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's phpname (e.g. 'AuthorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = JobeetJobPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setCategoryId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setType($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setCompany($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setLogo($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setUrl($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setPosition($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setLocation($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setDescription($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setHowToApply($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setToken($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setIsPublic($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { $this->setIsActivated($arr[$keys[12]]); } if (array_key_exists($keys[13], $arr)) { $this->setEmail($arr[$keys[13]]); } if (array_key_exists($keys[14], $arr)) { $this->setExpiresAt($arr[$keys[14]]); } if (array_key_exists($keys[15], $arr)) { $this->setCreatedAt($arr[$keys[15]]); } if (array_key_exists($keys[16], $arr)) { $this->setUpdatedAt($arr[$keys[16]]); } }
protected function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); $nb = JobeetJobPeer::cleanup($options['days']); $this->logSection('propel', sprintf('Removed %d stale jobs', $nb)); }
public function getActiveJobsCriteria() { $criteria = new Criteria(); $criteria->add(JobeetJobPeer::CATEGORY_ID, $this->getId()); return JobeetJobPeer::addActiveJobsCriteria($criteria); }