/** * prepare frontend about render * * @param string $return * @param GroupTable $group * @param string $users * @param string $invites * @param array $counters * @param array $buttons * @param array $menu * @param cbTabs $tabs * @param UserTable $user * @return array|null */ public function showAbout( &$return, &$group, &$users, &$invites, &$counters, &$buttons, &$menu, &$tabs, $user ) { global $_CB_framework; if ( CBGroupJive::isModerator( $user->get( 'id' ) ) || ( ( $group->get( 'published' ) == 1 ) && ( CBGroupJive::getGroupStatus( $user, $group ) >= 3 ) ) ) { $menu[] = '<a href="' . $_CB_framework->pluginClassUrl( $this->element, true, array( 'action' => 'about', 'func' => 'edit', 'id' => (int) $group->get( 'id' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'About' ) . '</a>'; } $about = trim( $group->params()->get( 'about_content' ) ); if ( ( ! $about ) || ( $about == '<p></p>' ) ) { return null; } CBGroupJive::getTemplate( 'about', true, true, $this->element ); if ( $this->params->get( 'groups_about_substitutions', 0 ) ) { $about = CBuser::getInstance( (int) $user->get( 'id' ), false )->replaceUserVars( $about, false, false, null, false ); } if ( $this->params->get( 'groups_about_content_plugins', 0 ) ) { $about = Application::Cms()->prepareHtmlContentPlugins( $about ); } return array( 'id' => 'about', 'title' => CBTxt::T( 'About' ), 'content' => HTML_groupjiveAbout::showAbout( $about, $group, $user, $this ) ); }
/** * Mutator: * Prepares field data for saving to database (safe transfer from $postdata to $user) * Override * * @param FieldTable $field * @param UserTable $user RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit) * @param array $postdata Typically $_POST (but not necessarily), filtering required. * @param string $reason 'edit' for save user edit, 'register' for save registration */ public function prepareFieldDataSave( &$field, &$user, &$postdata, $reason ) { $hybrid = new cbconnectHybrid(); $fieldName = $field->get( 'name' ); $provider = $hybrid->getProviderFromField( $fieldName ); $providerId = $hybrid->getIdFromProvider( $provider ); $currentValue = $user->get( $fieldName ); $value = cbGetParam( $postdata, $fieldName ); if ( $currentValue && ( $user->get( 'id' ) == Application::MyUser()->get( 'id' ) ) ) { if ( is_array( $value ) ) { if ( isset( $value[0] ) && ( $value[0] == 1 ) ) { $postdata[$fieldName] = ''; } } $value = cbGetParam( $postdata, $fieldName ); if ( $value === '' ) { try { $adapter = $hybrid->getAdapter( $providerId ); if ( $adapter ) { switch( $provider ) { case 'facebook': /** @noinspection PhpUndefinedMethodInspection */ $adapter->api()->api( '/me/permissions', 'DELETE' ); break; } $adapter->logout(); } } catch ( Exception $e ) {} } } if ( ( ! Application::Cms()->getClientId() ) && $user->get( 'id' ) && $currentValue && ( $value !== '' ) ) { $postdata[$fieldName] = $currentValue; } parent::prepareFieldDataSave( $field, $user, $postdata, $reason ); }
/** * render frontend event activity * * @param CB\Plugin\Activity\Table\ActivityTable $row * @param string $title * @param string $message * @param CB\Plugin\Activity\Activity $stream * @param EventTable $event * @param cbgjEventsPlugin $plugin * @return string */ static function showEventActivity( $row, &$title, &$message, $stream, $event, $plugin ) { global $_CB_framework; $title = CBTxt::T( 'GROUP_EVENT_ACTIVITY_TITLE', 'scheduled an event in [group]', array( '[group]' => '<strong><a href="' . $_CB_framework->pluginClassUrl( $plugin->_gjPlugin->element, true, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $event->group()->get( 'id' ) ) ) . '">' . htmlspecialchars( CBTxt::T( $event->group()->get( 'name' ) ) ) . '</a></strong>' ) ); $user = CBuser::getMyUserDataInstance(); $userStatus = CBGroupJive::getGroupStatus( $user, $event->group() ); $eventOwner = ( $user->get( 'id' ) == $event->get( 'user_id' ) ); $showAddress = $plugin->params->get( 'groups_events_address', 1 ); $address = htmlspecialchars( $event->get( 'location' ) ); if ( $showAddress ) { if ( $event->get( 'address' ) ) { $mapUrl = CBTxt::T( 'GROUP_EVENT_ADDRESS_MAP_URL', 'https://www.google.com/maps/place/[address]', array( '[location]' => urlencode( $event->get( 'location' ) ), '[address]' => urlencode( $event->get( 'address' ) ) ) ); } else { $mapUrl = CBTxt::T( 'GROUP_EVENT_LOCATION_MAP_URL', 'https://www.google.com/maps/search/[location]', array( '[location]' => urlencode( $event->get( 'location' ) ), '[address]' => urlencode( $event->get( 'address' ) ) ) ); } if ( $mapUrl ) { $address = '<a href="' . htmlspecialchars( $mapUrl ) . '" target="_blank" rel="nofollow">' . $address . '</a>'; } } $canAttend = ( ( ! $eventOwner ) && ( $event->status() != 1 ) && ( ! $event->get( '_attending' ) ) && ( $userStatus >= 1 ) && ( ( ! $event->get( 'limit' ) ) || ( $event->get( 'limit' ) && ( $event->get( '_guests' ) < $event->get( 'limit' ) ) ) ) ); $return = '<div class="gjEventActivity">' . '<div class="gjGroupEventsRow row' . ( $event->status() == 1 ? ' gjGroupEventExpired' : ( $event->status() == 2 ? ' gjGroupEventActive' : null ) ) . '">' . '<div class="gjGroupEventCalendar col-md-2 hidden-sm hidden-xs">' . '<div class="panel panel-default text-center">' . '<div class="gjGroupEventMonth panel-body">' . cbFormatDate( $event->get( 'start' ), true, false, 'M' ) . '</div>' . '<div class="gjGroupEventDay panel-footer">' . cbFormatDate( $event->get( 'start' ), true, false, 'j' ) . '</div>' . '</div>' . '</div>' . '<div class="gjGroupEventContainer col-md-10 col-sm-12 col-xs-12">' . '<div class="panel ' . ( $event->status() == 1 ? 'panel-warning' : ( $event->status() == 2 ? 'panel-primary' : 'panel-default' ) ) . '">' . '<div class="gjGroupEventHeader panel-heading">' . '<div class="row">' . '<div class="gjGroupEventTitle ' . ( $canAttend ? 'col-sm-8' : 'col-sm-12' ) . '">' . htmlspecialchars( $event->get( 'title' ) ) . '</div>'; if ( $canAttend ) { $return .= '<div class="gjGroupEventMenu col-sm-4 text-right">' . '<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'events', 'func' => 'attend', 'id' => (int) $event->get( 'id' ) ) ) . '\';" class="gjButton gjButtonAttend btn btn-xs btn-success">' . CBTxt::T( 'Attend' ) . '</button>' . '</div>'; } $return .= '</div>' . '</div>' . '<div class="gjGroupEventDetails panel-body small">'; if ( $event->status() == 1 ) { $return .= '<div class="gjGroupEventNotice text-warning text-right">' . CBTxt::T( 'This event has ended.' ) . '</div>'; } elseif ( $event->status() == 2 ) { if ( $event->get( 'end' ) ) { $return .= '<div class="gjGroupEventNotice text-primary text-right">' . CBTxt::T( 'GROUP_EVENT_ENDS_IN', 'This event is currently in progress and ends in [timeago].', array( '[timeago]' => cbFormatDate( $event->get( 'end' ), true, 'exacttimeago' ) ) ) . '</div>'; } else { $return .= '<div class="gjGroupEventNotice text-primary text-right">' . CBTxt::T( 'This event is currently in progress.' ) . '</div>'; } } else { $return .= '<div class="gjGroupEventNotice text-right">' . CBTxt::T( 'GROUP_EVENT_STARTS_IN', 'This event starts in [timeago].', array( '[timeago]' => cbFormatDate( $event->get( 'start' ), true, 'exacttimeago' ) ) ) . '</div>'; } $return .= '<div class="gjGroupEventDate">' . '<span class="gjGroupEventIcon fa fa-clock-o text-center"></span> ' . $event->date() . '</div>' . '<div class="gjGroupEventLocation">' . '<span class="gjGroupEventIcon fa fa-map-marker text-center"></span> ' . $address . '</div>' . '<div class="gjGroupEventAttending">' . '<div class="gjGroupEventGuests">' . '<span class="gjGroupEventIcon fa fa-users text-center"></span> ' . '<a href="' . htmlspecialchars( $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'events', 'func' => 'attending', 'id' => (int) $event->get( 'id' ), 'return' => CBGroupJive::getReturn() ) ) ) . '">' . ( $event->get( 'limit' ) ? CBTxt::T( 'GROUP_GUESTS_COUNT_LIMITED', '%%COUNT%% of [limit] Guest|%%COUNT%% of [limit] Guests', array( '%%COUNT%%' => (int) $event->get( '_guests', 0 ), '[limit]' => (int) $event->get( 'limit' ) ) ) : CBTxt::T( 'GROUP_GUESTS_COUNT', '%%COUNT%% Guest|%%COUNT%% Guests', array( '%%COUNT%%' => (int) $event->get( '_guests', 0 ) ) ) ) . '</a>' . '</div>' . '</div>' . '</div>' . '<div class="gjGroupEventDescription panel-footer">' . '<div class="cbMoreLess">' . '<div class="cbMoreLessContent">' . ( $plugin->params->get( 'groups_events_content_plugins', 0 ) ? Application::Cms()->prepareHtmlContentPlugins( $event->get( 'event' ) ) : $event->get( 'event' ) ) . '</div>' . '<div class="cbMoreLessOpen fade-edge hidden">' . '<a href="javascript: void(0);" class="cbMoreLessButton">' . CBTxt::T( 'See More' ) . '</a>' . '</div>' . '</div>' . '</div>' . '</div>' . '</div>' . '</div>' . '</div>'; return $return; }
/** * Outputs stream HTML * * @param bool $inline * @param bool $data * @return string */ public function stream( $inline = false, $data = true ) { global $_CB_framework, $_PLUGINS; static $plugin = null; if ( ! $plugin ) { $plugin = $_PLUGINS->getLoadedPlugin( 'user', 'cbactivity' ); } if ( ! $plugin ) { return null; } if ( ! class_exists( 'CBplug_cbactivity' ) ) { $component = $_CB_framework->getCfg( 'absolute_path' ) . '/components/com_comprofiler/plugin/user/plug_cbactivity/component.cbactivity.php'; if ( file_exists( $component ) ) { include_once( $component ); } } ob_start(); $pluginTab = null; $pluginData = array( 'stream' => $this, 'inline' => $inline, 'data' => $data ); $pluginArguements = array( &$pluginTab, &$this->user, ( Application::Cms()->getClientId() ? 2 : 1 ), &$pluginData ); $_PLUGINS->call( $plugin->id, 'getCBpluginComponent', 'CBplug_cbactivity', $pluginArguements, $pluginTab ); $return = ob_get_contents(); ob_end_clean(); return $return; }
/** * @param string $value * @param string $reason * @param null|FieldTable $field * @param null|UserTable $user * @param boolean $htmlspecialchars * @param array $extra * @return string */ protected function formatFieldValueLayout($value, $reason = 'profile', $field = null, $user = null, $htmlspecialchars = true, $extra = array()) { if (in_array($reason, array('profile', 'list', 'edit', 'register')) && $value !== null && $value !== '' && $field !== null && !$field->get('_hideLayout', 0)) { switch ($reason) { case 'register': $layout = CBTxt::T($field->params->get('fieldLayoutRegister', null)); break; case 'edit': $layout = CBTxt::T($field->params->get('fieldLayoutEdit', null)); break; case 'list': $layout = CBTxt::T($field->params->get('fieldLayoutList', null)); break; case 'profile': default: $layout = CBTxt::T($field->params->get('fieldLayout', null)); break; } // Remove userdata and userfield usage of self from layout to avoid infinite loop: $layout = trim(preg_replace('/\\[cb:(userdata +field|userfield +field)="' . preg_quote($field->get('name')) . '"[^]]+\\]/i', '', $layout)); if ($layout) { $value = str_replace('[value]', $value, $layout); if ($field->params->get('fieldLayoutContentPlugins', 0)) { $value = Application::Cms()->prepareHtmlContentPlugins($value); } if ($user !== null) { $value = cbReplaceVars($value, $user, $htmlspecialchars, true, $extra); } } } return $value; }
/** * Evaluate [cb:if ...] * * @access private (public because it's recursively calling itself in the preg_replace_callback function at bottom) * * @param string|array $input * @param array $extraStrings * @return string */ public function _evaluateIfs($input, $extraStrings = array()) { // $regex = "#\[if ([^\]]+)\](.*?)\[/if\]#s"; // $regex = '#\[indent]((?:[^[]|\[(?!/?indent])|(?R))+)\[/indent]#s'; $regex = '#\\[cb:if(?: +user="******"/\\[\\] ]+)")?( +[^\\]]+)\\]((?:[^\\[]|\\[(?!/?cb:if[^\\]]*])|(?R))+)\\[/cb:if]#'; $that = $this; return preg_replace_callback($regex, function (array $matches) use($extraStrings, $that) { $regex2 = '# +(?:(&&|and|\\|\\||or|) +)?([^=<!>~ ]+) *(=|<|>|>=|<=|<>|!=|=~|!~| includes |!includes ) *"([^"]*)"#'; $conditions = null; if (preg_match_all($regex2, $matches[2], $conditions)) { $user = $that->_evaluateUserAttrib($matches[1]); $resultsIdx = 0; $results = array($resultsIdx => true); for ($i = 0, $n = count($conditions[0]); $i < $n; $i++) { $operator = $conditions[1][$i]; $field = $conditions[2][$i]; $compare = $conditions[3][$i]; $value = $conditions[4][$i]; if ($field === 'viewaccesslevel') { $var = Application::User((int) $user->getUserData()->get('id'))->getAuthorisedViewLevels(); } elseif ($field === 'usergroup') { $var = Application::User((int) $user->getUserData()->get('id'))->getAuthorisedGroups(); } elseif ($field === 'application_context') { $var = Application::Cms()->getClientId() ? 'administrator' : 'frontend'; } elseif ($field === 'language_code') { list($var) = explode('-', Application::Cms()->getLanguageTag()); } elseif ($field === 'language_tag') { $var = Application::Cms()->getLanguageTag(); } elseif ($field) { if (isset($extraStrings[$field])) { $var = $extraStrings[$field]; } else { $var = $user->getField($field, null, 'php', 'none', 'profile', 0, true); // allow accessing all fields in the if if (is_array($var)) { $var = array_shift($var); } elseif (isset($user->_cbuser->{$field})) { // fall-back to the record if it exists: $var = $user->_cbuser->get($field); } else { $fieldLower = strtolower($field); if (isset($user->_cbuser->{$fieldLower})) { // second fall-back to the record if it exists: $var = $user->_cbuser->get($fieldLower); } else { $var = null; } } } } else { $var = null; } // When using an includes or !includes operator ensure the value stays an array if it is an array: if (is_array($var) && !in_array($compare, array(' includes ', '!includes '))) { $var = implode('|*|', $var); } // Ensure user id is always an integer: if (in_array($field, array('id', 'user_id'))) { $var = (int) $var; } if ($field == 'user_id' && $value == 'myid') { $value = (int) Application::MyUser()->getUserId(); } switch ($compare) { case '=': $r = $var == $value; break; case '<': $r = $var < $value; break; case '>': $r = $var > $value; break; case '>=': $r = $var >= $value; break; case '<=': $r = $var <= $value; break; case '<>': case '!=': $r = $var != $value; break; case '=~': case '!~': $ma = @preg_match($value, $var); $r = $compare == '=~' ? $ma === 1 : $ma == 0; if ($ma === false) { // error in regexp itself: global $_CB_framework; if ($_CB_framework->getCfg('debug') > 0) { echo sprintf(CBTxt::T("CB Regexp Error %s in expression %s"), !is_callable('preg_last_error') ? '' : preg_last_error(), htmlspecialchars($value)); } } break; case ' includes ': // [cb:if viewaccesslevel includes "1"] or [cb:if multicheckboxfield includes "choice2"] $r = in_array($value, (array) $var); break; case '!includes ': // [cb:if viewaccesslevel !includes "3"] or [cb:if multicheckboxfield !includes "choice2"] $r = !in_array($value, (array) $var); break; default: return CBTxt::T('UNDEFINED_IF_COMPARISON_OPERATOR_OPERATOR', 'Undefined [cb:if ...] comparison operator [OPERATOR] !', array('[OPERATOR]' => $compare)); } if (in_array($operator, array('or', '||'))) { $resultsIdx++; $results[++$resultsIdx] = true; } // combine and: $results[$resultsIdx] = $results[$resultsIdx] && $r; } // combine or: $r = false; foreach ($results as $rr) { $r = $r || $rr; } return $r ? $matches[3] : ''; } else { return ''; } }, $input); }
/** * @return string */ public function icon() { global $_CB_framework; if ( Application::Cms()->getClientId() ) { CBActivity::getTemplate( 'twemoji', false, true, false ); } $icon = null; $emoteClass = 'streamIconEmote' . ucfirst( strtolower( preg_replace( '/[^-a-zA-Z0-9_]/', '', $this->get( 'value' ) ) ) ); if ( $this->get( 'icon' ) ) { $icon = '<img src="' . $_CB_framework->getCfg( 'live_site' ) . '/images/' . htmlspecialchars( $this->get( 'icon' ) ) . '" class="streamIconEmote ' . $emoteClass . ' img-responsive-inline" />'; } elseif ( $this->get( 'class' ) ) { $icon = '<span class="streamIconEmote ' . $emoteClass . ' ' . htmlspecialchars( $this->get( 'class' ) ) . '"></span>'; } return $icon; }
/** * Returns an options array of available groups * * @param bool $raw * @param array $excludeCategories * @param array $excludeGroups * @return array|\stdClass[] */ static public function getGroupOptions( $raw = false, $excludeCategories = array(), $excludeGroups = array() ) { global $_CB_database; if ( Application::Cms()->getClientId() ) { $raw = false; $excludeCategories = array(); $excludeGroups = array(); } static $cache = array(); $userId = Application::MyUser()->getUserId(); if ( ! isset( $cache[$userId] ) ) { $query = 'SELECT g.' . $_CB_database->NameQuote( 'id' ) . ' AS value' . ', g.' . $_CB_database->NameQuote( 'name' ) . ' AS text' . ', g.' . $_CB_database->NameQuote( 'category' ) . ', c.' . $_CB_database->NameQuote( 'name' ) . ' AS category_name' . "\n FROM " . $_CB_database->NameQuote( '#__groupjive_groups' ) . " AS g" . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_categories' ) . " AS c" . ' ON c.' . $_CB_database->NameQuote( 'id' ) . ' = g.' . $_CB_database->NameQuote( 'category' ); if ( ( ! self::isModerator( $userId ) ) && ( ! Application::Cms()->getClientId() ) ) { $query .= "\n LEFT JOIN " . $_CB_database->NameQuote( '#__groupjive_users' ) . " AS u" . ' ON u.' . $_CB_database->NameQuote( 'group' ) . ' = g.' . $_CB_database->NameQuote( 'id' ) . ' AND u.' . $_CB_database->NameQuote( 'user_id' ) . ' = ' . (int) $userId . ' AND u.' . $_CB_database->NameQuote( 'status' ) . ' >= 1' . "\n WHERE c." . $_CB_database->NameQuote( 'published' ) . " = 1" . "\n AND c." . $_CB_database->NameQuote( 'access' ) . " IN " . $_CB_database->safeArrayOfIntegers( self::getAccess( $userId ) ) . "\n AND ( g." . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $userId . ' OR ( ( g.' . $_CB_database->NameQuote( 'published' ) . ' = 1 )' . ' AND ( ( g.' . $_CB_database->NameQuote( 'type' ) . ' IN ( 1, 2 ) )' . ' OR ( u.' . $_CB_database->NameQuote( 'id' ) . ' IS NOT NULL ) ) ) )' . ( $excludeCategories ? "\n AND c." . $_CB_database->NameQuote( 'id' ) . " NOT IN " . $_CB_database->safeArrayOfIntegers( $excludeCategories ) : null ) . ( $excludeGroups ? "\n AND g." . $_CB_database->NameQuote( 'id' ) . " NOT IN " . $_CB_database->safeArrayOfIntegers( $excludeGroups ) : null ); } else { $query .= ( $excludeCategories ? "\n WHERE c." . $_CB_database->NameQuote( 'id' ) . " NOT IN " . $_CB_database->safeArrayOfIntegers( $excludeCategories ) : null ) . ( $excludeGroups ? "\n " . ( $excludeCategories ? 'AND' : 'WHERE' ) . " g." . $_CB_database->NameQuote( 'id' ) . " NOT IN " . $_CB_database->safeArrayOfIntegers( $excludeGroups ) : null ); } $query .= "\n ORDER BY c." . $_CB_database->NameQuote( 'ordering' ) . ", g." . $_CB_database->NameQuote( 'ordering' ); $_CB_database->setQuery( $query ); $cache[$userId] = $_CB_database->loadObjectList(); } if ( $raw === true ) { return $cache[$userId]; } $optGroups = array(); $options = array(); foreach ( $cache[$userId] as $group ) { $category = (int) $group->category; if ( ! in_array( $category, $optGroups ) ) { $options[] = \moscomprofilerHTML::makeOptGroup( ( $category ? CBTxt::T( $group->category_name ) : CBTxt::T( 'Uncategorized' ) ) ); $optGroups[] = $category; } $options[] = \moscomprofilerHTML::makeOption( (int) $group->value, CBTxt::T( $group->text ) ); } return $options; }
} } /** * Triggers the system plugins */ public function triggerSysPlugins() { // now check for content plugin: self::registerOnRealStart(false); //TODO LATER: make it more universal. // $_PLUGINS->trigger( 'onCPayHostSystemStart', array() ); // not needed here as plugins are not loaded depending on triggers yet } } /** * Event handler for onAfterStart */ function cbpaidSysPlugin_onAfterStart() { $_CBPAID_SYSPLUG = new cbpaidSysPlugin(); $_CBPAID_SYSPLUG->checkExpireMe(); $_CBPAID_SYSPLUG->triggerSysPlugins(); } //TODO this is temporary as we don't have yet a general CB method: if (Application::Cms()->getClientId() == 0) { // We do check for content restrictions only in frontend: define('_CBSUBS_CONTENT_BOT_FILE', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugin' . DIRECTORY_SEPARATOR . 'cbsubscontent' . DIRECTORY_SEPARATOR . 'cbsubs.content_access.php'); if (is_readable(_CBSUBS_CONTENT_BOT_FILE)) { /** @noinspection PhpIncludeInspection */ include_once _CBSUBS_CONTENT_BOT_FILE; } }
/** * Validator: * Validates $value for $field->required and other rules * Override * * @param FieldTable $field * @param UserTable $user RETURNED populated: touch only variables related to saving this field (also when not validating for showing re-edit) * @param string $columnName Column to validate * @param string $value (RETURNED:) Value to validate, Returned Modified if needed ! * @param array $postdata Typically $_POST (but not necessarily), filtering required. * @param string $reason 'edit' for save user edit, 'register' for save registration * @return boolean True if validate, $this->_setErrorMSG if False */ public function validate( &$field, &$user, $columnName, &$value, &$postdata, $reason ) { if ( ( ! Application::Cms()->getClientId() ) && ( ! Application::MyUser()->isGlobalModerator() ) && in_array( $reason, array( 'register', 'edit' ) ) ) { if ( parent::validate( $field, $user, $columnName, $value, $postdata, $reason ) ) { $captcha = cbantispamCaptcha::getInstance( $field->get( 'name' ), $field->params->get( 'cbantispam_captcha_mode', null ) ); if ( ! $captcha->validateCaptcha() ) { $this->_setValidationError( $field, $user, $reason, ( $captcha->error ? $captcha->error : CBTxt::T( 'Invalid Captcha Code' ) ) ); return false; } } } return true; }
/** * @param FieldTable $field * @param UserTable $user * @param string $output * @param string $reason * @param int $list_compare_types * @return mixed|null|string */ public function getField( &$field, &$user, $output, $reason, $list_compare_types ) { global $_CB_framework; $return = null; if ( ( ! Application::Cms()->getClientId() ) && ( $output == 'htmledit' ) && ( $reason == 'edit' ) && $user->get( 'id' ) && ( ! cbprivacyClass::checkUserModerator( $user->get( 'id' ) ) ) ) { $url = $_CB_framework->pluginClassUrl( $this->element, true, array( 'action' => 'privacy', 'func' => 'delete' ) ); $value = '<a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete your account?' ) ) . '\' ) ) { location.href = \'' . $url . '\'; }">' . CBTxt::T( 'Delete account and user profile.' ) . '</a>'; $return = $this->formatFieldValueLayout( $value, $reason, $field, $user, false ) . $this->_fieldIconsHtml( $field, $user, $output, $reason, null, 'html', $value, null, null, true, 0 ); } return $return; }
/** * @param bool $updateNulls * @return bool */ public function store( $updateNulls = false ) { global $_CB_framework, $_PLUGINS; $new = ( $this->get( 'id' ) ? false : true ); $old = new self(); $this->set( 'date', $this->get( 'date', Application::Database()->getUtcDateTime() ) ); if ( ! $new ) { $old->load( (int) $this->get( 'id' ) ); $_PLUGINS->trigger( 'gj_onBeforeUpdateGroup', array( &$this, $old ) ); } else { $_PLUGINS->trigger( 'gj_onBeforeCreateGroup', array( &$this ) ); } if ( ! parent::store( $updateNulls ) ) { return false; } if ( ! CBGroupJive::uploadImage( 'canvas', $this ) ) { return false; } if ( ! CBGroupJive::uploadImage( 'logo', $this ) ) { return false; } if ( ! parent::store( $updateNulls ) ) { return false; } // If the new owner doesn't match the previous then demote (frontend) or delete (backend) the previous: if ( $old->get( 'id' ) ) { if ( $old->get( 'user_id' ) != $this->get( 'user_id' ) ) { $previousUser = new UserTable(); $previousUser->load( array( 'user_id' => (int) $old->get( 'user_id' ), 'group' => (int) $this->get( 'id' ) ) ); if ( $previousUser->get( 'id' ) ) { if ( Application::Cms()->getClientId() ) { if ( ! $previousUser->delete() ) { $this->setError( $previousUser->getError() ); return false; } } else { $previousUser->set( 'status', 1 ); if ( ! $previousUser->store() ) { $this->setError( $previousUser->getError() ); return false; } } } } } $user = new UserTable(); $user->load( array( 'user_id' => (int) $this->get( 'user_id' ), 'group' => (int) $this->get( 'id' ) ) ); // If the owner doesn't exist or isn't marked owner then create them or promote them to owner: if ( ( ! $user->get( 'id' ) ) || ( $user->get( 'status' ) != 4 ) ) { $user->set( 'user_id', (int) $this->get( 'user_id' ) ); $user->set( 'group', (int) $this->get( 'id' ) ); $user->set( 'status', 4 ); if ( $user->getError() || ( ! $user->store() ) ) { $this->setError( $user->getError() ); return false; } } // If the category is changed be sure to move the canvas and logo as needed: if ( $old->get( 'id' ) && ( $this->get( 'canvas' ) || $this->get( 'logo' ) ) && ( $old->get( 'category' ) != $this->get( 'category' ) ) ) { $basePath = $_CB_framework->getCfg( 'absolute_path' ) . '/images/comprofiler/plug_cbgroupjive'; $oldPath = $basePath . '/' . (int) $old->get( 'category' ) . '/' . (int) $this->get( 'id' ); $newPath = $basePath . '/' . (int) $this->get( 'category' ) . '/' . (int) $this->get( 'id' ); if ( is_dir( $oldPath ) ) { CBGroupJive::createDirectory( $basePath, $this->get( 'category' ), $this->get( 'id' ) ); CBGroupJive::copyDirectory( $oldPath, $newPath, true ); } } if ( ! $new ) { $_PLUGINS->trigger( 'gj_onAfterUpdateGroup', array( $this, $old ) ); } else { $_PLUGINS->trigger( 'gj_onAfterCreateGroup', array( $this ) ); } return true; }
/** * Checks if a page is executed https, and if not, if it should be according to login module HTTPS posts specifications * * @param boolean $return [default: false] : True: returns if https switchover is needed for the POST form (if not already on HTTPS and login module asks for it). False: errors 403 if not in https and it's configured in login module. * @return boolean True: switchover needed (returned only if $return = true) */ function checkCBPostIsHTTPS($return = false) { global $_CB_framework, $_CB_database, $_SERVER; $isHttps = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'; if (!$isHttps && file_exists($_CB_framework->getCfg('absolute_path') . '/modules/' . (checkJversion() > 0 ? 'mod_cblogin/' : null) . 'mod_cblogin.php')) { $language = CBuser::getMyUserDataInstance()->getUserLanguage(); if (!$language) { $language = Application::Cms()->getLanguageTag(); } $query = 'SELECT ' . $_CB_database->NameQuote('params') . "\n FROM " . $_CB_database->NameQuote('#__modules') . "\n WHERE " . $_CB_database->NameQuote('module') . " = " . $_CB_database->Quote('mod_cblogin') . "\n AND " . $_CB_database->NameQuote('published') . " = 1" . "\n AND " . $_CB_database->NameQuote('access') . " IN " . $_CB_database->safeArrayOfIntegers(Application::MyUser()->getAuthorisedViewLevels()) . "\n AND " . $_CB_database->NameQuote('language') . " IN ( " . $_CB_database->Quote($language) . ", " . $_CB_database->Quote('*') . ", " . $_CB_database->Quote('') . " )" . "\n ORDER BY " . $_CB_database->NameQuote('position') . ", " . $_CB_database->NameQuote('ordering'); $_CB_database->setQuery($query, 0, 1); $module = $_CB_database->loadResult(); if ($module) { $params = new Registry($module); $https_post = $params->get('https_post', 0) != 0; } else { $https_post = false; } } else { $https_post = false; } if ($return) { return $https_post; } else { if ($https_post && !$isHttps) { header('HTTP/1.0 403 Forbidden'); exit(CBTxt::T('UE_NOT_AUTHORIZED', 'You are not authorized to view this page!')); } } return null; }
/** * Returns the UI (admin: 2, front-end: 1) * @deprecated 2.0 Use Application::Cms()->getClientId() which returns (0 = front, 1 = admin) * * @return int */ function getUi() { return Application::Cms()->getClientId() ? 2 : 1; }
/** * render frontend events * * @param EventTable[] $rows * @param cbPageNav $pageNav * @param bool $searching * @param array $input * @param array $counters * @param GroupTable $group * @param UserTable $user * @param cbgjEventsPlugin $plugin * @return string */ static function showEvents( $rows, $pageNav, $searching, $input, &$counters, $group, $user, $plugin ) { global $_CB_framework, $_PLUGINS; $_CB_framework->outputCbJQuery( "$( '.gjGroupEventDescription .cbMoreLess' ).cbmoreless();", 'cbmoreless' ); $counters[] = '<span class="gjGroupEventsIcon fa-before fa-calendar"> ' . CBTxt::T( 'GROUP_EVENTS_COUNT', '%%COUNT%% Event|%%COUNT%% Events', array( '%%COUNT%%' => (int) $pageNav->total ) ) . '</span>'; initToolTip(); $isModerator = CBGroupJive::isModerator( $user->get( 'id' ) ); $isOwner = ( $user->get( 'id' ) == $group->get( 'user_id' ) ); $userStatus = CBGroupJive::getGroupStatus( $user, $group ); $canCreate = CBGroupJive::canCreateGroupContent( $user, $group, 'events' ); $canSearch = ( $plugin->params->get( 'groups_events_search', 1 ) && ( $searching || $pageNav->total ) ); $showAddress = $plugin->params->get( 'groups_events_address', 1 ); $return = null; $_PLUGINS->trigger( 'gj_onBeforeDisplayEvents', array( &$return, &$rows, $group, $user ) ); $return .= '<div class="gjGroupEvents">' . '<form action="' . $_CB_framework->pluginClassUrl( $plugin->_gjPlugin->element, true, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $group->get( 'id' ) ) ) . '" method="post" name="gjGroupEventsForm" id="gjGroupEventsForm" class="gjGroupEventsForm">'; if ( $canCreate || $canSearch ) { $return .= '<div class="gjHeader gjGroupEventsHeader row">'; if ( $canCreate ) { $return .= '<div class="' . ( ! $canSearch ? 'col-sm-12' : 'col-sm-8' ) . ' text-left">' . '<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'events', 'func' => 'new', 'group' => (int) $group->get( 'id' ) ) ) . '\';" class="gjButton gjButtonNewEvent btn btn-success"><span class="fa fa-plus-circle"></span> ' . CBTxt::T( 'New Event' ) . '</button>' . '</div>'; } if ( $canSearch ) { $return .= '<div class="' . ( ! $canCreate ? 'col-sm-offset-8 ' : null ) . 'col-sm-4 text-right">' . '<div class="input-group">' . '<span class="input-group-addon"><span class="fa fa-search"></span></span>' . $input['search'] . '</div>' . '</div>'; } $return .= '</div>'; } $return .= '<div class="gjGroupEventsRows">'; if ( $rows ) foreach ( $rows as $row ) { $rowOwner = ( $user->get( 'id' ) == $row->get( 'user_id' ) ); $address = htmlspecialchars( $row->get( 'location' ) ); if ( $showAddress ) { if ( $row->get( 'address' ) ) { $mapUrl = CBTxt::T( 'GROUP_EVENT_ADDRESS_MAP_URL', 'https://www.google.com/maps/place/[address]', array( '[location]' => urlencode( $row->get( 'location' ) ), '[address]' => urlencode( $row->get( 'address' ) ) ) ); } else { $mapUrl = CBTxt::T( 'GROUP_EVENT_LOCATION_MAP_URL', 'https://www.google.com/maps/search/[location]', array( '[location]' => urlencode( $row->get( 'location' ) ), '[address]' => urlencode( $row->get( 'address' ) ) ) ); } if ( $mapUrl ) { $address = '<a href="' . htmlspecialchars( $mapUrl ) . '" target="_blank" rel="nofollow">' . $address . '</a>'; } } $menu = array(); $integrations = $_PLUGINS->trigger( 'gj_onDisplayEvent', array( &$row, &$menu, $group, $user ) ); $canAttend = ( ( ! $rowOwner ) && ( $row->status() != 1 ) && ( ! $row->get( '_attending' ) ) && ( $userStatus >= 1 ) && ( ( ! $row->get( 'limit' ) ) || ( $row->get( 'limit' ) && ( $row->get( '_guests' ) < $row->get( 'limit' ) ) ) ) ); $canMenu = ( $isModerator || $isOwner || $rowOwner || ( $userStatus >= 2 ) || ( ( ! $rowOwner ) && ( $row->status() != 1 ) && ( $userStatus >= 1 ) && $row->get( '_attending' ) ) || $menu ); $return .= '<div class="gjGroupEventsRow row' . ( $row->status() == 1 ? ' gjGroupEventExpired' : ( $row->status() == 2 ? ' gjGroupEventActive' : null ) ) . '">' . '<div class="gjGroupEventCalendar col-md-2 hidden-sm hidden-xs">' . '<div class="panel panel-default text-center">' . '<div class="gjGroupEventMonth panel-body">' . cbFormatDate( $row->get( 'start' ), true, false, 'M' ) . '</div>' . '<div class="gjGroupEventDay panel-footer">' . cbFormatDate( $row->get( 'start' ), true, false, 'j' ) . '</div>' . '</div>' . '</div>' . '<div class="gjGroupEventContainer col-md-10 col-sm-12 col-xs-12">' . '<div class="panel ' . ( $row->status() == 1 ? 'panel-warning' : ( $row->status() == 2 ? 'panel-primary' : 'panel-default' ) ) . '">' . '<div class="gjGroupEventHeader panel-heading">' . '<div class="row">' . '<div class="gjGroupEventTitle ' . ( $canAttend || $canMenu ? 'col-sm-8' : 'col-sm-12' ) . '">' . htmlspecialchars( $row->get( 'title' ) ) . '</div>'; if ( $canAttend || $canMenu ) { $return .= '<div class="gjGroupEventMenu col-sm-4 text-right">'; if ( $canAttend ) { $return .= '<button type="button" onclick="window.location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'events', 'func' => 'attend', 'id' => (int) $row->get( 'id' ) ) ) . '\';" class="gjButton gjButtonAttend btn btn-xs btn-success">' . CBTxt::T( 'Attend' ) . '</button> '; } if ( $canMenu ) { $menuItems = '<ul class="gjEventMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">'; if ( ( ! $rowOwner ) && ( $row->status() != 1 ) && ( $userStatus >= 1 ) && $row->get( '_attending' ) ) { $menuItems .= '<li class="gjEventMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you do not want to attend this Event?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'events', 'func' => 'unattend', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unattend' ) . '</a></li>'; } if ( $isModerator || $isOwner || $rowOwner || ( $userStatus >= 2 ) ) { $menuItems .= '<li class="gjEventMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'events', 'func' => 'edit', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>'; if ( ( $row->get( 'published' ) == -1 ) && ( $group->params()->get( 'events', 1 ) == 2 ) ) { if ( $isModerator || $isOwner || ( $userStatus >= 2 ) ) { $menuItems .= '<li class="gjEventMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'events', '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="gjEventMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to unpublish this Event?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'events', 'func' => 'unpublish', 'id' => (int) $row->get( 'id' ) ) ) . '\'; })"><span class="fa fa-times-circle"></span> ' . CBTxt::T( 'Unpublish' ) . '</a></li>'; } else { $menuItems .= '<li class="gjEventMenuItem"><a href="' . $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'events', 'func' => 'publish', 'id' => (int) $row->get( 'id' ) ) ) . '"><span class="fa fa-check"></span> ' . CBTxt::T( 'Publish' ) . '</a></li>'; } } if ( $menu ) { $menuItems .= '<li class="gjEventMenuItem">' . implode( '</li><li class="gjEventMenuItem">', $menu ) . '</li>'; } if ( $isModerator || $isOwner || $rowOwner || ( $userStatus >= 2 ) ) { $menuItems .= '<li class="gjEventMenuItem"><a href="javascript: void(0);" onclick="cbjQuery.cbconfirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this Event?' ) ) . '\' ).done( function() { window.location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'events', '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="gjEventMenu btn-group">' . '<button type="button" ' . trim( $menuAttr ) . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>' . '</span>'; } $return .= '</div>'; } $return .= '</div>' . '</div>' . '<div class="gjGroupEventDetails panel-body small">'; if ( $row->status() == 1 ) { $return .= '<div class="gjGroupEventNotice text-warning text-right">' . CBTxt::T( 'This event has ended.' ) . '</div>'; } elseif ( $row->status() == 2 ) { if ( $row->get( 'end' ) ) { $return .= '<div class="gjGroupEventNotice text-primary text-right">' . CBTxt::T( 'GROUP_EVENT_ENDS_IN', 'This event is currently in progress and ends in [timeago].', array( '[timeago]' => cbFormatDate( $row->get( 'end' ), true, 'exacttimeago' ) ) ) . '</div>'; } else { $return .= '<div class="gjGroupEventNotice text-primary text-right">' . CBTxt::T( 'This event is currently in progress.' ) . '</div>'; } } else { $return .= '<div class="gjGroupEventNotice text-right">' . CBTxt::T( 'GROUP_EVENT_STARTS_IN', 'This event starts in [timeago].', array( '[timeago]' => cbFormatDate( $row->get( 'start' ), true, 'exacttimeago' ) ) ) . '</div>'; } $return .= '<div class="gjGroupEventDate">' . '<span class="gjGroupEventIcon fa fa-clock-o text-center"></span> ' . $row->date() . '</div>' . '<div class="gjGroupEventLocation">' . '<span class="gjGroupEventIcon fa fa-map-marker text-center"></span> ' . $address . '</div>' . '<div class="gjGroupEventAttending row">' . '<div class="gjGroupEventGuests col-sm-6">' . '<span class="gjGroupEventIcon fa fa-users text-center"></span> ' . '<a href="' . htmlspecialchars( $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'events', 'func' => 'attending', 'id' => (int) $row->get( 'id' ) ) ) ) . '">' . ( $row->get( 'limit' ) ? CBTxt::T( 'GROUP_GUESTS_COUNT_LIMITED', '%%COUNT%% of [limit] Guest|%%COUNT%% of [limit] Guests', array( '%%COUNT%%' => (int) $row->get( '_guests', 0 ), '[limit]' => (int) $row->get( 'limit' ) ) ) : CBTxt::T( 'GROUP_GUESTS_COUNT', '%%COUNT%% Guest|%%COUNT%% Guests', array( '%%COUNT%%' => (int) $row->get( '_guests', 0 ) ) ) ) . '</a>' . '</div>' . '<div class="gjGroupEventHost col-sm-6 text-right">' . CBuser::getInstance( (int) $row->get( 'user_id' ), false )->getField( 'formatname', null, 'html', 'none', 'list', 0, true ) . '</div>' . '</div>' . '</div>' . '<div class="gjGroupEventDescription panel-footer">' . '<div class="cbMoreLess">' . '<div class="cbMoreLessContent">' . ( $plugin->params->get( 'groups_events_content_plugins', 0 ) ? Application::Cms()->prepareHtmlContentPlugins( $row->get( 'event' ) ) : $row->get( 'event' ) ) . '</div>' . '<div class="cbMoreLessOpen fade-edge hidden">' . '<a href="javascript: void(0);" class="cbMoreLessButton">' . CBTxt::T( 'See More' ) . '</a>' . '</div>' . '</div>' . '</div>' . ( is_array( $integrations ) && $integrations ? '<div class="gjGroupEventFooter panel-footer">' . implode( '', $integrations ) . '</div>' : null ) . '</div>' . '</div>' . '</div>'; } else { if ( $searching ) { $return .= CBTxt::T( 'No group event search results found.' ); } else { $return .= CBTxt::T( 'This group currently has no events.' ); } } $return .= '</div>'; if ( $plugin->params->get( 'groups_events_paging', 1 ) && ( $pageNav->total > $pageNav->limit ) ) { $return .= '<div class="gjGroupEventsPaging text-center">' . $pageNav->getListLinks() . '</div>'; } $return .= $pageNav->getLimitBox( false ) . '</form>' . '</div>'; $_PLUGINS->trigger( 'gj_onAfterDisplayEvents', array( &$return, $rows, $group, $user ) ); return $return; }
/** * Returns a DELIMITER field in specified format * * @param FieldTable $field * @param UserTable $user * @param string $output 'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit' * @param string $reason 'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists * @param int $list_compare_types IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search * @return mixed */ public function getField(&$field, &$user, $output, $reason, $list_compare_types) { $value = cbReplaceVars(cbUnHtmlspecialchars($field->description), $user); //TBD: unhtml is kept for backwards database compatibility until CB 2.0 if ($field->params->get('field_content_plugins', 0)) { $value = Application::Cms()->prepareHtmlContentPlugins($value); } $return = $this->_formatFieldOutput($field->name, $value, $output, false); if ($output == 'htmledit') { $return .= $this->_fieldIconsHtml($field, $user, $output, $reason, null, null, $value, null, null, false, false); } return $return; }
/** * @param FieldTable $field * @param UserTable $user * @param string $output * @param string $formatting * @param string $reason * @param int $list_compare_types * @return mixed|null|string */ public function fieldDisplay( &$field, &$user, $output, $formatting, $reason, $list_compare_types ) { $return = null; if ( ( ! $field->get( '_noCondition', false ) ) && ( ( ! Application::Cms()->getClientId() ) || $this->params->get( 'cond_backend', 0 ) ) ) { $field->set( '_noCondition', true ); if ( $output == 'html' ) { $tabCondition = $this->getTabConditional( (int) $field->get( 'tabid' ), $reason, $user->get( 'id' ) ); $display = true; if ( $tabCondition && in_array( (int) $field->get( 'tabid' ), $tabCondition ) ) { $display = false; } if ( $display ) { $condition = $this->getFieldConditional( null, $reason, $user->get( 'id' ) ); if ( $condition->hide ) { if ( in_array( (int) $field->get( 'fieldid' ), $condition->hide ) ) { $display = false; } } } if ( ! $display ) { $return = ' '; } } elseif ( $output == 'htmledit' ) { $this->getFieldConditional( $field, $reason, $user->id, true ); } $field->set( '_noCondition', false ); } return $return; }
/** * @param int[] $paging * @param string $where * @param UserTable $viewer * @param UserTable $user * @param PluginTable $plugin * @return cbblogsBlogTable[] */ static public function getBlogs( $paging, $where, $viewer, $user, /** @noinspection PhpUnusedParameterInspection */ $plugin ) { global $_CB_database; $categories = cbblogsModel::getCategoriesList( true ); $blogs = array(); if ( $categories ) { $query = 'SELECT a.*' . ', a.' . $_CB_database->NameQuote( 'created_by' ) . ' AS user' . ', a.' . $_CB_database->NameQuote( 'introtext' ) . ' AS blog_intro' . ', a.' . $_CB_database->NameQuote( 'fulltext' ) . ' AS blog_full' . ', b.' . $_CB_database->NameQuote( 'name' ) . ' AS category' . ', b.' . $_CB_database->NameQuote( 'published' ) . ' AS category_published' . ', b.' . $_CB_database->NameQuote( 'alias' ) . ' AS category_alias' . "\n FROM " . $_CB_database->NameQuote( '#__k2_items' ) . " AS a" . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__k2_categories' ) . " AS b" . ' ON b.' . $_CB_database->NameQuote( 'id' ) . ' = a.' . $_CB_database->NameQuote( 'catid' ) . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__users' ) . " AS c" . ' ON c.' . $_CB_database->NameQuote( 'id' ) . ' = a.' . $_CB_database->NameQuote( 'created_by' ) . "\n WHERE a." . $_CB_database->NameQuote( 'catid' ) . " IN ( " . implode( ',', $categories ) . " )" . "\n AND a." . $_CB_database->NameQuote( 'created_by' ) . " = " . (int) $user->get( 'id' ) . ( ( $viewer->get( 'id' ) != $user->get( 'id' ) ) && ( ! Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator() ) ? "\n AND a." . $_CB_database->NameQuote( 'published' ) . " = 1" : null ) . ( ! Application::Cms()->getClientId() ? "\n AND a." . $_CB_database->NameQuote( 'trash' ) . " = 0" : null ) . "\n AND a." . $_CB_database->NameQuote( 'access' ) . " IN " . $_CB_database->safeArrayOfIntegers( Application::MyUser()->getAuthorisedViewLevels() ) . $where . "\n ORDER BY a." . $_CB_database->NameQuote( 'created' ) . " DESC"; if ( $paging ) { $_CB_database->setQuery( $query, $paging[0], $paging[1] ); } else { $_CB_database->setQuery( $query ); } $blogs = $_CB_database->loadObjectList( null, 'cbblogsBlogTable', array( $_CB_database ) ); } return $blogs; }
/** * @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; }
/** * Previews the item * * @param bool $thumbnail * @return bool */ public function preview( $thumbnail = false ) { if ( Application::Cms()->getClientId() ) { $thumbnail = false; } return $this->output( true, $thumbnail ); }
static function loginForm( /** @noinspection PhpUnusedParameterInspection */ $option, &$postvars, $regErrorMSG = null, $messagesToUser = null, $alertmessages = null ) { global $_CB_framework, $_CB_database, $_PLUGINS; $results = $_PLUGINS->trigger( 'onBeforeLoginFormDisplay', array( &$postvars, &$regErrorMSG, &$messagesToUser, &$alertmessages ) ); if ( $_PLUGINS->is_errors() ) { echo "<script type=\"text/javascript\">alert(\"" . $_PLUGINS->getErrorMSG() . "\"); window.history.go(-1); </script>\n"; exit(); } if ( $regErrorMSG ) { $_CB_framework->enqueueMessage( $regErrorMSG, 'error' ); } outputCbTemplate( 1 ); outputCbJs( 1 ); initToolTip( 1 ); $params = null; $moduleFile = $_CB_framework->getCfg( 'absolute_path' ) . '/modules/' . ( checkJversion() > 0 ? 'mod_cblogin/' : '' ) . 'mod_cblogin.php'; if ( file_exists( $moduleFile ) ) { $language = CBuser::getMyUserDataInstance()->getUserLanguage(); if ( ! $language ) { $language = Application::Cms()->getLanguageTag(); } define( '_UE_LOGIN_FROM', 'loginform' ); $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote( '#__modules' ) . "\n WHERE " . $_CB_database->NameQuote( 'module' ) . " = " . $_CB_database->Quote( 'mod_cblogin' ) . "\n AND " . $_CB_database->NameQuote( 'published' ) . " = 1" . "\n AND " . $_CB_database->NameQuote( 'access' ) . " IN " . $_CB_database->safeArrayOfIntegers( Application::MyUser()->getAuthorisedViewLevels() ) . "\n AND " . $_CB_database->NameQuote( 'language' ) . " IN ( " . $_CB_database->Quote( $language ) . ", " . $_CB_database->Quote( '*' ) . ", " . $_CB_database->Quote( '' ) . " )" . "\n ORDER BY " . $_CB_database->NameQuote( 'position' ) . ", " . $_CB_database->NameQuote( 'ordering' ); $_CB_database->setQuery( $query, 0, 1 ); $module = null; $_CB_database->loadObject( $module ); if ( $module ) { $moduleContent = JModuleHelper::renderModule( $module, array( 'style' => 'xhtml' ) ); } else { $moduleContent = CBTxt::T( 'Error: CB Login module not created (required).' ); } } else { $moduleContent = CBTxt::T( 'Error: CB Login module not installed (required).' ); } $return = null; if ( ( is_array( $messagesToUser ) && $messagesToUser ) || ( is_array( $results ) && $results ) ) { $pageClass = $_CB_framework->getMenuPageClass(); $return .= '<div class="cbLoginPage cb_template cb_template_' . selectTemplate( 'dir' ) . ( $pageClass ? ' ' . htmlspecialchars( $pageClass ) : null ) . '">' . ( is_array( $messagesToUser ) && $messagesToUser ? '<div>' . implode( '</div><div>', $messagesToUser ) . '</div>' : null ) . ( is_array( $results ) && $results ? implode( '', $results ) : null ) . '</div>'; } $return .= $moduleContent; echo $return; $_CB_framework->setMenuMeta(); }
/** * Translates, prepares the HTML $htmlText with triggering CMS Content Plugins, replaces CB substitutions and extra HTML and non-HTML substitutions * @see CBuser::replaceUserVars * * @param string $mainText * @param int $user_id * @param boolean $html * @param boolean $translateMainText * @param boolean $prepareHtmlContentPlugins * @param array|null $extraHtmlStrings * @param array|null $extraNonHtmlStrings * @return string */ public static function replaceUserVars( $mainText, $user_id, $html, $translateMainText = true, $prepareHtmlContentPlugins = false, $extraHtmlStrings = null, $extraNonHtmlStrings = null ) { if ( $translateMainText ) { $mainText = $html ? parent::Th( $mainText ) : parent::T( $mainText ); } if ( $prepareHtmlContentPlugins ) { $mainText = Application::Cms()->prepareHtmlContentPlugins( $mainText ); if ( ! $html ) { $mainText = strip_tags( $mainText ); } } $cbUser = CBuser::getInstance( (int) $user_id ); if ( ! $cbUser ) { $cbUser = CBuser::getInstance( null ); } $mainText = $cbUser->replaceUserVars( $mainText, true, false, $extraNonHtmlStrings, false ); if ( $extraHtmlStrings ) { foreach ( $extraHtmlStrings as $k => $v ) { $mainText = str_replace( "[$k]", $html ? $v : strip_tags( $v ), $mainText ); } } return $mainText; }
/** * Outputs a JQuery init string into JQuery strings at end of page, * and adds if needed JS file inclusions at begin of page. * Pro-memo, JQuery runs in CB in noConflict mode. * * @param string $javascriptCode Javascript code ended by ; which will be put in between jQuery(document).ready(function($){ AND }); * @param string $jQueryPlugin (optional) name of plugin to auto-load (if core plugin, or call first addJQueryPlugin). */ function outputCbJQuery($javascriptCode, $jQueryPlugin = null) { if (Application::Config()->get('jsJqueryMigrate', 1) || Application::Cms()->getClientId()) { $this->addJQueryPlugin('migrate', true); } if ($jQueryPlugin) { $this->addJQueryPlugin($jQueryPlugin, true); } if ($javascriptCode) { $this->_jQueryCodes[] = $javascriptCode; } if ($this->document->isHeadOutputed()) { $this->getAllJsPageCodes(); } }
/** * Outputs an arbitrary html text into head tags if possible and configured, otherwise echo it. * Adds RTL overrides in 'rtl.css' on 'template.css' file if in RTL output mode from template's rtl.css file if existing, otherwise from default template. * * @param int $obsoleteUi (was int $ui user interface : 1: frontend, 2: backend) * @param string $templateFile * @param string $media e.g. "screen" * @return void */ function outputCbTemplate($obsoleteUi = 0, $templateFile = 'template.css', $media = null) { global $_CB_framework, $ueConfig; $loadBootstrap = isset($ueConfig['templateBootstrap']) ? (int) $ueConfig['templateBootstrap'] : 1; $loadFontawesome = isset($ueConfig['templateFontawesme']) ? (int) $ueConfig['templateFontawesme'] : 1; $tmplFileExists = file_exists(selectTemplate('absolute_path') . '/' . $templateFile); if ($tmplFileExists) { $livePath = selectTemplate('relative_path'); } else { $tmplFileExists = file_exists(selectTemplate('absolute_path', 'default') . '/' . $templateFile); $livePath = selectTemplate('relative_path', 'default'); } if ($templateFile === 'template.css') { if ($loadBootstrap || Application::Cms()->getClientId()) { // Add bootstrap styles if available: outputCbTemplate(null, 'bootstrap.css', $media); } if ($loadFontawesome || Application::Cms()->getClientId()) { // Add fontawesome styles if available: outputCbTemplate(null, 'fontawesome.css', $media); } } if ($tmplFileExists) { $_CB_framework->document->addHeadStyleSheet($livePath . '/' . $templateFile, false, $media); } if ($templateFile === 'template.css') { // Add RTL style overrides if available: if ($_CB_framework->document->getDirection() == 'rtl') { outputCbTemplate(null, 'rtl.css', $media); } } if ($templateFile === 'template.css' && selectTemplate('dir') != 'default') { // Add style overrides if available: outputCbTemplate(null, 'override.css', $media); } }
/** * @param bool $updateNulls * @return bool */ public function store( $updateNulls = false ) { $groups = ( is_string( $this->get( 'groups' ) ) ? explode( '|*|', $this->get( 'groups' ) ) : $this->get( 'groups' ) ); $users = ( is_string( $this->get( 'users' ) ) ? json_decode( $this->get( 'users' ), true ) : $this->get( 'users' ) ); foreach ( $users as $user ) { $userId = ( isset( $user['user_id'] ) ? (int) $user['user_id'] : 0 ); if ( ! $userId ) { continue; } foreach ( $groups as $group ) { $groupId = (int) $group; if ( ! $groupId ) { continue; } $row = new UserTable(); $row->load( array( 'user_id' => $userId, 'group' => $groupId ) ); $row->set( 'user_id', $userId ); $row->set( 'group', $groupId ); $row->set( 'status', ( isset( $user['user_id'] ) ? (int) $user['status'] : 1 ) ); if ( $row->check() ) { $row->store(); } } } if ( Application::Cms()->getClientId() ) { cbRedirect( 'index.php?option=com_comprofiler&view=showusers', CBTxt::T( 'Users successfully added to CB GroupJive groups!' ) ); } return true; }