当前位置: 首页>>代码示例>>PHP>>正文


PHP Plugin::byType方法代码示例

本文整理汇总了PHP中Plugin::byType方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugin::byType方法的具体用法?PHP Plugin::byType怎么用?PHP Plugin::byType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Plugin的用法示例。


在下文中一共展示了Plugin::byType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getPlugin

 /**
  * Get the plugin data of a specific type if no specific plugin is specified
  * otherwise only the specific plugin data is returned.
  *
  * @param   string  $type    The plugin type, relates to the sub-directory in the plugins directory.
  * @param   string  $plugin  The plugin name.
  *
  * @return  mixed  An array of plugin data objects, or a plugin data object.
  *
  * @since   11.1
  */
 public static function getPlugin($type, $plugin = null)
 {
     // [!] Hubzero
     if (class_exists('\\Plugin')) {
         return \Plugin::byType($type, $plugin);
     }
     $result = array();
     $plugins = self::_load();
     // Find the correct plugin(s) to return.
     if (!$plugin) {
         foreach ($plugins as $p) {
             // Is this the right plugin?
             if ($p->type == $type) {
                 $result[] = $p;
             }
         }
     } else {
         foreach ($plugins as $p) {
             // Is this plugin in the right group?
             if ($p->type == $type && $p->name == $plugin) {
                 $result = $p;
                 break;
             }
         }
     }
     return $result;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:38,代码来源:helper.php

示例2: display

 /**
  * Display module contents
  *
  * @return  void
  */
 public function display()
 {
     if (!App::isAdmin()) {
         return;
     }
     $return = self::getReturnURI();
     $freturn = base64_encode('index.php?' . Request::getQueryString());
     $returnQueryString = !empty($return) ? "&return={$return}" : '';
     $authenticators = [];
     $plugins = \Plugin::byType('authentication');
     foreach ($plugins as $p) {
         $pparams = new Registry($p->params);
         // Make sure it supports admin login
         if (!$pparams->get('admin_login', false)) {
             continue;
         }
         // If it's the default hubzero plugin, don't include it in the list (we'll include it separately)
         if ($p->name == 'hubzero') {
             $site_display = $pparams->get('display_name', \Config::get('sitename'));
             $basic = true;
         } else {
             $display = $pparams->get('display_name', ucfirst($p->name));
             $authenticators[$p->name] = array('name' => $p->name, 'display' => $display);
         }
     }
     require $this->getLayoutPath($this->params->get('layout', 'default'));
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:32,代码来源:helper.php

示例3: display

 function display($tpl = null)
 {
     $user = User::getRoot();
     // If this is an auth_link account update, carry on, otherwise raise an error
     if (!is_object($user) || !array_key_exists('auth_link_id', $user) || !is_numeric($user->get('username')) || !$user->get('username') < 0) {
         App::abort('405', 'Method not allowed');
         return;
     }
     // Get and add the js and extra css to the page
     \Hubzero\Document\Assets::addComponentStylesheet('com_users', 'link.css');
     \Hubzero\Document\Assets::addComponentStylesheet('com_users', 'providers.css');
     \Hubzero\Document\Assets::addComponentScript('com_users', 'link');
     // Import a few things
     jimport('joomla.user.helper');
     // Look up a few things
     $hzal = \Hubzero\Auth\Link::find_by_id($user->get("auth_link_id"));
     $hzad = \Hubzero\Auth\Domain::find_by_id($hzal->auth_domain_id);
     $plugins = Plugin::byType('authentication');
     // Get the display name for the current plugin being used
     Plugin::import('authentication', $hzad->authenticator);
     $plugin = Plugin::byType('authentication', $hzad->authenticator);
     $pparams = new \Hubzero\Config\Registry($plugin->params);
     $refl = new ReflectionClass("plgAuthentication{$plugin->name}");
     $display_name = $pparams->get('display_name', $refl->hasMethod('onGetLinkDescription') ? $refl->getMethod('onGetLinkDescription')->invoke(NULL) : ucfirst($plugin->name));
     // Look for conflicts - first check in the hub accounts
     $profile_conflicts = \Hubzero\User\Profile\Helper::find_by_email($hzal->email);
     // Now check the auth_link table
     $link_conflicts = \Hubzero\Auth\Link::find_by_email($hzal->email, array($hzad->id));
     $conflict = array();
     if ($profile_conflicts) {
         foreach ($profile_conflicts as $p) {
             $user_id = JUserHelper::getUserId($p);
             $juser = User::getInstance($user_id);
             $auth_link = \Hubzero\Auth\Link::find_by_user_id($juser->id);
             $dname = is_object($auth_link) && $auth_link->auth_domain_name ? $auth_link->auth_domain_name : 'hubzero';
             $conflict[] = array("auth_domain_name" => $dname, "name" => $juser->name, "email" => $juser->email);
         }
     }
     if ($link_conflicts) {
         foreach ($link_conflicts as $l) {
             $juser = User::getInstance($l['user_id']);
             $conflict[] = array("auth_domain_name" => $l['auth_domain_name'], "name" => $juser->name, "email" => $l['email']);
         }
     }
     // Make sure we don't somehow have any duplicate conflicts
     $conflict = array_map("unserialize", array_unique(array_map("serialize", $conflict)));
     // @TODO: Could also check for high probability of name matches???
     // Get the site name
     $sitename = Config::get('sitename');
     // Assign variables to the view
     $this->assign('hzal', $hzal);
     $this->assign('hzad', $hzad);
     $this->assign('plugins', $plugins);
     $this->assign('display_name', $display_name);
     $this->assign('conflict', $conflict);
     $this->assign('sitename', $sitename);
     $this->assignref('juser', $user);
     parent::display($tpl);
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:59,代码来源:view.html.php

示例4: getOptions

 /**
  * Method to get the field options for category
  *
  * @return  array
  */
 protected function getOptions()
 {
     $options = [];
     $options[] = Html::select('option', '', Lang::txt('Site default'));
     foreach (Plugin::byType('mail') as $plugin) {
         $options[] = Html::select('option', $plugin->name, ucfirst($plugin->name));
     }
     return $options;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:14,代码来源:mailers.php

示例5: up

 /**
  * Up
  **/
 public function up()
 {
     // If a plugin is enabled, we'll assume that it should also be enabled for site login if not already saved
     // We changed the CMS to enforce the configuration option of site_login enabled.  Prior to this, it was
     // assuming true.  We need to default the database to emulate current behavior.
     $plugins = Plugin::byType('authentication');
     if (count($plugins) > 0) {
         foreach ($plugins as $plugin) {
             $params = json_decode($plugin->params);
             if (is_null($params)) {
                 $params = new \stdClass();
             }
             if (!isset($params->site_login)) {
                 $params->site_login = "1";
                 $this->saveParams('plg_authentication_' . $plugin->name, (array) $params);
             }
         }
     }
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:22,代码来源:Migration20151014171203Core.php

示例6: array

        break;
    default:
        break;
}
?>

	<form action="<?php 
echo Route::url('index.php?option=' . $this->option . '&' . ($this->task == 'create' ? 'return=' . $form_redirect : 'task=' . $this->task));
?>
" method="post" id="hubForm">

		<?php 
if ($this->task == 'create' && empty($this->xregistration->_invalid) && empty($this->xregistration->_missing)) {
    // Check to see if third party auth plugins are enabled
    Plugin::import('authentication');
    $plugins = Plugin::byType('authentication');
    $authenticators = array();
    foreach ($plugins as $p) {
        if ($p->name != 'hubzero') {
            $pparams = new \Hubzero\Config\Registry($p->params);
            $display = $pparams->get('display_name', ucfirst($p->name));
            $authenticators[] = array('name' => $p->name, 'display' => $display);
        }
    }
    // There are third party plugins, so show them on the registration form
    if (!empty($authenticators)) {
        $this->css('providers.css', 'com_users');
        ?>
				<div class="explaination">
					<p class="info">You can choose to log in via one of these services, and we'll help you fill in the info below!</p>
					<p>Already have an account? <a href="<?php 
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:31,代码来源:default.php

示例7: onLoginUser

 /**
  * This method should handle any login logic and report back to the subject
  *
  * @param   array    $user     holds the user data
  * @param   array    $options  array holding options (remember, autoregister, group)
  * @return  boolean  True on success
  */
 public function onLoginUser($user, $options = array())
 {
     jimport('joomla.user.helper');
     $xuser = User::getRoot();
     // get user from session (might be tmp_user, can't fetch from db)
     if ($xuser->get('guest')) {
         // joomla user plugin hasn't run or something went very badly
         $plugins = Plugin::byType('user');
         $xuser_order = false;
         $joomla_order = false;
         $i = 0;
         foreach ($plugins as $plugin) {
             if ($plugin->name == 'xusers') {
                 $xuser_order = $i;
             }
             if ($plugin->name == 'joomla') {
                 $joomla_order = $i;
             }
             $i++;
         }
         if ($joomla_order === false) {
             return new Exception(Lang::txt('E_JOOMLA_USER_PLUGIN_MISCONFIGURED'), 500);
         }
         if ($xuser_order <= $joomla_order) {
             return new Exception(Lang::txt('E_HUBZERO_USER_PLUGIN_MISCONFIGURED'), 500);
         }
         return new Exception(Lang::txt('E_JOOMLA_USER_PLUGIN_FAILED'), 500);
     }
     // log login to auth log
     Log::auth($xuser->get('id') . ' [' . $xuser->get('username') . '] ' . $_SERVER['REMOTE_ADDR'] . ' login');
     // correct apache log data
     apache_note('auth', 'login');
     // Log attempt to the database
     Hubzero\User\User::oneOrFail($xuser->get('id'))->logger()->auth()->save(['username' => $xuser->get('username'), 'status' => 'success']);
     // update session tracking with new data
     $session = App::get('session');
     $session->set('tracker.user_id', $xuser->get('id'));
     $session->set('tracker.username', $xuser->get('username'));
     if ($session->get('tracker.sid') == '') {
         $session->set('tracker.sid', $session->getId());
     }
     $session->set('tracker.psid', $session->get('tracker.sid'));
     if ($session->get('tracker.rsid') == '') {
         $session->set('tracker.rsid', $session->getId());
     }
     if ($session->get('tracker.user_id') != $xuser->get('id') || $session->get('tracker.ssid') == '') {
         $session->set('tracker.ssid', $session->getId());
     }
     if (empty($user['type'])) {
         $session->clear('session.authenticator');
     } else {
         $session->set('session.authenticator', $user['type']);
     }
     if (isset($options['silent']) && $options['silent']) {
         $session->set('session.source', 'cookie');
     } else {
         $session->set('session.source', 'user');
     }
     // update tracking data with changes related to login
     jimport('joomla.utilities.utility');
     $hash = App::hash(App::get('client')->name . ':tracker');
     $key = \App::hash('');
     $crypt = new \Hubzero\Encryption\Encrypter(new \Hubzero\Encryption\Cipher\Simple(), new \Hubzero\Encryption\Key('simple', $key, $key));
     $tracker = array();
     $tracker['user_id'] = $session->get('tracker.user_id');
     $tracker['username'] = $session->get('tracker.username');
     $tracker['sid'] = $session->getId();
     $tracker['rsid'] = $session->get('tracker.rsid', $tracker['sid']);
     $tracker['ssid'] = $session->get('tracker.ssid', $tracker['sid']);
     $cookie = $crypt->encrypt(serialize($tracker));
     $lifetime = time() + 365 * 24 * 60 * 60;
     // Determine whether cookie should be 'secure' or not
     $secure = false;
     $forceSsl = \Config::get('force_ssl', false);
     if (\App::isAdmin() && $forceSsl >= 1) {
         $secure = true;
     } else {
         if (\App::isSite() && $forceSsl == 2) {
             $secure = true;
         }
     }
     setcookie($hash, $cookie, $lifetime, '/', '', $secure, true);
     /* Mark registration as incomplete so it gets checked on next page load */
     $username = $xuser->get('username');
     if (isset($user['auth_link']) && is_object($user['auth_link'])) {
         $hzal = $user['auth_link'];
     } else {
         $hzal = null;
     }
     if ($xuser->get('tmp_user')) {
         $email = $xuser->get('email');
         if ($username[0] == '-') {
             $username = trim($username, '-');
//.........这里部分代码省略.........
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:101,代码来源:xusers.php

示例8: onAfterRoute

 /**
  * Hook for after parsing route
  *
  * @return void
  */
 public function onAfterRoute()
 {
     if (App::isSite() && !User::isGuest()) {
         $exceptions = ['com_users.logout', 'com_users.userlogout', 'com_support.tickets.save.index', 'com_support.tickets.new.index', 'com_members.media.download.profiles', 'com_members.save.profiles', 'com_members.profiles.save', 'com_members.profiles.save.profiles', 'com_members.changepassword', 'com_content.article', '/legal/terms'];
         if ($allowed = trim($this->params->get('exceptions'))) {
             $allowed = str_replace("\r", '', $allowed);
             $allowed = str_replace('\\n', "\n", $allowed);
             $allowed = explode("\n", $allowed);
             $allowed = array_map('trim', $allowed);
             $allowed = array_map('strtolower', $allowed);
             $exceptions = array_merge($exceptions, $allowed);
             $exceptions = array_unique($exceptions);
         }
         $current = Request::getWord('option', '');
         $current .= ($controller = Request::getWord('controller', false)) ? '.' . $controller : '';
         $current .= ($task = Request::getWord('task', false)) ? '.' . $task : '';
         $current .= ($view = Request::getWord('view', false)) ? '.' . $view : '';
         // If exception not found, let's try by raw URL path
         if (!in_array($current, $exceptions)) {
             $current = Request::path();
         }
         if (!in_array($current, $exceptions) && Session::get('registration.incomplete')) {
             // First check if we're heading to the registration pages, and allow that through
             if (Request::getWord('option') == 'com_members' && (Request::getWord('controller') == 'register' || Request::getWord('view') == 'register')) {
                 // Set linkaccount far to false at this point, otherwise we'd get stuck in a loop
                 Session::set('linkaccount', false);
                 $this->event->stop();
                 return;
             }
             // Tmp users
             if (User::get('tmp_user')) {
                 Request::setVar('option', 'com_members');
                 Request::setVar('controller', 'register');
                 Request::setVar('task', 'create');
                 Request::setVar('act', '');
                 $this->event->stop();
             } else {
                 if (substr(User::get('email'), -8) == '@invalid') {
                     $usersConfig = Component::params('com_users');
                     $simpleRegistration = $usersConfig->get('simple_registration', false);
                     if (Session::get('linkaccount', true) && !$simpleRegistration) {
                         Request::setVar('option', 'com_users');
                         Request::setVar('view', 'link');
                     } else {
                         Request::setVar('option', 'com_members');
                         Request::setVar('controller', 'register');
                         Request::setVar('task', 'update');
                         Request::setVar('act', '');
                     }
                     $this->event->stop();
                 } else {
                     // Does the user even have access to the profile plugin?
                     // If not, then we can't redirect them there
                     $plugin = Plugin::byType('members', 'profile');
                     if (!empty($plugin)) {
                         Request::setVar('option', 'com_members');
                         Request::setVar('task', 'view');
                         Request::setVar('id', User::get('id'));
                         Request::setVar('active', 'profile');
                         $this->event->stop();
                     } else {
                         // Nothing else we can do, so let them go
                         // and mark the incompleteness state so we don't
                         // keep checking on every page load
                         Session::get('registration.incomplete', false);
                     }
                 }
             }
         }
     }
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:76,代码来源:incomplete.php

示例9: link

 public function link()
 {
     $user = User::getInstance();
     // First, they should already be logged in, so check for that
     if ($user->get('guest')) {
         App::abort(403, Lang::txt('You must be logged in to perform this function'));
         return;
     }
     // Do we have a return
     $return = '';
     $options = array();
     if ($return = Request::getVar('return', '', 'method', 'base64')) {
         $return = base64_decode($return);
         if (!JURI::isInternal($return)) {
             $return = '';
         } else {
             $options['return'] = base64_encode($return);
         }
     }
     $authenticator = Request::getVar('authenticator', '', 'method');
     // If a specific authenticator is specified try to call the link method for that plugin
     if (!empty($authenticator)) {
         Plugin::import('authentication');
         $plugin = Plugin::byType('authentication', $authenticator);
         $className = 'plg' . $plugin->type . $plugin->name;
         if (class_exists($className)) {
             if (method_exists($className, 'link')) {
                 $myplugin = new $className($this, (array) $plugin);
                 $myplugin->link($options);
             } else {
                 // No Link method is availble
                 App::redirect(Route::url('index.php?option=com_members&id=' . $user->get('id') . '&active=account'), 'Linked accounts are not currently available for this provider.', 'error');
             }
         }
     } else {
         // No authenticator provided...
         App::abort(400, Lang::txt('Missing authenticator'));
         return;
     }
     // Success!  Redict with message
     App::redirect(Route::url('index.php?option=com_members&id=' . $user->get('id') . '&active=account'), 'Your account has been successfully linked!');
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:42,代码来源:user.php

示例10: _view

 /**
  * Primary/default view function
  *
  * @return object Return
  */
 private function _view()
 {
     // Setup our view
     $view = $this->view('default', 'overview');
     // Get linked accounts, if any
     Plugin::import('authentication');
     $view->domains_avail = Plugin::byType('authentication');
     $view->hzalaccounts = \Hubzero\Auth\Link::find_by_user_id($this->user->get("id"));
     // Put the used domains into an array with details available from the providers (if applicable)
     $view->domains_used = array();
     $view->domain_names = array();
     if ($view->hzalaccounts) {
         Plugin::import('authentication');
         $i = 0;
         foreach ($view->hzalaccounts as $authenticators) {
             $plugin = Plugin::byType('authentication', $authenticators['auth_domain_name']);
             // Make sure we got the plugin
             if (!is_object($plugin)) {
                 unset($view->hzalaccounts[$i]);
                 continue;
             }
             $className = 'plg' . $plugin->type . $plugin->name;
             $details = array();
             if (class_exists($className)) {
                 if (method_exists($className, 'getInfo')) {
                     $details = $className::getInfo($plugin->params);
                 }
             }
             $view->domains_used[] = array('name' => $authenticators['auth_domain_name'], 'details' => $details);
             $view->domain_names[] = $authenticators['auth_domain_name'];
             // Increment index
             $i++;
         }
     }
     // Get unused domains
     $view->domains_unused = array();
     foreach ($view->domains_avail as $domain) {
         if ($domain->name != 'hubzero' && !in_array($domain->name, $view->domain_names)) {
             $view->domains_unused[] = $domain;
         }
     }
     // Determine what type of password change the user needs
     $hzup = \Hubzero\User\Password::getInstance($this->member->get('uidNumber'));
     if (!empty($hzup->passhash)) {
         // A password has already been set, now check if they're logged in with a linked account
         if (array_key_exists('auth_link_id', $this->user)) {
             // Logged in with linked account
             $view->passtype = 'changelocal';
         } else {
             // Logged in with hub
             $view->passtype = 'changehub';
         }
     } else {
         // No password has been set...
         $view->passtype = 'set';
     }
     // Get password expiration information
     $view->passinfo = $this->getPassInfo();
     // Get the ssh key if it exists
     $view->key = $this->readKey();
     // Get the password rules
     $password_rules = \Hubzero\Password\Rule::getRules();
     // Get the password rule descriptions
     $view->password_rules = array();
     foreach ($password_rules as $rule) {
         if (!empty($rule['description'])) {
             $view->password_rules[] = $rule['description'];
         }
     }
     // A few more things...
     $view->option = $this->option;
     $view->member = $this->member;
     $view->params = $this->params;
     $view->notifications = $this->getPluginMessage() ? $this->getPluginMessage() : array();
     // Set any errors
     foreach ($this->getErrors() as $error) {
         $view->setError($error);
     }
     return $view->loadTemplate();
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:85,代码来源:account.php

示例11: annotateit

 /**
  * Processes file annotations
  *
  * @return  void
  */
 public function annotateit()
 {
     // Check permission
     if (!$this->model->access('content')) {
         throw new Exception(Lang::txt('ALERTNOTAUTH'), 403);
         return;
     }
     // Get the file entity
     $file = trim($this->subdir, '/') . '/' . trim(Request::getVar('item', ''));
     $entity = Entity::fromPath($file, $this->connection->adapter());
     // Grab annotations
     $keys = Request::getVar('key', []);
     $values = Request::getVar('value', []);
     $metadata = [];
     foreach ($keys as $idx => $key) {
         $key = trim($key);
         $value = trim($values[$idx]);
         if (!empty($key) && !empty($value)) {
             $metadata[$key] = $value;
         }
     }
     // Look for plugins that know how to handle them
     $plugins = Plugin::byType('metadata');
     if (count($plugins) == 0) {
         \Notify::message(Lang::txt('PLG_PROJECTS_FILES_ERROR_NO_ANNOTATION_PLUGINS'), 'error', 'projects');
     } else {
         // Send the data off to the plugins
         $response = Event::trigger('metadata.onMetadataSave', [$entity, $metadata]);
         if (empty($response)) {
             \Notify::message(Lang::txt('PLG_PROJECTS_FILES_ANNOTATED_SUCCESS'), 'success', 'projects');
         } else {
             \Notify::message(Lang::txt('PLG_PROJECTS_FILES_ERROR_ANNOTATE_FAILED'), 'error', 'projects');
         }
     }
     // Redirect to file list
     $url = $this->model->link('files') . '&action=browse&connection=' . $this->connection->id;
     $url .= $this->subdir ? '&subdir=' . urlencode($this->subdir) : '';
     // Redirect
     App::redirect(Route::url($url, false));
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:45,代码来源:connections.php

示例12: getInstitutions

 private static function getInstitutions()
 {
     static $inst = NULL;
     if ($inst === NULL) {
         $plugin = Plugin::byType('authentication', 'shibboleth');
         $inst = json_decode(json_decode($plugin->params)->institutions, TRUE);
         $inst = $inst['activeIdps'];
     }
     return $inst;
 }
开发者ID:sumudinie,项目名称:hubzero-cms,代码行数:10,代码来源:shibboleth.php

示例13: foreach

if ($ag->get('state') == 1) {
    echo ' selected="selected"';
}
?>
><?php 
echo Lang::txt('JYes');
?>
</option>
			</select>
		</p>

<?php 
if ($plugins = Event::trigger('courses.onAssetgroupEdit')) {
    $data = $ag->get('params');
    foreach ($plugins as $plugin) {
        $p = Plugin::byType('courses', $plugin['name']);
        $default = new \Hubzero\Config\Registry($p->params);
        $param = new JParameter(is_object($data) ? $data->toString() : $data, PATH_CORE . DS . 'plugins' . DS . 'courses' . DS . $plugin['name'] . DS . $plugin['name'] . '.xml');
        foreach ($default->toArray() as $k => $v) {
            if (substr($k, 0, strlen('default_')) == 'default_') {
                $param->def(substr($k, strlen('default_')), $default->get($k, $v));
            }
        }
        $out = $param->render('params', 'onAssetgroupEdit');
        if (!$out) {
            continue;
        }
        ?>
			<fieldset class="eventparams" id="params-<?php 
        echo $plugin['name'];
        ?>
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:31,代码来源:editassetgroup.php

示例14: onPointRoyalties

 /**
  * Calculate point royalties for members
  *
  * @param   object   $job  \Components\Cron\Models\Job
  * @return  boolean
  */
 public function onPointRoyalties(\Components\Cron\Models\Job $job)
 {
     $this->database = App::get('db');
     $action = 'royalty';
     // What month/year is it now?
     $curmonth = Date::format("F");
     $curyear = Date::format("Y-m");
     $ref = strtotime($curyear);
     $this->_message = Lang::txt('PLG_CRON_MEMBERS_POINT_ROYALTIES_DISTRIBUTED_ANSWERS', $curyear);
     $rmsg = Lang::txt('PLG_CRON_MEMBERS_POINT_ROYALTIES_DISTRIBUTED_REVIEWS', $curyear);
     $resmsg = Lang::txt('PLG_CRON_MEMBERS_POINT_ROYALTIES_DISTRIBUTED_RESOURCES', $curyear);
     // Make sure we distribute royalties only once/ month
     $royaltyAnswers = \Hubzero\Bank\MarketHistory::getRecord('', $action, 'answers', $curyear, $this->_message);
     $royaltyReviews = \Hubzero\Bank\MarketHistory::getRecord('', $action, 'reviews', $curyear, $rmsg);
     $royaltyResources = \Hubzero\Bank\MarketHistory::getRecord('', $action, 'resources', $curyear, $resmsg);
     // Include economy classes
     if (is_file(PATH_CORE . DS . 'components' . DS . 'com_answers' . DS . 'helpers' . DS . 'economy.php')) {
         require_once PATH_CORE . DS . 'components' . DS . 'com_answers' . DS . 'helpers' . DS . 'economy.php';
     }
     if (is_file(PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'helpers' . DS . 'economy.php')) {
         require_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'helpers' . DS . 'economy.php';
     }
     $AE = new \Components\Answers\Helpers\Economy($this->database);
     $accumulated = 0;
     // Get Royalties on Answers
     if (!$royaltyAnswers) {
         $rows = $AE->getQuestions();
         if ($rows) {
             foreach ($rows as $r) {
                 $AE->distribute_points($r->id, $r->q_owner, $r->a_owner, $action);
                 $accumulated = $accumulated + $AE->calculate_marketvalue($r->id, $action);
             }
             // make a record of royalty payment
             if (intval($accumulated) > 0) {
                 $MH = \Hubzero\Bank\MarketHistory::blank()->set(array('itemid' => $ref, 'date' => Date::toSql(), 'market_value' => $accumulated, 'category' => 'answers', 'action' => $action, 'log' => $this->_message));
                 if (!$MH->save()) {
                     $err = $MH->getError();
                 }
             }
         } else {
             $this->_message = Lang::txt('PLG_CRON_MEMBERS_POINT_ROYALTIES_NO_QUESTIONS');
         }
     } else {
         $this->_message = Lang::txt('PLG_CRON_MEMBERS_POINT_ROYALTIES_ALREADY_DISTRIBUTED_ANSWERS', $curyear);
     }
     // Get Royalties on Resource Reviews
     if (!$royaltyReviews) {
         // get eligible
         $RE = new \Components\Resources\Helpers\Economy\Reviews($this->database);
         $reviews = $RE->getReviews();
         // do we have ratings on reviews enabled?
         $param = Plugin::byType('resources', 'reviews');
         $plparam = new \Hubzero\Config\Registry($param->params);
         $voting = $plparam->get('voting');
         $accumulated = 0;
         if ($reviews && $voting) {
             foreach ($reviews as $r) {
                 $RE->distribute_points($r, $action);
                 $accumulated = $accumulated + $RE->calculate_marketvalue($r, $action);
             }
             $this->_message .= $rmsg;
         } else {
             $this->_message .= Lang::txt('PLG_CRON_MEMBERS_POINT_ROYALTIES_NO_REVIEWS');
         }
         // make a record of royalty payment
         if (intval($accumulated) > 0) {
             $MH = \Hubzero\Bank\MarketHistory::blank()->set(array('itemid' => $ref, 'date' => Date::toSql(), 'market_value' => $accumulated, 'category' => 'reviews', 'action' => $action, 'log' => $rmsg));
             if (!$MH->save()) {
                 $err = $MH->getError();
             }
         }
     } else {
         $this->_message .= Lang::txt('PLG_CRON_MEMBERS_POINT_ROYALTIES_ALREADY_DISTRIBUTED_REVIEWS', $curyear);
     }
     // Get Royalties on Resources
     if (!$royaltyResources) {
         // get eligible
         $ResE = new \Components\Resources\Helpers\Economy($this->database);
         $cons = $ResE->getCons();
         $accumulated = 0;
         if ($cons) {
             foreach ($cons as $con) {
                 $ResE->distribute_points($con, $action);
                 $accumulated = $accumulated + $con->ranking;
             }
             $this->_message .= $resmsg;
         } else {
             $this->_message .= Lang::txt('PLG_CRON_MEMBERS_POINT_ROYALTIES_NO_RESOURCES');
         }
         // make a record of royalty payment
         if (intval($accumulated) > 0) {
             $MH = \Hubzero\Bank\MarketHistory::blank()->set(array('itemid' => $ref, 'date' => Date::toSql(), 'market_value' => $accumulated, 'category' => 'resources', 'action' => $action, 'log' => $resmsg));
             if (!$MH->save()) {
                 $err = $MH->getError();
//.........这里部分代码省略.........
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:101,代码来源:members.php

示例15: display

 /**
  * Method to display the view.
  *
  * @param	string	The template file to include
  * @since	1.5
  */
 public function display($tpl = null)
 {
     // Get the view data.
     $this->user = User::getInstance();
     $this->form = $this->get('Form');
     $this->state = $this->get('State');
     $this->params = $this->state->get('params');
     // Make sure we're using a secure connection
     if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') {
         App::redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
         die('insecure connection and redirection failed');
     }
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         App::abort(500, implode('<br />', $errors));
         return false;
     }
     // Check for layout override
     $active = \App::get('menu')->getActive();
     if (isset($active->query['layout'])) {
         $this->setLayout($active->query['layout']);
     }
     //Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
     $this->prepareDocument();
     $furl = base64_encode(Request::current(true));
     $this->freturn = $furl;
     // HUBzero: If we have a return set with an authenticator in it, we're linking an existing account
     // Parse the return to retrive the authenticator, and remove it from the list below
     $auth = '';
     if ($return = Request::getVar('return', null, 'GET', 'BASE64')) {
         $decoded_return = base64_decode($return);
         $query = parse_url($decoded_return);
         if (is_array($query) && isset($query['query'])) {
             $query = $query['query'];
             $query = explode('&', $query);
             $auth = '';
             foreach ($query as $q) {
                 $n = explode('=', $q);
                 if ($n[0] == 'authenticator') {
                     $auth = $n[1];
                 }
             }
         }
     }
     // Set return if is isn't already
     if (is_null($return) && is_object($active)) {
         $return = $active->params->get('login_redirect_url', Route::url('index.php?option=com_members&task=myaccount'));
         $return = base64_encode($return);
     }
     // Figure out whether or not any of our third party auth plugins are turned on
     // Don't include the 'hubzero' plugin, or the $auth plugin as described above
     $multiAuth = false;
     $plugins = Plugin::byType('authentication');
     $authenticators = array();
     $remember_me_default = 0;
     foreach ($plugins as $p) {
         $client = App::get('client')->alias . '_login';
         $pparams = new \Hubzero\Config\Registry($p->params);
         // Make sure plugin is enabled for a given client
         if (!$pparams->get($client, false)) {
             continue;
         }
         if ($p->name != 'hubzero' && $p->name != $auth) {
             $display = $pparams->get('display_name', ucfirst($p->name));
             $authenticators[$p->name] = array('name' => $p->name, 'display' => $display);
             $multiAuth = true;
         } else {
             if ($p->name == 'hubzero') {
                 $remember_me_default = $pparams->get('remember_me_default', 0);
                 $this->site_display = $pparams->get('display_name', Config::get('sitename'));
                 $this->local = true;
             }
         }
     }
     // Override $multiAuth if authenticator is set to hubzero
     if (Request::getWord('authenticator') == 'hubzero') {
         $multiAuth = false;
     }
     // Set the return if we have it...
     $this->returnQueryString = !empty($return) ? "&return={$return}" : '';
     $this->multiAuth = $multiAuth;
     $this->return = $return;
     $this->authenticators = $authenticators;
     $this->totalauths = count($plugins);
     $this->remember_me_default = $remember_me_default;
     // if authenticator is specified call plugin display method, otherwise (or if method does not exist) use default
     $authenticator = Request::getVar('authenticator', '', 'method');
     Plugin::import('authentication');
     foreach ($plugins as $plugin) {
         $className = 'plg' . $plugin->type . $plugin->name;
         if (class_exists($className)) {
             $myplugin = new $className($this, (array) $plugin);
             if (method_exists($className, 'status')) {
//.........这里部分代码省略.........
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:101,代码来源:view.html.php


注:本文中的Plugin::byType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。