Joomla and Extensions Hacks

From HAA Best Practices Wiki
Revision as of 02:29, 15 January 2010 by Whbean65 (talk | contribs) (Community Builder)
Jump to: navigation, search

Lavinya6 Template

Fix problem with table width in articles

The original template enclosed article content in a table with a style "contentpaneopen", which called for a cell width of 100%. This caused conflicts when the author specified a table cell width within an article. Fixed it by removing the width specification.

table.contentpaneopen td {
  /* line-height : 18px;*/
  /* font-size : 12px;*/
  line-height : 20px;
  font-size : 14px;
/*  width: 100%; *//* WHB This caused problems when the content specified a table width */
}

The css for the template is in joomla\templates\lavinya6\css\template.css

Change the size of the banner image

Edited joomla\template\lavinya6\index.php to increase the height of the banner image from 170 to 235 pixels. You can find the line by searching for "HRGenericPhoto"

Fix problem with menus blinking when you hover

If you had a narrow window the menus would blink rapidly when you hovered over a two-line menu item. To fix this replace the following code in joomla\templates\lavinya6\css\template.css:

.moduletable_menu li a:hover {
  font-family : Verdana, Arial, Helvetica, sans-serif;
  background-position : left 0%;
  /*background-image : url(../images/menud.png);*/
  height : 16px !important;
  display : block;
  height : 23px;
  color : #a52a2a;
  font-size : 1em;
  /*text-align : center;*/
  text-align : left;
  padding-left : 10px;
}

with

.moduletable_menu li a:hover {
  color : #a52a2a;
}

Increased font size in textareas

The font in the private email message box was small and hard to read. Increased the size by adding the following code to joomla\templates\lavinya6\css\template.css immediately after the selector for 'inputbox':

textarea.inputbox{
  font-size: 1.2em;
}

Community Builder

Suppress certain icons during edit of user profile

During edit of the user profile suppress the display of the icon indicating that the field will not be displayed in the profile from the 'First Name' and 'Last Name' fields. The icon was missleading since the combined full name will be displayed.

In the file joomla\administrator\components\com_comprofiler\comprofiler.class.php add the following lines in the function getFieldIcons, immediately after the declaration of $ueConfig as global.

    // WHB hack to suppress display of the icon saying that the field is not displayed on the profile.  
    // The individual first/last name fields are not, but the composite name field is displayed
    if ($oTitle === "First Name" || $oTitle === "Last Name")
    {
        $oProfile = 1;
    }
    // WHB End of hack.  If we lose this one in an update the worst that happens is the icon reapears.

Added lastname to the list of fields that can be searched even though not on the profile

Normally CB won't let you search for a field that isn't displayed in the profile. We want to search for last name, not full name, so I added the lastname field to the list of exceptions. To do so I modified one line of code in the function _getTabFieldsDb in the file joomla\administrator\components\com_comprofiler\comprofiler.class.php. The original line is commented out immediately over the modified line.

switch ( $reason ) {
  case 'profile':
      $where[] = 'f.profile != 0';
      break;
  case 'list':
      // WHB hack.  Added lastname to exceptions for fileds that are not on the profile yet are searchable.
      // $where[] = "( f.profile != 0 OR f.name = 'username'" . ( in_array( $ueConfig['name_format'], array( 1, 2, 4 ) ) ? " OR f.name = 'name'" : '' ) . ')';
      $where[] = "( f.profile != 0 OR f.name = 'username'" . ( in_array( $ueConfig['name_format'], array( 1, 2, 4 ) ) ? " OR f.name = 'name' OR f.name='lastname'" : '' ) . ')';
      // END WHB hack.				    
      break;
   case 'register':
      $where[] = 'f.registration = 1';
      break;
    default:
      break;
}


Make the AIM link on the user profile activate AIM

In order to make the AIM link on the Web Contact tab work, we had to reconfigure the link built by Community Builder. The code to make the change is in the file joomla\administrator\components\com_comprofiler\plugin.class.php. It occurs in the functions getFieldRow immediately after the line:

$oValue = $this->getField( $field, $user, $output, $reason, $list_compare_types ); 

The added code is:

// WHB Hack to allow aim in Web page, if we lose it the aim file will simply show the user
// name, without the link.
if ($field->name === "cb_aim")
{
    if(ereg("http://aim", $oValue))
    {
        $oValue = ereg_replace("http://aim", "aim", $oValue);
        $oValue = ereg_replace("target=\\\"_blank\\\"", "", $oValue);
    }
}
//WHB end of hack.        

Modify language file to include instructions for uploading profile image

Change the definition of _UE_UPLOAD_DIMENSIONS_AVATAR to include upload instructions in .\components\com_comprofiler\plugin\language\default\default_language.php to read:

DEFINE('_UE_UPLOAD_DIMENSIONS_AVATAR','To upload a picture press the "Browse" button and select a picture on your computer.  Then press the "Upload" button. '
.'Your image will be resized if needed to a maximum dimension of %s pixels width x %s height automatically, but your image file should not exceed %s KB.'

.' ');

GMapsPro

Suppress map on user profile tab

joomla\components\com_comprofiler\plugin\user\plug_cbmapuser\mapnearbyuserstab.class.php;

Added:

return;

after the code block that does the geocoding right after the comment

// If the users profile needs to be geocoded and IF geocoding is enabled

The effect is to suppress the generation of the map on the user profile tab.

Fix problem with calls to www.sitename.org vs. sitename.org

// ORIG LINE	$query = 'SELECT * from #__gmaps_config where site = "' . $mosConfig_live_site . '"';
// NEW LINE	$query = 'SELECT * from #__gmaps_config limit 1';

