/** * Create/Update ldap group as tl_member_group * @param serialized array $varValue * @return serialized array $varValue */ public static function updateMemberGroups($varValue) { $arrSelectedLdapMemberGroups = deserialize($varValue, true); if (!empty($arrSelectedLdapMemberGroups)) { $arrLdapMemberGroups = LdapMemberGroupModel::getLdapMemberGroups(); if (!is_array($arrLdapMemberGroups) || empty($arrLdapMemberGroups)) { return $varValue; } // ldap groups foreach ($arrLdapMemberGroups as $k => $v) { // selected ldap groups in settings foreach ($arrSelectedLdapMemberGroups as $gid) { if (isset($v['gidnumber']) && $v['gidnumber'][0] == $gid) { $objMemberGroup = \MemberGroupModel::findBy('ldapGid', $gid); if ($objMemberGroup === null) { $objMemberGroup = new \MemberGroupModel(); $objMemberGroup->ldapGid = $gid; } $objMemberGroup->tstamp = time(); // name if (isset($v['cn'])) { $objMemberGroup->name = $v['cn'][0]; } else { $objMemberGroup->name = $gid; } $objMemberGroup->save(); } } } LdapMember::updateMembers($arrSelectedLdapMemberGroups); } return $varValue; }
/** * Filter disabled groups * * @return array */ public function getActiveGroups() { $arrGroups = array(); $objGroup = MemberGroupModel::findAllActive(); if ($objGroup !== null) { while ($objGroup->next()) { $arrGroups[$objGroup->id] = $objGroup->name; } } return $arrGroups; }
public static function getLocalMemberGroupIds($arrLdapMemberGroupIds) { $arrResult = array(); foreach ($arrLdapMemberGroupIds as $currentGid) { $objMemberGroup = \MemberGroupModel::findBy('ldapGid', $currentGid); if ($objMemberGroup !== null) { $arrResult[] = $objMemberGroup->id; } } return $arrResult; }
public static function getMemberGroups() { $arrOptions = array(); $arrMemberGroups = \MemberGroupModel::findAllActive(); if ($arrMemberGroups !== null) { foreach ($arrMemberGroups as $objMemberGroup) { $arrOptions[$objMemberGroup->id] = $objMemberGroup->name; } } return $arrOptions; }
/** * 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> '; }
public static function doUpdateMember($objMember, $uid, $mail, $firstname, $lastname, $arrSelectedLdapMemberGroups) { $arrMemberGroups = deserialize($objMember->groups, true); $objLocalLdapMemberGroups = \MemberGroupModel::findBy(array('(tl_member_group.ldapGid > 0)'), null, array()); $arrLdapMemberGroups = LdapMemberModel::getLdapMemberGroupsByUid($uid); if ($objLocalLdapMemberGroups !== null) { $arrLocalLdapMemberGroups = $objLocalLdapMemberGroups->fetchEach('ldapGid'); $objMember->ldapUid = $uid; $objMember->email = $mail; $objMember->firstname = $firstname; $objMember->lastname = $lastname; $objMember->username = $GLOBALS['TL_CONFIG']['ldap_uid'] == 'mail' ? $objMember->email : $objMember->ldapUid; // merge non ldap contao groups with assigned (and active!) remote ldap groups $objMember->groups = serialize(array_merge(array_diff($arrMemberGroups, array_keys($arrLocalLdapMemberGroups)), LdapMemberGroupModel::getLocalMemberGroupIds(array_intersect($arrLdapMemberGroups, $arrSelectedLdapMemberGroups)))); if (isset($GLOBALS['TL_HOOKS']['ldapUpdateMember']) && is_array($GLOBALS['TL_HOOKS']['ldapUpdateMember'])) { foreach ($GLOBALS['TL_HOOKS']['ldapUpdateMember'] as $callback) { $objMember = call_user_func(array($callback[0], $callback[1]), $objMember); } } $objMember->save(); } }
/** * Set all user properties from a database record */ protected function setUserFromDb() { $this->intId = $this->id; // Unserialize values foreach ($this->arrData as $k => $v) { if (!is_numeric($v)) { $this->{$k} = \StringUtil::deserialize($v); } } // Set language if ($this->language != '') { \System::getContainer()->get('request_stack')->getCurrentRequest()->setLocale($this->language); \System::getContainer()->get('translator')->setLocale($this->language); // Deprecated since Contao 4.0, to be removed in Contao 5.0 $GLOBALS['TL_LANGUAGE'] = str_replace('_', '-', $this->language); } $GLOBALS['TL_USERNAME'] = $this->username; // Make sure that groups is an array if (!is_array($this->groups)) { $this->groups = $this->groups != '' ? array($this->groups) : array(); } // Skip inactive groups if (($objGroups = \MemberGroupModel::findAllActive()) !== null) { $this->groups = array_intersect($this->groups, $objGroups->fetchEach('id')); } // Get the group login page if ($this->groups[0] > 0) { $objGroup = \MemberGroupModel::findPublishedById($this->groups[0]); if ($objGroup !== null && $objGroup->redirect && $objGroup->jumpTo) { $this->strLoginPage = $objGroup->jumpTo; } } }
/** * Display a login form * * @return string */ public function generate() { if (TL_MODE == 'BE') { /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['login'][0]) . ' ###'; $objTemplate->title = $this->headline; $objTemplate->id = $this->id; $objTemplate->link = $this->name; $objTemplate->href = '' . $GLOBALS['TL_CONFIG']['backendPath'] . '/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; return $objTemplate->parse(); } // Set the last page visited if (!$_POST && $this->redirectBack) { $_SESSION['LAST_PAGE_VISITED'] = $this->getReferer(); } // Login if (\Input::post('FORM_SUBMIT') == 'tl_login') { // Check whether username and password are set if (empty($_POST['username']) || empty($_POST['password'])) { $_SESSION['LOGIN_ERROR'] = $GLOBALS['TL_LANG']['MSC']['emptyField']; $this->reload(); } $this->import('FrontendUser', 'User'); $strRedirect = \Environment::get('request'); // Redirect to the last page visited if ($this->redirectBack && $_SESSION['LAST_PAGE_VISITED'] != '') { $strRedirect = $_SESSION['LAST_PAGE_VISITED']; } else { // Redirect to the jumpTo page if ($this->jumpTo && ($objTarget = $this->objModel->getRelated('jumpTo')) !== null) { $strRedirect = $this->generateFrontendUrl($objTarget->row()); } // Overwrite the jumpTo page with an individual group setting $objMember = \MemberModel::findByUsername(\Input::post('username')); if ($objMember !== null) { $arrGroups = deserialize($objMember->groups); if (!empty($arrGroups) && is_array($arrGroups)) { $objGroupPage = \MemberGroupModel::findFirstActiveWithJumpToByIds($arrGroups); if ($objGroupPage !== null) { $strRedirect = $this->generateFrontendUrl($objGroupPage->row()); } } } } // Auto login is not allowed if (isset($_POST['autologin']) && !$this->autologin) { unset($_POST['autologin']); \Input::setPost('autologin', null); } // Login and redirect if ($this->User->login()) { $this->redirect($strRedirect); } $this->reload(); } // Logout and redirect to the website root if the current page is protected if (\Input::post('FORM_SUBMIT') == 'tl_logout') { /** @var \PageModel $objPage */ global $objPage; $this->import('FrontendUser', 'User'); $strRedirect = \Environment::get('request'); // Redirect to last page visited if ($this->redirectBack && strlen($_SESSION['LAST_PAGE_VISITED'])) { $strRedirect = $_SESSION['LAST_PAGE_VISITED']; } elseif ($objPage->protected) { $strRedirect = \Environment::get('base'); } // Logout and redirect if ($this->User->logout()) { $this->redirect($strRedirect); } $this->reload(); } return parent::generate(); }
<?php /** * Isotope eCommerce for Contao Open Source CMS * * Copyright (C) 2009-2014 terminal42 gmbh & Isotope eCommerce Workgroup * * @package Isotope * @link http://isotopeecommerce.org * @license http://opensource.org/licenses/lgpl-3.0.html */ /** * Table tl_iso_product_price */ $GLOBALS['TL_DCA']['tl_iso_product_price'] = array('config' => array('dataContainer' => 'Table', 'enableVersioning' => true, 'ptable' => 'tl_iso_product', 'ctable' => array('tl_iso_product_pricetier'), 'onload_callback' => array(array('Isotope\\Backend\\ProductPrice\\Callback', 'initializeDCA')), 'sql' => array('keys' => array('id' => 'primary', 'pid' => 'index', 'config_id,member_group,start,stop,pid' => 'index'))), 'list' => array('sorting' => array('mode' => 4, 'fields' => array('id'), 'flag' => 1, 'panelLayout' => 'filter;search,limit', 'headerFields' => array('id', 'name', 'alias', 'sku'), 'disableGrouping' => true, 'child_record_callback' => array('Isotope\\Backend\\ProductPrice\\Callback', 'listRows')), 'global_operations' => array('all' => array('label' => &$GLOBALS['TL_LANG']['MSC']['all'], 'href' => 'act=select', 'class' => 'header_edit_all', 'attributes' => 'onclick="Backend.getScrollOffset();"')), 'operations' => array('edit' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_price']['edit'], 'href' => 'act=edit', 'icon' => 'edit.gif'), 'copy' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_price']['copy'], 'href' => 'act=copy', 'icon' => 'copy.gif'), 'delete' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_price']['delete'], 'href' => 'act=delete', 'icon' => 'delete.gif', 'attributes' => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"'), 'show' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_price']['show'], 'href' => 'act=show', 'icon' => 'show.gif'))), 'palettes' => array('default' => '{price_legend},price_tiers,tax_class;{limit_legend},config_id,member_group,start,stop'), 'fields' => array('id' => array('sql' => "int(10) unsigned NOT NULL auto_increment"), 'pid' => array('foreignKey' => 'tl_iso_product.name', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'belongsTo', 'load' => 'lazy')), 'tstamp' => array('sql' => "int(10) unsigned NOT NULL default '0'"), 'price_tiers' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_price']['price_tiers'], 'exclude' => true, 'inputType' => 'multiColumnWizard', 'eval' => array('doNotSaveEmpty' => true, 'tl_class' => 'clr', 'disableSorting' => true, 'columnFields' => array('min' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_price']['price_tier_columns']['min'], 'inputType' => 'text', 'eval' => array('mandatory' => true, 'rgxp' => 'digit', 'style' => 'width:100px')), 'price' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_price']['price_tier_columns']['price'], 'inputType' => 'text', 'eval' => array('mandatory' => true, 'rgxp' => 'price', 'style' => 'width:100px')))), 'load_callback' => array(array('Isotope\\Backend\\ProductPrice\\Callback', 'loadTiers')), 'save_callback' => array(array('Isotope\\Backend\\ProductPrice\\Callback', 'saveTiers'))), 'tax_class' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_price']['tax_class'], 'exclude' => true, 'inputType' => 'select', 'foreignKey' => \Isotope\Model\TaxClass::getTable() . '.name', 'eval' => array('includeBlankOption' => true, 'tl_class' => 'clr'), 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'config_id' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_price']['config_id'], 'exclude' => true, 'inputType' => 'select', 'foreignKey' => \Isotope\Model\Config::getTable() . '.name', 'eval' => array('includeBlankOption' => true, 'tl_class' => 'w50'), 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'member_group' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_price']['member_group'], 'exclude' => true, 'inputType' => 'select', 'foreignKey' => \MemberGroupModel::getTable() . '.name', 'eval' => array('includeBlankOption' => true, 'tl_class' => 'w50', 'chosen' => true), 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'start' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_price']['start'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('rgxp' => 'date', 'datepicker' => method_exists($this, 'getDatePickerString') ? $this->getDatePickerString() : true, 'tl_class' => 'w50 wizard'), 'sql' => "varchar(10) NOT NULL default ''"), 'stop' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product_price']['stop'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('rgxp' => 'date', 'datepicker' => method_exists($this, 'getDatePickerString') ? $this->getDatePickerString() : true, 'tl_class' => 'w50 wizard'), 'sql' => "varchar(10) NOT NULL default ''")));
/** * Set all user properties from a database record */ protected function setUserFromDb() { $this->intId = $this->id; // Unserialize values foreach ($this->arrData as $k => $v) { if (!is_numeric($v)) { $this->{$k} = deserialize($v); } } // Set language if ($this->language != '') { $GLOBALS['TL_LANGUAGE'] = $this->language; } $GLOBALS['TL_USERNAME'] = $this->username; // Make sure that groups is an array if (!is_array($this->groups)) { $this->groups = $this->groups != '' ? array($this->groups) : array(); } // Skip inactive groups if (($objGroups = \MemberGroupModel::findAllActive()) !== null) { $this->groups = array_intersect($this->groups, $objGroups->fetchEach('id')); } // Get the group login page if ($this->groups[0] > 0) { $objGroup = \MemberGroupModel::findPublishedById($this->groups[0]); if ($objGroup !== null && $objGroup->redirect && $objGroup->jumpTo) { $this->strLoginPage = $objGroup->jumpTo; } } // Restore session if (is_array($this->session)) { $this->Session->setData($this->session); } else { $this->session = array(); } }
/** * Get the member permissions. * * @param \User $contaoUser The contao user. * * @return array */ private function getMemberPermissions($contaoUser) { $groups = \MemberGroupModel::findMultipleByIds($contaoUser->groups); $permissions = array(); if ($groups) { while ($groups->next()) { $permissions = array_merge($permissions, deserialize($groups->workflow, true)); } $permissions = array_unique($permissions); } return $permissions; }
protected function getJumpTo($objMember = null) { $strRedirect = \Environment::get('request'); if ($this->redirectBack && $_SESSION['LAST_PAGE_VISITED'] != '') { $strRedirect = $_SESSION['LAST_PAGE_VISITED']; } else { if ($this->jumpTo && ($objTarget = $this->objModel->getRelated('jumpTo')) !== null) { $strRedirect = $this->generateFrontendUrl($objTarget->row()); // Overwrite the jumpTo page with an individual group setting if ($objMember !== null) { $arrGroups = deserialize($objMember->groups); if (!empty($arrGroups) && is_array($arrGroups)) { $objGroupPage = \MemberGroupModel::findFirstActiveWithJumpToByIds($arrGroups); if ($objGroupPage !== null) { $strRedirect = $this->generateFrontendUrl($objGroupPage->row()); } } } } } return $strRedirect; }