Compare commits

...

6 Commits

5 changed files with 95 additions and 56 deletions

View File

@ -14,9 +14,11 @@ MOD_PERGROUP_VALIDATION_TYPE="Validation Type"
MOD_PERGROUP_IN_GROUP="In Group" MOD_PERGROUP_IN_GROUP="In Group"
MOD_PERGROUP_NOT_IN_GROUP="Not In Group" MOD_PERGROUP_NOT_IN_GROUP="Not In Group"
MOD_PERGROUP_EXECUTION_DIRECTION="Execution Direction" MOD_PERGROUP_EXECUTION_DIRECTION="Load Direction"
MOD_PERGROUP_UP="Up" MOD_PERGROUP_FIRST_FOUND_CONTENT="Load Only First Found"
MOD_PERGROUP_DOWN="Down" MOD_PERGROUP_UP="Normal"
MOD_PERGROUP_DOWN="Change"
MOD_PERGROUP_NONE="None"
MOD_PERGROUP_BREAK="New Line" MOD_PERGROUP_BREAK="New Line"
MOD_PERGROUP_CLASS="Class [<div class="separator">]" MOD_PERGROUP_CLASS="Class [<div class="separator">]"
MOD_PERGROUP_BOOTSTRAP="Bootstrap" MOD_PERGROUP_BOOTSTRAP="Bootstrap"

View File

@ -10,7 +10,7 @@
**/ **/
defined( '_JEXEC' ) or die; defined( '_JEXEC' ) or die;
// Include the syndicate functions only once // Include the functions only once
require_once __DIR__ . '/pergroup.php'; require_once __DIR__ . '/pergroup.php';
// load the module class // load the module class

View File

