/**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      MemberClass $value A MemberClass object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(MemberClass $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Exemple #2
0
 /**
  * Declares an association between this object and a MemberClass object.
  *
  * @param      MemberClass $v
  * @return     Member The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setMemberClass(MemberClass $v = null)
 {
     if ($v === null) {
         $this->setMemberClassId(NULL);
     } else {
         $this->setMemberClassId($v->getId());
     }
     $this->aMemberClass = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the MemberClass object, it will not be re-added.
     if ($v !== null) {
         $v->addMember($this);
     }
     return $this;
 }
Exemple #3
0
 /**
  * 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;
 }