/**
  * Run this page (figure out the action needed and perform it).
  */
 public function run()
 {
     $instanceId = CRM_Report_Utils_Report::getInstanceID();
     if (!$instanceId) {
         $instanceId = CRM_Report_Utils_Report::getInstanceIDForPath();
     }
     if (is_numeric($instanceId)) {
         $instanceURL = CRM_Utils_System::url("civicrm/report/instance/{$instanceId}", 'reset=1');
         CRM_Core_Session::singleton()->replaceUserContext($instanceURL);
     }
     $action = CRM_Utils_Request::retrieve('action', 'String', $this);
     $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId);
     $reportUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1");
     if ($action & CRM_Core_Action::DELETE) {
         if (!CRM_Core_Permission::check('administer Reports')) {
             $statusMessage = ts('You do not have permission to Delete Report.');
             CRM_Core_Error::statusBounce($statusMessage, $reportUrl);
         }
         $navId = CRM_Core_DAO::getFieldValue('CRM_Report_DAO_ReportInstance', $instanceId, 'navigation_id', 'id');
         CRM_Report_BAO_ReportInstance::del($instanceId);
         //delete navigation if exists
         if ($navId) {
             CRM_Core_BAO_Navigation::processDelete($navId);
             CRM_Core_BAO_Navigation::resetNavigation();
         }
         CRM_Core_Session::setStatus(ts('Selected report has been deleted.'), ts('Deleted'), 'success');
     } else {
         $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value');
         if (empty($templateInfo)) {
             CRM_Core_Error::statusBounce('You have tried to access a report that does not exist.');
         }
         $extKey = strpos($templateInfo['name'], '.');
         $reportClass = NULL;
         if ($extKey !== FALSE) {
             $ext = CRM_Extension_System::singleton()->getMapper();
             $reportClass = $ext->keyToClass($templateInfo['name'], 'report');
             $templateInfo['name'] = $reportClass;
         }
         if (strstr($templateInfo['name'], '_Form') || !is_null($reportClass)) {
             $instanceInfo = array();
             CRM_Report_BAO_ReportInstance::retrieve(array('id' => $instanceId), $instanceInfo);
             if (!empty($instanceInfo['title'])) {
                 CRM_Utils_System::setTitle($instanceInfo['title']);
                 $this->assign('reportTitle', $instanceInfo['title']);
             } else {
                 CRM_Utils_System::setTitle($templateInfo['label']);
                 $this->assign('reportTitle', $templateInfo['label']);
             }
             $wrapper = new CRM_Utils_Wrapper();
             return $wrapper->run($templateInfo['name'], NULL, NULL);
         }
         CRM_Core_Session::setStatus(ts('Could not find template for the instance.'), ts('Template Not Found'), 'error');
     }
     return CRM_Utils_System::redirect($reportUrl);
 }
Beispiel #2
0
 /**
  * run this page (figure out the action needed and perform it).
  *
  * @return void
  */
 function run()
 {
     $instanceId = CRM_Report_Utils_Report::getInstanceID();
     if (!$instanceId) {
         $instanceId = CRM_Report_Utils_Report::getInstanceIDForPath();
     }
     $action = CRM_Utils_Request::retrieve('action', 'String', $this);
     $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId);
     $reportUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1");
     if ($action & CRM_Core_Action::DELETE) {
         if (!CRM_Core_Permission::check('administer Reports')) {
             $statusMessage = ts('Your do not have permission to Delete Report.');
             CRM_Core_Error::statusBounce($statusMessage, $reportUrl);
         }
         $navId = CRM_Core_DAO::getFieldValue('CRM_Report_DAO_Instance', $instanceId, 'navigation_id', 'id');
         CRM_Report_BAO_Instance::delete($instanceId);
         //delete navigation if exists
         if ($navId) {
             require_once 'CRM/Core/BAO/Navigation.php';
             CRM_Core_BAO_Navigation::processDelete($navId);
             CRM_Core_BAO_Navigation::resetNavigation();
         }
         CRM_Core_Session::setStatus(ts('Selected Instance has been deleted.'));
     } else {
         require_once 'CRM/Core/OptionGroup.php';
         $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value');
         $extKey = strpos($templateInfo['name'], '.');
         $reportClass = null;
         if ($extKey !== FALSE) {
             require_once 'CRM/Core/Extensions.php';
             $ext = new CRM_Core_Extensions();
             $reportClass = $ext->keyToClass($templateInfo['name'], 'report');
             $templateInfo['name'] = $reportClass;
         }
         if (strstr($templateInfo['name'], '_Form') || !is_null($reportClass)) {
             $instanceInfo = array();
             CRM_Report_BAO_Instance::retrieve(array('id' => $instanceId), $instanceInfo);
             if (!empty($instanceInfo['title'])) {
                 CRM_Utils_System::setTitle($instanceInfo['title']);
                 $this->assign('reportTitle', $instanceInfo['title']);
             } else {
                 CRM_Utils_System::setTitle($templateInfo['label']);
                 $this->assign('reportTitle', $templateInfo['label']);
             }
             $wrapper = new CRM_Utils_Wrapper();
             return $wrapper->run($templateInfo['name'], null, null);
         }
         CRM_Core_Session::setStatus(ts('Could not find template for the instance.'));
     }
     return CRM_Utils_System::redirect($reportUrl);
 }
