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


PHP CRM_Core_DAO类代码示例

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


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

示例1: ukrainerayons_loadcounties

/**
 * Check and load counties
 */
function ukrainerayons_loadcounties()
{
    $counties = ukrainerayons_listcounties();
    static $dao = NULL;
    if (!$dao) {
        $dao = new CRM_Core_DAO();
    }
    // go state-by-state to check existing counties
    foreach ($counties as $id => $state) {
        $check = "SELECT name FROM civicrm_county WHERE state_province_id = {$id}";
        $results = CRM_Core_DAO::executeQuery($check);
        $existing = array();
        while ($results->fetch()) {
            $existing[] = $results->name;
        }
        // identify counties needing to be loaded
        $add = array_diff($state, $existing);
        $insert = array();
        foreach ($add as $county) {
            $countydao = $dao->escape($county);
            $insert[] = "('{$countydao}', {$id})";
        }
        // put it into queries of 50 counties each
        for ($i = 0; $i < count($insert); $i = $i + 50) {
            $inserts = array_slice($insert, $i, 50);
            $query = "INSERT INTO civicrm_county (name, state_province_id) VALUES ";
            $query .= implode(', ', $inserts);
            CRM_Core_DAO::executeQuery($query);
        }
    }
}
开发者ID:nditech,项目名称:ukrainerayons,代码行数:34,代码来源:ukrainerayons.php

示例2: setUp

 function setUp()
 {
     parent::setUp();
     $baoObj = new CRM_Core_DAO();
     $baoObj->createTestObject('CRM_Pledge_BAO_Pledge', array(), 1, 0);
     $baoObj->createTestObject('CRM_Core_BAO_Phone', array(), 1, 0);
     $this->hookClass = CRM_Utils_Hook::singleton();
     $config = CRM_Core_Config::singleton();
     $config->userPermissionClass->permissions = array();
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:10,代码来源:ACLPermissionTest.php

示例3: preProcess

 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     $values = $ids = array();
     $params = array('id' => $this->get('id'));
     CRM_Pledge_BAO_Pledge::getValues($params, $values, $ids);
     $values['frequencyUnit'] = ts('%1(s)', array(1 => $values['frequency_unit']));
     if (isset($values["honor_contact_id"]) && $values["honor_contact_id"]) {
         $sql = "SELECT display_name FROM civicrm_contact WHERE id = " . $values["honor_contact_id"];
         $dao = new CRM_Core_DAO();
         $dao->query($sql);
         if ($dao->fetch()) {
             $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$values['honor_contact_id']}");
             $values["honor_display"] = "<A href = {$url}>" . $dao->display_name . "</A>";
         }
         $honor = CRM_Core_PseudoConstant::get('CRM_Pledge_DAO_Pledge', 'honor_type_id');
         $values['honor_type'] = $honor[$values['honor_type_id']];
     }
     //handle custom data.
     $groupTree = CRM_Core_BAO_CustomGroup::getTree('Pledge', $this, $params['id']);
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
     if (!empty($values['contribution_page_id'])) {
         $values['contribution_page'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $values['contribution_page_id'], 'title');
     }
     $values['financial_type'] = CRM_Utils_Array::value($values['financial_type_id'], CRM_Contribute_PseudoConstant::financialType());
     if ($values['status_id']) {
         $values['pledge_status'] = CRM_Utils_Array::value($values['status_id'], CRM_Contribute_PseudoConstant::contributionStatus());
     }
     $url = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     $recentOther = array();
     if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::UPDATE)) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::DELETE)) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     $displayName = CRM_Contact_BAO_Contact::displayName($values['contact_id']);
     $this->assign('displayName', $displayName);
     $title = $displayName . ' - (' . ts('Pledged') . ' ' . CRM_Utils_Money::format($values['pledge_amount']) . ' - ' . $values['financial_type'] . ')';
     // add Pledge to Recent Items
     CRM_Utils_Recent::add($title, $url, $values['id'], 'Pledge', $values['contact_id'], NULL, $recentOther);
     // Check if this is default domain contact CRM-10482
     if (CRM_Contact_BAO_Contact::checkDomainContact($values['contact_id'])) {
         $displayName .= ' (' . ts('default organization') . ')';
     }
     // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
     CRM_Utils_System::setTitle(ts('View Pledge by') . ' ' . $displayName);
     //do check for campaigns
     if ($campaignId = CRM_Utils_Array::value('campaign_id', $values)) {
         $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
         $values['campaign'] = $campaigns[$campaignId];
     }
     $this->assign($values);
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:59,代码来源:PledgeView.php

