Esempio n. 1
0
 /**
  * Function to build user dashboard
  *
  * @return none
  * @access public
  */
 function buildUserDashBoard()
 {
     //build component selectors
     $dashboardElements = array();
     $config =& CRM_Core_Config::singleton();
     require_once 'CRM/Core/BAO/Preferences.php';
     $this->_userOptions = CRM_Core_BAO_Preferences::valueOptions('user_dashboard_options');
     $components = CRM_Core_Component::getEnabledComponents();
     foreach ($components as $name => $component) {
         $elem = $component->getUserDashboardElement();
         if (!$elem) {
             continue;
         }
         if (CRM_Utils_Array::value($name, $this->_userOptions) && (CRM_Core_Permission::access($component->name) || CRM_Core_Permission::check($elem['perm'][0]))) {
             $userDashboard = $component->getUserDashboardObject();
             $dashboardElements[] = array('templatePath' => $userDashboard->getTemplateFileName(), 'sectionTitle' => $elem['title'], 'weight' => $elem['weight']);
             $userDashboard->run();
         }
     }
     $sectionName = 'Permissioned Orgs';
     if ($this->_userOptions[$sectionName]) {
         $dashboardElements[] = array('templatePath' => 'CRM/Contact/Page/View/Relationship.tpl', 'sectionTitle' => ts('Your Contacts / Organizations'), 'weight' => 40);
         $links =& self::links();
         $currentRelationships = CRM_Contact_BAO_Relationship::getRelationship($this->_contactId, CRM_Contact_BAO_Relationship::CURRENT, 0, 0, 0, $links, null, true);
         $this->assign('currentRelationships', $currentRelationships);
     }
     if ($this->_userOptions['PCP']) {
         require_once 'CRM/Contribute/BAO/PCP.php';
         $dashboardElements[] = array('templatePath' => 'CRM/Contribute/Page/PcpUserDashboard.tpl', 'sectionTitle' => ts('Personal Campaign Pages'), 'weight' => 40);
         list($pcpBlock, $pcpInfo) = CRM_Contribute_BAO_PCP::getPcpDashboardInfo($this->_contactId);
         $this->assign('pcpBlock', $pcpBlock);
         $this->assign('pcpInfo', $pcpInfo);
     }
     require_once 'CRM/Utils/Sort.php';
     usort($dashboardElements, array('CRM_Utils_Sort', 'cmpFunc'));
     $this->assign('dashboardElements', $dashboardElements);
     if ($this->_userOptions['Groups']) {
         $this->assign('showGroup', true);
         //build group selector
         require_once "CRM/Contact/Page/View/UserDashBoard/GroupContact.php";
         $gContact = new CRM_Contact_Page_View_UserDashBoard_GroupContact();
         $gContact->run();
     } else {
         $this->assign('showGroup', false);
     }
 }
 /**
  * Function to build user dashboard
  *
  * @return void
  * @access public
  */
 function buildUserDashBoard()
 {
     //build component selectors
     $dashboardElements = array();
     $config = CRM_Core_Config::singleton();
     $this->_userOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'user_dashboard_options');
     $components = CRM_Core_Component::getEnabledComponents();
     $this->assign('contactId', $this->_contactId);
     foreach ($components as $name => $component) {
         $elem = $component->getUserDashboardElement();
         if (!$elem) {
             continue;
         }
         if (!empty($this->_userOptions[$name]) && (CRM_Core_Permission::access($component->name) || CRM_Core_Permission::check($elem['perm'][0]))) {
             $userDashboard = $component->getUserDashboardObject();
             $dashboardElements[] = array('class' => 'crm-dashboard-' . strtolower($component->name), 'sectionTitle' => $elem['title'], 'templatePath' => $userDashboard->getTemplateFileName(), 'weight' => $elem['weight']);
             $userDashboard->run();
         }
     }
     if (!empty($this->_userOptions['Permissioned Orgs'])) {
         $dashboardElements[] = array('class' => 'crm-dashboard-permissionedOrgs', 'templatePath' => 'CRM/Contact/Page/View/RelationshipSelector.tpl', 'sectionTitle' => ts('Your Contacts / Organizations'), 'weight' => 40);
     }
     if (!empty($this->_userOptions['PCP'])) {
         $dashboardElements[] = array('class' => 'crm-dashboard-pcp', 'templatePath' => 'CRM/Contribute/Page/PcpUserDashboard.tpl', 'sectionTitle' => ts('Personal Campaign Pages'), 'weight' => 40);
         list($pcpBlock, $pcpInfo) = CRM_PCP_BAO_PCP::getPcpDashboardInfo($this->_contactId);
         $this->assign('pcpBlock', $pcpBlock);
         $this->assign('pcpInfo', $pcpInfo);
     }
     if (!empty($this->_userOptions['Assigned Activities'])) {
         // Assigned Activities section
         $dashboardElements[] = array('class' => 'crm-dashboard-assignedActivities', 'templatePath' => 'CRM/Activity/Page/UserDashboard.tpl', 'sectionTitle' => ts('Your Assigned Activities'), 'weight' => 5);
         $userDashboard = new CRM_Activity_Page_UserDashboard();
         $userDashboard->run();
     }
     usort($dashboardElements, array('CRM_Utils_Sort', 'cmpFunc'));
     $this->assign('dashboardElements', $dashboardElements);
     if (!empty($this->_userOptions['Groups'])) {
         $this->assign('showGroup', TRUE);
         //build group selector
         $gContact = new CRM_Contact_Page_View_UserDashBoard_GroupContact();
         $gContact->run();
     } else {
         $this->assign('showGroup', FALSE);
     }
 }