Ejemplo n.º 1
0
 /**
  * This function is the main function that is called when the page loads, it decides the which action has to be taken for the page.
  *
  * return null
  * @access public
  */
 function run()
 {
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('action', $this->_action);
     $this->assign('context', $this->_context);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     CRM_Pledge_Page_Tab::setContext();
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $this->edit();
         // set page title
         CRM_Contact_Page_View::setTitle($this->_contactId);
     } else {
         $pledgeId = CRM_Utils_Request::retrieve('pledgeId', 'Positive', $this);
         $paymentDetails = CRM_Pledge_BAO_PledgePayment::getPledgePayments($pledgeId);
         $this->assign('rows', $paymentDetails);
         $this->assign('pledgeId', $pledgeId);
         $this->assign('contactId', $this->_contactId);
         // check if we can process credit card contribs
         $processors = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, "billing_mode IN ( 1, 3 )");
         if (count($processors) > 0) {
             $this->assign('newCredit', TRUE);
         } else {
             $this->assign('newCredit', FALSE);
         }
         // check is the user has view/edit signer permission
         $permission = 'view';
         if (CRM_Core_Permission::check('edit pledges')) {
             $permission = 'edit';
         }
         $this->assign('permission', $permission);
     }
     return parent::run();
 }
Ejemplo n.º 2
0
 /**
  * This function is the main function that is called when the page loads, it decides the which action has to be taken for the page.
  *
  * return null
  * @access public
  */
 function run()
 {
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('action', $this->_action);
     $this->assign('context', $this->_context);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     CRM_Pledge_Page_Tab::setContext();
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $this->edit();
         // set page title
         CRM_Contact_Page_View::setTitle($this->_contactId);
     } else {
         $pledgeId = CRM_Utils_Request::retrieve('pledgeId', 'Positive', $this);
         $paymentDetails = CRM_Pledge_BAO_PledgePayment::getPledgePayments($pledgeId);
         $this->assign('rows', $paymentDetails);
         $this->assign('pledgeId', $pledgeId);
         $this->assign('contactId', $this->_contactId);
         // check if we can process credit card contribs
         CRM_Core_Payment::allowBackofficeCreditCard($this);
         // check is the user has view/edit signer permission
         $permission = 'view';
         if (CRM_Core_Permission::check('edit pledges')) {
             $permission = 'edit';
         }
         $this->assign('permission', $permission);
     }
     return parent::run();
 }
Ejemplo n.º 3
0
 static function preProcessSingle(&$form, $cid)
 {
     $form->_contactIds = array($cid);
     // put contact display name in title for single contact mode
     require_once 'CRM/Contact/Page/View.php';
     CRM_Contact_Page_View::setTitle($cid);
 }
Ejemplo n.º 4
0
 function preProcess()
 {
     // Make sure case types have been configured for the component
     require_once 'CRM/Core/OptionGroup.php';
     $caseType = CRM_Core_OptionGroup::values('case_type');
     if (empty($caseType)) {
         $this->assign('notConfigured', 1);
         return;
     }
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'browse');
     if ($this->_contactId) {
         $this->assign('contactId', $this->_contactId);
         // check logged in url permission
         require_once 'CRM/Contact/Page/View.php';
         CRM_Contact_Page_View::checkUserPermission($this);
     } else {
         if ($this->_action & CRM_Core_Action::VIEW) {
             CRM_Core_Error::fatal('Contact Id is required for view action.');
         }
     }
     $activityTypes = CRM_Case_PseudoConstant::activityType();
     $this->assign('openCaseId', $activityTypes['Open Case']['id']);
     $this->assign('changeCaseTypeId', $activityTypes['Change Case Type']['id']);
     $this->assign('changeCaseStatusId', $activityTypes['Change Case Status']['id']);
     $this->assign('changeCaseStartDateId', $activityTypes['Change Case Start Date']['id']);
 }
