Jump to content

jmarvin

New Members
  • Posts

    1
  • Joined

  • Last visited

jmarvin's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm still pretty new at this but I want to learn... I have a GPL plugin (for Joomla 1.6 / JomSocial 2.6) that I would like to use (w/ Joomla 2.5 & JomSocial 2.8 ) but it will need some fixing or updating. It should check for a default avatar and replace it with a random one. It installed but doesn't work. How can I verify it's getting the data it needs? I think one problem might be no file listed in the database is default. It looks like this plugin expects one to be there. The script is only about 100 lines so I hope someone can point out some obvious problems. Thanks for looking and any help you can offer. // no direct access defined('_JEXEC') or die('Restricted access'); jimport( 'joomla.plugin.plugin' ); require_once( JPATH_BASE . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'core.php'); class plgUserMiniSocialGender extends JPlugin { function plgUserMiniSocialGender(& $subject, $config) { parent::__construct($subject, $config); } //function onLoginUser($user, $options) function onUserLogin($user, $options) { //$juser = $this->getJomSocialUser($user); $juser = CFactory::getUser($userid); //$curavatar = $juser->getAvatar(); $curavatar = $juser->getThumbAvatar(); $gender = $juser->getInfo($this->params->get( 'genderfield' , 'FIELD_GENDER' )); //$gender = $user->getInfo('FIELD_GENDER'); if($this->compareEnd("default.jpg", $curavatar) || $this->compareEnd("user.png", $curavatar) || ($this->contains('minisocialgender_images',$curavatar) && $this->params->get( 'reassign' , '0' ))) { if($gender) { $maleurl = JPATH_SITE . DS . 'plugins' . DS . 'user' . DS . 'minisocialgender' .DS . 'minisocialgender_images' . DS . 'male' . DS; $femaleurl = JPATH_SITE . DS . 'plugins' . DS . 'user' . DS . 'minisocialgender' .DS . 'minisocialgender_images' . DS . 'female' . DS; $usermodel =& CFactory::getModel('user'); if($this->params->get( 'maletype' , 'Male' ) == $gender) { if($this->contains("male", $curavatar)) return; } if($this->params->get( 'femaletype' , 'Female' ) == $gender) { if($this->contains("female", $curavatar)) return; } if($gender == $this->params->get( 'maletype' , 'Male' )) { $files = $this->getDirItems($maleurl); $random = rand ( 0 , (count( $files) - 1)); JFile::copy($maleurl . $files[$random], JPATH_SITE . DS . 'plugins' . DS . 'user' . DS .'minisocialgender' .DS . 'minisocialgender_images' . DS . $juser->id . 'male' . '.png'); JFile::copy($maleurl . 'thumb' . DS .$files[$random], JPATH_SITE . DS . 'plugins' . DS . 'user' . DS . 'minisocialgender' .DS . 'minisocialgender_images' . DS . 'thumb' . $juser->id . 'male' . '.png'); $usermodel->setImage($juser->id, 'plugins' . DS . 'user' . DS . 'minisocialgender' .DS . 'minisocialgender_images' . DS . $juser->id . 'male' . '.png', 'avatar'); $usermodel->setImage($juser->id, 'plugins' . DS . 'user' . DS . 'minisocialgender' .DS . 'minisocialgender_images' . DS . 'thumb' . $juser->id . 'male' . '.png', 'thumb'); } elseif($gender == $this->params->get( 'femaletype' , 'Female' )) { $files = $this->getDirItems($femaleurl); $random= rand ( 0 , (count( $files) - 1) ); JFile::copy($femaleurl . $files[$random], JPATH_SITE . DS . 'plugins' . DS . 'user' . DS . 'minisocialgender' .DS . 'minisocialgender_images' . DS . $juser->id . 'female' . '.png'); JFile::copy($femaleurl . 'thumb' . DS . $files[$random], JPATH_SITE . DS . 'plugins' . DS . 'minisocialgender' .DS . 'user' . DS . 'minisocialgender_images' . DS . 'thumb' . $juser->id . 'female' . '.png'); $usermodel->setImage($juser->id, 'plugins' . DS . 'user' . DS . 'minisocialgender' .DS . 'minisocialgender_images' . DS . $juser->id . 'female' . '.png', 'avatar'); $usermodel->setImage($juser->id, 'plugins' . DS . 'user' . DS . 'minisocialgender' .DS . 'minisocialgender_images' . DS . 'thumb' . $juser->id . 'female' . '.png', 'thumb'); } if($this->params->get( 'warnuser' , 1 )) { JFactory::getApplication()->enqueueMessage( $this->params->get( 'warnmessage' )); } } } } function getDirItems($dir) { $files = array(); if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if(filetype($dir . $file) == "file") { $files[] = $file; } } closedir($dh); } } return $files; } function compareEnd($end, $fullstring) { $StrLen = strlen($end); $FullStrEnd = substr($fullstring, strlen($fullstring) - $StrLen); return ($end == $FullStrEnd); } function contains($needle, $haystack) { $pos = strpos($haystack,$needle); if($pos) return true; else return false; } //function getJomSocialUser($user) //{ // $user2 =& JFactory::getUser(); // $userid = $user2->id; // return CFactory::getUser($userid); //} }
×
×
  • 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.