Example #1
0
 public function save()
 {
     if (!isset($this->tripId) || $this->tripId === '') {
         // Need a trip ID before we can save. Any trip ID is fine.
         return false;
     }
     if (!isset($this->name) || $this->name === '') {
         // Need a name before we can save. Any name is fine.
         return false;
     }
     $query = "INSERT INTO blogTripAttribute SET " . "tripId=" . db_sql_encode($this->tripId) . ", name=" . db_sql_encode($this->name) . db_created($this->created) . db_updated($this->updated) . ", value=" . db_sql_encode($this->value) . ", deleted=" . db_sql_encode($this->deleted) . ", hash=" . db_sql_encode($this->hash);
     if (mysql_query($query)) {
         // Saved successfully, now load fresh, including created and
         // updated values, and update the hash value
         $mustUpdateHash = true;
         if ($this->hash !== $this->latestHash) {
             // Hash value was manually set, so don't re-calculate it
             $mustUpdateHash = false;
         }
         if ($this->load($this->tripId, $this->name)) {
             if ($mustUpdateHash) {
                 $value = "|" . $this->created . "|" . $this->latestUpdated . "|" . $this->value . "|" . $this->deleted . "|";
                 $this->hash = md5($value);
                 $this->latestHash = $this->hash;
                 $query = "UPDATE blogTripAttribute SET " . "hash=" . db_sql_encode($this->hash) . " WHERE tripId=" . db_sql_encode($this->tripId) . " AND name=" . db_sql_encode($this->name) . " AND updated=" . db_sql_encode($this->latestUpdated);
                 if (mysql_query($query)) {
                     return true;
                 } else {
                     print $query . "<br/>";
                     print " --> error: " . mysql_error() . "<br/>\n";
                     return false;
                 }
             }
             return true;
         } else {
             return false;
         }
     } else {
         print $query . "<br/>";
         print " --> error: " . mysql_error() . "<br/>\n";
         return false;
     }
 }
Example #2
0
 public function save()
 {
     if (!isset($this->tripId) || $this->tripId === "") {
         // Need a trip ID before we can save.
         return false;
     }
     if (!isset($this->mediaId) || $this->mediaId === "") {
         // Need a journal ID before we can save. Any journal ID is fine.
         return false;
     }
     $query = "INSERT INTO blogMedia SET " . "tripId=" . db_sql_encode($this->tripId) . ", mediaId=" . db_sql_encode($this->mediaId) . db_created($this->created) . db_updated($this->updated) . ", type=" . db_sql_encode($this->type) . ", caption=" . db_sql_encode($this->caption) . ", timestamp=" . db_sql_encode($this->timestamp) . ", location=" . db_sql_encode($this->location) . ", width=" . db_sql_encode($this->width) . ", height=" . db_sql_encode($this->height) . ", deleted=" . db_sql_encode($this->deleted) . ", hash=" . db_sql_encode($this->hash);
     // print "Saving to database: $query<br/>\n";
     if (mysql_query($query)) {
         // Saved successfully, now load fresh, including created and
         // updated values, and update the hash value
         $mustUpdateHash = true;
         if ($this->hash !== $this->latestHash) {
             // Hash value was manually set, so don't re-calculate it
             $mustUpdateHash = false;
         }
         if ($this->load($this->tripId, $this->mediaId)) {
             if ($mustUpdateHash) {
                 $value = "|" . $this->created . "|" . $this->latestUpdated . "|" . $this->type . "|" . $this->caption . "|" . $this->timestamp . "|" . $this->location . "|" . $this->width . "|" . $this->height . "|" . $this->deleted . "|";
                 $this->hash = md5($value);
                 $this->latestHash = $this->hash;
                 $query = "UPDATE blogMedia SET " . "hash=" . db_sql_encode($this->hash) . " WHERE tripId=" . db_sql_encode($this->tripId) . " AND mediaId=" . db_sql_encode($this->mediaId) . " AND updated=" . db_sql_encode($this->latestUpdated);
                 if (mysql_query($query)) {
                     return true;
                 } else {
                     print $query . "<br/>";
                     print " --> error: " . mysql_error() . "<br/>\n";
                     return false;
                 }
             }
             return true;
         } else {
             return false;
         }
     } else {
         print $query . "<br/>";
         print " --> error: " . mysql_error() . "<br/>\n";
         return false;
     }
 }
Example #3
0
if (!empty($_GET['doc_id'])) {
    if ($_GET['doc_id'] == 'new') {
        $_GET['doc_id'] = false;
    }
    $f = new form('dl_docs', @$_GET['doc_id'], ($_GET['doc_id'] ? 'Edit' : 'Add') . ' Document');
    $f->set_title_prefix($page['breadcrumbs']);
    $f->set_field(array('name' => 'title', 'label' => getString('title'), 'type' => 'text'));
    $f->unset_fields('extension');
    $f->set_field(array('name' => 'content', 'label' => getString('file'), 'type' => 'file', 'additional' => getString('upload_max') . file_get_max()));
    $f->set_field(array('name' => 'categories', 'label' => getString('categories'), 'type' => 'checkboxes', 'options_table' => 'dl_categories', 'option_title' => 'title', 'linking_table' => 'dl_docs_to_categories', 'object_id' => 'doc_id', 'option_id' => 'category_id'));
    echo $f->draw();
} else {
    $result = db_table('SELECT 
					d.id, 
					d.title, 
					' . db_updated('d') . ', 
					d.extension,
					c.title "group"
			FROM dl_docs d
			JOIN dl_docs_to_categories d2c ON d.id = d2c.doc_id
			JOIN dl_categories c ON d2c.category_id = c.id
			ORDER BY c.precedence, d.title;');
    $links = $page['is_admin'] ? array(url_query_add(array('doc_id' => 'new'), false) => getString('add_new')) : false;
    $t = new table('dl_docs', drawHeader($links));
    $t->set_column('icon', 'd', '&nbsp;');
    $t->set_column('title', 'l', getString('title'));
    $t->set_column('updated', 'r', getString('updated'));
    foreach ($result as &$r) {
        $link = 'info.php?id=' . $r['id'];
        $r['icon'] = file_icon($r['extension'], $link);
        $r['title'] = draw_link($link, $r['title']);
Example #4
0
		u.emerCont1Phone,
		u.emerCont1Cell,
		u.emerCont1Email,
		u.emerCont2Name,
		u.emerCont2Relationship,
		u.emerCont2Phone,
		u.emerCont2Cell,
		u.emerCont2Email,
		u.startDate,
		u.longDistanceCode,
		u.endDate,
		u.is_active,
		u.is_admin,
		r.description rank,
		l.title language,
		' . db_updated('u') . '
	FROM users u
	JOIN languages l ON u.language_id = l.id
	LEFT JOIN users_to_channels u2c ON u.id = u2c.user_id
	LEFT JOIN channels			c ON u2c.channel_id = c.id
	LEFT JOIN intranet_ranks	r ON u.rankID = r.id
	LEFT JOIN organizations		o ON u.organization_id = o.id
	LEFT JOIN departments		d ON d.departmentID	= u.departmentID 				
	LEFT JOIN offices    		f ON f.id			= u.officeID 				
	LEFT JOIN intranet_us_states		s ON u.homeStateID	= s.stateID
	WHERE u.id = ' . $_GET['id']);
$r['nickname'] = trim($r['nickname']);
$r['organization'] = empty($r['organization']) ? '<a href="organizations.php?id=0">' . getString('shared') . '</a>' : '<a href="organizations.php?id=' . $r['organization_id'] . '">' . $r['organization'] . '</a>';
//if (!isset($r['is_active'])) url_change("./");
if (!($img = draw_img(file_dynamic('users', 'image_large', $_GET['id'], 'jpg', $r['updated'])))) {
    $img = draw_img(DIRECTORY_WRITE . "/images/to-be-taken.png");
Example #5
0
 public function save()
 {
     if ($this->authId === "") {
         // Need an auth ID before we can save.
         return false;
     }
     $query = "INSERT INTO blogAuth SET " . "authId=" . db_sql_encode($this->authId) . db_created($this->created) . db_updated($this->updated) . ", userId=" . db_sql_encode($this->userId) . ", expiration=" . db_sql_encode($this->expiration);
     // print "Saving to database: $query<br/>\n";
     if (!mysql_query($query)) {
         print $query . "<br/>";
         print " --> error: " . mysql_error() . "<br/>\n";
         return false;
     }
     // load object to get the new values for created and updated
     Auth::load($this->authId);
     return true;
 }
Example #6
0
<?php

include "../include.php";
echo drawTop();
$t = new table('bb_topics', drawHeader());
$t->set_column('contact', 'l', 'Contact Record');
$t->set_column('action');
//$t->set_column('contact', 'l', 'Done By');
$t->set_column('when', 'r');
$result = db_table('SELECT
			c.id,
			c.firstname,
			c.lastname,
			c.updated_date,
			' . db_updated('c') . '
		FROM contacts c
		ORDER BY updated DESC', 40);
foreach ($result as &$r) {
    $r['contact'] = draw_link('contact.php?id=' . $r['id'], $r['lastname'] . ', ' . $r['firstname']);
    $r['action'] = $r['updated_date'] ? 'Update' : 'New Contact';
    $r['when'] = format_date($r['updated']);
}
echo $t->draw($result);
echo drawBottom();
Example #7
0
} elseif (url_action('delete')) {
    db_delete('dl_categories');
    url_drop('action,id');
}
echo drawTop();
if (!empty($_GET['category_id'])) {
    //category form
    if ($_GET['category_id'] == 'new') {
        $_GET['category_id'] = false;
    }
    $f = new form('dl_categories', $_GET['category_id'], ($_GET['category_id'] ? 'Edit' : 'Add') . ' Category');
    $f->set_title_prefix($page['breadcrumbs']);
    echo $f->draw();
} else {
    //list of categories
    $result = db_table('SELECT id, title, ' . db_updated() . ' FROM dl_categories WHERE is_active = 1 ORDER BY precedence');
    $links = $page['is_admin'] ? array(url_query_add(array('category_id' => 'new'), false) => getString('add_new')) : false;
    $t = new table('dl_categories', drawHeader($links));
    $t->set_column('draggy', 'd', '&nbsp;');
    $t->set_column('title', 'l', getString('title'));
    $t->set_column('updated', 'r', getString('updated'));
    $t->set_column('delete', 'd', '&nbsp;');
    foreach ($result as &$r) {
        $r['draggy'] = draw_img('/images/icons/move.png');
        $r['title'] = draw_link(url_query_add(array('category_id' => $r['id']), false), $r['title']);
        $r['updated'] = format_date($r['updated']);
        $r['delete'] = draw_link(url_query_add(array('action' => 'delete', 'id' => $r['id']), false), 'x', false, 'confirm');
    }
    echo $t->draw($result, getString('categories_empty'));
}
echo drawBottom();
Example #8
0
<?php

include 'include.php';
$users = db_table('SELECT id, ' . db_updated() . ' FROM users');
foreach ($users as $u) {
    echo draw_img(file_dynamic('users', 'image_large', $u['id'], 'jpg', $u['updated']));
    echo draw_img(file_dynamic('users', 'image_medium', $u['id'], 'jpg', $u['updated']));
    echo draw_img(file_dynamic('users', 'image_small', $u['id'], 'jpg', $u['updated']));
}
Example #9
0
				d.id, 
				d.title' . langExt() . ' title, 
				' . db_updated('d') . ', 
				i.extension, 
				i.description alt, 
				c.title' . langExt() . ' "group",
				l.title language
			FROM docs d
			JOIN docs_to_categories d2c ON d.id = d2c.documentID
			JOIN docs_categories c ON d2c.categoryID = c.id
			JOIN docs_types i ON d.type_id = i.id
			JOIN languages l ON d.language_id = l.id
			' . getChannelsWhere('docs', 'd', 'doc_id') . '
			ORDER BY c.precedence, d.title;');
} else {
    $result = db_table('SELECT d.id, d.title, ' . db_updated('d') . ', i.extension, i.description alt, c.title "group"
			FROM docs d
			JOIN docs_to_categories d2c ON d.id = d2c.documentID
			JOIN docs_categories c ON d2c.categoryID = c.id
			JOIN docs_types i ON d.type_id = i.id
			' . getChannelsWhere('docs', 'd', 'doc_id') . '
			ORDER BY c.precedence, d.title;');
}
$links = $page['is_admin'] ? array('edit.php' => getString('add_new')) : false;
$t = new table('docs', drawHeader($links));
$t->set_column('icon', 'd', '&nbsp;');
$t->set_column('title', 'l', getString('title'));
$t->set_column('updated', 'r', getString('updated'));
foreach ($result as &$r) {
    $link = 'info.php?id=' . $r['id'];
    $r['icon'] = file_icon($r['extension'], $link);
Example #10
0
 public function save()
 {
     if (!isset($this->userId) || $this->userId === "") {
         // Need a user ID before we can save. Any user ID is fine.
         return false;
     }
     $query = "INSERT INTO blogUser SET " . "userId=" . db_sql_encode($this->userId) . ", password="******", name=" . db_sql_encode($this->name) . ", externalType=" . db_sql_encode($this->externalType) . ", externalId=" . db_sql_encode($this->externalId) . ", access=" . db_sql_encode($this->access) . ", email=" . db_sql_encode($this->email) . ", notification=" . db_sql_encode($this->notification) . ", tempCode=" . db_sql_encode($this->tempCode) . ", deleted=" . db_sql_encode($this->deleted) . ", hash=" . db_sql_encode($this->hash);
     // print "Saving to database: $query<br/>\n";
     if (mysql_query($query)) {
         // Saved successfully, now load fresh, including created and
         // updated values, and update the hash value
         $mustUpdateHash = true;
         if ($this->hash !== $this->latestHash) {
             // Hash value was manually set, so don't re-calculate it
             $mustUpdateHash = false;
         }
         if ($this->load($this->userId)) {
             if ($mustUpdateHash) {
                 $value = "|" . $this->password . "|" . $this->created . "|" . $this->latestUpdated . "|" . $this->name . "|" . $this->externalType . "|" . $this->externalId . "|" . $this->access . "|" . $this->email . "|" . $this->notification . "|" . $this->tempCode . "|" . $this->deleted . "|";
                 $this->hash = md5($value);
                 $this->latestHash = $this->hash;
                 $query = "UPDATE blogUser SET " . "hash=" . db_sql_encode($this->hash) . " WHERE userId=" . db_sql_encode($this->userId) . " AND updated=" . db_sql_encode($this->latestUpdated);
                 if (mysql_query($query)) {
                     return true;
                 } else {
                     print $query . "<br/>";
                     print " --> error: " . mysql_error() . "<br/>\n";
                     return false;
                 }
             }
             return true;
         } else {
             return false;
         }
     } else {
         print $query . "<br/>";
         print " --> error: " . mysql_error() . "<br/>\n";
         return false;
     }
 }
Example #11
0
<?php

include '../../include.php';
if (url_action('delete')) {
    db_delete('soc_whatsnew', $_GET['delete_id']);
    url_drop('action,delete_id');
}
echo drawTop();
$t = new table('soc_whatsnew', drawHeader(array('edit/' => getString('add_new'))));
$t->set_column('draggy', 'd', '&nbsp;');
$t->set_column('title', 'l', getString('title'));
$t->set_column('updated', 'r', getString('updated'));
$t->set_column('delete', 'd', '&nbsp;');
$result = db_table('SELECT w.id, w.title' . langExt() . ' title, ' . db_updated('w') . ' FROM soc_whatsnew w WHERE w.is_active = 1 ORDER BY w.precedence');
foreach ($result as &$r) {
    $r['draggy'] = draw_img('/images/icons/move.png');
    $r['title'] = draw_link('edit.php?id=' . $r['id'], format_string($r['title'], 70));
    $r['updated'] = format_date($r['updated']);
    $r['delete'] = drawColumnDelete($r['id']);
}
echo $t->draw($result);
echo drawBottom();
Example #12
0
<?php

include '../../include.php';
if (url_action('delete')) {
    db_delete('soc_members', $_GET['delete_id']);
    url_drop('action,delete_id');
}
echo drawTop();
$t = new table('soc_members', drawHeader(array('edit.php' => 'Add New')));
$t->set_column('is_selected', 'd', '&nbsp;');
$t->set_column('name');
$t->set_column('updated', 'r');
$t->set_column('delete', 'd', '&nbsp;');
$result = db_table('SELECT m.id, m.name, m.is_selected, c.en "group", ' . db_updated('m') . ' FROM soc_members m JOIN jr_countries c ON m.country_id = c.id WHERE m.is_active = 1 ORDER BY c.en, m.name');
foreach ($result as &$r) {
    $r['is_selected'] = draw_form_checkbox('foo', $r['is_selected'], false, 'ajax_set(\'soc_members\', \'is_selected\', ' . $r['id'] . ', ' . abs($r['is_selected'] - 1) . ');');
    $r['name'] = draw_link('edit.php?id=' . $r['id'], format_string($r['name'], 70));
    $r['updated'] = format_date($r['updated']);
    $r['delete'] = drawColumnDelete($r['id']);
}
echo $t->draw($result);
echo drawBottom();
Example #13
0
if ($_SESSION["departmentID"] != 8) {
    echo drawMessage("This page is specific to IT.");
    drawBottom();
    exit;
}
?>
<table class="left" cellspacing="1">
	<?php 
echo drawHeaderRow("Laptop Requests", 5);
$result = db_query('SELECT
						t.title,
						t.statusID,
						(SELECT count(*) FROM helpdesk_tickets_followups f WHERE f.ticketID = t.id) ticketfollowups,
						t.created_user,
						t.updated_date,
						' . db_updated('t') . ',
						t.id,
						t.ownerID,
						t.priorityID,
						t.created_date,
						ISNULL(u.nickname, u.firstname) first,
						u.lastname last,
						(SELECT COUNT(*) FROM users_to_modules a WHERE a.module_id = 3 AND a.user_id = t.created_user) is_adminIT
					FROM helpdesk_tickets t
					JOIN users u ON u.id    = t.created_user
					WHERE t.statusID <> 9 AND t.type_id = 1
					ORDER BY t.created_date DESC');
if (db_found($result)) {
    ?>
	<tr>
		<th>User</th>
Example #14
0
function emailITticket($id, $scenario, $admin = false, $debug = false)
{
    global $_josh, $page;
    $ticket = db_grab('SELECT
			u.id,
			(SELECT COUNT(*) FROM users_to_modules a WHERE a.user_id = u.id AND a.module_id = 3) isUserAdmin,
			t.title,
			t.created_user,
			t.description,
			t.departmentID,
			ISNULL(u.nickname, u.firstname) first,
			u.lastname last,
			u.email,
			' . db_updated('u') . ',
			t.created_date,
			t.priorityID,
			t.statusID,
			d.shortName department,
			t.type_id,
			y.description type,
			u2.email as ownerEmail,
			t.ownerID,
			ISNULL(u2.nickname, u2.firstname) as ownerName
		FROM helpdesk_tickets t
		LEFT JOIN helpdesk_tickets_types y	ON t.type_id = y.id
		JOIN users u ON t.created_user = u.id
		JOIN departments d ON t.departmentID = d.departmentID
		LEFT JOIN users u2 ON t.ownerID = u2.id
		WHERE t.id = ' . $id);
    //yellow box
    if ($scenario == "followup") {
        $subject = "Followup On Your Helpdesk Ticket";
        $message = drawMessage('There\'s been followup on your Helpdesk ticket - please see below.  <b>Don\'t reply to this email!</b>  Instead, please ' . draw_link('/helpdesk/ticket.php?id=' . $id, 'view your ticket') . ' in the intranet ticketing system.<br><br><b>Note:</b> if you add this sender to your "safe senders list," pictures will always download.');
    } elseif ($scenario == "followupadmin") {
        $subject = "Admin Followup on Helpdesk Ticket";
        $message = drawMessage(draw_link('/staff/view.php?id=' . user(), $_SESSION['full_name']) . ' just made an administrative followup on this Helpdesk ticket.  Regular staff were not copied on this message.');
    } elseif ($scenario == "closed") {
        $subject = "Your Ticket Has Been Closed";
        $message = drawMessage('This is to let you know that your ticket has been closed.  <b>Don\'t reply to this email!</b>  You can still followup on this thread by ' . draw_link('/helpdesk/ticket.php?id=' . $id, 'viewing your ticket') . ' in the intranet ticketing system.<br><br><b>Note:</b> if you add this sender to your "safe senders list," pictures will always download.');
    } elseif ($scenario == "assign") {
        $subject = "Your Ticket Has Been Assigned";
        $message = drawMessage(draw_link('/staff/view.php?id=' . user(), $_SESSION["full_name"]) . ' has assigned this ticket to ' . draw_link('/staff/view.php?id=' . $ticket['ownerID'], $ticket["ownerName"]) . '<b>Don\'t reply to this email!</b>  Instead, please ' . draw_link('/helpdesk/ticket.php?id=' . $id, 'view your ticket') . ' in the intranet ticketing system.<br><br><b>Note:</b> if you add this sender to your "safe senders list," pictures will always download.');
    } elseif ($scenario == "new") {
        $subject = "New " . $ticket["department"] . " Ticket Posted";
        $message = drawMessage('This is to let you know that a new ticket has just been posted to the Helpdesk.  You can ' . draw_link('/helpdesk/ticket.php?id=' . $id, 'view the ticket') . ' in the intranet ticketing system.');
    } elseif ($scenario == "critical") {
        $subject = "Critical " . $ticket["department"] . " Ticket Still Open";
        $message = drawMessage('A ticket flagged "Critical" is open on the Helpdesk.  You can ' . draw_link('/helpdesk/ticket.php?id=' . $id, 'view the ticket') . ' in the intranet ticketing system.');
    }
    //$message .= drawtableStart() . drawHeaderRow(false, 2);
    //recipients arrays
    $users = array();
    $admins = array();
    if ($ticket["isUserAdmin"]) {
        $admins[] = $ticket["email"];
    } else {
        $users[] = $ticket["email"];
    }
    if ($page['is_admin']) {
        $admins[] = $_SESSION["email"];
    } else {
        $users[] = $_SESSION["email"];
    }
    //add owner if ticket is assigned
    if ($ticket["ownerEmail"]) {
        $admins[] = $ticket["ownerEmail"];
    }
    //owner logically has to be admin
    $d_user = new display($page['breadcrumbs'] . $ticket['title'], false, false, 'thread');
    $d_admin = new display($page['breadcrumbs'] . $ticket['title'], false, false, 'thread');
    $d_user->row(drawName($ticket['created_user'], $ticket['first'] . ' ' . $ticket['last'], $ticket['created_date'], true, BR, $ticket['updated']), draw_h1($ticket['title']) . $ticket['description']);
    $d_admin->row(drawName($ticket['created_user'], $ticket['first'] . ' ' . $ticket['last'], $ticket['created_date'], true, BR, $ticket['updated']), draw_h1($ticket['title']) . $ticket['description']);
    //get followups
    $followups = db_query('SELECT
			u.id,
			f.message,
			(SELECT COUNT(*) FROM users_to_modules u2m WHERE u2m.user_id = u.id AND u2m.module_id = 3 AND u2m.is_admin = 1) isUserAdmin,
			ISNULL(u.nickname, u.firstname) firstname,
			u.lastname,
			u.email,
			f.created_date,
			f.is_admin,
			f.created_user,
			' . db_updated('u') . '
		FROM helpdesk_tickets_followups f
		INNER JOIN users  u  ON f.created_user	= u.id
		WHERE f.ticketID = ' . $id . ' ORDER BY f.created_date');
    while ($f = db_fetch($followups)) {
        $d_admin->row(drawName($f['created_user'], $f['firstname'] . ' ' . $f['lastname'], $f['created_date'], true, BR, $f['updated']), $f['message']);
        if (!$f['is_admin']) {
            $d_user->row(drawName($f['created_user'], $f['firstname'] . ' ' . $f['lastname'], $f['created_date'], true, BR, $f['updated']), $f['message']);
        }
        if ($f['isUserAdmin']) {
            $admins[] = $f['email'];
        } else {
            $users[] = $f['email'];
        }
    }
    $admins = array_remove($_SESSION['email'], array_unique($admins));
    $users = array_remove($_SESSION['email'], array_unique($users));
    if ($debug) {
        die(drawEmail($message . $d_admin->draw()));
    }
    //special codes for email
    //todo: put this in db, possibly by adding something to the users table or something
    if ($scenario == "new" && $ticket["departmentID"] == 3) {
        $admins = array('*****@*****.**', '*****@*****.**', '*****@*****.**');
    }
    if ($scenario == "new" && $ticket["departmentID"] == 13) {
        $admins = array('*****@*****.**', '*****@*****.**');
    }
    if ($scenario == "new" && $ticket["departmentID"] == 2) {
        $admins = array('*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**');
    }
    if ($scenario == "critical" && $ticket["departmentID"] == 8) {
        $admins = array('*****@*****.**');
    }
    if (count($admins)) {
        //$admins = join(", ", $admins);
        email($admins, drawEmail($message . $d_admin->draw()), $subject);
        error_debug('admin message emailed to ' . implode(', ', $admins) . ' admins', __FILE__, __LINE__);
    }
    if (count($users) && $scenario != "followupadmin" && !$admin) {
        //$users = join(", ", $users);
        email($users, drawEmail($message . $d_user->draw()), $subject);
        error_debug('user message emailed to ' . implode(', ', $users) . ' users', __FILE__, __LINE__);
    }
}
Example #15
0
 public static function set($name = '', $value = '')
 {
     if (!isset($name) || $name === '') {
         return false;
     }
     if (!isset($value)) {
         return false;
     }
     $query = "INSERT INTO blogSetting SET " . "name=" . db_sql_encode($name) . ", value=" . db_sql_encode($value) . db_updated(null) . " ON DUPLICATE KEY UPDATE " . "value=" . db_sql_encode($value) . db_updated(null);
     if (!mysql_query($query)) {
         // Error executing the query
         print $query . "<br/>";
         print " --> error: " . mysql_error() . "<br/>\n";
         return false;
     }
     return true;
 }
Example #16
0
 public function save()
 {
     if (!isset($this->tripId) || $this->tripId === "") {
         // Need a trip ID before we can save.
         return false;
     }
     if (!isset($this->commentId) || $this->commentId === "") {
         // Need a comment ID before we can save. Any comment ID is fine.
         return false;
     }
     $query = "INSERT INTO blogComment SET " . "tripId=" . db_sql_encode($this->tripId) . ", commentId=" . db_sql_encode($this->commentId) . db_created($this->created) . db_updated($this->updated) . ", userId=" . db_sql_encode($this->userId) . ", referenceId=" . db_sql_encode($this->referenceId) . ", commentText=" . db_sql_encode($this->commentText) . ", deleted=" . db_sql_encode($this->deleted) . ", hash=" . db_sql_encode($this->hash);
     // print "Saving to database: $query<br/>\n";
     if (mysql_query($query)) {
         // Saved successfully, now load fresh, including created and
         // updated values, and update the hash value
         $mustUpdateHash = true;
         if ($this->hash !== $this->latestHash) {
             // Hash value was manually set, so don't re-calculate it
             $mustUpdateHash = false;
         }
         if ($this->load($this->tripId, $this->commentId)) {
             if ($mustUpdateHash) {
                 $value = "|" . $this->created . "|" . $this->latestUpdated . "|" . $this->userId . "|" . $this->referenceId . "|" . $this->commentText . "|" . $this->deleted . "|";
                 $this->hash = md5($value);
                 $this->latestHash = $this->hash;
                 $query = "UPDATE blogComment SET " . "hash=" . db_sql_encode($this->hash) . " WHERE tripId=" . db_sql_encode($this->tripId) . " AND commentId=" . db_sql_encode($this->commentId) . " AND updated=" . db_sql_encode($this->latestUpdated);
                 if (mysql_query($query)) {
                     return true;
                 } else {
                     print $query . "<br/>";
                     print " --> error: " . mysql_error() . "<br/>\n";
                     return false;
                 }
             }
             return true;
         } else {
             return false;
         }
     } else {
         print $query . "<br/>";
         print " --> error: " . mysql_error() . "<br/>\n";
         return false;
     }
 }
Example #17
0
function bbDrawTopic($id, $email = false)
{
    global $_josh, $page;
    if (!($r = db_grab('SELECT 
		t.title' . langExt() . ' title,
		t.description' . langExt() . ' description,
		t.created_date,
		t.is_admin,
		t.type_id,
		y.title' . langExt() . ' type,
		u.id created_user,
		ISNULL(u.nickname, u.firstname) firstname,
		u.lastname,
		' . db_updated('u') . '
	FROM bb_topics t
	JOIN users u ON t.created_user = u.id
	LEFT JOIN bb_topics_types y ON t.type_id = y.id
	WHERE t.id = ' . $id))) {
        return false;
    }
    $return = '';
    if ($r['is_admin'] == 1) {
        $return .= drawMessage(getString('topic_admin'));
    }
    $options = ($page['is_admin'] || user() == $r['created_user']) && !$email ? array('edit.php?id=' . $id => getString('edit'), 'javascript:checkDelete();' => getString('delete')) : false;
    //display topic thread
    $d = new display($page['breadcrumbs'] . $r['title'], false, $options, 'thread');
    //if categories
    if (getOption('bb_types') && $r['type']) {
        $r['description'] .= draw_div_class('light', getString('category') . ': ' . draw_link('category.php?id=' . $r['type_id'], $r['type']));
    }
    //channels
    if (getOption('channels') && ($channels = db_array('SELECT c.title' . langExt() . ' title FROM channels c JOIN bb_topics_to_channels t2c ON c.id = t2c.channel_id WHERE t2c.topic_id = ' . $id . ' ORDER BY title' . langExt()))) {
        $r['description'] .= draw_div_class('light', 'Networks: ' . implode(', ', $channels));
    }
    $d->row(drawName($r['created_user'], $r['firstname'] . ' ' . $r['lastname'], $r['created_date'], true, BR, $r['updated']), '<h1>' . $r['title'] . '</h1>' . $r['description']);
    //append followups
    if ($r['is_admin']) {
        $return .= $d->draw();
    } else {
        $followups = db_table('SELECT
					f.description' . langExt() . ' description,
					ISNULL(u.nickname, u.firstname) firstname,
					u.lastname,
					f.created_date,
					f.created_user,
					' . db_updated('u') . '
				FROM bb_followups f
				JOIN users u ON u.id = f.created_user
				WHERE f.is_active = 1 AND f.topic_id = ' . $id . '
				ORDER BY f.created_date');
        foreach ($followups as $f) {
            $d->row(drawName($f['created_user'], $f['firstname'] . ' ' . $f['lastname'], $f['created_date'], true, BR, $f['updated']), $f['description']);
        }
        $return .= $d->draw();
        if (!$email) {
            //add a followup form
            $f = new form('bb_followups', false, getString('add_followup'));
            $f->unset_fields('topic_id');
            langUnsetFields($f, 'description');
            $return .= $f->draw(false, false);
        }
    }
    return $return;
}