Beispiel #1
0
 function add_sow_materials()
 {
     if ($this->input->post()) {
         $id = $this->input->post('task_id');
         $file_path = $this->input->post('file_paths');
         $file_hash = $this->input->post('file_hash');
         $where = array('id' => $id);
         $result = $this->task_model->select('file_paths, file_hash')->getOneWhere($where, IMS_DB_PREFIX . 'task');
         $oldfilearray = $result ? $result->file_paths == '' ? array() : unserialize($result->file_paths) : array();
         $tmpOldArray = array();
         if (!empty($oldfilearray)) {
             foreach ($oldfilearray as $key => $value) {
                 $tmpOldArray[] = $value;
             }
             $oldfilearray = $tmpOldArray;
         }
         $old_file_hash_array = $result ? $result->file_paths == '' ? array() : unserialize($result->file_paths) : array();
         $old_file_hash_array = '';
         if (!empty($oldfilearray) && empty($result->file_hash)) {
             for ($i = 0; $i < count($oldfilearray); $i++) {
                 $old_file_hash_array[$i] = '';
             }
         } else {
             if (!empty($result) && !empty($result->file_hash)) {
                 $old_file_hash_array = unserialize($result->file_hash);
             }
         }
         $oldfilearray[] = $file_path;
         end($oldfilearray);
         $inserted_key = key($oldfilearray);
         $old_file_hash_array[] = $file_hash;
         $file_hashtosubmit = serialize($old_file_hash_array);
         $file_pathtosubmit = serialize($oldfilearray);
         $this->task_model->updateRow($id, array('file_hash' => $file_hashtosubmit, 'file_paths' => $file_pathtosubmit), 'id', IMS_DB_PREFIX . 'task');
         echo json_encode(array('file_hash' => $file_hash, 'status' => 'true', 'insertion_key' => $inserted_key, 'encoded_file_name' => rawurlencode($file_path), 'file_name' => show_file_name($file_path, 40)));
         exit;
     }
 }
            <div class="assesment-wrap">
                <h3>Teaching Materials </h3>
                <div id="teaching_reference_materials" class="teaching_reference_materials">
<?php 
if (!empty($task->file_paths)) {
    foreach ($task->file_paths as $k => $file_path) {
        $path = isset($task->file_hash[$k]) && !empty($task->file_hash[$k]) ? $task->file_hash[$k] : $file_path;
        ?>
                            <div class="da-panel-widget individual_file" style="background:#F2F0F0; height:auto;">
                                <span class="add_files">
                                     <a href="<?php 
        echo site_url('sow/download_file/' . $path);
        ?>
"  style="color: #000;" target="_blank" >
                                          <?php 
        echo show_file_name($file_path, 40);
        ?>
</a>
                                     <span style="float:right;"><a href="javascript:;" main_id="<?php 
        echo $task->id;
        ?>
" file_name="<?php 
        echo $file_path;
        ?>
" delete_key="<?php 
        echo $k;
        ?>
" class="delete_files"><img src="<?php 
        echo base_url($theme_path . 'images/icons/color/cross.png');
        ?>
"></a></span></span>