当前位置: 首页>>代码示例>>PHP>>正文


PHP api_get_item_visibility函数代码示例

本文整理汇总了PHP中api_get_item_visibility函数的典型用法代码示例。如果您正苦于以下问题:PHP api_get_item_visibility函数的具体用法?PHP api_get_item_visibility怎么用?PHP api_get_item_visibility使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了api_get_item_visibility函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process

 public function process()
 {
     $results = array();
     foreach ($this->rows as $row_val) {
         $search_show_unlinked_results = api_get_setting('search_show_unlinked_results') == 'true';
         $course_visible_for_user = api_is_course_visible_for_user(NULL, $row_val['courseid']);
         // can view course?
         if ($course_visible_for_user || $search_show_unlinked_results) {
             // is visible?
             $visibility = api_get_item_visibility(api_get_course_info($row_val['courseid']), TOOL_DOCUMENT, $row_val['xapian_data'][SE_DATA]['doc_id']);
             if ($visibility) {
                 list($thumbnail, $image, $name, $author, $url) = $this->get_information($row_val['courseid'], $row_val['xapian_data'][SE_DATA]['doc_id']);
                 $result = array('toolid' => TOOL_DOCUMENT, 'score' => $row_val['score'], 'url' => $url, 'thumbnail' => $thumbnail, 'image' => $image, 'title' => $name, 'author' => $author);
                 if ($course_visible_for_user) {
                     $results[] = $result;
                 } else {
                     // course not visible for user
                     if ($search_show_unlinked_results) {
                         $result['url'] = '';
                         $results[] = $result;
                     }
                 }
             }
         }
     }
     // get information to sort
     foreach ($results as $key => $row) {
         $score[$key] = $row['score'];
     }
     // Sort results with score descending
     array_multisort($score, SORT_DESC, $results);
     return $results;
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:33,代码来源:document_processor.class.php

示例2: process

    public function process() {
        $results = array();

        foreach ($this->links as $courseid => $one_course_links) {
            $course_info = api_get_course_info($courseid);
            $search_show_unlinked_results = (api_get_setting('search_show_unlinked_results') == 'true');
            $course_visible_for_user = api_is_course_visible_for_user(NULL, $courseid);
            // can view course?
            if ($course_visible_for_user || $search_show_unlinked_results) {
                $result = NULL;
                foreach ($one_course_links['links'] as $one_link) {
                    // is visible?
                    $visibility = api_get_item_visibility($course_info, TOOL_LINK, $one_link['link_id']);
                    if ($visibility) {
                        // if one is visible let show the result for a course
                        // also asume all data of this item like the data of the whole group of links(Ex. author)
                        list($thumbnail, $image, $name, $author, $url) = $this->get_information($courseid, $one_link['link_id']);
                        $result_tmp = array(
                            'toolid' => TOOL_LINK,
                            'score' => $one_course_links['total_score'] / (count($one_course_links) - 1), // not count total_score array item
                            'url' => $url,
                            'thumbnail' => $thumbnail,
                            'image' => $image,
                            'title' => $name,
                            'author' => $author,
                        );
                        if ($course_visible_for_user) {
                            $result = $result_tmp;
                        } else { // course not visible for user
                            if ($search_show_unlinked_results) {
                                $result_tmp['url'] = '';
                                $result = $result_tmp;
                            }
                        }
                        break;
                    }
                }
                if (!is_null($result)) {
                    // if there is at least one link item found show link to course Links tool page
                    $results[] = $result;
                }
            }
        }

        // get information to sort
        foreach ($results as $key => $row) {
            $score[$key] = $row['score'];
        }

        // Sort results with score descending
        array_multisort($score, SORT_DESC, $results);

        return $results;
    }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:54,代码来源:link_processor.class.php

示例3: process

 public function process()
 {
     $results = array();
     foreach ($this->learnpaths as $courseid => $learnpaths) {
         $search_show_unlinked_results = api_get_setting('search_show_unlinked_results') == 'true';
         $course_visible_for_user = api_is_course_visible_for_user(NULL, $courseid);
         // can view course?
         if ($course_visible_for_user || $search_show_unlinked_results) {
             foreach ($learnpaths as $lp_id => $lp) {
                 // is visible?
                 $visibility = api_get_item_visibility(api_get_course_info($courseid), TOOL_LEARNPATH, $lp_id);
                 if ($visibility) {
                     list($thumbnail, $image, $name, $author) = $this->get_information($courseid, $lp_id, $lp['has_document_id']);
                     $url = api_get_path(WEB_PATH) . 'main/newscorm/lp_controller.php?cidReq=%s&action=view&lp_id=%s';
                     $url = sprintf($url, $courseid, $lp_id);
                     $result = array('toolid' => TOOL_LEARNPATH, 'score' => $lp['total_score'] / (count($lp) - 1), 'url' => $url, 'thumbnail' => $thumbnail, 'image' => $image, 'title' => $name, 'author' => $author);
                     if ($course_visible_for_user) {
                         $results[] = $result;
                     } else {
                         // course not visible for user
                         if ($search_show_unlinked_results) {
                             $result['url'] = '';
                             $results[] = $result;
                         }
                     }
                 }
             }
         }
     }
     // get information to sort
     foreach ($results as $key => $row) {
         $score[$key] = $row['score'];
     }
     // Sort results with score descending
     array_multisort($score, SORT_DESC, $results);
     return $results;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:37,代码来源:learnpath_processor.class.php

示例4: get_lang

                                 }
                             }
                         } else {
                             $number_of_questions = $rowi;
                         }*/
     $number_of_questions = $exercise_obj->getQuestionCount();
     if ($row['random'] > 0 && $row['random'] != -1) {
         $number_of_questions = $number_of_questions . ' (' . $row['random'] . ' ' . get_lang('Random') . ') ';
     }
     //Attempts
     //$attempts = get_count_exam_results($my_exercise_id).' '.get_lang('Attempts');
     //$item .=  Display::tag('td',$attempts);
     $item .= Display::tag('td', $number_of_questions);
 } else {
     // Student only
     $visibility = api_get_item_visibility($course_info, TOOL_QUIZ, $my_exercise_id);
     if ($visibility == 0) {
         continue;
     }
     // if time is actived show link to exercise
     if ($time_limits) {
         if ($is_actived_time) {
             $url = '<a ' . $alt_title . '  href="overview.php?' . api_get_cidreq() . $myorigin . $mylpid . $mylpitemid . '&exerciseId=' . $my_exercise_id . '">' . $cut_title . '</a>';
         } else {
             $url = $row['title'];
         }
     } else {
         $url = '<a ' . $alt_title . '  href="overview.php?' . api_get_cidreq() . $myorigin . $mylpid . $mylpitemid . '&exerciseId=' . $my_exercise_id . '">' . $cut_title . '</a>';
     }
     //Link of the exercise
     $item = Display::tag('td', $url . ' ' . $session_img);
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:exercice.php

示例5: change_visibility_announcement

 /**
  * This functions swithes the visibility a course resource
  * using the visibility field in 'item_property'
  * @param    array    the course array
  * @param    int     ID of the element of the corresponding type
  * @return   bool    False on failure, True on success
  */
 public static function change_visibility_announcement($_course, $id)
 {
     $session_id = api_get_session_id();
     $item_visibility = api_get_item_visibility($_course, TOOL_ANNOUNCEMENT, $id, $session_id);
     if ($item_visibility == '1') {
         api_item_property_update($_course, TOOL_ANNOUNCEMENT, $id, 'invisible', api_get_user_id());
     } else {
         api_item_property_update($_course, TOOL_ANNOUNCEMENT, $id, 'visible', api_get_user_id());
     }
     return true;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:18,代码来源:announcements.inc.php

示例6: get_exercise_progress


//.........这里部分代码省略.........
             foreach ($sessions as $sessionIdx => $sessionData) {
                 if (!empty($sessionIdx)) {
                     $whereSessionParams .= $sessionIdx . ',';
                 }
             }
             $whereSessionParams = substr($whereSessionParams, 0, -1);
         }
         if (!empty($exerciseId)) {
             $exerciseId = intval($exerciseId);
             $where .= ' AND q.id = %d ';
             $whereParams[] = $exerciseId;
         }
         /*
          * This feature has been disabled for now, to avoid having to
          * join two very large tables
         //2 = show all questions (wrong and correct answered)
         if ($answer != 2) {
             $answer = intval($answer);
             //$where .= ' AND qa.correct = %d';
             //$whereParams[] = $answer;
         }
         */
         $limit = '';
         if (!empty($options['limit'])) {
             $limit = " LIMIT " . $options['limit'];
         }
         if (!empty($options['where'])) {
             $where .= ' AND ' . Database::escape_string($options['where']);
         }
         $order = '';
         if (!empty($options['order'])) {
             $order = " ORDER BY " . $options['order'];
         }
         if (!empty($date_to) && !empty($date_from)) {
             $where .= sprintf(" AND (te.start_date BETWEEN '%s 00:00:00' AND '%s 23:59:59')", $date_from, $date_to);
         }
         $sql = "SELECT\n                te.session_id,\n                ta.id as attempt_id,\n                te.exe_user_id as user_id,\n                te.exe_id as exercise_attempt_id,\n                ta.question_id,\n                ta.answer as answer_id,\n                ta.tms as time,\n                te.exe_exo_id as quiz_id,\n                CONCAT ('c', q.c_id, '_e', q.id) as exercise_id,\n                q.title as quiz_title,\n                qq.description as description\n                FROM {$ttrack_exercises} te\n                INNER JOIN {$ttrack_attempt} ta ON ta.exe_id = te.exe_id\n                INNER JOIN {$tquiz} q ON q.id = te.exe_exo_id\n                INNER JOIN {$tquiz_rel_question} rq ON rq.exercice_id = q.id AND rq.c_id = q.c_id\n                INNER JOIN {$tquiz_question} qq\n                ON\n                    qq.id = rq.question_id AND\n                    qq.c_id = rq.c_id AND\n                    qq.position = rq.question_order AND\n                    ta.question_id = rq.question_id\n                WHERE\n                    te.c_id = {$courseIdx} " . (empty($whereSessionParams) ? '' : "AND te.session_id IN ({$whereSessionParams})") . "\n                    AND q.c_id = {$courseIdx}\n                    {$where} {$order} {$limit}";
         $sql_query = vsprintf($sql, $whereParams);
         // Now browse through the results and get the data
         $rs = Database::query($sql_query);
         $userIds = array();
         $questionIds = array();
         $answerIds = array();
         while ($row = Database::fetch_array($rs)) {
             //only show if exercise is visible
             if (api_get_item_visibility($courseData, 'quiz', $row['exercise_id'])) {
                 $userIds[$row['user_id']] = $row['user_id'];
                 $questionIds[$row['question_id']] = $row['question_id'];
                 $answerIds[$row['question_id']][$row['answer_id']] = $row['answer_id'];
                 $row['session'] = $sessions[$row['session_id']];
                 $data[] = $row;
             }
         }
         // Now fill questions data. Query all questions and answers for this test to avoid
         $sqlQuestions = "SELECT tq.c_id, tq.id as question_id, tq.question, tqa.id_auto,\n                            tqa.answer, tqa.correct, tq.position, tqa.id_auto as answer_id\n                            FROM {$tquiz_question} tq, {$tquiz_answer} tqa\n                            WHERE\n                                tqa.question_id = tq.id AND\n                                tqa.c_id = tq.c_id AND\n                                tq.c_id = {$courseIdx} AND\n                                tq.id IN (" . implode(',', $questionIds) . ")";
         $resQuestions = Database::query($sqlQuestions);
         $answer = array();
         $question = array();
         while ($rowQuestion = Database::fetch_assoc($resQuestions)) {
             $questionId = $rowQuestion['question_id'];
             $answerId = $rowQuestion['answer_id'];
             $answer[$questionId][$answerId] = array('position' => $rowQuestion['position'], 'question' => $rowQuestion['question'], 'answer' => $rowQuestion['answer'], 'correct' => $rowQuestion['correct']);
             $question[$questionId]['question'] = $rowQuestion['question'];
         }
         // Now fill users data
         $sqlUsers = "SELECT user_id, username, lastname, firstname\n                         FROM {$tuser}\n                         WHERE user_id IN (" . implode(',', $userIds) . ")";
         $resUsers = Database::query($sqlUsers);
         while ($rowUser = Database::fetch_assoc($resUsers)) {
             $users[$rowUser['user_id']] = $rowUser;
         }
         foreach ($data as $id => $row) {
             $rowQuestId = $row['question_id'];
             $rowAnsId = $row['answer_id'];
             $data[$id]['session'] = $sessions[$row['session_id']]['name'];
             $data[$id]['firstname'] = $users[$row['user_id']]['firstname'];
             $data[$id]['lastname'] = $users[$row['user_id']]['lastname'];
             $data[$id]['username'] = $users[$row['user_id']]['username'];
             $data[$id]['answer'] = $answer[$rowQuestId][$rowAnsId]['answer'];
             $data[$id]['correct'] = $answer[$rowQuestId][$rowAnsId]['correct'] == 0 ? get_lang('No') : get_lang('Yes');
             $data[$id]['question'] = $question[$rowQuestId]['question'];
             $data[$id]['question_id'] = $rowQuestId;
             $data[$id]['description'] = $row['description'];
         }
         /*
         The minimum expected array structure at the end is:
         attempt_id,
         session name,
         exercise_id,
         quiz_title,
         username,
         lastname,
         firstname,
         time,
         question_id,
         question,
         answer,
         */
     }
     return $data;
 }
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:101,代码来源:tracking.lib.php

