Site administrators
HowTo: Integrate Privatemsg with Application toolbar (AppBar)
The following code sample shows you how to integrate Privatemsg with the Application Toolbar.
<?php
/**
* Implements hook_privatemsg_message_insert().
*
* Adds a notification for each recipient when a message is sent.
*/
function yourmodule_privatemsg_message_insert($message) {
$text = t('!user sent you a private message', array('!user' => theme('username', $message['author'])));
$alert_type = 'privatemsg-receipt';
foreach ($message['recipients'] as $recipient) {
appbar_set_message($text, $alert_type, $recipient->uid);
}
}
/**
* Implementation of hook_appbar_id().
*/
function yourmodule_appbar_id() {
return array(
'privatemsg-receipt' => t('Privatemsg receipt (alerts recipient)'),
);
}
?>More information:
Privatemsg API documentation: http://blog.worldempire.ch/api
Application Toolbar API documentation: http://drupal.org/node/546536#api
Application Toolbar Integration examples: http://drupalcode.org/viewvc/drupal/contributions/modules/appbar/appbar_...
HowTo: Integrate Privatemsg with UserPoints Module
There are two way to integrate Privatemsg with the UserPoints module. First, it is possible to use the privatemsg_rules module (see #327938: Rules Integration) which allows to configure some basic definitions (For example, when sending a private message).
The second possibility is to create custom hook functions which allow for much mor flexiblitly and make it possible to set a description.
Example 1: Give a user 5 points when sending a new message and 6 when sending a reply.
<?php
function yourmodule_privatemsg_message_insert($message) {
// If thread_id and mid is the same, this is a new thread.
if ($message['thread_id'] == $message['mid']) {
$params = array(
'uid' => $message['author']->uid,
'points' => 5,
'description' => 'You have sent a new private message to a user of the community.',
);
}
else {
$params = array(
'uid' => $message['author']->uid,
'points' => 6,
'description' => 'You have replied to a private message.',
);
}
userpoints_userpointsapi($params);
}
?>Working with Field UI
Placeholder for Field UI handbook page
Block visible for Entire Sections but NOT Specific Sub-sections or Pages
This snippet lets you use includes and excludes in your block visibility settings. For example.
Show this block on blog/* but not blog/somepage and blog/other page
Show this block on news/* about/* and features/*, but not about/tom or news/listing/*
<?php
/* a list a pages to include in standard block include/exclude format (one per line) */
$include = "some/site/section/*
another/page/here
node/34";
/* a list a pages to exclude in standard block include/exclude format (one per line) */
$exclude = "some/site/section/page1
some/site/section/page2";
/* ----------- DO NOT TOUCH ANYTHING BELOW THIS LINE ----------- */
$match = FALSE;
$path = drupal_get_path_alias($_GET['q']);
$regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($include, '/')) .')$/';
if (preg_match($regexp, $path)) {
$regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($exclude, '/')) .')$/';
if (!preg_match($regexp, $path)) {
$match = TRUE;
}
}
return $match;
?>Running Tests Through command-line
Command-line test execution - Linux
This section is for the those that have the desire and/or the need to run the test-suite by command-line. This is often needed when one wants to integrate 3rd-party continuous-build tools, for example. I am hoping this page will collect info and tips on the manual aspects of testing, when one is doing it small-scale and only wants to test one or a few modules.
For those looking for info on the gui way of running simpletest, head for the Simpletest tutorial, lower down in that tutorial you will some information for running tests through drupal interface. The two important links for command-line commandos accessing simple-test through Drupal interface are admin/config/development/testing/ and admin/config/development/testing/results/
Running the tests through the command line in Drupal is quite easy with the help of run-tests.sh, located in /scripts. One can easily get the test-suite running by going to the root of the site directory, as web-server user and typing php scripts/run-tests.sh.
If you don't feel like typing /scripts/run-tests.sh all the time, symlink the script to your ~/bin directory, assuming you have an existing bin directory that is in your path:
ln - s scripts/run-tests.sh ~/binRules: Rules Executor
This is a holding page for documentation about the Rules Executor module
