$postcount = count($waka['posts']); for ($p = 0; $p < $postcount; $p++) { for ($p2 = 0; $p2 < count($oldplist); $p2++) { if ($oldplist[$p2] == $waka['posts'][$p]['id']) { array_splice($oldplist, $p2, 1); } } if (strnatcmp($waka['posts'][$p]['dateCreated'], $_REQUEST['d']) > 0) { $c = count($out); $out[$c]['html'] = renderPost($waka['posts'][$p], $waka['users'], $user); $out[$c]['location'] = 'post_' . $waka['posts'][$p]['id']; $out[$c]['type'] = 'new'; } else { if (strnatcmp($waka['posts'][$p]['dateContentTouched'], $_REQUEST['d']) > 0) { $c = count($out); $out[$c]['html'] = renderItemContent($waka['posts'][$p], 'post_' . $waka['posts'][$p]['id']); $out[$c]['location'] = 'post_' . $waka['posts'][$p]['id'] . '_content'; $out[$c]['type'] = 'changed'; if ($user['type'] == 'editor' && userMayEdit($user['email'], $waka['posts'][$p]['users'])) { $c = count($out); $out[$c]['html'] = renderItemContentForm($waka['posts'][$p], 'post_' . $waka['posts'][$p]['id']); $out[$c]['location'] = 'post_' . $waka['posts'][$p]['id'] . '_content_form'; $out[$c]['type'] = 'changed'; } } if (strnatcmp($waka['posts'][$p]['dateImagesTouched'], $_REQUEST['d']) > 0) { $c = count($out); $out[$c]['html'] = renderItemImages($waka['posts'][$p], 'post_' . $waka['posts'][$p]['id']); $out[$c]['location'] = 'post_' . $waka['posts'][$p]['id'] . '_images'; $out[$c]['type'] = 'changed'; if ($user['type'] == 'editor' && userMayEdit($user['email'], $waka['posts'][$p]['users'])) {
function renderPost($post, $users, $user) { $permitted = false; if ($user['type'] == 'editor' && userMayEdit($user['email'], $post['users'])) { $permitted = true; } $email = $user['email']; $str = ''; $str .= '<div class="post_avatar" id="post_' . $post['id'] . '_avatar">'; $str .= renderAvatar($post); $str .= '</div>'; $str .= '<div class="post_wrapper" id="post_wrapper_' . $post['id'] . '"><div class="post_small_gradient" style="display:none" id="post_small_gradient_' . $post['id'] . '" onclick="minmaxPost(\'' . $post['id'] . '\');"></div><div class="post_meta"><a href="javascript:minmaxPost(\'' . $post['id'] . '\')" style="text-decoration:none;">[' . $post['id'] . '] <small><b><span class="time" utctime="' . convert_datetime($post['dateCreated']) . '">' . $post['dateCreated'] . ' (UTC)</span></b>'; $str .= '</small></a>'; if ($permitted) { $str .= '<div class="postEditSwitch" id="postEditSwitch_' . $post['id'] . '_on"><a href="javascript:switchPostEdit(\'' . $post['id'] . '\')"><img src="img/Actions-document-edit-icon-1.png"></a></div>'; } if ($permitted) { $str .= '<div class="postEditSwitch" id="postEditSwitch_' . $post['id'] . '_off" style="display:none;"><a href="javascript:switchPostEdit(\'' . $post['id'] . '\')"><img src="img/Actions-application-exit-icon-1.png"></a></div>'; } $str .= '</div>'; $str .= '<div class="post_display" id="post_' . $post['id'] . '_display">'; $str .= '<div class="post_content" id="post_' . $post['id'] . '_content">'; $str .= renderItemContent($post, 'post_' . $post['id']); $str .= '</div><div class="post_images" id="post_' . $post['id'] . '_images">'; $str .= renderItemImages($post, 'post_' . $post['id']); $str .= '</div><div class="post_files" id="post_' . $post['id'] . '_files">'; $str .= renderItemFiles($post, 'post_' . $post['id']); $str .= '</div>'; $str .= '</div>'; if ($permitted) { $str .= '<div class="post_form" id="post_' . $post['id'] . '_form" style="display:none;">'; $str .= '<div class="post_content_form" id="post_' . $post['id'] . '_content_form">'; $str .= renderItemContentForm($post, 'post_' . $post['id']); $str .= '</div><div class="post_images_form" id="post_' . $post['id'] . '_images_form">'; $str .= renderItemImagesForm($post, 'post_' . $post['id']); $str .= '</div><div class="post_files_form" id="post_' . $post['id'] . '_files_form">'; $str .= renderItemFilesForm($post, 'post_' . $post['id']); $str .= '</div><div class="post_users_form" id="post_' . $post['id'] . '_users_form">'; $str .= renderItemUsersForm($post, $users, 'post_' . $post['id']); $str .= '</div>'; $str .= '</div>'; } if ($user['type'] != 'public') { $str .= '<div class="post_comments" id="post_' . $post['id'] . '_comments">'; $str .= renderItemComments($post, $user, 'post_' . $post['id']); $str .= '</div>'; } //$str.= '</div>'; $str .= '</div>'; $str .= '<div style="clear: both;"></div>'; return $str; }