Add new file record to database and handle callbacks.

@param stdClass $newrecord
195179
protected function create_file($newrecord) {
        global $DB;
        $newrecord->id = $DB->insert_record('files', $newrecord);

        if ($newrecord->filename !== '.') {
            // Callback for file created.
            if ($pluginsfunction = get_plugins_with_function('after_file_created')) {
                foreach ($pluginsfunction as $plugintype => $plugins) {
                    foreach ($plugins as $pluginfunction) {
                        $pluginfunction($newrecord);
                    }
                }
            }
        }
    }
312886
private function addNodeAfterProperties(Node $newNode)
    {
        $classNode = $this->getClassNode();

        // try to add after last property
        $targetNode = $this->findLastNode(function ($node) {
            return $node instanceof Node\Stmt\Property;
        }, [$classNode]);

        // otherwise, try to add after the last constant
        if (!$targetNode) {
            $targetNode = $this->findLastNode(function ($node) {
                return $node instanceof Node\Stmt\ClassConst;
            }, [$classNode]);
        }

        // add the new property after this node
        if ($targetNode) {
            $index = array_search($targetNode, $classNode->stmts);

            array_splice(
                $classNode->stmts,
                $index + 1,
                0,
                [$this->createBlankLineNode(self::CONTEXT_CLASS), $newNode]
            );

            $this->updateSourceCodeFromNewStmts();

            return;
        }

        // put right at the beginning of the class
        // add an empty line, unless the class is totally empty
        if (!empty($classNode->stmts)) {
            array_unshift($classNode->stmts, $this->createBlankLineNode(self::CONTEXT_CLASS));
        }
        array_unshift($classNode->stmts, $newNode);
        $this->updateSourceCodeFromNewStmts();
    }
798436
public function edit($recordId = 0)
    {
        $this->view = 'scaffold/edit';
        $recordId = StaticFilter::filter('number', $recordId);

        /** @var Model $record */
        $record = call_user_func_array(
            [$this->getModelName(), 'get'],
            [$recordId]
        );

        if (is_null($record)) {
            $this->addWarningMessage(
                "The {$this->get('modelSingular')} with the provided key ".
                "does not exists."
            );

            $this->redirect($this->_basePath .'/'.$this->get('modelPlural'));
            return;
        }

        $form = new Form(
            "edit-{$this->get('modelSingular')}", $this->getDescriptor()
        );

        if ($this->request->isPost()) {
            $form->setData($this->request->getPost());
            if ($form->isValid()) {
                try {
                    $modelClass = $this->getModelName();
                    /** @var Model $model */
                    $model = new $modelClass($form->getValues());
                    $model->save();
                    $name = ucfirst($this->get('modelSingular'));
                    $this->addSuccessMessage(
                        "{$name} successfully updated."
                    );
                    $pmk = $model->getPrimaryKey();
                    $this->redirect(
                        $this->_basePath .'/'.
                        $this->get('modelPlural').'/show/'.$model->$pmk
                    );
                    return;
                } catch (Database\Exception $exp) {
                    $this->addErrorMessage(
                        "Error while saving {$this->get('modelSingular')}} " .
                        "data: {$exp->getMessage()}"
                    );
                }
            } else {
                $this->addErrorMessage(
                    "Cannot save {$this->get('modelSingular')}. " .
                    "Please correct the errors bellow."
                );
            }
        } else {
            $form->setData($record->asArray());
        }
        $descriptor =  $this->getDescriptor();
        $this->set(compact('form', 'record', 'descriptor'));
    }
253848
public void addNew() throws DBException
    {
        if (((this.getRecord().getOpenMode() & DBConstants.OPEN_REFRESH_AND_LOCK_ON_CHANGE_STRATEGY) == 0)
            && ((this.getRecord().getOpenMode() & DBConstants.OPEN_READ_ONLY) != DBConstants.OPEN_READ_ONLY)
            && (this.getRecord().getCounterField() != null))
                this.getRecord().setOpenMode(this.getRecord().getOpenMode() | DBConstants.OPEN_REFRESH_AND_LOCK_ON_CHANGE_STRATEGY); // Must have for MirrorTable to sync new records
        super.addNew();
        Iterator<BaseTable> iterator = this.getTables();
        while (iterator.hasNext())
        {
            BaseTable table = iterator.next();
            if ((table != null) && (table != this.getNextTable()))
            {
                table.addNew();
            }
        }
    }
1039803
public synchronized void
addRecord(Record r, int cred, Object o) {
	Name name = r.getName();
	int type = r.getRRsetType();
	if (!Type.isRR(type))
		return;
	Element element = findElement(name, type, cred);
	if (element == null) {
		CacheRRset crrset = new CacheRRset(r, cred, maxcache);
		addRRset(crrset, cred);
	} else if (element.compareCredibility(cred) == 0) {
		if (element instanceof CacheRRset) {
			CacheRRset crrset = (CacheRRset) element;
			crrset.addRR(r);
		}
	}
}
688251
private function addBulkUpdateRecord($sObject, $objectType)
    {
        if (isset($this->bulkUpdateRecords[$objectType])
            && count($this->bulkUpdateRecords[$objectType]) == $this->bulkSaveLimit) {
            $this->flushUpdates($objectType);
        }

        $this->bulkUpdateRecords[$objectType][] = $sObject;
    }
