public function editAction()
 {
     $request = $this->getRequest();
     $category = $request->getParam("category");
     $info_mapper = new Application_Model_InfoMapper();
     $items = $info_mapper->findAllByTwoColumns("category", $category, 'user_id', get_user_id());
     $this->view->items = $items;
     $this->view->category = $category;
     if ($request->isPost()) {
         $add_key = $request->getParam("key_field");
         $add_value = $request->getParam("value_field");
         if (!empty($add_key) && !empty($add_value)) {
             $info_model = new Application_Model_Info();
             $info_model->_fields['user_id'] = get_user_id();
             $info_model->_fields['title'] = $add_key;
             $info_model->_fields['value'] = $add_value;
             $info_model->_fields['category'] = $category;
             $info_mapper->save($info_model);
         }
         $edit_value = $request->getParam("edit_value");
         $edit_key = $request->getParam("edit_key");
         if (!empty($edit_value)) {
             if ($edit_value != "Value") {
                 $info_mapper->update($edit_key, $edit_value, $category);
             }
         }
         $this->_redirect("/profile/profile");
     }
 }
예제 #2
0
 public function changeinfoAction()
 {
     $request = $this->getRequest();
     $category = $request->getParam("category");
     $user_id = get_user_id();
     $info_mapper = new Application_Model_InfoMapper();
     $items = $info_mapper->findAllByTwoColumns('user_id', $user_id, 'category', $category);
     if (empty($items)) {
         throw new Exception("empty_item");
     }
     $this->view->items = $items;
 }