Skip to content

Commit

Permalink
Merge branch 'umaster' into cookieTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
anvk committed Feb 15, 2013
2 parents 78c4654 + 1ac9d14 commit 8692916
Show file tree
Hide file tree
Showing 19 changed files with 105 additions and 86 deletions.
67 changes: 33 additions & 34 deletions documentation/developer/guidelines.html
Expand Up @@ -911,7 +911,7 @@ <h3><a name="directories"></a>13.1 Directories</h3>
<dd>This directory contains the SQL files necessary to set up or upgrade the ATutor database.</dd>

<dt><kbd>`install/include/`</kbd></dt>
<dd>This directory contains files used during a standalone installation or upgrade, calling on the file in include/install.</dd>
<dd>This directory contains files used during a standalone installation or upgrade, calling on the files in include/install.</dd>

<dt><kbd>`jscripts/`</kbd></dt>
<dd>This directory contains all JavaScript files.</dd>
Expand Down Expand Up @@ -956,7 +956,7 @@ <h2><a name="database-structure"></a>14. Database Structure</h2>

<a href="#top" class="top">top</a>
<h2><a name="localisation"></a>15. Localisation</h2>
<p>All language terms and phrases are stored in the ATutor database. See the <a href="#fn-at"><kbd>_AT()</kbd></a> function for details on displaying text. There are three tables that are used for managing languages, their roles are as follows:</p>
<p>All language terms and phrases are stored in the ATutor database. See the <a href="#fn-at"><kbd>_AT()</kbd></a> function in <kbd>include/lib/output.inc.php</kbd> for details on displaying text. There are three tables that are used for managing languages, their roles are as follows:</p>
<dl>
<dt><kbd>`language_pages`</kbd></dt>
<dd>This table is used to cross reference language terms with pages. It allows selecting, via a <kbd>JOIN</kbd>, only the terms needed for a particular page. The <kbd>JOIN</kbd> may be slow at first but once the result is cached, subsequent calls are many times faster such that only the language needed for a particular page is restored from cache.</dd>
Expand All @@ -983,7 +983,7 @@ <h2><a name="error-feedback-messages"></a>16. Error and Feedback Messages</h2>
<dd>Messages reflecting negative feedback to the user, indicating issues that need resolving or addressing.</dd>

<dt><kbd>Feedback</kbd></dt>
<dd>Messages reflecting positive feedback, aknowledging a users action was successfull.</dd>
<dd>Messages reflecting positive feedback, acknowledging a users action was successfull.</dd>

<dt><kbd>Warning</kbd></dt>
<dd>Messages warning the user of a possible action with undesireable effects.</dd>
Expand All @@ -999,15 +999,13 @@ <h2><a name="error-feedback-messages"></a>16. Error and Feedback Messages</h2>

</dl>


<p>Please note that using the old method of passing messages is not supported anymore.</p>

<p>Messages can be passed between pages and can be accessed at any time, without any time restriction other than a session timeout.</p>

<h3><a name="error-feedback-internals"></a>16.1 Internals</h3>
<p>Essentially the internals of the class are divided into two segments, a section responsible for printing graphics via Savant templates and another that manages the storage of Messages.</p>

<p>Tracking messages is accomplished by storing message codes and their optional arguments associatively in <kbd>$_SESSION</kbd>. Printing messages is accomplished via Savant and built in templates which can be found in <kbd>`templates/`</kbd>.</p>
<p>Tracking messages is accomplished by storing message codes and their optional arguments associatively in <kbd>$_SESSION</kbd>. Printing messages is accomplished via Savant and built in templates which can be found in <kbd>`themes/default/`</kbd>. Message templates can copied into themes other than default/ and modified to change their appearance, though typically changes are made in a secondary theme's styles.css file.</p>

<p>The relational tracking structure is organized in the following manner inside <kbd>$_SESSION</kbd> in no particular order.</p>
<ul>
Expand Down Expand Up @@ -1102,12 +1100,12 @@ <h3><a name="error-feedback-usage"></a>16.2 Adding Messages</h3>
</ul>


<p>There are two ways of adding messages: a single code or a code with an array fo arguments. You can mix-and-match, a combination of both is supported even for the same code. Below is description of the formats:</p>
<p>There are two ways of adding messages: a single code or a code with an array of arguments. You can mix-and-match, a combination of both is supported even for the same code. Below is description of the formats:</p>

