Esempio n. 1
0
 function test_should_not_insert_null_string_on_empty_binary_fields()
 {
     $this->installAndIncludeModels(array('Hybrid' => 'id,data binary'));
     $EmptyFile =& $this->Hybrid->create(array());
     $EmptyFile->reload();
     $this->assertNull($EmptyFile->get('data'));
 }
 public function create()
 {
     parent::create();
     $this->type = srCertificateType::find($this->getTypeId());
     $this->createSettings();
     $this->createPlaceholderValues();
 }
Esempio n. 3
0
 function test_handle_null_date_as_null()
 {
     $this->installAndIncludeModels(array('Hybrid' => 'id,name,born date'));
     $Hans =& $this->Hybrid->create(array('name' => 'Hans', 'born' => null));
     $Hans->reload();
     $this->assertNull($Hans->born);
 }
Esempio n. 4
0
 public static function create($values = array(), $save = false)
 {
     try {
         $Mapping = parent::create($values, $save);
     } catch (\DuplicateKeyException $e) {
         $Mapping = static::getByWhere(array('ContextClass' => $values['Context'] ? $values['Context']->getRootClass() : $values['ContextClass'], 'Connector' => $values['Connector'], 'ExternalKey' => $values['ExternalKey'], 'ExternalIdentifier' => $values['ExternalIdentifier']));
         $Mapping->ContextID = $values['Context'] ? $values['Context']->ID : $values['ContextID'];
         if ($save) {
             $Mapping->save();
         }
     }
     return $Mapping;
 }
Esempio n. 5
0
 /**
  * @return bool
  */
 public function saveObject()
 {
     if (!$this->beforeSave()) {
         return false;
     }
     global $ilUser;
     /**
      * @var ilObjUser $ilUser
      */
     if (!$this->setArFieldsAfterSubmit()) {
         return false;
     }
     $modified_by_field = $this->getFields()->getModifiedByField();
     if ($modified_by_field) {
         $set_modified_by_function = $modified_by_field->getSetFunctionName();
         $this->ar->{$set_modified_by_function}($ilUser->getId());
     }
     $modification_date_field = $this->getFields()->getModificationDateField();
     if ($modification_date_field) {
         $set_modification_date_function = $modification_date_field->getSetFunctionName();
         $datetime = new ilDateTime(time(), IL_CAL_UNIX);
         $this->ar->{$set_modification_date_function}($datetime);
     }
     if ($this->ar->getPrimaryFieldValue() != 0) {
         $this->ar->update();
     } else {
         $created_by_field = $this->getFields()->getCreatedByField();
         if ($created_by_field) {
             $set_created_by_function = $created_by_field->getSetFunctionName();
             $this->ar->{$set_created_by_function}($ilUser->getId());
         }
         $creation_date_field = $this->getFields()->getCreationDateField();
         if ($creation_date_field) {
             $set_creation_date_function = $creation_date_field->getSetFunctionName();
             $datetime = new ilDateTime(time(), IL_CAL_UNIX);
             $this->ar->{$set_creation_date_function}($datetime);
         }
         $this->ar->create();
     }
     return $this->afterSave();
 }
Esempio n. 6
0
 public function create()
 {
     global $ilUser;
     $this->setOwner($ilUser->getId());
     $this->setUpdateDate(time());
     $this->setCreateDate(time());
     parent::create();
 }
 public function create()
 {
     global $ilUser;
     $this->setOwner($ilUser->getId());
     $this->setUpdateDate(time());
     $this->setCreateDate(time());
     if (!$this->hasChecks()) {
         $this->setStatus(self::STATUS_INACTIVE);
     }
     parent::create();
 }
Esempio n. 8
0
 public function setUp()
 {
     $this->installAndIncludeModels(array('Picture', 'Thumbnail'));
     $Picture = $this->Picture->create(array('title' => 'This is not a picture'));
     $Picture->main_thumbnail->create(array('caption' => 'It cant have a thumbnail'));
 }
 public function create()
 {
     parent::create();
     $this->createDefaultSettings();
 }
 /**
  * Create certificate
  * Before calling parent::create(), the valid_from and valid_to are are calculated based on the chosen validity in the definition
  * If there exists already a certificate for the given definition and user, the version is increased
  *
  * @throws Exception
  */
 public function create()
 {
     if (is_null($this->getDefinition()) || !$this->getUserId()) {
         throw new Exception("srCertificate::create() must have valid Definition and User-ID");
     }
     // Set validity dates
     $valid_from = date("Y-m-d");
     $valid_to = $this->calculateValidTo();
     $this->setValidFrom($valid_from);
     $this->setValidTo($valid_to);
     // Check if we need to increase the version if a certificate for same user & definition already exists
     /** @var srCertificate $cert_last_version */
     $certs = srCertificate::where(array('definition_id' => $this->getDefinitionId(), 'user_id' => $this->getUserId()))->orderBy('file_version', 'DESC');
     $cert_last_version = $certs->first();
     if (!is_null($cert_last_version)) {
         $this->setFileVersion((int) $cert_last_version->getFileVersion() + 1);
     }
     // Remove active flag from other versions of this certificate
     /** @var srCertificate $cert */
     foreach ($certs->get() as $cert) {
         $cert->setActive(false);
         $cert->save();
     }
     // Set active flag
     $this->setActive(true);
     // Set the filename for certificate
     $this->filename = $this->createFilename();
     $this->created_at = date('Y-m-d H:i:s');
     parent::create();
     $this->event_handler->raise('Certificate/srCertificate', 'create', array('object' => $this));
 }
Esempio n. 11
0
 public function create()
 {
     $this->mapToActiveRecord();
     parent::create();
 }