public function imagesAction()
 {
     if ($this->request->getPost('upload')) {
         echo 'here at image upload<br />';
         $fp = new FormProcessor_Image($this->tempProduct, 'storeSeller');
         echo 'here at instantiating image<br />';
         if ($fp->process($this->request)) {
             echo 'here at process request<br />';
             //then update the session variable for it
             $this->messenger->addMessage('Image uploaded');
         } else {
             echo 'here at process error<br />';
             foreach ($fp->getErrors() as $error) {
                 $this->messenger->addMessage($error);
             }
         }
     } elseif ($this->request->getParam('delete')) {
         /*$image_id = (int) $this->request->getPost('image');
         		$image = new DatabaseObject_Image($this->db, $this->tempProduct->image_table, $this->tempProduct->product_tag);
         		
         		if($image->loadForPost($this->product_id, $image_id)){
         			$image->delete(); //the files are unlinked/deleted at preDelete.
         			////echo 'image at delete';
         			
         			if($this->request->isXmlHttpRequest()){
         				$json = array('deleted' =>true, 'image_id' =>$image_id);
         			}
         			else{
         				$this->messenger->addMessage('Image deleted');
         			}
         		}*/
     }
     /*elseif($this->request->getPost('reorder'))
     		{
     			$order = $request->getPost('post_images');
     			$product->setImageOrder($order);
     		}*/
     $this->_redirect('productlisting/productlistingpreview?id=' . $this->tempProduct->getId() . '&product=' . $this->product_type . '&tag=' . $this->product_tag);
 }
Ejemplo n.º 2
0
 public function imagesAction()
 {
     $request = $this->getRequest();
     $json = array();
     $user_id = (int) $request->getPost('id');
     $user = new DatabaseObject_User($this->db);
     if (!$user->load(Zend_Auth::getInstance()->getIdentity()->userID)) {
         $this->_redirect($this->getUrl());
     }
     if ($request->getPost('upload')) {
         $fp = new FormProcessor_Image($user);
         if ($fp->process($request)) {
             $this->messenger->addMessage('Image uploaded');
         } else {
             foreach ($fp->getErrors() as $error) {
                 $this->messenger->addMessage($error);
             }
         }
     } elseif ($request->getPost('reorder')) {
         $order = $request->getPost('post_images');
         $options = array('user_id' => Zend_Auth::getInstance()->getIdentity()->userID);
         //loading images
         $images = DatabaseObject_Image::GetImages($this->db, $options, 'user_id', 'users_profiles_images');
         $user->images = $images;
         $user->setImageOrder($order);
     } elseif ($request->getPost('delete')) {
         $image_id = (int) $request->getPost('image');
         $image = new DatabaseObject_Image($this->db);
         if ($image->loadForPost($user->getId(), $image_id)) {
             $image->delete();
             //the files are unlinked/deleted at preDelete.
             //echo "image at delete";
             if ($request->isXmlHttpRequest()) {
                 $json = array('deleted' => true, 'image_id' => $image_id);
             } else {
                 $this->messenger->addMessage('Image deleted');
             }
         }
     }
     if ($request->isXmlHttpRequest()) {
         $this->sendJson($json);
     } else {
         $url = $this->getUrl('details');
         $this->_redirect($url);
     }
 }