TUTOS PHP Cross Reference Groupware Applications

Source: /php/admin/demodata.p3 - 548 lines - 15114 bytes - Summary - Text - Print

Description: Copyright 2004 - 2010 by Gero Kohnert

   1  <?php
   2  /**
   3   *  Copyright 2004 - 2010 by Gero Kohnert
   4   *
   5   *  This program is free software; you can redistribute it and/or modify it
   6   *  under the terms of the GNU General Public License as published by the
   7   *  Free Software Foundation; version 2 of the License.
   8   *
   9   * Filling in demodata
  10   * this file is simply "sourced" when creating a database and filling in demodata
  11   * @modulegroup ADMIN
  12   * @module demodata
  13   * @package BASE
  14   */
  15  
  16  # Demo happens with team permissions
  17  
  18  $tutos[defaultacl] = 1;
  19  $cnt = 0;
  20  $u[0] = new tutos_user($this->obj);
  21  $u[1] = new tutos_user($this->obj);
  22  $u[2] = new tutos_user($this->obj);
  23  $u[3] = new tutos_user($this->obj);
  24  $u[4] = new tutos_user($this->obj);
  25  $u[5] = new tutos_user($this->obj);
  26  
  27  $ucnt = 3;
  28  $acnt = 3;
  29  
  30  # User & Addresses
  31  $a[0] = new tutos_address($this->obj);
  32  $a[0]->f_name = "Linus";
  33  $a[0]->m_name = "B";
  34  $a[0]->l_name = "Torvalds";
  35  $a[0]->creator = &$this->user;
  36  $msg .= $a[0]->save();
  37  acl_raise($a[0],EVERYBODY,$tutos[useok]);
  38  acl_save($a[0]);
  39  $r .= $lang[$a[0]->getType()].":". $a[0]->getFullName() ."<br />\n";
  40  $demodata[] = &$a[0];
  41  flush();
  42  
  43  $u[0]->updatepw = 1;
  44  $u[0]->login = "linus";
  45  $u[0]->pw = "guest";
  46  $u[0]->id = $a[0]->id;
  47  $msg .= $u[0]->save();
  48  $msg .= $u[0]->save_permissions();
  49  acl_raise($u[0],EVERYBODY,$tutos[useok]);
  50  acl_save($u[0]);
  51  $r .= $lang[$u[0]->getType()].":". $u[0]->login ."<br />\n";
  52  $demodata[] = &$u[0];
  53  flush();
  54  
  55  # all the coming stuff will happen as linus
  56  $current_user = &$u[0];
  57  
  58  $a[1] = new tutos_address($this->obj);
  59  $a[1]->f_name = "Bill";
  60  $a[1]->l_name = "Gates";
  61  $a[1]->creator = &$u[0];
  62  $msg .= $a[1]->save();
  63  acl_raise($a[1],EVERYBODY,$tutos[useok]);
  64  acl_save($a[1]);
  65  $r .= $lang[$a[1]->getType()].":". $a[1]->getFullName() ."<br />\n";
  66  $demodata[] = &$a[1];
  67  flush();
  68  
  69  $u[1]->updatepw = 1;
  70  $u[1]->login = "billgates";
  71  $u[1]->pw = "guest";
  72  $u[1]->id = $a[1]->id;
  73  $msg .= $u[1]->save();
  74  $msg .= $u[1]->save_permissions();
  75  acl_raise($u[1],EVERYBODY,$tutos[useok]);
  76  acl_save($u[1]);
  77  $r .= $lang[$u[1]->getType()].":". $u[1]->login ."<br />\n";
  78  $demodata[] = &$u[1];
  79  flush();
  80  
  81  $a[2] = new tutos_address($this->obj);
  82  $a[2]->f_name = "Gero";
  83  $a[2]->l_name = "Kohnert";
  84  $a[2]->creator = &$u[0];
  85  $msg .= $a[2]->save();
  86  acl_raise($a[2],EVERYBODY,$tutos[useok]);
  87  acl_save($a[2]);
  88  $r .= $lang[$a[2]->getType()].":". $a[2]->getFullName() ."<br />\n";
  89  $demodata[] = &$a[2];
  90  flush();
  91  
  92  $u[2]->updatepw = 1;
  93  $u[2]->login = "gero";
  94  $u[2]->pw = "guest";
  95  $u[2]->id = $a[2]->id;
  96  $msg .= $u[2]->save();
  97  $msg .= $u[2]->save_permissions();
  98  acl_raise($u[2],EVERYBODY,$tutos[useok]);
  99  acl_save($u[2]);
 100  $r .= $lang[$u[2]->getType()].":". $u[2]->login ."<br />\n";
 101  $demodata[] = &$u[2];
 102  flush();
 103  
 104  $a[3] = new tutos_address($this->obj);
 105  $a[3]->f_name = "Sepp";
 106  $a[3]->l_name = "Hinteregger";
 107  $a[3]->creator = &$u[0];
 108  $msg .= $a[3]->save();
 109  acl_raise($a[3],EVERYBODY,$tutos[useok]);
 110  acl_save($a[3]);
 111  $r .= $lang[$a[3]->getType()].":". $a[3]->getFullName() ."<br />\n";
 112  $demodata[] = &$a[3];
 113  flush();
 114  
 115  $u[3]->updatepw = 1;
 116  $u[3]->login = "sepp";
 117  $u[3]->pw = "guest";
 118  $u[3]->id = $a[3]->id;
 119  $msg .= $u[3]->save();
 120  $msg .= $u[3]->save_permissions();
 121  acl_raise($u[3],EVERYBODY,$tutos[useok]);
 122  acl_save($u[3]);
 123  $r .= $lang[$u[3]->getType()].":". $u[3]->login ."<br />\n";
 124  $demodata[] = &$u[3];
 125  flush();
 126  
 127  $a[4] = new tutos_address($this->obj);
 128  $a[4]->f_name = "Every";
 129  $a[4]->l_name = "Body";
 130  $a[4]->creator = &$u[0];
 131  $msg .= $a[4]->save();
 132  acl_raise($a[4],EVERYBODY,$tutos[useok]);
 133  acl_save($a[4]);
 134  $r .= $lang[$a[4]->getType()].":". $a[4]->getFullName() ."<br />\n";
 135  $demodata[] = &$a[4];
 136  flush();
 137  
 138  $u[4]->updatepw = 1;
 139  $u[4]->login = "someone";
 140  $u[4]->pw = "guest";
 141  $u[4]->id = $a[4]->id;
 142  $msg .= $u[4]->save();
 143  $msg .= $u[4]->save_permissions();
 144  acl_raise($u[4],EVERYBODY,$tutos[useok]);
 145  acl_save($u[4]);
 146  $r .= $lang[$u[4]->getType()].":". $u[4]->login ."<br />\n";
 147  $demodata[] = &$u[4];
 148  flush();
 149  
 150  
 151  # Team
 152  $x1 = new team($this->obj);
 153  $add = array();
 154  $del = array();
 155  $add[0] = $a[0]->id;
 156  $add[0] = $a[2]->id;
 157  $x1->name = "TUTOS Development";
 158  $x1->owner = $a[2];
 159  $x1->creator = $u[2];
 160  $msg .= $x1->save($add,$del);
 161  $msg .= $x1->save_permissions();
 162  acl_raise($x1,EVERYBODY,$tutos[useok]);
 163  acl_save($x1);
 164  $r .= $lang[$x1->getType()].":". $x1->getFullName() ."<br />\n";
 165  $demodata[] = &$x1;
 166  unset($x1);
 167  flush();
 168  
 169  $x2 = new team($this->obj);
 170  $add = array();
 171  $del = array();
 172  $add[0] = $a[1]->id;
 173  $x2->name = "The Others";
 174  $x2->creator = $u[2];
 175  $x2->owner = $a[2];
 176  $msg .= $x2->save($add,$del);
 177  $msg .= $x2->save_permissions();
 178  acl_raise($x2,EVERYBODY,$tutos[useok]);
 179  acl_save($x2);
 180  $r .= $lang[$x2->getType()].":". $x2->getFullName() ."<br />\n";
 181  $demodata[] = &$x2;
 182  unset($x2);
 183  flush();
 184  
 185  $x3 = new team($this->obj);
 186  $add = array();
 187  $del = array();
 188  $add[0] = $a[0]->id;
 189  $add[1] = $a[1]->id;
 190  $add[2] = $a[2]->id;
 191  # $add[3] = 1001; # hardcoded superuser
 192  $x3->name = "all";
 193  $x3->creator = $u[2];
 194  $x3->owner = $a[2];
 195  $msg .= $x3->save($add,$del);
 196  $msg .= $x3->save_permissions();
 197  acl_raise($x3,EVERYBODY,$tutos[useok]);
 198  acl_save($x3);
 199  $r .= $lang[$x3->getType()].":". $x3->getFullName() ."<br />\n";
 200  $demodata[] = &$x3;
 201  unset($x3);
 202  flush();
 203  
 204  for ($i = 0 ; $i < 30; $i++) {
 205      $x = new tutos_address($this->obj);
 206      if (($i % 2) == 0) {
 207          $x->title =  "Mr.";
 208          $x->f_name = "John ".$i;
 209          $x->m_name =  $i;
 210      } else {
 211          $x->title =  "Ms.";
 212          $x->f_name = "Johanna ".$i;
 213          $x->m_name =  $i;
 214      }
 215      $x->l_name = "Doe";
 216      $x->creator = &$u[$cnt % $ucnt];
 217      $msg .= $x->save();
 218      acl_raise($x,EVERYBODY,$tutos[modok]);
 219      acl_save($x);
 220      $r .= $lang[$x->getType()].":". $x->getFullName() ."<br />\n";
 221      $demodata[] = &$x;
 222      $a[] = &$x;
 223      flush();
 224      unset($x);
 225  }
 226  
 227  # Companies
 228  $comp[1] = new company($this->obj);
 229  $comp[1]->name = "Linux Consulting";
 230  $msg .= $comp[1]->save();
 231  acl_raise($comp[1],EVERYBODY,$tutos[modok]);
 232  acl_save($comp[1]);
 233  $r .= $lang[$comp[1]->getType()].":". $comp[1]->getFullName() ."<br />\n";
 234  $demodata[] = &$comp[1];
 235  
 236  $comp[2] = new company($this->obj);
 237  $comp[2]->name = "S.u.S.E";
 238  $msg .= $comp[2]->save();
 239  acl_raise($comp[2],EVERYBODY,$tutos[modok]);
 240  acl_save($comp[2]);
 241  $r .= $lang[$comp[2]->getType()].":". $comp[2]->getFullName() ."<br />\n";
 242  $demodata[] = &$comp[2];
 243  
 244  
 245  # Locations
 246  $l1 = new location($this->obj);
 247  $l1->company = &$comp[1];
 248  $l1->lname = "Home";
 249  $l1->phone_1 = "+49 9131 xxxxxx";
 250  $l1->email_1 = "nospam@tutos.xx";
 251  $l1->city = "Erlangen";
 252  $l1->zip  = "91058";
 253  $l1->country  = "DE";
 254  $l1->adr_id  = $a[2]->id;
 255  $l1->ref  = &$a[2];
 256  $msg .= $l1->save();
 257  acl_raise($l1,EVERYBODY,$tutos[modok]);
 258  acl_save($l1);
 259  $r .= $lang[$l1->getType()].":". $l1->lname ."<br />\n";
 260  $demodata[] = &$l1;
 261  unset($l1);
 262  flush();
 263  
 264  $l2 = new location($this->obj);
 265  $l2->company = &$comp[1];
 266  $l2->lname = "Headquarter";
 267  $l2->city = "Erlangen";
 268  $l2->zip  = "91058";
 269  $l2->email_1 = "hq@tutos.xx";
 270  $l2->country  = "DE";
 271  $l2->ref  = &$comp[1];
 272  $l2->adr_id  = $comp[1]->id;
 273  $msg .= $l2->save();
 274  acl_raise($l2,EVERYBODY,$tutos[modok]);
 275  acl_save($l2);
 276  $r .= $lang[$l2->getType()].":". $l2->lname ."<br />\n";
 277  $demodata[] = &$l2;
 278  unset($l2);
 279  flush();
 280  
 281  
 282  
 283  // No mails here !!
 284  $tutos[demo] = 1;
 285  
 286  // Products
 287  $p1 = new product($this->obj);
 288  $p1->name = "TUTOS";
 289  $p1->version = $tutos[version];
 290  $p1->creator = &$u[2];
 291  $p1->setRole($a[2],PROD_ROLE_MANAGER,"managing");
 292  $p1->setRole($comp[1],PROD_ROLE_PARTNER,"find the customers");
 293  $p1->setRole($a[4],PROD_ROLE_DEVEL,"developer");
 294  $p1->cl_new[1][] = 1;
 295  $p1->cl_new[2][] = 1;
 296  $p1->description = "This is TUTOS in TUTOS";
 297  $p1->desc1 = "A Groupware and Projectmanagementsoftware";
 298  $p1->desc2 = "demodata demodata";
 299  $p1->state = PROD_STATE_FINISH;
 300  $msg .= $p1->save();
 301  acl_raise($p1,EVERYBODY,$tutos[modok]);
 302  acl_save($p1);
 303  $r .= $lang[$p1->getType()].":". $p1->getFullName() ."<br />\n";
 304  $demodata[] = &$p1;
 305  
 306  
 307  $p2 = new product($this->obj);
 308  $p2->name = "Linux";
 309  $p2->version = "2.2";
 310  $p2->creator = &$u[0];
 311  $p2->setRole($a[0],PROD_ROLE_MANAGER,"lead the bunch");
 312  $p2->setRole($a[3],PROD_ROLE_DEVEL,"developer");
 313  $p2->setRole($a[4],PROD_ROLE_DEVEL,"developer");
 314  $p2->cl_new[1][] = 1;
 315  $p2->cl_new[2][] = 1;
 316  $p2->state = PROD_STATE_FINISH;
 317  $msg .= $p2->save();
 318  acl_raise($p2,EVERYBODY,$tutos[modok]);
 319  acl_save($p2);
 320  $r .= $lang[$p2->getType()].":". $p2->getFullName() ."<br />\n";
 321  $demodata[] = &$p2;
 322  
 323  $p3 = new product($this->obj);
 324  $p3->name = "Linux";
 325  $p3->version = "2.4";
 326  $p3->creator = &$u[0];
 327  $p2->state = PROD_STATE_RUN;
 328  $p3->setRole($a[0],PROD_ROLE_MANAGER,"lead the bunch");
 329  $p3->setRole($a[1],PROD_ROLE_PARTNER,"LEARN");
 330  $p3->setRole($p2,PROD_ROLE_ANCESTOR,"the previous version");
 331  $p3->setRole($a[3],PROD_ROLE_DEVEL,"developer");
 332  $p3->setRole($a[4],PROD_ROLE_DEVEL,"developer");
 333  $p3->cl_new[1][] = 2;
 334  $p3->cl_new[2][] = 2;
 335  $msg .= $p3->save();
 336  acl_raise($p3,EVERYBODY,$tutos[modok]);
 337  acl_save($p3);
 338  $r .= $lang[$p3->getType()].":". $p3->getFullName() ."<br />\n";
 339  $demodata[] = &$p3;
 340  
 341  $p4 = new product($this->obj);
 342  $p4->name = "TUTOS";
 343  $p4->version = "1.x";
 344  $p4->creator = &$u[0];
 345  $p4->state = PROD_STATE_RUN;
 346  $p4->setRole($a[2],PROD_ROLE_MANAGER,"managing");
 347  $p4->setRole($comp[1],PROD_ROLE_PARTNER,"find the customers");
 348  $p4->setRole($p1,PROD_ROLE_ANCESTOR,"the previous version");
 349  $p4->setRole($a[3],PROD_ROLE_DEVEL,"developer");
 350  $p4->setRole($a[4],PROD_ROLE_DEVEL,"developer");
 351  $p4->cl_new[1][] = 2;
 352  $p4->cl_new[2][] = 2;
 353  $msg .= $p4->save();
 354  acl_raise($p4,EVERYBODY,$tutos[modok]);
 355  acl_save($p4);
 356  $r .= $lang[$p4->getType()].":". $p4->getFullName() ."<br />\n";
 357  $demodata[] = &$p4;
 358  
 359  # Appointment
 360  $c1 = new appointment($this->obj);
 361  $c1->creator = &$u[0];
 362  $c1->mod_allow = 0;
 363  $c1->descr = "Meeting";
 364  $c1->outside = 1;
 365  $c1->t_ignore = 1;
 366  $c1->a_start = new TUTOS_Date_Time();
 367  $c1->a_end   = new TUTOS_Date_Time();
 368  $c1->visitor = &$a[1];
 369  $c1->product = &$p1;
 370  $c1->participant[$a[0]->id] = &$a[0];
 371  $c1->participant[$a[2]->id] = &$a[2];
 372  $msg .= $c1->save();
 373  acl_raise($c1,EVERYBODY,$tutos[modok]);
 374  acl_save($c1);
 375  $r .= $lang[$c1->getType()].":". $c1->getFullName() ."<br />\n";
 376  $demodata[] = &$c1;
 377  
 378  $c2 = new appointment($this->obj);
 379  $c2->creator = &$u[0];
 380  $c2->mod_allow = 0;
 381  $c2->descr = "Count my money";
 382  $c2->t_ignore = 1;
 383  $c2->outside = 0;
 384  $c2->a_start = new TUTOS_Date_Time();
 385  $c2->a_end   = new TUTOS_Date_Time();
 386  $c2->a_end->addDays(2);
 387  $c2->participant[$a[1]->id] = &$a[1];
 388  $msg .= $c2->save();
 389  acl_raise($c2,EVERYBODY,$tutos[modok]);
 390  acl_save($c2);
 391  $r .= $lang[$c2->getType()].":". $c2->getFullName() ."<br />\n";
 392  
 393  // adding some more departments
 394  foreach ($demodata as $i => $f) {
 395      if ($f->gettype() == "company") {
 396          // Departments
 397          $x = new department($this->obj);
 398          $x->name = "Sales";
 399          $x->setCompany($f->id);
 400          $msg .= $x->save();
 401          acl_raise($x,EVERYBODY,$tutos[modok]);
 402          acl_save($x);
 403          $r .= $lang[$x->getType()].":". $x->getFullName() ."<br />\n";
 404          $demodata[] = &$x;
 405          unset($x);
 406  
 407          $x = new department($this->obj);
 408          $x->name = "Development";
 409          $x->setCompany($f->id);
 410          $msg .= $x->save();
 411          acl_raise($x,EVERYBODY,$tutos[modok]);
 412          acl_save($x);
 413          $r .= $lang[$x->getType()].":". $x->getFullName() ."<br />\n";
 414          $demodata[] = &$x;
 415          unset($x);
 416      }
 417  }
 418  
 419  // adding some more locations
 420  foreach ($demodata as $i => $f) {
 421      if ( ($f->gettype() == "address")
 422           || ($f->gettype() == "company")
 423           || ($f->gettype() == "department")
 424          ) {
 425          $x = new location($this->obj);
 426          if ($f->gettype() == "company") {
 427              $x->company = &$f;
 428              $x->email_1 = $f->name."@tutos.xx";
 429          } else if ($f->gettype() == "address") {
 430              $x->company = &$comp[1];
 431              $x->email_1 = $f->l_name."@tutos.xx";
 432          }
 433          $x->lname = "Location";
 434          $x->city = "somewhere";
 435          $x->phone_1 = "+1 555 234762";
 436          $x->zip  = 91000+ $cnt;
 437          $x->country  = "DE";
 438          $x->adr_id  = $f->id;
 439          $x->ref  = &$f;
 440          $msg .= $x->save();
 441          acl_raise($x,EVERYBODY,$tutos[modok]);
 442          acl_save($x);
 443          $r .= $lang[$x->getType()].":". $x->lname ."<br />\n";
 444          $demodata[] = &$x;
 445          flush();
 446          unset($x);
 447          $cnt++;
 448      }
 449  }
 450  
 451  foreach ($demodata as $i => $f) {
 452      if ( ($f->gettype() == "product")
 453          ) {
 454          // Task
 455          $t1 = new task($this->obj);
 456          $t1->name = "Demo Task 1 /". $f->getFullName();
 457          $t1->description = "This is a task";
 458          $t1->creator = &$u[$cnt % $ucnt];
 459          $x = new TUTOS_Date_Time();
 460          $t1->setSStart($x);
 461          $x->addDays(3);
 462          $t1->setSEnd($x);
 463          $t1->volume = 12.5;
 464          $t1->state = 1;
 465          $t1->p_id = $f->id;
 466          $t1->parent = &$f;
 467          $t1->worker[$u[$cnt % $ucnt]->id] = $u[$cnt % $ucnt];
 468          $msg .= $t1->save();
 469          acl_raise($t1,EVERYBODY,$tutos[modok]);
 470          acl_save($t1);
 471          $r .= $lang[$t1->getType()].":". $t1->getFullName() ."<br />\n";
 472          $demodata[] = &$t1;
 473  
 474          $t2 = new task($this->obj);
 475          $t2->name = "Demo Task 2";
 476          $t2->description = "This is another task";
 477          $t2->creator = &$u[$cnt % $ucnt];
 478          $t2->volume = 2.5;
 479          $t2->state = 0;
 480          $t2->p_id = $f->id;
 481          $t2->parent = &$f;
 482          $t2->worker[$a[1]->id] = $a[1];
 483          $x = new TUTOS_Date_Time();
 484          $x->addDays(1);
 485          $t2->setSStart($x);
 486          $x->addDays(2);
 487          $t2->setSEnd($x);
 488          $msg .= $t2->save();
 489          acl_raise($t2,EVERYBODY,$tutos[modok]);
 490          acl_save($t2);
 491          $r .= $lang[$t2->getType()].":". $t2->getFullName() ."<br />\n";
 492          $demodata[] = &$t2;
 493  
 494          $t3 = new task($this->obj);
 495          $t3->name = "Demo Task 3";
 496          $t3->creator = &$u[$cnt % $ucnt];
 497          $t3->description = "a lot to do eh ?";
 498          $t3->volume = 14.5;
 499          $t3->state = 2;
 500          $t3->p_id = $t2->id;
 501          $t3->parent = &$t2;
 502          $t3->worker[$a[0]->id] = $a[0];
 503          $t3->worker[$a[1]->id] = $a[1];
 504          $x = new TUTOS_Date_Time();
 505          $x->addDays(2);
 506          $t3->setSStart($x);
 507          $x->addDays(2);
 508          $t3->setSEnd($x);
 509          $msg .= $t3->save();
 510          acl_raise($t3,EVERYBODY,$tutos[modok]);
 511          acl_save($t3);
 512          $r .= $lang[$t3->getType()].":". $t3->getFullName() ."<br />\n";
 513          $demodata[] = &$t3;
 514  
 515          unset($t1);
 516          unset($t2);
 517          unset($t3);
 518      }
 519  }
 520  // timetrack
 521  foreach ($demodata as $i => $f) {
 522      if ( ($f->gettype() == "product")
 523           || ($f->gettype() == "task")
 524          ) {
 525          // Timetrack
 526          $x = new timetrack($this->obj);
 527          $x->link_id = $f->id;
 528          $x->ref = $f;
 529          $x->worker= $a[$cnt % $acnt];
 530          $x->volume = 2 + ($cnt %7) * 0.25;
 531          $x->desc = "Working on ". $f->getFullName();
 532          $x->wday = new TUTOS_Date_Time();
 533          $x->state = ($cnt %4) + 1;
 534          $x->invoice = -1;
 535          $x->cph = 110.5 ;
 536          $x->currency = "EUR";
 537          $x->creator = $u[1];
 538          $msg .= $x->save();
 539          acl_raise($x,EVERYBODY,$tutos[modok]);
 540          acl_save($x);
 541          $r .= $lang[$x->getType()].":". $x->getFullName() ."<br />\n";
 542          $demodata[] = &$x;
 543          unset($x);
 544          $cnt++;
 545          flush();
 546      }
 547  }
 548  ?>

title

Description

title

Description

title

Description

title

title

Body