Group-Office PHP Cross Reference Groupware Applications

Source: /modules/demodata/controller/DemodataController.php - 1304 lines - 48605 bytes - Summary - Text - Print

   1  <?php
   2  class GO_Demodata_Controller_Demodata extends GO_Base_Controller_AbstractController {
   3      
   4  	protected function allowGuests() {
   5          return array('create');
   6      }
   7  
   8  	protected function actionCreate($params){
   9          
  10          
  11          if($this->isCli()){
  12              GO::session()->runAsRoot();
  13          }elseif(!GO::user()->isAdmin())
  14          {
  15              throw new GO_Base_Exception_AccessDenied();
  16          }
  17      
  18          
  19          if(GO::modules()->customfields){
  20              $customfieldModels = GO_Customfields_CustomfieldsModule::getCustomfieldModels();
  21  
  22              
  23              $types = GO_Customfields_CustomfieldsModule::getCustomfieldTypes();
  24              
  25              foreach($customfieldModels as $model){
  26              
  27  //                echo $model->getName(),'<br />';
  28                  $category = GO_Customfields_Model_Category::model()->createIfNotExists(GO::getModel($model->getName())->extendsModel(), "Demo Custom fields");
  29                  $category->acl->addGroup(GO::config()->group_internal, GO_Base_Model_Acl::WRITE_PERMISSION);
  30                  
  31                  if(strpos(GO::getModel($model->getName())->extendsModel(), 'Addresbook_')){
  32                      foreach($types as $t){
  33                          GO_Customfields_Model_Field::model()->createIfNotExists($category->id, $t['type'],array(
  34                                  'datatype'=>$t['className'],
  35                                  'helptext'=>($t['className']=="GO_Customfields_Customfieldtype_Text" ? "Some help text for this field" : "")
  36                                  ));
  37                      }
  38                  }else
  39                  {
  40                      GO_Customfields_Model_Field::model()->createIfNotExists($category->id, "Custom",array(
  41                                  'datatype'=>"GO_Customfields_Customfieldtype_Text",
  42                                  'helptext'=>"Some help text for this field"
  43                                  ));
  44                  }
  45              }
  46          }
  47          
  48  
  49  
  50          $addressbook = GO_Addressbook_Model_Addressbook::model()->findSingleByAttribute('name', GO::t('customers', 'addressbook'));
  51          if (!$addressbook) {
  52              $addressbook = new GO_Addressbook_Model_Addressbook();
  53              $addressbook->setAttributes(array(
  54                      'user_id' => 1,
  55                      'name' => GO::t('prospects', 'addressbook'),
  56                      //                'default_iso_address_format' => $default_language,
  57                      'default_salutation' => GO::t('defaultSalutation', 'addressbook')
  58              ));
  59              $addressbook->save();
  60              $addressbook->acl->addGroup(GO::config()->group_internal, GO_Base_Model_Acl::WRITE_PERMISSION);
  61          }
  62      
  63          $company = GO_Addressbook_Model_Company::model()->findSingleByAttribute('email', 'info@smith.demo');
  64          if (!$company) {
  65              $company = new GO_Addressbook_Model_Company();
  66              $company->setAttributes(array(
  67                      'addressbook_id' => $addressbook->id,
  68                      'name' => 'Smith Inc',
  69                      'address' => 'Kalverstraat',
  70                      'address_no' => '1',
  71                      'zip' => '1012 NX',
  72                      'city' => 'Amsterdam',
  73                      'state' => 'Noord-Holland',
  74                      'country' => 'NL',
  75                      'post_address' => 'Kalverstraat',
  76                      'post_address_no' => '1',
  77                      'post_zip' => '1012 NX',
  78                      'post_city' => 'Amsterdam',
  79                      'post_state' => 'Noord-Brabant',
  80                      'post_country' => 'NL',
  81                      'phone' => '+31 (0) 10 - 1234567',
  82                      'fax' => '+31 (0) 1234567',
  83                      'email' => 'info@smith.demo',
  84                      'homepage' => 'http://www.smith.demo',
  85                      'bank_no' => '',
  86                      'vat_no' => 'NL 1234.56.789.B01',
  87                      'user_id' => 1,
  88                      'comment' => 'Just a demo company'
  89              ));
  90              $company->save();
  91          }
  92  
  93          $john = GO_Addressbook_Model_Contact::model()->findSingleByAttribute('email', 'john@smith.demo');
  94          if (!$john) {
  95              $john = new GO_Addressbook_Model_Contact();
  96              $john->addressbook_id = $addressbook->id;
  97              $john->company_id = $company->id;
  98              $john->salutation = 'Dear Mr. Smith';
  99              $john->first_name = 'John';
 100              $john->last_name = 'Smith';
 101              $john->function = 'CEO';
 102              $john->cellular = '06-12345678';
 103              $john->email = 'john@smith.demo';
 104              $john->address = 'Kalverstraat';
 105              $john->address_no = '1';
 106              $john->zip = '1012 NX';
 107              $john->city = 'Amsterdam';
 108              $john->state = 'Noord-Holland';
 109              $john->country = 'NL';
 110              
 111              $john->url_facebook='http://www.facebook.com';
 112              $john->url_linkedin='http://www.linkedin.com';
 113              $john->url_twitter='http://www.twitter.com';
 114              $john->skype_name='echo123';
 115              
 116              $john->save();
 117              $john->setPhoto(new GO_Base_Fs_File(GO::modules()->addressbook->path . 'install/noperson.jpg'));
 118              $john->save();
 119          }
 120  
 121          $acme = GO_Addressbook_Model_Company::model()->findSingleByAttribute('email', 'info@acme.demo');
 122          if (!$acme) {
 123              $acme = new GO_Addressbook_Model_Company();
 124              $acme->setAttributes(array(
 125                      'addressbook_id' => $addressbook->id,
 126                      'name' => 'ACME Corporation',
 127                      'address' => '1111 Broadway',
 128                      'address_no' => '',
 129                      'zip' => '10019',
 130                      'city' => 'New York',
 131                      'state' => 'NY',
 132                      'country' => 'US',
 133                      'post_address' => '1111 Broadway',
 134                      'post_address_no' => '',
 135                      'post_zip' => '10019',
 136                      'post_city' => 'New York',
 137                      'post_state' => 'NY',
 138                      'post_country' => 'US',
 139                      'phone' => '(555) 123-4567',
 140                      'fax' => '(555) 123-4567',
 141                      'email' => 'info@acme.demo',
 142                      'homepage' => 'http://www.acme.demo',
 143                      'bank_no' => '',
 144                      'vat_no' => 'US 1234.56.789.B01',
 145                      'user_id' => 1,
 146                      'comment' => 'The name Acme became popular for businesses by the 1920s, when alphabetized business telephone directories such as the Yellow Pages began to be widespread. There were a flood of businesses named Acme (some of these still survive[1]). For example, early Sears catalogues contained a number of products with the "Acme" trademark, including anvils, which are frequently used in Warner Bros. cartoons.[2]'
 147              ));
 148              $acme->save();
 149  
 150              $acme->addComment("The company is never clearly defined in Road Runner cartoons but appears to be a conglomerate which produces every product type imaginable, no matter how elaborate or extravagant - none of which ever work as desired or expected. In the Road Runner cartoon Beep, Beep, it was referred to as \"Acme Rocket-Powered Products, Inc.\" based in Fairfield, New Jersey. Many of its products appear to be produced specifically for Wile E. Coyote; for example, the Acme Giant Rubber Band, subtitled \"(For Tripping Road Runners)\".");
 151              $acme->addComment("Sometimes, Acme can also send living creatures through the mail, though that isn't done very often. Two examples of this are the Acme Wild-Cat, which had been used on Elmer Fudd and Sam Sheepdog (which doesn't maul its intended victim); and Acme Bumblebees in one-fifth bottles (which sting Wile E. Coyote). The Wild Cat was used in the shorts Don't Give Up the Sheep and A Mutt in a Rut, while the bees were used in the short Zoom and Bored.");
 152          }
 153          $wile = GO_Addressbook_Model_Contact::model()->findSingleByAttribute('email', 'wile@acme.demo');
 154          if (!$wile) {
 155              $wile = new GO_Addressbook_Model_Contact();
 156              $wile->addressbook_id = $addressbook->id;
 157              $wile->company_id = $acme->id;
 158              $wile->salutation = 'Dear Mr. Coyote';
 159              $wile->first_name = 'Wile';
 160              $wile->middle_name = 'E.';
 161              $wile->last_name = 'Coyote';
 162              $wile->function = 'CEO';
 163              $wile->cellular = '06-12345678';
 164              $wile->email = 'wile@acme.demo';
 165              $wile->address = '1111 Broadway';
 166              $wile->address_no = '';
 167              $wile->zip = '10019';
 168              $wile->city = 'New York';
 169              $wile->state = 'NY';
 170              $wile->country = 'US';
 171              
 172              $wile->url_facebook='http://www.facebook.com';
 173              $wile->url_linkedin='http://www.linkedin.com';
 174              $wile->url_twitter='http://www.twitter.com';
 175              $wile->skype_name='test';
 176  
 177              $wile->save();
 178              $wile->setPhoto(new GO_Base_Fs_File(GO::modules()->addressbook->path . 'install/wecoyote.png'));
 179              $wile->save();
 180  
 181              $wile->addComment("Wile E. Coyote (also known simply as \"The Coyote\") and The Road Runner are a duo of cartoon characters from a series of Looney Tunes and Merrie Melodies cartoons. The characters (a coyote and Greater Roadrunner) were created by animation director Chuck Jones in 1948 for Warner Bros., while the template for their adventures was the work of writer Michael Maltese. The characters star in a long-running series of theatrical cartoon shorts (the first 16 of which were written by Maltese) and occasional made-for-television cartoons.");
 182  
 183              $wile->addComment("In each episode, instead of animal senses and cunning, Wile E. Coyote uses absurdly complex contraptions (sometimes in the manner of Rube Goldberg) and elaborate plans to pursue his quarry. It was originally meant to parody chase cartoons like Tom and Jerry, but became popular in its own right, much to Jones' chagrin.");
 184  
 185              $file = new GO_Base_Fs_File(GO::modules()->addressbook->path . 'install/Demo letter.docx');
 186              $copy = $file->copy($wile->filesFolder->fsFolder);
 187  
 188              $wile->filesFolder->addFile($copy->name());
 189          }
 190  
 191  
 192          $internalUserGroup = GO_Base_Model_Group::model()->findByPk(GO::config()->group_internal);
 193          
 194  
 195          GO::config()->password_validate=false;
 196  
 197          $elmer = GO_Base_Model_User::model()->findSingleByAttribute('username', 'elmer');
 198          if (!$elmer) {
 199              $elmer = new GO_Base_Model_User();
 200              $elmer->username = 'elmer';
 201              $elmer->first_name = 'Elmer';
 202              $elmer->last_name = 'Fudd';
 203              $elmer->email = 'elmer@acmerpp.demo';
 204              $elmer->password='demo';
 205              if ($elmer->save()) {
 206                  
 207                  //make sure he's member of the internal group.
 208                  $internalUserGroup->addUser($elmer->id);
 209                  
 210                  $this->_setUserContact($elmer);
 211                  $elmer->checkDefaultModels();
 212              }else
 213              {
 214                  var_dump($elmer->getValidationErrors());
 215                  exit();
 216              }
 217          }
 218          
 219  
 220  
 221  
 222          $demo = GO_Base_Model_User::model()->findSingleByAttribute('username', 'demo');
 223          if (!$demo) {
 224              $demo = new GO_Base_Model_User();
 225              $demo->username = 'demo';
 226              $demo->first_name = 'Demo';
 227              $demo->last_name = 'User';
 228              $demo->email = 'demo@acmerpp.demo';
 229              $demo->password='demo';
 230              if ($demo->save()) {
 231                  
 232                  //make sure he's member of the internal group.
 233                  $internalUserGroup->addUser($demo->id);
 234                  
 235                  $this->_setUserContact($demo);
 236                  $demo->checkDefaultModels();
 237              }else
 238              {
 239                  var_dump($demo->getValidationErrors());
 240                  exit();
 241              }
 242          }
 243  
 244  
 245          $linda = GO_Base_Model_User::model()->findSingleByAttribute('username', 'linda');
 246          if (!$linda) {
 247              $linda = new GO_Base_Model_User();
 248              $linda->username = 'linda';
 249              $linda->first_name = 'Linda';
 250              $linda->last_name = 'Smith';
 251              $linda->email = 'linda@acmerpp.demo';
 252              $linda->password='demo';
 253                              
 254              if ($linda->save()) {
 255                  
 256                  //make sure she's member of the internal group.
 257                  $internalUserGroup->addUser($linda->id);
 258                  
 259                  $this->_setUserContact($linda);
 260                  $linda->checkDefaultModels();
 261              }else
 262              {
 263                  var_dump($linda->getValidationErrors());
 264                  exit();
 265              }
 266          }
 267  
 268          if (GO::modules()->calendar) {
 269              
 270              //share calendars
 271              GO_Calendar_Model_Calendar::model()->getDefault($demo)->acl->addGroup(GO::config()->group_internal, GO_Base_Model_Acl::READ_PERMISSION);
 272              GO_Calendar_Model_Calendar::model()->getDefault($elmer)->acl->addGroup(GO::config()->group_internal,GO_Base_Model_Acl::READ_PERMISSION);
 273              GO_Calendar_Model_Calendar::model()->getDefault($linda)->acl->addGroup(GO::config()->group_internal,GO_Base_Model_Acl::READ_PERMISSION);
 274  
 275              $events = array(
 276                      array('Project meeting', 10),
 277                      array('Meet Wile', 12),
 278                      array('MT Meeting', 14)
 279              );
 280              
 281              //start on tuesday.
 282              $time = GO_Base_Util_Date::date_add(GO_Base_Util_Date::get_last_sunday(time()),2);
 283  
 284              foreach ($events as $e) {
 285                  $event = new GO_Calendar_Model_Event();
 286                  $event->name = $e[0];
 287                  $event->location = "ACME NY Office";
 288                  $event->start_time = GO_Base_Util_Date::clear_time($time, $e[1]);
 289                  $event->end_time = $event->start_time + 3600;
 290                  $event->user_id = $demo->id;
 291                  $event->calendar_id = GO_Calendar_Model_Calendar::model()->getDefault($demo)->id;
 292                  $event->save();
 293  
 294                  $participant = new GO_Calendar_Model_Participant();
 295                  $participant->is_organizer = true;
 296                  $participant->setContact($demo->createContact());
 297                  $event->addParticipant($participant);
 298  
 299                  $participant = new GO_Calendar_Model_Participant();
 300                  $participant->setContact($linda->createContact());
 301                  $event->addParticipant($participant);
 302  
 303                  $participant = new GO_Calendar_Model_Participant();
 304                  $participant->setContact($elmer->createContact());
 305                  $event->addParticipant($participant);
 306  
 307  
 308                  $participant = new GO_Calendar_Model_Participant();
 309                  $participant->setContact($wile);
 310                  $event->addParticipant($participant);
 311  
 312                  $wile->link($event);
 313              }
 314  
 315              
 316  
 317              $events = array(
 318                      array('Project meeting', 11),
 319                      array('Meet John', 13),
 320                      array('MT Meeting', 16)
 321              );
 322  
 323              foreach ($events as $e) {
 324                  $event = new GO_Calendar_Model_Event();
 325                  $event->name = $e[0];
 326                  $event->location = "ACME NY Office";
 327                  $event->start_time = GO_Base_Util_Date::date_add(GO_Base_Util_Date::clear_time($time, $e[1]), 1);
 328                  $event->end_time = $event->start_time + 3600;
 329                  $event->user_id = $linda->id;
 330                  $event->calendar_id = GO_Calendar_Model_Calendar::model()->getDefault($linda)->id;
 331                  $event->save();
 332  
 333                  $participant = new GO_Calendar_Model_Participant();
 334                  $participant->is_organizer = true;
 335                  $participant->setContact($linda->createContact());
 336                  $event->addParticipant($participant);
 337  
 338  
 339                  $participant = new GO_Calendar_Model_Participant();
 340                  $participant->setContact($demo->createContact());
 341                  $event->addParticipant($participant);
 342  
 343  
 344                  $participant = new GO_Calendar_Model_Participant();
 345                  $participant->setContact($john);
 346                  $event->addParticipant($participant);
 347  
 348                  $john->link($event);
 349              }
 350              
 351              
 352              
 353              $events = array(
 354                      array('Rocket testing', 8),
 355                      array('Blast impact test', 15),
 356                      array('Test range extender', 19)
 357              );
 358  
 359              foreach ($events as $e) {
 360                  $event = new GO_Calendar_Model_Event();
 361                  $event->name = $e[0];
 362                  $event->location = "ACME Testing fields";
 363                  $event->start_time = GO_Base_Util_Date::date_add(GO_Base_Util_Date::clear_time(time(), $e[1]), 1);
 364                  $event->end_time = $event->start_time + 3600;
 365                  $event->user_id = $linda->id;
 366                  $event->calendar_id = GO_Calendar_Model_Calendar::model()->getDefault($linda)->id;
 367                  $event->save();
 368  
 369                  $participant = new GO_Calendar_Model_Participant();
 370                  $participant->is_organizer = true;
 371                  $participant->setContact($linda->createContact());
 372                  $event->addParticipant($participant);
 373  
 374  
 375                  $participant = new GO_Calendar_Model_Participant();
 376                  $participant->setContact($demo->createContact());
 377                  $event->addParticipant($participant);
 378  
 379  
 380                  $participant = new GO_Calendar_Model_Participant();
 381                  $participant->setContact($john);
 382                  $event->addParticipant($participant);
 383  
 384                  $john->link($event);
 385              }
 386              
 387              
 388              $view = new GO_Calendar_Model_View();
 389              $view->name=GO::t('group_everyone');
 390              if($view->save()){
 391                  $view->addManyMany('groups', GO::config()->group_everyone);
 392              
 393                  //share view
 394                  $view->acl->addGroup(GO::config()->group_internal);
 395              }
 396              
 397              
 398              $view = new GO_Calendar_Model_View();
 399              $view->name=GO::t('group_everyone').' ('.GO::t('merge', 'calendar').')';
 400              $view->merge=true;
 401              $view->owncolor=true;
 402              if($view->save()){
 403                  $view->addManyMany('groups', GO::config()->group_everyone);
 404              
 405                  //share view
 406                  $view->acl->addGroup(GO::config()->group_internal);
 407              }
 408              
 409              
 410              //resource groups
 411              $resourceGroup = GO_Calendar_Model_Group::model()->findSingleByAttribute('name', "Meeting rooms");
 412              if(!$resourceGroup){
 413                  $resourceGroup = new GO_Calendar_Model_Group();
 414                  $resourceGroup->name="Meeting rooms";
 415                  $resourceGroup->save();
 416                  
 417                  //$resourceGroup->acl->addGroup(GO::config()->group_internal);
 418                                  
 419              }
 420              
 421              $resourceCalendar = GO_Calendar_Model_Calendar::model()->findSingleByAttribute('name', 'Road Runner Room');
 422              if(!$resourceCalendar){
 423                  $resourceCalendar = new GO_Calendar_Model_Calendar();
 424                  $resourceCalendar->group_id=$resourceGroup->id;
 425                  $resourceCalendar->name='Road Runner Room';
 426                  $resourceCalendar->save();
 427                  $resourceCalendar->acl->addGroup(GO::config()->group_internal);
 428              }
 429              
 430              $resourceCalendar = GO_Calendar_Model_Calendar::model()->findSingleByAttribute('name', 'Don Coyote Room');
 431              if(!$resourceCalendar){
 432                  $resourceCalendar = new GO_Calendar_Model_Calendar();
 433                  $resourceCalendar->group_id=$resourceGroup->id;
 434                  $resourceCalendar->name='Don Coyote Room';
 435                  $resourceCalendar->save();
 436                  $resourceCalendar->acl->addGroup(GO::config()->group_internal);
 437              }
 438              
 439              
 440              //setup elmer as a resource admin
 441              $resourceGroup->addManyMany('admins', $elmer->id);
 442              
 443              
 444          }
 445          
 446          if(GO::modules()->tasks){            
 447              $task = new GO_Tasks_Model_Task();
 448              $task->tasklist_id=  GO_Tasks_Model_Tasklist::model()->getDefault($demo)->id;
 449              $task->name='Feed the dog';
 450              $task->start_time=time();
 451              $task->due_time=GO_Base_Util_Date::date_add(time(),2);
 452              $task->save();            
 453              
 454              
 455              $task = new GO_Tasks_Model_Task();
 456              $task->tasklist_id=  GO_Tasks_Model_Tasklist::model()->getDefault($linda)->id;
 457              $task->name='Feed the dog';
 458              $task->start_time=time();
 459              $task->due_time=GO_Base_Util_Date::date_add(time(),1);
 460              $task->save();            
 461              
 462              $task = new GO_Tasks_Model_Task();
 463              $task->tasklist_id=  GO_Tasks_Model_Tasklist::model()->getDefault($elmer)->id;
 464              $task->name='Feed the dog';
 465              $task->start_time=time();
 466              $task->due_time=GO_Base_Util_Date::date_add(time(),1);
 467              $task->save();
 468              
 469              
 470              
 471              $task = new GO_Tasks_Model_Task();
 472              $task->tasklist_id=  GO_Tasks_Model_Tasklist::model()->getDefault($demo)->id;
 473              $task->name='Prepare meeting';
 474              $task->start_time=time();
 475              $task->due_time=GO_Base_Util_Date::date_add(time(),1);
 476              $task->save();            
 477              $task->link($wile);
 478              $task->link($event);
 479              
 480              
 481              $task = new GO_Tasks_Model_Task();
 482              $task->tasklist_id=  GO_Tasks_Model_Tasklist::model()->getDefault($linda)->id;
 483              $task->name='Prepare meeting';
 484              $task->start_time=time();
 485              $task->due_time=GO_Base_Util_Date::date_add(time(),1);
 486              $task->save();            
 487              $task->link($wile);
 488              $task->link($event);
 489              
 490              $task = new GO_Tasks_Model_Task();
 491              $task->tasklist_id=  GO_Tasks_Model_Tasklist::model()->getDefault($elmer)->id;
 492              $task->name='Prepare meeting';
 493              $task->start_time=time();
 494              $task->due_time=GO_Base_Util_Date::date_add(time(),1);
 495              $task->save();
 496              $task->link($wile);
 497              $task->link($event);
 498          }
 499          
 500  
 501          if(GO::modules()->billing){        
 502              
 503              $rocket = GO_Billing_Model_Product::model()->findSingleByAttribute('article_id', '12345');
 504              if (!$rocket) {
 505                  $rocket = new GO_Billing_Model_Product();
 506                  $rocket->article_id=12345;
 507                  $rocket->supplier_company_id=$acme->id;
 508                  $rocket->unit='pcs';
 509                  $rocket->cost_price=1000;
 510                  $rocket->list_price=2999.99;
 511                  $rocket->total_price=2999.99;
 512                  $rocket->vat=0;
 513                  if(!$rocket->save())
 514                      var_dump($rocket->getValidationErrors ());
 515              
 516              
 517              
 518              
 519                  $lang = new GO_Billing_Model_ProductLanguage();
 520                  $lang->language_id=1;
 521                  $lang->product_id=$rocket->id;
 522                  $lang->name='Master Rocket 1000';
 523                  $lang->description='Master Rocket 1000. The ultimate rocket to blast rocky mountains.';
 524                  $lang->save();
 525              }
 526              
 527              $rocketLauncher = GO_Billing_Model_Product::model()->findSingleByAttribute('article_id', '234567');
 528              if (!$rocketLauncher) {
 529                  $rocketLauncher = new GO_Billing_Model_Product();
 530                  $rocketLauncher->article_id=234567;
 531                  $rocketLauncher->supplier_company_id=$acme->id;
 532                  $rocketLauncher->unit='pcs';
 533                  $rocketLauncher->cost_price=3000;
 534                  $rocketLauncher->list_price=8999.99;
 535                  $rocketLauncher->total_price=8999.99;
 536                  $rocketLauncher->vat=0;
 537                  if(!$rocketLauncher->save())
 538                      var_dump($rocket->getValidationErrors ());
 539  
 540  
 541  
 542                  $lang = new GO_Billing_Model_ProductLanguage();
 543                  $lang->language_id=1;
 544                  $lang->product_id=$rocketLauncher->id;
 545                  $lang->name='Rocket Launcher 1000';
 546                  $lang->description='Rocket Launcher 1000. Required to launch rockets.';
 547                  $lang->save();
 548              }
 549              
 550              
 551              $books = GO_Billing_Model_Book::model()->find();
 552              foreach($books as $book){            
 553                  
 554                  //give demo access
 555                  $book->acl->addUser($demo->id, GO_Base_Model_Acl::WRITE_PERMISSION);
 556                  $book->acl->addUser($elmer->id, GO_Base_Model_Acl::WRITE_PERMISSION);
 557                  
 558                  
 559                  $order = new GO_Billing_Model_Order();
 560                  $order->book_id=$book->id;
 561                  $order->btime=time();
 562                  $order->setCustomerFromContact($john);            
 563                  $order->setCustomerFromCompany($company);            
 564                  $order->save();
 565  
 566                  $order->addProduct($rocketLauncher, 1);
 567                  $order->addProduct($rocket, 4);
 568                  
 569                  $status = $book->statuses(GO_Base_Db_FindParams::newInstance()->single());
 570                  $order->status_id=$status->id;
 571                  $order->syncItems();
 572                  
 573                  
 574                  
 575                  $order = new GO_Billing_Model_Order();
 576                  $order->book_id=$book->id;
 577                  $order->btime=time();
 578                  $order->setCustomerFromContact($wile);            
 579                  $order->setCustomerFromCompany($acme);            
 580                  $order->save();
 581  
 582                  $order->addProduct($rocketLauncher, 1);
 583                  $order->addProduct($rocket, 10);
 584                  
 585                  $status = $book->statuses(GO_Base_Db_FindParams::newInstance()->single());
 586                  $order->status_id=$status->id;
 587                  $order->syncItems();
 588              }            
 589          }
 590          
 591          if(GO::modules()->tickets){    
 592              $ticket = new GO_Tickets_Model_Ticket();
 593              $ticket->subject='Malfunctioning rockets';
 594              $ticket->setFromContact($wile);
 595              if(!$ticket->save()){
 596                  var_dump($ticket->getValidationErrors());
 597                  exit();
 598              }
 599              
 600              $message = new GO_Tickets_Model_Message();
 601              $message->sendEmail=false;
 602              $message->content="My rocket always circles back right at me? How do I aim right?";
 603              $message->is_note=false;            
 604              $message->user_id=0;
 605              $ticket->addMessage($message);
 606              
 607              //elmer picks up the ticket
 608              $ticket->agent_id=$elmer->id;
 609              $ticket->save();
 610              
 611              //make elmer and demo a ticket agent
 612              $ticket->type->acl->addUser($elmer->id, GO_Base_Model_Acl::MANAGE_PERMISSION);
 613              $ticket->type->acl->addUser($demo->id, GO_Base_Model_Acl::MANAGE_PERMISSION);
 614              
 615              
 616              $message = new GO_Tickets_Model_Message();
 617              $message->sendEmail=false;
 618              $message->content="Haha, good thing he doesn't know Accelleratii Incredibus designed this rocket and he can't read this note.";
 619              $message->is_note=true;        
 620              $message->user_id=$elmer->id;
 621              $ticket->addMessage($message);
 622              
 623              
 624              $message = new GO_Tickets_Model_Message();
 625              $message->sendEmail=false;
 626              $message->content="Gee I don't know how that can happen. I'll send you some new ones!";
 627              $message->is_note=false;            
 628              $message->status_id=GO_Tickets_Model_Ticket::STATUS_CLOSED;
 629              $message->has_status=true;
 630              $message->user_id=$elmer->id;
 631              $ticket->addMessage($message);            
 632              
 633              
 634              
 635              
 636              
 637              $ticket = new GO_Tickets_Model_Ticket();
 638              $ticket->subject='Can I speed up my rockets?';
 639              $ticket->setFromContact($wile);
 640              $ticket->ctime=$ticket->mtime=GO_Base_Util_Date::date_add(time(), -2);
 641              
 642              if(!$ticket->save()){
 643                  var_dump($ticket->getValidationErrors());
 644                  exit();
 645              }
 646              
 647              $message = new GO_Tickets_Model_Message();
 648              $message->sendEmail=false;
 649              $message->content="The rockets are too slow to hit my fast moving target. Is there a way to speed them up?";
 650              $message->is_note=false;            
 651              $message->user_id=0;
 652              $message->ctime=$message->mtime=GO_Base_Util_Date::date_add(time(), -2);
 653              $ticket->addMessage($message);
 654              
 655              //elmer picks up the ticket
 656  //            $ticket->agent_id=$elmer->id;
 657  //            $ticket->save();
 658              
 659          
 660              
 661              
 662              $message = new GO_Tickets_Model_Message();
 663              $message->sendEmail=false;
 664              $message->content="Please respond faster. Can't you see this ticket is marked in red?";
 665              $message->is_note=false;            
 666              $message->user_id=0;
 667              $ticket->addMessage($message);    
 668              
 669              
 670              if(!GO::modules()->isInstalled('site') && GO::modules()->isAvailable('site')){
 671                  $module = new GO_Base_Model_Module();
 672                  $module->id='site';            
 673                  $module->save();
 674              }
 675              
 676              if(!GO::modules()->isInstalled('defaultsite') && GO::modules()->isAvailable('defaultsite')){
 677                  $module = new GO_Base_Model_Module();
 678                  $module->id='defaultsite';            
 679                  $module->save();
 680              }
 681              
 682              $settings = GO_Tickets_Model_Settings::model()->findModel();
 683              $settings->enable_external_page=true;
 684              $settings->use_alternative_url=true;
 685              $settings->allow_anonymous=true;
 686              $settings->alternative_url = GO::config()->full_url.'modules/site/index.php?r=tickets/externalpage/ticket';
 687              $settings->save();
 688              
 689              
 690              if(GO::modules()->summary){
 691                  
 692                  $title = "Submit support ticket";
 693              
 694                  $announcement = GO_Summary_Model_Announcement::model()->findSingleByAttribute('title',$title);
 695                  if(!$announcement){
 696  
 697  
 698                      $newTicketUrl = GO::config()->full_url.'modules/site/index.php?r=tickets/externalpage/newTicket';
 699  
 700                      $announcement = new GO_Summary_Model_Announcement();
 701                      $announcement->title=$title;
 702                      $announcement->content='Anyone can submit tickets to the support system here:'.
 703                                      '<br /><br /><a href="'.$newTicketUrl.'">'.$newTicketUrl.'</a><br /><br />Anonymous ticket posting can be disabled in the ticket module settings.';
 704  
 705                      if($announcement->save()){            
 706                          $announcement->acl->addGroup(GO::config()->group_everyone);
 707                      }
 708                  }
 709              }
 710              
 711          }
 712          
 713          
 714          if(GO::modules()->notes){
 715              
 716              $category = GO_Notes_Model_Category::model()->findSingleByAttribute('name', GO::t('general','notes'));
 717              
 718              if(!$category){
 719                  $category = new GO_Notes_Model_Category();
 720                  $category->name=GO::t('general','notes');
 721                  $category->save();
 722                  $category->acl->addGroup(GO::config()->group_everyone, GO_Base_Model_Acl::READ_PERMISSION);
 723              }
 724              
 725              
 726              $note = new GO_Notes_Model_Note();
 727              $note->user_id=$elmer->id;            
 728              
 729              //$category = GO_Notes_Model_Category::model()->getDefault($elmer);
 730              
 731              $note->category_id=$category->id;
 732              
 733              $note->name="Laws and rules";
 734              $note->content='As in other cartoons, the Road Runner and the coyote follow the laws of cartoon physics. For example, the Road Runner has the ability to enter the painted image of a cave, while the coyote cannot (unless there is an opening through which he can fall). Sometimes, however, this is reversed, and the Road Runner can burst through a painting of a broken bridge and continue on his way, while the Coyote will instead enter the mirage painting and fall down the precipice of the cliff where the bridge is out. Sometimes the coyote is allowed to hang in midair until he realizes that he is about to plummet into a chasm (a process occasionally referred to elsewhere as Road-Runnering or Wile E. Coyote moment). The coyote can overtake rocks (or cannons) which fall earlier than he does, and end up being squashed by them. If a chase sequence happens upon a cliff, the Road Runner is not affected by gravity, whereas the Coyote will realize his error eventually and fall to the ground below. A chase sequence that happens upon railroad tracks will always result in the Coyote being run over by a train. If the Coyote uses an explosive (for instance, dynamite) that is triggered by a mechanism that is supposed to force the explosive in a forward motion toward its target, the actual mechanism itself will always shoot forward, leaving the explosive behind to detonate in the Coyote\'s face. Similarly, a complex apparatus that is supposed to propel an object like a boulder or steel ball forward, or trigger a trap, will not work on the Road Runner, but always will on the Coyote. For instance, the Road Runner can jump up and down on the trigger of a large animal trap and eat bird seed off from it, going completely unharmed and not setting off the trap; when the Coyote places the tiniest droplet of oil on the trigger, the trap snaps shut on him without fail. At certain times, the Coyote may don an exquisite Acme costume or propulsion device that briefly allows him to catch up to the Road Runner. This will always result in him losing track of his proximity to large cliffs or walls, and the Road Runner will dart around an extremely sharp turn on a cliff, but the Coyote will rocket right over the edge and fall to the ground.
 735  
 736  In his book Chuck Amuck: The Life and Times Of An Animated Cartoonist,[13] Chuck Jones claimed that he and the artists behind the Road Runner and Wile E. cartoons adhered to some simple but strict rules:
 737  
 738  The Road Runner cannot harm the Coyote except by going "beep, beep."
 739  No outside force can harm the Coyote — only his own ineptitude or the failure of Acme products. Trains and trucks were the exception from time to time.
 740  The Coyote could stop anytime — if he were not a fanatic. (Repeat: "A fanatic is one who redoubles his effort when he has forgotten his aim." — George Santayana).
 741  Dialogue must never be used, except "beep, beep" and yowling in pain. (This rule, however, was violated in some cartoons.)
 742  The Road Runner must stay on the road — for no other reason than that he\'s a roadrunner. This rule was broken in Beep, Beep, in a sequence where Wile E. chased the Road Runner into a cactus mine. And also in Fastest with the Mostestwhen Coyote lures Road Runner to the edge of a cliff.
 743  All action must be confined to the natural environment of the two characters — the southwest American desert.
 744  All (or at least almost all) tools, weapons, or mechanical conveniences must be obtained from the Acme Corporation. There were sometimes exceptions when the Coyote obtained other items from the desert such as boulders to use in his attempts.
 745  Whenever possible, make gravity the Coyote\'s greatest enemy (e.g., falling off a cliff).
 746  The Coyote is always more humiliated than harmed by his failures.
 747  The audience\'s sympathy must remain with the Coyote.
 748  The Coyote is not allowed to catch or eat the Road Runner, unless he escapes from the grasp. (The robot that the Coyote created in The Solid Tin Coyote caught the Road Runner so this does not break this rule. The Coyote does catch the Road Runner in Soup or Sonic but is too small to eat him. There is also two CGI shorts on The Looney Tunes Show were he caught the bird, but was not able to eat him because the Road Runner got away in both shorts.)';
 749              
 750              $note->save();
 751              $note->link($john);
 752              
 753              
 754              $note = new GO_Notes_Model_Note();
 755              $note->user_id=$demo->id;            
 756              
 757              $note->category_id=$category->id;
 758              
 759              $note->name="Wile E. Coyote and Bugs Bunny";
 760              $note->content='Wile E. Coyote has also unsuccessfully attempted to catch and eat Bugs Bunny in another series of cartoons. In these cartoons, the coyote takes on the guise of a self-described "super genius" and speaks with a smooth, generic upper-class accent provided by Mel Blanc. While he is incredibly intelligent, he is limited by technology and his own short-sighted arrogance, and is thus often easily outsmarted, a somewhat physical symbolism of "street smarts" besting "book smarts".
 761  
 762  In one short (Hare-Breadth Hurry, 1963), Bugs Bunny — with the help of "speed pills" — even stands in for Road Runner, who has "sprained a giblet", and carries out the duties of outsmarting the hungry scavenger. That is the only Bugs Bunny/Wile E. Coyote short in which the coyote does not speak. As usual Wile E. Coyote ends up falling down a canyon. In a later, made-for-TV short, which had a young Elmer Fudd chasing a young Bugs Bunny, Elmer also falls down a canyon. On the way down he is overtaken by Wile E. Coyote who shows a sign telling Elmer to get out of the way for someone who is more experienced in falling.';
 763              
 764              $note->save();
 765              
 766              $note->link($wile);
 767          }
 768          
 769          
 770          if(GO::modules()->summary){
 771              $title = "Welcome to ".GO::config()->product_name;
 772              
 773              $announcement = GO_Summary_Model_Announcement::model()->findSingleByAttribute('title',$title);
 774              if(!$announcement){
 775                  $announcement = new GO_Summary_Model_Announcement();
 776                  $announcement->title=$title;
 777                  $announcement->content='This is a demo announcements that administrators can set.<br />Have a look around.<br /><br />We hope you\'ll enjoy Group-Office as much as we do!';
 778  
 779                  if($announcement->save()){            
 780                      $announcement->acl->addGroup(GO::config()->group_everyone);
 781                  }
 782              }
 783          }
 784          
 785          
 786          if(GO::modules()->files){
 787              
 788              $demoHome = GO_Files_Model_Folder::model()->findHomeFolder($demo);
 789              $file = new GO_Base_Fs_File(GO::modules()->files->path.'install/templates/empty.docx');
 790              $copy = $file->copy($demoHome->fsFolder);
 791              
 792              $file = new GO_Base_Fs_File(GO::modules()->files->path.'install/templates/empty.odt');
 793              $copy = $file->copy($demoHome->fsFolder);
 794              
 795              
 796              $file = new GO_Base_Fs_File(GO::modules()->addressbook->path . 'install/Demo letter.docx');
 797              $copy = $file->copy($demoHome->fsFolder);
 798              
 799              
 800              $file = new GO_Base_Fs_File(GO::modules()->addressbook->path . 'install/wecoyote.png');
 801              $copy = $file->copy($demoHome->fsFolder);
 802              
 803              $file = new GO_Base_Fs_File(GO::modules()->addressbook->path . 'install/noperson.jpg');
 804              $copy = $file->copy($demoHome->fsFolder);
 805              
 806              //add files to db.
 807              $demoHome->syncFilesystem();
 808              
 809              
 810          }
 811          
 812          
 813          if(GO::modules()->projects){
 814              
 815              $templates = GO_Projects_Model_Template::model()->find();
 816              
 817              $folderTemplate = $templates->fetch();
 818              $projectTemplate = $templates->fetch();
 819              
 820              $status = GO_Projects_Model_Status::model()->findSingle();
 821              
 822              $type = GO_Projects_Model_Type::model()->findSingleByAttribute('name', 'Demo');
 823              if(!$type){
 824                  $type = new GO_Projects_Model_Type();
 825                  $type->name='Demo';
 826                  if(!$type->save())
 827                  {
 828                      var_dump($type->getValidationErrors());
 829                      exit();
 830                  }
 831                  $type->acl->addGroup(GO::config()->group_internal, GO_Base_Model_Acl::WRITE_PERMISSION);
 832              }
 833              
 834              
 835              $folderProject = GO_Projects_Model_Project::model()->findSingleByAttribute('name','Demo');
 836              if(!$folderProject){
 837                  $folderProject = new GO_Projects_Model_Project();
 838                  $folderProject->name='Demo';
 839                  $folderProject->description='Just a placeholder for sub projects.';
 840                  $folderProject->template_id=$folderTemplate->id;
 841                  $folderProject->type_id=$type->id;
 842                  $folderProject->status_id=$status->id;
 843                  if(!$folderProject->save()){
 844                          var_dump($folderProject->getValidationErrors());
 845                      exit();
 846                  }
 847                  
 848              }
 849              
 850              
 851              $rocketProject = GO_Projects_Model_Project::model()->findSingleByAttribute('name','[001] Develop Rocket 2000');
 852              if(!$rocketProject){
 853                  $rocketProject = new GO_Projects_Model_Project();
 854                  $rocketProject->type_id=$type->id;
 855                  $rocketProject->status_id=$status->id;
 856                  $rocketProject->name='[001] Develop Rocket 2000';
 857                  $rocketProject->description='Better range and accuracy';
 858                  $rocketProject->template_id=$projectTemplate->id;
 859                  $rocketProject->parent_project_id=$folderProject->id;
 860                  $rocketProject->start_time=time();
 861                  $rocketProject->due_time=GO_Base_Util_Date::date_add(time(),0,1);
 862                  $rocketProject->company_id=$acme->id;
 863                  $rocketProject->contact_id=$wile->id;
 864                  $rocketProject->save();
 865              }
 866              
 867              $launcherProject = GO_Projects_Model_Project::model()->findSingleByAttribute('name','[001] Develop Rocket Launcher');
 868              if(!$launcherProject){
 869                  $launcherProject = new GO_Projects_Model_Project();
 870                  $launcherProject->type_id=$type->id;
 871                  $launcherProject->status_id=$status->id;
 872                  $launcherProject->name='[001] Develop Rocket Launcher';
 873                  $launcherProject->description='Better range and accuracy';
 874                  $launcherProject->template_id=$projectTemplate->id;
 875                  $launcherProject->parent_project_id=$folderProject->id;
 876                  $launcherProject->start_time=time();
 877                  $launcherProject->due_time=GO_Base_Util_Date::date_add(time(),0,1);
 878                  $launcherProject->company_id=$acme->id;
 879                  $launcherProject->contact_id=$wile->id;
 880                  $launcherProject->save();
 881              }
 882              
 883          }
 884          
 885          
 886          
 887          
 888              
 889          if(GO::modules()->projects2){
 890              
 891              $employee = new GO_Projects2_Model_Employee();
 892              $employee->user_id=$elmer->id;
 893              $employee->external_fee=120;
 894              $employee->internal_fee=60;
 895              $employee->save();
 896              
 897              $employee = new GO_Projects2_Model_Employee();
 898              $employee->user_id=$demo->id;
 899              $employee->external_fee=80;
 900              $employee->internal_fee=40;
 901              $employee->save();
 902              
 903              $employee = new GO_Projects2_Model_Employee();
 904              $employee->user_id=$linda->id;
 905              $employee->external_fee=90;
 906              $employee->internal_fee=45;
 907              $employee->save();
 908              
 909              
 910              $templates = GO_Projects2_Model_Template::model()->find();
 911              
 912              $folderTemplate = $templates->fetch();
 913              $projectTemplate = $templates->fetch();
 914              
 915              $status = GO_Projects2_Model_Status::model()->findSingle();
 916              
 917              $type = GO_Projects2_Model_Type::model()->findSingleByAttribute('name', 'Demo');
 918              if(!$type){
 919                  $type = new GO_Projects2_Model_Type();
 920                  $type->name='Demo';
 921                  if(!$type->save())
 922                  {
 923                      var_dump($type->getValidationErrors());
 924                      exit();
 925                  }
 926                  $type->acl->addGroup(GO::config()->group_internal, GO_Base_Model_Acl::WRITE_PERMISSION);
 927              }
 928              
 929              
 930              $folderProject = GO_Projects2_Model_Project::model()->findSingleByAttribute('name','Demo');
 931              if(!$folderProject){
 932                  $folderProject = new GO_Projects2_Model_Project();
 933                  $folderProject->name='Demo';
 934                  $folderProject->start_time=time();
 935                  $folderProject->description='Just a placeholder for sub projects.';
 936                  $folderProject->template_id=$folderTemplate->id;
 937                  $folderProject->type_id=$type->id;
 938                  $folderProject->status_id=$status->id;
 939                  if(!$folderProject->save()){
 940                          var_dump($folderProject->getValidationErrors());
 941                      exit();
 942                  }
 943                  
 944              }
 945              
 946              
 947              $rocketProject = GO_Projects2_Model_Project::model()->findSingleByAttribute('name','[001] Develop Rocket 2000');
 948              if(!$rocketProject){
 949                  $rocketProject = new GO_Projects2_Model_Project();
 950                  $rocketProject->type_id=$type->id;
 951                  $rocketProject->status_id=$status->id;
 952                  $rocketProject->name='[001] Develop Rocket 2000';
 953                  $rocketProject->description='Better range and accuracy';
 954                  $rocketProject->template_id=$projectTemplate->id;
 955                  $rocketProject->parent_project_id=$folderProject->id;
 956                  $rocketProject->start_time=time();
 957                  $rocketProject->due_time=GO_Base_Util_Date::date_add(time(),0,1);
 958                  $rocketProject->company_id=$acme->id;
 959                  $rocketProject->contact_id=$wile->id;
 960                  $rocketProject->budget=20000;
 961                  $rocketProject->save();
 962                  
 963                  $resource = new GO_Projects2_Model_Resource();
 964                  $resource->project_id=$rocketProject->id;
 965                  $resource->user_id=$demo->id;
 966                  $resource->budgeted_units=100;
 967                  $resource->external_fee=80;
 968                  $resource->internal_fee=40;
 969                  $resource->save();
 970                  
 971                  $resource = new GO_Projects2_Model_Resource();
 972                  $resource->project_id=$rocketProject->id;
 973                  $resource->user_id=$elmer->id;
 974                  $resource->budgeted_units=16;
 975                  $resource->external_fee=120;
 976                  $resource->internal_fee=60;
 977                  $resource->save();
 978                  
 979                  $resource = new GO_Projects2_Model_Resource();
 980                  $resource->project_id=$rocketProject->id;
 981                  $resource->user_id=$linda->id;
 982                  $resource->budgeted_units=16;
 983                  $resource->external_fee=90;
 984                  $resource->internal_fee=45;
 985                  $resource->save();
 986                  
 987                  
 988                  $groupTask = new GO_Projects2_Model_Task();
 989                  $groupTask->project_id=$rocketProject->id;
 990                  $groupTask->description='Design';
 991                  $groupTask->duration=8*60;
 992                  $groupTask->user_id=$demo->id;
 993                  $groupTask->save();
 994                  
 995                  
 996                  $task = new GO_Projects2_Model_Task();
 997                  $task->parent_id=$groupTask->id;
 998                  $task->project_id=$rocketProject->id;
 999                  $task->description='Functional design';
1000                  $task->percentage_complete=100;
1001                  $task->duration=8*60;
1002                  $task->user_id=$demo->id;
1003                  $task->save();
1004                  
1005                  $task = new GO_Projects2_Model_Task();
1006                  $task->parent_id=$groupTask->id;
1007                  $task->project_id=$rocketProject->id;
1008                  $task->description='Technical design';
1009                  $task->percentage_complete=50;
1010                  $task->duration=8*60;
1011                  $task->user_id=$demo->id;
1012                  $task->save();
1013                  
1014                  
1015                  $groupTask = new GO_Projects2_Model_Task();
1016                  $groupTask->project_id=$rocketProject->id;
1017                  $groupTask->description='Implementation';
1018                  $groupTask->duration=8*60;
1019                  $groupTask->user_id=$demo->id;
1020                  $groupTask->save();
1021                  
1022                  
1023                  $task = new GO_Projects2_Model_Task();
1024                  $task->parent_id=$groupTask->id;
1025                  $task->project_id=$rocketProject->id;
1026                  $task->description='Models';
1027                  $task->duration=4*60;
1028                  $task->user_id=$demo->id;
1029                  $task->save();
1030                  
1031                  $task = new GO_Projects2_Model_Task();
1032                  $task->parent_id=$groupTask->id;
1033                  $task->project_id=$rocketProject->id;
1034                  $task->description='Controllers';
1035                  $task->duration=2*60;
1036                  $task->user_id=$demo->id;
1037                  $task->save();
1038                  
1039                  $task = new GO_Projects2_Model_Task();
1040                  $task->parent_id=$groupTask->id;
1041                  $task->project_id=$rocketProject->id;
1042                  $task->description='Views';
1043                  $task->duration=6*60;
1044                  $task->user_id=$demo->id;
1045                  $task->save();
1046                  
1047                  $groupTask = new GO_Projects2_Model_Task();
1048                  $groupTask->project_id=$rocketProject->id;
1049                  $groupTask->description='Testing';
1050                  $groupTask->duration=8*60;
1051                  $groupTask->user_id=$demo->id;
1052                  $groupTask->save();
1053                  
1054                  
1055                  $task = new GO_Projects2_Model_Task();
1056                  $task->parent_id=$groupTask->id;
1057                  $task->project_id=$rocketProject->id;
1058                  $task->description='GUI';
1059                  $task->duration=8*60;
1060                  $task->user_id=$elmer->id;
1061                  $task->save();
1062                  
1063                  $task = new GO_Projects2_Model_Task();
1064                  $task->parent_id=$groupTask->id;
1065                  $task->project_id=$rocketProject->id;
1066                  $task->description='Security';
1067                  $task->duration=8*60;
1068                  $task->user_id=$elmer->id;
1069                  $task->save();
1070                  
1071                  
1072                  $expenseBudget = new GO_Projects2_Model_ExpenseBudget();
1073                  $expenseBudget->description='Machinery';
1074                  $expenseBudget->nett=10000;
1075                  $expenseBudget->project_id=$rocketProject->id;
1076                  $expenseBudget->save();
1077                  
1078                  $expense = new GO_Projects2_Model_Expense();                
1079                  $expense->description='Rocket fuel';
1080                  $expense->project_id=$rocketProject->id;
1081                  $expense->nett=3000;
1082                  $expense->save();
1083                  
1084                  
1085                  $expense = new GO_Projects2_Model_Expense();                
1086                  $expense->expense_budget_id=$expenseBudget->id;
1087                  $expense->description='Fuse machine';
1088                  $expense->project_id=$rocketProject->id;
1089                  $expense->nett=2000;
1090                  $expense->save();
1091              }
1092              
1093              $launcherProject = GO_Projects2_Model_Project::model()->findSingleByAttribute('name','[001] Develop Rocket Launcher');
1094              if(!$launcherProject){
1095                  $launcherProject = new GO_Projects2_Model_Project();
1096                  $launcherProject->type_id=$type->id;
1097                  $launcherProject->status_id=$status->id;
1098                  $launcherProject->name='[001] Develop Rocket Launcher';
1099                  $launcherProject->description='Better range and accuracy';
1100                  $launcherProject->template_id=$projectTemplate->id;
1101                  $launcherProject->parent_project_id=$folderProject->id;
1102                  $launcherProject->start_time=time();
1103                  $launcherProject->due_time=GO_Base_Util_Date::date_add(time(),0,1);
1104                  $launcherProject->company_id=$acme->id;
1105                  $launcherProject->contact_id=$wile->id;
1106                  $launcherProject->save();
1107                  
1108                  
1109                  $resource = new GO_Projects2_Model_Resource();
1110                  $resource->project_id=$launcherProject->id;
1111                  $resource->user_id=$demo->id;
1112                  $resource->external_fee=80;
1113                  $resource->internal_fee=40;
1114                  $resource->budgeted_units=16;
1115                  $resource->save();
1116              }
1117              
1118          }
1119          
1120          
1121          
1122          
1123          if(GO::modules()->bookmarks){
1124              $category = GO_Bookmarks_Model_Category::model()->findSingleByAttribute('name', GO::t('general','bookmarks'));
1125              
1126              if(!$category){
1127                  $category = new GO_Bookmarks_Model_Category();
1128                  $category->name=GO::t('general','bookmarks');        
1129                  $category->save();
1130                  $category->acl->addGroup(GO::config()->group_internal, GO_Base_Model_Acl::READ_PERMISSION);
1131              }
1132              $bookmark = GO_Bookmarks_Model_Bookmark::model()->findSingleByAttribute('name', 'Google Search');
1133  
1134              if(!$bookmark){
1135                  $bookmark = new GO_Bookmarks_Model_Bookmark();
1136                  $bookmark->category_id=$category->id;
1137                  $bookmark->name='Google Search';
1138                  $bookmark->content='http://www.google.com';
1139                  $bookmark->logo='icons/viewmag.png';
1140                  $bookmark->public_icon=true;
1141                  $bookmark->description='Search the web';
1142                  $bookmark->open_extern=true;
1143                  $bookmark->save();
1144              }
1145              
1146              $bookmark = GO_Bookmarks_Model_Bookmark::model()->findSingleByAttribute('name', 'Wikipedia');
1147  
1148              if(!$bookmark){
1149                  $bookmark = new GO_Bookmarks_Model_Bookmark();
1150                  $bookmark->category_id=$category->id;
1151                  $bookmark->name='Wikipedia';
1152                  $bookmark->content='http://www.wikipedia.com';
1153                  $bookmark->logo='icons/agt_web.png';
1154                  $bookmark->public_icon=true;
1155                  $bookmark->description='The Free Encyclopedia';
1156                  $bookmark->behave_as_module=true;
1157                  $bookmark->save();
1158              }
1159          }
1160          
1161          if(GO::modules()->postfixadmin){
1162              
1163              
1164              $domainModel= GO_Postfixadmin_Model_Domain::model()->findSingleByAttribute('domain', 'acmerpp.demo');
1165              if(!$domainModel){
1166                  $domainModel = new GO_Postfixadmin_Model_Domain();
1167                  $domainModel->domain='acmerpp.demo';
1168                  $domainModel->save();
1169              }
1170                  
1171              $this->_createMailbox($domainModel, $demo);
1172              $this->_createMailbox($domainModel, $elmer);
1173              $this->_createMailbox($domainModel, $linda);
1174              
1175              
1176          }
1177          
1178          if(GO::modules()->savemailas){
1179              //link some demo mails
1180              $mimeFile = new GO_Base_Fs_File(GO::modules()->savemailas->path.'install/demo.eml');            
1181              GO_Savemailas_Model_LinkedEmail::model()->createFromMimeFile($mimeFile, $wile);
1182              GO_Savemailas_Model_LinkedEmail::model()->createFromMimeFile($mimeFile, $john);
1183              if(GO::modules()->projects){
1184                  GO_Savemailas_Model_LinkedEmail::model()->createFromMimeFile($mimeFile, $rocketProject);
1185                  GO_Savemailas_Model_LinkedEmail::model()->createFromMimeFile($mimeFile, $launcherProject);
1186              }
1187              
1188              $mimeFile = new GO_Base_Fs_File(GO::modules()->savemailas->path.'install/demo2.eml');
1189              GO_Savemailas_Model_LinkedEmail::model()->createFromMimeFile($mimeFile, $wile);
1190              GO_Savemailas_Model_LinkedEmail::model()->createFromMimeFile($mimeFile, $john);
1191              if(GO::modules()->projects){
1192                  GO_Savemailas_Model_LinkedEmail::model()->createFromMimeFile($mimeFile, $rocketProject);
1193                  GO_Savemailas_Model_LinkedEmail::model()->createFromMimeFile($mimeFile, $launcherProject);
1194              }
1195          }
1196          
1197          //useful for other modules to create stuff
1198          $this->fireEvent('demodata', array('users'=>array('demo'=>$demo, 'linda'=>$linda, 'elmer'=>$elmer)));
1199          
1200          if(GO::modules()->demodata)
1201              GO::modules()->demodata->delete();
1202          
1203          if(!$this->isCli()){
1204              //login as demo                
1205              GO::session()->restart();
1206              GO::session()->setCurrentUser($demo->id);
1207  
1208              $this->redirect();
1209          }        
1210      }
1211      
1212      
1213  	private function _createMailbox($domainModel, $demo){
1214          $demoMailbox = GO_Postfixadmin_Model_Mailbox::model()->findSingleByAttribute('username', $demo->email);
1215          if(!$demoMailbox){
1216              $demoMailbox = new GO_Postfixadmin_Model_Mailbox();
1217              $demoMailbox->domain_id=$domainModel->id;
1218              $demoMailbox->username=$demo->email;
1219              $demoMailbox->password='demo';
1220              $demoMailbox->name=$demo->name;
1221              $demoMailbox->save();                
1222          }            
1223  
1224          $accountModel = GO_Email_Model_Account::model()->findSingleByAttribute('username', $demoMailbox->username);
1225          if(!$accountModel){
1226              $accountModel = new GO_Email_Model_Account();
1227              $accountModel->user_id=$demo->id;
1228  //            $accountModel->checkImapConnectionOnSave=false;
1229              $accountModel->host = 'localhost';
1230              $accountModel->port = 143;
1231  
1232              $accountModel->username = $demoMailbox->username;
1233              $accountModel->password = 'demo';
1234  
1235              $accountModel->smtp_host = "localhost";
1236              $accountModel->smtp_port = 25;
1237              $accountModel->save();
1238              $accountModel->addAlias($accountModel->username, $demoMailbox->name);            
1239          }
1240          
1241          
1242          
1243          
1244          
1245          
1246          
1247          
1248          
1249      
1250          
1251          
1252          
1253          
1254      }
1255  
1256  	private function _setUserContact($user) {
1257          $contact = $user->createContact();
1258  
1259          $company = GO_Addressbook_Model_Company::model()->findSingleByAttribute('name', 'ACME Rocket Powered Products');
1260          if (!$company) {
1261              $company = new GO_Addressbook_Model_Company();
1262              $company->setAttributes(array(
1263                      'addressbook_id' => $contact->addressbook_id,
1264                      'name' => 'ACME Rocket Powered Products',
1265                      'address' => '1111 Broadway',
1266                      'address_no' => '',
1267                      'zip' => '10019',
1268                      'city' => 'New York',
1269                      'state' => 'NY',
1270                      'country' => 'US',
1271                      'post_address' => '1111 Broadway',
1272                      'post_address_no' => '',
1273                      'post_zip' => '10019',
1274                      'post_city' => 'New York',
1275                      'post_state' => 'NY',
1276                      'post_country' => 'US',
1277                      'phone' => '(555) 123-4567',
1278                      'fax' => '(555) 123-4567',
1279                      'email' => 'info@acmerpp.demo',
1280                      'homepage' => 'http://www.acmerpp.demo',
1281                      'bank_no' => '',
1282                      'vat_no' => 'US 1234.56.789.B01',
1283                      'user_id' => 1,
1284                      'comment' => 'The name Acme became popular for businesses by the 1920s, when alphabetized business telephone directories such as the Yellow Pages began to be widespread. There were a flood of businesses named Acme (some of these still survive[1]). For example, early Sears catalogues contained a number of products with the "Acme" trademark, including anvils, which are frequently used in Warner Bros. cartoons.[2]'
1285              ));
1286              $company->save();
1287          }
1288  
1289          $contact->company_id = $company->id;
1290          $contact->function = 'CEO';
1291          $contact->cellular = '06-12345678';
1292          $contact->address = '1111 Broadway';
1293          $contact->address_no = '';
1294          $contact->zip = '10019';
1295          $contact->city = 'New York';
1296          $contact->state = 'NY';
1297          $contact->country = 'US';
1298          $contact->save();
1299          
1300          
1301          
1302      }
1303  
1304  }

title

Description

title

Description

title

Description

title

title

Body