Exemplo n.º 1
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  * @access public
  *
  */
 function run()
 {
     // get the callback, module and activity id
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $dao = new CRM_Core_DAO_ActivityHistory();
     $dao->activity_id = $id;
     $dao->activity_type = ts('SMS Sent');
     if ($dao->find(TRUE)) {
         $cid = $dao->entity_id;
     }
     $dao = new CRM_SMS_DAO_History();
     $dao->id = $id;
     if ($dao->find(TRUE)) {
         $this->assign('fromName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $dao->contact_id, 'display_name'));
         $this->assign('toName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name'));
         $this->assign('sentDate', $dao->sent_date);
         $this->assign('message', $dao->message);
         // get the display name and images for the contact
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($dao->contact_id);
         CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
         // also add the cid params to the Menu array
         CRM_Core_Menu::addParam('cid', $cid);
     }
     return parent::run();
 }
Exemplo n.º 2
0
 /**
  * Display an introductory screen with any pre-upgrade messages
  */
 public function runIntro()
 {
     $upgrade = new CRM_Upgrade_Form();
     $template = CRM_Core_Smarty::singleton();
     list($currentVer, $latestVer) = $upgrade->getUpgradeVersions();
     if ($error = $upgrade->checkUpgradeableVersion($currentVer, $latestVer)) {
         CRM_Core_Error::fatal($error);
     }
     $config = CRM_Core_Config::singleton();
     // All cached content needs to be cleared because the civi codebase was just replaced
     CRM_Core_Resources::singleton()->flushStrings()->resetCacheCode();
     CRM_Core_Menu::store();
     // cleanup only the templates_c directory
     $config->cleanup(1, FALSE);
     $preUpgradeMessage = NULL;
     $upgrade->setPreUpgradeMessage($preUpgradeMessage, $currentVer, $latestVer);
     $template->assign('currentVersion', $currentVer);
     $template->assign('newVersion', $latestVer);
     $template->assign('upgradeTitle', ts('Upgrade CiviCRM from v %1 To v %2', array(1 => $currentVer, 2 => $latestVer)));
     $template->assign('upgraded', FALSE);
     // Render page header
     if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) {
         CRM_Utils_System::addHTMLHead($region->render(''));
     }
     $template->assign('preUpgradeMessage', $preUpgradeMessage);
     $content = $template->fetch('CRM/common/success.tpl');
     echo CRM_Utils_System::theme($content, $this->_print, TRUE);
 }
Exemplo n.º 3
0
function civicrm_main()
{
    global $civicrmUpgrade, $adminPath;
    civicrm_setup();
    // setup vars
    $configFile = $adminPath . DIRECTORY_SEPARATOR . 'civicrm.settings.php';
    // generate backend config file
    $string = "\n<?php\nrequire_once '{$configFile}';\n";
    $string = trim($string);
    civicrm_write_file($adminPath . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'civicrm.config.php', $string);
    // generate backend settings file
    $string = civicrm_config(false);
    civicrm_write_file($configFile, $string);
    // generate frontend settings file
    $string = civicrm_config(true);
    civicrm_write_file(JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_civicrm' . DIRECTORY_SEPARATOR . 'civicrm.settings.php', $string);
    include_once $configFile;
    // for install case only
    if (!$civicrmUpgrade) {
        $sqlPath = $adminPath . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'sql';
        civicrm_source($sqlPath . DIRECTORY_SEPARATOR . 'civicrm.mysql');
        civicrm_source($sqlPath . DIRECTORY_SEPARATOR . 'civicrm_data.mysql');
        civicrm_source($sqlPath . DIRECTORY_SEPARATOR . 'civicrm_sample_report.mysql', true);
        require_once 'CRM/Core/Config.php';
        $config =& CRM_Core_Config::singleton();
        // now also build the menu
        require_once 'CRM/Core/Menu.php';
        CRM_Core_Menu::store();
    }
}
Exemplo n.º 4
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false);
     if ($cid) {
         // not sure why this is needed :(
         // also add the cid params to the Menu array
         CRM_Core_Menu::addParam('cid', $cid);
         // create menus ..
         $startWeight = CRM_Core_Menu::getMaxWeight('civicrm/contact/view');
         $startWeight++;
         CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight);
         $this->_contactIds = array($cid);
         $this->_single = true;
         $smsNumbers = CRM_Contact_BAO_Contact::allPhones($cid, 'Mobile');
         $this->_emails = array();
         $toName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name');
         foreach ($smsNumbers as $number => $item) {
             $this->_smsNumbers[$number] = '"' . $toName . '" <' . $number . '> ' . $item['locationType'];
             if ($item['is_primary']) {
                 $this->_smsNumbers[$number] .= ' ' . ts('(preferred)');
             }
             $this->_smsNumbers[$number] = htmlspecialchars($this->_emails[$email]);
         }
     } else {
         parent::preProcess();
     }
     $this->assign('single', $this->_single);
 }
