本文整理汇总了PHP中CRM_Utils_Hook::enableDisable方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Hook::enableDisable方法的具体用法?PHP CRM_Utils_Hook::enableDisable怎么用?PHP CRM_Utils_Hook::enableDisable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Hook
的用法示例。
在下文中一共展示了CRM_Utils_Hook::enableDisable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enableDisable
/**
* Function to perform enable / disable actions on record.
*
*/
static function enableDisable()
{
$op = CRM_Utils_Type::escape($_POST['op'], 'String');
$recordID = CRM_Utils_Type::escape($_POST['recordID'], 'Positive');
$recordBAO = CRM_Utils_Type::escape($_POST['recordBAO'], 'String');
$isActive = NULL;
if ($op == 'disable-enable') {
$isActive = TRUE;
} elseif ($op == 'enable-disable') {
$isActive = FALSE;
}
$status = array('status' => 'record-updated-fail');
if (isset($isActive)) {
// first munge and clean the recordBAO and get rid of any non alpha numeric characters
$recordBAO = CRM_Utils_String::munge($recordBAO);
$recordClass = explode('_', $recordBAO);
// make sure recordClass is namespaced (we cant check CRM since extensions can also use this)
// but it should be at least 3 levels deep
if (count($recordClass) >= 3) {
require_once str_replace('_', DIRECTORY_SEPARATOR, $recordBAO) . ".php";
$method = 'setIsActive';
if (method_exists($recordBAO, $method)) {
$updated = call_user_func_array(array($recordBAO, $method), array($recordID, $isActive));
if ($updated) {
$status = array('status' => 'record-updated-success');
}
// call hook enableDisable
CRM_Utils_Hook::enableDisable($recordBAO, $recordID, $isActive);
}
}
echo json_encode($status);
CRM_Utils_System::civiExit();
}
}
示例2: setIsActive
/**
* update the is_active flag in the db
*
* @param int $id id of the database record
* @param boolean $is_active value we want to set the is_active field
*
* @return Object DAO object on success, null otherwise
* @static
*/
static function setIsActive($id, $is_active)
{
CRM_Core_DAO::setFieldValue('CRM_Contact_DAO_Relationship', $id, 'is_active', $is_active);
// call hook
CRM_Utils_Hook::enableDisable('CRM_Contact_BAO_Relationship', $id, $is_active);
return TRUE;
}
示例3: setIsActive
/**
* update the is_active flag in the db
*
* @param int $id id of the database record
* @param boolean $is_active value we want to set the is_active field
*
* @return Object DAO object on success, null otherwise
* @static
*/
static function setIsActive($id, $is_active)
{
// as both the create & add functions have a bunch of logic in them that
// doesn't seem to cope with a normal update we will call the api which
// has tested handling for this
// however, a longer term solution would be to simplify the add, create & api functions
// to be more standard. It is debatable @ that point whether it's better to call the BAO
// direct as the api is more tested.
$result = civicrm_api('relationship', 'create', array('id' => $id, 'is_active' => $is_active, 'version' => 3));
if (is_array($result) && !empty($result['is_error']) && $result['error_message'] != 'Relationship already exists') {
throw new CiviCRM_API3_Exception($result['error_message'], CRM_Utils_Array::value('error_code', $result, 'undefined'), $result);
}
// call (undocumented possibly deprecated) hook
CRM_Utils_Hook::enableDisable('CRM_Contact_BAO_Relationship', $id, $is_active);
return TRUE;
}
示例4: setIsActive
/**
* update the is_active flag in the db
*
* @param int $id id of the database record
* @param boolean $is_active value we want to set the is_active field
*
* @return Object DAO object on success, null otherwise
* @static
*/
static function setIsActive($id, $is_active)
{
// as both the create & add functions have a bunch of logic in them that
// doesn't seem to cope with a normal update we will call the api which
// has tested handling for this
// however, a longer term solution would be to simplify the add, create & api functions
// to be more standard. It is debatable @ that point whether it's better to call the BAO
// direct as the api is more tested.
civicrm_api3('relationship', 'create', array('id' => $id, 'is_active' => $is_active));
// call (undocumented possibly deprecated) hook
CRM_Utils_Hook::enableDisable('CRM_Contact_BAO_Relationship', $id, $is_active);
return TRUE;
}