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


PHP CRM_Contact_BAO_Contact_Permission::allow方法代码示例

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


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

示例1: 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'));
     }
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:32,代码来源:RelatedContact.php

示例2: __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;
             }
         }
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:25,代码来源:UserDashBoard.php

示例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'];
     }
 }
开发者ID:jvos,项目名称:nl.vnv.lidmaatschapwijziging_old,代码行数:63,代码来源:LidmaatschapwijzigingRelationship.php

示例4: 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;
 }
开发者ID:jvos,项目名称:nl.vnv.lidmaatschapwijziging_old,代码行数:29,代码来源:LidmaatschapWijzigingGroup.php

示例5: 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();
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:34,代码来源:Activity.php

示例6: 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);
     }
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:64,代码来源:Delete.php

示例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)
     $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);
     }
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:62,代码来源:Delete.php

示例8: 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']);
 }
开发者ID:jvos,项目名称:nl.vnv.lidmaatschapwijziging_old,代码行数:57,代码来源:LidmaatschapWijzigingContact.php

示例9: __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;
         }
     }
 }
开发者ID:eruraindil,项目名称:uk.co.vedaconsulting.pcpteams,代码行数:20,代码来源:Dashboard.php

示例10: 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();
     }
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:25,代码来源:Delete.php

示例11: 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);
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:46,代码来源:Relationship.php

