diff --git a/documentation/changelog.html b/documentation/changelog.html index 758a8ad78a..37a4edc556 100644 --- a/documentation/changelog.html +++ b/documentation/changelog.html @@ -33,16 +33,26 @@
  • An internationalization option has been added for improving sorting in arbitrary language. When the intl php-extension has been installed, various sorting routines exploit it for better sorting. Rationale: The PHP5 run-time environment does not provide native and reliable way of sorting UTF-8 strings. (FS#306)
  • The installation sript: The page about system requilements has been updated. Also, at the very beginning, a check has been added whether the mbstring php-extension is installed - see the related forum topic. (FS#306)
  • A new php-based configuration for the online editor has been implemented, see dokeos/main/inc/lib/fckeditor/myconfig.php. Also, toolbar definitions have been split in separate php-files within the directory dokeos/main/inc/lib/fckeditor/toolbars/ . Customization of the editor is more convenient and flexible now. (FS#2867)
  • -
  • The online editor: A upgrade from FCKEditor 2.6.4 to FCKEditor 2.6.4.1 has been implemented. (FS#4383)
  • -
  • The online editor: Several known bug-fixes from FCKEditor 2.6.5 SVN have been implemented, tickets #2821, #2856, #2915, #3120, #3181, #3429, #3439, #3880. (FS#2867)
  • -
  • The online editor: The simple file manager, the advanced file manager and the image manager have been integrated by default with the editor's dialog system. Thus, they work faster and in a more secure way. (FS#2867)
  • -
  • The online editor: Blocking copy/paste for trainees has been added. The feature is configurable through editing the toolbar definition files within the directory dokeos/main/inc/lib/fckeditor/toolbars/ . (FS#2867)
  • -
  • The online editor: Preview tabs have been added to the dialogs for inserting video, flv-video, and YouTube video. (FS#2867)
  • -
  • The online editor: The audio plugin has been activated by default as an implementation of the "Insert audio / Audio properties" dialog. This new plugin is intended to replace the "MP3" plugin. (FS#2867)
  • -
  • The online editor: Configuration of the mimetex plugin has been reworked to gain simplicity. The procedure for configuration has been updated, see the related forum topic. (FS#2867)
  • -
  • The online editor: The toolbar icons have been upgraded to those from CKEditor 3.0. (FS#2867)
  • +
  • Online editor: A upgrade from FCKEditor 2.6.4 to FCKEditor 2.6.4.1 has been implemented. (FS#4383)
  • +
  • Online editor: Several known bug-fixes from FCKEditor 2.6.5 SVN have been implemented, tickets #1537, #2156, #2689, #2821, #2856, #2874, #2915, #3120, #3181, #3427, #3429, #3439, #3446, #3481, #3677, #3818, #3880, #3925. (FS#2867)
  • +
  • Online editor: The simple file manager, the advanced file manager and the image manager have been integrated by default with the editor's dialog system. Thus, they work faster and in a more secure way. (FS#2867)
  • +
  • Online editor: Blocking copy/paste for trainees has been added. The feature is configurable through editing the toolbar definition files within the directory dokeos/main/inc/lib/fckeditor/toolbars/ . (FS#2867)
  • +
  • Online editor: Preview tabs have been added to the dialogs for inserting video, flv-video, and YouTube video. (FS#2867)
  • +
  • Online editor: The audio plugin has been activated by default as an implementation of the "Insert audio / Audio properties" dialog. This new plugin is intended to replace the "MP3" plugin. (FS#2867)
  • +
  • Online editor: Configuration of the mimetex plugin has been reworked to gain simplicity. The procedure for configuration has been updated, see the related forum topic. (FS#2867)
  • +
  • Online editor: The toolbar icons have been upgraded to those from CKEditor 3.0. (FS#2867)
  • A solution has been implemented for fixing the "__flash__removeCallback" bug, which affects the media player on Internet Explorer browser. (FS#4378 and FS#2867)
  • Implement new sub-language feature by which language terms redefinition becomes possible through the admin section (FS#4321)
  • +
  • Social: Added possibility to define RSS feeds inside personal page of social network (need to define an 'rssfeeds' extra user text field)
  • +
  • Admin: Added courses from sessions inside AJAX popup of courses list in users list (SVN#22398)
  • +
  • Admin: Showing full-length course titles in list of courses while adding to sessions(SVN#22399)
  • +
  • Admin: Added session name in title of session edition pages(SVN#22400)
  • + +
    +

    Known issues

    +

    Known issues

    diff --git a/main/admin/add_courses_to_session.php b/main/admin/add_courses_to_session.php index 216d625cbe..d482d5348d 100644 --- a/main/admin/add_courses_to_session.php +++ b/main/admin/add_courses_to_session.php @@ -1,26 +1,5 @@ -debugOn(); $xajax -> registerFunction ('search_courses'); @@ -164,7 +143,7 @@ function search_courses($needle,$type) while($course = Database :: fetch_array($rs)) { $course_list[] = $course['code']; $course_title=str_replace("'","\'",$course_title); - $return .= ''; + $return .= ''; } $return .= ''; @@ -301,8 +280,9 @@ echo '
    '; echo $link_add_type_unique.$link_add_type_multiple; echo '
    '; -// the form header -echo '
    '.$tool_name.'
    '; +// the form header +$session_info = SessionManager::fetch($id_session); +echo '
    '.$tool_name.' ('.$session_info['name'].')
    '; /*$sql = 'SELECT COUNT(1) FROM '.$tbl_course; @@ -436,7 +416,7 @@ else foreach($nosessionCourses as $enreg) { ?> - + - + - + \ No newline at end of file diff --git a/main/auth/inscription.php b/main/auth/inscription.php index 921dafb2bc..d07ff55e09 100644 --- a/main/auth/inscription.php +++ b/main/auth/inscription.php @@ -1,5 +1,5 @@ addElement('hidden', 'legal_accept_type',$term_preview['version'].':'.$term_preview['language_id']); + $form->addElement('hidden', 'legal_info',$term_preview['legal_id'].':'.$term_preview['language_id']); if (isset($_SESSION['info_current_user'][1]) && isset($_SESSION['info_current_user'][2])) { $form->addElement('hidden', 'login',$_SESSION['info_current_user'][1]); - $form->addElement('hidden', 'password',$_SESSION['info_current_user'][2]); + $form->addElement('hidden', 'password',$_SESSION['info_current_user'][2]); } if($term_preview['type'] == 1) { $form->addElement('checkbox', 'legal_accept', null, get_lang('IhaveReadAndAgree').' '.get_lang('TermsAndConditions').''); diff --git a/main/document/slideshowoptions.php b/main/document/slideshowoptions.php index a8ada88fd7..e64eb674de 100644 --- a/main/document/slideshowoptions.php +++ b/main/document/slideshowoptions.php @@ -1,4 +1,4 @@ -'; } ?>> -

    +

    @@ -178,32 +178,28 @@ echo ''; ?>>
    -

    +

    :   > -
    +
    :      - > + } else { + echo " class=\"disabled_input\""; + } + ?> >
    @@ -216,5 +212,4 @@ echo '
    '; +Display::display_footer(); \ No newline at end of file diff --git a/main/dropbox/dropbox_functions.inc.php b/main/dropbox/dropbox_functions.inc.php index ab3bc65c6b..fcd4d47a52 100644 --- a/main/dropbox/dropbox_functions.inc.php +++ b/main/dropbox/dropbox_functions.inc.php @@ -1,12 +1,10 @@ , Ghent University */ - /** * This function is a wrapper function for the multiple actions feature. * @return Mixed If there is a problem, return a string message, otherwise nothing @@ -137,13 +135,13 @@ function delete_category($action, $id) // step 1: delete the category $sql="DELETE FROM ".$dropbox_cnf['tbl_category']." WHERE cat_id='".Database::escape_string($id)."' AND $sentreceived='1'"; - $result=api_sql_query($sql); + $result=Database::query($sql,__FILE__,__LINE__); // step 2: delete all the documents in this category $sql="SELECT * FROM ".$entries_table." WHERE cat_id='".Database::escape_string($id)."'"; - $result=api_sql_query($sql); + $result=Database::query($sql,__FILE__,__LINE__); - while ($row=mysql_fetch_array($result)) + while ($row=Database::fetch_array($result)) { $dropboxfile=new Dropbox_Person( $_user['user_id'], $is_courseAdmin, $is_courseTutor); if ($action=='deletereceivedcategory') @@ -170,8 +168,8 @@ function display_move_form($part, $id, $target=array()) { echo '
    '.get_lang('MoveFileTo').'
    '; echo '
    '; - echo ''; - echo ''; + echo ''; + echo ''; echo '
    @@ -227,7 +225,7 @@ function store_move($id, $target, $part) WHERE dest_user_id='".Database::escape_string($_user['user_id'])."' AND file_id='".Database::escape_string($id)."' "; - api_sql_query($sql,__FILE__,__LINE__); + Database::query($sql,__FILE__,__LINE__); $return_message=get_lang('ReceivedFileMoved'); } if ($part=='sent') @@ -236,7 +234,7 @@ function store_move($id, $target, $part) WHERE uploader_id='".Database::escape_string($_user['user_id'])."' AND id='".Database::escape_string($id)."' "; - api_sql_query($sql,__FILE__,__LINE__); + Database::query($sql,__FILE__,__LINE__); $return_message=get_lang('SentFileMoved'); } } @@ -278,7 +276,7 @@ function display_action_options($part, $categories, $current_category=0) echo ''; } echo ''; - echo ''; + echo ''; } /** @@ -299,7 +297,7 @@ function display_file_checkbox($id, $part) { $checked='checked'; } - $return_value=''; + $return_value=''; return $return_value; } @@ -325,8 +323,8 @@ function get_dropbox_categories($filter='') $sql="SELECT * FROM ".$dropbox_cnf['tbl_category']." WHERE user_id='".$_user['user_id']."'"; - $result=api_sql_query($sql); - while ($row=mysql_fetch_array($result)) + $result=Database::query($sql,__FILE__,__LINE__); + while ($row=Database::fetch_array($result)) { if(($filter=='sent' AND $row['sent']==1) OR ($filter=='received' AND $row['received']==1) OR $filter=='') { @@ -382,7 +380,7 @@ function store_addcategory() { // step 3a, we check if the category doesn't already exist $sql="SELECT * FROM ".$dropbox_cnf['tbl_category']." WHERE user_id='".$_user['user_id']."' AND cat_name='".Database::escape_string(Security::remove_XSS($_POST['category_name']))."' AND received='".$received."' AND sent='".$sent."'"; - $result=api_sql_query($sql); + $result=Database::query($sql,__FILE__,__LINE__); // step 3b, we add the category if it does not exist yet. @@ -390,7 +388,7 @@ function store_addcategory() { $sql="INSERT INTO ".$dropbox_cnf['tbl_category']." (cat_name, received, sent, user_id) VALUES ('".Database::escape_string(Security::remove_XSS($_POST['category_name']))."', '".Database::escape_string($received)."', '".Database::escape_string($sent)."', '".Database::escape_string($_user['user_id'])."')"; - api_sql_query($sql); + Database::query($sql,__FILE__,__LINE__); return array('type' => 'confirmation', 'message'=>get_lang('CategoryStored')); } else @@ -403,7 +401,7 @@ function store_addcategory() $sql="UPDATE ".$dropbox_cnf['tbl_category']." SET cat_name='".Database::escape_string(Security::remove_XSS($_POST['category_name']))."', received='".Database::escape_string($received)."' , sent='".Database::escape_string($sent)."' WHERE user_id='".Database::escape_string($_user['user_id'])."' AND cat_id='".Database::escape_string(Security::remove_XSS($_POST['edit_id']))."'"; - api_sql_query($sql); + Database::query($sql,__FILE__,__LINE__); return array('type' => 'confirmation', 'message'=>get_lang('CategoryModified')); } } @@ -427,7 +425,7 @@ function display_addcategory_form($category_name='', $id='',$action) { // retrieve the category we are editing $sql="SELECT * FROM ".$dropbox_cnf['tbl_category']." WHERE cat_id='".Database::escape_string($id)."'"; - $result=api_sql_query($sql); + $result=Database::query($sql,__FILE__,__LINE__); $row=Database::fetch_array($result); if ($category_name=='') // after an edit with an error we do not want to return to the original name but the name we already modified. (happens when createinrecievedfiles AND createinsentfiles are not checked) @@ -485,7 +483,7 @@ function display_addcategory_form($category_name='', $id='',$action) { echo ''.get_lang('CategoryAlreadyExistsEditIt').'
    '; } - echo ' + echo '
    '; @@ -503,7 +501,7 @@ function display_addcategory_form($category_name='', $id='',$action) * '.get_lang('ThisFieldIsRequired').' '; - echo "
    "; + echo ''; echo '
    '; } @@ -520,7 +518,7 @@ function display_add_form() $token = Security::get_token(); $dropbox_person = new Dropbox_Person( $_user['user_id'], $is_courseAdmin, $is_courseTutor); ?> -
    " enctype="multipart/form-data" onsubmit="return checkForm(this)"> + " enctype="multipart/form-data" onsubmit="return checkForm(this)">
    @@ -536,7 +534,7 @@ function display_add_form() "; + echo ''; } ?> @@ -686,12 +684,12 @@ function getUserNameFromId ( $id) // RH: Mailing: return 'Mailing ' + id { return dropbox_lang("mailingAsUsername", "noDLTT") . $mailingId; } - + $id = intval($id); $sql = "SELECT CONCAT(lastname,' ', firstname) AS name FROM " . dropbox_cnf("tbl_user") . " - WHERE user_id='" . addslashes( $id) . "'"; - $result = api_sql_query($sql,__FILE__,__LINE__); - $res = mysql_fetch_array( $result); + WHERE user_id='$id'"; + $result = Database::query($sql,__FILE__,__LINE__); + $res = Database::fetch_array( $result); if ( $res == FALSE) return FALSE; return stripslashes( $res["name"]); @@ -703,11 +701,12 @@ function getUserNameFromId ( $id) // RH: Mailing: return 'Mailing ' + id */ function getLoginFromId ( $id) { + $id = intval($id); $sql = "SELECT username FROM " . dropbox_cnf("tbl_user") . " - WHERE user_id='" . addslashes( $id) . "'"; - $result =api_sql_query($sql,__FILE__,__LINE__); - $res = mysql_fetch_array( $result); + WHERE user_id='$id'"; + $result =Database::query($sql,__FILE__,__LINE__); + $res = Database::fetch_array( $result); if ( $res == FALSE) return FALSE; return stripslashes( $res["username"]); } @@ -736,14 +735,14 @@ function removeUnusedFiles( ) FROM " . dropbox_cnf("tbl_file") . " f LEFT JOIN " . dropbox_cnf("tbl_person") . " p ON f.id = p.file_id WHERE p.user_id IS NULL"; - $result = api_sql_query($sql,__FILE__,__LINE__); - while ( $res = mysql_fetch_array( $result)) + $result = Database::query($sql,__FILE__,__LINE__); + while ( $res = Database::fetch_array( $result)) { //delete the selected files from the post and file tables $sql = "DELETE FROM " . dropbox_cnf("tbl_post") . " WHERE file_id='" . $res['id'] . "'"; - $result1 = api_sql_query($sql,__FILE__,__LINE__); + $result1 = Database::query($sql,__FILE__,__LINE__); $sql = "DELETE FROM " . dropbox_cnf("tbl_file") . " WHERE id='" . $res['id'] . "'"; - $result1 = api_sql_query($sql,__FILE__,__LINE__); + $result1 = Database::query($sql,__FILE__,__LINE__); //delete file from server @unlink( dropbox_cnf("sysPath") . "/" . $res["filename"]); @@ -759,19 +758,20 @@ function removeUnusedFiles( ) * Mailing content files have uploader_id == mailing pseudo_id, a normal recipient, * and are visible initially to recipient and pseudo_id. * -* @author Ren� Haentjens, Ghent University +* @author René Haentjens, Ghent University * * @todo check if this function is still necessary. */ function getUserOwningThisMailing($mailingPseudoId, $owner = 0, $or_die = '') { + $mailingPseudoId = intval($mailingPseudoId); $sql = "SELECT f.uploader_id FROM " . dropbox_cnf("tbl_file") . " f LEFT JOIN " . dropbox_cnf("tbl_post") . " p ON f.id = p.file_id WHERE p.dest_user_id = '" . $mailingPseudoId . "'"; - $result = api_sql_query($sql,__FILE__,__LINE__); + $result = Database::query($sql,__FILE__,__LINE__); - if (!($res = mysql_fetch_array($result))) + if (!($res = Database::fetch_array($result))) die(dropbox_lang("generalError")." (code 901)"); if ($owner == 0) return $res['uploader_id']; @@ -791,23 +791,23 @@ function removeMoreIfMailing($file_id) // for all content files, delete mailingPseudoId from person-table // 2. finding the owner (getUserOwningThisMailing) is no longer possible, so // for all content files, replace mailingPseudoId by owner as uploader - + $file_id = intval($file_id); $sql = "SELECT p.dest_user_id FROM " . dropbox_cnf("tbl_post") . " p WHERE p.file_id = '" . $file_id . "'"; - $result = api_sql_query($sql,__FILE__,__LINE__); + $result = Database::query($sql,__FILE__,__LINE__); - if ( $res = mysql_fetch_array( $result)) + if ( $res = Database::fetch_array( $result)) { $mailingPseudoId = $res['dest_user_id']; if ( $mailingPseudoId > dropbox_cnf("mailingIdBase")) { $sql = "DELETE FROM " . dropbox_cnf("tbl_person") . " WHERE user_id='" . $mailingPseudoId . "'"; - $result1 = api_sql_query($sql,__FILE__,__LINE__); + $result1 = Database::query($sql,__FILE__,__LINE__); $sql = "UPDATE " . dropbox_cnf("tbl_file") . " SET uploader_id='" . api_get_user_id() . "' WHERE uploader_id='" . $mailingPseudoId . "'"; - $result1 = api_sql_query($sql,__FILE__,__LINE__); + $result1 = Database::query($sql,__FILE__,__LINE__); } } } @@ -817,7 +817,7 @@ function removeMoreIfMailing($file_id) * * @todo check if this function is still necessary. * -* @author Ren� Haentjens, Ghent University +* @author René Haentjens, Ghent University */ function dropbox_lang($variable, $notrans = 'DLTT') { @@ -1055,13 +1055,14 @@ function display_user_link($user_id, $name='') { $table_user = Database::get_main_table(TABLE_MAIN_USER); $sql="SELECT * FROM $table_user WHERE user_id='".Database::escape_string($user_id)."'"; - $result=api_sql_query($sql,__FILE__,__LINE__); - $row=mysql_fetch_array($result); + $result=Database::query($sql,__FILE__,__LINE__); + $row=Database::fetch_array($result); return "".$row['firstname']." ".$row['lastname'].""; } else { - return "".$name.""; + $user_id = intval($user_id); + return "".Security::remove_XSS($name).""; } } else @@ -1101,8 +1102,8 @@ function feedback($array) function format_feedback($feedback) { $output.=display_user_link($feedback['author_user_id']); - $output.='  ['.$feedback['feedback_date'].']
    '; - $output.='
    '.nl2br($feedback['feedback']).'


    '; + $output.='  ['.$feedback['feedback_date'].']
    '; + $output.='
    '.nl2br($feedback['feedback']).'


    '; return $output; } @@ -1122,8 +1123,8 @@ function feedback_form() // we now check if the other users have not delete this document yet. If this is the case then it is useless to see the // add feedback since the other users will never get to see the feedback. $sql="SELECT * FROM ".$dropbox_cnf["tbl_person"]." WHERE file_id='".Database::escape_string($_GET['id'])."'"; - $result=api_sql_query($sql,__LINE__, __FILE__); - $number_users_who_see_file=mysql_num_rows($result); + $result=Database::query($sql,__LINE__, __FILE__); + $number_users_who_see_file=Database::num_rows($result); if ($number_users_who_see_file>1) { $return .= '
    ';//for save button - echo ''; - echo ''; + echo ''; + echo ''; } } } diff --git a/main/wiki/wiki.inc.php b/main/wiki/wiki.inc.php index 34675e77e8..a9d6d92e7b 100644 --- a/main/wiki/wiki.inc.php +++ b/main/wiki/wiki.inc.php @@ -314,16 +314,46 @@ function save_wiki() { } //cleaning config variables - - $_clean['feedback1']=Database::escape_string(Security::remove_XSS($_POST['feedback1'])); - $_clean['feedback2']=Database::escape_string(Security::remove_XSS($_POST['feedback2'])); - $_clean['feedback3']=Database::escape_string(Security::remove_XSS($_POST['feedback3'])); - $_clean['max_text']=Database::escape_string(Security::remove_XSS($_POST['max_text'])); - $_clean['max_version']=Database::escape_string(Security::remove_XSS($_POST['max_version'])); - $_clean['startdate_assig']=Database::escape_string(Security::remove_XSS($_POST['startdate_assig'])); - $_clean['enddate_assig']=Database::escape_string(Security::remove_XSS($_POST['enddate_assig'])); - $_clean['delayedsubmit']=Database::escape_string(Security::remove_XSS($_POST['delayedsubmit'])); + + if(!empty($_POST['task'])) + { + $_clean['task']=Database::escape_string(Security::remove_XSS($_POST['task'])); + } + if(!empty($_POST['feedback1']) || !empty($_POST['feedback2']) || !empty($_POST['feedback3'])) + { + $_clean['feedback1']=Database::escape_string(Security::remove_XSS($_POST['feedback1'])); + $_clean['feedback2']=Database::escape_string(Security::remove_XSS($_POST['feedback2'])); + $_clean['feedback3']=Database::escape_string(Security::remove_XSS($_POST['feedback3'])); + $_clean['fprogress1']=Database::escape_string(Security::remove_XSS($_POST['fprogress1'])); + $_clean['fprogress2']=Database::escape_string(Security::remove_XSS($_POST['fprogress2'])); + $_clean['fprogress3']=Database::escape_string(Security::remove_XSS($_POST['fprogress3'])); + } + + if(Security::remove_XSS($_POST['initstartdate']==1)) + { + $_clean['startdate_assig']=Database::escape_string(Security::remove_XSS(get_date_from_select('startdate_assig'))); + } + else + { + $_clean['startdate_assig']=Database::escape_string(Security::remove_XSS($_POST['startdate_assig'])); + } + + if(Security::remove_XSS($_POST['initenddate']==1)) + { + $_clean['enddate_assig']=Database::escape_string(Security::remove_XSS(get_date_from_select('enddate_assig'))); + } + else + { + $_clean['enddate_assig']=Database::escape_string(Security::remove_XSS($_POST['enddate_assig'])); + } + + $_clean['delayedsubmit']=Database::escape_string(Security::remove_XSS($_POST['delayedsubmit'])); + if(!empty($_POST['max_text']) || !empty($_POST['max_version'])) + { + $_clean['max_text']=Database::escape_string(Security::remove_XSS($_POST['max_text'])); + $_clean['max_version']=Database::escape_string(Security::remove_XSS($_POST['max_version'])); + } $sql="INSERT INTO ".$tbl_wiki." (page_id, reflink, title, content, user_id, group_id, dtime, assignment, comment, progress, version, linksto, user_ip) VALUES ('".$_clean['page_id']."','".$_clean['reflink']."','".$_clean['title']."','".$_clean['content']."','".$_clean['user_id']."','".$_clean['group_id']."','".$dtime."','".$_clean['assignment']."','".$_clean['comment']."','".$_clean['progress']."','".$_clean['version']."','".$_clean['linksto']."','".Database::escape_string($_SERVER['REMOTE_ADDR'])."')"; @@ -332,12 +362,20 @@ function save_wiki() { if ($_clean['page_id'] ==0) { - $sql='UPDATE '.$tbl_wiki.' SET page_id="'.$Id.'" WHERE id="'.$Id.'"'; + $sql='UPDATE '.$tbl_wiki.' SET page_id="'.$Id.'" WHERE id="'.$Id.'"'; api_sql_query($sql,__FILE__,__LINE__); } //update wiki config - $sql='UPDATE'.$tbl_wiki.' SET page_id="'.$Id.'", feedback1="'.$_clean['feedback1'].'", feedback2="'.$_clean['feedback2'].'", feedback3="'.$_clean['feedback3'].'", max_text="'.$_clean['max_text'].'", max_version="'.$_clean['max_version'].'", startdate_assig="'.$_clean['startdate_assig'].'", enddate_assig="'.$_clean['enddate_assig'].'", delayedsubmit="'.$_clean['delayedsubmit'].'" WHERE id="'.$Id.'"'; + + if ($_clean['reflink']=='index' && $_clean['version']==1) + { + $sql="INSERT INTO ".$tbl_wiki_conf." (page_id, task, feedback1, feedback2, feedback3, fprogress1, fprogress2, fprogress3, max_text, max_version, startdate_assig, enddate_assig, delayedsubmit) VALUES ('".$Id."','".$_clean['task']."','".$_clean['feedback1']."','".$_clean['feedback2']."','".$_clean['feedback3']."','".$_clean['fprogress1']."','".$_clean['fprogress2']."','".$_clean['fprogress3']."','".$_clean['max_text']."','".$_clean['max_version']."','".$_clean['startdate_assig']."','".$_clean['enddate_assig']."','".$_clean['delayedsubmit']."')"; + } + else + { + $sql='UPDATE'.$tbl_wiki_conf.' SET task="'.$_clean['task'].'", feedback1="'.$_clean['feedback1'].'", feedback2="'.$_clean['feedback2'].'", feedback3="'.$_clean['feedback3'].'", fprogress1="'.$_clean['fprogress1'].'", fprogress2="'.$_clean['fprogress2'].'", fprogress3="'.$_clean['fprogress3'].'", max_text="'.$_clean['max_text'].'", max_version="'.$_clean['max_version'].'", startdate_assig="'.$_clean['startdate_assig'].'", enddate_assig="'.$_clean['enddate_assig'].'", delayedsubmit="'.$_clean['delayedsubmit'].'" WHERE page_id="'.$_clean['page_id'].'"'; + } api_sql_query($sql,__FILE__,__LINE__); api_item_property_update($_course, 'wiki', $Id, 'WikiAdded', api_get_user_id(), $_clean['group_id']); @@ -454,19 +492,37 @@ function save_new_wiki() { $_clean['linksto'] = links_to($_clean['content']); //check wikilinks - //cleaning config variables + //cleaning config variables + $_clean['task']=Database::escape_string(Security::remove_XSS($_POST['task'])); $_clean['feedback1']=Database::escape_string(Security::remove_XSS($_POST['feedback1'])); $_clean['feedback2']=Database::escape_string(Security::remove_XSS($_POST['feedback2'])); $_clean['feedback3']=Database::escape_string(Security::remove_XSS($_POST['feedback3'])); $_clean['fprogress1']=Database::escape_string(Security::remove_XSS($_POST['fprogress1'])); $_clean['fprogress2']=Database::escape_string(Security::remove_XSS($_POST['fprogress2'])); $_clean['fprogress3']=Database::escape_string(Security::remove_XSS($_POST['fprogress3'])); - $_clean['max_text']=Database::escape_string(Security::remove_XSS($_POST['max_text'])); - $_clean['max_version']=Database::escape_string(Security::remove_XSS($_POST['max_version'])); - $_clean['startdate_assig']=Database::escape_string(Security::remove_XSS(get_date_from_select('startdate_assig'))); - $_clean['enddate_assig']=Database::escape_string(Security::remove_XSS(get_date_from_select('enddate_assig'))); - $_clean['delayedsubmit']=Database::escape_string(Security::remove_XSS($_POST['delayedsubmit'])); + + if(Security::remove_XSS($_POST['initstartdate']==1)) + { + $_clean['startdate_assig']=Database::escape_string(Security::remove_XSS(get_date_from_select('startdate_assig'))); + } + else + { + $_clean['startdate_assig']=Database::escape_string(Security::remove_XSS($_POST['startdate_assig'])); + } + + if(Security::remove_XSS($_POST['initenddate']==1)) + { + $_clean['enddate_assig']=Database::escape_string(Security::remove_XSS(get_date_from_select('enddate_assig'))); + } + else + { + $_clean['enddate_assig']=Database::escape_string(Security::remove_XSS($_POST['enddate_assig'])); + } + $_clean['delayedsubmit']=Database::escape_string(Security::remove_XSS($_POST['delayedsubmit'])); + $_clean['max_text']=Database::escape_string(Security::remove_XSS($_POST['max_text'])); + $_clean['max_version']=Database::escape_string(Security::remove_XSS($_POST['max_version'])); + //filter no _uass if (api_eregi('_uass', $_POST['title']) || (api_strtoupper(trim($_POST['title'])) == 'INDEX' || api_strtoupper(trim(api_htmlentities($_POST['title'], ENT_QUOTES, $charset))) == api_strtoupper(api_htmlentities(get_lang('DefaultTitle'), ENT_QUOTES, $charset)))) { $message= get_lang('GoAndEditMainPage'); @@ -488,7 +544,7 @@ function save_new_wiki() { api_sql_query($sql,__FILE__,__LINE__); //insert wiki config - $sql="INSERT INTO ".$tbl_wiki_conf." (page_id, feedback1, feedback2, feedback3, fprogress1, fprogress2, fprogress3, max_text, max_version, startdate_assig, enddate_assig, delayedsubmit) VALUES ('".$Id."','".$_clean['feedback1']."','".$_clean['feedback2']."','".$_clean['feedback3']."','".$_clean['fprogress1']."','".$_clean['fprogress2']."','".$_clean['fprogress3']."','".$_clean['max_text']."','".$_clean['max_version']."','".$_clean['startdate_assig']."','".$_clean['enddate_assig']."','".$_clean['delayedsubmit']."')"; + $sql="INSERT INTO ".$tbl_wiki_conf." (page_id, task, feedback1, feedback2, feedback3, fprogress1, fprogress2, fprogress3, max_text, max_version, startdate_assig, enddate_assig, delayedsubmit) VALUES ('".$Id."','".$_clean['task']."','".$_clean['feedback1']."','".$_clean['feedback2']."','".$_clean['feedback3']."','".$_clean['fprogress1']."','".$_clean['fprogress2']."','".$_clean['fprogress3']."','".$_clean['max_text']."','".$_clean['max_version']."','".$_clean['startdate_assig']."','".$_clean['enddate_assig']."','".$_clean['delayedsubmit']."')"; api_sql_query($sql,__LINE__,__FILE__); api_item_property_update($_course, 'wiki', $Id, 'WikiAdded', api_get_user_id(), $_clean['group_id']); @@ -522,7 +578,7 @@ return true; } '; echo '
    '; echo '* '.get_lang(Title).': '; @@ -531,25 +587,31 @@ return true; { $_clean['group_id']=(int)$_SESSION['_gid']; // TODO: check if delete ? - - // echo' '.Display::return_icon('div_show.gif',get_lang('Show')).' '.get_lang('AdvancedParameters').''; // TODO: under develop, uncoment and activate later + + echo' '.Display::return_icon('div_show.gif',get_lang('Show')).' '.get_lang('AdvancedParameters').''; echo ''; echo '
    '; @@ -661,6 +745,7 @@ function display_wiki_entry() { global $charset; global $tbl_wiki; + global $tbl_wiki_conf; global $groupfilter; global $page; @@ -669,7 +754,8 @@ function display_wiki_entry() if ($_GET['view']) { $_clean['view']=(int)Database::escape_string($_GET['view']); - $filter=" AND id='".$_clean['view']."'"; + + $filter=' AND '.$tbl_wiki.'.id="'.$_clean['view'].'"'; } //first, check page visibility in the first page version @@ -679,9 +765,9 @@ function display_wiki_entry() $KeyVisibility=$row['visibility']; // second, show the last version - $sql="SELECT * FROM ".$tbl_wiki."WHERE reflink='".html_entity_decode(Database::escape_string(stripslashes(urldecode($page))))."' AND $groupfilter $filter ORDER BY id DESC"; - $result=api_sql_query($sql,__LINE__,__FILE__); - $row=Database::fetch_array($result); // we do not need a while loop since we are always displaying the last version + $sql='SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.' WHERE '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND '.$tbl_wiki.'.reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$tbl_wiki.'.'.$groupfilter.' '.$filter.' ORDER BY id DESC'; + $result=api_sql_query($sql,__LINE__,__FILE__); + $row=Database::fetch_array($result); // we do not need a while loop since we are always displaying the last version //update visits @@ -712,7 +798,7 @@ function display_wiki_entry() } - //assignment mode: for identify page type + //assignment mode: identify page type if(stripslashes($row['assignment'])==1) { $icon_assignment=''.get_lang('AssignmentDescExtra').''; @@ -721,8 +807,13 @@ function display_wiki_entry() { $icon_assignment=''.get_lang('AssignmentWorkExtra').''; } - - + + //task mode + + if (!empty($row['task'])) + { + $icon_task=''.get_lang('TaskExtra').''; + } //Show page. Show page to all users if isn't hide page. Mode assignments: if student is the author, can view if($KeyVisibility=="1" || api_is_allowed_to_edit() || api_is_platform_admin() || ($row['assignment']==2 && $KeyVisibility=="0" && (api_get_user_id()==$row['user_id']))) @@ -833,7 +924,7 @@ function display_wiki_entry() if (wiki_exist($title)) { - echo $icon_assignment.'   '.stripslashes($title); + echo $icon_assignment.' '.$icon_task.' '.stripslashes($title); } else { @@ -1723,17 +1814,6 @@ function double_post($wpost_id) } } -/** - * Function convert date to number - * 2008-10-12 00:00:00 ---to--> 12345672218 (timestamp) - */ -function convert_date_to_number($default) -{ - $parts = split(' ',$default); - list($d_year,$d_month,$d_day) = split('-',$parts[0]); - list($d_hour,$d_minute,$d_second) = split(':',$parts[1]); - return mktime($d_hour, $d_minute, $d_second, $d_month, $d_day, $d_year); -} /** * Function wizard individual assignment @@ -1980,7 +2060,7 @@ function display_wiki_search_results($search_term, $search_content=0) * */ function draw_date_picker($prefix,$default='') { - //$default = 2008-10-01 10:00:00 + if(empty($default)) { $default = date('Y-m-d H:i:s'); } @@ -2007,7 +2087,7 @@ function draw_date_picker($prefix,$default='') { array_unshift($minute,'00','01','02','03','04','05','06','07','08','09'); $date_form = make_select($prefix.'_day', array_combine(range(1,31),range(1,31)), $d_day); $date_form .= make_select($prefix.'_month', $month_list, $d_month); - $date_form .= make_select($prefix.'_year', array( $d_year=> $d_year, $d_year+1=>$d_year+1), $d_year).'    '; + $date_form .= make_select($prefix.'_year', array($d_year-2=>$d_year-2, $d_year-1=>$d_year-1, $d_year=> $d_year, $d_year+1=>$d_year+1, $d_year+2=>$d_year+2), $d_year).'    '; $date_form .= make_select($prefix.'_hour', array_combine(range(0,23),range(0,23)), $d_hour).' : '; $date_form .= make_select($prefix.'_minute', $minute, $d_minute); return $date_form; @@ -2026,14 +2106,6 @@ function make_select($name,$values,$checked='') { return $output; } -/** - * Enter description here... - * - */ -function make_checkbox($name,$checked='') { - return '' . - ''; -} /** * Enter description here... @@ -2051,4 +2123,5 @@ function two_digits($number) $number = (int)$number; return ($number < 10) ? '0'.$number : $number; } + ?> \ No newline at end of file diff --git a/tests/all.test2.php b/tests/all.test2.php new file mode 100644 index 0000000000..87ec7c2982 --- /dev/null +++ b/tests/all.test2.php @@ -0,0 +1,25 @@ +TestSuite('All tests2'); + //$this->addTestFile(dirname(__FILE__).'/main/admin/calendar.lib.test.php'); + $this->addTestFile(dirname(__FILE__).'/main/admin/statistics/statistics.lib.test.php'); + } +} +$test = &new AllTests2(); +//$test-> run( new HtmlReporter()); + +?> diff --git a/tests/main/admin/calendar.lib.test.php b/tests/main/admin/calendar.lib.test.php new file mode 100644 index 0000000000..9ffcb99103 --- /dev/null +++ b/tests/main/admin/calendar.lib.test.php @@ -0,0 +1,688 @@ +UnitTestCase('testing the file about calendar/agenda'); + + } + + public function testDisplayMinimonthcalendar(){ + ob_start(); + global $DaysShort; + $agendaitems=array('abc','cde'); + $month=11; + $year=2008; + $monthName=''; + $res = display_minimonthcalendar($agendaitems, $month, $year, $monthName); + ob_end_clean(); + $this->assertTrue(is_null($res)); + //var_dump($res); + } + + public function testToJavascript(){ + $res = to_javascript(); + $this->assertTrue($res); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + public function testUserGroupFilterJavascript(){ + $res = user_group_filter_javascript(); + $this->assertTrue($res); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + public function testDisplayMonthcalendar(){ + ob_start(); + global $MonthsLong; + global $DaysShort; + global $origin; + $month=05; + $year=2010; + $res = display_monthcalendar($month, $year); + ob_end_clean(); + $this->assertTrue(is_null($res)); + $this->assertNull($res); + //var_dump($res); + } + + public function testStoreNewAgendaItem(){ + global $_user; + $res = store_new_agenda_item(); + $this->assertFalse($res); + $this->assertTrue(is_null($res)); + $this->assertNull($res); + //var_dump($res); + } + + public function testDisplayCourseadminLinks(){ + ob_start(); + $res = display_courseadmin_links(); + ob_end_clean(); + $this->assertTrue(is_null($res)); + //var_dump($res); + } + + public function testDisplayStudentLinks(){ + ob_start(); + global $show; + $res = display_student_links(); + ob_end_clean(); + $this->assertTrue(is_null($res)); + //var_dump($res); + } + + public function testGetAgendaItem(){ + $realgrouplist= new MockDatabase(); + $id=1; + $TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); + $sql= "SELECT * FROM ".$TABLEAGENDA." WHERE id='".$id."'"; + $sql_result = api_sql_query($sql,__FILE__,__LINE__); + $result= Database::fetch_array($result); + $real_list[] = $result; + $res = get_agenda_item($id); + if(is_array($real_list)) + $this->assertTrue(is_array($real_list)); + else{ + $this->assertTrue(is_null($real_list)); + $this->assertTrue($real_list === true || $real_list === false); + } + $realgrouplist->expectOnce($real_list); + $this->assertTrue(is_array($res)); + //var_dump($real_list); + //var_dump($res); + } + + public function testStoreEditedAgendaItem(){ + ob_start(); + $instans = new MockDisplay(); + $id=1; + $title=''; + $content=''; + $start_date= 21; + $end_date=25; + $res = store_edited_agenda_item(); + $instans = Display::display_normal_message(get_lang("EditSuccess")); + $edit_result=save_edit_agenda_item($id,$title,$content,$start_date,$end_date); + ob_end_clean(); + $this->assertTrue(is_null($instans)); + $this->assertTrue($edit_result); + //var_dump($instans); + //var_dump($edit_result); + } + + public function testSaveEditAgendaItem(){ + $TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); + $id=Database::escape_string($id); + $title=Database::escape_string($title); + $content=Database::escape_string($content); + $start_date=Database::escape_string($start_date); + $end_date=Database::escape_string($end_date); + $res = save_edit_agenda_item($id,$title,$content,$start_date,$end_date); + $this->assertTrue($res); + $this->assertTrue($TABLEAGENDA); + $this->assertTrue(is_bool($res)); + //var_dump($res); + //var_dump($TABLEAGENDA); + } + + public function testDeleteAgendaItem(){ + $realagenda= new MockDatabase(); + $realagenda1 = new MockDisplay(); + global $_course; + $id=Database::escape_string($id); + $res = delete_agenda_item($id); + $sql = "SELECT * FROM $t_agenda WHERE id = $id"; + $sql_result = Database::query($sql,__FILE__,__LINE__); + $result = Database::fetch_array($sql_result); + $real_agenda[] = $result; + $res= delete_agenda_item($id); + $realagenda->expectOnce($real_agenda); + $this->assertTrue($real_agenda); + $this->assertTrue(is_null($res)); + $this->assertTrue(is_array($real_agenda)); + //var_dump($res); + //var_dump($real_agenda); + } + + public function testShowhideAgendaItem(){ + ob_start(); + $instans = new MockDisplay(); + $id=1; + global $nameTools; + $res = showhide_agenda_item($id); + $real_show = Display::display_normal_message(get_lang("VisibilityChanged")); + $instans_real[] = $real_show; + $instans->expectOnce($instans_real); + ob_end_clean(); + $this->assertTrue(is_object($instans)); + $this->assertTrue(is_array($instans_real)); + //var_dump($instans); + //var_dump($res); + //var_dump($instans_real); + } + /** + * Para poder ejecutar la funcion display_agenda_items(), es + * necesario comentar el die de la linea 718, porque sino, no se + * podria realizar la prueba. + */ + public function testDisplayAgendaItems(){ + ob_start(); + $realdisplay = new MockDatabase(); + $TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); + global $select_month, $select_year; + global $DaysShort, $DaysLong, $MonthsLong; + global $is_courseAdmin; + global $dateFormatLong, $timeNoSecFormat,$charset, $_user, $_course; + $sql = "SELECT * FROM ".$TABLEAGENDA.' ORDER BY start_date '.$_SESSION['sort']; + $result=api_sql_query($sql,__FILE__,__LINE__); + $real_display[] = $result; + $res = display_agenda_items(); + ob_end_clean(); + $realdisplay->expectOnce($real_display); + $this->assertTrue(is_null($res)); + $this->assertTrue(is_array($real_display)); + $realdisplay->expectOnce($real_display); + //var_dump($res); + //var_dump($real_display); + //var_dump($realdisplay); + } + /** + * Para poder ejecutar esta prueba es necesario comentar el + * die de la linea 984. + */ + public function testDisplayOneAgendaItem(){ + ob_start(); + $realdisplayone = new MockDatabase(); + $TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); + global $TABLE_ITEM_PROPERTY; + global $select_month, $select_year; + global $DaysShort, $DaysLong, $MonthsLong; + global $is_courseAdmin; + global $dateFormatLong, $timeNoSecFormat, $charset; + global $_user; + $agenda_id=2; + $agenda_id=Database::escape_string($agenda_id); + $sql = "SELECT * FROM ".$TABLEAGENDA; + $sql_result=api_sql_query($sql,__FILE__,__LINE__); + $myrow=Database::fetch_array($sql_result); + $real_display_one[]= $$myrow; + //$res = display_one_agenda_item($agenda_id); + ob_end_clean(); + $realdisplayone->expectOnce($real_display_one); + $this->assertTrue(is_array($real_display_one)); + //var_dump($res); + //var_dump($realdisplayone); + //var_dump($real_display_one); + } + + /*public function testShowGroupFilterForm(){ + $group_list=get_course_groups(); + $res = show_group_filter_form(); + $this->assertTrue($res); + //var_dump($res); + } + + public function testShowUserFilterForm(){ + + $res = show_user_filter_form(); + $this->assertTrue($res); + //var_dump($res); + } + */ + public function testShowAddForm(){ + ob_start(); + global $MonthsLong; + $id=''; + $res= show_add_form($id); + ob_end_clean(); + $this->assertTrue(is_null($res)); + //var_dump($res); + } + + public function testGetAgendaitems(){ + $realgetagenda = new MockDatabase(); + $$TABLEAGENDA = Database :: get_course_table(TABLE_MAIN_SYSTEM_CALENDAR); + $month=06; + $year=2010; + global $MonthsLong; + $month=Database::escape_string($month); + $year=Database::escape_string($year); + $sqlquery = "SELECT + DISTINCT * + FROM ".$TABLEAGENDA." + WHERE + MONTH(start_date)='".$month."' + AND YEAR(start_date)='".$year."' + GROUP BY id + ORDER BY start_date "; + $sql_result = api_sql_query($sqlquery, __FILE__, __LINE__); + $result = Database::fetch_array($sql_result); + $real_get_agenda[] = $result; + $res = get_agendaitems($month, $year); + $this->assertTrue(is_array($res)); + $realgetagenda->expectOnce($real_get_agenda); + $this->assertTrue(is_array($real_get_agenda)); + //var_dump($res); + //var_dump($real_get_agenda); + //var_dump($realgetagenda); + } + + public function testDisplayUpcomingEvents(){ + ob_start(); + $realdisplay = new MockDatabase(); + $TABLEAGENDA = Database :: get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); + $sqlquery = "SELECT + DISTINCT * + FROM ".$TABLEAGENDA." + ORDER BY start_date "; + $result = api_sql_query($sqlquery, __FILE__, __LINE__); + $resultado = Database::fetch_array($result,'ASSOC'); + $real_display[] = $resultado; + $res = display_upcoming_events(); + $realdisplay->expectOnce($real_display); + ob_end_clean(); + $this->assertTrue(is_array($real_display)); + $this->assertTrue(is_null($res)); + //var_dump($real_display); + //var_dump($realdisplay); + //var_dump($res); + } + + public function testCalculateStartEndOfWeek(){ + $week_number=4; + $year=2011; + $res = calculate_start_end_of_week($week_number, $year); + $this->assertTrue(is_array($res)); + $this->assertTrue($res); + //var_dump($res); + } + + public function testDisplayDaycalendar(){ + ob_start(); + $agendaitems=''; + $day=''; + $month=''; + $year=''; + $weekdaynames=''; + $monthName=''; + $res = display_daycalendar($agendaitems, $day, $month, $year, $weekdaynames, $monthName); + ob_end_clean(); + $this->assertTrue(is_null($res)); + //var_dump($res); + } + + public function testDisplayWeekcalendar(){ + ob_start(); + $agendaitems=''; + $month=10; + $year=2011; + $weekdaynames=''; + $monthName=''; + $res = display_weekcalendar($agendaitems, $month, $year, $weekdaynames, $monthName); + ob_end_clean(); + $this->assertTrue(is_null($res)); + //var_dump($res); + } + + public function testGetDayAgendaitems(){ + $realgetday = new MockDatabase(); + $TABLEAGENDA = Database :: get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); + global $_user; + global $_configuration; + global $setting_agenda_link; + $courses_dbs=''; + $month=11; + $year=2009; + $day=''; + $sqlquery = "SELECT DISTINCT * + FROM ".$TABLEAGENDA." + WHERE + DAYOFMONTH(start_date)='".$day."' AND MONTH(start_date)='".$month."' AND YEAR(start_date)='".$year."' + GROUP BY agenda.id + ORDER BY start_date "; + $result = api_sql_query($sqlquery, __FILE__, __LINE__); + $item = Database::fetch_array($result); + $real_get_day[] = $item; + $res = get_day_agendaitems($courses_dbs, $month, $year, $day); + $realgetday->expectOnce($real_get_day); + $this->assertTrue(is_array($real_get_day)); + $this->assertTrue(is_array($res)); + //var_dump($res); + //var_dump($real_get_day); + //var_dump($$realgetday); + } + + public function testGetWeekAgendaitems(){ + $realgetweek = new MockDatabase(); + $TABLEAGENDA = Database :: get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); + global $_user; + global $_configuration; + global $setting_agenda_link;$month=''; + $courses_dbs=''; + $year=''; + $week = ''; + $sqlquery = "SELECT DISTINCT * FROM ".$TABLEAGENDA." ORDER BY start_date"; + $result = api_sql_query($sqlquery, __FILE__, __LINE__); + $item = Database::fetch_array($result); + $real_get_week[]= $item; + $res = get_week_agendaitems($courses_dbs, $month, $year, $week); + $realgetweek->expectOnce($real_get_week); + $this->assertTrue(is_array($real_get_week)); + $this->assertTrue($realgetweek); + $this->assertTrue(is_array($res)); + //var_dump($res); + //var_dump($real_get_week); + //var_dump($realgetweek); + } + + public function testGetRepeatedEventsDayView(){ + $realgetrepeat = new MockDatabase(); + $course_info=''; + $start=0; + $end=0; + $params=''; + $t_cal = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR,$course_info['dbName']); + $t_ip = Database::get_course_table(TABLE_ITEM_PROPERTY,$course_info['dbName']); + $sql = "SELECT c.id, c.title, c.content, " . + " UNIX_TIMESTAMP(c.start_date) as orig_start, UNIX_TIMESTAMP(c.end_date) as orig_end, " . + " cr.cal_type, cr.cal_end " . + " FROM $t_cal c, $t_cal_repeat cr, $t_ip as item_property " . + " WHERE cr.cal_end >= $start " . + " AND cr.cal_id = c.id " . + " AND item_property.ref = c.id ". + " AND item_property.tool = '".TOOL_CALENDAR_EVENT."' ". + " AND c.start_date <= '$db_start' " + .(!empty($params['conditions'])?$params['conditions']:'') + .(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'') + .(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:''); + $res = api_sql_query($sql,__FILE__,__LINE__); + $row = Database::fetch_array($res); + $real_get_repeat[] = $row; + $resul = get_repeated_events_day_view($course_info,$start,$end,$params); + $realgetrepeat->expectOnce($real_get_repeat); + $this->assertTrue(is_array($real_get_repeat)); + $this->assertTrue(is_array($resul)); + //var_dump($resul); + //var_dump($realgetrepeat); + //var_dump($real_get_repeat); + } + + public function testget_repeated_events_week_view(){ + $realgetrepeated = new MockDatabase(); + $course_info=''; + $start=0; + $end=0; + $params=''; + $t_cal = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); + $sql = "SELECT c.id, c.title, c.content " . + " UNIX_TIMESTAMP(c.start_date) as orig_start, UNIX_TIMESTAMP(c.end_date) as orig_end, " . + " FROM". $t_cal ." + WHERE c.start_date <= '$db_start' " + .(!empty($params['conditions'])?$params['conditions']:'') + .(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'') + .(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:''); + $res = api_sql_query($sql,__FILE__,__LINE__); + $row = Database::fetch_array($res); + $real_get_repeated[] = $row; + $resul = get_repeated_events_week_view($course_info,$start,$end,$params); + $realgetrepeated->expectOnce($real_get_repeated); + $this->assertTrue(is_array($resul)); + $this->assertTrue($real_get_repeated); + //var_dump($resul); + //var_dump($real_get_repeated); + //var_dump($realgetrepeated); + } + + public function testGetRepeatedEventsMonthView(){ + $realgetrepeated= new MockDatabase(); + $course_info=''; + $start=''; + $end=''; + $params=''; + $t_cal = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); + $sql = "SELECT c.id, c.title, c.content, " . + " UNIX_TIMESTAMP(c.start_date) as orig_start, UNIX_TIMESTAMP(c.end_date) as orig_end, " . + " cr.cal_type, cr.cal_end " . + " FROM $t_cal c, $t_cal_repeat cr, $t_ip as item_property " . + " WHERE cr.cal_end >= $start " . + " AND cr.cal_id = c.id " . + " AND item_property.ref = c.id ". + " AND item_property.tool = '".TOOL_CALENDAR_EVENT."' ". + " AND c.start_date <= '$db_start' " + .(!empty($params['conditions'])?$params['conditions']:'') + .(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'') + .(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:''); + $res = api_sql_query($sql,__FILE__,__LINE__); + $row = Database::fetch_array($res); + $real_get_repeated[] = $row; + $resul= get_repeated_events_month_view($course_info,$start,$end,$params); + $realgetrepeated->expectOnce($real_get_repeated); + $this->assertTrue(is_array($resul)); + $this->assertTrue(is_bool($res)); + $this->assertTrue($res === false || $res === true); + $this->assertTrue($real_get_repeated); + //var_dump($resul); + //var_dump($real_get_repeated); + //var_dump($realgetrepeated); + } + + public function testGetRepeatedEventsListView(){ + $realgetrepeatedevents = new MockDatabase(); + $course_info=''; + $start=0; + $end=0; + $params=''; + $t_cal = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR,$course_info['dbName']); + $sql = "SELECT c.id, c.title, c.content, " . + " UNIX_TIMESTAMP(c.start_date) as orig_start, UNIX_TIMESTAMP(c.end_date) as orig_end, " . + " cr.cal_type, cr.cal_end " . + " FROM $t_cal c, $t_cal_repeat cr, $t_ip as item_property " . + " WHERE cr.cal_end >= $start " . + " AND cr.cal_id = c.id " . + " AND item_property.ref = c.id ". + " AND item_property.tool = '".TOOL_CALENDAR_EVENT."' ". + " AND c.start_date <= '$db_start' " + .(!empty($params['conditions'])?$params['conditions']:'') + .(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'') + .(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:''); + $res = api_sql_query($sql,__FILE__,__LINE__); + $row = Database::fetch_array($res); + $real_get_repeated_events[] = $row; + $resul = get_repeated_events_list_view($course_info,$start,$end,$params); + $realgetrepeatedevents->expectOnce($real_get_repeated_events); + $this->assertTrue(is_array($real_get_repeated_events)); + $this->assertTrue(is_array($resul)); + $realgetrepeatedevents->expectCallCount($real_get_repeated_events); + //var_dump($resul); + //var_dump($real_get_repeated_events); + //var_dump($realgetrepeatedevents); + } + + public function testIsRepeatedEvent() { + $realrepetead = new MockDatabase(); + $id=1; + $course=null; + $sql = "SELECT * FROM $t_agenda_repeat WHERE cal_id = $id"; + $res = Database::query($sql,__FILE__,__LINE__); + $result = Database::num_rows($res)>0; + $real_repetead[] = $result; + $resu = is_repeated_event($id,$course); + $realrepetead->expectOnce($real_repetead); + $this->assertTrue(is_bool($resu)); + $this->assertTrue($resu === true || $resu === false); + $this->assertTrue($real_repetead); + $this->assertTrue($realrepetead); + //var_dump($resu); + //var_dump($real_repetead); + //var_dump($realrepetead); + } + + public function testAddWeek(){ + $timestamp=12; + $num=1; + $res = add_week($timestamp,$num); + $this->assertTrue(is_numeric($res)); + //var_dump($res); + } + + public function testAddMonth(){ + $timestamp=5; + $num=1; + $res = add_month($timestamp,$num); + $this->assertTrue(is_numeric($res)); + //var_dump($res); + } + + public function testAddYear(){ + $timestamp=9999; + $num=1; + $res = add_year($timestamp,$num); + $this->assertTrue(is_numeric($res)); + //var_dump($res); + } + /** + * para poder realizar esta prueba, se tuvo que comentar el "die" ubicado en la + * linea 2877 para que la prueba pudiera ejecutarse de manera exitosa. + */ + public function testAgendaAddItem(){ + + $realagenda = new MockDatabase(); + global $_course; + $course_info='null'; + $title='test'; + $content='test function'; + $db_start_date='07/11/2009'; + $db_end_date='07/20/2009'; + $to=array(); + $parent_id=null; + $t_agenda = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); + $title = Database::escape_string($title); + $content = Database::escape_string($content); + $start_date = Database::escape_string($db_start_date); + $end_date = Database::escape_string($db_end_date); + $sql = "SELECT * FROM $t_agenda WHERE title='$title' AND content = '$content' AND start_date = '$start_date' + AND end_date = '$end_date' ".(!empty($parent_id)? "AND parent_event_id = '$parent_id'":""); + $result = api_sql_query($sql,__FILE__,__LINE__); + $sql1 = "INSERT INTO ".$t_agenda."(title,content, start_date, end_date)VALUES + ('".$title."','".$content."', '".$start_date."','".$end_date."')"; + $result1 = api_sql_query($sql1,__FILE__,__LINE__); + $real_agenda[]= $result; + $real_agenda1[]= $result1; + //$res = agenda_add_item($course_info, $title, $content, $db_start_date, $db_end_date, $to, $parent_id); + $realagenda->expectOnce($real_agenda); + $realagenda->expectOnce($real_agenda1); + //$this->assertTrue(is_numeric($res)); + $this->assertTrue(is_array($real_agenda)); + $this->assertTrue(is_array($real_agenda1)); + //var_dump($res); + //var_dump($real_agenda); + //var_dump($real_agenda1); + } + + public function testGetCalendarItems(){ + $realgetcalendar = new MockDatabase(); + global $_user, $_course; + global $is_allowed_to_edit; + $month='march'; + $year='2009'; + $TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); + $sql="SELECT + DISTINCT * + FROM ".$TABLEAGENDA." agenda + WHERE MONTH(start_date)='".$month."' AND YEAR(start_date)='".$year."' + GROUP BY id ". + "ORDER BY start_date "; + $result=api_sql_query($sql,__FILE__,__LINE__); + $row=Database::fetch_array($result); + $res = get_calendar_items($month, $year); + $real_get_calendar[]= $row; + $realgetcalendar->expectOnce($real_get_calendar); + $realgetcalendar->expectCallCount($real_get_calendar); + $this->assertTrue(is_bool($row)); + $this->assertTrue(is_array($real_get_calendar)); + $this->assertTrue(is_array($res)); + //var_dump($real_get_calendar); + //var_dump($row); + //var_dump($res); + } + + public function testAgendaAddRepeatItem(){ + $realagenda = new MockDatabase(); + $course_info='course of test'; + $orig_id=001; + $type='daily'; + $end=10; + $orig_dest='monday'; + $t_agenda = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR,$course_info['dbName']); + $sql = "SELECT title, content, start_date as sd, end_date as ed FROM $t_agenda WHERE id = $orig_id"; + $res = Database::query($sql,__FILE__,__LINE__); + $row = Database::fetch_array($res); + $sql1 = "INSERT INTO $t_agenda_r (cal_id, cal_type, cal_end)" . + " VALUES ($orig_id,'$type',$end)"; + $res1 = Database::query($sql1,__FILE__,__LINE__); + $resu= agenda_add_repeat_item($course_info,$orig_id,$type,$end,$orig_dest); + $real_agenda[] = $row; + $realagenda->expectOnce($real_agenda); + $realagenda->expectCallCount($real_agenda); + $realagenda->expectOnce($t_agenda); + $realagenda->expectOnce($res1); + if(is_bool($resu)){ + $this->assertTrue(is_bool($resu)); + $this->assertTrue($resu === true || $resu===false); + }else + $this->assertTrue(is_null($resu)); + $this->assertTrue(is_array($real_agenda)); + $this->assertTrue($row); + //var_dump($resu); + //var_dump($res); + //var_dump($res1); + //var_dump($real_agenda); + } + + public function testAgendaImportIcal(){ + $course_info='course_test'; + $file=''; + $res = agenda_import_ical($course_info,$file); + if(is_bool($res)){ + $this->assertTrue(is_bool($res)); + $this->assertTrue($res===false || $res === true); + }else{ + $this->assertTrue($res); + } + //var_dump($res); + } + + + + + + + + + + + + + + + + + + + + + + + + + +} +?> diff --git a/tests/main/admin/statistics/statistics.lib.test.php b/tests/main/admin/statistics/statistics.lib.test.php new file mode 100644 index 0000000000..2915a3863f --- /dev/null +++ b/tests/main/admin/statistics/statistics.lib.test.php @@ -0,0 +1,316 @@ +UnitTestCase('this File test the provides some function for statistics '); + } + + public function setUp(){ + $this-> statisc = new Statistics(); + } + + public function tearDown(){ + $this->statisc = null; + } + + public function testMakeSizeString(){ + $size=20960000; + $res = Statistics::make_size_string($size); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + public function testCountCourse(){ + $instans = new MockDatabase(); + + $course_code = 'ABC'; + $course_code2 = 'ABCD'; + $category_code = NULL; + $session_id = SessionManager::create_session($course_code,2009,07,20,2010,07,20,0,0,1,'coach'); + $res = Statistics::count_courses($category_code); + $this->assertTrue(is_numeric($res)); + $this->assertTrue(count($res) !== 0); + //var_dump($res); + } + + public function testCountCourse2(){ + $instans = new MockDatabase(); + $user_id=1; + $course_code = 'ABC'; + $course_code2 = 'ABCD'; + $category_code = NULL; + $session_id = SessionManager::create_session($course_code,2009,07,20,2010,07,20,0,0,1,'coach'); + SessionManager::add_courses_to_session($session_id,array($course_code)); + SessionManager::suscribe_users_to_session($session_id,array($user_id)); + $res = Statistics::count_courses($category_code); + $this->assertTrue(count($res ==0)); + $this->assertTrue(is_numeric($res)); + CourseManager::delete_course($course_code); + //var_dump($res); + } + + public function testCountCourse3(){ + $user_id=1; + $course_code = 'ABC'; + $course_code2 = 'ABCD'; + $category_code = NULL; + $session_id = SessionManager::create_session($course_code,2009,07,20,2010,07,20,0,0,1,'coach'); + SessionManager::suscribe_users_to_session($session_id,array($user_id+3)); + $res = Statistics::count_courses($category_code); + $this->assertTrue(is_numeric($res)); + $this->assertTrue(count($res)!==0); + //var_dump($res); + } + + public function testCountCourse4(){ + $user_id=1; + $course_code = 'ABC'; + $course_code2 = 'ABCD'; + $category_code = NULL; + //ob_start(); + $session_id = SessionManager::create_session($course_code,2009,07,20,2010,07,20,0,0,1,'coach'); + SessionManager::suscribe_users_to_session($session_id,array($user_id+3)); + SessionManager::add_courses_to_session($session_id,array()); + $res = Statistics::count_courses($category_code); + $this->assertTrue(is_numeric($res)); + $this->assertTrue(count($res)!==0); + SessionManager::delete_session($session_id); + CourseManager::delete_course($course_code2); + CourseManager::delete_course($course_code); + //ob_end_clean(); + //var_dump($res); + } + + public function testCountUsers(){ + $user_id =001; + $category_code = NULL; + $course_code='ABC'; + $firstName='adam'; $lastName='ivan'; $status='01'; $email='ricardo.rodriguez@dokeos.com'; $loginName='adam'; $password='1234'; + $count_invisible_courses = true; + $session_id = SessionManager::create_session($course_code,2009,07,20,2010,07,20,0,0,1,'coach'); + SessionManager::suscribe_users_to_session($session_id,array($user_id+3)); + $res = Statistics::count_users($status, $category_code, $count_invisible_courses); + $this->assertTrue(is_numeric($res)); + $this->assertTrue(count($res)===0 || count($res)!==0); + SessionManager::delete_session($session_id); + //var_dump($res); + } + + public function testGetNumberOfActivities(){ + $activitis = new MockDatabase(); + $sql = "SELECT count(default_id) AS total_number_of_items FROM $track_e_default "; + $res = api_sql_query($sql, __FILE__, __LINE__); + $obj = Database::fetch_object($res); + $resu = Statistics::get_number_of_activities(); + $this->assertTrue(is_numeric($resu)); + $this->assertTrue(count($resu)==0 || count($resu)!==0); + //var_dump($resu); + //var_dump($res); + } + + public function testGetActivitiesData(){ + $instans = new MockDatabase(); + global $dateTimeFormatLong; + $from=''; + $number_of_items=10; + $column=''; + $direction=''; + $track_e_default = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_DEFAULT); + $table_user = Database::get_main_table(TABLE_MAIN_USER); + $sql = "SELECT + default_event_type as col0, + default_value_type as col1, + default_value as col2, + user.username as col3, + default_date as col4 + FROM $track_e_default track_default, $table_user user + WHERE track_default.default_user_id = user.user_id "; + $res = api_sql_query($sql, __FILE__, __LINE__); + $row = Database::fetch_row($res); + $resu = Statistics::get_activities_data($from, $number_of_items, $column, $direction); + $this->assertTrue(is_array($resu)); + $this->assertTrue($row); + //var_dump($resu); + //var_dump($row); + //var_dump($res); + } + + public function testGetCourseCategories(){ + $user_id =002; + $category_code = NULL; + $course_code='ABCDE'; + $real_course_code='00001'; + $course_title='test1'; + $wanted_course_code='test2'; + $course_language='es'; + $course_category='primary'; + $code='00001'; + $session_id = SessionManager::create_session($course_code,2009,07,20,2010,07,20,0,0,1,'coach'); + CourseManager::create_virtual_course ($real_course_code, $course_title, $wanted_course_code, $course_language, $course_category); + $res = Statistics::get_course_categories(); + $this->assertTrue($res); + CourseManager::delete_course($code); + //var_dump($res); + } + + public function testRescale(){ + $data=array('aas','aaa'.'aab'); + $max = 500; + $res = Statistics::rescale($data, $max); + $this->assertTrue($res); + $this->assertTrue(is_array($res)); + //var_dump($res); + } + + public function testPrintStats(){ + ob_start(); + $title='testing'; + $stats=array('aa','bb','cc'); + $show_total = true; + $is_file_size = false; + $res = Statistics::print_stats($title, $stats, $show_total = true, $is_file_size = false); + ob_end_clean(); + $this->assertTrue(is_null($res)); + //var_dump($res); + } + + public function testPrintLoginStats(){ + ob_start(); + $instans = new MockDatabase(); + $type='january'; + $table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN); + if($type === 'month'){ + $sql = "SELECT DATE_FORMAT( login_date, '%Y %b' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table." GROUP BY stat_date ORDER BY login_date "; + }if($type === 'hour'){ + $sql = "SELECT DATE_FORMAT( login_date, '%H' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table." GROUP BY stat_date ORDER BY stat_date "; + }else{ + $sql = "SELECT DATE_FORMAT( login_date, '%a' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table." GROUP BY stat_date ORDER BY DATE_FORMAT( login_date, '%w' ) "; + } + $res = api_sql_query($sql,__FILE__,__LINE__); + $obj = Database::fetch_object($res); + $result[$obj->stat_date] = $obj->number_of_logins; + $login_stats[] = $result; + $resu = Statistics::print_login_stats($type); + ob_end_clean(); + $instans->expectOnce($login_stats); + $this->assertTrue(is_null($resu)); + $this->assertTrue($result); + //var_dump($resu); + //var_dump($result); + } + + public function testPrintRecenLoginStats(){ + ob_start(); + $instans = new MockDatabase(); + $total_logins = array(); + $table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN); + $query[get_lang('Total')] = "SELECT count(login_user_id) AS number FROM $table"; + $res = api_sql_query($query,__FILE__,__LINE__); + $obj = Database::fetch_object($res); + $total_logins[] = $obj->number; + $res = Statistics::print_recent_login_stats(); + ob_end_clean(); + $instans->expectCallCount($total_logins); + $this->assertTrue(is_null($res)); + $this->assertTrue(count($total_logins)); + //var_dump($res); + //var_dump($total_logins); + } + + public function testPrintToolStats(){ + ob_start(); + $instans = new MockDatabase(); + $table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS); + $tools = array('announcement','assignment','calendar_event','chat','conference','course_description','document','dropbox','group','learnpath','link','quiz','student_publication','user','bb_forum'); + $sql = "SELECT access_tool, count( access_id ) AS number_of_logins FROM $table WHERE access_tool IN ('".implode("','",$tools)."') GROUP BY access_tool "; + $res = api_sql_query($sql,__FILE__,__LINE__); + $result = array(); + $obj = Database::fetch_object($res); + $result[$obj->access_tool] = $obj->number_of_logins; + $resu = Statistics::print_tool_stats(); + ob_end_clean(); + $instans->expectCallCount($result); + $this->assertTrue(is_null($resu)); + //var_dump($resu); + //var_dump($result); + } + + public function testPrintCourseByLanguageStats(){ + ob_start(); + $instans = new MockDatabase(); + $table = Database::get_main_table(TABLE_MAIN_COURSE); + $sql = "SELECT course_language, count( code ) AS number_of_courses FROM $table GROUP BY course_language "; + $res = api_sql_query($sql,__FILE__,__LINE__); + $result = array(); + $obj = Database::fetch_object($res); + $result[$obj->course_language] = $obj->number_of_courses; + $instans->expectOnce($result); + $resu = Statistics::print_course_by_language_stats(); + ob_end_clean(); + $this->assertTrue(is_null($resu)); + $this->assertTrue(is_array($result)); + //var_dump($resu); + //var_dump($result); + } + + public function testPrintUserPicturesStats(){ + ob_start(); + $instans = new MockDatabase(); + $user_table = Database :: get_main_table(TABLE_MAIN_USER); + $sql = "SELECT COUNT(*) AS n FROM $user_table"; + $res = api_sql_query($sql,__FILE__,__LINE__); + $count1 = Database::fetch_object($res); + $instans_print[]= $count1; + $instans->expectOnce($instans_print); + $instans->expectCallCount($instans_print); + $resu = Statistics::print_user_pictures_stats(); + ob_end_clean(); + $this->assertTrue(is_null($resu)); + $this->assertTrue($instans_print); + //var_dump($resu); + //var_dump($instans_print); + } + + public function testPrintActivitiesStats(){ + ob_start(); + $res = Statistics::print_activities_stats(); + ob_end_clean(); + $this->assertTrue(is_null($res)); + //var_dump($res); + } + + public function testPrintCourseLastVisit(){ + ob_start(); + $instans = new MockDatabase(); + $instans1 = new MockDisplay(); + $table_header[] = array ("Coursecode", true); + $course = array (); + $courses[] = $course; + $column=''; + $direction=''; + $parameters['action'] = 'courselastvisit'; + $instans->expectCallCount('Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS)'); + $instans1->expectOnce(Display :: display_sortable_table($table_header, $courses, array('column'=>$column,'direction'=>$direction), array (), $parameters)); + $res = Statistics::print_course_last_visit(); + ob_end_clean(); + $this->assertTrue(is_null($res)); + //var_dump($res); + } + + + + + + + +} +?> diff --git a/tests/main/auth/lost_password.lib.test.php b/tests/main/auth/lost_password.lib.test.php new file mode 100644 index 0000000000..54756b875f --- /dev/null +++ b/tests/main/auth/lost_password.lib.test.php @@ -0,0 +1,78 @@ +assertTrue($res); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + function testget_secret_word(){ + global $_configuration; + $add=''; + $res = get_secret_word($add); + $this->assertTrue($res); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + function testget_user_account_list(){ + global $_configuration; + $user=''; + $thisUser=array(); + $secretword = get_secret_word($thisUser["email"]); + $reset_link = get_lang('Pass')." : $thisUser[password]"; + $userAccountList[] = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$thisUser["loginName"]."\n".get_lang('ResetLink').' : '.$reset_link.''; + $res = get_user_account_list($user, $reset = false); + $this->assertTrue($userAccountList); + $this->assertTrue(is_array($userAccountList)); + //var_dump($userAccountList); + } + + function testhandle_encrypted_password() { + require_once api_get_path (LIBRARY_PATH).'mail.lib.inc.php'; + global $charset; + global $_configuration; + ob_start(); + $user=array('abc'); + $emailHeaders = get_email_headers(); // Email Headers + $emailSubject = "[".get_setting('siteName')."] ".get_lang('LoginRequest'); // SUBJECT + $userAccountList = get_user_account_list($user, true); // BODY + $emailTo = $user[0]["email"]; + $secretword = get_secret_word($emailTo); + $emailBody = get_lang('DearUser')." :\n".get_lang("password_request")."\n\n"; + $emailBody .= "-----------------------------------------------\n".$userAccountList."\n-----------------------------------------------\n\n"; + $emailBody .=get_lang('PasswordEncryptedForSecurity'); + $emailBody .="\n\n".get_lang('Formula').",\n".get_lang('PlataformAdmin'); + $sender_name = get_setting('administratorName').' '.get_setting('administratorSurname'); + $email_admin = get_setting('emailAdministrator'); + $res=handle_encrypted_password($user); + if(!is_array($res))$this->assertTrue(is_null($res)); + ob_end_clean(); + //var_dump($res); + } + + function testreset_password(){ + $secret='1234567891011'; + $id=5; + $res=reset_password($secret, $id); + $this->assertTrue($res); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + function testsend_password_to_user() { + $user=array(); + ob_start(); + $res=send_password_to_user($user); + if(!is_null($res))$this->assertTrue(is_array($res)); + ob_end_clean(); + //var_dump($res); + } +} +?> diff --git a/tests/main/auth/openid/openid.lib.test.php b/tests/main/auth/openid/openid.lib.test.php new file mode 100644 index 0000000000..15164e2c4c --- /dev/null +++ b/tests/main/auth/openid/openid.lib.test.php @@ -0,0 +1,222 @@ +assertTrue(is_string($res)); + $this->assertTrue(is_string($serialized)); + //var_dump($serialized); + } + + function test_openid_dh_base64_to_long() { + $str=''; + $b64 = base64_decode($str); + $res=_openid_dh_base64_to_long($str); + $this->assertTrue(is_numeric($res)); + $this->assertTrue(is_string($b64)); + //var_dump($res); + } + + function test_openid_dh_binary_to_long() { + $str=''; + $bytes = array_merge(unpack('C*', $str)); + $res=_openid_dh_binary_to_long($str); + $this->assertTrue(is_numeric($res)); + $this->assertTrue(is_array($bytes)); + //var_dump($bytes); + } + + function test_openid_dh_long_to_base64() { + $str=''; + $res=_openid_dh_long_to_base64($str); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + function test_openid_dh_long_to_binary() { + $long=''; + $res=_openid_dh_long_to_binary($long); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + function test_openid_dh_rand() { + $stop=''; + $rbytes = _openid_dh_long_to_binary($stop); + $nbytes = strlen($rbytes); + $mxrand = bcpow(256, $nbytes); + $duplicate = bcmod($mxrand, $stop); + $duplicate_cache = array(); + $duplicate_cache[$rbytes] = array($duplicate, $nbytes); + $res=_openid_dh_rand($stop); + if(!is_array($res))$this->assertTrue(is_null($res)); + $this->assertTrue(is_array($duplicate_cache)); + //var_dump($res); + //var_dump($duplicate_cache); + } + + function test_openid_dh_xorsecret() { + $shared=''; + $secret=''; + $res=_openid_dh_xorsecret($shared, $secret); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + function test_openid_encode_message() { + $message=''; + $res=_openid_encode_message($message); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + function test_openid_fix_post() { + $post=''; + $res=_openid_fix_post($post); + $this->assertTrue(is_null($res)); + //var_dump($res); + } + + function test_openid_get_bytes() { + static $f = null; + $num_bytes=''; + $res=_openid_get_bytes($num_bytes); + $this->assertTrue(is_bool($res)); + //var_dump($res); + } + + function test_openid_hmac() { + $key=''; + $text=''; + $res=_openid_hmac($key, $text); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + function test_openid_is_xri() { + $identifier=''; + $res=_openid_is_xri($identifier); + $this->assertTrue(is_bool($res)); + //var_dump($res); + } + + function test_openid_link_href() { + $rel=''; + $html=''; + $res=_openid_link_href($rel, $html); + $this->assertTrue(is_bool($res)); + //var_dump($res); + } + + function test_openid_meta_httpequiv() { + $equiv=''; + $html=''; + $res=_openid_meta_httpequiv($equiv, $html); + $this->assertTrue(is_bool($res)); + //var_dump($res); + } + + function test_openid_nonce() { + $res=_openid_nonce(); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + function test_openid_normalize() { + $identifier=''; + $res=_openid_normalize($identifier); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + function test_openid_normalize_url() { + $url=''; + $res=_openid_normalize_url($url); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + function test_openid_normalize_xri() { + $xri=''; + $res=_openid_normalize_xri($xri); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + function test_openid_parse_message() { + $message=''; + $parsed_message = array(); + $res=_openid_parse_message($message); + $this->assertTrue(is_array($res)); + //var_dump($res); + } + + function test_openid_sha1() { + $text=''; + $res=_openid_sha1($text); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + function test_openid_signature() { + $association=''; + $message_array=''; + $keys_to_sign=''; + $res=_openid_signature($association, $message_array, $keys_to_sign); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + function testbcpowmod() { + $base=''; + $exp=''; + $mod=''; + $res=bcpowmod($base, $exp, $mod); + $this->assertTrue(is_bool($res)); + //var_dump($res); + } + + function testopenid_redirect() { + $url='http://localhost/dokeossvn186/tests/all.test2.php'; + $message=''; + ob_start(); + $res=openid_redirect($url, $message); + $this->assertTrue(is_null($res)); + ob_end_clean(); + //var_dump($res); + } + + function testopenid_redirect_http() { + $url='http://localhost/dokeossvn186/tests/all.test2.php'; + $message=''; + ob_start(); + $res=openid_redirect_http($url, $message); + $this->assertTrue(is_null($res)); + ob_end_clean(); + //var_dump($res); + } +} +?> diff --git a/tests/main/auth/openid/xrds.lib.test.php b/tests/main/auth/openid/xrds.lib.test.php new file mode 100644 index 0000000000..96e7902b8e --- /dev/null +++ b/tests/main/auth/openid/xrds.lib.test.php @@ -0,0 +1,46 @@ +assertTrue(is_null($res)); + //var_dump($res); + } + + function test_xrds_element_end() { + global $xrds_open_elements, $xrds_services, $xrds_current_service; + $parser=''; + $name=''; + $xrds_current_service['version'] = 2; + $xrds_current_service['version'] = 1; + $xrds_services[] = $xrds_current_service; + $xrds_current_service= array(); + $res=_xrds_element_end($parser, $name); + $this->assertTrue(is_null($res)); + //var_dump($xrds_current_service); + } + + function test_xrds_element_start() { + global $xrds_open_elements; + $parser=''; + $name=''; + $attribs=''; + $xrds_open_elements[] = _xrds_strip_namespace($name); + $res=_xrds_element_start($parser, $name); + $this->assertTrue(is_null($res)); + //var_dump($res); + } + + function test_xrds_strip_namespace() { + $name=''; + $res=_xrds_strip_namespace($name); + $this->assertTrue(is_string($res)); + //var_dump($res); + } +} +?> diff --git a/tests/main/chat/chat_functions.lib.test.php b/tests/main/chat/chat_functions.lib.test.php new file mode 100644 index 0000000000..60cfe7c3f4 --- /dev/null +++ b/tests/main/chat/chat_functions.lib.test.php @@ -0,0 +1,38 @@ +assertTrue(is_null($res)); + //var_dump($res); + } + + function testexit_of_chat () { + $docu = new MockCourseManager(); + $user_id=1; + $res = exit_of_chat(); + $docu->expectOnce(CourseManager::get_courses_list_by_user_id($user_id),'admin'); + $this->assertTrue(is_object($docu)); + $this->assertTrue(is_null($res)); + //var_dump($res); + } + + function testuser_connected_in_chat () { + $user_id=1; + $database_name=''; + $res = user_connected_in_chat($user_id,$database_name); + $this->assertTrue(is_bool($res)); + //var_dump($res); + } + + function testusers_list_in_chat () { + $res = users_list_in_chat(); + $this->assertTrue(is_array($res)); + //var_dump($res); + } +} +?> diff --git a/tests/main/conference/get_translation.lib.test.php b/tests/main/conference/get_translation.lib.test.php new file mode 100644 index 0000000000..9be7ad4123 --- /dev/null +++ b/tests/main/conference/get_translation.lib.test.php @@ -0,0 +1,12 @@ +assertTrue(($res)); + //var_dump($res); + } +} +?>