exit(); } elseif ($action == 'attach_documents') { /////////////////////////////////////////////////////////////////////////////// try { $doc_ids = isset($params['sel_document_id']) ? $params['sel_document_id'] : array(); $existent_doc_ids = get_calendar_event_document_ids($params['calendar_id']); $already_attached_doc_ids = array_intersect($doc_ids, $existent_doc_ids); $doc_ids = array_diff($doc_ids, $existent_doc_ids); $other_files = run_query_insert_other_files($params); if (!$other_files) { $display['msg'] .= display_warn_msg("$l_event : $l_warn_file_upload"); } else { $doc_ids = array_merge($doc_ids, $other_files); } $event_entity_id = of_entity_get('event', $params['calendar_id']); foreach ($doc_ids as $document_id) { run_query_calendar_attach_document($document_id, $event_entity_id); } if (count($already_attached_doc_ids) != 0) { redirect_err($params, $l_warn_already_attached); } else { redirect_ok($params, "$l_document: $l_insert_ok"); } } catch (OverQuotaDocumentException $e) { redirect_err($params, $l_over_quota_error); } } elseif ($action == 'download_document') { /////////////////////////////////////////////////////////////////////////////// require '../document/document_query.inc';
public function getValue($entity_id) { $id = of_entity_get($this->entity, $entity_id); $db = new DB_OBM(); $query = "SELECT * FROM field WHERE entity_id = '$id'"; $db->query($query); $ret = array(); while($db->next_record()) { $f = $db->f('field'); if ($this->fields[$f]['type'] == "boolean") { $ret[$f] = $db->f('value') == 1 ? $GLOBALS['l_yes']:$GLOBALS['l_no']; } else { $ret[$f] = $db->f('value'); } } return $ret; }
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; } }