function civicrm_invoke() { civicrm_init(); plugin_init(); $user = JFactory::getUser(); /* bypass synchronize if running upgrade * to avoid any serious non-recoverable error * which might hinder the upgrade process. */ require_once 'CRM/Utils/Array.php'; if (CRM_Utils_Array::value('task', $_REQUEST) != 'civicrm/upgrade') { require_once 'CRM/Core/BAO/UFMatch.php'; CRM_Core_BAO_UFMatch::synchronize($user, FALSE, 'Joomla', 'Individual', TRUE); } require_once 'CRM/Utils/System/Joomla.php'; CRM_Utils_System_Joomla::addHTMLHead(NULL, TRUE); if (isset($_GET['task'])) { $args = explode('/', trim($_GET['task'])); } else { $_GET['task'] = 'civicrm/dashboard'; $_GET['reset'] = 1; $args = array('civicrm', 'dashboard'); } CRM_Core_Invoke::invoke($args); }
function civicrm_invoke() { civicrm_init(); global $my; require_once 'CRM/Core/BAO/UFMatch.php'; CRM_Core_BAO_UFMatch::synchronize($my, false, 'Mambo'); $args = explode('/', trim($_GET['task'])); CRM_Core_Invoke::invoke($args); }
function civicrm_invoke() { civicrm_init(); plugin_init(); $user = JFactory::getUser(); require_once 'CRM/Core/BAO/UFMatch.php'; CRM_Core_BAO_UFMatch::synchronize($user, false, 'Joomla', 'Individual'); if (isset($_GET['task'])) { $args = explode('/', trim($_GET['task'])); CRM_Core_Invoke::invoke($args); } else { $_GET['task'] = 'civicrm/dashboard'; $_GET['reset'] = 1; $args = array('civicrm', 'dashboard'); CRM_Core_Invoke::invoke($args); } }
function civicrm_invoke() { civicrm_init(); // check and ensure that we have a valid session if (!empty($_POST)) { // the session should not be empty // however for standalone forms, it will not have any CiviCRM variables in the // session either, so dont check for it if (count($_SESSION) <= 1) { require_once 'CRM/Utils/System.php'; $config =& CRM_Core_Config::singleton(); CRM_Utils_System::redirect($config->userFrameworkBaseURL); } } // add all the values from the itemId param // overrride the GET values if conflict if (CRM_Utils_Array::value('Itemid', $_GET)) { $component =& JComponentHelper::getComponent('com_civicrm'); $menu =& JSite::getMenu(); $item = $menu->getItems('componentid', $component->id, true); $params = $menu->getParams($_GET['Itemid']); $args = array('task', 'id', 'gid', 'reset', 'pageId', 'action'); foreach ($args as $a) { $val = $params->get($a, null); if ($val !== null) { $_GET[$a] = $val; } } } $task = CRM_Utils_Array::value('task', $_GET, ''); $args = explode('/', trim($task)); // check permission if (!civicrm_check_permission($args)) { echo "You do not have permission to execute this url."; return; } require_once 'CRM/Utils/System/Joomla.php'; CRM_Utils_System_Joomla::addHTMLHead(null, true); $user = JFactory::getUser(); require_once 'CRM/Core/BAO/UFMatch.php'; CRM_Core_BAO_UFMatch::synchronize($user, false, 'Joomla', 'Individual'); CRM_Core_Invoke::invoke($args); }
function civicrm_invoke() { civicrm_init(); // check and ensure that we have a valid session if (!empty($_POST)) { // the session should not be empty // however for standalone forms, it will not have any CiviCRM variables in the // session either, so dont check for it if (count($_SESSION) <= 1) { require_once 'CRM/Utils/System.php'; $config = CRM_Core_Config::singleton(); CRM_Utils_System::redirect($config->userFrameworkBaseURL); } } // add all the values from the itemId param // overrride the GET values if conflict if (CRM_Utils_Array::value('Itemid', $_GET)) { $component = JComponentHelper::getComponent('com_civicrm'); $menu = JSite::getMenu(); $params = $menu->getParams($_GET['Itemid']); $args = array('task', 'id', 'gid', 'pageId', 'action', 'csid'); $view = CRM_Utils_Array::value('view', $_GET); if ($view) { $args[] = 'reset'; } foreach ($args as $a) { $val = $params->get($a, NULL); if ($val !== NULL && $view) { $_GET[$a] = $val; } } } $task = CRM_Utils_Array::value('task', $_GET, ''); $args = explode('/', trim($task)); require_once 'CRM/Utils/System/Joomla.php'; CRM_Utils_System_Joomla::addHTMLHead(NULL, TRUE); $user = JFactory::getUser(); require_once 'CRM/Core/BAO/UFMatch.php'; CRM_Core_BAO_UFMatch::synchronize($user, FALSE, 'Joomla', 'Individual', TRUE); CRM_Core_Invoke::invoke($args); }
static function getUserID($user) { //FIXME: look here a bit closer when testing UFMatch require_once 'CRM/Core/BAO/UFMatch.php'; // this puts the appropriate values in the session, so // no need to return anything CRM_Core_BAO_UFMatch::synchronize($user, true, 'Standalone', 'Individual'); }
/** * @param $user */ public function getUserID($user) { //FIXME: look here a bit closer when testing UFMatch // this puts the appropriate values in the session, so // no need to return anything CRM_Core_BAO_UFMatch::synchronize($user, TRUE, 'Standalone', 'Individual'); }
/** * @description: keep WordPress user synced with CiviCRM Contact * Callback function for 'user_register' hook * Callback function for 'profile_update' hook * * CMW: seems to (wrongly) create new CiviCRM Contact every time a user changes their * first_name or last_name attributes in WordPress. */ public function update_user($userID) { $user = get_userdata($userID); if ($user) { if (!$this->initialize()) { return; } require_once 'CRM/Core/BAO/UFMatch.php'; // this does not return anything, so if we want to do anything further // to the CiviCRM Contact, we have to search for it all over again... CRM_Core_BAO_UFMatch::synchronize($user, TRUE, 'WordPress', 'Individual'); /* // IN progress: synchronizeUFMatch does return the contact object, however $civi_contact = CRM_Core_BAO_UFMatch::synchronizeUFMatch( $user, // user object $user->ID, // ID $user->user_mail, // unique identifier null // unused 'WordPress' // CMS 'Individual' // contact type ); // now we can allow other plugins to do their thing do_action( 'civicrm_contact_synced', $user, $civi_contact ); */ } }
/** * Save user registration and notify users and admins if required * @return void */ function register_save() { global $mainframe; // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); // Get required system objects $user = clone JFactory::getUser(); $pathway =& $mainframe->getPathway(); $config =& JFactory::getConfig(); $authorize =& JFactory::getACL(); $document =& JFactory::getDocument(); // If user registration is not allowed, show 403 not authorized. $usersConfig =& JComponentHelper::getParams('com_users'); if ($usersConfig->get('allowUserRegistration') == '0') { JError::raiseError(403, JText::_('Access Forbidden')); return; } // do civicrm validation here require_once 'administrator/components/com_civicrm/civicrm.settings.php'; require_once 'CRM/Core/Config.php'; $civiConfig =& CRM_Core_Config::singleton(); $civiConfig->formKeyDisable = true; require_once 'CRM/Core/BAO/UFGroup.php'; $errors = CRM_Core_BAO_UFGroup::isValid(null, null, true); if (is_array($errors)) { $msg = null; foreach ($errors as $name => $error) { $msg .= "{$name}: {$error}<br/>"; } JError::raiseWarning('', JText::_($msg)); $this->register(); return false; } // Initialize new usertype setting $newUsertype = $usersConfig->get('new_usertype'); if (!$newUsertype) { $newUsertype = 'Registered'; } // Bind the post array to the user object if (!$user->bind(JRequest::get('post'), 'usertype')) { JError::raiseError(500, $user->getError()); } // Set some initial user values $user->set('id', 0); $user->set('usertype', ''); $user->set('gid', $authorize->get_group_id('', $newUsertype, 'ARO')); $date =& JFactory::getDate(); $user->set('registerDate', $date->toMySQL()); // If user activation is turned on, we need to set the activation information $useractivation = $usersConfig->get('useractivation'); if ($useractivation == '1') { jimport('joomla.user.helper'); $user->set('activation', md5(JUserHelper::genRandomPassword())); $user->set('block', '1'); } // If there was an error with registration, set the message and display form if (!$user->save()) { JError::raiseWarning('', JText::_($user->getError())); $this->register(); return false; } // Send registration confirmation mail $password = JRequest::getString('password', '', 'post', JREQUEST_ALLOWRAW); $password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $password); //Disallow control chars in the email UserController::_sendMail($user, $password); // if this was a successful save, call civicrm code to save the contact if ($user->id) { require_once 'CRM/Core/BAO/UFMatch.php'; CRM_Core_BAO_UFMatch::synchronize($user, true, 'Joomla', 'Individual'); $userID = CRM_Core_BAO_UFMatch::getContactId($user->id); if ($userID) { require_once 'CRM/Core/BAO/UFGroup.php'; CRM_Core_BAO_UFGroup::getEditHTML($userID, null, 2, true, false, null, false, 'Individual'); $session =& CRM_Core_Session::singleton(); $session->reset(); } } // Everything went fine, set relevant message depending upon user activation state and display message if ($useractivation == 1) { $message = JText::_('REG_COMPLETE_ACTIVATE'); } else { $message = JText::_('REG_COMPLETE'); } //TODO :: this needs to be replace by raiseMessage JError::raiseNotice('', $message); $this->register(); }
/** * Initialize CiviCRM * * @return bool $success */ public function initialize() { static $initialized = FALSE; static $failure = FALSE; if ($failure) { return FALSE; } if (!$initialized) { // Check for php version and ensure its greater than minPhpVersion $minPhpVersion = '5.3.4'; if (version_compare(PHP_VERSION, $minPhpVersion) < 0) { echo '<p>' . sprintf(__('CiviCRM requires PHP Version %s or greater. You are running PHP Version %s', 'civicrm'), $minPhpVersion, PHP_VERSION) . '<p>'; exit; } // check for settings if (!CIVICRM_INSTALLED) { $error = FALSE; } elseif (file_exists(CIVICRM_SETTINGS_PATH)) { $error = (include_once CIVICRM_SETTINGS_PATH); } // autoload require_once 'CRM/Core/ClassLoader.php'; CRM_Core_ClassLoader::singleton()->register(); // get ready for problems $installLink = admin_url() . "options-general.php?page=civicrm-install"; $docLinkInstall = "http://wiki.civicrm.org/confluence/display/CRMDOC/WordPress+Installation+Guide"; $docLinkTrouble = "http://wiki.civicrm.org/confluence/display/CRMDOC/Installation+and+Configuration+Trouble-shooting"; $forumLink = "http://forum.civicrm.org/index.php/board,6.0.html"; // construct message $errorMsgAdd = sprintf(__('Please review the <a href="%s">WordPress Installation Guide</a> and the <a href="%s">Trouble-shooting page</a> for assistance. If you still need help installing, you can often find solutions to your issue by searching for the error message in the <a href="%s">installation support section of the community forum</a>.', 'civicrm'), $docLinkInstall, $docLinkTrouble, $forumLink); // does install message get used? $installMessage = sprintf(__('Click <a href="%s">here</a> for fresh install.', 'civicrm'), $installLink); if ($error == FALSE) { header('Location: ' . admin_url() . 'options-general.php?page=civicrm-install'); return FALSE; } // access global defined in civicrm.settings.php global $civicrm_root; // this does pretty much all of the civicrm initialization if (!file_exists($civicrm_root . 'CRM/Core/Config.php')) { $error = FALSE; } else { $error = (include_once 'CRM/Core/Config.php'); } // have we got it? if ($error == FALSE) { // set static flag $failure = TRUE; // FIX ME - why? wp_die("<strong><p class='error'>" . sprintf(__('Oops! - The path for including CiviCRM code files is not set properly. Most likely there is an error in the <em>civicrm_root</em> setting in your CiviCRM settings file (%s).', 'civicrm'), CIVICRM_SETTINGS_PATH) . "</p><p class='error'> » " . sprintf(__('civicrm_root is currently set to: <em>%s</em>.', 'civicrm'), $civicrm_root) . "</p><p class='error'>" . $errorMsgAdd . "</p></strong>"); // won't reach here! return FALSE; } // set static flag $initialized = TRUE; // initialize the system by creating a config object $config = CRM_Core_Config::singleton(); //print_r( $config ); die(); // sync the logged in user with WP global $current_user; if ($current_user) { // sync procedure sets session values for logged in users require_once 'CRM/Core/BAO/UFMatch.php'; CRM_Core_BAO_UFMatch::synchronize($current_user, FALSE, 'WordPress', $this->users->get_civicrm_contact_type('Individual')); } } // notify plugins do_action('civicrm_initialized'); // success! return TRUE; }