registerFunction( 'onAfterDeleteUser', 'userDeleted','getProfileGalleryTab' );
/**
* Management Tab still under construction
*
*/
class getProfileGalleryManagementTab extends cbTabHandler {
/**
* Construnctor
*/
function getProfileGalleryManagementTab() {
$this->cbTabHandler();
cbimport( 'language.cbteamplugins' );
}
/**
* Get all plugin, tab, and CB fields related with this application
* @access private
* @param object mosUser reflecting the user being displayed
*/
function _pgGetTabParameters($user){
$params = $this->params;
// Plugin Parameters
$TabParams["pgmanagementtabenabled"] = $params->get('pgManagementTabEnabled', 0);
$TabParams["pgmoderatornotification"] = $params->get('pgModeratorNotification', 1);
return $TabParams;
}
/**
* Generates the HTML to display the user profile 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 getDisplayTab($tab,$user,$ui) {
global $_CB_framework;
$tabparams=$this->_pgGetTabParameters($user);
$htmltext1 = "";
if (!$tabparams["pgmanagementtabenabled"]) return $htmltext1;
// Is user a moderator?
$isModerator=isModerator($_CB_framework->myId());
if (!$isModerator) return $htmltext1;
if($tab->description != null) {
$htmltext1 .= "\t\t
\n";
}
// if connections restriction enable
// and connections enabled on the system
// and its not me viewing then
// check if current viewer is connected with
// profile owner
if($_CB_framework->myId()==0) {
$isAnonymous = true;
} else {
$isAnonymous = false;
}
$check4connection = 0;
switch ($tabparams["cbpgaccessmode"]) {
case 'PUB':
break;
case 'REG':
if ($isAnonymous) {
$htmltext1 .= "
"
. sprintf(CBTxt::Th("Only Registered Members Allowed to view the %1\$d items in this Gallery!"), (int) $user->cb_pgtotalitems)
. "
";
return $htmltext1;
}
break;
case 'REG-S':
if ($isAnonymous) return "";
break;
case 'CON':
if ($isAnonymous) {
$htmltext1 .= "
"
. sprintf(CBTxt::Th("Sorry - connections only viewing enabled for this gallery that currently has %1\$d items in it."), (int) $user->cb_pgtotalitems)
. "
";
return $htmltext1;
}
$check4connection = 1;
break;
case 'CON-S':
if ($isAnonymous) {
return $htmltext1;
}
$check4connection = 1;
break;
default:
break;
}
if ($check4connection && !$isAnonymous && !$isModerator && !$isME) {
if ($ueConfig['allowConnections']) {
$query="SELECT COUNT(*)"
. "\n FROM #__comprofiler_members"
. "\n WHERE memberid=" . (int) $user->id
. "\n AND referenceid=" . (int) $_CB_framework->myId()
. "\n AND accepted=1 AND pending=0";
$_CB_database->setQuery($query);
$isconnected = $_CB_database->loadResult();
if (!$isconnected) {
if ($tabparams["cbpgaccessmode"] == 'CON-S') return "";
$htmltext1 .= "
" . sprintf(CBTxt::Th("Sorry - connections only viewing enabled for this gallery that currently has %1\$d items in it."), (int) $user->cb_pgtotalitems) . "
" . sprintf(CBTxt::Th("Sorry - connections only viewing enabled for this gallery that currently has %1\$d items in it."), (int) $user->cb_pgtotalitems) . "
";
return $htmltext1;
}
}
//Check to see if a user has submitted a new gallery item entry to be processed
if (($isME || ($tabparams["pgallowaccessmodeoverride"] && $isModerator)) AND isset($_POST[$this->_getPagingParamName("pgitemtitle")])) {
$htmltext0 .= $this->_pgProcessNewItem($id,$user);
}
// Find and show posts
$pagingParams = $this->_getPaging(array(),array("pgposts_"));
//check to see if the Admin enabled pagination
if ($tabparams["pgpagingenabled"]) {
//select a count of all applicable entries for pagination
$query="SELECT count(*)"
. "\n FROM #__comprofiler_plug_profilegallery"
. "\n WHERE userid=" . (int) $user->id
. "\n " . $pgWHERE;
$_CB_database->setQuery($query);
$pgtotal = $_CB_database->loadResult();
if (!is_numeric($pgtotal)) $pgtotal = 0;
if ($pagingParams["pgposts_limitstart"] === null) $pagingParams["pgposts_limitstart"] = "0";
if ($tabparams["pgentriesperpage"] > $pgtotal) $pagingParams["pgposts_limitstart"] = "0";
} else {
$pagingParams["pgposts_limitstart"] = "0";
}
$PGItemAbsoluteUserPath = $PGItemAbsolutePath . $user->id . "/";
$PGItemUserPath = $PGItemPath . $user->id . "/";
$lastitemid = $this->_pgLastItemId($user->id);
// Select all entries to be displayed
$query="SELECT *"
. "\n FROM #__comprofiler_plug_profilegallery"
. "\n WHERE userid=" . (int) $user->id
. "\n " . $pgWHERE
. "\n ORDER BY pgitemorder"
. "\n " . $pgORDERBY
;
$_CB_database->setQuery($query, (int) ( $pagingParams["pgposts_limitstart"] ? $pagingParams["pgposts_limitstart"] : 0 ), (int) $tabparams["pgentriesperpage"] );
//print $database->getQuery();
$pgitems=$_CB_database->loadObjectList();
$pgdisplaycount=count($pgitems);
// Display welcome message
$htmltext2 .= '
';
$showform = false;
$warnText = ( ( ! $isME ) ? CBTxt::T( "You are about to add an entry to somebody else's gallery as a site Moderator. Proceed ?" ) : '' );
$htmltext2 .= '
'; // close cbpgItems div
break;
case 'DF2':
$htmltext2 .= "
";
break;
case 'DF3':
// $htmltext2 .= '
'; // close cbpgItems div
break;
}
// Add paging control at end of list if paging enabled
if ($tabparams["pgpagingenabled"] && ($tabparams["pgentriesperpage"] < $pgtotal)) {
$htmltext2 .= "
";
}
} else {
$htmltext2 .= " ";
$htmltext2 .= CBTxt::Th("No Items published in this profile gallery");
$htmltext2 .= " ";
}
$htmltext2 .= "
";
// $htmltext2 .= "";
return $htmltext0 . $htmltext1 . $htmltext2;
}
function _getPGparamName( $name ) {
return $name; // return same name as field for now.
}
/**
* 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 $_CB_framework;
//fix to hide edit tab from front-end!
//if ($ui==1) return;
// Get all relevant tab parameters - these settings are global and set by the admin
$tabparams = $this->_pgGetTabParameters($user);
//print_r($tabparams);
$isModerator=isModerator($_CB_framework->myId());
if ($ui==1 && $tabparams["pgallowuserenable"]!=1 && $tabparams["cbpgenable"]!=1 && !$isModerator) {
return null;
}
$testfeature = 0; // test feature setting to allow backend running total edits set this to 1;
$return = $this->_writeTabDescription( $tab, $user );
$return .= "
\n";
// Short Greeting:
$return .= "
\n";
$return .= "
" . CBTxt::Th("Short Greeting") . ":
\n";
$return .= "
_getPGparamName("cb_pgshortgreeting")."\" mosReq=\"0\" mosLabel=\"" . htmlspecialchars(CBTxt::T("Short Greeting")) . "\" value=\"".cbUnHtmlspecialchars($user->cb_pgshortgreeting)."\" size=\"40\" />";
$return .= getFieldIcons($ui, false, true, CBTxt::Th("Enter a short greeting for your gallery viewers"), CBTxt::Th("Short Greeting").":");
$return .= "
\n";
$lists = array();
// make the select list for the special gallery yes/no fields (normally 1=yes, 0=no)
$yesno = array();
$yesno[] = moscomprofilerHTML::makeOption( '_UE_YES', _CMN_YES ); // 1
$yesno[] = moscomprofilerHTML::makeOption( '_UE_NO', _CMN_NO ); // 0
// Enable Gallery:
// logic is: that backend can edit cb field but frontend can only edit if parameter is set to allow or if moderator is viewing
//
if ($tabparams["pgallowuserenable"] || $ui==2 || $isModerator) {
$lists['_pg_EnableProfileGallery'] = moscomprofilerHTML::radioList( $yesno, $this->_getPGparamName("cb_pgenable"), 'class="inputbox" size="1" mosReq="0" mosLabel="' . htmlspecialchars(CBTxt::T("Enable Gallery")).'"', 'value', 'text', $user->cb_pgenable);
$return .= "
\n";
$return .= "
" . CBTxt::Th("Enable Gallery") . ":
\n";
$return .= "
".$lists['_pg_EnableProfileGallery'];
$return .= getFieldIcons($ui, false, false, CBTxt::Th("Select Yes or No to turn-on or off the Gallery Tab"),CBTxt::Th("Enable Gallery") . ":");
$return .= "
". $lists['_pg_AutoPublish'];
$return .= getFieldIcons($ui, false, false, CBTxt::Th("Select Yes or No to autopublish or not newly uploaded gallery items"), CBTxt::Th("Autopublish items").":");
$return .= "
". $lists['_pg_AutoApprove'];
$return .= getFieldIcons($ui, false, false,CBTxt::Th("This value can be set by the admin to over-ride the gallery plugin backend default approval parameter"), CBTxt::Th("Automatically approve") . ":");
$return .= "
\n
\n";
}
// Storage Quota setting only in backend or frontend for moderators:
if (isset($user->cb_pgtotalquotasize) && $user->cb_pgtotalquotasize) {
$quota = $user->cb_pgtotalquotasize;
} else {
$quota = $tabparams["pgdefaultquota"];
}
$return .= "
\n";
$return .= "
" . CBTxt::Th("Storage Quota (KB)") . ":
\n";
$return .= "
";
if ($ui == 2 || $isModerator) {
$return .= "_getPGparamName("cb_pgtotalquotasize")."\" mosReq=\"0\" mosLabel=\"" . htmlspecialchars(CBTxt::T("Storage Quota (KB)")) . "\" value=\"".(isset($user->cb_pgtotalquotasize) ? $user->cb_pgtotalquotasize : null)."\" size=\"10\" />";
$return .= " (" . CBTxt::Th("Default setting") . ": ".$tabparams["pgdefaultquota"].")";
} else {
$return .= $quota;
}
$return .= getFieldIcons($ui, false, false, CBTxt::Th("This value can be set by the admin to over-ride the gallery plugin backend default user quota"), CBTxt::Th("Storage Quota (KB)") . ":");
$return .= "
\n
\n";
// Uploaded Items Quota setting only in backend or frontend for moderators:
if (isset($user->cb_pgtotalquotaitems) && $user->cb_pgtotalquotaitems) {
$quota = $user->cb_pgtotalquotaitems;
} else {
$quota = $tabparams["pgnumberofgalleryitems"];
}
$return .= "
\n";
$return .= "
" . CBTxt::Th("Item Quota") . ":
\n";
$return .= "
";
if ($ui == 2 || $isModerator) {
$return .= "_getPGparamName("cb_pgtotalquotaitems")."\" mosReq=\"0\" mosLabel=\"" . htmlspecialchars(CBTxt::T("Item Quota")) . "\" value=\"".(isset($user->cb_pgtotalquotaitems) ? $user->cb_pgtotalquotaitems : null)."\" size=\"10\" />";
$return .= " (" . CBTxt::Th("Default setting").": ".$tabparams["pgnumberofgalleryitems"].")";
} else {
$return .= $quota;
}
$return .= getFieldIcons($ui, false, false, CBTxt::Th("The admin may use this to over-ride the default value of allowable items for each profile owner"), CBTxt::Th("Item Quota") . ":");
$return .= "
\n
\n";
// Single Uploaded Item Maximum Size setting only in backend or frontend for moderators:
if (isset($user->cb_pguploadsize) && $user->cb_pguploadsize) {
$quota = $user->cb_pguploadsize;
} else {
$quota = $tabparams["pgmaxsize"];
}
$return .= "
\n";
$return .= "
" . CBTxt::Th("Max single upload (KB)") . ":
\n";
$return .= "
";
if ($ui == 2 || $isModerator) {
$return .= "_getPGparamName("cb_pguploadsize")."\" mosReq=\"0\" mosLabel=\"" . htmlspecialchars(CBTxt::T("Max single upload (KB)")) . "\" value=\"".(isset($user->cb_pguploadsize) ? $user->cb_pguploadsize : null)."\" size=\"10\" />";
$return .= " (" . CBTxt::Th("Default setting") . ": ".$tabparams["pgmaxsize"].")";
} else {
$return .= $quota;
}
$return .= getFieldIcons($ui, false, false, CBTxt::Th("This value can be set by the admin to over-ride the gallery plugin backend default maximum single upload size"), CBTxt::Th("Max single upload (KB)") . ":");
$return .= "
\n
\n";
// Current Item Count Usage (information field only):
if (isset($user->cb_pgtotalitems) && $user->cb_pgtotalitems) {
$quota = $user->cb_pgtotalitems;
} else {
$quota = "0";
}
$return .= "