Example #1
0
 public function preProcess()
 {
     $this->set('searchFormName', 'Custom');
     $this->set('context', 'custom');
     $csID = CRM_Utils_Request::retrieve('csid', 'Integer', $this);
     $ssID = CRM_Utils_Request::retrieve('ssID', 'Integer', $this);
     $gID = CRM_Utils_Request::retrieve('gid', 'Integer', $this);
     list($this->_customSearchID, $this->_customSearchClass, $formValues) = CRM_Contact_BAO_SearchCustom::details($csID, $ssID, $gID);
     if (!$this->_customSearchID) {
         CRM_Core_Error::fatal('Could not get details for custom search.');
     }
     // stash this as a hidden element so we can potentially go there if the session
     // is reset but this is available in the POST
     $this->addElement('hidden', 'csid', $csID);
     if (!empty($formValues)) {
         $this->_formValues = $formValues;
     }
     // set breadcrumb to return to Custom Search listings page
     $breadCrumb = array(array('title' => ts('Custom Searches'), 'url' => CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1')));
     CRM_Utils_System::appendBreadCrumb($breadCrumb);
     // use the custom selector
     self::$_selectorName = 'CRM_Contact_Selector_Custom';
     $this->set('customSearchID', $this->_customSearchID);
     $this->set('customSearchClass', $this->_customSearchClass);
     parent::preProcess();
     // instantiate the new class
     $this->_customClass = new $this->_customSearchClass($this->_formValues);
     // CRM-12747
     if (isset($this->_customClass->_permissionedComponent) && !self::isPermissioned($this->_customClass->_permissionedComponent)) {
         CRM_Utils_System::permissionDenied();
     }
 }
Example #2
0
 public function preProcess()
 {
     if (!CRM_Core_Permission::check('access CiviCRM') || !CRM_Core_Permission::check('administer CiviCRM')) {
         CRM_Utils_System::permissionDenied();
         exit;
     }
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false);
     $this->_object = CRM_Utils_Request::retrieve('object', 'String', $this, true);
     $isObjectID = true;
     if ($this->_action & CRM_Core_Action::ADD) {
         $isObjectID = false;
     }
     $this->_objectID = CRM_Utils_Request::retrieve('objectID', 'Integer', $this, $isObjectID);
     $this->_customFields = array();
     $this->assign('object', $this->_object);
     if ($this->_object == 'fee') {
         $this->_tableName = 'civicrm_value_extended_care_fee_tracker';
         CRM_Utils_System::setTitle(ts('Configure Fee Entry'));
         $this->_customFields = array('entity_id', 'fee_type', 'category', 'description', 'fee_date', 'total_blocks');
     } else {
         $this->_tableName = 'civicrm_value_extended_care_signout';
         CRM_Utils_System::setTitle(ts('Configure Activity block'));
         $this->_customFields = array('entity_id', 'pickup_person_name', 'signin_time', 'signout_time', 'class', 'is_morning', 'at_school_meeting');
     }
     $this->assign('fields', $this->_customFields);
     parent::preProcess();
 }
Example #3
0
 public function preProcess()
 {
     if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
         CRM_Utils_System::permissionDenied();
     }
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST');
     $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
     if ($this->_surveyId) {
         $this->_single = TRUE;
         $params = array('id' => $this->_surveyId);
         CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo);
         $this->_surveyTitle = $surveyInfo['title'];
         $this->assign('surveyTitle', $this->_surveyTitle);
         CRM_Utils_System::setTitle(ts('Configure Survey - %1', array(1 => $this->_surveyTitle)));
     }
     $this->assign('action', $this->_action);
     $this->assign('surveyId', $this->_surveyId);
     // when custom data is included in this page
     if (!empty($_POST['hidden_custom'])) {
         $this->set('type', 'Event');
         $this->set('entityId', $this->_surveyId);
         CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Survey', $this->_surveyId);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     // CRM-11480, CRM-11682
     // Preload libraries required by the "Questions" tab
     CRM_UF_Page_ProfileEditor::registerProfileScripts();
     CRM_UF_Page_ProfileEditor::registerSchemas(array('IndividualModel', 'ActivityModel'));
     CRM_Campaign_Form_Survey_TabHeader::build($this);
 }
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $this->_vid = CRM_Utils_Request::retrieve('vid', 'Positive', $this, TRUE);
     if (!CRM_Volunteer_Permission::checkProjectPerms(CRM_Core_Action::UPDATE, $this->_vid)) {
         CRM_Utils_System::permissionDenied();
     }
     $this->_batchInfo['item_count'] = 50;
     $params = array('project_id' => $this->_vid);
     $this->_volunteerData = CRM_Volunteer_BAO_Assignment::retrieve($params);
     $projects = CRM_Volunteer_BAO_Project::retrieve(array('id' => $this->_vid));
     $project = $projects[$this->_vid];
     $this->_entityID = $project->entity_id;
     $this->_entityTable = $project->entity_table;
     $this->_title = $project->title;
     $this->_title .= ' ( ' . CRM_Utils_Date::customFormat($project->start_date);
     $this->_start_date = $project->start_date;
     if ($project->end_date) {
         $this->_title .= ' - ' . CRM_Utils_Date::customFormat($project->end_date) . ' )';
     } else {
         $this->_title .= ' )';
     }
     /*
      * Because CiviCRM's asset management framework isn't mature yet (e.g., adding
      * assets to forms rendered in pop-ups using CRM_Core_Resources doesn't work),
      * we pass a URL fragment to the template and include them via HTML.
      */
     $this->assign('extResourceURL', CRM_Core_Resources::singleton()->getUrl('org.civicrm.volunteer'));
     $this->assign('vid', $this->_vid);
 }
 function preProcess()
 {
     if (!CRM_Core_Permission::check('access custom search form')) {
         CRM_Utils_System::permissionDenied();
         CRM_Utils_System::civiExit();
     }
 }
 /**
  * TODO: How many checks do we need to do? Should we check to make sure the
  * activity is the right type? That the cid and aid are associated? Seems like
  * if you are messing with URL params you are kind of asking for trouble...
  */
 function preProcess()
 {
     $this->_aid = CRM_Utils_Request::retrieve('aid', 'Positive', $this, FALSE);
     $this->_cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
     $this->_vid = CRM_Utils_Request::retrieve('vid', 'Positive', $this, FALSE);
     if (!CRM_Volunteer_Permission::checkProjectPerms(CRM_Core_Action::UPDATE, $this->_vid)) {
         CRM_Utils_System::permissionDenied();
     }
     if (!$this->_aid && !($this->_cid && $this->_vid)) {
         CRM_Core_Error::fatal("Form expects an activity ID or both a contact and a volunteer project ID.");
     }
     $check = array('Activity' => $this->_aid, 'Contact' => $this->_cid, 'VolunteerProject' => $this->_vid);
     $errors = array();
     foreach ($check as $entityType => $entityID) {
         if (!$this->entityExists($entityType, $entityID)) {
             $errors[] = "No {$entityType} with ID {$entityID} exists.";
         }
     }
     if (count($errors)) {
         CRM_Core_Error::fatal("Invalid parameter(s) passed to commendation form: " . implode(' ', $errors));
     }
     $contact_display_name = civicrm_api3('Contact', 'getvalue', array('id' => $this->_cid, 'return' => 'display_name'));
     CRM_Utils_System::setTitle(ts('Commend %1', array(1 => $contact_display_name, 'domain' => 'org.civicrm.volunteer')));
     parent::preProcess();
 }
