本文整理汇总了PHP中BaseModel::set方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseModel::set方法的具体用法?PHP BaseModel::set怎么用?PHP BaseModel::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseModel
的用法示例。
在下文中一共展示了BaseModel::set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
public function set($pa_fields, $pm_value = "", $pa_options = null)
{
if (!is_array($pa_fields)) {
$pa_fields = array($pa_fields => $pm_value);
}
// don't allow setting passwords of existing users if authentication backend doesn't support it. this way
// all other set() calls can still go through and update() doesn't necessarily have to barf because of a changed password
if ($this->getPrimaryKey() > 0) {
if (isset($pa_fields['password']) && !AuthenticationManager::supports(__CA_AUTH_ADAPTER_FEATURE_UPDATE_PASSWORDS__)) {
$this->postError(922, _t("Authentication back-end doesn't updating passwords of existing users."), 'ca_users->update()');
return false;
}
}
return parent::set($pa_fields, $pm_value, $pa_options);
}
示例2: set
/**
* Set field value(s) for the table row represented by this object
*
*/
public function set($pa_fields, $pm_value = "", $pa_options = null)
{
if ($this->ATTRIBUTE_TYPE_LIST_CODE) {
if (is_array($pa_fields)) {
if (isset($pa_fields[$this->ATTRIBUTE_TYPE_ID_FLD]) && !is_numeric($pa_fields[$this->ATTRIBUTE_TYPE_ID_FLD])) {
if ($vn_id = ca_lists::getItemID($this->ATTRIBUTE_TYPE_LIST_CODE, $pa_fields[$this->ATTRIBUTE_TYPE_ID_FLD])) {
$pa_fields[$this->ATTRIBUTE_TYPE_ID_FLD] = $vn_id;
}
}
} else {
if ($pa_fields == $this->ATTRIBUTE_TYPE_ID_FLD && !is_numeric($pm_value)) {
if ($vn_id = ca_lists::getItemID($this->ATTRIBUTE_TYPE_LIST_CODE, $pm_value)) {
$pm_value = $vn_id;
}
}
}
}
return parent::set($pa_fields, $pm_value, $pa_options);
}
示例3: caExtractEmbeddedMetadata
/**
* Perform mapping of extracted media metadata to CollectiveAccess bundles.
*
* @param BaseModel $po_instance Model instance to insert extracted metadata into
* @param array $pa_metadata Extracted metadata
* @param int $pn_locale_id The current locale as a numeric locale_id
* @return bool True extracted metadata was mapped and the model changed, false if no change was made to the model
*/
function caExtractEmbeddedMetadata($po_instance, $pa_metadata, $pn_locale_id)
{
if (!is_array($pa_metadata)) {
return false;
}
$vb_did_mapping = false;
if (!($vs_media_metadata_config = $po_instance->getAppConfig()->get('media_metadata'))) {
return false;
}
$o_metadata_config = Configuration::load($vs_media_metadata_config);
$va_mappings = $o_metadata_config->getAssoc('import_mappings');
$vs_tablename = $po_instance->tableName();
// set extracted georef?
$va_georef_elements = $o_metadata_config->getList('extract_embedded_exif_georeferencing_to');
$va_georef_containers = $o_metadata_config->getAssoc('extract_embedded_exif_georeferencing_to_container');
$va_date_elements = $o_metadata_config->getList('extract_embedded_exif_creation_date_to');
$va_date_containers = $o_metadata_config->getAssoc('extract_embedded_exif_creation_date_to_container');
if (isset($pa_metadata['EXIF']) && is_array($pa_metadata['EXIF']) && (is_array($va_georef_elements) && sizeof($va_georef_elements) || is_array($va_georef_containers) && sizeof($va_georef_containers) || is_array($va_date_elements) && sizeof($va_date_elements) || is_array($va_date_containers) && sizeof($va_date_containers))) {
$va_exif_data = $pa_metadata['EXIF'];
if (is_array($va_georef_elements)) {
if (is_array($va_coords = caParseEXIFLatLong($va_exif_data))) {
foreach ($va_georef_elements as $vs_element) {
$va_tmp = explode('.', $vs_element);
$po_instance->addAttribute(array($va_tmp[1] => "[" . $va_coords['latitude'] . ", " . $va_coords['longitude'] . "]", 'locale_id' => $pn_locale_id), $va_tmp[1]);
}
$vb_did_mapping = true;
}
}
if (is_array($va_georef_containers)) {
if (is_array($va_coords = caParseEXIFLatLong($va_exif_data))) {
foreach ($va_georef_containers as $vs_container => $va_info) {
$va_tmp = explode('.', $vs_container);
$vs_value_element = array_pop(explode('.', $va_info['value']));
$va_data = array($vs_value_element => "[" . $va_coords['latitude'] . ", " . $va_coords['longitude'] . "]", 'locale_id' => $pn_locale_id);
if (isset($va_info['map']) && is_array($va_info['map'])) {
foreach ($va_info['map'] as $vs_sub_element => $vs_value) {
$va_tmp2 = explode('.', $vs_sub_element);
$vs_sub_element = array_pop($va_tmp2);
if ($t_element = $po_instance->_getElementInstance($vs_sub_element)) {
switch ($t_element->get('datatype')) {
case 3:
// List
$t_list = new ca_lists();
$va_data[$vs_sub_element] = $t_list->getItemIDFromList($t_element->get('list_id'), $vs_value);
break;
default:
$va_data[$vs_sub_element] = $vs_value;
break;
}
}
}
}
$po_instance->addAttribute($va_data, $va_tmp[1]);
}
$vb_did_mapping = true;
}
}
if (is_array($va_date_elements)) {
if (($vs_raw_date = $va_exif_data['IFD0']['DateTimeOriginal']) || ($vs_raw_date = $va_exif_data['EXIF']['DateTimeOriginal'])) {
$va_date_tmp = preg_split('![: ]+!', $vs_raw_date);
$vs_date = $va_date_tmp[0] . '-' . $va_date_tmp[1] . '-' . $va_date_tmp[2] . 'T' . $va_date_tmp[3] . ':' . $va_date_tmp[4] . ':' . $va_date_tmp[5];
foreach ($va_date_elements as $vs_element) {
$va_tmp = explode('.', $vs_element);
$po_instance->addAttribute(array($va_tmp[1] => $vs_date, 'locale_id' => $pn_locale_id), $va_tmp[1]);
}
$vb_did_mapping = true;
}
}
if (is_array($va_date_containers)) {
$t_list = new ca_lists();
if (($vs_raw_date = $va_exif_data['IFD0']['DateTimeOriginal']) || ($vs_raw_date = $va_exif_data['EXIF']['DateTimeOriginal'])) {
$va_date_tmp = preg_split('![: ]+!', $vs_raw_date);
$vs_date = $va_date_tmp[0] . '-' . $va_date_tmp[1] . '-' . $va_date_tmp[2] . 'T' . $va_date_tmp[3] . ':' . $va_date_tmp[4] . ':' . $va_date_tmp[5];
foreach ($va_date_containers as $vs_container => $va_info) {
$va_tmp = explode('.', $vs_container);
$vs_value_element = array_pop(explode('.', $va_info['value']));
$va_data = array($vs_value_element => $vs_date, 'locale_id' => $pn_locale_id);
if (isset($va_info['map']) && is_array($va_info['map'])) {
foreach ($va_info['map'] as $vs_sub_element => $vs_value) {
$va_tmp2 = explode('.', $vs_sub_element);
$vs_sub_element = array_pop($va_tmp2);
if ($t_element = $po_instance->_getElementInstance($vs_sub_element)) {
switch ($t_element->get('datatype')) {
case 3:
// List
$va_data[$vs_sub_element] = $t_list->getItemIDFromList($t_element->get('list_id'), $vs_value);
break;
default:
$va_data[$vs_sub_element] = $vs_value;
break;
}
}
//.........这里部分代码省略.........
示例4: _checkAccess
/**
* Called just after record is deleted. Individual editor controllers can override this to implement their
* own post-deletion cleanup logic.
*
* @param BaseModel $pt_subject Model instance of row that was deleted
* @return bool True if post-deletion cleanup was successful, false if not
*/
protected function _checkAccess($pt_subject, $pa_options = null)
{
//
// Is record deleted?
//
if ($pt_subject->hasField('deleted') && $pt_subject->get('deleted')) {
if (!caGetOption('dontRedirectOnDelete', $pa_options, false)) {
$this->response->setRedirect($this->request->config->get('error_display_url') . '/n/2550?r=' . urlencode($this->request->getFullUrlPath()));
}
return false;
}
//
// Is record of correct type?
//
$va_restrict_to_types = null;
if ($pt_subject->getAppConfig()->get('perform_type_access_checking')) {
$va_restrict_to_types = caGetTypeRestrictionsForUser($this->ops_table_name, array('access' => __CA_BUNDLE_ACCESS_READONLY__));
}
if (is_array($va_restrict_to_types) && ($pt_subject->get('type_id') && ($pt_subject->getPrimaryKey() && !in_array($pt_subject->get('type_id'), $va_restrict_to_types)))) {
$this->response->setRedirect($this->request->config->get('error_display_url') . '/n/2560?r=' . urlencode($this->request->getFullUrlPath()));
return false;
}
//
// Is record from correct source?
//
$va_restrict_to_sources = null;
if ($pt_subject->getAppConfig()->get('perform_source_access_checking') && $pt_subject->hasField('source_id')) {
if (is_array($va_restrict_to_sources = caGetSourceRestrictionsForUser($this->ops_table_name, array('access' => __CA_BUNDLE_ACCESS_READONLY__)))) {
if (!$pt_subject->get('source_id') || $pt_subject->get('source_id') && !in_array($pt_subject->get('source_id'), $va_restrict_to_sources) || strlen($vn_source_id = $this->request->getParameter('source_id', pInteger)) && !in_array($vn_source_id, $va_restrict_to_sources)) {
$pt_subject->set('source_id', $pt_subject->getDefaultSourceID(array('request' => $this->request)));
}
if (is_array($va_restrict_to_sources) && !in_array($pt_subject->get('source_id'), $va_restrict_to_sources)) {
$this->response->setRedirect($this->request->config->get('error_display_url') . '/n/2562?r=' . urlencode($this->request->getFullUrlPath()));
return;
}
}
}
//
// Does user have access to row?
//
if ($pt_subject->getAppConfig()->get('perform_item_level_access_checking') && $vn_subject_id) {
if ($pt_subject->checkACLAccessForUser($this->request->user) < __CA_BUNDLE_ACCESS_READONLY__) {
$this->response->setRedirect($this->request->config->get('error_display_url') . '/n/2580?r=' . urlencode($this->request->getFullUrlPath()));
return false;
}
}
return true;
}
示例5: set
/**
* Override BaseModel::set() to prevent setting of element and source fields for existing records
*/
public function set($pa_fields, $pm_value = "", $pa_options = null)
{
if ($this->getPrimaryKey()) {
if (!is_array($pa_fields)) {
$pa_fields = array($pa_fields => $pm_value);
}
$va_fields_proc = array();
foreach ($pa_fields as $vs_field => $vs_value) {
if (!in_array($vs_field, array('element', 'source'))) {
$va_fields_proc[$vs_field] = $vs_value;
}
}
if (!sizeof($va_fields_proc)) {
$va_fields_proc = null;
}
$vn_rc = parent::set($va_fields_proc, null, $pa_options);
$this->initSettings();
return $vn_rc;
}
$vn_rc = parent::set($pa_fields, $pm_value, $pa_options);
$this->initSettings();
return $vn_rc;
}
示例6: set
public function set($pa_fields, $pm_value = "", $pa_options = null)
{
if (!is_array($pa_fields)) {
$pa_fields = array($pa_fields => $pm_value);
}
//print_R($pa_fields);
foreach ($pa_fields as $vs_f => $vs_v) {
switch ($vs_f) {
case 'shipped_on_date':
if (!in_array($this->get('order_status'), array('PROCESSED', 'PROCESSED_AWAITING_DIGITIZATION', 'PROCESSED_AWAITING_MEDIA_ACCESS'))) {
$this->postError(1101, _t('Cannot ship order until it is paid for'), 'ca_commerce_orders->set()');
return false;
}
$o_tep = new TimeExpressionParser();
if ($o_tep->parse($vs_v)) {
$va_dates = $o_tep->getUnixTimestamps();
if ($va_dates['start'] < $this->get('shipping_date', array('GET_DIRECT_DATE' => true))) {
$this->postError(1101, _t('Shipped on date must not be before the shipping date'), 'ca_commerce_orders->set()');
return false;
}
}
break;
}
}
$this->setOrderStatusDropDown();
return parent::set($pa_fields, $pm_value, $pa_options);
}