22                         $this->enable_log = $a_val;
 
   32                         return $this->enable_log;
 
   45                                 echo 
"<br>".$a_str; flush();
 
   56                         $a_end = 1000, $a_firstname = 
"John", $a_lastname_base = 
"Learner", $a_pw = 
"learnerpw",
 
   57                         $a_email = 
"de@de.de", $a_gender = 
"m", $a_lang = 
"en")
 
   62                         $this->
log(
"Creating Users");
 
   63                         for ($i = $a_start; $i <= $a_end; $i++)
 
   65                                 $this->
log($a_login_base.$i);
 
   67                                 $user->setLogin($a_login_base.$i);
 
   68                                 $user->setFirstname($a_firstname);
 
   69                                 $user->setLastname($a_lastname_base.
" ".$i);
 
   70                                 $user->setGender($a_gender);
 
   71                                 $user->setEmail($a_email);
 
   74                                 $user->setTitle($user->getFullname());
 
   75                                 $user->setDescription($user->getEmail());
 
   76                                 $user->setLastPasswordChangeTS( time() );
 
   77                                 $user->setActive(
true);
 
   78                                 $user->setTimeLimitUnlimited(
true);
 
   80                                 $user->setLanguage($a_lang);
 
   81                                 $user->saveAsNew(
false);
 
   83                                 $rbacadmin->assignUser(4, $user->getId(),
true);
 
   93                 function generateCategories($a_start = 1, $a_end = 500, $a_sub_cats_per_cat = 10, $a_title_base = 
"Category",
 
   94                         $a_node = 
"", $a_init_cnt = 
true, $a_depth = 1)
 
   98                         include_once(
"./Modules/Category/classes/class.ilObjCategory.php");
 
  102                                 $this->item_cnt = $a_start;
 
  103                                 $this->max_depth = ceil(
log($a_end - $a_start, $a_sub_cats_per_cat));
 
  106                         if ($a_depth > $this->max_depth)
 
  113                                 $a_node = $tree->getRootId();
 
  114                                 $this->
log(
"Creating Categories");
 
  119                         while ($sub_cat_cnt < $a_sub_cats_per_cat && $this->item_cnt <= $a_end)
 
  121                                 if ($this->item_cnt <= $a_end)
 
  123                                         $this->
log($a_title_base.
" ".$this->item_cnt);
 
  125                                         $new_cat->setTitle($a_title_base.
" ".$this->item_cnt);
 
  127                                         $new_cat->createReference();
 
  128                                         $new_cat->putInTree($a_node);
 
  129                                         $new_cat->setPermissions($a_node);
 
  130                                         $sub_cats[] = $new_cat;
 
  136                         foreach ($sub_cats as $sub_cat)
 
  138                                 $this->
generateCategories($this->item_cnt, $a_end, $a_sub_cats_per_cat, $a_title_base,
 
  139                                         $sub_cat->getRefId(), 
false, $a_depth + 1);
 
  150                         $a_title_base = 
"Course")
 
  154                         include_once(
"./Modules/Course/classes/class.ilObjCourse.php");
 
  156                         $this->
log(
"Creating Courses");
 
  158                         $a_current = $a_start;
 
  161                         $needed_cats = ceil(($a_end - $a_start + 1) / $a_course_per_cat);
 
  164                         $nodes = $tree->getFilteredSubTree($tree->getRootId(), array(
"adm", 
"crs", 
"fold", 
"grp"));
 
  167                         foreach ($nodes as $node)
 
  169                                 if ($node[
"type"] == 
"cat" && $a_current <= $a_end)
 
  171                                         for ($i = 1; $i <= $a_course_per_cat; $i++)
 
  173                                                 if ($a_current <= $a_end)
 
  175                                                         $this->
log($a_title_base.
" ".$a_current);
 
  177                                                         $new_crs->setTitle($a_title_base.
" ".$a_current);
 
  179                                                         $new_crs->createReference();
 
  180                                                         $new_crs->putInTree($node[
"child"]);
 
  181                                                         $new_crs->setPermissions($node[
"child"]);
 
  196                 function generateFiles($a_test_file, $a_files_per_course = 10, $a_title_base = 
"File")
 
  200                         include_once(
"./Modules/File/classes/class.ilObjFile.php");
 
  202                         $this->
log(
"Creating Files");
 
  204                         $a_current = $a_start;
 
  208                                 0, $limit = 1000000);
 
  210                         foreach ($crs_ref_ids as $rid)
 
  212                                 for ($i = 1; $i <= $a_files_per_course; $i++)
 
  214                                         $this->
log($a_title_base.
" ".$cnt);
 
  216                                         $fileObj->setTitle($a_title_base.
" ".$cnt);
 
  217                                         $fileObj->setFileName(
"file_".$cnt.
".txt");
 
  219                                         $fileObj->createReference();
 
  220                                         $fileObj->putInTree($rid);
 
  221                                         $fileObj->setPermissions($rid);
 
  222                                         $fileObj->createDirectory();
 
  223                                         $fileObj->getUploadFile($a_test_file,
 
  224                                                 "file_".$cnt.
".txt");
 
  239                         include_once(
"./Services/Calendar/classes/class.ilDateTime.php");
 
  240                         include_once(
"./Services/Calendar/classes/class.ilCalendarEntry.php");
 
  241                         include_once(
"./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php");
 
  242                         include_once(
"./Services/Calendar/classes/class.ilCalendarCategories.php");
 
  244                         $this->
log(
"Creating Calendar Entries");
 
  247                                 0, $limit = 1000000);
 
  249                         foreach ($crs_ref_ids as $rid)
 
  258                                 for ($i = 1; $i <= $a_num_per_course; $i++)
 
  260                                         $this->