1328237
protected static function newConnection()
    {
        static $newDb;

        if ($newDb === null) {
            $db = static::getDb();
            $className = get_class($db);
            $newDb = new $className;

            $class = new \ReflectionClass($db);
            foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
                if (!$property->isStatic()) {
                    $name = $property->getName();
                    $newDb->$name = $db->$name;
                }
            }

            $newDb->pdo = null;
        }

        return $newDb;
    }
494114
public function assign($dbRecord)
    {
        parent::assign($dbRecord);

        $oUtilsDate = \OxidEsales\Eshop\Core\Registry::getUtilsDate();

        // convert date's to international format
        $this->oxorder__oxorderdate = new \OxidEsales\Eshop\Core\Field($oUtilsDate->formatDBDate($this->oxorder__oxorderdate->value));
        $this->oxorder__oxsenddate = new \OxidEsales\Eshop\Core\Field($oUtilsDate->formatDBDate($this->oxorder__oxsenddate->value));
    }
1157539
public function update( $new_instance, $old_instance ) 
    {   
        $this->form->updater->set_new_instance( $new_instance );
        return $this->form->updater->update( $old_instance );
    }
1040935
public void addClass (ClassRecord record)
    {
        // validate the class id
        if (record.classId > 255) {
            log.warning("Refusing to add class; classId > 255 " + record + ".");
        } else {
            _classes.put(record.classId, record);
        }
    }
144062
public void doAdd(Record record) throws DBException
    {
        record = this.moveRecordToBase(record);

        int iOpenMode = record.getOpenMode();
        RecordChangedHandler recordChangeListener = (RecordChangedHandler)record.getListener(RecordChangedHandler.class);
        Object[] rgobjEnabledFields = record.setEnableFieldListeners(false);
        boolean[] rgbEnabled = record.setEnableListeners(false);
        if (recordChangeListener != null)
        	recordChangeListener.setEnabledListener(true);	// I may need this listener (for an update) to do the update =ID AND =LastChangeDate
        
        try {
            record.setOpenMode(0);  // Normal add
            this.getNextTable().add(record);
        } catch (DBException ex) {
            throw ex;
        } finally {
            record.setOpenMode(iOpenMode);
            record.setEnableListeners(rgbEnabled);
            record.setEnableFieldListeners(rgobjEnabledFields);
        }
    }
934158
private function addRecordToCart(GedcomRecord $record): void
    {
        $cart = Session::get('cart', []);

        $tree_name = $record->tree()->name();

        // Add this record
        $cart[$tree_name][$record->xref()] = true;

        // Add directly linked media, notes, repositories and sources.
        preg_match_all('/\n\d (?:OBJE|NOTE|SOUR|REPO) @(' . Gedcom::REGEX_XREF . ')@/', $record->gedcom(), $matches);

        foreach ($matches[1] as $match) {
            $cart[$tree_name][$match] = true;
        }

        Session::put('cart', $cart);
    }
414840
protected function stash_file(array $filerecord) {
        $this->converter->set_stash('files', $filerecord, $filerecord['id']);
        $this->fileids[] = $filerecord['id'];
    }
332729
public static function delete_existing_file_record(file_storage $fs, array $filerecord) {
        if ($existing = $fs->get_file($filerecord['contextid'], $filerecord['component'],
                $filerecord['filearea'], $filerecord['itemid'], $filerecord['filepath'],
                $filerecord['filename'])) {
            $existing->delete();
        }
    }
716610
function (cfg) {
            this.log("addRecordStore");
            var lrs;
            if (cfg instanceof TinCan.LRS) {
                lrs = cfg;
            }
            else {
                lrs = new TinCan.LRS (cfg);
            }
            this.recordStores.push(lrs);
        }
759765
public function addAttachment($path, $newName = "")
    {
        if ($newName == "") {
            $newName = basename($path);
        }

        $file = new \stdClass();
        $file->path = $path;
        $file->name = $newName;

        $this->attachments[] = $file;

        return $this;
    }
782323
public void addListener(Record record, FileListener listener)
    {
        super.addListener(record, listener);
        if (listener.getOwner() == this.getRecord())   // Only replicate listeners added to base.
        {
            Iterator<BaseTable> iterator = this.getTables();
            while (iterator.hasNext())
            {
                BaseTable table = iterator.next();
                if ((table != null) && (table != this.getNextTable()))
                {
                    FileListener newBehavior = null;    // Clone the file behaviors
                    try   {
                        newBehavior = (FileListener)listener.clone(); // Clone the file behaviors
                    } catch (CloneNotSupportedException ex)   {
                        newBehavior = null;
                    }
                    record = table.getRecord();
                    if (newBehavior != null)
                        table.addListener(record, newBehavior);     // Add them to the new query
                }
            }
        }
    }