Ejemplo n.º 5
0
 function preProcess()
 {
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $this->assign('contactId', $this->_contactId);
     $contact = new CRM_Contact_BAO_Contact();
     $contact->get('id', $this->_contactId);
     $this->_apiKey = $contact->api_key;
     $this->assign('apiKey', $this->_apiKey);
     // check logged in url permission
     CRM_Contact_Page_View::checkUserPermission($this);
     // set page title
     CRM_Contact_Page_View::setTitle($this->_contactId);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
     $this->assign('action', $this->_action);
     $isAdmin = CRM_Core_Permission::check('administer CiviCRM') && CRM_Core_Permission::check('edit all contacts');
     $session = CRM_Core_Session::singleton();
     $isMyself = $this->_contactId && $this->_contactId == $session->get('userID');
     $this->assign('isAdmin', $isAdmin);
     $this->assign('isMyself', $isMyself);
     $urlParam = 'reset=1&action=add&cid=' . $this->_contactId;
     if ($this->_apiKey) {
         $urlParam = 'reset=1&action=edit&cid=' . $this->_contactId;
     }
     $this->assign('addApiKeyUrl', CRM_Utils_System::url('civicrm/contact/apikey', $urlParam));
 }
Ejemplo n.º 6
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  */
 public function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $cgId = CRM_Utils_Request::retrieve('groupID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $customRecId = CRM_Utils_Request::retrieve('customRecId', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, 1, $_REQUEST);
     $cgcount = CRM_Utils_Request::retrieve('cgcount', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, 1, $_REQUEST);
     //custom groups Inline
     $entityType = CRM_Contact_BAO_Contact::getContactType($contactId);
     $entitySubType = CRM_Contact_BAO_Contact::getContactSubType($contactId);
     $groupTree =& CRM_Core_BAO_CustomGroup::getTree($entityType, $this, $contactId, $cgId, $entitySubType);
     $details = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $contactId);
     //get the fields of single custom group record
     if ($customRecId == 1) {
         $fields = reset($details[$cgId]);
     } else {
         $fields = CRM_Utils_Array::value($customRecId, $details[$cgId]);
     }
     $this->assign('cgcount', $cgcount);
     $this->assign('customRecId', $customRecId);
     $this->assign('contactId', $contactId);
     $this->assign('customGroupId', $cgId);
     $this->assign_by_ref('cd_edit', $fields);
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
Ejemplo n.º 7
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  */
 public function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name'));
     $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     $entityBlock = array('contact_id' => $contactId);
     $phones = CRM_Core_BAO_Phone::getValues($entityBlock);
     if (!empty($phones)) {
         foreach ($phones as $key => &$value) {
             $value['location_type'] = $locationTypes[$value['location_type_id']];
             $value['phone_type'] = $phoneTypes[$value['phone_type_id']];
         }
     }
     $contact = new CRM_Contact_BAO_Contact();
     $contact->id = $contactId;
     $contact->find(TRUE);
     $privacy = array();
     foreach (CRM_Contact_BAO_Contact::$_commPrefs as $name) {
         if (isset($contact->{$name})) {
             $privacy[$name] = $contact->{$name};
         }
     }
     $this->assign('contactId', $contactId);
     $this->assign('phone', $phones);
     $this->assign('privacy', $privacy);
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
Ejemplo n.º 8
0
 public function preProcess()
 {
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $this->assign('contactId', $this->_contactId);
     $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
     $this->assign('displayName', $displayName);
     // check logged in url permission
     CRM_Contact_Page_View::checkUserPermission($this);
 }
Ejemplo n.º 9
0
 function preProcess()
 {
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $this->assign('contactId', $this->_contactId);
     // check logged in url permission
     CRM_Contact_Page_View::checkUserPermission($this);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
     $this->assign('action', $this->_action);
 }
Ejemplo n.º 10
0
 /**
  * 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
  * @access public
  *
  */
 function run()
 {
     $this->preProcess();
     if ($this->_action & CRM_CORE_ACTION_UPDATE) {
         $this->edit();
     } else {
         $this->view();
     }
     return parent::run();
 }