Exemplo n.º 5
0
 /**
  * @return string
  */
 function run()
 {
     $errorMessage = '';
     // ensure that all CiviCRM tables are InnoDB, else abort
     // this is not a very fast operation, so we do it randomly 10% of the times
     // but we do it for most / all tables
     // http://bugs.mysql.com/bug.php?id=43664
     if (rand(1, 10) == 3 && CRM_Core_DAO::isDBMyISAM(150)) {
         $errorMessage = ts('Your database is configured to use the MyISAM database engine. CiviCRM requires InnoDB. You will need to convert any MyISAM tables in your database to InnoDB. Using MyISAM tables will result in data integrity issues.');
         CRM_Core_Session::setStatus($errorMessage, ts('Warning'), "alert");
     }
     if (!CRM_Utils_System::isDBVersionValid($errorMessage)) {
         CRM_Core_Session::setStatus($errorMessage, ts('Warning'), "alert", array('expires' => 0));
     }
     $groups = array('Customize Data and Screens' => ts('Customize Data and Screens'), 'Communications' => ts('Communications'), 'Localization' => ts('Localization'), 'Users and Permissions' => ts('Users and Permissions'), 'System Settings' => ts('System Settings'));
     $config = CRM_Core_Config::singleton();
     if (in_array('CiviContribute', $config->enableComponents)) {
         $groups['CiviContribute'] = ts('CiviContribute');
     }
     if (in_array('CiviMember', $config->enableComponents)) {
         $groups['CiviMember'] = ts('CiviMember');
     }
     if (in_array('CiviEvent', $config->enableComponents)) {
         $groups['CiviEvent'] = ts('CiviEvent');
     }
     if (in_array('CiviMail', $config->enableComponents)) {
         $groups['CiviMail'] = ts('CiviMail');
     }
     if (in_array('CiviCase', $config->enableComponents)) {
         $groups['CiviCase'] = ts('CiviCase');
     }
     if (in_array('CiviReport', $config->enableComponents)) {
         $groups['CiviReport'] = ts('CiviReport');
     }
     if (in_array('CiviCampaign', $config->enableComponents)) {
         $groups['CiviCampaign'] = ts('CiviCampaign');
     }
     $values = CRM_Core_Menu::getAdminLinks();
     $this->_showHide = new CRM_Core_ShowHideBlocks();
     foreach ($groups as $group => $title) {
         $groupId = str_replace(' ', '_', $group);
         $this->_showHide->addShow("id_{$groupId}_show");
         $this->_showHide->addHide("id_{$groupId}");
         $v = CRM_Core_ShowHideBlocks::links($this, $groupId, '', '', FALSE);
         if (isset($values[$group])) {
             $adminPanel[$groupId] = $values[$group];
             $adminPanel[$groupId]['show'] = $v['show'];
             $adminPanel[$groupId]['hide'] = $v['hide'];
             $adminPanel[$groupId]['title'] = $title;
         } else {
             $adminPanel[$groupId] = array();
             $adminPanel[$groupId]['show'] = '';
             $adminPanel[$groupId]['hide'] = '';
             $adminPanel[$groupId]['title'] = $title;
         }
     }
     $this->assign('adminPanel', $adminPanel);
     $this->_showHide->addToTemplate();
     return parent::run();
 }
Exemplo n.º 6
0
 /**
  * Note: Expected URL is htmlized because that's what CRM_Utils_System::url()
  * and CRM_Utils_System::redirect() work with.
  *
  * @param string $requestPath
  *   Eg "civicrm/requested/path".
  * @param string $requestArgs
  *   Eg "foo=bar&whiz=bang".
  * @param string $pageArgs
  *   Eg "url=civicrm/foo/bar?whiz=bang".
  * @param string $expectedUrl
  *   Eg "/index.php?q=civicrm/foo/bar&whiz=bang".
  * @dataProvider examples
  */
 public function testCreateUrl($requestPath, $requestArgs, $pageArgs, $expectedUrl)
 {
     $parsedRequestPath = explode('/', $requestPath);
     parse_str($requestArgs, $parsedRequestArgs);
     $parsedPageArgs = CRM_Core_Menu::getArrayForPathArgs($pageArgs);
     $actualUrl = CRM_Core_Page_Redirect::createUrl($parsedRequestPath, $parsedRequestArgs, $parsedPageArgs, FALSE);
     $this->assertEquals($expectedUrl, $actualUrl);
 }
