From: Roland Haeder Date: Mon, 20 Mar 2017 19:51:32 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/develop' into rewrites/coding-convention X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=09851331a9dc8601919cd0c9200686b92843d235;p=friendica.git Merge remote-tracking branch 'upstream/develop' into rewrites/coding-convention Signed-off-by: Roland Haeder --- 09851331a9dc8601919cd0c9200686b92843d235 diff --cc include/Contact.php index de76789e8c,fc9f660f13..dc29d38257 --- a/include/Contact.php +++ b/include/Contact.php @@@ -122,12 -122,12 +122,14 @@@ function terminate_friendship($user,$se // This provides for the possibility that their database is temporarily messed // up or some other transient event and that there's a possibility we could recover from it. --function mark_for_death($contact) { ++function mark_for_death(array $contact) { - if ($contact['archive']) - if($contact['archive']) ++ if ($contact['archive']) { return; ++ } - if ($contact['term-date'] == '0000-00-00 00:00:00') { ++ /// @TODO Comparison of strings this way may lead to bugs/incompatibility, better switch to DateTime + if ($contact['term-date'] <= NULL_DATE) { q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d", dbesc(datetime_convert()), intval($contact['id']) diff --cc include/dfrn.php index 1240228f06,25f8c9358e..9fa19bde6c --- a/include/dfrn.php +++ b/include/dfrn.php @@@ -1182,7 -1094,7 +1182,8 @@@ class dfrn return 3; } - if ($contact['term-date'] != '0000-00-00 00:00:00') { ++ /// @TODO Really compare with > here? Maybe DateTime (which allows such comparison again) is much safer/correcter + if ($contact['term-date'] > NULL_DATE) { logger("dfrn_deliver: $url back from the dead - removing mark for death"); require_once('include/Contact.php'); unmark_for_death($contact); diff --cc include/event.php index 44261b3691,ebd4885c91..7fffdd8a28 --- a/include/event.php +++ b/include/event.php @@@ -10,8 -10,9 +10,9 @@@ require_once 'include/datetime.php' function format_event_html($ev, $simple = false) { - if (! ((is_array($ev)) && count($ev))) - if(! ((is_array($ev)) && count($ev))) { ++ if (! ((is_array($ev)) && count($ev))) { return ''; + } $bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM @@@ -556,11 -594,12 +594,12 @@@ function event_by_id($owner_uid = 0, $e * @return array Query results */ function events_by_date($owner_uid = 0, $event_params, $sql_extra = '') { - // ownly allow events if there is a valid owner_id - if ($owner_uid == 0) + // Only allow events if there is a valid owner_id - if($owner_uid == 0) { ++ if ($owner_uid == 0) { return; + } - // query for the event by date + // Query for the event by date $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`, `item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event` LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid` @@@ -590,7 -629,7 +629,7 @@@ * @return array Event array for the template */ function process_events($arr) { -- $events=array(); ++ $events = array(); $last_date = ''; $fmt = t('l, F j'); diff --cc include/lock.php index a9cd7d6437,a48b0ad342..64f6319ef1 --- a/include/lock.php +++ b/include/lock.php @@@ -67,9 -66,10 +67,10 @@@ function block_on_function_lock($fn_nam }} -if(! function_exists('unlock_function')) { +if (! function_exists('unlock_function')) { function unlock_function($fn_name) { - $r = q("UPDATE `locks` SET `locked` = 0, `created` = '0000-00-00 00:00:00' WHERE `name` = '%s'", + $r = q("UPDATE `locks` SET `locked` = 0, `created` = '%s' WHERE `name` = '%s'", + dbesc(NULL_DATE), dbesc($fn_name) ); diff --cc include/poller.php index 2f9e726110,5560b3340e..27f8c7831a --- a/include/poller.php +++ b/include/poller.php @@@ -364,16 -364,16 +364,17 @@@ function poller_kill_stale_workers() return; } - foreach ($r AS $pid) { + foreach ($r AS $pid) if (!posix_kill($pid["pid"], 0)) { - q("UPDATE `workerqueue` SET `executed` = '0000-00-00 00:00:00', `pid` = 0 WHERE `pid` = %d", - intval($pid["pid"])); + q("UPDATE `workerqueue` SET `executed` = '%s', `pid` = 0 WHERE `pid` = %d", + dbesc(NULL_DATE), intval($pid["pid"])); } else { // Kill long running processes // Check if the priority is in a valid range -- if (!in_array($pid["priority"], array(PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW, PRIORITY_NEGLIGIBLE))) ++ if (!in_array($pid["priority"], array(PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW, PRIORITY_NEGLIGIBLE))) { $pid["priority"] = PRIORITY_MEDIUM; ++ } // Define the maximum durations $max_duration_defaults = array(PRIORITY_CRITICAL => 360, PRIORITY_HIGH => 10, PRIORITY_MEDIUM => 60, PRIORITY_LOW => 180, PRIORITY_NEGLIGIBLE => 360); diff --cc include/security.php index 63a6b9574f,05371f71ca..1c7813e74b --- a/include/security.php +++ b/include/security.php @@@ -54,23 -54,23 +54,27 @@@ function authenticate_success($user_rec $a->user = $user_record; - if($interactive) { + if ($interactive) { - if ($a->user['login_date'] === '0000-00-00 00:00:00') { ++ /// @TODO Comparison of strings this way may lead to bugs/incompatiblities + if ($a->user['login_date'] <= NULL_DATE) { $_SESSION['return_url'] = 'profile_photo/new'; $a->module = 'profile_photo'; info( t("Welcome ") . $a->user['username'] . EOL); info( t('Please upload a profile photo.') . EOL); -- } -- else ++ } else { info( t("Welcome back ") . $a->user['username'] . EOL); ++ } } $member_since = strtotime($a->user['register_date']); - if (time() < ($member_since + ( 60 * 60 * 24 * 14))) - if(time() < ($member_since + ( 60 * 60 * 24 * 14))) ++ ++ if (time() < ($member_since + ( 60 * 60 * 24 * 14))) { $_SESSION['new_member'] = true; -- else ++ } else { $_SESSION['new_member'] = false; - if(strlen($a->user['timezone'])) { ++ } ++ + if (strlen($a->user['timezone'])) { date_default_timezone_set($a->user['timezone']); $a->timezone = $a->user['timezone']; } diff --cc mod/contacts.php index 11a83f0a04,f2500099c3..ebb355b8a3 --- a/mod/contacts.php +++ b/mod/contacts.php @@@ -99,15 -99,15 +99,24 @@@ function contacts_init(App $a) function contacts_batch_actions(App $a) { $contacts_id = $_POST['contact_batch']; -- if (!is_array($contacts_id)) return; ++ if (!is_array($contacts_id)) { ++ return; ++ } $orig_records = q("SELECT * FROM `contact` WHERE `id` IN (%s) AND `uid` = %d AND `self` = 0", implode(",", $contacts_id), intval(local_user()) ); ++ if (!dbm::is_result($orig_records)) { ++ /// @TODO EOL really needed? ++ notice( t('Could not access contact record(s).') . EOL); ++ goaway('contacts'); ++ return; // NOTREACHED ++ } ++ $count_actions=0; - foreach($orig_records as $orig_record) { + foreach ($orig_records as $orig_record) { $contact_id = $orig_record['id']; if (x($_POST, 'contacts_batch_update')) { _contact_update($contact_id); @@@ -130,7 -130,7 +139,8 @@@ $count_actions++; } } -- if ($count_actions>0) { ++ ++ if ($count_actions > 0) { info ( sprintf( tt("%d contact edited.", "%d contacts edited.", $count_actions), $count_actions) ); } @@@ -164,7 -165,7 +174,8 @@@ function contacts_post(App $a) intval(local_user()) ); -- if (! count($orig_record)) { ++ if (! dbm::is_result($orig_record)) { ++ /// @TODO EOL really needed? notice( t('Could not access contact record.') . EOL); goaway('contacts'); return; // NOTREACHED @@@ -213,13 -212,12 +224,14 @@@ intval($contact_id), intval(local_user()) ); - if($r) ++ /// @TODO Decide to use dbm::is_result() here, what does $r include? + if ($r) { info( t('Contact updated.') . EOL); - else + } else { notice( t('Failed to update contact record.') . EOL); + } - $r = q("select * from contact where id = %d and uid = %d limit 1", + $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), intval(local_user()) ); @@@ -235,40 -231,40 +247,47 @@@ /*contact actions*/ function _contact_update($contact_id) { $r = q("SELECT `uid`, `url`, `network` FROM `contact` WHERE `id` = %d", intval($contact_id)); -- if (!$r) ++ if (!dbm::is_result($r)) { return; ++ } $uid = $r[0]["uid"]; -- if ($uid != local_user()) ++ if ($uid != local_user()) { return; ++ } if ($r[0]["network"] == NETWORK_OSTATUS) { $result = new_contact($uid, $r[0]["url"], false); -- if ($result['success']) ++ if ($result['success']) { $r = q("UPDATE `contact` SET `subhub` = 1 WHERE `id` = %d", intval($contact_id)); -- } else ++ } ++ } else { // pull feed and consume it, which should subscribe to the hub. proc_run(PRIORITY_HIGH, "include/onepoll.php", $contact_id, "force"); ++ } } function _contact_update_profile($contact_id) { $r = q("SELECT `uid`, `url`, `network` FROM `contact` WHERE `id` = %d", intval($contact_id)); -- if (!$r) ++ if (!dbm::is_result($r)) { return; ++ } $uid = $r[0]["uid"]; -- if ($uid != local_user()) ++ if ($uid != local_user()) { return; ++ } $data = probe_url($r[0]["url"]); // "Feed" or "Unknown" is mostly a sign of communication problems -- if ((in_array($data["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) AND ($data["network"] != $r[0]["network"])) ++ if ((in_array($data["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) AND ($data["network"] != $r[0]["network"])) { return; ++ } $updatefields = array("name", "nick", "url", "addr", "batch", "notify", "poll", "request", "confirm", "poco", "network", "alias"); @@@ -277,30 -273,30 +296,36 @@@ if ($data["network"] == NETWORK_OSTATUS) { $result = new_contact($uid, $data["url"], false); -- if ($result['success']) ++ if ($result['success']) { $update["subhub"] = true; ++ } } - foreach ($updatefields AS $field) - foreach($updatefields AS $field) -- if (isset($data[$field]) AND ($data[$field] != "")) ++ foreach ($updatefields AS $field) { ++ if (isset($data[$field]) AND ($data[$field] != "")) { $update[$field] = $data[$field]; ++ } ++ } $update["nurl"] = normalise_link($data["url"]); $query = ""; -- if (isset($data["priority"]) AND ($data["priority"] != 0)) ++ if (isset($data["priority"]) AND ($data["priority"] != 0)) { $query = "`priority` = ".intval($data["priority"]); ++ } - foreach($update AS $key => $value) { - if ($query != "") + foreach ($update AS $key => $value) { - if ($query != "") ++ if ($query != "") { $query .= ", "; ++ } $query .= "`".$key."` = '".dbesc($value)."'"; } -- if ($query == "") ++ if ($query == "") { return; ++ } $r = q("UPDATE `contact` SET $query WHERE `id` = %d AND `uid` = %d", intval($contact_id), @@@ -365,11 -361,11 +390,12 @@@ function contacts_content(App $a) return; } - if($a->argc == 3) { + if ($a->argc == 3) { $contact_id = intval($a->argv[1]); - if (! $contact_id) - if(! $contact_id) ++ if (! $contact_id) { return; ++ } $cmd = $a->argv[2]; @@@ -378,7 -374,7 +404,7 @@@ intval(local_user()) ); - if (! count($orig_record)) { - if(! count($orig_record)) { ++ if (! dbm::is_result($orig_record)) { notice( t('Could not access contact record.') . EOL); goaway('contacts'); return; // NOTREACHED @@@ -396,8 -392,8 +422,9 @@@ // NOTREACHED } - if($cmd === 'block') { + if ($cmd === 'block') { $r = _contact_block($contact_id, $orig_record[0]); ++ /// @TODO is $r a database result? if ($r) { $blocked = (($orig_record[0]['blocked']) ? 0 : 1); info((($blocked) ? t('Contact has been blocked') : t('Contact has been unblocked')).EOL); @@@ -407,8 -403,8 +434,9 @@@ return; // NOTREACHED } - if($cmd === 'ignore') { + if ($cmd === 'ignore') { $r = _contact_ignore($contact_id, $orig_record[0]); ++ /// @TODO is $r a database result? if ($r) { $readonly = (($orig_record[0]['readonly']) ? 0 : 1); info((($readonly) ? t('Contact has been ignored') : t('Contact has been unignored')).EOL); @@@ -419,8 -415,8 +447,9 @@@ } - if($cmd === 'archive') { + if ($cmd === 'archive') { $r = _contact_archive($contact_id, $orig_record[0]); ++ /// @TODO is $r a database result? if ($r) { $archived = (($orig_record[0]['archive']) ? 0 : 1); info((($archived) ? t('Contact has been archived') : t('Contact has been unarchived')).EOL); @@@ -463,8 -459,8 +492,7 @@@ if ($_REQUEST['canceled']) { if (x($_SESSION,'return_url')) { goaway('' . $_SESSION['return_url']); -- } -- else { ++ } else { goaway('contacts'); } } @@@ -473,8 -469,8 +501,7 @@@ info( t('Contact has been removed.') . EOL ); if (x($_SESSION,'return_url')) { goaway('' . $_SESSION['return_url']); -- } -- else { ++ } else { goaway('contacts'); } return; // NOTREACHED @@@ -542,9 -538,9 +569,9 @@@ ? t('Never') : datetime_convert('UTC',date_default_timezone_get(),$contact['last-update'],'D, j M Y, g:i A')); - if ($contact['last-update'] !== '0000-00-00 00:00:00') - if ($contact['last-update'] > NULL_DATE) { ++ if ($contact['last-update'] !== NULL_DATE) { $last_update .= ' ' . (($contact['last-update'] <= $contact['success_update']) ? t("\x28Update was successful\x29") : t("\x28Update was not successful\x29")); - + } $lblsuggest = (($contact['network'] === NETWORK_DFRN) ? t('Suggest friends') : ''); $poll_enabled = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2)); @@@ -562,26 -558,26 +589,28 @@@ // tabs $tab_str = contacts_tab($a, $contact_id, 2); - $lost_contact = (($contact['archive'] && $contact['term-date'] != '0000-00-00 00:00:00' && $contact['term-date'] < datetime_convert('','','now')) ? t('Communications lost with this contact!') : ''); + $lost_contact = (($contact['archive'] && $contact['term-date'] > NULL_DATE && $contact['term-date'] < datetime_convert('','','now')) ? t('Communications lost with this contact!') : ''); - if ($contact['network'] == NETWORK_FEED) + if ($contact['network'] == NETWORK_FEED) { $fetch_further_information = array('fetch_further_information', t('Fetch further information for feeds'), $contact['fetch_further_information'], t('Fetch further information for feeds'), array('0'=>t('Disabled'), '1'=>t('Fetch information'), '2'=>t('Fetch information and keywords'))); - - if (in_array($contact['network'], array(NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2))) + } - if (in_array($contact['network'], array(NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2))) ++ if (in_array($contact['network'], array(NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2))) { $poll_interval = contact_poll_interval($contact['priority'],(! $poll_enabled)); ++ } -- if ($contact['network'] == NETWORK_DFRN) ++ if ($contact['network'] == NETWORK_DFRN) { $profile_select = contact_profile_assign($contact['profile-id'],(($contact['network'] !== NETWORK_DFRN) ? true : false)); ++ } if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS)) AND -- ($contact['rel'] == CONTACT_IS_FOLLOWER)) ++ ($contact['rel'] == CONTACT_IS_FOLLOWER)) { $follow = App::get_baseurl(true)."/follow?url=".urlencode($contact["url"]); ++ } // Load contactact related actions like hide, suggest, delete and others $contact_actions = contact_actions($contact); -- $o .= replace_macros($tpl, array( //'$header' => t('Contact Editor'), '$header' => t("Contact"), @@@ -665,28 -661,28 +694,24 @@@ $ignored = false; $all = false; - if(($a->argc == 2) && ($a->argv[1] === 'all')) { + if (($a->argc == 2) && ($a->argv[1] === 'all')) { $sql_extra = ''; $all = true; -- } - elseif (($a->argc == 2) && ($a->argv[1] === 'blocked')) { - elseif(($a->argc == 2) && ($a->argv[1] === 'blocked')) { ++ } elseif (($a->argc == 2) && ($a->argv[1] === 'blocked')) { $sql_extra = " AND `blocked` = 1 "; $blocked = true; -- } - elseif (($a->argc == 2) && ($a->argv[1] === 'hidden')) { - elseif(($a->argc == 2) && ($a->argv[1] === 'hidden')) { ++ } elseif (($a->argc == 2) && ($a->argv[1] === 'hidden')) { $sql_extra = " AND `hidden` = 1 "; $hidden = true; -- } - elseif (($a->argc == 2) && ($a->argv[1] === 'ignored')) { - elseif(($a->argc == 2) && ($a->argv[1] === 'ignored')) { ++ } elseif (($a->argc == 2) && ($a->argv[1] === 'ignored')) { $sql_extra = " AND `readonly` = 1 "; $ignored = true; -- } - elseif (($a->argc == 2) && ($a->argv[1] === 'archived')) { - elseif(($a->argc == 2) && ($a->argv[1] === 'archived')) { ++ } elseif (($a->argc == 2) && ($a->argv[1] === 'archived')) { $sql_extra = " AND `archive` = 1 "; $archived = true; -- } -- else ++ } else { $sql_extra = " AND `blocked` = 0 "; ++ } $search = ((x($_GET,'search')) ? notags(trim($_GET['search'])) : ''); $nets = ((x($_GET,'nets')) ? notags(trim($_GET['nets'])) : ''); @@@ -758,22 -754,22 +783,20 @@@ $tab_tpl = get_markup_template('common_tabs.tpl'); $t = replace_macros($tab_tpl, array('$tabs'=>$tabs)); -- -- $searching = false; - if($search) { + if ($search) { $search_hdr = $search; $search_txt = dbesc(protect_sprintf(preg_quote($search))); $searching = true; } $sql_extra .= (($searching) ? " AND (name REGEXP '$search_txt' OR url REGEXP '$search_txt' OR nick REGEXP '$search_txt') " : ""); - if ($nets) - if($nets) ++ if ($nets) { $sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets)); ++ } $sql_extra2 = ((($sort_type > 0) && ($sort_type <= CONTACT_IS_FRIEND)) ? sprintf(" AND `rel` = %d ",intval($sort_type)) : ''); -- $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ", intval($_SESSION['uid'])); @@@ -861,23 -857,23 +884,25 @@@ function contacts_tab($a, $contact_id, // Show this tab only if there is visible friend list $x = count_all_friends(local_user(), $contact_id); -- if ($x) ++ if ($x) { $tabs[] = array('label'=>t('Contacts'), 'url' => "allfriends/".$contact_id, 'sel' => (($active_tab == 3)?'active':''), 'title' => t('View all contacts'), 'id' => 'allfriends-tab', 'accesskey' => 't'); ++ } // Show this tab only if there is visible common friend list $common = count_common_friends(local_user(),$contact_id); -- if ($common) ++ if ($common) { $tabs[] = array('label'=>t('Common Friends'), 'url' => "common/loc/".local_user()."/".$contact_id, 'sel' => (($active_tab == 4)?'active':''), 'title' => t('View all common friends'), 'id' => 'common-loc-tab', 'accesskey' => 'd'); ++ } $tabs[] = array('label' => t('Advanced'), 'url' => 'crepair/' . $contact_id, @@@ -895,12 -891,12 +920,13 @@@ function contact_posts($a, $contact_id) { $r = q("SELECT `url` FROM `contact` WHERE `id` = %d", intval($contact_id)); -- if ($r) { ++ if (dbm::is_result($r)) { $contact = $r[0]; $a->page['aside'] = ""; profile_load($a, "", 0, get_contact_details_by_url($contact["url"])); -- } else ++ } else { $profile = ""; ++ } $tab_str = contacts_tab($a, $contact_id, 1); @@@ -929,11 -925,11 +955,10 @@@ function _contact_detail_for_template($ default: break; } - if(($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) { + if (($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) { $url = "redir/{$rr['id']}"; $sparkle = ' class="sparkle" '; -- } -- else { ++ } else { $url = $rr['url']; $sparkle = ''; } diff --cc mod/events.php index 2dd79a0296,60e7b9f390..19078ab26a --- a/mod/events.php +++ b/mod/events.php @@@ -116,13 -109,14 +109,14 @@@ function events_post(App $a) $share = ((intval($_POST['share'])) ? intval($_POST['share']) : 0); - $c = q("select id from contact where uid = %d and self = 1 limit 1", + $c = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval(local_user()) ); - if (count($c)) - if (count($c)) { ++ if (dbm::is_result($c)) { $self = $c[0]['id']; - else + } else { $self = 0; + } if ($share) { @@@ -132,8 -126,7 +126,7 @@@ $str_contact_deny = perms2str($_POST['contact_deny']); // Undo the pseudo-contact of self, since there are real contacts now - if ( strpos($str_contact_allow, '<' . $self . '>') !== false ) - { - if (strpos($str_contact_allow, '<' . $self . '>') !== false ) { ++ if (strpos($str_contact_allow, '<' . $self . '>') !== false) { $str_contact_allow = str_replace('<' . $self . '>', '', $str_contact_allow); } // Make sure to set the `private` field as true. This is necessary to @@@ -151,27 -142,27 +142,27 @@@ $str_group_allow = $str_contact_deny = $str_group_deny = ''; } -- ++ /// @TODO One-time array initialization, one large block $datarray = array(); - $datarray['guid'] = get_guid(32); - $datarray['start'] = $start; - $datarray['finish'] = $finish; - $datarray['summary'] = $summary; - $datarray['desc'] = $desc; - $datarray['location'] = $location; - $datarray['type'] = $type; - $datarray['adjust'] = $adjust; - $datarray['nofinish'] = $nofinish; - $datarray['uid'] = $uid; - $datarray['cid'] = $cid; + $datarray['guid'] = get_guid(32); + $datarray['start'] = $start; + $datarray['finish'] = $finish; + $datarray['summary'] = $summary; + $datarray['desc'] = $desc; + $datarray['location'] = $location; + $datarray['type'] = $type; + $datarray['adjust'] = $adjust; + $datarray['nofinish'] = $nofinish; + $datarray['uid'] = $uid; + $datarray['cid'] = $cid; $datarray['allow_cid'] = $str_contact_allow; $datarray['allow_gid'] = $str_group_allow; - $datarray['deny_cid'] = $str_contact_deny; - $datarray['deny_gid'] = $str_group_deny; - $datarray['private'] = (($private_event) ? 1 : 0); - $datarray['id'] = $event_id; - $datarray['created'] = $created; - $datarray['edited'] = $edited; + $datarray['deny_cid'] = $str_contact_deny; + $datarray['deny_gid'] = $str_group_deny; + $datarray['private'] = (($private_event) ? 1 : 0); + $datarray['id'] = $event_id; + $datarray['created'] = $created; + $datarray['edited'] = $edited; if (intval($_REQUEST['preview'])) { $html = format_event_html($datarray); @@@ -416,28 -407,25 +407,27 @@@ function events_content(App $a) // Passed parameters overrides anything found in the DB if ($mode === 'edit' || $mode === 'new') { - if (!x($orig_event)) $orig_event = array(); - if (!x($orig_event)) {$orig_event = array();} ++ if (!x($orig_event)) { ++ $orig_event = array(); ++ } // In case of an error the browser is redirected back here, with these parameters filled in with the previous values - if (x($_REQUEST,'nofinish')) $orig_event['nofinish'] = $_REQUEST['nofinish']; - if (x($_REQUEST,'adjust')) $orig_event['adjust'] = $_REQUEST['adjust']; - if (x($_REQUEST,'summary')) $orig_event['summary'] = $_REQUEST['summary']; - if (x($_REQUEST,'description')) $orig_event['description'] = $_REQUEST['description']; - if (x($_REQUEST,'location')) $orig_event['location'] = $_REQUEST['location']; - if (x($_REQUEST,'start')) $orig_event['start'] = $_REQUEST['start']; - if (x($_REQUEST,'finish')) $orig_event['finish'] = $_REQUEST['finish']; - } - - if ($mode === 'edit' || $mode === 'new') { + if (x($_REQUEST, 'nofinish')) {$orig_event['nofinish'] = $_REQUEST['nofinish'];} + if (x($_REQUEST, 'adjust')) {$orig_event['adjust'] = $_REQUEST['adjust'];} + if (x($_REQUEST, 'summary')) {$orig_event['summary'] = $_REQUEST['summary'];} + if (x($_REQUEST, 'description')) {$orig_event['description'] = $_REQUEST['description'];} + if (x($_REQUEST, 'location')) {$orig_event['location'] = $_REQUEST['location'];} + if (x($_REQUEST, 'start')) {$orig_event['start'] = $_REQUEST['start'];} + if (x($_REQUEST, 'finish')) {$orig_event['finish'] = $_REQUEST['finish'];} $n_checked = ((x($orig_event) && $orig_event['nofinish']) ? ' checked="checked" ' : ''); - $a_checked = ((x($orig_event) && $orig_event['adjust']) ? ' checked="checked" ' : ''); - $t_orig = ((x($orig_event)) ? $orig_event['summary'] : ''); - $d_orig = ((x($orig_event)) ? $orig_event['desc'] : ''); - $l_orig = ((x($orig_event)) ? $orig_event['location'] : ''); - $eid = ((x($orig_event)) ? $orig_event['id'] : 0); - $cid = ((x($orig_event)) ? $orig_event['cid'] : 0); - $uri = ((x($orig_event)) ? $orig_event['uri'] : ''); + $a_checked = ((x($orig_event) && $orig_event['adjust']) ? ' checked="checked" ' : ''); + $t_orig = ((x($orig_event)) ? $orig_event['summary'] : ''); + $d_orig = ((x($orig_event)) ? $orig_event['desc'] : ''); + $l_orig = ((x($orig_event)) ? $orig_event['location'] : ''); + $eid = ((x($orig_event)) ? $orig_event['id'] : 0); + $cid = ((x($orig_event)) ? $orig_event['cid'] : 0); + $uri = ((x($orig_event)) ? $orig_event['uri'] : ''); if (! x($orig_event)) { $sh_checked = ''; diff --cc mod/profiles.php index d172febcfe,4e82ceaacd..3d7e9fd96d --- a/mod/profiles.php +++ b/mod/profiles.php @@@ -234,11 -233,11 +234,11 @@@ function profiles_post(App $a) $with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : ''); - if (! strlen($howlong)) - $howlong = '0000-00-00 00:00:00'; - else - if(! strlen($howlong)) { ++ if (! strlen($howlong)) { + $howlong = NULL_DATE; + } else { $howlong = datetime_convert(date_default_timezone_get(),'UTC',$howlong); - + } // linkify the relationship target if applicable $withchanged = false; @@@ -248,23 -247,23 +248,24 @@@ $withchanged = true; $prf = ''; $lookup = $with; - if (strpos($lookup,'@') === 0) - if(strpos($lookup,'@') === 0) ++ if (strpos($lookup,'@') === 0) { $lookup = substr($lookup,1); ++ } $lookup = str_replace('_',' ', $lookup); - if(strpos($lookup,'@') || (strpos($lookup,'http://'))) { + if (strpos($lookup,'@') || (strpos($lookup,'http://'))) { $newname = $lookup; ++ /// @TODO Maybe kill those error/debugging-surpressing @ characters $links = @Probe::lrdd($lookup); - if(count($links)) { - foreach($links as $link) { - if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') { + if (count($links)) { + foreach ($links as $link) { + if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') { $prf = $link['@attributes']['href']; } } } -- } -- else { ++ } else { $newname = $lookup; -/* if(strstr($lookup,' ')) { +/* if (strstr($lookup,' ')) { $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1", dbesc($newname), intval(local_user()) diff --cc update.php index 754ed77fc2,3bce492682..d54063ba74 --- a/update.php +++ b/update.php @@@ -530,11 -531,9 +530,12 @@@ function update_1065() } function update_1066() { - $r = q("ALTER TABLE `item` ADD `received` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `edited` "); - if($r) + $r = q("ALTER TABLE `item` ADD `received` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `edited` "); + ++ /// @TODO Decide to use dbm::is_result() here, what does $r include? + if ($r) { q("ALTER TABLE `item` ADD INDEX ( `received` ) "); + } $r = q("UPDATE `item` SET `received` = `edited` WHERE 1"); }