The intent of the original code was to allow a single Joomla installation to support more than one site. The problem was that the URL isn't unique within a site. A better approach would have been to use the database prefix (jos_, for example), which is unique within sites in the same installation. This would not be a difficult modification if it becomes desireable to run multiple sites in a single installation.

Fixed problem in communitybuilderprofileadapter.class.php

Changed code to suppress second copy of avatar and to add View Profile link.

$desc = "<table><tr><td>"  
 . $row["name"] . "<br/>"
 . $row["cb_address"] . "<br/>"
 . $row["cb_city"] . ", " . $row["cb_state"] . "<br/>"	
 . "<a href='".$profile_path.$row["user_id"]."'>View Profile</a><br />"
 . "</td></tr>
</table>";

CBMailing

Modified to recognize special list selection keywords

Added the following code in cbmailing.class.php immediately after $filterby is set from the database

// We modify the filter depending on keywords included in the filter
// This code appears in haareunion.php and must be changed in both places!!
// The only difference in the code is the definition of $HaaPrefix and the
// use of $row->filterfields vs. $filterby

$database->setQuery("SELECT params FROM #__comprofiler_plugin WHERE name='HAAReunion'");
$database->query();
$haaparams = $database->loadResult();    // In the form 'ActiveReunion=15'
ereg('ActiveReunion=([0-9]+)', $haaparams, $arrYear);
$actyear = (string)$arrYear[1];
if (strlen($actyear) == 1 )
    {$actyear = '0'.$actyear;}
$prioryear = (string)(((int)$arrYear[1]) - 5);
if (strlen($prioryear) == 1 )
    {$prioryear = '0'.$prioryear;}

if (ereg('NoPlansActiveReunion|PlansToComeActiveReunion|IsRegisteredActiveReunion|NoPlansPriorReunion|PlansToComePriorReunion|IsRegisteredPriorReunion', $filterby))
{
    $HaaPrefix = "ue.";
    $HaaFilter = $filterby;
    $HaaFilter = ereg_replace('NoPlansActiveReunion', "(".$HaaPrefix."`cb_reunion".$actyear."` < '1' or ".$HaaPrefix."`cb_reunion".$actyear."` is null)", $HaaFilter);
    $HaaFilter = ereg_replace('PlansToComeActiveReunion', "(".$HaaPrefix."`cb_reunion".$actyear."` = '1')", $HaaFilter);
    $HaaFilter = ereg_replace('IsRegisteredActiveReunion', "(".$HaaPrefix."`cb_reunion".$actyear."` ='2')", $HaaFilter);
    $HaaFilter = ereg_replace('NoPlansPriorReunion', "(".$HaaPrefix."`cb_reunion".$prioryear."` < '1' or ".$HaaPrefix."`cb_reunion".$prioryear."` is null)", $HaaFilter);
    $HaaFilter = ereg_replace('PlansToComePriorReunion', "(".$HaaPrefix."`cb_reunion".$prioryear."` ='1')", $HaaFilter);
    $HaaFilter = ereg_replace('IsRegisteredPriorReunion', "(".$HaaPrefix."`cb_reunion".$prioryear."` ='2')", $HaaFilter);
    $filterby = $HaaFilter;
}

Fixed problem in Javascript in file

In the file admin.cbmailing.html.php commented out a closing brace (}) and added submitform(pressbutton); right before the final return. The syntax error was showing up in IE with debugging enabled. Once the brace was removed the form wasn't submitted without the call to submit form.

	
function messageForm( &$lists, &$config, $option ) {      
 ?>
 <script language="javascript" type="text/javascript">
     //function getSelectedValue(
    function submitbutton(pressbutton) {
    var form = document.adminForm;
    if (pressbutton == 'cancel') {
    submitform( pressbutton );
    return;
    }
    // do field validation
   if (form.mm_subject.value == ""){
      alert( "<?php echo _CB_MAILING_FILLINSUBJECT ?>" );      
      return false;
   } else if (getSelectedValue('adminForm','mm_group') < 0){
      alert( "<?php echo _CB_MAILING_SELECTAGROUP ?>" );
      return false;
   } else if (form.mm_message.value == ""){
      alert( "<?php echo _CB_MAILING_FILLINMESSAGE ?>" );
      return false;
   }
   submitform(pressbutton);
   return true;
}
//}     

A few lines further down added the line commented with WHB

// Get all users email
$query = "SELECT email FROM #__users u, #__comprofiler ue WHERE u.id=ue.id AND ue.approved=1 AND ue.banned!=1 AND ue.confirmed=1";
$query .= " AND ue.cb_mailoptin = 1";  // WHB Modification to honor optin field
if (! $this->cbMailingConfig["incBlocked"])
{
	$query .= " AND u.block!=1";
}

Supressed sending of blank email

in joomla\administrator\components\com_cbmailing\cbmailing.class.php Commented out the line calling mosMail in the following. It was trying to send an empty email, resulting in an error.

// MRCB DEBUG
/* $result = mosMail( $this->cbMailingConfig["debugFromAddr"], 
   $this->cbMailingConfig["debugFromDesc"], 
   $this->cbMailingConfig["debugToAddr"], 
   $this->cbMailingConfig["debugETitle"],
   $mailedDetails . $msg, 0);      */
// Uncomment the following line to display the message - would need to comment out the mosRedirect
//HTML_cbmailing::errorMessage( $mailedDetails . $msg, NULL );	

Nicetalk

Added css to template for body of the comments

The original style used very small sans-serif type for the comments - too small for aging eyes. Added the following to the end of \joomla\components\com_nicetalk\css\nicetalk.css

/* WHB addition */

div#nicetalk{
font-size:14px;
font-family : georgia, Verdana, arial, serif;
}

Return to main Master Template page