public function Modificar() { $data = $this->VerPerfil(); $db = new db(); $db->connect(); $C = new ActiveRecord('fk_perfiles'); $C->fields['nombre_perfil'] = $this->nombre_perfil; $C->fields['descripcion'] = $this->descripcion; if ($data) { $C->fields['id_perfil'] = $this->id_perfil; $C->update(); } else { $C->insert(); } $db->close(); }
/** * @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(); }
public function update() { global $ilUser; $this->setOwner($ilUser->getId()); $this->setUpdateDate(time()); parent::update(); }
public function update() { global $ilUser; $this->setOwner($ilUser->getId()); $this->setUpdateDate(time()); if (!$this->hasChecks() and $this->getStatus() == self::STATUS_ACTIVE) { ilUtil::sendInfo(ilUserDefaultsPlugin::getInstance()->txt('msg_activation_failed')); ilUtil::sendInfo(ilUserDefaultsPlugin::getInstance()->txt('msg_activation_failed'), true); $this->setStatus(self::STATUS_INACTIVE); } parent::update(); }
private function saveLines() { $tableId = $this->tableId; $total = fk_post($tableId . '_tot'); for ($i = 1; $i <= $total; $i++) { $id_rec = fk_post($tableId . '_recId-' . $i); $Ar = new ActiveRecord($this->table_name); if ($id_rec > 0) { //UPDATE //procesar fields to save foreach ($this->fields_to_save as $key => $value_from) { $arr_src = array('{table-id}', '{row-id}'); $arr_repl = array($tableId . '_', '-' . $i); $value = str_replace($arr_src, $arr_repl, $value_from); $Ar->fields[$key] = fk_post($value); } $Ar->fields[$this->record_id_name] = $id_rec; $Ar->display_queries = true; $Ar->update(); } else { //INSERT //procesar fields to save foreach ($this->fields_to_save as $key => $value_from) { $arr_src = array('{table-id}', '{row-id}'); $arr_repl = array($tableId . '_', '-' . $i); $value = str_replace($arr_src, $arr_repl, $value_from); $Ar->fields[$key] = fk_post($value); } $Ar->insert(); } } }
/** * Also update placeholder values and settings. * If the certificate type did change, delete old settings/placeholder values and create new default ones from new type. * */ public function update() { /** @var $setting srCertificateDefinitionSetting */ /** @var $pl srCertificatePlaceholderValue */ if ($this->type_changed) { $this->signature_id = 0; // Reset signature } parent::update(); // If the type did change, we destroy all settings + placeholder values from the old type and create new ones if ($this->type_changed) { foreach ($this->getSettings() as $setting) { $setting->delete(); } foreach ($this->getCustomSettings() as $custom_setting) { $custom_setting->delete(); } foreach ($this->getPlaceholderValues() as $pl) { $pl->delete(); } $this->createSettings(); $this->createPlaceholderValues(); } else { foreach ($this->getSettings() as $setting) { $setting->update(); } foreach ($this->getCustomSettings() as $setting) { $setting->update(); } foreach ($this->getPlaceholderValues() as $pl) { $pl->update(); } } }
public static function generarConsecutivo($codigo, $increment = true) { // GenerarConsecutivo $Configsys = new ActiveRecord('config_sys'); $tot_contador = $Configsys->find_where('config_code = "' . $codigo . '" '); if ($tot_contador == 0) { // No existe $numero_consecutivo = 1; if ($increment == true) { $Configsys->fields['config_code'] = $codigo; $Configsys->fields['config_value'] = $numero_consecutivo; $Configsys->insert(); } } else { // Si existe $numero_consecutivo = $Configsys->fields['config_value'] + 1; // INCREMENTA if ($increment == true) { $Configsys->fields['config_value'] = $numero_consecutivo; $numero_consecutivo = $Configsys->fields['config_value']; $Configsys->update(); } } return $numero_consecutivo; }
public function ModificarAdmin() { $data = $this->VerUsuario(); $db = new db(); $db->connect(); $C = new ActiveRecord('usuarios'); $C->fields['usuario'] = $this->usuario; $C->fields['nombre'] = $this->nombre; $C->fields['apellidos'] = $this->apellidos; $C->fields['id_tipo'] = $this->id_tipo; $un = strtoupper($this->nombre[0] . $this->apellidos[0]); $x = ''; do { $username = $un . $x; $sql = 'SELECT * FROM usuarios WHERE usuario = "' . $username . '"'; if ($data) { $sql .= ' AND id_usuario != ' . $this->id_usuario; } $db->query($sql); $f = $db->next(); $x++; } while ($f != 0); $C->fields['usuario'] = $username; if ($this->password != '') { $C->fields['password'] = md5($this->password); } $C->fields['email'] = $this->email; if ($this->id_perfil != 0) { $C->fields['id_perfil'] = $this->id_perfil; } if ($data) { $C->fields['id_usuario'] = $this->id_usuario; $C->update(); } else { $C->fields['fecha_reg'] = $this->fecha_reg; $C->insert(); } $db->close(); }
protected function update() { $this->executePlugins($this, 'update'); $res = parent::update(); $this->executePlugins($this, 'save'); return $res; }
public function update() { parent::update(); if ($this->hasStatusChanged()) { // Status has changed $this->event_handler->raise('Certificate/srCertificate', 'changeStatus', array('object' => $this, 'old_status' => $this->old_status, 'new_status' => $this->status)); } $this->event_handler->raise('Certificate/srCertificate', 'update', array('object' => $this)); $this->old_status = null; }
public function send_password() { Context::get('db')->start_transaction(); // set new password $this->password = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'), 0, 8); $this->create_new_salt(); $this->encrypt_password($this->password, $this->salt); parent::update(); // send email text_mail($this->email, "임시 비밀번호 발급 안내", "임시 비밀번호는 \"{$this->password}\" 입니다."); Context::get('db')->commit(); }
public function update() { $this->mapToActiveRecord(); parent::update(); }