我正在构建一个Drupal站点,并添加了两个自定义菜单,以提供两组不同的管理链接(有些人会看到一个菜单或另一个菜单,有些人会看到这两个菜单,而匿名/低级用户都看不到).
问题是,目前所有用户都可以看到菜单(但菜单项不可见).
我正在尝试创建一个简单的权限模块 - 并创建了管理表单,用于指定哪些菜单可由哪个角色查看.
但我找不到一个钩子,让我覆盖特定菜单的可见性 - 只有项目.
那么,现在我在数据库中有一个权限列表,如何通过Drupal中的角色限制对菜单的访问?
-
我查看了每个角色和菜单访问菜单.不幸的是,这些工作在项目级别而不是直接在菜单上工作.
我正在编写一个脚本,它可以提取一些患者数据并生成XML导出.
每个患者记录都有一个相关的医生 - 但不是在每个记录中重复医生的详细信息,我想我会在患者记录中设置医生ID,然后在文档底部的不同部分中包含医生列表.
我需要做的一件事是在患者记录中包含医生的GUID,但实际的数据库关系是本地非唯一ID.我认为最好的方法是使用字典将GUID映射到本地ID列表中.
无论如何,长话短说,这里是构建需求列表的位:
While Not PatientRec.EOF
Set DoctorRec = MyDB.OpenRecordset("Select Lng_Key, Txt_GUID From Tbl_LU_DoctorDetail Where Lng_Key = " & PatientRec![Lng_Doctor])
While Not DoctorRec.EOF
If (IsNull(DoctorRec![Txt_GUID])) Then
DoctorRec.Edit
DoctorRec![Txt_GUID] = CreateGUID()
DoctorRec.Update
End If
DoctorList.Add DoctorRec![Lng_Key], DoctorRec![Txt_GUID]
' outputs something like '5:{03f50fe1-a0a4-4733-906a-771e22845ea6}
MsgBox (DoctorRec![Lng_Key] & ":" & DoctorList.Items(DoctorRec![Lng_Key]))
DoctorRec.MoveNext
Wend
Wend
' outputs nothing!
MsgBox (DoctorList.Item(5))
' but there is something in there???
MsgBox (DoctorList.count)
Run Code Online (Sandbox Code Playgroud)
我也尝试使用CStr将id转换为字符串,但使用DoctorList.Item("5")获得相同的结果
更糟糕的是,当我尝试:
Dim v As Variant
For Each v In DoctorList.Keys
MsgBox (v …Run Code Online (Sandbox Code Playgroud) 首先是快速代码段:
Dim GUID As String
Dim givenNames, familyName, preferredName, gender, comments, carer, medicareNumber, patientNumber As String
Dim dob As Variant
Dim deceased, resolved, consultNotes As Boolean
Dim age As Variant
givenNames = Null
familyName = Null
preferredName = Null
gender = Null
dob = Null
comments = Null
deceased = False
resolved = False
carer = Null
age = Null
consultNotes = False
patientNumber = Null ' This is where I get the error
Run Code Online (Sandbox Code Playgroud)
知道为什么这个最后一个变量会绊倒吗?我已经将Null分配给了许多其他字符串而没有任何错误.
问题示例:http://jsfiddle.net/xZmFg/4/
当然有一种方法可以使描述立即跟随输入(下面,而不是右边),而不是最终在菜单下面......
我意识到使用'float'你会打破内容流,但是没有办法只应用于父容器内的空间?
我试图通过添加一个允许我使用字符串数据而不是文件路径添加附件的方法来扩展来自Worx的PHP邮件程序类.
我提出了这样的事情:
public function addAttachmentString($string, $name='', $encoding = 'base64', $type = 'application/octet-stream')
{
$path = 'php://memory/' . md5(microtime());
$file = fopen($path, 'w');
fwrite($file, $string);
fclose($file);
$this->AddAttachment($path, $name, $encoding, $type);
}
Run Code Online (Sandbox Code Playgroud)
但是,我得到的只是一个PHP警告:
PHP Warning: fopen() [<a href='function.fopen'>function.fopen</a>]: Invalid php:// URL specified
Run Code Online (Sandbox Code Playgroud)
原始文档没有任何体面的例子,但我在互联网上发现了一对(包括一个在SO上),根据它们我的用法看起来是正确的.
有没有人使用过这个?
我的另一种方法是创建一个临时文件并清理 - 但这意味着必须写入光盘,并且此函数将用作大批量进程的一部分,我希望尽可能避免慢速光盘操作(旧服务器).这只是一个短文件,但脚本电子邮件的每个人都有不同的信息.
我有以下javascript:
$('#ge-display').click(function (event) {
window.open('/googleearth/ge-display.php','','scrollbars=yes,menubar=no,height=650,width=1000,resizable=yes,toolbar=yes,location=no,status=no');
event.stopPropagation();
return false;
});
Run Code Online (Sandbox Code Playgroud)
ID为'ge-display'的元素是标准链接:
<a href="/googleearth/ge-display.php" id="ge-display" target="_blank">Load Google Earth Plugin (in a new window)</a>
Run Code Online (Sandbox Code Playgroud)
问题是 - 当我拿出'return false;'时 来自click事件处理程序的行,javascript弹出窗口打开,然后另一个浏览器窗口打开 - 我以为stopPropagation()会阻止链接自己的点击处理程序?
我也尝试过stopImmediatePropagation() - 但我仍然需要返回false来停止链接的默认行为.
我已经开始使用RelaxNG来指定XML消息模式,并使用PHP DOMDocument来验证和解析传入的消息,但是无法弄清楚如何定义文本节点以使其不能为空.示例模式:
<?xml version="1.0"?>
<element name="amhAPI" xmlns="http://relaxng.org/ns/structure/1.0">
<element name="auth">
<element name="validateUser">
<element name="username">
<text/>
</element>
<element name="password">
<text/>
</element>
</element>
</element>
</element>
Run Code Online (Sandbox Code Playgroud)
但是,DOMDocument :: relaxNGValidate方法正在验证下面的消息是正确的(因为relaxng 匹配任意字符串 [包括空字符串 ]与text模式)并且相当于):
<?xml version="1.0"?>
<amhAPI>
<auth>
<validateUser>
<username/>
<password/>
</validateUser>
</auth>
</amhAPI>
Run Code Online (Sandbox Code Playgroud)
因此,我必须为不应该为空的字段添加一堆检查和验证,如果验证器将它们标识为非空元素,则可以删除这些字段.
有没有办法强制非空文本?
为了加强Jenkins CI服务器的安全性(在Ubuntu 14.04上运行1.614),我昨天配置了LDAP插件.昨天一切似乎都很好,我能够登录并手动配置和运行一些构建.
然而,今天早上,没有人 - 包括我自己 - 能够登录.
我们被告知要查看服务器控制台输出 - 但是,没有记录任何内容/var/log/jenkins/jenkins.log.我发现如何在本地文件系统上查看Jenkins服务器控制台输出?- 但是没有这样的日志文件/usr/lib/jenkins/(我的jenkins主目录).
我在https://wiki.jenkins-ci.org/display/JENKINS/LDAP+Plugin尝试了简单的故障排除groovy脚本,但每个查询返回:
Checking the name 'wibble'...
It is NOT a group, reason: No such property: Jenkins for class: RemoteClass
It is NOT a user, reason: No such property: Jenkins for class: RemoteClass
Run Code Online (Sandbox Code Playgroud)
我的安全配置:
<useSecurity>true</useSecurity>
<authorizationStrategy class="hudson.security.AuthorizationStrategy$Unsecured"/>
<securityRealm class="hudson.security.LDAPSecurityRealm" plugin="ldap@1.11">
<server>server.ip.address</server>
<rootDN>dc=domain,dc=location,dc=au</rootDN>
<inhibitInferRootDN>false</inhibitInferRootDN>
<userSearchBase>dc=domain,dc=location,dc=au</userSearchBase>
<userSearch>sAMAccountName={0}</userSearch>
<groupSearchBase>ou=groups</groupSearchBase>
<groupSearchFilter>(& (cn={0}) (objectclass=group) )</groupSearchFilter>
<groupMembershipStrategy class="jenkins.security.plugins.ldap.FromGroupSearchLDAPGroupMembershipStrategy">
<filter>(&(objectCategory=group)(member={0}))</filter>
</groupMembershipStrategy>
<managerDN>cn=administrator,cn=users,dc=domain,dc=location,dc=au</managerDN>
<managerPasswordSecret>wurble-bop-de-boo</managerPasswordSecret>
<disableMailAddressResolver>false</disableMailAddressResolver>
<displayNameAttributeName>displayname</displayNameAttributeName>
<mailAddressAttributeName>mail</mailAddressAttributeName>
<userIdStrategy class="jenkins.model.IdStrategy$CaseInsensitive"/>
<groupIdStrategy …Run Code Online (Sandbox Code Playgroud) 好吧,我已经用html/css工作了近十年了,对于我的生活,我似乎无法弄清楚为什么这不起作用.
最初,我无法在页面加载时获得两个单独的divs以display: none与其他属性一起使用.经过故障排除后,我最终得出的结论是,引导程序文件中存在错误,因此经过一个多小时的缩减后,我将其简化为以下内容以删除所有可能的错误来源:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
#first {
display: none;
}?
#second {
display: none;
}
</style>
</head>
<body>
<div id="first" >abc</div>
<div id="second">123</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我把test.html它保存为并通过firefox打开它只看到:
123
Run Code Online (Sandbox Code Playgroud)
我检查'Inspect element',果然,#first有"display:none"属性,但#second没有.
我继续用chrome和edge检查这个并获得相同的结果.
我发现使用了
#first, #second {
display: none;
}
Run Code Online (Sandbox Code Playgroud)
按预期工作.但是,我仍然需要为#second添加其他属性,因此,我认为自己很聪明:
#first, #second {
display: none; <!--Awesome!-->
}?
#second {
height: 100px; <!--nope-->
width: 100px; <!--nope-->
}
Run Code Online (Sandbox Code Playgroud)
经过多次重复以获得任何不同的结果后,我最终尝试了一些绝对没有理由继续工作的东西,但在这一点上,我停止了关怀.
我继续打开一个新文档,键入整个原始文件<style>...</style>(从上面的第一个代码块)并从未保存的文档中复制它并将其粘贴到有缺陷的文档上.
刷新页面,什么都看不见.检查Inspect Element,果然,一切都在那里,只需"display:none"
所以经过近3个小时的故障排除后,我的问题是:
额外信息:
Windows 10 Home …
我想验证用户是否在地址表单中选择了一个有效的状态值。为了在开发过程中简单起见,我还没有让他们选择国家。
状态信息位于具有以下字段的表中:
id
country_id
abbreviation
name
Run Code Online (Sandbox Code Playgroud)
该表单使用带有名称的 select 元素address[state]并将状态 ID 作为选定值发送。
我第一次尝试验证规则是:
'address.state' => [
'required',
Rule::exists('shop_address_states')->where(function ($query) {
$query->where('country_id', 1);
}),
],
Run Code Online (Sandbox Code Playgroud)
但我得到一个Unknown column 'address.state'错误。
当我尝试让它使用 ID 列时:
'address.state' => [
'required',
Rule::exists('shop_address_states,id')->where(function ($query) {
$query->where('country_id', 1);
}),
],
Run Code Online (Sandbox Code Playgroud)
我收到一个undefined offset: 1错误。
我想我有点'state' => 'exists:states,abbreviation'从https://laravel.com/docs/5.4/validation#rule-exists混搭规则,因为我无法在其他地方找到示例。
我如何让这个规则起作用?