protected function createGroup($domain_id, $delegation) { $groupName = $this->delegationGroupName($delegation); $gid = sql_parse_int(get_first_group_free_gid()); $q_delegation = of_delegation_query_insert_clauses('group_delegation', $delegation); $group_email = preg_replace('/Tous /', 'Tous', $groupName); $group_email = preg_replace('/\\//', '-', $group_email); $group_email = preg_replace('/\\s/', '-', $group_email); $query = "INSERT INTO UGroup (\n group_timeupdate,\n group_timecreate,\n group_userupdate,\n group_usercreate,\n group_domain_id,\n group_privacy,\n group_gid,\n group_name\n {$q_delegation['field']},\n group_email,\n group_desc\n ) VALUES (\n null,\n NOW(),\n null,\n 1,\n {$domain_id},\n 0,\n {$gid},\n '{$groupName}'\n {$q_delegation['value']},\n '{$group_email}',\n ''\n )"; $this->logger->core($query); $obm_q = new DB_OBM(); $retour = $obm_q->query($query); $id = $obm_q->lastid(); if ($id > 0) { $entity_id = of_entity_insert('group', $id); } return array($id, $groupName); }
public static function create($addressbook) { $domain_id = $GLOBALS['obm']['domain_id']; $uid = $GLOBALS['obm']['uid']; $ad_name = $addressbook['name']; $query = "INSERT INTO AddressBook ( domain_id, timeupdate, timecreate, userupdate, usercreate, origin, owner, name, is_default, syncable) VALUES ( $domain_id, NOW(), NOW(), $uid, $uid, '$GLOBALS[c_origin_web]', $uid, '$ad_name', false, true)"; $db = new DB_OBM; $db->query($query); $id = $db->lastid(); $entity_id = of_entity_insert('addressbook', $id); return self::get($id); }
/** * Insert the user pattern into the database * @access protected **/ protected function insert() { global $cdg_sql; $domain_id = sql_parse_id($this->domain_id); $title = addslashes($this->title); $description = addslashes($this->description); $usercreate = sql_parse_id($GLOBALS['obm']['uid']); $obm_q = new DB_OBM(); $query = "INSERT INTO userpattern (domain_id, title, description, timecreate, usercreate)\n VALUES ({$domain_id},'{$title}','{$description}',NOW(),{$usercreate})"; display_debug_msg($query, $cdg_sql, 'UserPattern::insert()'); $obm_q->query($query); $this->id = $obm_q->lastid(); $this->storeAttributes(); }
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; } }