示例#1
0
 public function getImages()
 {
     $options = array('Product_id' => $this->getId());
     //loading images
     $this->images = DatabaseObject_Image::GetImages($this->getDb(), $options, 'Product_id', 'product_inventory_images', 'inventory');
 }
示例#2
0
 public function getImages()
 {
     $options = array('event_id' => $this->getId());
     //loading images
     $this->images = DatabaseObject_Image::GetImages($this->getDb(), $options, 'event_id', 'events_images');
 }
 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);
     }
 }