• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP CRM_Core_TemporaryErrorScope类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: smarty_function_crmAPI

/**
 * @param $params
 * @param $smarty
 * @return string|void
 */
function smarty_function_crmAPI($params, &$smarty)
{
    if (!array_key_exists('entity', $params)) {
        $smarty->trigger_error("assign: missing 'entity' parameter");
        return "crmAPI: missing 'entity' parameter";
    }
    $errorScope = CRM_Core_TemporaryErrorScope::create(array('CRM_Utils_REST', 'fatal'));
    $entity = $params['entity'];
    $action = CRM_Utils_Array::value('action', $params, 'get');
    $params['sequential'] = CRM_Utils_Array::value('sequential', $params, 1);
    $var = CRM_Utils_Array::value('var', $params);
    CRM_Utils_Array::remove($params, 'entity', 'action', 'var');
    $params['version'] = 3;
    require_once 'api/api.php';
    $result = civicrm_api($entity, $action, $params);
    unset($errorScope);
    if ($result === FALSE) {
        $smarty->trigger_error("Unknown error");
        return;
    }
    if (!empty($result['is_error'])) {
        $smarty->trigger_error("{crmAPI} " . $result["error_message"]);
    }
    if (!$var) {
        return json_encode($result);
    }
    if (!empty($params['json'])) {
        $smarty->assign($var, json_encode($result));
    } else {
        $smarty->assign($var, $result);
    }
}
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:37,代码来源:function.crmAPI.php


示例3: civicrm_event_create

/**
 * Create a Event
 *
 * This API is used for creating a Event
 *
 * @param  array   $params           (reference ) input parameters
 * Allowed @params array keys are:
 * {@schema Event/Event.xml}
 *
 * @return array of newly created event property values.
 * @access public
 */
