Example #1
0
 /**
  * Function to get details of each dashlets
  *
  * @param int $dashletID widget ID
  *
  * @return array associted array title and content
  * @access public
  * @static  
  */
 static function getDashletInfo($dashletID)
 {
     $dashletInfo = array();
     $dao = new CRM_Core_DAO_Dashboard();
     $dao->id = $dashletID;
     $dao->find(true);
     //reset content based on the cache time set in config
     $currentDate = strtotime(date('Y-m-d h:i:s'));
     $createdDate = strtotime($dao->created_date);
     $dateDiff = round(abs($currentDate - $createdDate) / 60);
     $config = CRM_Core_Config::singleton();
     if ($config->dashboardCacheTimeout <= $dateDiff) {
         $dao->content = NULL;
     }
     // if content is empty and url is set, retrieve it from url
     if (!$dao->content && $dao->url) {
         $url = $dao->url;
         // CRM-7087
         // -lets use relative url for internal use.
         // -make sure relative url should not be htmlize.
         if (substr($dao->url, 0, 4) != 'http') {
             if ($config->userFramework == 'Joomla' || $config->userFramework == 'Drupal' && !variable_get('clean_url', '0')) {
                 $url = CRM_Utils_System::url($dao->url, null, false, null, false);
             }
         }
         //get content from url
         $dao->content = CRM_Utils_System::getServerResponse($url);
         $dao->created_date = date("YmdHis");
         $dao->save();
     }
     $dashletInfo = array('title' => $dao->label, 'content' => $dao->content);
     if ($dao->is_fullscreen) {
         $dashletInfo['fullscreen'] = $dao->content;
     }
     return $dashletInfo;
 }
Example #2
0
 /**
  * Function to get details of each dashlets
  *
  * @param int $dashletID widget ID
  *
  * @return array associted array title and content
  * @access public
  * @static  
  */
 static function getDashletInfo($dashletID)
 {
     $dashletInfo = array();
     $dao = new CRM_Core_DAO_Dashboard();
     $dao->id = $dashletID;
     $dao->find(true);
     //reset content based on the cache time set in config
     $currentDate = strtotime(date('Y-m-d h:i:s'));
     $createdDate = strtotime($dao->created_date);
     $dateDiff = round(abs($currentDate - $createdDate) / 60);
     $config = CRM_Core_Config::singleton();
     if ($config->dashboardCacheTimeout <= $dateDiff) {
         $dao->content = NULL;
     }
     // if content is empty and url is set, retrieve it from url
     if (!$dao->content && $dao->url) {
         if (substr($dao->url, 0, 4) === 'http') {
             $url = $dao->url;
         } else {
             $url = CRM_Utils_System::url($dao->url, null, true, null, false);
         }
         //get content from url
         $dao->content = CRM_Utils_System::getServerResponse($url);
         $dao->created_date = date("YmdHis");
         $dao->save();
     }
     $dashletInfo = array('title' => $dao->label, 'content' => $dao->content);
     if ($dao->is_fullscreen) {
         $dashletInfo['fullscreen'] = $dao->content;
     }
     return $dashletInfo;
 }
 /**
  * Get details of each dashlets.
  *
  * @param int $dashletID
  *   Widget ID.
  *
  * @return array
  *   associted array title and content
  */
 public static function getDashletInfo($dashletID)
 {
     $dashletInfo = array();
     $params = array(1 => array($dashletID, 'Integer'));
     $query = "SELECT name, label, url, fullscreen_url, is_fullscreen FROM civicrm_dashboard WHERE id = %1";
     $dashboadDAO = CRM_Core_DAO::executeQuery($query, $params);
     $dashboadDAO->fetch();
     // build the content
     $dao = new CRM_Contact_DAO_DashboardContact();
     $session = CRM_Core_Session::singleton();
     $dao->contact_id = $session->get('userID');
     $dao->dashboard_id = $dashletID;
     $dao->find(TRUE);
     //reset content based on the cache time set in config
     $createdDate = strtotime($dao->created_date);
     $dateDiff = round(abs(time() - $createdDate) / 60);
     $config = CRM_Core_Config::singleton();
     if ($config->dashboardCacheTimeout <= $dateDiff) {
         $dao->content = NULL;
     }
     // if content is empty and url is set, retrieve it from url
     if (!$dao->content && $dashboadDAO->url) {
         $url = $dashboadDAO->url;
         // CRM-7087
         // -lets use relative url for internal use.
         // -make sure relative url should not be htmlize.
         if (substr($dashboadDAO->url, 0, 4) != 'http') {
             $urlParam = explode('?', $dashboadDAO->url);
             $url = CRM_Utils_System::url($urlParam[0], $urlParam[1], TRUE, NULL, FALSE);
         }
         //get content from url
         $dao->content = CRM_Utils_System::getServerResponse($url);
         $dao->created_date = date("YmdHis");
         $dao->save();
     }
     $dashletInfo = array('title' => $dashboadDAO->label, 'name' => $dashboadDAO->name, 'content' => $dao->content);
     if ($dashboadDAO->is_fullscreen) {
         $fullscreenUrl = $dashboadDAO->fullscreen_url;
         if (substr($fullscreenUrl, 0, 4) != 'http') {
             $urlParam = explode('?', $dashboadDAO->fullscreen_url);
             $fullscreenUrl = CRM_Utils_System::url($urlParam[0], $urlParam[1], TRUE, NULL, FALSE);
         }
         $dashletInfo['fullscreenUrl'] = $fullscreenUrl;
     }
     return $dashletInfo;
 }