示例7: is_visible

 /**
  *  Checks if the exercise is visible due a lot of conditions - visibility, time limits, student attempts
  * @return bool true if is active
  */
 public function is_visible($lp_id = 0, $lp_item_id = 0, $lp_item_view_id = 0, $filter_by_admin = true)
 {
     // 1. By default the exercise is visible
     $is_visible = true;
     $message = null;
     // 1.1 Admins and teachers can access to the exercise
     if ($filter_by_admin) {
         if (api_is_platform_admin() || api_is_course_admin()) {
             return array('value' => true, 'message' => '');
         }
     }
     // Deleted exercise.
     if ($this->active == -1) {
         return array('value' => false, 'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false));
     }
     // Checking visibility in the item_property table.
     $visibility = api_get_item_visibility(api_get_course_info(), TOOL_QUIZ, $this->id, api_get_session_id());
     if ($visibility == 0 || $visibility == 2) {
         $this->active = 0;
     }
     // 2. If the exercise is not active.
     if (empty($lp_id)) {
         // 2.1 LP is OFF
         if ($this->active == 0) {
             return array('value' => false, 'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false));
         }
     } else {
         // 2.1 LP is loaded
         if ($this->active == 0 && !learnpath::is_lp_visible_for_student($lp_id, api_get_user_id())) {
             return array('value' => false, 'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false));
         }
     }
     //3. We check if the time limits are on
     $limit_time_exists = !empty($this->start_time) && $this->start_time != '0000-00-00 00:00:00' || !empty($this->end_time) && $this->end_time != '0000-00-00 00:00:00' ? true : false;
     if ($limit_time_exists) {
         $time_now = time();
         if (!empty($this->start_time) && $this->start_time != '0000-00-00 00:00:00') {
             $is_visible = $time_now - api_strtotime($this->start_time, 'UTC') > 0 ? true : false;
         }
         if ($is_visible == false) {
             $message = sprintf(get_lang('ExerciseAvailableFromX'), api_convert_and_format_date($this->start_time));
         }
         if ($is_visible == true) {
             if ($this->end_time != '0000-00-00 00:00:00') {
                 $is_visible = (api_strtotime($this->end_time, 'UTC') > $time_now) > 0 ? true : false;
                 if ($is_visible == false) {
                     $message = sprintf(get_lang('ExerciseAvailableUntilX'), api_convert_and_format_date($this->end_time));
                 }
             }
         }
         if ($is_visible == false && $this->start_time != '0000-00-00 00:00:00' && $this->end_time != '0000-00-00 00:00:00') {
             $message = sprintf(get_lang('ExerciseWillBeActivatedFromXToY'), api_convert_and_format_date($this->start_time), api_convert_and_format_date($this->end_time));
         }
     }
     // 4. We check if the student have attempts
     $exerciseAttempts = $this->selectAttempts();
     if ($is_visible) {
         if ($exerciseAttempts > 0) {
             $attempt_count = Event::get_attempt_count_not_finished(api_get_user_id(), $this->id, $lp_id, $lp_item_id, $lp_item_view_id);
             if ($attempt_count >= $exerciseAttempts) {
                 $message = sprintf(get_lang('ReachedMaxAttempts'), $this->name, $exerciseAttempts);
                 $is_visible = false;
             }
         }
     }
     if (!empty($message)) {
         $message = Display::return_message($message, 'warning', false);
     }
     return array('value' => $is_visible, 'message' => $message);
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:74,代码来源:exercise.class.php

示例8: showQuestion


//.........这里部分代码省略.........
                    if ($answerCorrect) {
                        $s .= Display::div($counterAnswer, ['id' => "drop_{$windowId}", 'class' => 'droppable col-md-2']);
                        $counterAnswer++;
                    }
                }
                $s .= '</div>';
                // row
                $s .= '</div>';
                // col-md-12
                $s .= '</div>';
                // col-md-12 ui-widget ui-helper-clearfix
            }
            if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
                $s .= '</div>';
                //drag_question
            }
            $s .= '</div>';
            //question_options row
            // destruction of the Answer object
            unset($objAnswerTmp);
            // destruction of the Question object
            unset($objQuestionTmp);
            if ($origin != 'export') {
                echo $s;
            } else {
                return $s;
            }
        } elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) {
            global $exerciseId, $exe_id;
            // Question is a HOT_SPOT
            //checking document/images visibility
            if (api_is_platform_admin() || api_is_course_admin()) {
                $course = api_get_course_info();
                $doc_id = DocumentManager::get_document_id($course, '/images/' . $pictureName);
                if (is_numeric($doc_id)) {
                    $images_folder_visibility = api_get_item_visibility($course, 'document', $doc_id, api_get_session_id());
                    if (!$images_folder_visibility) {
                        //This message is shown only to the course/platform admin if the image is set to visibility = false
                        Display::display_warning_message(get_lang('ChangeTheVisibilityOfTheCurrentImage'));
                    }
                }
            }
            $questionName = $objQuestionTmp->selectTitle();
            $questionDescription = $objQuestionTmp->selectDescription();
            if ($freeze) {
                echo "\n                    <script>\n                        \$(document).on('ready', function () {\n                            new " . ($answerType == HOT_SPOT ? "HotspotQuestion" : "DelineationQuestion") . "({\n                                questionId: {$questionId},\n                                exerciseId: {$exerciseId},\n                                selector: '#hotspot-preview-{$questionId}',\n                                for: 'preview'\n                            });\n                        });\n                    </script>\n                    <div id=\"hotspot-preview-{$questionId}\"></div>\n                ";
                return;
            }
            // Get the answers, make a list
            $objAnswerTmp = new Answer($questionId);
            $nbrAnswers = $objAnswerTmp->selectNbrAnswers();
            // get answers of hotpost
            $answers_hotspot = array();
            for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
                $answers = $objAnswerTmp->selectAnswerByAutoId($objAnswerTmp->selectAutoId($answerId));
                $answers_hotspot[$answers['id']] = $objAnswerTmp->selectAnswer($answerId);
            }
            $answerList = '';
            if ($answerType != HOT_SPOT_DELINEATION) {
                $answerList = '
                    <div class="well well-sm">
                        <h5 class="page-header">' . get_lang('HotspotZones') . '</h5>
                        <ol>
                ';
                if (!empty($answers_hotspot)) {
                    ksort($answers_hotspot);
                    $countAnswers = 1;
                    foreach ($answers_hotspot as $value) {
                        $answerList .= "<li><p>{$countAnswers} - {$value}</p></li>";
                        $countAnswers++;
                    }
                }
                $answerList .= '
                        </ol>
                    </div>
                ';
            }
            if (!$only_questions) {
                if ($show_title) {
                    TestCategory::displayCategoryAndTitle($objQuestionTmp->id);
                    echo '<div class="question_title">' . $current_item . '. ' . $questionName . '</div>';
                }
                //@todo I need to the get the feedback type
                echo <<<HOTSPOT
                    <input type="hidden" name="hidden_hotspot_id" value="{$questionId}" />
                    <div class="exercise_questions">
                        {$questionDescription}
                        <div class="row">
HOTSPOT;
            }
            $canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1');
            $s .= "\n                            <div class=\"col-sm-8 col-md-9\">\n                                <div class=\"hotspot-image\"></div>\n                                <script>\n                                    \$(document).on('ready', function () {\n                                        new " . ($answerType == HOT_SPOT_DELINEATION ? 'DelineationQuestion' : 'HotspotQuestion') . "({\n                                            questionId: {$questionId},\n                                            exerciseId: {$exe_id},\n                                            selector: '#question_div_' + {$questionId} + ' .hotspot-image',\n                                            for: 'user'\n                                        });\n                                    });\n                                </script>\n                            </div>\n                            <div class=\"col-sm-4 col-md-3\">\n                                {$answerList}\n                            </div>\n            ";
            echo <<<HOTSPOT
                            {$s}
                        </div>
                    </div>