function civicrm_event_create(&$params)
{
    _civicrm_initialize();
    $errorScope = CRM_Core_TemporaryErrorScope::useException();
    try {
        civicrm_api_check_permission(__FUNCTION__, $params, TRUE);
        civicrm_verify_mandatory($params, 'CRM_Event_DAO_Event', array('start_date', 'event_type_id', 'title'));
        // Do we really want $params[id], even if we have
        // $params[event_id]? if yes then please uncomment the below line
        //$ids['event'      ] = $params['id'];
        $ids['eventTypeId'] = (int) $params['event_type_id'];
        $ids['startDate'] = $params['start_date'];
        $ids['event_id'] = CRM_Utils_Array::value('event_id', $params);
        require_once 'CRM/Event/BAO/Event.php';
        $eventBAO = CRM_Event_BAO_Event::create($params, $ids);
        if (is_a($eventBAO, 'CRM_Core_Error')) {
            return civicrm_create_error("Event is not created");
        } else {
            $event = array();
            _civicrm_object_to_array($eventBAO, $event);
            $values = array();
            $values['event_id'] = $event['id'];
            $values['is_error'] = 0;
        }
        return $values;
    } catch (Exception $e) {
        return civicrm_create_error($e->getMessage());
    }
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:41,代码来源:Event.php


示例4: run

 /**
  * @param string $entity
  *   type of entities to deal with
  * @param string $action
  *   create, get, delete or some special action name.
  * @param array $params
  *   array to be passed to function
  * @param null $extra
  *
  * @return array|int
  */
 public function run($entity, $action, $params, $extra = NULL)
 {
     /**
      * @var $apiProvider \Civi\API\Provider\ProviderInterface|NULL
      */
     $apiProvider = NULL;
     // TODO Define alternative calling convention makes it easier to construct $apiRequest
     // without the ambiguity of "data" vs "options"
     $apiRequest = Request::create($entity, $action, $params, $extra);
     try {
         if (!is_array($params)) {
             throw new \API_Exception('Input variable `params` is not an array', 2000);
         }
         $this->boot();
         $errorScope = \CRM_Core_TemporaryErrorScope::useException();
         list($apiProvider, $apiRequest) = $this->resolve($apiRequest);
         $this->authorize($apiProvider, $apiRequest);
         $apiRequest = $this->prepare($apiProvider, $apiRequest);
         $result = $apiProvider->invoke($apiRequest);
         $apiResponse = $this->respond($apiProvider, $apiRequest, $result);
         return $this->formatResult($apiRequest, $apiResponse);
     } catch (\Exception $e) {
         $this->dispatcher->dispatch(Events::EXCEPTION, new ExceptionEvent($e, $apiProvider, $apiRequest));
         if ($e instanceof \PEAR_Exception) {
             $err = $this->formatPearException($e, $apiRequest);
         } elseif ($e instanceof \API_Exception) {
             $err = $this->formatApiException($e, $apiRequest);
         } else {
             $err = $this->formatException($e, $apiRequest);
         }
         return $this->formatResult($apiRequest, $err);
     }
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:44,代码来源:Kernel.php


示例5: 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


示例6: activate

 function activate()
 {
     $this->active = TRUE;
     $this->backup = array();
     foreach (array('display_errors', 'html_errors', 'xmlrpc_errors') as $key) {
         $this->backup[$key] = ini_get($key);
         ini_set($key, 0);
     }
     set_error_handler(array($this, 'onError'), $this->level);
     // FIXME make this temporary/reversible
     $this->errorScope = CRM_Core_TemporaryErrorScope::useException();
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:12,代码来源:ErrorPolicy.php


示例7: civicrm_contact_create

/**
 * @todo Write sth
 *
 * @param  array   $params           (reference ) input parameters
 *
 * Allowed @params array keys are:
 * {@schema Contact/Contact.xml}
 * {@schema Core/Address.xml}}
 *
 * @return array (reference )        contact_id of created or updated contact
 *
 * @static void
 * @access public
 */
function civicrm_contact_create(&$params)
{
    // call update and tell it to create a new contact
    _civicrm_initialize();
    $errorScope = CRM_Core_TemporaryErrorScope::useException();
    try {
        civicrm_api_check_permission(__FUNCTION__, $params, TRUE);
        $create_new = TRUE;
        return civicrm_contact_update($params, $create_new);
    } catch (Exception $e) {
        return civicrm_create_error($e->getMessage());
    }
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:27,代码来源:Contact.php


示例8: preProcess

 /**
  * Set variables up before form is built.
  */
 public function preProcess()
 {
     //Test database user privilege to create table(Temporary) CRM-4725
     $errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
     $daoTestPrivilege = new CRM_Core_DAO();
     $daoTestPrivilege->query("CREATE TEMPORARY TABLE import_job_permission_one(test int) ENGINE=InnoDB");
     $daoTestPrivilege->query("CREATE TEMPORARY TABLE import_job_permission_two(test int) ENGINE=InnoDB");
     $daoTestPrivilege->query("DROP TEMPORARY TABLE IF EXISTS import_job_permission_one, import_job_permission_two");
     unset($errorScope);
     if ($daoTestPrivilege->_lastError) {
         CRM_Core_Error::fatal(ts('Database Configuration Error: Insufficient permissions. Import requires that the CiviCRM database user has permission to create temporary tables. Contact your site administrator for assistance.'));
     }
     $results = array();
     $config = CRM_Core_Config::singleton();
     $handler = opendir($config->uploadDir);
     $errorFiles = array('sqlImport.errors', 'sqlImport.conflicts', 'sqlImport.duplicates', 'sqlImport.mismatch');
     // check for post max size avoid when called twice
     $snippet = CRM_Utils_Array::value('snippet', $_GET, 0);
     if (empty($snippet)) {
         CRM_Utils_Number::formatUnitSize(ini_get('post_max_size'), TRUE);
     }
     while ($file = readdir($handler)) {
         if ($file != '.' && $file != '..' && in_array($file, $errorFiles) && !is_writable($config->uploadDir . $file)) {
             $results[] = $file;
         }
     }
     closedir($handler);
     if (!empty($results)) {
         CRM_Core_Error::fatal(ts('<b>%1</b> file(s) in %2 directory are not writable. Listed file(s) might be used during the import to log the errors occurred during Import process. Contact your site administrator for assistance.', array(1 => implode(', ', $results), 2 => $config->uploadDir)));
     }
     $this->_dataSourceIsValid = FALSE;
     $this->_dataSource = CRM_Utils_Request::retrieve('dataSource', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET');
     $this->_params = $this->controller->exportValues($this->_name);
     if (!$this->_dataSource) {
         //considering dataSource as base criteria instead of hidden_dataSource.
         $this->_dataSource = CRM_Utils_Array::value('dataSource', $_POST, CRM_Utils_Array::value('dataSource', $this->_params));
         $this->assign('showOnlyDataSourceFormPane', FALSE);
     } else {
         $this->assign('showOnlyDataSourceFormPane', TRUE);
     }
     $dataSources = $this->_getDataSources();
     if ($this->_dataSource && isset($dataSources[$this->_dataSource])) {
         $this->_dataSourceIsValid = TRUE;
         $this->assign('showDataSourceFormPane', TRUE);
         $dataSourcePath = explode('_', $this->_dataSource);
         $templateFile = "CRM/Contact/Import/Form/" . $dataSourcePath[3] . ".tpl";
         $this->assign('dataSourceFormTemplateFile', $templateFile);
     } elseif ($this->_dataSource) {
         throw new \CRM_Core_Exception("Invalid data source");
     }
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:54,代码来源:DataSource.php


示例9: startTest

 public function startTest(\PHPUnit_Framework_Test $test)
 {
     if ($this->isCiviTest($test)) {
         error_reporting(E_ALL);
         $this->errorScope = \CRM_Core_TemporaryErrorScope::useException();
     }
     if ($test instanceof HeadlessInterface) {
         $this->bootHeadless($test);
     }
     if ($test instanceof HookInterface) {
         // Note: bootHeadless() indirectly resets any hooks, which means that hook_civicrm_config
         // is unsubscribable. However, after bootHeadless(), we're free to subscribe to hooks again.
         $this->registerHooks($test);
     }
     if ($test instanceof TransactionalInterface) {
         $this->tx = new \CRM_Core_Transaction(TRUE);
         $this->tx->rollback();
     } else {
         $this->tx = NULL;
     }
 }
开发者ID:sdekok,项目名称:civicrm-core,代码行数:21,代码来源:CiviTestListener.php


示例10: smarty_function_crmSetting

/**
 * Retrieve CiviCRM settings from the api for use in templates.
 *
 * @param $params
 * @param $smarty
 *
 * @return int|string|null
 */
function smarty_function_crmSetting($params, &$smarty)
{
    $errorScope = CRM_Core_TemporaryErrorScope::create(array('CRM_Utils_REST', 'fatal'));
    unset($params['method']);
    unset($params['assign']);
    $params['version'] = 3;
    require_once 'api/api.php';
    $result = civicrm_api('setting', 'getvalue', $params);
    unset($errorScope);
    if ($result === FALSE) {
        $smarty->trigger_error("Unknown error");
        return NULL;
    }
    if (empty($params['var'])) {
        return is_numeric($result) ? $result : json_encode($result);
    }
    if (!empty($params['json'])) {
        $smarty->assign($params["var"], json_encode($result));
    } else {
        $smarty->assign($params["var"], $result);
    }
}
开发者ID:kidaa30,项目名称:yes,代码行数:30,代码来源:function.crmSetting.php


示例11: unset

 /**
  * Singleton function used to manage this object.
  *
  * @param bool $loadFromDB
  *   whether to load from the database.
  * @param bool $force
  *   whether to force a reconstruction.
  *
  * @return CRM_Core_Config
  */
 public static function &singleton($loadFromDB = TRUE, $force = FALSE)
 {
     if (self::$_singleton === NULL || $force) {
         $GLOBALS['civicrm_default_error_scope'] = CRM_Core_TemporaryErrorScope::create(array('CRM_Core_Error', 'handle'));
         $errorScope = CRM_Core_TemporaryErrorScope::create(array('CRM_Core_Error', 'simpleHandler'));
         if (defined('E_DEPRECATED')) {
             error_reporting(error_reporting() & ~E_DEPRECATED);
         }
         self::$_singleton = new CRM_Core_Config();
         \Civi\Core\Container::boot($loadFromDB);
         if ($loadFromDB && self::$_singleton->dsn) {
             $domain = \CRM_Core_BAO_Domain::getDomain();
             \CRM_Core_BAO_ConfigSetting::applyLocale(\Civi::settings($domain->id), $domain->locales);
             unset($errorScope);
             CRM_Utils_Hook::config(self::$_singleton);
             self::$_singleton->authenticate();
             // Extreme backward compat: $config binds to active domain at moment of setup.
             self::$_singleton->getSettings();
             Civi::service('settings_manager')->useDefaults();
         }
     }
     return self::$_singleton;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:33,代码来源:Config.php


示例12: send_confirm_request

 /**
  * Ask a contact for subscription confirmation (opt-in)
  *
  * @param string $email
  *   The email address.
  *
  * @return void
  */
 public function send_confirm_request($email)
 {
     $config = CRM_Core_Config::singleton();
     $domain = CRM_Core_BAO_Domain::getDomain();
     //get the default domain email address.
     list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
     $localpart = CRM_Core_BAO_MailSettings::defaultLocalpart();
     $emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
     $confirm = implode($config->verpSeparator, array($localpart . 'c', $this->contact_id, $this->id, $this->hash)) . "@{$emailDomain}";
     $group = new CRM_Contact_BAO_Group();
     $group->id = $this->group_id;
     $group->find(TRUE);
     $component = new CRM_Mailing_BAO_Component();
     $component->is_default = 1;
     $component->is_active = 1;
     $component->component_type = 'Subscribe';
     $component->find(TRUE);
     $headers = array('Subject' => $component->subject, 'From' => "\"{$domainEmailName}\" <{$domainEmailAddress}>", 'To' => $email, 'Reply-To' => $confirm, 'Return-Path' => "do-not-reply@{$emailDomain}");
     $url = CRM_Utils_System::url('civicrm/mailing/confirm', "reset=1&cid={$this->contact_id}&sid={$this->id}&h={$this->hash}", TRUE);
     $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::replaceSubscribeTokens($html, $group->title, $url, TRUE);
     $text = CRM_Utils_Token::replaceDomainTokens($text, $domain, FALSE, $tokens['text']);
     $text = CRM_Utils_Token::replaceSubscribeTokens($text, $group->title, $url, FALSE);
     // render the &amp; entities in text mode, so that the links work
     $text = str_replace('&amp;', '&', $text);
     $message = new Mail_mime("\n");
     $message->setHTMLBody($html);
     $message->setTxtBody($text);
     $b = CRM_Utils_Mail::setMimeParams($message);
     $h = $message->headers($headers);
     CRM_Mailing_BAO_Mailing::addMessageIdHeader($h, 's', $this->contact_id, $this->id, $this->hash);
     $mailer = \Civi::service('pear_mail');
     if (is_object($mailer)) {
         $errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
         $mailer->send($email, $h, $b);
         unset($errorScope);
     }
 }
开发者ID:rollox,项目名称:civicrm-core,代码行数:56,代码来源:Subscribe.php


示例13: testMoveField

 /**
  * Move a custom field from $groupA to $groupB. Make sure that data records are
  * correctly matched and created.
  */
 public function testMoveField()
 {
     $countriesByName = array_flip(CRM_Core_PseudoConstant::country(FALSE, FALSE));
     $this->assertTrue($countriesByName['ANDORRA'] > 0);
     $groups = array('A' => Custom::createGroup(array('title' => 'Test_Group A', 'name' => 'test_group_a', 'extends' => array('Individual'), 'style' => 'Inline', 'is_multiple' => 0, 'is_active' => 1, 'version' => 3)), 'B' => Custom::createGroup(array('title' => 'Test_Group B', 'name' => 'test_group_b', 'extends' => array('Individual'), 'style' => 'Inline', 'is_multiple' => 0, 'is_active' => 1, 'version' => 3)));
     $fields = array('countryA' => Custom::createField(array(), array('groupId' => $groups['A']->id, 'label' => 'Country A', 'dataType' => 'Country', 'htmlType' => 'Select Country')), 'countryB' => Custom::createField(array(), array('groupId' => $groups['A']->id, 'label' => 'Country B', 'dataType' => 'Country', 'htmlType' => 'Select Country')), 'countryC' => Custom::createField(array(), array('groupId' => $groups['B']->id, 'label' => 'Country C', 'dataType' => 'Country', 'htmlType' => 'Select Country')));
     $contacts = array('alice' => Contact::createIndividual(array('first_name' => 'Alice', 'last_name' => 'Albertson', 'custom_' . $fields['countryA']->id => $countriesByName['ANDORRA'], 'custom_' . $fields['countryB']->id => $countriesByName['BARBADOS'])), 'bob' => Contact::createIndividual(array('first_name' => 'Bob', 'last_name' => 'Roberts', 'custom_' . $fields['countryA']->id => $countriesByName['AUSTRIA'], 'custom_' . $fields['countryB']->id => $countriesByName['BERMUDA'], 'custom_' . $fields['countryC']->id => $countriesByName['CHAD'])), 'carol' => Contact::createIndividual(array('first_name' => 'Carol', 'last_name' => 'Carolson', 'custom_' . $fields['countryC']->id => $countriesByName['CAMBODIA'])));
     // Move!
     CRM_Core_BAO_CustomField::moveField($fields['countryB']->id, $groups['B']->id);
     // Group[A] no longer has fields[countryB]
     $errorScope = CRM_Core_TemporaryErrorScope::useException();
     try {
         $this->assertDBQuery(1, "SELECT {$fields['countryB']->column_name} FROM {$groups['A']->table_name}");
         $this->fail('Expected exception when querying column on wrong table');
     } catch (PEAR_Exception $e) {
     }
     $errorScope = NULL;
     // Alice: Group[B] has fields[countryB], but fields[countryC] did not exist before
     $this->assertDBQuery(1, "SELECT count(*) FROM {$groups['B']->table_name}\n            WHERE entity_id = %1\n            AND {$fields['countryB']->column_name} = %3\n            AND {$fields['countryC']->column_name} is null", array(1 => array($contacts['alice'], 'Integer'), 3 => array($countriesByName['BARBADOS'], 'Integer')));
     // Bob: Group[B] has merged fields[countryB] and fields[countryC] on the same record
     $this->assertDBQuery(1, "SELECT count(*) FROM {$groups['B']->table_name}\n            WHERE entity_id = %1\n            AND {$fields['countryB']->column_name} = %3\n            AND {$fields['countryC']->column_name} = %4", array(1 => array($contacts['bob'], 'Integer'), 3 => array($countriesByName['BERMUDA'], 'Integer'), 4 => array($countriesByName['CHAD'], 'Integer')));
     // Carol: Group[B] still has fields[countryC] but did not get fields[countryB]
     $this->assertDBQuery(1, "SELECT count(*) FROM {$groups['B']->table_name}\n            WHERE entity_id = %1\n            AND {$fields['countryB']->column_name} is null\n            AND {$fields['countryC']->column_name} = %4", array(1 => array($contacts['carol'], 'Integer'), 4 => array($countriesByName['CAMBODIA'], 'Integer')));
     Custom::deleteGroup($groups['A']);
     Custom::deleteGroup($groups['B']);
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:30,代码来源:CustomFieldTest.php


示例14: testSetGetValuesYesNoRadio

 /**
  * Test setValues() and getValues() methods with custom field YesNo(Boolean) Radio
  */
 public function testSetGetValuesYesNoRadio()
 {
     $contactID = $this->individualCreate();
     $customGroup = $this->customGroupCreate(array('is_multiple' => 1));
     //create Custom Field of type YesNo(Boolean) Radio
     $fields = array('custom_group_id' => $customGroup['id'], 'data_type' => 'Boolean', 'html_type' => 'Radio', 'default_value' => '');
     $customField = $this->customFieldCreate($fields);
     // Retrieve the field ID for sample custom field 'test_Boolean'
     $params = array('label' => 'test_Boolean');
     $field = array();
     //get field Id
     CRM_Core_BAO_CustomField::retrieve($params, $field);
     $fieldID = $customField['id'];
     // valid boolean value '1' for Boolean Radio
     $yesNo = '1';
     $params = array('entityID' => $contactID, 'custom_' . $fieldID => $yesNo);
     $result = CRM_Core_BAO_CustomValueTable::setValues($params);
     $this->assertEquals($result['is_error'], 0, 'Verify that is_error = 0 (success).');
     // Check that the YesNo radio value is stored
     $params = array('entityID' => $contactID, 'custom_' . $fieldID => 1);
     $values = CRM_Core_BAO_CustomValueTable::getValues($params);
     $this->assertEquals($values['is_error'], 0, 'Verify that is_error = 0 (success).');
     $this->assertEquals($values["custom_{$fieldID}_1"], $yesNo, 'Verify that the boolean value is stored for contact ' . $contactID);
     // Now set YesNo radio to an invalid boolean value and try to reset
     $badYesNo = '20';
     $params = array('entityID' => $contactID, 'custom_' . $fieldID => $badYesNo);
     CRM_Core_TemporaryErrorScope::useException();
     $message = NULL;
     try {
         CRM_Core_BAO_CustomValueTable::setValues($params);
     } catch (Exception $e) {
         $message = $e->getMessage();
     }
     $errorScope = NULL;
     // Check that an exception has been thrown
     $this->assertNotNull($message, 'Verify than an exception is thrown when bad boolean is passed');
     $params = array('entityID' => $contactID, 'custom_' . $fieldID => 1);
     $values = CRM_Core_BAO_CustomValueTable::getValues($params);
     $this->assertEquals($values["custom_{$fieldID}_1"], $yesNo, 'Verify that the date value has NOT been updated for contact ' . $contactID);
     // Cleanup
     $this->customFieldDelete($customField['id']);
     $this->customGroupDelete($customGroup['id']);
     $this->contactDelete($contactID);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:47,代码来源:CustomValueTableSetGetTest.php


示例15: checkTriggerViewPermission

 /**
  * @param bool $view
  * @param bool $trigger
  *
  * @return bool
  */
 public static function checkTriggerViewPermission($view = TRUE, $trigger = TRUE)
 {
     // test for create view and trigger permissions and if allowed, add the option to go multilingual
     // and logging
     // I'm not sure why we use the getStaticProperty for an error, rather than checking for DB_Error
     $errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
     $dao = new CRM_Core_DAO();
     if ($view) {
         $dao->query('CREATE OR REPLACE VIEW civicrm_domain_view AS SELECT * FROM civicrm_domain');
         if (PEAR::getStaticProperty('DB_DataObject', 'lastError')) {
             return FALSE;
         }
     }
     if ($trigger) {
         $result = $dao->query('CREATE TRIGGER civicrm_domain_trigger BEFORE INSERT ON civicrm_domain FOR EACH ROW BEGIN END');
         if (PEAR::getStaticProperty('DB_DataObject', 'lastError') || is_a($result, 'DB_Error')) {
             if ($view) {
                 $dao->query('DROP VIEW IF EXISTS civicrm_domain_view');
             }
             return FALSE;
         }
         $dao->query('DROP TRIGGER IF EXISTS civicrm_domain_trigger');
         if (PEAR::getStaticProperty('DB_DataObject', 'lastError')) {
             if ($view) {
                 $dao->query('DROP VIEW IF EXISTS civicrm_domain_view');
             }
             return FALSE;
         }
     }
     if ($view) {
         $dao->query('DROP VIEW IF EXISTS civicrm_domain_view');
         if (PEAR::getStaticProperty('DB_DataObject', 'lastError')) {
             return FALSE;
         }
     }
     return TRUE;
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:43,代码来源:DAO.php


示例16: send_unsub_response

 /**
  * Send a response email informing the contact of the groups from which he.
  * has been unsubscribed.
  *
  * @param string $queue_id
  *   The queue event ID.
  * @param array $groups
  *   List of group IDs.
  * @param bool $is_domain
  *   Is this domain-level?.
  * @param int $job
  *   The job ID.
  */
 public static function send_unsub_response($queue_id, $groups, $is_domain = FALSE, $job)
 {
     $config = CRM_Core_Config::singleton();
     $domain = CRM_Core_BAO_Domain::getDomain();
     $jobObject = new CRM_Mailing_BAO_MailingJob();
     $jobTable = $jobObject->getTableName();
     $mailingObject = new CRM_Mailing_DAO_Mailing();
     $mailingTable = $mailingObject->getTableName();
     $contactsObject = new CRM_Contact_DAO_Contact();
     $contacts = $contactsObject->getTableName();
     $emailObject = new CRM_Core_DAO_Email();
     $email = $emailObject->getTableName();
     $queueObject = new CRM_Mailing_Event_BAO_Queue();
     $queue = $queueObject->getTableName();
     //get the default domain email address.
     list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
     $dao = new CRM_Mailing_BAO_Mailing();
     $dao->query("   SELECT * FROM {$mailingTable}\n                        INNER JOIN {$jobTable} ON\n                            {$jobTable}.mailing_id = {$mailingTable}.id\n                        WHERE {$jobTable}.id = {$job}");
     $dao->fetch();
     $component = new CRM_Mailing_BAO_Component();
     if ($is_domain) {
         $component->id = $dao->optout_id;
     } else {
         $component->id = $dao->unsubscribe_id;
     }
     $component->find(TRUE);
     $html = $component->body_html;
     if ($component->body_text) {
         $text = $component->body_text;
     } else {
         $text = CRM_Utils_String::htmlToText($component->body_html);
     }
     $eq = new CRM_Core_DAO();
     $eq->query("SELECT     {$contacts}.preferred_mail_format as format,\n                    {$contacts}.id as contact_id,\n                    {$email}.email as email,\n                    {$queue}.hash as hash\n        FROM        {$contacts}\n        INNER JOIN  {$queue} ON {$queue}.contact_id = {$contacts}.id\n        INNER JOIN  {$email} ON {$queue}.email_id = {$email}.id\n        WHERE       {$queue}.id = " . CRM_Utils_Type::escape($queue_id, 'Integer'));
     $eq->fetch();
     if ($groups) {
         foreach ($groups as $key => $value) {
             if (!$value) {
                 unset($groups[$key]);
             }
         }
     }
     $message = new Mail_mime("\n");
     list($addresses, $urls) = CRM_Mailing_BAO_Mailing::getVerpAndUrls($job, $queue_id, $eq->hash, $eq->email);
     $bao = new CRM_Mailing_BAO_Mailing();
     $bao->body_text = $text;
     $bao->body_html = $html;
     $tokens = $bao->getTokens();
     if ($eq->format == 'HTML' || $eq->format == 'Both') {
         $html = CRM_Utils_Token::replaceDomainTokens($html, $domain, TRUE, $tokens['html']);
         $html = CRM_Utils_Token::replaceUnsubscribeTokens($html, $domain, $groups, TRUE, $eq->contact_id, $eq->hash);
         $html = CRM_Utils_Token::replaceActionTokens($html, $addresses, $urls, TRUE, $tokens['html']);
         $html = CRM_Utils_Token::replaceMailingTokens($html, $dao, NULL, $tokens['html']);
         $message->setHTMLBody($html);
     }
     if (!$html || $eq->format == 'Text' || $eq->format == 'Both') {
         $text = CRM_Utils_Token::replaceDomainTokens($text, $domain, FALSE, $tokens['text']);
         $text = CRM_Utils_Token::replaceUnsubscribeTokens($text, $domain, $groups, FALSE, $eq->contact_id, $eq->hash);
         $text = CRM_Utils_Token::replaceActionTokens($text, $addresses, $urls, FALSE, $tokens['text']);
         $text = CRM_Utils_Token::replaceMailingTokens($text, $dao, NULL, $tokens['text']);
         $message->setTxtBody($text);
     }
     $emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
     $headers = array('Subject' => $component->subject, 'From' => "\"{$domainEmailName}\" <do-not-reply@{$emailDomain}>", 'To' => $eq->email, 'Reply-To' => "do-not-reply@{$emailDomain}", 'Return-Path' => "do-not-reply@{$emailDomain}");
     CRM_Mailing_BAO_Mailing::addMessageIdHeader($headers, 'u', $job, $queue_id, $eq->hash);
     $b = CRM_Utils_Mail::setMimeParams($message);
     $h = $message->headers($headers);
     $mailer = \Civi::service('pear_mail');
     if (is_object($mailer)) {
         $errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
         $mailer->send($eq->email, $h, $b);
         unset($errorScope);
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:87,代码来源:Unsubscribe.php


示例17: smarty_function_crmSQL

function smarty_function_crmSQL($params, &$smarty) { 
    $is_error = 0;
    $error = "";
    $values = "";
    $sql="";

    if (!array_key_exists('sql', $params) && !array_key_exists('file', $params) && !array_key_exists('json', $params)) { 
        $smarty->trigger_error("assign: missing 'sql', 'json' OR 'file' parameter"); 
        $error = "crmAPI: missing 'sql', 'json' or 'file' parameter"; 
        $is_error = 1;
    } 

    $parameters = array();

    if(array_key_exists('json', $params)){
        $json=json_decode(file_get_contents('queries/'.$params["json"].".json", true));//file_get_contents('queries/'.$params["json"].".json", true)
        $sql=$json->{"query"};
        foreach ($json->{"params"} as $key => $value) {
            $var=intval($key);
            $name=$value->{"name"};
            $type=$value->{"type"};
            if(array_key_exists($name, $params)){
                $parameters[$var] = array($params[$name],$type);
            }
        }
    }

    else if(array_key_exists('sql', $params)){
        $sql = $params["sql"];
    }

    else if(array_key_exists('file', $params)){
        $sql = file_get_contents('queries/'.$params["file"].".sql", true);
    }

    $forbidden=array("delete ", "drop ","update ","grant ");
    foreach ($forbidden as $check) {
        if(strpos(strtolower($sql), $check)!==false){
            $smarty->trigger_error($check."command not allowed");
            $error = "crmAPI: you can not ".$check."using crmSQL";
            $is_error = 1;
            break;
        }
    }

    if (array_key_exists('debug', $params)) { 
        $smarty->trigger_error("sql:". $params["sql"]); 
    }

    try{
        if($is_error==0){
            $errorScope = CRM_Core_TemporaryErrorScope::useException();
            $dao = CRM_Core_DAO::executeQuery($sql,$parameters);
            $values = array();
            while ($dao->fetch()) {
                $values[] = $dao->toArray();
            }
        }
    }
    catch(Exception $e){
        $is_error=1;
        $error = "crmAPI: ".$e->getMessage();
        $values="";
    }

    if(array_key_exists('set', $params)){
        if($values!=""){
            //echo "console.log('string')";
            $smarty->assign($params['set'], $values);
        }
    }

    return json_encode(array("is_error"=>$is_error, "error"=>$error, "values" => $values), JSON_NUMERIC_CHECK);
}
开发者ID:riyadennis,项目名称:my_civicrm,代码行数:74,代码来源:function.crmSQL.php


示例18: createCaseViews

 /**
  * Used during case component enablement and during ugprade
  */
 static function createCaseViews()
 {
     $errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
     $dao = new CRM_Core_DAO();
     $sql = self::createCaseViewsQuery('upcoming');
     $dao->query($sql);
     if (PEAR::getStaticProperty('DB_DataObject', 'lastError')) {
         return FALSE;
     }
     // Above error doesn't get caught?
     $doublecheck = $dao->singleValueQuery("SELECT count(id) FROM civicrm_view_case_activity_upcoming");
     if (is_null($doublecheck)) {
         return FALSE;
     }
     $sql = self::createCaseViewsQuery('recent');
     $dao->query($sql);
     if (PEAR::getStaticProperty('DB_DataObject', 'lastError')) {
         return FALSE;
     }
     // Above error doesn't get caught?
     $doublecheck = $dao->singleValueQuery("SELECT count(id) FROM civicrm_view_case_activity_recent");
     if (is_null($doublecheck)) {
         return FALSE;
     }
     return TRUE;
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:29,代码来源:Case.php


示例19: ajaxJson

 /**
  * This is a wrapper so you can call an api via json (it returns json too)
  * http://example.org/civicrm/api/json?entity=Contact&action=Get"&json={"contact_type":"Individual","email.get.email":{}} to take all the emails from individuals
  * works for POST & GET (POST recommended)
  */
 public static function ajaxJson()
 {
     $requestParams = CRM_Utils_Request::exportValues();
     require_once 'api/v3/utils.php';
     // Why is $config undefined -- $config = CRM_Core_Config::singleton();
     if (!$config->debug && (!array_key_exists('HTTP_X_REQUESTED_WITH', $_SERVER) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest")) {
         $error = civicrm_api3_create_error("SECURITY ALERT: Ajax requests can only be is 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP CRM_Core_Transaction类代码示例发布时间:2022-05-20
下一篇:
PHP CRM_Core_StateMachine类代码示例发布时间:2022-05-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap