コード例 #1
0
ファイル: gradebook.php プロジェクト: secuencia24/chamilo-lms
                break;
            case 'setinvisible':
                foreach ($_POST['id'] as $indexstr) {
                    if (api_substr($indexstr, 0, 4) == 'CATE') {
                        $cats = Category::load(api_substr($indexstr, 4));
                        $cats[0]->set_visible(0);
                        $cats[0]->save();
                        $cats[0]->apply_visibility_to_children();
                    }
                    if (api_substr($indexstr, 0, 4) == 'EVAL') {
                        $eval = Evaluation::load(api_substr($indexstr, 4));
                        $eval[0]->set_visible(0);
                        $eval[0]->save();
                    }
                    if (api_substr($indexstr, 0, 4) == 'LINK') {
                        $link = LinkFactory::load(api_substr($indexstr, 4));
                        $link[0]->set_visible(0);
                        $link[0]->save();
                    }
                }
                $confirmation_message = get_lang('ItemsInVisible');
                $filter_confirm_msg = false;
                break;
        }
    }
}
if (isset($_POST['submit']) && isset($_POST['keyword'])) {
    header('Location: ' . api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&search=' . Security::remove_XSS($_POST['keyword']));
    exit;
}
// DISPLAY HEADERS AND MESSAGES                           -
コード例 #2
0
/* For licensing terms, see /license.txt */
/**
 * Script
 * @package chamilo.gradebook
 */
//$cidReset = true;
require_once '../inc/global.inc.php';
api_block_anonymous_users();
GradebookUtils::block_students();
$tbl_grade_links = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
//selected name of database
$course_id = GradebookUtils::get_course_id_by_link_id($_GET['editlink']);
$tbl_forum_thread = Database::get_course_table(TABLE_FORUM_THREAD);
$tbl_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
$linkarray = LinkFactory::load($_GET['editlink']);
$link = $linkarray[0];
if ($link->is_locked() && !api_is_platform_admin()) {
    api_not_allowed();
}
$linkcat = isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']) : '';
$linkedit = isset($_GET['editlink']) ? Security::remove_XSS($_GET['editlink']) : '';
$session_id = api_get_session_id();
if ($session_id == 0) {
    $cats = Category::load(null, null, $course_code, null, null, $session_id, false);
    //already init
} else {
    $cats = Category::load_session_categories(null, $session_id);
}
$form = new LinkAddEditForm(LinkAddEditForm::TYPE_EDIT, $cats, null, $link, 'edit_link_form', api_get_self() . '?selectcat=' . $linkcat . '&editlink=' . $linkedit . '&' . api_get_cidreq());
if ($form->validate()) {
コード例 #3
0
ファイル: learnpath.class.php プロジェクト: Eidn/shanghai
 /**
  * Static admin function allowing removal of a learnpath
  * @param	string	Course code
  * @param	integer	Learnpath ID
  * @param	string	Whether to delete data or keep it (default: 'keep', others: 'remove')
  * @return	boolean	True on success, false on failure (might change that to return number of elements deleted)
  */
 function delete($course = null, $id = null, $delete = 'keep')
 {
     //TODO implement a way of getting this to work when the current object is not set
     //In clear: implement this in the item class as well (abstract class) and use the given ID in queries
     //if(empty($course)){$course = api_get_course_id();}
     //if(empty($id)){$id = $this->get_id();}
     //If an ID is specifically given and the current LP is not the same,
     //prevent delete
     if (!empty($id) && $id != $this->lp_id) {
         return false;
     }
     $lp = Database::get_course_table(TABLE_LP_MAIN);
     $lp_item = Database::get_course_table(TABLE_LP_ITEM);
     // Proposed by Christophe (clefevre), see below.
     $lp_view = Database::get_course_table(TABLE_LP_VIEW);
     $lp_item_view = Database::get_course_table(TABLE_LP_ITEM_VIEW);
     //if($this->debug>0){error_log('New LP - In learnpath::delete()',0);}
     //delete lp item id
     foreach ($this->items as $id => $dummy) {
         //$this->items[$id]->delete();
         $sql_del_view = "DELETE FROM {$lp_item_view} WHERE lp_item_id = '" . $id . "'";
         $res_del_item_view = Database::query($sql_del_view, __FILE__, __LINE__);
     }
     // Proposed by Christophe (nickname: clefevre), see http://www.dokeos.com/forum/viewtopic.php?t=29673
     $sql_del_item = "DELETE FROM {$lp_item} WHERE lp_id = " . $this->lp_id;
     $res_del_item = Database::query($sql_del_item, __FILE__, __LINE__);
     $sql_del_view = "DELETE FROM {$lp_view} WHERE lp_id = " . $this->lp_id;
     //if($this->debug>2){error_log('New LP - Deleting views bound to lp '.$this->lp_id.': '.$sql_del_view,0);}
     $res_del_view = Database::query($sql_del_view, __FILE__, __LINE__);
     $this->toggle_publish($this->lp_id, 'i');
     //if($this->debug>2){error_log('New LP - Deleting lp '.$this->lp_id.' of type '.$this->type,0);}
     if ($this->type == 2 or $this->type == 3) {
         //this is a scorm learning path, delete the files as well
         $sql = "SELECT path FROM {$lp} WHERE id = " . $this->lp_id;
         $res = Database::query($sql, __FILE__, __LINE__);
         if (Database::num_rows($res) > 0) {
             $row = Database::fetch_array($res);
             $path = $row['path'];
             $sql = "SELECT id FROM {$lp} WHERE path = '{$path}' AND id != " . $this->lp_id;
             $res = Database::query($sql, __FILE__, __LINE__);
             if (Database::num_rows($res) > 0) {
                 //another learning path uses this directory, so don't delete it
                 if ($this->debug > 2) {
                     error_log('New LP - In learnpath::delete(), found other LP using path ' . $path . ', keeping directory', 0);
                 }
             } else {
                 //no other LP uses that directory, delete it
                 $course_rel_dir = api_get_course_path() . '/scorm/';
                 //scorm dir web path starting from /courses
                 $course_scorm_dir = api_get_path(SYS_COURSE_PATH) . $course_rel_dir;
                 //absolute system path for this course
                 if ($delete == 'remove' && is_dir($course_scorm_dir . $path) and !empty($course_scorm_dir)) {
                     if ($this->debug > 2) {
                         error_log('New LP - In learnpath::delete(), found SCORM, deleting directory: ' . $course_scorm_dir . $path, 0);
                     }
                     // Proposed by Christophe (clefevre).
                     if (strcmp(substr($path, -2), "/.") == 0) {
                         $path = substr($path, 0, -1);
                         // Remove "." at the end
                     }
                     //exec('rm -rf ' . $course_scorm_dir . $path); // See Bug #5208, this is not OS-portable way.
                     rmdirr($course_scorm_dir . $path);
                 }
             }
         }
     }
     $sql_del_lp = "DELETE FROM {$lp} WHERE id = " . $this->lp_id;
     //if($this->debug>2){error_log('New LP - Deleting lp '.$this->lp_id.': '.$sql_del_lp,0);}
     $res_del_lp = Database::query($sql_del_lp, __FILE__, __LINE__);
     $this->update_display_order();
     //updates the display order of all lps
     api_item_property_update(api_get_course_info(), TOOL_LEARNPATH, $this->lp_id, 'delete', api_get_user_id());
     require_once '../gradebook/lib/be.inc.php';
     $tbl_grade_link = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
     //delete link of gradebook tool
     $sql = 'SELECT gl.id FROM ' . $tbl_grade_link . ' gl WHERE gl.type="4" AND gl.ref_id="' . $id . '";';
     $result = Database::query($sql, __FILE__, __LINE__);
     $row = Database::fetch_array($result, 'ASSOC');
     //fixing gradebook link deleted see #5229
     if (!empty($row['id'])) {
         $link = LinkFactory::load($row['id']);
         if ($link[0] != null) {
             $link[0]->delete();
         }
     }
     //TODO: also delete items and item-views
     if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
         require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
         $r = delete_all_values_for_item($this->cc, TOOL_LEARNPATH, $this->lp_id);
     }
 }
コード例 #4
0
 /**
  * Get appropriate links visible for the user
  * @param int $stud_id student id (default: all students)
  * @param boolean $recursive process subcategories (default: no recursion)
  */
 public function get_links($stud_id = null, $recursive = false, $course_code = '')
 {
     $links = array();
     if (empty($course_code)) {
         $course_code = api_get_course_id();
     }
     // no links in root or course independent categories
     if ($this->id == 0) {
     } elseif (isset($stud_id)) {
         // 1 student $stud_id
         $links = LinkFactory::load(null, null, null, null, empty($this->course_code) ? null : $course_code, $this->id, api_is_allowed_to_edit() ? null : 1);
     } elseif (api_is_allowed_to_edit() || api_is_drh() || api_is_session_admin()) {
         // all students -> only for course/platform admin
         $links = LinkFactory::load(null, null, null, null, empty($this->course_code) ? null : $this->course_code, $this->id, null);
     }
     if ($recursive) {
         $subcats = $this->get_subcategories($stud_id, $course_code);
         if (!empty($subcats)) {
             foreach ($subcats as $subcat) {
                 $sublinks = $subcat->get_links($stud_id, false, $course_code);
                 $links = array_merge($links, $sublinks);
             }
         }
     }
     return $links;
 }