Example #4
0
/**
 * Implementation of hook_civicrm_pageRun
 *
 * @return void
 */
function hrreport_civicrm_pageRun(&$page)
{
    $pageName = $page->getVar('_name');
    $componentName = $page->getVar('_compName');
    //change page title from 'Case Report' to  'Assignment Report'
    if ($pageName == 'CRM_Report_Page_InstanceList' && $componentName == 'Case') {
        CRM_Utils_System::setTitle(ts('Assignment Reports'));
    }
    if ($pageName == 'CRM_Report_Page_InstanceList' || $pageName == 'CRM_Report_Page_TemplateList') {
        CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.hrreport', 'js/hrreport.js');
    }
    if ($pageName == 'CRM_Contact_Page_DashBoard') {
        $report_id = _hrreport_getId();
        $session = CRM_Core_Session::singleton();
        $contact_id = $session->get('userID');
        //to do entry of default casedashboard report and civicrm news report
        foreach (array('blog', 'casedashboard') as $name) {
            $caseDashlet = civicrm_api3('Dashboard', 'getsingle', array('return' => array("id", "url", "permission"), 'name' => $name));
            $dashboardContactId = civicrm_api3('DashboardContact', 'get', array('return' => array("id", "is_active"), 'dashboard_id' => $caseDashlet['id'], 'contact_id' => $contact_id));
            $url = CRM_Utils_System::getServerResponse($caseDashlet['url'], false);
            if (empty($dashboardContactId['id'])) {
                if ($name == 'blog') {
                    civicrm_api3('DashboardContact', 'create', array("dashboard_id" => $caseDashlet['id'], 'is_active' => '1', 'contact_id' => $contact_id, 'column_no' => '1', 'content' => $url));
                } elseif (CRM_Case_BAO_Case::accessCiviCase()) {
                    civicrm_api3('DashboardContact', 'create', array("dashboard_id" => $caseDashlet['id'], 'is_active' => '1', 'contact_id' => $contact_id, 'column_no' => '1', 'content' => $url));
                }
            }
            if (!empty($dashboardContactId['id']) && $name == 'casedashboard') {
                $id = $dashboardContactId['id'];
                if (!CRM_Case_BAO_Case::accessCiviCase()) {
                    _hrreport_createDashlet($id, '0');
                } elseif ($dashboardContactId['values'][$id]['is_active'] == 0) {
                    _hrreport_createDashlet($id, '1');
                }
            }
        }
        $i = 1;
        foreach ($report_id as $key => $val) {
            $dashletParams['url'] = "civicrm/report/instance/{$val}?reset=1&section=2&snippet=5&context=dashlet";
            $dashlet = civicrm_api3('Dashboard', 'get', array('name' => "report/{$val}"));
            if (!empty($dashlet['count']) && $dashlet['count'] > 0) {
                $contentUrl = CRM_Utils_System::getServerResponse($dashletParams['url']);
                $dashboardContact = civicrm_api3('DashboardContact', 'get', array('return' => array("id", "is_active"), 'dashboard_id' => $dashlet['id'], 'contact_id' => $contact_id));
                $dashId = $dashlet['id'];
                if (empty($dashboardContact['id'])) {
                    if (CRM_Core_Permission::check($dashlet['values'][$dashId]['permission'])) {
                        civicrm_api3('DashboardContact', 'create', array("dashboard_id" => $dashlet['id'], 'is_active' => '1', 'contact_id' => $contact_id, 'column_no' => $i, 'content' => CRM_Utils_System::getServerResponse($dashletParams['url'])));
                    }
                }
                if (!empty($dashboardContact['id'])) {
                    $id = $dashboardContact['id'];
                    if (!CRM_Core_Permission::check($dashlet['values'][$dashId]['permission'])) {
                        _hrreport_createDashlet($id, '0');
                    } elseif ($dashboardContact['values'][$id]['is_active'] == 0) {
                        _hrreport_createDashlet($id, '1');
                    }
                }
                $i = 0;
            }
        }
    }
}