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


PHP api_get_utc_datetime函数代码示例

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


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

示例1: onLogoutSuccess

 /**
  * @param Request $request
  * @return null|RedirectResponse
  */
 public function onLogoutSuccess(Request $request)
 {
     // Chamilo logout
     $request->getSession()->remove('_locale');
     $request->getSession()->remove('_locale_user');
     if (api_is_global_chat_enabled()) {
         $chat = new \Chat();
         $chat->setUserStatus(0);
     }
     $userId = $this->storage->getToken()->getUser()->getId();
     $tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
     $sql = "SELECT login_id, login_date\n                FROM {$tbl_track_login}\n                WHERE login_user_id = {$userId}\n                ORDER BY login_date DESC\n                LIMIT 0,1";
     $row = Database::query($sql);
     $loginId = null;
     if (Database::num_rows($row) > 0) {
         $loginId = Database::result($row, 0, "login_id");
     }
     $loginAs = $this->checker->isGranted('ROLE_PREVIOUS_ADMIN');
     if (!$loginAs) {
         $current_date = api_get_utc_datetime();
         $sql = "UPDATE {$tbl_track_login}\n                    SET logout_date='" . $current_date . "'\n        \t\t    WHERE login_id='{$loginId}'";
         Database::query($sql);
     }
     $online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
     $query = "DELETE FROM " . $online_table . " WHERE login_user_id = {$userId}";
     Database::query($query);
     require_once api_get_path(SYS_PATH) . 'main/chat/chat_functions.lib.php';
     exit_of_chat($userId);
     $login = $this->router->generate('home');
     $response = new RedirectResponse($login);
     return $response;
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:36,代码来源:LogoutSuccessHandler.php

示例2: createRoom

 /**
  * Create a video chat
  * @param int $fromUser The sender user
  * @param int $toUser The receiver user
  * @return int The created video chat id. Otherwise return false
  */
 public static function createRoom($fromUser, $toUser)
 {
     $fromUserInfo = api_get_user_info($fromUser);
     $toUserInfo = api_get_user_info($toUser);
     $chatName = vsprintf(get_lang('VideoChatBetweenUserXAndUserY'), [$fromUserInfo['firstname'], $toUserInfo['firstname']]);
     return Database::insert(Database::get_main_table(TABLE_MAIN_CHAT_VIDEO), ['from_user' => intval($fromUser), 'to_user' => intval($toUser), 'room_name' => $chatName, 'datetime' => api_get_utc_datetime()]);
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:13,代码来源:VideoChat.php

示例3: save_scores

/**
 * 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>";
    }
}
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:35,代码来源:savescores.php

示例4: update

 /**
  * Updates an URL access
  * @author Julio Montoya <gugli100@gmail.com>,
  *
  * @param	int 	$url_id The url id
  * @param	string 	$url
  * @param	string  $description The description of the site
  * @param	int		$active is active or not
  * @return 	boolean if success
  */
 public static function update($url_id, $url, $description, $active)
 {
     $url_id = intval($url_id);
     $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL);
     $sql = "UPDATE {$table}\n                SET url \t= '" . Database::escape_string($url) . "',\n                description = '" . Database::escape_string($description) . "',\n                active \t\t= '" . intval($active) . "',\n                created_by \t= '" . api_get_user_id() . "',\n                tms \t\t= '" . api_get_utc_datetime() . "'\n                WHERE id = '{$url_id}'";
     $result = Database::query($sql);
     return $result;
 }
开发者ID:daffef,项目名称:chamilo-lms,代码行数:18,代码来源:urlmanager.lib.php

示例5: update

 /**
  * Updates a group
  * @author Julio Montoya <gugli100@gmail.com>,
  *
  * @param	int 	The id
  * @param	string  The description of the site
  * @param	int		is active or not
  * @param	int     the user_id of the owner
  * @return 	boolean if success
  */
 public static function update($group_id, $name, $description, $url, $visibility, $picture_uri)
 {
     $group_id = intval($group_id);
     $table = Database::get_main_table(TABLE_MAIN_GROUP);
     $now = api_get_utc_datetime();
     $sql = "UPDATE {$table}\n               \tSET name \t= '" . Database::escape_string($name) . "',\n                description = '" . Database::escape_string($description) . "',\n                picture_uri = '" . Database::escape_string($picture_uri) . "',\n                url \t\t= '" . Database::escape_string($url) . "',\n                visibility \t= '" . Database::escape_string($visibility) . "',\n                updated_on \t= '" . $now . "'\n                WHERE id = '{$group_id}'";
     $result = Database::query($sql);
     return $result;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:19,代码来源:group_portal_manager.lib.php

示例6: fill_whoisonline

/**
 * Loads the data and injects it into the Dokeos database, using the Dokeos
 * internal functions.
 * @return  array  List of user IDs for the users that have just been inserted
 */
function fill_whoisonline()
{
    $table_e_online = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
    $max = 100;
    //Cleaning the table
    $sql = "TRUNCATE {$table_e_online}";
    $rs = Database::query($sql);
    //filling the table
    for ($i = 1; $i <= $max; $i++) {
        $date = api_get_utc_datetime();
        $sql = "INSERT INTO\t{$table_e_online} (login_id, login_user_id, login_date, login_ip, course, session_id, access_url_id)\n\t\t\t\tVALUES ('{$i}', '{$i}', '{$date}', '127.0.0.1', '', '0','1')";
        $rs = Database::query($sql);
    }
}
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:19,代码来源:fill_whoisonline.php

示例7: update

 /**
  * Updates a group
  * @author Julio Montoya <gugli100@gmail.com>,
  *
  * @param int $group_id The id
  * @param string $name The description of the site
  * @param string $description
  * @param string $url
  * @param int $visibility
  * @param string $picture_uri
  * @param bool $allowMemberGroupToLeave
  * @return bool if success
  */
 public static function update($group_id, $name, $description, $url, $visibility, $picture_uri, $allowMemberGroupToLeave = null)
 {
     $group_id = intval($group_id);
     $table = Database::get_main_table(TABLE_MAIN_GROUP);
     $now = api_get_utc_datetime();
     $groupLeaveCondition = null;
     if (isset($allowMemberGroupToLeave)) {
         $allowMemberGroupToLeave = $allowMemberGroupToLeave == true ? 1 : 0;
         $groupLeaveCondition = " allow_members_leave_group = {$allowMemberGroupToLeave} , ";
     }
     $sql = "UPDATE {$table} SET\n                    name \t= '" . Database::escape_string($name) . "',\n                    description = '" . Database::escape_string($description) . "',\n                    picture_uri = '" . Database::escape_string($picture_uri) . "',\n                    url \t\t= '" . Database::escape_string($url) . "',\n                    visibility \t= '" . Database::escape_string($visibility) . "',\n                    {$groupLeaveCondition}\n                    updated_on \t= '" . $now . "'\n                WHERE id = '{$group_id}'";
     $result = Database::query($sql);
     return $result;
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:27,代码来源:group_portal_manager.lib.php

示例8: clean_parameters

 public function clean_parameters($params)
 {
     //Convert dates
     $params['display_start_date'] = isset($params['display_start_date']) ? api_get_utc_datetime($params['display_start_date'], true) : null;
     $params['display_end_date'] = isset($params['display_end_date']) ? api_get_utc_datetime($params['display_end_date'], true) : null;
     $params['access_start_date'] = isset($params['access_start_date']) ? api_get_utc_datetime($params['access_start_date'], true) : null;
     $params['access_end_date'] = isset($params['access_end_date']) ? api_get_utc_datetime($params['access_end_date'], true) : null;
     $params['coach_access_start_date'] = isset($params['coach_access_start_date']) ? api_get_utc_datetime($params['coach_access_start_date'], true) : null;
     $params['coach_access_end_date'] = isset($params['coach_access_end_date']) ? api_get_utc_datetime($params['coach_access_end_date'], true) : null;
     $params['id_coach'] = is_array($params['id_coach']) ? $params['id_coach'][0] : $params['id_coach'];
     if (empty($params['access_end_date'])) {
         $params['visibility'] = SessionManager::DEFAULT_VISIBILITY;
     }
     unset($params['submit']);
     return $params;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:16,代码来源:session_model.lib.php

示例9: save_scores

/**
 * 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, $_user, $TABLETRACK_HOTPOTATOES;
    $weighting = 100;
    // 100%
    $date = api_get_utc_datetime();
    if ($_user['user_id']) {
        $user_id = $_user['user_id'];
    } else {
        // anonymous
        $user_id = "NULL";
    }
    $sql = "INSERT INTO {$TABLETRACK_HOTPOTATOES} (exe_name, exe_user_id, exe_date, c_id, exe_result, exe_weighting) VALUES (\n\t\t\t'" . Database::escape_string($file) . "',\n\t\t\t'" . Database::escape_string($user_id) . "',\n\t\t\t'" . Database::escape_string($date) . "',\n\t\t\t'" . api_get_course_int_id() . "',\n\t\t\t'" . Database::escape_string($score) . "',\n\t\t\t'" . Database::escape_string($weighting) . "')";
    Database::query($sql);
    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>";
    }
}
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:savescores.php

示例10: add

 /**
  * Creates a new url access
  *
  * @author Julio Montoya <gugli100@gmail.com>,
  *
  * @param string The URL of the site
  * @param string The description of the site
  * @param int is active or not
  * @param int the user_id of the owner
  * @param int The type of URL (1=multiple-access-url, 2=sincro-server, 3=sincro-client)
  * @param array If the type is different than 1, then there might be extra URL parameters to take into account
  * @return boolean if success
  */
 public static function add($url, $description, $active, $type = 1, $extra_params)
 {
     $tms = time();
     $type = intval($type);
     $table_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL);
     $u = api_get_user_id();
     if ($u == 0) {
         $u = api_get_anonymous_id();
     }
     if ($type > 1) {
         $active = 0;
     }
     $sql = "INSERT INTO {$table_access_url} " . " SET url \t= '" . Database::escape_string($url) . "', " . " description = '" . Database::escape_string($description) . "', " . " active \t\t= {$active}, " . " created_by \t= {$u}, " . " url_type        = {$type}, " . " tms = FROM_UNIXTIME(" . $tms . ")";
     $result = Database::query($sql);
     $id = Database::insert_id();
     if ($result !== false && $type == 3 && count($extra_params) > 0) {
         // Register extra parameters in the branch_sync table
         $t = Database::get_main_table(TABLE_BRANCH_SYNC);
         $sql = "INSERT INTO {$t} SET " . " access_url_id = {$id} " . (!empty($extra_params['ip']) ? ", branch_ip = '" . Database::escape_string($extra_params['ip']) . "'" : "") . (!empty($extra_params['name']) ? ", branch_name = '" . Database::escape_string($extra_params['name']) . "'" : "") . (!empty($extra_params['last_sync']) ? ", last_sync_trans_id = '" . Database::escape_string($extra_params['last_sync']) . "'" : "") . (!empty($extra_params['dwn_speed']) ? ", dwn_speed = '" . Database::escape_string($extra_params['dwn_speed']) . "'" : "") . (!empty($extra_params['up_speed']) ? ", up_speed = '" . Database::escape_string($extra_params['up_speed']) . "'" : "") . (!empty($extra_params['delay']) ? ", delay = '" . Database::escape_string($extra_params['delay']) . "'" : "") . (!empty($extra_params['admin_mail']) ? ", admin_mail = '" . Database::escape_string($extra_params['admin_mail']) . "'" : "") . (!empty($extra_params['admin_name']) ? ", admin_name = '" . Database::escape_string($extra_params['admin_name']) . "'" : "") . (!empty($extra_params['admin_phone']) ? ", admin_phone = '" . Database::escape_string($extra_params['admin_phone']) . "'" : "") . (!empty($extra_params['latitude']) ? ", latitude = '" . Database::escape_string($extra_params['latitude']) . "'" : "") . (!empty($extra_params['longitude']) ? ", longitude = '" . Database::escape_string($extra_params['longitude']) . "'" : "") . ", last_sync_trans_date = '" . api_get_utc_datetime() . "'";
         $result = $result && Database::query($sql);
     }
     return $result;
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:36,代码来源:urlmanager.lib.php

示例11: html_to_pdf_with_template

 /**
  * Export the given HTML to PDF, using a global template
  * @param string the HTML content
  * @uses export/table_pdf.tpl
  */
 function html_to_pdf_with_template($content)
 {
     Display::display_no_header();
     //Assignments
     Display::$global_template->assign('pdf_content', $content);
     $organization = api_get_setting('Institution');
     $img = api_get_path(SYS_CODE_PATH) . 'css/' . api_get_visual_theme() . '/images/header-logo.png';
     if (file_exists($img)) {
         $img = api_get_path(WEB_CODE_PATH) . 'css/' . api_get_visual_theme() . '/images/header-logo.png';
         $organization = "<img src='{$img}'>";
     } else {
         if (!empty($organization)) {
             $organization = '<h2 align="left">' . $organization . '</h2>';
         }
     }
     Display::$global_template->assign('organization', $organization);
     //Showing only the current teacher/admin instead the all teacherlist name see BT#4080
     $user_info = api_get_user_info();
     $teacher_list = $user_info['complete_name'];
     $session_name = api_get_session_name(api_get_session_id());
     if (!empty($session_name)) {
         Display::$global_template->assign('pdf_session', $session_name);
     }
     Display::$global_template->assign('pdf_course', $this->params['course_code']);
     Display::$global_template->assign('pdf_date', api_format_date(api_get_utc_datetime(), DATE_TIME_FORMAT_LONG));
     Display::$global_template->assign('pdf_teachers', $teacher_list);
     Display::$global_template->assign('pdf_title', $this->params['pdf_title']);
     Display::$global_template->assign('add_signatures', $this->params['add_signatures']);
     //Getting template
     $tpl = Display::$global_template->get_template('export/table_pdf.tpl');
     $html = Display::$global_template->fetch($tpl);
     $html = api_utf8_encode($html);
     $css_file = api_get_path(TO_SYS, WEB_CSS_PATH) . '/print.css';
     $css = file_exists($css_file) ? @file_get_contents($css_file) : '';
     self::content_to_pdf($html, $css, $this->params['filename'], $this->params['course_code']);
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:41,代码来源:pdf.lib.php

示例12: substr

 $sql = "SELECT * FROM {$TBL_STUDENT_PUBLICATION}\n                            \t\tWHERE description like '%{$search_this}%' AND url LIKE '%{$search_this2}%' AND session_id = {$new_session_id} AND c_id = {$course_id}\n                            \t\tORDER BY id desc  LIMIT 1";
 if ($debug) {
     echo $sql;
 }
 $sub_res = Database::query($sql);
 $num_rows = Database::num_rows($sub_res);
 if ($num_rows > 0) {
     $new_result = Database::fetch_array($sub_res, 'ASSOC');
     $created_dir = $new_result['url'];
     $new_parent_id = $new_result['id'];
 } else {
     if ($update_database) {
         $dir_name = substr($parent_data['url'], 1);
         $created_dir = create_unexisting_work_directory($base_work_dir, $dir_name);
         $created_dir = '/' . $created_dir;
         $now = api_get_utc_datetime();
         //Creating directory
         $sql_add_publication = "INSERT INTO " . $TBL_STUDENT_PUBLICATION . " SET\n                                           url         = '" . $created_dir . "',\n\t                                       c_id        = {$course_id},\n\t                                       title        = '" . $parent_data['title'] . "',\n\t                                       description  = '" . $parent_data['description'] . " folder_moved_from_session_id_{$origin_session_id} ',\n\t                                       author       = '',\n\t                                       active       = '0',\n\t                                       accepted     = '1',\n\t                                       filetype     = 'folder',\n\t                                       sent_date    = '" . $now . "',\n\t                                       qualification    = '" . $parent_data['qualification'] . "',\n\t                                       parent_id    = '',\n\t                                       qualificator_id  = '',\n\t                                       date_of_qualification    = '0000-00-00 00:00:00',\n\t                                       session_id   = " . $new_session_id;
         $rest_insert = Database::query($sql_add_publication);
         if ($debug) {
             echo $sql_add_publication;
         }
         // add the directory
         $id = Database::insert_id();
         //Folder created
         api_item_property_update($course_info, 'work', $id, 'DirectoryCreated', api_get_user_id());
         if ($debug) {
             var_dump($rest_insert);
         }
         $new_parent_id = $id;
         $result_message[$TBL_STUDENT_PUBLICATION . ' - new folder created called: ' . $created_dir]++;
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:user_move_stats.php

示例13: importStudents

 /**
  * @param string $file
  * @param bool $moveFile
  */
 private function importStudents($file, $moveFile = true)
 {
     $data = Import::csv_to_array($file);
     /*
     * Another users import.
             Unique identifier: official code and username . ok
             Password should never get updated. ok
             If an update should need to occur (because it changed in the .csv),
             we’ll want that logged. We will handle this manually in that case.
             All other fields should be updateable, though passwords should of course not get updated. ok
             If a user gets deleted (not there anymore),
             He should be set inactive one year after the current date.
             So I presume you’ll just update the expiration date.
             We want to grant access to courses up to a year after deletion.
     */
     if (!empty($data)) {
         $language = $this->defaultLanguage;
         $this->logger->addInfo(count($data) . " records found.");
         foreach ($data as $row) {
             $row = $this->cleanUserRow($row);
             $user_id = UserManager::get_user_id_from_original_id($row['extra_' . $this->extraFieldIdNameList['user']], $this->extraFieldIdNameList['user']);
             $userInfo = array();
             $userInfoByOfficialCode = null;
             if (!empty($user_id)) {
                 $userInfo = api_get_user_info($user_id);
                 $userInfoByOfficialCode = api_get_user_info_from_official_code($row['official_code']);
             }
             $expirationDate = api_get_utc_datetime(strtotime("+" . intval($this->expirationDateInUserCreation) . "years"));
             if (empty($userInfo) && empty($userInfoByOfficialCode)) {
                 // Create user
                 $result = UserManager::create_user($row['firstname'], $row['lastname'], STUDENT, $row['email'], $row['username'], $row['password'], $row['official_code'], $language, $row['phone'], null, $row['auth_source'], $expirationDate, 1, 0, null, null, false);
                 if ($result) {
                     foreach ($row as $key => $value) {
                         if (substr($key, 0, 6) == 'extra_') {
                             //an extra field
                             UserManager::update_extra_field_value($result, substr($key, 6), $value);
                         }
                     }
                     $this->logger->addInfo("Students - User created: " . $row['username']);
                 } else {
                     $this->logger->addError("Students - User NOT created: " . $row['username'] . " " . $row['firstname'] . " " . $row['lastname']);
                 }
             } else {
                 if (empty($userInfo)) {
                     $this->logger->addError("Students - Can't update user :" . $row['username']);
                     continue;
                 }
                 if ($row['action'] == 'delete') {
                     // Inactive one year later
                     $userInfo['expiration_date'] = api_get_utc_datetime(api_strtotime(time() + 365 * 24 * 60 * 60));
                 }
                 $password = $row['password'];
                 // change password
                 $email = $row['email'];
                 // change email
                 $resetPassword = 2;
                 // allow password change
                 // Conditions that disables the update of password and email:
                 if (isset($this->conditions['importStudents'])) {
                     if (isset($this->conditions['importStudents']['update']) && isset($this->conditions['importStudents']['update']['avoid'])) {
                         // Blocking email update -
                         // 1. Condition
                         $avoidUsersWithEmail = $this->conditions['importStudents']['update']['avoid']['email'];
                         if ($userInfo['email'] != $row['email'] && in_array($row['email'], $avoidUsersWithEmail)) {
                             $this->logger->addInfo("Students - User email is not updated : " . $row['username'] . " because the avoid conditions (email).");
                             // Do not change email keep the old email.
                             $email = $userInfo['email'];
                         }
                         // 2. Condition
                         if (!in_array($userInfo['email'], $avoidUsersWithEmail) && !in_array($row['email'], $avoidUsersWithEmail)) {
                             $email = $userInfo['email'];
                         }
                         // 3. Condition
                         if (in_array($userInfo['email'], $avoidUsersWithEmail) && !in_array($row['email'], $avoidUsersWithEmail)) {
                             $email = $row['email'];
                         }
                         // Blocking password update
                         $avoidUsersWithPassword = $this->conditions['importStudents']['update']['avoid']['password'];
                         if ($userInfo['password'] != api_get_encrypted_password($row['password']) && in_array($row['password'], $avoidUsersWithPassword)) {
                             $this->logger->addInfo("Students - User password is not updated: " . $row['username'] . " because the avoid conditions (password).");
                             $password = null;
                             $resetPassword = 0;
                             // disallow password change
                         }
                     }
                 }
                 $expirationDate = api_get_utc_datetime(strtotime("+" . intval($this->expirationDateInUserUpdate) . "years"));
                 // Update user
                 $result = UserManager::update_user($userInfo['user_id'], $row['firstname'], $row['lastname'], $row['username'], $password, $row['auth_source'], $email, STUDENT, $userInfo['official_code'], $userInfo['phone'], $userInfo['picture_uri'], $expirationDate, $userInfo['active'], null, 0, null, null, null, false, $resetPassword);
                 if ($result) {
                     if ($row['username'] != $userInfo['username']) {
                         $this->logger->addInfo("Students - Username was changes from '" . $userInfo['username'] . "' to '" . $row['username'] . "' ");
                     }
                     foreach ($row as $key => $value) {
                         if (substr($key, 0, 6) == 'extra_') {
                             //an extra field
//.........这里部分代码省略.........
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:101,代码来源:import_csv.php

示例14: create_course_request

 /**
  * Creates a new course request within the database.
  * @param string $wanted_code       The code for the created in the future course.
  * @param string $title
  * @param string $description
  * @param string $category_code
  * @param string $course_language
  * @param string $objetives
  * @param string $target_audience
  * @param int/string $user_id
  * @return int/bool The database id of the newly created course request or FALSE on failure.
  */
 public static function create_course_request($wanted_code, $title, $description, $category_code, $course_language, $objetives, $target_audience, $user_id, $exemplary_content)
 {
     $wanted_code = trim($wanted_code);
     $user_id = (int) $user_id;
     $exemplary_content = (bool) $exemplary_content ? 1 : 0;
     if ($wanted_code == '') {
         return false;
     }
     if (self::course_code_exists($wanted_code)) {
         return false;
     }
     if ($user_id <= 0) {
         return false;
     }
     $user_info = api_get_user_info($user_id);
     if (!is_array($user_info)) {
         return false;
     }
     $tutor_name = api_get_person_name($user_info['firstname'], $user_info['lastname'], null, null, $course_language);
     $request_date = api_get_utc_datetime();
     $status = COURSE_REQUEST_PENDING;
     $info = 0;
     $keys = AddCourse::define_course_keys($wanted_code, '');
     if (!count($keys)) {
         return false;
     }
     $visual_code = $keys['currentCourseCode'];
     $code = $keys['currentCourseId'];
     $db_name = isset($keys['currentCourseDbName']) ? $keys['currentCourseDbName'] : null;
     $directory = $keys['currentCourseRepository'];
     $sql = sprintf('INSERT INTO %s (
             code, user_id, directory, db_name,
             course_language, title, description, category_code,
             tutor_name, visual_code, request_date,
             objetives, target_audience, status, info, exemplary_content)
         VALUES (
             "%s", "%s", "%s", "%s",
             "%s", "%s", "%s", "%s",
             "%s", "%s", "%s",
             "%s", "%s", "%s", "%s", "%s");', Database::get_main_table(TABLE_MAIN_COURSE_REQUEST), Database::escape_string($code), Database::escape_string($user_id), Database::escape_string($directory), Database::escape_string($db_name), Database::escape_string($course_language), Database::escape_string($title), Database::escape_string($description), Database::escape_string($category_code), Database::escape_string($tutor_name), Database::escape_string($visual_code), Database::escape_string($request_date), Database::escape_string($objetives), Database::escape_string($target_audience), Database::escape_string($status), Database::escape_string($info), Database::escape_string($exemplary_content));
     $result_sql = Database::query($sql);
     if (!$result_sql) {
         return false;
     }
     $last_insert_id = Database::insert_id();
     // E-mail notifications.
     // E-mail language: The platform language seems to be the best choice.
     $email_language = api_get_setting('platformLanguage');
     $email_subject = sprintf(get_lang('CourseRequestEmailSubject', null, $email_language), '[' . api_get_setting('siteName') . ']', $code);
     $email_body = get_lang('CourseRequestMailOpening', null, $email_language) . "\n\n";
     $email_body .= get_lang('CourseName', null, $email_language) . ': ' . $title . "\n";
     $email_body .= get_lang('Fac', null, $email_language) . ': ' . $category_code . "\n";
     $email_body .= get_lang('CourseCode', null, $email_language) . ': ' . $code . "\n";
     $email_body .= get_lang('Professor', null, $email_language) . ': ' . api_get_person_name($user_info['firstname'], $user_info['lastname'], null, null, $email_language) . "\n";
     $email_body .= get_lang('Email', null, $email_language) . ': ' . $user_info['mail'] . "\n";
     $email_body .= get_lang('Description', null, $email_language) . ': ' . $description . "\n";
     $email_body .= get_lang('Objectives', null, $email_language) . ': ' . $objetives . "\n";
     $email_body .= get_lang('TargetAudience', null, $email_language) . ': ' . $target_audience . "\n";
     $email_body .= get_lang('Ln', null, $email_language) . ': ' . $course_language . "\n";
     $email_body .= get_lang('FillWithExemplaryContent', null, $email_language) . ': ' . ($exemplary_content ? get_lang('Yes', null, $email_language) : get_lang('No', null, $email_language)) . "\n";
     // Sending an e-mail to the platform administrator.
     $email_body_admin = $email_body;
     $email_body_admin .= "\n" . get_lang('CourseRequestPageForApproval', null, $email_language) . ' ' . api_get_path(WEB_CODE_PATH) . 'admin/course_request_edit.php?id=' . $last_insert_id . "\n";
     $email_body_admin .= "\n" . get_lang('CourseRequestLegalNote', null, $email_language) . "\n";
     $sender_name_teacher = api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
     $sender_email_teacher = $user_info['mail'];
     $recipient_name_admin = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
     $recipient_email_admin = api_get_setting('emailAdministrator');
     $userInfo = api_get_user_info($user_id);
     $additionalParameters = array('smsType' => SmsPlugin::NEW_COURSE_SUGGESTED_TEACHER, 'userId' => $user_id, 'userUsername' => $userInfo['username']);
     api_mail_html($recipient_name_admin, $recipient_email_admin, $email_subject, $email_body_admin, $sender_name_teacher, $sender_email_teacher, null, null, null, $additionalParameters);
     // Sending an e-mail to the requestor.
     $email_body_teacher = get_lang('Dear', null, $email_language) . ' ';
     $email_body_teacher .= api_get_person_name($user_info['firstname'], $user_info['lastname'], null, null, $email_language) . ",\n\n";
     $email_body_teacher .= $email_body;
     $email_body_teacher .= "\n" . get_lang('Formula', null, $email_language) . "\n";
     $email_body_teacher .= api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, null, $email_language) . "\n";
     $email_body_teacher .= get_lang('Manager', null, $email_language) . ' ' . api_get_setting('siteName') . "\n";
     $email_body_teacher .= get_lang('Phone', null, $email_language) . ': ' . api_get_setting('administratorTelephone') . "\n";
     $email_body_teacher .= get_lang('Email', null, $email_language) . ': ' . api_get_setting('emailAdministrator', null, $email_language) . "\n";
     $email_body_teacher .= "\n" . get_lang('CourseRequestLegalNote', null, $email_language) . "\n";
     // Swap the sender and the recipient.
     $sender_name_admin = $recipient_name_admin;
     $sender_email_admin = $recipient_email_admin;
     $recipient_name_teacher = $sender_name_teacher;
     $recipient_email_teacher = $sender_email_teacher;
     $additionalParameters = array('smsType' => SmsPlugin::COURSE_OPENING_REQUEST_CODE_REGISTERED, 'userId' => $user_info['user_id'], 'courseCode' => $wanted_code);
     api_mail_html($recipient_name_teacher, $recipient_email_teacher, $email_subject, $email_body_teacher, $sender_name_admin, $sender_email_admin, null, null, null, $additionalParameters);
//.........这里部分代码省略.........
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:101,代码来源:course_request.lib.php

示例15: WSUnsuscribeCoursesFromSession

function WSUnsuscribeCoursesFromSession($params)
{
    if (!WSHelperVerifyKey($params)) {
        return return_error(WS_ERROR_SECRET_KEY);
    }
    // Initialisation
    $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
    $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
    $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
    $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
    $coursessessions_params = $params['coursessessions'];
    $results = array();
    $orig_course_id_value = array();
    $orig_session_id_value = array();
    foreach ($coursessessions_params as $coursesession_param) {
        $original_session_id_value = $coursesession_param['original_session_id_value'];
        $original_session_id_name = $coursesession_param['original_session_id_name'];
        $original_course_id_name = $coursesession_param['original_course_id_name'];
        $original_course_id_values = $coursesession_param['original_course_id_values'];
        $orig_session_id_value[] = $original_session_id_value;
        $id_session = SessionManager::getSessionIdFromOriginalId($original_session_id_value, $original_session_id_name);
        if (empty($id_session)) {
            $results[] = 0;
            continue;
        }
        // Get courses list from row_original_course_id_values
        $course_list = array();
        $courseIdList = [];
        foreach ($original_course_id_values as $row_original_course_list) {
            $course_code = Database::escape_string($row_original_course_list['course_code']);
            // Check whether exits $x_course_code into user_field_values table.
            $courseInfo = CourseManager::getCourseInfoFromOriginalId($row_original_course_list['course_code'], $original_course_id_name);
            if (empty($courseInfo) || isset($courseInfo) && $courseInfo['visibility'] == 0) {
                continue;
                // Course_code doesn't exist'
            }
            $course_list[] = $courseInfo['code'];
            $courseIdList[] = $courseInfo['real_id'];
        }
        if (empty($course_list)) {
            $results[] = 0;
            continue;
        }
        $orig_course_id_value[] = implode(',', $course_list);
        foreach ($courseIdList as $courseId) {
            $courseId = intval($courseId);
            Database::query("DELETE FROM {$tbl_session_rel_course}\n                            WHERE c_id ='{$courseId}' AND session_id='{$id_session}'");
            $result = Database::query("DELETE FROM {$tbl_session_rel_course_rel_user} WHERE c_id='{$courseId}' AND session_id = '{$id_session}'");
            Event::addEvent(LOG_SESSION_DELETE_COURSE, LOG_COURSE_ID, $courseId, api_get_utc_datetime(), api_get_user_id(), $courseId, $id_session);
            $return = Database::affected_rows($result);
        }
        $nbr_courses = 0;
        $sql = "SELECT nbr_courses FROM {$tbl_session} WHERE id = '{$id_session}'";
        $res_nbr_courses = Database::query($sql);
        $row_nbr_courses = Database::fetch_row($res_nbr_courses);
        if (Database::num_rows($res_nbr_courses) > 0) {
            $nbr_users = $row_nbr_courses[0] - $return;
        }
        // Update number of users in the session.
        $update_sql = "UPDATE {$tbl_session} SET nbr_courses= {$nbr_courses} WHERE id='{$id_session}' ";
        Database::query($update_sql);
        $results[] = 1;
        continue;
    }
    $count_results = count($results);
    $output = array();
    for ($i = 0; $i < $count_results; $i++) {
        $output[] = array('original_course_id_values' => $orig_course_id_value[$i], 'original_session_id_value' => $orig_session_id_value[$i], 'result' => $results[$i]);
    }
    return $output;
}
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:71,代码来源:registration.soap.php


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