Skip to content

Commit

Permalink
add plugin buy course in course about - refs BT#7683
Browse files Browse the repository at this point in the history
  • Loading branch information
aragonc committed Jun 13, 2018
1 parent dd3390a commit ff1c3f5
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 38 deletions.
26 changes: 8 additions & 18 deletions main/auth/courses_categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ function returnThumbnail($course, $registeredUser)
{
$html = '';
$title = cut($course['title'], 70);
$linkCourse = api_get_course_url($course['code']);

//$linkCourse = api_get_course_url($course['code']);
$linkCourse = api_get_path(WEB_PATH).'course/'.$course['real_id'].'/about';
// course path
$course_path = api_get_path(SYS_COURSE_PATH).$course['directory'];

Expand All @@ -329,15 +329,9 @@ function returnThumbnail($course, $registeredUser)
}

$html .= '<div class="image">';
if (!$registeredUser) {
$html .= '<img class="img-responsive"'
.' src="'.$courseMediumImage.'" '
.' alt="'.api_htmlentities($title).'"/>';
} else {
$html .= '<a href="'.$linkCourse.'" title="'.$course['title'].'">'
.'<img class="img-responsive" src="'.$courseMediumImage.'" '
.'alt="'.api_htmlentities($title).'"/></a>';
}
$html .= '<a href="'.$linkCourse.'" title="'.$course['title'].'">'
.'<img class="img-responsive" src="'.$courseMediumImage.'" '
.'alt="'.api_htmlentities($title).'"/></a>';

$categoryTitle = isset($course['category_title']) ? $course['category_title'] : '';
if (!empty($categoryTitle)) {
Expand Down Expand Up @@ -421,14 +415,10 @@ class="btn btn-default panel_popover"
*/
function return_title($course, $registeredUser)
{
$linkCourse = api_get_course_url($course['code']);
//$linkCourse = api_get_course_url($course['code']);
$linkCourse = api_get_path(WEB_PATH).'course/'.$course['real_id'].'/about';
$html = '<div class="block-title"><h4 class="title">';
if (!$registeredUser) {
$html .= $course['title'];
} else {
$html .= '<a title="'.$course['title'].'" href="'.$linkCourse.'">'.$course['title'].'</a>';
}

$html .= '<a title="'.$course['title'].'" href="'.$linkCourse.'">'.$course['title'].'</a>';
$html .= '</h4></div>';

if (api_get_configuration_value('hide_course_rating') === false) {
Expand Down
12 changes: 11 additions & 1 deletion main/course_info/about.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
$courseTags = [];

if (!is_null($tagField)) {
$courseTags = $fieldTagsRepo->getTags($tagField, $course->getId());
$courseTags = $fieldTagsRepo->getTags($tagField, $courseId);
}

$courseDescription = $courseObjectives = $courseTopics = $courseMethodology = $courseMaterial = $courseResources = $courseAssessment = '';
Expand Down Expand Up @@ -123,6 +123,15 @@

$subscriptionUser = CourseManager::is_user_subscribed_in_course($user_id,$course->getCode());

$plugin = BuyCoursesPlugin::create();
$checker = $plugin->isEnabled();
$courseIsPremium = null;
if ($checker) {
$courseIsPremium = $plugin->getItemByProduct(
$courseId,
BuyCoursesPlugin::PRODUCT_TYPE_COURSE
);
}

$courseItem = [
'code' => $course->getCode(),
Expand Down Expand Up @@ -153,6 +162,7 @@
$template->assign('course', $courseItem);
$essence = Essence\Essence::instance();
$template->assign('essence', $essence);
$template->assign('is_premium', $courseIsPremium);
$template->assign('url', $urlCourse);
$layout = $template->get_template('course_home/about.tpl');
$content = $template->fetch($layout);
Expand Down
2 changes: 1 addition & 1 deletion main/session/about.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
);
$template->assign('has_requirements', $hasRequirements);
$template->assign('sequences', $sessionRequirements);
$template->assign('is_premiun', $sessionIsPremium);
$template->assign('is_premium', $sessionIsPremium);
$layout = $template->get_template('session/about.tpl');
$content = $template->fetch($layout);
//$template->assign('header', $session->getName());
Expand Down
32 changes: 17 additions & 15 deletions main/template/default/course_home/about.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,25 @@
<div class="col-sm-4">
<div class="panel panel-default">
<div class="panel-body">
<div class="session-price">
{% if is_premium == false %}
{% if course.subscription %}
<div class="buy-box">
<a href="{{ _p.web }}courses/{{ course.code }}/index.php?id_session=0" class="btn btn-lg btn-success btn-block">{{ 'SignInCourse'|get_lang }}</a>
</div>
{% else %}
<div class="sale-price">
{{ 'SalePrice'|get_lang }}
</div>
<div class="price-text">
S/. 100.00
</div>
<div class="buy-box">
<a href="#" class="btn btn-lg btn-primary btn-block">{{ 'BuyNow'|get_lang }}</a>
</div>
<div class="buy-box">
<a href="{{ _p.web }}courses/{{ course.code }}/index.php?id_session=0" class="btn btn-lg btn-success btn-block">{{ 'SignInCourse'|get_lang }}</a>
</div>
{% endif %}
</div>
{% else %}
<div class="session-price">
<div class="sale-price">
{{ 'SalePrice'|get_lang }}
</div>
<div class="price-text">
{{ is_premium.iso_code }} {{ is_premium.price }}
</div>
<div class="buy-box">
<a href="{{ _p.web }}plugin/buycourses/src/process.php?i={{ is_premium.product_id }}&t={{ is_premium.product_type }}" class="btn btn-lg btn-primary btn-block">{{ 'BuyNow'|get_lang }}</a>
</div>
</div>
{% endif %}
</div>
</div>
<div class="panel panel-default">
Expand Down
6 changes: 3 additions & 3 deletions main/template/default/session/about.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
{% endif %}
</p>
</div>
{% if is_premiun == false %}
{% if is_premium == false %}
<h5>{{ 'CourseSubscription'|get_lang }}</h5>
<div class="session-subscribe">
{% if _u.logged and not is_subscribed %}
Expand All @@ -80,10 +80,10 @@
{{ 'SalePrice'|get_lang }}
</div>
<div class="price-text">
{{ is_premiun.iso_code }} {{ is_premiun.price }}
{{ is_premium.iso_code }} {{ is_premium.price }}
</div>
<div class="buy-box">
<a href="{{ _p.web }}plugin/buycourses/src/process.php?i={{ is_premiun.product_id }}&t={{ is_premiun.product_type }}" class="btn btn-lg btn-primary btn-block">{{ 'BuyNow'|get_lang }}</a>
<a href="{{ _p.web }}plugin/buycourses/src/process.php?i={{ is_premium.product_id }}&t={{ is_premium.product_type }}" class="btn btn-lg btn-primary btn-block">{{ 'BuyNow'|get_lang }}</a>
</div>
</div>
{% endif %}
Expand Down

0 comments on commit ff1c3f5

Please sign in to comment.