HOTSPOT;
        }
        return $nbrAnswers;
    }
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:101,代码来源:exercise.lib.php

示例9: getFiles

 /**
  * Get all the files and directories of a relative path.
  * @param string $path relative path to be base path.
  * @return array of file and path information.
  * <code>array(0=>array('relative'=>'fullpath',...), 1=>array('filename'=>fileinfo array(),...)</code>
  * fileinfo array: <code>array('url'=>'full url',
  *                       'relative'=>'relative to base',
  *                        'fullpath'=>'full file path',
  *                        'image'=>imageInfo array() false if not image,
  *                        'stat' => filestat)</code>
  */
 function getFiles($path)
 {
     $files = array();
     $dirs = array();
     if (!$this->isValidBase()) {
         return array($files, $dirs);
     }
     $path = Files::fixPath($path);
     $base = Files::fixPath($this->getBaseDir());
     $fullpath = Files::makePath($base, $path);
     $d = @dir($fullpath);
     if (empty($d)) {
         $path = Files::fixPath('/');
         $base = Files::fixPath($this->getBaseDir());
         $fullpath = Files::makePath($base, $path);
         $d = @dir($fullpath);
     }
     $in_group = api_is_in_group();
     $user_id = api_get_user_id();
     // check templates files in bd
     $tbl_system_template = Database::get_main_table(TABLE_MAIN_SYSTEM_TEMPLATE);
     $sql = "SELECT image FROM {$tbl_system_template} ";
     $res = Database::query($sql);
     $files_templates = array();
     while ($row = Database::fetch_row($res)) {
         $files_templates[] = $row[0];
     }
     while (false !== ($entry = $d->read())) {
         if (in_array($entry, $files_templates)) {
             continue;
         }
         if (substr($entry, 0, 1) != '.' && strpos($entry, '_DELETED_') === false && strpos($entry, 'chat_files') === false && strpos($entry, 'css') === false && strpos($entry, 'HotPotatoes_files') === false && ($in_group || !$in_group && strpos($entry, '_groupdocs') === false)) {
             $is_dir = is_dir($fullpath . $entry);
             if ($is_dir) {
                 $dir_entry = Files::fixPath($fullpath . $entry);
                 /*
                 if (strpos($dir_entry, '/shared_folder/') !== false)
                 {
                 	if (!preg_match('/.*\/shared_folder\/$/', $dir_entry))
                 	{
                 		//all students can see the shared_folder
                 		if (strpos($dir_entry, '/shared_folder/sf_user_'.$user_id.'/') === true)
                 		{
                 			continue;
                 		}
                 	}
                 }
                 */
             }
             if ($is_dir && !$this->isThumbDir($entry)) {
                 global $_course;
                 if (isset($_course) && !empty($_course) && isset($_course['code'])) {
                     //checking visibility
                     $base_dir = substr($dir_entry, 0, strpos($dir_entry, '/document/') + 9);
                     $new_dir = substr($dir_entry, strlen($base_dir), -1);
                     //
                     $doc_id = DocumentManager::get_document_id($_course, $new_dir);
                     $visible_status = api_get_item_visibility($_course, TOOL_DOCUMENT, $doc_id);
                 }
                 //Teachers can access to hidden files and directories as they can in the tool documents
                 /*
                 if ($visible_status=='0' || $visible_status=='-1') {
                 	continue;
                 }
                 */
                 $relative = Files::fixPath($path . $entry);
                 $full = Files::fixPath($fullpath . $entry);
                 $count = $this->countFiles($full);
                 $dirs[$relative] = array('fullpath' => $full, 'entry' => $entry, 'count' => $count);
             } else {
                 if (is_file($fullpath . $entry) && !$this->isThumb($entry) && !$this->isTmpFile($entry)) {
                     $img = $this->getImageInfo($fullpath . $entry);
                     if (!(!is_array($img) && $this->config['validate_images'])) {
                         global $_course;
                         if (!empty($_course) && isset($_course['code'])) {
                             //checking visibility
                             $base_dir = substr($fullpath . $entry, 0, strpos($fullpath . $entry, '/document/') + 9);
                             $new_dir = substr($fullpath . $entry, strlen($base_dir));
                             $doc_id = DocumentManager::get_document_id($_course, $new_dir);
                             $visible_status = api_get_item_visibility($_course, TOOL_DOCUMENT, $doc_id);
                         }
                         //Teachers can access to hidden files and directories as they can in the tool documents
                         /*
                         if ($visible_status=='0' || $visible_status=='-1') {
                         	continue;
                         }
                         */
                         $file['url'] = Files::makePath($this->config['base_url'], $path) . $entry;
                         $file['relative'] = $path . $entry;
//.........这里部分代码省略.........
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:101,代码来源:ImageManager.php

示例10: substr

        $doc_url = substr($doc_url, 0, $dul);
    }
    //create the path
    $document_explorer = api_get_path(WEB_COURSE_PATH) . api_get_course_path();
    //redirect
    header('Location: ' . $document_explorer);
}
$tbl_forum_attachment = Database::get_course_table(TABLE_FORUM_ATTACHMENT);
$tbl_forum_post = Database::get_course_table(TABLE_FORUM_POST);
$course_id = api_get_course_int_id();
$courseInfo = api_get_course_info_by_id($course_id);
// launch event
Event::event_download($doc_url);
$sql = 'SELECT thread_id, forum_id,filename
        FROM ' . $tbl_forum_post . '  f
        INNER JOIN ' . $tbl_forum_attachment . ' a
        ON a.post_id=f.post_id
        WHERE
            f.c_id = ' . $course_id . ' AND
            a.c_id = ' . $course_id . ' AND
            path LIKE BINARY "' . $doc_url . '"';
$result = Database::query($sql);
$row = Database::fetch_array($result);
$forum_thread_visibility = api_get_item_visibility($courseInfo, TOOL_FORUM_THREAD, $row['thread_id'], api_get_session_id());
$forum_forum_visibility = api_get_item_visibility($courseInfo, TOOL_FORUM, $row['forum_id'], api_get_session_id());
if ($forum_thread_visibility == 1 && $forum_forum_visibility == 1) {
    if (Security::check_abs_path($full_file_name, api_get_path(SYS_COURSE_PATH) . $courseInfo['path'] . '/upload/forum/')) {
        DocumentManager::file_send_for_download($full_file_name, true, $row['filename']);
    }
}
exit;
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:download.php

示例11: getAnnouncements


//.........这里部分代码省略.........
                 } else {
                     $cond_user_id = " AND (\n                            ip.to_user_id = {$user_id} AND (ip.to_group_id IS NULL OR ip.to_group_id IN (0, " . $group_id . "))\n                        )";
                 }
             }
             $sql = "SELECT {$select}\n                        FROM {$tbl_announcement} announcement,\n                        {$tbl_item_property} ip\n                        WHERE\n                            announcement.c_id = {$course_id} AND\n                            ip.c_id = {$course_id} AND\n                            announcement.id = ip.ref\n                            AND ip.tool='announcement'\n                            {$cond_user_id}\n                            {$condition_session}\n                            {$searchCondition}\n                            AND ip.visibility='1'\n                        ORDER BY display_order DESC";
         } else {
             if ($user_id) {
                 if ($allowUserEditSetting && !api_is_anonymous()) {
                     $cond_user_id = " AND (\n                            ip.lastedit_user_id = '" . api_get_user_id() . "' OR\n                            (ip.to_user_id='" . $user_id . "' AND (ip.to_group_id='0' OR ip.to_group_id IS NULL))\n                        ) ";
                 } else {
                     $cond_user_id = " AND (ip.to_user_id='" . $user_id . "' AND (ip.to_group_id='0' OR ip.to_group_id IS NULL) ) ";
                 }
                 $sql = "SELECT {$select}\n\t\t\t\t\t\tFROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n\t\t\t\t\t\tWHERE\n    \t\t\t\t\t\tannouncement.c_id = {$course_id} AND\n\t\t\t\t\t\t\tip.c_id = {$course_id} AND\n    \t\t\t\t\t\tannouncement.id = ip.ref AND\n    \t\t\t\t\t\tip.tool='announcement'\n    \t\t\t\t\t\t{$cond_user_id}\n    \t\t\t\t\t\t{$condition_session}\n    \t\t\t\t\t\t{$searchCondition}\n    \t\t\t\t\t\tAND ip.visibility='1'\n    \t\t\t\t\t\tAND announcement.session_id IN(0, " . $session_id . ")\n\t\t\t\t\t\tORDER BY display_order DESC";
             } else {
                 if ($allowUserEditSetting && !api_is_anonymous()) {
                     $cond_user_id = " AND (\n                            ip.lastedit_user_id = '" . $user_id . "' OR ip.to_group_id='0' OR ip.to_group_id IS NULL\n                        )";
                 } else {
                     $cond_user_id = " AND ip.to_group_id='0' OR ip.to_group_id IS NULL ";
                 }
                 $sql = "SELECT {$select}\n\t\t\t\t\t\tFROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n\t\t\t\t\t\tWHERE\n                            announcement.c_id = {$course_id} AND\n                            ip.c_id = {$course_id} AND\n                            announcement.id = ip.ref AND\n                            ip.tool='announcement'\n                            {$cond_user_id}\n                            {$condition_session}\n                            {$searchCondition}\n                            AND\n                            ip.visibility='1' AND\n                            announcement.session_id IN ( 0," . api_get_session_id() . ")";
             }
         }
     }
     if (!is_null($start) && !is_null($limit)) {
         $start = intval($start);
         $limit = intval($limit);
         $sql .= " LIMIT {$start}, {$limit}";
     }
     $result = Database::query($sql);
     if ($getCount) {
         $result = Database::fetch_array($result, 'ASSOC');
         return $result['count'];
     }
     $iterator = 1;
     $bottomAnnouncement = $announcement_number;
     $origin = null;
     $displayed = [];
     $results = [];
     $actionUrl = api_get_path(WEB_CODE_PATH) . 'announcements/announcements.php?' . api_get_cidreq();
     while ($myrow = Database::fetch_array($result, 'ASSOC')) {
         if (!in_array($myrow['id'], $displayed)) {
             $sent_to_icon = '';
             // the email icon
             if ($myrow['email_sent'] == '1') {
                 $sent_to_icon = ' ' . Display::return_icon('email.gif', get_lang('AnnounceSentByEmail'));
             }
             $title = $myrow['title'] . $sent_to_icon;
             $item_visibility = api_get_item_visibility($_course, TOOL_ANNOUNCEMENT, $myrow['id'], $session_id);
             $myrow['visibility'] = $item_visibility;
             // show attachment list
             $attachment_list = AnnouncementManager::get_attachment($myrow['id']);
             $attachment_icon = '';
             if (count($attachment_list) > 0) {
                 $attachment_icon = ' ' . Display::return_icon('attachment.gif', get_lang('Attachment'));
             }
             /* TITLE */
             $user_info = api_get_user_info($myrow['insert_user_id']);
             $username = sprintf(get_lang("LoginX"), $user_info['username']);
             $username_span = Display::tag('span', api_get_person_name($user_info['firstName'], $user_info['lastName']), array('title' => $username));
             $title = Display::url($title . $attachment_icon, $actionUrl . '&action=view&id=' . $myrow['id']);
             //$html .= Display::tag('td', $username_span, array('class' => 'announcements-list-line-by-user'));
             //$html .= Display::tag('td', api_convert_and_format_date($myrow['insert_date'], DATE_TIME_FORMAT_LONG), array('class' => 'announcements-list-line-datetime'));
             $modify_icons = '';
             // we can edit if : we are the teacher OR the element belongs to
             // the session we are coaching OR the option to allow users to edit is on
             if (api_is_allowed_to_edit(false, true) || api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $myrow['id']) || api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) {
                 $modify_icons = "<a href=\"" . $actionUrl . "&action=modify&id=" . $myrow['id'] . "\">" . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "</a>";
                 if ($myrow['visibility'] == 1) {
                     $image_visibility = "visible";
                     $alt_visibility = get_lang('Hide');
                 } else {
                     $image_visibility = "invisible";
                     $alt_visibility = get_lang('Visible');
                 }
                 $modify_icons .= "<a href=\"" . $actionUrl . "&origin=" . $origin . "&action=showhide&id=" . $myrow['id'] . "&sec_token=" . $stok . "\">" . Display::return_icon($image_visibility . '.png', $alt_visibility, '', ICON_SIZE_SMALL) . "</a>";
                 // DISPLAY MOVE UP COMMAND only if it is not the top announcement
                 if ($iterator != 1) {
                     $modify_icons .= "<a href=\"" . $actionUrl . "&action=move&up=" . $myrow["id"] . "&sec_token=" . $stok . "\">" . Display::return_icon('up.gif', get_lang('Up')) . "</a>";
                 } else {
                     $modify_icons .= Display::return_icon('up_na.gif', get_lang('Up'));
                 }
                 if ($iterator < $bottomAnnouncement) {
                     $modify_icons .= "<a href=\"" . $actionUrl . "&action=move&down=" . $myrow["id"] . "&sec_token=" . $stok . "\">" . Display::return_icon('down.gif', get_lang('Down')) . "</a>";
                 } else {
                     $modify_icons .= Display::return_icon('down_na.gif', get_lang('Down'));
                 }
                 if (api_is_allowed_to_edit(false, true)) {
                     $modify_icons .= "<a href=\"" . $actionUrl . "&action=delete&id=" . $myrow['id'] . "&sec_token=" . $stok . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, api_get_system_encoding())) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . "</a>";
                 }
                 $iterator++;
             } else {
                 $modify_icons = Display::url(Display::return_icon('default.png'), $actionUrl . '&action=view&id=' . $myrow['id']);
             }
             $announcement = ['id' => $myrow["id"], 'title' => $title, 'username' => $username_span, 'insert_date' => api_convert_and_format_date($myrow['insert_date'], DATE_TIME_FORMAT_LONG), 'actions' => $modify_icons];
             $results[] = $announcement;
         }
         $displayed[] = $myrow['id'];
     }
     return $results;
 }
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:101,代码来源:AnnouncementManager.php

