/**
* Mambot that Cloaks all emails in content from spambots via javascript
*/
function botMosEmailCloak($published, &$row, &$cparams, $page = 0, $params)
{
global $database;
// load mambot params info
/*$query = "SELECT id FROM #__mambots WHERE element = 'mosemailcloak' AND folder = 'content'";
$database->setQuery( $query );
$id = $database->loadResult();
$mambot = new mosMambot( $database );
$mambot->load( $id );*/
$mambots =& mosMambotHandler::getInstance();
$mambot = $mambots->getBot('mosemailcloack', 'content');
$params =& new mosParameters(isset($mambot->params) ? $mambot->params : '');
$mode = $params->def('mode', 1);
//$search = "([[:alnum:]_\.\-]+)(\@[[:alnum:]\.\-]+\.+)([[:alnum:]\.\-]+)";
$search = "([[:alnum:]_\\.\\-]+)(\\@[[:alnum:]\\.\\-]+\\.+)([[:alnum:]\\.\\-\\?\\=\\%]+)";
$search_text = "([[:alnum:][:space:][:punct:]][^<>]+)";
// search for derivativs of link code <a href="mailto:[email protected]">[email protected]</a>
// extra handling for inclusion of title and target attributes either side of href attribute
$searchlink = "(<a [[:alnum:] _\"\\'=\\@\\.\\-]*href=[\"\\']mailto:" . $search . "[\"\\'][[:alnum:] _\"\\'=\\@\\.\\-]*>)" . $search . "</a>";
if (is_callable(array($row, 'getText'))) {
$localtext = $row->getText();
} else {
$localtext = $row->text;
}
while (eregi($searchlink, $localtext, $regs)) {
$mail = $regs[2] . $regs[3] . $regs[4];
$mail_text = $regs[5] . $regs[6] . $regs[7];
// check to see if mail text is different from mail addy
if ($mail_text) {
$replacement = mosHTML::emailCloaking($mail, $mode, $mail_text);
} else {
$replacement = mosHTML::emailCloaking($mail, $mode);
}
// replace the found address with the js cloacked email
$localtext = str_replace($regs[0], $replacement, $localtext);
}
// search for derivativs of link code <a href="mailto:[email protected]">anytext</a>
// extra handling for inclusion of title and target attributes either side of href attribute
$searchlink = "(<a [[:alnum:] _\"\\'=\\@\\.\\-]*href=[\"\\']mailto:" . $search . "[\"\\'][[:alnum:] _\"\\'=\\@\\.\\-]*)>" . $search_text . "</a>";
while (eregi($searchlink, $localtext, $regs)) {
$mail = $regs[2] . $regs[3] . $regs[4];
$mail_text = $regs[5];
$replacement = mosHTML::emailCloaking($mail, $mode, $mail_text, 0);
// replace the found address with the js cloacked email
$localtext = str_replace($regs[0], $replacement, $localtext);
}
// search for plain text [email protected]
while (eregi($search, $localtext, $regs)) {
$mail = $regs[0];
$replacement = mosHTML::emailCloaking($mail, $mode);
// replace the found address with the js cloacked email
$localtext = str_replace($regs[0], $replacement, $localtext);
}
if (is_callable(array($row, 'saveText'))) {
$row->saveText($localtext);
} else {
$row->text = $localtext;
}
}
function messageForm($option)
{
global $acl;
$gtree = array(mosHTML::makeOption(0, '- All User Groups -'));
// get list of groups
$lists = array();
$gtree = array_merge($gtree, $acl->get_group_children_tree(null, 'USERS', false));
$lists['gid'] = mosHTML::selectList($gtree, 'mm_group', 'size="10"', 'value', 'text', 0);
HTML_massmail::messageForm($lists, $option);
}
/**
* @param string The name of the form element
* @param string The value of the element
* @param object The xml element for the parameter
* @param string The control name
* @return string The html for the element
*/
function _form_editor_list($name, $value, &$node, $control_name)
{
global $database;
// compile list of the editors
$query = "SELECT element AS value, name AS text" . "\n FROM #__mambots" . "\n WHERE folder = 'editors'" . "\n AND published = 1" . "\n ORDER BY ordering, name";
$database->setQuery($query);
$editors = $database->loadObjectList();
array_unshift($editors, mosHTML::makeOption('', '- Selecionar Editor -'));
return mosHTML::selectList($editors, '' . $control_name . '[' . $name . ']', 'class="inputbox"', 'value', 'text', $value);
}
/**
* @param database A database connector object
* @param integer The unique id of the category to edit (0 if new)
*/
function edit(&$uid, $menutype, $option)
{
global $database, $my, $mainframe;
$menu = new mosMenu($database);
$menu->load((int) $uid);
// fail if checked out not by 'me'
if ($menu->checked_out && $menu->checked_out != $my->id) {
mosErrorAlert("The module " . $menu->title . " is currently being edited by another administrator");
}
if ($uid) {
$menu->checkout($my->id);
// get previously selected Categories
$params = new mosParameters($menu->params);
$catids = $params->def('categoryid', '');
if ($catids) {
$catidsArray = explode(',', $catids);
mosArrayToInts($catidsArray);
$catids = 'c.id=' . implode(' OR c.id=', $catidsArray);
$query = "SELECT c.id AS `value`, c.section AS `id`, CONCAT_WS( ' / ', s.title, c.title) AS `text`" . "\n FROM #__sections AS s" . "\n INNER JOIN #__categories AS c ON c.section = s.id" . "\n WHERE s.scope = 'content'" . "\n AND ( {$catids} )" . "\n ORDER BY s.name,c.name";
$database->setQuery($query);
$lookup = $database->loadObjectList();
} else {
$lookup = '';
}
} else {
$menu->type = 'content_blog_category';
$menu->menutype = $menutype;
$menu->ordering = 9999;
$menu->parent = intval(mosGetParam($_POST, 'parent', 0));
$menu->published = 1;
$lookup = '';
}
// build the html select list for category
$rows[] = mosHTML::makeOption('', 'All Categories');
$query = "SELECT c.id AS `value`, c.section AS `id`, CONCAT_WS( ' / ', s.title, c.title) AS `text`" . "\n FROM #__sections AS s" . "\n INNER JOIN #__categories AS c ON c.section = s.id" . "\n WHERE s.scope = 'content'" . "\n ORDER BY s.name,c.name";
$database->setQuery($query);
$rows = array_merge($rows, $database->loadObjectList());
$category = mosHTML::selectList($rows, 'catid[]', 'class="inputbox" size="10" multiple="multiple"', 'value', 'text', $lookup);
$lists['categoryid'] = $category;
// build the html select list for ordering
$lists['ordering'] = mosAdminMenus::Ordering($menu, $uid);
// build the html select list for the group access
$lists['access'] = mosAdminMenus::Access($menu);
// build the html select list for paraent item
$lists['parent'] = mosAdminMenus::Parent($menu);
// build published button option
$lists['published'] = mosAdminMenus::Published($menu);
// build the url link output
$lists['link'] = mosAdminMenus::Link($menu, $uid);
// get params definitions
$params = new mosParameters($menu->params, $mainframe->getPath('menu_xml', $menu->type), 'menu');
/* chipjack: passing $sectCatList (categories) instead of $slist (sections) */
content_blog_category_html::edit($menu, $lists, $params, $option);
}
/**
* @param database A database connector object
* @param integer The unique id of the section to edit (0 if new)
*/
function edit($uid, $menutype, $option)
{
global $database, $my, $mainframe;
$menu = new mosMenu($database);
$menu->load((int) $uid);
// fail if checked out not by 'me'
if ($menu->checked_out && $menu->checked_out != $my->id) {
mosErrorAlert("O módulo " . $menu->title . " está sendo editado atualmente por outro administrador");
}
if ($uid) {
$menu->checkout($my->id);
// get previously selected Categories
$params = new mosParameters($menu->params);
$secids = $params->def('sectionid', '');
if ($secids) {
$secidsArray = explode(',', $secids);
mosArrayToInts($secidsArray);
$secids = 's.id=' . implode(' OR s.id=', $secidsArray);
$query = "SELECT s.id AS `value`, s.id AS `id`, s.title AS `text`" . "\n FROM #__sections AS s" . "\n WHERE s.scope = 'content'" . "\n AND ( {$secids} )" . "\n ORDER BY s.name";
$database->setQuery($query);
$lookup = $database->loadObjectList();
} else {
$lookup = '';
}
} else {
$menu->type = 'content_blog_section';
$menu->menutype = $menutype;
$menu->ordering = 9999;
$menu->parent = intval(mosGetParam($_POST, 'parent', 0));
$menu->published = 1;
$lookup = '';
}
// build the html select list for section
$rows[] = mosHTML::makeOption('', 'Todas as Seções');
$query = "SELECT s.id AS `value`, s.id AS `id`, s.title AS `text`" . "\n FROM #__sections AS s" . "\n WHERE s.scope = 'content'" . "\n ORDER BY s.name";
$database->setQuery($query);
$rows = array_merge($rows, $database->loadObjectList());
$section = mosHTML::selectList($rows, 'secid[]', 'class="inputbox" size="10" multiple="multiple"', 'value', 'text', $lookup);
$lists['sectionid'] = $section;
// build the html select list for ordering
$lists['ordering'] = mosAdminMenus::Ordering($menu, $uid);
// build the html select list for the group access
$lists['access'] = mosAdminMenus::Access($menu);
// build the html select list for paraent item
$lists['parent'] = mosAdminMenus::Parent($menu);
// build published button option
$lists['published'] = mosAdminMenus::Published($menu);
// build the url link output
$lists['link'] = mosAdminMenus::Link($menu, $uid);
// get params definitions
$params = new mosParameters($menu->params, $mainframe->getPath('menu_xml', $menu->type), 'menu');
content_blog_section_html::edit($menu, $lists, $params, $option);
}
/**
* @param database A database connector object
* @param integer The unique id of the section to edit (0 if new)
*/
function edit(&$uid, $menutype, $option)
{
global $database, $my, $mainframe;
global $mosConfig_absolute_path;
$menu = new mosMenu($database);
$menu->load($uid);
// fail if checked out not by 'me'
if ($menu->checked_out && $menu->checked_out != $my->id) {
echo "<script>alert('The module {$menu->title} is currently being edited by another administrator'); document.location.href='index2.php?option={$option}'</script>\n";
exit(0);
}
if ($uid) {
$menu->checkout($my->id);
// get previously selected Categories
$params =& new mosParameters($menu->params);
$secids = $params->def('sectionid', '');
if ($secids) {
$query = "SELECT s.id AS `value`, s.id AS `id`, s.title AS `text`" . "\n FROM #__sections AS s" . "\n WHERE s.scope = 'content'" . "\n AND s.id IN ( " . $secids . ")" . "\n ORDER BY s.name";
$database->setQuery($query);
$lookup = $database->loadObjectList();
} else {
$lookup = '';
}
} else {
$menu->type = 'content_blog_section';
$menu->menutype = $menutype;
$menu->ordering = 9999;
$menu->parent = intval(mosGetParam($_POST, 'parent', 0));
$menu->published = 1;
$lookup = '';
}
// build the html select list for section
$rows[] = mosHTML::makeOption('', 'All Sections');
$query = "SELECT s.id AS `value`, s.id AS `id`, s.title AS `text`" . "\n FROM #__sections AS s" . "\n WHERE s.scope = 'content'" . "\n ORDER BY s.name";
$database->setQuery($query);
$rows = array_merge($rows, $database->loadObjectList());
$section = mosHTML::selectList($rows, 'secid[]', 'class="inputbox" size="10" multiple="multiple"', 'value', 'text', $lookup);
$lists['sectionid'] = $section;
// build the html select list for ordering
$lists['ordering'] = mosAdminMenus::Ordering($menu, $uid);
// build the html select list for the group access
$lists['access'] = mosAdminMenus::Access($menu);
// build the html select list for paraent item
$lists['parent'] = mosAdminMenus::Parent($menu);
// build published button option
$lists['published'] = mosAdminMenus::Published($menu);
// build the url link output
$lists['link'] = mosAdminMenus::Link($menu, $uid);
// get params definitions
$params =& new mosParameters($menu->params, $mainframe->getPath('menu_xml', $menu->type), 'component');
/* chipjack: passing $sectCatList (categories) instead of $slist (sections) */
content_blog_section_html::edit($menu, $lists, $params, $option);
}
function newMessage($option, $user, $subject)
{
global $database, $mainframe, $my, $acl;
// get available backend user groups
$gid = $acl->get_group_id('Public Backend', 'ARO');
$gids = $acl->get_group_children($gid, 'ARO', 'RECURSE');
$gids = implode(',', $gids);
// get list of usernames
$recipients = array(mosHTML::makeOption('0', '- Select User -'));
$database->setQuery("SELECT id AS value, username AS text FROM #__users" . "\n WHERE gid IN ({$gids})" . "\n ORDER BY name");
$recipients = array_merge($recipients, $database->loadObjectList());
$recipientslist = mosHTML::selectList($recipients, 'user_id_to', 'class="inputbox" size="1"', 'value', 'text', $user);
HTML_messages::newMessage($option, $recipientslist, $subject);
}
function edit(&$uid, $menutype, $option)
{
global $database, $my, $mainframe;
$menu = new mosMenu($database);
$menu->load((int) $uid);
// fail if checked out not by 'me'
if ($menu->checked_out && $menu->checked_out != $my->id) {
mosErrorAlert("O módulo " . $menu->title . " está sendo editado atualmente por outro administrador");
}
if ($uid) {
$menu->checkout($my->id);
} else {
// load values for new entry
$menu->type = 'component_item_link';
$menu->menutype = $menutype;
$menu->browserNav = 0;
$menu->ordering = 9999;
$menu->parent = intval(mosGetParam($_POST, 'parent', 0));
$menu->published = 1;
}
if ($uid) {
$temp = explode('&Itemid=', $menu->link);
$query = "SELECT a.name" . "\n FROM #__menu AS a" . "\n WHERE a.link = " . $database->Quote($temp[0]);
$database->setQuery($query);
$components = $database->loadResult();
$lists['components'] = $components;
$lists['components'] .= '<input type="hidden" name="link" value="' . $menu->link . '" />';
} else {
$query = "SELECT CONCAT( a.link, '&Itemid=', a.id ) AS value, a.name AS text" . "\n FROM #__menu AS a" . "\n WHERE a.published = 1" . "\n AND a.type = 'components'" . "\n ORDER BY a.menutype, a.name";
$database->setQuery($query);
$components = $database->loadObjectList();
// Create a list of links
$lists['components'] = mosHTML::selectList($components, 'link', 'class="inputbox" size="10"', 'value', 'text', '');
}
// build html select list for target window
$lists['target'] = mosAdminMenus::Target($menu);
// build the html select list for ordering
$lists['ordering'] = mosAdminMenus::Ordering($menu, $uid);
// build the html select list for the group access
$lists['access'] = mosAdminMenus::Access($menu);
// build the html select list for paraent item
$lists['parent'] = mosAdminMenus::Parent($menu);
// build published button option
$lists['published'] = mosAdminMenus::Published($menu);
// build the url link output
$lists['link'] = mosAdminMenus::Link($menu, $uid, 1);
// get params definitions
$params = new mosParameters($menu->params, $mainframe->getPath('menu_xml', $menu->type), 'menu');
component_item_link_menu_html::edit($menu, $lists, $params, $option);
}
请发表评论