Ejemplo n.º 11
0
 /**
  * This function is the main function that is called when the page loads,
  * it decides the which action has to be taken for the page.
  * 
  * return null
  * @access public
  */
 function run()
 {
     $this->preProcess();
     $pid = CRM_Utils_Request::retrieve('pid', $this);
     $log = CRM_Utils_Request::retrieve('log', $this);
     if ($this->_action & (CRM_CORE_ACTION_UPDATE | CRM_CORE_ACTION_ADD | CRM_CORE_ACTION_VIEW | CRM_CORE_ACTION_DELETE)) {
         $this->edit();
     }
     return parent::run();
 }
Ejemplo n.º 12
0
 function preProcess()
 {
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, true);
     $this->assign('contactId', $this->_contactId);
     // check logged in url permission
     require_once 'CRM/Contact/Page/View.php';
     CRM_Contact_Page_View::checkUserPermission($this);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'browse');
     $this->assign('action', $this->_action);
 }
Ejemplo n.º 13
0
 /**
  * Add a few specific things to view contact.
  *
  * @return void
  */
 public function preProcess()
 {
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $this->assign('contactId', $this->_contactId);
     // check logged in url permission
     CRM_Contact_Page_View::checkUserPermission($this);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
     $this->assign('action', $this->_action);
     $this->_groupId = CRM_Utils_Request::retrieve('gid', 'Positive', $this, TRUE);
     $this->assign('groupId', $this->_groupId);
     $this->_multiRecordDisplay = CRM_Utils_Request::retrieve('multiRecordDisplay', 'String', $this, FALSE);
     $this->_cgcount = CRM_Utils_Request::retrieve('cgcount', 'Positive', $this, FALSE);
     $this->_recId = CRM_Utils_Request::retrieve('recId', 'Positive', $this, FALSE);
 }
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  * @access public
  *
  */
 function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $params = array('id' => $contactId);
     $defaults = array();
     CRM_Contact_BAO_Contact::getValues($params, $defaults);
     $defaults['privacy_values'] = CRM_Core_SelectValues::privacy();
     $this->assign('contactId', $contactId);
     $this->assign($defaults);
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
Ejemplo n.º 15
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  */
 public function run()
 {
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $this->assign('contactId', $contactId);
     $this->assign('actionsMenuList', CRM_Contact_BAO_Contact::contextMenu($contactId));
     CRM_Contact_Page_View::addUrls($this, $contactId);
     // also create the form element for the activity links box
     $controller = new CRM_Core_Controller_Simple('CRM_Activity_Form_ActivityLinks', ts('Activity Links'), NULL);
     $controller->setEmbedded(TRUE);
     $controller->run();
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
Ejemplo n.º 16
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  */
 public function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $isDeleted = (bool) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactId, 'is_deleted');
     $this->assign('contactId', $contactId);
     $title = CRM_Contact_Page_View::setTitle($contactId, $isDeleted);
     $this->assign('title', $title);
     // Check if this is default domain contact CRM-10482
     $this->assign('domainContact', CRM_Contact_BAO_Contact::checkDomainContact($contactId));
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
Ejemplo n.º 17
0
 public function preProcess()
 {
     $context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'view');
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $this->assign('contactId', $this->_contactId);
     // check logged in url permission
     CRM_Contact_Page_View::checkUserPermission($this);
     $this->assign('action', $this->_action);
     if ($this->_permission == CRM_Core_Permission::EDIT && !CRM_Core_Permission::check('edit contributions')) {
         // demote to view since user does not have edit contrib rights
         $this->_permission = CRM_Core_Permission::VIEW;
         $this->assign('permission', 'view');
     }
 }
Ejemplo n.º 18
0
 function preProcess()
 {
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
     if ($cid) {
         CRM_Contact_Page_View::setTitle($cid);
     }
     CRM_Contact_Form_Task_SMSCommon::preProcessProvider($this);
     if (!$cid && $this->_context != 'standalone') {
         parent::preProcess();
     }
     $this->assign('single', $this->_single);
     if (CRM_Core_Permission::check('administer CiviCRM')) {
         $this->assign('isAdmin', 1);
     }
 }
