aastuce : pnsearchapi pas de compatibilité ascendante
Auteur Sujet
Post 
Juste pour dire pour ceux qui utilisent des plugins de recherche (pour le module recherche), que ceux développé pour les modules pn0.7 ne marchait pas, en effet la méthode de recherche à changer depuis peu (çà touche pagemaster, pnforum ...)

en faites, vous avez toujours la phase de recherche, ensuite les résultats sont stockés dans une table "temporaire"
c'est la phase de stockage qui n'est pas implémenté

http://community.postnuke.com/Wiki-ModuleProgrammingPart4.htm

voir exemple sur la recherche d'utilisateur
  1. <?php 
  2. /** 
  3.  * PostNuke Application Framework 
  4.  * 
  5.  * ;@copyright (c) 2001, PostNuke Development Team 
  6.  * ;@link http://www.postnuke.com 
  7.  * ;@version $Id: pnsearchapi.php 22325 2007-07-04 19:44:26Z rgasch $ 
  8.  * ;@license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 
  9.  * ;@package PostNuke_System_Modules 
  10.  * ;@subpackage Users 
  11. */ 
  12.  
  13. /** 
  14.  * Search plugin info 
  15.  **/ 
  16. function users_searchapi_info() 
  17.     pnModLangLoad('Users', 'user'); 
  18.     return array('title' => 'Users', 
  19.                  'functions' => array('Users' => 'search')); 
  20.  
  21. /** 
  22.  * Search form component 
  23.  **/ 
  24. function users_searchapi_options($args) 
  25.     if (SecurityUtil::checkPermission('Users::', '::', ACCESS_READ)) { 
  26.         // Create output object - this object will store all of our output so that 
  27.         // we can return it easily when required 
  28.         $pnRender = pnRender::getInstance('Users'); 
  29.         $pnRender->assign('active',(isset($args['active'])&&isset($args['active']['Users']))||(!isset($args['active']))); 
  30.         return $pnRender->fetch('users_search_options.htm'); 
  31.     } 
  32.  
  33.     return ''; 
  34.  
  35. function users_searchapi_search($args) 
  36.     // Security check 
  37.     if (!SecurityUtil::checkPermission('Users::', '::', ACCESS_READ)) { 
  38.         return $items; 
  39.     } 
  40.  
  41.     // get the db and table info 
  42.     pnModDBInfoLoad('Profile', 'Profile'); 
  43.     pnModDBInfoLoad('Users', 'Users'); 
  44.     pnModLangLoad('Profile', 'user'); 
  45.     $dbconn  = pnDBGetConn(true); 
  46.     $pntable = pnDBGetTables(); 
  47.     $userstable  = $pntable['users']; 
  48.     $userscolumn = $pntable['users_column']; 
  49.     $datacolumn  = $pntable['user_data_column']; 
  50.     $propcolumn  = $pntable['user_property_column']; 
  51.     $searchTable = $pntable['search_result']; 
  52.     $searchColumn = $pntable['search_result_column']; 
  53.  
  54.     // Select basic user data and join _UREALNAME property into the result 
  55.     $sql = "SELECT     $datacolumn[uda_value] as name, 
  56.                        $userscolumn[uname] as uname, 
  57.                        $userscolumn[uid] as uid, 
  58.                        $userscolumn[user_regdate] as user_regdate 
  59.             FROM       $pntable[users] 
  60.             LEFT JOIN  $pntable[user_property] 
  61.                        ON $propcolumn[prop_label] = '_UREALNAME' 
  62.             LEFT JOIN  $pntable[user_data] 
  63.                        ON $datacolumn[uda_propid] = $propcolumn[prop_id] AND $datacolumn[uda_uid] = $userscolumn[uid] "; 
  64.  
  65.     // form the where clause 
  66.     $where = "WHERE $userscolumn[activated] = 1 AND "; 
  67.     $where .= search_construct_where($args, array($userscolumn['uname'], $datacolumn['uda_value'])); 
  68.  
  69.     $sql = $sql . $where; 
  70.     $result = DBUtil::executeSQL($sql); 
  71.     if (!$result) { 
  72.         return LogUtil::registerError(_GETFAILED); 
  73.     } 
  74.  
  75.     $sessionId = session_id(); 
  76.  
  77.     $insertSql = "INSERT INTO $searchTable 
  78.                       ($searchColumn[title], 
  79.                        $searchColumn[text], 
  80.                        $searchColumn[extra], 
  81.                        $searchColumn[module], 
  82.                        $searchColumn[created], 
  83.                        $searchColumn[session]) 
  84.                     VALUES "; 
  85.  
  86.     // process the result set into an array of records 
  87.     for (; !$result->EOF; $result->MoveNext()) { 
  88.         $user = $result->GetRowAssoc(2); 
  89.         if ($user['uid'] != 1 && SecurityUtil::checkPermission('Users::', "$user[uname]::$user[uid]", ACCESS_READ)) { 
  90.             $name = !empty($user['name']) ? $user['name'] : _USERS_SEARCHNOEXTRAINFOVIEWPROFILE; 
  91.             $sql = $insertSql . '(' 
  92.                    . '\'' . _USERS_SEARCH . ': ' . DataUtil::formatForStore($user['uname']) . '\', ' 
  93.                    . '\'' . DataUtil::formatForStore(_UREALNAME . ': ' . $user['name']) . '\', ' 
  94.                    . '\'' . DataUtil::formatForStore($user['uid']) . '\', ' 
  95.                    . '\'' . 'Users' . '\', ' 
  96.                    . '\'' . DataUtil::formatForStore($user['user_regdate']) . '\', ' 
  97.                    . '\'' . DataUtil::formatForStore($sessionId) . '\')'; 
  98.             $insertResult = DBUtil::executeSQL($sql); 
  99.             if (!$insertResult) { 
  100.                 return LogUtil::registerError (_GETFAILED); 
  101.             } 
  102.         } 
  103.     } 
  104.  
  105.     return true; 
  106.  
  107.  
  108. /** 
  109.  * Do last minute access checking and assign URL to items 
  110.  * 
  111.  * Access checking is ignored since access check has 
  112.  * already been done. But we do add a URL to the found user 
  113.  */ 
  114. function users_searchapi_search_check(&$args) 
  115.     $datarow = &$args['datarow']; 
  116.     $userId = $datarow['extra']; 
  117.  
  118.     $datarow['url'] = pnModUrl('Profile', 'user', 'view', array('uid' => $userId)); 
  119.  
  120.     return true; 
  121.  



EDIT pour pnforum
http://noc.postnuke.com/tracker/ind...p_id=8&atid=112

modifié par : mumuri, 17 Mai 2008 - 00:40
Données personnelles Accueil