function sendMail() { global $database, $my, $acl; global $mosConfig_sitename; global $mosConfig_mailfrom, $mosConfig_fromname; $mode = mosGetParam($_POST, 'mm_mode', 0); $subject = mosGetParam($_POST, 'mm_subject', ''); $gou = mosGetParam($_POST, 'mm_group', NULL); $recurse = mosGetParam($_POST, 'mm_recurse', 'NO_RECURSE'); $inc_blocked = mosGetParam($_POST, 'inc_blocked', 0); // pulls message inoformation either in text or html format if ($mode) { $message_body = $_POST['mm_message']; } else { // automatically removes html formatting $message_body = mosGetParam($_POST, 'mm_message', ''); } $message_body = stripslashes($message_body); if (!$message_body || !$subject || $gou === null) { $msg = T_('Please fill in the form correctly'); mosRedirect('index2.php?option=com_massmail&mosmsg=' . $msg); } // get users in the group out of the acl $to = $acl->get_group_objects($gou, 'ARO', $recurse); $rows = array(); if (count($to['users']) || $gou === '0') { // Get sending email address $query = "SELECT email FROM #__users WHERE id='{$my->id}'"; $database->setQuery($query); $my->email = $database->loadResult(); // Get all users email and group except for senders $query = "SELECT email FROM #__users" . "\n WHERE id != '{$my->id}'" . ($inc_blocked !== '0' ? " AND block = 0 " : '') . ($gou !== '0' ? " AND id IN (" . implode(',', $to['users']) . ")" : ''); $database->setQuery($query); $rows = $database->loadObjectList(); // Build e-mail message format $message_header = sprintf(T_("This is an email from '%s'\n\nMessage:\n"), $mosConfig_sitename); $message = $message_header . $message_body; $subject = $mosConfig_sitename . ' / ' . stripslashes($subject); //Send email foreach ($rows as $row) { mosMail($mosConfig_mailfrom, $mosConfig_fromname, $row->email, $subject, $message, $mode); } } $msg = sprintf(Tn_('E-mail sent to %d user.', 'E-mail sent to %d users.', count($rows)), count($rows)); mosRedirect('index2.php?option=com_massmail', $msg); }
} else { $database->setQuery("UPDATE {$tn} SET checked_out=0, checked_out_time='0000-00-00 00:00:00' WHERE checked_out > 0"); } $res = $database->query(); if ($res == 1) { if ($num > 0) { echo "<tr class=\"row{$k}\">"; echo "\n\t<td width=\"350\">" . T_('Checking table') . " - {$tn}</td>"; echo "\n\t<td width=\"150\">" . sprintf(Tn_('Checked in <strong>%d</strong> item', 'Checked in <strong>%d</strong> items', $num), $num) . "</td>"; echo "\n\t<td width=\"100\" align=\"center\"><img src=\"images/tick.png\" border=\"0\" alt=\"tick\" /></td>"; echo "\n\t<td> </td>"; echo "\n</tr>"; } else { echo "<tr class=\"row{$k}\">"; echo "\n\t<td width=\"350\">" . T_('Checking table') . " - {$tn}</td>"; echo "\n\t<td width=\"150\">" . sprintf(Tn_('Checked in <strong>%d</strong> item', 'Checked in <strong>%d</strong> items', $num), $num) . "</td>"; echo "\n\t<td width=\"100\"> </td>"; echo "\n\t<td> </td>"; echo "\n</tr>"; } $k = 1 - $k; } } } ?> <tr> <td colspan="4"><strong><?php echo T_('Checked out items have now been all checked in'); ?> </strong></td> </tr>
/** * Changes the state of one or more content pages * @param string The name of the category section * @param integer A unique category id (passed from an edit form) * @param array An array of unique category id numbers * @param integer 0 if unpublishing, 1 if publishing * @param string The name of the current user */ function changeState($cid = null, $state = 0, $option) { global $database, $my; if (count($cid) < 1) { $action = $state == 1 ? T_('publish') : ($state == -1 ? T_('archive') : T_('unpublish')); echo "<script> alert('" . sprintf(T_('Select an item to %s'), $action) . "'); window.history.go(-1);</script>\n"; exit; } $total = count($cid); $cids = implode(',', $cid); $database->setQuery("UPDATE #__content SET state='{$state}'" . "\nWHERE id IN ({$cids}) AND (checked_out=0 OR (checked_out='{$my->id}'))"); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; exit; } if (count($cid) == 1) { $row = new mosContent($database); $row->checkin($cid[0]); } if ($state == "1") { $msg = $total . ""; $msg = sprintf(Tn_('%d Item successfully Published', '%d Items successfully Published', $total), $total); } else { if ($state == "0") { $msg = sprintf(Tn_('%d Item successfully Unpublished', '%d Items successfully Unpublished', $total), $total); } } mosRedirect('index2.php?option=' . $option . '&msg=' . $msg); }
/** * Save the item(s) to the menu selected */ function copyMenuSave($option, $cid, $menu, $menutype) { global $database; $curr = new mosMenu($database); $cidref = array(); foreach ($cid as $id) { $curr->load($id); $curr->id = NULL; if (!$curr->store()) { echo "<script> alert('" . $curr->getError() . "'); window.history.go(-1); </script>\n"; exit; } $cidref[] = array($id, $curr->id); } foreach ($cidref as $ref) { unset($curr); $curr = new mosMenu($database); $curr->load($ref[1]); if ($curr->parent != 0) { $found = false; foreach ($cidref as $ref2) { if ($curr->parent == $ref2[0]) { $curr->parent = $ref2[1]; $found = true; break; } } // if if (!$found && $curr->menutype != $menu) { $curr->parent = 0; } } // if $curr->menutype = $menu; $curr->ordering = '9999'; if (!$curr->store()) { echo "<script> alert('" . $curr->getError() . "'); window.history.go(-1); </script>\n"; exit; } $curr->updateOrder("menutype='" . $curr->menutype . "' AND parent='" . $curr->parent . "'"); } // foreach $msg = sprintf(Tn_('%d Menu Item Copied to %s', '%d Menu Items Copied to %s', count($cid)), count($cid), $menu); mosRedirect('index2.php?option=' . $option . '&menutype=' . $menutype . '&mosmsg=' . $msg); }
/** * Restores items selected to normal - restores to an unpublished state */ function restoreTrash($cid, $option) { global $database; $type = mosGetParam($_POST, 'type', array(0)); $total = count($cid); // restores to an unpublished state $state = "0"; $ordering = '9999'; //seperate contentids $cids = implode(',', $cid); if ($type == "content") { $query = "UPDATE #__content SET state = '" . $state . "', ordering = '" . $ordering . "'" . "\n WHERE id IN ( " . $cids . " )"; } else { if ($type == "menu") { $query = "UPDATE #__menu SET published = '" . $state . "', ordering = '9999'" . "\n WHERE id IN ( " . $cids . " )"; } } $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; exit; } $msg = sprintf(Tn_('%s Item successfully Restored', '%s Items successfully Restored', $total), $total); mosRedirect("index2.php?option={$option}&mosmsg=" . $msg . ""); }
/** * Display links to categories */ function showCategories(&$params, &$items, $gid, &$other_categories, $catid, $id, $Itemid) { ?> <ul> <?php foreach ($other_categories as $row) { if ($catid != $row->id) { if ($row->access <= $gid) { $link = sefRelToAbs('index.php?option=com_content&task=category&sectionid=' . $id . '&id=' . $row->id . '&Itemid=' . $Itemid); ?> <li> <a href="<?php echo $link; ?> " class="category"> <?php echo $row->name; ?> </a> <?php if ($params->get('cat_items')) { ?> <i>( <?php printf(Tn_('%d item', '%d items', $row->numitems), $row->numitems); ?> )</i> <?php } // Writes Category Description if ($params->get('cat_description') && $row->description) { echo "<br />"; echo $row->description; } ?> </li> <?php } else { ?> <li> <?php echo $row->name; ?> <a href="<?php echo sefRelToAbs('index.php?option=com_registration&task=register'); ?> "> ( <?php echo T_('Registered Users Only'); ?> ) </a> <?php } } } ?> </ul> <?php }
function CheckIn($userid, $access, $option) { global $database; global $mosConfig_db; if (!($access->canEdit || $access->canEditOwn || $userid > 0)) { mosNotAuth(); return; } $lt = mysql_list_tables($mosConfig_db); $k = 0; echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">"; while (list($tn) = mysql_fetch_array($lt)) { // only check in the mos_* tables if (strpos($tn, $database->_table_prefix) !== 0) { continue; } $lf = mysql_list_fields($mosConfig_db, "{$tn}"); $nf = mysql_num_fields($lf); $checked_out = false; $editor = false; for ($i = 0; $i < $nf; $i++) { $fname = mysql_field_name($lf, $i); if ($fname == "checked_out") { $checked_out = true; } else { if ($fname == "editor") { $editor = true; } } } if ($checked_out) { if ($editor) { $database->setQuery("SELECT checked_out, editor FROM {$tn} WHERE checked_out > 0 AND checked_out={$userid}"); } else { $database->setQuery("SELECT checked_out FROM {$tn} WHERE checked_out > 0 AND checked_out={$userid}"); } $res = $database->query(); $num = $database->getNumRows($res); if ($editor) { $database->setQuery("UPDATE {$tn} SET checked_out=0, checked_out_time='00:00:00', editor=NULL WHERE checked_out > 0"); } else { $database->setQuery("UPDATE {$tn} SET checked_out=0, checked_out_time='0000-00-00 00:00:00' WHERE checked_out > 0"); } $res = $database->query(); if ($res == 1) { if ($num > 0) { echo "\n<tr class=\"row{$k}\">"; echo "\n\t<td width=\"250\">"; echo T_('Checking table'); echo " - {$tn}</td>"; echo "\n\t<td>"; printf(Tn_('Checked in %d item', 'Checked in %d items', $num), $num); echo T_(); echo "</td>"; echo "\n</tr>"; } $k = 1 - $k; } } } ?> <tr> <td colspan="2"><strong><?php echo T_('All items checked out have now been checked in'); ?> </strong></td> </tr> </table> <?php }
/** * saves Copies of items **/ function copyItemSave($cid, $sectionid, $option) { global $database, $my; $sectcat = mosGetParam($_POST, 'sectcat', ''); //seperate sections and categories from selection $sectcat = explode(',', $sectcat); list($newsect, $newcat) = $sectcat; if (!$newsect && !$newcat) { mosRedirect('index.php?option=com_content§ionid=' . $sectionid . '&mosmsg=' . urlencode(T_('An error has occurred'))); } // find section name $query = "SELECT a.name" . "\n FROM #__sections AS a" . "\n WHERE a.id = " . $newsect . ""; $database->setQuery($query); $section = $database->loadResult(); // find category name $query = "SELECT a.name" . "\n FROM #__categories AS a" . "\n WHERE a.id = " . $newcat . ""; $database->setQuery($query); $category = $database->loadResult(); $total = count($cid); for ($i = 0; $i < $total; $i++) { $row = new mosContent($database); // main query $query = "SELECT a.* FROM #__content AS a" . "\n WHERE a.id = " . $cid[$i] . ""; $database->setQuery($query); $item = $database->loadObjectList(); // values loaded into array set for store $row->id = NULL; $row->sectionid = $newsect; $row->catid = $newcat; $row->hits = '0'; $row->ordering = '0'; $row->title = $item[0]->title; $row->title_alias = $item[0]->title_alias; $row->introtext = $item[0]->introtext; $row->fulltext = $item[0]->fulltext; $row->state = $item[0]->state; $row->mask = $item[0]->mask; $row->created = $item[0]->created; $row->created_by = $item[0]->created_by; $row->created_by_alias = $item[0]->created_by_alias; $row->modified = $item[0]->modified; $row->modified_by = $item[0]->modified_by; $row->checked_out = $item[0]->checked_out; $row->checked_out_time = $item[0]->checked_out_time; $row->frontpage_up = $item[0]->frontpage_up; $row->frontpage_down = $item[0]->frontpage_down; $row->publish_up = $item[0]->publish_up; $row->publish_down = $item[0]->publish_down; $row->images = $item[0]->images; $row->attribs = $item[0]->attribs; $row->version = $item[0]->parentid; $row->parentid = $item[0]->parentid; $row->metakey = $item[0]->metakey; $row->metadesc = $item[0]->metadesc; $row->access = $item[0]->access; 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->updateOrder("catid='" . $row->catid . "' AND state >= 0"); } $msg = sprintf(Tn_('%d Item successfully copied to Section: %s, Category: %s', '%d Items successfully copied to Section: %s, Category: %s', $total), $total, $section, $category); mosRedirect('index2.php?option=' . $option . '§ionid=' . $sectionid . '&mosmsg=' . $msg); }
function display(&$rows, $params) { global $mosConfig_offset; $c = count($rows); $tabclass = array("sectiontableentry1", "sectiontableentry2"); $k = 0; // number of matches found printf(Tn_('returned %d match', 'returned %d matches', $c), $c); ?> </td> </tr> </table> <br /> <table class="contentpaneopen<?php echo $params->get('pageclass_sfx'); ?> "> <?php foreach ($rows as $row) { if ($row->created) { $created = mosFormatDate($row->created, '%d %B, %Y'); } else { $created = ''; } ?> <tr class="<?php echo $tabclass[$k] . $params->get('pageclass_sfx'); ?> "> <td> <?php if ($row->browsernav == 1) { ?> <a href="<?php echo sefRelToAbs($row->href); ?> " target="_blank"> <?php } else { ?> <a href="<?php echo sefRelToAbs($row->href); ?> "> <?php } echo $row->title; ?> </a> <span class="small<?php echo $params->get('pageclass_sfx'); ?> "> (<?php echo $row->section; ?> ) </span> </td> </tr> <tr class="<?php echo $tabclass[$k] . $params->get('pageclass_sfx'); ?> "> <td> <?php echo $row->text; ?> … </td> </tr> <tr> <td class="small<?php echo $params->get('pageclass_sfx'); ?> "> <?php echo $created; ?> </td> </tr> <tr> <td> </td> </tr> <?php $k = 1 - $k; } }
/** * Save the item(s) to the menu selected */ function copyCategorySave($cid, $sectionOld) { global $database; $sectionMove = mosGetParam($_REQUEST, 'sectionmove', ''); $contentid = mosGetParam($_REQUEST, 'item', ''); $total = count($contentid); $category = new mosCategory($database); foreach ($cid as $id) { $category->load($id); $category->id = NULL; $category->title = "Copy of " . $category->title; $category->name = "Copy of " . $category->name; $category->section = $sectionMove; if (!$category->check()) { echo "<script> alert('" . $category->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$category->store()) { echo "<script> alert('" . $category->getError() . "'); window.history.go(-1); </script>\n"; exit; } $category->checkin(); // stores original catid $newcatids[]["old"] = $id; // pulls new catid $newcatids[]["new"] = $category->id; } $content = new mosContent($database); foreach ($contentid as $id) { $content->load($id); $content->id = NULL; $content->sectionid = $sectionMove; $content->hits = 0; foreach ($newcatids as $newcatid) { if ($content->catid == $newcatid["old"]) { $content->catid = $newcatid["new"]; } } if (!$content->check()) { echo "<script> alert('" . $content->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$content->store()) { echo "<script> alert('" . $content->getError() . "'); window.history.go(-1); </script>\n"; exit; } $content->checkin(); } $sectionNew = new mosSection($database); $sectionNew->load($sectionMove); $msg = sprintf(Tn_('%d Category copied to %s', '%d Categories copied to %s', $total), $total, $sectionNew->name); mosRedirect('index2.php?option=com_categories§ion=' . $sectionOld . '&mosmsg=' . $msg); }
/** * Copies a complete menu, all its items and creates a new module, using the name speified */ function copyMenu($option, $cid, $type) { global $database; $menu_name = mosGetParam($_POST, 'menu_name', 'New Menu'); $module_name = mosGetParam($_POST, 'module_name', 'New Module'); // check for unique menutype for new menu copy $query = "SELECT params" . "\n FROM #__modules" . "\n WHERE module = 'mod_mainmenu'"; $database->setQuery($query); $menus = $database->loadResultArray(); foreach ($menus as $menu) { $pparser = new mosParameters($menu); $params = $pparser->getParams(); if ($params->menutype == $menu_name) { echo "<script> alert('" . T_('A menu with that name already exists - you must enter a unique Menu Name') . "'); window.history.go(-1); </script>\n"; exit; } } // copy the menu items $mids = mosGetParam($_POST, 'mids', ''); $total = count($mids); $copy = new mosMenu($database); $original = new mosMenu($database); sort($mids); $a_ids = array(); foreach ($mids as $mid) { $original->load($mid); $copy = $original; $copy->id = NULL; $copy->parent = $a_ids[$original->parent]; $copy->menutype = $menu_name; if (!$copy->check()) { echo "<script> alert('" . $copy->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$copy->store()) { echo "<script> alert('" . $copy->getError() . "'); window.history.go(-1); </script>\n"; exit; } $a_ids[$original->id] = $copy->id; } // create the module copy $row = new mosModule($database); $row->load(0); $row->title = $module_name; $row->iscore = 0; $row->published = 1; $row->position = 'left'; $row->module = 'mod_mainmenu'; $row->params = 'menutype=' . $menu_name; 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(); $row->updateOrder("position='" . $row->position . "'"); // module assigned to show on All pages by default // ToDO: Changed to become a mambo db-object $query = "INSERT INTO #__modules_menu VALUES ( {$row->id}, 0 )"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; exit; } $msg = sprintf(Tn_('Copy of Menu `%s` created, consisting of %d item', 'Copy of Menu `%s` created, consisting of %d items', $total), $type, $total); mosRedirect('index2.php?option=' . $option, $msg); }
if ($showmode == 0 || $showmode == 2) { $query1 = "SELECT count(session_id) as guest_online FROM #__session WHERE guest=1 AND (usertype is NULL OR usertype='')"; $database->setQuery($query1); $guest_array = $database->loadResult(); $query2 = "SELECT DISTINCT count(username) as user_online FROM #__session WHERE guest=0 AND usertype <> 'administrator' AND usertype <> 'superadministrator'"; $database->setQuery($query2); $user_array = $database->loadResult(); if ($guest_array != 0 && $user_array == 0) { $content .= sprintf(Tn_('We have %d guest online', 'We have %d guests online', $guest_array), $guest_array); } if ($guest_array == 0 && $user_array != 0) { $content .= sprintf(Tn_('We have %d member online', 'We have %d members online', $user_array), $user_array); } if ($guest_array != 0 && $user_array != 0) { $content .= sprintf(Tn_('We have %d guest online and ', 'We have %d guests online and ', $guest_array), $guest_array); $content .= sprintf(Tn_(' %d member online', ' %d members online', $user_array), $user_array); } } if ($showmode == 1 || $showmode == 2) { $query = "SELECT DISTINCT a.username" . "\n FROM #__session AS a" . "\n WHERE (a.guest=0)"; $database->setQuery($query); $rows = $database->loadObjectList(); if (is_array($rows)) { foreach ($rows as $row) { $content .= "<ul>\n"; $content .= "<li><strong>" . $row->username . "</strong></li>\n"; $content .= "</ul>\n"; } } if ($content == "") { echo T_('No Users Online') . "\n";