本文整理汇总了PHP中CBLib\Application\Application类的典型用法代码示例。如果您正苦于以下问题:PHP Application类的具体用法?PHP Application怎么用?PHP Application使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Application类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadEnabledAccounts
/**
* 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];
}
}
示例2: initNotification
/**
* 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;
}
}
示例3: __construct
/**
* 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;
}
示例4: showAbout
/**
* 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 )
);
}
示例5: canAjax
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;
}
示例6: store
/**
* @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;
}
示例7: __construct
/**
* Constructor
*
* @param DatabaseDriverInterface $db Database driver
*/
public function __construct(DatabaseDriverInterface $db = null)
{
if ($db === null) {
$db = Application::Database();
}
$this->_db = $db;
$this->_silentWhenOK = false;
}
示例8: __construct
/**
* 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;
}
示例9: store
/**
* 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);
}
示例10: getReturnURL
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);
}
示例11: __construct
/**
* 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;
}
}
示例12: getCBpluginComponent
/**
* @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;
}
示例13: cbEditRowView
/**
* 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};
}
}
示例14: sqlCleanQuote
/**
* 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);
}
示例15: getArticles
/**
* 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'));
}