Difference between revisions of "Joomla and Extensions Hacks Joomla 3.0"

From HAA Best Practices Wiki
Jump to navigationJump to search
Line 60: Line 60:
 
<PRE>
 
<PRE>
 
if ( is_array( $this->users ) && ( count( $this->users ) > 0 ) ) foreach ( $this->users as $userIndex => $user ) {
 
if ( is_array( $this->users ) && ( count( $this->users ) > 0 ) ) foreach ( $this->users as $userIndex => $user ) {
 +
</PRE>
 +
 +
===For summary reunion attendees report we want users to run across the line===
 +
 +
<PRE>
 +
// WHB Hack
 +
                    if (false !== stripos($this->listTitleHtml, "Reunion Attendees - Summary")){
 +
                        // For the summary report we want to run the names across three cells, using up three rows in the process
 +
                        if ($columnIndex == 1 || $columnIndex == 2) {
 +
                            $userIndex++;
 +
                        }
 +
                        $whbUserIndex = $userIndex;
 +
                        $whbUserCount = sizeof($this->users);
 +
                        if ($whbUserCount <= $userIndex){
 +
                            break;
 +
                        }
 +
                    }
 +
// END WHB HACK
 
</PRE>
 
</PRE>
  

Revision as of 18:47, 11 August 2021

Community Builder

Strip pointer to profile for dummy users

In components\com_comprofiler\comprofiler.html.php Add:

// WHB Hack            
	foreach( $users as $user ) {
                if (!$user->cb_dummyregistrant){
                                $js .= "cbUserURLs[" . (int) $user->id . "] = '" . addslashes( $_CB_framework->userProfileUrl( (int) $user->id, false ) ) . "';";
                }
                else {
                                $js .= "cbUserURLs[" . (int) $user->id . "] = '" . addslashes( "./notUser.html") . "';";
                }
            }
// ORIGINAL CODE:
//            foreach( $users as $user ) {
//                                $js .= "cbUserURLs[" . (int) $user->id . "] = '" . addslashes( $_CB_framework->userProfileUrl( (int) $user->id, false ) ) . "';";
//            }
// END WHB Hack

Suppress full name of the site in the user lists where not all users are shown

In components\com_comprofiler\lugin\templates\default\default.php

This code goes in class CBListView_html_default, function _renderHead after first assignment of $return

//WHB Hack
if(strcmp($this->listTitleHtml, "All users"))
    $this->totalIsAllUsers = false;
//End WHB Hack

For summary reunion attendees report we are monkeying with the user index inside a for loop

//WHB Hack
// We are manipulating $userIndex for the summary report and must override it
            if (false !== stripos($this->listTitleHtml, "Reunion Attendees - Summary")){
                if (isset($whbUserIndex)){
                    $whbIx = $whbUserIndex - $userIndex;
                    while($whbIx >= 0){
                        $userIndex ++;
                        $whbIx --;
                    }
                    // Need to break our of the foreach if the $userIndex is above the number of users
                    $whbUserCount = sizeof($this->users);
                    if ($whbUserCount <= $userIndex){
                        break;
                    }
                }
            }
//End WHB Hack

This code goes in \components\com_comprofiler\plugin\tempates\default\default.php. It belongs right after the line:

if ( is_array( $this->users ) && ( count( $this->users ) > 0 ) ) foreach ( $this->users as $userIndex => $user ) {

For summary reunion attendees report we want users to run across the line

// WHB Hack
                    if (false !== stripos($this->listTitleHtml, "Reunion Attendees - Summary")){
                         // For the summary report we want to run the names across three cells, using up three rows in the process
                         if ($columnIndex == 1 || $columnIndex == 2) {
                             $userIndex++;
                         }
                         $whbUserIndex = $userIndex;
                         $whbUserCount = sizeof($this->users);
                         if ($whbUserCount <= $userIndex){
                             break;
                         }
                    }
// END WHB HACK

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\libraries\CBLib\CB\Legacy\LegacyComprofilerFunctions.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.

Modify the reunion attendees list to include non-user reunion attendees

Added code to .\administrator\components\com_profiler\library\cb\cb.lists.php

Added the following code after After $usergids = implode(",",$allusergids):

// WHB Hack
// We want to include front end users who have been entered to 
// represent non-user classmates who have indicated that they
// are coming to the reunion.  We do this only for the "Reunion Attendees"  list
        
    if (false !== stripos($row->title, "Reunion Attendees")){
        $usergids .= ", 1"; // 29 before J1.7
    }

// End of WHB Hack        

Also the following before $queryFrom .= " " . $filterby; in .\administrator\components\com_profiler\library\cb\cb.lists.php

    // WHB Hack
    // We only want to include the front end users if they have cb_dummyregistrant set
    // We also want to eliminate the admin user, provided they aren't specifically included.
        $whbIncludeAdmin =  !strncmp($row->title, "Super Administrators", 19);
        if (!$whbIncludeAdmin){
                $queryFrom .= " AND (u.username != 'admin')";
        }
        if (strlen($row->title) >= 17){
            if (false !== stripos($row->title, "Reunion Attendees", 17)){
                $queryFrom .= " AND (ue.cb_dummyregistrant OR (g.group_id = 2))\n";
            }
        }
    // END WHB Hack

Modified code in .\components\com_comprofiler\comprofiler.html.php

   //WHB HACK we suppress the row click for reunion attendees who are not
   //users of the web site
                
                if ($user->gid != 1){ // 29 pre J17
                    $jsClickTr .= "'" . cbSef( 'index.php?option=com_comprofiler&task=userProfile&user=' . $user->id . getCBprofileItemid( true ), false ) . "',";
                }
                else{
                    $jsClickTr .= "'" . cbSef( 'index.php?option=com_comprofiler&task=userslist&listid=6') . "',";
                }
   // END HACK
   // The next line replaces the hack in the original 
   // $jsClickTr        .=                "'" . cbSef( 'index.php?option=com_comprofiler&task=userProfile&user=' . 
          $user->id . getCBprofileItemid( true ), false ) . "',";

Also added the following code in function _getListTableContent (after assignment of $fieldView->value) in foreach loop that assigns links to the avatars and user names:

 //WHB HACK we strip the links on the avatar and the individual name for Reunion Attendees
 //who are dummy registrants
 if ($user->gid == 1){ // 29 pre J17
     if ($fieldView->name =="avatar" or $fieldView->name == "name"){
         $fieldView->value = preg_replace('/<a.+?>/', , $fieldView->value);    
         $fieldView->value = preg_replace('/<\/a>/', , $fieldView->value);    
     }
 }
 //WHB End hack

Added code to support a summary version of the Reunion Attendees list

Modified code in .\components\com_comprofiler\comprofiler.html.php

// WHB hack to support summary list
                        
    if (false !== stripos($row->title, "Reunion Attendees - Summary")){
           global $_CB_database;

           // Get the reunion year 
                        
           $_CB_database->setQuery("SELECT params FROM #__comprofiler_plugin WHERE name='HAAReunion'");
           $_CB_database->query();
           $haaparams = $_CB_database->loadResult();        
           preg_match('/ActiveReunion=([0-9]+)/', $haaparams, $arrYear);
           $whbRyr = $arrYear[1];
           if (false !== stripos($row->title, "Prior")){
                $whbRyr = $whbRyr - 5;

           }
           $whbRyr = (string)$whbRyr;
           if (strlen($whbRyr) == 1 )
               {$whbRyr = '0'.$whbRyr;}

           $whbCount = count($users);
           $whbRowCount =  ceil($whbCount/3);
           $whbLastRowColCount = $whbCount % 3;
           echo "<table>";
           for ($whbIx = 0; $whbIx < $whbRowCount; $whbIx++)
           {
                if ($whbIx == $whbRowCount - 1)
                {
                     if ($whbLastRowColCount == 1)
                     {
                          echo $tt = '<tr>'.whbUserCell($whbIx, 0, $whbRowCount, $whbLastRowColCount,  $users, $whbRyr).'</tr>';
                     }
                     else if ($whbLastRowColCount == 2)
                     {
                          echo $tt = '<tr>'.whbUserCell($whbIx, 0, $whbRowCount, $whbLastRowColCount,  $users, $whbRyr).whbUserCell($whbIx, 1, $whbRowCount, $whbLastRowColCount,  $users, $whbRyr).'</tr>';                
                     }
                     else if ($whbLastRowColCount == 0)
                     {  
                          echo $tt = '<tr>'.whbUserCell($whbIx, 0, $whbRowCount, $whbLastRowColCount,  $users, $whbRyr).whbUserCell($whbIx, 1, $whbRowCount, $whbLastRowColCount,  $users, $whbRyr).whbUserCell($whbIx, 2, $whbRowCount, $whbLastRowColCount,  $users, $whbRyr).'</tr>';                
                     }
                }
                else
                {
                    echo $tt = '<tr>'.whbUserCell($whbIx, 0, $whbRowCount, $whbLastRowColCount,  $users, $whbRyr).whbUserCell($whbIx, 1, $whbRowCount, $whbLastRowColCount,  $users, $whbRyr).whbUserCell($whbIx, 2, $whbRowCount, $whbLastRowColCount,  $users, $whbRyr).'</tr>';
                }
           }     
           echo "</table>";     
                 
      }  
      else {
               if ( $showPaging && ( ( $limitstart != 0 ) || ( $limit <= $total ) ) ) {

                   // top page links:
      ?>
            <div class="cbUserListPagination cbUserListPaginationTop" style="width:100%;text-align:center;"><?php echo writePagesLinks($limitstart, $limit, $total, $ue_base_url.$pagingSearch.$spoofAmp, $search); ?></div>
       <?php
               }
               echo HTML_comprofiler::_cbTemplateRender( $cbTemplate, $myUser, 'List', 'drawListBody', array( &$users, &$columns, &$tableContent, $listid, $ueConfig['allow_profilelink'] ) );
       }          
                        
  // Original content of hacked area: echo HTML_comprofiler::_cbTemplateRender( $cbTemplate, $myUser, 'List', 'drawListBody', array( &$users, &$columns, &$tableContent, $listid, $ueConfig['allow_profilelink'] ) );

  // End WHB hack           

Added code in .\components\com_comprofiler\comprofiler.html.php

// WHB FUNCTION to print one cell of Reunion Attendees - Summary report

function whbUserCell($row, $col, $lastrow,  $lastrowcolcount, &$users, $Ryr)
{
    $renplanstmt = '$renp = $users[$rowix]->cb_reunion%02d;';
    $renplanstmt = sprintf($renplanstmt, $Ryr);
    $rowincadj =  ($lastrowcolcount == 1 && $col == 2 ) ? 1 : 0;
    $whbColor = ' color = "gray">';
    $rowix = $col  * $lastrow + $row - $rowincadj;
    eval($renplanstmt);
    if ($renp == "2")
    {
        $whbColor = ' color = "green">';
    }
    return '<td width="200"><font '.$whbColor.$users[$rowix]->name.'</font></td>';   
}

//    

Also added code before $query = "SELECT ue.*, ....." in .\administrator\components\com_comprofiler\library\cb\cb.lists.php


NOTE that after Joomla 2.* this code needs to go before the test for "checkJversion() == 2"

//WHB Hack
// We don't want to impose a limit on the number of users for the summary report'
if (false !== stripos($row->title, "Reunion Attendees - Summary")){
    $limitstart = 0;
    $limit = $total;
}

//END WHB Hack // $query = "SELECT u.id, ue.banned, '' AS 'NA' " . ( $fieldsSQL ? ", " . $fieldsSQL . " " : '' ) . $queryFrom . " " . $orderby

===Workaround for CB bug in User Manager=== NOT NEEDED in 3.0 In version 1.2.3 and 1.4 of CB there is a bug in the User Manger that causes a partial display of the advanced search feature when you cancel out of a user edit. CB has opened a bug for this (#1922). A temporary workaround is to suppress the search when you cancel out of the edit. The following code in .\components\com_comprofiler\plugin\user\plug_cbcore\cb.core.php accomplishes this. (The hope is that this won't be required in the next version of CB.) The code is about line 954.

// WHB hack to supress bug in CB 1.2.3 that caused advanced search checkboxes to be displayed if you cancel out of user edit.
        
if(isset($postdata['password__verify'])){
   return $query;
   }
// End  WHB hack

Not required in CB 1.7

==GMapsPro== NOT NEEDED in 3.0

===Suppress map on user profile tab=== NOT NEEDED in 3.0

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 desirable 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>";

Modified to recognize special list selection keywords

We have heavily altered CBMailing to integrate it with PHPList. The modified install file is available here: haa_cbmailing.zip

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'
preg_match('/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 (preg_match('/NoPlansActiveReunion|PlansToComeActiveReunion|IsRegisteredActiveReunion|NoPlansPriorReunion|PlansToComePriorReunion|IsRegisteredPriorReunion/', $filterby))
{
    $HaaPrefix = "ue.";
    $HaaFilter = $filterby;
    $HaaFilter = preg_replace('/NoPlansActiveReunion/', "(".$HaaPrefix."`cb_reunion".$actyear."` < '1' or ".$HaaPrefix."`cb_reunion".$actyear."` is null)", $HaaFilter);
    $HaaFilter = preg_replace('/PlansToComeActiveReunion/', "(".$HaaPrefix."`cb_reunion".$actyear."` = '1')", $HaaFilter);
    $HaaFilter = preg_replace('/IsRegisteredActiveReunion/', "(".$HaaPrefix."`cb_reunion".$actyear."` ='2')", $HaaFilter);
    $HaaFilter = preg_replace('/NoPlansPriorReunion/', "(".$HaaPrefix."`cb_reunion".$prioryear."` < '1' or ".$HaaPrefix."`cb_reunion".$prioryear."` is null)", $HaaFilter);
    $HaaFilter = preg_replace('/PlansToComePriorReunion/', "(".$HaaPrefix."`cb_reunion".$prioryear."` ='1')", $HaaFilter);
    $HaaFilter = preg_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

OBSOLETE since we switched forum software.

/* WHB addition */

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

Joomla

Problems with date() in php 5.3

Must insert

date_default_timezone_set('UTC');

in both index.php files or the date() function fails. This shows up in ExpirePrive

Intermittent bug when editing/creating menu items

While editing/creating a menu item, when you selected 'Article layout' for the type of page the resulting screen didn't have the dropdown list that is supposed to let you select the article to be associated with the menu item. The problem was intermittent and was often cured by switching browsers.

NOTE: Not installed in Joomla 2.5.0+, so far no reports of problems! (7/15/12)

In administrator\components\com_menus\models\item.php changed the line that read:

$url = JRequest::getVar('url', array(), '', 'array');

To:

// WHB hack to fix intermittent bug with url field in $_REQUEST
$url = JRequest::getVar('url', array(), 'GET', 'array');
if (!isset($url['option'])){
     $url = JRequest::getVar('url', array(), '', 'array');
}
// WHB end of hack.  Original code was $url = JRequest::getVar('url', array(), '', 'array');

Return to main Master Template page