/** * Loads all (published) plans from database in a way which is ordered as a tree * * @param int $owner reflecting the user needing to see plan (NULL: means all plans) * @param boolean $enabled TRUE if to load only published plans * @param array $currency Currency of payment that must be accepted * @return cbpaidGatewayAccount[] */ public function loadEnabledAccounts($owner = 0, $enabled = true, $currency = null) { static $_objects = array(); if (!isset($_objects[$enabled][$owner])) { $sql = "SELECT a.* FROM `" . $this->_tbl . "` AS a"; $where = array(); if ($enabled) { $where[] = "a.enabled > 0"; } if ($owner !== null) { $where[] = "a.owner = " . (int) $owner; } $where[] = "a.viewaccesslevel IN " . $this->_db->safeArrayOfIntegers(Application::MyUser()->getAuthorisedViewLevels()); if (count($where) > 0) { $sql .= "\n WHERE " . implode(" AND ", $where); } $sql .= "\n ORDER BY a.`ordering` ASC"; $this->_db->setQuery($sql); $_objects[$enabled][$owner] = $this->_loadTrueObjects($this->_tbl_key); } if ($currency) { // A currency has been specified: we need to filter available gateways by their list of accepted currencies: $acts = array(); foreach ($_objects[$enabled][$owner] as $k => $v) { /** @noinspection PhpUndefinedMethodInspection */ if ($_objects[$enabled][$owner][$k]->acceptsCurrency($currency)) { $acts[] = $_objects[$enabled][$owner][$k]; } } return $acts; } else { return $_objects[$enabled][$owner]; } }
/** * Fills object with all standard items of a Notification record * * @param cbpaidPayHandler $payHandler * @param int $test_ipn * @param string $log_type * @param string $paymentStatus * @param string $paymentType * @param string $reasonCode * @param int $paymentTime * @param string $charset */ public function initNotification($payHandler, $test_ipn, $log_type, $paymentStatus, $paymentType, $reasonCode, $paymentTime, $charset = 'utf-8') { $this->payment_method = $payHandler->getPayName(); $this->gateway_account = $payHandler->getAccountParam('id'); $this->log_type = $log_type; $this->time_received = Application::Database()->getUtcDateTime(); $this->ip_addresses = cbpaidRequest::getIPlist(); $this->geo_ip_country_code = cbpaidRequest::getGeoIpCountryCode(); $this->notify_version = '2.1'; $this->user_id = (int) cbGetParam($_GET, 'user', 0); $this->charset = $charset; $this->test_ipn = $test_ipn; $this->payer_status = 'unverified'; $this->payment_status = $paymentStatus; if (in_array($paymentStatus, array('Completed', 'Pending', 'Processed', 'Failed', 'Reversed', 'Refunded', 'Partially-Refunded', 'Canceled_Reversal'))) { if (in_array($paymentStatus, array('Completed', 'Reversed', 'Refunded', 'Partially-Refunded', 'Canceled_Reversal'))) { $this->payment_date = gmdate('H:i:s M d, Y T', $paymentTime); // paypal-style } $this->payment_type = $paymentType; } if ($reasonCode) { $this->reason_code = $reasonCode; } }
/** * Constructor * * @param null|string $date null: now, string: date or datetime string as UTC, int: unix timestamp * @param null|string|int|DateTimeZone $tz null: server offset, string: timezone string (e.g. UTC), int: offset in hours, DateTimeZone: PHP timezone * @param null|string $from Format to convert the date from * @param Config $config */ public function __construct($date = null, $tz = null, $from = null, Config $config) { $this->config = $config; $this->init(); if (!$date) { $date = 'now'; } if (!$tz) { $tz = Application::CBFramework()->getCfg('user_timezone'); } $tzCache = date_default_timezone_get(); date_default_timezone_set('UTC'); if (is_integer($date)) { $this->date = new DateTime(); $this->date->setTimestamp($date); } else { if ($date == 'now') { $from = null; } elseif (is_numeric($date)) { $date = date('c', $date); } if ($from) { $this->date = new DateTime(); $dateArray = date_parse_from_format($from, $date); $this->date->setDate($dateArray['year'], $dateArray['month'], $dateArray['day']); $this->date->setTime($dateArray['hour'], $dateArray['minute'], $dateArray['second']); } else { $this->date = new DateTime($date); } } date_default_timezone_set($tzCache); $this->setTimezone($tz); $this->from = $from; }
/** * 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 ) ); }
private function canAjax( &$field, &$user, $output, $reason, $ignoreEmpty = false ) { global $_CB_framework, $ueConfig; if ( ( $_CB_framework->getUi() == 1 ) && ( $output == 'html' ) && ( $reason == 'profile' ) && ( $field instanceof FieldTable ) && ( $user instanceof UserTable ) ) { if ( ! ( $field->params instanceof ParamsInterface ) ) { $params = new Registry( $field->params ); } else { $params = $field->params; } $value = $user->get( $field->get( 'name' ) ); $notEmpty = ( ( ! ( ( $value === null ) || ( $value === '' ) ) ) || $ueConfig['showEmptyFields'] || cbReplaceVars( CBTxt::T( $field->params->get( 'ajax_placeholder' ) ), $user ) ); $readOnly = $field->get( 'readonly' ); if ( $field->get( 'name' ) == 'username' ) { if ( ! $ueConfig['usernameedit'] ) { $readOnly = true; } } if ( ( ! $field->get( '_noAjax', false ) ) && ( ! $readOnly ) && ( $notEmpty || $ignoreEmpty ) && $params->get( 'ajax_profile', 0 ) && Application::MyUser()->canViewAccessLevel( (int) $params->get( 'ajax_profile_access', 2 ) ) && ( ! cbCheckIfUserCanPerformUserTask( $user->get( 'id' ), 'allowModeratorsUserEdit' ) ) ) { return true; } } return false; }
/** * @param bool $updateNulls * @return bool */ public function store( $updateNulls = false ) { global $_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_onBeforeUpdateAttendance', array( &$this, $old ) ); } else { $_PLUGINS->trigger( 'gj_onBeforeCreateAttendance', array( &$this ) ); } if ( ! parent::store( $updateNulls ) ) { return false; } if ( ! $new ) { $_PLUGINS->trigger( 'gj_onAfterUpdateAttendance', array( $this, $old ) ); } else { $_PLUGINS->trigger( 'gj_onAfterCreateAttendance', array( $this ) ); } return true; }
/** * Constructor * * @param DatabaseDriverInterface $db Database driver */ public function __construct(DatabaseDriverInterface $db = null) { if ($db === null) { $db = Application::Database(); } $this->_db = $db; $this->_silentWhenOK = false; }
/** * Constructor * * @param DatabaseDriverInterface $db Database driver interface * @param boolean $silentTestLogs TRUE: Silent on successful tests */ public function __construct(DatabaseDriverInterface $db = null, $silentTestLogs = true) { if ($db === null) { $db = Application::Database(); } $this->_db = $db; $this->_silentTestLogs = $silentTestLogs; }
/** * If table key (id) is NULL : inserts a new row * otherwise updates existing row in the database table * * Can be overridden or overloaded by the child class * * @param boolean $updateNulls TRUE: null object variables are also updated, FALSE: not. * @return boolean TRUE if successful otherwise FALSE */ public function store($updateNulls = false) { $key = $this->_tbl_key; if (!$this->{$key}) { $this->event_time = $this->_db->getUtcDateTime(); $this->user_id = Application::MyUser()->getUserId(); $this->ip_addresses = cbpaidRequest::getIPlist(); $this->log_version = 1; } return parent::store($updateNulls); }
static function getReturnURL($params, $type) { global $cbSpecialReturnAfterLogin, $cbSpecialReturnAfterLogout; static $returnUrl = null; if (!isset($returnUrl)) { $returnUrl = Application::Input()->get('get/return', '', GetterInterface::BASE64); if ($returnUrl) { $returnUrl = base64_decode($returnUrl); if (!JUri::isInternal($returnUrl)) { // The URL isn't internal to the site; reset it to index to be safe: $returnUrl = 'index.php'; } } else { $isHttps = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'; $returnUrl = 'http' . ($isHttps ? 's' : '') . '://' . $_SERVER['HTTP_HOST']; if (!empty($_SERVER['PHP_SELF']) && !empty($_SERVER['REQUEST_URI'])) { $returnUrl .= $_SERVER['REQUEST_URI']; } else { $returnUrl .= $_SERVER['SCRIPT_NAME']; if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { $returnUrl .= '?' . $_SERVER['QUERY_STRING']; } } } $returnUrl = cbUnHtmlspecialchars(preg_replace('/[\\\\"\\\'][\\s]*javascript:(.*)[\\\\"\\\']/', '""', preg_replace('/eval\\((.*)\\)/', '', htmlspecialchars(urldecode($returnUrl))))); if (preg_match('/index.php\\?option=com_comprofiler&task=confirm&confirmCode=|index.php\\?option=com_comprofiler&view=confirm&confirmCode=|index.php\\?option=com_comprofiler&task=login|index.php\\?option=com_comprofiler&view=login/', $returnUrl)) { $returnUrl = 'index.php'; } } $secureForm = (int) $params->get('https_post', 0); if ($type == 'login') { $loginReturnUrl = $params->get('login', $returnUrl); if (isset($cbSpecialReturnAfterLogin)) { $loginReturnUrl = $cbSpecialReturnAfterLogin; } $url = cbSef($loginReturnUrl, true, 'html', $secureForm); } elseif ($type == 'logout') { $logoutReturnUrl = $params->get('logout', 'index.php'); if ($logoutReturnUrl == '#') { $logoutReturnUrl = $returnUrl; } if (isset($cbSpecialReturnAfterLogout)) { $logoutReturnUrl = $cbSpecialReturnAfterLogout; } $url = cbSef($logoutReturnUrl, true, 'html', $secureForm); } else { $url = $returnUrl; } return base64_encode($url); }
/** * Constructor (allows to set non-standard table and key field) * Can be overloaded/supplemented by the child class * * @param DatabaseDriverInterface $db [optional] CB Database object * @param string $table [optional] Name of the table in the db schema relating to child class * @param string|array $key [optional] Name of the primary key field in the table */ public function __construct(DatabaseDriverInterface $db = null, $table = null, $key = null) { if ($db) { $this->_db = $db; } else { $this->_db = Application::Database(); } if ($table) { $this->_tbl = $table; } if ($key) { $this->_tbl_key = $key; } }
/** * @param null $tab * @param UserTable $user * @param int $ui * @param array $postdata */ public function getCBpluginComponent( $tab, $user, $ui, $postdata ) { global $_CB_framework; outputCbJs( 1 ); outputCbTemplate( 1 ); $action = $this->input( 'action', null, GetterInterface::STRING ); $function = $this->input( 'func', null, GetterInterface::STRING ); $id = $this->input( 'id', null, GetterInterface::INT ); $user = CBuser::getMyUserDataInstance(); $tab = new TabTable(); $tab->load( array( 'pluginclass' => 'cbinvitesTab' ) ); $profileUrl = $_CB_framework->userProfileUrl( $user->get( 'id' ), false, 'cbinvitesTab' ); if ( ! ( $tab->enabled && Application::MyUser()->canViewAccessLevel( $tab->viewaccesslevel ) ) ) { cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' ); } ob_start(); switch ( $action ) { case 'preparaty': switch ( $function ) { case 'delete': $this->deletePreparaty( $id, $user ); break; } break; default: cbRedirect( $profileUrl, CBTxt::T( 'Not authorized.' ), 'error' ); break; } $html = ob_get_contents(); ob_end_clean(); $class = $this->params->get( 'general_class', null ); $return = '<div id="cbInvites" class="cbInvites' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">' . '<div id="cbInvitesInner" class="cbInvitesInner">' . $html . '</div>' . '</div>'; echo $return; }
/** * Constructor (must stay old-named for compatibility with CBSubs GPL 3.0.0) * * @param Registry $pluginParams The parameters of the plugin * @param SimpleXMLElement $types The types definitions in XML * @param SimpleXMLElement $actions The actions definitions in XML * @param SimpleXMLElement $views The views definitions in XML * @param PluginTable $pluginObject The plugin object * @param int $tabId The tab id (if there is one) */ public function cbEditRowView($pluginParams, $types, $actions, $views, $pluginObject, $tabId = null) { global $_CB_database; $input = Application::Input(); /** @noinspection PhpDeprecationInspection */ if ($pluginParams instanceof cbParamsBase) { // Backwards-compatibility: /** @noinspection PhpDeprecationInspection */ $pluginParams = new Registry($pluginParams->toParamsArray()); } $this->registryEditView = new RegistryEditView($input, $_CB_database, $pluginParams, $types, $actions, $views, $pluginObject, $tabId); foreach (array_keys(get_object_vars($this->registryEditView)) as $k) { $this->{$k} =& $this->registryEditView->{$k}; } }
/** * Cleans the field value by type in a secure way for SQL * * @param mixed $fieldValue * @param string $type const,sql,param : string,int,float,datetime,formula * @param GetterInterface $pluginParams * @param DatabaseDriverInterface $db * @param array|null $extDataModels * @return string|boolean STRING: sql-safe value, Quoted or type-casted to int or float, or FALSE in case of type error */ public static function sqlCleanQuote($fieldValue, $type, GetterInterface $pluginParams, DatabaseDriverInterface $db, array $extDataModels = null) { $typeArray = explode(':', $type, 3); if (count($typeArray) < 2) { $typeArray = array('const', $type); } if ($typeArray[0] == 'param') { $fieldValue = $pluginParams->get($fieldValue); } elseif ($typeArray[0] == 'user') { // TODO: Change this to use Inversion Of Control, and allow XML valuetypes to be extended dynamically (e.g. instead of calling specifically CBLib\CB\User or similar when available, it is CB that adds the type and a closure to handle that type. if ($fieldValue == 'viewaccesslevels') { $fieldValue = Application::MyUser()->getAuthorisedViewLevels(); } else { if ($fieldValue == 'usergroups') { $fieldValue = Application::MyUser()->getAuthorisedGroups(false); } else { $fieldValue = \CBuser::getMyUserDataInstance()->get($fieldValue); } } } elseif (in_array($typeArray[0], array('request', 'get', 'post', 'cookie', 'cbcookie', 'session', 'server', 'env'))) { $fieldValue = self::_globalConv($typeArray[0], $fieldValue); } elseif ($typeArray[0] == 'ext') { if (isset($typeArray[2]) && $extDataModels && isset($extDataModels[$typeArray[2]])) { $model = $extDataModels[$typeArray[2]]; if (is_object($model)) { if ($model instanceof ParamsInterface) { $fieldValue = $model->get($fieldValue); } elseif (isset($model->{$fieldValue})) { $fieldValue = $model->{$fieldValue}; } } elseif (is_array($model)) { if (isset($model[$fieldValue])) { $fieldValue = $model[$fieldValue]; } } else { $fieldValue = $model; } } else { trigger_error('SQLXML::sqlCleanQuote: ERROR: ext valuetype "' . htmlspecialchars($type) . '" has not been setExternalDataTypeValues.', E_USER_NOTICE); } // } elseif ( ( $typeArray[0] == 'const' ) || ( $cnt_valtypeArray[0] == 'sql' ) { // $fieldValue = $fieldValue; } if (is_array($fieldValue)) { return self::cleanArrayType($fieldValue, $typeArray[1], $db); } return self::cleanScalarType($fieldValue, $typeArray[1], $db); }
/** * Gets articles * * @param int[] $paging * @param string $where * @param UserTable $viewer * @param UserTable $user * @param PluginTable $plugin * @return Table[] */ public static function getArticles($paging, $where, $viewer, $user, $plugin) { global $_CB_database; $categories = $plugin->params->get('article_k2_category', null); $query = 'SELECT a.*' . ', b.' . $_CB_database->NameQuote('id') . ' AS category' . ', b.' . $_CB_database->NameQuote('name') . ' AS category_title' . ', 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 WHERE a." . $_CB_database->NameQuote('created_by') . " = " . (int) $user->get('id') . "\n AND a." . $_CB_database->NameQuote('published') . " = 1" . "\n AND a." . $_CB_database->NameQuote('trash') . " = 0" . "\n AND a." . $_CB_database->NameQuote('access') . " IN " . $_CB_database->safeArrayOfIntegers(Application::MyUser()->getAuthorisedViewLevels()) . "\n AND b." . $_CB_database->NameQuote('published') . " = 1" . "\n AND b." . $_CB_database->NameQuote('trash') . " = 0" . "\n AND b." . $_CB_database->NameQuote('access') . " IN " . $_CB_database->safeArrayOfIntegers(Application::MyUser()->getAuthorisedViewLevels()); if ($categories) { $categories = explode('|*|', $categories); cbArrayToInts($categories); $query .= "\n AND a." . $_CB_database->NameQuote('catid') . " NOT IN ( " . implode(',', $categories) . " )"; } $query .= $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); } return $_CB_database->loadObjectList(null, '\\CBLib\\Database\\Table\\Table', array(null, '#__k2_items', 'id')); }
/** * @param OrderedTable $row * @param string[] $input * @param UserTable $user * @param stdClass $model * @param PluginTable $plugin */ static function showBlogEdit($row, $input, $user, $model, $plugin) { global $_CB_framework, $_PLUGINS; cbValidator::loadValidation(); $blogMode = $plugin->params->get('blog_mode', 1); $pageTitle = $row->get('id') ? CBTxt::T('Edit Blog') : CBTxt::T('Create Blog'); $cbModerator = Application::User((int) $user->get('id'))->isGlobalModerator(); $_CB_framework->setPageTitle($pageTitle); $_CB_framework->appendPathWay(htmlspecialchars(CBTxt::T('Blogs')), $_CB_framework->userProfileUrl($row->get('user', $user->get('id')), true, 'cbblogsTab')); $_CB_framework->appendPathWay(htmlspecialchars($pageTitle), $_CB_framework->pluginClassUrl($plugin->element, true, $row->get('id') ? array('action' => 'blogs', 'func' => 'edit', 'id' => (int) $row->get('id')) : array('action' => 'blogs', 'func' => 'new'))); initToolTip(); $return = '<div class="blogEdit">' . '<form action="' . $_CB_framework->pluginClassUrl($plugin->element, true, array('action' => 'blogs', 'func' => 'save', 'id' => (int) $row->get('id'))) . '" method="post" enctype="multipart/form-data" name="blogForm" id="blogForm" class="cb_form blogForm form-auto cbValidation">' . ($pageTitle ? '<div class="blogsTitle page-header"><h3>' . $pageTitle . '</h3></div>' : null); if ($cbModerator || !$plugin->params->get('blog_approval', 0)) { $return .= '<div class="cbft_select cbtt_select form-group cb_form_line clearfix">' . '<label for="published" class="col-sm-3 control-label">' . CBTxt::Th('Published') . '</label>' . '<div class="cb_field col-sm-9">' . $input['published'] . getFieldIcons(1, 0, null, CBTxt::T('Select publish status of the blog. Unpublished blogs will not be visible to the public.')) . '</div>' . '</div>'; } if ($plugin->params->get('blog_category_config', 1) || $cbModerator) { $return .= '<div class="cbft_select cbtt_select form-group cb_form_line clearfix">' . '<label for="category" class="col-sm-3 control-label">' . CBTxt::Th('Category') . '</label>' . '<div class="cb_field col-sm-9">' . $input['category'] . getFieldIcons(1, 0, null, CBTxt::T('Select blog category. Select the category that best describes your blog.')) . '</div>' . '</div>'; } if ($plugin->params->get('blog_access_config', 1) || $cbModerator) { $return .= '<div class="cbft_select cbtt_select form-group cb_form_line clearfix">' . '<label for="access" class="col-sm-3 control-label">' . CBTxt::Th('Access') . '</label>' . '<div class="cb_field col-sm-9">' . $input['access'] . getFieldIcons(1, 0, null, CBTxt::T('Select access to blog; all groups above that level will also have access to the blog.')) . '</div>' . '</div>'; } $return .= '<div class="cbft_text cbtt_input form-group cb_form_line clearfix">' . '<label for="title" class="col-sm-3 control-label">' . CBTxt::Th('Title') . '</label>' . '<div class="cb_field col-sm-9">' . $input['title'] . getFieldIcons(1, 1, null, CBTxt::T('Input blog title. This is the title that will distinguish this blog from others. Suggested to input something unique and intuitive.')) . '</div>' . '</div>'; if (in_array($blogMode, array(1, 2))) { $return .= '<div class="cbft_textarea cbtt_textarea form-group cb_form_line clearfix">' . '<label for="blog_intro" class="col-sm-3 control-label">' . ($blogMode == 1 ? CBTxt::T('Blog Intro') : CBTxt::T('Blog')) . '</label>' . '<div class="cb_field col-sm-9">' . $input['blog_intro'] . getFieldIcons(1, 0, null, CBTxt::T('Input HTML supported blog intro contents. Suggested to use minimal but well formatting for easy readability.')) . '</div>' . '</div>'; } if (in_array($blogMode, array(1, 3))) { $return .= '<div class="cbft_textarea cbtt_textarea form-group cb_form_line clearfix">' . '<label for="blog_full" class="col-sm-3 control-label">' . ($blogMode == 1 ? CBTxt::T('Blog Full') : CBTxt::T('Blog')) . '</label>' . '<div class="cb_field col-sm-9">' . $input['blog_full'] . getFieldIcons(1, 0, null, CBTxt::T('Input HTML supported blog contents. Suggested to use minimal but well formatting for easy readability.')) . '</div>' . '</div>'; } if ($cbModerator) { $return .= '<div class="cbft_text cbtt_input form-group cb_form_line clearfix">' . '<label for="user" class="col-sm-3 control-label">' . CBTxt::T('Owner') . '</label>' . '<div class="cb_field col-sm-9">' . $input['user'] . getFieldIcons(1, 1, null, CBTxt::T('Input owner of blog as single integer user_id.')) . '</div>' . '</div>'; } if ($plugin->params->get('blog_captcha', 0) && !$cbModerator) { $_PLUGINS->loadPluginGroup('user'); $captcha = $_PLUGINS->trigger('onGetCaptchaHtmlElements', array(false)); if (!empty($captcha)) { $captcha = $captcha[0]; $return .= '<div class="form-group cb_form_line clearfix">' . '<label class="col-sm-3 control-label">' . CBTxt::Th('Captcha') . '</label>' . '<div class="cb_field col-sm-9">' . (isset($captcha[0]) ? $captcha[0] : null) . '</div>' . '</div>' . '<div class="form-group cb_form_line clearfix">' . '<div class="cb_field col-sm-offset-3 col-sm-9">' . str_replace('inputbox', 'form-control', isset($captcha[1]) ? $captcha[1] : null) . getFieldIcons(1, 1, null) . '</div>' . '</div>'; } } $return .= '<div class="form-group cb_form_line clearfix">' . '<div class="col-sm-offset-3 col-sm-9">' . '<input type="submit" value="' . htmlspecialchars($row->get('id') ? CBTxt::T('Update Blog') : CBTxt::T('Create Blog')) . '" class="blogsButton blogsButtonSubmit btn btn-primary"' . cbValidator::getSubmitBtnHtmlAttributes() . ' /> ' . ' <input type="button" value="' . htmlspecialchars(CBTxt::T('Cancel')) . '" class="blogsButton blogsButtonCancel btn btn-default" onclick="if ( confirm( \'' . addslashes(CBTxt::T('Are you sure you want to cancel? All unsaved data will be lost!')) . '\' ) ) { location.href = \'' . $_CB_framework->userProfileUrl($row->get('user', $user->get('id')), false, 'cbblogsTab') . '\'; }" />' . '</div>' . '</div>' . cbGetSpoofInputTag('plugin') . '</form>' . '</div>'; echo $return; }
/** * Checks user access permission * * @param int $userIdPosted * @return null|string */ private function _authorizedEdit($userIdPosted) { global $_CB_framework; $iAmAdmin = Application::MyUser()->isSuperAdmin(); if (!$iAmAdmin) { if (Application::MyUser()->isAuthorizedToPerformActionOnAsset('core.manage', 'com_users')) { if ($userIdPosted == 0) { $action = 'core.create'; } elseif ($userIdPosted == $_CB_framework->myId()) { $action = 'core.edit.own'; } else { $action = 'core.edit'; } $iAmAdmin = Application::MyUser()->isAuthorizedToPerformActionOnAsset($action, 'com_users') && !Application::User((int) $userIdPosted)->isSuperAdmin(); } } if (!$iAmAdmin) { return CBTxt::T("Not Authorized"); } else { return null; } }
/** * @param int[] $paging * @param string $where * @param UserTable $viewer * @param UserTable $user * @param PluginTable $plugin * @return cbconsultationsconsultationTable[] */ static public function getconsultations( $paging, $where, $viewer, $user, /** @noinspection PhpUnusedParameterInspection */ $plugin ) { global $_CB_database; $categories = cbconsultationsModel::getCategoriesList( true ); $consultations = array(); if ( $categories ) { $query = 'SELECT a.*' . ', a.' . $_CB_database->NameQuote( 'created_by' ) . ' AS user' . ', a.' . $_CB_database->NameQuote( 'introtext' ) . ' AS consultation_intro' . ', a.' . $_CB_database->NameQuote( 'fulltext' ) . ' AS consultation_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 ) . "\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 ); } $consultations = $_CB_database->loadObjectList( null, 'cbconsultationsconsultationTable', array( $_CB_database ) ); } return $consultations; }
/** * @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; }
/** * Get plugin inputs * * @return InputInterface */ public function getInput() { if ($this->input) { return $this->input; } return Application::Input(); }
/** * Renders the Blogs tab * * @param OrderedTable[] $rows Blogs to render * @param cbPageNav $pageNav Pagination * @param boolean $searching Currently searching * @param string[] $input HTML of input elements * @param UserTable $viewer Viewing user * @param UserTable $user Viewed user * @param stdClass $model The model reference * @param TabTable $tab Current Tab * @param PluginTable $plugin Current Plugin * @return string HTML */ static function showBlogTab($rows, $pageNav, $searching, $input, $viewer, $user, $model, $tab, $plugin) { global $_CB_framework; $blogLimit = (int) $plugin->params->get('blog_limit', null); $tabPaging = $tab->params->get('tab_paging', 1); $canSearch = $tab->params->get('tab_search', 1) && ($searching || $pageNav->total); $canCreate = false; $profileOwner = $viewer->get('id') == $user->get('id'); $cbModerator = Application::User((int) $viewer->get('id'))->isGlobalModerator(); $canPublish = $cbModerator || $profileOwner && !$plugin->params->get('blog_approval', 0); if ($profileOwner) { if ($cbModerator) { $canCreate = true; } elseif ($user->get('id') && Application::User((int) $viewer->get('id'))->canViewAccessLevel((int) $plugin->params->get('blog_create_access', 2))) { if (!$blogLimit || $blogLimit && $pageNav->total < $blogLimit) { $canCreate = true; } } } $return = '<div class="blogsTab">' . '<form action="' . $_CB_framework->userProfileUrl($user->get('id'), true, $tab->tabid) . '" method="post" name="blogForm" id="blogForm" class="blogForm">'; if ($canCreate || $canSearch) { $return .= '<div class="blogsHeader row" style="margin-bottom: 10px;">'; if ($canCreate) { $return .= '<div class="' . (!$canSearch ? 'col-sm-12' : 'col-sm-8') . ' text-left">' . '<button type="button" onclick="location.href=\'' . $_CB_framework->pluginClassUrl($plugin->element, false, array('action' => 'blogs', 'func' => 'new')) . '\';" class="blogsButton blogsButtonNew btn btn-success"><span class="fa fa-plus-circle"></span> ' . CBTxt::T('New Blog') . '</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>'; } $menuAccess = $cbModerator || $profileOwner || $canPublish; $return .= '<table class="blogsContainer table table-hover table-responsive">' . '<thead>' . '<tr>' . '<th style="width: 50%;" class="text-left">' . CBTxt::T('Title') . '</th>' . '<th style="width: 25%;" class="text-left hidden-xs">' . CBTxt::T('Category') . '</th>' . '<th style="width: 24%;" class="text-left hidden-xs">' . CBTxt::T('Created') . '</th>' . ($menuAccess ? '<th style="width: 1%;" class="text-right"> </th>' : null) . '</tr>' . '</thead>' . '<tbody>'; if ($rows) { foreach ($rows as $row) { $return .= '<tr>' . '<td style="width: 50%;" class="text-left">' . ($row->get('published') ? '<a href="' . cbblogsModel::getUrl($row, true, 'article') . '">' . $row->get('title') . '</a>' : $row->get('title')) . '</td>' . '<td style="width: 25%;" class="text-left hidden-xs">' . ($row->get('category_published') ? '<a href="' . cbblogsModel::getUrl($row, true, 'category') . '">' . $row->get('category') . '</a>' : $row->get('category')) . '</td>' . '<td style="width: 24%;" class="text-left hidden-xs">' . cbFormatDate($row->get('created')) . '</td>'; if ($menuAccess) { $menuItems = '<ul class="blogsMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">'; if ($cbModerator || $profileOwner) { $menuItems .= '<li class="blogsMenuItem"><a href="' . $_CB_framework->pluginClassUrl($plugin->element, true, array('action' => 'blogs', 'func' => 'edit', 'id' => (int) $row->get('id'))) . '"><span class="fa fa-edit"></span> ' . CBTxt::T('Edit') . '</a></li>'; } if ($canPublish) { if ($row->get('published')) { $menuItems .= '<li class="blogsMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes(CBTxt::T('Are you sure you want to unpublish this Blog?')) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl($plugin->element, false, array('action' => 'blogs', 'func' => 'unpublish', 'id' => (int) $row->get('id'))) . '\'; }"><span class="fa fa-times-circle"></span> ' . CBTxt::T('Unpublish') . '</a></li>'; } else { $menuItems .= '<li class="blogsMenuItem"><a href="' . $_CB_framework->pluginClassUrl($plugin->element, true, array('action' => 'blogs', 'func' => 'publish', 'id' => (int) $row->get('id'))) . '"><span class="fa fa-check"></span> ' . CBTxt::T('Publish') . '</a></li>'; } } if ($cbModerator || $profileOwner) { $menuItems .= '<li class="blogsMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes(CBTxt::T('Are you sure you want to delete this Blog?')) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl($plugin->element, false, array('action' => 'blogs', '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 .= '<td style="width: 1%;" class="text-right">' . '<div class="blogsMenu btn-group">' . '<button type="button"' . $menuAttr . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>' . '</div>' . '</td>'; } $return .= '</tr>'; } } else { $return .= '<tr>' . '<td colspan="' . ($menuAccess ? 4 : 3) . '" class="text-left">'; if ($searching) { $return .= CBTxt::T('No blog search results found.'); } else { if ($viewer->id == $user->id) { $return .= CBTxt::T('You have no blogs.'); } else { $return .= CBTxt::T('This user has no blogs.'); } } $return .= '</td>' . '</tr>'; } $return .= '</tbody>'; if ($tabPaging && $pageNav->total > $pageNav->limit) { $return .= '<tfoot>' . '<tr>' . '<td colspan="' . ($menuAccess ? 4 : 3) . '" class="text-center">' . $pageNav->getListLinks() . '</td>' . '</tr>' . '</tfoot>'; } $return .= '</table>' . $pageNav->getLimitBox(false) . '</form>' . '</div>'; return $return; }
/** * Gets the FieldTable's corresponding to $tabid (and $reason if not $fullAccess) * * @param int $tabId * @param UserTable $user * @param string $reason * @param int|string $fieldIdOrName * @param boolean $prefetchFields * @param boolean $fullAccess * @return FieldTable[] */ public function _getTabFieldsDb($tabId, $user, $reason, $fieldIdOrName = null, $prefetchFields = true, $fullAccess = false) { static $preFetched = array(); static $fieldsByName = array(); $fields = array(); $preIdx = $fullAccess ? 'full' : $reason; if (!$prefetchFields || !isset($preFetched[$preIdx])) { global $_CB_framework, $_CB_database, $ueConfig; $where = array(); $ordering = array(); if ($fieldIdOrName && !$prefetchFields) { if (is_int($fieldIdOrName)) { $where[] = 'f.fieldid = ' . (int) $fieldIdOrName; } else { $where[] = 'f.name = ' . $_CB_database->Quote($fieldIdOrName); } } if ($reason == 'list' && in_array($ueConfig['name_format'], array(1, 2, 4))) { $where[] = "( f.published = 1 OR f.name = 'name' )"; } elseif ($reason != 'adminfulllist') { $where[] = 'f.published = 1'; } if (!$fullAccess) { switch ($reason) { case 'edit': if ($_CB_framework->getUi() == 1) { $where[] = 'f.edit > 0'; } break; case 'profile': $where[] = 'f.profile > 0'; break; case 'list': $where[] = "( f.profile > 0 OR f.name = 'username'" . (in_array($ueConfig['name_format'], array(1, 2, 4)) ? " OR f.name = 'name'" : '') . ')'; break; case 'register': $where[] = 'f.registration > 0'; break; case 'adminfulllist': default: break; } if ($tabId && !$prefetchFields) { $where[] = 'f.tabid = ' . (int) $tabId; } else { if ($reason != 'adminfulllist') { $where[] = 't.enabled = 1'; } if ($reason != 'register' && !($_CB_framework->getUi() == 2 && Application::MyUser()->isSuperAdmin())) { $where[] = 't.viewaccesslevel IN ' . $_CB_database->safeArrayOfIntegers(Application::MyUser()->getAuthorisedViewLevels()); } } if (($reason == 'profile' || $reason == 'list') && $ueConfig['allow_email_display'] == 0 && $reason != 'adminfulllist') { $where[] = 'f.type != ' . $_CB_database->Quote('emailaddress'); } } if (!$tabId || $prefetchFields) { if ($reason == 'register') { $ordering[] = 't.ordering_register'; } $ordering[] = 't.position'; $ordering[] = 't.ordering'; } $ordering[] = 'f.ordering'; $sql = 'SELECT f.*'; if ($reason == 'register') { $sql .= ', t.ordering_register AS tab_ordering_register, t.position AS tab_position, t.ordering AS tab_ordering'; } $sql .= ' FROM #__comprofiler_fields f'; if (!$tabId || $prefetchFields) { // don't get fields which are not assigned to tabs: $sql .= "\n INNER JOIN #__comprofiler_tabs AS t ON (f.tabid = t.tabid)"; } $sql .= ($where ? "\n WHERE " . implode(' AND ', $where) : '') . "\n ORDER BY " . implode(', ', $ordering); $_CB_database->setQuery($sql); $fields = $_CB_database->loadObjectList(null, '\\CB\\Database\\Table\\FieldTable', array()); if (!$_CB_database->getErrorNum()) { for ($i = 0, $n = count($fields); $i < $n; $i++) { $fields[$i]->params = new Registry($fields[$i]->params); if ($prefetchFields) { $fieldsByName[$preIdx][strtolower($fields[$i]->name)] = $fields[$i]; $preFetched[$preIdx][(int) $fields[$i]->tabid][(int) $fields[$i]->fieldid] = $fields[$i]; } } } } if (isset($preFetched[$preIdx])) { if ($tabId) { if (isset($preFetched[$preIdx][(int) $tabId])) { $fields = $preFetched[$preIdx][(int) $tabId]; } else { $fields = array(); } } elseif ($fieldIdOrName) { if (is_int($fieldIdOrName)) { $fields = array(); foreach (array_keys($preFetched[$preIdx]) as $k) { if (isset($preFetched[$preIdx][$k][$fieldIdOrName])) { $fields[] = $preFetched[$preIdx][$k][$fieldIdOrName]; break; } } } elseif (isset($fieldsByName[$preIdx][strtolower($fieldIdOrName)])) { $fields = array($fieldsByName[$preIdx][strtolower($fieldIdOrName)]); } else { $fields = array(); } } else { $fields = array(); foreach ($preFetched[$preIdx] as $flds) { // $fields = array_merge( $fields, $flds ); foreach ($flds as $fl) { $fields[$fl->fieldid] = $fl; } } } } // THIS is VERY experimental, and not yet part of CB API !!! : global $_PLUGINS; $_PLUGINS->loadPluginGroup('user'); $_PLUGINS->trigger('onAfterFieldsFetch', array(&$fields, &$user, $reason, $tabId, $fieldIdOrName, $fullAccess)); return $fields; }
/** * @param \CB\Database\Table\UserTable $user */ public function prepareStatus($user) { global $_CB_framework; $this->ui = $_CB_framework->getUi(); $this->cbUserIsModerator = Application::User((int) $user->id)->isGlobalModerator(); $this->cbMyIsModerator = Application::MyUser()->isModeratorFor(Application::User((int) $user->id)); $params = $this->params; switch ($params->get('statusFormat', 'menuList')) { case 'menuBar': $this->menuList = new cbMenuBar(1); break; case 'menuUL': $this->menuList = new cbMenuUL(1); break; case 'menuDivs': $this->menuList = new cbMenuDivs(1); break; case 'menuList': default: $this->menuList = new cbMenuList(1); break; } $this->menuList->outputScripts(1); }
/** * prepare frontend invite edit render * * @param int $id * @param UserTable $user */ private function showInviteEdit( $id, $user ) { global $_CB_framework; $row = new InviteTable(); $row->load( (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->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 ( $row->get( 'id' ) && ( $user->get( 'id' ) != $row->get( 'user_id' ) ) ) { cbRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to edit this invite.' ), 'error' ); } elseif ( ! $isModerator ) { if ( ( $row->get( 'published' ) == -1 ) || ( ( ! $this->params->get( 'groups_invites_display', 1 ) ) && ( $group->get( 'type' ) != 3 ) ) ) { cbRedirect( $returnUrl, CBTxt::T( 'You do not have access to invites in this group.' ), 'error' ); } elseif ( ( ! $row->get( 'id' ) ) && ( ! CBGroupJive::canCreateGroupContent( $user, $group, 'invites' ) ) ) { cbRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to create an invite in this group.' ), 'error' ); } } CBGroupJive::getTemplate( 'invite_edit' ); $input = array(); $inviteBy = array(); $inviteByLimit = explode( '|*|', $this->params->get( 'groups_invites_by', '1|*|2|*|3|*|4' ) ); if ( ! $inviteByLimit ) { $inviteByLimit = array( 1, 2, 3, 4 ); } if ( in_array( 1, $inviteByLimit ) ) { $inviteBy[] = CBTxt::T( 'User ID' ); } if ( in_array( 2, $inviteByLimit ) ) { $inviteBy[] = CBTxt::T( 'Username' ); } if ( in_array( 3, $inviteByLimit ) ) { $inviteBy[] = CBTxt::T( 'Name' ); } if ( in_array( 4, $inviteByLimit ) ) { $inviteBy[] = CBTxt::T( 'Email Address' ); } $input['invite_by'] = $inviteBy; $listConnections = array(); if ( Application::Config()->get( 'allowConnections' ) ) { $cbConnection = new cbConnection( (int) $user->get( 'id' ) ); foreach( $cbConnection->getConnectedToMe( (int) $user->get( 'id' ) ) as $connection ) { $listConnections[] = moscomprofilerHTML::makeOption( (string) $connection->id, getNameFormat( $connection->name, $connection->username, Application::Config()->get( 'name_format', 3 ) ) ); } } if ( $listConnections ) { array_unshift( $listConnections, moscomprofilerHTML::makeOption( '0', CBTxt::T( '- Select Connection -' ) ) ); $listTooltip = cbTooltip( null, CBTxt::T( 'Select a connection to invite.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['list'] = moscomprofilerHTML::selectList( $listConnections, 'selected', 'class="gjInviteConnection form-control"' . $listTooltip, 'value', 'text', (int) $this->input( 'post/selected', 0, GetterInterface::INT ), 1, false, false ); } else { $input['list'] = null; } $toTooltup = cbTooltip( null, CBTxt::T( 'GROUP_INVITE_BY', 'Input the recipient as [invite_by].', array( '[invite_by]' => implode( ', ', $inviteBy ) ) ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['to'] = '<input type="text" id="to" name="to" value="' . htmlspecialchars( $this->input( 'post/to', ( $row->get( 'user' ) ? (int) $row->get( 'user' ) : $row->get( 'email' ) ), GetterInterface::STRING ) ) . '" class="gjInviteOther form-control" size="40"' . $toTooltup . ' />'; $messageTooltip = cbTooltip( null, CBTxt::T( 'Optionally input private message to include with the invite.' ), null, null, null, null, null, 'data-hascbtooltip="true"' ); $input['message'] = '<textarea id="message" name="message" class="form-control" cols="40" rows="5"' . $messageTooltip . '>' . htmlspecialchars( $this->input( 'post/message', $row->get( 'message' ), GetterInterface::STRING ) ) . '</textarea>'; HTML_groupjiveInviteEdit::showInviteEdit( $row, $input, $group, $user, $this ); }
/** * 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); }
<?php /** * Community Builder (TM) * @version $Id: $ * @package CommunityBuilder * @copyright (C) 2004-2016 www.joomlapolis.com / Lightning MultiCom SA - and its licensors, all rights reserved * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU/GPL version 2 */ // ensure this file is being included by a parent file if (!(defined('_VALID_CB') || defined('_JEXEC') || defined('_VALID_MOS'))) { die('Direct Access to this location is not allowed.'); } // Auto-load and initialize everything that was in here: /** @see CB\Legacy\LegacyComprofilerFunctions */ \CBLib\Application\Application::DI()->get('CB\\Legacy\\LegacyComprofilerFunctions'); /** * The classes that were in here have moved to libraries/CBLib/CB/Legacy folder. * The functions in here have moved to libraries/CBLib/CB/Legacy/LegacyComprofilerFunctions.php */
function cbPoweredBy() { global $ueConfig; if (isset($ueConfig['poweredBy']) && !$ueConfig['poweredBy']) { return null; } $input = Application::Input(); $url = $input->get('server/SERVER_NAME', null, GetterInterface::STRING) . $input->get('server/REQUEST_URI', null, GetterInterface::STRING); $urls = array(array('title' => 'social network platform', 'url' => 'http://www.joomlapolis.com/social-networking?pk_campaign=in-cb&pk_kwd=poweredby'), array('title' => 'community software', 'url' => 'http://www.joomlapolis.com/community-builder?pk_campaign=in-cb&pk_kwd=poweredby'), array('title' => 'online community software', 'url' => 'http://www.joomlapolis.com/community-builder?pk_campaign=in-cb&pk_kwd=poweredby'), array('title' => 'social networking software', 'url' => 'http://www.joomlapolis.com/community-builder?pk_campaign=in-cb&pk_kwd=poweredby'), array('title' => 'open source social networking', 'url' => 'http://www.joomlapolis.com/social-networking?pk_campaign=in-cb&pk_kwd=poweredby'), array('title' => 'social network script', 'url' => 'http://www.joomlapolis.com/community-builder?pk_campaign=in-cb&pk_kwd=poweredby'), array('title' => 'social community software', 'url' => 'http://www.joomlapolis.com/community-builder?pk_campaign=in-cb&pk_kwd=poweredby'), array('title' => 'online social networking', 'url' => 'http://www.joomlapolis.com/community-builder?pk_campaign=in-cb&pk_kwd=poweredby'), array('title' => 'social websites', 'url' => 'http://www.joomlapolis.com/social-networking?pk_campaign=in-cb&pk_kwd=poweredby'), array('title' => 'online community sites', 'url' => 'http://www.joomlapolis.com/community-builder?pk_campaign=in-cb&pk_kwd=poweredby'), array('title' => 'how to build a social networking site', 'url' => 'http://www.joomlapolis.com?pk_campaign=in-cb&pk_kwd=poweredby'), array('title' => 'how to create a social network', 'url' => 'http://www.joomlapolis.com?pk_campaign=in-cb&pk_kwd=poweredby'), array('title' => 'online membership sites', 'url' => 'http://www.joomlapolis.com/cb-solutions/cbsubs?pk_campaign=in-cb&pk_kwd=poweredby'), array('title' => 'online paid subscription sites', 'url' => 'http://www.joomlapolis.com/cb-solutions/cbsubs?pk_campaign=in-cb&pk_kwd=poweredby'), array('title' => 'membership sites', 'url' => 'http://www.joomlapolis.com/cb-solutions/cbsubs?pk_campaign=in-cb&pk_kwd=poweredby'), array('title' => 'paid membership sites', 'url' => 'http://www.joomlapolis.com/cb-solutions/cbsubs?pk_campaign=in-cb&pk_kwd=poweredby')); list($urlBits) = sscanf(substr(md5($url), -4), '%4x'); $key = $urlBits % count($urls); $return = '<div class="cbPoweredBy cb_template cb_template_' . selectTemplate('dir') . '">' . '<div class="text-center text-small content-spacer">' . '<a title="' . htmlspecialchars($urls[$key]['title']) . '" href="' . htmlspecialchars($urls[$key]['url']) . '" target="_blank">' . 'Powered by Community Builder' . '</a>' . '</div>' . '</div>'; return $return; }
/** * 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; }
/** * Send an email to all global moderators * * @param string $subject Subject * @param string $message HTML message for PMS * @param boolean|int $replaceVariables Should we replace variables ? * @param int $mode false = plain text, true = HTML * @param null|string $cc Email CC address * @param null|string $bcc Email BCC address * @param null|string $attachment Email attachment files * @param array $extraStrings Extra replacement strings to use if $replaceVariables = true * @return boolean Result */ public function sendToModerators($subject, $message, $replaceVariables = false, $mode = 0, $cc = null, $bcc = null, $attachment = null, $extraStrings = array()) { global $_CB_database; $moderators = Application::CmsPermissions()->getGroupsOfViewAccessLevel(Application::Config()->get('moderator_viewaccesslevel', 3, \CBLib\Registry\GetterInterface::INT), true); if ($moderators) { $query = 'SELECT u.id' . "\n FROM #__users u" . "\n INNER JOIN #__comprofiler c" . ' ON u.id = c.id'; $query .= "\n INNER JOIN #__user_usergroup_map g" . ' ON c.id = g.user_id' . "\n WHERE g.group_id IN " . $_CB_database->safeArrayOfIntegers($moderators); $query .= "\n AND u.block = 0" . "\n AND c.confirmed = 1" . "\n AND c.approved = 1" . "\n AND u.sendEmail = 1"; $_CB_database->setQuery($query); $mods = $_CB_database->loadObjectList(); if ($mods) { foreach ($mods as $mod) { $this->sendFromSystem($mod->id, $subject, $message, $replaceVariables, $mode, $cc, $bcc, $attachment, $extraStrings); } } } }
/** * Renders the Articles tab * * @param Table[] $rows Articles to render * @param cbPageNav $pageNav Pagination * @param boolean $searching Currently searching * @param string[] $input HTML of input elements * @param UserTable $viewer Viewing user * @param UserTable $user Viewed user * @param stdClass $model The model reference * @param TabTable $tab Current Tab * @param PluginTable $plugin Current Plugin * @return string HTML */ static public function showPreparatyTab( $rows, $pageNav, $searching, $input, $viewer, $user, /** @noinspection PhpUnusedParameterInspection */ $model, $tab, /** @noinspection PhpUnusedParameterInspection */ $plugin ) { global $_CB_framework, $_LANG; $app =& JFactory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); $Itemid = $active->id; $tabPaging = $tab->params->get( 'tab_paging', 1 ); $canSearch = ( $tab->params->get( 'tab_search', 1 ) && ( $searching || $pageNav->total ) ); $canCreate = false; $profileOwner = ( $viewer->get( 'id' ) == $user->get( 'id' ) ); $cbModerator = Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator(); //$canPublish = ( $cbModerator || ( $profileOwner && ( ! $plugin->params->get( 'hangout_approval', 0 ) ) ) ); if ( $profileOwner ) { if ( $cbModerator ) { $canCreate = true; } elseif ( $user->get( 'id' ) && Application::User( (int) $viewer->get( 'id' ) )->canViewAccessLevel( (int) $plugin->params->get( 'hangout_create_access', 2 ) ) ) { if ( ( ! $blogLimit ) || ( $blogLimit && ( $pageNav->total < $blogLimit ) ) ) { $canCreate = true; } } } $return = '<div class="articlesTab">' . '<form action="' . $_CB_framework->userProfileUrl( $user->id, true, $tab->tabid ) . '" method="post" name="articleForm" id="articleForm" class="articleForm">'; if ( $canCreate ) { $return .= '<div class="' . ( ! $canSearch ? 'col-sm-12' : 'col-sm-8' ) . ' text-left">' . '<button type="button" onclick="location.href=\'' . ($_CB_framework->getCfg( 'live_site' ).'/index.php?option=com_flexicontent&view=item&typeid=2&task=add&Itemid='.$Itemid) . '\';" class="blogsButton blogsButtonNew btn btn-success"><span class="fa fa-plus-circle"></span> ' . $_LANG['New Preparat'] . '</button>' . '</div>'; } if ( $canSearch ) { $return .= '<div class="articlesHeader row" style="margin-bottom: 10px;">' . '<div class="col-sm-offset-8 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>' . '</div>'; } $return .= '<table class="articlesContainer table table-hover table-responsive">' . '<thead>' . '<tr>' . '<th style="width: 50%;" class="text-left">' . $_LANG['Preparat'] . '</th>' . '<th style="width: 25%;" class="text-left hidden-xs">' . CBTxt::T( 'Category' ) . '</th>' . '<th style="width: 25%;" class="text-left hidden-xs">' . CBTxt::T( 'Created' ) . '</th>' . '<th style="width: 1%;" class="text-left hidden-xs"></th>' . '</tr>' . '</thead>' . '<tbody>'; $attribs = ''; $image = FLEXI_J16GE ? JHTML::image(FLEXI_ICONPATH.'edit.png', JText::_( 'FLEXI_EDIT' ), $attribs) : JHTML::_('image.site', 'edit.png', FLEXI_ICONPATH, NULL, NULL, JText::_( 'FLEXI_EDIT' ), $attribs) ; if ( $rows ) foreach ( $rows as $row ) { $item_url = cbpreparatyModel::getUrl( $row, true, 'article' , $Itemid); //$item_url_edit = cbpreparatyModel::getUrl( $row, true, 'article' , 445); $link = $_CB_framework->getCfg( 'live_site' ). '/' .$item_url .(strstr($item_url, '?') ? '&' : '?'). 'task=edit'; $edit_row = $profileOwner ? '<a href="'.$link.'">'.$image.'</a> ' : ''; $return .= '<tr>' . '<td style="width: 50%;" class="text-left">'.$edit_row.'<a href="' . cbpreparatyModel::getUrl( $row, true, 'article' ) . '">' . $row->get( 'title' ) . '</a></td>' . '<td style="width: 25%;" class="text-left hidden-xs">' . ( $row->get( 'category' ) ? $row->get( 'category_title' ) : CBTxt::T( 'None' ) ) . '</td>' . '<td style="width: 25%;" class="text-left hidden-xs">' . cbFormatDate( $row->get( 'created' ) ) . '</td>'; if ( ( $cbModerator || $profileOwner ) ) { $menuItems = '<ul class="invitesMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">'; $menuItems .= '<li class="invitesMenuItem"><a href="' . $link . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>' . '<li class="invitesMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this Drug?' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'preparaty', '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 .= '<td style="width: 1%;" class="text-right">' . '<div class="invitesMenu btn-group">' . '<button type="button"' . $menuAttr . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>' . '</div>' . '</td>'; } else{ $return .= '<td style="width: 1%;" class="text-right"></td>'; } $return .= '</tr>'; } else { $return .= '<tr>' . '<td colspan="3" class="text-left">'; if ( $searching ) { $return .= $_LANG['No preparaty search results found.']; } else { if ( $viewer->id == $user->id ) { $return .= $_LANG['You have no preparaty.']; } else { $return .= $_LANG['This user has no preparaty.']; } } $return .= '</td>' . '</tr>'; } $return .= '</tbody>'; if ( $tabPaging && ( $pageNav->total > $pageNav->limit ) ) { $return .= '<tfoot>' . '<tr>' . '<td colspan="3" class="text-center">' . $pageNav->getListLinks() . '</td>' . '</tr>' . '</tfoot>'; } $return .= '</table>' . $pageNav->getLimitBox( false ) . '</form>' . '</div>'; return $return; }