Ejemplo n.º 1
0
 protected static function _loadBehavior($group, $params = array())
 {
     static $loaded = array();
     if (!array_key_exists($group, $loaded)) {
         $loaded[$group] = true;
         // Include mootools framework.
         MHtml::_('behavior.framework', true);
         $document = MFactory::getDocument();
         $display = isset($params['startOffset']) && isset($params['startTransition']) && $params['startTransition'] ? (int) $params['startOffset'] : null;
         $show = isset($params['startOffset']) && !(isset($params['startTransition']) && $params['startTransition']) ? (int) $params['startOffset'] : null;
         $options = '{';
         $opt['onActive'] = "function(toggler, i) {toggler.addClass('pane-toggler-down');" . "toggler.removeClass('pane-toggler');i.addClass('pane-down');i.removeClass('pane-hide');Cookie.write('jpanesliders_" . $group . "',\$\$('div#" . $group . ".pane-sliders > .panel > h3').indexOf(toggler));}";
         $opt['onBackground'] = "function(toggler, i) {toggler.addClass('pane-toggler');" . "toggler.removeClass('pane-toggler-down');i.addClass('pane-hide');i.removeClass('pane-down');if(\$\$('div#" . $group . ".pane-sliders > .panel > h3').length==\$\$('div#" . $group . ".pane-sliders > .panel > h3.pane-toggler').length) Cookie.write('jpanesliders_" . $group . "',-1);}";
         $opt['duration'] = isset($params['duration']) ? (int) $params['duration'] : 300;
         $opt['display'] = isset($params['useCookie']) && $params['useCookie'] ? MRequest::getInt('jpanesliders_' . $group, $display, 'cookie') : $display;
         $opt['show'] = isset($params['useCookie']) && $params['useCookie'] ? MRequest::getInt('jpanesliders_' . $group, $show, 'cookie') : $show;
         $opt['opacity'] = isset($params['opacityTransition']) && $params['opacityTransition'] ? 'true' : 'false';
         $opt['alwaysHide'] = isset($params['allowAllClose']) && !$params['allowAllClose'] ? 'false' : 'true';
         foreach ($opt as $k => $v) {
             if ($v) {
                 $options .= $k . ': ' . $v . ',';
             }
         }
         if (substr($options, -1) == ',') {
             $options = substr($options, 0, -1);
         }
         $options .= '}';
         $js = "jQuery(document).ready(function () { new Fx.Accordion(\$\$('div#" . $group . ".pane-sliders > .panel > h3.pane-toggler'), \$\$('div#" . $group . ".pane-sliders > .panel > div.pane-slider'), " . $options . "); });";
         $document->addScriptDeclaration($js);
     }
 }
Ejemplo n.º 2
0
 public function apply()
 {
     // Check for request forgeries
     MRequest::checkToken() or mexit('Invalid Token');
     if ($this->_model->save($this->_table, $this->_query)) {
         $msg = MText::_('COM_MIWOSQL_SAVE_TRUE');
     } else {
         $msg = MText::_('COM_MIWOSQL_SAVE_FALSE');
     }
     $id = MRequest::getInt('id', MRequest::getInt('id', null, 'post'), 'get');
     $key = MRequest::getCmd('key', MRequest::getCmd('key', null, 'post'), 'get');
     $vars = '&ja_tbl_g=' . base64_encode($this->_table) . '&ja_qry_g=' . base64_encode($this->_query) . '&key=' . $key . '&id=' . $id;
     $this->setRedirect('index.php?option=com_miwosql&task=edit' . $vars, $msg);
 }