<dl>
<dt>Adding single code</dt>
<dt><kbd>$msg->addHelp('FILE_EXPORTABLE');</kbd></dt>
<dt><strong>>OR</strong></dt>
<dt><strong>OR</strong></dt>
<dt>Adding array with arguments</dt>
<dt><kbd>$f = array('FILE_EXPORTABLE', 'arg', 'arg2', ...);</kbd></dt>
<dt><kbd>$msg->addHelp($f);</kbd></dt>
Expand Down Expand Up @@ -1136,23 +1134,23 @@ <h3><a name="error-feedback-usage"></a>16.2 Adding Messages</h3>

<p>Snapshot of a portion of <kbd>$_SESSION</kbd> as a result:</p>
<pre class="code">
[feedback] => Array
(
[AT_FEEDBACK_FORUM_ADDED] => Array
(
[0] => AT_FEEDBACK_FORUM_ADDED
[1] => ac_access_groups
[2] => about_atutor_help_text
)
[AT_FEEDBACK_FILE_UPLOADED_ZIP] => Array
(
[0] => AT_FEEDBACK_FILE_UPLOADED_ZIP
[1] => archive.zip
)


)
[feedback] => Array
(
[AT_FEEDBACK_FORUM_ADDED] => Array
(
[0] => AT_FEEDBACK_FORUM_ADDED
[1] => ac_access_groups
[2] => about_atutor_help_text
)

[AT_FEEDBACK_FILE_UPLOADED_ZIP] => Array
(
[0] => AT_FEEDBACK_FILE_UPLOADED_ZIP
[1] => archive.zip
)


)
...
</pre>

Expand Down Expand Up @@ -1180,12 +1178,12 @@ <h3><a name="error-feedback-printing"></a>16.3 Printing Messages</h3>
Essentially, two lines of code are accomplished in one.</p>
<p>Example:</p>
<pre class="code">
$msg->addError('MAX_ATTEMPTS');
$msg->printErrors();
can also be accomplished as:
$msg->printErrors('MAX_ATTEMPTS');
$msg->addError('MAX_ATTEMPTS');
$msg->printErrors();

can also be accomplished as:

$msg->printErrors('MAX_ATTEMPTS');
</pre>