Ejemplo n.º 19
0
 function preProcess()
 {
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'browse');
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     //validate case configuration.
     require_once 'CRM/Case/BAO/Case.php';
     $configured = CRM_Case_BAO_Case::isCaseConfigured($this->_contactId);
     $this->assign('notConfigured', !$configured['configured']);
     $this->assign('allowToAddNewCase', $configured['allowToAddNewCase']);
     $this->assign('redirectToCaseAdmin', $configured['redirectToCaseAdmin']);
     if (!$configured['configured'] || $configured['redirectToCaseAdmin']) {
         return;
     }
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     if ($this->_contactId) {
         $this->assign('contactId', $this->_contactId);
         // check logged in user permission
         require_once 'CRM/Contact/Page/View.php';
         if ($this->_id && $this->_action & CRM_Core_Action::VIEW) {
             //user might have special permissions to view this case, CRM-5666
             if (!CRM_Core_Permission::check('access all cases and activities')) {
                 $session = CRM_Core_Session::singleton();
                 $userCases = CRM_Case_BAO_Case::getCases(false, $session->get('userID'));
                 if (!array_key_exists($this->_id, $userCases)) {
                     CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
                 }
             }
         } else {
             CRM_Contact_Page_View::checkUserPermission($this);
         }
         // set page title
         CRM_Contact_Page_View::setTitle($this->_contactId);
     } else {
         if ($this->_action & CRM_Core_Action::VIEW) {
             CRM_Core_Error::fatal('Contact Id is required for view action.');
         }
     }
     $activityTypes = CRM_Case_PseudoConstant::activityType();
     $this->assign('openCaseId', $activityTypes['Open Case']['id']);
     $this->assign('changeCaseTypeId', $activityTypes['Change Case Type']['id']);
     $this->assign('changeCaseStatusId', $activityTypes['Change Case Status']['id']);
     $this->assign('changeCaseStartDateId', $activityTypes['Change Case Start Date']['id']);
 }
