Пример #1
0
 public function postDelete(Doctrine_Event $event)
 {
     //Make sure all linked tables are clean
     //RokGallery_Model_FileTags
     $q = Doctrine_Query::create()->delete('RokGallery_Model_FileTags ft')->andWhere('ft.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
     $q->execute();
     $q->free();
     //RokGallery_Model_FileViews
     $q = Doctrine_Query::create()->delete('RokGallery_Model_FileViews fv')->andWhere('fv.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
     $q->execute();
     $q->free();
     //RokGallery_Model_FileLoves
     $q = Doctrine_Query::create()->delete('RokGallery_Model_FileLoves fl')->andWhere('fl.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
     $q->execute();
     $q->free();
     //rokgallery_files_index
     $conn =& Doctrine_Manager::connection();
     $dbh =& $conn->getDbh();
     $stmt = $dbh->prepare('delete from ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_files_index') . ' where id NOT IN (SELECT f.id from ' . RokGallery_Model_FileTable::getInstance()->getTableName() . ' f)');
     $stmt->execute();
     //RokGallery_Model_Slice
     $q = Doctrine_Query::create()->delete('RokGallery_Model_Slice s')->andWhere('s.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
     $q->execute();
     $q->free();
 }
 public function preUp()
 {
     if (!$this->isInnoDBEngine(RokCommon_Doctrine::getPlatformInstance()->getSchema(), RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_files'))) {
         $this->run = true;
         //Clean up bad data
         //RokGallery_Model_FileTags
         $q = Doctrine_Query::create()->delete('RokGallery_Model_FileTags ft')->andWhere('ft.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
         $q->execute();
         $q->free();
         //RokGallery_Model_FileViews
         $q = Doctrine_Query::create()->delete('RokGallery_Model_FileViews fv')->andWhere('fv.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
         $q->execute();
         $q->free();
         //RokGallery_Model_FileLoves
         $q = Doctrine_Query::create()->delete('RokGallery_Model_FileLoves fl')->andWhere('fl.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
         $q->execute();
         $q->free();
         //rokgallery_files_index
         $conn =& Doctrine_Manager::connection();
         $dbh =& $conn->getDbh();
         $stmt = $dbh->prepare('delete from ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_files_index') . ' where id NOT IN (SELECT f.id from ' . RokGallery_Model_FileTable::getInstance()->getTableName() . ' f)');
         $stmt->execute();
         //RokGallery_Model_Slice
         $q = Doctrine_Query::create()->delete('RokGallery_Model_Slice s')->andWhere('s.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
         $q->execute();
         $q->free();
         //RokGallery_Model_SliceTags
         $q = Doctrine_Query::create()->delete('RokGallery_Model_SliceTags st')->andWhere('st.slice_id NOT IN (SELECT s.id from RokGallery_Model_Slice s)');
         $q->execute();
         $q->free();
         //rokgallery_slices_index
         $stmt = $dbh->prepare('delete from ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_slices_index') . ' where id NOT IN (SELECT s.id from ' . RokGallery_Model_SliceTable::getInstance()->getTableName() . ' s)');
         $stmt->execute();
         //RokGallery_Model_Gallery
         $q = Doctrine_Query::create()->update('RokGallery_Model_Slice')->set('gallery_id', 'NULL')->andWhere('gallery_id NOT IN (SELECT g.id from RokGallery_Model_Gallery g)');
         $q->execute();
         $q->free();
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_file_loves') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_file_views') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_file_tags') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_files') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_files_index') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_filters') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_galleries') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_jobs') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_profiles') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_schema_version') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_slice_tags') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_slices') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_slices_index') . ' ENGINE=INNODB');
     }
 }
