public function getForm($item, $description = '') { if ($item instanceof TaskPermission) { $tp = new TaskPermissionList(); $tp->add($item); } else { $tp = $item; } $gl = new GroupList($tp); $ul = new UserInfoList($tp); $uArray = $ul->getUserInfoList(); $gArray = $gl->getGroupList(); $tps = $tp->getTaskPermissions(); $html = ''; foreach ($tps as $_tp) { $html .= '<input type="hidden" name="tpID[]" value="' . $_tp->getTaskPermissionID() . '" />'; } $html .= '<a href="' . REL_DIR_FILES_TOOLS_REQUIRED . '/user_group_selector" id="ug-selector" dialog-modal="false" dialog-width="90%" dialog-title="' . t('Choose User/Group') . '" dialog-height="70%" class="ccm-button-right dialog-launch"><span><em>' . t('Add Group or User') . '</em></span></a>'; $html .= '<p>' . $description . '</p>'; $html .= '<div class="ccm-spacer"> </div><br/>'; $html .= '<div id="ccm-permissions-entities-wrapper" class="ccm-permissions-entities-wrapper"><div id="ccm-permissions-entity-base" class="ccm-permissions-entity-base">' . $this->getAccessRow($tp) . '</div>'; foreach ($gArray as $g) { $html .= $this->getAccessRow($tp, $g); } foreach ($uArray as $ui) { $html .= $this->getAccessRow($tp, $ui); } $html .= '</div>'; return $html; }
/** * @see \C5TL\Parser\DynamicItem::parseManual() */ public function parseManual(\Gettext\Translations $translations, $concrete5version) { if (class_exists('\\GroupList', true)) { $gl = new \GroupList(null, false, true); foreach ($gl->getGroupList() as $g) { $this->addTranslation($translations, $g->getGroupName(), 'GroupName'); $this->addTranslation($translations, $g->getGroupDescription(), 'GroupDescription'); } } }
function getAllGroups() { if (func_num_args() == 0) { return array('description' => t('List of all groups')); } Loader::model('groups'); $groupslist = new GroupList(null, false, true); $groups = $groupslist->getGroupList(); $groups_names = array(); foreach ($groups as $group) { $groups_names[] = $group->getGroupName(); } $count = count($groups_names) - 1; $last = $groups_names[$count]; unset($groups_names[$count]); $str = join(", ", $groups_names); $str .= ' ' . t('and') . ' ' . $last; return $str; }
public function getForm($item, $description = '') { if ($item instanceof TaskPermission) { $tp = new TaskPermissionList(); $tp->add($item); } else { $tp = $item; } $gl = new GroupList($tp); $ul = new UserInfoList($tp); $uArray = $ul->getUserInfoList(); $gArray = $gl->getGroupList(); $tps = $tp->getTaskPermissions(); $html = ''; foreach($tps as $_tp) { $html .= '<input type="hidden" name="tpID[]" value="' . $_tp->getTaskPermissionID() . '" />'; } $html .= '<div class="ccm-pane-body">'; $html .= '<a class="btn ug-selector ccm-button-right dialog-launch" href="' . REL_DIR_FILES_TOOLS_REQUIRED . '/users/search_dialog?mode=choose_multiple" dialog-modal="false" dialog-width="90%" dialog-title="' . t('Add User') . '" dialog-height="70%">' . t('Add User') . '</a>'; $html .= '<a class="btn ug-selector ccm-button-right dialog-launch" style="margin-right: 5px" href="' . REL_DIR_FILES_TOOLS_REQUIRED . '/select_group" dialog-modal="false" dialog-title="' . t('Add Group') . '">' . t('Add Group') . '</a>'; $html .= '<p>' . $description . '</p>'; $html .= '<div id="ccm-permissions-entities-wrapper" class="ccm-permissions-entities-wrapper"><div id="ccm-permissions-entity-base" class="ccm-permissions-entity-base">' . $this->getAccessRow($tp) . '</div>'; foreach($gArray as $g) { $html .= $this->getAccessRow($tp, $g); } foreach($uArray as $ui) { $html .= $this->getAccessRow($tp, $ui); } $html .= '</div></div>'; return $html; }
protected function set_permissions($saved = false) { //IP Address Blacklist Loader::model('user_banned_ip'); $ip_ban_enable_lock_ip_after = Config::get('IP_BAN_LOCK_IP_ENABLE'); $ip_ban_enable_lock_ip_after = $ip_ban_enable_lock_ip_after == 1 ? 1 : 0; $ip_ban_lock_ip_after_attempts = Config::get('IP_BAN_LOCK_IP_ATTEMPTS'); $ip_ban_lock_ip_after_time = Config::get('IP_BAN_LOCK_IP_TIME'); $ip_ban_lock_ip_how_long_min = Config::get('IP_BAN_LOCK_IP_HOW_LONG_MIN') ? Config::get('IP_BAN_LOCK_IP_HOW_LONG_MIN') : ''; if (!$ip_ban_lock_ip_how_long_min) { $ip_ban_lock_ip_how_long_type = self::IP_BAN_LOCK_IP_HOW_LONG_TYPE_FOREVER; } else { $ip_ban_lock_ip_how_long_type = self::IP_BAN_LOCK_IP_HOW_LONG_TYPE_TIMED; } $user_banned_ip = new UserBannedIP(); //pull all once filter various lists using code $user_banned_ips = $user_banned_ip->Find('1=1'); $user_banned_manual_ips = array(); $user_banned_limited_ips = array(); foreach ($user_banned_ips as $user_banned_ip) { if ($user_banned_ip->isManual == 1) { $user_banned_manual_ips[] = $user_banned_ip->getIPRangeForDisplay(); } else { if ($user_banned_ip->expires - time() > 0 || $user_banned_ip->expires == 0) { $user_banned_limited_ips[] = $user_banned_ip; } } } $user_banned_manual_ips = join($user_banned_manual_ips, "\n"); $this->set('user_banned_manual_ips', $user_banned_manual_ips); $this->set('user_banned_limited_ips', $user_banned_limited_ips); $this->set('ip_ban_enable_lock_ip_after', $ip_ban_enable_lock_ip_after); $this->set('ip_ban_lock_ip_after_attempts', $ip_ban_lock_ip_after_attempts); $this->set('ip_ban_lock_ip_after_time', $ip_ban_lock_ip_after_time); $this->set('ip_ban_change_makeperm', self::IP_BLACKLIST_CHANGE_MAKEPERM); $this->set('ip_ban_change_remove', self::IP_BLACKLIST_CHANGE_REMOVE); $this->set('ip_ban_lock_ip_how_long_type', $ip_ban_lock_ip_how_long_type); $this->set('ip_ban_lock_ip_how_long_type', $ip_ban_lock_ip_how_long_type); $this->set('ip_ban_lock_ip_how_long_type_forever', self::IP_BAN_LOCK_IP_HOW_LONG_TYPE_FOREVER); $this->set('ip_ban_lock_ip_how_long_type_timed', self::IP_BAN_LOCK_IP_HOW_LONG_TYPE_TIMED); $this->set('ip_ban_lock_ip_how_long_min', $ip_ban_lock_ip_how_long_min); //maintanence mode $site_maintenance_mode = Config::get('SITE_MAINTENANCE_MODE'); if ($site_maintenance_mode < 1) { $site_maintenance_mode = 0; } $this->set('site_maintenance_mode', $site_maintenance_mode); $this->set('user_banned_ips', $user_banned_ips); if ($saved) { switch ($saved) { case "maintenance_enabled": $this->set('message', t('Maintenance Mode turned on. Your site is now private.')); break; case "maintenance_disabled": $this->set('message', t('Maintenance Mode turned off. Your site is public.')); break; case "saved_ipblacklist": $this->set('message', t('IP Blacklist Settings Updated')); break; //permissions saved //permissions saved default: $this->set('message', t('Permissions saved.')); } } if (PERMISSIONS_MODEL != 'simple') { return; } $home = Page::getByID(1, "RECENT"); $gl = new GroupList($home, false, true); $gArrayTmp = $gl->getGroupList(); $gArray = array(); foreach ($gArrayTmp as $gi) { if ($gi->getGroupID() == GUEST_GROUP_ID) { $ggu = $gi; if ($ggu->canRead()) { $this->set('guestCanRead', true); } } else { if ($gi->getGroupID() == REGISTERED_GROUP_ID) { $gru = $gi; if ($gru->canRead()) { $this->set('registeredCanRead', true); } } else { $gArray[] = $gi; } } } $this->set('ggu', $ggu); $this->set('gru', $gru); $this->set('gArray', $gArray); $this->set('home', $home); }
// pass our current area to our grouplist, userinfolist objects, knowing that they will // smartly inherit the correct items. $gl = new GroupList($a); $ul = new UserInfoList($a); $permsSet = true; } } if (!$permsSet) { // otherwise we grab the collection permissions for this page $gl = new GroupList($c); $ul = new UserInfoList($c); } } $gArray = $gl->getGroupList(); $ulArray = $ul->getUserInfoList(); ?> <script type="text/javascript"> function ccm_triggerSelectUser(uID, uName) { rowValue = "uID:" + uID; rowText = uName; if ($("#_row_uID_" + uID).length > 0) { return false; } tbl = document.getElementById("ccmPermissionsTableArea"); row1 = tbl.insertRow(-1); // insert at bottom of table. safari, wtf ? row1.id = "_row_uID_" + uID; row2 = tbl.insertRow(-1); // insert at bottom of table. safari, wtf ?
<td colspan="3"> <?php echo $form->select('uTimezone', $dh->getTimezones(), ($uo->getUserTimezone()?$uo->getUserTimezone():date_default_timezone_get()) ); ?> </td> </tr> <?php } ?> <tr> <td colspan="3" class="header"> <a id="groupSelector" href="<?php echo REL_DIR_FILES_TOOLS_REQUIRED?>/user_group_selector.php?mode=groups" dialog-title="<?php echo t('Add Groups')?>" dialog-modal="false" style="float: right"><?php echo t('Add Group')?></a> <?php echo t('Groups')?> </td> </tr> <?php $gArray = $gl->getGroupList(); ?> <tr> <td colspan="3"> <?php foreach ($gArray as $g) { ?> <input type="checkbox" name="gID[]" value="<?php echo $g->getGroupID()?>" style="vertical-align: middle" <?php if (is_array($_POST['gID'])) { if (in_array($g->getGroupID(), $_POST['gID'])) { echo(' checked '); } } else { if ($g->inGroup()) { echo(' checked '); } } ?> /> <?php echo $g->getGroupName()?><br> <?php } ?>
public function view() { if (PERMISSIONS_MODEL != 'simple') { return; } $home = Page::getByID(1, "RECENT"); $gl = new GroupList($home, false, true); $gArrayTmp = $gl->getGroupList(); $gArray = array(); foreach ($gArrayTmp as $gi) { if ($gi->getGroupID() == GUEST_GROUP_ID) { $ggu = $gi; if ($ggu->canRead()) { $this->set('guestCanRead', true); } } else { if ($gi->getGroupID() == REGISTERED_GROUP_ID) { $gru = $gi; if ($gru->canRead()) { $this->set('registeredCanRead', true); } } else { $gArray[] = $gi; } } } $this->set('ggu', $ggu); $this->set('gru', $gru); $this->set('gArray', $gArray); $this->set('home', $home); if ($this->isPost()) { if ($this->token->validate('site_permissions_code')) { $gru = Group::getByID(REGISTERED_GROUP_ID); $ggu = Group::getByID(GUEST_GROUP_ID); $gau = Group::getByID(ADMIN_GROUP_ID); $args = array(); switch ($_POST['view']) { case "ANYONE": $args['collectionRead'][] = 'gID:' . $ggu->getGroupID(); // this API is pretty crappy. TODO: clean this up in a nice object oriented fashion break; case "USERS": $args['collectionRead'][] = 'gID:' . $gru->getGroupID(); // this API is pretty crappy. TODO: clean this up in a nice object oriented fashion break; case "PRIVATE": $args['collectionRead'][] = 'gID:' . $gau->getGroupID(); break; } $args['collectionWrite'] = array(); if (is_array($_POST['gID'])) { foreach ($_POST['gID'] as $gID) { $args['collectionReadVersions'][] = 'gID:' . $gID; $args['collectionWrite'][] = 'gID:' . $gID; $args['collectionAdmin'][] = 'gID:' . $gID; $args['collectionDelete'][] = 'gID:' . $gID; } } $args['cInheritPermissionsFrom'] = 'OVERRIDE'; $args['cOverrideTemplatePermissions'] = 1; $home->updatePermissions($args); $this->redirect('/dashboard/system/permissions/site/', 'saved'); } else { $this->error->add($this->token->getErrorMessage()); } } }