示例4: setDefaultValues

 function setDefaultValues()
 {
     $defaults = parent::setDefaultValues();
     if (!CRM_Utils_Array::value('weight', $defaults)) {
         $query = "SELECT max( `weight` ) as weight FROM `civicrm_booking_resource_config_set`";
         $dao = new CRM_Core_DAO();
         $dao->query($query);
         $dao->fetch();
         $defaults['weight'] = $dao->weight + 1;
     }
     return $defaults;
 }
开发者ID:sushantpaste,项目名称:civibooking,代码行数:12,代码来源:ResourceConfigSet.php

示例5: civicrm_drupal_create_user

/**
 * Create a Drupal user and return Drupal ID
 *
 * @param       email   email address of new user
 *
 * @return      res     Drupal ID for new user or FALSE if error
 */
function civicrm_drupal_create_user($email, $rid = NULL)
{
    $email = trim($email);
    if (empty($email)) {
        return FALSE;
    }
    $user_tab = _civicrm_get_user_table_name();
    // If user already exists, return Drupal id
    $uid = db_result(db_query("SELECT uid FROM {$user_tab} WHERE mail = '%s'", $email));
    if ($uid) {
        return $uid;
    }
    // escape email to prevent sql injection
    $dao = new CRM_Core_DAO();
    $email = $dao->escape($email);
    // Default values for new user
    $params = array();
    //WARNING -- this is likely *wrong* since it will crash Drupal 6.
    //calling conventions for Drupal 7 are different, as well.
    //$params['uid']     = db_next_id('{users}_uid');
    $params['name'] = $email;
    $params['pass'] = md5(uniqid(rand(), TRUE));
    $params['mail'] = $email;
    $params['mode'] = 0;
    $params['access'] = 0;
    // don't allow user to login until verified
    $params['status'] = 0;
    $params['init'] = $email;
    $params['created'] = time();
    $db_fields = '(';
    $db_values = '(';
    foreach ($params as $key => $value) {
        $db_fields .= "{$key},";
        $db_values .= "'{$value}',";
    }
    $db_fields = rtrim($db_fields, ",");
    $db_values = rtrim($db_values, ",");
    $db_fields .= ')';
    $db_values .= ')';
    $q = "INSERT INTO {$user_tab} {$db_fields} VALUES {$db_values}";
    db_query($q);
    if ($rid) {
        // Delete any previous roles entry before adding the role id
        //NOTE: weirdly, D7 schema from alpha 3 allows the following:
        db_query('DELETE FROM {users_roles} WHERE uid = %d', $params['uid']);
        db_query('INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)', $params['uid'], $rid);
    }
    return $params['uid'];
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:56,代码来源:api.php

示例6: testToCsv

 /**
  * Test the to csv function.
  *
  * @param string $fileName
  *
  * @dataProvider getCsvFiles
  */
 public function testToCsv($fileName)
 {
     $dataSource = new CRM_Import_DataSource_Csv();
     $params = array('uploadFile' => array('name' => __DIR__ . '/' . $fileName), 'skipColumnHeader' => TRUE);
     // Get the PEAR::DB object
     $dao = new CRM_Core_DAO();
     $db = $dao->getDatabaseConnection();
     $form = new CRM_Contact_Import_Form_DataSource();
     $form->controller = new CRM_Contact_Import_Controller();
     $dataSource->postProcess($params, $db, $form);
     $tableName = $form->get('importTableName');
     $this->assertEquals(4, CRM_Core_DAO::singleValueQuery("SELECT LENGTH(last_name) FROM {$tableName}"), $fileName . ' failed on last_name');
     $this->assertEquals(21, CRM_Core_DAO::singleValueQuery("SELECT LENGTH(email) FROM {$tableName}"), $fileName . ' failed on email');
     CRM_Core_DAO::executeQuery("DROP TABLE {$tableName}");
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:22,代码来源:CsvTest.php

示例7: setUp

 /**
  * Set up permissions for test.
  */
 public function setUp()
 {
     $this->useTransaction(TRUE);
     parent::setUp();
     $individualID = $this->individualCreate();
     $daoObj = new CRM_Core_DAO();
     $this->callAPISuccess('Attachment', 'create', array('entity_table' => 'civicrm_contact', 'entity_id' => $individualID, 'mime_type' => 'k', 'name' => 'p', 'content' => 'l'));
     $daoObj->createTestObject('CRM_Activity_BAO_Activity', array(), 1, 0);
     $daoObj->createTestObject('CRM_Case_BAO_Case', array(), 1, 0);
     $entities = $this->getTagOptions();
     foreach ($entities as $key => $entity) {
         $this->callAPISuccess('Tag', 'create', array('used_for' => $key, 'name' => $entity, 'description' => $entity));
     }
     CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM');
 }
开发者ID:sdekok,项目名称:civicrm-core,代码行数:18,代码来源:EntityTagACLTest.php

示例8: uninstall

 /**
 * Example: Run an external SQL script when the module is uninstalled
 *
   public function uninstall() {
 $this->executeSqlFile('sql/myuninstall.sql');
   }
 
   /**
 * Example: Run a simple query when a module is enabled
 *
   public function enable() {
  CRM_Core_DAO::executeQuery('UPDATE foo SET is_active = 1 WHERE bar = "whiz"');
   }
 
   /**
 * Example: Run a simple query when a module is disabled
 *
   public function disable() {
  CRM_Core_DAO::executeQuery('UPDATE foo SET is_active = 0 WHERE bar = "whiz"');
   }
 
   /**
 * Example: Add start and and date for job roles
 *
 * @return TRUE on success
 * @throws Exception
 *
 */
 public function upgrade_1001()
 {
     $this->ctx->log->info('Applying update for job role start and end dates');
     CRM_Core_DAO::executeQuery("ALTER TABLE  `civicrm_hrjobroles` ADD COLUMN  `start_date` timestamp DEFAULT 0 COMMENT 'Start Date of the job role'");
     CRM_Core_DAO::executeQuery("ALTER TABLE  `civicrm_hrjobroles` ADD COLUMN  `end_date` timestamp DEFAULT 0 COMMENT 'End Date of the job role'");
     return TRUE;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:35,代码来源:Upgrader.php

示例9: browse

 /**
  * Browse all event templates.
  */
 public function browse()
 {
     //get all event templates.
     $allEventTemplates = array();
     $eventTemplate = new CRM_Event_DAO_Event();
     $eventTypes = CRM_Event_PseudoConstant::eventType();
     $participantRoles = CRM_Event_PseudoConstant::participantRole();
     $participantListings = CRM_Event_PseudoConstant::participantListing();
     //find all event templates.
     $eventTemplate->is_template = TRUE;
     $eventTemplate->find();
     while ($eventTemplate->fetch()) {
         CRM_Core_DAO::storeValues($eventTemplate, $allEventTemplates[$eventTemplate->id]);
         //get listing types.
         if ($eventTemplate->participant_listing_id) {
             $allEventTemplates[$eventTemplate->id]['participant_listing'] = $participantListings[$eventTemplate->participant_listing_id];
         }
         //get participant role
         if ($eventTemplate->default_role_id) {
             $allEventTemplates[$eventTemplate->id]['participant_role'] = $participantRoles[$eventTemplate->default_role_id];
         }
         //get event type.
         if (isset($eventTypes[$eventTemplate->event_type_id])) {
             $allEventTemplates[$eventTemplate->id]['event_type'] = $eventTypes[$eventTemplate->event_type_id];
         }
         //form all action links
         $action = array_sum(array_keys($this->links()));
         //add action links.
         $allEventTemplates[$eventTemplate->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $eventTemplate->id), ts('more'), FALSE, 'eventTemplate.manage.action', 'Event', $eventTemplate->id);
     }
     $this->assign('rows', $allEventTemplates);
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1&action=browse'));
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:37,代码来源:EventTemplate.php

示例10: pledgeName

 /**
  * Function for building Pledge Name combo box
  */
 function pledgeName(&$config)
 {
     $getRecords = FALSE;
     if (isset($_GET['name']) && $_GET['name']) {
         $name = CRM_Utils_Type::escape($_GET['name'], 'String');
         $name = str_replace('*', '%', $name);
         $whereClause = "p.creator_pledge_desc LIKE '%{$name}%' ";
         $getRecords = TRUE;
     }
     if (isset($_GET['id']) && is_numeric($_GET['id'])) {
         $pledgeId = CRM_Utils_Type::escape($_GET['id'], 'Integer');
         $whereClause = "p.id = {$pledgeId} ";
         $getRecords = TRUE;
     }
     if ($getRecords) {
         $query = "\nSELECT p.creator_pledge_desc, p.id\nFROM civicrm_pb_pledge p\nWHERE {$whereClause}\n";
         $dao = CRM_Core_DAO::executeQuery($query);
         $elements = array();
         while ($dao->fetch()) {
             $elements[] = array('name' => $dao->creator_pledge_desc, 'value' => $dao->id);
         }
     }
     if (empty($elements)) {
         $name = $_GET['name'];
         if (!$name && isset($_GET['id'])) {
             $name = $_GET['id'];
         }
         $elements[] = array('name' => trim($name, '*'), 'value' => trim($name, '*'));
     }
     echo CRM_Utils_JSON::encode($elements, 'value');
     CRM_Utils_System::civiExit();
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:35,代码来源:AJAX.php

示例11: testCombinedIndex

 /**
  * Test creating an index.
  *
  * We want to be sure it creates an index and exits gracefully if the index
  * already exists.
  */
 public function testCombinedIndex()
 {
     $tables = array('civicrm_uf_join' => array('weight'));
     CRM_Core_BAO_SchemaHandler::createIndexes($tables);
     $tables = array('civicrm_uf_join' => array(array('weight', 'module')));
     CRM_Core_BAO_SchemaHandler::createIndexes($tables);
     $dao = CRM_Core_DAO::executeQuery("SHOW INDEX FROM civicrm_uf_join");
     $weightCount = 0;
     $combinedCount = 0;
     $indexes = array();
     while ($dao->fetch()) {
         if ($dao->Column_name == 'weight') {
             $weightCount++;
             $indexes[$dao->Key_name] = $dao->Key_name;
         }
         if ($dao->Column_name == 'module') {
             $combinedCount++;
             $this->assertArrayHasKey($dao->Key_name, $indexes);
         }
     }
     foreach (array_keys($indexes) as $index) {
         CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_uf_join DROP INDEX " . $index);
     }
     $this->assertEquals(2, $weightCount);
 }
开发者ID:sdekok,项目名称:civicrm-core,代码行数:31,代码来源:SchemaHandlerTest.php

示例12: preProcess

 /**
  * Heart of the viewing process. The runner gets all the meta data for
  * the contact and calls the appropriate type of page to view.
  *
  * @return void
  */
 public function preProcess()
 {
     //fetch the dedupe exception contacts.
     $dedupeExceptions = array();
     $exception = new CRM_Dedupe_DAO_Exception();
     $exception->find();
     $contactIds = array();
     while ($exception->fetch()) {
         $key = "{$exception->contact_id1}_{$exception->contact_id2}";
         $contactIds[$exception->contact_id1] = $exception->contact_id1;
         $contactIds[$exception->contact_id2] = $exception->contact_id2;
         $dedupeExceptions[$key] = array('main' => array('id' => $exception->contact_id1), 'other' => array('id' => $exception->contact_id2));
     }
     //get the dupe contacts display names.
     if (!empty($dedupeExceptions)) {
         $sql = 'select id, display_name from civicrm_contact where id IN ( ' . implode(', ', $contactIds) . ' )';
         $contact = CRM_Core_DAO::executeQuery($sql);
         $displayNames = array();
         while ($contact->fetch()) {
             $displayNames[$contact->id] = $contact->display_name;
         }
         foreach ($dedupeExceptions as $key => &$values) {
             $values['main']['name'] = CRM_Utils_Array::value($values['main']['id'], $displayNames);
             $values['other']['name'] = CRM_Utils_Array::value($values['other']['id'], $displayNames);
         }
     }
     $this->assign('dedupeExceptions', $dedupeExceptions);
 }
开发者ID:kidaa30,项目名称:yes,代码行数:34,代码来源:DedupeException.php

示例13: buildQuickForm

 /**
  * Build the form - it consists of
  *    - displaying the QILL (query in local language)
  *    - displaying elements for saving the search
  *
  * @access public
  * @return void
  */
 function buildQuickForm()
 {
     CRM_Utils_System::setTitle(ts('Smart Group'));
     require_once "CRM/Event/BAO/Query.php";
     // get the qill
     $query =& new CRM_Event_BAO_Query($this->get('formValues'));
     $qill = $query->qill();
     // need to save qill for the smarty template
     $this->assign('qill', $qill);
     // the name and description are actually stored with the group and not the saved search
     $this->add('text', 'title', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'), true);
     $this->addElement('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description'));
     // get the group id for the saved search
     $groupId = null;
     if (isset($this->_id)) {
         $params = array('saved_search_id' => $this->_id);
         require_once "CRM/Contact/BAO/Group.php";
         CRM_Contact_BAO_Group::retrieve($params, $values);
         $groupId = $values['id'];
         $this->addDefaultButtons(ts('Update Smart Group'));
     } else {
         $this->addDefaultButtons(ts('Save Smart Group'));
     }
     $this->addRule('title', ts('Name already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Group', $groupId, 'title'));
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:33,代码来源:SaveSearch.php

示例14: buildQuickForm

 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     $config = CRM_Core_Config::singleton();
     CRM_Utils_System::setTitle(ts('Settings - Localization'));
     $warningTitle = json_encode(ts("Warning"));
     $defaultLocaleOptions = CRM_Admin_Form_Setting_Localization::getDefaultLocaleOptions();
     $domain = new CRM_Core_DAO_Domain();
     $domain->find(TRUE);
     if ($domain->locales) {
         // add language limiter and language adder
         $this->addCheckBox('languageLimit', ts('Available Languages'), array_flip($defaultLocaleOptions), NULL, NULL, NULL, NULL, ' &nbsp; ');
         $this->addElement('select', 'addLanguage', ts('Add Language'), array_merge(array('' => ts('- select -')), array_diff(CRM_Core_I18n::languages(), $defaultLocaleOptions)));
         // add the ability to return to single language
         $warning = ts('This will make your CiviCRM installation a single-language one again. THIS WILL DELETE ALL DATA RELATED TO LANGUAGES OTHER THAN THE DEFAULT ONE SELECTED ABOVE (and only that language will be preserved).');
         $this->assign('warning', $warning);
         $warning = json_encode($warning);
         $this->addElement('checkbox', 'makeSinglelingual', ts('Return to Single Language'), NULL, array('onChange' => "if (this.checked) CRM.alert({$warning}, {$warningTitle})"));
     } else {
         $warning = ts('Enabling multiple languages changes the schema of your database, so make sure you know what you are doing when enabling this function; making a database backup is strongly recommended.');
         $this->assign('warning', $warning);
         $warning = json_encode($warning);
         $validTriggerPermission = CRM_Core_DAO::checkTriggerViewPermission(TRUE);
         if ($validTriggerPermission && !$config->logging) {
             $this->addElement('checkbox', 'makeMultilingual', ts('Enable Multiple Languages'), NULL, array('onChange' => "if (this.checked) CRM.alert({$warning}, {$warningTitle})"));
         }
     }
     $this->addElement('select', 'contact_default_language', ts('Default Language for users'), CRM_Admin_Form_Setting_Localization::getDefaultLanguageOptions());
     $includeCurrency =& $this->addElement('advmultiselect', 'currencyLimit', ts('Available Currencies') . ' ', self::getCurrencySymbols(), array('size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect'));
     $includeCurrency->setButtonAttributes('add', array('value' => ts('Add >>')));
     $includeCurrency->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $this->addFormRule(array('CRM_Admin_Form_Setting_Localization', 'formRule'));
     parent::buildQuickForm();
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:36,代码来源:Localization.php

示例15: preProcess

 /**
  * set up variables to build the form
  *
  * @param null
  *
  * @return void
  * @acess protected
  */
 function preProcess()
 {
     $this->_fid = $this->get('fid');
     $this->_title = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $this->_fid, 'label', 'id');
     $this->assign('title', $this->_title);
     CRM_Utils_System::setTitle(ts('Confirm Price Field Delete'));
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:15,代码来源:DeleteField.php


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