/** * 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']); }
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; } }