Ejemplo n.º 3
0
 public function display($tpl = null)
 {
     $db = MFactory::getDbo();
     $task = MRequest::getCmd('task');
     $table = MiwosqlHelper::getVar('tbl');
     $query = MiwosqlHelper::getVar('qry');
     $id = MRequest::getInt('id', MRequest::getInt('id', null, 'post'), 'get');
     $key = MRequest::getCmd('key', MRequest::getCmd('key', null, 'post'), 'get');
     $document = MFactory::getDocument();
     $document->addStyleSheet(MURL_MIWOSQL . '/admin/assets/css/miwosql.css');
     // Toolbar
     MToolBarHelper::title(MText::_('MiwoSQL') . ': <small><small> ' . $table . ' [ ' . $key . ' = ' . $id . ' ]' . ' </small></small>', 'miwosql');
     MToolBarHelper::apply();
     MToolBarHelper::save();
     MToolBarHelper::divider();
     MToolBarHelper::cancel();
     if ($task == 'edit') {
         $fld_value = '$value = $this->rows[$this->id][$field];';
     } else {
         $fld_value = '$value = "";';
     }
     list($rows, $last_key_vol) = $this->get('Data');
     $this->task = $task;
     $this->id = $id;
     $this->key = $key;
     $this->table = $table;
     $this->query = $query;
     $this->fld_value = $fld_value;
     $this->last_key_vol = $last_key_vol;
     $this->rows = $rows;
     $fields = $this->get('Fields');
     if (!MiwosqlHelper::is30()) {
         $fields = $fields[$this->table];
     }
     $this->fields = $fields;
     parent::display($tpl);
 }
Ejemplo n.º 4
0
 protected function getInput()
 {
     MHtml::_('behavior.tooltip');
     // Initialise some field attributes.
     $section = $this->element['section'] ? (string) $this->element['section'] : '';
     $component = $this->element['component'] ? (string) $this->element['component'] : '';
     $assetField = $this->element['asset_field'] ? (string) $this->element['asset_field'] : 'asset_id';
     // Get the actions for the asset.
     $actions = MAccess::getActions($component, $section);
     // Iterate over the children and add to the actions.
     foreach ($this->element->children() as $el) {
         if ($el->getName() == 'action') {
             $actions[] = (object) array('name' => (string) $el['name'], 'title' => (string) $el['title'], 'description' => (string) $el['description']);
         }
     }
     // Get the explicit rules for this asset.
     if ($section == 'component') {
         // Need to find the asset id by the name of the component.
         $db = MFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select($db->quoteName('id'));
         $query->from($db->quoteName('#__assets'));
         $query->where($db->quoteName('name') . ' = ' . $db->quote($component));
         $db->setQuery($query);
         $assetId = (int) $db->loadResult();
         if ($error = $db->getErrorMsg()) {
             MError::raiseNotice(500, $error);
         }
     } else {
         // Find the asset id of the content.
         // Note that for global configuration, com_config injects asset_id = 1 into the form.
         $assetId = $this->form->getValue($assetField);
     }
     // Use the compact form for the content rules (deprecated).
     //if (!empty($component) && $section != 'component') {
     //	return MHtml::_('rules.assetFormWidget', $actions, $assetId, $assetId ? null : $component, $this->name, $this->id);
     //}
     // Full width format.
     // Get the rules for just this asset (non-recursive).
     $assetRules = MAccess::getAssetRules($assetId);
     // Get the available user groups.
     $groups = $this->getUserGroups();
     // Build the form control.
     $curLevel = 0;
     // Prepare output
     $html = array();
     $html[] = '<div id="permissions-sliders" class="pane-sliders">';
     $html[] = '<p class="rule-desc">' . MText::_('MLIB_RULES_SETTINGS_DESC') . '</p>';
     $html[] = '<ul id="rules">';
     // Start a row for each user group.
     foreach ($groups as $group) {
         $difLevel = $group->level - $curLevel;
         if ($difLevel > 0) {
             $html[] = '<li><ul>';
         } elseif ($difLevel < 0) {
             $html[] = str_repeat('</ul></li>', -$difLevel);
         }
         $html[] = '<li>';
         $html[] = '<div class="panel">';
         $html[] = '<h3 class="pane-toggler title"><a href="javascript:void(0);"><span>';
         $html[] = str_repeat('<span class="level">|&ndash;</span> ', $curLevel = $group->level) . $group->text;
         $html[] = '</span></a></h3>';
         $html[] = '<div class="pane-slider content pane-hide">';
         $html[] = '<div class="mypanel">';
         $html[] = '<table class="group-rules">';
         $html[] = '<thead>';
         $html[] = '<tr>';
         $html[] = '<th class="actions" id="actions-th' . $group->value . '">';
         $html[] = '<span class="acl-action">' . MText::_('MLIB_RULES_ACTION') . '</span>';
         $html[] = '</th>';
         $html[] = '<th class="settings" id="settings-th' . $group->value . '">';
         $html[] = '<span class="acl-action">' . MText::_('MLIB_RULES_SELECT_SETTING') . '</span>';
         $html[] = '</th>';
         // The calculated setting is not shown for the root group of global configuration.
         $canCalculateSettings = $group->parent_id || !empty($component);
         if ($canCalculateSettings) {
             $html[] = '<th id="aclactionth' . $group->value . '">';
             $html[] = '<span class="acl-action">' . MText::_('MLIB_RULES_CALCULATED_SETTING') . '</span>';
             $html[] = '</th>';
         }
         $html[] = '</tr>';
         $html[] = '</thead>';
         $html[] = '<tbody>';
         foreach ($actions as $action) {
             $html[] = '<tr>';
             $html[] = '<td headers="actions-th' . $group->value . '">';
             $html[] = '<label class="hasTip" for="' . $this->id . '_' . $action->name . '_' . $group->value . '" title="' . htmlspecialchars(MText::_($action->title) . '::' . MText::_($action->description), ENT_COMPAT, 'UTF-8') . '">';
             $html[] = MText::_($action->title);
             $html[] = '</label>';
             $html[] = '</td>';
             $html[] = '<td headers="settings-th' . $group->value . '">';
             $html[] = '<select name="' . $this->name . '[' . $action->name . '][' . $group->value . ']" id="' . $this->id . '_' . $action->name . '_' . $group->value . '" title="' . MText::sprintf('MLIB_RULES_SELECT_ALLOW_DENY_GROUP', MText::_($action->title), trim($group->text)) . '">';
             $inheritedRule = MAccess::checkGroup($group->value, $action->name, $assetId);
             // Get the actual setting for the action for this group.
             $assetRule = $assetRules->allow($action->name, $group->value);
             // Build the dropdowns for the permissions sliders
             // The parent group has "Not Set", all children can rightly "Inherit" from that.
             $html[] = '<option value=""' . ($assetRule === null ? ' selected="selected"' : '') . '>' . MText::_(empty($group->parent_id) && empty($component) ? 'MLIB_RULES_NOT_SET' : 'MLIB_RULES_INHERITED') . '</option>';
             $html[] = '<option value="1"' . ($assetRule === true ? ' selected="selected"' : '') . '>' . MText::_('MLIB_RULES_ALLOWED') . '</option>';
             $html[] = '<option value="0"' . ($assetRule === false ? ' selected="selected"' : '') . '>' . MText::_('MLIB_RULES_DENIED') . '</option>';
             $html[] = '</select>&#160; ';
             // If this asset's rule is allowed, but the inherited rule is deny, we have a conflict.
             if ($assetRule === true && $inheritedRule === false) {
                 $html[] = MText::_('MLIB_RULES_CONFLICT');
             }
             $html[] = '</td>';
             // Build the Calculated Settings column.
             // The inherited settings column is not displayed for the root group in global configuration.
             if ($canCalculateSettings) {
                 $html[] = '<td headers="aclactionth' . $group->value . '">';
                 // This is where we show the current effective settings considering currrent group, path and cascade.
                 // Check whether this is a component or global. Change the text slightly.
                 if (MAccess::checkGroup($group->value, 'core.admin', $assetId) !== true) {
                     if ($inheritedRule === null) {
                         $html[] = '<span class="icon-16-unset">' . MText::_('MLIB_RULES_NOT_ALLOWED') . '</span>';
                     } elseif ($inheritedRule === true) {
                         $html[] = '<span class="icon-16-allowed">' . MText::_('MLIB_RULES_ALLOWED') . '</span>';
                     } elseif ($inheritedRule === false) {
                         if ($assetRule === false) {
                             $html[] = '<span class="icon-16-denied">' . MText::_('MLIB_RULES_NOT_ALLOWED') . '</span>';
                         } else {
                             $html[] = '<span class="icon-16-denied"><span class="icon-16-locked">' . MText::_('MLIB_RULES_NOT_ALLOWED_LOCKED') . '</span></span>';
                         }
                     }
                 } elseif (!empty($component)) {
                     $html[] = '<span class="icon-16-allowed"><span class="icon-16-locked">' . MText::_('MLIB_RULES_ALLOWED_ADMIN') . '</span></span>';
                 } else {
                     // Special handling for  groups that have global admin because they can't  be denied.
                     // The admin rights can be changed.
                     if ($action->name === 'core.admin') {
                         $html[] = '<span class="icon-16-allowed">' . MText::_('MLIB_RULES_ALLOWED') . '</span>';
                     } elseif ($inheritedRule === false) {
                         // Other actions cannot be changed.
                         $html[] = '<span class="icon-16-denied"><span class="icon-16-locked">' . MText::_('MLIB_RULES_NOT_ALLOWED_ADMIN_CONFLICT') . '</span></span>';
                     } else {
                         $html[] = '<span class="icon-16-allowed"><span class="icon-16-locked">' . MText::_('MLIB_RULES_ALLOWED_ADMIN') . '</span></span>';
                     }
                 }
                 $html[] = '</td>';
             }
             $html[] = '</tr>';
         }
         $html[] = '</tbody>';
         $html[] = '</table></div>';
         $html[] = '</div></div>';
         $html[] = '</li>';
     }
     $html[] = str_repeat('</ul></li>', $curLevel);
     $html[] = '</ul><div class="rule-notes">';
     if ($section == 'component' || $section == null) {
         $html[] = MText::_('MLIB_RULES_SETTING_NOTES');
     } else {
         $html[] = MText::_('MLIB_RULES_SETTING_NOTES_ITEM');
     }
     $html[] = '</div></div>';
     $js = "jQuery(document).ready(function () { new Fx.Accordion(\$\$('div#permissions-sliders.pane-sliders .panel h3.pane-toggler')," . "\$\$('div#permissions-sliders.pane-sliders .panel div.pane-slider'), {onActive: function(toggler, i) {toggler.addClass('pane-toggler-down');" . "toggler.removeClass('pane-toggler');i.addClass('pane-down');i.removeClass('pane-hide');Cookie.write('jpanesliders_permissions-sliders" . $component . "',\$\$('div#permissions-sliders.pane-sliders .panel h3').indexOf(toggler));}," . "onBackground: function(toggler, i) {toggler.addClass('pane-toggler');toggler.removeClass('pane-toggler-down');i.addClass('pane-hide');" . "i.removeClass('pane-down');}, duration: 300, display: " . MRequest::getInt('jpanesliders_permissions-sliders' . $component, 0, 'cookie') . ", show: " . MRequest::getInt('jpanesliders_permissions-sliders' . $component, 0, 'cookie') . ", alwaysHide:true, opacity: false}); });";
     MFactory::getDocument()->addScriptDeclaration($js);
     return implode("\n", $html);
 }
