public function listAction() { $p = $_REQUEST; $tMO = new MemberModel(); $tDatas = $tMO->field('id mid,name,idcard,phone')->where('uid = ' . $this->tUid)->fList(); Tool_Fnc::ajaxMsg('', 1, $tDatas); }
/** * 获取会员列表 */ public function memberListAction() { $m = new MemberModel(); $page = safe::filterGet('page', 'int'); $pageData = $m->getList($page); $this->getView()->assign('member', $pageData['data']); $this->getView()->assign('bar', $pageData['bar']); }
public function index() { $op = ggp('op'); if ($op == 'do') { $this->isLogin(); list($address, $realname) = explode('@', $this->my['device_token']); $this->my['decive_token'] = unserialize($this->my['device_token']); if (!$address || !$this->my['mobile'] || !$realname) { $this->myError('请完善您的收货信息', U('member/address')); } $jf_goods_id = ggp('jf_goods_id:i'); $jfitem = M('jf_goods')->where('state=1')->find($jf_goods_id); empty($jfitem) && $this->myError('没有该商品'); $jfitem['jf_goods_jf'] > $this->my['jifen'] && $this->myError('您的积分不足'); MemberModel::I()->decJf($this->my['uid'], $jfitem['jf_goods_jf']); M('jf_log')->add(array('uid' => $this->my['uid'], 'uname' => $this->my['uname'], 'order_id' => $jfitem['jf_goods_id'], 'state' => 0, 'jf_goods_jf' => -$jfitem['jf_goods_jf'], 'ctime' => TIME, 'beizhu' => serialize(array('jf_goods_name' => $jfitem['jf_goods_name'], 'address' => $address, 'realname' => $realname, 'mobile' => $this->my['mobile'])))); if ($jfitem['jf_goods_num'] > 0) { if (intval($jfitem['jf_goods_num']) === 1) { M('jf_goods')->where("jf_goods_id='{$jfitem['jf_goods_id']}'")->save(array('state' => 0)); } M('jf_goods')->where("jf_goods_id='{$jfitem['jf_goods_id']}'")->setDec('jf_goods_num'); } $this->mySuccess('兑换成功'); } $hot_goods = M('goods')->where("state=1")->order('`order` DESC,hits DESC,goods_id DESC')->limit(8)->select(); $this->assign('hot_goods', $hot_goods); $list = M('jf_goods')->where("state=1")->order('`order` desc,jf_goods_id desc')->select(); $this->a('$list', $list); $this->d(); }
/** * Get the member avatar * @param integer * @param integer * @param integer * @return string */ public static function getMember($intId, $intWidth = null, $intHeight = null) { $objMember = \MemberModel::findByPk($intId); // Use the default size if (!$intWidth || !$intHeight) { list($intWidth, $intHeight) = static::getMemberSize(); } // Use the Gravatar if ($objMember->avatar_gravatar) { return static::getGravatar($objMember->email, $intWidth); } $strFile = static::find($intId, static::getMemberPath()); // Use placeholder member has no avatar if ($strFile == '') { if (\Config::get('avatar_member_placeholder') == '') { return ''; } $objFile = \FilesModel::findByUuid(\Config::get('avatar_member_placeholder')); if ($objFile === null || !is_file(TL_ROOT . '/' . $objFile->path)) { return ''; } $strFile = $objFile->path; } return \Image::get($strFile, $intWidth, $intHeight); }
/** * Send a lost password e-mail * @param object */ protected function sendPasswordLink($objMember) { $objNotification = \NotificationCenter\Model\Notification::findByPk($this->nc_notification); if ($objNotification === null) { $this->log('The notification was not found ID ' . $this->nc_notification, __METHOD__, TL_ERROR); return; } $confirmationId = md5(uniqid(mt_rand(), true)); // Store the confirmation ID $objMember = \MemberModel::findByPk($objMember->id); $objMember->activation = $confirmationId; $objMember->save(); $arrTokens = array(); // Add member tokens foreach ($objMember->row() as $k => $v) { $arrTokens['member_' . $k] = $v; } $arrTokens['recipient_email'] = $objMember->email; $arrTokens['domain'] = \Idna::decode(\Environment::get('host')); $arrTokens['link'] = \Idna::decode(\Environment::get('base')) . \Environment::get('request') . ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos(\Environment::get('request'), '?') !== false ? '&' : '?') . 'token=' . $confirmationId; $objNotification->send($arrTokens); $this->log('A new password has been requested for user ID ' . $objMember->id . ' (' . $objMember->email . ')', __METHOD__, TL_ACCESS); // Check whether there is a jumpTo page if (($objJumpTo = $this->objModel->getRelated('jumpTo')) !== null) { $this->jumpToOrReload($objJumpTo->row()); } $this->reload(); }
/** * Run the controller and parse the template */ public function run() { /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_preview'); $objTemplate->base = \Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->title = specialchars($GLOBALS['TL_LANG']['MSC']['fePreview']); $objTemplate->charset = \Config::get('characterSet'); $objTemplate->site = \Input::get('site', true); if (\Input::get('url')) { $objTemplate->url = \Environment::get('base') . \Input::get('url'); } elseif (\Input::get('page')) { $objTemplate->url = $this->redirectToFrontendPage(\Input::get('page'), \Input::get('article'), true); } else { $objTemplate->url = \Environment::get('base'); } // Switch to a particular member (see #6546) if (\Input::get('user') && $this->User->isAdmin) { $objUser = \MemberModel::findByUsername(\Input::get('user')); if ($objUser !== null) { $strHash = sha1(session_id() . (!\Config::get('disableIpCheck') ? \Environment::get('ip') : '') . 'FE_USER_AUTH'); // Remove old sessions $this->Database->prepare("DELETE FROM tl_session WHERE tstamp<? OR hash=?")->execute(time() - \Config::get('sessionTimeout'), $strHash); // Insert the new session $this->Database->prepare("INSERT INTO tl_session (pid, tstamp, name, sessionID, ip, hash) VALUES (?, ?, ?, ?, ?, ?)")->execute($objUser->id, time(), 'FE_USER_AUTH', session_id(), \Environment::get('ip'), $strHash); // Set the cookie $this->setCookie('FE_USER_AUTH', $strHash, time() + \Config::get('sessionTimeout'), null, null, false, true); $objTemplate->user = \Input::post('user'); } } \Config::set('debugMode', false); $objTemplate->output(); }
public static function cleanMembers(\DataContainer $objDc) { $intPid = \Input::get('id'); $blnIntroPrinted = false; if ($intPid && ($objArchive = SubmissionArchiveModel::findByPk($intPid)) !== null && $objArchive->memberGroups) { $arrArchiveGroups = deserialize($objArchive->memberGroups, true); if (!empty($arrArchiveGroups)) { if (($objMembers = \MemberModel::findAll()) !== null) { while ($objMembers->next()) { $arrGroups = deserialize($objMembers->groups, true); if (count(array_intersect($arrGroups, $arrArchiveGroups)) > 0) { // check for existing submissions if (SubmissionModel::findBy('mid', $objMembers->id) === null) { if (!$blnIntroPrinted) { echo $GLOBALS['TL_LANG']['tl_competition_submission']['cleanMembersIntro'] . '<br>'; $blnIntroPrinted = true; } echo $objMembers->id . '<br>'; $objMembers->groups = serialize(array_diff($arrGroups, $arrArchiveGroups)); $objMembers->save(); } } } } } } die; }
protected function onSubmitCallback(\DataContainer $dc) { // HOOK: send insert ID and user data if (isset($GLOBALS['TL_HOOKS']['preRegistration']) && is_array($GLOBALS['TL_HOOKS']['preRegistration'])) { foreach ($GLOBALS['TL_HOOKS']['preRegistration'] as $callback) { $this->import($callback[0]); $this->{$callback}[0]->{$callback}[1]($dc->activeRecord->id, $dc->activeRecord, $this->objModule); } } $objMember = \MemberModel::findByPk($dc->activeRecord->id); $objMember->login = $this->objModule->reg_allowLogin; $objMember->activation = md5(uniqid(mt_rand(), true)); $objMember->dateAdded = $dc->activeRecord->tstamp; // Set default groups if (empty($objMember->groups)) { $objMember->groups = $this->objModule->reg_groups; } // Disable account $objMember->disable = 1; $objMember->save(); if ($this->objModule->reg_activate_plus) { $this->formHybridSendConfirmationViaEmail = true; } // HOOK: send insert ID and user data if (isset($GLOBALS['TL_HOOKS']['createNewUser']) && is_array($GLOBALS['TL_HOOKS']['createNewUser'])) { foreach ($GLOBALS['TL_HOOKS']['createNewUser'] as $callback) { $this->import($callback[0]); $this->{$callback}[0]->{$callback}[1]($objMember->id, $objMember->row(), $this->objModule); } } // $this->setReset(false); // debug - stay on current page }
public function saveDefaultUserName($varValue, DataContainer $dc) { $member = \MemberModel::findById($dc->id); $member->username = $varValue; $member->save(); return $varValue; }
/** * Generate the module */ protected function compile() { $this->import('FrontendUser', 'User'); // Initialize the password widget $arrField = array('name' => 'password', 'inputType' => 'text', 'label' => $GLOBALS['TL_LANG']['MSC']['password'][0], 'eval' => array('hideInput' => true, 'mandatory' => true, 'required' => true, 'tableless' => $this->tableless)); $objWidget = new \FormTextField(\FormTextField::getAttributesFromDca($arrField, $arrField['name'])); $objWidget->rowClass = 'row_0 row_first even'; // Validate widget if (\Input::post('FORM_SUBMIT') == 'tl_close_account') { $objWidget->validate(); // Validate the password if (!$objWidget->hasErrors()) { // The password has been generated with crypt() if (\Encryption::test($this->User->password)) { $blnAuthenticated = \Encryption::verify($objWidget->value, $this->User->password); } else { list($strPassword, $strSalt) = explode(':', $this->User->password); $blnAuthenticated = $strSalt == '' ? $strPassword === sha1($objWidget->value) : $strPassword === sha1($strSalt . $objWidget->value); } if (!$blnAuthenticated) { $objWidget->value = ''; $objWidget->addError($GLOBALS['TL_LANG']['ERR']['invalidPass']); } } // Close account if (!$objWidget->hasErrors()) { // HOOK: send account ID if (isset($GLOBALS['TL_HOOKS']['closeAccount']) && is_array($GLOBALS['TL_HOOKS']['closeAccount'])) { foreach ($GLOBALS['TL_HOOKS']['closeAccount'] as $callback) { $this->import($callback[0]); $this->{$callback}[0]->{$callback}[1]($this->User->id, $this->reg_close, $this); } } $objMember = \MemberModel::findByPk($this->User->id); // Remove the account if ($this->reg_close == 'close_delete') { $objMember->delete(); $this->log('User account ID ' . $this->User->id . ' (' . $this->User->email . ') has been deleted', __METHOD__, TL_ACCESS); } else { $objMember->disable = 1; $objMember->tstamp = time(); $objMember->save(); $this->log('User account ID ' . $this->User->id . ' (' . $this->User->email . ') has been deactivated', __METHOD__, TL_ACCESS); } $this->User->logout(); // Check whether there is a jumpTo page if (($objJumpTo = $this->objModel->getRelated('jumpTo')) !== null) { $this->jumpToOrReload($objJumpTo->row()); } $this->reload(); } } $this->Template->fields = $objWidget->parse(); $this->Template->formId = 'tl_close_account'; $this->Template->action = \Environment::get('indexFreeRequest'); $this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['closeAccount']); $this->Template->rowLast = 'row_1 row_last odd'; $this->Template->tableless = $this->tableless; }
/** * Generate the module */ protected function compile() { // add miscellaneous vars to the template $this->addTemplateVars(); // get href for the detail-page $objDetailPage = \PageModel::findWithDetails($this->detailPage); if ($objDetailPage === NULL) { $href = NULL; } else { $href = $this->generateFrontendUrl($objDetailPage->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/member/%s', $objDetailPage->language); } $objMember = $this->Database->prepare('SELECT * FROM tl_member WHERE disable = ?')->execute(0); $arrRows = array(); while ($row = $objMember->fetchAssoc()) { foreach ($row as $k => $v) { if ($k == 'id' || $k == 'tstamp' || $k == 'password' || $k == 'avatar') { continue; } $row[$k] = $v; } // score and grade $row['score'] = $this->getScore($row['id']); $row['averageRating'] = $this->getAverageRating($row['id']); $row['ratingEnities'] = $this->getRatingEnities($row['id']); $row['gradeLabel'] = $this->getGrade($row['id'], 'label'); $row['gradeIcon'] = $this->getGrade($row['id'], 'label'); // link to detail page $row['hrefDetailPage'] = $href ? sprintf($href, $row['id']) : false; // get avatar of member $arrSize = deserialize($this->avatarSizeListing); $title = $row['firstname'] . ' ' . $row['lastname']; $row['avatar'] = $this->getAvatar($objMember->id, $arrSize, 'avatar', $title, 'avatar_thumb', $this); // Show only Members from a selected group if ($this->limitUsers) { $arrGroups = deserialize($this->listedGroups); $oMember = \MemberModel::findByPk($objMember->id); if ($oMember !== null) { if (count(array_intersect(deserialize($oMember->groups), $arrGroups)) < 1) { continue; } } } $arrRows[] = $row; } // Sorting $arrSorting = array(); if (!empty($this->sortingField1) && !empty($this->sortingDirection1)) { $arrSorting[$this->sortingField1] = constant($this->sortingDirection1); } if (!empty($this->sortingField2) && !empty($this->sortingDirection2)) { $arrSorting[$this->sortingField2] = constant($this->sortingDirection2); } if (!empty($this->sortingField3) && !empty($this->sortingDirection3)) { $arrSorting[$this->sortingField3] = constant($this->sortingDirection3); } $arrRows = sortArrayByFields($arrRows, $arrSorting); $this->Template->rows = count($arrRows) ? $arrRows : false; }
public static function getCompanyMembers() { $arrOptions = array(); if (($objMembers = \MemberModel::findByType('company')) !== null) { $arrOptions = array_combine($objMembers->fetchEach('id'), $objMembers->fetchEach('company')); } asort($arrOptions); return $arrOptions; }
public static function getMemberContentLink($intId) { if (($objMemberContentArchive = MemberContentArchiveModel::findByPk($intId)) !== null) { if (($objTag = MemberContentArchiveTagModel::findByPk($objMemberContentArchive->tag)) !== null && $objTag->jumpTo) { if (($objMember = \MemberModel::findByPk($objMemberContentArchive->mid)) !== null) { return Url::generateFrontendUrl($objTag->jumpTo) . '/' . General::getAliasIfAvailable($objMember); } } } }
/** * Check Credentials, ldap password != contao password * @param String - Input Username $username * @param String - Input Password $password * @param unknown $objMember */ public function checkCredentialsHook($strUsername, $strPassword, $objMember) { // store randomized password, so contao will always trigger the checkCredentials HOOK $objMember1 = \MemberModel::findByPk($objMember->id); LdapMember::resetPassword($objMember1, $strUsername); if (LdapMember::authenticateLdapMember($strUsername, $strPassword)) { LdapMember::doUpdateMember($objMember1, $objMember1->ldapUid, $objMember1->email, $objMember1->firstname, $objMember1->lastname, deserialize($GLOBALS['TL_CONFIG']['ldap_groups'], true)); return true; } else { return false; } }
/** * Actually execute the GoogleAnalytics tracking * @param Database_Result * @param IsotopeProductCollection $objOrder */ protected function trackGATransaction($objConfig, $objOrder) { // Initilize GA Tracker $tracker = new \UnitedPrototype\GoogleAnalytics\Tracker($objConfig->ga_account, \Environment::get('base')); // Assemble Visitor information // (could also get unserialized from database) $visitor = new \UnitedPrototype\GoogleAnalytics\Visitor(); $visitor->setIpAddress(\Environment::get('ip')); $visitor->setUserAgent(\Environment::get('httpUserAgent')); $transaction = new \UnitedPrototype\GoogleAnalytics\Transaction(); $transaction->setOrderId($objOrder->document_number); $transaction->setAffiliation($objConfig->name); $transaction->setTotal($objOrder->getTotal()); $transaction->setTax($objOrder->getTotal() - $objOrder->getTaxFreeTotal()); // $transaction->setShipping($objOrder->shippingTotal); $objAddress = $objOrder->getBillingAddress(); $transaction->setCity($objAddress->city); if ($objAddress->subdivision) { $arrSub = explode("-", $objAddress->subdivision, 2); $transaction->setRegion($arrSub[1]); } $transaction->setCountry($objAddress->country); /** @var \Isotope\Model\ProductCollectionItem $objItem */ foreach ($objOrder->getItems() as $objItem) { $item = new \UnitedPrototype\GoogleAnalytics\Item(); if ($objItem->getSku()) { $item->setSku($objItem->getSku()); } else { $item->setSku('product' . $objItem->product_id); } $item->setName($objItem->getName()); $item->setPrice($objItem->getPrice()); $item->setQuantity($objItem->quantity); $arrOptionValues = array(); foreach ($objItem->getConfiguration() as $option) { $arrOptionValues[] = (string) $option; } if (!empty($arrOptionValues)) { $item->setVariation(implode(', ', $arrOptionValues)); } $transaction->addItem($item); } // Track logged-in member as custom variable if ($objConfig->ga_member != '' && $objOrder->member > 0 && ($objMember = \MemberModel::findByPk($objOrder->member)) !== null) { $customVar = new \UnitedPrototype\GoogleAnalytics\CustomVariable(1, 'Member', $this->parseSimpleTokens($objConfig->ga_member, $objMember->row()), \UnitedPrototype\GoogleAnalytics\CustomVariable::SCOPE_VISITOR); $tracker->addCustomVariable($customVar); } // Assemble Session information // (could also get unserialized from PHP session) $session = new \UnitedPrototype\GoogleAnalytics\Session(); $tracker->trackTransaction($transaction, $session, $visitor); }
public static function getMembersAsOptions() { $arrOptions = array(); if (($objMembers = \MemberModel::findAll()) !== null) { while ($objMembers->next()) { $strName = $objMembers->firstname . ' ' . $objMembers->lastname; $strEmail = $objMembers->email ? $objMembers->email . ', ' : ''; $arrOptions[$objMembers->id] = trim($strName) ? $strName . ' (' . $strEmail . 'ID ' . $objMembers->id . ')' : $strEmail . 'ID ' . $objMembers->id; } } asort($arrOptions); return $arrOptions; }
public function recordUsername($intId, &$arrData) { if (!strlen($arrData['username'])) { $arrData['username'] = $arrData['email']; \Input::setPost('username', $arrData['email']); \Database::getInstance()->prepare("UPDATE tl_member SET username=? WHERE id=?")->execute($arrData['email'], $intId); $memberModel = \MemberModel::findByPk($intId); // Fix the problem with versions (see #7) if (null !== $memberModel) { $memberModel->refresh(); } } }
public function finishOrder() { $order_id = gg('order_id:i'); $where = "state=3 and order_id={$order_id} and buy_id={$this->my['uid']}"; $pay_price = M("order")->where($where)->getField("pay_price"); if (M('order')->where($where)->save(array('state' => '4'))) { $jifen = ceil($this->setting['jifen_order'] * $pay_price); MemberModel::I()->addJifen($this->my['uid'], $jifen); MemberModel::I()->addjfLog($this->my['uid'], $this->my['uname'], $order_id, 0 - $jifen, '3', "完成订单送积分"); $this->mySuccess('msg_common_update_success'); } $this->mySuccess('error_common_error'); }
public function listReviews($arrRow) { $strReview = '<div>'; if (($objMember = \MemberModel::findByPk($arrRow['jid'])) !== null) { $strReview .= $objMember->firstname . ' ' . $objMember->lastname; } if (($objSubmission = \HeimrichHannot\Competition\SubmissionModel::findByPk($arrRow['sid'])) !== null) { if ($objSubmission->companyTeamName) { $strReview .= ' <span style="color:#b3b3b3; padding-left:3px">[' . $objSubmission->companyTeamName . ']</span>'; } } $strReview .= '</div>'; return $strReview; }
/** * Authenticates a user. * The example implementation makes sure if the username and password * are both 'demo'. * In practical applications, this should be changed to authenticate * against some persistent user identity storage (e.g. database). * @return boolean whether authentication succeeds. */ public function authenticate() { $user_info = MemberModel::model()->find("username=:username", array(":username" => $this->username)); if ($user_info) { if ($user_info['pswd'] != md5($this->password)) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { $this->errorCode = self::ERROR_NONE; } } else { $this->errorCode = self::ERROR_USERNAME_INVALID; } return !$this->errorCode; }
/** * {@inheritdoc} */ public function authenticate(\PageModel $rootPage) { $authorization = \Environment::get('httpAuthorization'); list($mechanism, $authorization) = preg_split('#\\s+#', $authorization, 2); if (strtolower($mechanism) == 'basic') { $authorization = base64_decode($authorization); list($username, $password) = explode(':', $authorization, 2); $member = \MemberModel::findByUsername($username); // The password has been generated with crypt() if (crypt($password, $member->password) == $member->password) { return $member; } } return null; }
public static function addMember($strFirstname, $strLastname, $strUid, $strEmail, $strUsername, $arrGroups, $strLanguage) { $objMember = new \MemberModel(); // store randomized password, so contao will always trigger the checkCredentials hook $time = time(); $objMember->tstamp = $time; $objMember->dateAdded = $time; $objMember->firstname = $strFirstname; $objMember->lastname = $strLastname; $objMember->ldapUid = $strUid; $objMember->email = $strEmail; $objMember->login = true; $objMember->username = $strUsername; $objMember->password = md5($time . $strUsername); $objMember->groups = serialize($arrGroups); $objMember->language = $strLanguage; $objMember->save(); if (isset($GLOBALS['TL_HOOKS']['ldapAddMember']) && is_array($GLOBALS['TL_HOOKS']['ldapAddMember'])) { foreach ($GLOBALS['TL_HOOKS']['ldapAddMember'] as $callback) { $objMember = call_user_func(array($callback[0], $callback[1]), $objMember); } } $objMember->save(); }
/** * Generate the module */ protected function compile() { $this->import('FrontendUser', 'User'); // Initialize the password widget $arrField = array('name' => 'password', 'inputType' => 'text', 'label' => $GLOBALS['TL_LANG']['MSC']['password'][0], 'eval' => array('hideInput' => true, 'mandatory' => true, 'required' => true, 'tableless' => $this->tableless)); $objWidget = new \FormTextField($this->prepareForWidget($arrField, $arrField['name'])); $objWidget->rowClass = 'row_0 row_first even'; // Validate widget if (\Input::post('FORM_SUBMIT') == 'tl_close_account') { $objWidget->validate(); // Validate password if (!$objWidget->hasErrors()) { list(, $strSalt) = explode(':', $this->User->password); if (!strlen($strSalt) || sha1($strSalt . $objWidget->value) . ':' . $strSalt != $this->User->password) { $objWidget->value = ''; $objWidget->addError($GLOBALS['TL_LANG']['ERR']['invalidPass']); } } // Close account if (!$objWidget->hasErrors()) { // HOOK: send account ID if (isset($GLOBALS['TL_HOOKS']['closeAccount']) && is_array($GLOBALS['TL_HOOKS']['closeAccount'])) { foreach ($GLOBALS['TL_HOOKS']['closeAccount'] as $callback) { $this->import($callback[0]); $this->{$callback}[0]->{$callback}[1]($this->User->id, $this->reg_close, $this); } } $objMember = \MemberModel::findByPk($this->User->id); // Remove the account if ($this->reg_close == 'close_delete') { $objMember->delete(); $this->log('User account ID ' . $this->User->id . ' (' . $this->User->email . ') has been deleted', 'ModuleCloseAccount compile()', TL_ACCESS); } else { $objMember->disable = 1; $objMember->save(); $this->log('User account ID ' . $this->User->id . ' (' . $this->User->email . ') has been deactivated', 'ModuleCloseAccount compile()', TL_ACCESS); } $this->User->logout(); $this->jumpToOrReload($this->objModel->getRelated('jumpTo')->row()); } } $this->Template->fields = $objWidget->parse(); $this->Template->formId = 'tl_close_account'; $this->Template->action = $this->getIndexFreeRequest(); $this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['closeAccount']); $this->Template->rowLast = 'row_1 row_last odd'; $this->Template->tableless = $this->tableless; }
public function beforeAction($action) { if (parent::beforeAction($action)) { if (Yii::app()->user->isGuest) { $this->redirect(array('site/login')); } else { $userInfo = MemberModel::model()->find('username=:username', array(':username' => Yii::app()->user->name)); foreach (GroupModel::model()->findAll() as $g) { $group[$g->id] = $g; } Yii::app()->session['group'] = $group; Yii::app()->session['userInfo'] = array('uid' => $userInfo->uid, 'username' => $userInfo->username, 'nickname' => $userInfo->nickname, 'lv' => $userInfo->lv, 'groupId' => $userInfo->groupId); } } return true; }
/** * Get all FrontendUsers and return them as array * @param object * @return array */ public function getFrontendUsers($objModule) { $objFrontendUsers = MemberModel::findAll(); if ($objFrontendUsers === null) { return array(); } $arrFrontendUsers = array(); // Back end if (TL_MODE == 'BE') { while ($objFrontendUsers->next()) { $arrFrontendUsers[$objFrontendUsers->id] = "{$objFrontendUsers->firstname} {$objFrontendUsers->lastname} ({$objFrontendUsers->email})"; } return $arrFrontendUsers; } return array(); }
/** * Return the "toggle visibility" button * @param array * @param string * @param string * @param string * @param string * @param string * @return string */ public function toggleIcon($row, $href, $label, $title, $icon, $attributes) { $objMember = \MemberModel::findByPk($row['id']); $href .= '&id=' . $row['id']; $arrDB = \Database::getInstance()->prepare("SELECT * FROM tl_abo as a, tl_abo_order as o WHERE o.memberId = ? and o.aboId = a.id")->execute($row['id'])->fetchAssoc(); if ($arrDB) { $icon = 'system/modules/abonnement/html/abo.png'; $title = "Abo: " . $arrDB['title'] . '<br>'; } else { $icon = 'system/modules/abonnement/html/abo_none.png'; $title = 'Derzeit kein Abo laufen!<br>'; } foreach (deserialize($objMember->groups, true) as $intGroupId) { $objGroup = MemberGroupModel::findByPk($intGroupId); $title .= "<br>" . $objGroup->name; } return '<a href="' . $this->addToUrl('do=member&' . $href) . '" title="' . specialchars($title) . '"' . $attributes . '>' . $this->generateImage($icon, $label) . '</a> '; }
protected function compile() { if ($this->check_news && FE_USER_LOGGED_IN) { $this->Import('FrontendUser', 'Member'); $objMember = \MemberModel::findById($this->Member->id); $arrArchives = deserialize($this->news_archives); if (is_array($arrArchives)) { $objNews = $this->Database->prepare("SELECT * FROM tl_news WHERE pid IN(" . implode(",", $arrArchives) . ") && tstamp > ? && published='1'")->execute($objMember->lastLogin); if (!$objNews->count()) { $objPage = \PageModel::findById($this->jumpTo); \Controller::redirect(\Controller::generateFrontendUrl($objPage->row(), '')); } } } if (!FE_USER_LOGGED_IN && $this->redirecter_guests or FE_USER_LOGGED_IN && $this->redirecter_protected) { $objPage = \PageModel::findById($this->jumpTo); $this->redirect($this->generateFrontendUrl($objPage->row(), '')); } }
/** * Store Login Module ID in Session, required by LdapAuth (Module config) * @return string */ public function generate() { // Login if (\Input::post('FORM_SUBMIT') == 'tl_login') { if (\Input::post('username', true) && \Input::post('password', true)) { $objMember = \MemberModel::findBy('username', \Input::post('username', true)); if ($objMember !== null) { // always reset the password to a random value, otherwise checkCredentialsHook will never be triggered LdapMember::resetPassword($objMember, \Input::post('username', true)); } } // validate email if ($GLOBALS['TL_CONFIG']['ldap_uid'] == 'mail' && !\Validator::isEmail(\Input::post('username', true))) { \Message::addError($GLOBALS['TL_LANG']['ERR']['email']); $this->reload(); } } $strParent = parent::generate(); return $strParent; }
/** * add member to a certain group that is assigned to a certain score */ public function addGroupMembership() { $arrayGrades = MemberRating::getGradeLabelingArray(); if (!count($arrayGrades) > 0) { return; } krsort($arrayGrades); $objMember = \MemberModel::findAll(); while ($objMember->next()) { foreach ($arrayGrades as $grade) { $score = MemberRating::getScore($objMember->id); if ($score >= $grade['score']) { if (count($grade['groups']) > 0) { MemberRating::addToGroup($objMember->id, $grade['groups']); } break; } } } }
public function setUsernameFromEmail(&$objDc) { if ($objDc instanceof \Contao\FrontendUser) { if (!$objDc->email) { return; } $objDc->username = $objDc->email; $objDc->save(); } elseif ($objDc->activeRecord) { if (!$objDc->activeRecord->email) { return; } $objMember = \MemberModel::findByPk($objDc->activeRecord->id); $objMember->refresh(); $objMember->username = $objDc->activeRecord->email; if (TL_MODE == 'BE') { $objDc->activeRecord->username = $objDc->activeRecord->email; } $objMember->save(); } }