function get_account_params() { // Get global params $params = get_global_params('Account'); $params['balance_date'] = of_isodate_convert($params['balance_date'], true); return $params; }
/** * allow to check a date attribute before to set it * @param string $value * @param string $attribute * @access protected * @return boolean **/ protected function validate_date(&$value, $attribute) { $value = preg_replace('/\\s/', '', trim($value)); if ($value == '') { $value = null; return true; } if (preg_match('/^%today([-+]\\d*){0,1}%$/', $value)) { return true; } if ($value = of_isodate_convert($value, true, true)) { return true; } $value = null; return false; }
function get_calendar_params() { global $ccalendar_first_hour, $ccalendar_last_hour, $obm; // Get global params $params = get_global_params('Entity'); // Get calendar specific params if ($params['group_view'] == '') { $params['group_view'] = $params['group_id']; } //FIXME $params['date'] = of_isodate_convert($params['date']); $params['date'] = new Of_Date($params['date']); $params['repeat_end'] = of_isodate_convert($params['repeat_end'],true); if(!is_null($params['repeat_end'])) { $params['repeat_end'] = new Of_Date($params['repeat_end']); } $params['event_before_date'] = of_isodate_convert($params['event_before_date']); if(!is_null($params['event_before_date'])) { $params['event_before_date'] = new Of_Date($params['event_before_date']); } $params['date_begin'] = of_isodate_convert($params['date_begin'],true); if(!is_null($params['date_begin'])) { $params['date_begin'] = new Of_Date($params['date_begin']); } $params['date_end'] = of_isodate_convert($params['date_end'],true); if(!is_null($params['date_end'])) { $params['date_end'] = new Of_Date($params['date_end']); } $params['old_date_begin'] = of_isodate_convert($params['old_date_begin'],true); if(!is_null($params['old_date_begin'])) { $params['old_date_begin'] = new Of_Date($params['old_date_begin']); } if (isset($params['time_begin']) && !is_null($params['date_begin'])) { $params['date_begin']->setHour($params['time_begin']); $params['date_begin']->setMinute($params['min_begin']); } if (isset($params['time_end']) && !is_null($params['date_end'])) { $params['date_end']->setHour($params['time_end']); $params['date_end']->setMinute($params['min_end']); if(!is_null($params['repeat_end'])) { # Don't remove the two lines below. The side effect is that this sets the # end date right. $params['repeat_end']->setHour($params['time_end']); $params['repeat_end']->setMinute($params['min_end']); } } elseif(!is_null($params['date_end'])) { $params['date_end']->setHour($ccalendar_last_hour); } // New meeting event duration if (isset($params['time_duration'])) { $params['meeting_duration'] = $params['time_duration'] * 3600; if (isset($params['min_duration'])) { $params['meeting_duration'] += $params['min_duration'] * 60; } } if (!is_null($params['date_end']) && !is_null($params['date_begin'])) { $params['event_duration'] = $params['date_end']->diffTimestamp($params['date_begin']); if($params['event_duration'] <= 0) { $params['event_duration'] = 0; } } else { $params['event_duration'] = 0; } if (!is_null($params['date_begin']) && is_null($params['date_end']) && isset($params['duration'])) { $clone = clone $params['date_begin']; $params['date_end'] = $clone->addSecond($params['duration']); } if (is_array($params['date_exception'])) { $exceptions = array_unique($params['date_exception']); $params['date_exception'] = array(); foreach($exceptions as $key => $exception) { if(trim($exception) != '') { $exception = of_isodate_convert($exception); $params['date_exception'][$key] = new Of_Date($exception); } } } // repeat days for ($i=0; $i<7; $i++) { if (isset($params["repeatday_$i"])) { $params['repeat_days'] .= '1'; } else { $params['repeat_days'] .= '0'; } } if ($params['owner']=='') { $params['owner'] = $obm['uid']; } else { if (strcmp(substr($params['owner'], 0, 10),'data-user-') == 0) { $data = explode('-', $params['owner']); $params['owner'] = $data[2]; } } if ($params['organizer']=='') { $params['organizer'] = $obm['uid']; } // sel_group_id can be filled by sel_group_id if (is_array($params['group_id'])) { while (list($key, $value) = each($params['group_id']) ) { // sel_group_id contains select infos (data-group-$id) if (strcmp(substr($value, 0, 11),'data-group-') == 0) { $data = explode('-', $value); $id = $data[2]; $params['sel_group_id'][] = $id; } else { // direct id $params['sel_group_id'][] = $value; } } } // sel_user_id can be filled by sel_user_id or sel_ent (see below) if (is_array($params['user_id'])) { while (list($key, $value) = each($params['user_id'])) { // sel_user_id contains select infos (data-user-$id) if (strcmp(substr($value, 0, 10),'data-user-') == 0) { $data = explode('-', $value); $id = $data[2]; $params['sel_user_id'][] = $id; } else if (strcmp(substr($value, 0, 13),'data-contact-') == 0) { $data = explode('-', $value); $id = $data[2]; $params['sel_contact_id'][] = $id; } else { // direct id $params['sel_user_id'][] = $value; } } } // sel_contact_id can be filled by sel_contact_id or sel_ent (see below) if (is_array($params['contact_id'])) { while (list($key, $value) = each($params['contact_id'])) { // sel_user_id contains select infos (data-user-$id) if (strcmp(substr($value, 0, 13),'data-contact-') == 0) { $data = explode('-', $value); $id = $data[2]; $params['sel_contact_id'][] = $id; } else { // direct id $params['sel_contact_id'][] = $value; } } } // sel_resource_id can be filled by sel_resource_id or sel_ent (see below) if (is_array($params['resource_id'])) { while (list($key, $value) = each($params['resource_id']) ) { // sel_resource_id contains select infos (data-resource-$id) if (strcmp(substr($value, 0, 14),'data-resource-') == 0) { $data = explode('-', $value); $id = $data[2]; $params['sel_resource_id'][] = $id; } else { // direct id $params['sel_resource_id'][] = $value; } } } // sel_resource_id can be filled by sel_resource_id or sel_ent (see below) if (is_array($params['resource_group_id'])) { while (list($key, $value) = each($params['resource_group_id']) ) { // sel_resource_id contains select infos (data-resource-$id) if (strcmp(substr($value, 0, 19),'data-resourcegroup-') == 0) { $data = explode('-', $value); $id = $data[2]; $params['sel_resource_group_id'][] = $id; } else { // direct id $params['sel_resource_group_id'][] = $value; } } } if (is_array($params['document_id'])) { while (list($key, $value) = each($params['document_id']) ) { // sel_document_id contains select infos (data-document-$id) if (strcmp(substr($value, 0, 14),'data-document-') == 0) { $data = explode('-', $value); $id = $data[2]; $params['sel_document_id'][] = $id; } else { // direct id $params['sel_document_id'][] = $value; } } } // feature params (user & resource) if (is_array($params['ent'])) { $nb_data = 0; $nb['user'] = 0; $nb['resource'] = 0; while(list($key,$value ) = each($params['ent'])) { if (strcmp(substr($value, 0, 5),'data-') == 0) { $nb_data++; $data = explode('-', $value); $ent = $data[1]; $id = $data[2]; $nb[$ent]++; $params["sel_${ent}_id"][] = $id; } } } // imported file if (isset ($_FILES['fi_ics'])) { $params['ics_tmp'] = $_FILES['fi_ics']['tmp_name']; $params['ics_name'] = $_FILES['fi_ics']['name']; $params['ics_size'] = $_FILES['fi_ics']['size']; $params['ics_type'] = $_FILES['fi_ics']['type']; } if (isset ($_FILES['fi_other_files'])) { $params['other_files'] = array(); foreach ($_FILES['fi_other_files']['name'] as $k => $name) { if ($_FILES['fi_other_files']['error'][$k] !== UPLOAD_ERR_OK) { continue; } $params['other_files'][] = array( 'file_tmp' => $_FILES['fi_other_files']['tmp_name'][$k], 'name' => $_FILES['fi_other_files']['name'][$k], 'size' => $_FILES['fi_other_files']['size'][$k], 'type' => $_FILES['fi_other_files']['type'][$k], ); } } if(is_array($params['others_attendees'])) { foreach($params['others_attendees'] as $mail) { if(trim($mail) != '') $others_attendees[] = trim($mail); } $params['others_attendees'] = $others_attendees; } get_global_params_document($params); return $params; }
function get_user_params() { // Get global params $params = get_global_params('UserObm'); if (isset($params)) { $nb_group = 0; while ( list( $key ) = each($params) ) { if (strcmp(substr($key, 0, 11),'data-group-') == 0) { $nb_group++; $group_num = substr($key, 11); $params["group_$nb_group"] = $group_num; } } $params['group_nb'] = $nb_group; } if(isset($params['exp_op'])) $params['exp_op'] = urldecode($params['exp_op']); if(isset($params['quota_op'])) $params['quota_op'] = urldecode($params['quota_op']); if (isset ($_FILES['fi_file'])) { $params['file_tmp'] = $_FILES['fi_file']['tmp_name']; $params['file_name'] = $_FILES['fi_file']['name']; $params['size'] = $_FILES['fi_file']['size']; $params['type'] = $_FILES['fi_file']['type']; } if(isset ($params['vacation_datebegin'])) { $params['vacation_datebegin'] = of_isodate_convert($params['vacation_datebegin']); $params['vacation_datebegin'] = new Of_Date($params['vacation_datebegin']); $params['vacation_datebegin']->setHour($params["time_begin"])->setMinute($params["min_begin"])->setSecond(0); } if(isset ($params['vacation_dateend'])) { $params['vacation_dateend'] = of_isodate_convert($params['vacation_dateend']); $params['vacation_dateend'] = new Of_Date($params['vacation_dateend']); $params['vacation_dateend']->setHour($params["time_end"])->setMinute($params["min_end"])->setSecond(0); } if (is_array($params['email_nomade'])) { $email_aliases = array(); while(!empty($params['email_nomade'])) { $email = trim(array_shift($params['email_nomade'])); if(!empty($email)) { $email_aliases[] = $email; } } $params['email_nomade'] = implode("\r\n", $email_aliases); } if (is_array($params['email'])) { $email_aliases = array(); while(!empty($params['email'])) { $email = trim(array_shift($params['email'])); $domain = array_shift($params['aliases']); if(!empty($email)) { if(!empty($domain)) { $email_aliases[] = $email.'@'.$domain; } else { $email_aliases[] = $email; } } } $params['email'] = implode("\r\n", $email_aliases); } return $params; }
function get_calendar_params() { global $ccalendar_first_hour, $ccalendar_last_hour; // Get global params $params = get_global_params('Entity'); $params['date'] = of_isodate_convert($params['date']); $params['date'] = new Of_Date($params['date']); $params['event_before_date'] = of_isodate_convert($params['event_before_date']); if(!is_null($params['event_before_date'])) { $params['event_before_date'] = new Of_Date($params['event_before_date']); } $params['date_begin'] = of_isodate_convert($params['date_begin'],true); if(!is_null($params['date_begin'])) { $params['date_begin'] = new Of_Date($params['date_begin']); } $params['date_end'] = of_isodate_convert($params['date_end'],true); if(!is_null($params['date_end'])) { $params['date_end'] = new Of_Date($params['date_end']); } return $params; }
public static function create($data, $addressbook) { global $cgp_show, $cdg_sql, $obm; $uid = sql_parse_id($obm['uid']); $domain_id = sql_parse_id($obm['domain_id']); $data['aka'] = trim($data['aka']); $data['sound'] = phonetic_key($data['lastname']); $add_comment = $data['add_comment']; if ($add_comment != '') { $datecomment = of_isodate_convert($data['datecomment']); $usercomment = $data['usercomment']; $data['comment'] = "\n$datecomment:$usercomment:$add_comment"; } $add_comment2 = $data['add_comment']; if ($add_comment2 != '') { $datecomment2 = of_isodate_convert($data['datecomment2']); $usercomment2 = $data['usercomment2']; $data['comment2'] = "\n$datecomment2:$usercomment2:$add_comment2"; } $add_comment3 = $data['add_comment3']; if ($add_comment3 != '') { $datecomment3 = of_isodate_convert($data['datecomment3']); $usercomment3 = $data['usercomment3']; $data['comment3'] = "\n$datecomment3:$usercomment3:$add_comment3"; } $data['mailok'] = ($data['mailok'] == '1' ? '1' : '0'); $data['newsletter'] = ($data['newsletter'] == '1' ? '1' : '0'); $data['archive'] = ($data['archive'] == '1' ? '1' : '0'); if (empty($data['datasource_id'])) $data['datasource_id'] = $data['datasource']; $contact = new OBM_Contact; $contact->lastname = $data['lastname']; $contact->firstname = $data['firstname']; $fields = array('commonname','mname','kind','title','function','company_id','company', 'market_id','suffix','aka','sound','manager','assistant','spouse','category', 'service','mailok','newsletter','archive','comment','comment2','comment3', 'origin' ); foreach($fields as $field) { $contact->$field = $data[$field]; } $date_fields = array('date','birthday','anniversary'); foreach($date_fields as $field) { if (isset($data[$field])) { $date = of_isodate_convert($data[$field], true); $contact->$field = (!empty($date) ? new Of_Date($date) : null); } } $contact->phone = is_array($data['phones']) ? $data['phones'] : array(); $contact->email = is_array($data['emails']) ? $data['emails'] : array(); $contact->address = is_array($data['addresses'])? $data['addresses'] : array(); $contact->im = is_array($data['ims']) ? $data['ims'] : array(); $contact->website = is_array($data['websites']) ? $data['websites'] : array(); $comp_id = sql_parse_id($contact->company_id); $dsrc = sql_parse_id($contact->datasource_id); $kind = sql_parse_id($contact->kind); $market_id = sql_parse_id($contact->market_id); $func = sql_parse_id($contact->function); $contact->addressbook_id = $addressbook->id; $date = ($contact->date ? "'{$contact->date}'" : 'null'); $query = "INSERT INTO Contact (contact_timeupdate, contact_timecreate, contact_userupdate, contact_usercreate, contact_domain_id, contact_datasource_id, contact_company_id, contact_company, contact_kind_id, contact_marketingmanager_id, contact_lastname, contact_firstname, contact_commonname, contact_middlename, contact_suffix, contact_aka, contact_sound, contact_manager, contact_assistant, contact_spouse, contact_category, contact_service, contact_function_id, contact_title, contact_mailing_ok, contact_newsletter, contact_archive, contact_date, contact_comment, contact_comment2, contact_comment3, contact_origin, contact_addressbook_id ) VALUES ( NOW(), NOW(), $uid, $uid, $domain_id, $dsrc, $comp_id, '{$contact->company}', $kind, $market_id, '{$contact->lastname}', '{$contact->firstname}', '{$contact->commonname}', '{$contact->mname}', '{$contact->suffix}', '{$contact->aka}', '{$contact->sound}', '{$contact->manager}', '{$contact->assistant}', '{$contact->spouse}', '{$contact->category}', '{$contact->service}', $func, '{$contact->title}', {$contact->mailok}, {$contact->newsletter}, {$contact->archive}, $date, '{$contact->comment}', '{$contact->comment2}', '{$contact->comment3}', '{$GLOBALS['c_origin_web']}', '{$addressbook->id}' )"; display_debug_msg($query, $cdg_sql, 'OBM_Contact:create(1)'); $obm_q = new DB_OBM; $retour = $obm_q->query($query); $contact->id = $obm_q->lastid(); if ($contact->id > 0) { if (($cgp_show['module']['company']) && ($retour)) { run_query_global_company_contact_number_update($comp_id); } $contact->entity_id = of_entity_insert('contact',$contact->id); // Birthday & Anniversary support //FIXME: do it better if (!is_null($contact->birthday)) { self::storeAnniversary('birthday', $contact->id, $uid, null, $contact->display_name(), null, $contact->birthday); } if (!is_null($contact->anniversary)) { self::storeAnniversary('anniversary', $contact->id, $uid, null, $contact->display_name(), null, $contact->anniversary); } //FIXME: do it better self::storeCoords($contact); of_userdata_query_update('contact', $contact->id, $data); } OBM_AddressBook::timestamp($addressbook->id); $ret = OBM_Contact::get($contact->id); // Indexing Contact self::solrStore($ret); return $ret; }