Example #1
0
 public function populateUserData($obj, $user_id)
 {
     // joomla fills the info
     $obj = parent::populateUserData($obj, $user_id);
     //populate jomsocial
     require_once JPATH_BASE . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'core.php';
     $pModel = CFactory::getModel('profile');
     $profile = $pModel->getEditableProfile($this->activationUserID);
     $fields = $profile['fields'];
     //$obj->jomsocial = array();
     foreach ($fields as $name => $fieldGroup) {
         foreach ($fieldGroup as $field) {
             $name = $field['name'];
             if ($field['fieldcode'] == 'XIPT_PROFILETYPE') {
                 require_once JPATH_BASE . DS . 'components' . DS . 'com_xipt' . DS . 'api.xipt.php';
                 $profiletypeName = XiptAPI::getUserProfiletype($user_id, 'name');
                 $obj['profile'][$name] = $profiletypeName;
                 continue;
             }
             $fieldId = $pModel->getFieldId($field['fieldcode']);
             $query = 'SELECT value FROM #__community_fields_values' . ' ' . 'WHERE `field_id`=' . $this->db->Quote($fieldId) . ' ' . 'AND `user_id`=' . $this->db->Quote($user_id);
             $result = $this->db->setQuery($query)->loadresult();
             if (!empty($result)) {
                 $obj['profile'][$name] = $result;
             }
         }
     }
     return $obj;
 }
Example #2
0
 function _extendUsers($usersdata)
 {
     foreach ($usersdata as $k => $v) {
         $usersdata[$k]['jspt'] = XiptAPI::getUserProfiletype($v['id']);
         $usersdata[$k]['jsptname'] = XiptAPI::getUserProfiletype($v['id'], 'name');
     }
     return $usersdata;
 }
Example #3
0
 public function isApprovalRequired($user_id)
 {
     $file = JPATH_BASE . DS . 'components' . DS . 'com_xipt' . DS . 'api.xipt.php';
     if (JFile::exists($file) && (include_once $file)) {
         $pID = XiptAPI::getUserProfiletype($user_id);
         // TODO : what to do for $pId =0
         $allCondition = array();
         $allCondition = XiptAPI::getProfiletypeInfo($pID);
         // if admin approval NOT required, then do nothing let the joomla handle
         if ($allCondition && $pID) {
             return $allCondition[0]->approve;
         }
     }
     return false;
 }