Example #7
0
 public function preProcess()
 {
     if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
         CRM_Utils_System::permissionDenied();
     }
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
     if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) {
         $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
         if ($this->_action & CRM_Core_Action::UPDATE) {
             CRM_Utils_System::setTitle(ts('Edit Survey'));
         } else {
             CRM_Utils_System::setTitle(ts('Delete Survey'));
         }
     }
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', FALSE);
     if ($this->_cdType) {
         $this->assign('cdType', TRUE);
         return CRM_Custom_Form_CustomData::preProcess($this);
     }
     // when custom data is included in this page
     if (!empty($_POST['hidden_custom'])) {
         CRM_Custom_Form_CustomData::preProcess($this);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
     }
     $session = CRM_Core_Session::singleton();
     $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
     $session->pushUserContext($url);
     $this->_values = $this->get('values');
     if (!is_array($this->_values)) {
         $this->_values = array();
         if ($this->_surveyId) {
             $params = array('id' => $this->_surveyId);
             CRM_Campaign_BAO_Survey::retrieve($params, $this->_values);
         }
         $this->set('values', $this->_values);
     }
     $this->assign('action', $this->_action);
     $this->assign('surveyId', $this->_surveyId);
     // for custom data
     $this->assign('entityID', $this->_surveyId);
     if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) {
         $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
         if ($this->_action & CRM_Core_Action::UPDATE) {
             CRM_Utils_System::setTitle(ts('Edit Petition'));
         } else {
             CRM_Utils_System::setTitle(ts('Delete Petition'));
         }
     }
     $session = CRM_Core_Session::singleton();
     $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=petition');
     $session->pushUserContext($url);
     CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Petition Dashboard'), 'url' => $url)));
 }
Example #8
0
 function run()
 {
     if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
         CRM_Utils_System::permissionDenied();
     }
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 0);
     $this->assign('action', $action);
     $this->browse();
     return parent::run();
 }
Example #9
0
 function run()
 {
     if (!CRM_Core_Permission::check('administer CiviCampaign')) {
         CRM_Utils_System::permissionDenied();
     }
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 0);
     $this->assign('action', $action);
     $this->browse();
     parent::run();
 }
Example #10
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
         CRM_Utils_System::permissionDenied();
     }
     $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
     $params = array('id' => $this->_surveyId);
     CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo);
     $this->_surveyTitle = $surveyInfo['title'];
     $this->assign('surveyTitle', $this->_surveyTitle);
     CRM_Utils_System::setTitle(ts('Delete Survey') . ' - ' . $this->_surveyTitle);
 }
Example #11
0
 public function preProcess()
 {
     if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
         CRM_Utils_System::permissionDenied();
     }
     //check for custom data type.
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', FALSE);
     if ($this->_cdType) {
         $this->assign('cdType', TRUE);
         return CRM_Custom_Form_CustomData::preProcess($this);
     }
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
     $this->_campaignId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $title = NULL;
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $title = ts('Edit Campaign');
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         $title = ts('Delete Campaign');
     }
     if ($title) {
         CRM_Utils_System::setTitle($title);
     }
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=campaign'));
     $this->assign('action', $this->_action);
     //load the values;
     $this->_values = $this->get('values');
     if (!is_array($this->_values)) {
         $this->_values = array();
         // if we are editing
         if (isset($this->_campaignId) && $this->_campaignId) {
             $params = array('id' => $this->_campaignId);
             CRM_Campaign_BAO_Campaign::retrieve($params, $this->_values);
         }
         //lets use current object session.
         $this->set('values', $this->_values);
     }
     // when custom data is included in form.
     if (!empty($_POST['hidden_custom'])) {
         $this->set('type', 'Campaign');
         $this->set('subType', CRM_Utils_Array::value('campaign_type_id', $_POST));
         $this->set('entityId', $this->_campaignId);
         CRM_Custom_Form_CustomData::preProcess($this);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
 }
Example #12
0
 public function preProcess()
 {
     if (!CRM_Core_Permission::check('access CiviCRM')) {
         CRM_Utils_System::permissionDenied();
         exit;
     }
     $this->_indexID = CRM_Utils_Request::retrieve('id', 'Integer', $this, false);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false);
     if ($this->_action & (CRM_Core_Action::DISABLE | CRM_Core_Action::ENABLE)) {
         return;
     }
     // table fields, fieldname => type
     $this->_customFields = array('term' => 'String', 'session' => 'String', 'name' => 'String', 'day_of_week' => 'String', 'min_grade' => 'Integer', 'max_grade' => 'Integer', 'start_date' => 'Timestamp', 'end_date' => 'Timestamp', 'instructor' => 'String', 'fee_block' => 'Float', 'total_fee_block' => 'Float', 'max_participants' => 'Integer', 'location' => 'String', 'url' => 'String', 'additional_rows' => 'Integer');
     if ($this->_action & CRM_Core_Action::ADD) {
         $this->_customFields['is_active'] = 'Integer';
     }
     parent::preProcess();
 }
 /**
  * create a Volunteer Need
  * takes an associative array and creates a Need object
  *
  * This function is invoked from within the web form layer and also from the api layer
  *
  * @param array   $params      (reference ) an assoc array of name/value pairs
  *
  * @return CRM_Volunteer_BAO_Need object
  * @access public
  * @static
  */
 static function &create($params)
 {
     $projectId = CRM_Utils_Array::value('project_id', $params);
     $op = CRM_Core_Action::UPDATE;
     if (!empty($params['check_permissions']) && !CRM_Volunteer_Permission::checkProjectPerms($op, $projectId)) {
         CRM_Utils_System::permissionDenied();
         // FIXME: If we don't return here, the script keeps executing. This is not
         // what I expect from CRM_Utils_System::permissionDenied().
         return FALSE;
     }
     if (empty($params)) {
         return;
     }
     $need = new CRM_Volunteer_DAO_Need();
     $need->copyValues($params);
     $need->save();
     return $need;
 }
Example #14
0
 /**
  * Pre processing.
  *
  * @return void
  */
 public function preProcess()
 {
     // Ensure user has permission to be here
     if (!CRM_Core_Permission::check('administer dedupe rules')) {
         CRM_Utils_System::permissionDenied();
         CRM_Utils_System::civiExit();
     }
     $this->_options = CRM_Core_SelectValues::getDedupeRuleTypes();
     $this->_rgid = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0);
     $this->_contactType = CRM_Utils_Request::retrieve('contact_type', 'String', $this, FALSE, 0);
     if ($this->_rgid) {
         $rgDao = new CRM_Dedupe_DAO_RuleGroup();
         $rgDao->id = $this->_rgid;
         $rgDao->find(TRUE);
         $this->_defaults['threshold'] = $rgDao->threshold;
         $this->_contactType = $rgDao->contact_type;
         $this->_defaults['used'] = CRM_Utils_Array::key($rgDao->used, $this->_options);
         $this->_defaults['title'] = $rgDao->title;
         $this->_defaults['name'] = $rgDao->name;
         $this->_defaults['is_reserved'] = $rgDao->is_reserved;
         $this->assign('isReserved', $rgDao->is_reserved);
         $this->assign('ruleName', $rgDao->name);
         $ruleDao = new CRM_Dedupe_DAO_Rule();
         $ruleDao->dedupe_rule_group_id = $this->_rgid;
         $ruleDao->find();
         $count = 0;
         while ($ruleDao->fetch()) {
             $this->_defaults["where_{$count}"] = "{$ruleDao->rule_table}.{$ruleDao->rule_field}";
             $this->_defaults["length_{$count}"] = $ruleDao->rule_length;
             $this->_defaults["weight_{$count}"] = $ruleDao->rule_weight;
             $count++;
         }
     }
     $supported = CRM_Dedupe_BAO_RuleGroup::supportedFields($this->_contactType);
     if (is_array($supported)) {
         foreach ($supported as $table => $fields) {
             foreach ($fields as $field => $title) {
                 $this->_fields["{$table}.{$field}"] = $title;
             }
         }
     }
     asort($this->_fields);
 }
