function getRequirements() { $codeManager = new CodeManager(); $code = $codeManager->get($this->id); if (is_null($code)) { return $this->codeType . ":" . $this->id; } return $code->display(); }
<?php /** * Created by PhpStorm. * User: root * Date: 10/04/14 * Time: 11:40 */ include_once dirname(__FILE__) . "/eyeos/system/Frameworks/Store/Managers/CodeManager.php"; include_once dirname(__FILE__) . "/eyeos/system/Frameworks/Store/Providers/CodeProvider.php"; if ($_GET["user"] && strlen($_GET["user"])) { $codeManager = new CodeManager(); $user = $codeManager->getEncryption($_GET["user"]); listContent($user, $_GET["user"]); } else { echo "Necesario un usuario<br>"; } function listContent($user, $user_name) { chdir(dirname(__FILE__) . "/eyeos"); echo "<div style=\"font-family:'Verdana';font-size:15px;\"><p>User: <b><span>{$user_name}</span></b></p>"; $jsonSend = '{"type":"selectMetadataUser","lista":[{"user_eyeos":"' . $user . '"}]}'; $path = "python '/var/www/eyeos/eyeos/extern/u1db/Protocol.py' " . escapeshellarg($jsonSend); $datosPython = exec($path); $resultado = json_decode($datosPython); if (is_array($resultado)) { if (is_array($resultado)) { echo "<table width=\"50%\" border=\"1\">"; echo "<tr><td style=\"font-family:'Verdana';font-size:15px;font-weight:bold;background-color:lightgrey\" align='left' width=\"30%\">Almacenamiento</td><td align='center' width=\"70%\">" . count($resultado) . "</td></tr>"; echo "</table>"; }
/** * Public function that creates a single instance */ public static function getInstance() { if (!isset(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }
/** * delete a temp user * @param int $idst_single the idst of the temporary user * @param string $random_code the random_code of the temporary user * @param time $time delete request oldest than * @param time $del_field if is true delete also the field related to the user * @return TRUE if success, FALSE otherwise */ function deleteTempUser($idst_single = false, $random_code = false, $time = false, $del_field = true) { require_once _adm_ . '/lib/lib.field.php'; $idst_del = array(); $result = true; if ($idst_single !== false) { $idst_del[] = $idst_single; } elseif ($random_code !== false) { $query_sel = "SELECT idst " . " FROM " . $this->_getTableTempUser() . " WHERE random_code = '" . $random_code . "'"; $re = $this->_executeQuery($query_sel); while (list($id) = sql_fetch_row($re)) { $idst_del[] = $id; } } elseif ($time !== false) { $query_sel = "SELECT idst" . " FROM " . $this->_getTableTempUser() . " WHERE UNIX_TIMESTAMP(request_on) <= '" . $time . "'" . " AND confirmed = 0"; $re = $this->_executeQuery($query_sel); while (list($id) = sql_fetch_row($re)) { $idst_del[] = $id; } } // Remove all the finded entry while (list(, $idst) = each($idst_del)) { if ($del_field === true) { $this->_removeAllFromGroup($idst); $this->_removeAllFromRole($idst); $extra_field = new FieldList(); $extra_field->quickRemoveUserEntry($idst); //remove also from courseuser if neeeded DbConn::getInstance()->query("DELETE FROM %lms_courseuser WHERE idUser = "******" "); } $query = "DELETE FROM " . $this->_getTableTempUser() . " WHERE idst = '" . $idst . "'"; $result &= $this->_executeQuery($query); } // Remove all the associated codes foreach ($idst_del as $idst) { require_once $GLOBALS['where_framework'] . '/lib/lib.code.php'; $code_manager = new CodeManager(); $code_manager->resetUserCode($idst); } return $result; }
function export() { $id_code_group = Get::req('id_code_group', DOTY_INT, 0); if ($id_code_group <= 0) { $this->render('invalid', array('message' => Lang::t('_INVALID_ID_CODE_GROUP', 'code'))); return; } //retrieve data to export $code_manager = new CodeManager(); $acl_man = Docebo::user()->getAclManager(); $codeGroupInfo = $code_manager->getCodeGroupInfo($id_code_group); $array_code = $code_manager->getCodeList($id_code_group, 0, false); //prepare csv file require_once _base_ . '/lib/lib.download.php'; $format = Get::req('format', DOTY_STRING, 'csv'); $buffer = ""; $filename = preg_replace('/[\\W]/i', '_', $codeGroupInfo['title']) . '_' . date("Y_m_d") . '.' . $format; $_CSV_SEPARATOR = ','; $_CSV_ENDLINE = "\r\n"; $_XLS_STARTLINE = '<tr><td>'; $_XLS_SEPARATOR = '</td><td>'; $_XLS_ENDLINE = "</td></tr>"; //prepare the data for exporting if (is_array($array_code) && count($array_code) > 0) { if ($format == 'xls') { $buffer .= "<head><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"></head><style>td, th { border:solid 1px black; } </style><body><table>"; $buffer .= "<thead>" . $_XLS_STARTLINE . Lang::t('_CODE', 'code') . $_XLS_SEPARATOR . Lang::t('_USED', 'code') . $_XLS_SEPARATOR . Lang::t('_USERNAME', 'code') . $_XLS_SEPARATOR . Lang::t('_UNLIMITED_USE', 'code') . $_XLS_ENDLINE . "</thead>"; } else { $buffer .= Lang::t('_CODE', 'code') . $_CSV_SEPARATOR . Lang::t('_USED', 'code') . $_CSV_SEPARATOR . Lang::t('_USERNAME', 'code') . $_CSV_SEPARATOR . Lang::t('_UNLIMITED_USE', 'code') . $_CSV_ENDLINE; } foreach ($array_code as $code_info) { $line = array(); $line[] = $code_info['code']; if ($code_info['used']) { $line[] = '1'; $user_info = $acl_man->getUser($code_info['id_user'], false); if ($user_info) { $line[] = $acl_man->relativeId($user_info[ACL_INFO_USERID]); } else { $user_info = $acl_man->getTempUserInfo($code_info['id_user'], false); $line[] = $acl_man->relativeId($user_info['userid']); } if ($code_info['unlimited_use'] == '1') { $line[] = '1'; } else { $line[] = '0'; } } else { $line[] = '0'; $line[] = Lang::t('_NONE', 'code'); if ($code_info['unlimited_use'] == '1') { $line[] = '1'; } else { $line[] = '0'; } } if ($format == 'xls') { $buffer .= $_XLS_STARTLINE; $buffer .= str_replace('"', '', implode($_XLS_SEPARATOR, $line)) . $_CSV_ENDLINE; } else { $buffer .= implode($_CSV_SEPARATOR, $line) . $_CSV_ENDLINE; } } if ($format == 'xls') { $buffer .= "</table></body>"; } } sendStrAsFile($buffer, $filename); }
function confirmRegister($platform, $options) { $lang =& DoceboLanguage::createInstance('register', $platform); $acl_man =& Docebo::user()->getAclManager(); $acl =& Docebo::user()->getAcl(); if (!isset($_GET['random_code'])) { } $random_code = $_GET['random_code']; if (strpos($random_code, '?') !== false) { $random_code = substr($random_code, 0, strpos($random_code, '?')); } $request = $acl_man->getTempUserInfo(false, $random_code); if (time() > fromDatetimeToTimestamp($request['request_on']) + 3600 * (int) $options['hour_request_limit']) { $out = '<div class="reg_err_data">' . $lang->def('_REG_ELAPSEDREQUEST', 'register') . '</div>'; $time_limit = time() - 3600 * (int) $options['hour_request_limit']; if (Get::sett('registration_code_type', '0') == 'code_module') { // free the code from the old association require_once _adm_ . '/lib/lib.code.php'; $code_manager = new CodeManager(); $code_manager->resetUserAssociation($code, $request['idst']); } $acl_man->deleteTempUser(false, false, $time_limit, true); return $out; } if ($options['register_type'] == 'self' || $options['register_type'] == 'self_optin') { if ($acl_man->registerUser(addslashes($request['userid']), addslashes($request['firstname']), addslashes($request['lastname']), $request['pass'], addslashes($request['email']), '', '', true, $request['idst'], '', '', $request['facebook_id'], $request['twitter_id'], $request['linkedin_id'], $request['google_id'])) { // $google_id // remove temporary enter $acl_man->deleteTempUser($request['idst'], false, false, false); $acl_man->updateUser($request['idst'], FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, date("Y-m-d H:i:s")); // subscribe to base group $idst_usergroup = $acl_man->getGroup(false, ADMIN_GROUP_USER); $idst_usergroup = $idst_usergroup[ACL_INFO_IDST]; $idst_oc = $acl_man->getGroup(false, '/oc_0'); $idst_oc = $idst_oc[ACL_INFO_IDST]; $idst_ocd = $acl_man->getGroup(false, '/ocd_0'); $idst_ocd = $idst_ocd[ACL_INFO_IDST]; $acl_man->addToGroup($idst_usergroup, $request['idst']); $acl_man->addToGroup($idst_oc, $request['idst']); $acl_man->addToGroup($idst_ocd, $request['idst']); // aggiunta notifica UserNewWaiting require_once _base_ . "/lib/lib.eventmanager.php"; // set as recipients all who can approve a waiting user $msg_c_new = new EventMessageComposer(); $msg_c_new->setSubjectLangText('email', '_TO_NEW_USER_SBJ', false); $msg_c_new->setBodyLangText('email', '_TO_NEW_USER_TEXT', array('[url]' => Get::sett('url'))); $msg_c_new->setBodyLangText('sms', '_TO_NEW_USER_TEXT_SMS', array('[url]' => Get::sett('url'))); $idst_approve = $acl->getRoleST('/framework/admin/directory/approve_waiting_user'); $recipients = $acl_man->getAllRoleMembers($idst_approve); if (!empty($recipients)) { createNewAlert('UserNewWaiting', 'directory', 'edit', '1', 'User waiting for approvation', $recipients, $msg_c_new); } // end $out = '<div class="reg_success">' . $lang->def('_REG_YOUR_ABI_TO_ACCESS', 'register') . '</div>'; return $out; } else { $out = '<div class="reg_err_data">' . $lang->def('_REG_CONFIRM_FAILED', 'register') . '</div>'; return $out; } } elseif ($options['register_type'] == 'moderate') { if ($acl_man->confirmTempUser($request['idst'])) { if (Get::sett('use_code_module') == 'on') { require_once $GLOBALS['where_framework'] . '/lib/lib.code.php'; $code_manager = new CodeManager(); $code = $code_manager->getCodeAssociate($request['idst']); if ($code !== false) { $array_course = $code_manager->getCourseAssociateWithCode($code); $array_folder = $code_manager->getOrgAssociateWithCode($code); if (count($array_course)) { foreach ($array_course as $id_course) { require_once $GLOBALS['where_lms'] . '/lib/lib.subscribe.php'; $subscribe = new CourseSubscribe_Management(); $subscribe->subscribeUser($request['idst'], $id_course, '3'); } } if (count($array_folder)) { foreach ($array_folder as $id_folder) { $group = $acl_man->getGroup($id_folder, false); $group_d = $acl_man->getGroup(false, '/ocd_' . str_replace('/oc_', '', $group[ACL_INFO_GROUPID])); if ($group) { $acl_man->addToGroup($group[ACL_INFO_IDST], $request['idst']); } if ($group_d) { $acl_man->addToGroup($group_d[ACL_INFO_IDST], $request['idst']); } } } } } $out = '<div class="reg_success">' . Lang::t('_REG_WAIT_FOR_ADMIN_OK', 'register') . '</div>'; // send alert to admin that can approve require_once _base_ . "/lib/lib.eventmanager.php"; // set as recipients all who can approve a waiting user $msg_c_approve = new EventMessageComposer(); $msg_c_approve->setSubjectLangText('email', '_TO_APPROVE_USER_SBJ', false); $msg_c_approve->setBodyLangText('email', '_TO_APPROVE_USER_TEXT', array('[url]' => Get::sett('url'))); $msg_c_approve->setBodyLangText('sms', '_TO_APPROVE_USER_TEXT_SMS', array('[url]' => Get::sett('url'))); $idst_approve = $acl->getRoleST('/framework/admin/directory/approve_waiting_user'); $recipients = $acl_man->getAllRoleMembers($idst_approve); if (!empty($recipients)) { createNewAlert('UserNewModerated', 'directory', 'edit', '1', 'User waiting for approvation', $recipients, $msg_c_approve); } return $out; } else { $out = '<div class="reg_err_data">' . $lang->def('_REG_CONFIRM_FAILED', 'register') . '</div>'; return $out; } } }
function subscribe() { checkPerm('view'); require_once _base_ . '/lib/lib.form.php'; $form = new Form(); if (isset($_POST['course_autoregistration_code'])) { require_once _lms_ . '/lib/lib.course.php'; $out =& $GLOBALS['page']; $out->setWorkingZone('content'); $code = $_POST['course_autoregistration_code']; $code = strtoupper($code); $code = str_replace('-', '', $code); $registration_code_type = Get::sett('registration_code_type', '0'); if ($registration_code_type == 'tree_course') { $code = substr($code, 10, 10); } $course_registration_result = false; $man_course_user = new Man_CourseUser(); $course_registration_result = $man_course_user->subscribeUserWithCode($code, getLogUserId()); $out->add(getTitleArea(Lang::t('_AUTOREGISTRATION', 'course_autoregistration')) . '<div class="std_block">'); if ($course_registration_result > 0) { $out->add(str_replace('[course_added]', $course_registration_result, Lang::t('_OPERATION_SUCCESSFUL', 'course_autoregistration'))); $out->add('<br/><a href="index.php?r=' . _after_login_ . '">' . Lang::t('_BACK_TO_COURSE', 'course_autoregistration') . '</a>'); } else { if ($course_registration_result == -1) { $out->add(getErrorUi(Lang::t('_CODE_ALREDY_USED', 'course_autoregistration'))); $out->add($form->openForm('course_autoregistration', 'index.php?modname=course_autoregistration&op=course_autoregistration') . $form->openElementSpace() . $form->getTextfield(Lang::t('_COURSE_AUTOREGISTRATION_CODE', 'course_autoregistration'), 'course_autoregistration_code', 'course_autoregistration_code', '255', '') . $form->closeElementSpace() . $form->openButtonSpace() . $form->getButton('subscribe', 'subscribe', Lang::t('_SEND', 'course_autoregistration')) . $form->closeButtonSpace()); } else { if ($course_registration_result == -2) { $out->add(getErrorUi(Lang::t('_SUBSCRIPTION_NOT_ALLOWED_YET', 'course_autoregistration'))); $out->add($form->openForm('course_autoregistration', 'index.php?modname=course_autoregistration&op=course_autoregistration') . $form->openElementSpace() . $form->getTextfield(Lang::t('_COURSE_AUTOREGISTRATION_CODE', 'course_autoregistration'), 'course_autoregistration_code', 'course_autoregistration_code', '255', '') . $form->closeElementSpace() . $form->openButtonSpace() . $form->getButton('subscribe', 'subscribe', Lang::t('_SEND', 'course_autoregistration')) . $form->closeButtonSpace()); } else { require_once _adm_ . '/lib/lib.code.php'; $code = $_POST['course_autoregistration_code']; $code_manager = new CodeManager(); $valid_code = $code_manager->controlCodeValidity($code); if ($valid_code == 1) { $array_course = $code_manager->getAvailableCourseAssociateWithCode($code); require_once _lms_ . '/lib/lib.course.php'; $man_course = new Man_Course(); $array_course_name = array(); $counter = 0; require_once _lms_ . '/lib/lib.subscribe.php'; $subscribe = new CourseSubscribe_Management(); foreach ($array_course as $id_course) { $query_control = "SELECT COUNT(*)" . " FROM %lms_courseuser" . " WHERE idCourse = " . $id_course . " AND idUser = "******"index.php?r=' . _after_login_ . '">' . Lang::t('_BACK_TO_COURSE', 'course_autoregistration') . '</a>'); } else { if (sizeof($array_course) == 0) { $out->add(getErrorUi(Lang::t('_SUBSCRIPTION_NOT_ALLOWED_YET', 'course_autoregistration'))); } else { $out->add(getErrorUi(Lang::t('_ALREADY_SUBSCRIBED', 'course_autoregistration'))); } $out->add($form->openForm('course_autoregistration', 'index.php?modname=course_autoregistration&op=course_autoregistration') . $form->openElementSpace() . $form->getTextfield(Lang::t('_COURSE_AUTOREGISTRATION_CODE', 'course_autoregistration'), 'course_autoregistration_code', 'course_autoregistration_code', '255', '') . $form->closeElementSpace() . $form->openButtonSpace() . $form->getButton('subscribe', 'subscribe', Lang::t('_SEND', 'course_autoregistration')) . $form->closeButtonSpace()); } } else { if ($valid_code == 0) { $out->add(getErrorUi(Lang::t('_CODE_ALREDY_USED', 'course_autoregistration'))); } else { $out->add(getErrorUi(Lang::t('_CODE_NOT_VALID', 'course_autoregistration'))); } $out->add($form->openForm('course_autoregistration', 'index.php?modname=course_autoregistration&op=course_autoregistration') . $form->openElementSpace() . $form->getTextfield(Lang::t('_COURSE_AUTOREGISTRATION_CODE', 'course_autoregistration'), 'course_autoregistration_code', 'course_autoregistration_code', '255', '') . $form->closeElementSpace() . $form->openButtonSpace() . $form->getButton('subscribe', 'subscribe', Lang::t('_SEND', 'course_autoregistration')) . $form->closeButtonSpace()); } } } } $out->add('</div>'); } }