<h4><a name="Boolean"></a>Printing String inside Feedback style box</h4>
Expand Down Expand Up @@ -1344,7 +1342,7 @@ <h4><a name="Example"></a>Example Code</h4>
</pre>
<a href="#top" class="top">top</a>
<h2><a name="mbstring-support"></a>16.4 UTF-8 and Multibyte language</h2>
<p>As of ATutor 1.6, string parsing is done with multibtyle string functions, either the <kbd>mbstring</kbd> function in PHP itself, or the multibyte string functions in the UTF-8 library included with ATutor. By default ATutor will attempt to use the PHP <kbd>mbstring</kbd> functions, and will fall back on the ATutor library if this fails. In order to support both methods of string processing, a set of custom string parsing functions have been created. The only time the ATutor functions will be used is when the mbstring check during the installation or upgrade process has been disabled. The functions mirror the standard string parsing function in PHP, but with the <kbd>$</kbd> prepended. So, where ever you would normally use a PHP function like <kbd>substr() </kbd>, instead use <kbd>$substr()</kbd>. These functions are located in the vital.inc.php</p>
<p>As of ATutor 1.6, string parsing is done with multibtyle string functions, either the <kbd>mbstring</kbd> function in PHP itself, or the multibyte string functions in the UTF-8 library included with ATutor. By default ATutor will attempt to use the PHP <kbd>mbstring</kbd> functions, and will fall back on the ATutor library if this fails. In order to support both methods of string processing, a set of custom string parsing functions have been created. The only time the ATutor functions will be used is when the mbstring check during the installation or upgrade process has been disabled. The functions mirror the standard string parsing function in PHP, but with the <kbd>$</kbd> prepended. So, where ever you would normally use a PHP function like <kbd>substr() </kbd>, instead use <kbd>$substr()</kbd>. These functions are located in the vitals.inc.php file.</p>
<pre class="code">
if (extension_loaded('mbstring')){
$strtolower = 'mb_strtolower';
Expand Down Expand Up @@ -1422,8 +1420,9 @@ <h4>Description</h4>
<p><kbd>$db</kbd> is the main database handler. Use it to connect to the ATutor database.</p>

<h4>Location</h4>
<p><kbd>`include/vitals.inc.php`</kbd></p>

<p><kbd>`include/vitals.inc.php`</kbd></p >
<h4>NOTE:</h4>
<p>The <kbd>$db</kbd> variable should not be use in versions of ATutor 2.1.1 and beyond, with database queries now being handles by the <a href="#querydb">queryDB()</a> function.</p>
<h3><a name="var-addslashes"></a>17.2 $addslashes</h3>
<p>See <a href="#fn-addslashes"><kbd>$addslashes()</kbd></a>.</p>

Expand Down
3 changes: 2 additions & 1 deletion include/classes/UrlRewrite/UrlRewrite.class.php
Expand Up @@ -191,12 +191,13 @@ function convertToPrettyUrl($course_id, $url){
$end = '';
}
$front_array = explode('/', $front);
if ($front_array[1]=='_standard' || $front_array[1]=='_core' ){
if (isset($front_array[1]) && ($front_array[1]=='_standard' || $front_array[1]=='_core' )){
//shift the first 2 elements.
array_shift($front_array);
array_shift($front_array);
$front = implode('/', $front_array);
}

//find out what kind of link this is, pretty url? relative url? or PHP_SELF url?
$dir_deep = substr_count(AT_INCLUDE_PATH, '..');
$url_parts = explode('/', $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
Expand Down
5 changes: 3 additions & 2 deletions include/footer.inc.php
Expand Up @@ -73,8 +73,9 @@ functionDemo();
<?php

//TODO******************BOLOGNA***************REMOVE ME ***********************/

$popup = intval($_GET['popup']);
if(isset($_GET['popup'])){
$popup = intval($_GET['popup']);
}
$footerName = 'footer';
if ($framed || $popup) {
$footerName = (isset($tool_flag) && ($tool_flag)) ? 'tm_footer' : 'fm_footer';
Expand Down
8 changes: 7 additions & 1 deletion include/header.inc.php
Expand Up @@ -88,7 +88,7 @@
}

// Set session timeout warning if user is logged in
if($_SESSION['valid_user']){
if(isset($_SESSION['valid_user'])){
// Setup the timeout warning when a user logs in
if($_config['session_timeout']){
$_at_timeout = ($_config['session_timeout']*60);
Expand Down Expand Up @@ -287,12 +287,18 @@
}

//side menu array
// NOT SURE IF THIS IS DOING ANYTHING
/*
if ($_SESSION['course_id'] > 0) {
$side_menu = array();
$side_menu = explode('|', $system_courses[$_SESSION['course_id']]['side_menu']);
debug($side_menu);
debug($_stacks);
$side_menu = array_intersect($side_menu, $_stacks);
debug($side_menu);
$savant->assign('side_menu', $side_menu);
}
*/
}

// array of content tools for shortcuts tool bar.
Expand Down
8 changes: 6 additions & 2 deletions include/html/browse.inc.php
Expand Up @@ -21,7 +21,7 @@
$cats[$row['cat_id']] = $row['cat_name'];
}

if ($_GET['reset_filter']) { unset($_GET); }
if (isset($_GET['reset_filter'])) { unset($_GET); }

$page_string = '';

Expand Down Expand Up @@ -128,7 +128,11 @@
$savant->assign('has_categories', $has_categories);
$savant->assign('categories_select', $categories_select);
$savant->assign('checked_include_all', $checked_include_all);
$savant->assign('checked_include_one', $checked_include_one);
if(isset($checked_include_one)){
$savant->assign('checked_include_one', $checked_include_one);
} else{
$savant->assign('checked_include_one', '');
}
$savant->assign('courses_rows', $courses_rows);

$savant->display('users/browse.tmpl.php');
Expand Down
1 change: 1 addition & 0 deletions include/lib/constants.inc.php
Expand Up @@ -289,6 +289,7 @@
define('ANDROID_DEVICE', 'android');
define('UNKNOWN_DEVICE', 'unknown');
define('IPAD_DEVICE', 'ipad');
define('PLAYBOOK', 'playbook');

// machine type
define('DESKTOP_DEVICE', 'Desktop');
Expand Down
7 changes: 4 additions & 3 deletions include/lib/menu_pages.php
Expand Up @@ -23,7 +23,7 @@
}

if($_config['allow_browse'] && $_config['just_social'] != "1") {
if($_SESSION['valid_user']){
if(isset($_SESSION['valid_user'])){
$browse_tab = "users/browse.php";
}else{
$browse_tab = "browse.php";
Expand Down Expand Up @@ -214,8 +214,9 @@
$_pages['users/profile.php']['title_var'] = 'profile';
$_pages['users/profile.php']['parent'] = AT_NAV_START;
$_pages['users/profile.php']['guide'] = 'general/?p=profile.php';
if(isset($_pages['users/profile.php']['children'])){
$_pages['users/profile.php']['children'] = array_merge(array('users/password_change.php', 'users/email_change.php','mods/_standard/profile_pictures/profile_picture.php'), (array) $_pages['users/profile.php']['children']);

}
$_pages['users/password_change.php']['title_var'] = 'change_password';
$_pages['users/password_change.php']['parent'] = 'users/profile.php';
//$_pages['users/password_change.php']['guide'] = 'instructor/?p=creating_courses.php';
Expand Down Expand Up @@ -350,7 +351,7 @@ function get_main_navigation($current_page) {
$table = '';
}

$_top_level_pages[] = array('url' => AT_print($_base_path, 'url.page') . url_rewrite($page), 'title' => $_page_title, 'img' => AT_print($_base_path, 'url.page').$_pages[$page]['img'], 'tool_file' => $tool_file, 'table' => $table);
$_top_level_pages[] = array('url' => AT_print($_base_path, 'url.page') . url_rewrite($page), 'title' => $_page_title, 'tool_file' => $tool_file, 'table' => $table);
}
}
} else if (isset($parent_page)) {
Expand Down
17 changes: 10 additions & 7 deletions include/lib/output.inc.php
Expand Up @@ -301,18 +301,21 @@ function _AT() {
}
$_template = $_cache_template;
}

$term_text = $_template[$term];
$outString = isset($term_text) ? (isset($args) && is_array($args) ? vsprintf($term_text, $args) : $term_text) : '';

if(isset($_template[$term])){
$term_text = $_template[$term];
$outString = isset($term_text) ? (isset($args) && is_array($args) ? vsprintf($term_text, $args) : $term_text) : '';
}

if (empty($outString)) {
// Note: the query below limits the returned data to one row to deal with the case that one language term has multiple text defined.
// Using "_template" always has more priority over "_module". This logic should be fixed once we have support for _module terms.
$row = queryDB('SELECT L.* FROM %slanguage_text L WHERE L.language_code="%s" AND L.term="%s" ORDER BY variable DESC LIMIT 1', array(TABLE_PREFIX, $lang, $term), true);
$row_term = $row['term'];

$outString = $_template[$row_term] = stripslashes($row['text']);
if(isset($row['term']) && isset($row['text'])){
$row_term = $row['term'];

$outString = $_template[$row_term] = stripslashes($row['text']);
}
// specifically for "_msgs" type
$term_prefix = substr($term, 0, 7); // 7 is the shortest type of msg (AT_HELP)
if (in_array($term_prefix, $termTypes)) {
Expand All @@ -322,7 +325,7 @@ function _AT() {
}
}

$outString = is_array($args) ? vsprintf($outString, $args) : $outString;
$outString = isset($term_text) ? (isset($args) && is_array($args) ? vsprintf($outString, $args) : $outString) : '';

/* update the locations */
// NOTE!! This code should be removed from here. Eventually a separate module will be created for populating language_pages
Expand Down
12 changes: 7 additions & 5 deletions include/lib/vital_funcs.inc.php
Expand Up @@ -537,7 +537,9 @@ function url_rewrite($url, $is_rewriting_header=AT_PRETTY_URL_NOT_HEADER, $force
$course_id = $url_parser->getCourseDirName($_SESSION['course_id']);
}
} else {
if(isset($_SESSION['course_id'])){
$course_id = $_SESSION['course_id'];
}
}
$url = $pathinfo[1]->convertToPrettyUrl($course_id, $url);
} elseif ($_config['course_dir_name'] > 0) {
Expand Down Expand Up @@ -618,13 +620,13 @@ function query_bit( $bitfield, $bit ) {
* @author Joel Kronenberg
*/
function authenticate($privilege, $check = false) {
if ($_SESSION['is_admin']) {
if (isset($_SESSION['is_admin'])) {
return true;
}

$auth = query_bit($_SESSION['privileges'], $privilege);

if (!$_SESSION['valid_user'] || !$auth) {
if(isset($_SESSION['privileges'])){
$auth = query_bit($_SESSION['privileges'], $privilege);
}
if (!isset($_SESSION['valid_user']) || !$auth) {
if (!$check){
global $msg;
$msg->addInfo('NO_PERMISSION');
Expand Down
12 changes: 6 additions & 6 deletions jscripts/ATutor_js.php
Expand Up @@ -40,14 +40,14 @@
//everything in the document.ready block executes after the page is fully loaded
jQuery(document).ready( function () {
ATutor.users.preferences.setStyles(
'<?php echo $_SESSION["prefs"]["PREF_BG_COLOUR"]; ?>',
'<?php echo $_SESSION["prefs"]["PREF_FG_COLOUR"]; ?>',
'<?php echo $_SESSION["prefs"]["PREF_HL_COLOUR"]; ?>',
'<?php echo $_SESSION["prefs"]["PREF_FONT_FACE"]; ?>',
'<?php echo $_SESSION["prefs"]["PREF_FONT_TIMES"]; ?>');
'<?php if(isset($_SESSION["prefs"]["PREF_BG_COLOUR"])){echo $_SESSION["prefs"]["PREF_BG_COLOUR"];} ?>',
'<?php if(isset($_SESSION["prefs"]["PREF_FG_COLOUR"])){ echo $_SESSION["prefs"]["PREF_FG_COLOUR"];} ?>',
'<?php if(isset($_SESSION["prefs"]["PREF_HL_COLOUR"])){echo $_SESSION["prefs"]["PREF_HL_COLOUR"];} ?>',
'<?php if(isset($_SESSION["prefs"]["PREF_FONT_FACE"])){echo $_SESSION["prefs"]["PREF_FONT_FACE"];} ?>',
'<?php if(isset($_SESSION["prefs"]["PREF_FONT_TIMES"])){echo $_SESSION["prefs"]["PREF_FONT_TIMES"];} ?>');

ATutor.users.preferences.addPrefWizClickHandler();
ATutor.users.preferences.course_id = "<?php echo $_SESSION['course_id']; ?>";
ATutor.users.preferences.course_id = "<?php if(isset($_SESSION['course_id'])){ echo $_SESSION['course_id'];} ?>";
<?php
if (isset($_SESSION['course_id']) && ($_SESSION['course_id'] > 0)) {
?>
Expand Down
4 changes: 2 additions & 2 deletions mods/_core/cats_categories/lib/admin_categories.inc.php
Expand Up @@ -74,8 +74,8 @@ function select_categories($categories, $cat_id, $current_cat_id, $exclude, $dep
echo '>';
echo str_repeat("&nbsp;", $depth*4);
echo validate_length($categories[$cat_id]['cat_name'], 45, VALIDATE_LENGTH_FOR_DISPLAY).'</option>';

if (is_array($categories[$cat_id]['children'])) {
if (isset($categories[$cat_id]['children']) && is_array($categories[$cat_id]['children'])) {
foreach($categories[$cat_id]['children'] as $child_cat_id) {
select_categories($categories, $child_cat_id, $current_cat_id, $exclude, $depth+1);
}
Expand Down
4 changes: 3 additions & 1 deletion mods/_standard/assignment_dropbox/module.php
Expand Up @@ -38,7 +38,9 @@
$this->_pages['mods/_standard/assignment_dropbox/index.php']['text'] = _AT('assignment_dropbox_text');
$this->_pages['mods/_standard/assignment_dropbox/index.php']['parent'] = 'mods/_standard/assignments/index_instructor.php';


if(isset($_SESSION['course_id'])){
$this->_pages['mods/_standard/assignments/index_instructor.php']['children'] =
array_merge(is_array($this->_pages['mods/_standard/assignments/index_instructor.php']['children']) ? $this->_pages['mods/_standard/assignments/index_instructor.php']['children'] : array(), array('mods/_standard/assignment_dropbox/index.php'));

}
?>
4 changes: 2 additions & 2 deletions mods/_standard/file_storage/file_storage.inc.php
Expand Up @@ -199,8 +199,8 @@ function fs_get_folder_by_pid($parent_folder_id, $owner_type, $owner_id) {
$sql = "SELECT G.group_id AS folder_id, G.title FROM ".TABLE_PREFIX."groups G INNER JOIN ".TABLE_PREFIX."file_storage_groups FS USING (group_id) WHERE G.type_id=$row[assign_to] ORDER BY G.title";
} else {
global $system_courses;

$sql = "SELECT E.member_id AS folder_id, M.login AS title FROM ".TABLE_PREFIX."course_enrollment E INNER JOIN ".TABLE_PREFIX."members M USING (member_id) WHERE E.course_id=$_SESSION[course_id] AND E.approved='y' AND E.privileges & ".AT_PRIV_GROUPS." = 0 AND E.member_id<>{$system_courses[$_SESSION[course_id]][member_id]} ORDER BY M.login";
$this_member = $system_courses[$_SESSION['course_id']]['member_id'];
$sql = "SELECT E.member_id AS folder_id, M.login AS title FROM ".TABLE_PREFIX."course_enrollment E INNER JOIN ".TABLE_PREFIX."members M USING (member_id) WHERE E.course_id=$_SESSION[course_id] AND E.approved='y' AND E.privileges & ".AT_PRIV_GROUPS." = 0 AND E.member_id<>{$this_member} ORDER BY M.login";
}
$result = mysql_query($sql, $db);

Expand Down

0 comments on commit 8692916

Please sign in to comment.