/** * Mark an entry as opted out * * @return mixed */ public function award() { if (!$this->uid) { return NULL; } $opts = new ModIncrementalRegistrationOptions(); $awardPer = $opts->getAwardPerField(); $fieldMap = array('name' => 'Fullname', 'orgtype' => 'Employment', 'organization' => 'Organization', 'countryorigin' => 'Citizenship', 'countryresident' => 'Residency', 'gender' => 'Sex', 'url' => 'URL', 'reason' => 'Reason', 'race' => 'Race', 'phone' => 'Phone', 'disability' => 'Disability'); $alreadyComplete = 0; $eligible = array(); $newAmount = 0; $completeSql = 'UPDATE `#__profile_completion_awards` SET edited_profile = 1'; $optedOut = NULL; foreach ($this->awards as $k => $complete) { if ($k === 'opted_out') { $optedOut = $complete; continue; } if ($complete) { continue; } if ($k === 'picture') { self::$dbh->setQuery('SELECT picture FROM `#__xprofiles` WHERE uidNumber = ' . $this->uid); if (self::$dbh->loadResult()) { $completeSql .= ', ' . $k . ' = 1'; $alreadyComplete += $awardPer; } else { $eligible['picture'] = 1; } continue; } $regField = $fieldMap[$k]; if ((bool) $this->profile->get($k)) { $completeSql .= ', ' . $k . ' = 1'; $alreadyComplete += $awardPer; } else { $eligible[$k == 'url' ? 'web' : $k] = 1; } } self::$dbh->setQuery('SELECT SUM(amount) AS amount FROM `#__users_transactions` WHERE type = \'deposit\' AND category = \'registration\' AND uid = ' . $this->uid); $prior = self::$dbh->loadResult(); self::$dbh->setQuery($completeSql . ' WHERE user_id = ' . $this->uid); self::$dbh->execute(); if ($alreadyComplete) { self::$dbh->setQuery('SELECT COALESCE((SELECT balance FROM `#__users_transactions` WHERE uid = ' . $this->uid . ' AND id = (SELECT MAX(id) FROM `#__users_transactions` WHERE uid = ' . $this->uid . ')), 0)'); $newAmount = self::$dbh->loadResult() + $alreadyComplete; $BTL = new \Hubzero\Bank\Teller(self::$dbh, $this->uid); $BTL->deposit($alreadyComplete, 'Profile completion award', 'registration', 0); } return array('prior' => $prior, 'new' => $alreadyComplete, 'eligible' => $eligible, 'opted_out' => $optedOut); }
/** * Get the database connection * * @return object */ private static function getCurrent() { if (!self::$current) { $dbh = App::get('db'); $dbh->setQuery('SELECT * FROM `#__incremental_registration_options` ORDER BY added DESC LIMIT 1'); self::$current = $dbh->loadAssoc(); } return self::$current; }
} //registration update $update_missing = array(); if (isset($this->registration_update)) { $update_missing = $this->registration_update->_missing; } $invalid = array(); if (isset($this->registration_update)) { $invalid = $this->registration_update->_invalid; } //incremental registration require_once PATH_CORE . '/components/com_members/tables/incremental/awards.php'; require_once PATH_CORE . '/components/com_members/tables/incremental/groups.php'; require_once PATH_CORE . '/components/com_members/tables/incremental/options.php'; $uid = (int) $this->profile->get('uidNumber'); $incrOpts = new ModIncrementalRegistrationOptions(); $isIncrementalEnabled = $incrOpts->isEnabled($uid); ?> <?php if ($this->getError()) { ?> <p class="error"><?php echo $this->getError(); ?> </p> <?php } ?> <div id="profile-page-content" data-url="<?php