if ($role->sortorder != $firstrole->sortorder) { $row[3] .= get_action_icon($baseurl . '?action=moveup&roleid=' . $role->id . '&sesskey=' . sesskey(), 'up', $strmoveup, $strmoveup); } else { $row[3] .= get_spacer(); } // Move down. if ($role->sortorder != $lastrole->sortorder) { $row[3] .= get_action_icon($baseurl . '?action=movedown&roleid=' . $role->id . '&sesskey=' . sesskey(), 'down', $strmovedown, $strmovedown); } else { $row[3] .= get_spacer(); } // Edit. $row[3] .= get_action_icon($defineurl . '?action=edit&roleid=' . $role->id, 'edit', $stredit, get_string('editxrole', 'core_role', $role->localname)); // Delete. if (isset($undeletableroles[$role->id])) { $row[3] .= get_spacer(); } else { $row[3] .= get_action_icon($baseurl . '?action=delete&roleid=' . $role->id, 'delete', $strdelete, get_string('deletexrole', 'core_role', $role->localname)); } $table->data[] = $row; } echo html_writer::table($table); echo $OUTPUT->container_start('buttons'); echo $OUTPUT->single_button(new moodle_url($defineurl, array('action' => 'add')), get_string('addrole', 'core_role'), 'get'); echo $OUTPUT->container_end(); echo $OUTPUT->footer(); die; function get_action_icon($url, $icon, $alt, $tooltip) { global $OUTPUT; return '<a title="' . $tooltip . '" href="' . $url . '">' . '<img src="' . $OUTPUT->pix_url('t/' . $icon) . '" class="iconsmall" alt="' . $alt . '" /></a> ';
function makeHTML($indent, $parent = 0, $expandAll) { global $modx; global $icons, $iconsPrivate, $_style, $modx_textdir; global $output, $_lang, $opened, $opened2, $closed2, $tree_orderby, $docgrp, $in_docgrp, $mgrRole; //added global vars $pad = ' '; if ($parent == '') { $parent = 0; } // setup spacer $spacer = get_spacer($indent); $tblsc = $modx->getFullTableName('site_content'); $tbldg = $modx->getFullTableName('document_groups'); $tbldgn = $modx->getFullTableName('documentgroup_names'); $access = get_where_mydocs($mgrRole, $in_docgrp); $field = 'DISTINCT sc.id,pagetitle,menutitle,parent,isfolder,published,deleted,type,menuindex,hidemenu,alias,contentType'; $field .= ",privateweb, privatemgr,MAX(IF(1={$mgrRole} OR sc.privatemgr=0 {$in_docgrp}, 1, 0)) AS has_access"; $from = '[+prefix+]site_content AS sc LEFT JOIN [+prefix+]document_groups dg on dg.document = sc.id'; $where = "(parent='{$parent}') {$access} GROUP BY sc.id"; $result = $modx->db->select($field, $from, $where, $tree_orderby); $has_child = $modx->db->getRecordCount($result); $has_child0 = $has_child; if (!isset($modx->config['limit_by_container'])) { $modx->config['limit_by_container'] = ''; } if ($modx->config['tree_page_click'] !== '27') { if ($modx->config['limit_by_container'] === '') { $container_status = 'asis'; } elseif ($modx->config['limit_by_container'] === '0') { $container_status = 'container_only'; } elseif ($modx->config['limit_by_container'] < $has_child) { $container_status = 'too_many'; } else { $container_status = 'asis'; } if ($container_status !== 'asis' && $parent !== '0') { $where = "(parent={$parent}) AND isfolder=1 {$access} GROUP BY sc.id"; $result = $modx->db->select($field, $from, $where, $tree_orderby); $has_child = $modx->db->getRecordCount($result); } } if ($has_child == 0 && $container_status !== 'container_only' && $container_status !== 'asis') { if ($container_status === 'too_many') { $msg = $_lang['too_many_resources']; } else { $msg = $_lang['empty_folder']; } if ($msg) { $output .= '<div style="white-space: nowrap;">' . $spacer . $pad . '<img align="absmiddle" src="' . $_style["tree_deletedpage"] . '"> <span class="emptyNode">' . $msg . '</span></div>'; } } elseif ($has_child == 0 && $container_status !== 'container_only') { $msg = $_lang['empty_folder']; if ($msg) { $output .= '<div style="white-space: nowrap;">' . $spacer . $pad . '<img align="absmiddle" src="' . $_style["tree_deletedpage"] . '"> <span class="emptyNode">' . $msg . '</span></div>'; } } $loop_count = 0; while ($row = $modx->db->getRow($result, 'num')) { $loop_count++; list($id, $pagetitle, $menutitle, $parent, $isfolder, $published, $deleted, $type, $menuindex, $hidemenu, $alias, $contenttype, $privateweb, $privatemgr, $hasAccess) = $row; if ($container_status === 'container_only' && $isfolder == 1) { $where = "(parent={$id}) AND isfolder=1 {$access} GROUP BY sc.id"; $result2 = $modx->db->select($field, $from, $where, $tree_orderby); $has_child = $modx->db->getRecordCount($result2); } $resource_tree_node_name = $modx->config['resource_tree_node_name']; switch ($resource_tree_node_name) { case 'menutitle': $nodetitle = $menutitle ? $menutitle : $pagetitle; break; case 'alias': $nodetitle = $alias ? $alias : $id; if (strpos($alias, '.') === false || $modx->config['suffix_mode'] != 1) { $nodetitle .= $modx->config['friendly_url_suffix']; } $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle; break; case 'pagetitle': $nodetitle = $pagetitle; break; case 'createdon': case 'editedon': case 'publishedon': case 'pub_date': case 'unpub_date': $doc = $modx->getDocumentObject('id', $id); $date = $doc[$resource_tree_node_name]; if (!empty($date)) { $nodetitle = $modx->toDateFormat($date); } else { $nodetitle = '- - -'; } break; default: $nodetitle = $pagetitle; } $nodetitle = htmlspecialchars(str_replace(array("\r\n", "\n", "\r"), '', $nodetitle)); $protectedClass = $hasAccess == 0 ? ' protectedNode' : ''; if ($deleted == 1) { $class = 'deletedNode'; } elseif ($published == 0) { $class = 'unpublishedNode'; } elseif ($hidemenu == 1) { $class = "notInMenuNode{$protectedClass}"; } else { $class = "publishedNode{$protectedClass}"; } $nodetitleDisplay = '<span class="' . $class . '">' . "{$nodetitle}</span>"; $weblinkDisplay = $type == "reference" ? ' <img src="' . $_style["tree_linkgo"] . '">' : ''; $pageIdDisplay = '<small>(' . ($modx_textdir ? '‏' : '') . $id . ')</small>'; $url = $modx->makeUrl($id, '', '', 'full'); $alt = "[{$id}] "; $alt .= !empty($alias) ? $_lang['alias'] . ": " . $alias : $_lang['alias'] . ": -"; $alt .= "\n{$_lang['resource_opt_menu_index']}: {$menuindex}"; $alt .= "\n{$_lang['resource_opt_show_menu']}: " . ($hidemenu == 1 ? $_lang['no'] : $_lang['yes']); $alt .= "\n{$_lang['page_data_web_access']}: " . ($privateweb ? $_lang['private'] : $_lang['public']); $alt .= "\n{$_lang['page_data_mgr_access']}: " . ($privatemgr ? $_lang['private'] : $_lang['public']); $ph['id'] = $id; $alt = addslashes($alt); $alt = htmlspecialchars($alt, ENT_QUOTES, $modx->config['modx_charset']); $ph['alt'] = $alt; $ph['parent'] = $parent; $ph['spacer'] = $spacer; $pagetitle = addslashes($pagetitle); $pagetitle = htmlspecialchars($pagetitle, ENT_QUOTES, $modx->config['modx_charset']); $nodetitle = addslashes($nodetitle); $nodetitle = htmlspecialchars($nodetitle, ENT_QUOTES, $modx->config['modx_charset']); $ph['pagetitle'] = "'{$pagetitle}'"; $ph['nodetitle'] = "'{$nodetitle}'"; $ph['url'] = "'{$url}'"; $ph['published'] = $published; $ph['deleted'] = $deleted; $ph['nodetitleDisplay'] = $nodetitleDisplay; $ph['weblinkDisplay'] = $weblinkDisplay; $ph['pageIdDisplay'] = $pageIdDisplay; $ph['_lang_click_to_context'] = $_lang['click_to_context']; if (!$isfolder) { $icon = $privateweb || $privatemgr ? $_style["tree_page_secure"] : $_style["tree_page"]; if ($privateweb || $privatemgr) { if (isset($iconsPrivate[$contenttype])) { $icon = $iconsPrivate[$contenttype]; } } else { if (isset($icons[$contenttype])) { $icon = $icons[$contenttype]; } } if ($id == $modx->config['site_start']) { $icon = $_style["tree_page_home"]; } elseif ($id == $modx->config['error_page']) { $icon = $_style["tree_page_404"]; } elseif ($id == $modx->config['site_unavailable_page']) { $icon = $_style["tree_page_hourglass"]; } elseif ($id == $modx->config['unauthorized_page']) { $icon = $_style["tree_page_info"]; } $ph['pid'] = "'p{$id}'"; $ph['pad'] = $pad; $ph['icon'] = $icon; switch ($modx->config['tree_page_click']) { case '27': $ph['ca'] = 'open'; break; case '3': $ph['ca'] = 'docinfo'; break; default: $ph['ca'] = 'open'; } $tpl = get_src_page_node(); $output .= parse_ph($ph, $tpl); } else { $ph['fid'] = "'f{$id}'"; $ph['indent'] = $indent + 1; switch ($modx->config['tree_page_click']) { case '27': $ph['ca'] = 'open'; break; case '3': $ph['ca'] = 'docinfo'; break; default: $ph['ca'] = 'docinfo'; } if ($id == $modx->config['site_start']) { $icon = $_style["tree_page_home"]; } elseif ($id == $modx->config['error_page']) { $icon = $_style["tree_page_404"]; } elseif ($id == $modx->config['site_unavailable_page']) { $icon = $_style["tree_page_hourglass"]; } elseif ($id == $modx->config['unauthorized_page']) { $icon = $_style["tree_page_info"]; } // expandAll: two type for partial expansion if ($expandAll == 1 || $expandAll == 2 && in_array($id, $opened)) { if ($expandAll == 1) { array_push($opened2, $id); } $ph['_style_tree_minusnode'] = $container_status === 'container_only' && $has_child == 0 ? $_style["tree_blanknode"] : $_style["tree_minusnode"]; $ph['icon'] = $privateweb == 1 || $privatemgr == 1 ? $_style["tree_folderopen_secure"] : $_style["tree_folderopen"]; $ph['private_status'] = $privateweb == 1 || $privatemgr == 1 ? '1' : '0'; $tpl = get_src_fopen_node(); $output .= parse_ph($ph, $tpl); makeHTML($indent + 1, $id, $expandAll); $output .= '</div></div>'; } else { if ($container_status === 'container_only' && $has_child == 0) { $ph['_style_tree_plusnode'] = $_style["tree_blanknode"]; } else { $ph['_style_tree_plusnode'] = $_style["tree_plusnode"]; } $ph['icon'] = $privateweb == 1 || $privatemgr == 1 ? $_style["tree_folder_secure"] : $_style["tree_folder"]; $ph['private_status'] = $privateweb == 1 || $privatemgr == 1 ? '1' : '0'; $tpl = get_src_fclose_node(); $output .= parse_ph($ph, $tpl); if ($parent != 0 && $container_status === 'too_many' && $loop_count == $has_child) { $output .= '<div style="white-space: nowrap;">' . $spacer . $pad . '<img align="absmiddle" src="' . $_style["tree_deletedpage"] . '"> <span class="emptyNode">' . $_lang['too_many_resources'] . '</span></div>'; } array_push($closed2, $id); } } // store vars in Javascript if ($expandAll == 1) { echo '<script type="text/javascript"> '; foreach ($opened2 as $item) { printf("parent.openedArray[%d] = 1; ", $item); } echo '</script> '; } elseif ($expandAll == 0) { echo '<script type="text/javascript"> '; foreach ($closed2 as $item) { printf("parent.openedArray[%d] = 0; ", $item); } echo '</script> '; } } }