Exemplo n.º 7
0
 function run()
 {
     // ensure that all CiviCRM tables are InnoDB, else abort
     if (CRM_Core_DAO::isDBMyISAM()) {
         $errorMessage = 'Your database is configured to use the MyISAM database engine. CiviCRM  requires InnoDB. You will need to convert any MyISAM tables in your database to InnoDB. Using MyISAM tables will result in data integrity issues. This will be a fatal error in CiviCRM v2.1.';
         require_once 'CRM/Core/Session.php';
         CRM_Core_Session::setStatus($errorMessage);
     }
     if (!CRM_Utils_System::isDBVersionValid($errorMessage)) {
         CRM_Core_Session::setStatus($errorMessage);
     }
     $groups = array('Customize' => ts('Customize'), 'Configure' => ts('Configure'), 'Manage' => ts('Manage'), 'Option Lists' => ts('Option Lists'));
     $config = CRM_Core_Config::singleton();
     if (in_array("CiviContribute", $config->enableComponents)) {
         $groups['CiviContribute'] = ts('CiviContribute');
     }
     if (in_array("CiviMember", $config->enableComponents)) {
         $groups['CiviMember'] = ts('CiviMember');
     }
     if (in_array("CiviEvent", $config->enableComponents)) {
         $groups['CiviEvent'] = ts('CiviEvent');
     }
     if (in_array("CiviMail", $config->enableComponents)) {
         $groups['CiviMail'] = ts('CiviMail');
     }
     if (in_array("CiviCase", $config->enableComponents)) {
         $groups['CiviCase'] = ts('CiviCase');
     }
     if (in_array("CiviReport", $config->enableComponents)) {
         $groups['CiviReport'] = ts('CiviReport');
     }
     if (in_array("CiviCampaign", $config->enableComponents)) {
         $groups['CiviCampaign'] = ts('CiviCampaign');
     }
     require_once 'CRM/Core/Menu.php';
     $values =& CRM_Core_Menu::getAdminLinks();
     require_once 'CRM/Core/ShowHideBlocks.php';
     $this->_showHide = new CRM_Core_ShowHideBlocks();
     foreach ($groups as $group => $title) {
         $this->_showHide->addShow("id_{$group}_show");
         $this->_showHide->addHide("id_{$group}");
         $v = CRM_Core_ShowHideBlocks::links($this, $group, '', '', false);
         $adminPanel[$group] = $values[$group];
         $adminPanel[$group]['show'] = $v['show'];
         $adminPanel[$group]['hide'] = $v['hide'];
         $adminPanel[$group]['title'] = $title;
     }
     require_once 'CRM/Utils/VersionCheck.php';
     $versionCheck =& CRM_Utils_VersionCheck::singleton();
     $this->assign('newVersion', $versionCheck->newerVersion());
     $this->assign('localVersion', $versionCheck->localVersion);
     $this->assign('adminPanel', $adminPanel);
     $this->_showHide->addToTemplate();
     return parent::run();
 }
Exemplo n.º 8
0
 /**
  * Run page.
  *
  * @return string
  */
 public function run()
 {
     Civi::resources()->addStyleFile('civicrm', 'css/admin.css');
     $this->assign('registerSite', htmlspecialchars('https://civicrm.org/register-your-site?src=iam&sid=' . CRM_Utils_System::getSiteID()));
     $groups = array('Customize Data and Screens' => ts('Customize Data and Screens'), 'Communications' => ts('Communications'), 'Localization' => ts('Localization'), 'Users and Permissions' => ts('Users and Permissions'), 'System Settings' => ts('System Settings'));
     $config = CRM_Core_Config::singleton();
     if (in_array('CiviContribute', $config->enableComponents)) {
         $groups['CiviContribute'] = ts('CiviContribute');
     }
     if (in_array('CiviMember', $config->enableComponents)) {
         $groups['CiviMember'] = ts('CiviMember');
     }
     if (in_array('CiviEvent', $config->enableComponents)) {
         $groups['CiviEvent'] = ts('CiviEvent');
     }
     if (in_array('CiviMail', $config->enableComponents)) {
         $groups['CiviMail'] = ts('CiviMail');
     }
     if (in_array('CiviCase', $config->enableComponents)) {
         $groups['CiviCase'] = ts('CiviCase');
     }
     if (in_array('CiviReport', $config->enableComponents)) {
         $groups['CiviReport'] = ts('CiviReport');
     }
     if (in_array('CiviCampaign', $config->enableComponents)) {
         $groups['CiviCampaign'] = ts('CiviCampaign');
     }
     $values = CRM_Core_Menu::getAdminLinks();
     $this->_showHide = new CRM_Core_ShowHideBlocks();
     foreach ($groups as $group => $title) {
         $groupId = str_replace(' ', '_', $group);
         $this->_showHide->addShow("id_{$groupId}_show");
         $this->_showHide->addHide("id_{$groupId}");
         $v = CRM_Core_ShowHideBlocks::links($this, $groupId, '', '', FALSE);
         if (isset($values[$group])) {
             $adminPanel[$groupId] = $values[$group];
             $adminPanel[$groupId]['show'] = $v['show'];
             $adminPanel[$groupId]['hide'] = $v['hide'];
             $adminPanel[$groupId]['title'] = $title;
         } else {
             $adminPanel[$groupId] = array();
             $adminPanel[$groupId]['show'] = '';
             $adminPanel[$groupId]['hide'] = '';
             $adminPanel[$groupId]['title'] = $title;
         }
     }
     $this->assign('adminPanel', $adminPanel);
     $this->_showHide->addToTemplate();
     return parent::run();
 }