Example #15
0
 public function preProcess()
 {
     require_once 'CRM/Campaign/BAO/Campaign.php';
     if (!CRM_Campaign_BAO_Campaign::accessCampaignDashboard()) {
         CRM_Utils_System::permissionDenied();
     }
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     if ($this->_context) {
         $this->assign('context', $this->_context);
     }
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
     if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) {
         $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
         if ($this->_action & CRM_Core_Action::UPDATE) {
             CRM_Utils_System::setTitle(ts('Edit Survey'));
         } else {
             CRM_Utils_System::setTitle(ts('Delete Survey'));
         }
     }
     $session = CRM_Core_Session::singleton();
     $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
     $session->pushUserContext($url);
     if ($this->_name != 'Petition') {
         CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Survey Dashboard'), 'url' => $url)));
     }
     $this->_values = array();
     if ($this->_surveyId) {
         $this->assign('surveyId', $this->_surveyId);
         $values = $this->get('values');
         // get contact values.
         if (!empty($values)) {
             $this->_values = $values;
         } else {
             $params = array('id' => $this->_surveyId);
             CRM_Campaign_BAO_Survey::retrieve($params, $this->_values, true);
             $this->set('values', $this->_values);
         }
     }
     $this->assign('action', $this->_action);
 }
Example #16
0
 /**
  * Function to pre processing
  *
  * @return None
  * @access public
  */
 function preProcess()
 {
     // Ensure user has permission to be here
     require_once 'CRM/Core/Permission.php';
     if (!CRM_Core_Permission::check('administer dedupe rules')) {
         CRM_Utils_System::permissionDenied();
         CRM_Utils_System::civiExit();
     }
     $this->_rgid = CRM_Utils_Request::retrieve('id', 'Positive', $this, false, 0);
     $this->_contactType = CRM_Utils_Request::retrieve('contact_type', 'String', $this, false, 0);
     if ($this->_rgid) {
         $rgDao = new CRM_Dedupe_DAO_RuleGroup();
         $rgDao->id = $this->_rgid;
         $rgDao->find(true);
         $this->_defaults['threshold'] = $rgDao->threshold;
         $this->_contactType = $rgDao->contact_type;
         $this->_defaults['level'] = $rgDao->level;
         $this->_defaults['name'] = $rgDao->name;
         $this->_defaults['is_default'] = $rgDao->is_default;
         $ruleDao = new CRM_Dedupe_DAO_Rule();
         $ruleDao->dedupe_rule_group_id = $this->_rgid;
         $ruleDao->find();
         $count = 0;
         while ($ruleDao->fetch()) {
             $this->_defaults["where_{$count}"] = "{$ruleDao->rule_table}.{$ruleDao->rule_field}";
             $this->_defaults["length_{$count}"] = $ruleDao->rule_length;
             $this->_defaults["weight_{$count}"] = $ruleDao->rule_weight;
             $count++;
         }
     }
     $supported =& CRM_Dedupe_BAO_RuleGroup::supportedFields($this->_contactType);
     if (is_array($supported)) {
         foreach ($supported as $table => $fields) {
             foreach ($fields as $field => $title) {
                 $this->_fields["{$table}.{$field}"] = $title;
             }
         }
     }
     asort($this->_fields);
 }
 /**
  * create a Volunteer Need
  * takes an associative array and creates a Need object
  *
  * This function is invoked from within the web form layer and also from the api layer
  *
  * @param array   $params      (reference ) an assoc array of name/value pairs
  *
  * @return CRM_Volunteer_BAO_Need object
  * @access public
  * @static
  */
 static function &create($params)
 {
     $need = new CRM_Volunteer_BAO_Need();
     $need->copyValues($params);
     $projectId = $need->getProjectId();
     if ($projectId === FALSE) {
         CRM_Core_Error::fatal('Missing required Need ID or Project ID');
     }
     // creating a Need constitutes updating a Project
     $op = CRM_Core_Action::UPDATE;
     if (!empty($params['check_permissions']) && !CRM_Volunteer_Permission::checkProjectPerms($op, $projectId)) {
         CRM_Utils_System::permissionDenied();
         // FIXME: If we don't return here, the script keeps executing. This is not
         // what I expect from CRM_Utils_System::permissionDenied().
         return FALSE;
     }
     if (empty($params)) {
         return;
     }
     $need->save();
     return $need;
 }
Example #18
0
 public function preProcess()
 {
     if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
         CRM_Utils_System::permissionDenied();
     }
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST');
     $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
     if ($this->_surveyId) {
         $this->_single = TRUE;
         $params = array('id' => $this->_surveyId);
         CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo);
         $this->_surveyTitle = $surveyInfo['title'];
         $this->assign('surveyTitle', $this->_surveyTitle);
         CRM_Utils_System::setTitle(ts('Configure Survey - %1', array(1 => $this->_surveyTitle)));
     }
     $this->assign('action', $this->_action);
     $this->assign('surveyId', $this->_surveyId);
     // CRM-11480, CRM-11682
     // Preload libraries required by the "Questions" tab
     CRM_UF_Page_ProfileEditor::registerProfileScripts();
     CRM_UF_Page_ProfileEditor::registerSchemas(array('IndividualModel', 'ActivityModel'));
     CRM_Campaign_Form_Survey_TabHeader::build($this);
 }
