Пример #1
0
/**
 * Get the classes to display on the current page.
 */
function get_class_data($from, $number_of_items, $column, $direction)
{
    $class_table = Database::get_main_table(TABLE_MAIN_CLASS);
    $class_user_table = Database::get_main_table(TABLE_MAIN_CLASS_USER);
    $courseId = api_get_course_int_id();
    $em = Database::getManager();
    $res = $em->getRepository('ChamiloCoreBundle:CourseRelClass')->findBy(['courseId' => $courseId]);
    $subscribed_classes = array();
    foreach ($res as $obj) {
        $subscribed_classes[] = $obj->getClassId();
    }
    $sql = "SELECT\n                c.id AS col0,\n                c.name   AS col1,\n                COUNT(cu.user_id) AS col2,\n                c.id AS col3\n            FROM {$class_table} c ";
    $sql .= " LEFT JOIN {$class_user_table} cu ON cu.class_id = c.id";
    $sql .= " WHERE 1 = 1";
    if (isset($_GET['keyword'])) {
        $keyword = Database::escape_string(trim($_GET['keyword']));
        $sql .= " AND (c.name LIKE '%" . $keyword . "%')";
    }
    if (count($subscribed_classes) > 0) {
        $sql .= " AND c.id NOT IN ('" . implode("','", $subscribed_classes) . "')";
    }
    $sql .= " GROUP BY c.id, c.name ";
    $sql .= " ORDER BY col{$column} {$direction} ";
    $sql .= " LIMIT {$from},{$number_of_items}";
    $res = Database::query($sql);
    $classes = array();
    while ($class = Database::fetch_row($res)) {
        $classes[] = $class;
    }
    return $classes;
}
 /**
  * Search users by username, firstname or lastname, based on the given
  * search string
  * @param string Search string
  * @param int Deprecated param
  * @return string Xajax response block
  * @assert () === false
  */
 function search_users($needle, $id)
 {
     $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
     $xajax_response = new xajaxResponse();
     $return = '';
     if (!empty($needle)) {
         // xajax send utf8 datas... datas in db can be non-utf8 datas
         $charset = api_get_system_encoding();
         $needle = api_convert_encoding($needle, $charset, 'utf-8');
         $needle = Database::escape_string($needle);
         // search users where username or firstname or lastname begins likes $needle
         $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
         $sql = 'SELECT u.user_id, username, lastname, firstname FROM ' . $tbl_user . ' u ' . ' WHERE (username LIKE "' . $needle . '%" ' . ' OR firstname LIKE "' . $needle . '%" ' . ' OR lastname LIKE "' . $needle . '%") ' . $order_clause . ' LIMIT 11';
         $rs = Database::query($sql);
         $i = 0;
         while ($user = Database::fetch_array($rs)) {
             $i++;
             if ($i <= 10) {
                 $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\'' . addslashes($user['user_id']) . '\',\'' . api_get_person_name(addslashes($user['firstname']), addslashes($user['lastname'])) . ' (' . addslashes($user['username']) . ')' . '\')">' . api_get_person_name($user['firstname'], $user['lastname']) . ' (' . $user['username'] . ')</a><br />';
             } else {
                 $return .= '...<br />';
             }
         }
     }
     $xajax_response->addAssign('ajax_list_users', 'innerHTML', api_utf8_encode($return));
     return $xajax_response;
 }
 public function uninstall()
 {
     $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
     $t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
     $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
     //New settings
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'openmeetings_tool_enable'";
     Database::query($sql);
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'openmeetings_pass'";
     Database::query($sql);
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'openmeetings_user'";
     Database::query($sql);
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'openmeetings_host'";
     Database::query($sql);
     //Old settings deleting just in case
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'openmeetings_plugin'";
     Database::query($sql);
     $sql = "DELETE FROM {$t_options} WHERE variable  = 'openmeetings_plugin'";
     Database::query($sql);
     //        $sql = "DELETE FROM $t_settings WHERE variable = 'openmeetings_plugin_host'";
     //        Database::query($sql);
     //        $sql = "DELETE FROM $t_settings WHERE variable = 'openmeetings_plugin_salt'";
     //        Database::query($sql);
     //hack to get rid of Database::query warning (please add c_id...)
     $sql = "DELETE FROM {$t_tool} WHERE name = 'openmeetings' AND c_id = c_id";
     Database::query($sql);
     $sql = "DROP TABLE IF EXISTS plugin_openmeetings";
     Database::query($sql);
     //Deleting course settings
     $this->uninstall_course_fields_in_all_courses();
 }
 /**
  * Search sessions by name, based on a search string
  * @param string Search string
  * @param int Deprecated param
  * @return string Xajax response block
  * @assert () === false
  */
 function search_sessions($needle, $id)
 {
     $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
     $xajax_response = new xajaxResponse();
     $return = '';
     if (!empty($needle)) {
         // xajax send utf8 datas... datas in db can be non-utf8 datas
         $charset = api_get_system_encoding();
         $needle = api_convert_encoding($needle, $charset, 'utf-8');
         $needle = Database::escape_string($needle);
         // search sessiones where username or firstname or lastname begins likes $needle
         $sql = 'SELECT id, name FROM ' . $tbl_session . ' u
                 WHERE (name LIKE "' . $needle . '%")
                 ORDER BY name, id
                 LIMIT 11';
         $rs = Database::query($sql);
         $i = 0;
         while ($session = Database::fetch_array($rs)) {
             $i++;
             if ($i <= 10) {
                 $return .= '<a href="#" onclick="add_user_to_url(\'' . addslashes($session['id']) . '\',\'' . addslashes($session['name']) . ' (' . addslashes($session['id']) . ')' . '\')">' . $session['name'] . ' </a><br />';
             } else {
                 $return .= '...<br />';
             }
         }
     }
     $xajax_response->addAssign('ajax_list_courses', 'innerHTML', api_utf8_encode($return));
     return $xajax_response;
 }
