Esempio n. 1
0
  /**
   * Return the Report instance from filters list and data type.
   * 
   * @param mixed $filters array of IFilter used to filter data before adding to Report
   * @param mixed $type data type the report refers to (user, mailshare, group). The equivalent class must be defined to access data (e.g. class User for $type='user').
   * @access public
   * @return void
   */
  public static function getReport($filters, $type='user') {

    if (($type!='mailshare') && ($type!='group')) {
      $type = 'user';
    }

    $report = new Report;
    $obm_q = new DB_OBM;
    $query_builder = 'build_'.$type.'_query';
    $entity_builder = 'build_'.$type.'_entity';

    // query database to get entity data
    $query = ReportFactory::$query_builder($obm_q);
    display_debug_msg($query, $cdg_sql, 'getReport()');
    $obm_q->query($query);
    while ($obm_q->next_record()) {

      // build object from any result row
      $record = ReportFactory::$entity_builder($obm_q);

      // filter the results with filters list
      $included = true;
      foreach($filters as $filter) {
        $included &= $filter->filter($record);
      }
      if ($included) $report->addRecord($record);
    }

    return $report;
  }
Esempio n. 2
0
 /**
  * standard constructor
  * @access public
  **/
 public function __construct($user = '')
 {
     global $cdg_sql;
     if (empty($user)) {
         $user = '******';
     }
     $obm_q = new DB_OBM();
     $query = "SELECT usersystem_password as password FROM UserSystem WHERE usersystem_login='******'";
     display_debug_msg($query, $cdg_sql, "SatelliteCredentials::__construct()");
     $obm_q->query($query);
     if (!$obm_q->next_record()) {
         throw new Exception("Can't find {$user} system user");
     }
     //else
     parent::__construct($user, $obm_q->f('password'));
 }
Esempio n. 3
0
File: ICS.php Progetto: Kervinou/OBM
  function getOBMId($attendee, $entity) {
    global $cdg_sql;

    $db = new DB_OBM;
    $db_type = $obm_q->type;
    if(!is_null($attendee['cn'])) {
      $this->cns[$entity][$attendee['cn']] = NULL;
      $cn = "OR cn = '".addslashes($attendee['cn'])."'";
    }
    if(!is_null($attendee['mail'])) {
      $this->mails[$entity][$attendee['mail']] = NULL;
      $mail = "OR mail #LIKE '%".addslashes($attendee['mail'])."%' ";
    }
    if(!$mail && !$cn) {
      return NULL;
    }
    $entityTable = $this->buildEntityQuery($entity, $db);
    if(is_null($entityTable)) {
      return NULL;
    }
    $query = 'SELECT id, mail, cn
              FROM ('.$entityTable.') as Entity WHERE (1 = 0 '.$cn.' '.$mail.') 
              AND domain_id '.sql_parse_id($GLOBALS['obm']['domain_id'], true).'
              GROUP BY id, mail, cn';
    display_debug_msg($query, $cdg_sql, 'getOBMId');
    $db->xquery($query);
    while($db->next_record()) {
      if((!is_null($attendee['cn']) && strtolower($db->f('cn')) == $attendee['cn']) ||
         preg_match_all('/^('.($attendee['mail']).'|'.$attendee['email'].')\r?$/mi',$db->f('mail'),$results)) { 
        $this->cns[strtolower($db->f('cn'))][$entity] = $db->f('id');
        $emails = get_entity_email($db->f('mail'),null,true,null);
        foreach($emails as $email) {
          $this->mails[strtolower($email)][$entity] = $db->f('id');
        } 
        return  $db->f('id');
      }
    }
    return NULL;
  }
Esempio n. 4
0
 /**
  * Delete all attributes stored into the database
  * @access protected
  **/
 protected function purgeAttributes()
 {
     global $cdg_sql;
     $obm_q = new DB_OBM();
     $id = sql_parse_id($this->id, true);
     $query = "DELETE FROM userpattern_property WHERE userpattern_id {$id}";
     display_debug_msg($query, $cdg_sql, "UserPattern::purgeAttributes()");
     $obm_q->query($query);
 }
