Joomla and Extensions Hacks Joomla 3.0: Difference between revisions

From HAA Best Practices Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 183: Line 183:
     // WHB End of hack.  If we lose this one in an update the worst that happens is the icon reappears.
     // WHB End of hack.  If we lose this one in an update the worst that happens is the icon reappears.
</PRE>
</PRE>
===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):
<PRE>
// 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       
</PRE>


[[Master Template for Class Web Sites|Return to main Master Template page]]
[[Master Template for Class Web Sites|Return to main Master Template page]]

Revision as of 19:19, 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

This code goes in \components\com_comprofiler\plugin\tempates\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

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\tempates\default\default.php. It belongs right after the line:

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

Add keywords to the Community Builder reports

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

// 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')";
}
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

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 reappears.

Return to main Master Template page