<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hello All,<div class="">For another installation we had this problem. This Time a CEO shared a custom view with someone with role Commercial, which just beneath CEO in this Case. The Commercial user can’t view the List as isPermittedCustomView() return false and the problem is:</div><div class=""><br class=""></div><div class=""><pre style="background-color: rgb(255, 255, 255); color: rgb(74, 92, 110); font-family: Menlo;" class=""><span style="color: rgb(155, 112, 177);" class="">$sql </span>= <span style="color: rgb(166, 202, 145);" class="">"select <a href="http://vtiger_users.id" class="">vtiger_users.id</a> from vtiger_customview inner join vtiger_users where vtiger_customview.cvid = ? and vtiger_customview.userid in (select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on <a href="http://vtiger_users.id" class="">vtiger_users.id</a>=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '%" </span>. <span style="color: rgb(155, 112, 177);" class="">$current_user_parent_role_seq </span>. <span style="color: rgb(166, 202, 145);" class="">"::%')"</span><span style="color: rgb(242, 137, 49);" class="">;<br class=""></span></pre><div class="">More specifically this part</div></div><div class=""><pre style="background-color: rgb(255, 255, 255); color: rgb(74, 92, 110); font-family: Menlo;" class=""><span style="color: rgb(166, 202, 145);" class="">and vtiger_customview.userid in (select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on <a href="http://vtiger_users.id" class="">vtiger_users.id</a>=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '%" </span>. <span style="color: rgb(155, 112, 177);" class="">$current_user_parent_role_seq </span>. <span style="color: rgb(166, 202, 145);" class="">"::%')</span></pre><div class="">Commercial user has this <span style="font-family: Menlo; background-color: rgb(255, 255, 255); color: rgb(155, 112, 177);" class="">$current_user_parent_role_seq</span><span style="color: rgb(74, 92, 110); font-family: Menlo; background-color: rgb(255, 255, 255);" class="">=</span><span style="font-family: Menlo; background-color: rgb(255, 255, 255); color: rgb(166, 202, 145);" class="">'H1::H2::H10'</span><span style="font-family: Menlo; background-color: rgb(255, 255, 255); color: rgb(242, 137, 49);" class="">;</span></div><div class=""><br class=""></div><div class="">I’m wondering why on earth you let the user choose with whom to share the list but not let the user whom the list is shared with see it, unless they happen to have the save role? Ex:</div></div><div class="">Commercial role can’t see the Custom views CEO created and shared with them because the $current_user_parent_role_seq pf commercia type user includes their role too, and CEO’s $current_user_parent_role_seq is H1::H2, never going to happen that Commercial user see anything shared to him by CEO. Oh this works in reverse too: a list created by Commercial and shared with CEO can’t be possibly seen by CEO.</div><div class="">Now the question is why do you even have the table tiger_cv2users/role/groups if you aren’t going to check there, where is literally written who have access to the custom view. I don’t understand… </div><div class=""><br class=""></div><div class=""><br class=""><div class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div>Best Regards,<br class="">Sukhdev Mohan<br class="">———————————</div><div>Cel. (+39) 320 7020345<br class=""><a href="mailto:s.mohan@myti.it" class="">Email s.mohan@myti.it</a></div><div class=""><br class=""></div></div><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>
<div><br class=""><blockquote type="cite" class=""><div class="">Il giorno 14 apr 2020, alle ore 23:14, Sukhdev Mohan <<a href="mailto:s.mohan@myti.it" class="">s.mohan@myti.it</a>> ha scritto:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""> Hello all,<div class=""><br class=""></div><div class="">I’m having some trouble with sharing lists. The workflow the client is following:</div><div class="">Admin creates lista -> shares it with users</div><div class=""><br class=""></div><div class="">The User can’t access this list and is redirected to the general list all.</div><div class=""><br class=""></div><div class="">User with whom the list is shared have role CEO (we had to make all CEO in order for them to assign tasks to any user of any role - very particular use case, I’d argue they should review their process), using Vtiger 7.1</div><div class=""><br class=""></div><div class="">Debugging I found this code in modules/CutomView/CustomView.php line 2007 and following in function isPermittedCustomView(), (any one can tell me why so much code is commented out?)</div><div class=""><br class=""></div><div class=""><pre style="background-color: rgb(255, 255, 255); color: rgb(74, 92, 110); font-family: Menlo;" class=""><span style="color: rgb(242, 137, 49);" class="">elseif </span>(<span style="color: rgb(155, 112, 177);" class="">$status </span>== <span style="color: rgb(155, 112, 177); font-style: italic;" class="">CV_STATUS_PRIVATE </span>|| <span style="color: rgb(155, 112, 177);" class="">$status </span>== <span style="color: rgb(155, 112, 177); font-style: italic;" class="">CV_STATUS_PENDING</span>) {<br class="">   <span style="color: rgb(155, 112, 177);" class="">$log</span>-><span style="color: rgb(167, 95, 0);" class="">debug</span>(<span style="color: rgb(166, 202, 145);" class="">"Entering when status=1 or 2"</span>)<span style="color: rgb(242, 137, 49);" class="">;<br class=""></span><span style="color: rgb(242, 137, 49);" class="">   if </span>(<span style="color: rgb(155, 112, 177);" class="">$userid </span>== <span style="color: rgb(155, 112, 177);" class="">$current_user</span>-><span style="color: rgb(155, 112, 177);" class="">id</span>)<br class="">      <span style="color: rgb(155, 112, 177);" class="">$permission </span>= <span style="color: rgb(166, 202, 145);" class="">"yes"</span><span style="color: rgb(242, 137, 49);" class="">;<br class=""></span><span style="color: rgb(242, 137, 49);" class="">   else </span>{<br class="">      <span style="color: rgb(159, 159, 159);" class="">/* if($action == 'ListView' || $action == $module."Ajax" || $action == 'index')<br class=""></span><span style="color: rgb(159, 159, 159);" class="">        { */<br class=""></span><span style="color: rgb(159, 159, 159);" class="">      </span><span style="color: rgb(155, 112, 177);" class="">$log</span>-><span style="color: rgb(167, 95, 0);" class="">debug</span>(<span style="color: rgb(166, 202, 145);" class="">"Entering when status=1 or status=2 & action = ListView or </span><span style="color: rgb(155, 112, 177);" class="">$module</span><span style="color: rgb(166, 202, 145);" class="">.Ajax or index"</span>)<span style="color: rgb(242, 137, 49);" class="">;<br class=""></span><span style="color: rgb(242, 137, 49);" class="">      </span><span style="color: rgb(155, 112, 177);" class="">$sql </span>= <span style="color: rgb(166, 202, 145);" class="">"select <a href="http://vtiger_users.id/" class="">vtiger_users.id</a> from vtiger_customview inner join vtiger_users where vtiger_customview.cvid = ? and vtiger_customview.userid in (select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on <a href="http://vtiger_users.id/" class="">vtiger_users.id</a>=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '%" </span>. <span style="color: rgb(155, 112, 177);" class="">$current_user_parent_role_seq </span>. <span style="color: rgb(166, 202, 145);" class="">"::%')"</span><span style="color: rgb(242, 137, 49);" class="">;<br class=""></span><span style="color: rgb(242, 137, 49);" class="">      </span><span style="color: rgb(155, 112, 177);" class="">$result </span>= <span style="color: rgb(155, 112, 177);" class="">$adb</span>-><span style="color: rgb(167, 95, 0);" class="">pquery</span>(<span style="color: rgb(155, 112, 177);" class="">$sql</span><span style="color: rgb(242, 137, 49);" class="">, array</span>(<span style="color: rgb(155, 112, 177);" class="">$record_id</span>))<span style="color: rgb(242, 137, 49);" class="">;<br class=""></span><span style="color: rgb(242, 137, 49);" class="">      while </span>(<span style="color: rgb(155, 112, 177);" class="">$row </span>= <span style="color: rgb(155, 112, 177);" class="">$adb</span>-><span style="color: rgb(167, 95, 0);" class="">fetchByAssoc</span>(<span style="color: rgb(155, 112, 177);" class="">$result</span>)) {<br class="">         <span style="color: rgb(155, 112, 177);" class="">$temp_result</span>[] = <span style="color: rgb(155, 112, 177);" class="">$row</span>[<span style="color: rgb(166, 202, 145);" class="">'id'</span>]<span style="color: rgb(242, 137, 49);" class="">;<br class=""></span><span style="color: rgb(242, 137, 49);" class="">      </span>}<br class="">      <span style="color: rgb(155, 112, 177);" class="">$user_array </span>= <span style="color: rgb(155, 112, 177);" class="">$temp_result</span><span style="color: rgb(242, 137, 49);" class="">;<br class=""></span><span style="color: rgb(242, 137, 49);" class="">      if </span>(sizeof(<span style="color: rgb(155, 112, 177);" class="">$user_array</span>) > <span style="color: rgb(93, 151, 196);" class="">0</span>) {<br class="">         <span style="color: rgb(242, 137, 49);" class="">if </span>(!in_array(<span style="color: rgb(155, 112, 177);" class="">$current_user</span>-><span style="color: rgb(155, 112, 177);" class="">id</span><span style="color: rgb(242, 137, 49);" class="">, </span><span style="color: rgb(155, 112, 177);" class="">$user_array</span>))<br class="">            <span style="color: rgb(155, 112, 177);" class="">$permission </span>= <span style="color: rgb(166, 202, 145);" class="">"no"</span><span style="color: rgb(242, 137, 49);" class="">;<br class=""></span><span style="color: rgb(242, 137, 49);" class="">         else<br class=""></span><span style="color: rgb(242, 137, 49);" class="">            </span><span style="color: rgb(155, 112, 177);" class="">$permission </span>= <span style="color: rgb(166, 202, 145);" class="">"yes"</span><span style="color: rgb(242, 137, 49);" class="">;<br class=""></span><span style="color: rgb(242, 137, 49);" class="">      </span>}<br class="">      <span style="color: rgb(242, 137, 49);" class="">else<br class=""></span><span style="color: rgb(242, 137, 49);" class="">         </span><span style="color: rgb(155, 112, 177);" class="">$permission </span>= <span style="color: rgb(166, 202, 145);" class="">"no"</span><span style="color: rgb(242, 137, 49);" class="">;</span></pre><div class=""><br class=""></div></div><div class="">The problem seems the query in this part:</div><div class=""><pre style="background-color: rgb(255, 255, 255); color: rgb(74, 92, 110); font-family: Menlo;" class=""><span style="color: rgb(166, 202, 145);" class="">where vtiger_role.parentrole like '%" </span>. <span style="color: rgb(155, 112, 177);" class="">$current_user_parent_role_seq </span>. <span style="color: rgb(166, 202, 145);" class="">"::%')</span></pre><div class="">So when it compiles for my user it becomes this:</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class="">SELECT</div><div class="">    <a href="http://vtiger_users.id/" class="">vtiger_users.id</a></div><div class="">FROM</div><div class="">    vtiger_customview</div><div class="">INNER JOIN vtiger_users WHERE vtiger_customview.cvid = '207' AND vtiger_customview.userid IN(</div><div class="">    SELECT</div><div class="">        vtiger_user2role.userid</div><div class="">    FROM</div><div class="">        vtiger_user2role</div><div class="">    INNER JOIN vtiger_users ON <a href="http://vtiger_users.id/" class="">vtiger_users.id</a> = vtiger_user2role.userid</div><div class="">    INNER JOIN vtiger_role ON vtiger_role.roleid = vtiger_user2role.roleid</div><div class="">    WHERE</div><div class="">        vtiger_role.parentrole LIKE '%H1::H2::%'</div><div class="">)</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">The last ::% makes the query return empty set. I think before appending “::%”  you should consider if it’s a specific role or a set of roles and sub. I’ve tried sharing with just role CEO still nothing changes… Also in past I’ve had problem updating list which used custom fields in column list or condition, error was just a json with generic error message.</div><div class=""><br class=""></div><div class="">Any ideas how I can solve without disabling the whole check?</div><div class=""><br class=""></div><div class="">P.S. </div><div class=""><div class=""><div class="">Wouldn’t be more efficient doing check in query directly $current_user->id and $current_user->role instead of doing on PHP side? </div><div class=""><br class="webkit-block-placeholder"></div><div class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">Best Regards,<br class="">Sukhdev Mohan<br class="">———————————</div><div class="">Cel. (+39) 320 7020345<br class=""><a href="mailto:s.mohan@myti.it" class="">Email s.mohan@myti.it</a></div><div class=""><br class=""></div></div><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>

<br class=""></div></div></div></div></blockquote></div><br class=""></div></body></html>