Module edits

Submitted by Delphium on 15 April, 2013 - 14:29

This blog is an effort to make a note of any custom edits to modules used on the site.

Core

Core:- theme.inc
File:- /includes/theme.inc

Code:
// What this edit does:- changes the way usernames are displayed by providing additional group info as a class so that user names may have different colours. @FIND if (user_access('access user profiles')) { $output = l($name, 'user/'. $object->uid, array('attributes' => array('title' => t('View user profile.')))); @REPLACE /*if (user_access('access user profiles')) { $output = l($name, 'user/'. $object->uid, array('attributes' => array('title' => t('View user profile.'))));*/ $roles = array(); if (user_access('access user profiles')) { $user = array(); if (array_key_exists($object->uid, $roles)) { $roles = $user_roles[$object->uid]; } else { $user = user_load(array('uid' => $object->uid)); foreach ($user->roles as $user_role) { $roles[] = sprintf('user-role-%s', strtolower(str_replace(" ", "-", $user_role))); } $user_roles[$object->uid] = $roles; } $output = l($name, 'user/'. $object->uid, array('attributes' => array('title' => t('View user profile.'),'class' => join(" ", $roles) )));

Core:- robots.txt
File:- /robots.txt

Code:
// What this edit does:- Prevents search engine bots from indexing certain parts of the site. @FIND Disallow: /?q=user/login/ @ADD BELOW # Boost Disallow: /boost_stats.php #phpbb Disallow: /phpBB/* Disallow: /posting.php Disallow: /admin Disallow: /privmsg.php Disallow: /login.php Disallow: /images Disallow: /includes Disallow: /forums/viewtopic.php?f=47 Disallow: /forums/viewtopic.php?f=50 Disallow: /forums/viewtopic.php?f=51 Disallow: /forums/viewtopic.php?f=52 Disallow: /forums/viewtopic.php?f=53 Disallow: /forums/viewtopic.php?f=54 Disallow: /forums/viewtopic.php?f=55 Disallow: /forums/viewtopic.php?f=56 Disallow: /forums/viewtopic.php?f=47&t=* Disallow: /forums/viewtopic.php?f=50&t=* Disallow: /forums/viewtopic.php?f=51&t=* Disallow: /forums/viewtopic.php?f=52&t=* Disallow: /forums/viewtopic.php?f=53&t=* Disallow: /forums/viewtopic.php?f=54&t=* Disallow: /forums/viewtopic.php?f=55&t=* Disallow: /forums/viewtopic.php?f=56&t=*

Module:- Blog
File:- /modules/blog/blog.module

Code:
// What this edit does:- changes the recent blogs block to show 6 items instead of the default 10. @FIND $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, 10); @REPLACE //$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, 10); $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, 6);

Module:- Comment
File:- /modules/comment/comment.module

Code:
// What this edit does:- changes the drop down options for number of drupal comments to display per page. @FIND return drupal_map_assoc(array(10, 30, 50, 70, 90, 150, 200, 250, 300)); @REPLACE //return drupal_map_assoc(array(10, 30, 50, 70, 90, 150, 200, 250, 300)); return drupal_map_assoc(array(10, 15, 20, 25, 30, 50, 75, 100, 150, 200, 250, 300));

Module:- Filter
File:- /modules/filter/filter.module

Code:
// What this edit does:- check file for documentation @FIND $match[2] = check_url($match[2]);

Module:- Profile
File:- /modules/profile/profile.module

Code:
// What this edit does:- adds a modified user profile save function, for use with phpbb integration. @FIND function _profile_get_fields($category, $register = FALSE) { $args = array(); $sql = 'SELECT * FROM {profile_fields} WHERE '; $filters = array(); if ($register) { $filters[] = 'register = 1'; } else { // Use LOWER('%s') instead of PHP's strtolower() to avoid UTF-8 conversion issues. $filters[] = "category = '%s'"; $args[] = $category; } if (!user_access('administer users')) { $filters[] = 'visibility != %d'; $args[] = PROFILE_HIDDEN; } $sql .= implode(' AND ', $filters); $sql .= ' ORDER BY category, weight'; return db_query($sql, $args); } @ADD BELOW //delphium edit function profile_save_profile_delph(&$edit, &$user, $category, $register = FALSE, $hidden = FALSE) { $result = _profile_get_fields_delph($category, $register, $hidden); while ($field = db_fetch_object($result)) { if (_profile_field_serialize($field->type)) { $edit[$field->name] = serialize($edit[$field->name]); } db_query("DELETE FROM {profile_values} WHERE fid = %d AND uid = %d", $field->fid, $user->uid); db_query("INSERT INTO {profile_values} (fid, uid, value) VALUES (%d, %d, '%s')", $field->fid, $user->uid, $edit[$field->name]); // Mark field as handled (prevents saving to user->data). $edit[$field->name] = NULL; } } function _profile_get_fields_delph($category, $register = FALSE, $hidden = FALSE) { $args = array(); $sql = 'SELECT * FROM {profile_fields} WHERE '; $filters = array(); if ($register) { $filters[] = 'register = 1'; } else { // Use LOWER('%s') instead of PHP's strtolower() to avoid UTF-8 conversion issues. $filters[] = "LOWER(category) = LOWER('%s')"; $args[] = $category; } /*if (!user_access('administer users') and !$hidden) { $filters[] = 'visibility != %d'; $args[] = PROFILE_HIDDEN; }*/ $sql .= implode(' AND ', $filters); $sql .= ' ORDER BY category, weight'; return db_query($sql, $args); } // end delphium edit