/**
 * Implementation of hook_civicrm_uninstall
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall
 */
function maxadditionalparticipants_civicrm_uninstall()
{
    require_once "CRM/Core/DAO.php";
    $maxparticipantMenuItem = array('Participant_Settings');
    foreach ($maxparticipantMenuItem as $name) {
        $itemId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', $name, 'id', 'name', TRUE);
        if ($itemId) {
            CRM_Core_BAO_Navigation::processDelete($itemId);
        }
    }
    CRM_Core_BAO_Navigation::resetNavigation();
    CRM_Core_DAO::executeQuery("DELETE FROM civicrm_setting WHERE group_name = 'Event Preferences' AND name = 'max_participants'");
    return _maxadditionalparticipants_civix_civicrm_uninstall();
}
Beispiel #4
0
/**
 * Implementation of hook_civicrm_uninstall
 */
function hrprofile_civicrm_uninstall()
{
    $groups = CRM_Core_PseudoConstant::get('CRM_Core_BAO_UFField', 'uf_group_id', array('labelColumn' => 'name'));
    $profileId = array_search('hrstaffdir_listing', $groups);
    $isEnabled = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Extension', 'org.civicrm.hrstaffdir', 'is_active', 'full_name');
    if ($profileId && $isEnabled) {
        $originalUrl = "civicrm/profile/table?reset=1&gid={$profileId}&force=1";
        $updatedUrl = "civicrm/profile?reset=1&gid={$profileId}&force=1";
        hrprofile_updateNavigation($originalUrl, $updatedUrl);
    } else {
        $navigationParams = array('label' => 'Directory', 'url' => "civicrm/profile/table?reset=1&gid={$profileId}&force=1");
        $navigation = CRM_Core_BAO_Navigation::retrieve($navigationParams, $defaultParams);
        CRM_Core_BAO_Navigation::processDelete($navigation->id);
        CRM_Core_BAO_Navigation::resetNavigation();
    }
    return _hrprofile_civix_civicrm_uninstall();
}
Beispiel #5
0
 /**
  * Post process function.
  *
  * @param CRM_Core_Form $form
  * @param bool $redirect
  */
 public static function postProcess(&$form, $redirect = TRUE)
 {
     $params = $form->getVar('_params');
     $instanceID = $form->getVar('_id');
     if ($isNew = $form->getVar('_createNew')) {
         // set the report_id since base template is going to be same, and we going to unset $instanceID
         // which will make it difficult later on, to compute report_id
         $params['report_id'] = CRM_Report_Utils_Report::getValueFromUrl($instanceID);
         // Unset $instanceID so a new copy would be created.
         $instanceID = NULL;
     }
     $params['instance_id'] = $instanceID;
     if (!empty($params['is_navigation'])) {
         $params['navigation'] = $form->_navigation;
     } elseif ($instanceID) {
         // Delete navigation if exists.
         $navId = CRM_Core_DAO::getFieldValue('CRM_Report_DAO_ReportInstance', $instanceID, 'navigation_id', 'id');
         if ($navId) {
             CRM_Core_BAO_Navigation::processDelete($navId);
             CRM_Core_BAO_Navigation::resetNavigation();
         }
     }
     // make a copy of params
     $formValues = $params;
     // unset params from $formValues that doesn't match with DB columns of instance tables, and also not required in form-values for sure
     $unsetFields = array('title', 'to_emails', 'cc_emails', 'header', 'footer', 'qfKey', 'id', '_qf_default', 'report_header', 'report_footer', 'grouprole');
     foreach ($unsetFields as $field) {
         unset($formValues[$field]);
     }
     $view_mode = $formValues['view_mode'];
     // pass form_values as string
     $params['form_values'] = serialize($formValues);
     $instance = CRM_Report_BAO_ReportInstance::create($params);
     $form->set('id', $instance->id);
     if ($instanceID && !$isNew) {
         // updating existing instance
         $statusMsg = ts('"%1" report has been updated.', array(1 => $instance->title));
     } elseif ($form->getVar('_id') && $isNew) {
         $statusMsg = ts('Your report has been successfully copied as "%1". You are currently viewing the new copy.', array(1 => $instance->title));
     } else {
         $statusMsg = ts('"%1" report has been successfully created. You are currently viewing the new report instance.', array(1 => $instance->title));
     }
     CRM_Core_Session::setStatus($statusMsg);
     if ($redirect) {
         $urlParams = array('reset' => 1);
         if ($view_mode == 'view') {
             $urlParams['force'] = 1;
         } else {
             $urlParams['output'] = 'criteria';
         }
         CRM_Utils_System::redirect(CRM_Utils_System::url("civicrm/report/instance/{$instance->id}", $urlParams));
     }
 }
