Skip to content

Commit

Permalink
Bugfixed the restricted access to the prev-up-next navigation
Browse files Browse the repository at this point in the history
Added the restricted access icon on the module's list
  • Loading branch information
goldsky committed Nov 30, 2011
1 parent 81b0811 commit 50c7876
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 30 deletions.
6 changes: 4 additions & 2 deletions assets/modules/easy2/changes.english.txt
Expand Up @@ -4,10 +4,12 @@
(____)\_/\_/(____/(__/ (____) \___/\_/\_/\____/\____/(____)(__\_)(__/

***************** 1.4.9 ******************
Fix:
Fixes:
+ Bugfixed the restricted access to the prev-up-next navigation
+ Added the restricted access icon on the module's list
+ Debug returned the valid folders as false

Improvement:
Improvements:
+ deleted old template files
+ refactored the snippet's class
+ added &wmposxy for specified x,y watermark's position
Expand Down
Expand Up @@ -191,12 +191,38 @@
<img src="' . E2G_MODULE_URL . 'includes/tpl/icons/folder.png"
width="16" height="16" border="0" alt="" />
';
// checks any redirect link
if (!empty($fetchDir['cat_redirect_link'])) {
$dirIcon .= '
<img src="' . E2G_MODULE_URL . 'includes/tpl/icons/link.png" width="16"
height="16" alt="link" title="' . $lng['redirect_link'] . ': ' . $fetchDir['cat_redirect_link'] . '" border="0" />
';
}
// checks the restricted web access
$checkWebAccess = array();
$$checkWebAccessQuery = 'SELECT * FROM ' . $modx->db->config['table_prefix'] . 'easy2_webgroup_access '
. 'WHERE type=\'dir\' AND id=\'' . $fetchDir['cat_id'] . '\'';
$checkWebAccess = $modx->db->makeArray($modx->db->query($$checkWebAccessQuery));
if (!empty($checkWebAccess)) {
foreach ($checkWebAccess as $k => $v) {
$webgroup_id['dir'][$fetchDir['cat_id']][] = '\'' . $v['webgroup_id'] . '\'';
}
$implodeGroupId = implode(',', $webgroup_id['dir'][$fetchDir['cat_id']]);
$webAccessQuery = 'SELECT name FROM ' . $modx->db->config['table_prefix'] . 'webgroup_names '
. 'WHERE id IN (' . $implodeGroupId . ')';
$webGroup = $modx->db->makeArray($modx->db->query($webAccessQuery));
foreach ($webGroup as $k => $v) {
$webGroupNames[] = $v['name'];
}
if (!empty($webGroup)) {
$webGroupNames = implode(', ', $webGroupNames);
$dirIcon .= '
<img src="' . E2G_MODULE_URL . 'includes/tpl/icons/lock.png" width="16"
height="16" alt="lock" title="' . $lng['access'] . ': ' . $webGroupNames . '" border="0" />
';
}
}

$dirButtons = '';

if (!$e2gMod->validFolder($gdirRealPath . DIRECTORY_SEPARATOR . $e2gMod->e2gDecode($fetchDir['cat_name']))) {
Expand Down
11 changes: 6 additions & 5 deletions assets/modules/easy2/includes/langs/english.inc.php
@@ -1,6 +1,7 @@
<?php
$e2g_lang['english'] = array (
'_thumb_err' => 'Could not create folder &quot;_thumbnails&quot;',
'access' => 'Restricted Access',
'actions' => 'Actions',
'add' => 'Add',
'add_to_db' => 'Add to DB',
Expand Down Expand Up @@ -272,7 +273,7 @@
&lt;ul&gt;
&lt;li&gt;[field][,comma][operator][,comma][value]&lt;/li&gt;
&lt;li&gt;They can have multiple clauses by using &#039;AND&#039; and/or &#039;OR&#039;&lt;/li&gt;
&lt;li&gt;The Operator have to be a string, as following:
&lt;li&gt;The Operator have to be a string, as following:
&lt;ul&gt;
&lt;li&gt;&quot;NULL safe equal&quot; =&amp;gt; &#039;&amp;lt;=&amp;gt;&#039;&lt;/li&gt;
&lt;li&gt;&quot;equal&quot; =&amp;gt; &#039;=&#039;&lt;/li&gt;
Expand Down Expand Up @@ -399,15 +400,15 @@
&lt;p&gt;&lt;strong&gt;&amp;amp;ss_config&lt;/strong&gt; - custom configuration/options for each of slideshow types.&lt;br /&gt; The implementation is up to the developer to use it inside the slideshow&#039;s index file.&lt;/p&gt;
&lt;p&gt;Default options:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;galleriffic
&lt;li&gt;galleriffic
&lt;ul&gt;
&lt;li&gt;example-1 &lt;em&gt;(default)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;example-2&lt;/li&gt;
&lt;li&gt;example-3&lt;/li&gt;
&lt;li&gt;example-5&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;smoothgallery
&lt;li&gt;smoothgallery
&lt;ul&gt;
&lt;li&gt;fullgallery &lt;em&gt;(default)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;galleryset&lt;/li&gt;
Expand All @@ -421,7 +422,7 @@
&lt;li&gt;zoom&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;galleryview
&lt;li&gt;galleryview
&lt;ul&gt;
&lt;li&gt;gallerylight &lt;em&gt;(default)&lt;/em&gt;&lt;br /&gt;[!easy2? &amp;amp;slideshow=`galleryview` &amp;amp;ss_config=`gallerylight` &amp;amp;w=`100` &amp;amp;h=`100` &amp;amp;ss_w=`600` &amp;amp;ss_h=`400` !]&lt;/li&gt;
&lt;li&gt;gallerydark&lt;br /&gt;[!easy2? &amp;amp;slideshow=`galleryview` &amp;amp;ss_config=`gallerydark` &amp;amp;w=`30` &amp;amp;h=`30` &amp;amp;ss_w=`600` &amp;amp;ss_h=`400`!]&lt;/li&gt;
Expand All @@ -431,7 +432,7 @@
&lt;li&gt;panel&lt;br /&gt;[!easy2? &amp;amp;slideshow=`galleryview` &amp;amp;ss_config=`panel` &amp;amp;ss_w=`600` &amp;amp;ss_h=`300`!]&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;contentflow
&lt;li&gt;contentflow
&lt;ul&gt;
&lt;li&gt;default &lt;em&gt;(default)&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
Expand Down
19 changes: 7 additions & 12 deletions assets/modules/easy2/includes/models/e2g.public.class.php
Expand Up @@ -25,7 +25,7 @@ class E2gPub { // public/public class
*/
private $_e2g = array();
/**
* Directorie information
* Directory information
* @var array
*/
private $_dirInfo = array();
Expand Down Expand Up @@ -555,8 +555,8 @@ public function plugin($e2gEvtName, $e2gEvtParams = array(), $e2gPluginName = NU
*/
public function folderImg($gid, $gdir) {

$excludeDirWebAccess = $this->excludeWebAccess('dir');
$excludeFileWebAccess = $this->excludeWebAccess('file');
$excludeDirWebAccess = $this->checkWebAccess('dir');
$excludeFileWebAccess = $this->checkWebAccess('file');

/**
* Select the file from the manual selected thumbnail
Expand Down Expand Up @@ -693,12 +693,7 @@ public function folderImg($gid, $gdir) {
* @param string $type dir/file selection
* @return string the excluded ids from the SQL parameter
*/
public function excludeWebAccess($type) {
// if in the manager mode, don't use this
if (IN_MANAGER_MODE !== "false") {
return FALSE;
}

public function checkWebAccess($type) {
/**
* Get all the restricted list ids
*/
Expand Down Expand Up @@ -747,11 +742,11 @@ public function excludeWebAccess($type) {
/**
* Get the difference
*/
$excludeWebAccess = array_diff($allWebAccess, $userWebAccess);
if (empty($excludeWebAccess)) {
$checkWebAccess = array_diff($allWebAccess, $userWebAccess);
if (empty($checkWebAccess)) {
return FALSE;
}
$excludeWebAccessString = @implode(',', $excludeWebAccess);
$excludeWebAccessString = @implode(',', $checkWebAccess);
return $excludeWebAccessString;
}

Expand Down
29 changes: 18 additions & 11 deletions assets/modules/easy2/includes/models/e2g.snippet.class.php
Expand Up @@ -1976,7 +1976,7 @@ private function _checkTaggedDirIds($tag, $id=1) {
$selectTaggedDirs .= 'OR LOWER(cat_tag) LIKE \'%' . $xpldDirTags[$i] . '%\' ';
}

$excludeDirWebAccess = $this->excludeWebAccess('dir');
$excludeDirWebAccess = $this->checkWebAccess('dir');

if ($excludeDirWebAccess !== FALSE) {
$selectTaggedDirs .= 'AND cat_id NOT IN (' . $excludeDirWebAccess . ') ';
Expand Down Expand Up @@ -2029,7 +2029,7 @@ private function _checkTaggedFileIds($tag, $id) {
$selectTaggedFiles .= 'OR LOWER(tag) LIKE \'%' . $xpldFileTags[$i] . '%\' ';
}

$excludeFileWebAccess = $this->excludeWebAccess('file');
$excludeFileWebAccess = $this->checkWebAccess('file');

if ($excludeFileWebAccess !== FALSE) {
$selectFiles .= ' AND id NOT IN (' . $excludeFileWebAccess . ') ';
Expand Down Expand Up @@ -2327,6 +2327,11 @@ private function _getSiblingInfo($trigger, $dynamicId, $field, $siblingCounter)
. 'SELECT b.parent_id FROM ' . $this->modx->db->config['table_prefix'] . 'easy2_dirs b '
. 'WHERE ';

$excludeDirWebAccess = $this->checkWebAccess('dir');
if ($excludeDirWebAccess !== FALSE) {
$selectChildren .= 'b.cat_id NOT IN (' . $excludeDirWebAccess . ') AND ';
}

if ($dynamicId !== '*') {
if ($trigger === 'tag') {
$selectChildren .= 'b.cat_tag LIKE \'%' . $dynamicId . '%\' AND ';
Expand All @@ -2335,8 +2340,11 @@ private function _getSiblingInfo($trigger, $dynamicId, $field, $siblingCounter)
}
}

$selectChildren .= 'b.cat_visible = 1 ) '
. 'AND a.cat_visible = 1 ';
$selectChildren .= 'b.cat_visible = 1 ) AND a.cat_visible = 1 ';

if ($excludeDirWebAccess !== FALSE) {
$selectChildren .= 'AND a.cat_id NOT IN (' . $excludeDirWebAccess . ') ';
}

if ($trigger === 'tag' && $dynamicId !== '*') {
$selectChildren .= 'AND a.cat_tag LIKE \'%' . $dynamicId . '%\' ';
Expand Down Expand Up @@ -2503,7 +2511,7 @@ private function _stripHTMLTags($string, $strippedTags=array('p', 'div', 'span')
* @return string The complete SQL's statement with additional parameters
*/
private function _dirSqlStatement($select, $prefix = NULL) {
$excludeDirWebAccess = $this->excludeWebAccess('dir');
$excludeDirWebAccess = $this->checkWebAccess('dir');

$prefixDot = '';
if (isset($prefix))
Expand Down Expand Up @@ -2605,9 +2613,6 @@ private function _fileSqlStatement($select, $allowedRatio = NULL, $dirId=NULL) {
$this->e2gSnipCfg['fid'] = $this->e2gSnipCfg['fid'];
$this->e2gSnipCfg['static_fid'] = $this->e2gSnipCfg['static_fid'];

$excludeDirWebAccess = $this->excludeWebAccess('dir');
$excludeFileWebAccess = $this->excludeWebAccess('file');

if (!empty($allowedRatio) && $allowedRatio !== 'all') {
/**
* Filtering the slideshow size ratio
Expand Down Expand Up @@ -2682,10 +2687,12 @@ private function _fileSqlStatement($select, $allowedRatio = NULL, $dirId=NULL) {
}
}

if ($excludeDirWebAccess !== FALSE) {
$dirSqlStatement .= 'dir_id NOT IN (' . $excludeDirWebAccess . ') AND ';
}
// $excludeDirWebAccess = $this->checkWebAccess('dir');
// if ($excludeDirWebAccess !== FALSE) {
// $dirSqlStatement .= 'dir_id NOT IN (' . $excludeDirWebAccess . ') AND ';
// }

$excludeFileWebAccess = $this->checkWebAccess('file');
if ($excludeFileWebAccess !== FALSE) {
$fileSqlStatement .= 'id NOT IN (' . $excludeFileWebAccess . ') AND ';
}
Expand Down
Binary file added assets/modules/easy2/includes/tpl/icons/lock.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 50c7876

Please sign in to comment.