Пример #3
0
 /**
  */
 public function process()
 {
     try {
         /** @var $properties RokGallery_Job_Property_ImportFile[] */
         $properties = $this->_job->getProperties();
         $total_files = count($properties['files']);
         foreach ($properties['files'] as $key => &$file) {
             // keep bumping the time as log as a file doesnt take 30 seconds or more
             /** @var RokGallery_Job_Property_ImportFile $file  */
             if (!$this->_checkState($properties, rc__('ROKGALLERY_CREATE_UPDATE'))) {
                 return;
             }
             if ($file->isCompleted()) {
                 continue;
             }
             RokGallery_Doctrine::getConnection()->beginTransaction();
             $gallery = RokGallery_Model_GalleryTable::getSingle($properties['galleryId']);
             if ($gallery === false) {
                 throw new RokGallery_Job_Exception(rc__('ROKGALLERY_NOT_A_VALID_GALLERY'));
             }
             $full_file = RokGallery_Model_FileTable::getSingle($file->getId());
             if ($full_file === false) {
                 $file->setStatus(rc__('ROKGALLERY_UNABLE_TO_FIND_FILE'));
                 $file->setError(true);
                 RokGallery_Doctrine::getConnection()->commit();
                 continue;
             }
             if ($gallery && $full_file) {
                 $full_file->updateSlicesForGallery($gallery);
             }
             $file->setCompleted();
             $percent = (int) (($key + 1) / $total_files * 100);
             $this->_job->setProperties($properties);
             $this->_job->save(rc__('ROKGALLERY_UPDATED_GALLERY_SLICE_FOR_FILE_N', $full_file->title), $percent);
             RokGallery_Doctrine::getConnection()->commit();
         }
         $this->_job->Complete(rc__('ROKGALLERY_GALLERY_UPDATE_COMPLETE'));
         if (RokGallery_Config::getOption(RokGallery_Config::OPTION_AUTO_CLEAR_SUCCESSFUL_JOBS, false)) {
             sleep(5);
             $this->_job->Delete();
         }
         return;
     } catch (Exception $e) {
         RokGallery_Doctrine::getConnection()->rollback();
         $this->_job->Error($e->getMessage());
         return;
     }
 }
Пример #4
0
 /**
  */
 public function process()
 {
     try {
         /** @var $properties RokGallery_Job_Property_FileTags[] */
         $properties = $this->_job->getProperties();
         $total_files = count($properties);
         foreach ($properties as $key => &$tagAddition) {
             // keep bumping the time as log as a file doesnt take 30 seconds or more
             if (!$this->_checkState($properties, rc__('ROKGALLERY_CREATE_UPDATE'))) {
                 return;
             }
             if ($tagAddition->isCompleted()) {
                 continue;
             }
             RokGallery_Doctrine::getConnection()->beginTransaction();
             $file = RokGallery_Model_FileTable::getSingle($tagAddition->getFileId());
             if (!$file) {
                 $tagAddition->setStatus(rc__('ROKGALLERY_UNABLE_TO_FIND_FILE'));
                 $tagAddition->setError(true);
                 RokGallery_Doctrine::getConnection()->commit();
                 continue;
             }
             RokGallery_Model_FileTable::addTagsToFile($file, $tagAddition->getTags());
             $tagAddition->setCompleted();
             $percent = (int) (($key + 1) / $total_files * 100);
             $this->_job->setProperties($properties);
             $this->_job->save(rc__('ROKGALLERY_ADDED_TAGS_TO_FILE_N', $file->title), $percent);
             RokGallery_Doctrine::getConnection()->commit();
         }
         $this->_job->Complete(rc__('ROKGALLERY_TAG_ADDITION_COMPLETE'));
         if (RokGallery_Config::getOption(RokGallery_Config::OPTION_AUTO_CLEAR_SUCCESSFUL_JOBS, false)) {
             sleep(5);
             $this->_job->Delete();
         }
         return;
     } catch (Exception $e) {
         RokGallery_Doctrine::getConnection()->rollback();
         $this->_job->Error($e->getMessage());
         return;
     }
 }