Beispiel #6
0
/**
 * Implementation of hook_civicrm_uninstall
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall
 */
function hrjobcontract_civicrm_uninstall()
{
    $subTypeInfo = CRM_Contact_BAO_ContactType::subTypeInfo('Organization');
    $sub_type_name = array('Health Insurance Provider', 'Life Insurance Provider');
    foreach ($sub_type_name as $sub_type_name) {
        $subTypeName = ucfirst(CRM_Utils_String::munge($sub_type_name));
        $orid = array_key_exists($subTypeName, $subTypeInfo);
        if ($orid) {
            $id = $subTypeInfo[$subTypeName]['id'];
            CRM_Contact_BAO_ContactType::del($id);
        }
    }
    $jobContractMenu = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'job_contracts', 'id', 'name');
    if (!empty($jobContractMenu)) {
        CRM_Core_BAO_Navigation::processDelete($jobContractMenu);
    }
    CRM_Core_DAO::executeQuery("DELETE FROM civicrm_navigation WHERE name IN ('job_contracts', 'import_export_job_contracts', 'jobImport', 'hoursType', 'pay_scale','hours_location', 'hrjc_contact_type', 'hrjc_location', 'hrjc_pay_cycle', 'hrjc_benefit_name', 'hrjc_benefit_type', 'hrjc_deduction_name', 'hrjc_deduction_type', 'hrjc_health_provider', 'hrjc_life_provider', 'hrjc_pension_type', 'hrjc_revision_change_reason')");
    CRM_Core_BAO_Navigation::resetNavigation();
    //delete custom groups and field
    $customGroup = civicrm_api3('CustomGroup', 'get', array('name' => "HRJobContract_Summary"));
    $customGroupData = CRM_Utils_Array::first($customGroup['values']);
    if (!empty($customGroupData['id'])) {
        civicrm_api3('CustomGroup', 'delete', array('id' => $customGroupData['id']));
    }
    $customGroup = civicrm_api3('CustomGroup', 'get', array('name' => "HRJobContract_Summary"));
    $customGroupData = CRM_Utils_Array::first($customGroup['values']);
    if (!empty($customGroupData['id'])) {
        civicrm_api3('CustomGroup', 'delete', array('id' => $customGroupData['id']));
    }
    //delete all option group and values
    CRM_Core_DAO::executeQuery("DELETE FROM civicrm_option_group WHERE name IN ('job_contracts', 'hoursType', 'pay_scale','hours_location', 'hrjc_contact_type', 'hrjc_location', 'hrjc_pay_cycle', 'hrjc_benefit_name', 'hrjc_benefit_type', 'hrjc_deduction_name', 'hrjc_deduction_type', 'hrjc_health_provider', 'hrjc_life_provider', 'hrjc_pension_type', 'hrjc_revision_change_reason', 'hrjc_contract_type', 'hrjc_level_type', 'hrjc_department', 'hrjc_hours_type', 'hrjc_pay_grade', 'hrjc_health_provider', 'hrjc_life_provider', 'hrjc_location', 'hrjc_pension_type', 'hrjc_region', 'hrjc_pay_scale')");
    //delete job contract files to entities relations
    CRM_Core_DAO::executeQuery("DELETE FROM civicrm_entity_file WHERE entity_table LIKE 'civicrm_hrjobcontract_%'");
    return _hrjobcontract_civix_civicrm_uninstall();
}
Beispiel #7
0
/**
 * Implementation of hook_civicrm_uninstall
 */
