Agaric Design Collective

Figuring out Organic Groups Project module integration: output of project module's link altering hook

By Benjamin Melançon
on 09 Oct
0 comments

Description

See also, for OG/Project integration, Adding and modifying organic group action (create content) links.

Figuring out organic project module

These are the links we have to deal with, from hook_project_page_link_alter().

<?php
/**
* Implementation of project.module's hook_project_page_link_alter().
*
* Accepts a node context and an array of all links, which is passed by
* reference so that changes made will be returned.
*/
function organic_project_project_page_link_alter($node, $all_links) {
 
drupal_set_message('<pre>'. var_export($all_links,TRUE) .'</pre>');
}
?>

PHP output:

<?php
array (
 
'resources' =>
  array (
   
'name' => 'Resources',
   
'weight' => 4,
  ),
 
'support' =>
  array (
   
'name' => 'Support',
   
'weight' => 6,
   
'links' =>
    array (
     
'all_support' => 'View all support requests',
     
'pending_support' => 'View pending support requests',
     
'pending_bugs' => 'View pending bug reports',
     
'pending_features' => 'View pending feature requests',
     
'request_support' => 'Request support',
     
'report_bug' => 'Report new bug',
     
'request_feature' => 'Request new feature',
    ),
  ),
 
'development' =>
  array (
   
'name' => 'Development',
   
'weight' => 8,
   
'links' =>
    array (
     
'pending_patches' => 'View pending patches',
     
'available_tasks' => 'View available tasks',
     
'pending_issues' => 'View all pending issues',
    ),
  ),
)
?>

But that's not what they output at all. (Oh, yes it is. I just couldn't see the link information, 'cause they were linked ;-)

The array provides actual HTML, not a representation that gets refactored later.

So:

http://localhost/myagaric_svn/www/?q=node/add/project_issue/good_project...

http://localhost/myagaric_svn/www/?q=node/add/project_issue/good_project...

http://localhost/myagaric_svn/www/?q=node/add/project_issue/good_project...

aka:

<?php
array (
 
'resources' =>
...
  array (
   
'name' => 'Support',
   
'weight' => 6,
   
'links' =>
    array (
...
     
'request_support' => '<a href="/myagaric_svn/www/?q=node/add/project_issue/good_project/support">Request support</a>',
     
'report_bug' => '<a href="/myagaric_svn/www/?q=node/add/project_issue/good_project/bug">Report new bug</a>',
     
'request_feature' => '<a href="/myagaric_svn/www/?q=node/add/project_issue/good_project/feature">Request new feature</a>',
    ),
  ),
)


 
'support' =>
  array (
   
'name' => 'Support',
   
'weight' => 6,
   
'links' =>
    array (
     
'all_support' => '<a href="/myagaric_svn/www/?q=project/issues/good_project&amp;categories=support&amp;states=all">View all support requests</a>',
     
'pending_support' => '<a href="/myagaric_svn/www/?q=project/issues/good_project&amp;categories=support">View pending support requests</a>',
     
'pending_bugs' => '<a href="/myagaric_svn/www/?q=project/issues/good_project&amp;categories=bug">View pending bug reports</a>',
     
'pending_features' => '<a href="/myagaric_svn/www/?q=project/issues/good_project&amp;categories=feature">View pending feature requests</a>',
     
'request_support' => '<a href="/myagaric_svn/www/?q=node/add/project_issue/good_project/support">Request support</a>',
     
'report_bug' => '<a href="/myagaric_svn/www/?q=node/add/project_issue/good_project/bug">Report new bug</a>',
     
'request_feature' => '<a href="/myagaric_svn/www/?q=node/add/project_issue/good_project/feature">Request new feature</a>',
    ),
  ),
?>

<?php
function organic_project_project_page_link_alter($node, &$all_links) {
 
drupal_set_message('<pre>'. var_export($node,TRUE) .'</pre>');
}
?>

<?php
stdClass
::__set_state(array(
  
'nid' => '2',
  
'vid' => '2',
  
'type' => 'project_project',
  
'status' => '1',
  
'created' => '1220205231',
  
'changed' => '1220207696',
  
'comment' => 0,
  
'promote' => '1',
  
'sticky' => '0',
  
'revision_timestamp' => '1220207696',
  
'title' => 'Good project',
  
'body' => '
Good project description


'
,
  
'teaser' => 'Good project description',
  
'log' => '',
  
'format' => '1',
  
'uid' => '1',
  
'name' => 'submin',
  
'picture' => '',
  
'data' => 'a:0:{}',
  
'uri' => 'good_project',
  
'homepage' => '',
  
'changelog' => '',
  
'cvs' => '',
  
'demo' => '',
  
'release_directory' => '',
  
'documentation' => '',
  
'screenshots' => '',
  
'license' => '',
  
'og_selective' => '0',
  
'og_description' => 'More description',
  
'og_theme' => '',
  
'og_register' => '0',
  
'og_directory' => '1',
  
'og_notification' => '0',
  
'og_language' => '',
  
'og_private' => '0',
  
'releases' => '1',
  
'version_format' => '',
  
'project_release_show_snapshots' => true,
  
'components' =>
  array (
   
0 => 'Code',
   
1 => 'Documentation',
   
2 => 'Miscellaneous',
   
3 => 'User interface',
  ),
  
'mail_copy_filter' => false,
  
'mail_copy_filter_state' => false,
  
'issues' => '1',
  
'help' => NULL,
  
'mail_digest' => '',
  
'mail_copy' => '',
  
'mail_reminder' => '0',
  
'last_comment_timestamp' => '1220205586',
  
'last_comment_name' => NULL,
  
'comment_count' => '0',
  
'taxonomy' =>
  array (
  ),
  
'files' =>
  array (
  ),
  
'readmore' => false,
  
'content' =>
  array (
   
'body' =>
    array (
     
'#value' => '
Good project description


'
,
     
'#weight' => 0,
    ),
   
'download_table' =>
    array (
     
'#value' => '
Releases
'
,
     
'#weight' => 1,
    ),
  ),
))
?>

 

Post new comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <small> <pre> <strike> <sub> <sup> <kbd> <s>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.