예제 #1
0
파일: Instance.php 프로젝트: ksecor/civicrm
 /**
  * run this page (figure out the action needed and perform it).
  *
  * @return void
  */
 function run()
 {
     $instanceId = CRM_Report_Utils_Report::getInstanceID();
     $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);
         }
         CRM_Report_BAO_Instance::delete($instanceId);
         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');
         if (strstr($templateInfo['name'], '_Form')) {
             $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);
 }
 /**
  * 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('You 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) {
             CRM_Core_BAO_Navigation::processDelete($navId);
             CRM_Core_BAO_Navigation::resetNavigation();
         }
         CRM_Core_Session::setStatus(ts('Selected Instance has been deleted.'));
     } else {
         $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value');
         if (empty($templateInfo)) {
             CRM_Core_Session::setStatus(ts('Could not find template for the instance.'));
             return;
         }
         $extKey = strpos($templateInfo['name'], '.');
         $reportClass = NULL;
         if ($extKey !== FALSE) {
             $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);
 }
예제 #3
0
 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);
     }
 }
예제 #4
0
 static function processReport($params)
 {
     $instanceId = CRM_Utils_Array::value('instanceId', $params);
     // hack for now, CRM-8358
     $_GET['instanceId'] = $instanceId;
     $_GET['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'
     $_GET['output'] = CRM_Utils_Array::value('format', $params, CRM_Utils_Array::value('output', $params, 'pdf'));
     $_GET['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_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'));
         $arguments['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;
 }
예제 #5
0
 /**
  * Function for find out whether to use logging schema entries for contact
  * summary, instead of normal log entries.
  *
  * @return int report id of Contact Logging Report (Summary) / false
  * @access public
  * @static
  */
 static function useLoggingReport()
 {
     // first check if logging is enabled
     $config = CRM_Core_Config::singleton();
     if (!$config->logging) {
         return FALSE;
     }
     $loggingSchema = new CRM_Logging_Schema();
     if ($loggingSchema->isEnabled()) {
         $params = array('report_id' => 'logging/contact/summary');
         $instance = array();
         CRM_Report_BAO_Instance::retrieve($params, $instance);
         if (!empty($instance) && (!CRM_Utils_Array::value('permission', $instance) || CRM_Utils_Array::value('permission', $instance) && CRM_Core_Permission::check($instance['permission']))) {
             return $instance['id'];
         }
     }
     return FALSE;
 }