@ -50,13 +50,13 @@
<option value="1">MOD_PERGROUP_YES</option> <option value="1">MOD_PERGROUP_YES</option>
</field> </field>
<field type="spacer" name="myspacer_0" label="MOD_PERGROUP_HTML_INPUT" /> <field type="spacer" name="myspacer_0" label="MOD_PERGROUP_HTML_INPUT" />
<field name="group0-notice" label="" type="editor" width="95%" height="300" filter="safehtml"/> <field name="group0-notice" label="" type="editor" width="95%" height="300" filter="raw"/>
<field type="spacer" name="spasor_0" label="MOD_PERGROUP_CSS_INPUT" /> <field type="spacer" name="spasor_0" label="MOD_PERGROUP_CSS_INPUT" />
<field name="group0-css" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group0-css" label="" type="editor" width="95%" height="100" filter="raw" editor="none|codemirror" />
<field type="spacer" name="spacer_0" label="MOD_PERGROUP_JAVASCRIPT_INPUT" /> <field type="spacer" name="spacer_0" label="MOD_PERGROUP_JAVASCRIPT_INPUT" />
<field name="group0-js" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group0-js" label="" type="editor" width="95%" height="100" filter="raw" editor="none|codemirror" />
<field type="spacer" name="spacur_0" label="MOD_PERGROUP_PHP_INPUT"/> <field type="spacer" name="spacur_0" label="MOD_PERGROUP_PHP_INPUT"/>
<field name="group0-php" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group0-php" label="" type="editor" width="95%" height="200" filter="raw" editor="none|codemirror" />
<field type="spacer" name="line0" hr="true" /> <field type="spacer" name="line0" hr="true" />
<field name="group1" type="usergroup" multiple="true" <field name="group1" type="usergroup" multiple="true"
@ -78,13 +78,13 @@
<option value="1">MOD_PERGROUP_YES</option> <option value="1">MOD_PERGROUP_YES</option>
</field> </field>
<field type="spacer" name="myspacer_1" label="MOD_PERGROUP_HTML_INPUT" /> <field type="spacer" name="myspacer_1" label="MOD_PERGROUP_HTML_INPUT" />
<field name="group1-notice" label="" type="editor" width="95%" height="300" filter="safehtml" /> <field name="group1-notice" label="" type="editor" width="95%" height="300" filter="raw" />
<field type="spacer" name="spasor_1" label="MOD_PERGROUP_CSS_INPUT" /> <field type="spacer" name="spasor_1" label="MOD_PERGROUP_CSS_INPUT" />
<field name="group1-css" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group1-css" label="" type="editor" width="95%" height="100" filter="raw" editor="none|codemirror"/>
<field type="spacer" name="spacer_1" label="MOD_PERGROUP_JAVASCRIPT_INPUT" /> <field type="spacer" name="spacer_1" label="MOD_PERGROUP_JAVASCRIPT_INPUT" />
<field name="group1-js" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group1-js" label="" type="editor" width="95%" height="100" filter="raw" editor="none|codemirror"/>
<field type="spacer" name="spacur_1" label="MOD_PERGROUP_PHP_INPUT"/> <field type="spacer" name="spacur_1" label="MOD_PERGROUP_PHP_INPUT"/>
<field name="group1-php" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group1-php" label="" type="editor" width="95%" height="200" filter="raw" editor="none|codemirror"/>
<field type="spacer" name="line1" hr="true" /> <field type="spacer" name="line1" hr="true" />
<field name="group2" type="usergroup" multiple="true" <field name="group2" type="usergroup" multiple="true"
@ -106,13 +106,13 @@
<option value="1">MOD_PERGROUP_YES</option> <option value="1">MOD_PERGROUP_YES</option>
</field> </field>
<field type="spacer" name="myspacer_2" label="MOD_PERGROUP_HTML_INPUT" /> <field type="spacer" name="myspacer_2" label="MOD_PERGROUP_HTML_INPUT" />
<field name="group2-notice" label="" type="editor" width="95%" height="300" filter="safehtml" /> <field name="group2-notice" label="" type="editor" width="95%" height="300" filter="raw" />
<field type="spacer" name="spasor_2" label="MOD_PERGROUP_CSS_INPUT" /> <field type="spacer" name="spasor_2" label="MOD_PERGROUP_CSS_INPUT" />
<field name="group2-css" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group2-css" label="" type="editor" width="95%" height="100" filter="raw" editor="none|codemirror" />
<field type="spacer" name="spacer_2" label="MOD_PERGROUP_JAVASCRIPT_INPUT" /> <field type="spacer" name="spacer_2" label="MOD_PERGROUP_JAVASCRIPT_INPUT" />
<field name="group2-js" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group2-js" label="" type="editor" width="95%" height="100" filter="raw" editor="none|codemirror" />
<field type="spacer" name="spacur_2" label="MOD_PERGROUP_PHP_INPUT"/> <field type="spacer" name="spacur_2" label="MOD_PERGROUP_PHP_INPUT"/>
<field name="group2-php" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group2-php" label="" type="editor" width="95%" height="200" filter="raw" editor="none|codemirror" />
<field type="spacer" name="line2" hr="true" /> <field type="spacer" name="line2" hr="true" />
<field name="group3" type="usergroup" multiple="true" <field name="group3" type="usergroup" multiple="true"
@ -134,13 +134,13 @@
<option value="1">MOD_PERGROUP_YES</option> <option value="1">MOD_PERGROUP_YES</option>
</field> </field>
<field type="spacer" name="myspacer_3" label="MOD_PERGROUP_HTML_INPUT" /> <field type="spacer" name="myspacer_3" label="MOD_PERGROUP_HTML_INPUT" />
<field name="group3-notice" label="" type="editor" width="95%" height="300" filter="safehtml" /> <field name="group3-notice" label="" type="editor" width="95%" height="300" filter="raw" />
<field type="spacer" name="spasor_3" label="MOD_PERGROUP_CSS_INPUT" /> <field type="spacer" name="spasor_3" label="MOD_PERGROUP_CSS_INPUT" />
<field name="group3-css" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group3-css" label="" type="editor" width="95%" height="100" filter="raw" editor="none|codemirror" />
<field type="spacer" name="spacer_3" label="MOD_PERGROUP_JAVASCRIPT_INPUT" /> <field type="spacer" name="spacer_3" label="MOD_PERGROUP_JAVASCRIPT_INPUT" />
<field name="group3-js" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group3-js" label="" type="editor" width="95%" height="100" filter="raw" editor="none|codemirror" />
<field type="spacer" name="spacur_3" label="MOD_PERGROUP_PHP_INPUT"/> <field type="spacer" name="spacur_3" label="MOD_PERGROUP_PHP_INPUT"/>
<field name="group3-php" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group3-php" label="" type="editor" width="95%" height="200" filter="raw" editor="none|codemirror" />
<field type="spacer" name="line3" hr="true" /> <field type="spacer" name="line3" hr="true" />
<field name="group4" type="usergroup" multiple="true" <field name="group4" type="usergroup" multiple="true"
@ -162,13 +162,13 @@
<option value="1">MOD_PERGROUP_YES</option> <option value="1">MOD_PERGROUP_YES</option>
</field> </field>
<field type="spacer" name="myspacer_4" label="MOD_PERGROUP_HTML_INPUT" /> <field type="spacer" name="myspacer_4" label="MOD_PERGROUP_HTML_INPUT" />
<field name="group4-notice" label="" type="editor" width="95%" height="300" filter="safehtml" /> <field name="group4-notice" label="" type="editor" width="95%" height="300" filter="raw" />
<field type="spacer" name="spasor_4" label="MOD_PERGROUP_CSS_INPUT" /> <field type="spacer" name="spasor_4" label="MOD_PERGROUP_CSS_INPUT" />
<field name="group4-css" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group4-css" label="" type="editor" width="95%" height="100" filter="raw" editor="none|codemirror" />
<field type="spacer" name="spacer_4" label="MOD_PERGROUP_JAVASCRIPT_INPUT" /> <field type="spacer" name="spacer_4" label="MOD_PERGROUP_JAVASCRIPT_INPUT" />
<field name="group4-js" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group4-js" label="" type="editor" width="95%" height="100" filter="raw" editor="none|codemirror" />
<field type="spacer" name="spacur_4" label="MOD_PERGROUP_PHP_INPUT"/> <field type="spacer" name="spacur_4" label="MOD_PERGROUP_PHP_INPUT"/>
<field name="group4-php" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group4-php" label="" type="editor" width="95%" height="200" filter="raw" editor="none|codemirror" />
<field type="spacer" name="line4" hr="true" /> <field type="spacer" name="line4" hr="true" />
<field name="group5" type="usergroup" multiple="true" <field name="group5" type="usergroup" multiple="true"
@ -190,13 +190,13 @@
<option value="1">MOD_PERGROUP_YES</option> <option value="1">MOD_PERGROUP_YES</option>
</field> </field>
<field type="spacer" name="myspacer_5" label="MOD_PERGROUP_HTML_INPUT" /> <field type="spacer" name="myspacer_5" label="MOD_PERGROUP_HTML_INPUT" />
<field name="group5-notice" label="" type="editor" width="95%" height="300" filter="safehtml" /> <field name="group5-notice" label="" type="editor" width="95%" height="300" filter="raw" />
<field type="spacer" name="spasor_5" label="MOD_PERGROUP_CSS_INPUT" /> <field type="spacer" name="spasor_5" label="MOD_PERGROUP_CSS_INPUT" />
<field name="group5-css" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group5-css" label="" type="editor" width="95%" height="100" filter="raw" editor="none|codemirror" />
<field type="spacer" name="spacer_5" label="MOD_PERGROUP_JAVASCRIPT_INPUT" /> <field type="spacer" name="spacer_5" label="MOD_PERGROUP_JAVASCRIPT_INPUT" />
<field name="group5-js" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group5-js" label="" type="editor" width="95%" height="100" filter="raw" editor="none|codemirror" />
<field type="spacer" name="spacur_5" label="MOD_PERGROUP_PHP_INPUT"/> <field type="spacer" name="spacur_5" label="MOD_PERGROUP_PHP_INPUT"/>
<field name="group5-php" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group5-php" label="" type="editor" width="95%" height="200" filter="raw" editor="none|codemirror" />
<field type="spacer" name="line5" hr="true" /> <field type="spacer" name="line5" hr="true" />
<field name="group6" type="usergroup" multiple="true" <field name="group6" type="usergroup" multiple="true"
@ -218,13 +218,13 @@
<option value="1">MOD_PERGROUP_YES</option> <option value="1">MOD_PERGROUP_YES</option>
</field> </field>
<field type="spacer" name="myspacer_6" label="MOD_PERGROUP_HTML_INPUT" /> <field type="spacer" name="myspacer_6" label="MOD_PERGROUP_HTML_INPUT" />
<field name="group6-notice" label="" type="editor" width="95%" height="300" filter="safehtml" /> <field name="group6-notice" label="" type="editor" width="95%" height="300" filter="raw" />
<field type="spacer" name="spasor_6" label="MOD_PERGROUP_CSS_INPUT" /> <field type="spacer" name="spasor_6" label="MOD_PERGROUP_CSS_INPUT" />
<field name="group6-css" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group6-css" label="" type="editor" width="95%" height="100" filter="raw" editor="none|codemirror" />
<field type="spacer" name="spacer_6" label="MOD_PERGROUP_JAVASCRIPT_INPUT" /> <field type="spacer" name="spacer_6" label="MOD_PERGROUP_JAVASCRIPT_INPUT" />
<field name="group6-js" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group6-js" label="" type="editor" width="95%" height="100" filter="raw" editor="none|codemirror" />
<field type="spacer" name="spacur_6" label="MOD_PERGROUP_PHP_INPUT"/> <field type="spacer" name="spacur_6" label="MOD_PERGROUP_PHP_INPUT"/>
<field name="group6-php" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group6-php" label="" type="editor" width="95%" height="200" filter="raw" editor="none|codemirror" />
<field type="spacer" name="line6" hr="true" /> <field type="spacer" name="line6" hr="true" />
<field name="group7" type="usergroup" multiple="true" <field name="group7" type="usergroup" multiple="true"
@ -246,13 +246,13 @@
<option value="1">MOD_PERGROUP_YES</option> <option value="1">MOD_PERGROUP_YES</option>
</field> </field>
<field type="spacer" name="myspacer_7" label="MOD_PERGROUP_HTML_INPUT" /> <field type="spacer" name="myspacer_7" label="MOD_PERGROUP_HTML_INPUT" />
<field name="group7-notice" label="" type="editor" width="95%" height="300" filter="safehtml" /> <field name="group7-notice" label="" type="editor" width="95%" height="300" filter="raw" />
<field type="spacer" name="spasor_7" label="MOD_PERGROUP_CSS_INPUT" /> <field type="spacer" name="spasor_7" label="MOD_PERGROUP_CSS_INPUT" />
<field name="group7-css" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group7-css" label="" type="editor" width="95%" height="100" filter="raw" editor="none|codemirror" />
<field type="spacer" name="spacer_7" label="MOD_PERGROUP_JAVASCRIPT_INPUT" /> <field type="spacer" name="spacer_7" label="MOD_PERGROUP_JAVASCRIPT_INPUT" />
<field name="group7-js" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group7-js" label="" type="editor" width="95%" height="100" filter="raw" editor="none|codemirror" />
<field type="spacer" name="spacur_7" label="MOD_PERGROUP_PHP_INPUT"/> <field type="spacer" name="spacur_7" label="MOD_PERGROUP_PHP_INPUT"/>
<field name="group7-php" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group7-php" label="" type="editor" width="95%" height="200" filter="raw" editor="none|codemirror" />
<field type="spacer" name="line7" hr="true" /> <field type="spacer" name="line7" hr="true" />
<field name="group8" type="usergroup" multiple="true" <field name="group8" type="usergroup" multiple="true"
@ -274,13 +274,13 @@
<option value="1">MOD_PERGROUP_YES</option> <option value="1">MOD_PERGROUP_YES</option>
</field> </field>
<field type="spacer" name="myspacer_8" label="MOD_PERGROUP_HTML_INPUT" /> <field type="spacer" name="myspacer_8" label="MOD_PERGROUP_HTML_INPUT" />
<field name="group8-notice" label="" type="editor" width="95%" height="300" filter="safehtml" /> <field name="group8-notice" label="" type="editor" width="95%" height="300" filter="raw" />
<field type="spacer" name="spasor_8" label="MOD_PERGROUP_CSS_INPUT" /> <field type="spacer" name="spasor_8" label="MOD_PERGROUP_CSS_INPUT" />
<field name="group8-css" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group8-css" label="" type="editor" width="95%" height="100" filter="raw" editor="none|codemirror" />
<field type="spacer" name="spacer_8" label="MOD_PERGROUP_JAVASCRIPT_INPUT" /> <field type="spacer" name="spacer_8" label="MOD_PERGROUP_JAVASCRIPT_INPUT" />
<field name="group8-js" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group8-js" label="" type="editor" width="95%" height="100" filter="raw" editor="none|codemirror" />
<field type="spacer" name="spacur_8" label="MOD_PERGROUP_PHP_INPUT"/> <field type="spacer" name="spacur_8" label="MOD_PERGROUP_PHP_INPUT"/>
<field name="group8-php" label="" type="editor" width="95%" height="100" filter="raw" /> <field name="group8-php" label="" type="editor" width="95%" height="200" filter="raw" editor="none|codemirror" />
</fieldset> </fieldset>
<fieldset <fieldset
@ -295,6 +295,16 @@
<option value="1">JYES</option> <option value="1">JYES</option>
<option value="0">JNO</option> <option value="0">JNO</option>
</field> </field>
<field
name="first_found_content"
type="radio"
class="btn-group btn-group-yesno"
label="MOD_PERGROUP_FIRST_FOUND_CONTENT"
description=""
default="1">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field <field
name="execution_direction" name="execution_direction"
type="radio" type="radio"
@ -306,10 +316,11 @@
<option value="0">MOD_PERGROUP_DOWN</option> <option value="0">MOD_PERGROUP_DOWN</option>
</field> </field>
<field name="separator" type="radio" default="0" label="MOD_PERGROUP_SEPERATOR" description=""> <field name="separator" type="radio" default="0" label="MOD_PERGROUP_SEPERATOR" description="">
<option value="0">MOD_PERGROUP_BREAK</option> <option value="0">MOD_PERGROUP_NONE</option>
<option value="1">MOD_PERGROUP_CLASS</option> <option value="1">MOD_PERGROUP_BREAK</option>
<option value="2">MOD_PERGROUP_BOOTSTRAP</option> <option value="2">MOD_PERGROUP_CLASS</option>
<option value="3">MOD_PERGROUP_DIV</option> <option value="3">MOD_PERGROUP_BOOTSTRAP</option>
<option value="4">MOD_PERGROUP_DIV</option>
</field> </field>
<field <field
name="layout" name="layout"

