示例#1
0
 public static function get_permitted_tfs($requested_tfs = array())
 {
     $current_user =& singleton("current_user");
     // If admin, just use the requested tfs
     if ($current_user->have_role('admin')) {
         $rtn = $requested_tfs;
         // If not admin, then remove the items from $requested_tfs that the user can't access
     } else {
         $allowed_tfs = (array) tf::get_tfs_for_person($current_user->get_id());
         foreach ((array) $requested_tfs as $tf) {
             if (in_array($tf, $allowed_tfs)) {
                 $rtn[] = $tf;
             }
         }
     }
     // db_esc everything
     foreach ((array) $rtn as $tf) {
         $r[] = db_esc($tf);
     }
     return (array) array_unique((array) $r);
 }