示例12: preProcess

 function preProcess()
 {
     $params = array();
     $defaults = array();
     $ids = array();
     $session =& CRM_Core_Session::singleton();
     $uid = $session->get('userID');
     if (!$uid) {
         require_once 'CRM/Utils/System.php';
         CRM_Utils_System::setUFMessage(ts('We could not find a user id. You must be logged in to access the CiviCRM Home Page and menus.'));
         CRM_Core_Error::statusBounce(ts('We could not find a user id. You must be logged in to access the CiviCRM Home Page and menus.'));
     }
     $this->assign('contactId', $uid);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'view');
     $this->assign('action', $this->_action);
     // a user can always view their own activity history
     // if they have access CiviCRM permission
     $this->_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($uid, CRM_Core_Permission::EDIT)) {
         $this->_permission = CRM_Core_Permission::EDIT;
     }
     $displayName = $this->get('displayName');
     list($displayName, $contactImage, $contactType) = CRM_Contact_BAO_Contact::getDisplayAndImage($uid, true);
     $this->set('displayName', $displayName);
     $this->set('contactImage', $contactImage);
     CRM_Utils_System::setTitle($contactImage . ' ' . $displayName, $displayName);
     CRM_Utils_Recent::add($displayName, CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $uid), $uid, $contactType, $uid, $displayName);
     // call hook to get html from other modules
     require_once 'CRM/Utils/Hook.php';
     $contentPlacement = CRM_Utils_Hook::DASHBOARD_BELOW;
     // ignored but needed to prevent warnings
     $html = CRM_Utils_Hook::dashboard($uid, $contentPlacement);
     if (is_array($html)) {
         $this->assign_by_ref('hookContent', $html);
         $this->assign('hookContentPlacement', $contentPlacement);
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:39,代码来源:DashBoard.php

示例13: 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->_configRegiOplBel = CRM_Lidmaatschapwijziging_ConfigRegistratieOpleidingBelangstelling::singleton($this->_contactId);
     $this->_values = $this->_configRegiOplBel->getContact();
     // set display name
     $this->_display_name = $this->_values['display_name'];
     // set title
     CRM_Utils_System::setTitle('LidmaatschapWijziging - Registratie Opleiding Belangstelling - ' . $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->_configRegiOplBel->getRegiOplBelCustomValues();
     // set vnvn info id, is neede for update or insert in the postProccess
     if (isset($values['id']) and !empty($values['id'])) {
         $this->_regiOplBelId = $values['id'];
     }
     $this->_values['regioplbel_id'] = $this->_regiOplBelId;
     foreach ($this->_configRegiOplBel->getRegiOplBelCustomFields() as $key => $field) {
         $this->_values[$field['name']] = $values[$field['column_name']];
     }
 }
开发者ID:jvos,项目名称:nl.vnv.lidmaatschapwijziging_old,代码行数:41,代码来源:LidmaatschapWijzigingRegistratieOpleidingBelangstelling.php

示例14: run

 /**
  * List activities as dashlet.
  *
  * @return void
  */
 public function run()
 {
     $session = CRM_Core_Session::singleton();
     $contactID = $session->get('userID');
     $this->assign('contactID', $contactID);
     $this->assign('contactId', $contactID);
     $context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'dashlet');
     $this->assign('context', $context);
     // 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
     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');
     $this->assign('admin', $admin);
     // also create the form element for the activity filter box
     $controller = new CRM_Core_Controller_Simple('CRM_Activity_Form_ActivityFilter', ts('Activity Filter'), NULL);
     $controller->setEmbedded(TRUE);
     $controller->run();
     return parent::run();
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:28,代码来源:Activity.php

示例15: formatContactIDSToLinks

    /**
     * Given an array of contact ids this function will return array with links to view contact page.
     *
     * @param array $contactIDs
     *   Associated contact id's.
     * @param bool $addViewLink
     * @param bool $addEditLink
     * @param int $originalId
     *   Associated with the contact which is edited.
     *
     *
     * @return array
     *   returns array with links to contact view
     */
    public static function formatContactIDSToLinks($contactIDs, $addViewLink = TRUE, $addEditLink = TRUE, $originalId = NULL)
    {
        $contactLinks = array();
        if (!is_array($contactIDs) || empty($contactIDs)) {
            return $contactLinks;
        }
        // does contact has sufficient permissions.
        $permissions = array('view' => 'view all contacts', 'edit' => 'edit all contacts', 'merge' => 'merge duplicate contacts');
        $permissionedContactIds = array();
        foreach ($permissions as $task => $permission) {
            // give permission.
            if (CRM_Core_Permission::check($permission)) {
                foreach ($contactIDs as $contactId) {
                    $permissionedContactIds[$contactId][$task] = TRUE;
                }
                continue;
            }
            // check permission on acl basis.
            if (in_array($task, array('view', 'edit'))) {
                $aclPermission = CRM_Core_Permission::VIEW;
                if ($task == 'edit') {
                    $aclPermission = CRM_Core_Permission::EDIT;
                }
                foreach ($contactIDs as $contactId) {
                    if (CRM_Contact_BAO_Contact_Permission::allow($contactId, $aclPermission)) {
                        $permissionedContactIds[$contactId][$task] = TRUE;
                    }
                }
            }
        }
        // retrieve display names for all contacts
        $query = '
   SELECT  c.id, c.display_name, c.contact_type, ce.email
     FROM  civicrm_contact c
LEFT JOIN  civicrm_email ce ON ( ce.contact_id=c.id AND ce.is_primary = 1 )
    WHERE  c.id IN  (' . implode(',', $contactIDs) . ' ) LIMIT 20';
        $dao = CRM_Core_DAO::executeQuery($query);
        $contactLinks['msg'] = NULL;
        $i = 0;
        while ($dao->fetch()) {
            $contactLinks['rows'][$i]['display_name'] = $dao->display_name;
            $contactLinks['rows'][$i]['primary_email'] = $dao->email;
            // get the permission for current contact id.
            $hasPermissions = CRM_Utils_Array::value($dao->id, $permissionedContactIds);
            if (!is_array($hasPermissions) || empty($hasPermissions)) {
                $i++;
                continue;
            }
            // do check for view.
            if (array_key_exists('view', $hasPermissions)) {
                $contactLinks['rows'][$i]['view'] = '<a class="action-item" href="' . CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $dao->id) . '" target="_blank">' . ts('View') . '</a>';
                if (!$contactLinks['msg']) {
                    $contactLinks['msg'] = 'view';
                }
            }
            if (array_key_exists('edit', $hasPermissions)) {
                $contactLinks['rows'][$i]['edit'] = '<a class="action-item" href="' . CRM_Utils_System::url('civicrm/contact/add', 'reset=1&action=update&cid=' . $dao->id) . '" target="_blank">' . ts('Edit') . '</a>';
                if (!$contactLinks['msg'] || $contactLinks['msg'] != 'merge') {
                    $contactLinks['msg'] = 'edit';
                }
            }
            if (!empty($originalId) && array_key_exists('merge', $hasPermissions)) {
                $rgBao = new CRM_Dedupe_BAO_RuleGroup();
                $rgBao->contact_type = $dao->contact_type;
                $rgBao->used = 'Supervised';
                if ($rgBao->find(TRUE)) {
                    $rgid = $rgBao->id;
                }
                if ($rgid && isset($dao->id)) {
                    //get an url to merge the contact
                    $contactLinks['rows'][$i]['merge'] = '<a class="action-item" href="' . CRM_Utils_System::url('civicrm/contact/merge', "reset=1&cid=" . $originalId . '&oid=' . $dao->id . '&action=update&rgid=' . $rgid) . '">' . ts('Merge') . '</a>';
                    $contactLinks['msg'] = 'merge';
                }
            }
            $i++;
        }
        return $contactLinks;
    }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:92,代码来源:Utils.php


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