本文整理汇总了PHP中CRM_Core_DAO类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_DAO类的具体用法?PHP CRM_Core_DAO怎么用?PHP CRM_Core_DAO使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_DAO类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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, ' ');
$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
示例16: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
parent::buildQuickForm();
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
$this->applyFilter('__ALL__', 'trim');
$this->add('text', 'label_a_b', ts('Relationship Label-A to B'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_RelationshipType', 'label_a_b'), true);
$this->addRule('label_a_b', ts('Label already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_RelationshipType', $this->_id, 'label_a_b'));
$this->add('text', 'label_b_a', ts('Relationship Label-B to A'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_RelationshipType', 'label_b_a'));
$this->addRule('label_b_a', ts('Label already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_RelationshipType', $this->_id, 'label_b_a'));
$this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_RelationshipType', 'description'));
require_once 'CRM/Contact/BAO/ContactType.php';
$contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
// add select for contact type
$contactTypeA =& $this->add('select', 'contact_types_a', ts('Contact Type A') . ' ', array('' => ts('- select -')) + $contactTypes);
$contactTypeB =& $this->add('select', 'contact_types_b', ts('Contact Type B') . ' ', array('' => ts('- select -')) + $contactTypes);
$isActive =& $this->add('checkbox', 'is_active', ts('Enabled?'));
//only selected field should be allow for edit, CRM-4888
if ($this->_id && CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $this->_id, 'is_reserved')) {
foreach (array('contactTypeA', 'contactTypeB', 'isActive') as $field) {
${$field}->freeze();
}
}
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
$url = CRM_Utils_System::url('civicrm/admin/reltype&reset=1');
$location = "window.location='{$url}'";
$this->addElement('button', 'done', ts('Done'), array('onclick' => $location));
}
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:37,代码来源:RelationshipType.php
示例17: run
function run()
{
$sql = "SELECT * FROM civicrm_metrics_server ORDER BY site_name, timestamp";
$dao =& CRM_Core_DAO::executeQuery($sql);
$rows = array();
while ($dao->fetch()) {
$row = array();
$row['id'] = $dao->id;
$row['site_name'] = $dao->site_name;
$row['site_url'] = $dao->site_url;
$row['timestamp'] = $dao->timestamp;
$row['type'] = $dao->type;
$row['data'] = $dao->data;
$rows[] = $row;
}
if (array_key_exists("export", $_REQUEST) && $_REQUEST['export'] == 'csv') {
header('Content-type: text/csv');
header('Content-disposition: attachment;filename=metrics_data_' . date("Ymd_HiO") . '.csv');
$output = fopen('php://output', 'w');
$headers = array("Id", "Site Name", "Site URL", "Timestamp", "Metric Type", "Metric Data");
fputcsv($output, $headers);
foreach ($rows as $row) {
fputcsv($output, $row);
}
fclose($output);
die;
} else {
CRM_Utils_System::setTitle(ts('Metrics Report'));
$this->assign('data', $rows);
$this->assign('headers', array_keys($rows[0]));
parent::run();
}
}
开发者ID:TobiasLounsbury,项目名称:civicrm-metrics-server,代码行数:33,代码来源:Report.php
示例18: buildQuickForm
/**
* Function to build the form
*
* @return void
* @access public
*/
public function buildQuickForm()
{
parent::buildQuickForm();
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
CRM_Utils_System::setTitle(ts('Dropdown Options'));
$this->applyFilter('__ALL__', 'trim');
$this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'name'), TRUE);
$this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_DAO_OptionGroup', $this->_id));
$this->add('text', 'title', ts('Group Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'title'));
$this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'description'));
$element = $this->add('checkbox', 'is_active', ts('Enabled?'));
if ($this->_action & CRM_Core_Action::UPDATE) {
if (in_array($this->_values['name'], array('encounter_medium', 'case_type', 'case_status'))) {
static $caseCount = NULL;
if (!isset($caseCount)) {
$caseCount = CRM_Case_BAO_Case::caseCount(NULL, FALSE);
}
if ($caseCount > 0) {
$element->freeze();
}
}
if (!empty($this->_values['is_reserved'])) {
$this->freeze(array('name', 'is_active'));
}
}
$this->assign('id', $this->_id);
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:35,代码来源:OptionGroup.php
示例19: CRM_Mailing_Event_BAO_Bounce
/**
* Create a new bounce event, update the email address if necessary
*/
function &create(&$params)
{
$q =& CRM_Mailing_Event_BAO_Queue::verify($params['job_id'], $params['event_queue_id'], $params['hash']);
if (!$q) {
return null;
}
CRM_Core_DAO::transaction('BEGIN');
$bounce =& new CRM_Mailing_Event_BAO_Bounce();
$bounce->time_stamp = date('YmdHis');
$bounce->copyValues($params);
$bounce->save();
$bounceTable = CRM_Mailing_Event_BAO_Bounce::getTableName();
$bounceType = CRM_Mailing_DAO_BounceType::getTableName();
$emailTable = CRM_Core_BAO_Email::getTableName();
$queueTable = CRM_Mailing_Event_BAO_Queue::getTableName();
$bounce->reset();
// might want to put distinct inside the count
$query = "SELECT count({$bounceTable}.id) as bounces,\n {$bounceType}.hold_threshold as threshold\n FROM {$bounceTable}\n INNER JOIN {$bounceType}\n ON {$bounceTable}.bounce_type_id = {$bounceType}.id\n INNER JOIN {$queueTable}\n ON {$bounceTable}.event_queue_id = {$queueTable}.id\n INNER JOIN {$emailTable}\n ON {$queueTable}.email_id = {$emailTable}.id\n WHERE {$emailTable}.id = {$q->email_id}\n AND ({$emailTable}.reset_date IS NULL\n OR {$bounceTable}.time_stamp >= {$emailTable}.reset_date)\n GROUP BY {$bounceTable}.bounce_type_id\n ORDER BY threshold, bounces desc";
$bounce->query($query);
while ($bounce->fetch()) {
if ($bounce->bounces >= $bounce->threshold) {
$email =& new CRM_Core_BAO_Email();
$email->id = $q->email_id;
$email->on_hold = true;
$email->hold_date = date('YmdHis');
$email->save();
break;
}
}
CRM_Core_DAO::transaction('COMMIT');
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:34,代码来源:Bounce.php
示例20: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
parent::buildQuickForm();
if ($this->_action & CRM_Core_Action::DELETE) {
$formatName = CRM_Core_BAO_PdfFormat::getFieldValue('CRM_Core_BAO_PdfFormat', $this->_id, 'name');
$this->assign('formatName', $formatName);
return;
}
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_BAO_PdfFormat');
$this->add('text', 'name', ts('Name'), $attributes['name'], TRUE);
$this->add('text', 'description', ts('Description'), array('size' => CRM_Utils_Type::HUGE));
$this->add('checkbox', 'is_default', ts('Is this PDF Page Format the default?'));
$this->add('select', 'paper_size', ts('Paper Size'), array(0 => ts('- default -')) + CRM_Core_BAO_PaperSize::getList(TRUE), FALSE, array('onChange' => "selectPaper( this.value );"));
$this->add('static', 'paper_dimensions', NULL, ts('Width x Height'));
$this->add('select', 'orientation', ts('Orientation'), CRM_Core_BAO_PdfFormat::getPageOrientations(), FALSE, array('onChange' => "updatePaperDimensions();"));
$this->add('select', 'metric', ts('Unit of Measure'), CRM_Core_BAO_PdfFormat::getUnits(), FALSE, array('onChange' => "selectMetric( this.value );"));
$this->add('text', 'margin_left', ts('Left Margin'), array('size' => 8, 'maxlength' => 8), TRUE);
$this->add('text', 'margin_right', ts('Right Margin'), array('size' => 8, 'maxlength' => 8), TRUE);
$this->add('text', 'margin_top', ts('Top Margin'), array('size' => 8, 'maxlength' => 8), TRUE);
$this->add('text', 'margin_bottom', ts('Bottom Margin'), array('size' => 8, 'maxlength' => 8), TRUE);
$this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_BAO_PdfFormat', 'weight'), TRUE);
$this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_BAO_PdfFormat', $this->_id));
$this->addRule('margin_left', ts('Margin must be numeric'), 'numeric');
$this->addRule('margin_right', ts('Margin must be numeric'), 'numeric');
$this->addRule('margin_top', ts('Margin must be numeric'), 'numeric');
$this->addRule('margin_bottom', ts('Margin must be numeric'), 'numeric');
$this->addRule('weight', ts('Weight must be integer'), 'integer');
}
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:31,代码来源:PdfFormats.php
注:本文中的CRM_Core_DAO类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论