当前位置: 首页>>代码示例>>PHP>>正文


PHP ca_objects::replaceAttribute方法代码示例

本文整理汇总了PHP中ca_objects::replaceAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_objects::replaceAttribute方法的具体用法?PHP ca_objects::replaceAttribute怎么用?PHP ca_objects::replaceAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ca_objects的用法示例。


在下文中一共展示了ca_objects::replaceAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: reserve

 /**
  *
  */
 public function reserve($pn_object_id, $pn_user_id, $ps_note, $pa_options = null)
 {
     global $g_ui_locale_id;
     $vb_we_set_transaction = false;
     if ($this->inTransaction()) {
         $o_trans = $this->getTransaction();
     } else {
         $vb_we_set_transaction = true;
         $this->setTransaction($o_trans = new Transaction());
     }
     $o_request = caGetOption('request', $pa_options, null);
     $t_object = new ca_objects($pn_object_id);
     $t_object->setTransaction($o_trans);
     if (!$t_object->getPrimaryKey()) {
         return null;
     }
     if ($o_request && !$t_object->isReadable($o_request)) {
         return null;
     }
     // is object out?
     if ($t_object->getCheckoutStatus() === __CA_OBJECTS_CHECKOUT_STATUS_AVAILABLE__) {
         throw new Exception(_t('Item is not out'));
     }
     $va_reservations = $this->objectHasReservations($pn_object_id);
     // is object already reserved by this user?
     if (is_array($va_reservations)) {
         foreach ($va_reservations as $va_reservation) {
             if ($va_reservation['user_id'] == $pn_user_id) {
                 throw new Exception(_t('Item is already reserved by this user'));
             }
         }
     }
     $vs_uuid = $this->getTransactionUUID();
     $va_checkout_config = ca_object_checkouts::getObjectCheckoutConfigForType($t_object->getTypeCode());
     $this->setMode(ACCESS_WRITE);
     $this->set(array('group_uuid' => $vs_uuid, 'object_id' => $pn_object_id, 'user_id' => $pn_user_id, 'checkout_notes' => $ps_notes));
     // Do we need to set values?
     if (is_array($va_checkout_config['set_values']) && sizeof($va_checkout_config['set_values'])) {
         $t_object->setMode(ACCESS_WRITE);
         foreach ($va_checkout_config['set_values'] as $vs_attr => $va_attr_values_by_event) {
             if (!is_array($va_attr_values_by_event['reserve'])) {
                 if ($t_object->hasField($vs_attr)) {
                     // Intrinsic
                     $t_object->set($vs_attr, $va_attr_values_by_event['reserve']);
                 }
             } else {
                 $va_attr_values['locale_id'] = $g_ui_locale_id;
                 $t_object->replaceAttribute($va_attr_values_by_event['reserve'], $vs_attr);
             }
             $t_object->update();
             if ($t_object->numErrors()) {
                 $this->errors = $t_object->errors;
                 if ($vb_we_set_transaction) {
                     $o_trans->rollback();
                 }
                 return false;
             }
         }
     }
     $vn_rc = $this->insert();
     if ($vb_we_set_transaction) {
         $vn_rc ? $o_trans->commit() : $o_trans->rollback();
     }
     return $vn_rc;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:68,代码来源:ca_object_checkouts.php


注:本文中的ca_objects::replaceAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。