Example #19
0
 public function preProcess()
 {
     require_once 'CRM/Campaign/BAO/Campaign.php';
     if (!CRM_Campaign_BAO_Campaign::accessCampaignDashboard()) {
         CRM_Utils_System::permissionDenied();
     }
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     if ($this->_context) {
         $this->assign('context', $this->_context);
     }
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
     if ($this->_action & (CRM_Core_Action::UPDATE | $this->_action & CRM_Core_Action::DELETE)) {
         $this->_campaignId = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
         if ($this->_action & CRM_Core_Action::UPDATE) {
             CRM_Utils_System::setTitle(ts('Edit Campaign'));
         } else {
             CRM_Utils_System::setTitle(ts('Delete Campaign'));
         }
     }
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=campaign'));
     $this->assign('action', $this->_action);
 }
 /**
  * This function contains the actions for profile arguments
  *
  * @param $args array this array contains the arguments of the url
  *
  * @static
  * @access public
  */
 static function profile($args)
 {
     if ($args[1] !== 'profile') {
         return;
     }
     $secondArg = CRM_Utils_Array::value(2, $args, '');
     if ($secondArg == 'map') {
         $controller = new CRM_Core_Controller_Simple('CRM_Contact_Form_Task_Map', ts('Map Contact'), NULL, FALSE, FALSE, TRUE);
         $gids = explode(',', CRM_Utils_Request::retrieve('gid', 'String', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET'));
         if (count($gids) > 1) {
             foreach ($gids as $pfId) {
                 $profileIds[] = CRM_Utils_Type::escape($pfId, 'Positive');
             }
             $controller->set('gid', $profileIds[0]);
             $profileGID = $profileIds[0];
         } else {
             $profileGID = CRM_Utils_Request::retrieve('gid', 'Integer', $controller, TRUE);
         }
         // make sure that this profile enables mapping
         // CRM-8609
         $isMap = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileGID, 'is_map');
         if (!$isMap) {
             CRM_Core_Error::statusBounce(ts('This profile does not have the map feature turned on.'));
         }
         $profileView = CRM_Utils_Request::retrieve('pv', 'Integer', $controller, FALSE);
         // set the userContext stack
         $session = CRM_Core_Session::singleton();
         if ($profileView) {
             $session->pushUserContext(CRM_Utils_System::url('civicrm/profile/view'));
         } else {
             $session->pushUserContext(CRM_Utils_System::url('civicrm/profile', 'force=1'));
         }
         $controller->set('profileGID', $profileGID);
         $controller->process();
         return $controller->run();
     }
     if ($secondArg == 'edit' || $secondArg == 'create') {
         // set the userContext stack
         $session = CRM_Core_Session::singleton();
         $session->pushUserContext(CRM_Utils_System::url('civicrm/profile', 'reset=1'));
         if ($secondArg == 'edit') {
             $controller = new CRM_Core_Controller_Simple('CRM_Profile_Form_Edit', ts('Create Profile'), CRM_Core_Action::UPDATE, FALSE, FALSE, TRUE);
             $controller->set('edit', 1);
             $controller->process();
             return $controller->run();
         } else {
             $wrapper = new CRM_Utils_Wrapper();
             return $wrapper->run('CRM_Profile_Form_Edit', ts('Create Profile'), array('mode' => CRM_Core_Action::ADD, 'ignoreKey' => TRUE));
         }
     }
     if ($secondArg == 'view' || empty($secondArg)) {
         $page = new CRM_Profile_Page_Listings();
         return $page->run();
     }
     CRM_Utils_System::permissionDenied();
     return;
 }
Example #21
0
 /**
  * Given a menu item, call the appropriate controller and return the response
  *
  * @param array $item
  *   See CRM_Core_Menu.
  * @return string, HTML
  */
 public static function runItem($item)
 {
     $config = CRM_Core_Config::singleton();
     if ($config->userFramework == 'Joomla' && $item) {
         $config->userFrameworkURLVar = 'task';
         // joomla 1.5RC1 seems to push this in the POST variable, which messes
         // QF and checkboxes
         unset($_POST['option']);
         CRM_Core_Joomla::sidebarLeft();
     }
     // set active Component
     $template = CRM_Core_Smarty::singleton();
     $template->assign('activeComponent', 'CiviCRM');
     $template->assign('formTpl', 'default');
     if ($item) {
         // CRM-7656 - make sure we send a clean sanitized path to create printer friendly url
         $printerFriendly = CRM_Utils_System::makeURL('snippet', FALSE, FALSE, CRM_Utils_Array::value('path', $item)) . '2';
         $template->assign('printerFriendly', $printerFriendly);
         if (!array_key_exists('page_callback', $item)) {
             CRM_Core_Error::debug('Bad item', $item);
             CRM_Core_Error::fatal(ts('Bad menu record in database'));
         }
         // check that we are permissioned to access this page
         if (!CRM_Core_Permission::checkMenuItem($item)) {
             CRM_Utils_System::permissionDenied();
             return NULL;
         }
         // check if ssl is set
         if (!empty($item['is_ssl'])) {
             CRM_Utils_System::redirectToSSL();
         }
         if (isset($item['title'])) {
             CRM_Utils_System::setTitle($item['title']);
         }
         if (isset($item['breadcrumb']) && !isset($item['is_public'])) {
             CRM_Utils_System::appendBreadCrumb($item['breadcrumb']);
         }
         $pageArgs = NULL;
         if (!empty($item['page_arguments'])) {
             $pageArgs = CRM_Core_Menu::getArrayForPathArgs($item['page_arguments']);
         }
         $template = CRM_Core_Smarty::singleton();
         if (!empty($item['is_public'])) {
             $template->assign('urlIsPublic', TRUE);
         } else {
             $template->assign('urlIsPublic', FALSE);
             self::statusCheck($template);
         }
         if (isset($item['return_url'])) {
             $session = CRM_Core_Session::singleton();
             $args = CRM_Utils_Array::value('return_url_args', $item, 'reset=1');
             $session->pushUserContext(CRM_Utils_System::url($item['return_url'], $args));
         }
         $result = NULL;
         // WISHLIST: Refactor this. Instead of pattern-matching on page_callback, lookup
         // page_callback via Civi\Core\Resolver and check the implemented interfaces. This
         // would require rethinking the default constructor.
         if (is_array($item['page_callback']) || strpos($item['page_callback'], ':')) {
             $result = call_user_func(Civi\Core\Resolver::singleton()->get($item['page_callback']));
         } elseif (strstr($item['page_callback'], '_Form')) {
             $wrapper = new CRM_Utils_Wrapper();
             $result = $wrapper->run(CRM_Utils_Array::value('page_callback', $item), CRM_Utils_Array::value('title', $item), isset($pageArgs) ? $pageArgs : NULL);
         } else {
             $newArgs = explode('/', $_GET[$config->userFrameworkURLVar]);
             $mode = 'null';
             if (isset($pageArgs['mode'])) {
                 $mode = $pageArgs['mode'];
                 unset($pageArgs['mode']);
             }
             $title = CRM_Utils_Array::value('title', $item);
             if (strstr($item['page_callback'], '_Page') || strstr($item['page_callback'], '\\Page\\')) {
                 $object = new $item['page_callback']($title, $mode);
                 $object->urlPath = explode('/', $_GET[$config->userFrameworkURLVar]);
             } elseif (strstr($item['page_callback'], '_Controller') || strstr($item['page_callback'], '\\Controller\\')) {
                 $addSequence = 'false';
                 if (isset($pageArgs['addSequence'])) {
                     $addSequence = $pageArgs['addSequence'];
                     $addSequence = $addSequence ? 'true' : 'false';
                     unset($pageArgs['addSequence']);
                 }
                 $object = new $item['page_callback']($title, TRUE, $mode, NULL, $addSequence);
             } else {
                 CRM_Core_Error::fatal();
             }
             $result = $object->run($newArgs, $pageArgs);
         }
         CRM_Core_Session::storeSessionObjects();
         return $result;
     }
     CRM_Core_Menu::store();
     CRM_Core_Session::setStatus(ts('Menu has been rebuilt'), ts('Complete'), 'success');
     return CRM_Utils_System::redirect();
 }
Example #22
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'add');
     $this->_dedupeButtonName = $this->getButtonName('refresh', 'dedupe');
     $this->_duplicateButtonName = $this->getButtonName('upload', 'duplicate');
     $session =& CRM_Core_Session::singleton();
     if ($this->_action == CRM_Core_Action::ADD) {
         // check for add contacts permissions
         require_once 'CRM/Core/Permission.php';
         if (!CRM_Core_Permission::check('add contacts')) {
             CRM_Utils_System::permissionDenied();
             return;
         }
         $this->_contactType = CRM_Utils_Request::retrieve('ct', 'String', $this, true, null, 'REQUEST');
         if (!in_array($this->_contactType, array('Individual', 'Household', 'Organization'))) {
             CRM_Core_Error::statusBounce(ts('Could not get a contact_id and/or contact_type'));
         }
         $this->_contactSubType = CRM_Utils_Request::retrieve('cst', 'String', $this);
         $this->_gid = CRM_Utils_Request::retrieve('gid', 'Integer', CRM_Core_DAO::$_nullObject, false, null, 'GET');
         $this->_tid = CRM_Utils_Request::retrieve('tid', 'Integer', CRM_Core_DAO::$_nullObject, false, null, 'GET');
         if ($this->_contactSubType) {
             CRM_Utils_System::setTitle(ts('New %1', array(1 => $this->_contactSubType)));
         } else {
             $title = ts('New Individual');
             if ($this->_contactType == 'Household') {
                 $title = ts('New Household');
             } else {
                 if ($this->_contactType == 'Organization') {
                     $title = ts('New Organization');
                 }
             }
             CRM_Utils_System::setTitle($title);
         }
         $session->pushUserContext(CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
         $this->_contactId = null;
     } else {
         //update mode
         if (!$this->_contactId) {
             $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, true);
         }
         if ($this->_contactId) {
             require_once 'CRM/Contact/BAO/Contact.php';
             $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;
             $this->_contactSubType = $contact->contact_sub_type;
             // check for permissions
             require_once 'CRM/Contact/BAO/Contact/Permission.php';
             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);
             $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId));
             $values = $this->get('values');
             // get contact values.
             if (!empty($values)) {
                 $this->_values = $values;
             } else {
                 $params = array('id' => $this->_contactId, 'contact_id' => $this->_contactId);
                 $contact = CRM_Contact_BAO_Contact::retrieve($params, $this->_values, true);
                 $this->set('values', $this->_values);
             }
         } else {
             CRM_Core_Error::statusBounce(ts('Could not get a contact_id and/or contact_type'));
         }
     }
     $this->_editOptions = $this->get('contactEditOptions');
     if (CRM_Utils_System::isNull($this->_editOptions)) {
         require_once 'CRM/Core/BAO/Preferences.php';
         $this->_editOptions = CRM_Core_BAO_Preferences::valueOptions('contact_edit_options', true, null, false, 'name', true, 'AND v.filter = 0');
         $this->set('contactEditOptions', $this->_editOptions);
     }
     // build demographics only for Individual contact type
     if ($this->_contactType != 'Individual' && array_key_exists('Demographics', $this->_editOptions)) {
         unset($this->_editOptions['Demographics']);
     }
     // in update mode don't show notes
     if ($this->_contactId && array_key_exists('Notes', $this->_editOptions)) {
         unset($this->_editOptions['Notes']);
     }
     $this->assign('editOptions', $this->_editOptions);
     $this->assign('contactType', $this->_contactType);
     $this->assign('contactSubType', $this->_contactSubType);
     // get the location blocks.
     $this->_blocks = $this->get('blocks');
     if (CRM_Utils_System::isNull($this->_blocks)) {
         $this->_blocks = CRM_Core_BAO_Preferences::valueOptions('contact_edit_options', true, null, false, 'name', true, 'AND v.filter = 1');
         $this->set('blocks', $this->_blocks);
     }
     $this->assign('blocks', $this->_blocks);
     if (array_key_exists('CustomData', $this->_editOptions)) {
         //only custom data has preprocess hence directly call it
         CRM_Custom_Form_CustomData::preProcess($this, null, $this->_contactSubType, 1, $this->_contactType, $this->_contactId);
     }
     // this is needed for custom data.
     $this->assign('entityID', $this->_contactId);
     // also keep the convention.
     $this->assign('contactId', $this->_contactId);
     // location blocks.
     CRM_Contact_Form_Location::preProcess($this);
 }