Пример #5
0
 /**
  */
 public function process()
 {
     try {
         /** @var RokGallery_Job_Property_ImportFile[] $import_files  */
         $import_files = $this->_job->getProperties();
         $total_files = count($import_files);
         foreach ($import_files as $key => &$import_file) {
             $this->_job->refreshState();
             if (!$this->_checkState($properties, 'Import')) {
                 return;
             }
             if ($import_file->isCompleted()) {
                 continue;
             }
             RokGallery_Doctrine::getConnection()->beginTransaction();
             $file = RokGallery_Model_File::createNew($import_file->getFilename(), $import_file->getPath());
             // If we need to check to make sure it is not a duplicated file
             if (RokGallery_Config::getOption(RokGallery_Config::OPTION_ALLOW_DUPLICATE_FILES, true) == false && RokGallery_Model_FileTable::getMD5($file->md5) !== false && RokGallery_Model_FileTable::getMD5($file->md5)->count() > 0) {
                 throw new RokGallery_Job_Exception(rc__('ROKGALLERY_A_MATCHING_FILE_FOR_N_IN_SYSTEM', $file->filename));
             }
             // Copy file to fine directory
             $basepath = dirname($file->getFullPath());
             if (!file_exists($basepath)) {
                 @mkdir($basepath, 0777, true);
                 RokGallery_Queue_DirectoryCreate::add($basepath);
             }
             if (!(file_exists($basepath) && is_dir($basepath) && is_writable($basepath))) {
                 throw new RokGallery_Job_Exception(rc__('ROKGALLERY_UNABLE_TO_CREATE_OR_WRITE_TO_THE_DIR_N', $basepath));
             }
             // Move the file to its final location
             $endpath = $file->getFullPath();
             rename($import_file->getPath(), $endpath);
             // update the image file info
             $file_image_info = @getimagesize($endpath);
             $file->xsize = $file_image_info[0];
             /// x size
             $file->ysize = $file_image_info[1];
             /// y size
             // Create the initial admin slice
             $this->createInitialAdminSlice($file);
             // Save the file to the db;
             $file->save();
             $import_file->setCompleted();
             $percent = (int) (($key + 1) / $total_files * 100);
             $this->_job->setProperties($import_files);
             $this->_job->save(rc__('ROKGALLERY_IMPORTED_FILE_N', $import_file->getFilename()), $percent);
             RokGallery_Doctrine::getConnection()->commit();
             $file->free(true);
         }
         $this->_job->Complete('Importing Complete');
         if (RokGallery_Config::getOption(RokGallery_Config::OPTION_AUTO_CLEAR_SUCCESSFUL_JOBS, false)) {
             sleep(5);
             $this->_job->Delete();
         }
         return;
     } catch (Exception $e) {
         RokGallery_Doctrine::getConnection()->rollback();
         $this->_job->Error($e->getMessage());
         return;
     }
 }
Пример #6
0
 /**
  * Removes an array of tags to a {@link RokGallery_Model_File} object
  * $params object should be a json like
  * <code>
  * {
  *  'id': 1,
  *  'tags':['tag1','tag2']
  * }
  * </code>
  *
  * @param  $params
  * @return RokCommon_Ajax_Result
  */
 public function removeTags($params)
 {
     $result = new RokCommon_Ajax_Result();
     try {
         RokGallery_Doctrine::getConnection()->beginTransaction();
         $file = RokGallery_Model_FileTable::getSingle($params->id);
         if ($file === false) {
             throw new RokCommon_Ajax_Exception(rc__('ROKGALLERY_UNABLE_TO_FIND_FILE'));
         }
         RokGallery_Model_FileTable::removeTagsFromFile($file, $params->tags);
         RokGallery_Doctrine::getConnection()->commit();
         $file->imageurl;
         $file->Tags;
         foreach ($file->Slices as &$slice) {
             $slice->populateFilterInfo();
             $slice->manipulations = RokGallery_Manipulation_Helper::prepSerializedForJson($slice->manipulations);
             $slice->clearRelated('File');
             $slice->Tags;
             $slice->FileTags;
             $slice->Gallery;
         }
         $result->setPayload(array('file' => $file->toJsonableArray()));
     } catch (Exception $e) {
         RokGallery_Doctrine::getConnection()->rollback();
         throw $e;
     }
     return $result;
 }