View File

@ -20,6 +20,7 @@ class perGroup
protected $document; protected $document;
protected $jQuery_set; protected $jQuery_set;
protected $params; protected $params;
protected $found = false;
protected $range_low = 0; protected $range_low = 0;
protected $range_high = 8; protected $range_high = 8;
@ -34,11 +35,12 @@ class perGroup
// check if loged in // check if loged in
$this->userId = JFactory::getUser()->id; $this->userId = JFactory::getUser()->id;
if($this->userId){ if($this->userId){
// setup user details // setup user groups
$this->userGroups = JUserHelper::getUserGroups($this->userId); $this->userGroups = JUserHelper::getUserGroups($this->userId);
} else { } else {
// setup user details $params_users = JComponentHelper::getParams('com_users');
$this->userGroups = $this->params->get('group0'); // setup quest user groups
$this->userGroups = array($params_users->get('guest_usergroup'));
} }
// check direction of execution // check direction of execution
$up = $this->params->get('execution_direction'); $up = $this->params->get('execution_direction');
@ -76,6 +78,10 @@ class perGroup
$app->redirect($this->results[$field_id]); $app->redirect($this->results[$field_id]);
return true; return true;
} }
// if set so that not all content should be loaded, then break when firt data is found
if($this->found && $this->params->get('first_found_content')){
break;
}
} }
return true; return true;
} }
@ -106,6 +112,8 @@ class perGroup
} }
// set result only if not a redirect // set result only if not a redirect
$text[] = $result; $text[] = $result;
$this->found = true;
break;
} else { } else {
// when user is not in active group // when user is not in active group
$text[] = false; $text[] = false;
@ -119,6 +127,8 @@ class perGroup
} }
// set result only if not a redirect // set result only if not a redirect
$text[] = $result; $text[] = $result;
$this->found = true;
break;
} else { } else {
// when user is not in active group // when user is not in active group
$text[] = false; $text[] = false;
@ -155,7 +165,7 @@ class perGroup
$group_js = $this->params->get('group'.$id.'-js'); $group_js = $this->params->get('group'.$id.'-js');
if ($group_js){ if ($group_js){
if (!$this->jQuery_set){ if (!$this->jQuery_set){
$this->document->addScript(JURI::base().'modules/mod_perGroup/js/jquery.js'); $this->document->addScript(JURI::base().'modules/mod_pergroup/js/jquery.js');
$this->jQuery_set = true; $this->jQuery_set = true;
} }
$script = ''.$group_js.''; $script = ''.$group_js.'';

View File

@ -15,17 +15,33 @@ $separator_value = $params->get('separator');
?> ?>
<?php if(is_array($module->results)): ?> <?php if(is_array($module->results)): ?>
<div>
<?php $i = 0; ?> <?php $i = 0; ?>
<?php foreach($module->results as $group_id => &$group): ?> <?php foreach($module->results as $group_id => &$group): ?>
<?php if(is_array($group)): ?> <?php if(is_array($group)): ?>
<?php foreach($group as $text): ?> <?php foreach($group as $text): ?>
<?php if($counter): ?> <?php if($text): ?>
<?php echo '<br/>'; ?>
<?php endif; ?> <?php if($separator_value): ?>
<?php echo ($prepare_content) ? JHtml::_('content.prepare', $text) : $text; $i++; ?> <?php if($separator_value == 1): ?>
<?php endforeach; ?> <?php echo ($i) ? '<br/>' : ''; ?>
<?php else: ?>
<div<?php echo ($separator_value == 2) ? ' class="separator"' : ''; echo ($separator_value == 3) ? ' class="jumbotron"' : ''; ?>>
<?php endif; ?>
<?php endif; ?>
<!-- the main text -->
<?php echo ($prepare_content) ? JHtml::_('content.prepare', $text) : $text; ?>
<?php if($separator_value): ?>
<?php if($separator_value != 1): ?>
</div>
<?php endif; ?>
<?php endif ?>
<?php $i++; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
<?php endforeach; ?> <?php endforeach; ?>
</div>
<?php endif; ?> <?php endif; ?>