Example #23
0
 /**
  * Build all the data structures needed to build the form.
  */
 public function preProcess()
 {
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
     $this->_dedupeButtonName = $this->getButtonName('refresh', 'dedupe');
     $this->_duplicateButtonName = $this->getButtonName('upload', 'duplicate');
     CRM_Core_Resources::singleton()->addStyleFile('civicrm', 'css/contactSummary.css', 2, 'html-header');
     $session = CRM_Core_Session::singleton();
     if ($this->_action == CRM_Core_Action::ADD) {
         // check for add contacts permissions
         if (!CRM_Core_Permission::check('add contacts')) {
             CRM_Utils_System::permissionDenied();
             CRM_Utils_System::civiExit();
         }
         $this->_contactType = CRM_Utils_Request::retrieve('ct', 'String', $this, TRUE, NULL, 'REQUEST');
         if (!in_array($this->_contactType, array('Individual', 'Household', 'Organization'))) {
             CRM_Core_Error::statusBounce(ts('Could not get a contact id and/or contact type'));
         }
         $this->_isContactSubType = FALSE;
         if ($this->_contactSubType = CRM_Utils_Request::retrieve('cst', 'String', $this)) {
             $this->_isContactSubType = TRUE;
         }
         if ($this->_contactSubType && !CRM_Contact_BAO_ContactType::isExtendsContactType($this->_contactSubType, $this->_contactType, TRUE)) {
             CRM_Core_Error::statusBounce(ts("Could not get a valid contact subtype for contact type '%1'", array(1 => $this->_contactType)));
         }
         $this->_gid = CRM_Utils_Request::retrieve('gid', 'Integer', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET');
         $this->_tid = CRM_Utils_Request::retrieve('tid', 'Integer', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET');
         $typeLabel = CRM_Contact_BAO_ContactType::contactTypePairs(TRUE, $this->_contactSubType ? $this->_contactSubType : $this->_contactType);
         $typeLabel = implode(' / ', $typeLabel);
         CRM_Utils_System::setTitle(ts('New %1', array(1 => $typeLabel)));
         $session->pushUserContext(CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
         $this->_contactId = NULL;
     } else {
         //update mode
         if (!$this->_contactId) {
             $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
         }
         if ($this->_contactId) {
             $defaults = array();
             $params = array('id' => $this->_contactId);
             $returnProperities = array('id', 'contact_type', 'contact_sub_type', 'modified_date', 'is_deceased');
             CRM_Core_DAO::commonRetrieve('CRM_Contact_DAO_Contact', $params, $defaults, $returnProperities);
             if (empty($defaults['id'])) {
                 CRM_Core_Error::statusBounce(ts('A Contact with that ID does not exist: %1', array(1 => $this->_contactId)));
             }
             $this->_contactType = CRM_Utils_Array::value('contact_type', $defaults);
             $this->_contactSubType = CRM_Utils_Array::value('contact_sub_type', $defaults);
             // 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.'));
             }
             $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
             if ($defaults['is_deceased']) {
                 $displayName .= '  <span class="crm-contact-deceased">(deceased)</span>';
             }
             $displayName = ts('Edit %1', array(1 => $displayName));
             // Check if this is default domain contact CRM-10482
             if (CRM_Contact_BAO_Contact::checkDomainContact($this->_contactId)) {
                 $displayName .= ' (' . ts('default organization') . ')';
             }
             // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
             CRM_Utils_System::setTitle($displayName);
             $context = CRM_Utils_Request::retrieve('context', 'String', $this);
             $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
             $urlParams = 'reset=1&cid=' . $this->_contactId;
             if ($context) {
                 $urlParams .= "&context={$context}";
             }
             if (CRM_Utils_Rule::qfKey($qfKey)) {
                 $urlParams .= "&key={$qfKey}";
             }
             $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view', $urlParams));
             $values = $this->get('values');
             // get contact values.
             if (!empty($values)) {
                 $this->_values = $values;
             } else {
                 $params = array('id' => $this->_contactId, 'contact_id' => $this->_contactId, 'noRelationships' => TRUE, 'noNotes' => TRUE, 'noGroups' => TRUE);
                 $contact = CRM_Contact_BAO_Contact::retrieve($params, $this->_values, TRUE);
                 $this->set('values', $this->_values);
             }
         } else {
             CRM_Core_Error::statusBounce(ts('Could not get a contact_id and/or contact_type'));
         }
     }
     // parse street address, CRM-5450
     $this->_parseStreetAddress = $this->get('parseStreetAddress');
     if (!isset($this->_parseStreetAddress)) {
         $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options');
         $this->_parseStreetAddress = FALSE;
         if (!empty($addressOptions['street_address']) && !empty($addressOptions['street_address_parsing'])) {
             $this->_parseStreetAddress = TRUE;
         }
         $this->set('parseStreetAddress', $this->_parseStreetAddress);
     }
     $this->assign('parseStreetAddress', $this->_parseStreetAddress);
     $this->_editOptions = $this->get('contactEditOptions');
     if (CRM_Utils_System::isNull($this->_editOptions)) {
         $this->_editOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 0');
         $this->set('contactEditOptions', $this->_editOptions);
     }
     // build demographics only for Individual contact type
     if ($this->_contactType != 'Individual' && array_key_exists('Demographics', $this->_editOptions)) {
         unset($this->_editOptions['Demographics']);
     }
     // in update mode don't show notes
     if ($this->_contactId && array_key_exists('Notes', $this->_editOptions)) {
         unset($this->_editOptions['Notes']);
     }
     $this->assign('editOptions', $this->_editOptions);
     $this->assign('contactType', $this->_contactType);
     $this->assign('contactSubType', $this->_contactSubType);
     //build contact subtype form element, CRM-6864
     $buildContactSubType = TRUE;
     if ($this->_contactSubType && $this->_action & CRM_Core_Action::ADD) {
         $buildContactSubType = FALSE;
     }
     $this->assign('buildContactSubType', $buildContactSubType);
     // get the location blocks.
     $this->_blocks = $this->get('blocks');
     if (CRM_Utils_System::isNull($this->_blocks)) {
         $this->_blocks = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 1');
         $this->set('blocks', $this->_blocks);
     }
     $this->assign('blocks', $this->_blocks);
     // this is needed for custom data.
     $this->assign('entityID', $this->_contactId);
     // also keep the convention.
     $this->assign('contactId', $this->_contactId);
     // location blocks.
     CRM_Contact_Form_Location::preProcess($this);
     // retain the multiple count custom fields value
     if (!empty($_POST['hidden_custom'])) {
         $customGroupCount = CRM_Utils_Array::value('hidden_custom_group_count', $_POST);
         if ($contactSubType = CRM_Utils_Array::value('contact_sub_type', $_POST)) {
             $paramSubType = implode(',', $contactSubType);
         }
         $this->_getCachedTree = FALSE;
         unset($customGroupCount[0]);
         foreach ($customGroupCount as $groupID => $groupCount) {
             if ($groupCount > 1) {
                 $this->set('groupID', $groupID);
                 //loop the group
                 for ($i = 0; $i <= $groupCount; $i++) {
                     CRM_Custom_Form_CustomData::preProcess($this, NULL, $contactSubType, $i, $this->_contactType);
                     CRM_Contact_Form_Edit_CustomData::buildQuickForm($this);
                 }
             }
         }
         //reset all the ajax stuff, for normal processing
         if (isset($this->_groupTree)) {
             $this->_groupTree = NULL;
         }
         $this->set('groupID', NULL);
         $this->_getCachedTree = TRUE;
     }
     // execute preProcess dynamically by js else execute normal preProcess
     if (array_key_exists('CustomData', $this->_editOptions)) {
         //assign a parameter to pass for sub type multivalue
         //custom field to load
         if ($this->_contactSubType || isset($paramSubType)) {
             $paramSubType = isset($paramSubType) ? $paramSubType : str_replace(CRM_Core_DAO::VALUE_SEPARATOR, ',', trim($this->_contactSubType, CRM_Core_DAO::VALUE_SEPARATOR));
             $this->assign('paramSubType', $paramSubType);
         }
         if (CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject)) {
             CRM_Contact_Form_Edit_CustomData::preProcess($this);
         } else {
             $contactSubType = $this->_contactSubType;
             // need contact sub type to build related grouptree array during post process
             if (!empty($_POST['contact_sub_type'])) {
                 $contactSubType = $_POST['contact_sub_type'];
             }
             //only custom data has preprocess hence directly call it
             CRM_Custom_Form_CustomData::preProcess($this, NULL, $contactSubType, 1, $this->_contactType, $this->_contactId);
             $this->assign('customValueCount', $this->_customValueCount);
         }
     }
 }
Example #24
0
 /**
  * Delete relationships specific to case and relationship type.
  */
 public static function deleteCaseRoles()
 {
     $caseId = CRM_Utils_Type::escape($_POST['case_id'], 'Positive');
     $relType = CRM_Utils_Type::escape($_POST['rel_type'], 'Positive');
     if (!$relType || !CRM_Case_BAO_Case::accessCase($caseId)) {
         CRM_Utils_System::permissionDenied();
     }
     $sql = "DELETE FROM civicrm_relationship WHERE case_id={$caseId} AND relationship_type_id={$relType}";
     CRM_Core_DAO::executeQuery($sql);
     CRM_Utils_System::civiExit();
 }
Example #25
0
 /**
  * Retrieve contact relationships.
  */
 public static function getContactRelationships()
 {
     $contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
     $context = CRM_Utils_Type::escape($_GET['context'], 'String');
     $relationship_type_id = CRM_Utils_Type::escape(CRM_Utils_Array::value('relationship_type_id', $_GET), 'Integer', FALSE);
     if (!CRM_Contact_BAO_Contact_Permission::allow($contactID)) {
         return CRM_Utils_System::permissionDenied();
     }
     $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
     $params['contact_id'] = $contactID;
     $params['context'] = $context;
     if ($relationship_type_id) {
         $params['relationship_type_id'] = $relationship_type_id;
     }
     // get the contact relationships
     $relationships = CRM_Contact_BAO_Relationship::getContactRelationshipSelector($params);
     CRM_Utils_JSON::output($relationships);
 }
Example #26
0
 /**
  * Delete relationships specific to case and relationship type.
  */
 public static function deleteCaseRoles()
 {
     $caseId = CRM_Utils_Type::escape($_POST['case_id'], 'Positive');
     $cid = CRM_Utils_Type::escape($_POST['cid'], 'Positive');
     $relType = CRM_Utils_Request::retrieve('rel_type', 'String', CRM_Core_DAO::$_nullObject, TRUE);
     if (!$cid || !CRM_Case_BAO_Case::accessCase($caseId)) {
         CRM_Utils_System::permissionDenied();
     }
     list($relTypeId, $a, $b) = explode('_', $relType);
     CRM_Case_BAO_Case::endCaseRole($caseId, $b, $cid, $relTypeId);
     CRM_Utils_System::civiExit();
 }
Example #27
0
 /**
  * Retrieve contact relationships.
  */
 public static function getContactRelationships()
 {
     $contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
     $context = CRM_Utils_Type::escape($_GET['context'], 'String');
     $relationship_type_id = CRM_Utils_Type::escape(CRM_Utils_Array::value('relationship_type_id', $_GET), 'Integer', FALSE);
     if (!CRM_Contact_BAO_Contact_Permission::allow($contactID)) {
         return CRM_Utils_System::permissionDenied();
     }
     $sortMapper = array();
     foreach ($_GET['columns'] as $key => $value) {
         $sortMapper[$key] = $value['data'];
     }
     $offset = isset($_GET['start']) ? CRM_Utils_Type::escape($_GET['start'], 'Integer') : 0;
     $rowCount = isset($_GET['length']) ? CRM_Utils_Type::escape($_GET['length'], 'Integer') : 25;
     $sort = isset($_GET['order'][0]['column']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_GET['order'][0]['column'], 'Integer'), $sortMapper) : NULL;
     $sortOrder = isset($_GET['order'][0]['dir']) ? CRM_Utils_Type::escape($_GET['order'][0]['dir'], 'String') : 'asc';
     $params = $_GET;
     if ($sort && $sortOrder) {
         $params['sortBy'] = $sort . ' ' . $sortOrder;
     }
     $params['page'] = $offset / $rowCount + 1;
     $params['rp'] = $rowCount;
     $params['contact_id'] = $contactID;
     $params['context'] = $context;
     if ($relationship_type_id) {
         $params['relationship_type_id'] = $relationship_type_id;
     }
     // get the contact relationships
     $relationships = CRM_Contact_BAO_Relationship::getContactRelationshipSelector($params);
     CRM_Utils_JSON::output($relationships);
 }
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 function preProcess()
 {
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', FALSE);
     if ($this->_cdType) {
         $this->assign('cdType', TRUE);
         return CRM_Custom_Form_CustomData::preProcess($this);
     }
     $this->_caseId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_currentlyViewedContactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     if ($this->_action & CRM_Core_Action::ADD && !$this->_currentlyViewedContactId) {
         // check for add contacts permissions
         if (!CRM_Core_Permission::check('add contacts')) {
             CRM_Utils_System::permissionDenied();
             return;
         }
     }
     //CRM-4418
     if (!CRM_Core_Permission::checkActionPermission('CiviCase', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     if ($this->_action & CRM_Core_Action::DELETE || $this->_action & CRM_Core_Action::RENEW) {
         return TRUE;
     }
     if (!$this->_caseId) {
         $caseAttributes = array('case_type' => CRM_Case_PseudoConstant::caseType(), 'case_status' => CRM_Case_PseudoConstant::caseStatus(), 'encounter_medium' => CRM_Case_PseudoConstant::encounterMedium());
         foreach ($caseAttributes as $key => $values) {
             if (empty($values)) {
                 CRM_Core_Error::fatal(ts('You do not have any active %1', array(1 => str_replace('_', ' ', $key))));
                 break;
             }
         }
     }
     if ($this->_action & CRM_Core_Action::ADD) {
         $this->_activityTypeId = CRM_Core_OptionGroup::getValue('activity_type', 'Open Case', 'name');
         if (!$this->_activityTypeId) {
             CRM_Core_Error::fatal(ts('The Open Case activity type is missing or disabled. Please have your site administrator check Administer > Option Lists > Activity Types for the CiviCase component.'));
         }
     }
     //check for case permissions.
     if (!CRM_Case_BAO_Case::accessCiviCase()) {
         CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
     }
     if ($this->_action & CRM_Core_Action::ADD && (!CRM_Core_Permission::check('access all cases and activities') && !CRM_Core_Permission::check('add cases'))) {
         CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
     }
     if ($this->_activityTypeFile = CRM_Activity_BAO_Activity::getFileForActivityTypeId($this->_activityTypeId, 'Case')) {
         $this->assign('activityTypeFile', $this->_activityTypeFile);
     }
     $details = CRM_Case_PseudoConstant::caseActivityType(FALSE);
     CRM_Utils_System::setTitle($details[$this->_activityTypeId]['label']);
     $this->assign('activityType', $details[$this->_activityTypeId]['label']);
     $this->assign('activityTypeDescription', $details[$this->_activityTypeId]['description']);
     if (isset($this->_currentlyViewedContactId)) {
         $contact = new CRM_Contact_DAO_Contact();
         $contact->id = $this->_currentlyViewedContactId;
         if (!$contact->find(TRUE)) {
             CRM_Core_Error::statusBounce(ts('Client contact does not exist: %1', array(1 => $this->_currentlyViewedContactId)));
         }
         $this->assign('clientName', $contact->display_name);
     }
     $session = CRM_Core_Session::singleton();
     $this->_currentUserId = $session->get('userID');
     //when custom data is included in this page
     CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_activityTypeId, 1, 'Activity');
     eval("CRM_Case_Form_Activity_{$this->_activityTypeFile}::preProcess( \$this );");
     $activityGroupTree = $this->_groupTree;
     // for case custom fields to populate with defaults
     if (CRM_Utils_Array::value('hidden_custom', $_POST)) {
         CRM_Custom_Form_CustomData::preProcess($this);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
     }
     // so that grouptree is not populated with case fields, since the grouptree is used
     // for populating activity custom fields.
     $this->_groupTree = $activityGroupTree;
 }
Example #29
0
 function preProcess()
 {
     if (!CRM_Core_Permission::check('merge duplicate contacts')) {
         CRM_Core_Error::fatal(ts('You do not have access to this page'));
     }
     $rows = array();
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $oid = CRM_Utils_Request::retrieve('oid', 'Positive', $this, TRUE);
     $flip = CRM_Utils_Request::retrieve('flip', 'Positive', $this, FALSE);
     $this->_rgid = $rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this, FALSE);
     $this->_gid = $gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE);
     $this->_mergeId = CRM_Utils_Request::retrieve('mergeId', 'Positive', $this, FALSE);
     if (!CRM_Dedupe_BAO_Rule::validateContacts($cid, $oid)) {
         CRM_Core_Error::statusBounce(ts('The selected pair of contacts are marked as non duplicates. If these records should be merged, you can remove this exception on the <a href=\'%1\'>Dedupe Exceptions</a> page.', array(1 => CRM_Utils_System::url('civicrm/dedupe/exception', 'reset=1'))));
     }
     //load cache mechanism
     $contactType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'contact_type');
     $cacheKey = "merge {$contactType}";
     $cacheKey .= $rgid ? "_{$rgid}" : '_0';
     $cacheKey .= $gid ? "_{$gid}" : '_0';
     $join = "LEFT JOIN civicrm_dedupe_exception de ON ( pn.entity_id1 = de.contact_id1 AND\n                                                             pn.entity_id2 = de.contact_id2 )";
     $where = "de.id IS NULL";
     $pos = CRM_Core_BAO_PrevNextCache::getPositions($cacheKey, $cid, $oid, $this->_mergeId, $join, $where, $flip);
     // Block access if user does not have EDIT permissions for both contacts.
     if (!(CRM_Contact_BAO_Contact_Permission::allow($cid, CRM_Core_Permission::EDIT) && CRM_Contact_BAO_Contact_Permission::allow($oid, CRM_Core_Permission::EDIT))) {
         CRM_Utils_System::permissionDenied();
     }
     // get user info of main contact.
     $config = CRM_Core_Config::singleton();
     $config->doNotResetCache = 1;
     $viewUser = CRM_Core_Permission::check('access user profiles');
     $mainUfId = CRM_Core_BAO_UFMatch::getUFId($cid);
     $mainUser = NULL;
     if ($mainUfId) {
         // d6 compatible
         if ($config->userSystem->is_drupal == '1') {
             $mainUser = user_load($mainUfId);
         } elseif ($config->userFramework == 'Joomla') {
             $mainUser = JFactory::getUser($mainUfId);
         }
         $this->assign('mainUfId', $mainUfId);
         $this->assign('mainUfName', $mainUser ? $mainUser->name : NULL);
     }
     $flipUrl = CRM_Utils_System::url('civicrm/contact/merge', "reset=1&action=update&cid={$oid}&oid={$cid}&rgid={$rgid}&gid={$gid}");
     if (!$flip) {
         $flipUrl .= '&flip=1';
     }
     $this->assign('flip', $flipUrl);
     $this->prev = $this->next = NULL;
     foreach (array('prev', 'next') as $position) {
         if (!empty($pos[$position])) {
             if ($pos[$position]['id1'] && $pos[$position]['id2']) {
                 $urlParam = "reset=1&cid={$pos[$position]['id1']}&oid={$pos[$position]['id2']}&mergeId={$pos[$position]['mergeId']}&action=update";
                 if ($rgid) {
                     $urlParam .= "&rgid={$rgid}";
                 }
                 if ($gid) {
                     $urlParam .= "&gid={$gid}";
                 }
                 $this->{$position} = CRM_Utils_System::url('civicrm/contact/merge', $urlParam);
                 $this->assign($position, $this->{$position});
             }
         }
     }
     // get user info of other contact.
     $otherUfId = CRM_Core_BAO_UFMatch::getUFId($oid);
     $otherUser = NULL;
     if ($otherUfId) {
         // d6 compatible
         if ($config->userSystem->is_drupal == '1') {
             $otherUser = user_load($otherUfId);
         } elseif ($config->userFramework == 'Joomla') {
             $otherUser = JFactory::getUser($otherUfId);
         }
         $this->assign('otherUfId', $otherUfId);
         $this->assign('otherUfName', $otherUser ? $otherUser->name : NULL);
     }
     $cmsUser = $mainUfId && $otherUfId ? TRUE : FALSE;
     $this->assign('user', $cmsUser);
     $session = CRM_Core_Session::singleton();
     // context fixed.
     if ($rgid) {
         $urlParam = "reset=1&action=browse&rgid={$rgid}";
         if ($gid) {
             $urlParam .= "&gid={$gid}";
         }
         $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/dedupefind', $urlParam));
     }
     // ensure that oid is not the current user, if so refuse to do the merge
     if ($session->get('userID') == $oid) {
         $display_name = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $oid, 'display_name');
         $message = ts('The contact record which is linked to the currently logged in user account - \'%1\' - cannot be deleted.', array(1 => $display_name));
         CRM_Core_Error::statusBounce($message);
     }
     $rowsElementsAndInfo = CRM_Dedupe_Merger::getRowsElementsAndInfo($cid, $oid);
     $main =& $rowsElementsAndInfo['main_details'];
     $other =& $rowsElementsAndInfo['other_details'];
     if ($main['contact_id'] != $cid) {
         CRM_Core_Error::fatal(ts('The main contact record does not exist'));
     }
     if ($other['contact_id'] != $oid) {
         CRM_Core_Error::fatal(ts('The other contact record does not exist'));
     }
     $subtypes = CRM_Contact_BAO_ContactType::subTypePairs(NULL, TRUE, '');
     $this->assign('contact_type', $main['contact_type']);
     if (!empty($main['contact_sub_type'])) {
         $this->assign('main_contact_subtype', CRM_Utils_Array::value('contact_sub_type', $subtypes[$main['contact_sub_type'][0]]));
     }
     if (!empty($other['contact_sub_type'])) {
         $this->assign('other_contact_subtype', CRM_Utils_Array::value('contact_sub_type', $subtypes[$other['contact_sub_type'][0]]));
     }
     $this->assign('main_name', $main['display_name']);
     $this->assign('other_name', $other['display_name']);
     $this->assign('main_cid', $main['contact_id']);
     $this->assign('other_cid', $other['contact_id']);
     $this->assign('rgid', $rgid);
     $this->_cid = $cid;
     $this->_oid = $oid;
     $this->_rgid = $rgid;
     $this->_contactType = $main['contact_type'];
     $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "return toggleCheckboxVals('move_',this);"));
     $this->assign('mainLocBlock', json_encode($rowsElementsAndInfo['main_loc_block']));
     $this->assign('rows', $rowsElementsAndInfo['rows']);
     $this->_locBlockIds = array('main' => $rowsElementsAndInfo['main_details']['loc_block_ids'], 'other' => $rowsElementsAndInfo['other_details']['loc_block_ids']);
     // add elements
     foreach ($rowsElementsAndInfo['elements'] as $element) {
         $this->addElement($element[0], $element[1], array_key_exists('2', $element) ? $element[2] : NULL, array_key_exists('3', $element) ? $element[3] : NULL, array_key_exists('4', $element) ? $element[4] : NULL, array_key_exists('5', $element) ? $element[5] : NULL);
     }
     // add related table elements
     foreach ($rowsElementsAndInfo['rel_table_elements'] as $relTableElement) {
         $element = $this->addElement($relTableElement[0], $relTableElement[1]);
         $element->setChecked(TRUE);
     }
     $this->assign('rel_tables', $rowsElementsAndInfo['rel_tables']);
     $this->assign('userContextURL', $session->readUserContext());
 }
