Example #1
0
 public function delete()
 {
     try {
         $this->deleteMedia();
     } catch (Exception $e) {
         Bbx_Log::debug('Unable to delete media ' . get_class($this) . ' id ' . $this->id . ' - ' . $e->getMessage());
     }
     parent::delete();
 }
Example #2
0
 protected function _throwUploadException($upload)
 {
     $msgs = $upload->getMessages();
     if (empty($msgs)) {
         $msgs = array('Unknown failure - please contact support.');
     }
     Bbx_Log::debug('Upload failed: ' . implode($msgs));
     throw new Bbx_Controller_Rest_Exception('Upload failed: ' . implode($msgs), 500);
 }
Example #3
0
 protected function _closeSession()
 {
     $this->_user = $this->_helper->Authenticate->getUser();
     $session = $this->_user->current_admin_session;
     try {
         $session->close();
     } catch (Exception $e) {
         Bbx_Log::debug("Unable to close session: " . $e->getMessage());
     }
 }
Example #4
0
 public function __call($method, $arguments)
 {
     if (method_exists('Bbx_Date', $method)) {
         try {
             return call_user_func_array(array('Bbx_Date', $method), $arguments);
         } catch (Exception $e) {
             Bbx_Log::debug($e->getMessage());
         }
     } else {
         Bbx_Log::debug('Bbx_Date has no method "' . $method . '"');
     }
 }
Example #5
0
 public function notify(Exception $e)
 {
     if (isset(Bbx_Config::get()->site->support_address) && APPLICATION_ENV != 'development') {
         try {
             $mail = Bbx_Mail::instance();
             $mail->setFrom('error@' . Bbx_Config::get()->site->location, Bbx_Config::get()->site->location);
             $mail->setBodyText($this->getRequest()->getRequestUri() . "\n\n" . $e->getMessage());
             $mail->addTo(Bbx_Config::get()->site->support_address);
             $mail->setSubject('Error at ' . Bbx_Config::get()->site->location);
             $mail->sendAsync();
         } catch (Exception $exc) {
             Bbx_Log::debug(print_r($e, true));
             Bbx_Log::debug("Couldn't send mail: " . $exc->getMessage());
         }
     } else {
         Bbx_Log::debug(print_r($e, true));
     }
 }
Example #6
0
 protected function _options()
 {
     Bbx_Log::debug("received OPTIONS request");
     $this->_helper->authenticate();
 }
Example #7
0
 public function updateAllAction()
 {
     $this->_helper->authenticate();
     $model = $this->_getParam('model');
     try {
         $models = Bbx_Model::load($model)->findAll();
         foreach ($models as $m) {
             $m->update(array());
         }
     } catch (Exception $e) {
         Bbx_Log::debug($e->getMessage());
     }
     $this->getResponse()->sendResponse();
     exit;
 }
Example #8
0
 protected function _checkLastLogin()
 {
     $session = $this->_user->last_admin_session;
     if (!$session instanceof Bbx_Model) {
         return;
     }
     try {
         if ($session->logged_out_at == '0000-00-00 00:00:00') {
             $session->close();
         }
     } catch (Exception $e) {
         Bbx_Log::debug("Unable to close session: " . $e->getMessage());
     }
 }
Example #9
0
 protected function _resizeImage($size, $overwrite)
 {
     if (file_exists($this->getMediaPath($size)) && !$overwrite) {
         Bbx_Log::debug($size . ' exists (' . $this->getMediaPath($size) . ')');
         return;
     }
     $localPath = $this->getMediaPath('original', true);
     if (!is_readable($localPath)) {
         $cdnPath = $this->getMediaPath('original');
         if (!copy($cdnPath, $localPath)) {
             throw new Bbx_Model_Exception("Couldn't copy media from " . $cdnPath . " to " . $localPath);
         }
     }
     $img = Bbx_Media_Image::load($localPath);
     list($width, $height) = $this->_calculateImageGeometry($this->_sizes[$size], $this->width, $this->height);
     try {
         $img->resize((int) $width, (int) $height)->save($this->getMediaPath($size, true));
     } catch (Exception $e) {
         Bbx_Log::debug($e->getMessage());
         throw new Bbx_Model_Exception("Couldn't resize image " . $this->id . " to path " . $this->getMediaPath($size, true));
     }
 }
Example #10
0
 public function __get($key)
 {
     if ($this->isEmpty()) {
         $cols = $this->columns();
         if (array_key_exists($key, $cols)) {
             return null;
         }
     }
     $derivedParam = 'dp' . ucfirst($key);
     if (isset($this->_rowData()->{$key})) {
         $value = $this->_rowData()->{$key};
         $viewised = $this->_viewise($key, $value);
         return $viewised[1];
     } else {
         if (method_exists($this, $derivedParam)) {
             return $this->{$derivedParam}();
         } else {
             try {
                 return $this->_getRelationship(Inflector::underscore($key));
             } catch (Exception $e) {
                 Bbx_Log::debug($e->getMessage());
                 throw new Bbx_Model_Exception_NotFound("Trying to get value of uninitialised variable '{$key}': " . get_class($this));
             }
         }
     }
 }