/** * @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); }
function sendMail() { global $database, $my, $acl; global $mosConfig_sitename; global $mosConfig_mailfrom, $mosConfig_fromname; josSpoofCheck(); $mode = intval(mosGetParam($_POST, 'mm_mode', 0)); $subject = strval(mosGetParam($_POST, 'mm_subject', '')); $gou = mosGetParam($_POST, 'mm_group', NULL); $recurse = strval(mosGetParam($_POST, 'mm_recurse', 'NO_RECURSE')); // pulls message inoformation either in text or html format if ($mode) { $message_body = $_POST['mm_message']; } else { // automatically removes html formatting $message_body = strval(mosGetParam($_POST, 'mm_message', '')); } $message_body = stripslashes($message_body); if (!$message_body || !$subject || $gou === null) { mosRedirect('index2.php?option=com_massmail&mosmsg=Please fill in the form correctly'); } // 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" . "\n FROM #__users" . "\n WHERE id = " . (int) $my->id; $database->setQuery($query); $my->email = $database->loadResult(); mosArrayToInts($to['users']); $user_ids = 'id=' . implode(' OR id=', $to['users']); // Get all users email and group except for senders $query = "SELECT email" . "\n FROM #__users" . "\n WHERE id != " . (int) $my->id . ($gou !== '0' ? " AND ( {$user_ids} )" : ''); $database->setQuery($query); $rows = $database->loadObjectList(); // Build e-mail message format $message_header = sprintf(_MASSMAIL_MESSAGE, html_entity_decode($mosConfig_sitename, ENT_QUOTES)); $message = $message_header . $message_body; $subject = html_entity_decode($mosConfig_sitename, ENT_QUOTES) . ' / ' . stripslashes($subject); //Send email foreach ($rows as $row) { mosMail($mosConfig_mailfrom, $mosConfig_fromname, $row->email, $subject, $message, $mode); } } $msg = 'E-mail sent to ' . count($rows) . ' users'; mosRedirect('index2.php?option=com_massmail', $msg); }
function publishModule($cid = null, $publish = 1, $option, $client = 'admin') { global $database, $my; if (count($cid) < 1) { $action = $publish ? 'publish' : 'unpublish'; echo "<script> alert('Select a module to {$action}'); window.history.go(-1);</script>\n"; exit; } mosArrayToInts($cid); $cids = 'id=' . implode(' OR id=', $cid); $query = "UPDATE #__modules" . "\n SET published = " . (int) $publish . "\n WHERE ( {$cids} )" . "\n AND ( checked_out = 0 OR ( checked_out = " . (int) $my->id . " ) )"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; exit; } if (count($cid) == 1) { $row = new mosModule($database); $row->checkin($cid[0]); } mosCache::cleanCache('com_content'); $redirect = mosGetParam($_REQUEST, 'redirect', 'index2.php?option=' . $option . '&client=' . $client); mosRedirect($redirect); }
function removeMessage($cid, $option) { global $database; josSpoofCheck(); if (!is_array($cid) || count($cid) < 1) { echo "<script> alert('Select an item to delete'); window.history.go(-1);</script>\n"; exit; } if (count($cid)) { mosArrayToInts($cid); $cids = 'message_id=' . implode(' OR message_id=', $cid); $query = "DELETE FROM #__messages" . "\n WHERE ( {$cids} )"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; } } $limit = intval(mosGetParam($_REQUEST, 'limit', 10)); $limitstart = intval(mosGetParam($_REQUEST, 'limitstart', 0)); mosRedirect("index2.php?option={$option}&limit={$limit}&limitstart={$limitstart}"); }
/** * Generic Publish/Unpublish function * @param array An array of id numbers * @param integer 0 if unpublishing, 1 if publishing * @param integer The id of the user performnig the operation * @since 1.0.4 */ function publish($cid = null, $publish = 1, $user_id = 0) { mosArrayToInts($cid, array()); $user_id = (int) $user_id; $publish = (int) $publish; $k = $this->_tbl_key; if (count($cid) < 1) { $this->_error = "No items selected."; return false; } $cids = $this->_tbl_key . '=' . implode(' OR ' . $this->_tbl_key . '=', $cid); $query = "UPDATE {$this->_tbl}" . "\n SET published = " . (int) $publish . "\n WHERE ({$cids})" . "\n AND (checked_out = 0 OR checked_out = " . (int) $user_id . ")"; $this->_db->setQuery($query); if (!$this->_db->query()) { $this->_error = $this->_db->getErrorMsg(); return false; } if (count($cid) == 1) { $this->checkin($cid[0]); } $this->_error = ''; return true; }
/** * Removes records * @param array An array of id keys to remove * @param string The current GET/POST option */ function removeNewsFeeds(&$cid, $option) { global $database; josSpoofCheck(); if (!is_array($cid) || count($cid) < 1) { echo "<script> alert('Select an item to delete'); window.history.go(-1);</script>\n"; exit; } if (count($cid)) { mosArrayToInts($cid); $cids = 'id=' . implode(' OR id=', $cid); $query = "DELETE FROM #__newsfeeds" . "\n WHERE ( {$cids} )" . "\n AND checked_out = 0"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; } } mosRedirect('index2.php?option=' . $option); }
} unset($temp); break; case 1: default: //Content Items only $whereCatid = ''; if ($catid) { $catids = explode(',', $catid); mosArrayToInts($catids); $whereCatid = "\n AND ( a.catid=" . implode(" OR a.catid=", $catids) . " )"; } $whereSecid = ''; if ($secid) { $secids = explode(',', $secid); mosArrayToInts($secids); $whereSecid = "\n AND ( a.sectionid=" . implode(" OR a.sectionid=", $secids) . " )"; } $query = "SELECT a.id, a.title, a.sectionid, a.catid" . "\n FROM #__content AS a" . "\n LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id" . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid" . "\n INNER JOIN #__sections AS s ON s.id = a.sectionid" . "\n WHERE ( a.state = 1 AND a.sectionid > 0 )" . "\n AND ( a.publish_up = " . $database->Quote($nullDate) . " OR a.publish_up <= " . $database->Quote($now) . " )" . "\n AND ( a.publish_down = " . $database->Quote($nullDate) . " OR a.publish_down >= " . $database->Quote($now) . " )" . ($access ? "\n AND a.access <= " . (int) $my->gid . " AND cc.access <= " . (int) $my->gid . " AND s.access <= " . (int) $my->gid : '') . $whereCatid . $whereSecid . ($show_front == '0' ? "\n AND f.content_id IS NULL" : '') . "\n AND s.published = 1" . "\n AND cc.published = 1" . "\n ORDER BY a.created DESC"; $database->setQuery($query, 0, $count); $rows = $database->loadObjectList(); break; } // needed to reduce queries used by getItemid for Content Items if ($type == 1 || $type == 3) { $bs = $mainframe->getBlogSectionCount(); $bc = $mainframe->getBlogCategoryCount(); $gbs = $mainframe->getGlobalBlogSectionCount(); } // Output ?>
/** * 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; josSpoofCheck(); if (count($cid) < 1) { $action = $state == 1 ? 'publish' : ($state == -1 ? 'archive' : 'unpublish'); echo "<script> alert('Select an item to {$action}'); window.history.go(-1);</script>\n"; exit; } mosArrayToInts($cid); $total = count($cid); $cids = 'id=' . implode(' OR id=', $cid); $query = "UPDATE #__content" . "\n SET state = " . (int) $state . "\n WHERE ( {$cids} )" . "\n AND ( checked_out = 0 OR ( checked_out = " . (int) $my->id . " ) )"; $database->setQuery($query); 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]); } // clean any existing cache files mosCache::cleanCache('com_content'); if ($state == "1") { $msg = $total . " Item(s) successfully Published"; } else { if ($state == "0") { $msg = $total . " Item(s) successfully Unpublished"; } } mosRedirect('index2.php?option=' . $option . '&msg=' . $msg); }
/** * Gets the users from a group * @param string The value for the group (not used 1.0) * @param string The name for the group * @param string If RECURSE, will drill into child groups * @param string Ordering for the list * @return array */ function getUserListFromGroup($value, $name, $recurse = 'NO_RECURSE', $order = 'name') { global $acl; // Change back in //$group_id = $acl->get_group_id( $value, $name, $group_type = 'ARO'); $group_id = $acl->get_group_id($name, $group_type = 'ARO'); $objects = $acl->get_group_objects($group_id, 'ARO', 'RECURSE'); if (isset($objects['users'])) { mosArrayToInts($objects['users']); $gWhere = '(id =' . implode(' OR id =', $objects['users']) . ')'; $query = "SELECT id AS value, name AS text" . "\n FROM #__users" . "\n WHERE block = '0'" . "\n AND " . $gWhere . "\n ORDER BY " . $order; $this->_db->setQuery($query); $options = $this->_db->loadObjectList(); return $options; } else { return array(); } }
function del_object($object_id, $object_type = NULL, $erase = FALSE) { switch (strtolower(trim($object_type))) { case 'aco': $object_type = 'aco'; $table = $this->_db_table_prefix . 'aco'; $object_map_table = $this->_db_table_prefix . 'aco_map'; break; case 'aro': $object_type = 'aro'; $table = $this->_db_table_prefix . 'aro'; $object_map_table = $this->_db_table_prefix . 'aro_map'; $groups_map_table = $this->_db_table_prefix . 'aro_groups_map'; $object_group_table = $this->_db_table_prefix . 'groups_aro_map'; break; case 'axo': $object_type = 'axo'; $table = $this->_db_table_prefix . 'axo'; $object_map_table = $this->_db_table_prefix . 'axo_map'; $groups_map_table = $this->_db_table_prefix . 'axo_groups_map'; $object_group_table = $this->_db_table_prefix . 'groups_axo_map'; break; default: $this->debug_text('del_object(): Invalid Object Type: ' . $object_type); return FALSE; } $this->debug_text("del_object(): ID: {$object_id} Object Type: {$object_type}, Erase all referencing objects: {$erase}"); if (empty($object_id)) { $this->debug_text("del_object(): Object ID ({$object_id}) is empty, this is required"); return false; } if (empty($object_type)) { $this->debug_text("del_object(): Object Type ({$object_type}) is empty, this is required"); return false; } // <mos> $this->db->BeginTrans(); // Get Object section_value/value (needed to look for referencing objects) $this->db->setQuery('SELECT section_value,value FROM ' . $table . ' WHERE ' . $object_type . '_id=' . (int) $object_id); $object = $this->db->loadRow(); if (empty($object)) { $this->debug_text('del_object(): The specified object (' . strtoupper($object_type) . ' ID: ' . $object_id . ') could not be found.<br />SQL = ' . $this->db->stderr()); return FALSE; } $section_value = $object[0]; $value = $object[1]; // Get ids of acl referencing the Object (if any) //$this->db->setQuery( "SELECT acl_id FROM $object_map_table WHERE value=" . $this->db->Quote( $value ) . " AND section_value=" . $this->db->Quote( $section_value ) ); //$acl_ids = $this->db->loadResultArray(); $acl_ids = array(); if ($erase) { // We were asked to erase all acl referencing it $this->debug_text("del_object(): Erase was set to TRUE, delete all referencing objects"); if ($object_type == "aro" or $object_type == "axo") { // The object can be referenced in groups_X_map tables // in the future this branching may become useless because // ACO might me "groupable" too // Get rid of groups_map referencing the Object $this->db->setQuery('DELETE FROM ' . $object_group_table . ' WHERE ' . $object_type . '_id=' . (int) $object_id); $rs = $this->db->query(); if (!$rs) { $this->debug_db('edit_object'); // <mos> $this->db->RollBackTrans(); return false; } } if ($acl_ids) { //There are acls actually referencing the object if ($object_type == 'aco') { // I know it's extremely dangerous but // if asked to really erase an ACO // we should delete all acl referencing it // (and relative maps) // Do this below this branching // where it uses $orphan_acl_ids as // the array of the "orphaned" acl // in this case all referenced acl are // orhpaned acl $orphan_acl_ids = $acl_ids; } else { // The object is not an ACO and might be referenced // in still valid acls regarding also other object. // In these cases the acl MUST NOT be deleted // Get rid of $object_id map referencing erased objects $this->db->setQuery("DELETE FROM {$object_map_table} WHERE section_value=" . $this->db->Quote($section_value) . " AND value=" . $this->db->Quote($value)); $rs = $this->db->query(); if (!$rs) { $this->debug_db('edit_object'); $this->db->RollBackTrans(); return false; } // Find the "orphaned" acl. I mean acl referencing the erased Object (map) // not referenced anymore by other objects mosArrayToInts($acl_ids); $sql_acl_ids = implode(",", $acl_ids); $this->db->setQuery(' SELECT a.id FROM ' . $this->_db_table_prefix . 'acl a LEFT JOIN ' . $object_map_table . ' b ON a.id=b.acl_id ' . ' WHERE value IS NULL AND section_value IS NULL AND group_id IS NULL AND a.id in (' . $sql_acl_ids . ')'); $orphan_acl_ids = $this->db->loadResultArray(); } // End of else section of "if ($object_type == "aco")" if ($orphan_acl_ids) { // If there are orphaned acls get rid of them foreach ($orphan_acl_ids as $acl) { $this->del_acl($acl); } } } // End of if ($acl_ids) // Finally delete the Object itself $this->db->setQuery("DELETE FROM {$table} WHERE {$object_type}_id=" . (int) $object_id); $rs = $this->db->query(); if (!$rs) { $this->debug_db('edit_object'); // <mos> $this->db->RollBackTrans(); return false; } // <mos> $this->db->CommitTrans(); return true; } // End of "if ($erase)" $groups_ids = FALSE; if ($object_type == 'axo' or $object_type == 'aro') { // If the object is "groupable" (may become unnecessary, // see above // Get id of groups where the object is assigned: // you must explicitly remove the object from its groups before // deleting it (don't know if this is really needed, anyway it's safer ;-) $this->db->setQuery('SELECT group_id FROM ' . $object_group_table . ' WHERE ' . $object_type . '_id=' . (int) $object_id); $groups_ids = $this->db->loadResultArray(); } if (isset($acl_ids) and $acl_ids !== FALSE or isset($groups_ids) and $groups_ids !== FALSE) { // The Object is referenced somewhere (group or acl), can't delete it $this->debug_text("del_object(): Can't delete the object as it is being referenced by GROUPs (" . @implode($group_ids) . ") or ACLs (" . @implode($acl_ids, ",") . ")"); return false; } else { // The Object is NOT referenced anywhere, delete it $this->db->setQuery("DELETE FROM {$table} WHERE {$object_type}_id=" . (int) $object_id); $this->db->query(); if ($this->db->getErrorNum()) { $this->debug_db('edit_object'); // <mos> $this->db->RollBackTrans(); return false; } // <mos> $this->db->CommitTrans(); return true; } return false; }
/** * Form for copying item(s) to a specific menu */ function copyMenu($option, $cid, $menutype) { global $database; if (!is_array($cid) || count($cid) < 1) { echo "<script> alert('Selecione um item para mover'); window.history.go(-1);</script>\n"; exit; } ## query to list selected menu items mosArrayToInts($cid); $cids = 'a.id=' . implode(' OR a.id=', $cid); $query = "SELECT a.name" . "\n FROM #__menu AS a" . "\n WHERE ( {$cids} )"; $database->setQuery($query); $items = $database->loadObjectList(); $menuTypes = mosAdminMenus::menutypes(); foreach ($menuTypes as $menuType) { $menu[] = mosHTML::makeOption($menuType, $menuType); } // build the html select list $MenuList = mosHTML::selectList($menu, 'menu', 'class="inputbox" size="10"', 'value', 'text', null); HTML_menusections::copyMenu($option, $cid, $MenuList, $items, $menutype); }
function removeProfilers($cid, $option) { global $database; if (!is_array($cid) || count($cid) < 1) { echo "<script> alert('Select an item to delete'); window.history.go(-1);</script>\n"; exit; } //Delete data from related table if (count($cid)) { mosArrayToInts($cid); $cids = 'profiler_id=' . implode(' OR profiler_id=', $cid); //Delete the related field $sql = "Delete From #__im_fields Where ({$cids})"; $database->setQuery($sql); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; } //Delete global setting $sql = "Delete From #__im_global Where ({$cids})"; $database->setQuery($sql); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; } //Delete the global data $cids = 'id=' . implode(' OR id=', $cid); $query = "DELETE FROM #__im_profiler " . "\n WHERE ( {$cids} )"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; } } mosRedirect("index2.php?option={$option}"); }
/** * Form for copying item(s) to a specific menu */ function copyCategorySelect($option, $cid, $sectionOld) { global $database; $redirect = mosGetParam($_POST, 'section', 'content'); if (!is_array($cid) || count($cid) < 1) { echo "<script> alert('Select an item to move'); window.history.go(-1);</script>\n"; exit; } ## query to list selected categories mosArrayToInts($cid); $cids = 'a.id=' . implode(' OR a.id=', $cid); $query = "SELECT a.name, a.section" . "\n FROM #__categories AS a" . "\n WHERE ( {$cids} )"; $database->setQuery($query); $items = $database->loadObjectList(); ## query to list items from categories // mosArrayToInts( $cid ); // Just done a few lines earlier $cids = 'a.catid=' . implode(' OR a.catid=', $cid); $query = "SELECT a.title, a.id" . "\n FROM #__content AS a" . "\n WHERE ( {$cids} )" . "\n ORDER BY a.catid, a.title"; $database->setQuery($query); $contents = $database->loadObjectList(); ## query to choose section to move to $query = "SELECT a.name AS `text`, a.id AS `value`" . "\n FROM #__sections AS a" . "\n WHERE a.published = 1" . "\n ORDER BY a.name"; $database->setQuery($query); $sections = $database->loadObjectList(); // build the html select list $SectionList = mosHTML::selectList($sections, 'sectionmove', 'class="inputbox" size="10"', 'value', 'text', null); categories_html::copyCategorySelect($option, $cid, $SectionList, $items, $sectionOld, $contents, $redirect); }
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * Joomla! is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ // no direct access defined('_VALID_MOS') or die('Restricted access'); // clientids must be an integer $clientids = $params->get('banner_cids', ''); $banner = null; $where = ''; if ($clientids != '') { $clientidsArray = explode(',', $clientids); mosArrayToInts($clientidsArray); $where = "\n AND ( cid=" . implode(" OR cid=", $clientidsArray) . " )"; } $query = "SELECT *" . "\n FROM #__banner" . "\n WHERE showBanner=1 " . $where; $database->setQuery($query); $banners = $database->loadObjectList(); $numrows = count($banners); $bannum = 0; if ($numrows > 1) { $numrows--; mt_srand((double) microtime() * 1000000); $bannum = mt_rand(0, $numrows); } if ($numrows) { $banner = $banners[$bannum]; $query = "UPDATE #__banner" . "\n SET impmade = impmade + 1" . "\n WHERE bid = " . (int) $banner->bid;
function publishApplications() { global $database, $option, $task; $cid = mosGetParam($_REQUEST, 'cid', array(0)); $publish = $task == 'publish' ? 1 : 0; if (count($cid) < 1) { $action = $publish ? 'publish' : 'unpublish'; echo "<script>alert('Select an item to {$action}'); window.history.go(-1);</script>"; exit; } mosArrayToInts($cid); $cids = implode(',', $cid); $query = "UPDATE #__jumi SET published = " . intval($publish) . " WHERE id in ({$cids})"; $database->setQuery($query); if (!$database->query()) { echo "<script>alert('" . $database->getErrorMsg() . "'); window.history.go(-1);</script>"; exit; } mosRedirect('index2.php?option=' . $option, count($cid) . ' item(s) ' . $task . 'ed successfully'); }
/** * Publishes or Unpublishes one or more modules * @param array An array of unique category id numbers * @param integer 0 if unpublishing, 1 if publishing */ function publishMambot($cid = null, $publish = 1, $option, $client) { global $database, $my; josSpoofCheck(); if (count($cid) < 1) { $action = $publish ? 'publish' : 'unpublish'; echo "<script> alert('Selecione um plugin para {$action}'); window.history.go(-1);</script>\n"; exit; } mosArrayToInts($cid); $cids = 'id=' . implode(' OR id=', $cid); $query = "UPDATE #__mambots SET published = " . (int) $publish . "\n WHERE ( {$cids} )" . "\n AND ( checked_out = 0 OR ( checked_out = " . (int) $my->id . " ) )"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; exit; } if (count($cid) == 1) { $row = new mosMambot($database); $row->checkin($cid[0]); } mosRedirect('index2.php?option=' . $option . '&client=' . $client); }
/** * Deletes menu items(s) you have selected */ function deleteMenu($option, $cid, $type) { global $database; josSpoofCheck(); if ($type == 'mainmenu') { echo "<script> alert('You cannot delete the \\'mainmenu\\' menu as it is core menu'); window.history.go(-1); </script>\n"; exit; } $mid = mosGetParam($_POST, 'mids'); mosArrayToInts($mid); if (count($mid)) { // delete menu items $mids = 'id=' . implode(' OR id=', $mid); $query = "DELETE FROM #__menu" . "\n WHERE ( {$mids} )"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "');</script>\n"; exit; } } mosArrayToInts($cid); // checks whether any modules to delete if (count($cid)) { // delete modules $cids = 'id=' . implode(' OR id=', $cid); $query = "DELETE FROM #__modules" . "\n WHERE ( {$cids} )"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; exit; } // delete all module entires in jos_modules_menu $cids = 'moduleid=' . implode(' OR moduleid=', $cid); $query = "DELETE FROM #__modules_menu" . "\n WHERE ( {$cids} )"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "');</script>\n"; exit; } // reorder modules after deletion $mod = new mosModule($database); $mod->ordering = 0; $mod->updateOrder("position='left'"); $mod->updateOrder("position='right'"); } // clean any existing cache files mosCache::cleanCache('com_content'); $msg = 'Menu Deleted'; mosRedirect('index2.php?option=' . $option, $msg); }
/** * Form for copying item(s) to a specific menu */ function copySectionSelect($option, $cid, $section) { global $database; if (!is_array($cid) || count($cid) < 1) { echo "<script> alert('Select an item to move'); window.history.go(-1);</script>\n"; exit; } ## query to list selected categories mosArrayToInts($cid); $cids = 'a.section=' . implode(' OR a.section=', $cid); $query = "SELECT a.name, a.id" . "\n FROM #__categories AS a" . "\n WHERE ( {$cids} )"; $database->setQuery($query); $categories = $database->loadObjectList(); ## query to list items from categories //mosArrayToInts( $cid ); // Just done a few lines earlier $cids = 'a.sectionid=' . implode(' OR a.sectionid=', $cid); $query = "SELECT a.title, a.id" . "\n FROM #__content AS a" . "\n WHERE ( {$cids} )" . "\n ORDER BY a.sectionid, a.catid, a.title"; $database->setQuery($query); $contents = $database->loadObjectList(); sections_html::copySectionSelect($option, $cid, $categories, $contents, $section); }
/** * Form for copying item(s) **/ function copyItem($cid, $sectionid, $option) { global $database; if (!is_array($cid) || count($cid) < 1) { echo "<script> alert('Select an item to move'); window.history.go(-1);</script>\n"; exit; } //seperate contentids mosArrayToInts($cid); $cids = 'a.id=' . implode(' OR a.id=', $cid); ## Content Items query $query = "SELECT a.title" . "\n FROM #__content AS a" . "\n WHERE ( {$cids} )" . "\n ORDER BY a.title"; $database->setQuery($query); $items = $database->loadObjectList(); ## Section & Category query $query = "SELECT CONCAT_WS(',',s.id,c.id) AS `value`, CONCAT_WS(' // ', s.name, c.name) 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 = $database->loadObjectList(); // build the html select list $sectCatList = mosHTML::selectList($rows, 'sectcat', 'class="inputbox" size="10"', 'value', 'text', NULL); HTML_content::copySection($option, $cid, $sectCatList, $sectionid, $items); }
/** * DOCman 1.4.x - Joomla! Document Manager * @version $Id: documents.php 608 2008-02-18 13:31:26Z mjaz $ * @package DOCman_1.4 * @copyright (C) 2003-2008 The DOCman Development Team * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL * @link http://www.joomlatools.org/ Official website **/ defined('_VALID_MOS') or die('Restricted access'); include_once dirname(__FILE__) . '/documents.html.php'; require_once $_DOCMAN->getPath('classes', 'mambots'); require_once $_DOCMAN->getPath('classes', 'model'); require_once $_DOCMAN->getPath('classes', 'theme'); require_once $_DOCMAN->getPath('classes', 'utils'); include_once $_DOCMAN->getPath('classes', 'params'); mosArrayToInts($cid); function fetchDocument($id) { global $_DOCMAN, $_DMUSER; // onFetchDocument event, type = details $bot = new DOCMAN_mambot('onFetchDocument'); $bot->setParm('id', $id); $bot->copyParm('type', 'details'); $bot->trigger(); if ($bot->getError()) { _returnTo('cat_view', $bot->getErrorMsg()); } // document $doc =& DOCMAN_Document::getInstance($id); // process content mambots DOCMAN_Utils::processContentBots($doc, 'dmdescription');
/** * @param array An array of unique user id numbers * @param string The current url option */ function logoutUser($cid = null, $option, $task) { global $database, $my; josSpoofCheck(null, null, 'request'); if (is_array($cid)) { if (count($cid) < 1) { mosRedirect('index2.php?option=' . $option, 'Please select a user'); } foreach ($cid as $cidA) { $temp = new mosUser($database); $temp->load($cidA); // check to see whether a Administrator is attempting to log out a Super Admin if (!($my->gid == 24 && $temp->gid == 25)) { $id[] = $cidA; } } mosArrayToInts($cid); $ids = 'userid=' . implode(' OR userid=', $cid); } else { $temp = new mosUser($database); $temp->load($cid); // check to see whether a Administrator is attempting to log out a Super Admin if ($my->gid == 24 && $temp->gid == 25) { echo "<script> alert('You cannot log out a Super Administrator'); window.history.go(-1); </script>\n"; exit; } $ids = 'userid=' . (int) $cid; } $query = "DELETE FROM #__session" . "\n WHERE ( {$ids} )"; $database->setQuery($query); $database->query(); switch ($task) { case 'flogout': mosRedirect('index2.php', $database->getErrorMsg()); break; case 'remove': case 'block': case 'change': return; break; default: mosRedirect('index2.php?option=' . $option, $database->getErrorMsg()); break; } }
/** * Custom install method * @param int The id of the module * @param string The URL option * @param int The client id */ function uninstall($id, $option, $client = 0) { global $database, $mosConfig_absolute_path; josSpoofCheck(); $id = intval($id); $query = "SELECT module, iscore, client_id" . "\n FROM #__modules WHERE id = " . (int) $id; $database->setQuery($query); $row = null; $database->loadObject($row); if ($row->iscore) { HTML_installer::showInstallMessage($row->title . 'é um elemento do sistema e não pode ser desinstalado.<br />Caso não o pretenda continuar a utilizar será necessário retirar de publicação', 'Desinstalar - erro', $this->returnTo($option, 'module', $row->client_id ? '' : 'admin')); exit; } $query = "SELECT id" . "\n FROM #__modules" . "\n WHERE module = " . $database->Quote($row->module) . " AND client_id = " . (int) $row->client_id; $database->setQuery($query); $modules = $database->loadResultArray(); if (count($modules)) { mosArrayToInts($modules); $modID = 'moduleid=' . implode(' OR moduleid=', $modules); $query = "DELETE FROM #__modules_menu" . "\n WHERE ( {$modID} )"; $database->setQuery($query); if (!$database->query()) { $msg = $database->stderr; die($msg); } $query = "DELETE FROM #__modules" . "\n WHERE module = " . $database->Quote($row->module) . " AND client_id = " . (int) $row->client_id; $database->setQuery($query); if (!$database->query()) { $msg = $database->stderr; die($msg); } if (!$row->client_id) { $basepath = $mosConfig_absolute_path . '/modules/'; } else { $basepath = $mosConfig_absolute_path . '/administrator/modules/'; } $xmlfile = $basepath . $row->module . '.xml'; // see if there is an xml install file, must be same name as element if (file_exists($xmlfile)) { $this->i_xmldoc = new DOMIT_Lite_Document(); $this->i_xmldoc->resolveErrors(true); if ($this->i_xmldoc->loadXML($xmlfile, false, true)) { $mosinstall =& $this->i_xmldoc->documentElement; // get the files element $files_element =& $mosinstall->getElementsByPath('files', 1); if (!is_null($files_element)) { $files = $files_element->childNodes; foreach ($files as $file) { // delete the files $filename = $file->getText(); if (file_exists($basepath . $filename)) { $parts = pathinfo($filename); $subpath = $parts['dirname']; if ($subpath != '' && $subpath != '.' && $subpath != '..') { echo '<br />Deletado: ' . $basepath . $subpath; $result = deldir(mosPathName($basepath . $subpath . '/')); } else { echo '<br />Deletado: ' . $basepath . $filename; $result = unlink(mosPathName($basepath . $filename, false)); } echo intval($result); } } // remove XML file from front echo "Deletando arquivo XML: {$xmlfile}"; @unlink(mosPathName($xmlfile, false)); return true; } } } } }
function _where($type = 1, &$access, &$noauth, $gid, $id, $now = NULL, $year = NULL, $month = NULL, $params = NULL) { global $database, $mainframe; $noauth = !$mainframe->getCfg('shownoauth'); $nullDate = $database->getNullDate(); $now = _CURRENT_SERVER_TIME; $where = array(); $unpublished = 0; if (isset($params)) { // param controls whether unpublished items visible to publishers and above $unpublished = $params->def('unpublished', 0); } // normal if ($type > 0) { if (isset($params) && $unpublished) { // shows unpublished items for publishers and above if ($access->canEdit) { $where[] = "a.state >= 0"; } else { $where[] = "a.state = 1"; $where[] = "( a.publish_up = " . $database->Quote($nullDate) . " OR a.publish_up <= " . $database->Quote($now) . " )"; $where[] = "( a.publish_down = " . $database->Quote($nullDate) . " OR a.publish_down >= " . $database->Quote($now) . " )"; } } else { // unpublished items NOT shown for publishers and above $where[] = "a.state = 1"; //if ( !$access->canEdit ) { $where[] = "( a.publish_up = " . $database->Quote($nullDate) . " OR a.publish_up <= " . $database->Quote($now) . " )"; $where[] = "( a.publish_down = " . $database->Quote($nullDate) . " OR a.publish_down >= " . $database->Quote($now) . " )"; //} } // add query checks for category or section ids if ($id > 0) { $ids = explode(',', $id); mosArrayToInts($ids); if ($type == 1) { $where[] = '( a.sectionid=' . implode(' OR a.sectionid=', $ids) . ' )'; } else { if ($type == 2) { $where[] = '( a.catid=' . implode(' OR a.catid=', $ids) . ' )'; } } } } // archive if ($type < 0) { $where[] = "a.state = -1"; if ($year) { $where[] = "YEAR( a.created ) = " . $database->Quote($year); } if ($month) { $where[] = "MONTH( a.created ) = " . $database->Quote($month); } if ($id > 0) { if ($type == -1) { $where[] = "a.sectionid = " . (int) $id; } else { if ($type == -2) { $where[] = "a.catid = " . (int) $id; } } } } $where[] = "s.published = 1"; $where[] = "cc.published = 1"; if ($noauth) { $where[] = "a.access <= " . (int) $gid; $where[] = "s.access <= " . (int) $gid; $where[] = "cc.access <= " . (int) $gid; } return $where; }
/** * Publishes or Unpublishes one or more records * @param array An array of unique category id numbers * @param integer 0 if unpublishing, 1 if publishing * @param string The current url option */ function publishWeblinks($cid = null, $publish = 1, $option) { global $database, $my; josSpoofCheck(); if (!is_array($cid) || count($cid) < 1) { $action = $publish ? 'publish' : 'unpublish'; echo "<script> alert('Select an item to {$action}'); window.history.go(-1);</script>\n"; exit; } mosArrayToInts($cid); $cids = 'id=' . implode(' OR id=', $cid); $query = "UPDATE #__weblinks" . "\n SET published = " . (int) $publish . "\n WHERE ( {$cids} )" . "\n AND ( checked_out = 0 OR ( checked_out = " . (int) $my->id . " ) )"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; exit; } if (count($cid) == 1) { $row = new mosWeblink($database); $row->checkin($cid[0]); } mosRedirect("index2.php?option={$option}"); }
function removeBanner($cid) { global $database; josSpoofCheck(); if (count($cid)) { mosArrayToInts($cid); $cids = 'bid=' . implode(' OR bid=', $cid); $query = "DELETE FROM #__banner" . "\n WHERE ( {$cids} )"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; } } mosRedirect('index2.php?option=com_banners'); }
/** * Restores items selected to normal - restores to an unpublished state */ function restoreTrash($cid, $option) { global $database; josSpoofCheck(); $type = mosGetParam($_POST, 'type', array(0)); $total = count($cid); // restores to an unpublished state $state = 0; $ordering = 9999; if ($type == 'content') { // query to restore content items mosArrayToInts($cid); $cids = 'id=' . implode(' OR id=', $cid); $query = "UPDATE #__content" . "\n SET state = " . (int) $state . ", ordering = " . (int) $ordering . "\n WHERE ( {$cids} )"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; exit; } } else { if ($type == 'menu') { sort($cid); foreach ($cid as $id) { $check = 1; $row = new mosMenu($database); $row->load($id); // check if menu item is a child item if ($row->parent != 0) { $query = "SELECT id" . "\n FROM #__menu" . "\n WHERE id = " . (int) $row->parent . "\n AND ( published = 0 OR published = 1 )"; $database->setQuery($query); $check = $database->loadResult(); if (!$check) { // if menu items parent is not found that are published/unpublished make it a root menu item $query = "UPDATE #__menu" . "\n SET parent = 0, published = " . (int) $state . ", ordering = 9999" . "\n WHERE id = " . (int) $id; } } if ($check) { // query to restore menu items $query = "UPDATE #__menu" . "\n SET published = " . (int) $state . ", ordering = 9999" . "\n WHERE id = " . (int) $id; } $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; exit; } } } } $msg = $total . " Iten(s) restaurados com sucesso!"; mosRedirect("index2.php?option={$option}&mosmsg=" . $msg . ""); }
/** * Changes the state of one or more content pages * @param array An array of unique category id numbers * @param integer 0 if unpublishing, 1 if publishing */ function changeFrontPage($cid = null, $state = 0, $option) { global $database, $my; josSpoofCheck(); if (count($cid) < 1) { $action = $state == 1 ? 'publish' : ($state == -1 ? 'archive' : 'unpublish'); echo "<script> alert('Selecione um item para {$action}'); window.history.go(-1);</script>\n"; exit; } mosArrayToInts($cid); $cids = 'id=' . implode(' OR id=', $cid); $query = "UPDATE #__content" . "\n SET state = " . (int) $state . "\n WHERE ( {$cids} )" . "\n AND ( checked_out = 0 OR ( checked_out = " . (int) $my->id . " ) )"; $database->setQuery($query); 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]); } // clean any existing cache files mosCache::cleanCache('com_content'); mosRedirect("index2.php?option={$option}"); }