本文整理汇总了PHP中CRM_Core_Transaction类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Transaction类的具体用法?PHP CRM_Core_Transaction怎么用?PHP CRM_Core_Transaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_Transaction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: add_participant_to_cart
function add_participant_to_cart()
{
require 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
$cart_id = $_GET['cart_id'];
$event_id = $_GET['event_id'];
$cart = CRM_Event_Cart_BAO_Cart::find_by_id($_GET['cart_id']);
$params_array = array('cart_id' => $cart->id, 'contact_id' => CRM_Event_Cart_Form_Cart::find_or_create_contact(), 'event_id' => $event_id);
//XXX security?
$participant = CRM_Event_Cart_BAO_MerParticipant::create($params_array);
$participant->save();
$form = new CRM_Core_Form();
$pform = new CRM_Event_Cart_Form_MerParticipant($participant);
$pform->appendQuickForm($form);
$renderer = $form->getRenderer();
$config = CRM_Core_Config::singleton();
$templateDir = $config->templateDir;
if (is_array($templateDir)) {
$templateDir = array_pop($templateDir);
}
$requiredTemplate = file_get_contents($templateDir . '/CRM/Form/label.tpl');
$renderer->setRequiredTemplate($requiredTemplate);
$form->accept($renderer);
$template = CRM_Core_Smarty::singleton();
$template->assign('form', $renderer->toArray());
$template->assign('participant', $participant);
$output = $template->fetch("CRM/Event/Cart/Form/Checkout/Participant.tpl");
$transaction->commit();
echo $output;
CRM_Utils_System::civiExit();
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:31,代码来源:CheckoutAJAX.php
示例2: create
/**
* takes an associative array and creates a price field object
*
* This function is invoked from within the web form layer and also from the api layer
*
* @param array $params (reference) an assoc array of name/value pairs
*
* @return object CRM_Price_DAO_PriceField object
* @access public
* @static
*/
static function create(&$params)
{
if (empty($params['id']) && empty($params['name'])) {
$params['name'] = strtolower(CRM_Utils_String::munge($params['label'], '_', 242));
}
$transaction = new CRM_Core_Transaction();
$priceField = self::add($params);
if (is_a($priceField, 'CRM_Core_Error')) {
$transaction->rollback();
return $priceField;
}
$optionsIds = array();
$maxIndex = CRM_Price_Form_Field::NUM_OPTION;
if ($priceField->html_type == 'Text') {
$maxIndex = 1;
$fieldValue = new CRM_Price_DAO_PriceFieldValue();
$fieldValue->price_field_id = $priceField->id;
// update previous field values( if any )
if ($fieldValue->find(TRUE)) {
$optionsIds['id'] = $fieldValue->id;
}
}
$defaultArray = array();
//html type would be empty in update scenario not sure what would happen ...
if (!empty($params['html_type']) && $params['html_type'] == 'CheckBox' && isset($params['default_checkbox_option'])) {
$tempArray = array_keys($params['default_checkbox_option']);
foreach ($tempArray as $v) {
if ($params['option_amount'][$v]) {
$defaultArray[$v] = 1;
}
}
} else {
if (!empty($params['default_option'])) {
$defaultArray[$params['default_option']] = 1;
}
}
for ($index = 1; $index <= $maxIndex; $index++) {
if (array_key_exists('option_amount', $params) && array_key_exists($index, $params['option_amount']) && (CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_label', $params)) || !empty($params['is_quick_config'])) && !CRM_Utils_System::isNull($params['option_amount'][$index])) {
$options = array('price_field_id' => $priceField->id, 'label' => trim($params['option_label'][$index]), 'name' => CRM_Utils_String::munge($params['option_label'][$index], '_', 64), 'amount' => CRM_Utils_Rule::cleanMoney(trim($params['option_amount'][$index])), 'count' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_count', $params), NULL), 'max_value' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_max_value', $params), NULL), 'description' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_description', $params), NULL), 'membership_type_id' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('membership_type_id', $params), NULL), 'weight' => $params['option_weight'][$index], 'is_active' => 1, 'is_default' => CRM_Utils_Array::value($params['option_weight'][$index], $defaultArray) ? $defaultArray[$params['option_weight'][$index]] : 0, 'membership_num_terms' => NULL);
if ($options['membership_type_id']) {
$options['membership_num_terms'] = CRM_Utils_Array::value($index, CRM_Utils_Array::value('membership_num_terms', $params), 1);
}
if (CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_financial_type_id', $params))) {
$options['financial_type_id'] = $params['option_financial_type_id'][$index];
} elseif (!empty($params['financial_type_id'])) {
$options['financial_type_id'] = $params['financial_type_id'];
}
if ($opIds = CRM_Utils_Array::value('option_id', $params)) {
if ($opId = CRM_Utils_Array::value($index, $opIds)) {
$optionsIds['id'] = $opId;
} else {
$optionsIds['id'] = NULL;
}
}
CRM_Price_BAO_PriceFieldValue::create($options, $optionsIds);
}
}
$transaction->commit();
return $priceField;
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:71,代码来源:PriceField.php
示例3: _civicrm_initialize
/**
* Add or update a link between contribution and membership
*
* @param array $params (reference ) input parameters
*
* @return array (reference ) membership_payment_id of created or updated record
* @static void
* @access public
*/
function &civicrm_membershipcontributionlink_create(&$params)
{
_civicrm_initialize();
if (empty($params)) {
return civicrm_create_error(ts('No input parameters present'));
}
if (!is_array($params)) {
return civicrm_create_error(ts('Input parameters is not an array'));
}
if (!isset($params['contribution_id']) || !isset($params['membership_id'])) {
return civicrm_create_error(ts('Required parameters missing'));
}
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
require_once 'CRM/Member/DAO/MembershipPayment.php';
$mpDAO =& new CRM_Member_DAO_MembershipPayment();
$mpDAO->copyValues($params);
$result = $mpDAO->save();
if (is_a($result, 'CRM_Core_Error')) {
$transaction->rollback();
return civicrm_create_error($result->_errors[0]['message']);
}
$transaction->commit();
_civicrm_object_to_array($mpDAO, $mpArray);
return $mpArray;
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:35,代码来源:MembershipContributionLink.php
示例4: civicrm_api3_multisite_domain_create
/**
* Create a new domain - with a domain group.
*
* This is not fully developed & need to work on creating admin menus etc
*
* @param array $params
*
* @return array
* @example DomainCreate.php
* {@getfields domain_create}
*/
function civicrm_api3_multisite_domain_create($params)
{
$transaction = new CRM_Core_Transaction();
if (empty($params['contact_id'])) {
$params['contact_id'] = _civicrm_api3_multisite_domain_create_if_not_exists('Contact', array('organization_name' => $params['name'], 'contact_type' => 'organization'));
}
$domain = civicrm_api('domain', 'getsingle', array('version' => 3, 'current_domain' => TRUE));
$fullParams = array_merge($domain, $params);
$fullParams['domain_version'] = $domain['version'];
$fullParams['version'] = 3;
unset($fullParams['id']);
if (empty($params['group_id'])) {
$groupParams = array('title' => !empty($params['group_name']) ? $params['group_name'] : $params['name']);
$group = civicrm_api3('Group', 'get', array_merge($groupParams, array('options' => array('limit' => 1))));
if (empty($group['id'])) {
// Ideally would fix the api to be more consistent & not assume default but...
$groupParams['group_type'] = array(1 => 1);
$group = civicrm_api3('Group', 'create', $groupParams);
}
$domainGroupID = $group['id'];
} else {
$domainGroupID = $params['group_id'];
}
_civicrm_api3_multisite_domain_create_if_not_exists('GroupOrganization', array('group_id' => $domainGroupID, 'organization_id' => $params['contact_id']));
$domainID = _civicrm_api3_multisite_domain_create_if_not_exists('domain', $fullParams);
if (!$domainID || $domainID != civicrm_api3('Domain', 'getvalue', array('name' => $params['name'], 'return' => 'id'))) {
throw new CiviCRM_API3_Exception('Failed to create domain', 'unknown');
}
$transaction->commit();
if (!civicrm_api3('Navigation', 'getcount', array('domain_id' => $domainID))) {
_civicrm_load_navigation($params['name'], $domainID);
}
civicrm_api3('Setting', 'create', array('is_enabled' => TRUE, 'domain_group_id' => $domainGroupID, 'domain_id' => $domainID));
return civicrm_api3_create_success(array($domainID => array('id' => $domainID)));
}
开发者ID:seamuslee001,项目名称:org.civicrm.multisite,代码行数:46,代码来源:Create.php
示例5: ndiciviparty_add_default_dashboard
function ndiciviparty_add_default_dashboard($contactid)
{
$result = civicrm_api3('Dashboard', 'get', array('name' => "contact_per_month"));
$exists = 0;
$dashletid = 0;
if ($result['count'] > 0) {
$dashletid = $result['id'];
$result = civicrm_api3('DashboardContact', 'get', array('contact_id' => $contactid, 'return' => array("dashboard_id", "contact_id")));
if ($result['count'] > 0) {
foreach ($result['values'] as $key => $value) {
if ($value['dashboard_id'] == $dashletid) {
$exists = 1;
}
}
}
if ($exists != 1) {
$tx = new CRM_Core_Transaction();
$dashlet = array('dashboard_id' => $dashletid, 'contact_id' => $contactid, 'is_active' => 1, 'column_no' => 0, 'is_minimized' => 0, 'is_fullscreen' => 0, 'weight' => 0);
try {
$add = civicrm_api3('DashboardContact', 'create', $dashlet);
} catch (CiviCRM_API3_Exception $e) {
$tx->rollback();
echo get_class($e) . ' -- ' . $e->getMessage() . "\n";
echo $e->getTraceAsString() . "\n";
print_r($e->getExtraParams());
}
}
//end if exists
}
//end if dashlet found
}
开发者ID:agh1,项目名称:civisociety-extension,代码行数:31,代码来源:ndiciviparty.php
示例6: postProcess
function postProcess()
{
$values = $this->exportValues();
$title = str_replace("'", "''", $values['title']);
$params = array(1 => array($title, 'String'), 2 => array($values['widget'], 'Integer'));
if (isset($this->_id)) {
$params += array(3 => array($this->_id, 'Integer'));
$sql = "UPDATE civicrm_wci_embed_code SET name = %1, widget_id = %2 where id = %3";
} else {
$sql = "INSERT INTO civicrm_wci_embed_code (name, widget_id)VALUES (%1, %2)";
}
$errorScope = CRM_Core_TemporaryErrorScope::useException();
try {
$transaction = new CRM_Core_Transaction();
CRM_Core_DAO::executeQuery($sql, $params);
$transaction->commit();
CRM_Core_Session::setStatus(ts('Embed code created successfully'), '', 'success');
if (isset($_REQUEST['_qf_NewEmbedCode_next'])) {
isset($this->_id) ? $embed_id = $this->_id : ($embed_id = CRM_Core_DAO::singleValueQuery('SELECT LAST_INSERT_ID()'));
CRM_Utils_System::redirect('?action=update&reset=1&id=' . $embed_id);
} else {
CRM_Utils_System::redirect('embed-code?reset=1');
}
} catch (Exception $e) {
CRM_Core_Session::setStatus(ts('Failed to create embed code'), '', 'error');
$transaction->rollback();
}
parent::postProcess();
}
开发者ID:Jagadees-zyxware,项目名称:civicrm-wci,代码行数:29,代码来源:NewEmbedCode.php
示例7: civicrm_api3_workflow_save
/**
* PriceSet.FetchSection API
*
* @param array $params
* @return array API result descriptor
* @see civicrm_api3_create_success
* @see civicrm_api3_create_error
* @throws API_Exception
*/
function civicrm_api3_workflow_save($params)
{
if (!array_key_exists("data", $params) || !$params['data']) {
throw new API_Exception('Missing parameter: data', 170);
}
if (!array_key_exists("wid", $params) || !$params['wid']) {
throw new API_Exception('Missing parameter: wid', 170);
}
$wid = $params['wid'];
$d = urldecode($params['data']);
$data = parse_str($d);
//I don't know why this is important, but it made things work.
$try2 = parse_str($params['data']);
//Hook in case someone wants to alter the data
CRM_Workflow_hook::beforeSave($wid, $data);
$transaction = new CRM_Core_Transaction();
$dsql = "DELETE FROM civicrm_workflow_detail WHERE workflow_id = {$wid}";
$dao =& CRM_Core_DAO::executeQuery($dsql);
if (!empty($data)) {
$sql = "INSERT INTO civicrm_workflow_detail ( workflow_id, entity_table, entity_id, `order`, breadcrumb, `next`, title) VALUES ";
$i = 1;
$vals = array();
foreach ($data as $key => $d) {
//$did = (strpos($id, ":")) ? 0 : $id;
$eid = $d['entity_id'];
$e_type = $d['entity_table'];
$order = $d['order'];
$breadcrumb = $d['breadcrumb'];
$next = $d['next'];
$title = $d['title'];
$sql = $sql . "( %" . ($i + 0) . ", %" . ($i + 1) . ", %" . ($i + 2) . ", %" . ($i + 3) . ", %" . ($i + 4) . ", %" . ($i + 5) . ", %" . ($i + 6) . "),";
//$vals[$i++] = array($did, 'Integer');
$vals[$i++] = array($wid, 'Integer');
$vals[$i++] = array($e_type, 'String');
$vals[$i++] = array($eid, 'String');
$vals[$i++] = array($order, 'Integer');
$vals[$i++] = array($breadcrumb, 'String');
$vals[$i++] = array($next, 'String');
$vals[$i++] = array($title, 'String');
}
$sql = substr($sql, 0, -1);
try {
$dao =& CRM_Core_DAO::executeQuery($sql, $vals);
} catch (Exception $e) {
$transaction->rollback();
return civicrm_api3_create_error($e . message);
}
//TODO: Better error checking?
if ($dao->_lastError) {
$transaction->rollback();
} else {
$transaction->commit();
CRM_Workflow_hook::afterSave($wid, $data);
}
}
$returnValues = array();
return civicrm_api3_create_success($returnValues, $params, 'PriceSet', 'FetchSection');
}
开发者ID:robbrandt,项目名称:civicrm-workflow,代码行数:67,代码来源:Save.php
示例8: run
function run()
{
// get the requested action
$action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
// assign vars to templates
$this->assign('action', $action);
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0);
if ($action & CRM_Core_Action::UPDATE) {
$controller = new CRM_Core_Controller_Simple('CRM_Wci_Form_ProgressBar', 'Edit Progressbar', CRM_Core_Action::UPDATE);
$controller->set('id', $id);
$controller->process();
return $controller->run();
} elseif ($action & CRM_Core_Action::COPY) {
try {
$sql = "INSERT INTO civicrm_wci_progress_bar (name, starting_amount, goal_amount)\n SELECT concat(name, '-', (SELECT MAX(id) FROM civicrm_wci_progress_bar)),\n starting_amount, goal_amount FROM civicrm_wci_progress_bar\n WHERE id=%1";
CRM_Core_DAO::executeQuery($sql, array(1 => array($id, 'Integer')));
$new_pb_id = CRM_Core_DAO::singleValueQuery('SELECT LAST_INSERT_ID()');
$sql = "INSERT INTO civicrm_wci_progress_bar_formula\n (contribution_page_id, financial_type_id, progress_bar_id, start_date, end_date, percentage)\n SELECT contribution_page_id, financial_type_id, %1, start_date,\n end_date, percentage FROM civicrm_wci_progress_bar_formula WHERE progress_bar_id=%2";
CRM_Core_DAO::executeQuery($sql, array(1 => array($new_pb_id, 'Integer'), 2 => array($id, 'Integer')));
} catch (Exception $e) {
CRM_Core_Session::setStatus(ts('Failed to create Progress bar. ') . $e->getMessage(), '', 'error');
$transaction->rollback();
}
} elseif ($action & CRM_Core_Action::DELETE) {
$errorScope = CRM_Core_TemporaryErrorScope::useException();
try {
$transaction = new CRM_Core_Transaction();
$sql = "DELETE FROM civicrm_wci_progress_bar_formula where progress_bar_id = %1";
$params = array(1 => array($id, 'Integer'));
CRM_Core_DAO::executeQuery($sql, $params);
$sql = "DELETE FROM civicrm_wci_progress_bar where id = %1";
$params = array(1 => array($id, 'Integer'));
CRM_Core_DAO::executeQuery($sql, $params);
$transaction->commit();
} catch (Exception $e) {
$errmgs = $e->getMessage() . ts('. Check whether progressbar is used by any widget or not');
CRM_Core_Session::setStatus($errmgs, '', 'error');
$transaction->rollback();
}
}
// Example: Set the page-title dynamically; alternatively, declare a static title in xml/Menu/*.xml
CRM_Utils_System::setTitle(ts('Progress Bar List'));
$query = "SELECT * FROM civicrm_wci_progress_bar";
$params = array();
$dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Wci_DAO_ProgressBar');
while ($dao->fetch()) {
$con_page[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $con_page[$dao->id]);
$action = array_sum(array_keys($this->actionLinks()));
//build the normal action links.
$con_page[$dao->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $dao->id));
}
if (isset($con_page)) {
$this->assign('rows', $con_page);
}
return parent::run();
}
开发者ID:Jagadees-zyxware,项目名称:civicrm-wci,代码行数:57,代码来源:ProgressBarList.php
示例9: run
function run()
{
$transaction = new CRM_Core_Transaction();
$cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session();
$cart->load_associations();
$this->assign_by_ref('events_in_carts', $cart->get_main_events_in_carts());
$this->assign('events_count', count($cart->get_main_events_in_carts()));
$transaction->commit();
return parent::run();
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:10,代码来源:ViewCart.php
示例10: create
/**
* @param array $params
*
* @return $this
* @throws Exception
*/
public static function create($params)
{
$transaction = new CRM_Core_Transaction();
$cart = self::add($params);
if (is_a($cart, 'CRM_Core_Error')) {
$transaction->rollback();
CRM_Core_Error::fatal(ts('There was an error creating an event cart'));
}
$transaction->commit();
return $cart;
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:17,代码来源:Cart.php
示例11: confirm
/**
* Confirm a pending subscription
*
* @param int $contact_id The id of the contact
* @param int $subscribe_id The id of the subscription event
* @param string $hash The hash
*
* @return boolean True on success
* @access public
* @static
*/
public static function confirm($contact_id, $subscribe_id, $hash)
{
$se =& CRM_Mailing_Event_BAO_Subscribe::verify($contact_id, $subscribe_id, $hash);
if (!$se) {
return FALSE;
}
// before we proceed lets just check if this contact is already 'Added'
// if so, we should ignore this request and hence avoid sending multiple
// emails - CRM-11157
$details = CRM_Contact_BAO_GroupContact::getMembershipDetail($contact_id, $se->group_id);
if ($details && $details->status == 'Added') {
// This contact is already subscribed
// lets return the group title
return CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $se->group_id, 'title');
}
$transaction = new CRM_Core_Transaction();
$ce = new CRM_Mailing_Event_BAO_Confirm();
$ce->event_subscribe_id = $se->id;
$ce->time_stamp = date('YmdHis');
$ce->save();
CRM_Contact_BAO_GroupContact::addContactsToGroup(array($contact_id), $se->group_id, 'Email', 'Added', $ce->id);
$transaction->commit();
$config = CRM_Core_Config::singleton();
$domain = CRM_Core_BAO_Domain::getDomain();
list($domainEmailName, $_) = CRM_Core_BAO_Domain::getNameAndEmail();
list($display_name, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($se->contact_id);
$group = new CRM_Contact_DAO_Group();
$group->id = $se->group_id;
$group->find(TRUE);
$component = new CRM_Mailing_BAO_Component();
$component->is_default = 1;
$component->is_active = 1;
$component->component_type = 'Welcome';
$component->find(TRUE);
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
$html = $component->body_html;
if ($component->body_text) {
$text = $component->body_text;
} else {
$text = CRM_Utils_String::htmlToText($component->body_html);
}
$bao = new CRM_Mailing_BAO_Mailing();
$bao->body_text = $text;
$bao->body_html = $html;
$tokens = $bao->getTokens();
$html = CRM_Utils_Token::replaceDomainTokens($html, $domain, TRUE, $tokens['html']);
$html = CRM_Utils_Token::replaceWelcomeTokens($html, $group->title, TRUE);
$text = CRM_Utils_Token::replaceDomainTokens($text, $domain, FALSE, $tokens['text']);
$text = CRM_Utils_Token::replaceWelcomeTokens($text, $group->title, FALSE);
$mailParams = array('groupName' => 'Mailing Event ' . $component->component_type, 'subject' => $component->subject, 'from' => "\"{$domainEmailName}\" <do-not-reply@{$emailDomain}>", 'toEmail' => $email, 'toName' => $display_name, 'replyTo' => "do-not-reply@{$emailDomain}", 'returnPath' => "do-not-reply@{$emailDomain}", 'html' => $html, 'text' => $text);
// send - ignore errors because the desired status change has already been successful
$unused_result = CRM_Utils_Mail::send($mailParams);
return $group->title;
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:65,代码来源:Confirm.php
示例12: CRM_Core_Transaction
static function &create(&$params)
{
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
$statusType = self::add($params);
if (is_a($statusType, 'CRM_Core_Error')) {
$transaction->rollback();
return $statusType;
}
$transaction->commit();
return $statusType;
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:12,代码来源:ParticipantStatusType.php
示例13: run
function run()
{
// get the requested action
$action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
// assign vars to templates
$this->assign('action', $action);
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0);
if ($action & CRM_Core_Action::UPDATE) {
$controller = new CRM_Core_Controller_Simple('CRM_Wci_Form_CreateWidget', 'Edit Widget', CRM_Core_Action::UPDATE);
$controller->set('id', $id);
$controller->process();
return $controller->run();
} elseif ($action & CRM_Core_Action::COPY) {
try {
$sql = "INSERT INTO civicrm_wci_widget (title, logo_image, image,\n button_title, button_link_to, progress_bar_id, description,\n email_signup_group_id, size_variant, color_title, color_title_bg,\n color_progress_bar, color_progress_bar_bg, color_widget_bg, color_description, color_border,\n color_button, color_button_bg, hide_title, hide_border, hide_pbcap,\n color_btn_newsletter, color_btn_newsletter_bg, newsletter_text,\n color_newsletter_text, style_rules, override, custom_template, show_pb_perc)\n SELECT concat(title, '-', (SELECT MAX(id) FROM civicrm_wci_widget)), logo_image, image,\n button_title, button_link_to, progress_bar_id, description,\n email_signup_group_id, size_variant, color_title, color_title_bg,\n color_progress_bar, color_progress_bar_bg, color_widget_bg, color_description, color_border,\n color_button, color_button_bg, hide_title, hide_border, hide_pbcap,\n color_btn_newsletter, color_btn_newsletter_bg, newsletter_text,\n color_newsletter_text, style_rules, override, custom_template, show_pb_perc FROM civicrm_wci_widget WHERE id=%1";
CRM_Core_DAO::executeQuery("SET foreign_key_checks = 0;");
CRM_Core_DAO::executeQuery($sql, array(1 => array($id, 'Integer')));
CRM_Core_DAO::executeQuery("SET foreign_key_checks = 1;");
} catch (Exception $e) {
CRM_Core_Session::setStatus(ts('Failed to create widget. ') . $e->getMessage(), '', 'error');
$transaction->rollback();
}
} elseif ($action & CRM_Core_Action::DELETE) {
try {
$transaction = new CRM_Core_Transaction();
$sql = "DELETE FROM civicrm_wci_widget where id = %1";
$params = array(1 => array($id, 'Integer'));
CRM_Core_DAO::executeQuery($sql, $params);
$transaction->commit();
} catch (Exception $e) {
CRM_Core_Session::setStatus(ts('Failed to delete widget. ') . $e->getMessage(), '', 'error');
$transaction->rollback();
}
}
CRM_Utils_System::setTitle(ts('Widget List'));
$query = "SELECT * FROM civicrm_wci_widget";
$params = array();
$dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Wci_DAO_Widget');
while ($dao->fetch()) {
$wid_page[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $wid_page[$dao->id]);
$wid_page[$dao->id]['title'] = $wid_page[$dao->id]['title'];
$description = $wid_page[$dao->id]['description'];
$wid_page[$dao->id]['description'] = strip_tags($description);
$action = array_sum(array_keys($this->actionLinks()));
//build the normal action links.
$wid_page[$dao->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $dao->id));
}
if (isset($wid_page)) {
$this->assign('rows', $wid_page);
}
parent::run();
}
开发者ID:Jagadees-zyxware,项目名称:civicrm-wci,代码行数:53,代码来源:WidgetList.php
示例14: stub_out_and_inherit
function stub_out_and_inherit()
{
$transaction = new CRM_Core_Transaction();
foreach ($this->cart->get_main_events_in_carts() as $event_in_cart) {
if (empty($event_in_cart->participants)) {
$participant = CRM_Event_Cart_BAO_MerParticipant::create(array('cart_id' => $this->cart->id, 'event_id' => $event_in_cart->event_id, 'contact_id' => self::find_or_create_contact($this->getContactID())));
$participant->save();
$event_in_cart->add_participant($participant);
}
$event_in_cart->save();
}
$transaction->commit();
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:13,代码来源:Cart.php
示例15: create
/**
* @param array $params
*
* @return object $this|CRM_Event_Cart_BAO_EventInCart
* @throws Exception
*/
public static function create(&$params)
{
$transaction = new CRM_Core_Transaction();
$event_in_cart = new CRM_Event_Cart_BAO_EventInCart();
$event_in_cart->copyValues($params);
$event_in_cart = $event_in_cart->save();
if (is_a($event_in_cart, 'CRM_Core_Error')) {
$transaction->rollback();
CRM_Core_Error::fatal(ts('There was an error creating an event_in_cart'));
}
$transaction->commit();
return $event_in_cart;
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:19,代码来源:EventInCart.php
示例16: run
/**
* This function takes care of all the things common to all pages.
*
* This typically involves assigning the appropriate smarty variables :)
*/
public function run()
{
$transaction = new CRM_Core_Transaction();
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session();
$cart->load_associations();
$event_in_cart = $cart->get_event_in_cart_by_event_id($this->_id);
$removed_event = $cart->remove_event_in_cart($event_in_cart->id);
$removed_event_title = $removed_event->event->title;
CRM_Core_Session::setStatus(ts("<b>%1</b> has been removed from your cart.", array(1 => $removed_event_title)), '', 'success');
$transaction->commit();
return CRM_Utils_System::redirect($_SERVER['HTTP_REFERER']);
}
开发者ID:konadave,项目名称:civicrm-core,代码行数:18,代码来源:RemoveFromCart.php
示例17: run
/**
* This function takes care of all the things common to all pages.
*
* This typically involves assigning the appropriate smarty variables :)
*/
public function run()
{
$transaction = new CRM_Core_Transaction();
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
if (!CRM_Core_Permission::event(CRM_Core_Permission::VIEW, $this->_id, 'register for events')) {
CRM_Core_Error::fatal(ts('You do not have permission to register for this event'));
}
$cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session();
$event_in_cart = $cart->add_event($this->_id);
$url = CRM_Utils_System::url('civicrm/event/view_cart');
CRM_Utils_System::setUFMessage(ts("<b>%1</b> has been added to your cart. <a href='%2'>View your cart.</a>", array(1 => $event_in_cart->event->title, 2 => $url)));
$transaction->commit();
return CRM_Utils_System::redirect($_SERVER['HTTP_REFERER']);
}
开发者ID:konadave,项目名称:civicrm-core,代码行数:19,代码来源:AddToCart.php
示例18: delByResource
/**
* Delete all slots (associated bookings) for a particular resource
*/
static function delByResource($resourceId)
{
$result = civicrm_api3('Slot', 'get', array('resource_id' => $resourceId, 'is_deleted' => 0));
$slots = $result['values'];
$transaction = new CRM_Core_Transaction();
try {
foreach ($slots as $slotId => $slot) {
self::del($slotId);
}
} catch (Exception $e) {
$transaction->rollback();
CRM_Core_Error::fatal($e->getMessage());
}
}
开发者ID:sushantpaste,项目名称:civibooking,代码行数:17,代码来源:Slot.php
示例19: civicrm_api3_membership_payment_create
/**
* Add or update a link between contribution and membership
*
* @param array $params (reference ) input parameters
*
* @return array (reference ) membership_payment_id of created or updated record
* {@getfields MembershipPayment_create}
* @example MembershipPaymentCreate.php
* @access public
*/
function civicrm_api3_membership_payment_create($params)
{
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
$mpDAO = new CRM_Member_DAO_MembershipPayment();
$mpDAO->copyValues($params);
$result = $mpDAO->save();
if (is_a($result, 'CRM_Core_Error')) {
$transaction->rollback();
return civicrm_api3_create_error($result->_errors[0]['message']);
}
$transaction->commit();
_civicrm_api3_object_to_array($mpDAO, $mpArray[$mpDAO->id]);
return civicrm_api3_create_success($mpArray, $params);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:25,代码来源:MembershipPayment.php
示例20: UpgradeFromQueue
public static function UpgradeFromQueue(CRM_Queue_TaskContext $ctx, $mid, $params)
{
$today = new DateTime();
$membership = civicrm_api3('Membership', 'getsingle', array('id' => $mid));
$oldMembershipStatus = $params['rood_mstatus'];
$migratie_lidmaatschappen_cg = civicrm_api3('CustomGroup', 'getvalue', array('return' => 'id', 'name' => 'Migratie_Lidmaatschappen'));
$reason_fid = civicrm_api3('CustomField', 'getvalue', array('return' => 'id', 'name' => 'Reden', 'custom_group_id' => $migratie_lidmaatschappen_cg));
unset($membership['id']);
$dao = CRM_Core_DAO::executeQuery("\n SELECT `c`.`id` AS `contribution_id`\nFROM `civicrm_membership`\nINNER JOIN `civicrm_membership_payment` `mp` ON `civicrm_membership`.`id` = `mp`.`membership_id`\nINNER JOIN `civicrm_contribution` `c` ON `mp`.`contribution_id` = `c`.`id` AND c.receive_date <= civicrm_membership.end_date\nWHERE civicrm_membership.id = %1\nORDER BY c.receive_date DESC\nLIMIT 0, 1", array(1 => array($mid, 'Integer')));
if ($dao->fetch()) {
$contribution = self::getRenewalPayment($dao->contribution_id);
$renewTransaction = new CRM_Core_Transaction();
$membership['membership_type_id'] = $params['sp_mtype'];
$membership['start_date'] = $today->format('Ymd');
if ($today->format('m') >= 10) {
$newEndDate = clone $today;
$newEndDate->modify('last day of +1 year');
$membership['end_date'] = $newEndDate->format('Ymd');
}
$new_membership = civicrm_api3('Membership', 'create', $membership);
if ($contribution) {
$contribution['financial_type_id'] = civicrm_api3('MembershipType', 'getvalue', array('return' => 'financial_type_id', 'id' => $params['sp_mtype']));
if ((double) $contribution['total_amount'] < (double) $params['minimum_fee']) {
$contribution['total_amount'] = $params['minimum_fee'];
}
$result = civicrm_api3('Contribution', 'create', $contribution);
// Get Soft contributions
$softContributions = civicrm_api3('ContributionSoft', 'get', array('contribution_id' => $dao->contribution_id));
foreach ($softContributions['values'] as $softContribution) {
$newSoftContribution = $softContribution;
unset($newSoftContribution['id']);
$newSoftContribution['contribution_id'] = $result['id'];
civicrm_api3('ContributionSoft', 'create', $newSoftContribution);
}
$membershipPayment['contribution_id'] = $result['id'];
$membershipPayment['membership_id'] = $new_membership['id'];
civicrm_api3('MembershipPayment', 'create', $membershipPayment);
}
$oldMembership['id'] = $mid;
$oldMembership['is_override'] = 1;
$oldMembership['status_id'] = $oldMembershipStatus;
$oldMembership['custom_' . $reason_fid] = '28 jarige';
$oldMembership['end_date'] = $today->format('Ymd');
civicrm_api3('Membership', 'create', $oldMembership);
$renewTransaction->commit();
}
return true;
}
开发者ID:SPnl,项目名称:nl.sp.rood,代码行数:48,代码来源:MembershipUpgrade.php
注:本文中的CRM_Core_Transaction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论