Example #4
0
 function displayModules($userId, $params, $attribs = array())
 {
     // if no user id return blank
     if (empty($userId) || $userId == '0' || $userId == 0) {
         return "";
     }
     //get profiletype id of user
     require_once JPATH_BASE . DS . 'components' . DS . 'com_xipt' . DS . 'api.xipt.php';
     $pID = XiptAPI::getUserProfiletype($userId);
     //get module params
     $modId = $params->get('ximodule');
     $modPt = $params->get('xiprofiletypes');
     $module = self::getModule($modId);
     //custom module name is given by the title field
     $file = $module->module;
     $custom = substr($file, 0, 4) == 'mod_' ? 0 : 1;
     $module->user = $custom;
     $module->name = $custom ? $module->title : substr($file, 4);
     //check profiletype in module params, if its not an array, convert it
     if (!is_array($modPt)) {
         $modPt = array($modPt);
     }
     //check user Pid exists in module params or not
     if (!in_array($pID, $modPt)) {
         return;
     }
     // If style attributes are not given or set,
     // we enforce it to use the xhtml style
     // so the title will display correctly.
     if (!isset($attribs['style'])) {
         $attribs['style'] = 'xhtml';
     }
     $contents = '';
     $document = JFactory::getDocument();
     $renderer = $document->loadRenderer('module');
     $contents .= $renderer->render($module, $attribs);
     return $contents;
 }
 function createnewuser($data)
 {
     $usersConfig =& JComponentHelper::getParams('com_users');
     $authorize =& JFactory::getACL();
     $user = clone JFactory::getUser();
     $error_messages = array();
     $fieldname = array();
     $response = NULL;
     $validated = true;
     $pt = $this->_validatePT($data['jspt']);
     $pt = true;
     if (!$pt) {
         $validated = false;
         $error_messages[] = array("id" => 1, "fieldname" => "jspt", "message" => "Invalid profile type id");
     }
     if ($data['email'] == "") {
         $validated = false;
         $error_messages[] = array("id" => 1, "fieldname" => "email", "message" => "Email cannot be blank");
     } elseif (false == $this->isValidEmail($data['email'])) {
         $validated = false;
         $error_messages[] = array("id" => 1, "fieldname" => "email", "message" => "Please set valid email id eg.(example@gmail.com). Check 'email' field in request");
     }
     if ($data['password'] == "") {
         $validated = false;
         $error_messages[] = array("id" => 1, "fieldname" => "password", "message" => "Password cannot be blank");
     }
     if ($data['name'] == "") {
         $validated = false;
         $error_messages[] = array("id" => 1, "fieldname" => "name", "message" => "Name cannot be blank");
     }
     if (true == $validated) {
         jimport('joomla.filesystem.file');
         jimport('joomla.utilities.utility');
         CFactory::load('helpers', 'image');
         CFactory::load('libraries', 'avatar');
         $userModel =& CFactory::getModel('user');
         if ($data['username'] == "") {
             $username = $data['email'];
         } else {
             $username = $data['username'];
         }
         $user->set('username', $username);
         $user->set('password', $data['password']);
         $user->set('name', $data['name']);
         $user->set('email', $data['email']);
         // password encryption
         $salt = JUserHelper::genRandomPassword(32);
         $crypt = JUserHelper::getCryptedPassword($user->password, $salt);
         $user->password = "******";
         // user group/type
         $user->set('id', '');
         $user->set('usertype', 'Registered');
         $user->set('gid', $authorize->get_group_id('', 'Registered', 'ARO'));
         $date =& JFactory::getDate();
         $user->set('registerDate', $date->toMySQL());
         $storage = JPATH_ROOT . DS . 'images' . DS . 'avatar';
         //kapil
         if ($data['avatar_imagedata'] != "") {
             file_put_contents(JPATH_ROOT . DS . 'user_images/' . $data['username'], base64_decode($data['imagedata']));
             //kapil
             $imagedata = getimagesize(JPATH_ROOT . DS . 'user_images/' . $data['username']);
             rename(JPATH_ROOT . DS . 'user_images/' . $data['username'], JPATH_ROOT . DS . 'user_images/' . $data['username'] . "." . str_replace("image/", "", $imagedata['mime']));
             $imgtype = explode(".", $data['username'] . '.' . str_replace("image/", "", $imagedata['mime']));
             $imgmimetype = $imagedata['mime'];
         } else {
             if ($data['avatar'] != "") {
                 $imgtype = explode(".", $data['avatar']);
                 $imgmimetype = "image/" . $imgtype[1];
             }
         }
         //kapil
         if (isset($imgtype)) {
             $storageImage = $storage . DS . $imgtype[0] . '.' . $imgtype[1];
             $storageThumbnail = $storage . DS . 'thumb_' . $imgtype[0] . '.' . $imgtype[1];
             $image = 'images/avatar/' . $imgtype[0] . '.' . $imgtype[1];
             $thumbnail = 'images/avatar/' . 'thumb_' . $imgtype[0] . '.' . $imgtype[1];
             $imgpath = JPATH_ROOT . DS . 'user_images/' . $imgtype[0] . '.' . $imgtype[1];
             $filetype = $imgmimetype;
         } else {
             $image = 'components/com_community/assets/default.jpg';
             $thumbnail = 'components/com_community/assets/default_thumb.jpg';
         }
         if ($data['avatar'] == "" && $data['avatar_imagedata'] == "") {
             $user->set('avatar', 'components/com_community/assets/default.jpg');
             $user->set('thumb', 'components/com_community/assets/default_thumb.jpg');
         } else {
             if (!file_exists($imgpath)) {
                 $validated = false;
                 $error_messages[] = array("id" => 1, "fieldname" => "avatar", "message" => "Invalid Avatar image path");
             } else {
                 $user->set('avatar', 'images/avatar/' . $imgtype[0] . '.' . $imgtype[1]);
                 $user->set('avatar', 'images/avatar/thumb_' . $imgtype[0] . '.' . $imgtype[1]);
                 $imageMaxWidth = 160;
                 $imageSize = cImageGetSize($imgpath);
                 // Generate full image
                 if (!cImageResizePropotional($imgpath, $storageImage, $filetype, $imageMaxWidth)) {
                     $error_messages[] = array("id" => 1, "fieldname" => "avatar", "message" => "Fail: Error Moving Uploaded File");
                 }
                 // Generate thumbnail
                 if (!cImageCreateThumb($imgpath, $storageThumbnail, $filetype)) {
                     $error_messages[] = array("id" => 1, "fieldname" => "avatar", "message" => "Fail: Error Moving Uploaded File");
                 }
             }
         }
         if (!$user->save()) {
             $error_messages[] = array("id" => 1, "fieldname" => "usernameoremail", "message" => "username or email already in use.");
         } else {
             $my = CFactory::getUser($user->id);
             $userModel->setImage($my->id, $image, 'avatar');
             $userModel->setImage($my->id, $thumbnail, 'thumb');
             // Update the user object so that the profile picture gets updated.
             $my->set('_avatar', $image);
             $my->set('_thumb', $thumbnail);
             // Update Jomsocial profile type
             if ($user->id) {
                 XiptAPI::setUserProfiletype($user->id, $data['jspt']);
             }
         }
     }
     if (true == isset($error_messages) && 0 < sizeof($error_messages)) {
         $res = array();
         foreach ($error_messages as $key => $error_message) {
             $res[] = $error_message;
         }
         $response = array("id" => 0, 'errors' => $res);
     } else {
         $response = array('id' => $user->id);
     }
     return $response;
 }
Example #6
0
 function setUserProfiletype($userId, $pId)
 {
     if ($this->detect_application() == false) {
         return;
     }
     //IMP : if MI are attached but subscription_message is set to false
     // then dont apply any action
     //old
     //$subscription_message =  XiptFactory::getSettings('subscription_message');
     //new
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_xipt' . DS . 'api.xipt.php';
     $integrate_with = XiptAPI::getGlobalConfig('integrate_with');
     if ($integrate_with == 'aec') {
         XiptAPI::setUserProfiletype($userId, $pId, 'ALL');
     }
     return;
 }