コード例 #1
0
<?php

/* For licensing terms, see /license.txt */
/**
	@author Julio Montoya <*****@*****.**> BeezNest 2012
*	@package chamilo.admin
*/
// name of the language file that needs to be included
$language_file = array('registration', 'admin');
$cidReset = true;
require_once '../inc/global.inc.php';
// Access restrictions
api_protect_admin_script();
$plugin_name = $_GET['name'];
$plugin_obj = new AppPlugin();
$plugin_info = $plugin_obj->getPluginInfo($plugin_name, true);
if (empty($plugin_info)) {
    api_not_allowed();
}
$installed_plugins = $plugin_obj->get_installed_plugins();
if (!in_array($plugin_name, $installed_plugins)) {
    api_not_allowed();
}
global $_configuration;
$message = null;
$content = null;
if (isset($plugin_info['settings_form'])) {
    $form = $plugin_info['settings_form'];
    if (isset($form)) {
        //We override the form attributes
        $attributes = array('action' => api_get_self() . '?name=' . $plugin_name, 'method' => 'POST');
コード例 #2
0
 /**
  * Displays the tools of a certain category.
  * @param array $all_tools_list List of tools as returned by get_tools_category()
  * @param bool  $rows
  *
  * @return void
  */
 public static function show_tools_category($all_tools_list, $rows = false)
 {
     $_user = api_get_user_info();
     $theme = api_get_setting('homepage_view');
     if ($theme == 'vertical_activity') {
         //ordering by get_lang name
         $order_tool_list = array();
         if (is_array($all_tools_list) && count($all_tools_list) > 0) {
             foreach ($all_tools_list as $key => $new_tool) {
                 $tool_name = self::translate_tool_name($new_tool);
                 $order_tool_list[$key] = $tool_name;
             }
             natsort($order_tool_list);
             $my_temp_tool_array = array();
             foreach ($order_tool_list as $key => $new_tool) {
                 $my_temp_tool_array[] = $all_tools_list[$key];
             }
             $all_tools_list = $my_temp_tool_array;
         } else {
             $all_tools_list = array();
         }
     }
     $web_code_path = api_get_path(WEB_CODE_PATH);
     $session_id = api_get_session_id();
     $is_platform_admin = api_is_platform_admin();
     if ($session_id == 0) {
         $is_allowed_to_edit = api_is_allowed_to_edit(null, true) && api_is_course_admin();
     } else {
         $is_allowed_to_edit = api_is_allowed_to_edit(null, true) && !api_is_coach();
     }
     $i = 0;
     $items = array();
     $app_plugin = new AppPlugin();
     if (isset($all_tools_list)) {
         $lnk = '';
         foreach ($all_tools_list as &$tool) {
             $item = array();
             $studentview = false;
             $tool['original_link'] = $tool['link'];
             if ($tool['image'] == 'scormbuilder.gif') {
                 // check if the published learnpath is visible for student
                 $published_lp_id = self::get_published_lp_id_from_link($tool['link']);
                 if (api_is_allowed_to_edit(null, true)) {
                     $studentview = true;
                 }
                 if (!api_is_allowed_to_edit(null, true) && !learnpath::is_lp_visible_for_student($published_lp_id, api_get_user_id(), api_get_course_id(), api_get_session_id())) {
                     continue;
                 }
             }
             if ($session_id != 0 && in_array($tool['name'], array('course_setting'))) {
                 continue;
             }
             // This part displays the links to hide or remove a tool.
             // These links are only visible by the course manager.
             unset($lnk);
             $item['extra'] = null;
             $toolAdmin = isset($tool['admin']) ? $tool['admin'] : '';
             if ($is_allowed_to_edit) {
                 if (empty($session_id)) {
                     if (isset($tool['id'])) {
                         if ($tool['visibility'] == '1' && $toolAdmin != '1') {
                             $link['name'] = Display::return_icon('visible.png', get_lang('Deactivate'), array('id' => 'linktool_' . $tool['id']), ICON_SIZE_SMALL, false);
                             $link['cmd'] = 'hide=yes';
                             $lnk[] = $link;
                         }
                         if ($tool['visibility'] == '0' && $toolAdmin != '1') {
                             $link['name'] = Display::return_icon('invisible.png', get_lang('Activate'), array('id' => 'linktool_' . $tool['id']), ICON_SIZE_SMALL, false);
                             $link['cmd'] = 'restore=yes';
                             $lnk[] = $link;
                         }
                     }
                 }
                 if (!empty($tool['adminlink'])) {
                     $item['extra'] = '<a href="' . $tool['adminlink'] . '">' . Display::return_icon('edit.gif', get_lang('Edit')) . '</a>';
                 }
             }
             // Both checks are necessary as is_platform_admin doesn't take student view into account
             if ($is_platform_admin && $is_allowed_to_edit) {
                 if ($toolAdmin != '1') {
                     $link['cmd'] = 'hide=yes';
                 }
             }
             $item['visibility'] = null;
             if (isset($lnk) && is_array($lnk)) {
                 foreach ($lnk as $this_link) {
                     if (empty($tool['adminlink'])) {
                         $item['visibility'] .= '<a class="make_visible_and_invisible" href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;id=' . $tool['id'] . '&amp;' . $this_link['cmd'] . '">' . $this_link['name'] . '</a>';
                     }
                 }
             } else {
                 $item['visibility'] .= '';
             }
             // NOTE : Table contains only the image file name, not full path
             if (stripos($tool['link'], 'http://') === false && stripos($tool['link'], 'https://') === false && stripos($tool['link'], 'ftp://') === false) {
                 $tool['link'] = $web_code_path . $tool['link'];
             }
             if ($tool['visibility'] == '0' && $toolAdmin != '1' && !isset($tool['original_link'])) {
                 $class = 'invisible';
                 $info = pathinfo($tool['image']);
                 $basename = basename($tool['image'], '.' . $info['extension']);
                 // $file is set to "index"
                 $tool['image'] = $basename . '_na.' . $info['extension'];
             } else {
                 $class = '';
             }
             $qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&';
             // If it's a link, we don't add the cidReq
             if ($tool['image'] == 'file_html.png' || $tool['image'] == 'file_html_na.png') {
                 $tool['link'] = $tool['link'] . $qm_or_amp;
             } else {
                 $tool['link'] = $tool['link'] . $qm_or_amp . api_get_cidreq();
             }
             $tool_link_params = array();
             $toolId = isset($tool["id"]) ? $tool["id"] : null;
             //@todo this visio stuff should be removed
             if (strpos($tool['name'], 'visio_') !== false) {
                 $tool_link_params = array('id' => 'tooldesc_' . $toolId, 'href' => '"javascript: void(0);"', 'class' => $class, 'onclick' => 'javascript: window.open(\'' . $tool['link'] . '\',\'window_visio' . $_SESSION['_cid'] . '\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')', 'target' => $tool['target']);
             } elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) {
                 $tool_link_params = array('id' => 'tooldesc_' . $toolId, 'class' => $class, 'href' => 'javascript: void(0);', 'onclick' => 'javascript: window.open(\'' . $tool['link'] . '\',\'window_chat' . $_SESSION['_cid'] . '\',config=\'height=\'+600+\', width=\'+825+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')', 'target' => $tool['target']);
             } else {
                 if (count(explode('type=classroom', $tool['link'])) == 2 || count(explode('type=conference', $tool['link'])) == 2) {
                     $tool_link_params = array('id' => 'tooldesc_' . $toolId, 'href' => $tool['link'], 'class' => $class, 'target' => '_blank');
                 } else {
                     $tool_link_params = array('id' => 'tooldesc_' . $toolId, 'href' => $tool['link'], 'class' => $class, 'target' => $tool['target']);
                 }
             }
             $tool_name = self::translate_tool_name($tool);
             // Including Courses Plugins
             // Creating title and the link
             if (isset($tool['category']) && $tool['category'] == 'plugin') {
                 $plugin_info = $app_plugin->getPluginInfo($tool['name']);
                 if (isset($plugin_info) && isset($plugin_info['title'])) {
                     $tool_name = $plugin_info['title'];
                 }
                 if (!file_exists(api_get_path(SYS_CODE_PATH) . 'img/' . $tool['image']) && !file_exists(api_get_path(SYS_CODE_PATH) . 'img/icons/22/' . $tool['image'])) {
                     $tool['image'] = 'plugins.png';
                 }
                 $tool_link_params['href'] = api_get_path(WEB_PLUGIN_PATH) . $tool['original_link'] . '?' . api_get_cidreq();
             }
             $icon = Display::return_icon($tool['image'], $tool_name, array('class' => 'tool-icon', 'id' => 'toolimage_' . $toolId), ICON_SIZE_BIG, false);
             /*if (!empty($tool['custom_icon'])) {
                   $image = self::getCustomWebIconPath().$tool['custom_icon'];
                   $icon = Display::img(
                       $image,
                       $tool['description'],
                       array(
                           'class' => 'tool-icon',
                           'id' => 'toolimage_'.$tool['id']
                       )
                   );
               }*/
             // Validation when belongs to a session
             $session_img = api_get_session_image($tool['session_id'], !empty($_user['status']) ? $_user['status'] : '');
             if ($studentview) {
                 $tool_link_params['href'] .= '&isStudentView=true';
             }
             $item['url_params'] = $tool_link_params;
             $item['icon'] = Display::url($icon, $tool_link_params['href'], $tool_link_params);
             $item['tool'] = $tool;
             $item['name'] = $tool_name;
             $tool_link_params['id'] = 'is' . $tool_link_params['id'];
             $item['link'] = Display::url($tool_name . $session_img, $tool_link_params['href'], $tool_link_params);
             $items[] = $item;
             $i++;
         }
         // end of foreach
     }
     $i = 0;
     $html = '';
     if (!empty($items)) {
         foreach ($items as $item) {
             switch ($theme) {
                 case 'activity_big':
                     $data = '';
                     $html .= '<div class="col-xs-6 col-md-3 course-tool">';
                     $image = substr($item['tool']['image'], 0, strpos($item['tool']['image'], '.')) . '.png';
                     $toolId = isset($item['tool']['id']) ? $item['tool']['id'] : null;
                     if (isset($item['tool']['custom_image'])) {
                         $original_image = Display::img($item['tool']['custom_image'], $item['name'], array('id' => 'toolimage_' . $toolId));
                     } elseif (isset($item['tool']['custom_icon']) && !empty($item['tool']['custom_icon'])) {
                         $customIcon = $item['tool']['custom_icon'];
                         if ($item['tool']['visibility'] == '0') {
                             $fileInfo = pathinfo($item['tool']['custom_icon']);
                             $customIcon = self::getDisableIcon($item['tool']['custom_icon']);
                         }
                         $original_image = Display::img(self::getCustomWebIconPath() . $customIcon, $item['name'], array('id' => 'toolimage_' . $toolId));
                     } else {
                         $original_image = Display::return_icon($image, $item['name'], array('id' => 'toolimage_' . $toolId), ICON_SIZE_BIG, false);
                     }
                     $data .= Display::url($original_image, $item['url_params']['href'], $item['url_params']);
                     $html .= Display::div($data, array('class' => 'big_icon'));
                     //box-image reflection
                     $html .= Display::div('<h4>' . $item['visibility'] . $item['extra'] . $item['link'] . '</h4>', array('class' => 'content'));
                     $html .= '</div>';
                     break;
                 case 'activity':
                     $html .= '<div class="offset2 col-md-4 course-tool">';
                     $html .= $item['extra'];
                     $html .= $item['visibility'];
                     $html .= $item['icon'];
                     $html .= $item['link'];
                     $html .= '</div>';
                     break;
                 case 'vertical_activity':
                     if ($i == 0) {
                         $html .= '<ul>';
                     }
                     $html .= '<li class="course-tool">';
                     $html .= $item['extra'];
                     $html .= $item['visibility'];
                     $html .= $item['icon'];
                     $html .= $item['link'];
                     $html .= '</li>';
                     if ($i == count($items) - 1) {
                         $html .= '</ul>';
                     }
                     break;
             }
             $i++;
         }
     }
     return $html;
 }
コード例 #3
0
/* For licensing terms, see /license.txt */
/**
 * @author Julio Montoya <*****@*****.**> BeezNest 2012
 * @author Angel Fernando Quiroz Campos <*****@*****.**>
 * @package chamilo.admin
 */
use ChamiloSession as Session;
$cidReset = true;
//require_once '../inc/global.inc.php';
// Access restrictions
api_protect_admin_script();
$pluginName = $_GET['name'];
$appPlugin = new AppPlugin();
$installedPlugins = $appPlugin->get_installed_plugins();
$pluginInfo = $appPlugin->getPluginInfo($pluginName, true);
if (!in_array($pluginName, $installedPlugins) || empty($pluginInfo)) {
    api_not_allowed(true);
}
$message = null;
$content = null;
$currentUrl = api_get_self() . "?name={$pluginName}";
if (isset($pluginInfo['settings_form'])) {
    $form = $pluginInfo['settings_form'];
    if (isset($form)) {
        //We override the form attributes
        $attributes = array('action' => $currentUrl, 'method' => 'POST');
        $form->updateAttributes($attributes);
        $content = Display::page_header($pluginInfo['title']);
        $content .= $form->toHtml();
    }