Exemple #1
0
    print "Usage: {$argv['0']} <users number> <domains number> <dummized obm root dir>\n";
    exit(1);
}
if ($nb_users < 6) {
    // DummyGenerators::createEvents() limitation
    die("You may only specify at least 6 users.\n");
}
if ($nb_domain < 1) {
    // DummyGenerators::createEvents() limitation
    die("You may only specify at least 1 domain.\n");
}
/* Our files (need $obm_root) */
include 'helpers.php';
include 'generators.php';
/* Set some globals that OBM's includes need */
$obm = array('uid' => 1);
// run_query_domain_init_data() needs this
/* Hack to include obm's includes files */
$path = 'php';
// dummy value, useless
$GLOBALS['confFile'] = realpath('.') . '/conf.ini';
$GLOBALS['realPath'] = realPath('.');
chdir($obm_root);
$obminclude = "./obminclude";
require "{$obminclude}/global.inc";
for ($i = 0; $i < $nb_domain; $i++) {
    $obm['domain_name'] = "foo{$i}.bar";
    $obm['domain_label'] = "foo" . $i . "bar";
    $gens = new DummyGenerators();
    $gens->genDummyData($nb_users);
}
Exemple #2
0
  /**
   * initialize 
   * 
   * @access public
   * @return void
   */
  public function initialize() {
    /* read scales from conf.ini*/
    if(file_exists($GLOBALS['confFile'])) {
      $ratios = parse_ini_file($GLOBALS['confFile'],true);
    } else {
      print "\nPlease edit conf.ini.sample and save it as conf.ini\n";
      exit(1);
    }
    $this->groupRatio           = floatval($ratios['entity.group']['ratio']);
    $this->groupUserRatio       = floatval($ratios['entity.group.user']['ratio']);
    $this->contactPrivateRatio  = floatval($ratios['entity.contact.private']['ratio']);
    $this->contactPublicRatio   = floatval($ratios['entity.contact.public']['ratio']);
    $this->resourceRatio        = floatval($ratios['entity.resource']['ratio']);
    $this->eventNormalRatio     = floatval($ratios['entity.event.normal']['ratio']);
    $this->eventRecurringRatio  = floatval($ratios['entity.event.recurring']['ratio']);
    $this->eventMeetingRatio    = floatval($ratios['entity.event.meeting']['ratio']);
    $this->eventMeetingUserRatio= floatval($ratios['entity.event.meeting.user']['ratio']);
    $this->eventAllDayRatio     = floatval($ratios['entity.event.allday']['ratio']);
    /* 'Email' => 2 will create rand(0,2) mails per contact */
    $this->contactData = array (
      'Email'   => floatval($ratios['entity.contact.data']['email']),
      'Website' => floatval($ratios['entity.contact.data']['website']),
      'IM'      => floatval($ratios['entity.contact.data']['address']),
      'Address' => floatval($ratios['entity.contact.data']['phone']),
      'Phone'   => floatval($ratios['entity.contact.data']['im'])
    );
    $this->eventData = array (
      'maxEventDuration' => floatval($ratios['entity.event.data']['duration'])
    );
    /* The propabilities for a user/group to get each right
       (floats between 0 and 1) */
    $this->rights = array ( 
      'calendar' => array ( 
        'user' => array ( 
          'access'      => floatval($ratios['right.calendar.user']['access']), 
          'read'        => floatval($ratios['right.calendar.user']['read']),  
          'write'       => floatval($ratios['right.calendar.user']['write']),  
          'admin'       => floatval($ratios['right.calendar.user']['admin'])
        ),
        'group'         => array ( 
          'access'      => floatval($ratios['right.calendar.group']['access']), 
          'read'        => floatval($ratios['right.calendar.group']['read']),  
          'write'       => floatval($ratios['right.calendar.group']['write']),  
          'admin'       => floatval($ratios['right.calendar.group']['admin'])          
        ),
      ),
      'resource' => array ( 
        'user' => array(
          'access'      => floatval($ratios['right.resource.user']['access']), 
          'read'        => floatval($ratios['right.resource.user']['read']),  
          'write'       => floatval($ratios['right.resource.user']['write']),  
          'admin'       => floatval($ratios['right.resource.user']['admin'])
          ),
          'group' => array (
            'access'      => floatval($ratios['right.resource.group']['access']), 
            'read'        => floatval($ratios['right.resource.group']['read']),  
            'write'       => floatval($ratios['right.resource.group']['write']),  
            'admin'       => floatval($ratios['right.resource.group']['admin'])          
        )
      ),
      'contact' => array ( 
        'user' => array(
          'access'      => floatval($ratios['right.contact.user']['access']), 
          'read'        => floatval($ratios['right.contact.user']['read']),  
          'write'       => floatval($ratios['right.contact.user']['write']),  
          'admin'       => floatval($ratios['right.contact.user']['admin'])
        ),
        'group' => array (
          'access'      => floatval($ratios['right.contact.group']['access']), 
          'read'        => floatval($ratios['right.contact.group']['read']),  
          'write'       => floatval($ratios['right.contact.group']['write']),  
          'admin'       => floatval($ratios['right.contact.group']['admin'])        
        )
      )
    );
    /* Our stuff */
    $this->today = date('Y-m-d');

    /* Add a domain */
    $this->query("INSERT INTO Domain (domain_timeupdate,domain_timecreate,domain_userupdate,domain_usercreate,domain_label, domain_description, domain_name, domain_alias)
    VALUES (null, NOW(), null,  1, '".$GLOBALS['obm']['domain_label']."', '', '".$GLOBALS['obm']['domain_name']."', '')");

    $this->domain = $this->lastInsertId('Domain','domain_id');
    /* Add related entity */
    $entityId = $this->newEntity();
    $this->query("INSERT INTO DomainEntity (domainentity_domain_id, domainentity_entity_id) VALUES ( ".$this->domain.", $entityId)");
    /* Fill it with initial data from the global domain */
    run_query_domain_init_data($this->domain);


    /* Keep infos we will need */
    $res = $this->query("SELECT kind_id FROM Kind WHERE kind_domain_id = '$this->domain'");
    DummyGenerators::$KIND = $res->fetchAll(PDO::FETCH_COLUMN);
    unset($res); // Next queries would fail otherwise

    $res = $this->query("SELECT eventcategory1_id FROM EventCategory1 WHERE eventcategory1_domain_id = '$this->domain'");
    DummyGenerators::$EVENT_CATEGORY = $res->fetchAll(PDO::FETCH_COLUMN);
    $this->setup();
  }
Exemple #3
0
 public function getRandomFileData($handle) {
   if(DBTYPE == 'pgsql') {
     return "(SELECT data".rand(1,3)." FROM $handle[0] WHERE ids.id = ids.id LIMIT 1 OFFSET ".DummyGenerators::random(0,$handle[1]).')';
   } else {
     return "IF(@val:=".DummyGenerators::random(1,$handle[1]+1).",(SELECT data".rand(1,3)." FROM $handle[0] WHERE ids.id = ids.id LIMIT 1), '$handle[0]')";
   }
 }