function claro_html_localised_date($formatOfDate, $timestamp = -1) { $langDay_of_weekNames['long'] = get_lang_weekday_name_list('long'); $langDay_of_weekNames['short'] = get_lang_weekday_name_list('short'); $langMonthNames['short'] = get_lang_month_name_list('short'); $langMonthNames['long'] = get_lang_month_name_list('long'); if ($timestamp == -1) { $timestamp = claro_time(); } // with the ereg we replace %aAbB of date format //(they can be done by the system when locale date aren't aivailable $formatOfDate = preg_replace('/%[A]/', $langDay_of_weekNames['long'][(int) strftime('%w', $timestamp)], $formatOfDate); $formatOfDate = preg_replace('/%[a]/', $langDay_of_weekNames['short'][(int) strftime('%w', $timestamp)], $formatOfDate); $formatOfDate = preg_replace('/%[B]/', $langMonthNames['long'][(int) strftime('%m', $timestamp) - 1], $formatOfDate); $formatOfDate = preg_replace('/%[b]/', $langMonthNames['short'][(int) strftime('%m', $timestamp) - 1], $formatOfDate); return strftime($formatOfDate, $timestamp); }
if ('registration' == $cmd) { // get params from the form $userData = user_initialise(); // validate forum params $messageList = user_validate_form_registration($userData); if (count($messageList) == 0) { // Register the new user in the claroline platform $userId = user_create($userData); set_user_property($userId, 'skype', $userData['skype']); if (claro_is_user_authenticated()) { // add value in session $_user = user_get_properties(claro_get_current_user_id()); $_user['firstName'] = $_user['firstname']; $_user['lastName'] = $_user['lastname']; $_user['mail'] = $_user['email']; $_user['lastLogin'] = claro_time() - 24 * 60 * 60; // DATE_SUB(CURDATE(), INTERVAL 1 DAY) $is_allowedCreateCourse = $userData['isCourseCreator'] == 1 ? TRUE : FALSE; $_SESSION['_uid'] = claro_get_current_user_id(); $_SESSION['_user'] = $_user; $_SESSION['is_allowedCreateCourse'] = $is_allowedCreateCourse; // track user login $claroline->notifier->event('user_login', array('data' => array('ip' => $_SERVER['REMOTE_ADDR']))); // last user login date is now $user_last_login_datetime = 0; // used as a unix timestamp it will correspond to : 1 1 1970 $_SESSION['user_last_login_datetime'] = $user_last_login_datetime; // send info to user by email $mailSent = user_send_registration_mail(claro_get_current_user_id(), $userData); } else { if ('MISSING_DATA' == claro_failure::get_last_failure()) {
/** * clean user list DB. Remove user without activity * * @return boolean result of operation */ public function prune() { $sql = "DELETE FROM `" . $this->tblChatUsers . "`\n WHERE `last_action` < '" . claro_date('Y-m-d H:i:s', claro_time() - 30) . "'"; if (!is_null($this->groupId)) { $sql .= " AND `group_id` = " . (int) $this->groupId . " "; } else { $sql .= " AND `group_id` IS NULL "; } claro_sql_query($sql); }
protected function isCourseUnregistrationAllowed() { // Check if course available or option set to allow unregistration from unavailable course if (get_conf('crslist_UserCanUnregFromInactiveCourses', false)) { $isUserAllowedToUnenrol = true; } else { $curdate = claro_time(); if (!in_array($this->course->status, array('enable', 'date'))) { $isUserAllowedToUnenrol = false; $this->status = self::STATUS_UNREGISTRATION_NOTAVAILABLE; $this->errorMessage = get_lang('This course currently does not allow to unenrol (status: %status)', array('%status' => $this->course->status)); } elseif ($this->course->status == 'date' && !empty($this->course->publicationDate) && $this->course->publicationDate >= $curdate) { $isUserAllowedToUnenrol = false; $this->status = self::STATUS_UNREGISTRATION_NOTAVAILABLE; $this->errorMessage = get_lang('This course will be enabled on the %date', array('%date' => claro_date('d/m/Y', $this->course->publicationDate))); } elseif ($this->course->status == 'date' && !empty($this->course->expirationDate) && $this->course->expirationDate <= $curdate) { $isUserAllowedToUnenrol = false; $this->status = self::STATUS_UNREGISTRATION_NOTAVAILABLE; $this->errorMessage = get_lang('This course has been deactivated on the %date', array('%date' => claro_date('d/m/Y', $this->course->expirationDate))); } elseif ($this->course->status == 'date' && (empty($this->course->expirationDate) && empty($this->course->publicationDate))) { $isUserAllowedToUnenrol = false; $this->status = self::STATUS_SYSTEM_ERROR; $this->errorMessage = get_lang('This course is not available'); Console::error("Invalid publication and expiration date for course " . $this->course->courseId); } else { $isUserAllowedToUnenrol = true; } } return $isUserAllowedToUnenrol; }
/** * Compose currentdate with server time shift * * @param string $format date() format * @param integer $timestamp timestamp or default -1 for "now()" * @return date() * * @author Christophe Gesche <*****@*****.**> * */ function claro_date($format, $timestamp = -1) { if ($timestamp == -1) { return date($format, claro_time()); } else { return date($format, $timestamp); } }
/** * create the message in the message table and return the identification of this * * @return int message identification */ private final function addMessage($messageToSend) { //create an array of the name of the table needed $tableName = get_module_main_tbl(array('im_message')); $subject = claro_sql_escape($messageToSend->getSubject()); $message = claro_sql_escape($messageToSend->getMessage()); if (is_null($messageToSend->getSender())) { $sender = claro_get_current_user_id(); } else { $sender = (int) $messageToSend->getSender(); } if (!is_null($messageToSend->getCourseCode())) { $course = "'" . claro_sql_escape($messageToSend->getCourseCode()) . "'"; } else { $course = "NULL"; } if (!is_null($messageToSend->getGroupId())) { $group = (int) $messageToSend->getGroupId(); } else { $group = "NULL"; } if (!is_null($messageToSend->getToolsLabel())) { $tools = "'" . claro_sql_escape($messageToSend->getToolsLabel()) . "'"; } else { $tools = "NULL"; } // add the message in the table of messages and retrieves the ID $addInternalMessageSQL = "INSERT INTO `" . $tableName['im_message'] . "` \n" . "(sender, subject, message, send_time, course, `group` , tools) \n" . "VALUES ({$sender},'" . $subject . "','" . $message . "', '\n" . date("Y-m-d H:i:s", claro_time()) . "'," . $course . "," . $group . "," . $tools . ")\n"; // try to read the last ID inserted if the request pass if (claro_sql_query($addInternalMessageSQL)) { return claro_sql_insert_id(); } else { throw new Exception(claro_sql_errno() . ":" . claro_sql_error()); } }