Пример #5
0
 /**
  *
  * Constructor (generates a connection to the API and the Chamilo settings
  * required for the connection to the video conference server)
  * @param string $host
  * @param string $salt
  */
 public function __construct($host = null, $salt = null)
 {
     // Initialize video server settings from global settings
     $plugin = BBBPlugin::create();
     $bbb_plugin = $plugin->get('tool_enable');
     if (empty($host)) {
         $bbb_host = $plugin->get('host');
     } else {
         $bbb_host = $host;
     }
     if (empty($salt)) {
         $bbb_salt = $plugin->get('salt');
     } else {
         $bbb_salt = $salt;
     }
     $this->logout_url = api_get_path(WEB_PLUGIN_PATH) . 'bbb/listing.php?' . api_get_cidreq();
     $this->table = Database::get_main_table('plugin_bbb_meeting');
     if ($bbb_plugin == true) {
         $userInfo = api_get_user_info();
         $this->user_complete_name = $userInfo['complete_name'];
         $this->salt = $bbb_salt;
         $info = parse_url($bbb_host);
         $this->url = $bbb_host . '/bigbluebutton/';
         if (isset($info['scheme'])) {
             $this->protocol = $info['scheme'] . '://';
             $this->url = str_replace($this->protocol, '', $this->url);
         }
         // Setting BBB api
         define('CONFIG_SECURITY_SALT', $this->salt);
         define('CONFIG_SERVER_BASE_URL', $this->url);
         $this->api = new BigBlueButtonBN();
         $this->plugin_enabled = true;
     }
 }
Пример #6
0
    /**
     * Check whether the username and password are valid
     * @param string $username The username
     * @param string $password the password
     * @return boolean Whether the password belongs to the username return true. Otherwise return false
     */
    public static function isValidUser($username, $password)
    {
        if (empty($username) || empty($password)) {
            return false;
        }

        $userTable = Database::get_main_table(TABLE_MAIN_USER);

        $whereConditions = array(
            "username = '******' " => $username,
            "AND password = '******'" => sha1($password)
        );

        $conditions = array(
            'where' => $whereConditions
        );

        $table = Database::select('count(1) as qty', $userTable, $conditions);

        if ($table != false) {
            $row = current($table);

            if ($row['qty'] > 0) {
                return true;
            }
        }

        return false;
    }