Example #30
0
 /**
  * Shared pre-process function.
  *
  * If overriding preProcess function this should still be called.
  *
  * @throws \Exception
  */
 public function preProcessCommon()
 {
     $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', CRM_Core_DAO::$_nullObject);
     $this->_dashBoardRowCount = CRM_Utils_Request::retrieve('rowCount', 'Integer', CRM_Core_DAO::$_nullObject);
     $this->_section = CRM_Utils_Request::retrieve('section', 'Integer', CRM_Core_DAO::$_nullObject);
     $this->assign('section', $this->_section);
     CRM_Core_Region::instance('page-header')->add(array('markup' => sprintf('<!-- Report class: [%s] -->', htmlentities(get_class($this)))));
     if (!$this->noController) {
         $this->setID($this->get('instanceId'));
         if (!$this->_id) {
             $this->setID(CRM_Report_Utils_Report::getInstanceID());
             if (!$this->_id) {
                 $this->setID(CRM_Report_Utils_Report::getInstanceIDForPath());
             }
         }
         // set qfkey so that pager picks it up and use it in the "Next > Last >>" links.
         // FIXME: Note setting it in $_GET doesn't work, since pager generates link based on QUERY_STRING
         $_SERVER['QUERY_STRING'] .= "&qfKey={$this->controller->_key}";
     }
     if ($this->_id) {
         $this->assign('instanceId', $this->_id);
         $params = array('id' => $this->_id);
         $this->_instanceValues = array();
         CRM_Core_DAO::commonRetrieve('CRM_Report_DAO_ReportInstance', $params, $this->_instanceValues);
         if (empty($this->_instanceValues)) {
             CRM_Core_Error::fatal("Report could not be loaded.");
         }
         $this->_title = $this->_instanceValues['title'];
         if (!empty($this->_instanceValues['permission']) && !(CRM_Core_Permission::check($this->_instanceValues['permission']) || CRM_Core_Permission::check('administer Reports'))) {
             CRM_Utils_System::permissionDenied();
             CRM_Utils_System::civiExit();
         }
         $formValues = CRM_Utils_Array::value('form_values', $this->_instanceValues);
         if ($formValues) {
             $this->_formValues = unserialize($formValues);
         } else {
             $this->_formValues = NULL;
         }
         $this->setOutputMode();
         if ($this->_outputMode == 'copy') {
             $this->_createNew = TRUE;
             $this->_params = $this->_formValues;
             $this->_params['view_mode'] = 'criteria';
             $this->_params['title'] = ts('(copy)') . $this->getTitle();
             // Do not pass go. Do not collect another chance to re-run the same query.
             CRM_Report_Form_Instance::postProcess($this);
         }
         // lets always do a force if reset is found in the url.
         // Hey why not? see CRM-17225 for more about this. The use of reset to be force is historical for reasons stated
         // in the comment line above these 2.
         if (!empty($_REQUEST['reset']) && !in_array(CRM_Utils_Request::retrieve('output', 'String'), array('save', 'criteria'))) {
             $this->_force = 1;
         }
         // set the mode
         $this->assign('mode', 'instance');
     } elseif (!$this->noController) {
         list($optionValueID, $optionValue) = CRM_Report_Utils_Report::getValueIDFromUrl();
         $instanceCount = CRM_Report_Utils_Report::getInstanceCount($optionValue);
         if ($instanceCount > 0 && $optionValueID) {
             $this->assign('instanceUrl', CRM_Utils_System::url('civicrm/report/list', "reset=1&ovid={$optionValueID}"));
         }
         if ($optionValueID) {
             $this->_description = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $optionValueID, 'description');
         }
         // set the mode
         $this->assign('mode', 'template');
     }
     // lets display the Report Settings section
     $this->_instanceForm = $this->_force || $this->_id || !empty($_POST);
     // Do not display Report Settings section if administer Reports permission is absent OR
     // if report instance is reserved and administer reserved reports absent
     if (!CRM_Core_Permission::check('administer Reports') || $this->_instanceValues['is_reserved'] && !CRM_Core_Permission::check('administer reserved reports')) {
         $this->_instanceForm = FALSE;
     }
     $this->assign('criteriaForm', FALSE);
     // Display Report Criteria section if user has access Report Criteria OR administer Reports AND report instance is not reserved
     if (CRM_Core_Permission::check('administer Reports') || CRM_Core_Permission::check('access Report Criteria')) {
         if (!$this->_instanceValues['is_reserved'] || CRM_Core_Permission::check('administer reserved reports')) {
             $this->assign('criteriaForm', TRUE);
             $this->_criteriaForm = TRUE;
         }
     }
     $this->_instanceButtonName = $this->getButtonName('submit', 'save');
     $this->_createNewButtonName = $this->getButtonName('submit', 'next');
     $this->_printButtonName = $this->getButtonName('submit', 'print');
     $this->_pdfButtonName = $this->getButtonName('submit', 'pdf');
     $this->_csvButtonName = $this->getButtonName('submit', 'csv');
     $this->_groupButtonName = $this->getButtonName('submit', 'group');
     $this->_chartButtonName = $this->getButtonName('submit', 'chart');
 }