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

From HAA Best Practices Wiki
Jump to navigationJump to search
 
Line 155: Line 155:
 
$whbIncludeAdmin =  !strncmp($row->title, "Super Administrators", 19);
 
$whbIncludeAdmin =  !strncmp($row->title, "Super Administrators", 19);
 
if (!$whbIncludeAdmin){
 
if (!$whbIncludeAdmin){
       $tablesWhereSQL[] = "(u.username != 'admin')";
+
       $tablesWhereSQL[] = "(u.username != 'admin' && u.username != 'CabinBoy')";
 
}
 
}
 
if (strlen($row->title) >= 17){
 
if (strlen($row->title) >= 17){

Latest revision as of 15:34, 7 September 2021

Community Builder[edit]

Strip pointer to profile for dummy users[edit]

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[edit]

In components\com_comprofiler\plugin\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[edit]

//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[edit]

// 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

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

foreach ( $this->columns as $columnIndex => $column ) {

For the reunion reports we want to include dummy registrants and avoid profile links[edit]

if (false !== stripos($this->listTitleHtml, "Reunion Attendees")){
    if ($this->users[$userIndex]->cb_dummyregistrant == 1 && $columnIndex < 2){
        // Strip the link from $cellContent
        $cellContent = preg_replace('#<a.*?>#', '', $cellContent, 1);
        $cellContent = preg_replace('#</a>#', '', $cellContent, 1);
    }
    if ($this->users[$userIndex]->cb_dummyregistrant == 1 && $columnIndex == 2){
        // Strip the link from $cellContent
        $cellContent = preg_replace('#-#', '', 'Registered', 1);
    }
}

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

$cellContent = $this->_getUserListCell( $this->tableContent[$userIndex][$columnIndex] );

Add keywords to the Community Builder reports[edit]

// 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

$_CB_database->setQuery("SELECT params FROM #__comprofiler_plugin WHERE name='HAAReunion'");
$_CB_database->query();
$haaparams = $_CB_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."` in ('1', '2'))", $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;
}

This code goes in \libraries\CBLib\CB\Legacy\cbUsersList.php. It belongs immediately before the line:

return $filterBy;

Include dummy users in the reunion reports[edit]

// 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
// We need to change $tablesWhereSQL[gid] from ...AND g.`group.id` = 2 to ...AND g.`group.id` < 3
if (false !== stripos($row->title, "Reunion Attendees")){
   $tablesWhereSQL['gid'] = str_replace('`group_id` = 2', '`group_id` in (1, 2)', $tablesWhereSQL['gid']);
}
// 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){
       $tablesWhereSQL[] = "(u.username != 'admin' && u.username != 'CabinBoy')";
}
if (strlen($row->title) >= 17){
    if (false !== stripos($row->title, "Reunion Attendees", 17)){
       $tablesWhereSQL[] = "(ue.cb_dummyregistrant OR (g.group_id = 2))";
    }
}

This code belongs in \libraries\CBLib\CB\Legacy\cbUsersList.php. It goes right before the line:

$_PLUGINS->trigger( 'onBeforeUsersListBuildQuery', array( &$tablesSQL, &$joinsSQL, &$tablesWhereSQL ) );

Suppress certain icons during edit of user profile[edit]

During edit of tche 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 reappears.


Supress versioning on the personal.css page[edit]

In the file joomla/libraries/src/HTML/HTMLHelper.php add the following at line 660 right before $document->addStyleSheet...

/*
    WHB HACK
*/
    if (strpos($include, 'personal')){
        $options['version'] = false;   
    }
//END WHB HACK //