function hrstaffdir_civicrm_uninstall()
{
    _hrstaffdir_civix_civicrm_uninstall();
    $profileId = hrstaffdir_getUFGroupID();
    $path = array('url' => "civicrm/profile?reset=1&gid={$profileId}&force=1");
    $navigationPath = CRM_Core_BAO_Navigation::retrieve($path, $defaultpath);
    if ($navigationPath) {
        $navigationParams = array('label' => 'Directory', 'url' => "civicrm/profile?reset=1&gid={$profileId}&force=1");
        $navigation = CRM_Core_BAO_Navigation::retrieve($navigationParams, $defaultParams);
        CRM_Core_BAO_Navigation::processDelete($navigation->id);
        CRM_Core_BAO_Navigation::resetNavigation();
    }
    //delete ufgroup
    $ufID = civicrm_api3('UFGroup', 'getsingle', array('return' => "id", 'name' => "hrstaffdir_listing"));
    civicrm_api3('UFGroup', 'delete', array('id' => $ufID['id']));
}
 /**
  * Delete the instance of the Report.
  *
  * @param int $id
  *
  * @return mixed
  *   $results no of deleted Instance on success, false otherwise
  */
 public static function del($id = NULL)
 {
     $navId = CRM_Core_DAO::getFieldValue('CRM_Report_DAO_ReportInstance', $id, 'navigation_id', 'id');
     $dao = new CRM_Report_DAO_ReportInstance();
     $dao->id = $id;
     $result = $dao->delete();
     // Delete navigation if exists.
     if ($navId) {
         CRM_Core_BAO_Navigation::processDelete($navId);
         CRM_Core_BAO_Navigation::resetNavigation();
     }
     return $result;
 }
Beispiel #9
0
/**
 * Implementation of hook_civicrm_uninstall
 */
function hrrecruitment_civicrm_uninstall()
{
    $vacanciesId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Vacancies', 'id', 'name');
    CRM_Core_BAO_Navigation::processDelete($vacanciesId);
    CRM_Core_BAO_Navigation::resetNavigation();
    CRM_Core_DAO::executeQuery("DELETE FROM civicrm_option_group WHERE name IN ('vacancy_status', 'work_experience', 'rate_the_applicant_s_communicati', 'rate_the_applicant_s_technical_s', 'languages_known')");
    $caseTypes = CRM_Case_PseudoConstant::caseType('name', FALSE);
    $value = array_search('Application', $caseTypes);
    //Delete cases and related contact of type Application on uninstall
    if ($value) {
        $caseDAO = new CRM_Case_DAO_Case();
        $caseDAO->case_type_id = $value;
        $caseDAO->find();
        while ($caseDAO->fetch()) {
            CRM_Case_BAO_Case::deleteCase($caseDAO->id);
        }
    }
    $CaseStatuses = CRM_Core_OptionGroup::values('case_status', FALSE, FALSE, FALSE, " AND grouping = 'Vacancy'", 'id', FALSE);
    $CaseStatus = implode(',', $CaseStatuses);
    CRM_Core_DAO::executeQuery("DELETE FROM civicrm_option_value WHERE id IN ({$CaseStatus}) OR name IN ('Evaluation', 'Comment')");
    foreach (array('application_profile', 'evaluation_profile') as $name) {
        $ufID = civicrm_api3('UFGroup', 'getsingle', array('return' => "id", 'name' => $name));
        civicrm_api3('UFGroup', 'delete', array('id' => $ufID['id']));
    }
    foreach (array('Application', 'application_case', 'Evaluation_fields') as $cgName) {
        $customGroup = civicrm_api3('CustomGroup', 'getsingle', array('return' => "id", 'name' => $cgName));
        civicrm_api3('CustomGroup', 'delete', array('id' => $customGroup['id']));
    }
    $isEnabled = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Extension', 'org.civicrm.hrcase', 'is_active', 'full_name');
    if (!$isEnabled) {
        CRM_Core_DAO::executeQuery("DELETE FROM `civicrm_relationship_type` WHERE name_b_a IN ('Recruiting Manager')");
    }
    return _hrrecruitment_civix_civicrm_uninstall();
}