/** * run this page (figure out the action needed and perform it). * * @return void */ function run() { if (!CRM_Core_Permission::check('administer Reports')) { return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/report/list', 'reset=1')); } $optionVal = CRM_Report_Utils_Report::getValueFromUrl(); $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value', 'String', FALSE); $extKey = strpos(CRM_Utils_Array::value('name', $templateInfo), '.'); $reportClass = NULL; if ($extKey !== FALSE) { $ext = CRM_Extension_System::singleton()->getMapper(); $reportClass = $ext->keyToClass($templateInfo['name'], 'report'); $templateInfo['name'] = $reportClass; } if (strstr(CRM_Utils_Array::value('name', $templateInfo), '_Form') || !is_null($reportClass)) { CRM_Utils_System::setTitle($templateInfo['label'] . ' - Template'); $this->assign('reportTitle', $templateInfo['label']); $session = CRM_Core_Session::singleton(); $session->set('reportDescription', $templateInfo['description']); $wrapper = new CRM_Utils_Wrapper(); return $wrapper->run($templateInfo['name'], NULL, NULL); } if ($optionVal) { CRM_Core_Session::setStatus(ts('Could not find the report template. Make sure the report template is registered and / or url is correct.'), ts('Template Not Found'), 'error'); } return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/report/list', 'reset=1')); }
function run() { require_once 'CRM/Utils/Request.php'; require_once 'CRM/Core/DAO.php'; $eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, true); $fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, false); $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, true); $quest = CRM_Utils_Request::retrieve('quest', 'String', $this); $action = CRM_Utils_Request::retrieve('action', 'String', $this); require_once 'CRM/Core/BAO/File.php'; list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, null, $quest); if (!$path) { CRM_Core_Error::statusBounce('Could not retrieve the file'); } $buffer = file_get_contents($path); if (!$buffer) { CRM_Core_Error::statusBounce('The file is either empty or you do not have permission to retrieve the file'); } if ($action & CRM_Core_Action::DELETE) { if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) { CRM_Core_BAO_File::delete($id, $eid, $fid); CRM_Core_Session::setStatus(ts('The attached file has been deleted.')); $session = CRM_Core_Session::singleton(); $toUrl = $session->popUserContext(); CRM_Utils_System::redirect($toUrl); } else { $wrapper = new CRM_Utils_Wrapper(); return $wrapper->run('CRM_Custom_Form_DeleteFile', ts('Domain Information Page'), null); } } else { require_once 'CRM/Utils/File.php'; CRM_Utils_System::download(CRM_Utils_File::cleanFileName(basename($path)), $mimeType, $buffer); } }
function edit() { // used for ajax tabs $context = CRM_Utils_Request::retrieve('context', 'String', $this); $this->assign('context', $context); $this->_id = CRM_Utils_Request::retrieve('id', 'Integer', $this); $this->_caseId = CRM_Utils_Request::retrieve('caseid', 'Integer', $this); $activityTypeId = CRM_Utils_Request::retrieve('atype', 'Positive', $this); // Email and Create Letter activities use a different form class $emailTypeValue = CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name'); $letterTypeValue = CRM_Core_OptionGroup::getValue('activity_type', 'Print PDF Letter', 'name'); switch ($activityTypeId) { case $emailTypeValue: $wrapper = new CRM_Utils_Wrapper(); $arguments = array('attachUpload' => 1); return $wrapper->run('CRM_Contact_Form_Task_Email', ts('Email a Contact'), $arguments); case $letterTypeValue: $wrapper = new CRM_Utils_Wrapper(); $arguments = array('attachUpload' => 1); return $wrapper->run('CRM_Contact_Form_Task_PDF', ts('Create PDF Letter'), $arguments); default: $controller = new CRM_Core_Controller_Simple('CRM_Activity_Form_Activity', ts('Contact Activities'), $this->_action, FALSE, FALSE, FALSE, TRUE); } $controller->setEmbedded(TRUE); $controller->set('contactId', $this->_contactId); $controller->set('atype', $activityTypeId); $controller->set('id', $this->_id); $controller->set('pid', $this->get('pid')); $controller->set('action', $this->_action); $controller->set('context', $context); $controller->process(); $controller->run(); }
/** * 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(); } $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); }
/** * YoteUp ProcessCounselor API * * @return array API result descriptor * @see civicrm_api3_create_success * @see civicrm_api3_create_error * @throws API_Exception */ function civicrm_api3_nrm_processcounselor($params) { // Get list of counselors $counsellorCount = civicrm_api3('Contact', 'getCount', array('contact_sub_type' => 'Counselors')); $counselorParams = array('contact_sub_type' => 'Counselors', 'return.email' => 1, 'return.custom_' . TERRITORY_COUNSELOR => 1, 'rowCount' => $counsellorCount); $counselors = civicrm_api3('Contact', 'get', $counselorParams); $ind = array(); $is_error = 0; $messages = array("Report Mail Triggered..."); if ($counselors['count'] >= 1) { $counselors = $counselors['values']; foreach ($counselors as $key => $value) { if (!empty($value['custom_' . TERRITORY_COUNSELOR])) { $ind[$key]['contact_id'] = $value['contact_id']; $ind[$key]['email'] = $value['email']; } } // Now email $instanceId = CRM_Utils_Array::value('instanceId', $params); $_REQUEST['instanceId'] = $instanceId; $_REQUEST['sendmail'] = CRM_Utils_Array::value('sendmail', $params, 1); // if cron is run from terminal --output is reserved, and therefore we would provide another name 'format' $_REQUEST['output'] = CRM_Utils_Array::value('format', $params, CRM_Utils_Array::value('output', $params, 'pdf')); $_REQUEST['reset'] = CRM_Utils_Array::value('reset', $params, 1); $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId); $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', $optionVal, 'value'); if (strstr(CRM_Utils_Array::value('name', $templateInfo), '_Form')) { $obj = new CRM_Report_Page_Instance(); $instanceInfo = array(); CRM_Report_BAO_ReportInstance::retrieve(array('id' => $instanceId), $instanceInfo); if (!empty($instanceInfo['title'])) { $obj->assign('reportTitle', $instanceInfo['title']); } else { $obj->assign('reportTitle', $templateInfo['label']); } foreach ($ind as $key => $value) { $_REQUEST['email_to_send'] = $value['email']; $_GET['counsellor_id_value'] = $value['contact_id']; $wrapper = new CRM_Utils_Wrapper(); $arguments = array('urlToSession' => array(array('urlVar' => 'instanceId', 'type' => 'Positive', 'sessionVar' => 'instanceId', 'default' => 'null')), 'ignoreKey' => TRUE); $messages[] = $wrapper->run($templateInfo['name'], NULL, $arguments); } } } if ($is_error == 0) { return civicrm_api3_create_success(); } else { return civicrm_api3_create_error($messages); } }
/** * 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(); } $action = CRM_Utils_Request::retrieve('action', 'String', $this); $reportUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1"); if ($action & CRM_Core_Action::DELETE) { CRM_Report_BAO_ReportInstance::doFormDelete($instanceId, $reportUrl); return CRM_Utils_System::redirect($reportUrl); } if (is_numeric($instanceId)) { $instanceURL = CRM_Utils_System::url("civicrm/report/instance/{$instanceId}", 'reset=1'); CRM_Core_Session::singleton()->replaceUserContext($instanceURL); } $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId); $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); }
/** * Call generic ajax forms. * */ public static function run() { $className = CRM_Utils_Type::escape($_REQUEST['class_name'], 'String'); $type = ''; if (!empty($_REQUEST['type'])) { $type = CRM_Utils_Type::escape($_REQUEST['type'], 'String'); } if (!$className) { CRM_Core_Error::fatal(ts('Invalid className: %1', array(1 => $className))); } $fnName = NULL; if (isset($_REQUEST['fn_name'])) { $fnName = CRM_Utils_Type::escape($_REQUEST['fn_name'], 'String'); } if (!self::checkAuthz($type, $className, $fnName)) { CRM_Utils_System::civiExit(); } switch ($type) { case 'method': call_user_func(array($className, $fnName)); break; case 'page': case 'class': case '': // FIXME: This is done to maintain current wire protocol, but it might be // simpler to just require different 'types' for pages and forms if (preg_match('/^CRM_[a-zA-Z0-9]+_Page_Inline_/', $className)) { $page = new $className(); $page->run(); } else { $wrapper = new CRM_Utils_Wrapper(); $wrapper->run($className); } break; default: CRM_Core_Error::debug_log_message('Unsupported inline request type: ' . var_export($type, TRUE)); } CRM_Utils_System::civiExit(); }
function processReport() { $sendmail = CRM_Utils_Request::retrieve('sendmail', 'Boolean', CRM_Core_DAO::$_nullObject, true, null, 'REQUEST'); $instanceId = CRM_Utils_Request::retrieve('instanceId', 'Positive', CRM_Core_DAO::$_nullObject, true, null, 'REQUEST'); $resetVal = CRM_Utils_Request::retrieve('reset', 'Positive', CRM_Core_DAO::$_nullObject, true, null, 'REQUEST'); $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId); echo "Report Mail Triggered...<br />"; require_once 'CRM/Core/OptionGroup.php'; $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', $optionVal, 'value'); $obj = new CRM_Report_Page_Instance(); if (strstr($templateInfo['name'], '_Form')) { $instanceInfo = array(); CRM_Report_BAO_Instance::retrieve(array('id' => $instanceId), $instanceInfo); if (!empty($instanceInfo['title'])) { $obj->assign('reportTitle', $instanceInfo['title']); } else { $obj->assign('reportTitle', $templateInfo['label']); } $wrapper = new CRM_Utils_Wrapper(); $arguments['urlToSession'] = array(array('urlVar' => 'instanceId', 'type' => 'Positive', 'sessionVar' => 'instanceId', 'default' => 'null')); return $wrapper->run($templateInfo['name'], null, $arguments); } }
/** * 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; }
static function processReport($params) { $instanceId = CRM_Utils_Array::value('instanceId', $params); // hack for now, CRM-8358 $_REQUEST['instanceId'] = $instanceId; $_REQUEST['sendmail'] = CRM_Utils_Array::value('sendmail', $params, 1); // if cron is run from terminal --output is reserved, and therefore we would provide another name 'format' $_REQUEST['output'] = CRM_Utils_Array::value('format', $params, CRM_Utils_Array::value('output', $params, 'pdf')); $_REQUEST['reset'] = CRM_Utils_Array::value('reset', $params, 1); $optionVal = self::getValueFromUrl($instanceId); $messages = array("Report Mail Triggered..."); $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', $optionVal, 'value'); $obj = new CRM_Report_Page_Instance(); $is_error = 0; if (strstr(CRM_Utils_Array::value('name', $templateInfo), '_Form')) { $instanceInfo = array(); CRM_Report_BAO_ReportInstance::retrieve(array('id' => $instanceId), $instanceInfo); if (!empty($instanceInfo['title'])) { $obj->assign('reportTitle', $instanceInfo['title']); } else { $obj->assign('reportTitle', $templateInfo['label']); } $wrapper = new CRM_Utils_Wrapper(); $arguments = array('urlToSession' => array(array('urlVar' => 'instanceId', 'type' => 'Positive', 'sessionVar' => 'instanceId', 'default' => 'null')), 'ignoreKey' => TRUE); $messages[] = $wrapper->run($templateInfo['name'], NULL, $arguments); } else { $is_error = 1; if (!$instanceId) { $messages[] = 'Required parameter missing: instanceId'; } else { $messages[] = 'Did not find valid instance to execute'; } } $result = array('is_error' => $is_error, 'messages' => implode("\n", $messages)); return $result; }
/** * This function contains the default action. * * @param $action * * @param $contact_type * @param $contact_sub_type * */ public static function form($action, $contact_type, $contact_sub_type) { CRM_Utils_System::setUserContext(array('civicrm/contact/search/basic', 'civicrm/contact/view')); $wrapper = new CRM_Utils_Wrapper(); $properties = CRM_Core_Component::contactSubTypeProperties($contact_sub_type, 'Edit'); if ($properties) { $wrapper->run($properties['class'], ts('New %1', array(1 => $contact_sub_type)), $action, TRUE); } else { $wrapper->run('CRM_Contact_Form_Contact', ts('New Contact'), $action, TRUE); } }
/** * 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')); $buttonType = CRM_Utils_Array::value('_qf_Edit_cancel', $_POST); // CRM-5849: we should actually check the button *type*, but we get the *value*, potentially translated; // we should keep both English and translated checks just to make sure we also handle untranslated Cancels if ($buttonType == 'Cancel' or $buttonType == ts('Cancel')) { $cancelURL = CRM_Utils_Request::retrieve('cancelURL', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, $_POST); if ($cancelURL) { CRM_Utils_System::redirect($cancelURL); } } 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)); } } $page = new CRM_Profile_Page_Listings(); return $page->run(); }