/** * Toggles the subscription. * * @param string $type Subscription type (Project, Milestone, Ticket) * @param integer $id Subscribed object ID */ public function action_toggle($type, $id) { switch ($type) { // Project case 'project': // Delete subscription if (is_subscribed($this->user, $this->project)) { $sub = Subscription::select()->where(array(array('project_id', $this->project->id), array('user_id', $this->user->id), array('type', 'project')))->exec()->fetch(); $sub->delete(); } else { $sub = new Subscription(array('type' => "project", 'project_id' => $this->project->id, 'user_id' => $this->user->id, 'object_id' => $this->project->id)); $sub->save(); } Request::redirectTo($this->project->href()); break; // Milestone // Milestone case 'milestone': // Get milestone $milestone = Milestone::select()->where(array(array('project_id', $this->project->id), array('slug', $id)))->exec()->fetch(); // Delete subscription if (is_subscribed($this->user, $milestone)) { $sub = Subscription::select()->where(array(array('project_id', $this->project->id), array('user_id', $this->user->id), array('type', 'milestone'), array('object_id', $milestone->id)))->exec()->fetch(); $sub->delete(); } else { $sub = new Subscription(array('type' => "milestone", 'project_id' => $this->project->id, 'user_id' => $this->user->id, 'object_id' => $milestone->id)); $sub->save(); } Request::redirectTo($milestone->href()); break; // Milestone // Milestone case 'ticket': // Get ticket $ticket = Ticket::select()->where(array(array('project_id', $this->project->id), array('ticket_id', $id)))->exec()->fetch(); // Delete subscription if (is_subscribed($this->user, $ticket)) { $sub = Subscription::select()->where(array(array('project_id', $this->project->id), array('user_id', $this->user->id), array('type', 'ticket'), array('object_id', $ticket->id)))->exec()->fetch(); $sub->delete(); } else { $sub = new Subscription(array('type' => "ticket", 'project_id' => $this->project->id, 'user_id' => $this->user->id, 'object_id' => $ticket->id)); $sub->save(); } Request::redirectTo($ticket->href()); break; } }
$ret .= "<table>\n"; $ret .= "<tr class=\"" . $bg_style . "\"><td colspan=\"2\"><hr class=\"hr-msg\" /><br/></td></tr>\n"; $ret .= "<tr valign=\"top\" class=\"" . $bg_style . "\">\n"; $ret .= " <td width=\"80\" align=\"center\">\n"; $ret .= " <a href=\"view?webid=" . urlencode($row['from_uri']) . "\" target=\"_blank\"><img title=\"" . $name . "\" alt=\"" . $name . "\" width=\"48\" src=\"" . $pic . "\" style=\"padding: 0px 0px 10px;\" /></a>\n"; $ret .= " </td>\n"; $ret .= " <td>"; $ret .= " <table>\n"; $ret .= " <tr valign=\"top\">\n"; $ret .= " <td><b><a href=\"view?webid=" . urlencode($row['from_uri']) . "\" target=\"_blank\" style=\"font-color: black;\">" . $name . "</a></b> <small style=\"color: grey;\">" . date('Y-m-d H:i:s', $row['date']) . "</small></td>\n"; $ret .= " </tr>\n"; $ret .= " <tr>\n"; $ret .= " <td class=\"message\"><p>" . $text . "</p></td>\n"; $ret .= " </tr>\n"; $ret .= " <tr><td><br/>\n"; if (is_subscribed($row['from_uri'])) { $ret .= " <input type=\"submit\" class=\"btn btn-primary\" name=\"reply\" value=\" Reply \">"; } if ($new == 1) { $ret .= " <input type=\"submit\" class=\"btn btn-primary\" name=\"read\" value=\" Mark as read \">"; } else { if ($new == 0) { $ret .= " <input type=\"submit\" class=\"btn\" name=\"unread\" value=\" Mark as unread \">"; } } $ret .= " <input type=\"submit\" class=\"btn btn-danger\" name=\"delete\" value=\" Delete \"> "; $ret .= " </td>\n"; $ret .= " </tr>\n"; $ret .= " <tr><td> </td></tr>\n"; $ret .= " </table>\n"; $ret .= " </td>\n";
$submit = $_POST['sensors']; $i = 0; foreach ($rows as $row) { if (!empty($submit) and in_array($row['SENSOR_ID'], $submit)) { add_subscription($conn, $row['SENSOR_ID'], $pid); } else { remove_subscription($conn, $row['SENSOR_ID'], $pid); } $i++; } echo "Subscribed to selected sensors. (Total:" . count(get_subscribed_sensors($conn, $pid)) . ")"; } echo "<table border='1' class='table table-hover'>"; echo "<tr><td>Subscribed</td><td>SENSOR_ID</td><td>LOCATION</td></tr>"; foreach ($rows as $row) { if (is_subscribed($conn, $row['SENSOR_ID'], $pid)) { echo "<tr><td><input type='checkbox' name='sensors[]' value='" . $row['SENSOR_ID'] . "' checked></td>"; echo "<td>" . $row['SENSOR_ID'] . "</td>"; echo "<td>" . $row['LOCATION'] . "</td></tr>"; } else { echo "<tr><td><input type='checkbox' name='sensors[]' value='" . $row['SENSOR_ID'] . "'></td><td>" . $row['SENSOR_ID'] . '</td><td>' . $row['LOCATION'] . '</td></tr>'; } } echo "</table>"; oci_close($conn); echo "<br>"; echo "<input type='submit' class='btn btn-primary' name='submit' value='submit'>"; echo "</form>"; ?> <a href="MainPage.php" class="btn btn-primary">Back</a> </div>
/** * Return info about the current document as associative * array. * * @author Andreas Gohr <*****@*****.**> */ function pageinfo() { global $ID; global $REV; global $USERINFO; global $conf; // include ID & REV not redundant, as some parts of DokuWiki may temporarily change $ID, e.g. p_wiki_xhtml // FIXME ... perhaps it would be better to ensure the temporary changes weren't necessary $info['id'] = $ID; $info['rev'] = $REV; if ($_SERVER['REMOTE_USER']) { $info['userinfo'] = $USERINFO; $info['perm'] = auth_quickaclcheck($ID); $info['subscribed'] = is_subscribed($ID, $_SERVER['REMOTE_USER']); $info['client'] = $_SERVER['REMOTE_USER']; // if some outside auth were used only REMOTE_USER is set if (!$info['userinfo']['name']) { $info['userinfo']['name'] = $_SERVER['REMOTE_USER']; } } else { $info['perm'] = auth_aclcheck($ID, '', null); $info['subscribed'] = false; $info['client'] = clientIP(true); } $info['namespace'] = getNS($ID); $info['locked'] = checklock($ID); $info['filepath'] = realpath(wikiFN($ID)); $info['exists'] = @file_exists($info['filepath']); if ($REV) { //check if current revision was meant if ($info['exists'] && @filemtime($info['filepath']) == $REV) { $REV = ''; } else { //really use old revision $info['filepath'] = realpath(wikiFN($ID, $REV)); $info['exists'] = @file_exists($info['filepath']); } } $info['rev'] = $REV; if ($info['exists']) { $info['writable'] = is_writable($info['filepath']) && $info['perm'] >= AUTH_EDIT; } else { $info['writable'] = $info['perm'] >= AUTH_CREATE; } $info['editable'] = $info['writable'] && empty($info['lock']); $info['lastmod'] = @filemtime($info['filepath']); //load page meta data $info['meta'] = p_get_metadata($ID); //who's the editor if ($REV) { $revinfo = getRevisionInfo($ID, $REV, 1024); } else { $revinfo = isset($info['meta']['last_change']) ? $info['meta']['last_change'] : getRevisionInfo($ID, $info['lastmod'], 1024); } $info['ip'] = $revinfo['ip']; $info['user'] = $revinfo['user']; $info['sum'] = $revinfo['sum']; // See also $INFO['meta']['last_change'] which is the most recent log line for page $ID. // Use $INFO['meta']['last_change']['type']==='e' in place of $info['minor']. if ($revinfo['user']) { $info['editor'] = $revinfo['user']; } else { $info['editor'] = $revinfo['ip']; } // draft $draft = getCacheName($info['client'] . $ID, '.draft'); if (@file_exists($draft)) { if (@filemtime($draft) < @filemtime(wikiFN($ID))) { // remove stale draft @unlink($draft); } else { $info['draft'] = $draft; } } return $info; }
function show_forum($forum, $start, $sort_style, $user) { $gotoStr = ""; $nav = show_page_nav($forum, $start); if ($nav) { $gotoStr = "<div align=\"right\">{$nav}</div><br />"; } echo $gotoStr; // Display the navbar start_forum_table(array("", tra("Threads"), tra("Posts"), tra("Author"), tra("Views"), "<nobr>" . tra("Last post") . "</nobr>")); $sticky_first = !$user || !$user->prefs->ignore_sticky_posts; // Show hidden threads if logged in user is a moderator // $show_hidden = is_moderator($user, $forum); $threads = get_forum_threads($forum->id, $start, THREADS_PER_PAGE, $sort_style, $show_hidden, $sticky_first); if ($user) { $subs = BoincSubscription::enum("userid={$user->id}"); } // Run through the list of threads, displaying each of them $n = 0; $i = 0; foreach ($threads as $thread) { $owner = BoincUser::lookup_id($thread->owner); $unread = thread_is_unread($user, $thread); //if ($thread->status==1){ // This is an answered helpdesk thread if ($user && is_subscribed($thread, $subs)) { echo '<tr class="row_hd' . $n . '">'; } else { echo '<tr class="row' . $n . '">'; } echo '<td width="1%"><nobr>'; if ($user && $thread->rating() > $user->prefs->high_rating_threshold) { show_image(EMPHASIZE_IMAGE, "This message has a high average rating", "Highly rated"); } if ($user && $thread->rating() < $user->prefs->low_rating_threshold) { show_image(FILTER_IMAGE, "This message has a low average rating", "Low rated"); } if ($thread->hidden) { echo "[hidden]"; } if ($unread) { if ($thread->sticky) { if ($thread->locked) { show_image(NEW_IMAGE_STICKY_LOCKED, "This thread is sticky and locked, and you haven't read it yet", "sticky/locked/unread"); } else { show_image(NEW_IMAGE_STICKY, "This thread is sticky and you haven't read it yet", "sticky/unread"); } } else { if ($thread->locked) { show_image(NEW_IMAGE_LOCKED, "You haven't read this thread yet, and it's locked", "unread/locked"); } else { show_image(NEW_IMAGE, "You haven't read this thread yet", "unread"); } } } else { if ($thread->sticky) { if ($thread->locked) { show_image(IMAGE_STICKY_LOCKED, "This thread is sticky and locked", "sticky/locked"); } else { show_image(IMAGE_STICKY, "This thread is sticky", "sticky"); } } else { if ($thread->locked) { show_image(IMAGE_LOCKED, "This thread is locked", "locked"); } } } echo "</nobr></td>"; $titlelength = 48; $title = $thread->title; if (strlen($title) > $titlelength) { $title = substr($title, 0, $titlelength) . "..."; } $title = cleanup_title($title); echo '<td class="threadline"> <a href="forum_thread.php?id=' . $thread->id . '"><strong>' . $title . '</strong></a> <br /></td>'; $n = ($n + 1) % 2; echo '<td class="numbers leftborder">' . ($thread->replies + 1) . '</td> <td class="author leftborder">' . user_links($owner) . '</td> <td class="numbers leftborder">' . $thread->views . '</td> <td class="lastpost leftborder">' . time_diff_str($thread->timestamp, time()) . '</td> </tr>'; flush(); } end_table(); echo "<br />{$gotoStr}"; // show page links }
function show_forum($forum, $start, $sort_style, $user) { $page_nav = page_links("forum_forum.php?id={$forum->id}&sort={$sort_style}", $forum->threads, THREADS_PER_PAGE, $start); echo $page_nav; start_forum_table(array("", tra("Threads"), tra("Posts"), tra("Author"), tra("Views"), "<nobr>" . tra("Last post") . "</nobr>")); $sticky_first = !$user || !$user->prefs->ignore_sticky_posts; // Show hidden threads if logged in user is a moderator // $show_hidden = is_moderator($user, $forum); $threads = get_forum_threads($forum->id, $start, THREADS_PER_PAGE, $sort_style, $show_hidden, $sticky_first); if ($user) { $subs = BoincSubscription::enum("userid={$user->id}"); } // Run through the list of threads, displaying each of them // $n = 0; $i = 0; foreach ($threads as $thread) { $owner = BoincUser::lookup_id($thread->owner); if (!$owner) { continue; } $unread = thread_is_unread($user, $thread); //if ($thread->status==1){ // This is an answered helpdesk thread if ($user && is_subscribed($thread, $subs)) { echo '<tr class="row_hd' . $n . '">'; } else { // Just a standard thread. echo '<tr class="row' . $n . '">'; } echo "<td width=\"1%\" class=\"threadicon\"><nobr>"; if ($thread->hidden) { show_image(IMAGE_HIDDEN, tra("This thread is hidden"), tra("hidden")); } else { if ($unread) { if ($thread->sticky) { if ($thread->locked) { show_image(NEW_IMAGE_STICKY_LOCKED, tra("This thread is sticky and locked, and you haven't read it yet"), tra("sticky/locked/unread")); } else { show_image(NEW_IMAGE_STICKY, tra("This thread is sticky and you haven't read it yet"), tra("sticky/unread")); } } else { if ($thread->locked) { show_image(NEW_IMAGE_LOCKED, tra("You haven't read this thread yet, and it's locked"), tra("unread/locked")); } else { show_image(NEW_IMAGE, tra("You haven't read this thread yet"), tra("unread")); } } } else { if ($thread->sticky) { if ($thread->locked) { show_image(IMAGE_STICKY_LOCKED, tra("This thread is sticky and locked"), tra("sticky/locked")); } else { show_image(IMAGE_STICKY, tra("This thread is sticky"), tra("sticky")); } } else { if ($thread->locked) { show_image(IMAGE_LOCKED, tra("This thread is locked"), tra("locked")); } else { show_image(IMAGE_POST, tra("You read this thread"), tra("read")); } } } } echo "</nobr></td>"; $title = cleanup_title($thread->title); //$titlelength = 9999; //if (strlen($title) > $titlelength) { // $title = substr($title, 0, $titlelength)."..."; //} echo "<td class=\"threadline\"><a href=\"forum_thread.php?id={$thread->id}\"><b>{$title}</b></a><br></td>"; $n = ($n + 1) % 2; echo ' <td class="numbers">' . ($thread->replies + 1) . '</td> <td>' . user_links($owner, BADGE_HEIGHT_SMALL) . '</td> <td class="numbers">' . $thread->views . '</td> <td class="lastpost">' . time_diff_str($thread->timestamp, time()) . '</td> </tr> '; flush(); } end_table(); echo "<br>{$page_nav}"; // show page links }
$_SESSION['user_hash'] = null; $_SESSION['feed_hash'] = null; $ret .= $_SESSION['myprofile']->unsubscribe(); } // Unsubscribe from receiving email notifications if (isset($_REQUEST['email']) || $_REQUEST['email'] == 'on') { $ret .= $_SESSION['myprofile']->subscribe_email(); } else { if (!isset($_REQUEST['email']) || $_REQUEST['email'] == 'off') { $ret .= $_SESSION['myprofile']->unsubscribe_email(); } } } } // display form if we are not registered if (!is_subscribed($_SESSION['webid'])) { $ret .= "<h2><strong>Manage notifications</strong></h2>\n"; $ret .= "<form name=\"manage\" method=\"post\">\n"; $ret .= "<input type=\"hidden\" name=\"subscribe\" value=\"1\">\n"; $ret .= "<table border=\"0\">\n"; $ret .= "<tr><td>Would you like to register in order to receive notifications?</td></tr>\n"; $ret .= "<tr><td><br/><input class=\"btn btn-primary\" type=\"submit\" name=\"submit\" value=\"Register\"></td></tr>\n"; $ret .= "</table>\n"; $ret .= "</form>\n"; } else { $ret .= "<h1>The URI for your Wall is <a href=\"" . $base_uri . "/wall?user="******"\">" . $base_uri . "/wall?user="******"</a></h1>\n"; $check_email = ''; if (is_subscribed_email($_SESSION['webid']) == true) { $check_email = 'checked'; } $check_subscription = 'checked';
/** * Return info about the current document as associative * array. * * @author Andreas Gohr <*****@*****.**> */ function pageinfo() { global $ID; global $REV; global $RANGE; global $USERINFO; global $conf; global $lang; // include ID & REV not redundant, as some parts of DokuWiki may temporarily change $ID, e.g. p_wiki_xhtml // FIXME ... perhaps it would be better to ensure the temporary changes weren't necessary $info['id'] = $ID; $info['rev'] = $REV; if ($_SERVER['REMOTE_USER']) { $info['userinfo'] = $USERINFO; $info['perm'] = auth_quickaclcheck($ID); $info['subscribed'] = is_subscribed($ID, $_SERVER['REMOTE_USER'], false); $info['subscribedns'] = is_subscribed($ID, $_SERVER['REMOTE_USER'], true); $info['client'] = $_SERVER['REMOTE_USER']; // set info about manager/admin status $info['isadmin'] = false; $info['ismanager'] = false; if ($info['perm'] == AUTH_ADMIN) { $info['isadmin'] = true; $info['ismanager'] = true; } elseif (auth_ismanager()) { $info['ismanager'] = true; } // if some outside auth were used only REMOTE_USER is set if (!$info['userinfo']['name']) { $info['userinfo']['name'] = $_SERVER['REMOTE_USER']; } } else { $info['perm'] = auth_aclcheck($ID, '', null); $info['subscribed'] = false; $info['client'] = clientIP(true); } $info['namespace'] = getNS($ID); $info['locked'] = checklock($ID); $info['filepath'] = fullpath(wikiFN($ID)); $info['exists'] = @file_exists($info['filepath']); if ($REV) { //check if current revision was meant if ($info['exists'] && @filemtime($info['filepath']) == $REV) { $REV = ''; } elseif ($RANGE) { //section editing does not work with old revisions! $REV = ''; $RANGE = ''; msg($lang['nosecedit'], 0); } else { //really use old revision $info['filepath'] = fullpath(wikiFN($ID, $REV)); $info['exists'] = @file_exists($info['filepath']); } } $info['rev'] = $REV; if ($info['exists']) { $info['writable'] = is_writable($info['filepath']) && $info['perm'] >= AUTH_EDIT; } else { $info['writable'] = $info['perm'] >= AUTH_CREATE; } $info['editable'] = $info['writable'] && empty($info['lock']); $info['lastmod'] = @filemtime($info['filepath']); //load page meta data $info['meta'] = p_get_metadata($ID); //who's the editor if ($REV) { $revinfo = getRevisionInfo($ID, $REV, 1024); } else { if (is_array($info['meta']['last_change'])) { $revinfo = $info['meta']['last_change']; } else { $revinfo = getRevisionInfo($ID, $info['lastmod'], 1024); // cache most recent changelog line in metadata if missing and still valid if ($revinfo !== false) { $info['meta']['last_change'] = $revinfo; p_set_metadata($ID, array('last_change' => $revinfo)); } } } //and check for an external edit if ($revinfo !== false && $revinfo['date'] != $info['lastmod']) { // cached changelog line no longer valid $revinfo = false; $info['meta']['last_change'] = $revinfo; p_set_metadata($ID, array('last_change' => $revinfo)); } $info['ip'] = $revinfo['ip']; $info['user'] = $revinfo['user']; $info['sum'] = $revinfo['sum']; // See also $INFO['meta']['last_change'] which is the most recent log line for page $ID. // Use $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT in place of $info['minor']. if ($revinfo['user']) { $info['editor'] = $revinfo['user']; } else { $info['editor'] = $revinfo['ip']; } // draft $draft = getCacheName($info['client'] . $ID, '.draft'); if (@file_exists($draft)) { if (@filemtime($draft) < @filemtime(wikiFN($ID))) { // remove stale draft @unlink($draft); } else { $info['draft'] = $draft; } } // mobile detection $info['ismobile'] = clientismobile(); return $info; }
function action_buttons($alert_config) { global $username; $results = ''; if ($username == $alert_config['owner']) { $results .= '<a href="edit_alert.php?nid='. $alert_config['nid'] . '">Edit Alert</a> | '; } if (is_subscribed($username,$alert_config['nid'])) { $results .= '<a href="modify_subscription.php?nid='. $alert_config['nid'] . '&action=delete">Un-Subscribe</a> | '; } else { $results .= '<a href="modify_subscription.php?nid='. $alert_config['nid'] . '&action=add">Subscribe</a> | '; } //need to figure this out differently based on db; //if (in_object_key($username,$alert_config->subscribers)){ // $results .= 'Edit Subscription : '; // } else { //$results .= 'Subscribe : '; //} return $results; }
} else { $_SESSION['return_msg'] = $PHPML_LANG["no_email"]; } } elseif ($_REQUEST['action'] == "unsubscribe") { $query = "SELECT *\n FROM " . $phpml['dbMembers'] . "\n WHERE memberid = " . $memberid . "\n AND md5(email) = '" . $_GET['nid'] . "'"; $result = mysql_query($query) or die($PHPML_LANG["error_query"] . ": " . mysql_error()); if ($row = mysql_fetch_assoc($result)) { $dbFirstName = $row['firstname']; $dbLastName = $row['lastname']; $dbEmail = $row['email']; $dbRegi = $row['regdate']; $dbConfirmed = $row['confirmed']; $dbApproved = $row['approved']; $dbDeleted = $row['deleted']; $newEmail = str_replace('@', '[at]', $dbEmail); if (is_subscribed($dbEmail)) { $query = "UPDATE " . $phpml['dbMembers'] . "\n SET email = '" . $newEmail . "',\n confirmed = '0',\n deleted = '1',\n deldate = '" . time() . "',\n IP = CONCAT(IP, '," . $ip . "')\n WHERE memberid = " . $memberid; $result = mysql_query($query) or die($PHPML_LANG["error_query"] . ": " . mysql_error()); $_SESSION['return_msg'] .= $dbEmail . $PHPML_LANG["unsubscribed"]; $subscribeLink = $phpml['url_root'] . '/index.php?pg=subscribe'; $message = $dbEmail . $PHPML_LANG["now_unsubscribed_from"] . $phpml['ListName'] . $PHPML_LANG["compose2"] . ".<br /><br />\n"; $message .= $PHPML_LANG["subscribe"] . ":<br />\n"; $message .= $subscribeLink . " <br />\n"; send_message($dbEmail, $message); if ($phpml['adminBcc']) { $query = "SELECT *\n FROM " . $phpml['dbLists'] . "\n WHERE listid = 1"; $result = mysql_query($query) or die($PHPML_LANG["error_query"] . mysql_error($query)); $row = mysql_fetch_assoc($result); $phpml['FromName'] = $row['listowner']; $phpml['FromAddy'] = $row['listemail']; $message = "Member has unsubscribed: " . $dbFirstName . " " . $dbLastName . " (" . $dbEmail . ")";