Пример #7
0
 /**
  * Delete the file and all associated rows (done by foreign keys) and files
  * $params object should be a json like
  * <code>
  * {
  *  "page": 3,
  *  "items_per_page":6
  *  "filters": [{ type: "title", operator: "is not", query: "example"},{ type: "title", operator: "is not", query: "example"}]
  *  "get_remaining": true
  * }
  * </code>
  *
  * @param $params
  * @return RokCommon_Ajax_Result
  */
 public function getPage($params)
 {
     $result = new RokCommon_Ajax_Result();
     try {
         $html = '';
         $filters = array();
         foreach ($params->filters as $filter) {
             $filters[] = RokGallery_Filter_Item::createFromJson($filter);
         }
         $model = new RokGallery_Admin_MainPage();
         $order_by = isset($params->order->order_by) ? $params->order->order_by : null;
         $order_direction = isset($params->order->order_direction) ? $params->order->order_direction : null;
         $files = $model->getFiles($params->page, $params->items_per_page, $filters, $order_by, $order_direction);
         $pager = $model->getPager($params->page, $params->items_per_page, $filters, $order_by, $order_direction);
         $model->clearPager();
         $total_items_count = $pager->getResultsInPage();
         $current_page = $params->page;
         $next_page = $current_page == 1 ? 3 : $current_page + 1;
         $next_page = $current_page == $pager->getLastPage() ? false : $next_page;
         $remaining_pages = $next_page ? $pager->getLastPage() - $current_page : 0;
         $items_per_page = RokGallery_Config::getOption(RokGallery_Config::OPTION_ADMIN_ITEMS_PER_PAGE, 6);
         $passed_items_per_page = $items_per_page;
         $items_per_page = $current_page == 1 ? $items_per_page * 2 : $items_per_page;
         $items_per_row = RokGallery_Config::getOption(RokGallery_Config::OPTION_ADMIN_ITEMS_PER_ROW, 3);
         $that->files =& $files;
         $that->items_per_page = $items_per_page;
         $that->items_per_row = $items_per_row;
         ob_start();
         $that->row_entry_number = 0;
         $that->item_number = 1;
         $that->items_to_be_rendered = $pager->getResultsInPage();
         foreach ($that->files as $that->file) {
             if (!isset($params->composite) || !isset($params->composite->context) || !isset($params->composite->layout)) {
                 echo RokCommon_Composite::get('com_rokgallery.default')->load('default_row.php', array('that' => $that));
             } else {
                 echo RokCommon_Composite::get($params->composite->context)->load($params->composite->layout . '.php', array('that' => $that));
             }
             $that->row_entry_number++;
             $that->item_number++;
         }
         $html .= ob_get_clean();
         if (isset($params->get_remaining) && $params->get_remaining) {
             for ($params->page++; $params->page <= $pager->getLastPage(); $params->page++) {
                 $more_files = $model->getFiles($params->page, $params->items_per_page, $filters, $order_by, $order_direction);
                 $pager = $model->getPager($params->page, $params->items_per_page, $filters, $order_by, $order_direction);
                 $model->clearPager();
                 $total_items_count = $total_items_count + $pager->getResultsInPage();
                 $current_page = $params->page;
                 $next_page = $current_page == 1 ? 3 : $current_page + 1;
                 $next_page = $current_page == $pager->getLastPage() ? false : $next_page;
                 $remaining_pages = $next_page ? $pager->getLastPage() - $current_page : 0;
                 $items_per_page = RokGallery_Config::getOption(RokGallery_Config::OPTION_ADMIN_ITEMS_PER_PAGE, 6);
                 $passed_items_per_page = $items_per_page;
                 $items_per_page = $current_page == 1 ? $items_per_page * 2 : $items_per_page;
                 $items_per_row = RokGallery_Config::getOption(RokGallery_Config::OPTION_ADMIN_ITEMS_PER_ROW, 3);
                 $that->files =& $more_files;
                 $that->items_per_page = $items_per_page;
                 $that->items_per_row = $items_per_row;
                 ob_start();
                 $that->row_entry_number = 0;
                 $that->item_number = 1;
                 $that->items_to_be_rendered = $pager->getResultsInPage();
                 foreach ($that->files as $that->file) {
                     if (!isset($params->composite) || !isset($params->composite->context) || !isset($params->composite->layout)) {
                         echo RokCommon_Composite::get('com_rokgallery.default')->load('default_row.php', array('that' => $that));
                     } else {
                         echo RokCommon_Composite::get($params->composite->context)->load($params->composite->layout . '.php', array('that' => $that));
                     }
                     $that->row_entry_number++;
                     $that->item_number++;
                 }
                 $html .= ob_get_clean();
             }
         }
         $result->setPayload(array('next_page' => $next_page, 'last_page' => $pager->getLastPage(), 'items_per_page' => $passed_items_per_page, 'items_returned' => $total_items_count, 'more_pages' => $next_page == false ? false : true, 'remaining_pages' => $remaining_pages, 'total_items_in_filter' => $pager->getNumResults(), 'total_items_shown' => $pager->getLastIndice(), 'total_items' => RokGallery_Model_FileTable::getTotalFileCount(), 'html' => $html));
     } catch (Exception $e) {
         throw $e;
     }
     return $result;
 }
