Since I have users uploading resumes and personal documents that contain contact information I don't want other users seeing (only admins), I made a little hack on cb.profilegallery.php to prevent the display of files to non-admins (so the average user can only view pictures).
Seems to work just fine, but I would like to know if this is the best way to go about achieving my goal.
I replaced all code starting at line 1084 of cb.profilegallery.php (NOTE: the reason I am saying replace all of the code from 1084 down is because I can't find exactly where I added the necessary '}' so, this is easiest) :
[code:1]switch ($tabparams["cbpgdisplayformat"]){
case 'DF1': // image layout headings (none)
$filecheck = array("rtf","doc","docx","pdf","txt","xls"«»);
$piccheck = array("jpg","gif","png"«»);
if ((in_array($pgitemtype,$filecheck)) && ($isME || $isModerator)) {
if (!$pgitemapproved || !$pgitempublished) {
$htmltext2.= "<div class=\"connectionBox\" style=\"text-align:center;border:1px dotted;position:relative;height:".($tabparams["pgtnmaxheight"]+$dparm[4]+$pg_extrasize)."px;width:".($tabparams["pgtnmaxwidth"]+$dparm[5])."px;\">";
} else {
$htmltext2.= "<div class=\"connectionBox\" style=\"text-align:center;position:relative;height:".($tabparams["pgtnmaxheight"]+$dparm[4]+$pg_extrasize)."px;width:".($tabparams["pgtnmaxwidth"]+$dparm[5])."px;\">";
}
// Check file extension type
$inimagelist = in_array($pgitemtype,explode(",",$tabparams["pgimagefiletypelist"]));
if ($tabparams["pgopmode"]!="FILEMODE" && $inimagelist){
$htmltext2.= "<a href=\"".sefRelToAbs($pgitemfilenameuserpath) . "\" target=\"_blank\"><b>" . $html_pgitemtitle_formatted . "</b></a><br />"
. "<div style=\"height:".$tabparams["pgtnmaxheight"]."px;\">"
. "<a href=\"javascript:$popupname('$pglivelink','$js_pgitemtitle','$js_pgitemdescription')\">"
. "<img src=\"" . $pgitemthumbuserpath . "\" border=\"0\" height=\"$newtn_height\" width=\"$newtn_width\" alt=\"\" title=\"" . $html_pgitemdescription . "\" />"
. "</a>"
. "</div>"
. "<br /><br />";
} else {
$htmltext2.= "<a href=\"".sefRelToAbs($pgitemfilenameuserpath)."\"><b>" . $html_pgitemtitle_formatted . "</b></a><br />"
. "<div style=\"height:".$tabparams["pgtnmaxheight"]."px;\">"
. "<a href=\"$pgitemfilenameuserpath\" target=\"_blank\">"
. "<img src=\"" . $pgitemthumbuserpath . "\" border=\"0\" height=\"$newtn_height\" width=\"$newtn_width\" alt=\"\" title=\"" . $html_pgitemdescription . "\" />"
. "</a>"
. "</div>"
. "<br /><br />";
}
$htmltext2 .= "<form name=\"PGactionForm".$k."\" id=\"PGactionForm".$k."\" method=\"post\" action=\"".$base_url."\">";
$htmltext2 .= "<input type=\"hidden\" name=\"".$this->_getPagingParamName("id"«»)."\" value=\"".$pgitem->id."\" />";
$htmltext2 .= "<input type=\"submit\" name=\"PGsubmitform\" style=\"display:none;\" />";
$htmltext2 .= "<input type=\"hidden\" id=\"PGformaction\" name=\"".$this->_getPagingParamName("PGformaction"«»)."\" value=\"default\" /></form>";
if ($isME || $isModerator) {
$htmltext2 .= "<a href=\"javascript:if (confirm('" ._pg_DeleteWarning . "')) { document.PGactionForm".$k.".PGformaction.value='delete';document.PGactionForm".$k.".submit(); }\"><img style=\"cursor:«»pointer;border:0px;\" id=\"pg_c1\" src=\"components/com_comprofiler/plugin/user/plug_cbprofilegallery/images/" . $icon[0] . "\" alt=\"" ._pg_Delete."\" title=\""._pg_Delete."\"></a>";
if (!$pgitempublished) {
$htmltext2 .= "<a href=\"javascript:document.PGactionForm".$k.".PGformaction.value='publish';document.PGactionForm".$k.".submit();\"><img style=\"cursor:«»pointer;border:0px;\" id=\"pg_c2\" src=\"components/com_comprofiler/plugin/user/plug_cbprofilegallery/images/" . $icon[2] . "\" alt=\"" ._pg_Publish ."\" title=\""._pg_Publish."\"></a>";
} else {
$htmltext2 .= "<a href=\"javascript:document.PGactionForm".$k.".PGformaction.value='unpublish';document.PGactionForm".$k.".submit();\"><img style=\"cursor:«»pointer;border:0px;\" id=\"pg_c3\" src=\"components/com_comprofiler/plugin/user/plug_cbprofilegallery/images/" . $icon[1] . "\" alt=\"" ._pg_Unpublish ."\" title=\""._pg_Unpublish."\"></a>";
}
}
if ($isModerator) {
if (!$pgitemapproved) {
$htmltext2 .= "<a href=\"javascript:document.PGactionForm".$k.".PGformaction.value='approve';document.PGactionForm".$k.".submit();\"><img style=\"cursor:«»pointer;border:0px;\" id=\"pg_c4\" src=\"components/com_comprofiler/plugin/user/plug_cbprofilegallery/images/" . $icon[3] . "\" alt=\"" ._pg_Approve ."\" title=\""._pg_Approve."\"></a>";
} else {
$htmltext2 .= "<a href=\"javascript:document.PGactionForm".$k.".PGformaction.value='revoke';document.PGactionForm".$k.".submit();\"><img style=\"cursor:«»pointer;border:0px;\" id=\"pg_c5\" src=\"components/com_comprofiler/plugin/user/plug_cbprofilegallery/images/" . $icon[4] . "\" alt=\"" ._pg_Revoke ."\" title=\""._pg_Revoke."\"></a>";
}
}
if ($isME || $isModerator) {
$popform=null;
$popform .= "<form name=\"PGformaction".$k."\" id=\"PGformaction".$k."\" method=\"post\" action=\"".$base_url."\">";
$popform .= "<input type=\"hidden\" name=\"".$this->_getPagingParamName("id"«»)."\" value=\"".$pgitem->id."\" />";
$popform .= "<input type=\"hidden\" name=\"".$this->_getPagingParamName("PGformaction"«»)."\" value=\"update\" />";
$popform .= "<br /><b>"._pg_ItemTitle.":</b><br /><input class=\"inputbox\" type=\"text\" name=\"".$this->_getPagingParamName("pguitemtitle"«»)."\" size=\"30\" maxlength=\"255\" value=\"".$html_pgitemtitle."\"></input>";
$popform .= "<br /><b>"._pg_ItemDescription.":</b><br /><textarea class=\"inputbox\" cols=\"35\" rows=\"4\" name=\"".$this->_getPagingParamName("pguitemdescription"«»)."\" style=\"height:75px;width:400px;overflow:auto;\" >".$html_pgitemdescription."</textarea>";
$popform .= "<br /><input type=\"submit\" value=\""._pg_Update."\" /></form>";
//Add the localized Javascript Paramaters so that error messages are properly translated
//$popform .="\n\n<script type=\"text/javascript\">\n";
//$popform .="var _pg_TitleRequired='"._pg_TitleRequired."';\n";
//$popform .="var _TitleVariable=document.PGformaction.".$this->_getPagingParamName("pguitemtitle"«»).";\n";
//$popform .="</script>\n\n";
$htmltext2 .= "<a href=\"javascript:void(0);\" name=\"PGeditForm".$k."\" id=\"PGeditForm".$k."\" onclick=\""
."return overlib('".str_replace(array("&","\\",'"',"<",">","'","\n","\r"«»), array("&","\\\\",""","<",">","\'","\\n","\\r"«»),$popform)."', STICKY, CAPTION,'"._pg_EditPopup."', CENTER,CLOSECLICK,CLOSETEXT,'"._UE_CLOSE_OVERLIB."',WIDTH,350, ANCHOR,'PGeditForm".$k."',ANCHORALIGN,'LR','UR');\">"."<img style=\"cursor:«»pointer;border:0px;\" id=\"pg_c5\" src=\"components/com_comprofiler/plugin/user/plug_cbprofilegallery/images/" . $icon[5] . "\" alt=\"" ._pg_Edit ."\" title=\""._pg_Edit."\""."></a> ";
} } else {if(in_array($pgitemtype,$piccheck)) {
if (!$pgitemapproved || !$pgitempublished) {
$htmltext2.= "<div class=\"connectionBox\" style=\"text-align:center;border:1px dotted;position:relative;height:".($tabparams["pgtnmaxheight"]+$dparm[4]+$pg_extrasize)."px;width:".($tabparams["pgtnmaxwidth"]+$dparm[5])."px;\">";
} else {
$htmltext2.= "<div class=\"connectionBox\" style=\"text-align:center;position:relative;height:".($tabparams["pgtnmaxheight"]+$dparm[4]+$pg_extrasize)."px;width:".($tabparams["pgtnmaxwidth"]+$dparm[5])."px;\">";
}
// Check file extension type
$inimagelist = in_array($pgitemtype,explode(",",$tabparams["pgimagefiletypelist"]));
if ($tabparams["pgopmode"]!="FILEMODE" && $inimagelist){
$htmltext2.= "<a href=\"".sefRelToAbs($pgitemfilenameuserpath) . "\" target=\"_blank\"><b>" . $html_pgitemtitle_formatted . "</b></a><br />"
. "<div style=\"height:".$tabparams["pgtnmaxheight"]."px;\">"
. "<a href=\"javascript:$popupname('$pglivelink','$js_pgitemtitle','$js_pgitemdescription')\">"
. "<img src=\"" . $pgitemthumbuserpath . "\" border=\"0\" height=\"$newtn_height\" width=\"$newtn_width\" alt=\"\" title=\"" . $html_pgitemdescription . "\" />"
. "</a>"
. "</div>"
. "<br /><br />";
} else {
$htmltext2.= "<a href=\"".sefRelToAbs($pgitemfilenameuserpath)."\"><b>" . $html_pgitemtitle_formatted . "</b></a><br />"
. "<div style=\"height:".$tabparams["pgtnmaxheight"]."px;\">"
. "<a href=\"$pgitemfilenameuserpath\" target=\"_blank\">"
. "<img src=\"" . $pgitemthumbuserpath . "\" border=\"0\" height=\"$newtn_height\" width=\"$newtn_width\" alt=\"\" title=\"" . $html_pgitemdescription . "\" />"
. "</a>"
. "</div>"
. "<br /><br />";
}
$htmltext2 .= "<form name=\"PGactionForm".$k."\" id=\"PGactionForm".$k."\" method=\"post\" action=\"".$base_url."\">";
$htmltext2 .= "<input type=\"hidden\" name=\"".$this->_getPagingParamName("id"«»)."\" value=\"".$pgitem->id."\" />";
$htmltext2 .= "<input type=\"submit\" name=\"PGsubmitform\" style=\"display:none;\" />";
$htmltext2 .= "<input type=\"hidden\" id=\"PGformaction\" name=\"".$this->_getPagingParamName("PGformaction"«»)."\" value=\"default\" /></form>";
if ($isME || $isModerator) {
$htmltext2 .= "<a href=\"javascript:if (confirm('" ._pg_DeleteWarning . "')) { document.PGactionForm".$k.".PGformaction.value='delete';document.PGactionForm".$k.".submit(); }\"><img style=\"cursor:«»pointer;border:0px;\" id=\"pg_c1\" src=\"components/com_comprofiler/plugin/user/plug_cbprofilegallery/images/" . $icon[0] . "\" alt=\"" ._pg_Delete."\" title=\""._pg_Delete."\"></a>";
if (!$pgitempublished) {
$htmltext2 .= "<a href=\"javascript:document.PGactionForm".$k.".PGformaction.value='publish';document.PGactionForm".$k.".submit();\"><img style=\"cursor:«»pointer;border:0px;\" id=\"pg_c2\" src=\"components/com_comprofiler/plugin/user/plug_cbprofilegallery/images/" . $icon[2] . "\" alt=\"" ._pg_Publish ."\" title=\""._pg_Publish."\"></a>";
} else {
$htmltext2 .= "<a href=\"javascript:document.PGactionForm".$k.".PGformaction.value='unpublish';document.PGactionForm".$k.".submit();\"><img style=\"cursor:«»pointer;border:0px;\" id=\"pg_c3\" src=\"components/com_comprofiler/plugin/user/plug_cbprofilegallery/images/" . $icon[1] . "\" alt=\"" ._pg_Unpublish ."\" title=\""._pg_Unpublish."\"></a>";
}
}
if ($isModerator) {
if (!$pgitemapproved) {
$htmltext2 .= "<a href=\"javascript:document.PGactionForm".$k.".PGformaction.value='approve';document.PGactionForm".$k.".submit();\"><img style=\"cursor:«»pointer;border:0px;\" id=\"pg_c4\" src=\"components/com_comprofiler/plugin/user/plug_cbprofilegallery/images/" . $icon[3] . "\" alt=\"" ._pg_Approve ."\" title=\""._pg_Approve."\"></a>";
} else {
$htmltext2 .= "<a href=\"javascript:document.PGactionForm".$k.".PGformaction.value='revoke';document.PGactionForm".$k.".submit();\"><img style=\"cursor:«»pointer;border:0px;\" id=\"pg_c5\" src=\"components/com_comprofiler/plugin/user/plug_cbprofilegallery/images/" . $icon[4] . "\" alt=\"" ._pg_Revoke ."\" title=\""._pg_Revoke."\"></a>";
}
}
if ($isME || $isModerator) {
$popform=null;
$popform .= "<form name=\"PGformaction".$k."\" id=\"PGformaction".$k."\" method=\"post\" action=\"".$base_url."\">";
$popform .= "<input type=\"hidden\" name=\"".$this->_getPagingParamName("id"«»)."\" value=\"".$pgitem->id."\" />";
$popform .= "<input type=\"hidden\" name=\"".$this->_getPagingParamName("PGformaction"«»)."\" value=\"update\" />";
$popform .= "<br /><b>"._pg_ItemTitle.":</b><br /><input class=\"inputbox\" type=\"text\" name=\"".$this->_getPagingParamName("pguitemtitle"«»)."\" size=\"30\" maxlength=\"255\" value=\"".$html_pgitemtitle."\"></input>";
$popform .= "<br /><b>"._pg_ItemDescription.":</b><br /><textarea class=\"inputbox\" cols=\"35\" rows=\"4\" name=\"".$this->_getPagingParamName("pguitemdescription"«»)."\" style=\"height:75px;width:400px;overflow:auto;\" >".$html_pgitemdescription."</textarea>";
$popform .= "<br /><input type=\"submit\" value=\""._pg_Update."\" /></form>";
//Add the localized Javascript Paramaters so that error messages are properly translated
//$popform .="\n\n<script type=\"text/javascript\">\n";
//$popform .="var _pg_TitleRequired='"._pg_TitleRequired."';\n";
//$popform .="var _TitleVariable=document.PGformaction.".$this->_getPagingParamName("pguitemtitle"«»).";\n";
//$popform .="</script>\n\n";
$htmltext2 .= "<a href=\"javascript:void(0);\" name=\"PGeditForm".$k."\" id=\"PGeditForm".$k."\" onclick=\""
."return overlib('".str_replace(array("&","\\",'"',"<",">","'","\n","\r"«»), array("&","\\\\",""","<",">","\'","\\n","\\r"«»),$popform)."', STICKY, CAPTION,'"._pg_EditPopup."', CENTER,CLOSECLICK,CLOSETEXT,'"._UE_CLOSE_OVERLIB."',WIDTH,350, ANCHOR,'PGeditForm".$k."',ANCHORALIGN,'LR','UR');\">"."<img style=\"cursor:«»pointer;border:0px;\" id=\"pg_c5\" src=\"components/com_comprofiler/plugin/user/plug_cbprofilegallery/images/" . $icon[5] . "\" alt=\"" ._pg_Edit ."\" title=\""._pg_Edit."\""."></a> ";
} }
}
$htmltext2 .= "<br /></div>";
break;
case 'DF2': // file list layout
$htmltext2 .= "<form name=\"PGactionForm".$k."\" id=\"PGactionForm".$k."\" method=\"post\" action=\"".$base_url."\">";
$htmltext2 .= "<input type=\"hidden\" name=\"".$this->_getPagingParamName("id"«»)."\" value=\"".$pgitem->id."\" />";
$htmltext2 .= "<input type=\"submit\" name=\"PGsubmitform\" style=\"display:none;\" />";
$htmltext2 .= "<input type=\"hidden\" id=\"PGformaction\" name=\"".$this->_getPagingParamName("PGformaction"«»)."\" value=\"default\" /></form>";
$htmltext2 .= "<tr>";
$htmltext2 .= "<td>".$pgitemdate."</td>";
$htmltext2 .= "<td>".$pgitemtitle_url."</td>";
$htmltext2 .= "<td>".unHtmlspecialchars($pgitemdescription)."</td>";
if ($isME || $isModerator) $htmltext2 .= "<td>";
if ($isME || $isModerator) {
$htmltext2 .= "<a href=\"javascript:if (confirm('" ._pg_DeleteWarning . "')) { document.PGactionForm".$k.".PGformaction.value='delete';document.PGactionForm".$k.".submit(); }\">" ._pg_Delete."<br /></a>";
if (!$pgitempublished) {
$htmltext2 .= "<a href=\"javascript:document.PGactionForm".$k.".PGformaction.value='publish';document.PGactionForm".$k.".submit();\">"._pg_Publish."<br /></a>";
} else {
$htmltext2 .= "<a href=\"javascript:document.PGactionForm".$k.".PGformaction.value='unpublish';document.PGactionForm".$k.".submit();\">" ._pg_Unpublish."<br /></a>";
}
}
if ($isModerator) {
if (!$pgitemapproved) {
$htmltext2 .= "<a href=\"javascript:document.PGactionForm".$k.".PGformaction.value='approve';document.PGactionForm".$k.".submit();\">"._pg_Approve."<br /></a>";
} else {
$htmltext2 .= "<a href=\"javascript:document.PGactionForm".$k.".PGformaction.value='revoke';document.PGactionForm".$k.".submit();\">"._pg_Revoke."<br /></a>";
}
}
if ($isME || $isModerator) {
$popform=null;
$popform .= "<form name=\"PGformaction".$k."\" id=\"PGformaction".$k."\" method=\"post\" action=\"".$base_url."\">";
$popform .= "<input type=\"hidden\" name=\"".$this->_getPagingParamName("id"«»)."\" value=\"".$pgitem->id."\" />";
$popform .= "<input type=\"hidden\" name=\"".$this->_getPagingParamName("PGformaction"«»)."\" value=\"update\" />";
$popform .= "<br /><b>"._pg_ItemTitle.":</b><br /><input class=\"inputbox\" type=\"text\" name=\"".$this->_getPagingParamName("pguitemtitle"«»)."\" size=\"30\" maxlength=\"255\" value=\"".$html_pgitemtitle."\"></input>";
$popform .= "<br /><b>"._pg_ItemDescription.":</b><br /><textarea class=\"inputbox\" cols=\"35\" rows=\"4\" name=\"".$this->_getPagingParamName("pguitemdescription"«»)."\" style=\"height:75px;width:400px;overflow:auto;\" >".$html_pgitemdescription."</textarea>";
$popform .= "<br /><input type=\"submit\" value=\""._pg_Update."\" /></form>";
//Add the localized Javascript Paramaters so that error messages are properly translated
//$popform .="\n\n<script type=\"text/javascript\">\n";
//$popform .="var _pg_TitleRequired='"._pg_TitleRequired."';\n";
//$popform .="var _TitleVariable=document.PGformaction.".$this->_getPagingParamName("pguitemtitle"«»).";\n";
//$popform .="</script>\n\n";
$htmltext2 .= "<a href=\"javascript:void(0);\" name=\"PGeditForm".$k."\" id=\"PGeditForm".$k."\" onclick=\""
."return overlib('".str_replace(array("&","\\",'"',"<",">","'","\n","\r"«»), array("&","\\\\",""","<",">","\'","\\n","\\r"«»),$popform)."', STICKY, CAPTION,'"._pg_EditPopup."', CENTER,CLOSECLICK,CLOSETEXT,'"._UE_CLOSE_OVERLIB."',WIDTH,350, ANCHOR,'PGeditForm".$k."',ANCHORALIGN,'LR','UR');\">"._pg_Edit ."></a> ";
}
if ($isME || $isModerator) $htmltext2 .= "</td>";
$htmltext2 .= "</tr>";
break;
case 'DF3': // image layout headings (none)
if (!$pgitemapproved || !$pgitempublished) {
$htmltext2.= "<div class=\"connectionBox\" style=\"border:1px dotted;position:relative;height:".($tabparams["pgtnmaxheight"]+$dparm[4]+$pg_extrasize)."px;width:".($tabparams["pgtnmaxwidth"]+$dparm[5])."px;\">";
} else {
$htmltext2.= "<div class=\"connectionBox\" style=\"position:relative;height:".($tabparams["pgtnmaxheight"]+$dparm[4]+$pg_extrasize)."px;width:".($tabparams["pgtnmaxwidth"]+$dparm[5])."px;\">";
}
// Check file extension type
//<a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>
$inimagelist = in_array($pgitemtype,explode(",",$tabparams["pgimagefiletypelist"]));
if ($tabparams["pgopmode"]!="FILEMODE" && $inimagelist){
$htmltext2.= "<a href=\"".sefRelToAbs($pgitemfilenameuserpath) . "\" target=\"_blank\"><b>" . $html_pgitemtitle_formatted . "</b></a><br />"
. "<div style=\"height:".$tabparams["pgtnmaxheight"]."px;\">"
. "<a href=\"$pglivelink\" rel=\"lightbox[group]\" title=\"$html_pgitemlightbox\">"
. "<img src=\"" . $pgitemthumbuserpath . "\" border=\"0\" height=\"$newtn_height\" width=\"$newtn_width\" alt=\"\" title=\"" . $html_pgitemdescription . "\" />"
. "</a>"
. "</div>"
. "<br /><br />";
} else {
$htmltext2.= "<a href=\"".sefRelToAbs($pgitemfilenameuserpath)."\"><b>" . $html_pgitemtitle_formatted . "</b></a><br />"
. "<div style=\"height:".$tabparams["pgtnmaxheight"]."px;\">"
. "<a href=\"$pgitemfilenameuserpath\" target=\"_blank\">"
. "<img src=\"" . $pgitemthumbuserpath . "\" border=\"0\" height=\"$newtn_height\" width=\"$newtn_width\" alt=\"\" title=\"" . $html_pgitemdescription . "\" />"
. "</a>"
. "</div>"
. "<br /><br />";
}
$htmltext2 .= "<form name=\"PGactionForm".$k."\" id=\"PGactionForm".$k."\" method=\"post\" action=\"".$base_url."\">";
$htmltext2 .= "<input type=\"hidden\" name=\"".$this->_getPagingParamName("id"«»)."\" value=\"".$pgitem->id."\" />";
$htmltext2 .= "<input type=\"submit\" name=\"PGsubmitform\" style=\"display:none;\" />";
$htmltext2 .= "<input type=\"hidden\" id=\"PGformaction\" name=\"".$this->_getPagingParamName("PGformaction"«»)."\" value=\"default\" /></form>";
if ($isME || $isModerator) {
$htmltext2 .= "<a href=\"javascript:if (confirm('" ._pg_DeleteWarning . "')) { document.PGactionForm".$k.".PGformaction.value='delete';document.PGactionForm".$k.".submit(); }\"><img style=\"cursor:«»pointer;border:0px;\" id=\"pg_c1\" src=\"components/com_comprofiler/plugin/user/plug_cbprofilegallery/images/" . $icon[0] . "\" alt=\"" ._pg_Delete."\" title=\""._pg_Delete."\"></a>";
if (!$pgitempublished) {
$htmltext2 .= "<a href=\"javascript:document.PGactionForm".$k.".PGformaction.value='publish';document.PGactionForm".$k.".submit();\"><img style=\"cursor:«»pointer;border:0px;\" id=\"pg_c2\" src=\"components/com_comprofiler/plugin/user/plug_cbprofilegallery/images/" . $icon[2] . "\" alt=\"" ._pg_Publish ."\" title=\""._pg_Publish."\"></a>";
} else {
$htmltext2 .= "<a href=\"javascript:document.PGactionForm".$k.".PGformaction.value='unpublish';document.PGactionForm".$k.".submit();\"><img style=\"cursor:«»pointer;border:0px;\" id=\"pg_c3\" src=\"components/com_comprofiler/plugin/user/plug_cbprofilegallery/images/" . $icon[1] . "\" alt=\"" ._pg_Unpublish ."\" title=\""._pg_Unpublish."\"></a>";
}
}
if ($isModerator) {
if (!$pgitemapproved) {
$htmltext2 .= "<a href=\"javascript:document.PGactionForm".$k.".PGformaction.value='approve';document.PGactionForm".$k.".submit();\"><img style=\"cursor:«»pointer;border:0px;\" id=\"pg_c4\" src=\"components/com_comprofiler/plugin/user/plug_cbprofilegallery/images/" . $icon[3] . "\" alt=\"" ._pg_Approve ."\" title=\""._pg_Approve."\"></a>";
} else {
$htmltext2 .= "<a href=\"javascript:document.PGactionForm".$k.".PGformaction.value='revoke';document.PGactionForm".$k.".submit();\"><img style=\"cursor:«»pointer;border:0px;\" id=\"pg_c5\" src=\"components/com_comprofiler/plugin/user/plug_cbprofilegallery/images/" . $icon[4] . "\" alt=\"" ._pg_Revoke ."\" title=\""._pg_Revoke."\"></a>";
}
}
if ($isME || $isModerator) {
$popform=null;
$popform .= "<form name=\"PGformaction".$k."\" id=\"PGformaction".$k."\" method=\"post\" action=\"".$base_url."\">";
$popform .= "<input type=\"hidden\" name=\"".$this->_getPagingParamName("id"«»)."\" value=\"".$pgitem->id."\" />";
$popform .= "<input type=\"hidden\" name=\"".$this->_getPagingParamName("PGformaction"«»)."\" value=\"update\" />";
$popform .= "<br /><b>"._pg_ItemTitle.":</b><br /><input class=\"inputbox\" type=\"text\" name=\"".$this->_getPagingParamName("pguitemtitle"«»)."\" size=\"30\" maxlength=\"255\" value=\"".$html_pgitemtitle."\"></input>";
$popform .= "<br /><b>"._pg_ItemDescription.":</b><br /><textarea class=\"inputbox\" cols=\"35\" rows=\"4\" name=\"".$this->_getPagingParamName("pguitemdescription"«»)."\" style=\"height:75px;width:400px;overflow:auto;\" >".$html_pgitemdescription."</textarea>";
$popform .= "<br /><input type=\"submit\" value=\""._pg_Update."\" /></form>";
//Add the localized Javascript Paramaters so that error messages are properly translated
//$popform .="\n\n<script type=\"text/javascript\">\n";
//$popform .="var _pg_TitleRequired='"._pg_TitleRequired."';\n";
//$popform .="var _TitleVariable=document.PGformaction.".$this->_getPagingParamName("pguitemtitle"«»).";\n";
//$popform .="</script>\n\n";
$htmltext2 .= "<a href=\"javascript:void(0);\" name=\"PGeditForm".$k."\" id=\"PGeditForm".$k."\" onclick=\""
."return overlib('".str_replace(array("&","\\",'"',"<",">","'","\n","\r"«»), array("&","\\\\",""","<",">","\'","\\n","\\r"«»),$popform)."', STICKY, CAPTION,'"._pg_EditPopup."', CENTER,CLOSECLICK,CLOSETEXT,'"._UE_CLOSE_OVERLIB."',WIDTH,350, ANCHOR,'PGeditForm".$k."',ANCHORALIGN,'LR','UR');\">"."<img style=\"cursor:«»pointer;border:0px;\" id=\"pg_c5\" src=\"components/com_comprofiler/plugin/user/plug_cbprofilegallery/images/" . $icon[5] . "\" alt=\"" ._pg_Edit ."\" title=\""._pg_Edit."\""."></a> ";
}
$htmltext2 .= "<br /></div>";
break;
default:
$htmltext2 .= $pgitemurl . "|" . $pgitemtype . "|" . $pgitemtitle ."|" . $pgitemdescription ."<br />";
break;
}
}
switch ($tabparams["cbpgdisplayformat"]){
case 'DF1':
break;
case 'DF2':
$htmltext2 .= "</table>";
break;
case 'DF3':
break;
}
// Add paging control at end of list if paging enabled
if ($tabparams["pgpagingenabled"] && ($tabparams["pgentriesperpage"] < $pgtotal)) {
$htmltext2 .= "<div style=\"clear:both;\"> </div>";
$htmltext2 .= "<div style='width:95%;text-align:center;'>"
.$this->_writePaging($pagingParams,"pgposts_",$tabparams["pgentriesperpage"],$pgtotal)
."</div>";
}
} else {
$htmltext2 .= "<br/>";
$htmltext2 .= _pg_NoItems;
$htmltext2 .= "<br/>";
}
$htmltext2 .= "<div style=\"clear:both;\"> </div>";
return $htmltext0 . $htmltext1 . $htmltext2;
}
/**
* Generates the HTML to display the user edit tab
* @param object tab reflecting the tab database entry
* @param object mosUser reflecting the user being displayed
* @param int 1 for front-end, 2 for back-end
* @returns mixed : either string HTML for tab content, or false if ErrorMSG generated
*/
function getEditTab($tab,$user,$ui) {
global $ueConfig,$acl,$my,$mainframe;
//fix to hide edit tab from front-end!
//if ($ui==1) return;
$this->_getLanguageFile();
// Get all relevant tab parameters - these settings are global and set by the admin
$tabparams = $this->_pgGetTabParameters($user);
//print_r($tabparams);
if ($ui==1 && $tabparams["cbpgenable"]!=1 ) {
return;
}
$return="";
$return .= "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n";
if($tab->description != null) $return .= "\t\t<div class=\"tab_Description\">".unHtmlspecialchars(getLangDefinition($tab->description))."</div>\n";
if ($isModerator) {
// Short Greeting:
$return .= "<tr>\n";
$return .= " <td class=\"titleCell\">"._pg_ShortGreeting.":</td>\n";
$return .= " <td class=\"fieldCell\"><input class=\"inputbox\" type=\"text\" name=\"".$this->_getPagingParamName("cb_pgshortgreeting"«»)."\" mosReq=\"0\" mosLabel=\""._pg_ShortGreeting."\" value=\"".unHtmlspecialchars($user->cb_pgshortgreeting)."\" size=\"40\" />";
$return .= getFieldIcons($ui, false, true, _pg_ShortGreeting_Desc, _pg_ShortGreeting.":"«»);
$return .= "</td></tr>\n";
}
$lists = array();
// make the select list for the special gallery yes/no fields (normally 1=yes, 0=no)
$yesno = array();
$yesno[] = mosHTML::makeOption( '_UE_YES', _CMN_YES ); // 1
$yesno[] = mosHTML::makeOption( '_UE_NO', _CMN_NO ); // 0
// Enable Gallery:
if ($tabparams["pggalleryautoenabled"]=="0" || $ui==2) {
$lists = mosHTML::radioList( $yesno, $this->_getPagingParamName("cb_pgenable"«»), 'class="inputbox" size="1" mosReq="0" mosLabel="'._pg_EnableProfileGallery.'"', $user->cb_pgenable);
$return .= "<tr>\n";
$return .= " <td class=\"titleCell\">"._pg_EnableProfileGallery.":</td>\n";
$return .= " <td class=\"fieldCell\">".$lists;
$return .= getFieldIcons($ui, false, false, _pg_EnableProfileGallery_Desc,_pg_EnableProfileGallery.":"«»);
$return .= "</td>\n</tr>\n";
}
// Enable Autopublish Items:
if ($tabparams["pgallowautopublishoverride"]) {
$lists = mosHTML::radioList( $yesno, $this->_getPagingParamName("cb_pgautopublish"«»), 'class="inputbox" size="1" mosReq="0" mosLabel="'._pg_AutoPublish.'"', $user->cb_pgautopublish);
$return .= "<tr>\n";
$return .= " <td class=\"titleCell\">"._pg_AutoPublish.":</td>\n";
$return .= " <td class=\"fieldCell\">";
if ($tabparams["pgautopublish"]) {
$return .= $lists;
} else {
$return .= ($tabparams["cbpgautopublish"] ? _CMN_YES : _CMN_NO);
}
$return .= getFieldIcons($ui, false, false, _pg_AutoPublish_Desc, _pg_AutoPublish.":"«»);
$return .= "</td>\n</tr>\n";
}
// Auto-approve Items setting in backend:
if ($ui == 2 && $tabparams["pgallowautoapproveoverride"]) {
$lists = mosHTML::radioList( $yesno, $this->_getPagingParamName("cb_pgautoapprove"«»), 'class="inputbox" size="1" mosReq="0" mosLabel="'._pg_AutoApprove.'"', $user->cb_pgautoapprove);
$return .= "<tr>\n";
$return .= " <td class=\"titleCell\">"._pg_AutoApprove.":</td>\n";
$return .= " <td class=\"fieldCell\">". $lists;
$return .= getFieldIcons($ui, false, false,_pg_AutoApprove_Desc, _pg_AutoApprove.":"«»);
$return .= "</td>\n</tr>\n";
}
// Storage Quota (setting only in backend):
if ($user->cb_pgtotalquotasize) {
$quota = $user->cb_pgtotalquotasize;
} else {
$quota = $tabparams["pgdefaultquota"];
}
$return .= "<tr>\n";
$return .= " <td class=\"titleCell\">"._pg_TotalAllowedQuotaSize.":</td>\n";
$return .= " <td class=\"fieldCell\">";
if ($ui == 2) {
$return .= "<input class=\"inputbox\" type=\"text\" name=\"".$this->_getPagingParamName("cb_pgtotalquotasize"«»)."\" mosReq=\"0\" mosLabel=\""._pg_TotalAllowedQuotaSize."\" value=\"".$user->cb_pgtotalquotasize."\" size=\"10\" />";
$return .= " ("._pg_DefaultSetting.": ".$tabparams["pgdefaultquota"]."«»)";
} else {
$return .= $quota;
}
$return .= getFieldIcons($ui, false, false, _pg_TotalAllowedQuotaSize_Desc, _pg_TotalAllowedQuotaSize.":"«»);
$return .= "</td>\n</tr>\n";
// Uploaded Items Quota (setting only in backend):
if ($user->cb_pgtotalquotaitems) {
$quota = $user->cb_pgtotalquotaitems;
} else {
$quota = $tabparams["pgnumberofgalleryitems"];
}
$return .= "<tr>\n";
$return .= " <td class=\"titleCell\">"._pg_TotalAllowedQuotaItems.":</td>\n";
$return .= " <td class=\"fieldCell\">";
if ($ui == 2) {
$return .= "<input class=\"inputbox\" type=\"text\" name=\"".$this->_getPagingParamName("cb_pgtotalquotaitems"«»)."\" mosReq=\"0\" mosLabel=\""._pg_TotalAllowedQuotaItems."\" value=\"".$user->cb_pgtotalquotaitems."\" size=\"10\" />";
$return .= " ("._pg_DefaultSetting.": ".$tabparams["pgnumberofgalleryitems"]."«»)";
} else {
$return .= $quota;
}
$return .= getFieldIcons($ui, false, false, _pg_TotalAllowedQuotaItems_Desc, _pg_TotalAllowedQuotaItems.":"«»);
$return .= "</td>\n</tr>\n";
// Single Uploaded Item Maximum Size (setting only in backend):
if ($user->cb_pguploadsize) {
$quota = $user->cb_pguploadsize;
} else {
$quota = $tabparams["pgmaxsize"];
}
$return .= "<tr>\n";
$return .= " <td class=\"titleCell\">"._pg_MaxSingleUploadSize.":</td>\n";
$return .= " <td class=\"fieldCell\">";
if ($ui == 2) {
$return .= "<input class=\"inputbox\" type=\"text\" name=\"".$this->_getPagingParamName("cb_pguploadsize"«»)."\" mosReq=\"0\" mosLabel=\""._pg_MaxSingleUploadSize."\" value=\"".$user->cb_pguploadsize."\" size=\"10\" />";
$return .= " ("._pg_DefaultSetting.": ".$tabparams["pgmaxsize"]."«»)";
} else {
$return .= $quota;
}
$return .= getFieldIcons($ui, false, false, _pg_MaxSingleUploadSize_Desc, _pg_MaxSingleUploadSize.":"«»);
$return .= "</td>\n</tr>\n";
// Current Item Count Usage (information field only):
if ($user->cb_pgtotalitems) {
$quota = $user->cb_pgtotalitems;
} else {
$quota = "0";
}
$return .= "<tr>\n";
$return .= " <td class=\"titleCell\">"._pg_CurrentUploadedItemsCount.":</td>\n";
$return .= " <td class=\"fieldCell\">";
if ($ui == 2) {
$return .= "<input class=\"inputbox\" type=\"text\" name=\"".$this->_getPagingParamName("cb_pgtotalitems"«»)."\" mosReq=\"0\" mosLabel=\""._pg_CurrentUploadedItemsCount."\" value=\"".$user->cb_pgtotalitems."\" size=\"10\" />";
} else {
$return .= $quota;
}
$return .= getFieldIcons($ui, false, false, _pg_CurrentUploadedItemsCount_Desc, _pg_CurrentUploadedItemsCount.":"«»);
$return .= "</td>\n</tr>\n";
// Current Item Size Usage (information field only):
if ($user->cb_pgtotalsize) {
$quota = $user->cb_pgtotalsize;
} else {
$quota = "0";
}
$return .= "<tr>\n";
$return .= " <td class=\"titleCell\">"._pg_CurrentUploadedItemsSize.":</td>\n";
$return .= " <td class=\"fieldCell\">";
if ($ui == 2) {
$return .= "<input class=\"inputbox\" type=\"text\" name=\"".$this->_getPagingParamName("cb_pgtotalsize"«»)."\" mosReq=\"0\" mosLabel=\""._pg_CurrentUploadedItemsSize."\" value=\"".$user->cb_pgtotalsize."\" size=\"10\" />";
} else {
$return .= $quota;
}
$return .= getFieldIcons($ui, false, false, _pg_CurrentUploadedItemsSize_Desc, _pg_CurrentUploadedItemsSize.":"«»);
$return .= "</td>\n</tr>\n";
// Last Update (information field only):
if ($user->cb_pglastupdate) {
$quota = mosFormatDate($user->cb_pglastupdate);
} else {
$quota = _UE_NEVER;
}
$return .= "<tr>\n";
$return .= " <td class=\"titleCell\">"._pg_LastUpdate.":</td>\n";
$return .= " <td class=\"fieldCell\">";
if ($ui == 2) {
$return .= "<input class=\"inputbox\" type=\"text\" name=\"".$this->_getPagingParamName("cb_pglastupdate"«»)."\" mosReq=\"0\" mosLabel=\""._pg_LastUpdate."\" value=\"".$user->cb_pglastupdate."\" size=\"10\" />";
} else {
$return .= $quota;
}
$return .= getFieldIcons($ui, false, false, _pg_LastUpdate_Desc, _pg_LastUpdate.":"«»);
$return .= "</td>\n</tr>\n";
// Display Format:
if ($tabparams["pgallowdisplayformatoverride"]) {
$displayFormat = array();
$displayFormat[] = mosHTML::makeOption( '', ' ' );
$displayFormat[] = mosHTML::makeOption( 'DF1', _pg_DisplayFormat_DF1 );
$displayFormat[] = mosHTML::makeOption( 'DF2', _pg_DisplayFormat_DF2 );
$displayFormat[] = mosHTML::makeOption( 'DF3', _pg_DisplayFormat_DF3 );
$lists = mosHTML::«»selectList( $displayFormat, $this->_getPagingParamName("cb_pgdisplayformat"«»), 'class="inputbox" size="1" mosReq="0" mosLabel="'._pg_DisplayFormat.'"', 'value', 'text', $user->cb_pgdisplayformat );
$return .= "<tr>\n";
$return .= " <td class=\"titleCell\">"._pg_DisplayFormat.":</td>\n";
$return .= " <td class=\"fieldCell\">". $lists;
$return .= getFieldIcons($ui, false, false, _pg_DisplayFormat_Desc, _pg_DisplayFormat.":"«»);
$return .= "</td>\n</tr>\n";
}
// Access Mode:
if ($tabparams["pgallowaccessmodeoverride"]) {
$accessMode = array();
$accessMode[] = mosHTML::makeOption( '', ' ' );
$accessMode[] = mosHTML::makeOption( 'PUB', _pg_AccessMode_PUB );
$accessMode[] = mosHTML::makeOption( 'REG', _pg_AccessMode_REG );
$accessMode[] = mosHTML::makeOption( 'CON', _pg_AccessMode_CON );
$accessMode[] = mosHTML::makeOption( 'REG-S', _pg_AccessMode_REGS );
$accessMode[] = mosHTML::makeOption( 'CON-S', _pg_AccessMode_CONS );
$lists = mosHTML::«»selectList( $accessMode, $this->_getPagingParamName("cb_pgaccessmode"«»), 'class="inputbox" size="1" mosReq="0" mosLabel="'._pg_AccessMode.'"', 'value', 'text', $user->cb_pgaccessmode );
$return .= "<tr>\n";
$return .= " <td class=\"titleCell\">"._pg_AccessMode.":</td>\n";
$return .= " <td class=\"fieldCell\">". $lists;
$return .= getFieldIcons($ui, false, false, _pg_AccessMode_Desc, _pg_AccessMode.":"«»);
$return .= "</td>\n</tr>\n";
}
//$return .= "<tr>\n";
//$return .= " <td class=\"titleCell\">--- end ---</td>\n";
//$return .= " <td class=\"fieldCell\">--- end of programmed fields ! below are the standard cb fields: change fields to 0</td>\n";
//$return .= "</tr>\n";
$return .= "</table>\n";
return $return;
}
/**
* Saves the user edit tab postdata into the tab's permanent storage
* @param object tab reflecting the tab database entry
* @param object mosUser reflecting the user being displayed
* @param int 1 for front-end, 2 for back-end
* @param array _POST data for saving edited tab content as generated with getEditTab
* @returns mixed : either string HTML for tab content, or false if ErrorMSG generated
*/
function saveEditTab($tab, &$user, $ui, $postdata) {
// Get all relevant tab parameters - these settings are global and set by the admin
$tabparams = $this->_pgGetTabParameters($user);
// Short Greeting:
$cb_pgshortgreeting = $this->_getReqParam("cb_pgshortgreeting", ""«»);
$user->cb_pgshortgreeting = cbUnEscapeSQL($cb_pgshortgreeting);
// Enable Gallery:
if ($tabparams["pggalleryautoenabled"]=="0" || $ui==2) {
$cb_pgenable = $this->_getReqParam("cb_pgenable", null);
if ($cb_pgenable) {
$user->cb_pgenable = $cb_pgenable;
}
}
// Enable Autopublish Items:
if ($tabparams["pgallowautopublishoverride"]) {
if ($tabparams["pgautopublish"]) {
$cb_pgautopublish = $this->_getReqParam("cb_pgautopublish", null);
if ($cb_pgautopublish) {
$user->cb_pgautopublish = $cb_pgautopublish;
}
}
}
if ($ui == 2 && $tabparams["pgallowautoapproveoverride"]) {
// Auto-approve Items setting in backend:
$cb_pgautoapprove = $this->_getReqParam("cb_pgautoapprove", null);
if ($cb_pgautoapprove) {
$user->cb_pgautoapprove = $cb_pgautoapprove;
}
}
if ($ui == 2) {
// Item Quota (setting only in backend):
$cb_pgtotalquotaitems = $this->_getReqParam("cb_pgtotalquotaitems", null);
if ($cb_pgtotalquotaitems !== null) {
$user->cb_pgtotalquotaitems = $cb_pgtotalquotaitems;
}
}
if ($ui == 2) {
// Storage Quota (setting only in backend):
$cb_pgtotalquotasize = $this->_getReqParam("cb_pgtotalquotasize", null);
if ($cb_pgtotalquotasize !== null) {
$user->cb_pgtotalquotasize = $cb_pgtotalquotasize;
}
}
if ($ui == 2) {
// Maximum Single Upload Size (setting only in backend):
$cb_pguploadsize = $this->_getReqParam("cb_pguploadsize", null);
if ($cb_pguploadsize !== null) {
$user->cb_pguploadsize = $cb_pguploadsize;
}
}
if ($ui == 2) {
// Current Item Count Usage (information field only):
$cb_pgtotalitems = $this->_getReqParam("cb_pgtotalitems", null);
if ($cb_pgtotalitems !== null) {
$user->cb_pgtotalitems = $cb_pgtotalitems;
}
}
if ($ui == 2) {
// Current Item Size Usage (information field only):
$cb_pgtotalsize = $this->_getReqParam("cb_pgtotalsize", null);
if ($cb_pgtotalsize !== null) {
$user->cb_pgtotalsize = $cb_pgtotalsize;
}
}
if ($ui == 2) {
// Last Update Date (information field only):
$cb_pglastupdate = $this->_getReqParam("cb_pglastupdate", null);
if ($cb_pglastupdate !== null) {
$user->cb_pglasupdate = $cb_pglastupdate;
}
}
// Access Mode:
if ($tabparams["pgallowaccessmodeoverride"]) {
$cb_pgaccessmode = $this->_getReqParam("cb_pgaccessmode", null);
if ($cb_pgaccessmode) {
$user->cb_pgaccessmode = $cb_pgaccessmode;
}
}
// Display Format:
if ($tabparams["pgallowdisplayformatoverride"]) {
$cb_pgdisplayformat = $this->_getReqParam("cb_pgdisplayformat", null);
if ($cb_pgdisplayformat) {
$user->cb_pgdisplayformat = $cb_pgdisplayformat;
}
}
}
function getTabComponent($tab, $user, $ui, $postdata) {
return "Hello World of Components!";
}
/**
* UserBot Called when a user is deleted from backend (prepare future unregistration)
* @param object mosUser reflecting the user being deleted
* @param int 1 for successful deleting
* @returns true if all is ok, or false if ErrorMSG generated
*
*/
function userDeleted($user, $success) {
global $database,$ueConfig,$mainframe;
$PGItemAbsolutePath=$mainframe->GetCfg( 'absolute_path' ).'/images/comprofiler/plug_profilegallery/';
$PGItemAbsoluteUserPath = $PGItemAbsolutePath . $user->id;
$this->RemoveDirectory($PGItemAbsoluteUserPath);
print "Deleting user gallery folder ".$user->id;
$sql="DELETE FROM #__comprofiler_plug_profilegallery WHERE userid=".$user->id;
$database->SetQuery($sql);
if (!$database->query()) {
$this->_setErrorMSG("SQL error cb.profilegallery:userDeleted-1" . $database->stderr(true));
return false;
}
//NICK: Here you probably want to delete all user's files and directory using a loop through mosReadDirectory
return true;
}
/***********************************
Author : M. Niyazi Yarar
Created : February, 2006
Description : Simply clean files
and removes the directory
If any error occurs or for your suggestions,
please send me e-mail
***********************************/
function ClearDirectory($path){
if($dir_handle = opendir($path)){
while($file = readdir($dir_handle)){
if($file == "." || $file == ".."«»){
if(!@unlink($path."/".$file)){
continue;
}
}else{
@unlink($path."/".$file);
}
}
closedir($dir_handle);
return true;
// all files deleted
}else{
return false;
// directory doesn?t exist
}
}
function RemoveDirectory($path){
if($this->ClearDirectory($path)){
if(rmdir($path)){
return true;
// directory removed
}else{
return false;
// directory couldn?t removed
}
}else{
return false;
// no empty directory
}
}
} // end class getForumTab.
?>
[/code:1]