Module:- Search
File:- /modules/search/search.module

Code:
// What this edit does:- changes the search box title @FIND '#title' => t('Search this site'), @REPLACE //'#title' => t('Search this site'), '#title' => t('Search Articles & Games'),

File:- /modules/search/search-block-form.tpl.php

Code:
// What this edit does:- adds the opensearch plugin install link @FIND <?php print $search_form; ?> @ADD BELOW <?php //print '<span class="opensearch"><a title="Install WSGF Search Plugin" href="javascript:void(0)" onclick="addProvider(\'/wsgfsearch.xml\',\'false\',\'WSGF\')">Install WSGF Search Plugin</a></span><span class="searchnewtab"><a target="_blank" href="/search/apachesolr_search/">Open New Tab</a></span>'; ?>

Modules

Module:- Apachesolr
File:- /sites/all/modules/apachesolr/apachesolr.module

Code:
//What this edit does:- Adds the content node type to the "more like this" search output so that it may have CSS applied to it. @FIND 'fl' => 'nid,title,path,url', @REPLACE //'fl' => 'nid,title,path,url', 'fl' => 'nid,title,path,url,type',

Code:
//What this edit does:- reformats the output displayed for "more like this" search results, allowing us to apply classes for CSS to add a content type icon to the list. @FIND $links[] = l($result->title, $result->path, array('html' => TRUE)); @REPLACE //$links[] = l($result->title, $result->path, array('html' => TRUE)); $links[] = '<a class="morelikethis mlt-'.$result->type.'" href="/'.$result->path.'">'.$result->title.'</a>';

Module:- Pathologic
File:- /sites/all/modules/pathologic/pathologic.module

Code:
// What this edit does:- fixes a bug where URL encoded HTML was being incorrectly decoded, for example & would be changed to &%3B, this change fixes this bug. @FIND parse_str($parts['query'], $qparts); @REPLACE //parse_str($parts['query'], $qparts); parse_str(html_entity_decode($parts['query']), $qparts);

Module:- Purge
File:- /sites/all/modules/purge/purge.inc

Code:
// What this edit does:- fixes a bug where 404 Not Found was displayed on a working page several times at the top of the page, the issue is related to CURL and PHP 5.4.8 and greater. @FIND // Block until there is activity on any of the handlers. Avoids // busywaiting. if ($multi_result == CURLM_OK) { $select_result = curl_multi_select($curl_purges); } if ($multi_result != CURLM_OK || $select_result == -1) { // @TODO: error handling. Something truly awkward happened. return FALSE; } } while ($select_result != -1 && $active && $multi_result == CURLM_OK); ob_end_clean(); @REPLACE // Block until there is activity on any of the handlers. Avoids // busywaiting. if ($multi_result == CURLM_OK) { /* <a href="https://www.drupal.org/node/75790#comment-2615716" title="https://www.drupal.org/node/75790#comment-2615716">https://www.drupal.org/node/75790#comment-2615716</a> $select_result = curl_multi_select($curl_purges); } if ($multi_result != CURLM_OK || $select_result == -1) { // @TODO: error handling. Something truly awkward happened. return FALSE; */ // According to <a href="https://bugs.php.net/bug.php?id=63411" title="https://bugs.php.net/bug.php?id=63411">https://bugs.php.net/bug.php?id=63411</a>, in PHP 5.3.18+ // curl_multi_select can return immediately if libcurl cannot block, but // still has something to process, so we block a bit ourselves. if (curl_multi_select($curl_purges) == -1) { // Wait 0.1 second. usleep(100000); } } } //while ($select_result != -1 && $active && $multi_result == CURLM_OK); while ($active && $multi_result == CURLM_OK); ob_end_clean();