function reports_template_exercicesMultiCourses_getSQL()
{
    // foreach quiz
    $result = array();
    $columns = Database::query('select r.id as kid, c.title as course, ' . 'r.child_name as test from ' . Database::get_main_table(TABLE_MAIN_REPORTS_KEYS) . ' r, ' . Database::get_main_table(TABLE_MAIN_COURSE) . ' c ' . 'where r.course_id=c.id and r.tool_id=' . reports_getToolId(TOOL_QUIZ) . ' order by r.course_id, r.child_name');
    if (Database::num_rows($columns) == 0) {
        die('<b>' . get_lang('no data found') . '</b>');
    }
    $query = 'select u.lastname Name, u.firstname Firstname';
    $columns = Database::store_result($columns);
    if ($_REQUEST['tattempt'] == 'min' || $_REQUEST['tattempt'] == 'max') {
        $function = $_REQUEST['tattempt'];
    } else {
        $function = 'avg';
    }
    foreach ($columns as $key => $column) {
        $query .= ', ' . $function . '(k' . $key . '.score) as `' . $column['course'] . ' - ' . $column['test'] . '` ';
    }
    $query .= ' from ' . Database::get_main_table(TABLE_MAIN_USER) . ' u ';
    foreach ($columns as $key => $column) {
        // fixme sessions
        $query .= 'left outer join ' . Database::get_main_table(TABLE_MAIN_REPORTS_VALUES) . ' k' . $key . ' on k' . $key . '.key_id = ' . $column['kid'] . ' and k' . $key . '.user_id = u.user_id ';
    }
    $query .= ' group by ';
    foreach ($columns as $key => $column) {
        // grouping attempt
        $query .= 'k' . $key . '.attempt, ';
    }
    $query = substr($query, 0, -2);
    // removing last ', ';
    return $query;
}
Пример #8
0
 /**
  * Constructor (generates a connection to the API)
  * @param   string  Clockworksms API key required to use the plugin
  * @return  void
  */
 public function __construct($apiKey = null)
 {
     $plugin = ClockworksmsPlugin::create();
     $clockWorkSMSPlugin = $plugin->get('tool_enable');
     if (empty($apiKey)) {
         $clockWorkSMSApiKey = $plugin->get('api_key');
     } else {
         $clockWorkSMSApiKey = $apiKey;
     }
     $this->table = Database::get_main_table('user_field_values');
     if ($clockWorkSMSPlugin == true) {
         $this->apiKey = $clockWorkSMSApiKey;
         // Setting Clockworksms api
         if (!defined('CONFIG_SECURITY_API_KEY')) {
             define('CONFIG_SECURITY_API_KEY', $this->apiKey);
         }
         $trimmedApiKey = trim(CONFIG_SECURITY_API_KEY);
         if (!empty($trimmedApiKey)) {
             $this->api = new Clockwork(CONFIG_SECURITY_API_KEY);
         } else {
             $this->api = new Clockwork(' ');
             $recipient_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
             $email_form = api_get_setting('emailAdministrator');
             $emailsubject = 'Clockworksms error';
             $emailbody = 'Key cannot be blank';
             $sender_name = $recipient_name;
             $email_admin = $email_form;
             api_mail_html($recipient_name, $email_form, $emailsubject, $emailbody, $sender_name, $email_admin);
         }
         $this->plugin_enabled = true;
     }
 }
Пример #9
0
 function uninstall()
 {
     $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
     $t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
     $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
     //Delete settings
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'ticket_tool_enable'";
     Database::query($sql);
     $sql = "DROP TABLE IF EXISTS ticket_ticket";
     Database::query($sql);
     $sql = "DROP TABLE IF EXISTS ticket_status";
     Database::query($sql);
     $sql = "DROP TABLE IF EXISTS ticket_project";
     Database::query($sql);
     $sql = "DROP TABLE IF EXISTS ticket_priority";
     Database::query($sql);
     $sql = "DROP TABLE IF EXISTS ticket_message_attch";
     Database::query($sql);
     $sql = "DROP TABLE IF EXISTS ticket_message";
     Database::query($sql);
     $sql = "DROP TABLE IF EXISTS ticket_category";
     Database::query($sql);
     $sql = "DROP TABLE IF EXISTS ticket_assigned_log";
     Database::query($sql);
     $sql = "DROP TABLE IF EXISTS ticket_ticket";
     Database::query($sql);
     //Deleting course settings
     $this->uninstall_course_fields_in_all_courses();
 }
Пример #10
0
/**
 *
 */