示例12: __construct

 /**
  * This method is the constructor for the learnpathList. It gets a list of available learning paths from
  * the database and creates the learnpath objects. This list depends on the user that is connected
  * (only displays) items if he has enough permissions to view them.
  * @param	integer		User ID
  * @param	string		Optional course code (otherwise we use api_get_course_id())
  * @param	int			Optional session id (otherwise we use api_get_session_id())
  * @return	void
  */
 function __construct($user_id, $course_code = null, $session_id = null, $order_by = null, $check_publication_dates = false, $filter_by_category = null)
 {
     $course_info = api_get_course_info($course_code);
     $lp_table = Database::get_course_table(TABLE_LP_MAIN);
     $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
     $this->course_code = $course_code;
     $this->user_id = $user_id;
     $course_id = $course_info['real_id'];
     if (empty($course_id)) {
         return false;
     }
     // Condition for the session.
     if (isset($session_id)) {
         $session_id = intval($session_id);
     } else {
         $session_id = api_get_session_id();
     }
     $condition_session = api_get_session_condition($session_id, true, true);
     $order = "ORDER BY display_order ASC, name ASC";
     if (isset($order_by)) {
         $order = Database::parse_conditions(array('order' => $order_by));
     }
     $now = api_get_utc_datetime();
     $time_conditions = '';
     if ($check_publication_dates) {
         $time_conditions = " AND (\n                (publicated_on <> '0000-00-00 00:00:00' AND publicated_on < '{$now}'  AND expired_on <> '0000-00-00 00:00:00'  AND expired_on > '{$now}' )  OR\n                (publicated_on <> '0000-00-00 00:00:00'  AND publicated_on < '{$now}'  AND expired_on = '0000-00-00 00:00:00') OR\n                (publicated_on = '0000-00-00 00:00:00'   AND expired_on <> '0000-00-00 00:00:00' AND expired_on > '{$now}') OR\n                (publicated_on = '0000-00-00 00:00:00'   AND expired_on = '0000-00-00 00:00:00' )\n            )";
     }
     $category_filter = null;
     if (isset($filter_by_category)) {
         $filter_by_category = intval($filter_by_category);
         $category_filter = " AND category_id = {$filter_by_category}";
     }
     $sql = "SELECT * FROM {$lp_table} WHERE c_id = {$course_id} {$time_conditions} {$condition_session} {$category_filter} {$order}";
     $res = Database::query($sql);
     $names = array();
     while ($row = Database::fetch_array($res, 'ASSOC')) {
         // Check if published.
         $pub = '';
         // Use domesticate here instead of Database::escape_string because
         // it prevents ' to be slashed and the input (done by learnpath.class.php::toggle_visibility())
         // is done using domesticate()
         $myname = Text::domesticate($row['name']);
         $mylink = 'newscorm/lp_controller.php?action=view&lp_id=' . $row['id'] . '&id_session=' . $session_id;
         $sql2 = "SELECT * FROM {$tbl_tool} WHERE c_id = {$course_id} AND (name='{$myname}' and image='scormbuilder.gif' and link LIKE '{$mylink}%')";
         //error_log('New LP - learnpathList::__construct - getting visibility - '.$sql2, 0);
         $res2 = Database::query($sql2);
         if (Database::num_rows($res2) > 0) {
             $row2 = Database::fetch_array($res2);
             $pub = $row2['visibility'];
         } else {
             $pub = 'i';
         }
         // Check if visible
         $vis = api_get_item_visibility(api_get_course_info($course_code), 'learnpath', $row['id'], $session_id);
         if (!empty($row['created_on']) && $row['created_on'] != '0000-00-00 00:00:00') {
             $row['created_on'] = $row['created_on'];
         } else {
             $row['created_on'] = '';
         }
         if (!empty($row['modified_on']) && $row['modified_on'] != '0000-00-00 00:00:00') {
             $row['modified_on'] = $row['modified_on'];
         } else {
             $row['modified_on'] = '';
         }
         if (!empty($row['publicated_on']) && $row['publicated_on'] != '0000-00-00 00:00:00') {
             $row['publicated_on'] = $row['publicated_on'];
         } else {
             $row['publicated_on'] = '';
         }
         if (!empty($row['expired_on']) && $row['expired_on'] != '0000-00-00 00:00:00') {
             $row['expired_on'] = $row['expired_on'];
         } else {
             $row['expired_on'] = '';
         }
         //@todo user LP object
         $this->list[$row['id']] = array('lp_type' => $row['lp_type'], 'lp_session' => $row['session_id'], 'lp_name' => stripslashes($row['name']), 'lp_desc' => stripslashes($row['description']), 'lp_path' => $row['path'], 'lp_view_mode' => $row['default_view_mod'], 'lp_force_commit' => $row['force_commit'], 'lp_maker' => stripslashes($row['content_maker']), 'lp_proximity' => $row['content_local'], 'lp_encoding' => api_get_system_encoding(), 'lp_visibility' => $vis, 'lp_published' => $pub, 'lp_prevent_reinit' => $row['prevent_reinit'], 'seriousgame_mode' => $row['seriousgame_mode'], 'lp_scorm_debug' => $row['debug'], 'lp_display_order' => $row['display_order'], 'lp_preview_image' => stripslashes($row['preview_image']), 'autolaunch' => $row['autolunch'], 'session_id' => $row['session_id'], 'created_on' => $row['created_on'], 'modified_on' => $row['modified_on'], 'publicated_on' => $row['publicated_on'], 'expired_on' => $row['expired_on'], 'category_id' => $row['category_id'], 'subscribe_users' => $row['subscribe_users']);
         $names[$row['name']] = $row['id'];
     }
     $this->alpha_list = asort($names);
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:89,代码来源:learnpathList.class.php

示例13: protectWork

/**
 * @param array $courseInfo
 * @param int $workId
 * @return bool
 */
function protectWork($courseInfo, $workId)
{
    $userId = api_get_user_id();
    $groupId = api_get_group_id();
    $sessionId = api_get_session_id();
    $workData = get_work_data_by_id($workId);
    if (empty($workData) || empty($courseInfo)) {
        api_not_allowed(true);
    }
    if (api_is_platform_admin() || api_is_allowed_to_edit()) {
        return true;
    }
    $workId = $workData['id'];
    if ($workData['active'] != 1) {
        api_not_allowed(true);
    }
    $visibility = api_get_item_visibility($courseInfo, 'work', $workId, $sessionId);
    if ($visibility != 1) {
        api_not_allowed(true);
    }
    allowOnlySubscribedUser($userId, $workId, $courseInfo['real_id']);
    if (!empty($groupId)) {
        $showWork = GroupManager::user_has_access($userId, $groupId, GroupManager::GROUP_TOOL_WORK);
        if (!$showWork) {
            api_not_allowed(true);
        }
    }
}
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:33,代码来源:work.lib.php

示例14: api_get_item_visibility

             $number_of_questions = $random_number_of_question . ' ' . $random_label;
             //Bug if we set a random value bigger than the real number of questions
             if ($random_number_of_question > $rowi) {
                 $number_of_questions = $rowi . ' ' . $random_label;
             }
         }
     } else {
         $number_of_questions = $rowi;
     }
     //Attempts
     //$attempts = ExerciseLib::get_count_exam_results($row['id']).' '.get_lang('Attempts');
     //$item .=  Display::tag('td',$attempts);
     $item .= Display::tag('td', $number_of_questions);
 } else {
     // Student only.
     $visibility = api_get_item_visibility($courseInfo, TOOL_QUIZ, $my_exercise_id, $sessionId);
     if ($visibility == 0) {
         continue;
     }
     $url = '<a ' . $alt_title . '  href="overview.php?' . api_get_cidreq() . $myorigin . $mylpid . $mylpitemid . '&exerciseId=' . $row['id'] . '">' . $cut_title . '</a>';
     // Link of the exercise.
     $item = Display::tag('td', $url . ' ' . $session_img);
     // Count number exercise questions.
     /*$sql = "SELECT count(*) FROM $TBL_EXERCISE_QUESTION
                             WHERE c_id = $courseId AND exercice_id = ".$row['id'];
                     $sqlresult = Database::query($sql);
                     $rowi = Database::result($sqlresult, 0);
     
                     if ($row['random'] > 0) {
                         $row['random'].' '.api_strtolower(get_lang(($row['random'] > 1 ? 'Questions' : 'Question')));
                     } else {
开发者ID:daffef,项目名称:chamilo-lms,代码行数:31,代码来源:exercise.php

示例15: showQuestion


//.........这里部分代码省略.........
                if ($answerType == MATCHING || $answerType == UNIQUE_ANSWER_NO_OPTION || $answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
                    $s .= '</table>';
                }
            }
            if ($answerType == DRAGGABLE) {
                $s .= '</ul><div class="clear"></div>';
                $counterAnswer = 1;
                foreach ($objAnswerTmp->answer as $answerId => $answer_item) {
                    $answerCorrect = $objAnswerTmp->isCorrect($answerId);
                    $windowId = $questionId . '_' . $counterAnswer;
                    if ($answerCorrect == 0) {
                        $s .= '<div id="drop_' . $windowId . '" class="droppable ui-state-default">' . $counterAnswer . '</div>';
                        $counterAnswer++;
                    }
                }
            }
            if ($answerType == MATCHING) {
                $s .= '</div>';
            }
            $s .= '</div>';
            // destruction of the Answer object
            unset($objAnswerTmp);
            // destruction of the Question object
            unset($objQuestionTmp);
            $html .= $s;
            return $html;
        } elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) {
            // Question is a HOT_SPOT
            //checking document/images visibility
            if (api_is_platform_admin() || api_is_course_admin()) {
                $course = api_get_course_info();
                $doc_id = DocumentManager::get_document_id($course, '/images/' . $pictureName);
                if (is_numeric($doc_id)) {
                    $images_folder_visibility = api_get_item_visibility($course, 'document', $doc_id, api_get_session_id());
                    if (!$images_folder_visibility) {
                        //This message is shown only to the course/platform admin if the image is set to visibility = false
                        Display::display_warning_message(get_lang('ChangeTheVisibilityOfTheCurrentImage'));
                    }
                }
            }
            $questionName = $objQuestionTmp->selectTitle();
            $questionDescription = $objQuestionTmp->selectDescription();
            if ($freeze) {
                $s .= Display::img($objQuestionTmp->selectPicturePath());
                $html .= $s;
                return $html;
            }
            // Get the answers, make a list
            $objAnswerTmp = new Answer($questionId);
            // get answers of hotpost
            $answers_hotspot = array();
            foreach ($objAnswerTmp->answer as $answerId => $answer_item) {
                //$answers = $objAnswerTmp->selectAnswerByAutoId($objAnswerTmp->selectAutoId($answerId));
                $answers_hotspot[$answerId] = $objAnswerTmp->selectAnswer($answerId);
            }
            // display answers of hotpost order by id
            $answer_list = '<div style="padding: 10px; margin-left: 0px; border: 1px solid #A4A4A4; height: 408px; width: 200px;"><b>' . get_lang('HotspotZones') . '</b><dl>';
            if (!empty($answers_hotspot)) {
                ksort($answers_hotspot);
                foreach ($answers_hotspot as $key => $value) {
                    $answer_list .= '<dt>' . $key . '.- ' . $value . '</dt><br />';
                }
            }
            $answer_list .= '</dl></div>';
            if ($answerType == HOT_SPOT_DELINEATION) {
                $answer_list = '';
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:67,代码来源:exercise.class.php


注:本文中的api_get_item_visibility函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。