Ejemplo n.º 20
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  */
 public function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name'));
     $entityBlock = array('contact_id' => $contactId);
     $openids = CRM_Core_BAO_OpenID::getValues($entityBlock);
     if (!empty($openids)) {
         foreach ($openids as $key => &$value) {
             $value['location_type'] = $locationTypes[$value['location_type_id']];
         }
     }
     $this->assign('contactId', $contactId);
     $this->assign('openid', $openids);
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
Ejemplo n.º 21
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  */
 public function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
     $params = array('contact_id' => $contactId);
     $websites = CRM_Core_BAO_Website::getValues($params, CRM_Core_DAO::$_nullArray);
     if (!empty($websites)) {
         foreach ($websites as $key => &$value) {
             $value['website_type'] = $websiteTypes[$value['website_type_id']];
         }
     }
     $this->assign('contactId', $contactId);
     $this->assign('website', $websites);
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  * @access public
  *
  */
 function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $cgId = CRM_Utils_Request::retrieve('groupID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     //custom groups Inline
     $entityType = CRM_Contact_BAO_Contact::getContactType($contactId);
     $entitySubType = CRM_Contact_BAO_Contact::getContactSubType($contactId);
     $groupTree =& CRM_Core_BAO_CustomGroup::getTree($entityType, $this, $contactId, $cgId, $entitySubType);
     $details = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
     $fields = array_pop($details[$cgId]);
     $this->assign('contactId', $contactId);
     $this->assign('customGroupId', $cgId);
     $this->assign_by_ref('cd_edit', $fields);
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
Ejemplo n.º 23
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  */
 public function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $params = array('id' => $contactId);
     $defaults = array();
     CRM_Contact_BAO_Contact::getValues($params, $defaults);
     if (!empty($defaults['gender_id'])) {
         $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
         $defaults['gender_display'] = $gender[CRM_Utils_Array::value('gender_id', $defaults)];
     }
     $this->assign('contactId', $contactId);
     $this->assign($defaults);
     //for birthdate format with respect to birth format set
     $this->assign('birthDateViewFormat', CRM_Utils_Array::value('qfMapping', CRM_Utils_Date::checkBirthDateFormat()));
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
Ejemplo n.º 24
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  */
 public function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $params = array('id' => $contactId);
     $defaults = array();
     CRM_Contact_BAO_Contact::getValues($params, $defaults);
     //get the current employer name
     if (CRM_Utils_Array::value('contact_type', $defaults) == 'Individual') {
         if (!empty($defaults['employer_id']) && !empty($defaults['organization_name'])) {
             $defaults['current_employer'] = $defaults['organization_name'];
             $defaults['current_employer_id'] = $defaults['employer_id'];
         }
     }
     $this->assign('contactId', $contactId);
     $this->assign($defaults);
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
Ejemplo n.º 25
0
 function preProcess()
 {
     $context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     if ($context == 'standalone') {
         $this->_action = CRM_Core_Action::ADD;
     } else {
         $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
         $this->assign('contactId', $this->_contactId);
         // check logged in url permission
         CRM_Contact_Page_View::checkUserPermission($this);
         // set page title
         CRM_Contact_Page_View::setTitle($this->_contactId);
     }
     $this->assign('action', $this->_action);
     if ($this->_permission == CRM_Core_Permission::EDIT && !CRM_Core_Permission::check('edit booking')) {
         // demote to view since user does not have edit booking rights
         $this->_permission = CRM_Core_Permission::VIEW;
         $this->assign('permission', 'view');
     }
 }
Ejemplo n.º 26
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     // store case id if present
     $this->_caseId = CRM_Utils_Request::retrieve('caseid', 'Positive', $this, FALSE);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
     if ($cid) {
         CRM_Contact_Page_View::setTitle($cid);
     }
     CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);
     if (!$cid && $this->_context != 'standalone') {
         parent::preProcess();
     }
     //early prevent, CRM-6209
     if (count($this->_contactIds) > CRM_Contact_Form_Task_EmailCommon::MAX_EMAILS_KILL_SWITCH) {
         CRM_Core_Error::statusBounce(ts('Please do not use this task to send a lot of emails (greater than %1). We recommend using CiviMail instead.', array(1 => CRM_Contact_Form_Task_EmailCommon::MAX_EMAILS_KILL_SWITCH)));
     }
     $this->assign('single', $this->_single);
     if (CRM_Core_Permission::check('administer CiviCRM')) {
         $this->assign('isAdmin', 1);
     }
 }
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  */
 public function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $params = array('id' => $contactId);
     $defaults = array();
     CRM_Contact_BAO_Contact::getValues($params, $defaults);
     $defaults['privacy_values'] = CRM_Core_SelectValues::privacy();
     $communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id');
     if (!empty($communicationStyle)) {
         if (!empty($defaults['communication_style_id'])) {
             $defaults['communication_style_display'] = $communicationStyle[CRM_Utils_Array::value('communication_style_id', $defaults)];
         } else {
             // Make sure the field is displayed as long as it is active, even if it is unset for this contact.
             $defaults['communication_style_display'] = '';
         }
     }
     $this->assign('contactId', $contactId);
     $this->assign($defaults);
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
Ejemplo n.º 28
0
 /**
  * This function is the main function that is called when the page loads,
  * it decides the which action has to be taken for the page.
  *
  * return null
  * @access public
  */
 function run()
 {
     $this->preProcess();
     $this->browse();
     return parent::run();
 }