Пример #8
0
 /**
  * Update the slice
  * $params object should be a json like
  * <code>
  * {
  *  'id': 1
  *  'slice':{'title':'new title','description':'new description'}
  * }
  * </code>
  *
  * @param $params
  * @return RokCommon_Ajax_Result
  */
 public function create($params)
 {
     $result = new RokCommon_Ajax_Result();
     try {
         $file = RokGallery_Model_FileTable::getSingle($params->fileId);
         /** @var $slice RokGallery_Model_Slice */
         $slice =& RokGallery_Model_Slice::createNew($file);
         if ($slice === false) {
             throw new RokCommon_Ajax_Exception(rc__('ROKGALLERY_UNABLE_TO_FIND_SLICE_N', $params->id));
         }
         foreach ($params->slice as $field => $value) {
             // change the manipulation format if passed
             if ($field == 'manipulations') {
                 $value = RokGallery_Manipulation_Helper::unserializeFromJson($value);
             }
             // Add any tags if they are passed
             if ($field == 'Tags') {
                 if (!empty($value) && is_array($value)) {
                     foreach ($value as $tag) {
                         $slice->addTag($tag);
                     }
                 }
                 continue;
             }
             $slice->{$field} = $value;
         }
         $slice->save();
         $slice->populateFilterInfo();
         $slice->manipulations = RokGallery_Manipulation_Helper::prepSerializedForJson($slice->manipulations);
         $slice->Tags;
         $slice->FileTags;
         $slice->File;
         $result->setPayload(array('slice' => $slice->toJsonableArray()));
     } catch (Exception $e) {
         throw $e;
     }
     return $result;
 }
