Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ app/tmp/logs/*.log
app/webroot/uploads
/nbproject/private/
.idea
.DS_Store
6 changes: 3 additions & 3 deletions app/Config/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* In production mode, flash messages redirect after a time interval.
* In development mode, you need to click the flash message to continue.
*/
Configure::write('debug', 0);
Configure::write('debug', 2);

/**
* Configure the Error handler used to handle errors for your application. By default
Expand Down Expand Up @@ -227,7 +227,7 @@
Configure::write('Acl.database', 'default');

/**
* Uncomment this line and correct your server timezone to fix
* Uncomment this line and correct your server timezone to fix
* any date & time related errors.
*/
//date_default_timezone_set('UTC');
Expand All @@ -237,7 +237,7 @@
* If running via cli - apc is disabled by default. ensure it's available and enabled in this case
*
* Note: 'default' and other application caches should be configured in app/Config/bootstrap.php.
* Please check the comments in boostrap.php for more info on the cache engines available
* Please check the comments in boostrap.php for more info on the cache engines available
* and their setttings.
*/
$engine = 'File';
Expand Down
20 changes: 12 additions & 8 deletions app/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

class AppController extends Controller {

public $theme = 'GuideOnTheSide';

public $theme = 'GuideOnTheSide';
public $paginate = array();

// GD settings
var $padding = 10; // not the CSS padding, but the padding inside the image
var $character_width = 8;
Expand All @@ -29,15 +30,18 @@ function beforeFilter() {
$this->helpers[] = 'Js';

// provide the role to all actions
$role_id = $this->Auth->user('role_id');
$this->loadModel('Role');
$this->Role->recursive = 0;
$role = $this->Role->findById($role_id);
$this->Session->write('Role', $role['Role']);
$is_logged_in = $this->Auth->user();
if ($is_logged_in) {
$role_id = $this->Auth->user('role_id');
$this->loadModel('Role');
$this->Role->recursive = 0;
$role = $this->Role->findById($role_id);
$this->Session->write('Role', $role['Role']);
}

$this->set('is_admin', $this->Session->read('Role.name') == 'admin');
$this->set('show_password_link', !$this->Auth->user('noLoginForm'));

if ($theme = Configure::read('user_config.theme')) {
$this->theme = $theme;
}
Expand Down
54 changes: 27 additions & 27 deletions app/Controller/TutorialsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,11 @@ function view_tutorial_only($id = null, $revision_id = null) {
//$this->Tutorial->FinalQuiz->useDbConfig = 'default';
}

function add() {
public function add() {
if (!empty($this->data)) {
$this->Tutorial->create();
$this->data['Revision']['message'] = 'created';
$this->data = array_merge($this->data, array('Revision' => array('message' => 'created')));
$this->Tutorial->user_id = $this->Session->read('Auth.User.id');
$this->Tutorial->create();
if ($this->Tutorial->save($this->data)) {
$this->Session->setFlash(__('The tutorial has been saved'));
if ($this->data['Tutorial']['tutorial_type_id'] == TUTORIAL_TYPE_SIDEBYSIDE) {
Expand Down Expand Up @@ -776,7 +776,7 @@ function view_heading_image($type = 'chapter', $text = '') {
$this->layout = 'image';

$text = QH_urldecode($text);

if ($type == 'chapter') {
$string = ucfirst($type);
if (!empty($text)) {
Expand Down Expand Up @@ -841,7 +841,7 @@ function view_definition_image($link_text, $definition = '') {
} else {
$box_width = $this->padding * 2 + $this->number_of_characters * $this->character_width;
}

$image = imagecreatetruecolor($box_width, $box_height);
$background = imagecolorallocate($image, 128, 194, 120);

Expand All @@ -864,7 +864,7 @@ function view_text_box_image($type = 'one-line', $prompt = '', $placeholder = ''
$this->layout = 'image';

$text = QH_urldecode($prompt);

if ($type == 'one-line' || $type == 'multi-line') {
$string = ucfirst($type);
if (!empty($text)) {
Expand All @@ -887,10 +887,10 @@ function view_text_box_image($type = 'one-line', $prompt = '', $placeholder = ''

$black = imagecolorallocate($image, 0, 0, 0);
$white = imagecolorallocate($image, 255, 255, 255);

imagefill($image, 0, 0, $white);
imagerectangle($image, 0, 0, $box_width - 1, $box_height - 1, $black);

$y = $this->padding + $this->character_height;
foreach ($text as $line) {
imagettftext($image, $this->font_size, 0, $this->padding, $y, $black, APP . 'Lib/unifont_5.1.20080907.ttf', $line);
Expand All @@ -901,8 +901,8 @@ function view_text_box_image($type = 'one-line', $prompt = '', $placeholder = ''
imagepng($image);
imagedestroy($image);
$this->autoRender = false;
}
}

function provide_feedback($id = null, $mode = null) {
$this->set('noGoogleAnalytics', true);
if (!$id || !is_numeric($id)) {
Expand All @@ -924,18 +924,18 @@ function provide_feedback($id = null, $mode = null) {
htmlentities($this->data['Tutorial']['comment']);
$tutorialUrl = Router::url(array('action' => $action, $id), true);
$body .= "<p>" . __('This feedback was sent from %s', $tutorialUrl) . "</p>";

$message = new CakeEmail('default');
$message->subject(__('Feedback for %s tutorial', $tutorial['Tutorial']['title']));
$message->emailFormat('html');

$to_array = explode(',', Configure::read('user_config.email.send_all_feedback_to'));
$to_array[] = $tutorial['Tutorial']['contact_email'];

foreach ($to_array as $to) {
$message->addBcc(trim($to));
}

try {
// haddress ("Honeypot address") is the honeypot field.
// If it's filled out, pretend to send, but don't really.
Expand All @@ -946,9 +946,9 @@ function provide_feedback($id = null, $mode = null) {
exit();
} catch (Exception $e) {
echo $e->getMessage();
exit();
}
exit();
}

} else {
$this->layout = 'public';
$this->set(compact('tutorial', 'mode'));
Expand All @@ -964,7 +964,7 @@ function view_certificate() {
$is_quiz = false;
$this->set('tutorial_grades', array());
$this->set('quiz_grades', array());

if (array_key_exists('tutorial_id', $this->request->data) && is_numeric($this->request->data['tutorial_id'])) {
$tutorial = $this->Tutorial->read(null, $this->request->data['tutorial_id']);
if ($tutorial['Tutorial']['certificate']) {
Expand All @@ -973,16 +973,16 @@ function view_certificate() {
if (!isset($this->request->data['questions'])) {
$this->request->data['questions'] = array();
}
$this->set('tutorial_grades', $this->Tutorial->grade($this->request->data['tutorial_id'],
$this->set('tutorial_grades', $this->Tutorial->grade($this->request->data['tutorial_id'],
$this->request->data['questions']));
}
}
}

if (!isset($this->request->data['free-response'])) {
$this->request->data['free-response'] = array();
}
$this->set('free_responses', $this->request->data['free-response']);

if (array_key_exists('quiz_id', $this->request->data) && is_numeric($this->request->data['quiz_id'])) {
$final_quiz = $this->Tutorial->FinalQuiz->read(null, $this->request->data['quiz_id']);
if ($final_quiz['FinalQuiz']['certificate']) {
Expand All @@ -994,7 +994,7 @@ function view_certificate() {
$this->set('quiz_grades', $this->Tutorial->FinalQuiz->grade($this->request->data['quiz_id'], $this->request->data['questions']));
}
}

// parse supplied email fields

if ($is_tutorial || $is_quiz) {
Expand All @@ -1008,18 +1008,18 @@ function view_certificate() {
}
$to_string .= $this->request->data['certificate_email'];
}

$this->set('date', date('F j, Y'));
$this->set('time', date('g:ia'));
$this->set('name', Sanitize::paranoid($this->request->data['certificate_name'], array(' ')));
$this->set('title', $subject);

$message = new CakeEmail('default');
$message->subject(__('Certificate of Completion for %s', $subject));
$message->template('certificate_of_completion');
$message->emailFormat('html');
$message->viewVars($this->viewVars);

$to_array = explode(',', $to_string);
foreach ($to_array as $key => $to) {
if ($to == 'Emailaddresses' || empty($to)) {
Expand All @@ -1034,7 +1034,7 @@ function view_certificate() {
$email_success = true;
} catch (Exception $e) {
$email_success = $e->getMessage();
}
}

$this->viewPath = 'Emails/html';
$this->layout = 'Emails/html/default';
Expand All @@ -1049,7 +1049,7 @@ function view_certificate() {
$this->Session->setFlash(__('The following message could <strong>not</strong> be sent.'));
}
}

return $this->render('certificate_of_completion');
} else {
return __('This certificate cannot be generated.');
Expand Down
Loading