本文整理汇总了PHP中CRM_Contact_BAO_Contact_Permission类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Contact_Permission类的具体用法?PHP CRM_Contact_BAO_Contact_Permission怎么用?PHP CRM_Contact_BAO_Contact_Permission使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Contact_BAO_Contact_Permission类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* This function is called prior to building and submitting the form
*/
function preProcess()
{
// check contact_id
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
if (empty($this->_contactId)) {
CRM_Core_Error::statusBounce(ts('Could not get a contact id.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
// this also redirects to the default civicrm page
}
// check for permissions
$session = CRM_Core_Session::singleton();
if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
// this also redirects to the default civicrm page
}
// get session
$session = CRM_Core_Session::singleton();
// get values
$this->_configGroup = CRM_Lidmaatschapwijziging_ConfigGroup::singleton($this->_contactId);
$this->_values = $this->_configGroup->getContact();
// set display name
$this->_display_name = $this->_values['display_name'];
// set title
CRM_Utils_System::setTitle('LidmaatschapWijziging - Group - ' . $this->_values['display_name']);
// set contact id
$this->_values['contact_id'] = $this->_contactId;
}
示例2: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
$this->_participantId = CRM_Utils_Request::retrieve('participantId', 'Positive', $this);
$this->_cc = CRM_Utils_Request::retrieve('cc', 'String', $this);
//get the contact and event id and assing to session.
$values = array();
$csContactID = NULL;
if ($this->_participantId) {
$params = array('id' => $this->_participantId);
CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Participant', $params, $values, array('contact_id', 'event_id', 'status_id'));
}
$this->_participantStatusId = CRM_Utils_Array::value('status_id', $values);
$this->_eventId = CRM_Utils_Array::value('event_id', $values);
$csContactId = CRM_Utils_Array::value('contact_id', $values);
// make sure we have right permission to edit this user
$this->_csContactID = NULL;
if ($csContactId && $this->_eventId) {
$session = CRM_Core_Session::singleton();
if ($csContactId == $session->get('userID')) {
$this->_csContactID = $csContactId;
} else {
if (CRM_Contact_BAO_Contact_Permission::validateChecksumContact($csContactId, $this)) {
//since we have landing page so get this contact
//id in session if user really want to walk wizard.
$this->_csContactID = $csContactId;
}
}
}
if (!$this->_csContactID) {
$config = CRM_Core_Config::singleton();
CRM_Core_Error::statusBounce(ts('You do not have permission to access this event registration. Contact the site administrator if you need assistance.'), $config->userFrameworkBaseURL);
}
}
示例3: preProcess
/**
* This function is called prior to building and submitting the form
*/
function preProcess()
{
// check contact_id
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
if (empty($this->_contactId)) {
CRM_Core_Error::statusBounce(ts('Could not get a contact id.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
// this also redirects to the default civicrm page
}
// check for permissions
$session = CRM_Core_Session::singleton();
if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
// this also redirects to the default civicrm page
}
// get request
$this->_request = CRM_Utils_Request::retrieve('request', 'String', $this, FALSE, 'choose');
// get session
$session = CRM_Core_Session::singleton();
// get values
$this->_configRelationship = CRM_Lidmaatschapwijziging_ConfigRelationship::singleton($this->_contactId);
$this->_values = $this->_configRelationship->getContact();
// set contact id
$this->_values['contact_id'] = $this->_contactId;
// set display name
$this->_display_name = $this->_values['display_name'];
// set request
$this->_values['request'] = $this->_request;
// set title
CRM_Utils_System::setTitle('LidmaatschapWijziging - Relatie - ' . $this->_values['display_name']);
// request
if ('empty' == $this->_request) {
}
if ('choose' == $this->_request) {
// if there is no relatiosnhips then the options are empty, we
// show a message that there are no memebrships and a submit butten to
// go to the relationship, first we redirect them to request empty
$relationships = $this->_configRelationship->getRelationships();
if (empty($relationships)) {
// redirect user
$url = CRM_Utils_System::url('civicrm/lidmaatschapwijziging/relationship', 'reset=1&request=empty&cid=' . $this->_contactId);
CRM_Utils_System::redirect($url);
}
}
if ('update' == $this->_request) {
// get relationship id
$this->_relationshipId = CRM_Utils_Request::retrieve('relationship_id', 'Positive', $this);
$this->_values['relationship_id'] = $this->_relationshipId;
// get relationship
$this->_values = array_merge($this->_values, $this->_configRelationship->getRelationship($this->_relationshipId));
if (!empty($this->_values['contact_a']['display_name'])) {
$this->assign('sort_name_a', $this->_values['contact_a']['display_name']);
}
if (!empty($this->_values['contact_b']['display_name'])) {
$this->assign('sort_name_b', $this->_values['contact_b']['display_name']);
}
// note
$this->_values['note_id'] = $this->_values['notes']['id'];
$this->_values['note'] = $this->_values['notes']['note'];
}
}
示例4: run
/**
* List activities as dashlet
*
* @return none
*
* @access public
*/
function run()
{
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
// a user can always view their own activity
// if they have access CiviCRM permission
$permission = CRM_Core_Permission::VIEW;
// make the permission edit if the user has edit permission on the contact
require_once 'CRM/Contact/BAO/Contact/Permission.php';
if (CRM_Contact_BAO_Contact_Permission::allow($contactID, CRM_Core_Permission::EDIT)) {
$permission = CRM_Core_Permission::EDIT;
}
$admin = CRM_Core_Permission::check('view all activities') || CRM_Core_Permission::check('administer CiviCRM');
require_once 'CRM/Core/Selector/Controller.php';
$output = CRM_Core_Selector_Controller::SESSION;
require_once 'CRM/Activity/Selector/Activity.php';
$selector = new CRM_Activity_Selector_Activity($contactID, $permission, $admin, 'home');
$sortID = null;
if ($this->get(CRM_Utils_Sort::SORT_ID)) {
$sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION));
}
$controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, $output);
$controller->setEmbedded(true);
$controller->run();
$controller->moveFromSessionToTemplate();
return parent::run();
}
示例5: preProcess
/**
* build all the data structures needed to build the form
*
* @return void
* @access public
*/
function preProcess()
{
// reset action from the session
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'update');
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$rcid = CRM_Utils_Request::retrieve('rcid', 'Positive', $this);
$rcid = $rcid ? "&id={$rcid}" : '';
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url('civicrm/user', "reset=1{$rcid}"));
if ($this->_contactId) {
$contact = new CRM_Contact_DAO_Contact();
$contact->id = $this->_contactId;
if (!$contact->find(TRUE)) {
CRM_Core_Error::statusBounce(ts('contact does not exist: %1', array(1 => $this->_contactId)));
}
$this->_contactType = $contact->contact_type;
// check for permissions
if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'));
}
list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_contactId);
CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName);
} else {
CRM_Core_Error::statusBounce(ts('Could not get a contact_id and/or contact_type'));
}
}
示例6: __construct
function __construct()
{
parent::__construct();
$check = CRM_Core_Permission::check('access Contact Dashboard');
if (!$check) {
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
break;
}
$this->_contactId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$session =& CRM_Core_Session::singleton();
$userID = $session->get('userID');
if (!$this->_contactId) {
$this->_contactId = $userID;
} else {
if ($this->_contactId != $userID) {
require_once 'CRM/Contact/BAO/Contact/Permission.php';
if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::VIEW)) {
CRM_Core_Error::fatal(ts('You do not have permission to view this contact'));
}
if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
$this->_edit = false;
}
}
}
}
示例7: preProcess
/**
* build all the data structures needed to build the form
*
* @return void
* @access public
*/
function preProcess()
{
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
$this->_searchKey = CRM_Utils_Request::retrieve('key', 'String', $this);
// sort out whether it’s a delete-to-trash, delete-into-oblivion or restore (and let the template know)
$values = $this->controller->exportValues();
$this->_skipUndelete = (CRM_Core_Permission::check('access deleted contacts') and (CRM_Utils_Request::retrieve('skip_undelete', 'Boolean', $this) or CRM_Utils_Array::value('task', $values) == CRM_Contact_Task::DELETE_PERMANENTLY));
$this->_restore = (CRM_Utils_Request::retrieve('restore', 'Boolean', $this) or CRM_Utils_Array::value('task', $values) == CRM_Contact_Task::RESTORE);
if ($this->_restore && !CRM_Core_Permission::check('access deleted contacts')) {
CRM_Core_Error::fatal(ts('You do not have permission to access this contact.'));
} elseif (!CRM_Core_Permission::check('delete contacts')) {
CRM_Core_Error::fatal(ts('You do not have permission to delete this contact.'));
}
$this->assign('trash', CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_undelete', NULL) and !$this->_skipUndelete);
$this->assign('restore', $this->_restore);
if ($this->_restore) {
CRM_Utils_System::setTitle(ts('Restore Contact'));
}
if ($cid) {
if (!CRM_Contact_BAO_Contact_Permission::allow($cid, CRM_Core_Permission::EDIT)) {
CRM_Core_Error::fatal(ts('You do not have permission to delete this contact. Note: you can delete contacts if you can edit them.'));
} elseif (CRM_Contact_BAO_Contact::checkDomainContact($cid)) {
CRM_Core_Error::fatal(ts('This contact is a special one for the contact information associated with the CiviCRM installation for this domain. No one is allowed to delete it because the information is used for special system purposes.'));
}
$this->_contactIds = array($cid);
$this->_single = TRUE;
$this->assign('totalSelectedContacts', 1);
} else {
parent::preProcess();
}
$this->_sharedAddressMessage = $this->get('sharedAddressMessage');
if (!$this->_restore && !$this->_sharedAddressMessage) {
// we check for each contact for shared contact address
$sharedContactList = array();
$sharedAddressCount = 0;
foreach ($this->_contactIds as $contactId) {
// check if a contact that is being deleted has any shared addresses
$sharedAddressMessage = CRM_Core_BAO_Address::setSharedAddressDeleteStatus(NULL, $contactId, TRUE);
if ($sharedAddressMessage['count'] > 0) {
$sharedAddressCount += $sharedAddressMessage['count'];
$sharedContactList = array_merge($sharedContactList, $sharedAddressMessage['contactList']);
}
}
$this->_sharedAddressMessage = array('count' => $sharedAddressCount, 'contactList' => $sharedContactList);
if ($sharedAddressCount > 0) {
if (count($this->_contactIds) > 1) {
// more than one contact deleted
$message = ts('One of the selected contacts has an address record that is shared with 1 other contact.', array('plural' => 'One or more selected contacts have address records which are shared with %count other contacts.', 'count' => $sharedAddressCount));
} else {
// only one contact deleted
$message = ts('This contact has an address record which is shared with 1 other contact.', array('plural' => 'This contact has an address record which is shared with %count other contacts.', 'count' => $sharedAddressCount));
}
CRM_Core_Session::setStatus($message . ' ' . ts('Shared addresses will not be removed or altered but will no longer be shared.'), ts('Shared Addesses Owner'));
}
// set in form controller so that queries are not fired again
$this->set('sharedAddressMessage', $this->_sharedAddressMessage);
}
}
示例8: preProcess
/**
* build all the data structures needed to build the form
*
* @return void
* @access public
*/
function preProcess()
{
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
$this->_searchKey = CRM_Utils_Request::retrieve('key', 'String', $this);
// sort out whether it’s a delete-to-trash, delete-into-oblivion or restore (and let the template know)
$config = CRM_Core_Config::singleton();
$values = $this->controller->exportValues();
$this->_skipUndelete = (CRM_Core_Permission::check('access deleted contacts') and (CRM_Utils_Request::retrieve('skip_undelete', 'Boolean', $this) or CRM_Utils_Array::value('task', $values) == CRM_Contact_Task::DELETE_PERMANENTLY));
$this->_restore = (CRM_Utils_Request::retrieve('restore', 'Boolean', $this) or CRM_Utils_Array::value('task', $values) == CRM_Contact_Task::RESTORE);
if ($this->_restore && !CRM_Core_Permission::check('access deleted contacts')) {
CRM_Core_Error::fatal(ts('You do not have permission to access this contact.'));
} elseif (!CRM_Core_Permission::check('delete contacts')) {
CRM_Core_Error::fatal(ts('You do not have permission to delete this contact.'));
}
$this->assign('trash', $config->contactUndelete and !$this->_skipUndelete);
$this->assign('restore', $this->_restore);
if ($this->_restore) {
CRM_Utils_System::setTitle(ts('Restore Contact'));
}
if ($cid) {
if (!CRM_Contact_BAO_Contact_Permission::allow($cid, CRM_Core_Permission::EDIT)) {
CRM_Core_Error::fatal(ts('You do not have permission to delete this contact. Note: you can delete contacts if you can edit them.'));
}
$this->_contactIds = array($cid);
$this->_single = TRUE;
$this->assign('totalSelectedContacts', 1);
} else {
parent::preProcess();
}
$this->_sharedAddressMessage = $this->get('sharedAddressMessage');
if (!$this->_restore && !$this->_sharedAddressMessage) {
// we check for each contact for shared contact address
$sharedContactList = array();
$sharedAddressCount = 0;
foreach ($this->_contactIds as $contactId) {
// check if a contact that is being deleted has any shared addresses
$sharedAddressMessage = CRM_Core_BAO_Address::setSharedAddressDeleteStatus(NULL, $contactId, TRUE);
if ($sharedAddressMessage['count'] > 0) {
$sharedAddressCount += $sharedAddressMessage['count'];
$sharedContactList = array_merge($sharedContactList, $sharedAddressMessage['contactList']);
}
}
$this->_sharedAddressMessage = array('count' => $sharedAddressCount, 'contactList' => $sharedContactList);
if ($sharedAddressCount > 0) {
if (count($this->_contactIds) > 1) {
//more than one contact is deleted
CRM_Core_Session::setStatus(ts('Selected contact(s) has an address record which is shared with %1 other contact(s). Shared addresses will not be removed or altered but will no longer be shared.', array(1 => $sharedAddressCount)));
} else {
// only one contact is been deleted
CRM_Core_Session::setStatus(ts('This contact has an address record which is shared with %1 other contact(s). Shared addresses will not be removed or altered but will no longer be shared.', array(1 => $sharedAddressCount)));
}
}
// set in form controller so that queries are not fired again
$this->set('sharedAddressMessage', $this->_sharedAddressMessage);
}
}
示例9: preProcess
/**
* This function is called prior to building and submitting the form
*/
function preProcess()
{
// check contact_id
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
if (empty($this->_contactId)) {
CRM_Core_Error::statusBounce(ts('Could not get a contact id.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
// this also redirects to the default civicrm page
}
// check for permissions
$session = CRM_Core_Session::singleton();
if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
// this also redirects to the default civicrm page
}
// get session
$session = CRM_Core_Session::singleton();
// redirect user after postProcess
//$urlParams = 'reset=1&cid=' . $this->_contactId;
//$session->pushUserContext(CRM_Utils_System::url('civicrm/lidmaatschapwijziging/contact', $urlParams));
// get values
$this->_configContact = CRM_Lidmaatschapwijziging_ConfigContact::singleton($this->_contactId);
$this->_values = $this->_configContact->getContact();
// set display name
$this->_display_name = $this->_values['display_name'];
// set title
CRM_Utils_System::setTitle('LidmaatschapWijziging - Contact - ' . $this->_values['display_name']);
// set contact id
$this->_values['contact_id'] = $this->_contactId;
// change the default name like huppeldepup_35 to huppeldepup, this
// ensures the we can use the know names for custom fields in the template like
// huppeldepup and not the column_names like huppeldepup_35
$values = $this->_configContact->getVnvInfoCustomValues();
// set vnvn info id, is neede for update or insert in the postProccess
if (isset($values['id']) and !empty($values['id'])) {
$this->_vnvinfoId = $values['id'];
}
foreach ($this->_configContact->getVnvInfoCustomFields() as $key => $field) {
$this->_values[$field['name']] = $values[$field['column_name']];
}
$values = $this->_configContact->getWerkgeverCustomValues();
// set werkgever id, is neede for update or insert in the postProccess
if (isset($values['id']) and !empty($values['id'])) {
$this->_werkgeverId = $values['id'];
}
foreach ($this->_configContact->getWerkgeverCustomFields() as $key => $field) {
$this->_values[$field['name']] = $values[$field['column_name']];
}
$currentEmployer = CRM_Contact_BAO_Relationship::getCurrentEmployer(array($this->_contactId));
$defaults['current_employer_id'] = CRM_Utils_Array::value('org_id', $currentEmployer[$this->_contactId]);
// assign values needed for the template
$this->assign('contactId', $this->_contactId);
$this->assign('employerDataURL', '/civicrm/ajax/rest?className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=contact&org=1&employee_id=' . $this->_contactId);
$this->assign('currentEmployer', $this->_values['employer_id']);
}
示例10: getContactList
static function getContactList(&$config)
{
require_once 'CRM/Core/BAO/Preferences.php';
$name = CRM_Utils_Type::escape($_GET['s'], 'String');
$limit = '10';
$list = array_keys(CRM_Core_BAO_Preferences::valueOptions('contact_autocomplete_options'), '1');
$select = array('sort_name');
$where = '';
$from = array();
foreach ($list as $value) {
$suffix = substr($value, 0, 2) . substr($value, -1);
switch ($value) {
case 'street_address':
case 'city':
$selectText = $value;
$value = "address";
$suffix = 'sts';
case 'phone':
case 'email':
$select[] = $value == 'address' ? $selectText : $value;
$from[$value] = "LEFT JOIN civicrm_{$value} {$suffix} ON ( cc.id = {$suffix}.contact_id AND {$suffix}.is_primary = 1 ) ";
break;
case 'country':
case 'state_province':
$select[] = "{$suffix}.name";
if (!in_array('address', $from)) {
$from['address'] = 'LEFT JOIN civicrm_address sts ON ( cc.id = sts.contact_id AND sts.is_primary = 1) ';
}
$from[$value] = " LEFT JOIN civicrm_{$value} {$suffix} ON ( sts.{$value}_id = {$suffix}.id ) ";
break;
}
}
$select = implode(', ', $select);
$from = implode(' ', $from);
if (CRM_Utils_Array::value('limit', $_GET)) {
$limit = CRM_Utils_Type::escape($_GET['limit'], 'Positive');
}
// add acl clause here
require_once 'CRM/Contact/BAO/Contact/Permission.php';
list($aclFrom, $aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause('cc');
if ($aclWhere) {
$where .= " AND {$aclWhere} ";
}
$query = "\nSELECT DISTINCT(cc.id) as id, CONCAT_WS( ' :: ', {$select} ) as data\nFROM civicrm_contact cc {$from}\n{$aclFrom}\nWHERE sort_name LIKE '%{$name}%' {$where} \nORDER BY sort_name\nLIMIT 0, {$limit}\n";
// send query to hook to be modified if needed
require_once 'CRM/Utils/Hook.php';
CRM_Utils_Hook::contactListQuery($query, $name, CRM_Utils_Array::value('context', $_GET), CRM_Utils_Array::value('id', $_GET));
$dao = CRM_Core_DAO::executeQuery($query);
$contactList = null;
while ($dao->fetch()) {
echo $contactList = "{$dao->data}|{$dao->id}\n";
}
exit;
}
示例11: __construct
/**
* @throws Exception
*/
function __construct()
{
parent::__construct();
$this->_contactId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
if (!$this->_contactId) {
$this->_contactId = $userID;
} elseif ($this->_contactId != $userID) {
if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::VIEW)) {
CRM_Core_Error::fatal(ts('You do not have permission to view this contact'));
}
if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
$this->_edit = FALSE;
}
}
}
示例12: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
parent::preProcess();
// make sure we have right permission to edit this user
$csContactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false, $this->_userID);
require_once 'CRM/Contact/BAO/Contact.php';
if ($csContactID != $this->_userID) {
require_once 'CRM/Contact/BAO/Contact/Permission.php';
if (CRM_Contact_BAO_Contact_Permission::validateChecksumContact($csContactID, $this)) {
$session = CRM_Core_Session::singleton();
$session->set('userID', $csContactID);
$this->_userID = $csContactID;
}
}
if (CRM_Utils_Array::value('id', $this->_pcpInfo) && CRM_Utils_Array::value('intro_text', $this->_pcpInfo)) {
$this->assign('intro_text', $this->_pcpInfo['intro_text']);
} else {
if (CRM_Utils_Array::value('intro_text', $this->_values)) {
$this->assign('intro_text', $this->_values['intro_text']);
}
}
if (CRM_Utils_Array::value('footer_text', $this->_values)) {
$this->assign('footer_text', $this->_values['footer_text']);
}
//CRM-5001
if ($this->_values['is_for_organization']) {
$msg = ts('Mixed profile not allowed for on behalf of registration/sign up.');
require_once 'CRM/Core/BAO/UFGroup.php';
if ($preID = CRM_Utils_Array::value('custom_pre_id', $this->_values)) {
$preProfile = CRM_Core_BAO_UFGroup::profileGroups($preID);
foreach (array('Individual', 'Organization', 'Household') as $contactType) {
if (in_array($contactType, $preProfile) && (in_array('Membership', $preProfile) || in_array('Contribution', $preProfile))) {
CRM_Core_Error::fatal($msg);
}
}
}
if ($postID = CRM_Utils_Array::value('custom_post_id', $this->_values)) {
$postProfile = CRM_Core_BAO_UFGroup::profileGroups($postID);
foreach (array('Individual', 'Organization', 'Household') as $contactType) {
if (in_array($contactType, $postProfile) && (in_array('Membership', $postProfile) || in_array('Contribution', $postProfile))) {
CRM_Core_Error::fatal($msg);
}
}
}
}
}
示例13: preProcess
/**
* pre processing work done here.
*
* @param
* @return void
*
* @access public
*
*/
function preProcess()
{
$this->_mode = CRM_Profile_Form::MODE_CREATE;
//set the context for the profile
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
if ($this->_context) {
$this->assign('context', $this->_context);
}
if ($this->get('skipPermission')) {
$this->_skipPermission = true;
}
if ($this->get('edit')) {
//this is edit mode.
$this->_mode = CRM_Profile_Form::MODE_EDIT;
// make sure we have right permission to edit this user
$session =& CRM_Core_Session::singleton();
$userID = $session->get('userID');
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, false, $userID);
require_once 'CRM/Contact/BAO/Contact/Utils.php';
if ($id != $userID) {
// do not allow edit for anon users in joomla frontend, CRM-4668, unless u have checksum CRM-5228
require_once 'CRM/Contact/BAO/Contact/Permission.php';
$config =& CRM_Core_Config::singleton();
if ($config->userFrameworkFrontend) {
CRM_Contact_BAO_Contact_Permission::validateOnlyChecksum($id, $this);
} else {
CRM_Contact_BAO_Contact_Permission::validateChecksumContact($id, $this);
}
$this->_isPermissionedChecksum = true;
}
}
parent::preProcess();
// make sure the gid is set and valid
if (!$this->_gid) {
CRM_Core_Error::fatal(ts('The requested Profile (gid=%1) is disabled, OR there is no Profile with that ID, OR a valid \'gid=\' integer value is missing from the URL. Contact the site administrator if you need assistance.', array(1 => $this->_gid)));
}
// and also the profile is of type 'Profile'
$query = "\nSELECT module\n FROM civicrm_uf_join\n WHERE module = 'Profile'\n AND uf_group_id = %1\n";
$params = array(1 => array($this->_gid, 'Integer'));
$dao =& CRM_Core_DAO::executeQuery($query, $params);
if (!$dao->fetch()) {
CRM_Core_Error::fatal(ts('The requested Profile (gid=%1) is not configured to be used for \'Profile\' edit and view forms in its Settings. Contact the site administrator if you need assistance.', array(1 => $this->_gid)));
}
}
示例14: view
/**
* View details of a relationship.
*/
public function view()
{
$viewRelationship = CRM_Contact_BAO_Relationship::getRelationship($this->_contactId, NULL, NULL, NULL, $this->_id);
//To check whether selected contact is a contact_id_a in
//relationship type 'a_b' in relationship table, if yes then
//revert the permissionship text in template
$relationship = new CRM_Contact_DAO_Relationship();
$relationship->id = $viewRelationship[$this->_id]['id'];
if ($relationship->find(TRUE)) {
if ($viewRelationship[$this->_id]['rtype'] == 'a_b' && $this->_contactId == $relationship->contact_id_a) {
$this->assign("is_contact_id_a", TRUE);
}
}
$relType = $viewRelationship[$this->_id]['civicrm_relationship_type_id'];
$this->assign('viewRelationship', $viewRelationship);
$employerId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'employer_id');
$this->assign('isCurrentEmployer', FALSE);
$relTypes = CRM_Utils_Array::index(array('name_a_b'), CRM_Core_PseudoConstant::relationshipType('name'));
if ($viewRelationship[$this->_id]['employer_id'] == $this->_contactId) {
$this->assign('isCurrentEmployer', TRUE);
} elseif ($relType == $relTypes['Employee of']['id'] && $viewRelationship[$this->_id]['cid'] == $employerId) {
// make sure we are viewing employee of relationship
$this->assign('isCurrentEmployer', TRUE);
}
$viewNote = CRM_Core_BAO_Note::getNote($this->_id);
$this->assign('viewNote', $viewNote);
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Relationship', $this, $this->_id, 0, $relType);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $this->_id);
$rType = CRM_Utils_Array::value('rtype', $viewRelationship[$this->_id]);
// add viewed contribution to recent items list
$url = CRM_Utils_System::url('civicrm/contact/view/rel', "action=view&reset=1&id={$viewRelationship[$this->_id]['id']}&cid={$this->_contactId}&context=home");
$session = CRM_Core_Session::singleton();
$recentOther = array();
if ($session->get('userID') == $this->_contactId || CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
$recentOther = array('editUrl' => CRM_Utils_System::url('civicrm/contact/view/rel', "action=update&reset=1&id={$viewRelationship[$this->_id]['id']}&cid={$this->_contactId}&rtype={$rType}&context=home"), 'deleteUrl' => CRM_Utils_System::url('civicrm/contact/view/rel', "action=delete&reset=1&id={$viewRelationship[$this->_id]['id']}&cid={$this->_contactId}&rtype={$rType}&context=home"));
}
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
$this->assign('displayName', $displayName);
CRM_Utils_System::setTitle(ts('View Relationship for') . ' ' . $displayName);
$title = $displayName . ' (' . $viewRelationship[$this->_id]['relation'] . ' ' . CRM_Contact_BAO_Contact::displayName($viewRelationship[$this->_id]['cid']) . ')';
// add the recently viewed Relationship
CRM_Utils_Recent::add($title, $url, $viewRelationship[$this->_id]['id'], 'Relationship', $this->_contactId, NULL, $recentOther);
}
示例15: preProcess
/**
* build all the data structures needed to build the form
*
* @return void
* @access public
*/
function preProcess()
{
//check for delete
if (!CRM_Core_Permission::check('delete contacts')) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
}
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false);
if ($cid) {
require_once 'CRM/Contact/BAO/Contact/Permission.php';
if (!CRM_Contact_BAO_Contact_Permission::allow($cid, CRM_Core_Permission::EDIT)) {
CRM_Core_Error::fatal(ts('You do not have permission to delete this contact. Note: you can delete contacts if you can edit them.'));
}
$this->_contactIds = array($cid);
$this->_single = true;
$this->assign('totalSelectedContacts', 1);
} else {
parent::preProcess();
}
}