Пример #9
0
 /**
  * Get the basic file info and supporting slices/tags
  * $params object should be a json like
  * <code>
  * {
  *  "id": 1
  *  "gallery": {
  *      "name": "Gallery name",
  *      "width": 100
  *      "height": 100
  *      "thumb_xsize": 50
  *      "thumb_ysize": 50
  *   }
  *  "order": [1, 2, 10, 3, 8]
  * }
  * </code>
  *
  * @param $params
  * @return RokCommon_Ajax_Result
  */
 public function update($params)
 {
     $result = new RokCommon_Ajax_Result();
     /** @var Doctrine_Transaction $tx  */
     $tx = RokGallery_Doctrine::getConnection()->transaction;
     $tx->setIsolation('REPEATABLE READ');
     try {
         $tx->beginTransaction();
         $gallery = RokGallery_Model_GalleryTable::getSingle($params->id);
         if ($gallery === false) {
             throw new RokCommon_Ajax_Exception(rc__('ROKGALLERY_UNABLE_TO_FIND_GALLERY_WITH_ID_N_TO_UPDATE', $params->id));
         }
         $oldfiletags = $gallery->filetags;
         $update_slices = false;
         foreach ($params->gallery as $field => $value) {
             if (isset($gallery->{$field})) {
                 // see if we need to update the slices
                 if ($field == 'width' || $field == 'height' || $field == 'keep_aspect' || $field == 'thumb_xsize' || $field == 'thumb_ysize' || $field == 'thumb_background' || $field == 'thumb_keep_aspect') {
                     $update_slices = true;
                 }
                 if ($value == '') {
                     $value = null;
                 }
                 $gallery->{$field} = $value;
             }
         }
         $gallery->save();
         $result->setPayload(array('gallery' => $gallery->toJsonableArray()));
         // get list of files to process
         $fileids = RokGallery_Model_FileTable::getIdsByTags($gallery->filetags);
         // get list of files to remove
         $original_fileids = RokGallery_Model_FileTable::getIdsByTags($oldfiletags);
         // get the list of file ids to remove or add
         $remove_fileids = array_diff($original_fileids, $fileids);
         $new_fileids = array_diff($fileids, $original_fileids);
         // just return if there are no files to process
         if ((empty($fileids) || $fileids === false) && (empty($remove_fileids) || $remove_fileids === false)) {
             $tx->commit();
             return $result;
         }
         /** @var RokGallery_Job_Property_GalleryFile[] $files  */
         $files = array();
         // Add any new files to the job
         if (!empty($new_fileids)) {
             foreach ($new_fileids as $new_fileid) {
                 $files[] = new RokGallery_Job_Property_GalleryFile($new_fileid);
             }
         }
         // if we need to update all slices populate them
         if ($update_slices) {
             foreach ($fileids as $fileid) {
                 $files[] = new RokGallery_Job_Property_GalleryFile($fileid);
             }
         }
         $remove_slices = array();
         // remove all non linked slices
         foreach ($gallery->Slices as $key => &$slice) {
             /** @var RokGallery_Model_Slice $slice */
             if (in_array($slice->File->id, $remove_fileids)) {
                 $remove_slices[] = $slice->id;
             }
         }
         foreach ($remove_slices as $remove_slice_id) {
             $remove_slice = RokGallery_Model_SliceTable::getSingle($remove_slice_id);
             if (RokGallery_Config::getOption(RokGallery_Config::OPTION_GALLERY_REMOVE_SLICES, false)) {
                 $remove_slice->delete();
             } else {
                 $remove_slice->unlink('Gallery');
                 $remove_slice->save();
             }
         }
         // if there are no files to process just return
         if (empty($files)) {
             $tx->commit();
             return;
         }
         $properties = array("galleryId" => $gallery->id, "files" => $files);
         $job = RokGallery_Job::create(RokGallery_Job::TYPE_UPDATEGALLERY);
         $job->propertires = serialize($properties);
         $job->setProperties($properties);
         $job->save();
         $tx->commit();
         // Disconnect and process job
         $this->sendDisconnectingReturn($result);
         $job->Ready();
         $job->Run('Starting Gallery Update');
         $job->process();
         die;
     } catch (Exception $e) {
         $tx->rollback();
         throw $e;
     }
 }