/** * Offsets date-time if time is present and $serverTimeOffset 1, then formats to CB's configured date-time format. * * @param int|string $date In "Y-m-d H:i:s" format, or int : unix timestamp * @param boolean $serverTimeOffset False: don't offset, true: offset if time also in $date * @param bool|string $showTime False don't show time even if time is present in string, timeago: show jquery timeago * @param null|string $dateFormatOverride Format override for date display * @param null|string $timeFormatOverride Format override for time display * @param null|string|int $offsetOverride Offset override for time display * @return null|string */ function cbFormatDate($date, $serverTimeOffset = true, $showTime = true, $dateFormatOverride = null, $timeFormatOverride = null, $offsetOverride = null) { global $_CB_framework, $ueConfig; if ($date == '' || $date == '0000-00-00 00:00:00' || $date == '0000-00-00') { return null; } $dateTime = Application::Date($date, $serverTimeOffset ? $offsetOverride ? $offsetOverride : null : 'UTC'); if ($showTime === 'timeago' || $showTime === 'exacttimeago') { static $JS_loaded = 0; if (!$JS_loaded++) { $js = "\$.fn.cbtimeago.defaults.strings.future = '" . addslashes(CBTxt::T('TIMEAGO_FUTURE', 'in %s')) . "';" . "\$.fn.cbtimeago.defaults.strings.past = '" . addslashes(CBTxt::T('TIMEAGO_PAST', '%s ago')) . "';" . "\$.fn.cbtimeago.defaults.strings.seconds = '" . addslashes(CBTxt::T('TIMEAGO_LESS_THAN_A_MINUTE', 'less than a minute')) . "';" . "\$.fn.cbtimeago.defaults.strings.minute = '" . addslashes(CBTxt::T('TIMEAGO_ABOUT_A_MINUTE', 'about a minute')) . "';" . "\$.fn.cbtimeago.defaults.strings.minutes = '" . addslashes(CBTxt::T('TIMEAGO_N_MINUTES', '%d minutes')) . "';" . "\$.fn.cbtimeago.defaults.strings.hour = '" . addslashes(CBTxt::T('TIMEAGO_ABOUTE_ONE_HOUR', 'about an hour')) . "';" . "\$.fn.cbtimeago.defaults.strings.hours = '" . addslashes(CBTxt::T('TIMEAGO_ABOUT_N_HOURS', 'about %d hours')) . "';" . "\$.fn.cbtimeago.defaults.strings.day = '" . addslashes(CBTxt::T('TIMEAGO_A_DAY', 'a day')) . "';" . "\$.fn.cbtimeago.defaults.strings.days = '" . addslashes(CBTxt::T('TIMEAGO_N_DAYS', '%d days')) . "';" . "\$.fn.cbtimeago.defaults.strings.month = '" . addslashes(CBTxt::T('TIMEAGO_ABOUT_A_MONTH', 'about a month')) . "';" . "\$.fn.cbtimeago.defaults.strings.months = '" . addslashes(CBTxt::T('TIMEAGO_N_MONTHS', '%d months')) . "';" . "\$.fn.cbtimeago.defaults.strings.year = '" . addslashes(CBTxt::T('TIMEAGO_ABOUT A_YEAR', 'about a year')) . "';" . "\$.fn.cbtimeago.defaults.strings.years = '" . addslashes(CBTxt::T('TIMEAGO_N_YEARS', '%d years')) . "';" . "\$( '.cbDateTimeago' ).cbtimeago();"; $_CB_framework->outputCbJQuery($js, 'cbtimeago'); } $attributes = null; if ($showTime === 'exacttimeago') { $attributes .= ' data-cbtimeago-hideago="true"'; } return '<span class="cbDateTimeago"' . $attributes . ' title="' . htmlspecialchars($dateTime->format('c')) . '"></span>'; } else { if ($dateFormatOverride || $timeFormatOverride || !$showTime) { $format = $dateFormatOverride !== null ? $dateFormatOverride : (CBTxt::T('UE_DATE_FORMAT', '') != '' ? CBTxt::T('UE_DATE_FORMAT', '') : $ueConfig['date_format']); if ($showTime) { $format .= $timeFormatOverride !== null ? $timeFormatOverride : (CBTxt::T('UE_TIME_FORMAT', '') != '' ? CBTxt::T('UE_TIME_FORMAT', '') : ' ' . (isset($ueConfig['time_format']) ? $ueConfig['time_format'] : 'H:i:s')); } } else { $format = null; } return $dateTime->format($format); } }
/** * prepare frontend event edit render * * @param int $id * @param UserTable $user */ private function showEventEdit( $id, $user ) { global $_CB_framework; $row = CBGroupJiveEvents::getEvent( (int) $id ); $isModerator = CBGroupJive::isModerator( $user->get( 'id' ) ); $groupId = $this->input( 'group', null, GetterInterface::INT ); if ( $groupId === null ) { $group = $row->group(); } else { $group = CBGroupJive::getGroup( $groupId ); } $returnUrl = $_CB_framework->pluginClassUrl( $this->_gjPlugin->element, false, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) ); if ( ! CBGroupJive::canAccessGroup( $group, $user ) ) { cbRedirect( $returnUrl, CBTxt::T( 'Group does not exist.' ), 'error' ); } elseif ( ! $isModerator ) { if ( ( ! $row->get( 'id' ) ) && ( ! CBGroupJive::canCreateGroupContent( $user, $group, 'events' ) ) ) { cbRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to schedule an event in this group.' ), 'error' ); } elseif ( $row->get( 'id' ) && ( $user->get( 'id' ) != $row->get( 'user_id' ) ) && ( CBGroupJive::getGroupStatus( $user, $group ) < 2 ) ) { cbRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to edit this event.' ), 'error' ); } } CBGroupJive::getTemplate( 'event_edit', true, true, $this->element ); $input = array(); $publishedTooltip = cbTooltip( null, CBTxt::T( 'Select publish state of this event. Unpublished events will not be visible to the public.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['published'] = moscomprofilerHTML::yesnoSelectList( 'published', 'class="form-control"' . $publishedTooltip, (int) $this->input( 'post/published', $row->get( 'published', 1 ), GetterInterface::INT ) ); $titleTooltup = cbTooltip( null, CBTxt::T( 'Input the event title. This is the title that will distinguish this event from others. Suggested to input something to uniquely identify your event.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['title'] = '<input type="text" id="title" name="title" value="' . htmlspecialchars( $this->input( 'post/title', $row->get( 'title' ), GetterInterface::STRING ) ) . '" class="form-control required" size="35"' . $titleTooltup . ' />'; $event = $_CB_framework->displayCmsEditor( 'event', $this->input( 'post/event', $row->get( 'event' ), GetterInterface::HTML ), '100%', null, 40, 10, false ); $input['event'] = cbTooltip( null, CBTxt::T( 'Input a detailed description about this event.' ), null, null, null, $event, null, 'style="display:block;"' ); $locationTooltup = cbTooltip( null, CBTxt::T( 'Input the location for this event (e.g. My House, The Park, Restaurant Name, etc..).' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['location'] = '<input type="text" id="location" name="location" value="' . htmlspecialchars( $this->input( 'post/location', $row->get( 'location' ), GetterInterface::STRING ) ) . '" class="form-control required" size="35"' . $locationTooltup . ' />'; $addressTooltup = cbTooltip( null, CBTxt::T( 'Optionally input the address for this event or click the map button to attempt to find your current location.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['address'] = '<input type="text" id="address" name="address" value="' . htmlspecialchars( $this->input( 'post/address', $row->get( 'address' ), GetterInterface::STRING ) ) . '" class="form-control" size="45"' . $addressTooltup . ' />'; $calendars = new cbCalendars( 1 ); $minYear = (int) Application::Date( ( $row->get( 'id' ) ? $row->get( 'start' ) : 'now' ), 'UTC' )->format( 'Y' ); $startTooltup = cbTooltip( null, CBTxt::T( 'Select the date and time this event starts.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['start'] = $calendars->cbAddCalendar( 'start', null, true, $this->input( 'post/start', $row->get( 'start' ), GetterInterface::STRING ), false, true, $minYear, ( $minYear + 30 ), $startTooltup ); $endTooltup = cbTooltip( null, CBTxt::T( 'Optionally select the end date and time for this event.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['end'] = $calendars->cbAddCalendar( 'end', null, false, $this->input( 'post/end', $row->get( 'end' ), GetterInterface::STRING ), false, true, $minYear, ( $minYear + 30 ), $endTooltup ); $limitTooltip = cbTooltip( null, CBTxt::T( 'Optionally input a guest limit for this event.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['limit'] = '<input type="text" id="limit" name="limit" value="' . (int) $this->input( 'post/limit', $row->get( 'limit' ), GetterInterface::INT ) . '" class="digits form-control" size="6"' . $limitTooltip . ' />'; $ownerTooltip = cbTooltip( null, CBTxt::T( 'Input the event owner id. Event owner determines the creator of the event specified as User ID.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['user_id'] = '<input type="text" id="user_id" name="user_id" value="' . (int) $this->input( 'post/user_id', $this->input( 'user', $row->get( 'user_id', $user->get( 'id' ) ), GetterInterface::INT ), GetterInterface::INT ) . '" class="digits required form-control" size="6"' . $ownerTooltip . ' />'; HTML_groupjiveEventEdit::showEventEdit( $row, $input, $group, $user, $this ); }
/** * send group message * * @param int $id * @param UserTable $user */ private function sendMessage( $id, $user ) { global $_CB_framework, $_CB_database; $row = CBGroupJive::getGroup( $id ); $returnUrl = $_CB_framework->pluginClassUrl( $this->element, false, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $row->get( 'id' ) ) ); if ( CBGroupJive::canAccessGroup( $row, $user ) ) { if ( ! CBGroupJive::isModerator( $user->get( 'id' ) ) ) { if ( ! $this->params->get( 'groups_message', 0 ) ) { cbRedirect( $returnUrl, CBTxt::T( 'You do not have access to messaging in this group.' ), 'error' ); } elseif ( ( $row->get( 'published' ) == -1 ) || ( CBGroupJive::getGroupStatus( $user, $row ) < 3 ) ) { cbRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to messaging in this group.' ), 'error' ); } elseif ( $row->params()->get( 'messaged' ) ) { $seconds = (int) $this->params->get( 'groups_message_delay', 60 ); if ( $seconds ) { $diff = Application::Date( 'now', 'UTC' )->diff( $row->get( 'messaged' ) ); if ( ( $diff === false ) || ( $diff->s < $seconds ) ) { cbRedirect( $returnUrl, CBTxt::T( 'You can not send a message to this group at this time. Please wait awhile and try again.' ), 'error' ); } } } } } else { CBGroupJive::returnRedirect( $returnUrl, CBTxt::T( 'Group does not exist.' ), 'error' ); } $message = $this->input( 'post/message', null, GetterInterface::STRING ); if ( ! $message ) { $_CB_framework->enqueueMessage( CBTxt::T( 'GROUP_MESSAGE_FAILED_TO_SEND', 'Group message failed to send! Error: [error]', array( '[error]' => CBTxt::T( 'Message not specified!' ) ) ), 'error' ); $this->showGroupMessage( $id, $user ); return; } $query = 'SELECT cb.*, j.*' . "\n FROM " . $_CB_database->NameQuote( '#__groupjive_users' ) . " AS u" . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler' ) . " AS cb" . ' ON cb.' . $_CB_database->NameQuote( 'id' ) . ' = u.' . $_CB_database->NameQuote( 'user_id' ) . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS j" . ' ON j.' . $_CB_database->NameQuote( 'id' ) . ' = cb.' . $_CB_database->NameQuote( 'id' ) . "\n WHERE u." . $_CB_database->NameQuote( 'user_id' ) . " != " . (int) $user->get( 'id' ) . "\n AND u." . $_CB_database->NameQuote( 'group' ) . " = " . (int) $row->get( 'id' ) . "\n AND cb." . $_CB_database->NameQuote( 'approved' ) . " = 1" . "\n AND cb." . $_CB_database->NameQuote( 'confirmed' ) . " = 1" . "\n AND j." . $_CB_database->NameQuote( 'block' ) . " = 0" . "\n AND u." . $_CB_database->NameQuote( 'status' ) . " > 0"; $_CB_database->setQuery( $query ); $users = $_CB_database->loadObjectList( null, '\CB\Database\Table\UserTable', array( $_CB_database ) ); if ( ! $users ) { CBGroupJive::returnRedirect( $returnUrl, CBTxt::T( 'This group has no users to message.' ) ); } else { foreach ( $users as $usr ) { CBGroupJive::sendNotification( $this->params->get( 'groups_message_type', 2 ), $user, $usr, CBTxt::T( 'Group message' ), CBTxt::T( 'GROUP_MESSAGE', 'Group [group] has sent the following message.<p>[message]</p>', array( '[message]' => $message ) ), $row ); } } $row->params()->set( 'messaged', Application::Database()->getUtcDateTime() ); $row->set( 'params', $row->params()->asJson() ); if ( $row->getError() || ( ! $row->store() ) ) { $_CB_framework->enqueueMessage( CBTxt::T( 'GROUP_FAILED_TO_SAVE', 'Group failed to save! Error: [error]', array( '[error]' => $row->getError() ) ), 'error' ); $this->showGroupMessage( $id, $user ); return; } CBGroupJive::returnRedirect( $returnUrl, CBTxt::T( 'Group messaged successfully!' ) ); }
/** * compares two dates and returns the difference object or false if failed * * @param string|int $from * @param string|int $to * @param string|int $offset * @param string $formatFrom * @return DateInterval|boolean * @deprecated 2.0 use Application::Date( $from, $offset, $formatFrom )->diff( $to ) */ public static function getUTCDateDiff($from = 'now', $to = null, $offset = null, $formatFrom = null) { return Application::Date($from, $offset, $formatFrom)->diff($to); }
/** * get or set the kunena post object * * @param \KunenaForumMessage|null $post * @return \KunenaForumMessage|null */ public function post( $post = null ) { if ( $post !== null ) { $this->_post = $post; $data = array(); foreach ( $this->_post as $k => $v ) { switch ( $k ) { case 'userid': $k = 'user_id'; break; case 'catid': $k = 'category'; break; case 'time': $k = 'date'; $v = Application::Date( $v, 'UTC' )->format( 'Y-m-d H:i:s' ); break; case 'hold': $k = 'published'; $v = ( $v == 0 ? 1 : 0 ); break; } $data[$k] = $v; } parent::bind( $data ); } return $this->_post; }
/** * @return bool */ public function canResend() { global $_PLUGINS; if ( $this->accepted() ) { return false; } if ( ( ! $this->invited() ) || Application::Cms()->getClientId() ) { return true; } static $params = null; if ( ! $params ) { $plugin = $_PLUGINS->getLoadedPlugin( 'user', 'cbgroupjive' ); $params = $_PLUGINS->getPluginParams( $plugin ); } $days = (int) $params->get( 'groups_invites_resend', 7 ); if ( ! $days ) { return false; } $diff = Application::Date( 'now', 'UTC' )->diff( $this->get( 'invited' ) ); if ( ( $diff === false ) || ( $diff->days < $days ) ) { return false; } return true; }
/** * @return int */ public function status() { static $cache = array(); $id = $this->get( 'id' ); if ( ! isset( $cache[$id] ) ) { $start = Application::Date( $this->get( 'start' ), 'UTC' )->getTimestamp(); $now = Application::Date( 'now', 'UTC' )->getTimestamp(); $status = 0; if ( $start < $now ) { $status = 1; if ( $this->get( 'end' ) && ( Application::Date( $this->get( 'end' ), 'UTC' )->getTimestamp() > $now ) ) { $status = 2; } } $cache[$id] = $status; } return $cache[$id]; }
/** * render frontend group * * @param GroupTable $row * @param mixed $users * @param mixed $invites * @param UserTable $user * @param CBplug_cbgroupjive $plugin * @return string */ static function showGroup( $row, $users, $invites, $user, $plugin ) { global $_CB_framework, $_PLUGINS; $_CB_framework->setPageTitle( htmlspecialchars( CBTxt::T( $row->get( 'name' ) ) ) ); initToolTip(); $js = "$( '.gjGroupTabsMenuNavBar' ).on( 'click', '.navbar-toggle', function() {" . "if ( ! $( this ).hasClass( 'dropdown-toggle' ) ) {" . "var navbar = $( this ).closest( '.gjGroupTabsMenuNavBar' ).find( '.navbar-collapse' );" . "var toggle = $( this ).closest( '.gjGroupTabsMenuNavBar' ).find( '.navbar-toggle' );" . "if ( toggle.hasClass( 'collapsed' ) ) {" . "navbar.addClass( 'in' );" . "toggle.removeClass( 'collapsed' );" . "} else {" . "navbar.removeClass( 'in' );" . "toggle.addClass( 'collapsed' );" . "}" . "}" . "}).find( '.cbScroller' ).cbscroller({" . "height: false" . "});" . "$( '.gjGroupTabs' ).on( 'cbtabs.selected', function( e, event, cbtabs, tab ) {" . "var dropdownNav = $( event.target ).closest( '.gjGroupTabsMenuNavBar' );" . "if ( dropdownNav.length ) {" . "var toggle = dropdownNav.find( '.navbar-toggle' );" . "if ( ! toggle.hasClass( 'collapsed' ) ) {" . "toggle.click();" . "}" . "}" . "});"; $_CB_framework->outputCbJQuery( $js, 'cbscroller' ); $isModerator = CBGroupJive::isModerator( $user->get( 'id' ) ); $isOwner = ( $user->get( 'id' ) == $row->get( 'user_id' ) ); $userStatus = CBGroupJive::getGroupStatus( $user, $row ); $counters = array(); $buttons = array(); $menu = array(); $tabs = new cbTabs( 1, 1 ); $return = null; $integrations = $_PLUGINS->trigger( 'gj_onBeforeDisplayGroup', array( &$return, &$row, &$users, &$invites, &$counters, &$buttons, &$menu, &$tabs, $user ) ); $return .= '<div class="gjGroup">' . '<div class="gjGroupCanvas gjPageHeader border-default">' . '<div class="gjPageHeaderCanvas">' . '<div class="gjPageHeaderCanvasBackground">' . $row->canvas() . '</div>' . '<div class="gjPageHeaderCanvasLogo">' . $row->logo() . '</div>'; if ( $isModerator || $isOwner || ( ( ! $isOwner ) && ( ( $userStatus === null ) || ( $userStatus === 0 ) || ( $userStatus >= 1 ) ) ) || $buttons || $menu ) { $return .= '<div class="gjPageHeaderCanvasButtons text-right">' . ( $buttons ? ' <span class="gjPageHeaderCanvasButton">' . implode( '</span> <span class="gjPageHeaderCanvasButton">', $buttons ) . '</span>' : null ); if ( $isModerator && ( $row->get( 'published' ) == -1 ) && $plugin->params->get( 'groups_create_approval', 0 ) ) { $return .= ' <span class="gjPageHeaderCanvasButton">' . '<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '\';" class="gjButton gjButtonApprove btn btn-xs btn-success">' . CBTxt::T( 'Approve' ) . '</button>' . '</span>'; } elseif ( ! $isOwner ) { if ( $userStatus === null ) { $return .= ' <span class="gjPageHeaderCanvasButton">' . ( $row->get( '_invite_id' ) ? '<button type="button" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to reject all invites to this Group?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'reject', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })" class="gjButton gjButtonReject btn btn-xs btn-danger">' . CBTxt::T( 'Reject' ) . '</button> ' : null ) . '<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'join', 'id' => (int) $row->get( 'id' ) ) ) . '\';" class="gjButton gjButtonJoin btn btn-xs btn-success">' . ( $row->get( '_invite_id' ) ? CBTxt::T( 'Accept Invite' ) : CBTxt::T( 'Join' ) ) . '</button>' . '</span>'; } elseif ( $userStatus === 0 ) { $return .= ' <span class="gjPageHeaderCanvasButton">' . '<button type="button" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to cancel your pending join request to this Group?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'cancel', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })" class="gjButton gjButtonCancel btn btn-xs btn-danger">' . CBTxt::T( 'Cancel' ) . '</button> ' . '<span class="gjButton gjButtonPending btn btn-xs btn-warning disabled">' . CBTxt::T( 'Pending Approval' ) . '</span>' . '</span>'; } } if ( $isModerator || $isOwner || $menu || ( $userStatus >= 1) ) { $menuItems = '<ul class="gjGroupMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">'; if ( $isModerator || $isOwner ) { $menuItems .= '<li class="gjGroupMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'edit', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>'; if ( ( $row->get( 'published' ) == -1 ) && $plugin->params->get( 'groups_create_approval', 0 ) ) { if ( $isModerator ) { $menuItems .= '<li class="gjGroupMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Approve' ) . '</a></li>'; } } elseif ( $row->get( 'published' ) == 1 ) { $menuItems .= '<li class="gjGroupMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to unpublish this Group?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'unpublish', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unpublish' ) . '</a></li>'; } else { $menuItems .= '<li class="gjGroupMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Publish' ) . '</a></li>'; } } if ( $plugin->params->get( 'notifications', 1 ) && ( $isModerator || ( ( $row->get( 'published' ) == 1 ) && ( $isOwner || ( $userStatus >= 1 ) ) ) ) ) { $menuItems .= '<li class="gjGroupMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'notifications', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-envelope"></span> ' . CBTxt::T( 'Notifications' ) . '</a></li>'; } if ( $isModerator || ( ( $row->get( 'published' ) == 1 ) && $plugin->params->get( 'groups_message', 0 ) && ( $isOwner || ( $userStatus >= 3 ) ) ) ) { $delay = false; if ( ( ! $isModerator ) && $row->params()->get( 'messaged' ) && $plugin->params->get( 'groups_message_delay', 60 ) ) { $seconds = (int) $plugin->params->get( 'groups_message_delay', 60 ); if ( $seconds ) { $diff = Application::Date( 'now', 'UTC' )->diff( $row->get( 'messaged' ) ); if ( ( $diff === false ) || ( $diff->s < $seconds ) ) { $delay = true; } } } if ( ! $delay ) { $menuItems .= '<li class="gjGroupMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'groups', 'func' => 'message', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-comment"></span> ' . CBTxt::T( 'Message' ) . '</a></li>'; } } if ( ( ! $isOwner ) && ( $userStatus >= 1 ) ) { $menuItems .= '<li class="gjGroupMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to leave this Group?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'leave', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-minus-circle"></span> ' . CBTxt::T( 'Leave' ) . '</a></li>'; } if ( $menu ) { $menuItems .= '<li class="gjGroupMenuItem">' . implode( '</li><li class="gjGroupMenuItem">', $menu ) . '</li>'; } if ( $isModerator || $isOwner ) { $menuItems .= '<li class="gjGroupMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this Group?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'groups', 'func' => 'delete', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>'; } $menuItems .= '</ul>'; $menuAttr = cbTooltip( 1, $menuItems, null, 'auto', null, null, null, 'class="btn btn-default btn-xs" data-cbtooltip-menu="true" data-cbtooltip-classes="qtip-nostyle"' ); $return .= ' <span class="gjPageHeaderCanvasButton">' . '<div class="gjGroupMenu btn-group">' . '<button type="button" ' . trim( $menuAttr ) . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>' . '</div>' . '</span>'; } $return .= '</div>'; } $return .= '</div>' . '<div class="gjPageHeaderBar border-default">' . '<div class="gjPageHeaderBarTitle text-primary">' . '<strong>' . htmlspecialchars( CBTxt::T( $row->get( 'name' ) ) ) . '</strong>' . '</div>' . '<div class="gjPageHeaderBarCounters text-muted small">'; if ( $row->get( 'category' ) ) { $return .= '<span class="gjPageHeaderBarCounter"><span class="gjGroupCategoryIcon fa-before fa-folder">' . ' <a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'categories', 'func' => 'show', 'id' => (int) $row->get( 'category' ) ) ) . '">' . CBTxt::T( $row->category()->get( 'name' ) ) . '</a>' . '</span></span>'; } $return .= ' <span class="gjPageHeaderBarCounter"><span class="gjGroupTypeIcon fa-before fa-globe"> ' . $row->type() . '</span></span>' . ' <span class="gjPageHeaderBarCounter"><span class="gjGroupUsersIcon fa-before fa-user"> ' . CBTxt::T( 'GROUP_USERS_COUNT', '%%COUNT%% User|%%COUNT%% Users', array( '%%COUNT%%' => (int) $row->get( '_users', 0 ) ) ) . '</span></span>' . ( $counters ? ' <span class="gjPageHeaderBarCounter">' . implode( '</span> <span class="gjPageHeaderBarCounter">', $counters ) . '</span>' : null ) . '</div>' . ( $row->get( 'description' ) ? ' <div class="gjPageHeaderBarDescription">' . cbTooltip( 1, CBTxt::T( $row->get( 'description' ) ), CBTxt::T( $row->get( 'name' ) ), 400, null, '<span class="fa fa-info-circle text-muted"></span>' ) . '</div>' : null ) . '</div>' . '</div>' . '<div class="gjGroupTabs cbTabs cbTabsMenu" id="cbtabsgrouptab" data-cbtabs-use-cookies="true">' . '<div class="gjGroupTabsMenuNavBar cbTabsMenuNavBar navbar navbar-default">' . '<div class="container-fluid">' . '<div class="navbar-header">' . '<button type="button" class="gjGroupTabsMenuNavBarToggle cbTabsMenuNavBarToggle navbar-toggle collapsed">' . '<span class="icon-bar"></span>' . '<span class="icon-bar"></span>' . '<span class="icon-bar"></span>' . '</button>' . '</div>' . '<div class="collapse navbar-collapse cbScroller">' . '<div class="cbScrollerLeft hidden">' . '<button type="button" class="btn btn-xs btn-default"><span class="fa fa-angle-left"></span></button>' . '</div>' . '<ul class="gjGroupTabsNav cbTabsNav cbTabsMenuNav nav navbar-nav cbScrollerContent"></ul>' . '<div class="cbScrollerRight hidden">' . '<button type="button" class="btn btn-xs btn-default"><span class="fa fa-angle-right"></span></button>' . '</div>' . '</div>' . '</div>' . '</div>' . '<div class="cbTabsContent cbTabsMenuContent tab-content">'; foreach ( $integrations as $integration ) { if ( ( ! $integration ) || ( ! isset( $integration['id'] ) ) || ( ! isset( $integration['title'] ) ) || ( ! isset( $integration['content'] ) ) ) { continue; } $return .= $tabs->startTab( null, $integration['title'], 'grouptab' . $integration['id'], array( 'tab' => 'cbTabNavMenu', 'pane' => 'tab-pane cbTabPaneMenu', 'override' => true ) ) . '<div class="cb_tab_content cb_tab_menu">' . $integration['content'] . '</div>' . $tabs->endTab(); } if ( $users ) { $return .= $tabs->startTab( null, CBTxt::T( 'GROUP_USERS', 'Users' ), 'grouptabusers', array( 'tab' => 'cbTabNavMenu', 'pane' => 'tab-pane cbTabPaneMenu', 'override' => true ) ) . '<div class="cb_tab_content cb_tab_menu">' . $users . '</div>' . $tabs->endTab(); } if ( $invites ) { $return .= $tabs->startTab( null, CBTxt::T( 'Invites' ), 'grouptabinvites', array( 'tab' => 'cbTabNavMenu', 'pane' => 'tab-pane cbTabPaneMenu', 'override' => true ) ) . '<div class="cb_tab_content cb_tab_menu">' . $invites . '</div>' . $tabs->endTab(); } $return .= '</div>' . '</div>' . '</div>'; $_PLUGINS->trigger( 'gj_onAfterDisplayGroup', array( &$return, $row, $users, $invites, $user ) ); $_CB_framework->setMenuMeta(); echo $return; }