# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: W:\www\dev\administrator\components\com_comprofiler # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. --- administrator/components/com_comprofiler/plugin.foundation.php +++ administrator/components/com_comprofiler/plugin.foundation.php @@ -31,41 +31,115 @@ * @param boolean TRUE if should return "&:Itemid...." instead of "&Itemid..." (with FALSE as default), === 0 if return only int * @return string "&Itemid=xxx" */ -function getCBprofileItemid( $htmlspecialchars = false, $defaultItemid = true ) { - global $_CB__Cache_ProfileItemid, $_CB_database, $_CB_framework; +function getCBprofileItemid( $htmlspecialchars = false, $defaultItemid = true, $task = 'userprofile' ) { + global $_CB_framework, $_CB_database, $_CB__Cache_ProfileItemid; - if ( $_CB__Cache_ProfileItemid === null ) { - // if( ! isset( $_REQUEST['Itemid'] ) ) { - $_CB_database->setQuery("SELECT id FROM #__menu WHERE link = 'index.php?option=com_comprofiler' AND published=1 AND access " . ( $_CB_framework->myCmsGid() == 0 ? "= " : "<= " ) . (int) $_CB_framework->myCmsGid() ); - $Itemid = (int) $_CB_database->loadResult(); - // } else { - // $Itemid = (int) cbGetParam( $_REQUEST, 'Itemid', 0 ); - // } - if ( ! $Itemid ) { // if no user profile, try getting itemid of the default list: - $_CB_database->setQuery("SELECT id FROM #__menu WHERE link = 'index.php?option=com_comprofiler&task=usersList' AND published=1 AND access " . ( $_CB_framework->myCmsGid() == 0 ? "= " : "<= " ) . (int) $_CB_framework->myCmsGid() ); - $Itemid = (int) $_CB_database->loadResult(); + $task = trim( $task ); + + if ( $_CB__Cache_ProfileItemid[$task] === null ) { + $base = 'index.php?option=com_comprofiler'; + + switch( $task ) { + case 'banprofile': + $link = $base . '&task=banprofile'; + break; + case 'moderateimages': + $link = $base . '&task=moderateimages'; + break; + case 'moderatereports': + $link = $base . '&task=moderatereports'; + break; + case 'moderatebans': + $link = $base . '&task=moderatebans'; + break; + case 'reportuser': + $link = $base . '&task=reportuser'; + break; + case 'processreports': + case 'viewreports': + $link = $base . '&task=viewreports'; + break; + case 'approveimage': + $link = $base . '&task=approveimage'; + break; + case 'pendingapprovaluser': + case 'approveuser': + $link = $base . '&task=approveuser'; + break; + case 'teamcredits': + $link = $base . '&task=teamcredits'; + break; + case 'userslist': + $link = $base . '&task=userslist'; + break; + case 'emailuser': + $link = $base . '&task=emailuser'; + break; + case 'saveuseredit': + case 'userdetails': + $link = $base . '&task=userdetails'; + break; + case 'useravatar': + $link = $base . '&task=useravatar'; + break; + case 'addconnection': + case 'removeconnection': + case 'denyconnection': + case 'acceptconnection': + case 'saveconnections': + case 'processconnectionactions': + case 'manageconnections': + $link = $base . '&task=manageconnections'; + break; + case 'login': + $link = $base . '&task=login'; + break; + case 'logout': + $link = $base . '&task=logout'; + break; + case 'sendnewpass': + case 'lostpassword': + $link = $base . '&task=lostpassword'; + break; + case 'saveregisters': + case 'registers': + $link = $base . '&task=registers'; + break; + case 'confirm': + case 'userprofile': + default: + $link = $base; + break; } - if ( ( ! $Itemid ) && $defaultItemid && ( checkJversion() != 1 ) ) { - /** Nope, just use the homepage then. * NO: USE NONE: Homepage itemid isn't appropriate at all ! better use none ! - $query = "SELECT id" - . "\n FROM #__menu" - . "\n WHERE menutype = 'mainmenu'" - . "\n AND published = 1" - . "\n ORDER BY parent, ordering" - . "\n LIMIT 1" - ; + + $myCmsGid = $_CB_framework->myCmsGid(); + $operator = ( $myCmsGid == 0 ? " = " : " <= " ); + + $query = 'SELECT ' . $_CB_database->NameQuote( 'id' ) + . "\n FROM " . $_CB_database->NameQuote( '#__menu' ) + . "\n WHERE " . $_CB_database->NameQuote( 'link' ) . " = " . $_CB_database->Quote( $link ) + . "\n AND " . $_CB_database->NameQuote( 'published' ) . " = 1" + . "\n AND " . $_CB_database->NameQuote( 'access' ) . $operator . (int) $myCmsGid; $_CB_database->setQuery( $query ); - $Itemid = (int) $_CB_database->loadResult(); - */ - $Itemid = 0; + $Itemid = (int) $_CB_database->loadResult(); + + // no itemid found and isn't profile itemid; attempt to obtain profile itemid: + if ( ( ! $Itemid ) && ( ( ! $task ) || ( $task != 'userprofile' ) ) ) { + $Itemid = getCBprofileItemid( null, $defaultItemid, 'userprofile' ); } - $_CB__Cache_ProfileItemid = $Itemid; + + if ( ( ! $Itemid ) && $defaultItemid && ( checkJversion() != 1 ) ) { + $Itemid = 0; } - if ( $_CB__Cache_ProfileItemid ) { + + $_CB__Cache_ProfileItemid[$task] = $Itemid; + } + + if ( $_CB__Cache_ProfileItemid[$task] ) { if ( is_bool( $htmlspecialchars ) ) { - return ( $htmlspecialchars ? "&" : "&") . "Itemid=" . $_CB__Cache_ProfileItemid; + return ( $htmlspecialchars ? '&' : '&' ) . 'Itemid=' . $_CB__Cache_ProfileItemid[$task]; } else { - return $_CB__Cache_ProfileItemid; + return $_CB__Cache_ProfileItemid[$task]; } } else { return null;