This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Test for the home page of this website. | |
*/ | |
class SiteTestingHomePageTest extends SiteTesting { | |
/** | |
* Stores the user created for this test. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Common testing class for this Drupal site. | |
*/ | |
abstract class SiteTesting extends DrupalWebTestCase { | |
/** | |
* Overrides default set up handler to prevent database sand-boxing. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_views_api(). | |
*/ | |
function my_custom_module_views_api() { | |
return array( | |
'api' => 3, | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_views_data(). | |
*/ | |
function my_custom_module_views_data() { | |
$data['my_custom_module']['table']['group'] = t('My custom module'); | |
$data['my_custom_module']['table']['join'] = array( | |
// Exist in all views. | |
'#global' => array(), | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Custom views handler definition. | |
* | |
* Place this code in | |
* /sites/all/[custom_module_name]/includes/views_handler_my_custom_field.inc | |
*/ | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* DO NOT USE THIS CODE | |
* | |
* Substituting custom field content in views hooks is a great way | |
* to make enemies with future developers. | |
*/ | |
function my_confusing_module_views_pre_render(&$view) { | |
// This is messy and hard to understand for site builders and future developers. | |
$view->result[0]->custom_field_999 = t('Foo'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_node_access(). | |
* | |
* Runs every time a user tries to view a node on the website. | |
*/ | |
function my_custom_module_node_access($node, $op, $account) { | |
if ($node->type == 'page' && $op == 'view' && !user_access('my custom permission')) { | |
return NODE_ACCESS_DENY; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_init(). | |
* | |
* Runs every time a page is requested on the site. | |
*/ | |
function my_custom_module_init() { | |
// Return a 403 page and prevent further operations if the user does not have the right permissions. | |
if (!user_access('access content')) { | |
drupal_access_denied(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_init(). | |
* | |
* Runs every time a page is requested on the site. | |
*/ | |
function my_custom_module_init() { | |
if (user_access('access content')) { | |
drupal_set_message(t('User has Drupal core access content permission')); | |
} |