function get_course_usage($course_code, $session_id = 0)
{
    $table = Database::get_main_table(TABLE_MAIN_COURSE);
    $course_code = Database::escape_string($course_code);
    $sql = "SELECT * FROM {$table} WHERE code='" . $course_code . "'";
    $res = Database::query($sql);
    $course = Database::fetch_object($res);
    // Learnpaths
    $table = Database::get_course_table(TABLE_LP_MAIN);
    $usage[] = array(get_lang(ucfirst(TOOL_LEARNPATH)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Forums
    $table = Database::get_course_table(TABLE_FORUM);
    $usage[] = array(get_lang('Forums'), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Quizzes
    $table = Database::get_course_table(TABLE_QUIZ_TEST);
    $usage[] = array(get_lang(ucfirst(TOOL_QUIZ)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Documents
    $table = Database::get_course_table(TABLE_DOCUMENT);
    $usage[] = array(get_lang(ucfirst(TOOL_DOCUMENT)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Groups
    $table = Database::get_course_table(TABLE_GROUP);
    $usage[] = array(get_lang(ucfirst(TOOL_GROUP)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Calendar
    $table = Database::get_course_table(TABLE_AGENDA);
    $usage[] = array(get_lang(ucfirst(TOOL_CALENDAR_EVENT)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Link
    $table = Database::get_course_table(TABLE_LINK);
    $usage[] = array(get_lang(ucfirst(TOOL_LINK)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    // Announcements
    $table = Database::get_course_table(TABLE_ANNOUNCEMENT);
    $usage[] = array(get_lang(ucfirst(TOOL_ANNOUNCEMENT)), CourseManager::count_rows_course_table($table, $session_id, $course->id));
    return $usage;
}
Пример #11
0
 /**
  * Sets the surveylist and the plainsurveylist
  */
 public function __construct()
 {
     // Database table definitions
     $table_survey = Database::get_course_table(TABLE_SURVEY);
     $table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
     $table_user = Database::get_main_table(TABLE_MAIN_USER);
     // searching
     $search_restriction = SurveyUtil::survey_search_restriction();
     if ($search_restriction) {
         $search_restriction = ' AND ' . $search_restriction;
     }
     $course_id = api_get_course_int_id();
     $sql = "SELECT\n                    survey.survey_id,\n                    survey.parent_id,\n                    survey_version,\n                    survey.code as name\n\t\t\t\tFROM {$table_survey} survey\n\t\t\t\tLEFT JOIN {$table_survey_question}  survey_question\n\t\t\t\tON survey.survey_id = survey_question.survey_id , {$table_user} user\n\t\t\t\tWHERE\n\t\t\t\t\tsurvey.c_id \t\t\t=  {$course_id} AND\n\t\t\t\t\tsurvey_question.c_id \t=  {$course_id} AND\n\t\t\t\t\tsurvey.author \t\t\t= user.user_id\n\t\t\t\tGROUP BY survey.survey_id";
     $res = Database::query($sql);
     $surveys_parents = array();
     $refs = array();
     $list = array();
     $plain_array = array();
     while ($survey = Database::fetch_array($res, 'ASSOC')) {
         $plain_array[$survey['survey_id']] = $survey;
         $surveys_parents[] = $survey['survey_version'];
         $thisref =& $refs[$survey['survey_id']];
         $thisref['parent_id'] = $survey['parent_id'];
         $thisref['name'] = $survey['name'];
         $thisref['id'] = $survey['survey_id'];
         $thisref['survey_version'] = $survey['survey_version'];
         if ($survey['parent_id'] == 0) {
             $list[$survey['survey_id']] =& $thisref;
         } else {
             $refs[$survey['parent_id']]['children'][$survey['survey_id']] =& $thisref;
         }
     }
     $this->surveylist = $list;
     $this->plainsurveylist = $plain_array;
 }
Пример #12
0
    /**
     * Generate an array of attendances that a teacher hasn't created a link for.
     * @return array 2-dimensional array - every element contains 2 subelements (id, name)
     * @todo seems to be depracated
     */
    public function get_not_created_links()
    {
        return false;
        if (empty($this->course_code)) {
            die('Error in get_not_created_links() : course code not set');
        }
        $tbl_grade_links = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
        $sql = 'SELECT att.id, att.name, att.attendance_qualify_title
				FROM ' . $this->get_attendance_table() . ' att
				WHERE
					att.c_id = ' . $this->course_id . ' AND
					att.id NOT IN (
						SELECT ref_id FROM ' . $tbl_grade_links . '
						WHERE
							type = ' . LINK_ATTENDANCE . ' AND
							course_code = "' . Database::escape_string($this->get_course_code()) . '"
					)
				AND att.session_id=' . api_get_session_id() . '';
        $result = Database::query($sql);
        $cats = array();
        while ($data = Database::fetch_array($result)) {
            if (isset($data['attendance_qualify_title']) && $data['attendance_qualify_title'] != '') {
                $cats[] = array($data['id'], $data['attendance_qualify_title']);
            } else {
                $cats[] = array($data['id'], $data['name']);
            }
        }
        return $cats;
    }
Пример #13
0
/**
 * Get the classes to display on the current page.
 */
function get_class_data($from, $number_of_items, $column, $direction)
{
    $class_table = Database::get_main_table(TABLE_MAIN_CLASS);
    $course_class_table = Database::get_main_table(TABLE_MAIN_COURSE_CLASS);
    $class_user_table = Database::get_main_table(TABLE_MAIN_CLASS_USER);
    $sql = "SELECT * FROM {$course_class_table} WHERE course_code = '" . $_SESSION['_course']['id'] . "'";
    $res = Database::query($sql);
    $subscribed_classes = array();
    while ($obj = Database::fetch_object($res)) {
        $subscribed_classes[] = $obj->class_id;
    }
    $sql = "SELECT\n\t\t\t\t\t\t\tc.id AS col0,\n\t\t\t\t\t\t\tc.name   AS col1,\n\t\t\t\t\t\t\tCOUNT(cu.user_id) AS col2,\n\t\t\t\t\t\t\tc.id AS col3\n\t\t\t\t\t\tFROM {$class_table} c\n\t\t\t\t\t\t";
    $sql .= " LEFT JOIN {$class_user_table} cu ON cu.class_id = c.id";
    $sql .= " WHERE 1 = 1";
    if (isset($_GET['keyword'])) {
        $keyword = Database::escape_string(trim($_GET['keyword']));
        $sql .= " AND (c.name LIKE '%" . $keyword . "%')";
    }
    if (count($subscribed_classes) > 0) {
        $sql .= " AND c.id NOT IN ('" . implode("','", $subscribed_classes) . "')";
    }
    $sql .= " GROUP BY c.id, c.name ";
    $sql .= " ORDER BY col{$column} {$direction} ";
    $sql .= " LIMIT {$from},{$number_of_items}";
    $res = Database::query($sql);
    $classes = array();
    while ($class = Database::fetch_row($res)) {
        $classes[] = $class;
    }
    return $classes;
}
 /**
  * Returns users whose last login is prior from $ceiling
  *
  * @param int|string $ceiling last login date
  * @param bool $active_only if true returns only active users. Otherwise returns all users.
  * @return ResultSet
  */
 static function list_zombies($ceiling, $active_only = true)
 {
     $ceiling = is_numeric($ceiling) ? (int) $ceiling : strtotime($ceiling);
     $ceiling = date('Y-m-d H:i:s', $ceiling);
     $user_table = Database::get_main_table(TABLE_MAIN_USER);
     $login_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
     $sql = 'SELECT
                 user.user_id,
                 user.firstname,
                 user.lastname,
                 user.username,
                 user.auth_source,
                 user.email,
                 user.status,
                 user.registration_date,
                 user.active,
                 access.login_date';
     global $_configuration;
     if ($_configuration['multiple_access_urls']) {
         $access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
         $current_url_id = api_get_current_access_url_id();
         $sql .= " FROM {$user_table} as user, {$login_table} as access, {$access_url_rel_user_table} as url\n                      WHERE\n                        access.login_date = (SELECT MAX(a.login_date)\n                                             FROM {$login_table} as a\n                                             WHERE a.login_user_id = user.user_id\n                                             ) AND\n                        access.login_date <= '{$ceiling}' AND\n                        user.user_id = access.login_user_id AND\n                        url.login_user_id = user.user_id AND url.access_url_id={$current_url_id}";
     } else {
         $sql .= " FROM {$user_table} as user, {$login_table} as access\n                      WHERE\n                        access.login_date = (SELECT MAX(a.login_date)\n                                             FROM {$login_table} as a\n                                             WHERE a.login_user_id = user.user_id\n                                             ) AND\n                        access.login_date <= '{$ceiling}' AND\n                        user.user_id = access.login_user_id";
     }
     if ($active_only) {
         $sql .= ' AND user.active = 1';
     }
     return ResultSet::create($sql);
 }
/**
 * Get all categories and users ids from gradebook
 * @return array Categories and users ids
 */
function getAllCategoriesAndUsers()
{
    $table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
    $jointable = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
    $joinStatement = ' JOIN ' . $jointable . ' ON ' . $table . '.evaluation_id = ' . $jointable . '.id';
    return Database::select('DISTINCT ' . $jointable . '.category_id,' . $table . '.user_id', $table . $joinStatement);
}
Пример #16
0
 public function uninstall()
 {
     $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
     $t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
     $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
     //New settings
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'bbb_tool_enable'";
     Database::query($sql);
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'bbb_salt'";
     Database::query($sql);
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'bbb_host'";
     Database::query($sql);
     //Old settings deleting just in case
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'bbb_plugin'";
     Database::query($sql);
     $sql = "DELETE FROM {$t_options} WHERE variable  = 'bbb_plugin'";
     Database::query($sql);
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'bbb_plugin_host'";
     Database::query($sql);
     $sql = "DELETE FROM {$t_settings} WHERE variable = 'bbb_plugin_salt'";
     Database::query($sql);
     //hack to get rid of Database::query warning (please add c_id...)
     $sql = "DELETE FROM {$t_tool} WHERE name = 'bbb' AND c_id != 0";
     Database::query($sql);
     $t = Database::get_main_table('plugin_bbb_meeting');
     $sql = "DROP TABLE IF EXISTS {$t}";
     Database::query($sql);
     //Deleting course settings
     $this->uninstall_course_fields_in_all_courses($this->course_settings);
 }
Пример #17
0
 /**
  * @param string $type
  */
 public function __construct($type)
 {
     $this->type = $type;
     $this->table = Database::get_main_table(TABLE_EXTRA_FIELD);
     $this->table_field_options = Database::get_main_table(TABLE_EXTRA_FIELD_OPTIONS);
     $this->table_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
     switch ($this->type) {
         case 'calendar_event':
             $this->extraFieldType = EntityExtraField::CALENDAR_FIELD_TYPE;
             break;
         case 'course':
             $this->extraFieldType = EntityExtraField::COURSE_FIELD_TYPE;
             break;
         case 'user':
             $this->extraFieldType = EntityExtraField::USER_FIELD_TYPE;
             break;
         case 'session':
             $this->extraFieldType = EntityExtraField::SESSION_FIELD_TYPE;
             break;
         case 'question':
             $this->extraFieldType = EntityExtraField::QUESTION_FIELD_TYPE;
             break;
         case 'lp':
             $this->extraFieldType = EntityExtraField::LP_FIELD_TYPE;
             break;
         case 'lp_item':
             $this->extraFieldType = EntityExtraField::LP_ITEM_FIELD_TYPE;
             break;
     }
     $this->pageUrl = 'extra_fields.php?type=' . $this->type;
     // Example QuestionFields
     $this->pageName = get_lang(ucwords($this->type) . 'Fields');
 }
Пример #18
0
 /**
  *
  */
 public function __construct()
 {
     // Table definitions
     $this->tbl_global_agenda = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
     $this->tbl_personal_agenda = Database::get_main_table(TABLE_PERSONAL_AGENDA);
     $this->tbl_course_agenda = Database::get_course_table(TABLE_AGENDA);
     // Setting the course object if we are in a course
     $this->course = null;
     $course_info = api_get_course_info();
     if (!empty($course_info)) {
         $this->course = $course_info;
     }
     $this->events = array();
     //Event colors
     $this->event_platform_color = 'red';
     //red
     $this->event_course_color = '#458B00';
     //green
     $this->event_group_color = '#A0522D';
     //siena
     $this->event_session_color = '#00496D';
     // kind of green
     $this->event_personal_color = 'steel blue';
     //steel blue
 }
 /**
  * Search for a list of available courses by title or code, based on
  * a given string
  * @param string String to search for
  * @param int Deprecated param
  * @return string A formatted, xajax answer block
  * @assert () === false
  */
 function search_courses($needle, $id)
 {
     $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
     $xajax_response = new xajaxResponse();
     $return = '';
     if (!empty($needle)) {
         // xajax send utf8 datas... datas in db can be non-utf8 datas
         $charset = api_get_system_encoding();
         $needle = api_convert_encoding($needle, $charset, 'utf-8');
         $needle = Database::escape_string($needle);
         // search courses where username or firstname or lastname begins likes $needle
         $sql = 'SELECT code, title FROM ' . $tbl_course . ' u ' . ' WHERE (title LIKE "' . $needle . '%" ' . ' OR code LIKE "' . $needle . '%" ' . ' ) ' . ' ORDER BY title, code ' . ' LIMIT 11';
         $rs = Database::query($sql);
         $i = 0;
         while ($course = Database::fetch_array($rs)) {
             $i++;
             if ($i <= 10) {
                 $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\'' . addslashes($course['code']) . '\',\'' . addslashes($course['title']) . ' (' . addslashes($course['code']) . ')' . '\')">' . $course['title'] . ' (' . $course['code'] . ')</a><br />';
             } else {
                 $return .= '...<br />';
             }
         }
     }
     $xajax_response->addAssign('ajax_list_courses', 'innerHTML', api_utf8_encode($return));
     return $xajax_response;
 }
Пример #20
0
/**
 * Save the score for a HP quiz. Can be used by the learnpath tool as well
 * for HotPotatoes quizzes. When coming from the learning path, we
 * use the session variables telling us which item of the learning path has to
 * be updated (score-wise)
 * @param	string	File is the exercise name (the file name for a HP)
 * @param	integer	Score to save inside the tracking tables (HP and learnpath)
 * @return	void
 */
function save_scores($file, $score)
{
    global $origin;
    $TABLETRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
    $_user = api_get_user_info();
    // if tracking is disabled record nothing
    $weighting = 100;
    // 100%
    $date = api_get_utc_datetime();
    $c_id = api_get_course_int_id();
    if ($_user['user_id']) {
        $user_id = $_user['user_id'];
    } else {
        // anonymous
        $user_id = "NULL";
    }
    $params = ['exe_name' => $file, 'exe_user_id' => $user_id, 'exe_date' => $date, 'c_id' => $c_id, 'exe_result' => $score, 'exe_weighting' => $weighting];
    Database::insert($TABLETRACK_HOTPOTATOES, $params);
    if ($origin == 'learnpath') {
        //if we are in a learning path, save the score in the corresponding
        //table to get tracking in there as well
        global $jscript2run;
        //record the results in the learning path, using the SCORM interface (API)
        $jscript2run .= "<script>\n            \$(document).ready(function() {\n                //API_obj = window.frames.window.content.API;\n                //API_obj = \$('content_id').context.defaultView.content.API; //works only in FF\n                //API_obj = window.parent.frames.window.top.API;\n                API_obj = window.top.API;\n                API_obj.void_save_asset('{$score}', '{$weighting}', 0, 'completed');\n            });\n        </script>";
    }
}
Пример #21
0
 /**
  * Formats the necessary elements for the given datatype
  * @param string $type The type of data to which this extra field
  * applies (user, course, session, ...)
  *
  * @assert (-1) === false
  */
 public function __construct($type)
 {
     $this->type = $type;
     $extraField = new ExtraField($this->type);
     $this->extraField = $extraField;
     $this->table = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
     $this->table_handler_field = Database::get_main_table(TABLE_EXTRA_FIELD);
 }
Пример #22
0
 /**
  * Check if the video chat exists by its room name
  * @param string $name The video chat name
  *
  * @return boolean
  */
 public static function nameExists($name)
 {
     $resultData = Database::select('COUNT(1) AS count', Database::get_main_table(TABLE_MAIN_CHAT_VIDEO), ['where' => ['room_name = ?' => $name]], 'first');
     if ($resultData !== false) {
         return $resultData['count'] > 0;
     }
     return false;
 }
Пример #23
0
 /**
  * Install the plugin
  */
 public function install()
 {
     $this->installHook();
     $result = Database::select('variable', Database::get_main_table(TABLE_EXTRA_FIELD), array('where' => array('variable = ?' => array('skype'))));
     if (empty($result)) {
         $extraField = new ExtraField('user');
         $extraField->save(array('field_type' => ExtraField::FIELD_TYPE_TEXT, 'variable' => 'skype', 'display_text' => 'Skype', 'visible' => 1, 'changeable' => 1));
     }
 }
Пример #24
0
 /**
  * Constructor
  */
 protected function __construct()
 {
     $this->tables[TABLE_HOOK_OBSERVER] = Database::get_main_table(TABLE_HOOK_OBSERVER);
     $this->tables[TABLE_HOOK_EVENT] = Database::get_main_table(TABLE_HOOK_EVENT);
     $this->tables[TABLE_HOOK_CALL] = Database::get_main_table(TABLE_HOOK_CALL);
     $this->hookCalls = $this->listAllHookCalls();
     $this->hookEvents = $this->listAllHookEvents();
     $this->hookObservers = $this->listAllHookObservers();
 }
Пример #25
0
function reports_modules_course_val($course, $key_id) {
	return array('type'=> 'sql', 'sql' => 
			'select '.$key_id.', user_id as uid, '.
			'-1 as session_id, -1 as attempt, null as score, '.
			'NULL as progress, '.
			'(sum(logout_course_date) - sum(login_course_date)) as time, null as ts from '.
			Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS).
			' where course_code = '."'".$course['course_code']."'".
			' group by user_id');
}
Пример #26
0
function reports_modules_quiz_quizVal($quiz, $key_id) {
	return array('type'=> 'sql', 'sql' => 
			'select '.$key_id.', exe_user_id as uid, '.
			'session_id, -1 as attempt, exe_result as score, '.
			REPORTS_PROGRESS_COMPLETED.' as progress, '.
			'exe_duration as time, exe_date as ts from '.
			Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES).
			' where exe_cours_id = '."'".$quiz['course_code']."'".
			' and exe_exo_id='.$quiz['child_id']);
}
Пример #27
0
 /**
  * Drop the database tables for the plugin
  * @return void
  */
 private function uninstallDatabase()
 {
     /* Drop plugin tables */
     $pensTable = Database::get_main_table(PENSPlugin::TABLE_PENS);
     $sql = "DROP TABLE IF EXISTS {$pensTable}; ";
     Database::query($sql);
     /* Delete settings */
     $settingsTable = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
     Database::query("DELETE FROM {$settingsTable} WHERE subkey = 'plugin_pens'");
 }
Пример #28
0
 /**
  * Room constructor.
  */
 public function __construct()
 {
     $this->table = \Database::get_main_table('plugin_openmeetings');
     $this->name = 'C' . api_get_real_course_id() . '-' . api_get_session_id();
     $accessUrl = api_get_access_url(api_get_current_access_url_id());
     $this->externalRoomType = substr($accessUrl['url'], strpos($accessUrl['url'], '://') + 3, -1);
     if (strcmp($this->externalRoomType, 'localhost') == 0) {
         $this->externalRoomType = substr(api_get_path(WEB_PATH), strpos(api_get_path(WEB_PATH), '://') + 3, -1);
     }
     $this->externalRoomType = 'chamilolms.' . $this->externalRoomType;
 }
Пример #29
0
 /**
  *
  */
 public function __construct()
 {
     $this->table = Database::get_main_table(TABLE_NOTIFICATION);
     $this->sender_email = api_get_setting('noreply_email_address');
     $this->sender_name = api_get_setting('siteName');
     // If no-reply  email doesn't exist use the admin email
     if (empty($this->sender_email)) {
         $this->sender_email = api_get_setting('emailAdministrator');
         $this->sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
     }
 }
Пример #30
0
 /**
  * @param string $type
  */
 public function __construct($type)
 {
     $this->type = $type;
     switch ($this->type) {
         case 'course':
             $this->table_field_options = Database::get_main_table(TABLE_MAIN_COURSE_FIELD_OPTIONS);
             $this->table_field_values = Database::get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES);
             //Used for the model
             $this->table = Database::get_main_table(TABLE_MAIN_COURSE_FIELD);
             $this->handler_id = 'course_code';
             $this->handlerEntityId = 'courseCode';
             $this->primaryKey = 'id';
             break;
         case 'user':
             $this->table_field_options = Database::get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS);
             $this->table_field_values = Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES);
             //Used for the model
             $this->table = Database::get_main_table(TABLE_MAIN_USER_FIELD);
             $this->handler_id = 'user_id';
             $this->handlerEntityId = 'userId';
             $this->primaryKey = 'user_id';
             break;
         case 'session':
             $this->table_field_options = Database::get_main_table(TABLE_MAIN_SESSION_FIELD_OPTIONS);
             $this->table_field_values = Database::get_main_table(TABLE_MAIN_SESSION_FIELD_VALUES);
             //Used for the model
             $this->table = Database::get_main_table(TABLE_MAIN_SESSION_FIELD);
             $this->handler_id = 'session_id';
             $this->handlerEntityId = 'sessionId';
             $this->primaryKey = 'id';
             break;
         case 'question':
             $this->table_field_options = Database::get_main_table(TABLE_MAIN_QUESTION_FIELD_OPTIONS);
             $this->table_field_values = Database::get_main_table(TABLE_MAIN_QUESTION_FIELD_VALUES);
             //Used for the model
             $this->table = Database::get_main_table(TABLE_MAIN_QUESTION_FIELD);
             $this->handler_id = 'question_id';
             $this->handlerEntityId = 'questionId';
             $this->primaryKey = 'iid';
             break;
         case 'lp':
             $this->table_field_options = Database::get_main_table(TABLE_MAIN_LP_FIELD_OPTIONS);
             $this->table_field_values = Database::get_main_table(TABLE_MAIN_LP_FIELD_VALUES);
             // Used for the model
             $this->table = Database::get_main_table(TABLE_MAIN_LP_FIELD);
             $this->handler_id = 'lp_id';
             $this->handlerEntityId = 'lpId';
             $this->primaryKey = 'id';
             break;
     }
     $this->pageUrl = 'extra_fields.php?type=' . $this->type;
     // Example QuestionFields
     $this->pageName = get_lang(ucwords($this->type) . 'Fields');
 }