Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ashabed committed Nov 13, 2014
0 parents commit c83f5db
Show file tree
Hide file tree
Showing 66 changed files with 11,282 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/
modules/scorm/example_scorms/
339 changes: 339 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions js/opigno.admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
(function($) {

/**
* Automatically enables required permissions on demand.
*
* Many users do not understand that two permissions are required for the
* administration menu to appear. Since Drupal core provides no facility for
* this, we implement a simple manual confirmation for automatically enabling
* the "other" permission.
*/
Drupal.behaviors.opignoPermissions = {
attach: function (context, settings) {
$('#permissions', context).once('opigno-permissions-setup', function () {
// Retrieve matrix/mapping - these need to use the same indexes for the
// same permissions and roles.
var $roles = $(this).find('th:not(:first)');
var $admin = $(this).find('input[name$="[access administration pages]"]');
var $opigno = $(this).find('input[name$="[access opigno administration pages]"]');

// Retrieve the permission label - without description.
var adminPermission = $.trim($admin.eq(0).parents('td').prev().children().get(0).firstChild.textContent);
var opignoPermission = $.trim($opigno.eq(0).parents('td').prev().children().get(0).firstChild.textContent);

$admin.each(function (index) {
// Only proceed if both are not enabled already.
if (!(this.checked && $opigno[index].checked)) {
// Stack both checkboxes and attach a click event handler to both.
$(this).add($opigno[index]).click(function () {
// Do nothing when disabling a permission.
if (this.checked) {
// Figure out which is the other, check whether it still disabled,
// and if so, ask whether to auto-enable it.
var other = (this == $admin[index] ? $opigno[index] : $admin[index]);
if (!other.checked && confirm(Drupal.t('Also allow !name role to !permission?', {
'!name': $roles[index].textContent,
'!permission': (this == $admin[index] ? opignoPermission : adminPermission)
}))) {
other.checked = 'checked';
}
}
});
}
});
});
}
};

})(jQuery);
12 changes: 12 additions & 0 deletions modules/breadcrumbs/opigno_breadcrumbs.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name = Opigno Breadcrumbs
description = API for providing useful and intuitive breadcrumbs when in a course context.
core = 7.x
package = Opigno
dependencies[] = opigno
dependencies[] = og_context
; Information added by Drupal.org packaging script on 2014-10-19
version = "7.x-1.9"
core = "7.x"
project = "opigno"
datestamp = "1413751430"

65 changes: 65 additions & 0 deletions modules/breadcrumbs/opigno_breadcrumbs.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

/**
* @file
* Breadcrumbs module definition.
*/

/**
* Implements hook_preprocess_page().
*/
function opigno_breadcrumbs_preprocess_page(&$vars) {
$vars['breadcrumb'] = opigno_breadcrumbs();
}

/**
* Get the breadcrumb trail for the current page.
*/
function opigno_breadcrumbs() {
// Get the default breadcrumb.
$breadcrumb = drupal_get_breadcrumb();

// Fetch the group from URL context.
// If we are in group context, handle our own breadcrumbs.
$group = og_context('node');
if (!empty($group['gid'])) {
// Are we on the course page itself ? If so, skip this.
if (current_path() !== "node/{$group['gid']}") {
// We need some custom logic.
$new_breadcrumb = array(l(t('Home'), NULL));

// Add the course itself.
$group_title = opigno_breadcrumbs_get_group_title($group['gid']);
$new_breadcrumb[] = l($group_title, "node/{$group['gid']}");

// Ask other modules for breadcrumbs.
$module_breadcrumbs = module_invoke_all('opigno_breadcrumbs', $group['gid']);
if (!empty($module_breadcrumbs)) {
$new_breadcrumb = array_merge($new_breadcrumb, $module_breadcrumbs);
}

// Set the new trail.
$breadcrumb = $new_breadcrumb;
}
}

return theme_breadcrumb(array('breadcrumb' => $breadcrumb));
}

/**
* Helper function to get the group title.
*
* We use this instead of loading the entire node object from the DB.
*
* @param int $nid
*
* @return string
*/
function opigno_breadcrumbs_get_group_title($nid) {
$query = db_select('node', 'n');
$query->leftJoin('node_revision', 'v', 'n.vid = v.vid');
return $query->fields('v', array('title'))
->condition('n.nid', $nid)
->execute()
->fetchField();
}
16 changes: 16 additions & 0 deletions modules/og_prereq/opigno_og_prereq.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name = Opigno Course Prerequisite
description = Allows courses to have other courses as prerequisites.
core = 7.x
package = Opigno

dependencies[] = og
dependencies[] = rules
dependencies[] = rules_conditional
dependencies[] = entityreference
dependencies[] = opigno
; Information added by Drupal.org packaging script on 2014-10-19
version = "7.x-1.9"
core = "7.x"
project = "opigno"
datestamp = "1413751430"

68 changes: 68 additions & 0 deletions modules/og_prereq/opigno_og_prereq.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

/**
* @file
* Module install logic.
*/

/**
* Implements hook_install().
*/
function opigno_og_prereq_install() {
$field = field_info_field('course_required_course_ref');
if (empty($field)) {
field_create_field(array(
'active' => 1,
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'course_required_course_ref',
'foreign keys' => array(
'node' => array(
'columns' => array(
'target_id' => 'nid',
),
'table' => 'node',
),
),
'indexes' => array(
'target_id' => array(
0 => 'target_id',
),
),
'locked' => 0,
'module' => 'entityreference',
'settings' => array(
'handler' => 'base',
'handler_settings' => array(
'behaviors' => array(
'views-select-list' => array(
'status' => 0,
),
),
'sort' => array(
'type' => 'none',
),
'target_bundles' => array(
'course' => 'course',
),
),
'target_type' => 'node',
),
'translatable' => 1,
'type' => 'entityreference',
));
}

$instance = field_info_instance('node', 'course_required_course_ref', OPIGNO_COURSE_BUNDLE);
if (empty($instance)) {
field_create_instance(array(
'field_name' => 'course_required_course_ref',
'entity_type' => 'node',
'bundle' => OPIGNO_COURSE_BUNDLE,
'label' => "Required course",
'description' => "Makes this course dependent on another one.",
'required' => FALSE,
));
}
}
Loading

0 comments on commit c83f5db

Please sign in to comment.