本文整理汇总了PHP中CRM_Core_DAO_OptionValue::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_DAO_OptionValue::delete方法的具体用法?PHP CRM_Core_DAO_OptionValue::delete怎么用?PHP CRM_Core_DAO_OptionValue::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_DAO_OptionValue
的用法示例。
在下文中一共展示了CRM_Core_DAO_OptionValue::delete方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: del
/**
* Delete a PDF Page Format.
*
* @param int $id
* ID of the PDF Page Format to be deleted.
*
*/
public static function del($id)
{
if ($id) {
$dao = new CRM_Core_DAO_OptionValue();
$dao->id = $id;
if ($dao->find(TRUE)) {
if ($dao->option_group_id == self::_getGid()) {
$filter = array('option_group_id' => self::_getGid());
CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $id, $filter);
$dao->delete();
return;
}
}
}
CRM_Core_Error::fatal(ts('Invalid value passed to delete function.'));
}
示例2: del
/**
* Delete Option Value.
*
* @param int $optionValueId
*
* @return bool
*
*/
public static function del($optionValueId)
{
$optionValue = new CRM_Core_DAO_OptionValue();
$optionValue->id = $optionValueId;
if (self::updateRecords($optionValueId, CRM_Core_Action::DELETE)) {
CRM_Core_PseudoConstant::flush();
return $optionValue->delete();
}
return FALSE;
}
示例3: deleteEntry
public function deleteEntry($id, $key)
{
$e = self::$_extensions;
if ($e['per_id'][$id]['status'] === 'enabled') {
require_once 'CRM/Core/DAO/OptionValue.php';
$optionValue = new CRM_Core_DAO_OptionValue();
$optionValue->id = $id;
return $optionValue->delete();
}
return false;
}
示例4: updateCiviACLRole
static function updateCiviACLRole(&$params, $op)
{
$optionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'acl_role', 'id', 'name');
$dao = new CRM_Core_DAO_OptionValue();
$dao->option_group_id = $optionGroupID;
$dao->description = $params['source'];
if ($op == 'delete') {
$dao->delete();
return;
}
$dao->label = $params['title'];
$dao->is_active = 1;
$weightParams = array('option_group_id' => $optionGroupID);
$dao->weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $weightParams);
$dao->value = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $weightParams, 'value');
$query = "\nSELECT v.id\n FROM civicrm_option_value v\n WHERE v.option_group_id = %1\n AND v.description = %2\n";
$queryParams = array(1 => array($optionGroupID, 'Integer'), 2 => array($params['source'], 'String'));
$dao->id = CRM_Core_DAO::singleValueQuery($query, $queryParams);
$dao->save();
$params['acl_role_id'] = $dao->value;
}
示例5: postProcess
/**
* Process the form
*
* @param null
*
* @return void
* @access public
*/
public function postProcess()
{
// store the submitted values in an array
$params = $this->controller->exportValues($this->_name);
$session = CRM_Core_Session::singleton();
$params['last_modified_id'] = $session->get('userID');
$params['last_modified_date'] = date('YmdHis');
require_once 'CRM/Core/BAO/OptionValue.php';
require_once 'CRM/Core/BAO/OptionGroup.php';
$updateResultSet = false;
if (CRM_Utils_Array::value('option_type', $params) == 2 && CRM_Utils_Array::value('option_group_id', $params)) {
if ($params['option_group_id'] == CRM_Utils_Array::value('result_id', $this->_values)) {
$updateResultSet = true;
}
}
if ($this->_surveyId) {
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Campaign_BAO_Survey::del($this->_surveyId);
CRM_Core_Session::setStatus(ts(' Survey has been deleted.'));
$session->replaceUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey'));
return;
}
$params['id'] = $this->_surveyId;
} else {
$params['created_id'] = $session->get('userID');
$params['created_date'] = date('YmdHis');
}
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, 0);
$params['is_default'] = CRM_Utils_Array::value('is_default', $params, 0);
$recontactInterval = array();
if ($updateResultSet) {
$optionValue = new CRM_Core_DAO_OptionValue();
$optionValue->option_group_id = $this->_values['result_id'];
$optionValue->delete();
$params['result_id'] = $this->_values['result_id'];
} else {
$opGroupName = 'civicrm_survey_' . rand(10, 1000) . '_' . date('YmdHis');
$optionGroup = new CRM_Core_DAO_OptionGroup();
$optionGroup->name = $opGroupName;
$optionGroup->label = $params['title'] . ' Response Set';
$optionGroup->is_active = 1;
$optionGroup->save();
$params['result_id'] = $optionGroup->id;
}
foreach ($params['option_value'] as $k => $v) {
if (strlen(trim($v))) {
$optionValue = new CRM_Core_DAO_OptionValue();
$optionValue->option_group_id = $params['result_id'];
$optionValue->label = $params['option_label'][$k];
$optionValue->name = CRM_Utils_String::titleToVar($params['option_label'][$k]);
$optionValue->value = trim($v);
$optionValue->weight = $params['option_weight'][$k];
$optionValue->is_active = 1;
if (CRM_Utils_Array::value('default_option', $params) && $params['default_option'] == $k) {
$optionValue->is_default = 1;
}
$optionValue->save();
if (CRM_Utils_Array::value($k, $params['option_interval'])) {
$recontactInterval[$optionValue->label] = $params['option_interval'][$k];
}
}
}
$params['recontact_interval'] = serialize($recontactInterval);
$surveyId = CRM_Campaign_BAO_Survey::create($params);
if (CRM_Utils_Array::value('result_id', $this->_values) && !$updateResultSet) {
$query = "SELECT COUNT(*) FROM civicrm_survey WHERE result_id = %1";
$countSurvey = CRM_Core_DAO::singleValueQuery($query, array(1 => array($this->_values['result_id'], 'Integer')));
// delete option group if no any survey is using it.
if (!($countSurvey >= 1)) {
CRM_Core_BAO_OptionGroup::del($this->_values['result_id']);
}
}
require_once 'CRM/Core/BAO/UFJoin.php';
// also update the ProfileModule tables
$ufJoinParams = array('is_active' => 1, 'module' => 'CiviCampaign', 'entity_table' => 'civicrm_survey', 'entity_id' => $surveyId->id);
// first delete all past entries
if ($this->_surveyId) {
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
}
if (CRM_Utils_Array::value('profile_id', $params)) {
$ufJoinParams['weight'] = 1;
$ufJoinParams['uf_group_id'] = $params['profile_id'];
CRM_Core_BAO_UFJoin::create($ufJoinParams);
}
if (!is_a($surveyId, 'CRM_Core_Error')) {
CRM_Core_Session::setStatus(ts('Survey %1 has been saved.', array(1 => $params['title'])));
}
if ($this->_context == 'dialog') {
$returnArray = array('returnSuccess' => true);
echo json_encode($returnArray);
CRM_Utils_System::civiExit();
}
//.........这里部分代码省略.........
示例6: del
/**
* Function to delete Option Group
*
* @param int $optionGroupId Id of the Option Group to be deleted.
*
* @return void
*
* @access public
* @static
*/
static function del($optionGroupId)
{
// need to delete all option value field before deleting group
$optionValue = new CRM_Core_DAO_OptionValue();
$optionValue->option_group_id = $optionGroupId;
$optionValue->delete();
$optionGroup = new CRM_Core_DAO_OptionGroup();
$optionGroup->id = $optionGroupId;
$optionGroup->delete();
}
示例7: postProcess
/**
* Process the form.
*/
public function postProcess()
{
// store the submitted values in an array
$status = '';
$params = $this->controller->exportValues($this->_name);
$params['id'] = $this->_surveyId;
$updateResultSet = FALSE;
$resultSetOptGrpId = NULL;
if (CRM_Utils_Array::value('option_type', $params) == 2 && !empty($params['option_group_id'])) {
$updateResultSet = TRUE;
$resultSetOptGrpId = $params['option_group_id'];
}
$recontactInterval = array();
if ($updateResultSet) {
$optionValue = new CRM_Core_DAO_OptionValue();
$optionValue->option_group_id = $resultSetOptGrpId;
$optionValue->delete();
$params['result_id'] = $resultSetOptGrpId;
} else {
$opGroupName = 'civicrm_survey_' . rand(10, 1000) . '_' . date('YmdHis');
$optionGroup = new CRM_Core_DAO_OptionGroup();
$optionGroup->name = $opGroupName;
$optionGroup->title = $this->_values['title'] . ' Result Set';
$optionGroup->is_active = 1;
$optionGroup->save();
$params['result_id'] = $optionGroup->id;
}
foreach ($params['option_value'] as $k => $v) {
if (strlen(trim($v))) {
$optionValue = new CRM_Core_DAO_OptionValue();
$optionValue->option_group_id = $params['result_id'];
$optionValue->label = $params['option_label'][$k];
$optionValue->name = CRM_Utils_String::titleToVar($params['option_label'][$k]);
$optionValue->value = trim($v);
$optionValue->weight = $params['option_weight'][$k];
$optionValue->is_active = 1;
if (!empty($params['default_option']) && $params['default_option'] == $k) {
$optionValue->is_default = 1;
}
$optionValue->save();
// using is_numeric since 0 is a valid value for option_interval
if (is_numeric($params['option_interval'][$k])) {
$recontactInterval[$optionValue->label] = $params['option_interval'][$k];
}
}
}
$params['recontact_interval'] = serialize($recontactInterval);
$survey = CRM_Campaign_BAO_Survey::create($params);
// create report if required.
if (!$this->_reportId && $survey->id && !empty($params['create_report'])) {
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
$activityStatus = array_flip($activityStatus);
$this->_params = array('name' => "survey_{$survey->id}", 'title' => $params['report_title'] ? $params['report_title'] : $this->_values['title'], 'status_id_op' => 'eq', 'status_id_value' => $activityStatus['Scheduled'], 'survey_id_value' => array($survey->id), 'description' => ts('Detailed report for canvassing, phone-banking, walk lists or other surveys.'));
//Default value of order by
$this->_params['order_bys'] = array(1 => array('column' => 'sort_name', 'order' => 'ASC'));
// for WalkList or default
$displayFields = array('id', 'sort_name', 'result', 'street_number', 'street_name', 'street_unit', 'survey_response');
if (CRM_Core_OptionGroup::getValue('activity_type', 'WalkList') == $this->_values['activity_type_id']) {
$this->_params['order_bys'] = array(1 => array('column' => 'street_name', 'order' => 'ASC'), 2 => array('column' => 'street_number_odd_even', 'order' => 'ASC'), 3 => array('column' => 'street_number', 'order' => 'ASC'), 4 => array('column' => 'sort_name', 'order' => 'ASC'));
} elseif (CRM_Core_OptionGroup::getValue('activity_type', 'PhoneBank') == $this->_values['activity_type_id']) {
array_push($displayFields, 'phone');
} elseif (CRM_Core_OptionGroup::getValue('activity_type', 'Survey') == $this->_values['activity_type_id'] || CRM_Core_OptionGroup::getValue('activity_type', 'Canvass') == $this->_values['activity_type_id']) {
array_push($displayFields, 'phone', 'city', 'state_province_id', 'postal_code', 'email');
}
foreach ($displayFields as $key) {
$this->_params['fields'][$key] = 1;
}
$this->_createNew = TRUE;
$this->_id = CRM_Report_Utils_Report::getInstanceIDForValue('survey/detail');
CRM_Report_Form_Instance::postProcess($this, FALSE);
$query = "SELECT MAX(id) FROM civicrm_report_instance WHERE name = %1";
$reportID = CRM_Core_DAO::singleValueQuery($query, array(1 => array("survey_{$survey->id}", 'String')));
if ($reportID) {
$url = CRM_Utils_System::url("civicrm/report/instance/{$reportID}", 'reset=1');
$status = ts("A Survey Detail Report <a href='%1'>%2</a> has been created.", array(1 => $url, 2 => $this->_params['title']));
}
}
if ($status) {
// reset status as we don't want status set by Instance::postProcess
$session = CRM_Core_Session::singleton();
$session->getStatus(TRUE);
// set new status
CRM_Core_Session::setStatus($status, ts('Saved'), 'success');
}
parent::endPostProcess();
}
示例8: del
/**
* Function to delete Option Group
*
* @param int $optionGroupId Id of the Option Group to be deleted.
*
* @return void
*
* @access public
* @static
*/
static function del($optionGroupId)
{
// need to delete all option value field before deleting group
require_once 'CRM/Core/DAO/OptionValue.php';
$optionValue = new CRM_Core_DAO_OptionValue();
$optionValue->option_group_id = $optionGroupId;
$optionValue->delete();
$optionGroup = new CRM_Core_DAO_OptionGroup();
$optionGroup->id = $optionGroupId;
$optionGroup->delete();
}
示例9: del
/**
* Function to delete Option Value
*
* @param int $optionGroupId Id of the Option Group to be deleted.
*
* @return boolean
*
* @access public
* @static
*/
static function del($optionValueId)
{
$optionValue = new CRM_Core_DAO_OptionValue();
$optionValue->id = $optionValueId;
if (self::updateRecords($optionValueId, CRM_Core_Action::DELETE)) {
return $optionValue->delete();
}
return FALSE;
}
示例10: removeLegacyRegisteredReport
/** Remove all the report that registerd on GiftAid 1.0beta and 2.0beta
**/
static function removeLegacyRegisteredReport()
{
$reportClass = new CRM_Core_DAO_OptionValue();
$reportClass->option_group_id = self::getReportTemplateGroupId();
$reportClass->name = 'GiftAid_Report_Form_Contribute_GiftAid';
if ($reportClass->find(TRUE)) {
$reportClass->delete();
}
}
示例11: del
/**
* Function to delete Option Value
*
* @param int $optionGroupId Id of the Option Group to be deleted.
*
* @return void
*
* @access public
* @static
*/
static function del($optionValueId)
{
$optionValue = new CRM_Core_DAO_OptionValue();
$optionValue->id = $optionValueId;
require_once 'CRM/Core/Action.php';
if (self::updateRecords($optionValueId, CRM_Core_Action::DELETE)) {
return $optionValue->delete();
}
return false;
}