Exemplo n.º 9
0
 /**
  * @return string
  */
 public function run()
 {
     $groups = array('Customize Data and Screens' => ts('Customize Data and Screens'), 'Communications' => ts('Communications'), 'Localization' => ts('Localization'), 'Users and Permissions' => ts('Users and Permissions'), 'System Settings' => ts('System Settings'));
     $config = CRM_Core_Config::singleton();
     if (in_array('CiviContribute', $config->enableComponents)) {
         $groups['CiviContribute'] = ts('CiviContribute');
     }
     if (in_array('CiviMember', $config->enableComponents)) {
         $groups['CiviMember'] = ts('CiviMember');
     }
     if (in_array('CiviEvent', $config->enableComponents)) {
         $groups['CiviEvent'] = ts('CiviEvent');
     }
     if (in_array('CiviMail', $config->enableComponents)) {
         $groups['CiviMail'] = ts('CiviMail');
     }
     if (in_array('CiviCase', $config->enableComponents)) {
         $groups['CiviCase'] = ts('CiviCase');
     }
     if (in_array('CiviReport', $config->enableComponents)) {
         $groups['CiviReport'] = ts('CiviReport');
     }
     if (in_array('CiviCampaign', $config->enableComponents)) {
         $groups['CiviCampaign'] = ts('CiviCampaign');
     }
     $values = CRM_Core_Menu::getAdminLinks();
     $this->_showHide = new CRM_Core_ShowHideBlocks();
     foreach ($groups as $group => $title) {
         $groupId = str_replace(' ', '_', $group);
         $this->_showHide->addShow("id_{$groupId}_show");
         $this->_showHide->addHide("id_{$groupId}");
         $v = CRM_Core_ShowHideBlocks::links($this, $groupId, '', '', FALSE);
         if (isset($values[$group])) {
             $adminPanel[$groupId] = $values[$group];
             $adminPanel[$groupId]['show'] = $v['show'];
             $adminPanel[$groupId]['hide'] = $v['hide'];
             $adminPanel[$groupId]['title'] = $title;
         } else {
             $adminPanel[$groupId] = array();
             $adminPanel[$groupId]['show'] = '';
             $adminPanel[$groupId]['hide'] = '';
             $adminPanel[$groupId]['title'] = $title;
         }
     }
     $this->assign('adminPanel', $adminPanel);
     $this->_showHide->addToTemplate();
     return parent::run();
 }
Exemplo n.º 10
0
 public function rebuildMenu()
 {
     // ensure config is set with new values
     $config =& CRM_Core_Config::singleton(true, true);
     // rebuild menu items
     require_once 'CRM/Core/Menu.php';
     CRM_Core_Menu::store();
     // also delete the IDS file so we can write a new correct one on next load
     $configFile = $config->uploadDir . 'Config.IDS.ini';
     @unlink($configFile);
 }
Exemplo n.º 11
0
 public function rebuildMenu()
 {
     // ensure config is set with new values
     $config = CRM_Core_Config::singleton(TRUE, TRUE);
     // rebuild menu items
     CRM_Core_Menu::store();
     // also delete the IDS file so we can write a new correct one on next load
     $configFile = $config->uploadDir . 'Config.IDS.ini';
     @unlink($configFile);
 }
Exemplo n.º 12
0
 /**
  * Create the list of shortcuts for the application and format is as a block.
  *
  * @return void
  */
 private static function setTemplateMenuValues()
 {
     $config = CRM_Core_Config::singleton();
     $path = 'navigation';
     $values = CRM_Core_Menu::getNavigation();
     if ($values) {
         self::setProperty(self::MENU, 'templateValues', array('menu' => $values));
     }
 }
