Example #1
0
 /**
  * Add or edit gifts
  * CODE: gift_create
  */
 public function executeUpdateGift(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');
     }
     if ($request->getParameter('id')) {
         $gift_type = GiftTypePeer::retrieveByPK($request->getParameter('id'));
         $this->forward404Unless($gift_type);
         $this->title = 'Edit gift type';
         $success = 'Gift type information has been successfully changed!';
     } else {
         $gift_type = new GiftType();
         $this->title = 'Add new gift type';
         $success = 'Gift type information has been successfully created!';
     }
     $this->back = $request->getReferer();
     $this->form = new GiftTypeForm($gift_type);
     if ($request->isMethod('post')) {
         $this->referer = $request->getReferer();
         $this->form->bind($request->getParameter('gType'));
         if ($this->form->isValid()) {
             $gift_type->setGiftTypeDesc($this->form->getValue('gift_type_desc'));
             $gift_type->save();
             $this->getUser()->setFlash('success', $success);
             $last = $request->getParameter('back');
             if (strstr($last, 'donation/create')) {
                 $back_url = $last;
             } else {
                 $back_url = 'gift';
             }
             $this->redirect($back_url);
         }
     } else {
         # Set referer URL
         $this->referer = $request->getReferer() ? $request->getReferer() : '@gift';
     }
     $this->gift_type = $gift_type;
 }
Example #2
0
 /**
  * Declares an association between this object and a GiftType object.
  *
  * @param      GiftType $v
  * @return     Donation The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setGiftTypeRelatedByGiftType(GiftType $v = null)
 {
     if ($v === null) {
         $this->setGiftType(NULL);
     } else {
         $this->setGiftType($v->getId());
     }
     $this->aGiftTypeRelatedByGiftType = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the GiftType object, it will not be re-added.
     if ($v !== null) {
         $v->addDonation($this);
     }
     return $this;
 }
Example #3
0
 /**
  * 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      GiftType $value A GiftType object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(GiftType $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }