Ejemplo n.º 1
0
 /**
  * Returns a Collection of User objects 
  * TODO add criteria to selection process 
  * @param array
  * @return Users
  */
 public static function get($organisation = null, $group = null, $role = null, $proxy_id = null)
 {
     global $db;
     $query = "SELECT a.*, b.`group`, b.`role`, b.`id` AS `access_id` from `" . AUTH_DATABASE . "`.`user_data` a LEFT JOIN `" . AUTH_DATABASE . "`.`user_access` b on a.`id`=b.`user_id` and b.`app_id`=?";
     $conditions = generateAccessConditions($organisation, $group, $role, $proxy_id, 'b');
     if ($conditions) {
         $query .= " WHERE " . $conditions;
     }
     $query .= " ORDER BY lastname, firstname";
     //note to self. check use index page for user access components of display
     $results = $db->getAll($query, array(AUTH_APP_ID));
     $users = array();
     if ($results) {
         foreach ($results as $result) {
             $user = new User();
             $user = User::fromArray($result, $user);
             $cohort = groups_get_cohort($result["id"]);
             if ($cohort) {
                 $user->setCohort($cohort["group_id"]);
             }
             $users[] = $user;
         }
     }
     return new self($users);
 }
Ejemplo n.º 2
0
         break;
     case "faculty":
         $poll_where_clause = "(a.`poll_target` = 'all' OR a.`poll_target` = 'faculty')";
         break;
     case "medtech":
         $poll_where_clause = "(a.`poll_target` = 'all' OR a.`poll_target` = 'staff')";
         break;
     case "resident":
         $poll_where_clause = "(a.`poll_target` = 'all' OR a.`poll_target` = 'resident')";
         break;
     case "staff":
         $poll_where_clause = "(a.`poll_target` = 'all' OR a.`poll_target` = 'staff')";
         break;
     case "student":
     default:
         $cohort = groups_get_cohort($ENTRADA_USER->getID());
         $poll_where_clause = "(a.`poll_target_type` = 'cohort' AND a.`poll_target`='" . clean_input($cohort["group_id"], "alphanumeric") . "' OR a.`poll_target` = 'all' OR a.`poll_target` = 'students')";
         break;
 }
 if (!isset($_SESSION[APPLICATION_IDENTIFIER]["tmp"][$MODULE]["poll_id"])) {
     $query = "\tSELECT a.`poll_id`\n\t\t\t\t\tFROM `poll_questions` AS a\n\t\t\t\t\tLEFT JOIN `poll_results` AS b\n\t\t\t\t\tON b.`poll_id` = a.`poll_id`\n\t\t\t\t\tAND b.`proxy_id` = " . $db->qstr($ENTRADA_USER->getID()) . "\n\t\t\t\t\tWHERE b.`result_id` IS NULL\n\t\t\t\t\tAND (`poll_from` = '0' OR `poll_from` <= '" . time() . "')\n\t\t\t\t\tAND (`poll_until` = '0' OR `poll_until` >= '" . time() . "')\n\t\t\t\t\t" . ($poll_where_clause ? "AND " . $poll_where_clause : "") . "\n\t\t\t\t\tORDER BY RAND() LIMIT 1";
     $result = $db->GetRow($query);
     if ($result) {
         $_SESSION[APPLICATION_IDENTIFIER]["tmp"][$MODULE]["poll_id"] = $result["poll_id"];
     } else {
         $query = "\tSELECT a.`poll_id`\n\t\t\t\t\t\tFROM `poll_questions` AS a\n\t\t\t\t\t\tLEFT JOIN `poll_results` AS b\n\t\t\t\t\t\tON b.`poll_id` = a.`poll_id`\n\t\t\t\t\t\tWHERE b.`result_id` IS NOT NULL\n\t\t\t\t\t\tAND (`poll_from` = '0' OR `poll_from` <= '" . time() . "')\n\t\t\t\t\t\tAND (`poll_until` = '0' OR `poll_until` >= '" . time() . "')\n\t\t\t\t\t\tORDER BY RAND() LIMIT 1";
         $result = $db->GetRow($query);
         if ($result) {
             $_SESSION[APPLICATION_IDENTIFIER]["tmp"][$MODULE]["poll_id"] = $result["poll_id"];
         } else {
             $_SESSION[APPLICATION_IDENTIFIER]["tmp"][$MODULE]["poll_id"] = 0;
Ejemplo n.º 3
0
         	}
         } else {
         	$CHANNELS[] = "student";
         }
         */
         $CHANNELS[] = "student";
         break;
     case "staff":
         $CHANNELS[] = "student";
         break;
     case "medtech":
         $CHANNELS[] = "student";
         break;
     case "student":
     default:
         $cohort_array = groups_get_cohort($USER_PROXY_ID);
         $CHANNELS[] = "student:" . $cohort_array["group_id"];
         break;
 }
 $CHANNELS = array_unique($CHANNELS);
 if (is_array($CHANNELS) && count($CHANNELS)) {
     foreach ($CHANNELS as $channel) {
         $pieces = explode(":", $channel);
         switch ($pieces[0]) {
             case "course":
                 if (!isset($pieces[1]) || !($course_id = (int) $pieces[1])) {
                     $course_id = 0;
                 }
                 $query = "\n\t\t\t\t\t\t\t\tSELECT a.*, b.`efile_id`, b.`file_type`, b.`file_size`, b.`file_name`, b.`file_title`, b.`file_notes`, c.`audience_value` AS `event_cohort`\n\t\t\t\t\t\t\t\tFROM `events` AS a\n\t\t\t\t\t\t\t\tLEFT JOIN `event_files` AS b\n\t\t\t\t\t\t\t\tON b.`event_id` = a.`event_id`\n\t\t\t\t\t\t\t\tLEFT JOIN `event_audience` AS c\n\t\t\t\t\t\t\t\tON c.`event_id` = a.`event_id`\n\t\t\t\t\t\t\t\tWHERE " . ($course_id ? "a.`course_id` = " . $db->qstr((int) $course_id) . " AND " : "") . "\n\t\t\t\t\t\t\t\tb.`file_category` = 'podcast'\n\t\t\t\t\t\t\t\tAND b.`file_type` IN ('" . implode("', '", $VALID_PODCASTS) . "')\n\t\t\t\t\t\t\t\tAND (b.`release_date` = '0' OR b.`release_date` <= " . $db->qstr(time()) . ")\n\t\t\t\t\t\t\t\tAND (b.`release_until` = '0' OR b.`release_until` > " . $db->qstr(time()) . ")\n\t\t\t\t\t\t\t\tAND c.`audience_type` = 'cohort'\n\t\t\t\t\t\t\t\tORDER BY a.`event_start` DESC\n\t\t\t\t\t\t\t\tLIMIT 0, 150";
                 $results = $db->GetAll($query);
                 if ($results) {
Ejemplo n.º 4
0
 echo "<h5 class\"media-heading ps-media-heading\">" . html_encode(($result["prefix"] ? $result["prefix"] . " " : "") . $result["firstname"] . " " . $result["lastname"]) . "</h5>";
 echo "<span class=\"content-small\">";
 if ($departmentResults = get_user_departments($result["id"])) {
     $deptCtr = 0;
     foreach ($departmentResults as $key => $departmentValue) {
         if ($deptCtr == 0) {
             $deptCtr++;
             echo ucwords($departmentValue["department_title"]);
         } else {
             $deptCtr++;
             echo "<br />" . ucwords($departmentValue["department_title"]);
         }
     }
 } else {
     if ($result["group"] == "student") {
         $cohort = groups_get_cohort($result["id"]);
     }
     echo ucwords($result["group"]) . " > " . ($result["group"] == "student" && isset($cohort["group_name"]) ? $cohort["group_name"] : ucwords($result["role"]));
 }
 echo (isset($ORGANISATIONS_BY_ID[$result["organisation_id"]]) ? "<br />" . $ORGANISATIONS_BY_ID[$result["organisation_id"]]["organisation_title"] : "") . "\n";
 echo "<br />";
 if ($result["privacy_level"] > 1 || $is_administrator) {
     echo "\t\t\t<a href=\"mailto:" . html_encode($result["email"]) . "\" class=\"ps-email\">" . html_encode($result["email"]) . "</a><br />\n";
     if ($result["email_alt"]) {
         echo "\t\t<a href=\"mailto:" . html_encode($result["email_alt"]) . "\" class=\"ps-email\">" . html_encode($result["email_alt"]) . "</a>\n";
     }
 }
 echo "</span></div>";
 echo "<div class=\"content-small ps-address-margin pull-left\"\">";
 if ($result["privacy_level"] > 2 || $is_administrator) {
     if ($result["telephone"]) {
 echo "<h5 class\"media-heading ps-media-heading\">" . html_encode(($user["prefix"] ? $user["prefix"] . " " : "") . $user["firstname"] . " " . $user["lastname"]) . "</h5>";
 echo "<span class=\"content-small\">";
 if ($departmentResults = get_user_departments($proxy_id)) {
     $deptCtr = 0;
     foreach ($departmentResults as $key => $departmentValue) {
         if ($deptCtr == 0) {
             $deptCtr++;
             echo ucwords($departmentValue["department_title"]);
         } else {
             $deptCtr++;
             echo "<br />" . ucwords($departmentValue["department_title"]);
         }
     }
 } else {
     if ($user["group"] == "student") {
         $cohort = groups_get_cohort($proxy_id);
     }
     echo ucwords($user["group"]) . " > " . ($user["group"] == "student" && isset($cohort["group_name"]) ? $cohort["group_name"] : ucwords($user["role"]));
 }
 echo (isset($ORGANISATIONS_BY_ID[$user["organisation_id"]]) ? "<br />" . $ORGANISATIONS_BY_ID[$user["organisation_id"]]["organisation_title"] : "") . "\n";
 echo "<br />";
 if ($user["privacy_level"] > 1) {
     echo "\t\t\t<a href=\"mailto:" . html_encode($user["email"]) . "\" class=\"ps-email\">" . html_encode($user["email"]) . "</a><br />\n";
     if ($user["email_alt"]) {
         echo "\t\t<a href=\"mailto:" . html_encode($user["email_alt"]) . "\" class=\"ps-email\">" . html_encode($user["email_alt"]) . "</a>\n";
     }
 }
 echo "</span></div>";
 echo "<div class=\"content-small ps-address-margin pull-left\"\">";
 if ($user["privacy_level"] > 2) {
     if ($user["telephone"]) {