Jump to content

IG88

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

IG88's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Just hoping that some one who knows an answer will see this.
  2. It is not working. Very interesting though, when I right click the image and look at the properties the location shows this really long string with a hash at the end. http://www.site.com/image.php?src=/assets/snippets/webloginpe/userimages/bride_of_bob.jpg&w=100&h=100&aoe=1&hash=35dd829cf2b4ac5f79e8 Here is the code I was using. $userImage = $modx->config['base_path'].'assets/snippets/webloginpe/userimages/'.strtolower(str_replace(' ', '-', basename($_FILES['photo']['name']))); $temp = explode(".", $userImage); $temp[0] .= time(); $userImage = implode(".", $temp); if (!move_uploaded_file($_FILES['photo']['tmp_name'], $userImage)) { return $this->FormatMessage($this->LanguageArray[29]); }
  3. Yes that is exactly what I need to do. Adding the server time would look ugly but serve the purpose. There will be numerous seperate members uploading so it needs to be something random that will not repeat. I am just not sure why I can not get the time() to work. Thank you.
  4. Doing that just echos out the filepath and name of the file. /home/site/public_html/assets/snippets/webloginpe/userimages/8_5_12[1].gif
  5. I have added echo $userImage = $modx->config['base_path'].strtolower(str_replace(' ', '-', basename( $_FILES['photo']['name']))); and got nothing. I also tried echo htmlentities(var_dump($userImage)); I think I am just echoing wrong.
  6. Thank you, but that does not actually help. The line I am dealing with here is $userImage = $modx->config['base_path'].strtolower(str_replace(' ', '-', basename( $_FILES['photo']['name'])));
  7. I have this function to upload User images, but I need it to either rename or simply add a time() or date() stamp to the file name. Any suggestions? function CreateUserImage() { global $modx; $imageAttributes = str_replace(', ', ',', $this->UserImageSettings); $imageAttributes = explode(',', $imageAttributes); if ($_FILES['photo']['size'] >= $imageAttributes[0]) { $sizeInKb = round($imageAttributes[0] / 1024); $sizeError = str_replace('[+000+]', $sizeInKb, $this->LanguageArray[28]); return $this->FormatMessage($sizeError); } $userImage = $modx->config['base_path'].strtolower(str_replace(' ', '-', basename( $_FILES['photo']['name']))); if (!move_uploaded_file($_FILES['photo']['tmp_name'], $userImage)) { return $this->FormatMessage($this->LanguageArray[29]); } // License and registration ma'am. I need to se an ID! if ($modx->getLoginUserID()) { $currentWebUser = $modx->getWebUserInfo($modx->getLoginUserID()); if ($this->Type == 'manager') { $currentWebUser['username'] = $_POST['username']; } } else { $currentWebUser['username'] = $this->Username; if ($this->Username == '' || empty($this->Username)) { $currentWebUser['username'] = $_POST['username']; } }
  8. Can some one please help me with this. I have tried every possible combination and I can not figure it out. I need some one who knows what they are doing.
  9. Sorry. I was just asking for help. I have indeed tried writing it myself and below is what I have. <?php #:::::::::::::::::::::::::::::::::::::::: # Snippet name: extMemberCheck # Short Desc: checks logged in groups and displays a chunk # Version: 1.0 # Created By Richard Pugh from the MemberCheck 1.0 snippet # MemberCheck Created By Ryan Thrash (vertexworks.com) # Sanitized By Jason Coward (opengeek.com) # # Date: February 5th, 2007 # # Changelog: # Feb 05, 07 -- initial release # #:::::::::::::::::::::::::::::::::::::::: # Description: # Checks to see if users belong to a certain group and # displays the specified chunk if they do. Performs # several sanity checks and allows multiple uses on a page. # # Two modes of use are possible, if only one output chunk # is specified then this snippet functions as the original # MemberCheck returning the chunk if the user is in ANY # of the groups specified. # # If several chunks are specified there must be a one to one # correspondence between groups and chunks, i.e. there must be # as many values specified in groups as in chunks. The snippet # then checks if the user is in the groups one by one and # outputs the corresponding chunk, i.e. if the user is part of # group2 then chunk2 will be output. If you have a hierarchy # of user groups please ensure that they are placed in # descending order of importance in the group array as the # first matching value found is always returned. # # Params: # &groups [array] (REQUIRED) # array of webuser group-names to check against # # &chunk [array] (REQUIRED) # name of the chunk to use if passes the check # # &ph [string] (optional) # name of the placeholder to set instead of directly returning chunk # # &debug [boolean] (optional | false) # turn on debug mode for extra troubleshooting # # Example Usage: # # [[extMemberCheck? &groups=`group1, group2` &chunk=`chunk1, chunk2` &ph=`putItHere` &debug=`true`]] # # This would place the chunk 'chunk1' into a placeholder (called 'putItHere') if the user # is logged in as a webuser and is a member of the 'group1' group. If he is a member of the # 'group2' group, then 'chunk2' will be returned. # # If the chunk array contains only one value, then if the user is in either 'group1' OR 'group2' # then the value of 'chunk1' is returned ( as in the original MemberCheck ). # # The optional debug parameter can be used to display informative error messages # when configuring this snippet for your site. For example, if the developer had # mistakenly typed 'groupX' for the first group, and none existed with debug mode on, # it would have returned the error message: The group 'groupX' could not be found.... # #:::::::::::::::::::::::::::::::::::::::: # debug parameter $debug = isset ($debug) ? $debug : false; # check if inside manager if ($m = $modx->insideManager()) { return ''; # don't go any further when inside manager } if (!isset ($groups)) { return $debug ? '<p>Error: No Group(s) Specified</p>' : ''; } if (!isset ($chunk)) { return $debug ? '<p>Error: No Chunk(s) Specified</p>' : ''; } # check if default is set, if not sets value $default = (isset($default))? $default : ''; # turn comma-delimited list of groups into an array $groups = explode(',', $groups); $chunk = explode(',', $chunk); if (!class_exists('extMemberCheck')) { class extMemberCheck { var $allGroups = NULL; var $debug; function getInstance($debug) { static $instance; if (!isset ($instance)) { $instance = new extMemberCheck($debug); } return $instance; } function extMemberCheck($debug = false) { global $modx; $this->debug = $debug; if ($debug) { $this->allGroups = array (); $tableName = $modx->getFullTableName('webgroup_names'); $sql = "SELECT name FROM $tableName"; if ($rs = $modx->db->query($sql)) { while ($row = $modx->db->getRow($rs)) { array_push($this->allGroups, stripslashes($row['name'])); } } } } function isValidGroup($groupName) { $isValid = !(array_search($groupName, $this->allGroups) === false); return $isValid; } function getMemberChunk(& $groups, $chunk, $default) { global $modx; $o = ''; if (!is_array($chunk)) { $o .= "<p>No chunk names were specified!</p>"; return $o; } if (!is_array($groups)) { $o .= "<p>No group names were specified!</p>"; return $o; } if (count($groups) != count($chunk)) { if (count($chunk) != 1) { $o .= "<p>Number of group names and chunks must be the same!</p>"; return $o; } } for ($i = 0; $i < count($groups); $i++) { $groups[$i] = trim($groups[$i]); $chnk = trim($chunk[$i]); if ($this->isValidGroup($groups[$i])) { if (count($chunk) != 1) { $group = array($groups[$i]); $check = $modx->isMemberOfWebGroup($group); if ($check) { $chunkcheck = $modx->getChunk($chnk); $o = ($chunkcheck) ? $chunkcheck : ''; if (!$chunkcheck) $o .= $this->debug ? "<p>The chunk <strong>$chnk</strong> not found...</p>" : ''; return $o; } } $check = $modx->isMemberOfWebGroup($groups); $chunkcheck = $modx->getChunk($chnk); $defaultcheck = $modx->getChunk($default); $o .= ($check && $chunkcheck) ? $chunkcheck : ''; if (!$chunkcheck) $o .= $this->debug ? "<p>The chunk <strong>$chnk</strong> not found...</p>" : ''; } else { if ($defaultcheck && (strlen($default) >= 1)) { $o .= ($defaultcheck) ? $defaultcheck : ''; } if (!$defaultcheck && (strlen($default) >= 1)) { $o .= $this->debug ? "<p>The default chunk <strong>$default</strong> not found...</p>" : ''; } } { if ($this->debug) { return "<p>The group <strong>" . $groups[$i] . "</strong> could not be found...</p>"; } return $o; } } } } } $memberCheck = extMemberCheck :: getInstance($debug); if (!isset ($ph)) { echo htmlentities(var_dump($memberCheck)); return $memberCheck->getMemberChunk($groups, $chunk, $default); } else { $modx->setPlaceholder($ph, $memberCheck->getMemberChunk($groups, $chunk, $default)); return ''; } ?> I added the echo htmlentities(var_dump($memberCheck)); to see if it would give any ideas. It echo's
  10. OK here is the deal. Membercheck allows for a chunk of html to be shown to a certain Usergroup when they are logged in. If that Usergroup is not logged in then there is a default chunk of html that is shown in it's place. This works very well just like this. However you can only set it for one Group and one corresponding Chunk. SO basically you can show a default Chunk(Lets say a link), such as "Log In" but when you do log in that link will change to something else that relates to that group. extMemberCheck is just like Membercheck, but it allows for you to set more than one Group and more than one Chunk that corresponds with the Group. The only problem is that this extMemberCheck does not have the default variable included like the MemberCheck does. Therefore when you view the site and you are not logged in you do not see anything.
  11. Hey everyone. I am very glad I found this forum. I have been having problems with taking 2 different scripts and combining them. These were built for Modx but it is still php. Basically what I have is that both scripts are pretty identical, but I need to take one variable from one script and put it in another. The first script is called MemberCheck. It checks to see if a member of a certain group is logged in and if so then it displays a template chunk to them. If they are not logged in then it displays the default template chunk. The other script is called extMemberCheck. It checks to see if a member of a certain group is logged in and will allow for checks of multiple groups and multiple corresponding template chunks. However, this one was not coded with the default variable. That is what I am trying to accomplish. To get the default variable into the extMembercheck. You would think that this would be pretty straight forward.... not for a php noob like me. MemberCheck. <?php #:::::::::::::::::::::::::::::::::::::::: # Snippet name: MemberCheck # Short Desc: checks logged in groups and displays a chunk # Version: 1.1 # Created By Ryan Thrash (vertexworks.com) # Sanitized By Jason Coward (opengeek.com) # Addition Of &default Param By Jason W. Falk (jason@falkicon.com) # # Date: April 03, 2007 # # Changelog: # Nov 29, 05 -- initial release # Jul 13, 06 -- adjusted Singleton to work under PHP4, added placeholder code (by: garryn) # Apr 02, 07 -- added &default peram code (by: Jason W. Falk (Whitefen)) # #:::::::::::::::::::::::::::::::::::::::: # Description: # Checks to see if users belong to a certain group and # displays the specified chunk if they do. Performs several # sanity checks and allows to be used multiple times on a page. # # Params: # &groups [array] (REQUIRED) # array of webuser group-names to check against # # &chunk [string] (REQUIRED) # name of the chunk to use if passes the check # # &default [string] (optional) # name of the chunk to use if no webuser group-names match # # &ph [string] (optional) # name of the placeholder to set instead of directly retuning chunk # # &debug [boolean] (optional | false) # turn on debug mode for extra troubleshooting # # Example Usage: # # [[MemberCheck? &groups=`siteadmin, registered users` &chunk=`privateSiteNav` &default=`publicSiteNav` &ph=`MemberMenu` &debug=`true`]] # # This would place the 'members-only' navigation store in the chunk 'privateSiteNav' # into a placeholder (called 'MemberMenu'). It will only do this as long as the user # is logged in as a webuser and is a member of the 'siteadmin' or the 'registered users' # groups. Otherwise, it will place the default chunk 'publicSiteNav' into the 'MemberMenu' # placeholder. The optional debug parameter can be used to display informative error messages # when configuring this snippet for your site. For example, if the developer had # mistakenly typed 'siteowners' for the first group, and none existed with debug mode on, # it would have returned the error message: The group siteowners could not be found.... # #:::::::::::::::::::::::::::::::::::::::: # debug parameter $debug = isset ($debug) ? $debug : false; # check if inside manager if ($m = $modx->insideManager()) { return ''; # don't go any further when inside manager } if (!isset ($groups)) { return $debug ? '<p>Error: No Group Specified</p>' : ''; } if (!isset ($chunk)) { return $debug ? '<p>Error: No Chunk Specified</p>' : ''; } # check if default is set, if not sets value $default = (isset($default))? $default : ''; # turn comma-delimited list of groups into an array $groups = explode(',', $groups); if (!class_exists('MemberCheck')) { class MemberCheck { var $allGroups = NULL; var $debug; function getInstance($debug) { static $instance; if (!isset ($instance)) { $instance = new MemberCheck($debug); } return $instance; } function MemberCheck($debug = false) { global $modx; $this->debug = $debug; if ($debug) { $this->allGroups = array (); $tableName = $modx->getFullTableName('webgroup_names'); $sql = "SELECT name FROM $tableName"; if ($rs = $modx->db->query($sql)) { while ($row = $modx->db->getRow($rs)) { array_push($this->allGroups, stripslashes($row['name'])); } } } } function isValidGroup($groupName) { $isValid = !(array_search($groupName, $this->allGroups) === false); return $isValid; } function getMemberChunk(& $groups, $chunk, $default) { global $modx; $o = ''; if (is_array($groups)) { for ($i = 0; $i < count($groups); $i++) { $groups[$i] = trim($groups[$i]); if ($this->debug) { if (!$this->isValidGroup($groups[$i])) { return "<p>The group <strong>" . $groups[$i] . "</strong> could not be found...</p>"; } } } $check = $modx->isMemberOfWebGroup($groups); $chunkcheck = $modx->getChunk($chunk); $defaultcheck = $modx->getChunk($default); if ( $check ) { $o .= ($check && $chunkcheck) ? $chunkcheck : ''; if (!$chunkcheck) $o .= $this->debug ? "<p>The chunk <strong>$chunk</strong> not found...</p>" : ''; } else { if ($defaultcheck && (strlen($default) >= 1)) { $o .= ($defaultcheck) ? $defaultcheck : ''; } if (!$defaultcheck && (strlen($default) >= 1)) { $o .= $this->debug ? "<p>The default chunk <strong>$default</strong> not found...</p>" : ''; } } } else { $o .= "<p>No valid group names were specified!</p>"; } return $o; } } } $memberCheck = MemberCheck :: getInstance($debug); if (!isset ($ph)) { return $memberCheck->getMemberChunk($groups, $chunk, $default); } else { $modx->setPlaceholder($ph, $memberCheck->getMemberChunk($groups, $chunk, $default)); return ''; } ?> extMemberCheck <?php #:::::::::::::::::::::::::::::::::::::::: # Snippet name: extMemberCheck # Short Desc: checks logged in groups and displays a chunk # Version: 1.0 # Created By Richard Pugh from the MemberCheck 1.0 snippet # MemberCheck Created By Ryan Thrash (vertexworks.com) # Sanitized By Jason Coward (opengeek.com) # # Date: February 5th, 2007 # # Changelog: # Feb 05, 07 -- initial release # #:::::::::::::::::::::::::::::::::::::::: # Description: # Checks to see if users belong to a certain group and # displays the specified chunk if they do. Performs # several sanity checks and allows multiple uses on a page. # # Two modes of use are possible, if only one output chunk # is specified then this snippet functions as the original # MemberCheck returning the chunk if the user is in ANY # of the groups specified. # # If several chunks are specified there must be a one to one # correspondence between groups and chunks, i.e. there must be # as many values specified in groups as in chunks. The snippet # then checks if the user is in the groups one by one and # outputs the corresponding chunk, i.e. if the user is part of # group2 then chunk2 will be output. If you have a hierarchy # of user groups please ensure that they are placed in # descending order of importance in the group array as the # first matching value found is always returned. # # Params: # &groups [array] (REQUIRED) # array of webuser group-names to check against # # &chunk [array] (REQUIRED) # name of the chunk to use if passes the check # # &ph [string] (optional) # name of the placeholder to set instead of directly returning chunk # # &debug [boolean] (optional | false) # turn on debug mode for extra troubleshooting # # Example Usage: # # [[extMemberCheck? &groups=`group1, group2` &chunk=`chunk1, chunk2` &ph=`putItHere` &debug=`true`]] # # This would place the chunk 'chunk1' into a placeholder (called 'putItHere') if the user # is logged in as a webuser and is a member of the 'group1' group. If he is a member of the # 'group2' group, then 'chunk2' will be returned. # # If the chunk array contains only one value, then if the user is in either 'group1' OR 'group2' # then the value of 'chunk1' is returned ( as in the original MemberCheck ). # # The optional debug parameter can be used to display informative error messages # when configuring this snippet for your site. For example, if the developer had # mistakenly typed 'groupX' for the first group, and none existed with debug mode on, # it would have returned the error message: The group 'groupX' could not be found.... # #:::::::::::::::::::::::::::::::::::::::: # debug parameter $debug = isset ($debug) ? $debug : false; # check if inside manager if ($m = $modx->insideManager()) { return ''; # don't go any further when inside manager } if (!isset ($groups)) { return $debug ? '<p>Error: No Group(s) Specified</p>' : ''; } if (!isset ($chunk)) { return $debug ? '<p>Error: No Chunk(s) Specified</p>' : ''; } # turn comma-delimited list of groups into an array $groups = explode(',', $groups); $chunk = explode(',', $chunk); if (!class_exists('extMemberCheck')) { class extMemberCheck { var $allGroups = NULL; var $debug; function getInstance($debug) { static $instance; if (!isset ($instance)) { $instance = new extMemberCheck($debug); } return $instance; } function extMemberCheck($debug = false) { global $modx; $this->debug = $debug; if ($debug) { $this->allGroups = array (); $tableName = $modx->getFullTableName('webgroup_names'); $sql = "SELECT name FROM $tableName"; if ($rs = $modx->db->query($sql)) { while ($row = $modx->db->getRow($rs)) { array_push($this->allGroups, stripslashes($row['name'])); } } } } function isValidGroup($groupName) { $isValid = !(array_search($groupName, $this->allGroups) === false); return $isValid; } function getMemberChunk(&$groups, $chunk) { global $modx; $o = ''; if (!is_array($chunk)) { $o .= "<p>No chunk names were specified!</p>"; return $o; } if (!is_array($groups)) { $o .= "<p>No group names were specified!</p>"; return $o; } if (count($groups) != count($chunk)) { if (count($chunk) != 1) { $o .= "<p>Number of group names and chunks must be the same!</p>"; return $o; } } for ($i = 0; $i < count($groups); $i++) { $groups[$i] = trim($groups[$i]); $chnk = trim($chunk[$i]); if ($this->isValidGroup($groups[$i])) { if (count($chunk) != 1) { $group = array($groups[$i]); $check = $modx->isMemberOfWebGroup($group); if ($check) { $chunkcheck = $modx->getChunk($chnk); $o = ($chunkcheck) ? $chunkcheck : ''; if (!$chunkcheck) $o .= $this->debug ? "<p>The chunk <strong>$chnk</strong> not found...</p>" : ''; return $o; } } else { $check = $modx->isMemberOfWebGroup($groups); $chunkcheck = $modx->getChunk($chnk); $o .= ($check && $chunkcheck) ? $chunkcheck : ''; if (!$chunkcheck) $o .= $this->debug ? "<p>The chunk <strong>$chnk</strong> not found...</p>" : ''; return $o; } } else { if ($this->debug) { return "<p>The group <strong>" . $groups[$i] . "</strong> could not be found...</p>"; } } } } } } $memberCheck = extMemberCheck :: getInstance($debug); if (!isset ($ph)) { return $memberCheck->getMemberChunk($groups, $chunk); } else { $modx->setPlaceholder($ph, $memberCheck->getMemberChunk($groups, $chunk)); return ''; } ?> and here is my attempt at integrating the default variable into the extMemberCheck. <?php #:::::::::::::::::::::::::::::::::::::::: # Snippet name: extMemberCheck # Short Desc: checks logged in groups and displays a chunk # Version: 1.0 # Created By Richard Pugh from the MemberCheck 1.0 snippet # MemberCheck Created By Ryan Thrash (vertexworks.com) # Sanitized By Jason Coward (opengeek.com) # # Date: February 5th, 2007 # # Changelog: # Feb 05, 07 -- initial release # #:::::::::::::::::::::::::::::::::::::::: # Description: # Checks to see if users belong to a certain group and # displays the specified chunk if they do. Performs # several sanity checks and allows multiple uses on a page. # # Two modes of use are possible, if only one output chunk # is specified then this snippet functions as the original # MemberCheck returning the chunk if the user is in ANY # of the groups specified. # # If several chunks are specified there must be a one to one # correspondence between groups and chunks, i.e. there must be # as many values specified in groups as in chunks. The snippet # then checks if the user is in the groups one by one and # outputs the corresponding chunk, i.e. if the user is part of # group2 then chunk2 will be output. If you have a hierarchy # of user groups please ensure that they are placed in # descending order of importance in the group array as the # first matching value found is always returned. # # Params: # &groups [array] (REQUIRED) # array of webuser group-names to check against # # &chunk [array] (REQUIRED) # name of the chunk to use if passes the check # # &ph [string] (optional) # name of the placeholder to set instead of directly returning chunk # # &debug [boolean] (optional | false) # turn on debug mode for extra troubleshooting # # Example Usage: # # [[extMemberCheck? &groups=`group1, group2` &chunk=`chunk1, chunk2` &ph=`putItHere` &debug=`true`]] # # This would place the chunk 'chunk1' into a placeholder (called 'putItHere') if the user # is logged in as a webuser and is a member of the 'group1' group. If he is a member of the # 'group2' group, then 'chunk2' will be returned. # # If the chunk array contains only one value, then if the user is in either 'group1' OR 'group2' # then the value of 'chunk1' is returned ( as in the original MemberCheck ). # # The optional debug parameter can be used to display informative error messages # when configuring this snippet for your site. For example, if the developer had # mistakenly typed 'groupX' for the first group, and none existed with debug mode on, # it would have returned the error message: The group 'groupX' could not be found.... # #:::::::::::::::::::::::::::::::::::::::: # debug parameter $debug = isset ($debug) ? $debug : false; # check if inside manager if ($m = $modx->insideManager()) { return ''; # don't go any further when inside manager } if (!isset ($groups)) { return $debug ? '<p>Error: No Group(s) Specified</p>' : ''; } if (!isset ($chunk)) { return $debug ? '<p>Error: No Chunk(s) Specified</p>' : ''; } # check if default is set, if not sets value $default = (isset($default))? $default : ''; # turn comma-delimited list of groups into an array $groups = explode(',', $groups); $chunk = explode(',', $chunk); if (!class_exists('extMemberCheck')) { class extMemberCheck { var $allGroups = NULL; var $debug; function getInstance($debug) { static $instance; if (!isset ($instance)) { $instance = new extMemberCheck($debug); } return $instance; } function extMemberCheck($debug = false) { global $modx; $this->debug = $debug; if ($debug) { $this->allGroups = array (); $tableName = $modx->getFullTableName('webgroup_names'); $sql = "SELECT name FROM $tableName"; if ($rs = $modx->db->query($sql)) { while ($row = $modx->db->getRow($rs)) { array_push($this->allGroups, stripslashes($row['name'])); } } } } function isValidGroup($groupName) { $isValid = !(array_search($groupName, $this->allGroups) === false); return $isValid; } function getMemberChunk(& $groups, $chunk, $default) { global $modx; $o = ''; if (!is_array($chunk)) { $o .= "<p>No chunk names were specified!</p>"; return $o; } if (!is_array($groups)) { $o .= "<p>No group names were specified!</p>"; return $o; } if (count($groups) != count($chunk)) { if (count($chunk) != 1) { $o .= "<p>Number of group names and chunks must be the same!</p>"; return $o; } } for ($i = 0; $i < count($groups); $i++) { $groups[$i] = trim($groups[$i]); $chnk = trim($chunk[$i]); if ($this->isValidGroup($groups[$i])) { if (count($chunk) != 1) { $group = array($groups[$i]); $check = $modx->isMemberOfWebGroup($group); if ($check) { $chunkcheck = $modx->getChunk($chnk); $o = ($chunkcheck) ? $chunkcheck : ''; if (!$chunkcheck) $o .= $this->debug ? "<p>The chunk <strong>$chnk</strong> not found...</p>" : ''; return $o; } } $check = $modx->isMemberOfWebGroup($groups); $chunkcheck = $modx->getChunk($chnk); $defaultcheck = $modx->getChunk($default); $o .= ($check && $chunkcheck) ? $chunkcheck : ''; if (!$chunkcheck) $o .= $this->debug ? "<p>The chunk <strong>$chnk</strong> not found...</p>" : ''; } else { if ($defaultcheck && (strlen($default) >= 1)) { $o .= ($defaultcheck) ? $defaultcheck : ''; } if (!$defaultcheck && (strlen($default) >= 1)) { $o .= $this->debug ? "<p>The default chunk <strong>$default</strong> not found...</p>" : ''; } } { if ($this->debug) { return "<p>The group <strong>" . $groups[$i] . "</strong> could not be found...</p>"; } return $o; } } } } } $memberCheck = extMemberCheck :: getInstance($debug); if (!isset ($ph)) { echo htmlentities(var_dump($memberCheck)); return $memberCheck->getMemberChunk($groups, $chunk, $default); } else { $modx->setPlaceholder($ph, $memberCheck->getMemberChunk($groups, $chunk, $default)); return ''; } ?> The section of the script that holds the key is the getmemberchunk MemberChunk function getMemberChunk(& $groups, $chunk, $default) { global $modx; $o = ''; if (is_array($groups)) { for ($i = 0; $i < count($groups); $i++) { $groups[$i] = trim($groups[$i]); if ($this->debug) { if (!$this->isValidGroup($groups[$i])) { return "<p>The group <strong>" . $groups[$i] . "</strong> could not be found...</p>"; } } } $check = $modx->isMemberOfWebGroup($groups); $chunkcheck = $modx->getChunk($chunk); $defaultcheck = $modx->getChunk($default); if ( $check ) { $o .= ($check && $chunkcheck) ? $chunkcheck : ''; if (!$chunkcheck) $o .= $this->debug ? "<p>The chunk <strong>$chunk</strong> not found...</p>" : ''; } else { if ($defaultcheck && (strlen($default) >= 1)) { $o .= ($defaultcheck) ? $defaultcheck : ''; } if (!$defaultcheck && (strlen($default) >= 1)) { $o .= $this->debug ? "<p>The default chunk <strong>$default</strong> not found...</p>" : ''; } } } else { $o .= "<p>No valid group names were specified!</p>"; } return $o; } } } $memberCheck = MemberCheck :: getInstance($debug); if (!isset ($ph)) { return $memberCheck->getMemberChunk($groups, $chunk, $default); } else { $modx->setPlaceholder($ph, $memberCheck->getMemberChunk($groups, $chunk, $default)); return ''; } ?> extMemberChunk function getMemberChunk(&$groups, $chunk) { global $modx; $o = ''; if (!is_array($chunk)) { $o .= "<p>No chunk names were specified!</p>"; return $o; } if (!is_array($groups)) { $o .= "<p>No group names were specified!</p>"; return $o; } if (count($groups) != count($chunk)) { if (count($chunk) != 1) { $o .= "<p>Number of group names and chunks must be the same!</p>"; return $o; } } for ($i = 0; $i < count($groups); $i++) { $groups[$i] = trim($groups[$i]); $chnk = trim($chunk[$i]); if ($this->isValidGroup($groups[$i])) { if (count($chunk) != 1) { $group = array($groups[$i]); $check = $modx->isMemberOfWebGroup($group); if ($check) { $chunkcheck = $modx->getChunk($chnk); $o = ($chunkcheck) ? $chunkcheck : ''; if (!$chunkcheck) $o .= $this->debug ? "<p>The chunk <strong>$chnk</strong> not found...</p>" : ''; return $o; } } else { $check = $modx->isMemberOfWebGroup($groups); $chunkcheck = $modx->getChunk($chnk); $o .= ($check && $chunkcheck) ? $chunkcheck : ''; if (!$chunkcheck) $o .= $this->debug ? "<p>The chunk <strong>$chnk</strong> not found...</p>" : ''; return $o; } } else { if ($this->debug) { return "<p>The group <strong>" . $groups[$i] . "</strong> could not be found...</p>"; } } } } } } $memberCheck = extMemberCheck :: getInstance($debug); if (!isset ($ph)) { return $memberCheck->getMemberChunk($groups, $chunk); } else { $modx->setPlaceholder($ph, $memberCheck->getMemberChunk($groups, $chunk)); return ''; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.