function student_files_content_alter

7.x student_files.module student_files_content_alter(&$render, $content_id)
6.x student_files.module student_files_content_alter(&$render, $content_id)

Implememnt hook_content_alter

File

modules/student_files/student_files.module, line 773
This is the student_files module, which will facilitate uploading (securely) files to be associated with student accounts.

Code

function student_files_content_alter(&$render, $content_id) {

  // We want to place our files area under the Comment History on the history tab.

  if ($content_id == "advise_history_right_column") {

    // Add our css.
    fp_add_css(fp_get_module_path("student_files") . "/css/student_files.css");

    $html = "";

    $student_id = $render ["#student_id"];
    $files_array = student_files_get_files_for_student($student_id);

    $html .= "<div class='student-files-file-list'>
                <table border='0' width='100%' class='' cellpadding='0' cellspacing='0'>";

    $is_empty = TRUE;
    foreach ($files_array as $cur) {

      $fid = $cur ["fid"]; // file id
      $posted = format_date(convert_time($cur ["posted"]), "", "n/d/Y");
      $fac_name = fp_get_faculty_name($cur ["uploaded_by_cwid"]);

      // Is this user allowed to see this file at all?  (ie, this is a student and the file is for faculty only)
      if (!student_files_user_may_download_student_file($student_id, $fid)) {
        continue;
      }

      $extra_classes = "";
      if (strstr($cur ["filetype"], "image")) {
        $extra_classes .= " student-files-file-image ";
      }
      if (strstr($cur ["filetype"], "pdf")) {
        $extra_classes .= " student-files-file-pdf ";
      }
      if (strstr($cur ["filetype"], "compressed")) {
        $extra_classes .= " student-files-file-compressed ";
      }
      if (strstr($cur ["original_filename"], ".pdf")) {
        $extra_classes .= " student-files-file-pdf ";
      }
      if (strstr($cur ["original_filename"], ".doc")) {
        $extra_classes .= " student-files-file-word ";
      }
      if (strstr($cur ["original_filename"], ".ppt")) {
        $extra_classes .= " student-files-file-ppt ";
      }
      if (strstr($cur ["original_filename"], ".xls")) {
        $extra_classes .= " student-files-file-xls ";
      }
      if (strstr($cur ["original_filename"], ".zip")) {
        $extra_classes .= " student-files-file-compressed ";
      }


      $row_class = "";
      $row_class .= "student-files-access-type-" . $cur ["access_type"];

      $del_link = "";
      if (student_files_user_may_delete_student_file($student_id, $fid)) {
        $del_link = "<span class='student-files-delete'>" . fp_get_js_confirm_link("Are you sure you wish to delete this file? This action cannot be undone.", 
        "window.location=\"" . fp_url("student-files/handle-delete/$student_id/$fid") . "\"", "<i class='fa fa-remove'></i>", "action-link-remove", t("Delete?")) . "</span>";
      }

      $html .= "<tr class='$row_class'>
                  <td valign='top' width='50%' class='student-files-filenames'>
                    <div class='student-files-file $extra_classes'>
                      " . l($cur ["original_filename"], "student-files/handle-download/$student_id/$fid") . "</div>
                  </td>
                  <td valign='top' class='student-files-details-td'>
                    <div class='student-files-posted'>$posted</div>
                    <div class='student-files-fac-name'>$fac_name</div>
                  </td>
                  <td valign='top' class='student-files-delete-td'>
                    $del_link
                  </td>
                </tr>";


      $is_empty = FALSE;
    }

    if ($is_empty) {
      $html .= "No files have been uploaded for this student yet.";
    }

    $html .= "</table>
              </div>";

    // Create a region for uploading a new file.
    // Only if they have permission!
    $upload_form = "";
    if (user_has_permission("upload_student_files")) {

      $form = fp_render_form("student_files_little_upload_form", "normal", $student_id);

      $upload_form = fp_render_c_fieldset($form, t("Click to upload a new file"), TRUE, ' upload-file-fs');

      /*
      
      $upload_form = "<form class='tenpt' style='border: 1px solid #ccc; padding: 3px; margin: 5px;'
                          action='" . fp_url("student-files/handle-upload/$student_id", "current_student_id=$student_id") . "' 
                          method='POST' enctype='multipart/form-data'>
                      <b>" . t("Upload a new file:") . "</b>
                      <input type='file' name='student_file_upload_file' id='student_file_upload_file'>
                      <br><b>" . t("Visible to:") . "</b>
                      
                        &nbsp;<label><input type='radio' value='public' name='access_type'>Anyone (incl. students)</label>
                        <label><input type='radio' value='faculty' name='access_type' checked=checked>Faculty/Staff</label>
                      <div style='text-align: right; padding-top: 10px;'>
                        <input type='submit' value='Upload' onClick='showUpdate(false);'>
                      </div>
                     </form>";   
  
       * 
       */

    }


    $render ["student_files"] = array(
      "value" => "<div class='student-files-section-block'>
                  " . fp_render_section_title(t("Student Files")) . "              
                    $upload_form
                    $html
                  </div>",
    );

    // Since we rendered a form, make sure we aren't showing the title on screen afterwards.
    fp_show_title(FALSE);

  }


}