Ejemplo n.º 29
0
 /**
  * Wrapper for ajax activity selector.
  *
  * @param array $params
  *   Associated array for params record id.
  *
  * @return array
  *   Associated array of contact activities
  */
 public static function getContactActivitySelector(&$params)
 {
     // Format the params.
     $params['offset'] = ($params['page'] - 1) * $params['rp'];
     $params['rowCount'] = $params['rp'];
     $params['sort'] = CRM_Utils_Array::value('sortBy', $params);
     $params['caseId'] = NULL;
     $context = CRM_Utils_Array::value('context', $params);
     // Get contact activities.
     $activities = CRM_Activity_BAO_Activity::getActivities($params);
     // Add total.
     $params['total'] = CRM_Activity_BAO_Activity::getActivitiesCount($params);
     // Format params and add links.
     $contactActivities = array();
     if (!empty($activities)) {
         $activityStatus = CRM_Core_PseudoConstant::activityStatus();
         // Check logged in user for permission.
         $page = new CRM_Core_Page();
         CRM_Contact_Page_View::checkUserPermission($page, $params['contact_id']);
         $permissions = array($page->_permission);
         if (CRM_Core_Permission::check('delete activities')) {
             $permissions[] = CRM_Core_Permission::DELETE;
         }
         $mask = CRM_Core_Action::mask($permissions);
         foreach ($activities as $activityId => $values) {
             $activity = array();
             $activity['DT_RowId'] = $activityId;
             // Add class to this row if overdue.
             $activity['DT_RowClass'] = 'crm-entity';
             if (CRM_Utils_Date::overdue(CRM_Utils_Array::value('activity_date_time', $values)) && CRM_Utils_Array::value('status_id', $values) == 1) {
                 $activity['DT_RowClass'] .= ' status-overdue';
             } else {
                 $activity['DT_RowClass'] .= ' status-ontime';
             }
             $activity['DT_RowAttr'] = array();
             $activity['DT_RowAttr']['data-entity'] = 'activity';
             $activity['DT_RowAttr']['data-id'] = $activityId;
             $activity['activity_type'] = $values['activity_type'];
             $activity['subject'] = $values['subject'];
             $activity['source_contact_name'] = '';
             if ($params['contact_id'] == $values['source_contact_id']) {
                 $activity['source_contact_name'] = $values['source_contact_name'];
             } elseif ($values['source_contact_id']) {
                 $activity['source_contact_name'] = CRM_Utils_System::href($values['source_contact_name'], 'civicrm/contact/view', "reset=1&cid={$values['source_contact_id']}");
             } else {
                 $activity['source_contact_name'] = '<em>n/a</em>';
             }
             $activity['target_contact_name'] = '';
             if (isset($values['mailingId']) && !empty($values['mailingId'])) {
                 $activity['target_contact'] = CRM_Utils_System::href($values['recipients'], 'civicrm/mailing/report/event', "mid={$values['source_record_id']}&reset=1&event=queue&cid={$params['contact_id']}&context=activitySelector");
             } elseif (!empty($values['recipients'])) {
                 $activity['target_contact_name'] = $values['recipients'];
             } elseif (isset($values['target_contact_counter']) && $values['target_contact_counter']) {
                 $activity['target_contact_name'] = '';
                 foreach ($values['target_contact_name'] as $tcID => $tcName) {
                     $activity['target_contact_name'] .= CRM_Utils_System::href($tcName, 'civicrm/contact/view', "reset=1&cid={$tcID}");
                 }
                 if ($extraCount = $values['target_contact_counter'] - 1) {
                     $activity['target_contact_name'] .= ";<br />" . "(" . ts('%1 more', array(1 => $extraCount)) . ")";
                 }
             } elseif (!$values['target_contact_name']) {
                 $activity['target_contact_name'] = '<em>n/a</em>';
             }
             $activity['assignee_contact_name'] = '';
             if (empty($values['assignee_contact_name'])) {
                 $activity['assignee_contact_name'] = '<em>n/a</em>';
             } elseif (!empty($values['assignee_contact_name'])) {
                 $count = 0;
                 $activity['assignee_contact_name'] = '';
                 foreach ($values['assignee_contact_name'] as $acID => $acName) {
                     if ($acID && $count < 5) {
                         $activity['assignee_contact_name'] .= CRM_Utils_System::href($acName, 'civicrm/contact/view', "reset=1&cid={$acID}");
                         $count++;
                         if ($count) {
                             $activity['assignee_contact_name'] .= ";&nbsp;";
                         }
                         if ($count == 4) {
                             $activity['assignee_contact_name'] .= "(" . ts('more') . ")";
                             break;
                         }
                     }
                 }
             }
             $activity['activity_date_time'] = CRM_Utils_Date::customFormat($values['activity_date_time']);
             $activity['status_id'] = $activityStatus[$values['status_id']];
             // build links
             $activity['links'] = '';
             $accessMailingReport = FALSE;
             if (!empty($values['mailingId'])) {
                 $accessMailingReport = TRUE;
             }
             $actionLinks = CRM_Activity_Selector_Activity::actionLinks(CRM_Utils_Array::value('activity_type_id', $values), CRM_Utils_Array::value('source_record_id', $values), $accessMailingReport, CRM_Utils_Array::value('activity_id', $values));
             $actionMask = array_sum(array_keys($actionLinks)) & $mask;
             $activity['links'] = CRM_Core_Action::formLink($actionLinks, $actionMask, array('id' => $values['activity_id'], 'cid' => $params['contact_id'], 'cxt' => $context, 'caseid' => CRM_Utils_Array::value('case_id', $values)), ts('more'), FALSE, 'activity.tab.row', 'Activity', $values['activity_id']);
             if ($values['is_recurring_activity']) {
                 $activity['is_recurring_activity'] = CRM_Core_BAO_RecurringEntity::getPositionAndCount($values['activity_id'], 'civicrm_activity');
             }
             array_push($contactActivities, $activity);
         }
     }
     $activitiesDT = array();
     $activitiesDT['data'] = $contactActivities;
     $activitiesDT['recordsTotal'] = $params['total'];
     $activitiesDT['recordsFiltered'] = $params['total'];
     return $activitiesDT;
 }