Ejemplo n.º 5
0
				</select>
				&nbsp; &nbsp;
				<?php 
echo MText::_('COM_MIWOSQL_TABLE') . ': ';
?>
				<select class="text_area" id="ja_tbl_p" name="ja_tbl_p" onchange="changeQuery(this);">
					<?php 
echo $this->tables;
?>
				</select>
				&nbsp; &nbsp;
				<?php 
echo MText::_('COM_MIWOSQL_RECORDS') . ': ';
?>
				<input class="text_area" type="text" size="3" id="ja_lim_p" name="ja_lim_p" value="<?php 
echo MRequest::getInt('ja_lim_p', 10, 'post');
?>
" style="width:30px;" onchange="changeQuery(this);">
		   </td>
		</tr>
		<tr>
			<td>
			   <textarea class="text_area" id="ja_qry_p" name="ja_qry_p" style="width:100%;height:70px;"><?php 
echo MiwosqlHelper::getVar('qry');
?>
</textarea>
			</td>
		</tr>
	</table>
	<?php 
echo $this->data;
Ejemplo n.º 6
0
<?php

/**
* @package		MiwoSQL
* @copyright	2009-2012 Mijosoft LLC, www.mijosoft.com
* @license		GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/
// No Permission
defined('MIWI') or die('Restricted access');
$views = array('&controller=miwosql' => MText::_('COM_MIWOSQL_RUN_QUERY'), '&controller=queries' => MText::_('COM_MIWOSQL_SAVED_QUERIES'));
if (!class_exists('JSubMenuHelper')) {
    return;
}
require_once MPATH_COMPONENT . '/helpers/helper.php';
MHTML::_('behavior.switcher');
if (MRequest::getInt('hidemainmenu') != 1) {
    JSubMenuHelper::addEntry(MText::_('COM_MIWOSQL_RUN_QUERY'), 'index.php?option=com_miwosql', MiwosqlHelper::isActiveSubMenu('query'));
    JSubMenuHelper::addEntry(MText::_('COM_MIWOSQL_SAVED_QUERIES'), 'index.php?option=com_miwosql&controller=queries', MiwosqlHelper::isActiveSubMenu('queries'));
}
Ejemplo n.º 7
0
 protected function _buildSefRoute(&$uri)
 {
     // Get the route
     $route = $uri->getPath();
     $route = str_replace('index.php', '', $route);
     // Get the query data
     $query = $uri->getQuery(true);
     if (!isset($query['option'])) {
         return;
     }
     /*
      * Build the component route
      */
     $component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $query['option']);
     $tmp = '';
     // Use the component routing handler if it exists
     $path = MPATH_WP_PLG . '/' . str_replace('com_', '', $component) . '/site/router.php';
     // Use the custom routing handler if it exists
     if (file_exists($path) && !empty($query)) {
         require_once $path;
         $function = str_replace('com_', '', $component) . 'BuildRoute';
         $function = str_replace(array("-", "."), "", $function);
         $parts = $function($query);
         // encode the route segments
         $parts = $this->_encodeSegments($parts);
         $result = implode('/', $parts);
         $tmp = $result != "" ? $result : '';
     }
     /*
      * Build the application route
      */
     if ($tmp) {
         $route .= '/' . $tmp;
     } elseif ($route == 'index.php') {
         $route = '';
     }
     $option_get = str_replace('com_', '', MRequest::getWord('option', ''));
     if (str_replace('com_', '', $component) == $option_get) {
         $page_id = MRequest::getInt('page_id');
     } else {
         $page_id = null;
     }
     if (empty($page_id)) {
         $page_id = MFactory::getWOption(str_replace('com_', '', $query['option']) . '_page_id');
     }
     if (!empty($page_id)) {
         $post = MFactory::getWPost($page_id);
         if (is_object($post)) {
             $route = $post->post_name . '/' . ltrim($route, '/');
         }
         $route = MUri::base(true) . '/' . ltrim($route, '/');
     }
     // Unset unneeded query information
     unset($query['option']);
     //Set query again in the URI
     $uri->setQuery($query);
     $uri->setPath($route);
 }