liberty
[ class tree: liberty ] [ index: liberty ] [ all elements ]

Source for file data.userlink.php

Documentation is available at data.userlink.php

  1. <?php
  2. /**
  3.  * @version  $Revision$
  4.  * @package  liberty
  5.  * @subpackage plugins_data
  6.  * @author bigwasp bigwasp@sourceforge.net
  7.  */
  8. // +----------------------------------------------------------------------+
  9. // | Copyright (c) 2005, bitweaver.org
  10. // +----------------------------------------------------------------------+
  11. // | All Rights Reserved. See below for details and a complete list of authors.
  12. // | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
  13. // |
  14. // | For comments, please use phpdocu.sourceforge.net documentation standards!!!
  15. // | -> see http://phpdocu.sourceforge.net/
  16. // +----------------------------------------------------------------------+
  17. // | Author (TikiWiki): Damian Parker <damosoft@users.sourceforge.net>
  18. // | Reworked & Undoubtedly Screwed-Up for (Bitweaver)
  19. // | by: StarRider <starrrider@sourceforge.net>
  20. // | Reworked from: wikiplugin_usercount.php - see deprecated code below
  21. // +----------------------------------------------------------------------+
  22. // $Id$
  23.  
  24. /**
  25.  * definitions
  26.  */
  27. define( 'PLUGIN_GUID_DATAUSERLINK', 'datauserlink' );
  28. global $gLibertySystem;
  29. $pluginParams = array (
  30.     'tag' => 'USERLINK',
  31.     'auto_activate' => FALSE,
  32.     'requires_pair' => FALSE,
  33.     'load_function' => 'data_userlink',
  34.     'title' => 'UserLink per login or email',
  35.     'help_page' => 'DataPluginUserLink',
  36.     'description' => tra("Will show a link to the userpage for a given login name or email."),
  37.     'help_function' => 'data_userlink_help',
  38.     'syntax' => "{USERLINK login='bigwasp'}",
  39.     'plugin_type' => DATA_PLUGIN
  40. );
  41. $gLibertySystem->registerPlugin( PLUGIN_GUID_DATAUSERLINK, $pluginParams );
  42. $gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAUSERLINK );
  43.  
  44. // Help Function
  45. function data_userlink_help() {
  46.     $help =
  47.             '<table class="data help">'
  48.                 .'<tr>'
  49.                     .'<th>' . tra( "Key" ) . '</th>'
  50.                 .'<th>' . tra( "Type" ) . '</th>'
  51.                 .'<th>' . tra( "Comments") . '</th>'
  52.             .'</tr>'
  53.             .'<tr class="odd">'
  54.                     .'<td>login</td>'
  55.                     .'<td>' . tra( "string" ) . '<br />' . tra( "(optional)") . '</td>'
  56.                 .'<td>' . tra( "The login name to generate the link" ) . '</td>'
  57.             .'</tr>'
  58.             .'<tr class="even">'
  59.                     .'<td>email</td>'
  60.                 .'<td>' . tra( "string" ) . '<br />' . tra( "(optional)") . '</td>'
  61.                 .'<td>' . tra( "The e-mail address to generate the link" ) . '</td>'
  62.             .'</tr>'
  63.             .'<tr class="odd">'
  64.                     .'<td>label</td>'
  65.                 .'<td>' . tra( "string" ) . '<br />' . tra( "(optional)") . '</td>'
  66.                 .'<td>' . tra( "The label to show; default is user's name" ) . '</td>'
  67.             .'</tr>'
  68.         .'</table>'
  69.         .tra("Example: ") . "{USERLINK login='admin' label='Site Administrator'}";
  70.     return $help;
  71. }
  72.  
  73. // Load Function
  74. function data_userlink($data, $params) {
  75.     global $gBitUser;
  76.  
  77.     $myHash = array();
  78.     $ret = '';
  79.     extract ($params, EXTR_SKIP);
  80.  
  81.     if ( isset( $login ) ) {
  82.         $myHash['login'] = $login;
  83.     } else if ( isset( $email ) ) {
  84.         $myHash['email'] = $email;
  85.     } else if ( isset( $user_id ) ) {
  86.         $myHash['user_id'] = $user_id;
  87.     }
  88.  
  89.     $user = $gBitUser->userExists($myHash);
  90.  
  91.     if( $user != Null ) {
  92.         $tmpUser = $gBitUser->getUserInfo( array( 'user_id' => $user ) );
  93.         if ( isset( $label ) ) {
  94.             $tmpUser['link_label'] = $label;
  95.         }
  96.         $ret = $gBitUser->getDisplayName( TRUE, $tmpUser );
  97.     }
  98.     return $ret;
  99. }
  100. ?>

Documentation generated on Wed, 29 Jul 2015 13:56:21 +0000 by phpDocumentor 1.5.0-lsces