Esempio n. 5
0
function get_document_mime_type($id) {
  global $cdg_sql;
  
  $query = "SELECT documentmimetype_extension
            FROM Document
            JOIN DocumentMimeType ON document_mimetype_id = documentmimetype_id
            WHERE document_id = '$id'";
            
  
  display_debug_msg($query, $cdg_sql);
  $obm_q = new DB_OBM;
  $obm_q->query($query);
  
  if ($obm_q->num_rows() == 1){
    $obm_q->next_record();
    return $obm_q->f("documentmimetype_extension");
  }
  else 
    return "";
}
Esempio n. 6
0
  /**
   * Get recipients email addresses
   * 
   * $recipients : Id Recipients array
   * $setting    : recipient setting to check (set_mail, set_mail_participant)
   * $force      : Mail should be forced (all user even with no set_mail)
   * Returns: DB with email recipients, or false if no valid recipients
   */
  protected function getRecipients($recipients, $setting='set_mail', $force=false) {
    global $cdg_sql;

    if (($setting == 'set_mail') || ($setting == 'set_mail_participation')) {
      $set_mail = $setting;
    } else {
      $set_mail = 'set_mail';
    }

    if (!$force) {
      $mail_filter = "
        AND (up1.userobmpref_value = 'yes' OR
        (up2.userobmpref_value = 'yes' AND up1.userobmpref_value IS NULL))";
      $join = "LEFT JOIN UserObmPref as up1 ON up1.userobmpref_user_id=userobm_id
        AND up1.userobmpref_option = '$set_mail'
        LEFT JOIN UserObmPref as up2 on up2.userobmpref_user_id IS NULL
        AND up2.userobmpref_option = '$set_mail'";
    }
    $coma = '';
    foreach($recipients as $recipient) {
      if ($recipient) {
        $user_list .= $coma.$recipient;
        $coma = ',';
      }
    }
    if ($user_list != '') {
      $user_in = "userobm_id IN ($user_list) AND";
    } else {
      return false;
    }

    $query = "SELECT 
      userobm_email, userobm_lastname, userobm_firstname, userobm_commonname, domain_name
      FROM UserObm 
      INNER JOIN Domain on userobm_domain_id = domain_id
      $join
      WHERE $user_in
      userobm_email != ''
      $mail_filter";
    display_debug_msg($query, $cdg_sql, 'run_query_get_recipients()');
    $db = new DB_OBM;
    $db->query($query);
    $recipients = array();
    
    while ($db->next_record()) {
      $email = $this->getEntityEmail($db->f('userobm_email'), $db->f('domain_name'));
      $displayname = $db->f('userobm_commonname');
      if (!$displayname) $displayname = sprintf($GLOBALS['l_displayname_template'], $db->f('userobm_firstname'), $db->f('userobm_lastname'));
      if (isset($email) && $email != "") {
        $recipients[] = array($email, $displayname);
      }
    }
    return $recipients;
  }
Esempio n. 7
0
    $query = preg_replace("/(limit .*)$/i", '', $query);
  }
  
  // Check if banned words are included
  $excluded_words = array ('insert', 'update', 'delete', 'create', 'alter', 'drop', 'lock', 'userobm_password');
  while ( list($key, $value) = each($excluded_words) ) {
    if (preg_match("/\b$value\b/i", $query)) {
      $err['msg'] = "$l_err_query_banned $l_banned_word : $value";
      echo $err['msg'];
      return false;
    }
  }

  $prefs = get_display_pref($obm['uid'], $entity);
  
  display_debug_msg($query, $cdg_sql, 'export()');
  $obm_q = new DB_OBM;
  $obm_q->query($query);

  // Set separator (if not set in setting => ;)
  if (($_SESSION['set_csv_sep'] != $ccsvd_sc) && ($_SESSION['set_csv_sep'] != $ccsvd_tab)) {
    $sep = ';';
  } else if ($_SESSION['set_csv_sep'] == $ccsvd_tab) {
    $sep = "\t";
  } else {
    $sep = $_SESSION['set_csv_sep'];
  }

  $export_d = new OBM_DISPLAY('DATA', $prefs, $emodule);
  $export_d->display_entity = "$entity";
  $export_d->data_set = $obm_q;
Esempio n. 8
0
      $display['detail'] = dis_tools_update_detail();
      remove_update_lock();
    } else {
      $display['msg'] .= display_err_msg("$l_upd_error ($res)");
      remove_update_lock();
      $display['detail'] = dis_tools_update_detail();
    }
  } else {
    // Si le contexte ne permet pas une modification de configuration
    $display['msg'] .= display_warn_msg($err['msg']);
    $display['detail'] = dis_tools_update_detail();
  }

} elseif ($action == 'halt_halt') {
///////////////////////////////////////////////////////////////////////////////
  $display['msg'] .= display_debug_msg($cmd_halt, $cdg_exe);
  $ret = exec($cmd_halt);

} elseif($action == 'progress') {
///////////////////////////////////////////////////////////////////////////////
  json_tools_update_progress ($params['domain_id'], $params['realm']);
  echo "(".$display['json'].")";
  exit();
}
///////////////////////////////////////////////////////////////////////////////
// Display page
///////////////////////////////////////////////////////////////////////////////
$display['head'] = display_head($l_tools);
$display['header'] = display_menu($module);
$display['end'] = display_end();
Esempio n. 9
0
 /**
  * get the details for entity of type mailshare
  * @param int $mailshare_id
  * @access protected
  */
 protected function mailshareDetails($mailshare_id)
 {
     $obm_q = new DB_OBM();
     $db_type = $obm_q->type;
     $multidomain = sql_multidomain('mailshare');
     $id = sql_parse_id($mailshare_id, true);
     $query = "SELECT\n        mailshare_id as id,\n        mailshare_name as login,\n        'mailshare' as entity,\n        domain_name as realm,\n        ms.host_ip as host\n      FROM MailShare\n      LEFT JOIN Domain on mailshare_domain_id=domain_id\n      LEFT JOIN Host ms on mailshare_mail_server_id=ms.host_id\n      WHERE mailshare_id {$id} \n        {$multidomain}";
     display_debug_msg($query, $GLOBALS['cdg_sql'], 'Backup::mailshareDetails()');
     $obm_q->query($query);
     if (!$obm_q->next_record()) {
         throw new Exception($GLOBALS['l_err_reference']);
     }
     $this->details = $obm_q->Record;
     $this->details['login'] = strtolower($this->details['login']);
 }
