Пример #1
0
function asset_url($file)
{
    if (defined('ASSETS_PATH') && file_exists(ASSETS_PATH . $file)) {
        return file_url(ASSETS_PATH . $file);
    }
    return '/' . ltrim($file);
}
Пример #2
0
 }
 $cmdDirName = $entry['path'];
 if (!$entry['visible']) {
     $style = ' class="not_visible"';
 } else {
     $style = '';
 }
 if ($is_dir) {
     $img_href = icon('fa-folder-o');
     $file_url = $base_url . "openDir={$cmdDirName}";
     $link_title = q($entry['filename']);
     $dload_msg = $langDownloadDir;
     $link_href = "<a href='{$file_url}'>{$link_title}</a>";
 } else {
     $img_href = icon(choose_image('.' . $entry['format']));
     $file_url = file_url($cmdDirName, $entry['filename']);
     if ($entry['extra_path']) {
         $cdpath = common_doc_path($entry['extra_path']);
         if ($cdpath) {
             if ($can_upload) {
                 if ($common_doc_visible) {
                     $link_title_extra .= '&nbsp;' . icon('common', $langCommonDocLink);
                 } else {
                     $link_title_extra .= '&nbsp;' . icon('common-invisible', $langCommonDocLinkInvisible);
                     $style = ' class="invisible"';
                 }
             }
         } else {
             // External file URL
             $file_url = $entry['extra_path'];
             if ($is_editor) {
Пример #3
0
 /**
  *
  * @SWG\Api(
  *   path="/",
  *   description="API for project actions",
  * @SWG\Operation(
  *    method="POST",
  *    type="Project",
  *    summary="Create a new project for the current user (user must be logged in)",
  * @SWG\Parameter(
  *     name="name",
  *     description="Name of the project",
  *     paramType="form",
  *     required=true,
  *     type="string"
  *     ),
  * @SWG\Parameter(
  *     name="type_id",
  *     description="The Type of the project (1:UI/UX Project, 2:Video Project, 3:Business Template",
  *     paramType="form",
  *     required=true,
  *     type="integer"
  *     ),
  * @SWG\Parameter(
  *     name="templates",
  *     description="A comma-separated list of template uuids that have been chosen as screens for this project",
  *     paramType="form",
  *     required=false,
  *     type="string"
  *     )
  *   )
  * )
  */
 public function index_post()
 {
     /* Validate that they are the team owner */
     validate_team_owner(get_team_id(), get_user_id());
     /* Validate that they have a valid subscription and can add a project */
     validate_project_add(get_user_id());
     /* Validate add */
     $this->load->library('form_validation');
     $this->form_validation->set_rules('name', 'Project Name', 'trim|required|xss_clean');
     $this->form_validation->set_rules('type_id', 'Type ID', 'trim|required|integer|xss_clean|callback_validate_project_type');
     $this->form_validation->set_rules('templates', 'Templates', 'trim|xss_clean');
     if ($this->form_validation->run() == FALSE) {
         json_error('There was a problem with your submission: ' . validation_errors(' ', ' '));
     } else {
         $data = array('name' => $this->post('name', TRUE), 'type_id' => intval($this->post('type_id', TRUE)), 'team_id' => get_team_id());
         $project_id = $this->Project->add($data);
         $templates = $this->post('templates', TRUE);
         /* If this is a template project, add the templates to the project that they've chose */
         if ($templates) {
             $this->load->library('upload');
             $template_ids = explode(",", $templates);
             foreach ($template_ids as $template_id) {
                 $template = $this->Template->load_by_uuid(trim($template_id));
                 if ($template) {
                     // Copy the template file to the screens directory so we can link to it
                     $file = file_get_contents(file_url($template->url, FILE_TYPE_TEMPLATE));
                     $file_ext = $this->upload->get_extension($template->url);
                     if ($file) {
                         $file_name = md5(uniqid(mt_rand())) . $file_ext;
                         $full_path = $this->config->item('screen_upload_dir') . $file_name;
                         file_put_contents($full_path, $file);
                         $this->Screen->add(array('creator_id' => get_user_id(), 'project_id' => $project_id, 'ordering' => $this->Screen->get_max_ordering_for_project($project_id) + 1, 'url' => $file_name, 'file_type' => $template->file_type, 'file_size' => $template->file_size, 'image_height' => $template->image_height, 'image_width' => $template->image_width));
                     }
                 }
             }
         }
         /* Add the activity item to indicate that a project was added */
         activity_add_project($project_id, get_user_id());
         $project = $this->decorate_object($this->Project->load($project_id));
         $this->response($project);
     }
 }
Пример #4
0
		<div class="alert alert-warning" role="alert">目前還沒有提供來電辨識功能,但可以撥出</div>
		<div class="row">
			<div class="col-md-3">
				<h4>1.手機>設定>安全性></h4>
				<h4>&nbsp;&nbsp;&nbsp;未知的來源=>打勾</h4>
				<img src="<?php 
echo img_url('/unknown_source.jpg');
?>
" style="width:100%">
			</div>
			<div class="col-md-3">
				<h4>2.在手機用以下網址下載條碼掃描器(建議使用這個)</h4>
				&nbsp;&nbsp;&nbsp;<a href="https://goo.gl/sCdjUx">條碼掃描器(&nbsp;https://goo.gl/sCdjUx&nbsp;) </a>
				<h4>3.連到Book3126621Wifi, 用以下QRcode下載通訊錄APP</h4>
				<img src="http://chart.apis.google.com/chart?chs=300x300&chld=M|1&cht=qr&chl=<?php 
echo urlencode(file_url('/contactbook.apk'));
?>
" style="width:50%">

			</div>
			<div class="col-md-3">
				<h4>4.開啟下載的APP安裝檔, 並點選安裝</h4>
				<img src="<?php 
echo img_url('/download.jpg');
?>
" style="width:100%">
			</div>
			<div class="col-md-3">
				<h4>5.安裝好後點選開啟</h4>
				<img src="<?php 
echo img_url('/app_install.jpg');
Пример #5
0
/**
 * @brief display resource documents
 * @global type $is_editor
 * @global type $course_id
 * @global type $langWasDeleted
 * @global type $urlServer
 * @global type $id
 * @global type $course_code
 * @param type $title
 * @param type $comments
 * @param type $resource_id
 * @param type $file_id
 * @return string
 */
function show_doc($title, $comments, $resource_id, $file_id)
{
    global $is_editor, $course_id, $langWasDeleted, $urlServer, $id, $course_code;
    $file = Database::get()->querySingle("SELECT * FROM document WHERE course_id = ?d AND id = ?d", $course_id, $file_id);
    if (!$file) {
        if (!$is_editor) {
            return '';
        }
        $status = 'del';
        $image = 'fa-times';
        $link = "<span class='not_visible'>" . q($title) . " ({$langWasDeleted})</span>";
    } else {
        $status = $file->visible;
        if (!$is_editor and !resource_access($file->visible, $file->public)) {
            return '';
        }
        if ($file->format == '.dir') {
            $image = 'fa-folder-o';
            $link = "<a href='{$urlServer}modules/document/index.php?course={$course_code}&amp;openDir={$file->path}&amp;unit={$id}'>";
        } else {
            $image = choose_image('.' . $file->format);
            $link = "<a href='" . file_url($file->path, $file->filename) . "' target='_blank'>";
        }
    }
    $class_vis = ($status == '0' or $status == 'del') ? ' class="not_visible"' : '';
    if (!empty($comments)) {
        $comment = '<br />' . $comments;
    } else {
        $comment = '';
    }
    return "\n        <tr{$class_vis}>\n          <td width='1'>{$link}" . icon($image, '') . "</a></td>\n          <td align='left'>{$link}" . q($title) . "</a>{$comment}</td>" . actions('doc', $resource_id, $status) . '</tr>';
}
Пример #6
0
        Database::get()->query("INSERT INTO `lp_user_module_progress`\n\t            ( `user_id` , `learnPath_id` , `learnPath_module_id`, `lesson_location`, `suspend_data` )\n\t            VALUES (?d , ?d, ?d, '', '')", $uid, $_SESSION['path_id'], $learnPathModuleId);
    }
}
// else anonymous : record nothing !
// Get info about launched module
$module = Database::get()->querySingle("SELECT `contentType`, `startAsset_id`, `name`\n        FROM `lp_module`\n       WHERE `module_id` = ?d\n         AND `course_id` = ?d", $_SESSION['lp_module_id'], $course_id);
$assetPath = Database::get()->querySingle("SELECT `path` FROM `lp_asset` WHERE `asset_id` = ?d", $module->startAsset_id)->path;
// Get path of file of the starting asset to launch
switch ($module->contentType) {
    case CTDOCUMENT_:
        if ($uid) {
            // Directly pass this module
            directly_pass_lp_module($TABLEUSERMODULEPROGRESS, (int) $uid, (int) $learnPathModuleId);
        }
        // else anonymous : record nothing
        $file_url = file_url($assetPath);
        $play_url = file_playurl($assetPath);
        $furl = $file_url;
        if (MultimediaHelper::isSupportedMedia($module->name)) {
            $furl = $play_url;
        }
        $moduleStartAssetPage = $furl;
        break;
    case CTEXERCISE_:
        // clean session vars of exercise
        unset($_SESSION['objExercise']);
        unset($_SESSION['objQuestion']);
        unset($_SESSION['objAnswer']);
        unset($_SESSION['questionList']);
        unset($_SESSION['exerciseResult']);
        unset($_SESSION['exeStartTime']);
Пример #7
0
function display_my_documents($dialogBox, $style)
{
    global $curDirName;
    global $curDirPath;
    global $parentDir;
    global $langUp;
    global $langName;
    global $langSize;
    global $langDate;
    global $langAddModulesButton;
    global $fileList;
    global $themeimg;
    global $langSelection, $langDirectory, $course_code;
    $output = '';
    /*
     * DISPLAY
     */
    $dspCurDirName = htmlspecialchars($curDirName);
    // $cmdCurDirPath = rawurlencode($curDirPath);
    $cmdParentDir = rawurlencode($parentDir);
    $output .= '<form action="' . $_SERVER['SCRIPT_NAME'] . '?course=' . $course_code . '" method="POST">';
    /* --------------------------------------
       DIALOG BOX SECTION
       -------------------------------------- */
    $colspan = 5;
    if (!empty($dialogBox)) {
        $output .= disp_message_box($dialogBox, $style) . "<br />";
    }
    /* --------------------------------------
       CURRENT DIRECTORY LINE
       -------------------------------------- */
    /* CURRENT DIRECTORY */
    if ($curDirName) {
        $output .= '
        <table class="table-default">
        <tr>
          <td width="1" class="right">' . icon('fa-folder-o') . '</td>
          <td>' . $langDirectory . ': <b>' . $dspCurDirName . '</b></td>';
        /* GO TO PARENT DIRECTORY */
        if ($curDirName) {
            $linkup = "<a href='{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;openDir={$cmdParentDir}'>";
            $output .= "<td width='1'>{$linkup}<img src='{$themeimg}/folder_up.png' " . "hspace='5' alt='{$langUp}' title='langUp' /></a></td>" . "<td width='10' class='right'><small>{$linkup}{$langUp}</a></small></td>";
        }
        $output .= '</tr></table>';
    }
    $output .= '
    <div class="table-responsive">
    <table class="table-default" >';
    $output .= "\n    <tr class='list-header'>\n      <th colspan='2'><div align='left'>&nbsp;&nbsp;{$langName}</div></th>\n      <th>{$langSize}</th>\n      <th>{$langDate}</th>\n      <th>{$langSelection}</th>\n    </tr>";
    /* --------------------------------------
       DISPLAY FILE LIST
       -------------------------------------- */
    if ($fileList) {
        $iterator = 0;
        $ind = 1;
        while (list($fileKey, $fileName) = each($fileList['name'])) {
            if ($ind % 2 == 0) {
                $style = 'class="even"';
            } else {
                $style = 'class="odd"';
            }
            $dspFileName = htmlspecialchars($fileList['filename'][$fileKey]);
            $cmdFileName = str_replace("%2F", "/", rawurlencode($curDirPath . "/" . $fileName));
            if ($fileList['visible'][$fileKey] == 0) {
                continue;
                // skip the display of this file
            }
            if ($fileList['type'][$fileKey] == A_FILE) {
                $image = choose_image($fileName);
                $size = format_file_size($fileList['size'][$fileKey]);
                $date = nice_format($fileList['date'][$fileKey]);
                $file_url = file_url($fileList['path'][$fileKey], $dspFileName);
                $play_url = file_playurl($fileList['path'][$fileKey], $dspFileName);
                $urlFileName = MultimediaHelper::chooseMediaAhrefRaw($file_url, $play_url, $dspFileName, $dspFileName);
            } elseif ($fileList['type'][$fileKey] == A_DIRECTORY) {
                $image = 'fa-folder';
                $size = '&nbsp;';
                $date = '&nbsp;';
                $urlFileName = '<a href="' . $_SERVER['SCRIPT_NAME'] . '?course=' . $course_code . '&amp;openDir=' . $cmdFileName . '">' . $dspFileName . '</a>';
            }
            $output .= '
                <tr ' . $style . '>
                <td class="center" width="1">' . icon($image, '') . '</td>
                <td align="left">' . $urlFileName . '</td>
                <td width="80" class="center">' . $size . '</td>
                <td width="80" class="center">' . $date . '</td>';
            if ($fileList['type'][$fileKey] == A_FILE) {
                $iterator++;
                $output .= '
                <td width="10" class="center">
                        <input type="checkbox" name="insertDocument_' . $iterator . '" id="insertDocument_' . $iterator . '" value="' . $curDirPath . "/" . $fileName . '" />
                        <input type="hidden" name="filenameDocument_' . $iterator . '" id="filenameDocument_' . $iterator . '" value="' . $dspFileName . '" />
                </td>';
            } else {
                $output .= '<td>&nbsp;</td>';
            }
            $output .= '</tr>';
            /* COMMENTS */
            if ($fileList['comment'][$fileKey] != "") {
                $fileList['comment'][$fileKey] = htmlspecialchars($fileList['comment'][$fileKey]);
                $fileList['comment'][$fileKey] = parse_user_text($fileList['comment'][$fileKey]);
                $output .= '
                <tr class="even">
                <td>&nbsp;</td>
                <td colspan="' . $colspan . '"><span class="comment">' . $fileList['comment'][$fileKey] . '</span></td>
                </tr>';
            }
            $ind++;
        }
        // end each ($fileList)
        // form button
        $output .= '
    <tr>
      <th colspan="' . $colspan . '"><div class="pull-right">
        <input type="hidden" name="openDir" value="' . $curDirPath . '" />
        <input type="hidden" name="maxDocForm" value ="' . $iterator . '" />
        <input class="btn btn-primary" type="submit" name="submitInsertedDocument" value="' . $langAddModulesButton . '">        
      </th>
    </tr>';
    } else {
        $output .= '<tr><td colspan="4">&nbsp;</td></tr>';
    }
    $output .= '</table></div></form>';
    return $output;
}
Пример #8
0
/**
 * DECORATE TEMPLATES
 * @param $object
 * @return mixed
 */
function decorate_template($object)
{
    $CI =& get_instance();
    $CI->load->model(array('Template'));
    if (isset($object->creator_id)) {
        $object->creator_uuid = $CI->User->get_uuid($object->creator_id);
    }
    $object->url = file_url($object->url, FILE_TYPE_TEMPLATE);
    $object->ordering = intval($object->ordering);
    $object->image_width = floatval($object->image_width);
    $object->image_height = floatval($object->image_height);
    $object->file_size = floatval($object->file_size);
    unset($object->deleted, $object->id, $object->creator_id);
    return $object;
}
Пример #9
0
    not_found($uri);
}

$ebook_url_base = "{$urlServer}modules/ebook/show.php/$course_code/$ebook_id/";

if ($show_orphan_file and $file_path) {
    if (!preg_match('/\.html?$/i', $file_path)) {
        if (!$is_in_playmode)
            send_file_by_url_file_path($file_path);
        else {
            require_once 'include/lib/multimediahelper.class.php';

            $path_components = explode('/', str_replace('//', chr(1), $file_path));
            $file_info = public_path_to_disk_path($path_components, '');

            $mediaPath = file_url($file_info->path, $file_info->filename);
            $mediaURL = $urlServer . 'modules/ebook/document.php?course=' . $course_code . '&amp;ebook_id=' . $ebook_id . '&amp;download=' . $file_info->path;
            $token = token_generate($file_info->path, true);
            $mediaAccess = $mediaPath . '?token=' . $token;

            echo MultimediaHelper::mediaHtmlObjectRaw($mediaAccess, $mediaURL, $mediaPath);
            exit();
        }
    }
}

$pageName = $langEBook;
if ($unit !== false) {
    $exit_fullscreen_link = $urlAppend . "modules/units/index.php?course=$course_code&amp;id=$unit";
    $unit_parameter = 'unit=' . $unit;
} else {
Пример #10
0
/**
 * @brief display resource documents
 * @global type $is_editor
 * @global type $course_id
 * @global type $langWasDeleted
 * @global type $urlServer
 * @global type $id
 * @global type $course_code
 * @param type $title
 * @param type $comments
 * @param type $resource_id
 * @param type $file_id
 * @return string
 */
function show_doc($title, $comments, $resource_id, $file_id) {
    global $is_editor, $course_id, $langWasDeleted, $head_content,
           $urlServer, $id, $course_code;
 
    $file = Database::get()->querySingle("SELECT * FROM document WHERE course_id = ?d AND id = ?d", $course_id, $file_id);    
    if (!$file) {
        if (!$is_editor) {
            return '';
        }
        $status = 'del';
        $image = 'fa-times';
        $link = "<span class='not_visible'>" . q($title) . " ($langWasDeleted)</span>";
    } else {
        $status = $file->visible;
        if (!$is_editor and ( !resource_access($file->visible, $file->public))) {
            return '';
        }
        if ($file->format == '.dir') {
            $image = 'fa-folder-o';
            $download_hidden_link = '';
            $link = "<a href='{$urlServer}modules/document/index.php?course=$course_code&amp;openDir=$file->path&amp;unit=$id'>$file->filename</a>";            
        } else {
            $image = choose_image('.' . $file->format);
            $download_url = "{$urlServer}modules/document/index.php?course=$course_code&amp;download=$file->path";
            $download_hidden_link = "<input type='hidden' value='$download_url'>";
            $file_obj = MediaResourceFactory::initFromDocument($file);
            $file_obj->setAccessURL(file_url($file->path, $file->filename));
            $file_obj->setPlayURL(file_playurl($file->path, $file->filename));
            $link = MultimediaHelper::chooseMediaAhref($file_obj);              
        }
    }
    $class_vis = ($status == '0' or $status == 'del') ? ' class="not_visible"' : '';
    if (!empty($comments)) {
        $comment = '<br />' . $comments;
    } else {
        $comment = '';
    }
    return "
        <tr$class_vis>
          <td width='1'>" . icon($image, '') . "</a></td>
          <td align='left'>$download_hidden_link$link$comment</td>" .
            actions('doc', $resource_id, $status) .
            '</tr>';
}
Пример #11
0
/**
 * list documents while inserting them in course unit
 * @global type $id
 * @global type $webDir
 * @global type $course_code
 * @global type $tool_content
 * @global type $group_sql
 * @global type $langDirectory
 * @global type $langUp
 * @global type $langName
 * @global type $langSize
 * @global type $langDate
 * @global type $langType
 * @global type $langAddModulesButton
 * @global type $langChoice
 * @global type $langNoDocuments
 * @global type $course_code 
 */
function list_docs() {
    global $id, $webDir, $course_code, $tool_content,
    $group_sql, $langDirectory, $langUp, $langName, $langSize,
    $langDate, $langType, $langAddModulesButton, $langChoice,
    $langNoDocuments, $course_code, $langCommonDocs, $pageName;

    $basedir = $webDir . '/courses/' . $course_code . '/document';
    $path = get_dir_path('path');
    $dir_param = get_dir_path('dir');
    $dir_setter = $dir_param ? ('&amp;dir=' . $dir_param) : '';
    $dir_html = $dir_param ? "<input type='hidden' name='dir' value='$dir_param'>" : '';

    if ($id == -1) {
        $common_docs = true;
        $pageName = $langCommonDocs;
        $group_sql = "course_id = -1 AND subsystem = " . COMMON . "";
        $basedir = $webDir . '/courses/commondocs';
        $visible_sql = 'visible = 1 AND';
    } else {
        $common_docs = false;
        $visible_sql = '';
    }
    $result = Database::get()->queryArray("SELECT id, course_id, path, filename, format, title, extra_path, date_modified, visible, copyrighted, comment, IF(title = '', filename, title) AS sort_key FROM document
                                WHERE $group_sql AND $visible_sql
                                      path LIKE ?s AND
                                      path NOT LIKE ?s
                                ORDER BY sort_key COLLATE utf8_unicode_ci",
                                "$path/%", "$path/%/%");

    $fileinfo = array();
    $urlbase = $_SERVER['SCRIPT_NAME'] . "?course=$course_code$dir_setter&amp;type=doc&amp;id=$id&amp;path=";

    foreach ($result as $row) {
        $fullpath = $basedir . $row->path;
        if ($row->extra_path) {
            $size = 0;
        } else {
            $size = file_exists($fullpath)? filesize($fullpath): 0;
        }
        $fileinfo[] = array(
            'id' => $row->id,
            'is_dir' => is_dir($fullpath),
            'size' => $size,
            'title' => $row->title,
            'name' => htmlspecialchars($row->filename),
            'format' => $row->format,
            'path' => $row->path,
            'visible' => $row->visible,
            'comment' => $row->comment,
            'copyrighted' => $row->copyrighted,
            'date' => $row->date_modified,
            'object' => MediaResourceFactory::initFromDocument($row));
    }
    if (count($fileinfo) == 0) {
        $tool_content .= "<div class='alert alert-warning'>$langNoDocuments</div>";
    } else {
        if (!empty($path)) {
            $dirname = Database::get()->querySingle("SELECT filename FROM document
                                                                   WHERE $group_sql AND path = ?s", $path);
            $parentpath = dirname($path);
            $dirname =  htmlspecialchars($dirname->filename);
            $parentlink = $urlbase . $parentpath;
            $parenthtml = "<span class='pull-right'><a href='$parentlink'>$langUp " .
                    icon('fa-level-up') . "</a></span>";
            $colspan = 4;
        }
        $tool_content .= "<form action='insert.php?course=$course_code' method='post'><input type='hidden' name='id' value='$id' />" .
                "<table class='table-default'>";
        if( !empty($path)) {
        $tool_content .=
                "<tr>" .
                "<th colspan='$colspan'><div class='text-left'>$langDirectory: $dirname$parenthtml</div></th>" .
                "</tr>" ;
        }
        $tool_content .=
                "<tr class='list-header'>" .
                "<th class='text-left'>$langName</th>" .
                "<th class='text-center'>$langSize</th>" .
                "<th class='text-center'>$langDate</th>" .
                "<th style='width:20px;' class='text-center'>$langChoice</th>" .
                "</tr>";
        $counter = 0;
        foreach (array(true, false) as $is_dir) {
            foreach ($fileinfo as $entry) {
                if ($entry['is_dir'] != $is_dir) {
                    continue;
                }
                $dir = $entry['path'];
                if ($is_dir) {
                    $image = 'fa-folder-o';
                    $file_url = $urlbase . $dir;
                    $link_text = $entry['name'];

                    $link_href = "<a href='$file_url'>$link_text</a>";
                } else {
                    $image = choose_image('.' . $entry['format']);
                    $file_url = file_url($entry['path'], $entry['name'], $common_docs ? 'common' : $course_code);

                    $dObj = $entry['object'];
                    $dObj->setAccessURL($file_url);
                    $dObj->setPlayURL(file_playurl($entry['path'], $entry['name'], $common_docs ? 'common' : $course_code));

                    $link_href = MultimediaHelper::chooseMediaAhref($dObj);
                }
                if ($entry['visible'] == 'i') {
                    $vis = 'invisible';
                } else {
                    $vis = '';                    
                }
                $tool_content .= "<tr class='$vis'>";
                $tool_content .= "<td>" . icon($image, '')."&nbsp;&nbsp;&nbsp;$link_href";

                /* * * comments ** */
                if (!empty($entry['comment'])) {
                    $tool_content .= "<br /><div class='comment'>" .
                            standard_text_escape($entry['comment']) .
                            "</div>";
                }
                $tool_content .= "</td>";
                if ($is_dir) {
                    // skip display of date and time for directories
                    $tool_content .= "<td>&nbsp;</td><td>&nbsp;</td>";
                } else {
                    $size = format_file_size($entry['size']);
                    $date = nice_format($entry['date'], true, true);
                    $tool_content .= "<td class='text-right'>$size</td><td class='text-center'>$date</td>";
                }
                $tool_content .= "<td class='text-center'><input type='checkbox' name='document[]' value='$entry[id]' /></td>";
                $tool_content .= "</tr>";
                $counter++;
            }
        }
        $tool_content .= "</table>";
        $tool_content .= "<div class='text-right'>";
        $tool_content .= "<input class='btn btn-primary' type='submit' name='submit_doc' value='$langAddModulesButton' /></div>$dir_html</form>";
        
    }
}
Пример #12
0
            mkdir($LOCAL_DIR, 0777, true);
        }
        $filename = $file["filename"];
        $fileurl = $file["url"];
        $filetime = $file["timestamp"];
        $filehash = $file["md5sum"];
        echo "Checking " . $filename . "\n";
        $local_filename = $LOCAL_DIR . $filename;
        // check if file exists
        $download_file = false;
        if (!file_exists($local_filename)) {
            $download_file = true;
        } else {
            $local_filetime = filemtime($local_filename);
            $local_filehash = md5_file($local_filename);
            if ($local_filehash != $filehash && $filetime >= $local_filetime) {
                $download_file = true;
            }
        }
        // download the file, if necessary
        if (!$download_file) {
            continue;
        }
        echo "Downloading " . $fileurl . "\n";
        file_put_contents($local_filename, fopen(file_url($fileurl), 'r'));
        if (file_exists($local_filename)) {
            // set the timestamp
            touch($local_filename, $filetime);
        }
    }
}
Пример #13
0
/**
 * list documents while inserting them in course unit
 * @global type $id
 * @global type $webDir
 * @global type $course_code
 * @global type $tool_content
 * @global type $group_sql
 * @global type $langDirectory
 * @global type $langUp
 * @global type $langName
 * @global type $langSize
 * @global type $langDate
 * @global type $langType
 * @global type $langAddModulesButton
 * @global type $langChoice
 * @global type $langNoDocuments
 * @global type $course_code 
 */
function list_docs()
{
    global $id, $webDir, $course_code, $tool_content, $group_sql, $langDirectory, $langUp, $langName, $langSize, $langDate, $langType, $langAddModulesButton, $langChoice, $langNoDocuments, $course_code, $langCommonDocs, $pageName;
    $basedir = $webDir . '/courses/' . $course_code . '/document';
    $path = get_dir_path('path');
    $dir_param = get_dir_path('dir');
    $dir_setter = $dir_param ? '&amp;dir=' . $dir_param : '';
    $dir_html = $dir_param ? "<input type='hidden' name='dir' value='{$dir_param}'>" : '';
    if ($id == -1) {
        $common_docs = true;
        $pageName = $langCommonDocs;
        $group_sql = "course_id = -1 AND subsystem = " . COMMON . "";
        $basedir = $webDir . '/courses/commondocs';
        $result = Database::get()->queryArray("SELECT * FROM document\n                                    WHERE {$group_sql} AND\n                                          visible = 1 AND\n                                          path LIKE ?s AND\n                                          path NOT LIKE ?s", "{$path}/%", "{$path}/%/%");
    } else {
        $common_docs = false;
        $result = Database::get()->queryArray("SELECT * FROM document\n                                    WHERE {$group_sql} AND\n                                          path LIKE ?s AND\n                                          path NOT LIKE ?s", "{$path}/%", "{$path}/%/%");
    }
    $fileinfo = array();
    $urlbase = $_SERVER['SCRIPT_NAME'] . "?course={$course_code}{$dir_setter}&amp;type=doc&amp;id={$id}&amp;path=";
    foreach ($result as $row) {
        $fullpath = $basedir . $row->path;
        if ($row->extra_path) {
            $size = 0;
        } else {
            $size = file_exists($fullpath) ? filesize($fullpath) : 0;
        }
        $fileinfo[] = array('id' => $row->id, 'is_dir' => is_dir($fullpath), 'size' => $size, 'title' => $row->title, 'name' => htmlspecialchars($row->filename), 'format' => $row->format, 'path' => $row->path, 'visible' => $row->visible, 'comment' => $row->comment, 'copyrighted' => $row->copyrighted, 'date' => $row->date_modified, 'object' => MediaResourceFactory::initFromDocument($row));
    }
    if (count($fileinfo) == 0) {
        $tool_content .= "<div class='alert alert-warning'>{$langNoDocuments}</div>";
    } else {
        if (empty($path)) {
            $dirname = '';
            $parenthtml = '';
            $colspan = 5;
        } else {
            $dirname = Database::get()->querySingle("SELECT filename FROM document\n                                                                   WHERE {$group_sql} AND path = ?s", $path);
            $parentpath = dirname($path);
            $dirname = "/" . htmlspecialchars($dirname);
            $parentlink = $urlbase . $parentpath;
            $parenthtml = "<th class='right'><a href='{$parentlink}'>{$langUp}</a> " . icon('fa-upload', $langUp, $parentlink) . "</th>";
            $colspan = 4;
        }
        $tool_content .= "<form action='insert.php?course={$course_code}' method='post'><input type='hidden' name='id' value='{$id}' />" . "<table class='table-default'>" . "<tr>" . "<th colspan='{$colspan}'><div align='left'>{$langDirectory}: {$dirname}</div></th>" . $parenthtml . "</tr>" . "<tr>" . "<th>{$langType}</th>" . "<th><div align='left'>{$langName}</div></th>" . "<th width='100'>{$langSize}</th>" . "<th width='80'>{$langDate}</th>" . "<th width='80'>{$langChoice}</th>" . "</tr>";
        $counter = 0;
        foreach (array(true, false) as $is_dir) {
            foreach ($fileinfo as $entry) {
                if ($entry['is_dir'] != $is_dir) {
                    continue;
                }
                $dir = $entry['path'];
                if ($is_dir) {
                    $image = 'fa-folder-o';
                    $file_url = $urlbase . $dir;
                    $link_text = $entry['name'];
                    $link_href = "<a href='{$file_url}'>{$link_text}</a>";
                } else {
                    $image = choose_image('.' . $entry['format']);
                    $file_url = file_url($entry['path'], $entry['name'], $common_docs ? 'common' : $course_code);
                    $dObj = $entry['object'];
                    $dObj->setAccessURL($file_url);
                    $dObj->setPlayURL(file_playurl($entry['path'], $entry['name'], $common_docs ? 'common' : $course_code));
                    $link_href = MultimediaHelper::chooseMediaAhref($dObj);
                }
                if ($entry['visible'] == 'i') {
                    $vis = 'invisible';
                } else {
                    $vis = '';
                }
                $tool_content .= "<tr class='{$vis}'>";
                $tool_content .= "<td width='1' class='center'>" . icon($image, '') . "</td>";
                $tool_content .= "<td>{$link_href}";
                /* * * comments ** */
                if (!empty($entry['comment'])) {
                    $tool_content .= "<br /><div class='comment'>" . standard_text_escape($entry['comment']) . "</div>";
                }
                $tool_content .= "</td>";
                if ($is_dir) {
                    // skip display of date and time for directories
                    $tool_content .= "<td>&nbsp;</td><td>&nbsp;</td>";
                } else {
                    $size = format_file_size($entry['size']);
                    $date = nice_format($entry['date'], true, true);
                    $tool_content .= "<td class='center'>{$size}</td><td class='center'>{$date}</td>";
                }
                $tool_content .= "<td class='center'><input type='checkbox' name='document[]' value='{$entry['id']}' /></td>";
                $tool_content .= "</tr>";
                $counter++;
            }
        }
        $tool_content .= "<tr><th colspan={$colspan}><div align='right'>";
        $tool_content .= "<input class='btn btn-primary' type='submit' name='submit_doc' value='{$langAddModulesButton}' /></div></th>";
        $tool_content .= "</tr></table>{$dir_html}</form>";
    }
}
Пример #14
0
/**
 * @brief get user documents newer than one month
 * @global type $langNoDocsExist
 * @param type $param
 * @return string
 */
function getUserDocuments($lesson_id)
{
    global $langNoDocsExist, $group_sql;
    $last_month = strftime('%Y-%m-%d', strtotime('now -1 month'));
    $found = false;
    $doc_content = '<table width="100%">';
    foreach ($lesson_id as $lid) {
        $q = Database::get()->queryArray("SELECT document.path, document.course_id, document.filename,\n                                            document.title, document.date_modified,\n                                            document.format, document.visible,\n                                            document.id\n                                     FROM document, course_module\n                                     WHERE document.course_id = ?d AND                             \n                                            subsystem = " . MAIN . " AND\n                                            document.visible = 1 AND\n                                            date_modified >= '{$last_month}' AND\n                                            format <> '.dir' AND\n                                            course_module.module_id = " . MODULE_ID_DOCS . " AND\n                                            course_module.visible = 1 AND\n                                            course_module.course_id = ?d\n                                    ORDER BY date_modified DESC", $lid, $lid);
        if ($q) {
            $found = true;
            $doc_content .= "<tr><td class='sub_title1'>" . q(ellipsize(course_id_to_title($lid), 70)) . "</td></tr>";
            foreach ($q as $course_file) {
                $group_sql = "course_id = " . $lid . " AND subsystem = " . MAIN;
                $url = file_url($course_file->path, $course_file->filename, course_id_to_code($lid));
                $dObj = MediaResourceFactory::initFromDocument($course_file);
                $dObj->setAccessURL($url);
                $dObj->setPlayURL(file_playurl($course_file->path, $course_file->filename, course_id_to_code($lid)));
                $href = MultimediaHelper::chooseMediaAhref($dObj);
                $doc_content .= "<tr><td class='smaller'><ul class='custom_list'><li>" . $href . ' - (' . nice_format(date('Y-m-d', strtotime($course_file->date_modified))) . ")</li></ul></td></tr>";
            }
        }
    }
    $doc_content .= "</table>";
    if ($found) {
        return $doc_content;
    } else {
        return "<div class='alert alert-warning'>{$langNoDocsExist}</div>";
    }
}
Пример #15
0
function clean_user($user)
{
    unset($user->id);
    unset($user->password);
    unset($user->salt);
    unset($user->user_type_id);
    unset($user->created);
    unset($user->deleted);
    unset($user->inactive);
    unset($user->notify_general);
    unset($user->notify_promotions);
    if (isset($user->avatar)) {
        $user->avatar = file_url($user->avatar);
    } else {
        $user->avatar = get_gravatar($user->email, IMG_SIZE_LG);
    }
    $user->last_login_pretty = pretty_twitter_date(strtotime($user->last_login)) . " ago";
    return $user;
}