public function executeDelete(sfWebRequest $request) { $request->checkCSRFProtection(); $this->forward404Unless($activity = ActivityPeer::retrieveByPk($request->getParameter('id')), sprintf('Object activity does not exist (%s).', $request->getParameter('id'))); $activity->delete(); $this->redirect('activity/index'); }
protected function doClean($values) { if (is_null($values)) { $values = array(); } if (!is_array($values)) { throw new InvalidArgumentException('You must pass an array parameter to the clean() method'); } $duration = $values['duration']; if (is_null($duration)) { return $values; } $date = $values['date']; if (is_null($date)) { return $values; } $date = strtotime($date); $activity = ActivityPeer::retrieveByPK($values['Activity_id']); $roomId = isset($values['Room_id']) ? $values['Room_id'] : null; $reservation_id = isset($values['id']) ? $values['id'] : null; if (!is_null($activity)) { if (!is_null($values['User_id'])) { $user = UserPeer::retrieveByPK($values['User_id']); $subscriptions = $user->getActiveSubscriptions($date, $activity->getId(), $roomId); } else { if (!is_null($values['Card_id'])) { $card = CardPeer::retrieveByPK($values['Card_id']); $subscriptions = $card->getActiveSubscriptions($date, $activity->getId(), $roomId); } else { /* Trick to enforce potential new login objects (Like User or Card) to update this function */ /* This way, the validator will always throw. */ $subscriptions = null; } } $valid = false; $maxAvailableDuration = 0; if (!empty($subscriptions)) { foreach ($subscriptions as $subscription) { $remainingCredit = $subscription->getRemainingCredit($duration, $reservation_id); if ($remainingCredit >= 0) { $valid = true; break; } else { if ($maxAvailableDuration < abs($remainingCredit)) { /* We keep the maximum duration number for the reservation */ $maxAvailableDuration = abs($remainingCredit); } } } } if (!$valid) { $error = new sfValidatorError($this, 'invalid', array('remaining_credit' => $maxAvailableDuration)); if ($this->getOption('throw_global_error')) { throw $error; } throw new sfValidatorErrorSchema($this, array('duration' => $error)); } } return $values; }
protected function doClean($values) { if (is_null($values)) { $values = array(); } if (!is_array($values)) { throw new InvalidArgumentException('You must pass an array parameter to the clean() method'); } if (is_null($values[$this->getOption('members_count_field')]) || is_null($values[$this->getOption('guests_count_field')])) { return $values; } $activity = ActivityPeer::retrieveByPK($values['Activity_id']); if (!is_null($activity)) { $needed_count = $activity->getMinimumOccupation() - 1; $granted_count = $activity->getMaximumOccupation() - 1; $people_count = $values[$this->getOption('members_count_field')] + $values[$this->getOption('guests_count_field')]; if ($people_count < $needed_count) { $error = new sfValidatorError($this, 'people_missing', array('people_count' => $people_count, 'needed_count' => $needed_count)); if ($this->getOption('throw_global_error')) { throw $error; } throw new sfValidatorErrorSchema($this, array($this->getOption('members_count_field') => $error)); } if ($people_count > $granted_count) { $error = new sfValidatorError($this, 'too_much_people', array('people_count' => $people_count, 'granted_count' => $granted_count)); if ($this->getOption('throw_global_error')) { throw $error; } throw new sfValidatorErrorSchema($this, array($this->getOption('members_count_field') => $error)); } } return $values; }
public function getActivities() { $c = new Criteria(); $c->addJoin(ActivityPeer::ID, ActivityHasFeaturePeer::ACTIVITY_ID); $c->add(ActivityHasFeaturePeer::FEATURE_ID, $this->getId(), Criteria::EQUAL); $c->addAscendingOrderByColumn(ActivityPeer::NAME); return ActivityPeer::doSelect($c); }
public function executeAjaxIndex(sfWebRequest $request) { $exclude_ids = $this->getUser()->getAttribute('hidden_activity', array(), 'person'); $c = new Criteria(); $c->add(ActivityPeer::ID, $exclude_ids, Criteria::NOT_IN); $c->addDescendingOrderByColumn(ActivityPeer::CREATED_AT); $c->setLimit(sfConfig::get('app_max_recent_activity', 10)); $this->activities = ActivityPeer::doSelect($c); }
protected function doClean($values) { if (is_null($values)) { $values = array(); } if (!is_array($values)) { throw new InvalidArgumentException('You must pass an array parameter to the clean() method'); } $duration = $values['duration']; if (is_null($duration)) { return $values; } $date = $values['date']; if (is_null($date)) { return $values; } $date = strtotime($date); $activity = ActivityPeer::retrieveByPK($values['Activity_id']); $roomId = isset($values['Room_id']) ? $values['Room_id'] : null; $reservation_id = isset($values['id']) ? $values['id'] : null; if (!is_null($activity)) { if (!is_null($values['User_id'])) { $user = UserPeer::retrieveByPK($values['User_id']); $hours_per_week = $user->getHoursPerWeek($activity->getId(), $roomId); $total = $user->countMinutesPerWeek($activity->getId(), $roomId, $date, $reservation_id); } else { if (!is_null($values['Card_id'])) { $card = CardPeer::retrieveByPK($values['Card_id']); $hours_per_week = $card->getHoursPerWeek($activity->getId(), $roomId); $total = $card->countMinutesPerWeek($activity->getId(), $roomId, $date, $reservation_id); } else { /* Trick to enforce potential new login objects (Like User or Card) to update this function */ /* This way, the validator will always throw. */ $hours_per_week = null; $total = null; } } if (empty($total)) { $total = 0; } if ($hours_per_week < 0 || is_null($hours_per_week)) { $error = new sfValidatorError($this, 'no_hours_per_week', array()); if ($this->getOption('throw_global_error')) { throw $error; } throw new sfValidatorErrorSchema($this, array('duration' => $error)); } if ($total + $duration > $hours_per_week * 60) { $error = new sfValidatorError($this, 'invalid', array('minutes_per_week' => $hours_per_week * 60, 'total' => $total)); if ($this->getOption('throw_global_error')) { throw $error; } throw new sfValidatorErrorSchema($this, array('duration' => $error)); } } return $values; }
public function executeCreate(sfWebRequest $request) { $this->forward404Unless($request->isMethod('post')); $this->forward404Unless($this->activity = ActivityPeer::retrieveByPk($request->getParameter('activityId')), sprintf('Object activity does not exist (%s).', $request->getParameter('activityId'))); $this->form = new ReservationreasonForm(); $this->processForm($request, $this->form); $this->form->setDefaultActivity($this->activity); $this->setTemplate('new'); }
public function hasCapacityIssue() { if (is_null($this->getCapacity())) { return false; } $c = new Criteria(); $c->add(ActivityPeer::MAXIMUM_OCCUPATION, $this->getCapacity(), Criteria::GREATER_THAN); $c->addJoin(ActivityPeer::ID, RoomHasActivityPeer::ACTIVITY_ID); $c->addAnd(RoomHasActivityPeer::ROOM_ID, $this->getId(), Criteria::EQUAL); return ActivityPeer::doCount($c) > 0; }
public function executeNavigation() { $this->person = $this->getUser()->getPerson(); $activityId = $this->getUser()->getAttribute('activityId'); if ($this->getUser()->hasActivity($activityId)) { $this->activity = ActivityPeer::retrieveByPk($activityId); } else { $this->activity = null; } $this->usergroup = UsergroupPeer::retrieveByPk($this->getUser()->getAttribute('usergroupId')); $this->user = UserPeer::retrieveByPk($this->getUser()->getAttribute('userId')); }
/** * Wing add edit * CODE:wing_create */ public function executeUpdate(sfWebRequest $request) { #security if (!$this->getUser()->hasCredential(array('Administrator'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getUri()); $this->redirect('dashboard/index'); } if ($request->getParameter('id')) { $this->wing = WingPeer::retrieveByPK($request->getParameter('id')); $this->title = 'Edit Wing'; $success = 'Wing has successfully edited!'; } else { $this->wing = new Wing(); $this->title = 'Add Wing'; $success = 'Wing has successfully created!'; } $this->form = new WingForm($this->wing); if ($request->isMethod('post')) { $this->referer = $request->getReferer(); $this->form->bind($request->getParameter('wing')); if ($this->form->isValid() && $this->form->getValue('name')) { $this->wing->setname($this->form->getValue('name')); $this->wing->setNewsletterAbbreviation($this->form->getValue('newsletter_abbreviation')); $this->wing->setDisplayName($this->form->getValue('display_name')); $this->wing->setState($this->form->getValue('state')); if ($this->wing->isNew()) { $content = $this->getUser()->getName() . ' added new Mission type: ' . $this->wing->getName(); ActivityPeer::log($content); } $this->wing->save(); $this->getUser()->setFlash('success', $success); $this->redirect('wing/index'); } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : 'wing/index'; } $this->wing = $this->wing; }
protected function doClean($values) { if (is_null($values)) { $values = array(); } if (!is_array($values)) { throw new InvalidArgumentException('You must pass an array parameter to the clean() method'); } $date = strtotime($values['date']); $now = time(); if ($date < $now) { return $values; } $activity = ActivityPeer::retrieveByPK($values['Activity_id']); $roomId = isset($values['Room_id']) ? $values['Room_id'] : null; if (!is_null($activity)) { $overall_minimum_delay = $activity->getMinimumDelay(); $overall_minimum_date = $activity->getMinimumDate($now); if (!is_null($values['User_id'])) { $user = UserPeer::retrieveByPK($values['User_id']); $minimum_delay = $user->getMinimumDelay($activity->getId(), $roomId); $minimum_date = $user->getMinimumDate($activity->getId(), $roomId, $now); $maximum_delay = $user->getMaximumDelay($activity->getId(), $roomId); $maximum_date = $user->getMaximumDate($activity->getId(), $roomId, $now); $has_subscription = $user->hasSubscription($activity->getId(), $roomId, $date); } else { if (!is_null($values['Card_id'])) { $card = CardPeer::retrieveByPK($values['Card_id']); $minimum_delay = $card->getMinimumDelay($activity->getId(), $roomId); $minimum_date = $card->getMinimumDate($activity->getId(), $roomId, $now); $maximum_delay = $card->getMaximumDelay($activity->getId(), $roomId); $maximum_date = $card->getMaximumDate($activity->getId(), $roomId, $now); $has_subscription = $card->hasSubscription($activity->getId(), $roomId, $date); } else { /* Trick to enforce potential new login objects (Like User or Card) to update this function */ /* This way, the validator will always throw. */ $has_subscription = false; $minimum_delay = null; $maximum_delay = null; } } if (!$has_subscription) { $error = new sfValidatorError($this, 'no_subscription', array()); if ($this->getOption('throw_global_error')) { throw $error; } throw new sfValidatorErrorSchema($this, array('date' => $error)); } if ($date < $overall_minimum_date) { $error = new sfValidatorError($this, 'minimum_delay', array('minimum_delay' => $overall_minimum_delay)); if ($this->getOption('throw_global_error')) { throw $error; } throw new sfValidatorErrorSchema($this, array('date' => $error)); } if ($maximum_delay < 0 || is_null($maximum_delay)) { $error = new sfValidatorError($this, 'no_delay', array()); if ($this->getOption('throw_global_error')) { throw $error; } throw new sfValidatorErrorSchema($this, array('date' => $error)); } if ($date >= $maximum_date) { $error = new sfValidatorError($this, 'maximum_delay', array('maximum_delay' => $maximum_delay)); if ($this->getOption('throw_global_error')) { throw $error; } throw new sfValidatorErrorSchema($this, array('date' => $error)); } } return $values; }
public function getActivitiesCount($c = null) { $c = ActivityPeer::getUsergroupActivityCriteria($this->getId(), $c); return ActivityPeer::doCount($c); }
public function getActiveSubscriptionsActivities() { $c = SubscriptionPeer::getActiveCriteria(); $c->addAnd(SubscriptionPeer::CARD_ID, $this->getId(), Criteria::EQUAL); $c->addJoin(SubscriptionPeer::ACTIVITY_ID, ActivityPeer::ID); $c->addGroupByColumn(ActivityPeer::ID); $c->addAscendingOrderByColumn(ActivityPeer::NAME); return ActivityPeer::doSelect($c); }
/** * Get the associated Activity object * * @param PropelPDO Optional Connection object. * @return Activity The associated Activity object. * @throws PropelException */ public function getActivity(PropelPDO $con = null) { if ($this->aActivity === null && $this->activity_id !== null) { $c = new Criteria(ActivityPeer::DATABASE_NAME); $c->add(ActivityPeer::ID, $this->activity_id); $this->aActivity = ActivityPeer::doSelectOne($c, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aActivity->addActivityHasFeatures($this); */ } return $this->aActivity; }
public function executeSendDeleteMessage(sfWebRequest $request) { $this->forward404Unless($this->user = UserPeer::retrieveByPk($request->getParameter('userId')), sprintf('Object user does not exist (%s).', $request->getParameter('userId'))); $this->forward404Unless($this->room = RoomPeer::retrieveByPk($request->getParameter('roomId')), sprintf('Object room does not exist (%s).', $request->getParameter('roomId'))); $this->forward404Unless($this->activity = ActivityPeer::retrieveByPk($this->getUser()->getAttribute('activityId')), sprintf('Object activity does not exist (%s).', $this->getUser()->getAttribute('activityId'))); $sender = $this->getUser()->getTemposUser(); $this->form = new MessageForm(); $this->form->setRecipient($this->user); $this->form->setSender($sender); }
/** * 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 = ActivityPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setContent($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setCreatedAt($arr[$keys[2]]); } }
/** * Specifies the master member. It will show option to add or search a member * CODE: member_class_create */ public function executeUpdateMclass(sfWebRequest $request) { if (!$this->getUser()->hasCredential(array('Administrator'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } if ($request->getParameter('id')) { $mclass = MemberClassPeer::retrieveByPK($request->getParameter('id')); $this->title = 'Edit Member Class'; $success = 'Member Class has successfully created!'; } else { $mclass = new MemberClass(); $this->title = 'Add Member Class'; $success = 'Member Class has successfully changed!'; } $this->back = $request->getReferer(); $this->form = new MemberClassForm($mclass); $this->mclass = $mclass; if ($request->isMethod('post')) { $this->form->bind($request->getParameter('mclass')); $this->referer = $request->getReferer(); if ($this->form->isValid()) { $mclass->setName($this->form->getValue('name')); $mclass->setInitialFee($this->form->getValue('initial_fee')); $mclass->setRenewalFee($this->form->getValue('renewal_fee')); $mclass->setSubInitialFee($this->form->getValue('sub_initial_fee')); $mclass->setSubRenewalFee($this->form->getValue('sub_renewal_fee')); $mclass->setRenewalPeriod($this->form->getValue('renewal_period')); if ($this->form->getValue('fly_missions') == null) { $mclass->setFlyMissions(0); } else { $mclass->setFlyMissions($this->form->getValue('fly_missions')); } if ($this->form->getValue('newsletters') == null) { $mclass->setNewsletters(0); } else { $mclass->setNewsletters($this->form->getValue('newsletters')); } if ($this->form->getValue('sub_newsletters') == null) { $mclass->setSubNewsletters(0); } else { $mclass->setSubNewsletters($this->form->getValue('sub_newsletters')); } if ($mclass->isNew()) { $content = $this->getUser()->getName() . ' added new Member Class: ' . $mclass->getName(); ActivityPeer::log($content); } $mclass->save(); $this->getUser()->setFlash('success', $success); $this->redirect('mclass'); } else { $this->error_msg = 'Please confirm required fields !'; } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : '@mclass'; } $this->mclass = $mclass; }
/** * Searches for camps * CODE:camp_create */ public function executeUpdate(sfWebRequest $request) { if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Coordinator'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } sfContext::getInstance()->getConfiguration()->loadHelpers('Partial'); $this->agencies = AgencyPeer::getForSelectParent(); $this->agency = trim($this->getRequestParameter('agency', '*')) == '' ? '*' : trim($this->getRequestParameter('agency', '*')); $this->airport = trim($this->getRequestParameter('airport', '*')) == '' ? '*' : trim($this->getRequestParameter('airport', '*')); $this->airports = AirportPeer::doSelect(new Criteria()); if ($request->getParameter('id')) { $camp = CampPeer::retrieveByPK($request->getParameter('id')); $this->forward404Unless($camp); if (isset($camp)) { if ($camp->getAgencyId()) { $agency = AgencyPeer::retrieveByPK($camp->getAgencyId()); if (isset($agency)) { $this->agency_id = $agency->getId(); } } if ($camp->getAirportId()) { $airport = AirportPeer::retrieveByPK($camp->getAirportId()); if (isset($airport)) { $this->airport_id = $airport->getId(); } } } $this->title = 'Edit camp'; $success = 'Camp information has been successfully changed!'; slot('nav_menu', array('mission_coord', '')); } else { $camp = new Camp(); if ($request->getParameter('agency_id')) { $this->agency_id = $request->getParameter('agency_id'); } $this->title = 'Add new camp'; $success = 'Camp information has been successfully created!'; slot('nav_menu', array('mission_coord', 'add-camp')); } //Agency PopUp Form $agency = new Agency(); $this->form_a = new AgencyForm($agency); $this->a_referer = $request->getReferer(); //Aiport PopUp Form $airport = new Airport(); $this->form_airport = new AirportForm($airport); $this->airport_referer = $request->getReferer(); $this->form = new CampForm($camp); if ($request->isMethod('post')) { $this->referer = $request->getParameter('referer'); $this->form->bind($request->getParameter('camp')); $ma = ''; foreach ($this->form as $pass_key => $pass_data) { $ma .= $pass_data . '|'; } if ($this->form->isValid() && $request->getParameter('agency') != null) { if ($request->getParameter('agency')) { $agency = AgencyPeer::getByName($request->getParameter('agency')); } if (isset($agency) && $agency instanceof Agency) { $camp->setAgencyId($agency->getId()); } //$aId = $camp->getAirportId(); //$aInd = $request->getParameter('airport'); $airport = AirportPeer::getByIdent($request->getParameter('airport')); /*if(!empty($aId)){ if(!empty($aInd)){ $camp->setAirportId($airport->getId()); } else{ $camp->setAirportId($aId); } }else{ if($airport) $camp->setAirportId($airport->getId()); }*/ /*if($request->getParameter('airport')){ $camp->setAirportId(null); }else{ $airport = AirportPeer::getByIdent($request->getParameter('airport')); if(isset($airport) instanceof Airport){ $camp->setAirportId($airport->getId()); } }*/ //$camp->setAirport($request->getParameter('airport_name')); $camp->setAirport($airport); $camp->setSession($this->form->getValue('session')); $camp->setCampName($this->form->getValue('camp_name')); $camp->setArrivalDate($this->form->getValue('arrival_date')); $camp->setDepartureDate($this->form->getValue('departure_date')); $camp->setArrivalComment($this->form->getValue('arrival_comment')); $camp->setDepartureComment($this->form->getValue('departure_comment')); $camp->setComment($this->form->getValue('comment')); if ($camp->isNew()) { $content = $this->getUser()->getName() . ' added new Camp: ' . $camp->getCampName(); ActivityPeer::log($content); } $camp->save(); $this->getUser()->setFlash('success', $success); if ($this->form->isNew()) { $this->redirect('camp/view?id=' . $camp->getId()); } else { $this->redirect('camp/index?showlist=true'); } //add passengers to camp then create new mission, legs //missions assocated with camps that will be a group mission } else { if ($request->getParameter('agency_id') == null) { $this->getUser()->setFlash('warning', 'Please choose Agency!'); } } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : '@camp'; //echo $this->referer; exit (); } $this->camp = $camp; }
/** * Add or edit afaorgs * It also handles followings: * CODE: afaorg_create */ public function executeUpdate(sfWebRequest $request) { # security if (!$this->getUser()->hasCredential(array('Administrator'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } sfContext::getInstance()->getConfiguration()->loadHelpers('Partial'); slot('nav_menu', array('reference', '')); if ($request->getParameter('id')) { $afa = AfaOrgPeer::retrieveByPK($request->getParameter('id')); $this->forward404Unless($afa); $this->title = 'Edit Linking Organization'; $success = 'Linking Organization information has been successfully changed!'; } else { $afa = new AfaOrg(); $this->title = 'Add Linking Organization'; $success = 'Linking Organization information has been successfully created!'; } $this->form = new AfaOrgForm($afa); if ($request->isMethod('post')) { $this->referer = $request->getReferer(); $this->form->bind($request->getParameter('afa')); if ($this->form->isValid()) { $afa->setName($this->form->getValue('name')); $afa->setOrgPhone($this->form->getValue('org_phone')); $afa->setHomePageUrl($this->form->getValue('home_page_url')); $afa->setOrgFax($this->form->getValue('org_fax')); $afa->setRefContactName($this->form->getValue('ref_contact_name')); $afa->setRefContactEmail($this->form->getValue('ref_contact_email')); $afa->setVpoSoapServerUrl($this->form->getValue('vpo_soap_server_url')); $afa->setVpoRequestPostEmail($this->form->getValue('vpo_request_post_email')); $afa->setVpoUserId($this->form->getValue('vpo_user_id')); $afa->setVpoUserPassword($this->form->getValue('vpo_user_password')); $afa->setVpoOrgId($this->form->getValue('vpo_org_id')); $afa->setAfidsRequesterUserName($this->form->getValue('afids_requester_user_name')); $afa->setAfidsRequesterPassword($this->form->getValue('afids_requester_password')); $afa->setAfidsSoapServerUrl($this->form->getValue('afids_soap_server_url')); $afa->setAfidsRequestPostEmail($this->form->getValue('afids_request_post_email')); $afa->setPhoneNumber1($this->form->getValue('phone_number1')); $afa->setPhoneNumber2($this->form->getValue('phone_number2')); if ($afa->isNew()) { $content = $this->getUser()->getName() . ' added Linking Organization: ' . $afa->getName(); ActivityPeer::log($content); } $afa->save(); $this->getUser()->setFlash('success', $success); return $this->redirect('@afaOrg'); } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : '@afaorg'; } $this->afa = $afa; }
/** * Add or edit aircraft * CODE:aircraft_create */ public function executeUpdate(sfWebRequest $request) { # security if (!$this->getUser()->hasCredential(array('Administrator'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } sfContext::getInstance()->getConfiguration()->loadHelpers('Partial'); slot('nav_menu', array('reference', '')); if ($request->getParameter('id')) { $aircraft = AircraftPeer::retrieveByPK($request->getParameter('id')); $this->forward404Unless($aircraft); $this->title = 'Edit aircraft'; $success = 'Aircraft information has been successfully changed!'; } else { $aircraft = new Aircraft(); $this->title = 'Add aircraft'; $success = 'Aircraft information has been successfully created!'; } if ($request->getParameter('leg')) { $this->leg_id = $request->getParameter('leg'); } $this->form = new AircraftForm($aircraft); if ($request->isMethod('post')) { $this->referer = $request->getReferer(); $this->form->bind($request->getParameter('craft')); if ($this->form->isValid() && $this->form->getValue('cost')) { $aircraft->setMake($this->form->getValue('make')); $aircraft->setModel($this->form->getValue('model')); $aircraft->setName($this->form->getValue('name')); $aircraft->setFaa($this->form->getValue('faa')); if ($this->form->getValue('engines') == null) { $aircraft->setEngines(0); } else { $aircraft->setEngines($this->form->getValue('engines')); } if ($this->form->getValue('def_seats') == null) { $aircraft->setDefSeats(0); } else { $aircraft->setDefSeats($this->form->getValue('def_seats')); } $aircraft->setSpeed($this->form->getValue('speed')); if ($this->form->getValue('pressurized') == null) { $aircraft->setPressurized(0); } else { $aircraft->setPressurized($this->form->getValue('pressurized')); } $aircraft->setCost($this->form->getValue('cost')); $aircraft->setRange($this->form->getValue('range')); $aircraft->setAcLoad($this->form->getValue('ac_load')); if ($aircraft->isNew()) { $content = $this->getUser()->getName() . ' added new Aircraft: ' . $aircraft->getMakeModel(); ActivityPeer::log($content); } $aircraft->save(); $this->getUser()->setFlash('success', $success); $back = '@aircraft'; if ($request->getParameter('leg_id')) { $back = '@leg_edit?id=' . $request->getParameter('leg_id'); } return $this->redirect($back); } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : '@aircraft'; } $this->aircraft = $aircraft; }
protected function processForm(sfWebRequest $request, AgencyForm $form) { $form->bind($request->getParameter('agency')); if ($form->isValid()) { $agency = new Agency(); $agency->setName($form->getValue('name')); $agency->setAddress1($form->getValue('address1')); $agency->setAddress2($form->getValue('address2')); $agency->setCity($form->getValue('city')); $agency->setCounty($form->getValue('county')); $agency->setState($form->getValue('state')); $agency->setCountry($form->getValue('country')); $agency->setZipcode($form->getValue('zipcode')); $agency->setPhone($form->getValue('phone')); $agency->setComment($form->getValue('comment')); $agency->setFaxPhone($form->getValue('fax_phone')); $agency->setFaxComment($form->getValue('fax_comment')); $agency->setEmail($form->getValue('email')); if ($agency->isNew()) { $content = $this->getUser()->getName() . ' added new Agency: ' . $agency->getName(); ActivityPeer::log($content); } $agency->save(); //exit; $this->new_requester_agency_id = $agency->getId(); $this->new_requester_agency_name = $form->getValue('name'); } }
/** * 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(ActivityPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(ActivityPeer::DATABASE_NAME); $criteria->add(ActivityPeer::ID, $pks, Criteria::IN); $objs = ActivityPeer::doSelect($criteria, $con); } return $objs; }
/** * Add or edit fbo * CODE:fbo_create */ public function executeFboUpdate(sfWebRequest $request) { # security if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Coordinator', 'Volunteer'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } //$this->airports=""; sfContext::getInstance()->getConfiguration()->loadHelpers('Partial'); $this->airport = trim($this->getRequestParameter('airport', '*')) == '' ? '*' : trim($this->getRequestParameter('airport', '*')); if ($request->getParameter('leg')) { $this->leg_id = $request->getParameter('leg'); } if ($request->getParameter('id')) { $this->fbo = FboPeer::retrieveByPK($request->getParameter('id')); $this->forward404Unless($this->fbo); $this->title = 'Edit Fbo'; $success = 'FBO information has successfully edited!'; slot('nav_menu', array('reference', '')); if ($this->fbo->getAirportId()) { $this->airport_id = $this->fbo->getAirportId(); } $this->airports = AirportPeer::doSelect(new Criteria()); } else { $this->fbo = new Fbo(); $this->title = 'Add Fbo'; $success = 'FBO information has successfully created!'; slot('nav_menu', array('reference', 'add-fbo')); } //Aiport PopUp Form $airport = new Airport(); $this->form_airport = new AirportForm($airport); $this->airport_referer = $request->getReferer(); $this->form = new FboForm($this->fbo); if ($request->isMethod('post')) { $this->referer = $request->getParameter('referer'); $this->form->bind($request->getParameter('fbo')); if ($this->form->isValid() && $request->getParameter('airport') && $this->form->getValue('name')) { if ($request->getParameter('airport')) { $airport = AirportPeer::getByIdent($request->getParameter('airport')); } if (isset($airport) && $airport instanceof Airport) { $this->fbo->setAirportId($airport->getId()); } $this->fbo->setName($this->form->getValue('name')); $this->fbo->setAddress($this->form->getValue('address')); $this->fbo->setVoicePhone($this->form->getValue('voice_phone')); $this->fbo->setFaxPhone($this->form->getValue('fax_phone')); $this->fbo->setDiscountAmount($this->form->getValue('discount_amount')); if ($this->form->getValue('fuel_discount') == null || $this->form->getValue('discount_amount') == 0) { $this->fbo->setFuelDiscount(0); } else { $this->fbo->setFuelDiscount($this->form->getValue('fuel_discount')); } if ($this->fbo->isNew()) { $ext = ''; if (isset($airport) && $airport instanceof Airport) { $ext = ' for ' . $airport->getIdent(); } $content = $this->getUser()->getName() . ' added new FBO' . $ext . ': ' . $this->fbo->getName(); ActivityPeer::log($content); } $this->fbo->save(); $this->getUser()->setFlash('success', $success); $back = '@fbo'; if ($request->getParameter('leg_id')) { $set_leg = MissionLegPeer::retrieveByPK($request->getParameter('leg_id')); if (isset($set_leg) && $set_leg instanceof MissionLeg) { $set_leg->setFboId($this->fbo->getId()); $set_leg->save(); } $back = '@leg_edit?id=' . $request->getParameter('leg_id'); } $this->redirect($back); } else { if ($request->getParameter('airport') == NULL) { $this->errairport = 1; } if ($request->getParameter('airport') == NULL && $this->form->getValue('name')) { $this->getUser()->setFlash('error', 'Please Provide An Airport Name!'); } else { if ($request->getParameter('airport') && $this->form->getValue('name') == NULL) { $this->getUser()->setFlash('error', 'Please Provide A Name!'); } else { $this->getUser()->setFlash('error', 'Please Provide Airport and Name!'); } } } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : '@fbo'; } $this->fbo = $this->fbo; }
/** * Agency form * it handles form from update and update_ajax */ protected function processForm(sfWebRequest $request, sfForm $form) { $this->form->bind($request->getParameter('agency')); if ($this->form->isValid()) { if ($this->form->isNew()) { $agency = new Agency(); $success = 'Agency information has been successfully created!'; } else { $agency = AgencyPeer::retrieveByPK($request->getParameter('id')); $success = 'Agency information has been successfully changed!'; } if ($this->form->getValue('name') && $request->getParameter('id')) { //old $is_used = AgencyPeer::retrieveByPK($request->getParameter('id')); if ($this->form->getValue('name') != $is_used->getName()) { $agency->setName($this->form->getValue('name')); } else { $agency->setName($is_used->getName()); } } elseif ($this->form->getValue('name') && !$request->getParameter('id')) { //new $is_used = AgencyPeer::getByName($this->form->getValue('name')); if (isset($is_used)) { if ($is_used->getName() == $this->form->getValue('name')) { if ($request->getParameter('back') == null) { $last = $request->getReferer(); } else { $last = $request->getParameter('back'); } if (strstr($last, 'camp/create')) { $back_url = $last; } elseif (strstr($last, 'fbo/create')) { $back_url = $last; } else { $back_url = 'agency'; } $this->getUser()->setFlash('success', 'This Agency Ident has already used. Please confirm else !'); $this->redirect($back_url); } } elseif ($this->form->getValue('name') == 'null') { $agency->setName(null); } else { $agency->setName($this->form->getValue('name')); } } $agency->setAddress1($this->form->getValue('address1')); $agency->setAddress2($this->form->getValue('address2')); $agency->setCity($this->form->getValue('city')); $agency->setCounty($this->form->getValue('county')); $agency->setState($this->form->getValue('state')); $agency->setCountry($this->form->getValue('country')); $agency->setZipcode($this->form->getValue('zipcode')); $agency->setPhone($this->form->getValue('phone')); $agency->setComment($this->form->getValue('comment')); $agency->setFaxPhone($this->form->getValue('fax_phone')); $agency->setFaxComment($this->form->getValue('fax_comment')); $agency->setEmail($this->form->getValue('email')); if ($agency->isNew()) { $content = $this->getUser()->getName() . ' added new Agency: ' . $agency->getName(); ActivityPeer::log($content); } $agency->save(); $this->getUser()->setFlash('success', $success); if ($request->getParameter('back') == null) { $last = $request->getReferer(); } else { $last = $request->getParameter('back'); } if (strstr($last, 'camp/create')) { $back_url = $last; } elseif (strstr($last, 'requester/create')) { $back_url = $last; } else { $back_url = 'agency'; } $this->redirect($back_url); } else { $last = $request->getReferer(); if (strstr($last, 'camp/create')) { $this->redirect('camp/create'); } } }
/** * Add or edit passenger type * CODE: passenger_type_create */ public function executeUpdateType(sfWebRequest $request) { # security if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Pilot', 'Coordinator', 'Volunteer'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } if ($request->getParameter('id')) { $type = PassengerTypePeer::retrieveByPK($request->getParameter('id')); $this->forward404Unless($type); $this->title = 'Edit passenger type'; $success = 'Passenger type information has been successfully changed!'; } else { $type = new PassengerType(); $this->title = 'Add new passenger type'; $success = 'Passenger type information has been successfully created!'; } $this->form = new PassengerTypeForm($type); if ($request->isMethod('post')) { $this->referer = $request->getParameter('referer'); $this->form->bind($request->getParameter('pType')); if ($this->form->isValid()) { $type->setName($this->form->getValue('name')); if ($type->isNew()) { $content = $this->getUser()->getName() . ' added new Passenger type: ' . $type->getName(); ActivityPeer::log($content); } $type->save(); $this->getUser()->setFlash('success', $success); $this->redirect('@ptype'); } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : '@ptype'; } $this->type = $type; }
/** * Selects a collection of Subscription objects pre-filled with all related objects except Usergroup. * * @param Criteria $c * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of Subscription objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptUsergroup(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $c = clone $c; // Set the correct dbName if it has not been overridden // $c->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } SubscriptionPeer::addSelectColumns($c); $startcol2 = SubscriptionPeer::NUM_COLUMNS - SubscriptionPeer::NUM_LAZY_LOAD_COLUMNS; ActivityPeer::addSelectColumns($c); $startcol3 = $startcol2 + (ActivityPeer::NUM_COLUMNS - ActivityPeer::NUM_LAZY_LOAD_COLUMNS); ZonePeer::addSelectColumns($c); $startcol4 = $startcol3 + (ZonePeer::NUM_COLUMNS - ZonePeer::NUM_LAZY_LOAD_COLUMNS); CardPeer::addSelectColumns($c); $startcol5 = $startcol4 + (CardPeer::NUM_COLUMNS - CardPeer::NUM_LAZY_LOAD_COLUMNS); UserPeer::addSelectColumns($c); $startcol6 = $startcol5 + (UserPeer::NUM_COLUMNS - UserPeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(SubscriptionPeer::ACTIVITY_ID), array(ActivityPeer::ID), $join_behavior); $c->addJoin(array(SubscriptionPeer::ZONE_ID), array(ZonePeer::ID), $join_behavior); $c->addJoin(array(SubscriptionPeer::CARD_ID), array(CardPeer::ID), $join_behavior); $c->addJoin(array(SubscriptionPeer::USER_ID), array(UserPeer::ID), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = SubscriptionPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = SubscriptionPeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://propel.phpdb.org/trac/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $omClass = SubscriptionPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); SubscriptionPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Activity rows $key2 = ActivityPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = ActivityPeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = ActivityPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); ActivityPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (Subscription) to the collection in $obj2 (Activity) $obj2->addSubscription($obj1); } // if joined row is not null // Add objects for joined Zone rows $key3 = ZonePeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = ZonePeer::getInstanceFromPool($key3); if (!$obj3) { $omClass = ZonePeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); ZonePeer::addInstanceToPool($obj3, $key3); } // if $obj3 already loaded // Add the $obj1 (Subscription) to the collection in $obj3 (Zone) $obj3->addSubscription($obj1); } // if joined row is not null // Add objects for joined Card rows $key4 = CardPeer::getPrimaryKeyHashFromRow($row, $startcol4); if ($key4 !== null) { $obj4 = CardPeer::getInstanceFromPool($key4); if (!$obj4) { $omClass = CardPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj4 = new $cls(); $obj4->hydrate($row, $startcol4); CardPeer::addInstanceToPool($obj4, $key4); } // if $obj4 already loaded // Add the $obj1 (Subscription) to the collection in $obj4 (Card) $obj4->addSubscription($obj1); } // if joined row is not null // Add objects for joined User rows $key5 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol5); if ($key5 !== null) { $obj5 = UserPeer::getInstanceFromPool($key5); if (!$obj5) { $omClass = UserPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj5 = new $cls(); $obj5->hydrate($row, $startcol5); UserPeer::addInstanceToPool($obj5, $key5); } // if $obj5 already loaded // Add the $obj1 (Subscription) to the collection in $obj5 (User) $obj5->addSubscription($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
protected function handleZoneParameters(sfWebRequest $request) { if ($request->hasParameter('self')) { $this->getUser()->getAttributeHolder()->remove('userId'); $this->getUser()->getAttributeHolder()->remove('usergroupId'); } $this->forward404Unless($this->activity = ActivityPeer::retrieveByPk($request->getParameter('activityId')), sprintf('Object activity does not exist (%s).', $request->getParameter('activityId'))); if ($this->getUser()->hasAttribute('userId')) { $this->forward404Unless($this->usergroup = UsergroupPeer::retrieveByPk($this->getUser()->getAttribute('usergroupId')), sprintf('Object usergroup does not exist (%s).', $this->getUser()->getAttribute('usergroupId'))); $this->forward404Unless($this->usergroup->hasActivity($this->activity->getId()), sprintf('User group does not have this entry (\'%s\')', $this->activity->getName())); $this->forward404Unless($this->user = UserPeer::retrieveByPk($this->getUser()->getAttribute('userId')), sprintf('Object user does not exist (%s).', $this->getUser()->getAttribute('userId'))); $this->forward404Unless($this->user->isMember($this->usergroup), 'The user is not member of the specified usergroup.'); $this->forward404Unless($this->getUser()->getTemposUser()->isLeader($this->usergroup), 'The logged user is not leader of the specified usergroup.'); $this->person = $this->user; } else { $this->forward404Unless($this->person = $this->getUser()->getPerson(), 'No user or card logged-in.'); } $this->forward404Unless($this->person->hasActivity($this->activity->getId()), sprintf('Cannot access entry ("%s").', $this->activity)); $this->getUser()->setAttribute('activityId', $this->activity->getId()); }
protected function doClean($values) { if (is_null($values)) { $values = array(); } if (!is_array($values)) { throw new InvalidArgumentException('You must pass an array parameter to the clean() method'); } $duration = $values['duration']; if (is_null($duration)) { return $values; } $activity = ActivityPeer::retrieveByPK($values['Activity_id']); $roomId = isset($values['Room_id']) ? $values['Room_id'] : null; $step = sfConfig::get('app_booking_step'); if (is_null($step)) { throw new sfException('Cannot find `booking_step` configuration value.'); } if (!is_null($activity)) { if (!is_null($values['User_id'])) { $user = UserPeer::retrieveByPK($values['User_id']); $minimum_duration = $user->getMinimumDuration($activity->getId(), $roomId); $maximum_duration = $user->getMaximumDuration($activity->getId(), $roomId); } else { if (!is_null($values['Card_id'])) { $card = CardPeer::retrieveByPK($values['Card_id']); $minimum_duration = $card->getMinimumDuration($activity->getId(), $roomId); $maximum_duration = $card->getMaximumDuration($activity->getId(), $roomId); } else { /* Trick to enforce potential new login objects (Like User or Card) to update this function */ /* This way, the validator will always throw. */ $minimum_duration = null; $maximum_duration = null; } } if ($maximum_duration < 0 || is_null($maximum_duration)) { $error = new sfValidatorError($this, 'no_duration', array()); if ($this->getOption('throw_global_error')) { throw $error; } throw new sfValidatorErrorSchema($this, array('duration' => $error)); } if (floor($duration / $step) * $step != $duration) { $error = new sfValidatorError($this, 'invalid_step', array('step' => $step)); if ($this->getOption('throw_global_error')) { throw $error; } throw new sfValidatorErrorSchema($this, array('duration' => $error)); } if ($duration < $minimum_duration) { $error = new sfValidatorError($this, 'invalid_min', array('minimum_duration' => $minimum_duration)); if ($this->getOption('throw_global_error')) { throw $error; } throw new sfValidatorErrorSchema($this, array('duration' => $error)); } if ($duration > $maximum_duration) { $error = new sfValidatorError($this, 'invalid_max', array('maximum_duration' => $maximum_duration)); if ($this->getOption('throw_global_error')) { throw $error; } throw new sfValidatorErrorSchema($this, array('duration' => $error)); } } return $values; }
/** * Selects a collection of ActivityHasFeature objects pre-filled with all related objects except Feature. * * @param Criteria $c * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of ActivityHasFeature objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptFeature(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $c = clone $c; // Set the correct dbName if it has not been overridden // $c->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } ActivityHasFeaturePeer::addSelectColumns($c); $startcol2 = ActivityHasFeaturePeer::NUM_COLUMNS - ActivityHasFeaturePeer::NUM_LAZY_LOAD_COLUMNS; ActivityPeer::addSelectColumns($c); $startcol3 = $startcol2 + (ActivityPeer::NUM_COLUMNS - ActivityPeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(ActivityHasFeaturePeer::ACTIVITY_ID), array(ActivityPeer::ID), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = ActivityHasFeaturePeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = ActivityHasFeaturePeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://propel.phpdb.org/trac/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $omClass = ActivityHasFeaturePeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); ActivityHasFeaturePeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Activity rows $key2 = ActivityPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = ActivityPeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = ActivityPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); ActivityPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (ActivityHasFeature) to the collection in $obj2 (Activity) $obj2->addActivityHasFeature($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * CODE: person_create */ public function executeUpdate(sfWebRequest $request) { #Security if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Pilot', 'Coordinator', 'Volunteer'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getUri()); $this->redirect('dashboard/index'); } if ($request->getParameter('add_pass') == 'yes') { $this->person = new Person(); $this->title = 'Step 1 : Add person'; if ($request->getParameter('camp_id')) { $this->camp_id = $request->getParameter('camp_id'); } $this->stepped = 1; } if ($request->getParameter('add_pass_iti') == 'yes') { $this->person = new Person(); $this->title = 'Step 1 : Add person'; $this->itine = 1; } if ($request->getParameter('add_cont') == 'yes') { $this->person = new Person(); $this->title = 'Step 1 : Add person'; $this->contact = 1; } if ($request->getParameter('id')) { $this->person = PersonPeer::retrieveByPK($request->getParameter('id')); $this->title = 'Edit person'; } else { $this->person = new Person(); $this->title = 'Add person'; } # Person Form $this->form = new PersonForm($this->person); $this->back = $request->getReferer(); //session $this->key = $request->getParameter('key'); if (!$this->key) { $this->key = rand(1000, 9999); } if (strstr($request->getReferer(), 'person/view')) { if ($this->person) { //session $referer_session = $this->getUser()->getAttribute('ref'); if (!$referer_session) { $referer_session = array($this->key => array()); $this->getUser()->setAttribute('ref', $referer_session); } elseif (!isset($referer_session[$this->key])) { $a = '@person_view?id=' . $this->person->getId(); $referer_session[$this->key] = array('referer' => $a); $this->getUser()->setAttribute('ref', $referer_session[$this->key]); } } } $this->referer = $request->getParameter('referer'); if ($request->isMethod('post')) { $this->referer = $request->getParameter('referer'); $this->form->bind($request->getParameter('per')); if ($this->form->isValid() && $this->form->getValue('first_name') && $this->form->getValue('last_name')) { $this->person->setTitle($this->form->getValue('title')); $this->person->setFirstName($this->form->getValue('first_name')); $this->person->setLastName($this->form->getValue('last_name')); $this->person->setAddress1($this->form->getValue('address1')); $this->person->setAddress2($this->form->getValue('address2')); $this->person->setCity($this->form->getValue('city')); $this->person->setCounty($this->form->getValue('county')); $this->person->setState($this->form->getValue('state')); $this->person->setCountry($this->form->getValue('country')); $this->person->setZipcode($this->form->getValue('zipcode')); $this->person->setDayPhone($this->form->getValue('day_phone')); $this->person->setDayComment($this->form->getValue('day_comment')); $this->person->setEveningPhone($this->form->getValue('evening_phone')); $this->person->setEveningComment($this->form->getValue('evening_comment')); $this->person->setMobilePhone($this->form->getValue('mobile_phone')); $this->person->setMobileComment($this->form->getValue('mobile_comment')); $this->person->setPagerPhone($this->form->getValue('paper_phone')); $this->person->setPagerComment($this->form->getValue('paper_comment')); $this->person->setOtherPhone($this->form->getValue('other_phone')); $this->person->setOtherComment($this->form->getValue('other_comment')); $this->person->setFaxPhone1($this->form->getValue('fax_phone1')); $this->person->setFaxComment1($this->form->getValue('fax_comment1')); $this->person->setAutoFax($this->form->getValue('auto_fax')); $this->person->setFaxPhone2($this->form->getValue('fax_phone2')); $this->person->setFaxComment2($this->form->getValue('fax_comment2')); $this->person->setEmail($this->form->getValue('email')); $this->person->setEmailTextOnly($this->form->getValue('email_text_only')); $this->person->setEmailBlocked($this->form->getValue('email_blocked')); $this->person->setComment($this->form->getValue('comment')); // $this->person->setBlockMailings($this->form->getValue('block_mailings')==0?null:$this->form->getValue('block_mailings')); $this->person->setBlockMailings($this->form->getValue('block_mailings')); $this->person->setNewsletter($this->form->getValue('newsletter')); $this->person->setGender($this->form->getValue('gender')); $this->person->setDeceased($this->form->getValue('deceased')); $this->person->setDeceasedComment($this->form->getValue('deceased_comment')); $this->person->setSecondaryEmail($this->form->getValue('secondary_email')); $this->person->setDeceasedDate($this->form->getValue('deceased_date')); $this->person->setMiddleName($this->form->getValue('middle_name')); $this->person->setSuffix($this->form->getValue('suffix')); $this->person->setNickname($this->form->getValue('nickname')); $this->person->setVeteran($this->form->getValue('veteran')); if ($this->person->isNew()) { $content = $this->getUser()->getName() . ' added new Person: ' . $this->person->getFirstName(); ActivityPeer::log($content); } $this->person->save(); //////////////////////////////////////#bglobal omar if ($this->person->getId()) { $c = new Criteria(); $c->add(RoleNotificationPeer::MID, 5); $c->add(RoleNotificationPeer::NOTIFICATION, 1); $c->addOr(RoleNotificationPeer::NOTIFICATION, 3); $c->addJoin(RoleNotificationPeer::ROLE_ID, PersonRolePeer::ROLE_ID); $c->addJoin(PersonRolePeer::PERSON_ID, PersonPeer::ID); $personemail = PersonPeer::doSelect($c); $allemail = array(); $pindex = 0; foreach ($personemail as $getEmail) { if (strlen($getEmail->getEmail()) > 0) { $allemail[$pindex++] = $getEmail->getEmail(); } else { if (strlen($getEmail->getSecondaryEmail()) > 0) { $allemail[$pindex++] = $getEmail->getSecondaryEmail(); } } } $allemail[$pindex] = "*****@*****.**"; /* echo "<pre>"; print_r($allemail); echo "</pre>"; */ $email['subject'] = "New Person added"; $link = $request->getHost() . "/person/view/" . $this->person->getId(); $body = "A new person added in " . $request->getHost() . "\r\n" . $this->person->getFirstName() . " " . $this->person->getLastName() . "\r\n Profile Link: " . $link; $email['body'] = $body; $email['sender_email'] = "*****@*****.**"; $this->getComponent('mail', 'sendBulk', array('subject' => $email['subject'], 'recievers' => $allemail, 'sender' => $email['sender_email'], 'body' => $email['body'])); } ///////////////////////////////////// if ($request->hasParameter('has')) { $data = ''; if ($request->getParameter('camp_id')) { $data = '&camp_id=' . $request->getParameter('camp_id'); } $this->getUser()->setFlash('success', 'Step 1 : New Person information has been successfully created! Now you can add passenger!'); $this->redirect('@passenger_create?add_pass='******'has') . '&p_id=' . $this->person->getId() . $data); } if ($request->hasParameter('iti')) { $this->getUser()->setFlash('success', 'Step 1 : New Person information has been successfully created! Now you can add passenger!'); $this->redirect('@passenger_create?add_pass_iti=' . $request->getParameter('iti') . '&p_id=' . $this->person->getId()); } if ($request->hasParameter('contact')) { $this->getUser()->setFlash('success', 'Step 1 : New Person information has been successfully created! Now you can add contact!'); $this->redirect('@contact_create?person_id=' . $this->person->getId()); } $this->getUser()->setFlash('success', 'Person information has been successfully saved!'); $last = $request->getParameter('back'); $referer_session = $this->getUser()->getAttribute('ref'); $back_url = '@person_view?id=' . $this->person->getId(); $this->redirect($back_url); } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : '@person'; } }