log(
"Event ".$cnt);
 
  262                                         $entry->setStart($start);               
 
  263                                         $entry->setEnd($end);           
 
  264                                         $entry->setFullday(
false);              
 
  265                                         $entry->setTitle(
"Event ".$cnt);                
 
  267                                         $id = $entry->getEntryId();
 
  269                                         $ass->addAssignment($cat_id);
 
  291                         if ($ilDB->getDBType() == 
"mysql")
 
  293                                 $fp = fopen(
$file, 
'r');
 
  296                                         $this->
log(
"Error reading file $file.");
 
  299                                 $this->
log(
"Dropping Tables.");
 
  300                                 $set = $ilDB->query(
"SHOW tables");
 
  301                                 while ($rec = $ilDB->fetchAssoc($set))
 
  305                                                 $ilDB->query(
"DROP TABLE ".$v);
 
  309                                 $this->
log(
"Read Dump.");
 
  313                                         $line = trim($this->
getline($fp, 
"\n"));
 
  315                                         if ($line != 
"" && substr($line,0,1)!=
"#" 
  316                                                 && substr($line,0,1)!=
"-")
 
  319                                                 if (substr($line,-1)==
";")
 
  322                                                         $q .= 
" ".substr($line,0,-1);
 
  323                                                         $r = $ilDB->query($q);
 
  324                                                         if (mysql_errno() > 0)
 
  326                                                                 echo 
"<br />ERROR: ".mysql_error().
 
  343                         if ($ilDB->getDBType() == 
"oracle")
 
  345                                 include_once(
"./setup/sql/ilDBTemplate.php");
 
  346                                 setupILIASDatabase();
 
  356                         while( !feof( $fp ) )
 
  371                 function createDump($a_target_file, $a_dump_cmd, $a_db_user = 
"root",
 
  372                         $a_db_pw = 
"", $a_db_name = 
"loadtest")
 
  374                         $this->
log(
"Writing Dump");
 
  375                         $a_pw = ($a_pwd == 
"")
 
  378                         $cmd = $a_dump_cmd.
" -u".$a_db_user.
" ".$a_pw.
" --skip-lock-tables -Q --extended-insert=FALSE --default-character-set=utf8".
 
  379                                 " --add-drop-table=FALSE --add-locks=FALSE  --compatible=mysql40 ".$a_db_name.
" > ".$a_target_file;
 
  380                         if (!is_file($a_target_file))
 
  382                                 $this->
log(
"Something went wrong when writing the dump:<br>".
$cmd);
 
  396                         $this->
log(
"Writing User CSV");
 
  397                         $set = $ilDB->query(
"SELECT * FROM usr_data");
 
  398                         $file = fopen($a_target_file, 
"w");
 
  401                                 while ($rec  = $ilDB->fetchAssoc($set))
 
  403                                         if (substr($rec[
"login"], 0, strlen($a_user_base_name)) == $a_user_base_name)
 
  405                                                 fwrite(
$file, $rec[
"login"].
"\n");
 
  412                                 $this->
log(
"Could not write USer CSV.");
 
  427                         $this->
log(
"Writing Course CSV");
 
  429                                 0, $limit = 1000000);
 
  430                         $file = fopen($a_target_file, 
"w");
 
  433                                 foreach ($crs_ref_ids as $r)
 
  435                                         fwrite(
$file, $r.
"\n");
 
  441                                 $this->
log(
"Could not write Course CSV.");
 
  456                         $this->
log(
"Writing Category CSV");
 
  458                                 0, $limit = 1000000);
 
  459                         $file = fopen($a_target_file, 
"w");
 
  462                                 foreach ($cat_ref_ids as $r)
 
  464                                         fwrite(
$file, $r.
"\n");
 
  470                                 $this->
log(
"Could not write Category CSV.");
 
  480                         $a_start = 1, $a_end = 100)
 
  484                         $this->
log(
"Assigning Course Members");
 
  485                         $set = $ilDB->query(
"SELECT usr_id, login FROM usr_data WHERE ".
 
  486                                 " login LIKE ".$ilDB->quote($a_user_login_base.
"%", 
"text")
 
  489                         while ($rec  = $ilDB->fetchAssoc($set))
 
  491                                 $rest = substr($rec[
"login"], strlen($a_user_login_base));
 
  492                                 if (is_numeric(
$rest) &&
 
  493                                         ((
int) 
$rest >= $a_start && (
int) 
$rest <= $a_end))
 
  495                                         $user_ids[] = $rec[
"usr_id"];
 
  500                                 0, $limit = 1000000);
 
  501                         include_once 
"./Modules/Course/classes/class.ilCourseParticipants.php";
 
  502                         foreach ($crs_ref_ids as $r)
 
  506                                 foreach ($user_ids as $u)
 
  508                                         $this->
log(
"$cnt: add user $u as member to course ".$crs_id);                           
 
  509                                         $mem_obj->add($u, 1);
 
  522                         $this->
log(
"Remove Desktop Items.");
 
  523                         $ilDB->manipulate(
"DELETE FROM desktop_item");
 
  533                         $this->
log(
"Deactivate calendars on personal desktop.");
 
  534                         $set = $ilDB->query(
"SELECT * FROM usr_data");
 
  535                         while ($rec  = $ilDB->fetchAssoc($set))
 
  537                                 $ilDB->manipulate(
"REPLACE INTO il_block_setting ".
 
  538                                         "(type, user_id, block_id, setting, value) VALUES (".
 
  539                                         $ilDB->quote(
"pdcal", 
"text").
",".
 
  540                                         $ilDB->quote($rec[
"usr_id"], 
"integer").
",".
 
  541                                         $ilDB->quote(0, 
"integer").
",".
 
  542                                         $ilDB->quote(
"detail", 
"text").
",".
 
  543                                         $ilDB->quote(0, 
"integer").