Esempio n. 10
0
  private static function storeAnniversary($date='birthday', $contact_id, $contact_usercreate, $event_id, $contact_fullname, $old_value, $new_value) {
    global $cdg_sql, $obm;
    global $l_birthday_event_title, $l_anniversary_event_title;

    list($nope_event, $insert_event, $update_event, $delete_event) = array(0,1,2,3);
    if ($event_id == null) {
      if ($new_value != null) {
        $do = $insert_event;
      }
    } else {
      if ($new_value == null) {
        $do = $delete_event;
      } else if ($new_value->compare($old_value) != 0) {
        $do = $update_event;
      }
    }

    $obm_q = new DB_OBM;

    $multidomain_contact = sql_multidomain('contact');
    $multidomain_event = sql_multidomain('event');

    switch ($do) {
    case $insert_event:
      $duration = 3600*24;
      $label = ${"l_${date}_event_title"};
      $title = str_replace('\'', '\\\'', sprintf($label, $contact_fullname));
      $ext_id =  get_obm_info('product_id').sha1(uniqid()).sha1($GLOBALS['obm']['domain_name']).sha1(mktime()*rand());

      $query = "INSERT INTO Event
        (event_timeupdate,
        event_timecreate,
        event_usercreate,
        event_origin,
        event_owner,
        event_ext_id,
        event_timezone,
        event_title,
        event_date,
        event_description,
        event_properties,
        event_location,
        event_category1_id,
        event_priority,
        event_privacy,
        event_duration,
        event_repeatkind,
        event_repeatfrequence,
        event_repeatdays,
        event_allday,
        event_color,
        event_endrepeat,
        event_domain_id,
        event_opacity)
        VALUES
        (
         NOW(),
         NOW(),
        '$contact_usercreate',
        '$GLOBALS[c_origin_web]',
        '$contact_usercreate',
        '$ext_id',
        '".Of_Date::getOption('timezone')."',
        '$title',
        '$new_value',
        '',
        '',
        '',
        NULL,
        '2',
        '0',
        '$duration',
        'yearly',
        '1',
        '0000000',
        '1',
        '',
        NULL,
        '$obm[domain_id]',
        'TRANSPARENT')";

      $obm_q->query($query);
      display_debug_msg($query, $cdg_sql, 'run_query_contact_birthday_update(insert event)');

      $insert_event_id = $obm_q->lastid();
      if ($insert_event_id) {
        of_entity_insert('event', $insert_event_id);
        $sql_id = sql_parse_id($contact_id);
        $query = "UPDATE Contact
          SET contact_${date}_id = $insert_event_id
          WHERE
          contact_id = $sql_id
          $multidomain_contact";

        $obm_q->query($query);
        display_debug_msg($query, $cdg_sql, "run_query_contact_birthday_update(update birthday id)");
        $entity_id = of_entity_get('user', $contact_usercreate);
        $query = "INSERT INTO EventLink (
          eventlink_timecreate,
          eventlink_usercreate,
          eventlink_event_id, 
          eventlink_entity_id,
          eventlink_state) 
        VALUES (
          NOW(),
          $contact_usercreate,
          $insert_event_id,
          $entity_id,
          'ACCEPTED')";

        $obm_q->query($query);
        display_debug_msg($query, $cdg_sql, "run_query_contact_birthday_update(insert entity)");
      }

      break;

    case $update_event:
      $sql_id = sql_parse_id($event_id);
      $query = "UPDATE Event SET
        event_date = '$new_value',
        event_origin = '$GLOBALS[c_origin_web]'
      WHERE
        event_id = $sql_id
        $multidomain_event";

      $obm_q->query($query);
      display_debug_msg($query, $cdg_sql, 'run_query_contact_birthday_update(update event)');

      break;

    case $delete_event:
      of_entity_delete('event',$event_id);
      $sql_id = sql_parse_id($event_id);
      $query = "DELETE FROM Event WHERE event_id = $sql_id
        $multidomain_event";
      $obm_q->query($query);
      display_debug_msg($query, $cdg_sql, 'run_query_contact_birthday_update(delete event)');

      break;
    }
  }