Ejemplo n.º 30
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  * @access public
  *
  */
 function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $locBlockNo = CRM_Utils_Request::retrieve('locno', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $addressId = CRM_Utils_Request::retrieve('aid', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, NULL, $_REQUEST);
     $address = array();
     if ($addressId > 0) {
         $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name'));
         $entityBlock = array('id' => $addressId);
         $address = CRM_Core_BAO_Address::getValues($entityBlock, FALSE, 'id');
         if (!empty($address)) {
             foreach ($address as $key => &$value) {
                 $value['location_type'] = $locationTypes[$value['location_type_id']];
             }
         }
     }
     // we just need current address block
     $currentAddressBlock['address'][$locBlockNo] = array_pop($address);
     if (!empty($currentAddressBlock['address'][$locBlockNo])) {
         // get contact name of shared contact names
         $sharedAddresses = array();
         $shareAddressContactNames = CRM_Contact_BAO_Contact_Utils::getAddressShareContactNames($currentAddressBlock['address']);
         foreach ($currentAddressBlock['address'] as $key => $addressValue) {
             if (!empty($addressValue['master_id']) && !$shareAddressContactNames[$addressValue['master_id']]['is_deleted']) {
                 $sharedAddresses[$key]['shared_address_display'] = array('address' => $addressValue['display'], 'name' => $shareAddressContactNames[$addressValue['master_id']]['name']);
             }
         }
         // add custom data of type address
         $groupTree = CRM_Core_BAO_CustomGroup::getTree('Address', $this, $currentAddressBlock['address'][$locBlockNo]['id']);
         // we setting the prefix to dnc_ below so that we don't overwrite smarty's grouptree var.
         $currentAddressBlock['address'][$locBlockNo]['custom'] = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, "dnc_");
         $this->assign("dnc_viewCustomData", NULL);
         $this->assign('add', $currentAddressBlock['address'][$locBlockNo]);
         $this->assign('sharedAddresses', $sharedAddresses);
     }
     $contact = new CRM_Contact_BAO_Contact();
     $contact->id = $contactId;
     $contact->find(true);
     $privacy = array();
     foreach (CRM_Contact_BAO_Contact::$_commPrefs as $name) {
         if (isset($contact->{$name})) {
             $privacy[$name] = $contact->{$name};
         }
     }
     $this->assign('contactId', $contactId);
     $this->assign('locationIndex', $locBlockNo);
     $this->assign('addressId', $addressId);
     $this->assign('privacy', $privacy);
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }