/** * Cancels an edit operation * @param string The current url option */ function cancelWeblink($option) { josSpoofCheck(); global $database; $row = new mosWeblink($database); $row->bind($_POST); $row->checkin(); mosRedirect("index2.php?option={$option}"); }
/** * Saves the record on an edit form submit * @param database A database connector object */ function saveWeblink($option) { global $database, $my; if ($my->gid < 1) { mosNotAuth(); return; } // security check to see if link exists in a menu $link = 'index.php?option=com_weblinks&task=new'; $query = "SELECT id" . "\n FROM #__menu" . "\n WHERE link LIKE '%{$link}%'" . "\n AND published = 1"; $database->setQuery($query); $exists = $database->loadResult(); if (!$exists) { mosNotAuth(); return; } // simple spoof check security josSpoofCheck(); $row = new mosWeblink($database); if (!$row->bind($_POST, 'published')) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } // sanitise id field // $row->id = (int) $row->id; // until full edit capabilities are given for weblinks - limit saving to new weblinks only $row->id = 0; $isNew = $row->id < 1; $row->date = date('Y-m-d H:i:s'); if (!$row->check()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $row->checkin(); // admin users gid $gid = 25; // list of admins $query = "SELECT email, name" . "\n FROM #__users" . "\n WHERE gid = " . (int) $gid . "\n AND sendEmail = 1"; $database->setQuery($query); if (!$database->query()) { echo $database->stderr(true); return; } $adminRows = $database->loadObjectList(); // send email notification to admins foreach ($adminRows as $adminRow) { mosSendAdminMail($adminRow->name, $adminRow->email, '', 'Weblink', $row->title, $my->username); } $msg = $isNew ? _THANK_SUB : ''; mosRedirect('index.php', $msg); }
/** * Cancels an edit operation * @param string The current url option */ function cancelWeblink($option) { global $database; $row = new mosWeblink($database); $row->bind($_POST); // sanitize $row->id = intval($row->id); $row->checkin(); mosRedirect("index2.php?option={$option}"); }
/** * Saves the record on an edit form submit * @param database A database connector object */ function saveWeblink($option) { global $database, $my; if ($my->gid < 1) { mosNotAuth(); return; } $row = new mosWeblink($database); if (!$row->bind($_POST, "approved published")) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $isNew = $row->id < 1; $row->date = date("Y-m-d H:i:s"); if (!$row->check()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $row->checkin(); /** Notify admin's */ $query = "SELECT email, name" . "\n FROM #__users" . "\n WHERE usertype = 'superadministrator'" . "\n AND sendemail = '1'"; $database->setQuery($query); if (!$database->query()) { echo $database->stderr(true); return; } $adminRows = $database->loadObjectList(); foreach ($adminRows as $adminRow) { $type = "Weblink"; $title = $linktitle; mosSendAdminMail($adminRow->name, $adminRow->email, "", $type, $row->title, $my->name); } $msg = $isNew ? _THANK_SUB : ''; $Itemid = mosGetParam($_POST, 'Returnid', ''); mosRedirect('index.php?Itemid=' . $Itemid . '&mosmsg=' . $msg); }
/** * Saves the record on an edit form submit * @param database A database connector object */ function saveWeblink($option) { global $database, $my, $mosConfig_absolute_path, $mosConfig_mailfrom; if ($my->gid < 1) { mosNotAuth(); return; } $row = new mosWeblink($database); if (!$row->bind($_POST, "approved published")) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } // sanitize $row->id = intval($row->id); $isNew = $row->id < 1; $row->date = date("Y-m-d H:i:s"); $row->title = $database->getEscaped($row->title); $row->catid = $database->getEscaped($row->catid); if (!$row->check()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $row->checkin(); // messaging for new items require_once $mosConfig_absolute_path . '/components/com_messages/messages.class.php'; $query = "SELECT id,email FROM #__users WHERE sendEmail = '1'"; $database->setQuery($query); $rows = $database->loadObjectList(); foreach ($rows as $user) { // admin message $msg = new mosMessage($database); $msg->send($my->id, $user->id, T_("New Item"), sprintf(T_('A new WebLink has been submitted by [ %s ] titled [ %s ] '), $my->username, $row->title)); // email message mosMail($mosConfig_mailfrom, $mosConfig_mailfrom, $user->email, "A new Web Link has been submitted", 'A new WebLink has been submitted by [' . $my->username . '] titled [' . $row->title . ']. Please login to view and approve it.'); } $msg = $isNew ? T_('Thanks for your submission; it will be reviewed before being posted to the site.') : ''; $Itemid = mosGetParam($_POST, 'Returnid', ''); mosRedirect('index.php?Itemid=' . $Itemid, $msg); }