/** * render frontend group message * * @param cbgjGroup $row * @param array $input * @param cbgjCategory $category * @param moscomprofilerUser $user * @param object $plugin */ static function showGroupMessage( $row, $input, $category, $user, $plugin ) { $row->setPathway( CBTxt::P( 'Message [users]', array( '[users]' => cbgjClass::getOverride( 'user', true ) ) ), cbgjClass::getPluginURL( array( 'groups', 'message', (int) $category->get( 'id' ), (int) $row->get( 'id' ) ) ) ); $return = '<div class="gjGroupMessage">' . '<form action="' . cbgjClass::getPluginURL( array( 'groups', 'send', (int) $category->get( 'id' ), (int) $row->get( 'id' ) ) ) . '" method="post" enctype="multipart/form-data" name="gjForm" id="gjForm" class="gjForm form-horizontal">' . '<legend class="gjEditTitle">' . CBTxt::Ph( 'Message [users]', array( '[users]' => cbgjClass::getOverride( 'user', true ) ) ) . '</legend>' . '<div class="gjEditContentInput control-group">' . '<label class="gjEditContentInputTitle control-label">' . CBTxt::Th( 'Subject' ) . '</label>' . '<div class="gjEditContentInputField controls">' . $input['subject'] . '<span class="gjEditContentInputIcon help-inline">' . cbgjClass::getIcon( null, CBTxt::T( 'Required' ), 'icon-star' ) . cbgjClass::getIcon( CBTxt::P( 'Input [users] message subject.', array( '[users]' => cbgjClass::getOverride( 'user', true ) ) ) ) . '</span>' . '</div>' . '</div>' . '<div class="gjEditContentInput control-group">' . '<label class="gjEditContentInputTitle control-label">' . CBTxt::Th( 'Body' ) . '</label>' . '<div class="gjEditContentInputField controls">' . $input['body'] . '<span class="gjEditContentInputIcon help-inline">' . cbgjClass::getIcon( null, CBTxt::T( 'Required' ), 'icon-star' ) . cbgjClass::getIcon( CBTxt::P( 'Input [users] message body.', array( '[users]' => cbgjClass::getOverride( 'user', true ) ) ) ) . '</span>' . '</div>' . '</div>'; if ( $input['captcha'] !== false ) { $return .= '<div class="gjEditContentInput control-group">' . '<label class="gjEditContentInputTitle control-label">' . CBTxt::Th( 'Captcha' ) . '</label>' . '<div class="gjEditContentInputField controls">' . '<div style="margin-bottom: 5px;">' . $input['captcha']['code'] . '</div>' . '<div>' . $input['captcha']['input'] . '</div>' . '<span class="gjEditContentInputIcon help-inline">' . cbgjClass::getIcon( null, CBTxt::T( 'Required' ), 'icon-star' ) . '</span>' . '</div>' . '</div>'; } $return .= '<div class="gjButtonWrapper form-actions">' . '<input type="submit" value="' . htmlspecialchars( CBTxt::T( 'Send Message' ) ) . '" class="gjButton gjButtonSubmit btn btn-primary" /> ' . '<input type="button" value="' . htmlspecialchars( CBTxt::T( 'Cancel' ) ) . '" class="gjButton gjButtonCancel btn btn-mini" onclick="' . cbgjClass::getPluginURL( array( 'groups', 'show', (int) $category->get( 'id' ), (int) $row->get( 'id' ) ), CBTxt::T( 'Are you sure you want to cancel? All unsaved data will be lost!' ) ) . '" />' . '</div>' . cbGetSpoofInputTag( 'plugin' ) . '</form>' . '</div>'; echo $return; }
/** * render frontend users * * @param object $rows * @param object $pageNav * @param cbgjCategory $category * @param cbgjGroup $group * @param moscomprofilerUser $user * @param object $plugin * @return string */ static function showUsers( $rows, $pageNav, $category, $group, $user, $plugin ) { $groupUsersSearch = $plugin->params->get( 'group_users_search', 1 ); $groupUsersPaging = $plugin->params->get( 'group_users_paging', 1 ); $groupUsersLimitbox = $plugin->params->get( 'group_users_limitbox', 1 ); $return = '<form action="' . $group->getUrl() . '" method="post" name="gjForm_users" id="gjForm_users" class="gjUsers_form">' . ( $groupUsersSearch && ( $pageNav->searching || $pageNav->total ) ? '<div class="gjTop gjTopRight">' . $pageNav->search . '</div>' : null ); if ( $rows ) { $return .= '<div class="gjContent">'; foreach ( $rows as $row ) { $authorized = cbgjClass::getAuthorization( $category, $group, $user, $row->getOwner() ); $adminUrl = cbgjClass::getPluginURL( array( 'users', 'admin', (int) $category->get( 'id' ), (int) $group->get( 'id' ), (int) $row->get( 'id' ) ), CBTxt::P( 'Are you sure you want to set this [user] to [admin]?', array( '[user]' => cbgjClass::getOverride( 'user' ), '[admin]' => cbgjClass::getOverride( 'admin' ) ) ) ); $modUrl = cbgjClass::getPluginURL( array( 'users', 'mod', (int) $category->get( 'id' ), (int) $group->get( 'id' ), (int) $row->get( 'id' ) ), CBTxt::P( 'Are you sure you want to set this [user] to [mod]?', array( '[user]' => cbgjClass::getOverride( 'user' ), '[mod]' => cbgjClass::getOverride( 'moderator' ) ) ) ); $activeUrl = cbgjClass::getPluginURL( array( 'users', 'active', (int) $category->get( 'id' ), (int) $group->get( 'id' ), (int) $row->get( 'id' ) ), CBTxt::P( 'Are you sure you want to set this [user] as Active?', array( '[user]' => cbgjClass::getOverride( 'user' ) ) ) ); $inactiveUrl = cbgjClass::getPluginURL( array( 'users', 'inactive', (int) $category->get( 'id' ), (int) $group->get( 'id' ), (int) $row->get( 'id' ) ), CBTxt::P( 'Are you sure you want to set this [user] as Inactive?', array( '[user]' => cbgjClass::getOverride( 'user' ) ) ) ); $banUrl = cbgjClass::getPluginURL( array( 'users', 'ban', (int) $category->get( 'id' ), (int) $group->get( 'id' ), (int) $row->get( 'id' ) ), CBTxt::P( 'Are you sure you want to ban this [user]?', array( '[user]' => cbgjClass::getOverride( 'user' ) ) ) ); $deleteUrl = cbgjClass::getPluginURL( array( 'users', 'delete', (int) $category->get( 'id' ), (int) $group->get( 'id' ), (int) $row->get( 'id' ) ), CBTxt::P( 'Are you sure you want to delete this [user]?', array( '[user]' => cbgjClass::getOverride( 'user' ) ) ) ); if ( $row->get( 'status' ) == 0 ) { $typeClass = 'gjUserTypePENDING'; $type = CBTxt::Th( 'Pending' ); } elseif ( $row->get( 'status' ) == -1 ) { $typeClass = 'gjUserTypeBANNED'; $type = CBTxt::Th( 'Banned' ); } elseif ( $row->get( 'status' ) == 2 ) { $typeClass = 'gjUserTypeMOD'; $type = cbgjClass::getOverride( 'moderator' ); } elseif ( $row->get( 'status' ) == 3 ) { $typeClass = 'gjUserTypeADMIN'; $type = cbgjClass::getOverride( 'admin' ); } elseif ( $row->get( 'status' ) == 4 ) { $typeClass = 'gjUserTypeOWNER'; $type = cbgjClass::getOverride( 'owner' ); } else { $typeClass = 'gjUserTypeUSER'; $type = cbgjClass::getOverride( 'user' ); } if ( ( ! in_array( $row->get( 'status' ), array( -1, 4 ) ) ) && ( ( $row->get( 'status' ) != 3 ) || cbgjClass::hasAccess( 'mod_lvl2', $authorized ) ) && cbgjClass::hasAccess( 'mod_lvl3', $authorized ) ) { $ban = '<div><a href="javascript: void(0);" onclick="' . $banUrl . '"><i class="icon-lock"></i> ' . CBTxt::T( 'Ban' ) . '</a></div>'; } elseif ( ( $row->get( 'status' ) == -1 ) && cbgjClass::hasAccess( 'mod_lvl3', $authorized ) ) { $ban = '<div><a href="javascript: void(0);" onclick="' . $activeUrl . '"><i class="icon-ok"></i> ' . CBTxt::T( 'Unban' ) . '</a></div>'; } else { $ban = null; } if ( ( $row->get( 'status' ) == 1 ) && cbgjClass::hasAccess( 'mod_lvl3', $authorized ) ) { $promote = '<div><a href="javascript: void(0);" onclick="' . $modUrl . '"><i class="icon-thumbs-up"></i> ' . CBTxt::T( 'Promote' ) . '</a></div>'; } elseif ( ( $row->get( 'status' ) == 2 ) && cbgjClass::hasAccess( 'mod_lvl2', $authorized ) ) { $promote = '<div><a href="javascript: void(0);" onclick="' . $adminUrl . '"><i class="icon-thumbs-up"></i> ' . CBTxt::T( 'Promote' ) . '</a></div>'; } else { $promote = null; } if ( ( $row->get( 'status' ) == 2 ) && cbgjClass::hasAccess( 'mod_lvl3', $authorized ) ) { $demote = '<div><a href="javascript: void(0);" onclick="' . $activeUrl . '"><i class="icon-thumbs-down"></i> ' . CBTxt::T( 'Demote' ) . '</a></div>'; } elseif ( ( $row->get( 'status' ) == 3 ) && cbgjClass::hasAccess( 'mod_lvl2', $authorized ) ) { $demote = '<div><a href="javascript: void(0);" onclick="' . $modUrl . '"><i class="icon-thumbs-down"></i> ' . CBTxt::T( 'Demote' ) . '</a></div>'; } elseif ( ( $row->get( 'status' ) == 1 ) && cbgjClass::hasAccess( 'mod_lvl4', $authorized ) ) { $demote = '<div><a href="javascript: void(0);" onclick="' . $inactiveUrl . '"><i class="icon-thumbs-down"></i> ' . CBTxt::T( 'Demote' ) . '</a></div>'; } else { $demote = null; } if ( ( $row->get( 'status' ) != 4 ) && cbgjClass::hasAccess( 'mod_lvl2', $authorized ) ) { $delete = '<div><a href="javascript: void(0);" onclick="' . $deleteUrl . '"><i class="icon-remove"></i> ' . CBTxt::T( 'Delete' ) . '</a></div>'; } else { $delete = null; } $beforeMenu = cbgjClass::getIntegrations( 'gj_onBeforeGroupUserMenu', array( $row, $group, $category, $user, $plugin ) ); $afterMenu = cbgjClass::getIntegrations( 'gj_onAfterGroupUserMenu', array( $row, $group, $category, $user, $plugin ) ); $return .= '<div class="gjContentBox mini-layout">' . '<div class="gjContentBoxRow">' . $row->getOwnerName( true ) . '</div>' . '<div class="gjContentBoxRow">' . $row->getOwnerAvatar( true ) . '</div>' . '<div class="gjContentBoxRow">' . $row->getOwnerOnline() . '</div>' . '<div class="gjContentBoxRow">' . cbgjClass::getIntegrations( 'gj_onBeforeGroupUserInfo', array( $row, $group, $category, $user, $plugin ) ) . '<span class="' . $typeClass . '" title="' . cbFormatDate( $row->get( 'date' ), 1, false ) . '">' . $type . '</span>' . cbgjClass::getIntegrations( 'gj_onAfterGroupUserInfo', array( $row, $group, $category, $user, $plugin ) ) . '</div>'; if ( ( $row->get( 'status' ) == 0 ) && cbgjClass::hasAccess( 'mod_lvl4', $authorized ) ) { $return .= '<div class="gjContentBoxRow">' . '<input type="button" value="' . htmlspecialchars( CBTxt::Th( 'Approve' ) ) . '" class="gjButton btn btn-mini btn-success" onclick="' . cbgjClass::getPluginURL( array( 'users', 'active', (int) $category->get( 'id' ), (int) $group->get( 'id' ), (int) $row->get( 'id' ) ), CBTxt::P( 'Are you sure you want to set this [user] as Active?', array( '[user]' => cbgjClass::getOverride( 'user' ) ) ), true ) . '" />' . '</div>'; } if ( $beforeMenu || $ban || $delete || $promote || $demote || $afterMenu ) { $return .= '<div class="gjContentBoxRow">' . cbgjClass::getDropdown( ( $beforeMenu . $ban . $delete . $promote . $demote . $afterMenu ), CBTxt::T( 'Menu' ) ) . '</div>'; } $return .= '</div>'; } $return .= '</div>'; } else { $return .= '<div class="gjContent">'; if ( $groupUsersSearch && $pageNav->searching ) { $return .= CBTxt::Ph( 'No [user] search results found.', array( '[user]' => cbgjClass::getOverride( 'user' ) ) ); } else { $return .= CBTxt::Ph( 'There are no [users] available.', array( '[users]' => cbgjClass::getOverride( 'user', true ) ) ); } $return .= '</div>'; } if ( $groupUsersPaging ) { $return .= '<div class="gjPaging pagination pagination-centered">' . ( $pageNav->total > $pageNav->limit ? $pageNav->pagelinks : null ) . ( ! $groupUsersLimitbox ? $pageNav->getLimitBox( false ) : ( $pageNav->total ? '<div class="gjPagingLimitbox">' . $pageNav->limitbox . '</div>' : null ) ) . '</div>'; } $return .= cbGetSpoofInputTag( 'plugin' ) . '</form>'; return $return; }
/** * render frontend invites list * * @param array $rows * @param cbgjCategory $category * @param cbgjGroup $group * @param moscomprofilerUser $user * @param object $plugin * @return mixed */ static function showInvitesList( $rows, $category, $group, $user, $plugin ) { $group->setPathway( CBTxt::T( 'Invites List' ), true ); $inviteBy = explode( '|*|', $plugin->params->get( 'group_invites_by', '1|*|2|*|3|*|4' ) ); $return = '<div class="gjInvitesList">' . '<form action="' . cbgjClass::getPluginURL( array( 'invites', 'send', (int) $category->get( 'id' ), (int) $group->get( 'id' ) ) ) . '" method="post" enctype="multipart/form-data" name="gjForm" id="gjForm" class="gjForm">' . '<legend class="gjEditTitle">' . cbgjClass::getOverride( 'user', true ) . '</legend>'; if ( $rows ) { $return .= '<div class="gjContent">'; foreach ( $rows as $row ) { $cbUser =& CBuser::getInstance( (int) $row->get( 'id' ) ); if ( ! $cbUser ) { $cbUser =& CBuser::getInstance( null ); } $recipient =& $cbUser->getUserData(); if ( in_array( 1, $inviteBy ) ) { $invite = (int) $recipient->id; } elseif ( in_array( 4, $inviteBy ) ) { $invite = $recipient->email; } elseif ( in_array( 2, $inviteBy ) ) { $invite = $recipient->username; } elseif ( in_array( 3, $inviteBy ) ) { $invite = $recipient->name; } if ( ! $invite ) { $invite = (int) $row->get( 'id' ); } $inviteUrl = "document.gjForm.invites_invite.value = '" . addslashes( $invite ) . "';" . "document.gjForm.submit();"; $return .= '<div class="gjContentBox mini-layout">' . '<div class="gjContentBoxRow">' . $cbUser->getField( 'formatname', null, 'html', 'none', 'list', 0, true ) . '</div>' . '<div class="gjContentBoxRow">' . $cbUser->getField( 'avatar', null, 'html', 'none', 'list', 0, true ) . '</div>' . '<div class="gjContentBoxRow">' . $cbUser->getField( 'onlinestatus', null, 'html', 'none', 'profile', 0, true ) . '</div>' . '<div class="gjContentBoxRow">' . '<input type="button" value="' . htmlspecialchars( CBTxt::Th( 'Invite' ) ) . '" class="gjButton btn btn-success" onclick="' . $inviteUrl . '" />' . '</div>' . '</div>'; } $return .= '</div>'; } else { $return .= '<div class="gjContent">' . CBTxt::Ph( 'There are no [users] available to invite.', array( '[users]' => cbgjClass::getOverride( 'user', true ) ) ) . '</div>'; } $return .= '<div class="gjButtonWrapper form-actions">' . '<input type="button" value="' . htmlspecialchars( CBTxt::T( 'Cancel' ) ) . '" class="gjButton gjButtonCancel btn" onclick="' . cbgjClass::getPluginURL( array( 'groups', 'show', (int) $category->get( 'id' ), (int) $group->get( 'id' ) ), CBTxt::T( 'Are you sure you want to cancel? All unsaved data will be lost!' ) ) . '" />' . '</div>' . '<input type="hidden" name="invites_invite" id="invites_invite" value="" />' . '<input type="hidden" name="invites_list" id="invites_list" value="1" />' . cbGetSpoofInputTag( 'plugin' ) . '</form>' . '</div>'; echo $return; }
/** * render frontend nested groups * * @param object $rows * @param object $pageNav * @param cbgjCategory $category * @param cbgjGroup $group * @param moscomprofilerUser $user * @param object $plugin * @return string */ static function showNested( $rows, $pageNav, $category, $group, $user, $plugin ) { $groupNestedSearch = $plugin->params->get( 'group_nested_search', 1 ); $groupNestedPaging = $plugin->params->get( 'group_nested_paging', 1 ); $groupNestedLimitbox = $plugin->params->get( 'group_nested_paging', 1 ); $groupNestedDescLimit = (int) $plugin->params->get( 'group_nested_desc_limit', 150 ); $groupApprove = $plugin->params->get( 'group_approve', 0 ); $return = '<form action="' . $group->getUrl() . '" method="post" name="gjForm" id="gjForm" class="gjForm">' . ( $groupNestedSearch && ( $pageNav->searching || $pageNav->total ) ? '<div class="gjTop gjTopRight">' . $pageNav->search . '</div>' : null ); if ( $rows ) foreach ( $rows as $row ) { $authorized = cbgjClass::getAuthorization( $category, $row, $user ); if ( $row->get( 'published' ) == 1 ) { $state = '<div><a href="javascript: void(0);" onclick="' . cbgjClass::getPluginURL( array( 'groups', 'unpublish', (int) $category->get( 'id' ), (int) $row->get( 'id' ) ), CBTxt::P( 'Are you sure you want to unpublish this [group]?', array( '[group]' => cbgjClass::getOverride( 'group' ) ) ), true, false, null, true ) . '"><i class="icon-ban-circle"></i> ' . CBTxt::Th( 'Unpublish' ) . '</a></div>'; } else { $state = '<div><a href="' . cbgjClass::getPluginURL( array( 'groups', 'publish', (int) $category->get( 'id' ), (int) $row->get( 'id' ) ), null, true, false, null, true ) . '"><i class="icon-ok"></i> ' . CBTxt::Th( 'Publish' ) . '</a></div>'; } $canApprove = ( $groupApprove && ( $row->get( 'published' ) == -1 ) && cbgjClass::hasAccess( 'grp_can_publish', $authorized ) ); $beforeMenu = cbgjClass::getIntegrations( 'gj_onBeforeCategoryGroupMenu', array( $row, $category, $user, $plugin ) ); $afterMenu = cbgjClass::getIntegrations( 'gj_onAfterCategoryGroupMenu', array( $row, $category, $user, $plugin ) ); $return .= '<div class="gjContent row-fluid">' . '<div class="gjContentLogo span2">' . $row->getLogo( true, true, true ) . '</div>' . '<div class="gjContentBody mini-layout span10">' . '<div class="gjContentBodyHeader row-fluid">' . '<div class="gjContentBodyTitle span9"><h5>' . $row->getName( 0, true ) . '<small> ' . cbFormatDate( $row->get( 'date' ), 1, false ) . '</small></h5></div>' . '<div class="gjContentBodyMenu span3">'; if ( $canApprove ) { $return .= '<input type="button" value="' . htmlspecialchars( CBTxt::T( 'Approve' ) ) . '" class="gjButton btn btn-mini btn-success" onclick="' . cbgjClass::getPluginURL( array( 'groups', 'publish', (int) $category->get( 'id' ), (int) $row->get( 'id' ) ), true, true, false, null, true ) . '" />'; } else { if ( ( $row->get( 'published' ) == 0 ) || ( ( $row->get( 'published' ) == 1 ) && ( ! cbgjClass::hasAccess( 'grp_approved', $authorized ) ) ) ) { $return .= cbgjClass::getIcon( null, CBTxt::P( 'This [group] is currently unpublished.', array( '[group]' => cbgjClass::getOverride( 'group' ) ) ), 'icon-eye-close' ); } if ( cbgjClass::hasAccess( 'grp_join', $authorized ) ) { $return .= ' <input type="button" value="' . htmlspecialchars( ( cbgjClass::hasAccess( 'grp_invited', $authorized ) ? CBTxt::T( 'Accept Invite' ) : CBTxt::T( 'Join' ) ) ) . '" class="gjButton btn btn-mini btn-success" onclick="' . cbgjClass::getPluginURL( array( 'groups', 'join', (int) $category->get( 'id' ), (int) $row->get( 'id' ) ), true, true, false, null, true ) . '" />'; } } if ( $beforeMenu || cbgjClass::hasAccess( array( 'grp_leave', 'mod_lvl2', 'mod_lvl3' ), $authorized ) || $afterMenu || ( ( ! $canApprove ) && cbgjClass::hasAccess( 'grp_can_publish', $authorized ) ) || ( $canApprove && cbgjClass::hasAccess( 'grp_join', $authorized ) ) ) { $menuItems = $beforeMenu . ( $canApprove && cbgjClass::hasAccess( 'grp_join', $authorized ) ? '<div><a href="javascript: void(0);" onclick="' . cbgjClass::getPluginURL( array( 'groups', 'join', (int) $category->get( 'id' ), (int) $row->get( 'id' ) ), null, true, false, null, true ) . '"><i class="icon-plus"></i> ' . CBTxt::Th( 'Join' ) . '</a></div>' : null ) . ( cbgjClass::hasAccess( 'grp_leave', $authorized ) ? '<div><a href="javascript: void(0);" onclick="' . cbgjClass::getPluginURL( array( 'groups', 'leave', (int) $category->get( 'id' ), (int) $row->get( 'id' ) ), CBTxt::P( 'Are you sure you want to leave this [group]?', array( '[group]' => cbgjClass::getOverride( 'group' ) ) ), true, false, null, true ) . '"><i class="icon-minus"></i> ' . CBTxt::Th( 'Leave' ) . '</a></div>' : null ) . ( cbgjClass::hasAccess( 'mod_lvl3', $authorized ) ? '<div><a href="' . cbgjClass::getPluginURL( array( 'groups', 'edit', (int) $category->get( 'id' ), (int) $row->get( 'id' ) ), null, true, false, null, true ) . '"><i class="icon-pencil"></i> ' . CBTxt::Th( 'Edit' ) . '</a></div>' : null ) . ( ( ! $canApprove ) && cbgjClass::hasAccess( 'grp_can_publish', $authorized ) ? $state : null ) . ( cbgjClass::hasAccess( 'mod_lvl2', $authorized ) ? '<div><a href="javascript: void(0);" onclick="' . cbgjClass::getPluginURL( array( 'groups', 'delete', (int) $category->get( 'id' ), (int) $row->get( 'id' ) ), CBTxt::P( 'Are you sure you want to delete this [group] and all its associated [users]?', array( '[group]' => cbgjClass::getOverride( 'group' ), '[users]' => cbgjClass::getOverride( 'user', true ) ) ), true, false, null, true ) . '"><i class="icon-remove"></i> ' . CBTxt::Th( 'Delete' ) . '</a></div>' : null ) . $afterMenu; $return .= cbgjClass::getDropdown( $menuItems, CBTxt::Th( 'Menu' ) ); } $return .= '</div>' . '</div>' . '<div class="gjContentBodyInfo">' . ( $row->getDescription( $groupNestedDescLimit ) ? '<div class="well well-small">' . $row->getDescription( $groupNestedDescLimit ) . '</div>' : null ) . '</div>' . '<div class="gjContentDivider"></div>' . '<div class="gjContentBodyFooter">' . cbgjClass::getIntegrations( 'gj_onBeforeCategoryGroupInfo', array( $row, $category, $user, $plugin ), null, 'span' ) . ( ( ( ( ! $row->get( 'nested' ) ) && cbgjClass::hasAccess( 'mod_lvl2', $authorized ) ) || $row->get( 'nested' ) ) && $row->nestedCount() ? cbgjClass::getOverride( 'group', $row->nestedCount() ) . ' | ' : null ) . ( $row->userCount() ? cbgjClass::getOverride( 'user', $row->userCount() ) . ' | ' : null ) . $row->getType() . cbgjClass::getIntegrations( 'gj_onAfterCategoryGroupInfo', array( $row, $category, $user, $plugin ), null, 'span' ) . '</div>' . '</div>' . '</div>'; } else { $return .= '<div class="gjContent">'; if ( $groupNestedSearch && $pageNav->searching ) { $return .= CBTxt::Ph( 'No [group] search results found.', array( '[group]' => cbgjClass::getOverride( 'group' ) ) ); } else { $return .= CBTxt::Ph( 'There are no [groups] available.', array( '[groups]' => cbgjClass::getOverride( 'group', true ) ) ); } $return .= '</div>'; } if ( $groupNestedPaging ) { $return .= '<div class="gjPaging pagination pagination-centered">' . ( $pageNav->total > $pageNav->limit ? $pageNav->pagelinks : null ) . ( ! $groupNestedLimitbox ? $pageNav->getLimitBox( false ) : ( $pageNav->total ? '<div class="gjPagingLimitbox">' . $pageNav->limitbox . '</div>' : null ) ) . '</div>'; } $return .= cbGetSpoofInputTag( 'plugin' ) . '</form>'; return $return; }
/** * migrate old groupjive data * * @param moscomprofilerUser $user * @param object $plugin */ private function showMigrate( $user, $plugin ) { global $_CB_framework, $_CB_database; $gj_categories = $_CB_database->getTableStatus( '#__gj_grcategory' ); $gj_groups = $_CB_database->getTableStatus( '#__gj_groups' ); $gj_users = $_CB_database->getTableStatus( '#__gj_users' ); $gj_path = $_CB_framework->getCfg( 'absolute_path' ) . '/images/com_groupjive'; if ( $gj_categories ) { $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote( '#__gj_grcategory' ); $_CB_database->setQuery( $query ); $categories = $_CB_database->loadObjectList(); if ( $categories ) foreach ( $categories as $category ) { $cat = new cbgjCategory( $_CB_database ); $types = array(); if ( $category->create_open ) { $types[] = 1; } if ( $category->create_closed ) { $types[] = 2; } if ( $category->create_invite ) { $types[] = 3; } $cat->set( 'user_id', (int) ( $category->admin ? $category->admin : $user->id ) ); $cat->set( 'name', trim( strip_tags( $category->catname ) ) ); if ( $plugin->params->get( 'category_editor', 1 ) >= 2 ) { $cat->set( 'description', cbgjClass::getFilteredText( $category->descr ) ); } else { $cat->set( 'description', trim( strip_tags( $category->descr ) ) ); } $cat->set( 'types', ( is_array( $types ) ? implode( '|*|', $types ) : null ) ); $cat->set( 'date', cbgjClass::getUTCDate() ); $cat->set( 'ordering', (int) $category->ordering ); $cat->set( 'published', (int) $category->published ); if ( $category->access == 2 ) { $cat->set( 'access', 30 ); } elseif ( $category->access == 1 ) { $cat->set( 'access', -1 ); } else { $cat->set( 'access', -2 ); } if ( ! $cat->store() ) { cbgjClass::getPluginURL( array( 'tools' ), CBTxt::P( 'Category failed to migrate! Error: [error]', array( '[error]' => $cat->getError() ) ), false, true, 'error' ); } $cat_path = $plugin->imgsAbs . '/' . (int) $cat->get( 'id' ); if ( $category->cat_image ) { $mode = cbgjClass::getFilePerms(); if ( ! is_dir( $cat_path ) ) { $oldmask = @umask( 0 ); if ( @mkdir( $cat_path, cbgjClass::getFolderPerms(), true ) ) { @umask( $oldmask ); if ( ! file_exists( $plugin->imgsAbs . '/index.html' ) ) { @copy( $plugin->absPath . '/images/index.html', $plugin->imgsAbs . '/index.html' ); @chmod( $plugin->imgsAbs . '/index.html', $mode ); } if ( ! file_exists( $cat_path . '/index.html' ) ) { @copy( $plugin->absPath . '/images/index.html', $cat_path . '/index.html' ); @chmod( $cat_path . '/index.html', $mode ); } } else { @umask( $oldmask ); } } if ( file_exists( $gj_path . '/' . $category->cat_image ) && ( ! file_exists( $cat_path . '/' . $category->cat_image ) ) ) { @copy( $gj_path . '/' . $category->cat_image, $cat_path . '/' . $category->cat_image ); @chmod( $cat_path . '/' . $category->cat_imag, $mode ); } if ( file_exists( $gj_path . '/tn' . $category->cat_image ) && ( ! file_exists( $cat_path . '/tn' . $category->cat_image ) ) ) { @copy( $gj_path . '/tn' . $category->cat_image, $cat_path . '/tn' . $category->cat_image ); @chmod( $cat_path . '/tn' . $category->cat_image, $mode ); } if ( file_exists( $cat_path . $category->cat_image ) && file_exists( $cat_path . 'tn' . $category->cat_image ) ) { $cat->set( 'logo', $category->cat_image ); } } if ( $gj_groups ) { $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote( '#__gj_groups' ) . "\n WHERE " . $_CB_database->NameQuote( 'category' ) . " = " . (int) $cat->get( 'id' ); $_CB_database->setQuery( $query ); $groups = $_CB_database->loadObjectList(); if ( $groups ) foreach ( $groups as $group ) { $grp = new cbgjGroup( $_CB_database ); $grp->set( 'user_id', (int) ( $group->user_id ? $group->user_id : $user->id ) ); $grp->set( 'name', trim( strip_tags( $group->name ) ) ); if ( $plugin->params->get( 'group_editor', 1 ) >= 2 ) { $grp->set( 'description', cbgjClass::getFilteredText( $group->descr ) ); } else { $grp->set( 'description', trim( strip_tags( $group->descr ) ) ); } $grp->set( 'type', (int) $group->type ); $grp->set( 'date', $group->date_s ); $grp->set( 'category', $cat->get( 'id' ) ); $grp->set( 'published', (int) $group->active ); $grp->set( 'access', -2 ); if ( ! $grp->store() ) { cbgjClass::getPluginURL( array( 'tools' ), CBTxt::P( 'Group failed to migrate! Error: [error]', array( '[error]' => $grp->getError() ) ), false, true, 'error' ); } $grp_path = $plugin->imgsAbs . '/' . (int) $cat->get( 'id' ) . '/' . (int) $grp->get( 'id' ); if ( $group->logo ) { $mode = cbgjClass::getFilePerms(); if ( ! is_dir( $grp_path ) ) { $oldmask = @umask( 0 ); if ( @mkdir( $grp_path, cbgjClass::getFolderPerms(), true ) ) { @umask( $oldmask ); if ( ! file_exists( $plugin->imgsAbs . '/index.html' ) ) { @copy( $plugin->absPath . '/images/index.html', $plugin->imgsAbs . '/index.html' ); @chmod( $plugin->imgsAbs . '/index.html', $mode ); } if ( ! file_exists( $cat_path . '/index.html' ) ) { @copy( $plugin->absPath . '/images/index.html', $cat_path . '/index.html' ); @chmod( $cat_path . '/index.html', $mode ); } if ( ! file_exists( $grp_path . '/index.html' ) ) { @copy( $plugin->absPath . '/images/index.html', $grp_path . '/index.html' ); @chmod( $grp_path . '/index.html', $mode ); } } else { @umask( $oldmask ); } } if ( file_exists( $gj_path . '/' . $group->logo ) && ( ! file_exists( $grp_path . '/' . $group->logo ) ) ) { @copy( $gj_path . '/' . $group->logo, $grp_path . '/' . $group->logo ); @chmod( $grp_path . '/' . $group->logo, $mode ); } if ( file_exists( $gj_path . '/tn' . $group->logo ) && ( ! file_exists( $grp_path . '/tn' . $group->logo ) ) ) { @copy( $gj_path . '/tn' . $group->logo, $grp_path . '/tn' . $group->logo ); @chmod( $grp_path . '/tn' . $group->logo, $mode ); } if ( file_exists( $grp_path . $group->logo ) && file_exists( $grp_path . 'tn' . $group->logo ) ) { $grp->set( 'logo', $group->logo ); } } $owner = new cbgjUser( $_CB_database ); $owner->set( 'user_id', (int) $grp->get( 'user_id' ) ); $owner->set( 'group', (int) $grp->get( 'id' ) ); $owner->set( 'date', $grp->get( 'date' ) ); $owner->set( 'status', 4 ); if ( ! $owner->store() ) { cbgjClass::getPluginURL( array( 'tools' ), CBTxt::P( 'Owner failed to migrate! Error: [error]', array( '[error]' => $owner->getError() ) ), false, true, 'error' ); } if ( $gj_users ) { $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote( '#__gj_users' ) . "\n WHERE " . $_CB_database->NameQuote( 'id_group' ) . " = " . (int) $grp->get( 'id' ) . "\n AND " . $_CB_database->NameQuote( 'id_user' ) . " != " . (int) $grp->get( 'user_id' ); $_CB_database->setQuery( $query ); $users = $_CB_database->loadObjectList(); if ( $users ) foreach ( $users as $u ) { $usr = new cbgjUser( $_CB_database ); $usr->set( 'user_id', (int) $u->id_user ); $usr->set( 'group', (int) $grp->get( 'id' ) ); $usr->set( 'date', $u->date ); $usr->set( 'status', ( $u->status == 'active' ? 1 : 0 ) ); if ( ! $usr->store() ) { cbgjClass::getPluginURL( array( 'tools' ), CBTxt::P( 'User failed to migrate! Error: [error]', array( '[error]' => $usr->getError() ) ), false, true, 'error' ); } } } } } } } else { cbgjClass::getPluginURL( array( 'tools' ), CBTxt::T( 'Nothing to migrate.' ), false, true, 'error' ); } cbgjClass::getPluginURL( array( 'tools' ), CBTxt::T( 'GroupJive migration successful.' ), false, true ); }