Log in

View Full Version : (Simple enough) Change from php code in plugin to template code


basketmen
06-16-2010, 04:42 PM
This is a conditional code in a plugin,

if(($thread['postuserid'] == $this->registry->userinfo['userid']) OR ($this->registry->userinfo['permissions']['answers_forum_perms'] & $this->registry->bf_ugp_answers_forum_perms['canselect_others_answers'])){
}

i want to put it in template, is this right guys? because i think this is not fully working

<if condition="$thread['postuserid'] == $this->registry->userinfo['userid'] OR $this->registry->userinfo['permissions']['answers_forum_perms'] & $this->registry->bf_ugp_answers_forum_perms['canselect_others_answers']">
</if>

regrads

BirdOPrey5
06-16-2010, 05:26 PM
In the template conditional I would use 'AND' instead of & but either may work... I know 'AND' does and you already use 'OR' - also I would use brackets () to make the logic easier to follow.

Lynne
06-16-2010, 07:35 PM
Definitely need to put your brackets back in for the OR part just like in the original.

noppid
06-16-2010, 07:54 PM
Looks fine. It should work with or without the grouping Lynne suggests. Making them explicit can be faster though.

<if condition="($thread['postuserid'] == $this->registry->userinfo['userid']) OR ($this->registry->userinfo['permissions']['answers_forum_perms'] & $this->registry->bf_ugp_answers_forum_perms['canselect_others_answers'])">
</if>

Do not change the & to AND. It is a bitwise arithmetic operation. AND is a logical operator.

BirdOPrey5
06-16-2010, 08:11 PM
my bad... :confused:

noppid
06-16-2010, 08:15 PM
We all have to learn nuances. I've made worse mistakes.

In the if condition AND would be && using ampersands instead of text.