コード例 #1
0
ファイル: actions.class.php プロジェクト: Chipusy/lkbroker
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $notice = $form->getObject()->isNew() ? 'Категория создана успешно.' : 'Категория изменена успешно.';
         $Category = $form->save();
         foreach ((array) $request->getParameter('category_preference') as $key => $value) {
             if (isset($value['id']) and $value['id'] != 0) {
                 $category_preference = CategoryPreferencePeer::retrieveByPk(intval($value['id']));
             } else {
                 $category_preference = new CategoryPreference();
                 $category_preference->setCategoryId($form->getObject()->getId());
             }
             if (isset($value['delete'])) {
                 $category_preference->delete();
             } elseif ($value['name'] != '') {
                 $category_preference->setKey($value['name']);
                 $category_preference->setPreferenceType($value['preference_type']);
                 $category_preference->setPreferenceUnit($value['preference_unit']);
                 $category_preference->setFilterStatus(isset($value['filter_status']) ? $value['filter_status'] : 0);
                 $category_preference->save();
             }
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $Category)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $notice . ' Вы можете создать еще одну.');
             $this->redirect('@category_new');
         } else {
             $this->getUser()->setFlash('notice', $notice);
             $this->redirect(array('sf_route' => 'category_edit', 'sf_subject' => $Category));
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
コード例 #2
0
ファイル: BasePreference.php プロジェクト: Chipusy/lkbroker
 /**
  * Declares an association between this object and a CategoryPreference object.
  *
  * @param      CategoryPreference $v
  * @return     Preference The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setCategoryPreference(CategoryPreference $v = null)
 {
     if ($v === null) {
         $this->setCategoryPreferenceId(NULL);
     } else {
         $this->setCategoryPreferenceId($v->getId());
     }
     $this->aCategoryPreference = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the CategoryPreference object, it will not be re-added.
     if ($v !== null) {
         $v->addPreference($this);
     }
     return $this;
 }
コード例 #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      CategoryPreference $value A CategoryPreference object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(CategoryPreference $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
コード例 #4
0
function createCategoryPreference($user_id, $category_id)
{
    global $bdd, $_TABLES;
    if (!is_null($bdd) && !is_null($_TABLES)) {
        $objCategoryPreference = new CategoryPreference($bdd, $_TABLES);
        $objCategoryPreference->createCategoryPreference($user_id, $category_id);
    } else {
        error_log("BDD ERROR : " . json_encode($bdd));
        error_log("TABLES ERROR : " . json_encode($_TABLES));
    }
}
コード例 #5
0
ファイル: actions.class.php プロジェクト: Chipusy/lkbroker
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
         $Category = $form->save();
         foreach ((array) $request->getParameter('category_preference') as $key => $value) {
             if (isset($value['id'])) {
                 $category_preference = CategoryPreferencePeer::retrieveByPk(intval($value['id']));
             } else {
                 $category_preference = new CategoryPreference();
                 $category_preference->setCategoryId($form->getObject()->getId());
             }
             if (isset($value['delete'])) {
                 $category_preference->delete();
             } elseif ($value['name'] != '') {
                 $category_preference->setKey($value['name']);
                 $category_preference->setFilterStatus(isset($value['filter_status']) ? $value['filter_status'] : 0);
                 $category_preference->save();
             }
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $Category)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $notice . ' You can add another one below.');
             $this->redirect('@category_new');
         } else {
             $this->getUser()->setFlash('notice', $notice);
             $this->redirect(array('sf_route' => 'category_edit', 'sf_subject' => $Category));
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }