public function generate_certificate($permissions = 0) { require $_SERVER['DOCUMENT_ROOT'] . '/application/models/Certificate.php'; $certificate = new Certificate(Certificate::kContextChannel); $certificate->setData(array('certificate' => $this->certificate, 'id' => $this->channelId(), 'permissions' => $permissions)); return $certificate->toArray(); }
public function test_signature() { $cert = new Certificate($this->manager->file_path('certificate.p12')); $this->manager->generate_file('manifest.json', ''); $signature = $cert->signature($this->manager->file_path('manifest.json'), $this->manager->file_path('signature')); $this->assertNotNull($signature); }
public static function read_by_get_key() { $key = $_GET['Key']; $certificate = new Certificate(); $evaluator = Evaluator::read_by_key($key); $certificate->set_by_evaluator($evaluator, false); $certificate->adjust(); return $certificate->get_data(); }
/** * @param $privateCertPfx * @param $privateCertPass * @param bool $productionMode * @throws Exception if there are problems with certificate loading */ public function __construct($privateCertPfx, $privateCertPass, $productionMode = FALSE) { $this->cert = new Certificate(); $this->cert->loadFile($privateCertPfx, $privateCertPass); $this->cis = new CIS_Service(); if ($productionMode) { $this->setProductionMode(); } }
public function test_generate_zip() { $manager = new Pass_File_Manager($this->pass); \Fuel\Core\File::copy(APPPATH . 'tests/certificate.p12', $manager->file_path('certificate.p12')); $cert_password = ''; $manager->generate_file('pass.json', $this->pass->pass_json()); $manager->generate_file('manifest.json', $this->pass->manifest($manager->files())); $cert = new Certificate($manager->file_path('certificate.p12')); $signature = $cert->signature($manager->file_path('manifest.json'), $manager->file_path('signature')); $manager->generate_file('signature', $signature); $this->assertTrue($manager->generate_zip()); $this->assertFileExists($manager->pkpass_path()); }
public function generate_certificate() { $certificate = false; if (!$this->certificate) { if ($this->owner && $this->id) { require $_SERVER['DOCUMENT_ROOT'] . '/application/models/Certificate.php'; $certificate = new Certificate(Certificate::kContextApplication); $certificate->setData(array('owner' => $this->owner, 'instance' => $this->type, 'application' => $this->id, 'description' => $this->description, 'domain' => $this->domain)); $certificate = $certificate->toArray(); $this->certificate = $certificate; } } return $this->certificate; }
public function toArray() { $toArray = parent::toArray(); $toArray['Barrier Level'] = $this->barrier_level; $toArray['Barrier Hit?'] = $this->isBarrierHit() ? 'YES' : 'NO'; return $toArray; }
/** * __construct() create a new Robot_Certificate */ function __construct($cert) { parent::__construct($cert); /* Not expired? */ if (!$this->isValid()) { throw new CertificateException("The certificate is not valid. Rejected."); } $this->getCertFromDB(true); $this->changed = array(); }
protected function _validateWithOpenSsl() { $command = new Janus_OpenSsl_Command_Verify(); if (isset($this->_trustedRootCertificateAuthorityFile)) { $command->setCertificateAuthorityFile($this->_trustedRootCertificateAuthorityFile); } // Open ssl command does not return it's error output when called indirectly $command->enableErrorToOutputRedirection(); $command->execute($this->_certificate->getPem()); $results = $command->getParsedResults(); $this->_isValid = $results['valid']; foreach ($results['errors'] as $openSslErrorCode => $openSslError) { if ($openSslErrorCode === OPENSSL_X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT) { if ($this->_ignoreOnSelfSigned) { continue; } elseif ($this->_warnOnSelfSigned) { $this->_warnings[] = self::WARNING_PREFIX . $openSslError['description']; continue; } } $this->_errors[] = self::ERROR_PREFIX . $openSslError['description']; } }
/** * insertNewCertificate() insert the new certificate into the robot hold * * Take a string holding the certificate and insert it into the keyhold * given that the string is actually holding a valid certificate. * * @param String base64 encoded PEM formatted X.509 certificate * @return boolean indicating the success of the opreation (true means inserted OK) */ private function insertCertificate($certificate, $comment) { /* validate certificate */ try { $cert = new Certificate($certificate); } catch (KeyNotFoundException $knfe) { Framework::error_output(htmlentities($knfe->getMessage())); return false; } catch (CertificateException $ce) { Framework::error_output(htmlentities($ce->getMessage())); return false; } /* Find valid_until for cert */ try { $query = "SELECT subscriber_id, uploaded_by, uploaded_date, valid_until, fingerprint "; $query .= "FROM robot_certs WHERE fingerprint = ? OR serial=?"; $res = MDB2Wrapper::execute($query, array('text', 'text'), array($cert->getFingerprint(), $cert->getSerial())); if (count($res) > 0) { Framework::error_output($this->translateTag('l10n_err_certalrthere', 'robot')); return false; } } catch (Exception $e) { /* FIXME, add better exception mask & handling */ Framework::error_output(__FILE__ . ":" . __LINE__ . " FIXME: " . htmlentities($e->getMessage())); return false; } /* Get subscriber, nren and admin_id */ try { $query = "SELECT * FROM admins WHERE admin=? AND subscriber=? AND nren=? "; $params = array('text', 'text', 'text'); $data = array($this->person->getEPPN(), $this->person->getSubscriber()->getDBID(), $this->person->getNREN()->getID()); $res = MDB2Wrapper::execute($query, $params, $data); switch (count($res)) { case 0: /* * Strange error. User is admin, yet not admin. * * Fixme: better error-reporting here, even * though we cannot do much about it. */ $error_code = strtoupper(PW::create(8)); $error_msg = "[error_code: {$error_code}]<br /><br />\n"; $log_msg = "[{$error_code}] "; $query = "SELECT * FROM admins WHERE admin=? AND admin_level=? AND subscriber IS NULL"; $params = array('text', 'text'); $data = array($this->person->getEPPN(), SUBSCRIBER_ADMIN); $admin_query_res = MDB2Wrapper::execute($query, $params, $data); if (count($admin_query_res) != 0) { $error_msg .= "The subscriber-admin (" . htmlentites($this->person->getEPPN()) . ") is not properly connected "; $error_msg .= "to any database. This is due to a database inconsistency "; $error_msg .= "and is a direct result of someone manually adding the admin to the database "; $error_msg .= "without connecting the admin to a subscriber."; $log_msg .= "Subscriber-admin " . $this->person->getEPPN(); $log_msg .= " has not set any affilitated subscriber in the database."; $log_msg .= " It should be " . $this->person->getSubscriber()->getOrgName(); $log_msg .= ", but is NULL. Please update the database."; } else { $error_msg .= "For some reason, the subscriber (" . $this->person->getSubscriber()->getOrgName() . ") "; $error_msg .= "is not properly configured in the database. "; $error_msg .= "The exact reason is unknown. Please contact operational support."; $log_msg .= "Subscriber " . $this->person->getSubscriber()->getOrgName(); $log_msg .= " is not properly configured in the database."; } $error_msg .= "<br /><br />\nThis event has been logged, please contact operational support (provide the error-code) "; $error_msg .= "to resolve this issue."; Framework::error_output($error_msg); Logger::log_event(LOG_ALERT, $log_msg); return false; case 1: $admin_id = $res[0]['admin_id']; $nren_id = $res[0]['nren']; $subscriber_id = $res[0]['subscriber']; break; default: /* FIXME: DB-inconsistency */ $error_code = strtoupper(PW::create(8)); $error_msg = "[error_code: {$error_code}] multiple instances of admin ("; $error_msg .= $this->person->getEPPN() . ") found in the database."; $log_msg = "[{$error_code}] multiple hits (" . count($res) . ")on "; $log_msg .= $this->person->getEPPN() . " in admins-table."; Framework::error_output($error_msg); Logger::log_event(LOG_ALERT, $log_msg); return false; } } catch (Exception $e) { Framework::error_output(hmtlentities($e->getMessage())); /* FIXME, add proper exception handling */ return false; } try { if (!isset($comment) || $comment == "") { $comment = " "; } $update = "INSERT INTO robot_certs (subscriber_id, uploaded_by, uploaded_date, valid_until, cert, fingerprint, serial, comment)"; $update .= " VALUES(?, ?, current_timestamp(), ?, ?, ?, ?, ?)"; $params = array('text', 'text', 'text', 'text', 'text', 'text', 'text'); $data = array($subscriber_id, $admin_id, $cert->getEndDate(), $cert->getPEMContent(), $cert->getFingerprint(), $cert->getSerial(), $comment); MDB2Wrapper::update($update, $params, $data); Logger::log_event(LOG_INFO, "[RI] Added new certificate (" . $cert->getSerial() . ") for subscriber " . $this->person->getSubscriber()->getOrgName() . " associated with admin " . $this->person->getEPPN()); } catch (Exception $e) { /* FIXME */ Framework::error_output("Couldn't update robot_certs, server said:<br />\n" . htmlentities($e->getMessage())); return false; } Framework::success_output($this->translateTag('l10n_suc_insertcert1', 'robot') . " " . $cert->getSerial() . $this->translateTag('l10n_suc_insertcert2', 'robot')); return true; }
static function register_user_certificate($category_id, $user_id) { // generating the total score for a course $cats_course = Category::load($category_id, null, null, null, null, null, false); $alleval_course = $cats_course[0]->get_evaluations($user_id, true); $alllink_course = $cats_course[0]->get_links($user_id, true); $evals_links = array_merge($alleval_course, $alllink_course); $item_total = 0; //@todo move these in a function $sum_categories_weight_array = array(); if (isset($cats_course) && !empty($cats_course)) { $categories = Category::load(null, null, null, $category_id); if (!empty($categories)) { foreach ($categories as $category) { $sum_categories_weight_array[$category->get_id()] = $category->get_weight(); } } else { $sum_categories_weight_array[$category_id] = $cats_course[0]->get_weight(); } } $main_weight = $cats_course[0]->get_weight(); $item_total_value = 0; $item_value = 0; for ($count = 0; $count < count($evals_links); $count++) { $item = $evals_links[$count]; $score = $item->calc_score($user_id); $divide = $score[1] == 0 ? 1 : $score[1]; $sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()]; $item_value = $score[0] / $divide * $item->get_weight() * $sub_cat_percentage / $main_weight; $item_total_value += $item_value; } $item_total_value = (double) $item_total_value; $cattotal = Category::load($category_id); $scoretotal = $cattotal[0]->calc_score($user_id); //Do not remove this the gradebook/lib/fe/gradebooktable.class.php file load this variable as a global $scoredisplay = ScoreDisplay::instance(); $my_score_in_gradebook = $scoredisplay->display_score($scoretotal, SCORE_SIMPLE); //Show certificate $certificate_min_score = $cats_course[0]->get_certificate_min_score(); $scoretotal_display = $scoredisplay->display_score($scoretotal, SCORE_DIV_PERCENT); //a student always sees only the teacher's repartition if (isset($certificate_min_score) && $item_total_value >= $certificate_min_score) { $my_certificate = get_certificate_by_user_id($cats_course[0]->get_id(), $user_id); if (empty($my_certificate)) { register_user_info_about_certificate($category_id, $user_id, $my_score_in_gradebook, api_get_utc_datetime()); $my_certificate = get_certificate_by_user_id($cats_course[0]->get_id(), $user_id); } if (!empty($my_certificate)) { $certificate_obj = new Certificate($my_certificate['id']); $url = Certificate::getCertificatePublicURL($my_certificate['id']); $certificates = Display::url(Display::return_icon('certificate.png', get_lang('Certificates'), array(), 32), $url, array('target' => '_blank')); $html = '<div class="actions" align="right">'; $html .= Display::url($url, $url, array('target' => '_blank')); $html .= $certificates; $html .= '</div>'; return $html; } } else { return false; } }
/** * Get the certificate with key $key in a deployable from for the specified * browser. * * Usually this means some kind of JavaScript to install it to the keystore, * but sometimes it suffices to send the certificate with the right MIME-type * to the browser. * * @param $key The order-number/auth-key for the certificate * @param $browser The browser for which the certificate should be returned * Current legal values for that: * msie_post_vista: return full chain as PKCS7 in JavaScript * msie_pre_vista: return full chain as PKCS7 in JavaScript * keygen: return certificate only as string enclosed base64-encoded PKCS7 */ public function getCertDeploymentScript($key, $browser) { $key = $this->transformToOrderNumber($key); switch ($browser) { case "msie_post_vista": $collect_endpoint = ConfusaConstants::$CAPI_COLLECT_ENDPOINT . "?loginName=" . $this->account->getLoginName() . "&loginPassword="******"&orderNumber=" . $key . "&queryType=1" . "&responseType=2" . "&responseEncoding=2" . "&responseMimeType=text/javascript" . "&callbackFunctionName=installIEVistaCertificate"; $data = CurlWrapper::curlContact($collect_endpoint); return "<script type=\"text/javascript\">{$data}</script>"; break; case "msie_pre_vista": $collect_endpoint = ConfusaConstants::$CAPI_COLLECT_ENDPOINT . "?loginName=" . $this->account->getLoginName() . "&loginPassword="******"&orderNumber=" . $key . "&queryType=1" . "&responseType=2" . "&responseEncoding=2" . "&responseMimeType=text/javascript" . "&callbackFunctionName=installIEXPCertificate"; $data = CurlWrapper::curlContact($collect_endpoint); return "<script type=\"text/javascript\">{$data}</script>"; break; case "chrome": $collect_endpoint = ConfusaConstants::$CAPI_COLLECT_ENDPOINT . "?loginName=" . $this->account->getLoginName() . "&loginPassword="******"&orderNumber=" . $key . "&queryType=2" . "&responseType=3" . "&responseEncoding=0"; /* encode base-64 */ $data = CurlWrapper::curlContact($collect_endpoint); $cert = new Certificate(trim(substr($data, 2))); $der_cert = $cert->getDERContent(true); return $der_cert; break; case "mozilla": case "safari": case "opera": $collect_endpoint = ConfusaConstants::$CAPI_COLLECT_ENDPOINT . "?loginName=" . $this->account->getLoginName() . "&loginPassword="******"&orderNumber=" . $key . "&queryType=2" . "&responseType=3" . "&responseEncoding=0"; /* encode base-64 */ $data = CurlWrapper::curlContact($collect_endpoint); return trim(substr($data, 2)); break; default: throw new ConfusaGenException("Deployment in browser {$browser} not supported"); break; } }
$parent_id = 0; } $current_folder_id = $document_id; // Show preview if (isset($_GET['curdirpath']) && $_GET['curdirpath'] == '/certificates' && isset($_GET['set_preview']) && $_GET['set_preview'] == strval(intval($_GET['set_preview']))) { if (isset($_GET['set_preview'])) { // Generate document HTML $content_html = DocumentManager::replace_user_info_into_html(api_get_user_id(), api_get_course_id(), api_get_session_id(), true); $filename = 'certificate_preview/' . api_get_unique_id() . '.png'; $qr_code_filename = api_get_path(SYS_ARCHIVE_PATH) . $filename; $temp_folder = api_get_path(SYS_ARCHIVE_PATH) . 'certificate_preview'; if (!is_dir($temp_folder)) { mkdir($temp_folder, api_get_permissions_for_new_directories()); } $qr_code_web_filename = api_get_path(WEB_ARCHIVE_PATH) . $filename; $certificate = new Certificate(); $text = $certificate->parse_certificate_variables($content_html['variables']); $result = $certificate->generate_qr($text, $qr_code_filename); $new_content_html = $content_html['content']; $path_image = api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/document/images/gallery'; $new_content_html = str_replace('../images/gallery', $path_image, $new_content_html); $path_image_in_default_course = api_get_path(WEB_CODE_PATH) . 'default_course_document'; $new_content_html = str_replace('/main/default_course_document', $path_image_in_default_course, $new_content_html); $new_content_html = str_replace(SYS_CODE_PATH . 'img/', api_get_path(WEB_IMG_PATH), $new_content_html); Display::display_reduced_header(); echo '<style>body {background:none;}</style> <style media="print" type="text/css"> #print_div { visibility:hidden; } </style>'; echo '<a href="javascript:window.print();" style="float:right; padding:4px;" id="print_div"> <img src="../img/printmgr.gif" alt="' . get_lang('Print') . '"/>' . get_lang('Print') . '</a>'; if (is_file($qr_code_filename) && is_readable($qr_code_filename)) { $new_content_html = str_replace('((certificate_barcode))', Display::img($qr_code_web_filename), $new_content_html);
{ $certi= StudentCertificateDetailsTable::model()->find(array('condition'=>' student_certificate_details_table_student_id='.$trans->student_transaction_id.' and student_certificate_type_id='.$certificate_type,'order'=>'student_certificate_details_table_id desc')); $ref_no = $certi->certificate_reference_number; } else{ $certi = StudentCertificateDetailsTable::model()->find(array('order'=>'student_certificate_details_table_id desc')); $autonum = 0; if(!empty($certi) && $certi->certificate_reference_number!=""){ $arr = explode('/',$certi->certificate_reference_number); $autonum = $arr[3]; } $autonum +=1; $ref_no = $year."/".$branch_model->branch_code."/".date('Y').'/'.$autonum; } $quota = "<b>".Quota::model()->findByPk($trans->student_transaction_quota_id)->quota_name."</b>"; $content = Certificate::model()->findByPk($model->certificatetype)->certificate_content; $content = str_replace('{title}',$titl,$content); $content = str_replace('{name}',$name,$content); $content = str_replace('{branch}',$branch,$content); $content = str_replace('{sem}',$sem,$content); $content = str_replace('{division}',$div,$content); $content = str_replace('{enrollment}',$en_no,$content); $content = str_replace('{gender}',$gender,$content); $content = str_replace('{category}',$category,$content); $content = str_replace('{quota}',$quota,$content); $content = str_replace('{smobile}',$smobile,$content); $content = str_replace('{pmobile}',$pmobile,$content); $content = str_replace('{date}',$cdate,$content); $content = str_replace('{line1}',$lin1,$content); $content = str_replace('{line2}',$lin2,$content);
function release_cert() { checkPerm('view'); require_once $GLOBALS['where_lms'] . '/lib/lib.certificate.php'; $id_certificate = importVar('id_certificate', true, 0); $id_course = importVar('id_course', true, 0); $id_user = Get::req('iduser', DOTY_INT, 0); $id_meta = Get::req('idmeta', DOTY_INT, 0); $cert = new Certificate(); $subs = $cert->getSubstitutionArray($id_user, $id_course, $id_meta); $cert->send_certificate($id_certificate, $id_user, $id_course, $subs); }
function userCourseList(&$url, $use_tab = true, $page_add = true) { YuiLib::load(array('animation' => 'animation-min.js', 'dragdrop' => 'dragdrop-min.js', 'button' => 'button-min.js', 'container' => 'container-min.js', 'my_window' => 'windows.js'), array('container/assets/skins/sam' => 'container.css', 'button/assets/skins/sam' => 'button.css')); if ($page_add) { addJs($GLOBALS['where_lms_relative'] . '/modules/coursecatalogue/', 'ajax.coursecatalogue.js'); } require_once _base_ . '/lib/lib.form.php'; require_once _base_ . '/lib/lib.user_profile.php'; require_once _base_ . '/lib/lib.navbar.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.preassessment.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.catalogue.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.coursereport.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.coursepath.php'; require_once $GLOBALS["where_framework"] . "/lib/lib.ajax_comment.php"; require_once $GLOBALS['where_lms'] . '/lib/lib.classroom.php'; // pre-loading coursepath ------------------------------------------------------------------ $path_man = new CoursePath_Manager(); // search for the coursepath ---------------------------------------------------------- $user_coursepath = $path_man->getUserSubscriptionsInfo(getLogUserId(), true); $coursepath = $path_man->getCoursepathAllInfo(array_keys($user_coursepath)); if (!empty($coursepath)) { // find structures of the course path --------------------------------------------- $path_courses = $path_man->getPathStructure(array_keys($coursepath)); $cp_info = $path_man->getAllCoursesInfo($path_courses['all_paths']); /*echo "<pre>\n\n"; print_r($cp_info); echo "\n\n</pre>";*/ } // ------------------------------------------------------------------------ $course_stats = array('total' => 0, 'u_can_enter' => 0, 'with_status' => array(CST_AVAILABLE => 0, CST_EFFECTIVE => 0, CST_CONCLUDED => 0, CST_CANCELLED => 0), 'with_ustatus' => array(_CUS_SUBSCRIBED => 0, _CUS_BEGIN => 0, _CUS_END => 0, _CUS_SUSPEND => 0), 'with_wstatus' => array(_CUS_RESERVED => 0, _CUS_WAITING_LIST => 0), 'with_ulevel' => array(), 'expiring' => 0, 'cert_relesable' => 0); // ------------------------------------------------------------------------ $filter = importVar('filter', false, 'total'); if ($filter == 'level') { $filter_level = importVar('filter_on', true, 0); } $current_tab = importVar('current_tab', false, 'lo_plan'); if ($use_tab && $page_add) { addCss('style_tab'); $lo_plan = importVar('lo_plan', false, 0); $lo_history = importVar('lo_history', false, 0); if ($lo_plan != 0) { $current_tab = 'lo_plan'; } if ($lo_history != 0) { $current_tab = 'lo_history'; } } if ($use_tab && $page_add) { addCss('style_tab'); $lo_plan = importVar('lo_plan', false, 0); $lo_history = importVar('lo_history', false, 0); if ($lo_plan != 0) { $current_tab = 'lo_plan'; } if ($lo_history != 0) { $current_tab = 'lo_history'; } } require_once $GLOBALS['where_lms'] . '/lib/lib.certificate.php'; $cert = new Certificate(); $released = $cert->certificateReleased(getLogUserId()); $available_cert = $cert->certificateForCourses(false, false); // cahce classroom ----------------------------------------------------------------- $classroom_man = new ClassroomManager(); $classrooms = $classroom_man->getClassroomNameList(); $lang =& DoceboLanguage::createInstance('catalogue'); $lang_c =& DoceboLanguage::createInstance('course'); $man_course = new Man_Course(); $subcourse_list = sql_query("" . " SELECT u.idCourse, u.edition_id, level, u.date_inscr, u.date_first_access, " . "\t\tu.date_complete, u.status AS user_status, u.waiting, u.edition_id " . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser AS u" . " WHERE idUser = '******'"); $subscription = array(); while ($cinfo = mysql_fetch_assoc($subcourse_list)) { $subscription['course'][$cinfo['idCourse']] = $cinfo; if ($cinfo['edition_id'] != 0) { $subscription['edition'][$cinfo['idCourse']][$cinfo['edition_id']] = $cinfo; } } // searching courses --------------------------------------------------------------- $select_course = "" . " SELECT c.idCourse, c.course_type, c.idCategory, c.code, c.name, c.description, c.lang_code, c.difficult, " . "\tc.subscribe_method, c.date_begin, c.date_end, c.max_num_subscribe, " . "\tc.selling, c.prize, c.create_date, c.status AS course_status, c.course_edition, " . "\tc.classrooms, c.img_othermaterial, c.course_demo, c.course_vote, " . "\tc.can_subscribe, c.sub_start_date, c.sub_end_date, c.valid_time, c.userStatusOp, c.show_result, u.status AS user_status, u.level " . ", c.use_logo_in_courselist, c.img_course, c.direct_play "; $from_course = " FROM " . $GLOBALS['prefix_lms'] . "_course AS c " . "\t JOIN " . $GLOBALS['prefix_lms'] . "_courseuser AS u "; $where_course = " c.idCourse = u.idCourse " . " AND u.idUser = '******' " . " AND ( c.status <> '" . CST_PREPARATION . "' OR u.level > 3 )" . " AND c.course_type <> 'assessment' "; $selected_year = 0; $selected_search = ''; if (isset($_POST['apply_filter'])) { if ($_POST['year']) { $where_course .= " AND c.create_date BETWEEN '" . $_POST['year'] . "-01-01 00:00:00' AND '" . $_POST['year'] . "-12-31 23:59:59'"; $selected_year = $_POST['year']; } if ($_POST['search'] !== '') { $where_course .= " AND c.name LIKE '%" . $_POST['search'] . "%'"; $selected_search = $_POST['search']; } } $group_by_course = " GROUP BY c.idCourse "; $order_course = " ORDER BY "; $tablist = Get::sett('tablist_mycourses', ''); if ($tablist != '') { $arr_order_course = explode(',', $tablist); $arr_temp = array(); foreach ($arr_order_course as $key => $value) { switch ($value) { case 'status': $arr_temp[] = ' u.status '; break; case 'code': $arr_temp[] = ' c.code '; break; case 'name': $arr_temp[] = ' c.name '; break; } } $order_course = $order_course . implode(', ', $arr_temp); } if ($order_course == " ORDER BY ") { //default without parameter $order_course .= " u.status, c.name "; } // apply search filter -------------------------------------------------------------- $all_lang = Docebo::langManager()->getAllLangCode(); $re_course = sql_query($select_course . $from_course . " WHERE " . $where_course . $group_by_course . $order_course); // retrive editions ---------------------------------------------------------------- $select_edition = " SELECT e.* "; $from_edition = " FROM " . $GLOBALS["prefix_lms"] . "_course_editions AS e " . " JOIN " . $GLOBALS["prefix_lms"] . "_courseuser AS u "; $where_edition = " WHERE e.status <> '" . CST_PREPARATION . "' AND e.id_edition = u.edition_id "; $re_edition = sql_query($select_edition . $from_edition . $where_edition); // -------------------------------------------------------------------------------- $editions = array(); if ($re_edition) { while ($edition_elem = mysql_fetch_assoc($re_edition)) { $edition_elem['classrooms'] = isset($classrooms[$edition_elem['classrooms']]) ? $classrooms[$edition_elem['classrooms']] : ''; $editions[$edition_elem["id_course"]][$edition_elem["id_course"]] = $edition_elem; } } $man_courseuser = new Man_CourseUser(); $ax_comm = new AjaxComment('course', 'lms'); $comment_count = $ax_comm->getResourceCommentCount(); $user_score = $man_courseuser->getUserCourseScored(getLogUserId()); // ----------------------------------------------------------------------------- $needed_info_for = array(); if (!empty($subscription['course'])) { $id_course_list = array_keys($subscription['course']); // find last access to the courses --------------------------------------------------------------------- require_once $GLOBALS['where_lms'] . '/lib/lib.track_user.php'; $last_access_courses = TrackUser::getLastAccessToCourse(getLogUserId()); // retrive unreaded advice ----------------------------------------------------------------------------- require_once $GLOBALS['where_lms'] . '/lib/lib.advice.php'; $advices = Man_Advice::getCountUnreaded(getLogUserId(), $id_course_list, $last_access_courses); // retrive unreaded forum messages --------------------------------------------------------------------- require_once $GLOBALS['where_lms'] . '/lib/lib.forum.php'; $forums = Man_Forum::getCountUnreaded(getLogUserId(), $id_course_list, $last_access_courses); // retrive new lesson ---------------------------------------------------------------------------------- require_once $GLOBALS['where_lms'] . '/lib/lib.orgchart.php'; $org_chart = OrganizationManagement::getCountUnreaded(getLogUserId(), $id_course_list, $last_access_courses); if (!empty($path_courses['all_items'])) { $needed_info_for = array_diff($path_courses['all_items'], $id_course_list); } $first_is_scorm = OrganizationManagement::objectFilter($id_course_list, 'scormorg'); $enroll_list = sql_query("" . " SELECT u.idCourse, u.edition_id, COUNT(*) as number " . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser AS u" . " WHERE u.idCourse IN (" . implode($id_course_list, ',') . ") " . " AND u.level = '3'" . " AND u.status IN ('" . _CUS_CONFIRMED . "', '" . _CUS_SUBSCRIBED . "', '" . _CUS_BEGIN . "', '" . _CUS_END . "', '" . _CUS_SUSPEND . "', '" . _CUS_WAITING_LIST . "')" . " AND u.absent = '0'" . " GROUP BY u.idCourse, u.edition_id "); $enrolled = array(); while ($cinfo = mysql_fetch_assoc($enroll_list)) { $enrolled[$cinfo['idCourse']][$cinfo['edition_id']] = $cinfo['number']; } } // search pre-assessment ----------------------------------------------------------- $select_assess = "" . " SELECT c.idCourse, c.course_type, c.idCategory, c.code, c.name, c.description, c.lang_code, c.difficult, " . "\tc.subscribe_method, c.date_begin, c.date_end, c.max_num_subscribe, " . "\tc.selling, c.prize, c.create_date, c.status AS course_status, c.course_edition, " . "\tc.classrooms, c.img_othermaterial, c.course_demo, c.course_vote, " . "\tc.can_subscribe, c.sub_start_date, c.sub_end_date, c.valid_time, c.userStatusOp, " . "\tu.level, u.date_inscr, u.date_first_access, u.date_complete, u.status AS user_status, u.waiting, c.advance, u.waiting "; $from_assess = " FROM " . $GLOBALS['prefix_lms'] . "_course AS c " . "\t JOIN " . $GLOBALS['prefix_lms'] . "_courseuser AS u "; $where_assess = " c.idCourse = u.idCourse " . " AND u.idUser = '******' " . " AND c.course_type = 'assessment' " . " AND ( c.status <> '" . CST_PREPARATION . "' OR u.level > 3 ) " . ($filter == 'level' ? " AND level = '" . $filter_level . "'" : ""); //." AND ( u.status <> '"._CUS_END."' OR u.level > 3 ) "; $preass_list = sql_query($select_assess . $from_assess . " WHERE " . $where_assess . " ORDER BY c.name "); // pre assessment list --------------------------------------------------------------------------------------- $i = 0; if (mysql_num_rows($preass_list) && $current_tab == 'lo_plan') { if ($page_add) { $GLOBALS['page']->add('<div id="mycourse_asses">' . '<h1>' . $lang_c->def('_ASSESSMENT_LIST') . '</h1>', 'content'); } while ($cinfo = mysql_fetch_assoc($preass_list)) { $cinfo['user_score'] = isset($user_score[$cinfo['idCourse']]) ? $user_score[$cinfo['idCourse']] : NULL; if (isset($comment_count[$cinfo['idCourse']])) { $cinfo['comment_count'] = $comment_count[$cinfo['idCourse']]; } if ($page_add) { $GLOBALS['page']->add(dashmyassess($url, $lang_c, $cinfo, $i++), 'content'); } } if ($page_add) { $GLOBALS['page']->add('</div>', 'content'); } } // page intest ------------------------------------------------------------ require_once $GLOBALS['where_lms'] . '/lib/lib.levels.php'; $lvl = CourseLevel::getLevels(); $title = $lang->def('_COURSE_LIST'); switch ($filter) { case "access": $title = $lang->def('_COURSE_YOU_CAN_ACCESS'); break; case "expiring": $title = $lang->def('_COURSE_EXPIRING'); break; case "subscribed": $title = $lang->def('_COURSE_SUBSCRIBED'); break; case "begin": $title = $lang->def('_COURSE_BEGIN'); break; case "end": $title = $lang->def('_COURSE_END'); break; case "level": $title = str_replace('[level]', $lvl[$_GET['filter_on']], $lang->def('_COURSE_AS')); break; } if ($page_add) { $GLOBALS['page']->add('<div id="mycourse_list">' . '<h1>' . $title . '</h1>', 'content'); } $i = 0; $direct_play = false; while ($cinfo = mysql_fetch_assoc($re_course)) { $access = Man_Course::canEnterCourse($cinfo); if ($cinfo['direct_play'] == 1) { $direct_play = true; } $course_stats['total']++; if ($cinfo['user_status'] == _CUS_RESERVED || $cinfo['user_status'] == _CUS_WAITING_LIST) { $course_stats['with_wstatus'][$cinfo['user_status']]++; } elseif ($access['can']) { $course_stats['u_can_enter']++; } if (isset($course_stats['with_ustatus'][$cinfo['user_status']])) { $course_stats['with_ustatus'][$cinfo['user_status']]++; } else { $course_stats['with_ustatus'][$cinfo['user_status']] = 1; } if (!isset($course_stats['with_ulevel'][$cinfo['level']])) { $course_stats['with_ulevel'][$cinfo['level']] = 1; } else { $course_stats['with_ulevel'][$cinfo['level']]++; } if (isset($available_cert[$cinfo['idCourse']])) { while (list($id_cert, $certificate) = each($available_cert[$cinfo['idCourse']])) { if (!isset($released[$id_cert]) && $cert->canRelease($certificate[CERT_AV_STATUS], $cinfo['user_status'])) { $course_stats['cert_relesable']++; } } } } if (mysql_num_rows($re_course)) { mysql_data_seek($re_course, 0); } while ($cinfo = mysql_fetch_assoc($re_course)) { $cinfo['edition_list'] = isset($editions[$cinfo['idCourse']]) ? $editions[$cinfo['idCourse']] : array(); $cinfo['user_score'] = isset($user_score[$cinfo['idCourse']]) ? $user_score[$cinfo['idCourse']] : NULL; $cinfo['enrolled'] = isset($enrolled[$cinfo['idCourse']]) ? $enrolled[$cinfo['idCourse']] : false; if (isset($comment_count[$cinfo['idCourse']])) { $cinfo['comment_count'] = $comment_count[$cinfo['idCourse']]; } $cinfo['classrooms'] = isset($classrooms[$cinfo['classrooms']]) ? $classrooms[$cinfo['classrooms']] : ''; // advertising -------------------------------------------------------------------------------------------- $cinfo['to_read']['advice'] = isset($advices[$cinfo['idCourse']]) ? $advices[$cinfo['idCourse']] : 0; $cinfo['to_read']['forum'] = isset($forums[$cinfo['idCourse']]) ? $forums[$cinfo['idCourse']] : 0; $cinfo['to_read']['lobj'] = isset($org_chart[$cinfo['idCourse']]) ? $org_chart[$cinfo['idCourse']] : 0; // 10 days in the future $range = time() + 10 * 24 * 60 * 60; $expiring = false; if ($cinfo['date_end'] != '0000-00-00') { $time_end = fromDatetimeToTimestamp($cinfo['date_end']); if ($range > $time_end) { $expiring = true; $course_stats['expiring']++; } } if ($cinfo['valid_time'] != '0' && $cinfo['valid_time'] != '' && $cinfo['date_first_access'] != '') { $time_first_access = fromDatetimeToTimestamp($cinfo['date_first_access']); if ($range > $time_first_access + $cinfo['valid_time'] * 24 * 3600) { $expiring = true; $course_stats['expiring']++; } } if (isset($first_is_scorm[$cinfo['idCourse']])) { $cinfo['first_is_scorm'] = $first_is_scorm[$cinfo['idCourse']]; } else { $cinfo['first_is_scorm'] = false; } $access = Man_Course::canEnterCourse($cinfo); // -------------------------------------------------------------------- if (!isset($path_courses['all_items'][$cinfo['idCourse']])) { // the course is not related with a coursepath, so i can print it -------------- if ($filter == 'level') { if ($subscription['course'][$cinfo['idCourse']]['level'] == $filter_level) { $dash = dashmycourse($url, $lang_c, $subscription, $cinfo, $i++); } else { $dash = ''; } } else { $dash = dashmycourse($url, $lang_c, $subscription, $cinfo, $i++); } if ($use_tab == true) { if ($course_stats['with_ustatus'][_CUS_END] == $course_stats['total']) { $current_tab = 'lo_history'; } if ($current_tab == 'lo_history') { if ($cinfo['user_status'] == _CUS_END && $page_add) { $GLOBALS['page']->add($dash, 'content'); } } else { if (($cinfo['user_status'] != _CUS_END || $cinfo['level'] >= 4) && $page_add) { $GLOBALS['page']->add($dash, 'content'); } } } else { switch ($filter) { case "access": if ($access['can'] && $page_add) { $GLOBALS['page']->add($dash, 'content'); } break; case "expiring": if ($expiring && $page_add) { $GLOBALS['page']->add($dash, 'content'); } break; case "subscribed": if ($cinfo['user_status'] == _CUS_SUBSCRIBED && $page_add) { $GLOBALS['page']->add($dash, 'content'); } break; case "begin": if ($cinfo['user_status'] == _CUS_BEGIN && $page_add) { $GLOBALS['page']->add($dash, 'content'); } break; case "end": if ($cinfo['user_status'] == _CUS_END && $page_add) { $GLOBALS['page']->add($dash, 'content'); } break; case "level": if ($_GET['filter_on'] == $cinfo['level'] && $page_add) { $GLOBALS['page']->add($dash, 'content'); } break; default: if ($page_add) { $GLOBALS['page']->add($dash, 'content'); } } } } else { // the course is related with a coursepath, so i must wait to print it ---------- //$cinfo['prerequisites'] = $path_courses['all_items'][$cinfo['idCourse']]; // <- useless? //$courses =array($cinfo['idCourse']=>$cinfo); $prere = $cp_info[$cinfo['idCourse']]["prerequisites"]; if ($path_man->checkPrerequisites($prere, $subscription)) { $cinfo['prerequisites_satisfied'] = true; } else { $cinfo['prerequisites_satisfied'] = false; } if ($filter == 'level') { if ($subscription['course'][$cinfo['idCourse']]['level'] == $filter_level) { $course_cache[$cinfo['idCourse']] = dashmycourse($url, $lang_c, $subscription, $cinfo, 1, true, 4); } else { $course_cache[$cinfo['idCourse']] = ''; } } else { $course_cache[$cinfo['idCourse']] = dashmycourse($url, $lang_c, $subscription, $cinfo, 1, true, 4); } } // end else-if ------------------------------------------------------- } // end while ------------------------------------------------------------ if ($direct_play && $page_add) { $GLOBALS['page']->add('' . ' <link href="' . getPathTemplate() . '/style/shadowbox.css" rel="stylesheet" type="text/css" />' . '<script type="text/javascript" src="' . $GLOBALS['where_framework_relative'] . '/addons/shadowbox/shadowbox-yui.js"></script>' . "\n" . '<script type="text/javascript" src="' . $GLOBALS['where_framework_relative'] . '/addons/shadowbox/shadowbox.js"></script>' . "\n", 'page_head'); $GLOBALS['page']->add('<script type="text/javascript"> YAHOO.util.Event.onDOMReady(function() { var options = { listenOverlay:false, overlayOpacity:"0.8", loadingImage:"' . getPathImage('lms') . 'standard/loading.gif", overlayBgImage:"' . getPathImage('lms') . 'standard/overlay-85.png", text: {close: "' . Lang::t('_CLOSE') . '", cancel: "' . Lang::t('_UNDO') . '", loading:"' . Lang::t('_LOADING') . '" }, onOpen: function (gallery) { window.onbeforeunload = function() { return "' . Lang::t('_CONFIRM_EXIT', 'organization', 'lms') . '"; } } }; Shadowbox.init(options); Shadowbox.close = function() { window.frames[\'shadowbox_content\'].uiPlayer.closePlayer(true, window); } }); </script>'); } if ($course_stats['total'] == 0 && $page_add) { $GLOBALS['page']->add('' . '<b>' . $lang->def('_NO_COURSE') . '</b> ' . '<br />', 'content'); } if ($page_add) { $GLOBALS['page']->add('</div>', 'content'); } // Coursepath -------------------------------------------------------------- if (!empty($coursepath)) { // find structures of the course path ---------------------------------- $path_slot = $path_man->getPathSlot(array_keys($coursepath)); // coursepath list ----------------------------------------------------- if ($page_add) { $GLOBALS['page']->add('<div id="mycoursepath_list">' . '<h1>' . $lang->def('_COURSEPATH_LIST') . '</h1>', 'content'); } $i = 0; // find course basilar information ------------------------------------- if (!empty($needed_info_for)) { $course_info = $man_course->getAllCourses(false, false, $needed_info_for); } else { $course_info = array(); } while (list($id_path, $path) = each($coursepath)) { $html = '<div class="coursepath_container coursepath_container_simple">'; $html .= '<h2>' . ($path[COURSEPATH_CODE] != '' ? '[' . $path[COURSEPATH_CODE] . '] ' : '') . $path[COURSEPATH_NAME] . '</h2>'; if (!isset($path_courses[$id_path]) || empty($path_courses[$id_path])) { $html .= $lang->def('_NO_COURSE_ASSIGNED_TO_COURSEPATH') . '<br />'; } else { // display the slots foreach ($path_slot[$id_path] as $id_slot => $slot_info) { if ($id_slot == 0) { $html .= '<h3>' . $lang->def('_MANDATORY') . '</h3>'; if (!empty($path_courses[$id_path][$id_slot])) { $html .= '<ul class="coursepath_mainslot">'; } } else { if ($slot_info['min_selection'] > 0 && $slot_info['max_selection'] > 0) { $title = str_replace(array('[min_selection]', '[max_selection]'), array($slot_info['min_selection'], $slot_info['max_selection']), $lang->def('_COURSE_PATH_SLOT_MIN_MAX')); } elseif ($slot_info['max_selection'] > 0) { $title = str_replace('[max_selection]', $slot_info['max_selection'], $lang->def('_COURSE_PATH_SLOT_MAX')); } else { $title = $lang->def('_COURSE_PATH_SLOT'); } $html .= '<h3>' . $title . '</h3>'; if (!empty($path_courses[$id_path][$id_slot])) { $html .= '<ul class="coursepath_otherslot">'; } } while (list($id) = each($path_courses[$id_path][$id_slot])) { if (isset($course_cache[$id])) { $html .= '<li>' . $course_cache[$id] . '</li>'; } else { $html .= '<li>' . dashAcourse($id, 4) . '</li>'; } } if (!empty($path_courses[$id_path][$id_slot])) { $html .= '</ul>'; } } } $html .= '</div>'; if ($page_add) { $GLOBALS['page']->add($html, 'content'); } } if ($page_add) { $GLOBALS['page']->add('</div>', 'content'); } } if ($course_stats['cert_relesable'] < 0) { $course_stats['cert_relesable'] = 0; } return $course_stats; }
function release_cert(&$url) { checkPerm('view'); $id_certificate = importVar('id_certificate', true, 0); $id_course = importVar('id_course', true, 0); $id_meta = Get::req('idmeta', DOTY_INT, 0); $cert = new Certificate(); $subs = $cert->getSubstitutionArray(Docebo::user()->getIdST(), $id_course, $id_meta); $cert->send_certificate($id_certificate, Docebo::user()->getIdST(), $id_course, $subs); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Certificate the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Certificate::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
'id'=>'certificate-form', 'enableAjaxValidation'=>true, 'clientOptions'=>array('validateOnSubmit'=>true), )); ?> <div class="block-error"> <?php echo Yii::app()->user->getFlash('No-Employee-Found'); ?> </div> <div class="row"> <?php echo $form->labelEx($model,'attendenceno'); ?> <?php echo $form->textField($model,'attendenceno',array('size'=>13));?><span class="status"> </span> <?php echo $form->error($model,'attendenceno'); ?> </div> </br></br> <div class="row"> <?php echo $form->labelEx($model,'certificatetype'); ?> <?php echo $form->dropDownList($model,'certificatetype',Certificate::items1(),array('empty'=>'Select Type'));?><span class="status"> </span> <?php echo $form->error($model,'certificatetype'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton('Generate', array('class'=>'submit')); echo CHtml::link('Cancel', array('employee/employeeCertificateDetailsTable/admin'), array('class'=>'btnCan')); ?> </div> <?php $this->endWidget(); ?> </div><!-- form --> </div>
<tr> <td> <?php echo $k; ?> </td> <td> <?php echo EmployeeInfo::model()->findByAttributes(array("employee_info_transaction_id" => $v['employee_certificate_details_table_emp_id']))->employee_first_name; ?> </td> <td> <?php echo Certificate::model()->findByPk($v['employee_certificate_type_id'])->certificate_title; ?> </td> <td> <?php echo User::model()->findByPk($v['employee_certificate_created_by'])->user_organization_email_id; ?> </td> <td> <?php echo Organization::model()->findByPk($v['employee_certificate_org_id'])->organization_name; ?>
public function __construct($filename, $password) { parent::__construct($filename); $this->setPassword($password); }
function preview() { checkPerm('view'); require_once $GLOBALS['where_lms'] . '/lib/lib.certificate.php'; $id_certificate = importVar('id_certificate', true, 0); $cert = new Certificate(); $cert->send_preview_certificate($id_certificate, array()); }
/** * return all content to replace and all content to be replace */ static function get_all_info_to_certificate($user_id, $course_id, $is_preview = false) { $info_list = array(); $user_id = intval($user_id); $course_info = api_get_course_info($course_id); //info portal $organization_name = api_get_setting('platform.institution'); $portal_name = api_get_setting('platform.site_name'); //Extra user data information $extra_user_info_data = UserManager::get_extra_user_data($user_id, false, false, false, true); //Student information $user_info = api_get_user_info($user_id); $first_name = $user_info['firstname']; $last_name = $user_info['lastname']; $official_code = $user_info['official_code']; //Teacher information $info_teacher_id = UserManager::get_user_id_of_course_admin_or_session_admin($course_info); $teacher_info = api_get_user_info($info_teacher_id); $teacher_first_name = $teacher_info['firstname']; $teacher_last_name = $teacher_info['lastname']; // info gradebook certificate $info_grade_certificate = UserManager::get_info_gradebook_certificate($course_id, $user_id); $date_certificate = $info_grade_certificate['created_at']; $date_no_time = null; $date_long_certificate = ''; if (!empty($date_certificate)) { $date_long_certificate = api_convert_and_format_date($date_certificate); $date_no_time = api_convert_and_format_date($date_certificate, DATE_FORMAT_LONG_NO_DAY); } if ($is_preview) { $date_long_certificate = api_convert_and_format_date(api_get_utc_datetime()); $date_no_time = api_convert_and_format_date(api_get_utc_datetime(), DATE_FORMAT_LONG_NO_DAY); } $url = Certificate::getCertificatePublicURL($info_grade_certificate['id']); //replace content $info_to_replace_in_content_html = array($first_name, $last_name, $organization_name, $portal_name, $teacher_first_name, $teacher_last_name, $official_code, $date_long_certificate, $date_no_time, $course_id, $course_info['name'], $info_grade_certificate['grade'], $url, '<a href="' . $url . '" target="_blank">' . get_lang('CertificateOnlineLink') . '</a>', '((certificate_barcode))'); $info_to_be_replaced_in_content_html = array('((user_firstname))', '((user_lastname))', '((gradebook_institution))', '((gradebook_sitename))', '((teacher_firstname))', '((teacher_lastname))', '((official_code))', '((date_certificate))', '((date_certificate_no_time))', '((course_code))', '((course_title))', '((gradebook_grade))', '((certificate_link))', '((certificate_link_html))', '((certificate_barcode))'); if (!empty($extra_user_info_data)) { foreach ($extra_user_info_data as $key_extra => $value_extra) { $info_to_be_replaced_in_content_html[] = '((' . strtolower($key_extra) . '))'; $info_to_replace_in_content_html[] = $value_extra; } } $info_list[] = $info_to_be_replaced_in_content_html; $info_list[] = $info_to_replace_in_content_html; return $info_list; }
public static function curlContactCert($url, $key, $cert, $keypw = false, $postData = null) { if (is_null($key) || is_null($cert) || $key === "" || $cert === "") { throw new ConfusaGenException("Empty key or certificate received " . "when using curlContactCert(). " . "Aborting curl-transfer to url: {$url}"); } if (is_null($postData) || !is_array($postData) || count($postData) == 0) { return false; } /* Do basic URL filtering */ $curlurl = Input::sanitizeURL($url); if (is_null($curlurl) || $curlurl === "" || filter_var($curlurl, FILTER_VALIDATE_URL) === false) { Logger::log_event(LOG_NOTICE, "invalid URL (" . $curlurl . "), aborting curl-fetch."); return false; } Logger::log_event(LOG_DEBUG, "Contacting {$curlurl} using cert AuthN"); /* key should be encrypted, if not, do not use it (not safe!) */ $start = "-----BEGIN ENCRYPTED PRIVATE KEY-----"; if (substr($key, 0, strlen($start)) !== $start) { Logger::log_event(LOG_NOTICE, "Trying to use curlContactCert with unecrypted private key, aborting."); return false; } $rkey = openssl_pkey_get_private($key, $keypw); if ($rkey === false) { Logger::log_event(LOG_NOTICE, "Could not parse private key for CurlContactCert, aborting"); return false; } if (!openssl_x509_check_private_key($cert, $rkey)) { Logger::log_event(LOG_NOTICE, "Provided key and certificate is not a pair, cannot continue."); /* throw exception? */ return false; } $rcert = new Certificate($cert); if (!$rcert->isValid()) { $logline = "Certificate (" . $rcert->getHash() . ") has expired, cannot use this. Aborting curl."; Logger::log_event(LOG_NOTICE, $logline); return false; } if (!file_exists("/tmp/" . $rcert->getHash() . ".key") || !file_exists("/tmp/" . $rcert->getHash() . ".crt")) { if (file_put_contents("/tmp/" . $rcert->getHash() . ".key", $key) === false) { Logger::log_event(LOG_NOTICE, "Could not write key to file"); } if (file_put_contents("/tmp/" . $rcert->getHash() . ".crt", $cert) === false) { Logger::log_event(LOG_NOTICE, "Could not write cert to file"); } } $options = array(CURLOPT_URL => $curlurl, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => 2, CURLOPT_SSLKEY => "/tmp/" . $rcert->getHash() . ".key", CURLOPT_SSLCERT => "/tmp/" . $rcert->getHash() . ".crt", CURLOPT_SSLKEYPASSWD => $keypw, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_RETURNTRANSFER => 1, CURLOPT_CONNECTTIMEOUT => 15); $channel = curl_init(); curl_setopt_array($channel, $options); $data = curl_exec($channel); $status = curl_errno($channel); curl_close($channel); if ($status !== 0) { throw new ConfusaGenException("Could not connect properly to remote " . "endpoint {$curlurl} using cert-based authN! " . "Maybe the Confusa instance is misconfigured? " . "Please contact an administrator!"); } return $data; }
//'filter'=>$model, 'columns'=>array( array( 'header'=>'SI No', 'class'=>'IndexColumn', ), array( 'header'=>'Name', 'name'=>'student_first_name', 'value'=>'$data->cer_student_id->student_first_name', ), array('name'=>'student_certificate_type_id', 'value'=>'Certificate::model()->findByPk($data->student_certificate_type_id)->certificate_title', 'filter' =>CHtml::listData(Certificate::model()->findAll(array('condition'=>'certificate_organization_id='.Yii::app()->user->getState('org_id'))),'certificate_id','certificate_title'), ), array('name'=>'Organization', 'value'=>'Organization::model()->findByPk($data->student_certificate_org_id)->organization_name', 'filter' => false, ), ), 'pager'=>array( 'class'=>'AjaxList', 'maxButtonCount'=>$studentcertificate->count(), // 'maxButtonCount'=>25, 'header'=>'' ), )); ?> </fieldset>
public function generate($cert_password = '') { $manager = new Pass_File_Manager($this); $cert = new Certificate($manager->file_path('certificate.p12'), $cert_password); if (!$manager->generate_file('pass.json', $this->pass_json($cert->pass_type_identifier(), $cert->team_identifier()))) { return $manager->error; } if (!$manager->generate_file('manifest.json', $this->manifest($manager->files()))) { return $manager->error; } if (!($signature = $cert->signature($manager->file_path('manifest.json'), $manager->file_path('signature')))) { return $cert->error; } if (!$manager->generate_file('signature', $signature)) { return $manager->error; } if (!$manager->generate_zip()) { return $manager->error; } return null; }
} } break; case 'delete_all_certificates': Category::deleteAllCertificates($cat_id); break; } $course_code = api_get_course_id(); $interbreadcrumb[] = array('url' => Security::remove_XSS($_SESSION['gradebook_dest']) . '?', 'name' => get_lang('Gradebook')); $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('GradebookListOfStudentsCertificates')); $this_section = SECTION_COURSES; Display::display_header(''); if (isset($_GET['action']) && $_GET['action'] == 'delete') { $check = Security::check_token('get'); if ($check) { $certificate = new Certificate($_GET['certificate_id']); $result = $certificate->delete(true); Security::clear_token(); if ($result == true) { Display::display_confirmation_message(get_lang('CertificateRemoved')); } else { Display::display_error_message(get_lang('CertificateNotRemoved')); } } } $token = Security::get_token(); echo Display::page_header(get_lang('GradebookListOfStudentsCertificates')); //@todo replace all this code with something like get_total_weight() $cats = Category::load($cat_id, null, null, null, null, null, false); if (!empty($cats)) { //with this fix the teacher only can view 1 gradebook
/** * @param $id * @return string */ public function showCertificateAction($id) { $certificate = new \Certificate($id); // Show certificate HTML. return $certificate->show(true); }
/** * @param Certificate $certificate * @return bool */ public function delete(Certificate $certificate) { return $this->rmrf($certificate->getPath()); }
<?php $this->widget('zii.widgets.grid.CGridView', array( 'dataProvider'=>$model, 'summaryText'=>false, 'enableSorting'=>false, 'enablePagination' => false, 'columns'=>array( array( 'header'=>'SI No', 'class'=>'IndexColumn', ), array('name'=>'employee_first_name', 'value'=>'$data->cer_employee_id->employee_first_name.\'----\'.$data->cer_employee_id->employee_attendance_card_id', //'value'=>'$data->a.\' \'.$data->b.\' \'.$data->c', ), array('name'=>'employee_certificate_type_id', 'value'=>'Certificate::model()->findByPk($data->employee_certificate_type_id)->certificate_title', 'filter' =>Certificate::items1(), ), ), )); ?>