Ejemplo n.º 1
0
 /**
  * Return true if the specified user's primary group matches the group specified by group_id.
  * @param int $user_id the user_id to check.
  * @param int $group_id the group_id to compare to the specified user's primary group.
  */
 static function isUserPrimaryGroup($user_id, $group_id)
 {
     $primary_group = fetchUserPrimaryGroup($user_id);
     return $primary_group['id'] == $group_id;
 }
Ejemplo n.º 2
0
function fetchUserMenu($user_id, $hooks)
{
    // Get the user's primary group
    if (!($primary_group = fetchUserPrimaryGroup($user_id))) {
        return null;
    }
    $group_id = $primary_group['id'];
    $path = MENU_TEMPLATES . "menu-" . $group_id . ".html";
    $contents = file_get_contents($path);
    //Check to see we can access the file / it has some contents
    if (!$contents || empty($contents)) {
        addAlert("danger", "The menu for this group could not be found.");
        return null;
    } else {
        $find = array_keys($hooks);
        $replace = array_values($hooks);
        //Replace hooks
        $contents = str_replace($find, $replace, $contents);
        return $contents;
    }
}