Exemplo n.º 13
0
 /**
  * @param bool $triggerRebuild
  * @param bool $sessionReset
  *
  * @throws Exception
  */
 public static function rebuildMenuAndCaches($triggerRebuild = FALSE, $sessionReset = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     $config->clearModuleList();
     // also cleanup all caches
     $config->cleanupCaches($sessionReset || CRM_Utils_Request::retrieve('sessionReset', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET'));
     CRM_Core_Menu::store();
     // also reset navigation
     CRM_Core_BAO_Navigation::resetNavigation();
     // also cleanup module permissions
     $config->cleanupPermissions();
     // rebuild word replacement cache - pass false to prevent operations redundant with this fn
     CRM_Core_BAO_WordReplacement::rebuild(FALSE);
     Civi::service('settings_manager')->flush();
     // Clear js caches
     CRM_Core_Resources::singleton()->flushStrings()->resetCacheCode();
     CRM_Case_XMLRepository::singleton(TRUE);
     // also rebuild triggers if requested explicitly
     if ($triggerRebuild || CRM_Utils_Request::retrieve('triggerRebuild', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')) {
         CRM_Core_DAO::triggerRebuild();
     }
     CRM_Core_DAO_AllCoreTables::reinitializeCache(TRUE);
     CRM_Core_ManagedEntities::singleton(TRUE)->reconcile();
     //CRM-16257 update Config.IDS.ini might be an old copy
     CRM_Core_IDS::createConfigFile(TRUE);
 }
Exemplo n.º 14
0
 static function get($path)
 {
     // return null if menu rebuild
     $config =& CRM_Core_Config::singleton();
     $params = array();
     $args = explode('/', $path);
     $elements = array();
     while (!empty($args)) {
         $string = implode('/', $args);
         $string = CRM_Core_DAO::escapeString($string);
         $elements[] = "'{$string}'";
         array_pop($args);
     }
     $queryString = implode(', ', $elements);
     $domainID = CRM_Core_Config::domainID();
     $domainWhereClause = " AND domain_id = {$domainID} ";
     if ($path == 'civicrm/upgrade' && !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'domain_id')) {
         //domain_id wouldn't be available for earlier version of
         //3.0 and therefore can't be used as part of query for
         //upgrade case
         $domainWhereClause = "";
     }
     $query = "\n( \n  SELECT * \n  FROM     civicrm_menu \n  WHERE    path in ( {$queryString} )\n           {$domainWhereClause}\n  ORDER BY length(path) DESC\n  LIMIT    1 \n)\n";
     if ($path != 'navigation') {
         $query .= "\nUNION ( \n  SELECT *\n  FROM   civicrm_menu \n  WHERE  path IN ( 'navigation' )\n         {$domainWhereClause}\n)\n";
     }
     require_once "CRM/Core/DAO/Menu.php";
     $menu =& new CRM_Core_DAO_Menu();
     $menu->query($query);
     self::$_menuCache = array();
     $menuPath = null;
     while ($menu->fetch()) {
         self::$_menuCache[$menu->path] = array();
         CRM_Core_DAO::storeValues($menu, self::$_menuCache[$menu->path]);
         foreach (self::$_serializedElements as $element) {
             self::$_menuCache[$menu->path][$element] = unserialize($menu->{$element});
             if (strpos($path, $menu->path) !== false) {
                 $menuPath =& self::$_menuCache[$menu->path];
             }
         }
     }
     // *FIXME* : hack for 2.1 -> 2.2 upgrades.
     if ($path == 'civicrm/upgrade') {
         $menuPath['page_callback'] = 'CRM_Upgrade_Page_Upgrade';
         $menuPath['access_arguments'][0][] = 'administer CiviCRM';
         $menuPath['access_callback'] = array('CRM_Core_Permission', 'checkMenu');
     }
     $i18n =& CRM_Core_I18n::singleton();
     $i18n->localizeTitles($menuPath);
     return $menuPath;
 }
Exemplo n.º 15
0
 static function get($path)
 {
     // return null if menu rebuild
     $config = CRM_Core_Config::singleton();
     $params = array();
     $args = explode('/', $path);
     $elements = array();
     while (!empty($args)) {
         $string = implode('/', $args);
         $string = CRM_Core_DAO::escapeString($string);
         $elements[] = "'{$string}'";
         array_pop($args);
     }
     $queryString = implode(', ', $elements);
     $domainID = CRM_Core_Config::domainID();
     $domainWhereClause = " AND domain_id = {$domainID} ";
     if ($config->isUpgradeMode() && !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'domain_id')) {
         //domain_id wouldn't be available for earlier version of
         //3.0 and therefore can't be used as part of query for
         //upgrade case
         $domainWhereClause = "";
     }
     $query = "\n(\n  SELECT *\n  FROM     civicrm_menu\n  WHERE    path in ( {$queryString} )\n           {$domainWhereClause}\n  ORDER BY length(path) DESC\n  LIMIT    1\n)\n";
     if ($path != 'navigation') {
         $query .= "\nUNION (\n  SELECT *\n  FROM   civicrm_menu\n  WHERE  path IN ( 'navigation' )\n         {$domainWhereClause}\n)\n";
     }
     $menu = new CRM_Core_DAO_Menu();
     $menu->query($query);
     self::$_menuCache = array();
     $menuPath = NULL;
     while ($menu->fetch()) {
         self::$_menuCache[$menu->path] = array();
         CRM_Core_DAO::storeValues($menu, self::$_menuCache[$menu->path]);
         foreach (self::$_serializedElements as $element) {
             self::$_menuCache[$menu->path][$element] = unserialize($menu->{$element});
             if (strpos($path, $menu->path) !== FALSE) {
                 $menuPath =& self::$_menuCache[$menu->path];
             }
         }
     }
     if (strstr($path, 'report/instance')) {
         $args = explode('/', $path);
         if (is_numeric(end($args))) {
             $menuPath['path'] .= '/' . end($args);
         }
     }
     // *FIXME* : hack for 2.1 -> 2.2 upgrades.
     if ($path == 'civicrm/upgrade') {
         $menuPath['page_callback'] = 'CRM_Upgrade_Page_Upgrade';
         $menuPath['access_arguments'][0][] = 'administer CiviCRM';
         $menuPath['access_callback'] = array('CRM_Core_Permission', 'checkMenu');
     }
     // *FIXME* : hack for 4.1 -> 4.2 upgrades.
     if (preg_match('/^civicrm\\/(upgrade\\/)?queue\\//', $path)) {
         CRM_Queue_Menu::alter($path, $menuPath);
     }
     // Part of upgrade framework but not run inside main upgrade because it deletes data
     // Once we have another example of a 'cleanup' we should generalize the clause below so it grabs string
     // which follows upgrade/ and checks for existence of a function in Cleanup class.
     if ($path == 'civicrm/upgrade/cleanup425') {
         $menuPath['page_callback'] = array('CRM_Upgrade_Page_Cleanup', 'cleanup425');
         $menuPath['access_arguments'][0][] = 'administer CiviCRM';
         $menuPath['access_callback'] = array('CRM_Core_Permission', 'checkMenu');
     }
     if (!empty($menuPath)) {
         $i18n = CRM_Core_I18n::singleton();
         $i18n->localizeTitles($menuPath);
     }
     return $menuPath;
 }
function civicrm_main()
{
    global $civicrmUpgrade, $adminPath;
    civicrm_setup();
    // setup vars
    $configFile = $adminPath . DIRECTORY_SEPARATOR . 'civicrm.settings.php';
    // generate backend config file
    $string = "\n<?php\ndefine('CIVICRM_SETTINGS_PATH', '{$configFile}');\n\$error = @include_once( '{$configFile}' );\nif ( \$error == false ) {\n    echo \"Could not load the settings file at: {$configFile}\n\";\n    exit( );\n}\n\n// Load class loader\nrequire_once \$civicrm_root . '/CRM/Core/ClassLoader.php';\nCRM_Core_ClassLoader::singleton()->register();\n";
    $string = trim($string);
    civicrm_write_file($adminPath . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'civicrm.config.php', $string);
    $liveSite = substr_replace(JURI::root(), '', -1, 1);
    $siteKey = md5(uniqid('', true) . $liveSite);
    // generate backend settings file
    $string = civicrm_config(FALSE, $siteKey);
    civicrm_write_file($configFile, $string);
    // generate frontend settings file
    $string = civicrm_config(TRUE, $siteKey);
    civicrm_write_file(JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_civicrm' . DIRECTORY_SEPARATOR . 'civicrm.settings.php', $string);
    define('CIVICRM_SETTINGS_PATH', $configFile);
    include_once CIVICRM_SETTINGS_PATH;
    // for install case only
    if (!$civicrmUpgrade) {
        $sqlPath = $adminPath . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'sql';
        civicrm_source($sqlPath . DIRECTORY_SEPARATOR . 'civicrm.mysql');
        civicrm_source($sqlPath . DIRECTORY_SEPARATOR . 'civicrm_data.mysql');
        require_once 'CRM/Core/ClassLoader.php';
        CRM_Core_ClassLoader::singleton()->register();
        require_once 'CRM/Core/Config.php';
        $config = CRM_Core_Config::singleton();
        // now also build the menu
        require_once 'CRM/Core/Menu.php';
        CRM_Core_Menu::store();
    }
}
Exemplo n.º 17
0
 static function rebuildMenuAndCaches($triggerRebuild = FALSE, $sessionReset = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     $config->clearModuleList();
     CRM_Core_Menu::store();
     // also reset navigation
     CRM_Core_BAO_Navigation::resetNavigation();
     // also cleanup all caches
     $config->cleanupCaches($sessionReset || CRM_Utils_Request::retrieve('sessionReset', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET'));
     // also rebuild triggers if requested explicitly
     if ($triggerRebuild || CRM_Utils_Request::retrieve('triggerRebuild', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')) {
         CRM_Core_DAO::triggerRebuild();
     }
     CRM_Core_ManagedEntities::singleton(TRUE)->reconcile();
 }
Exemplo n.º 18
0
 /**
  * This is the main function that is called on every click action and based on the argument
  * respective functions are called
  *
  * @param $args array this array contains the arguments of the url 
  * 
  * @static
  * @access public
  */
 static function invoke($args)
 {
     require_once 'CRM/Core/I18n.php';
     require_once 'CRM/Utils/Wrapper.php';
     require_once 'CRM/Core/Action.php';
     require_once 'CRM/Utils/Request.php';
     require_once 'CRM/Core/Menu.php';
     require_once 'CRM/Core/Component.php';
     require_once 'CRM/Core/Permission.php';
     if ($args[0] !== 'civicrm') {
         return;
     }
     if (isset($args[1]) and $args[1] == 'menu' and isset($args[2]) and $args[2] == 'rebuild') {
         CRM_Core_Menu::store();
         CRM_Core_Session::setStatus(ts('Menu has been rebuilt'));
         // also reset navigation
         require_once 'CRM/Core/BAO/Navigation.php';
         CRM_Core_BAO_Navigation::resetNavigation();
         return CRM_Utils_System::redirect();
     }
     // first fire up IDS and check for bad stuff
     require_once 'CRM/Core/IDS.php';
     $ids = new CRM_Core_IDS();
     $ids->check($args);
     $config =& CRM_Core_Config::singleton();
     // also initialize the i18n framework
     $i18n =& CRM_Core_I18n::singleton();
     if ($config->userFramework == 'Standalone') {
         require_once 'CRM/Core/Session.php';
         $session =& CRM_Core_Session::singleton();
         if ($session->get('new_install') !== true) {
             require_once 'CRM/Core/Standalone.php';
             CRM_Core_Standalone::sidebarLeft();
         } else {
             if ($args[1] == 'standalone' && $args[2] == 'register') {
                 CRM_Core_Menu::store();
             }
         }
     }
     // get the menu items
     $path = implode('/', $args);
     $item =& CRM_Core_Menu::get($path);
     // we should try to compute menus, if item is empty and stay on the same page,
     // rather than compute and redirect to dashboard.
     if (!$item) {
         CRM_Core_Menu::store(false);
         $item =& CRM_Core_Menu::get($path);
     }
     if ($config->userFramework == 'Joomla' && $item) {
         $config->userFrameworkURLVar = 'task';
         require_once 'CRM/Core/Joomla.php';
         // joomla 1.5RC1 seems to push this in the POST variable, which messes
         // QF and checkboxes
         unset($_POST['option']);
         CRM_Core_Joomla::sidebarLeft();
     }
     // set active Component
     $template =& CRM_Core_Smarty::singleton();
     $template->assign('activeComponent', 'CiviCRM');
     $template->assign('formTpl', 'default');
     if ($item) {
         if (!array_key_exists('page_callback', $item)) {
             CRM_Core_Error::debug('Bad item', $item);
             CRM_Core_Error::fatal(ts('Bad menu record in database'));
         }
         // check that we are permissioned to access this page
         if (!CRM_Core_Permission::checkMenuItem($item)) {
             CRM_Utils_System::permissionDenied();
             return;
         }
         // check if ssl is set
         if (CRM_Utils_Array::value('is_ssl', $item)) {
             CRM_Utils_System::redirectToSSL();
         }
         if (isset($item['title'])) {
             CRM_Utils_System::setTitle($item['title']);
         }
         if (isset($item['breadcrumb']) && !isset($item['is_public'])) {
             CRM_Utils_System::appendBreadCrumb($item['breadcrumb']);
         }
         $pageArgs = null;
         if (CRM_Utils_Array::value('page_arguments', $item)) {
             $pageArgs = CRM_Core_Menu::getArrayForPathArgs($item['page_arguments']);
         }
         $template =& CRM_Core_Smarty::singleton();
         if (isset($item['is_public']) && $item['is_public']) {
             $template->assign('urlIsPublic', true);
         } else {
             $template->assign('urlIsPublic', false);
         }
         if (isset($item['return_url'])) {
             $session =& CRM_Core_Session::singleton();
             $args = CRM_Utils_Array::value('return_url_args', $item, 'reset=1');
             $session->pushUserContext(CRM_Utils_System::url($item['return_url'], $args));
         }
         if (is_array($item['page_callback'])) {
             $newArgs = explode('/', $_GET[$config->userFrameworkURLVar]);
             require_once str_replace('_', DIRECTORY_SEPARATOR, $item['page_callback'][0]) . '.php';
             return call_user_func($item['page_callback'], $newArgs);
         } else {
             if (strstr($item['page_callback'], '_Form')) {
                 $wrapper =& new CRM_Utils_Wrapper();
                 return $wrapper->run(CRM_Utils_Array::value('page_callback', $item), CRM_Utils_Array::value('title', $item), isset($pageArgs) ? $pageArgs : null);
             } else {
                 $newArgs = explode('/', $_GET[$config->userFrameworkURLVar]);
                 require_once str_replace('_', DIRECTORY_SEPARATOR, $item['page_callback']) . '.php';
                 $mode = 'null';
                 if (isset($pageArgs['mode'])) {
                     $mode = $pageArgs['mode'];
                     unset($pageArgs['mode']);
                 }
                 $title = CRM_Utils_Array::value('title', $item);
                 if (strstr($item['page_callback'], '_Page')) {
                     eval('$object =& ' . "new {$item['page_callback']}( \$title, \$mode );");
                 } else {
                     if (strstr($item['page_callback'], '_Controller')) {
                         $addSequence = 'false';
                         if (isset($pageArgs['addSequence'])) {
                             $addSequence = $pageArgs['addSequence'];
                             $addSequence = $addSequence ? 'true' : 'false';
                             unset($pageArgs['addSequence']);
                         }
                         eval('$object =& ' . "new {$item['page_callback']} ( \$title, true, \$mode, null, \$addSequence );");
                     } else {
                         CRM_Core_Error::fatal();
                     }
                 }
                 return $object->run($newArgs, $pageArgs);
             }
         }
     }
     CRM_Core_Menu::store();
     CRM_Core_Session::setStatus(ts('Menu has been rebuilt'));
     return CRM_Utils_System::redirect();
 }
Exemplo n.º 19
0
 /**
  * @param $inputString
  * @param $expectedArray
  * @dataProvider pathArguments
  */
 function testGetArrayForPathArgs($inputString, $expectedArray)
 {
     $actual = CRM_Core_Menu::getArrayForPathArgs($inputString);
     $this->assertEquals($expectedArray, $actual);
 }
Exemplo n.º 20
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  * @access public
  *
  */
 function run()
 {
     // get the callback, module and activity id
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'browse');
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $dao =& new CRM_Core_DAO_ActivityHistory();
     $dao->activity_id = $id;
     $dao->activity_type = ts('Email Sent');
     if ($dao->find(true)) {
         $cid = $dao->entity_id;
     }
     $dao =& new CRM_Core_DAO_EmailHistory();
     $dao->id = $id;
     if ($dao->find(true)) {
         // get the display name and email for the contact
         list($toContactName, $toContactEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($cid);
         if (!trim($toContactName)) {
             $toContactName = $toContactEmail;
         }
         if (trim($toContactEmail)) {
             $toContactName = "\"{$toContactName}\" <{$toContactEmail}>";
         }
         $this->assign('toName', $toContactName);
         // get the display name and email for the contact
         list($fromContactName, $fromContactEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($dao->contact_id);
         if (!trim($fromContactEmail)) {
             CRM_Core_Error::statusBounce(ts('Your user record does not have a valid email address'));
         }
         if (!trim($fromContactName)) {
             $fromContactName = $fromContactEmail;
         }
         $this->assign('fromName', "\"{$fromContactName}\" <{$fromContactEmail}>");
         $this->assign('sentDate', $dao->sent_date);
         $this->assign('subject', $dao->subject);
         $this->assign('message', $dao->message);
         // get the display name and images for the contact
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($dao->contact_id);
         CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
         require_once 'CRM/Core/Menu.php';
         // also add the cid params to the Menu array
         CRM_Core_Menu::addParam('cid', $cid);
     }
     parent::run();
 }
Exemplo n.º 21
0
 static function rebuildMenuAndCaches($triggerRebuild = FALSE, $sessionReset = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     $config->clearModuleList();
     // also cleanup all caches
     $config->cleanupCaches($sessionReset || CRM_Utils_Request::retrieve('sessionReset', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET'));
     CRM_Core_Menu::store();
     // also reset navigation
     CRM_Core_BAO_Navigation::resetNavigation();
     // also cleanup module permissions
     $config->cleanupPermissions();
     // also rebuild word replacement cache
     CRM_Core_BAO_WordReplacement::rebuild();
     CRM_Core_BAO_Setting::updateSettingsFromMetaData();
     CRM_Core_Resources::singleton()->resetCacheCode();
     // also rebuild triggers if requested explicitly
     if ($triggerRebuild || CRM_Utils_Request::retrieve('triggerRebuild', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')) {
         CRM_Core_DAO::triggerRebuild();
     }
     CRM_Core_DAO_AllCoreTables::reinitializeCache(TRUE);
     CRM_Core_ManagedEntities::singleton(TRUE)->reconcile();
 }
Exemplo n.º 22
0
 /**
  * Example: Run an external SQL script
  *
  * @return TRUE on success
  * @throws Exception
  */
 public function upgrade_4204()
 {
     $this->ctx->log->info('Applying update 4204');
     // this path is relative to the extension base dir
     $this->executeSqlFile('sql/upgrade_4204.sql');
     // rebuild menu items
     CRM_Core_Menu::store();
     $params = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend');
     if ($params['outBound_option'] == 0 && CRM_Utils_Array::value('smtpServer', $params) == 'smtp.mandrillapp.com') {
         unset($params['qfKey'], $params['entryURL'], $params['sendmail_path'], $params['sendmail_args'], $params['outBound_option']);
         $params['is_active'] = 1;
         CRM_Core_BAO_Setting::setItem($params, CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mandrill_smtp_settings');
     }
     return TRUE;
 }