Esempio n. 1
0
 public function loadUserColumnFields(Entity $entity)
 {
     $pdo = $this->getEntityManager()->getPDO();
     $sql = "\n            SELECT is_read AS 'isRead', is_important AS 'isImportant' FROM email_user\n            WHERE\n                deleted = 0 AND\n                user_id = " . $pdo->quote($this->getUser()->id) . " AND\n                email_id = " . $pdo->quote($entity->id) . "\n        ";
     $sth = $pdo->prepare($sql);
     $sth->execute();
     if ($row = $sth->fetch(\PDO::FETCH_ASSOC)) {
         $isRead = !empty($row['isRead']) ? true : false;
         $isImportant = !empty($row['isImportant']) ? true : false;
         $entity->set('isRead', $isRead);
         $entity->set('isImportant', $isImportant);
     } else {
         $entity->set('isRead', null);
         $entity->clear('isImportant');
     }
 }
Esempio n. 2
0
 public function prepareEntityForOutput(Entity $entity)
 {
     foreach ($this->internalFields as $field) {
         $entity->clear($field);
     }
 }
Esempio n. 3
0
 public function prepareEntityForOutput(Entity $entity)
 {
     foreach ($this->internalAttributeList as $field) {
         $entity->clear($field);
     }
     foreach ($this->getAcl()->getScopeForbiddenAttributeList($entity->getEntityType(), 'read') as $attribute) {
         $entity->clear($attribute);
     }
 }
Esempio n. 4
0
 public function save(Entity $entity, array $options = array())
 {
     $nowString = date('Y-m-d H:i:s', time());
     $restoreData = array();
     if ($entity->isNew()) {
         if (!$entity->has('id')) {
             $entity->set('id', Util::generateId());
         }
         if ($entity->hasField('createdAt')) {
             $entity->set('createdAt', $nowString);
         }
         if ($entity->hasField('modifiedAt')) {
             $entity->set('modifiedAt', $nowString);
         }
         if ($entity->hasField('createdById')) {
             $entity->set('createdById', $this->entityManager->getUser()->id);
         }
         if ($entity->has('modifiedById')) {
             $restoreData['modifiedById'] = $entity->get('modifiedById');
         }
         if ($entity->has('modifiedAt')) {
             $restoreData['modifiedAt'] = $entity->get('modifiedAt');
         }
         $entity->clear('modifiedById');
     } else {
         if (empty($options['silent'])) {
             if ($entity->hasField('modifiedAt')) {
                 $entity->set('modifiedAt', $nowString);
             }
             if ($entity->hasField('modifiedById')) {
                 $entity->set('modifiedById', $this->entityManager->getUser()->id);
             }
         }
         if ($entity->has('createdById')) {
             $restoreData['createdById'] = $entity->get('createdById');
         }
         if ($entity->has('createdAt')) {
             $restoreData['createdAt'] = $entity->get('createdAt');
         }
         $entity->clear('createdById');
         $entity->clear('createdAt');
     }
     $this->restoreData = $restoreData;
     $result = parent::save($entity, $options);
     return $result;
 }
Esempio n. 5
0
 public function save(Entity $entity)
 {
     $nowString = date('Y-m-d H:i:s', time());
     $restoreData = array();
     if ($entity->isNew()) {
         if (!$entity->has('id')) {
             $entity->set('id', uniqid());
         }
         if ($entity->hasField('createdAt')) {
             $entity->set('createdAt', $nowString);
         }
         if ($entity->hasField('createdById')) {
             $entity->set('createdById', $this->entityManager->getUser()->id);
         }
         if ($entity->has('modifiedById')) {
             $restoreData['modifiedById'] = $entity->get('modifiedById');
         }
         if ($entity->has('modifiedAt')) {
             $restoreData['modifiedAt'] = $entity->get('modifiedAt');
         }
         $entity->clear('modifiedById');
         $entity->clear('modifiedAt');
     } else {
         if ($entity->hasField('modifiedAt')) {
             $entity->set('modifiedAt', $nowString);
         }
         if ($entity->hasField('modifiedById')) {
             $entity->set('modifiedById', $this->entityManager->getUser()->id);
         }
         if ($entity->has('createdById')) {
             $restoreData['createdById'] = $entity->get('createdById');
         }
         if ($entity->has('createdAt')) {
             $restoreData['createdAt'] = $entity->get('createdAt');
         }
         $entity->clear('createdById');
         $entity->clear('createdAt');
     }
     $result = parent::save($entity);
     $entity->set($restoreData);
     $this->handleEmailAddressSave($entity);
     $this->handlePhoneNumberSave($entity);
     $this->handleSpecifiedRelations($entity);
     return $result;
 }