本文整理汇总了PHP中BaseModel::setChangeLogUnitID方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseModel::setChangeLogUnitID方法的具体用法?PHP BaseModel::setChangeLogUnitID怎么用?PHP BaseModel::setChangeLogUnitID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseModel
的用法示例。
在下文中一共展示了BaseModel::setChangeLogUnitID方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveBundlesForScreen
/**
* Saves all bundles on the specified screen in the database by extracting
* required data from the supplied request
* $pm_screen can be a screen tag (eg. "Screen5") or a screen_id (eg. 5)
*
* Calls processBundlesBeforeBaseModelSave() method in subclass right before invoking insert() or update() on
* the BaseModel, if the method is defined. Passes the following parameters to processBundlesBeforeBaseModelSave():
* array $pa_bundles An array of bundles to be saved
* string $ps_form_prefix The form prefix
* RequestHTTP $po_request The current request
* array $pa_options Optional array of parameters; expected to be the same as that passed to saveBundlesForScreen()
*
* The processBundlesBeforeBaseModelSave() is useful for those odd cases where you need to do some processing before the basic
* database record defined by the model (eg. intrinsic fields and hierarchy coding) is inserted or updated. You usually don't need
* to use it.
*
* @param mixed $pm_screen
* @param RequestHTTP $ps_request
* @param array $pa_options Options are:
* dryRun = Go through the motions of saving but don't actually write information to the database
* batch = Process save in "batch" mode. Specifically this means honoring batch mode settings (add, replace, remove), skipping bundles that are not supported in batch mode and ignoring updates
* existingRepresentationMap = an array of representation_ids key'ed on file path. If set saveBundlesForScreen() use link the specified representation to the row it is saving rather than processing the uploaded file. saveBundlesForScreen() will build the map as it goes, adding newly uploaded files. If you want it to process a file in a batch situation where it should be processed the first time and linked subsequently then pass an empty array here. saveBundlesForScreen() will use the empty array to build the map.
*/
public function saveBundlesForScreen($pm_screen, $po_request, &$pa_options)
{
$vb_we_set_transaction = false;
$vs_form_prefix = caGetOption('formName', $pa_options, $po_request->getParameter('_formName', pString));
$vb_dryrun = caGetOption('dryRun', $pa_options, false);
$vb_batch = caGetOption('batch', $pa_options, false);
if (!$this->inTransaction()) {
$this->setTransaction(new Transaction($this->getDb()));
$vb_we_set_transaction = true;
} else {
if ($vb_dryrun) {
$this->postError(799, _t('Cannot do dry run save when in transaction. Try again without setting a transaction.'), "BundlableLabelableBaseModelWithAttributes->saveBundlesForScreen()");
return false;
}
}
$vb_read_only_because_deaccessioned = $this->hasField('is_deaccessioned') && (bool) $this->getAppConfig()->get('deaccession_dont_allow_editing') && (bool) $this->get('is_deaccessioned');
BaseModel::setChangeLogUnitID();
// get items on screen
$t_ui = caGetOption('ui_instance', $pa_options, ca_editor_uis::loadDefaultUI($this->tableName(), $po_request, $this->getTypeID()));
$va_bundle_lists = $this->getBundleListsForScreen($pm_screen, $po_request, $t_ui, $pa_options);
//
// Filter bundles to save if deaccessioned - only allow editing of the ca_objects_deaccession bundle
//
if ($vb_read_only_because_deaccessioned) {
foreach ($va_bundle_lists['bundles'] as $vn_i => $va_bundle) {
if ($va_bundle['bundle_name'] !== 'ca_objects_deaccession') {
unset($va_bundle_lists['bundles'][$vn_i]);
}
}
foreach ($va_bundle_lists['fields_by_type'] as $vs_type => $va_bundles) {
foreach ($va_bundles as $vs_id => $vs_bundle_name) {
if ($vs_bundle_name !== 'ca_objects_deaccession') {
unset($va_bundle_lists['fields_by_type'][$vs_type][$vs_id]);
}
}
}
}
$va_bundles = $va_bundle_lists['bundles'];
$va_fields_by_type = $va_bundle_lists['fields_by_type'];
// save intrinsic fields
if (is_array($va_fields_by_type['intrinsic'])) {
$vs_idno_field = $this->getProperty('ID_NUMBERING_ID_FIELD');
foreach ($va_fields_by_type['intrinsic'] as $vs_placement_code => $vs_f) {
if ($vb_batch) {
$vs_batch_mode = $po_request->getParameter("{$vs_placement_code}{$vs_form_prefix}_batch_mode", pString);
if ($vs_batch_mode == '_disabled_') {
continue;
}
}
if (isset($_FILES["{$vs_placement_code}{$vs_form_prefix}{$vs_f}"]) && $_FILES["{$vs_placement_code}{$vs_form_prefix}{$vs_f}"]) {
// media field
$this->set($vs_f, $_FILES["{$vs_placement_code}{$vs_form_prefix}{$vs_f}"]['tmp_name'], array('original_filename' => $_FILES["{$vs_placement_code}{$vs_form_prefix}{$vs_f}"]['name']));
} else {
switch ($vs_f) {
case 'access':
if ((bool) $this->getAppConfig()->get($this->tableName() . '_allow_access_inheritance') && $this->hasField('access_inherit_from_parent')) {
$this->set('access_inherit_from_parent', $po_request->getParameter("{$vs_placement_code}{$vs_form_prefix}access_inherit_from_parent", pInteger));
}
if (!(bool) $this->getAppConfig()->get($this->tableName() . '_allow_access_inheritance') || !$this->hasField('access_inherit_from_parent') || !(bool) $this->get('access_inherit_from_parent')) {
$this->set('access', $po_request->getParameter("{$vs_placement_code}{$vs_form_prefix}access", pString));
}
break;
case $vs_idno_field:
if ($this->opo_idno_plugin_instance) {
$this->opo_idno_plugin_instance->setDb($this->getDb());
$this->set($vs_f, $vs_tmp = $this->opo_idno_plugin_instance->htmlFormValue($vs_idno_field));
} else {
$this->set($vs_f, $po_request->getParameter("{$vs_placement_code}{$vs_form_prefix}{$vs_f}", pString));
}
break;
default:
// Look for fully qualified intrinsic
if (!strlen($vs_v = $po_request->getParameter("{$vs_placement_code}{$vs_form_prefix}{$vs_f}", pString))) {
// fall back to simple field name intrinsic spec - still used for "mandatory" fields such as type_id and parent_id
$vs_v = $po_request->getParameter("{$vs_f}", pString);
}
$this->set($vs_f, $vs_v);
//.........这里部分代码省略.........
示例2: delete
/**
*
*/
public function delete($pb_delete_related = false, $pa_options = null, $pa_fields = null, $pa_table_list = null)
{
$vb_web_set_change_log_unit_id = BaseModel::setChangeLogUnitID();
if (!$this->inTransaction()) {
$o_trans = new Transaction($this->getDb());
$this->setTransaction($o_trans);
}
if (!is_array($pa_options)) {
$pa_options = array();
}
$vn_id = $this->getPrimaryKey();
if (parent::delete($pb_delete_related, $pa_options, $pa_fields, $pa_table_list)) {
// Delete any associated attribute values that use this list item
if (!($qr_res = $this->getDb()->query("\n\t\t\t\tDELETE FROM ca_attribute_values \n\t\t\t\tWHERE item_id = ?\n\t\t\t", (int) $vn_id))) {
$this->errors = $this->getDb()->errors();
if ($o_trans) {
$o_trans->rollback();
}
if ($vb_web_set_change_log_unit_id) {
BaseModel::unsetChangeLogUnitID();
}
return false;
}
// Kill any attributes that no longer have values
// This cleans up attributes that had a single list value (and now have nothing)
// in a relatively efficient way
//
// We should not need to reindex for search here because the delete of the list item itself
// should have triggered reindexing
//
if (!($qr_res = $this->getDb()->query("\n\t\t\t\tDELETE FROM ca_attributes WHERE attribute_id not in (SELECT distinct attribute_id FROM ca_attribute_values)\n\t\t\t"))) {
$this->errors = $this->getDb()->errors();
if ($o_trans) {
$o_trans->rollback();
}
if ($vb_web_set_change_log_unit_id) {
BaseModel::unsetChangeLogUnitID();
}
return false;
}
if ($o_trans) {
$o_trans->commit();
}
if ($vb_web_set_change_log_unit_id) {
BaseModel::unsetChangeLogUnitID();
}
return true;
}
if ($o_trans) {
$o_trans->rollback();
}
if ($vb_web_set_change_log_unit_id) {
BaseModel::unsetChangeLogUnitID();
}
return false;
}
示例3: delete
/**
* Override delete() to scramble the set_code before we soft-delete. This is useful
* because the database field has a unique key that really enforces uniqueneness
* and we might wanna reuse a code of a set we previously deleted.
*/
public function delete($pb_delete_related = false, $pa_options = null, $pa_fields = null, $pa_table_list = null)
{
$vb_web_set_change_log_unit_id = BaseModel::setChangeLogUnitID();
if ($pb_delete_related) {
// quickly delete all labels for all set items in this set
$this->getDb()->query('DELETE FROM ca_set_item_labels WHERE item_id IN (SELECT item_id FROM ca_set_items WHERE set_id=?)', $this->getPrimaryKey());
// quickly delete attribute values
$this->getDb()->query('
DELETE FROM ca_attribute_values WHERE attribute_id IN
(SELECT attribute_id FROM ca_attributes WHERE table_num=? and row_id IN (SELECT item_id FROM ca_set_items WHERE set_id=7))
', $this->tableNum(), $this->getPrimaryKey());
// quickly delete attributes
$this->getDb()->query('
DELETE FROM ca_attributes WHERE table_num=? and row_id IN (SELECT item_id FROM ca_set_items WHERE set_id=7)
', $this->tableNum(), $this->getPrimaryKey());
// get list of set item ids
$qr_items = $this->getDb()->query('SELECT item_id FROM ca_set_items WHERE set_id=?', $this->getPrimaryKey());
$va_item_ids = $qr_items->getAllFieldValues('item_id');
// nuke set items
$this->getDb()->query('DELETE FROM ca_set_items WHERE set_id=?', $this->getPrimaryKey());
// remove search indexing for deleted set items
foreach ($va_item_ids as $vn_item_id) {
$this->getSearchIndexer()->startRowUnIndexing($this->tableNum(), $vn_item_id);
$this->getSearchIndexer()->commitRowUnIndexing($this->tableNum(), $vn_item_id);
}
}
if ($vn_rc = parent::delete($pb_delete_related, $pa_options, $pa_fields, $pa_table_list)) {
if (!caGetOption('hard', $pa_options, false)) {
// only applies if we don't hard-delete
$vb_we_set_transaction = false;
if (!$this->inTransaction()) {
$o_t = new Transaction($this->getDb());
$this->setTransaction($o_t);
$vb_we_set_transaction = true;
}
$this->set('set_code', $this->get('set_code') . '_' . time());
$this->update(array('force' => true));
if ($vb_we_set_transaction) {
$this->removeTransaction(true);
}
}
}
if ($vb_web_set_change_log_unit_id) {
BaseModel::unsetChangeLogUnitID();
}
return $vn_rc;
}
示例4: delete
public function delete($pb_delete_related = false, $pa_options = null, $pa_fields = null, $pa_table_list = null)
{
$vb_web_set_change_log_unit_id = BaseModel::setChangeLogUnitID();
$o_trans = null;
if (!$this->inTransaction()) {
$o_trans = new Transaction($this->getDb());
$this->setTransaction($o_trans);
}
if (!is_array($pa_options)) {
$pa_options = array();
}
$vn_id = $this->getPrimaryKey();
if (($vn_rc = parent::delete($pb_delete_related, $pa_options, $pa_fields, $pa_table_list)) && (!$this->hasField('deleted') || caGetOption('hard', $pa_options, false))) {
// Delete any associated attributes and attribute_values
if (!($qr_res = $this->getDb()->query("\n\t\t\t\t\tDELETE FROM ca_attribute_values \n\t\t\t\t\tUSING ca_attributes \n\t\t\t\t\tINNER JOIN ca_attribute_values ON ca_attribute_values.attribute_id = ca_attributes.attribute_id \n\t\t\t\t\tWHERE ca_attributes.table_num = ? AND ca_attributes.row_id = ?\n\t\t\t\t", array((int) $this->tableNum(), (int) $vn_id)))) {
$this->errors = $this->getDb()->errors();
if ($o_trans) {
$o_trans->rollback();
}
if ($vb_web_set_change_log_unit_id) {
BaseModel::unsetChangeLogUnitID();
}
return false;
}
if (!($qr_res = $this->getDb()->query("\n\t\t\t\t\tDELETE FROM ca_attributes\n\t\t\t\t\tWHERE\n\t\t\t\t\t\ttable_num = ? AND row_id = ?\n\t\t\t\t", array((int) $this->tableNum(), (int) $vn_id)))) {
$this->errors = $this->getDb()->errors();
if ($o_trans) {
$o_trans->rollback();
}
if ($vb_web_set_change_log_unit_id) {
BaseModel::unsetChangeLogUnitID();
}
return false;
}
//
// Remove any authority attributes that reference this row
//
if ($vn_element_type = (int) AuthorityAttributeValue::tableToElementType($this->tableName())) {
if ($qr_res = $this->getDb()->query("\n\t\t\t\t\t\tSELECT ca.table_num, ca.row_id FROM ca_attributes ca\n\t\t\t\t\t\tINNER JOIN ca_attribute_values AS cav ON cav.attribute_id = ca.attribute_id \n\t\t\t\t\t\tINNER JOIN ca_metadata_elements AS cme ON cav.element_id = cme.element_id \n\t\t\t\t\t\tWHERE cme.datatype = ? AND cav.value_integer1 = ?\n\t\t\t\t\t", array($vn_element_type, (int) $vn_id))) {
$va_ids = array();
while ($qr_res->nextRow()) {
$va_ids[$qr_res->get('table_num')][] = $qr_res->get('row_id');
}
if (!($qr_res = $this->getDb()->query("\n\t\t\t\t\t\t\tDELETE FROM ca_attribute_values \n\t\t\t\t\t\t\tUSING ca_metadata_elements \n\t\t\t\t\t\t\tINNER JOIN ca_attribute_values ON ca_attribute_values.element_id = ca_metadata_elements.element_id \n\t\t\t\t\t\t\tWHERE ca_metadata_elements.datatype = ? AND ca_attribute_values.value_integer1 = ?\n\t\t\t\t\t\t", array($vn_element_type, (int) $vn_id)))) {
$this->errors = $this->getDb()->errors();
if ($o_trans) {
$o_trans->rollback();
}
if ($vb_web_set_change_log_unit_id) {
BaseModel::unsetChangeLogUnitID();
}
return false;
} else {
$o_indexer = new SearchIndexer($this->getDb());
foreach ($va_ids as $vs_table => $va_ids) {
$o_indexer->reindexRows($vs_table, $va_ids, array('transaction' => $o_trans));
}
}
}
}
if ($o_trans) {
$o_trans->commit();
}
if ($vb_web_set_change_log_unit_id) {
BaseModel::unsetChangeLogUnitID();
}
return $vn_rc;
}
if ($o_trans) {
$vn_rc ? $o_trans->commit() : $o_trans->rollback();
}
if ($vb_web_set_change_log_unit_id) {
BaseModel::unsetChangeLogUnitID();
}
return $vn_rc;
}
示例5: delete
public function delete($pb_delete_related = false, $pa_options = null, $pa_fields = null, $pa_table_list = null)
{
$vb_web_set_change_log_unit_id = BaseModel::setChangeLogUnitID();
if (!$this->inTransaction()) {
$o_trans = new Transaction($this->getDb());
$this->setTransaction($o_trans);
}
if (!is_array($pa_options)) {
$pa_options = array();
}
$vn_id = $this->getPrimaryKey();
if (parent::delete($pb_delete_related, $pa_options, $pa_fields, $pa_table_list)) {
// Delete any associated attributes and attribute_values
if (!($qr_res = $this->getDb()->query("\n\t\t\t\t\tDELETE FROM ca_attribute_values \n\t\t\t\t\tUSING ca_attributes \n\t\t\t\t\tINNER JOIN ca_attribute_values ON ca_attribute_values.attribute_id = ca_attributes.attribute_id \n\t\t\t\t\tWHERE ca_attributes.table_num = ? AND ca_attributes.row_id = ?\n\t\t\t\t", (int) $this->tableNum(), (int) $vn_id))) {
$this->errors = $this->getDb()->errors();
if ($o_trans) {
$o_trans->rollback();
}
if ($vb_web_set_change_log_unit_id) {
BaseModel::unsetChangeLogUnitID();
}
return false;
}
if (!($qr_res = $this->getDb()->query("\n\t\t\t\t\tDELETE FROM ca_attributes\n\t\t\t\t\tWHERE\n\t\t\t\t\t\ttable_num = ? AND row_id = ?\n\t\t\t\t", (int) $this->tableNum(), (int) $vn_id))) {
$this->errors = $this->getDb()->errors();
if ($o_trans) {
$o_trans->rollback();
}
if ($vb_web_set_change_log_unit_id) {
BaseModel::unsetChangeLogUnitID();
}
return false;
}
if ($o_trans) {
$o_trans->commit();
}
if ($vb_web_set_change_log_unit_id) {
BaseModel::unsetChangeLogUnitID();
}
return true;
}
if ($o_trans) {
$o_trans->rollback();
}
if ($vb_web_set_change_log_unit_id) {
BaseModel::unsetChangeLogUnitID();
}
return false;
}