Esempio n. 1
0
 /**
  * @param int $pid
  * @return Mail
  */
 public function setPid($pid)
 {
     parent::setPid($pid);
     return $this;
 }
Esempio n. 2
0
 /**
  * Overrides the isPropertyDirty method. See http://forge.typo3.org/issues/8952
  * for further information.
  *
  * @param mixed $previousValue
  * @param mixed $currentValue
  *
  * @return boolean
  */
 protected function isPropertyDirty($previousValue, $currentValue)
 {
     if ($currentValue instanceof Forum || $currentValue instanceof Topic) {
         return FALSE;
     } else {
         return parent::isPropertyDirty($previousValue, $currentValue);
     }
 }
 /**
  * Copies the FAL relations of the given field.
  *
  * @param \TYPO3\CMS\Extbase\DomainObject\AbstractEntity $model
  * @param array $originalRow
  * @param string $originalField
  * @param array $targetConfig
  */
 protected function migrateFalField($model, array $originalRow, $originalField, array $targetConfig)
 {
     if (empty($targetConfig['tableField'])) {
         throw new \RuntimeException(sprintf('tableField config is missing for fal migration for %s field %s', $this->originalTable, $originalField));
     }
     $db = $this->getDatabaseConnection();
     $currentReferences = $db->exec_SELECTgetRows('*', 'sys_file_reference', 'tablenames=' . $db->fullQuoteStr($this->originalTable, 'sys_file_reference') . ' AND fieldname=' . $db->fullQuoteStr($originalField, 'sys_file_reference') . ' AND uid_foreign=' . (int) $originalRow['uid']);
     foreach ($currentReferences as $reference) {
         $existingReferenceCount = $db->exec_SELECTcountRows('uid', 'sys_file_reference', 'tx_czsimplecalimportercal_imported_uid=' . (int) $reference['uid']);
         if ($existingReferenceCount > 0) {
             continue;
         }
         $reference['tablenames'] = $this->targetTable;
         $reference['fieldname'] = $targetConfig['tableField'];
         $reference['uid_foreign'] = (int) $model->getUid();
         $reference['tx_czsimplecalimportercal_imported_uid'] = $reference['uid'];
         unset($reference['uid']);
         $db->exec_INSERTquery('sys_file_reference', $reference);
     }
 }
 /**
  * Creates a sys_file_reference record
  *
  * @param string $table                                  table    the file reference relates to
  * @param string $field                                  field    the file reference relates to
  * @param \TYPO3\CMS\Extbase\DomainObject\AbstractEntity $record  record the file reference relates to
  * @param \TYPO3\CMS\Core\Resource\File                  $file    file the file reference relates to
  * @return array                                                  error log if an error occurs
  */
 protected function addFileReference($table, $field, \TYPO3\CMS\Extbase\DomainObject\AbstractEntity $record, \TYPO3\CMS\Core\Resource\File $file)
 {
     // Make user admin temporarily to circumvent permission issues
     $adminStatus = $GLOBALS['BE_USER']->user['admin'];
     $GLOBALS['BE_USER']->user['admin'] = true;
     // Define content for file reference record
     $data = array();
     $data['sys_file_reference']['NEW1234'] = array('uid_local' => $file->getUid(), 'uid_foreign' => $record->getUid(), 'tablenames' => $table, 'fieldname' => $field, 'pid' => $record->getPid(), 'table_local' => 'sys_file');
     // Create relation to main record
     $data[$table][$record->getUid()] = array($field => 'NEW1234');
     // Use TYPO3 data handler to simulate form submit in backend
     $tce = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
     $tce->start($data, array());
     $tce->process_datamap();
     // Revert original admin status
     $GLOBALS['BE_USER']->user['admin'] = $adminStatus;
     return $tce->errorLog;
 }
Esempio n. 5
0
 /**
  * @param \TYPO3\CMS\Extbase\DomainObject\AbstractEntity $model
  * @param array                                          $mapping
  * @param                                                $entry
  *
  * @return \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
  */
 protected function mapModel($model, $mapping, $entry)
 {
     if (is_array($mapping)) {
         foreach ($mapping as $key => $value) {
             $model->_setProperty($value, $entry[$key]);
         }
     }
     return $model;
 }
 /**
  * Returns an array wih the absolute path to all FAL files in the given object-property
  *
  * @param AbstractEntity $object
  * @param string $propertyName
  * @return array
  */
 protected function getAttachmentsFromProperty($object, $propertyName)
 {
     $attachments = [];
     $property = $object->_getProperty($propertyName);
     if ($property instanceof \TYPO3\CMS\Extbase\Persistence\ObjectStorage) {
         /** @var $property \TYPO3\CMS\Extbase\Persistence\ObjectStorage */
         foreach ($property as $object) {
             if ($object instanceof \TYPO3\CMS\Extbase\Domain\Model\FileReference) {
                 $attachments[] = $object->getOriginalResource()->getForLocalProcessing(false);
             }
         }
     }
     if ($property instanceof \TYPO3\CMS\Extbase\Domain\Model\FileReference) {
         /** @var $property \TYPO3\CMS\Extbase\Domain\Model\FileReference */
         $attachments[] = $property->getOriginalResource()->getForLocalProcessing(false);
     }
     return $attachments;
 }
Esempio n. 7
0
 /**
  * Check if the given attribute on the given model is dirty.
  *
  * @param  \TYPO3\CMS\Extbase\DomainObject\AbstractEntity  $entity  Entity
  * @param  string  $attr  Lower camel-cased attribute name
  * @return  boolean
  */
 protected function isDirty(AbstractEntity $entity, $attr)
 {
     $attr = (string) $attr;
     if ($entity->_isDirty($attr)) {
         $cls = str_replace('\\', '_', get_class($entity));
         $uid = (string) $entity->getUid();
         $val = $entity->{'get' . ucwords($attr)}();
         if (!isset($this->dirty[$cls])) {
             $this->dirty[$cls] = [];
         }
         if (!isset($this->dirty[$cls][$uid])) {
             $this->dirty[$cls][$uid] = [];
         }
         if (!isset($this->dirty[$cls][$uid][$attr])) {
             $this->dirty[$cls][$uid][$attr] = null;
         }
         if ($this->dirty[$cls][$uid][$attr] !== $val) {
             $this->dirty[$cls][$uid][$attr] = $val;
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }