/** * get profile fields * * @param icms_member_user_Object $thisUser * @return array of profile fields */ public function getProfileFields(&$thisUser) { // get handlers $category_handler = icms_getModuleHandler('category', basename(dirname(dirname(__FILE__))), 'profile'); $profile_handler = icms_getModuleHandler('profile', basename(dirname(dirname(__FILE__))), 'profile'); $visibility_handler = icms_getModuleHandler('visibility', basename(dirname(dirname(__FILE__))), 'profile'); $groups = is_object(icms::$user) ? icms::$user->getGroups() : array(ICMS_GROUP_ANONYMOUS); $criteria = new icms_db_criteria_Compo(); $criteria->setSort("cat_weight"); $categories = $category_handler->getObjects($criteria); $visible_fields = $visibility_handler->getVisibleFields($groups, $thisUser->getGroups()); unset($criteria); $criteria = new icms_db_criteria_Compo(); $criteria->add(new icms_db_criteria_Item('fieldid', '(' . implode(',', $visible_fields) . ')', 'IN')); $criteria->setSort('field_weight'); $fields = $this->getObjects($criteria); $profile = $profile_handler->get($thisUser->getVar('uid')); unset($category_handler, $visibility_handler, $profile_handler, $criteria); $module = icms::handler("icms_module")->getByDirname(basename(dirname(dirname(__FILE__))), TRUE); $rtn = array(); for ($i = 0; $i < count($categories); $i++) { $first_category = true; for ($j = 0; $j < count($fields); $j++) { $value = $fields[$j]->getOutputValue($thisUser, $profile); if ($fields[$j]->getVar('field_show') && $fields[$j]->getVar('catid') == $categories[$i]->getVar('catid') && ($module->config['show_empty'] || trim($value) || $value == '0')) { if ($first_category) { $rtn[$i]['title'] = $categories[$i]->getVar('cat_title'); } $first_category = false; $rtn[$i]['fields'][$j]['image'] = $fields[$j]->getImage(); $rtn[$i]['fields'][$j]['title'] = $fields[$j]->getVar('field_title'); $rtn[$i]['fields'][$j]['value'] = $value; } } } return $rtn; }
* to revert the masqerading effect [formulize\footer.php] */ // Revert masquerade effect if (isset($_SESSION['masquerade_end']) && $_SESSION['masquerade_end'] == 1) { $masqueradeUser = new icms_member_user_Object($_SESSION['masquerade_xoopsUserId']); unset($_SESSION['masquerade_xoopsUserId']); unset($_SESSION['masquerade_end']); } else { $masqueradeUser = new icms_member_user_Object($_REQUEST['id']); // Save UserId of the actual user if (isset($_SESSION['masquerade_xoopsUserId']) == false) { $_SESSION['masquerade_xoopsUserId'] = $_SESSION['xoopsUserId']; } } // Change effective user $_SESSION['xoopsUserId'] = $masqueradeUser->getVar('uid'); $_SESSION['xoopsUserGroups'] = $masqueradeUser->getGroups(); $_SESSION['xoopsUserLastLogin'] = $masqueradeUser->getVar('last_login'); $_SESSION['xoopsUserLanguage'] = $masqueradeUser->language(); if (isset($_SESSION['XOOPS_TOKEN_SESSION'])) { unset($_SESSION['XOOPS_TOKEN_SESSION']); } $xoops_user_theme = $masqueradeUser->getVar('theme'); if (in_array($xoops_user_theme, $icmsConfig['theme_set_allowed'])) { $_SESSION['xoopsUserTheme'] = $xoops_user_theme; } elseif (isset($_SESSION['xoopsUserTheme'])) { unset($_SESSION['xoopsUserTheme']); } // Redirect user header('Location: ' . SITE_BASE_URL . "/"); die;
/** * Returns a value for output of this field * * @param icms_member_user_Object $user object to get the value of * @param mod_profile_Profile $profile object to get the value of * @global array $icmsConfigAuth * @return mixed **/ public function getOutputValue(&$user, $profile) { global $icmsConfigAuth; $value = in_array($this->getVar('field_name'), $this->getUserVars()) ? $user->getVar($this->getVar('field_name')) : $profile->getVar($this->getVar('field_name')); switch ($this->getVar('field_type')) { case "textarea": case "dhtml": return icms_core_DataFilter::undoHtmlSpecialChars(str_replace('&', '&', $value), 1); break; case "select": case "radio": $options = unserialize($this->getVar('field_options', 'n')); return isset($options[$value]) ? htmlspecialchars($options[$value]) : ""; break; case "select_multi": case "checkbox": $options = unserialize($this->getVar('field_options', 'n')); $ret = array(); if (count($options) > 0) { foreach (array_keys($options) as $key) { if (in_array($key, $value)) { $ret[$key] = htmlspecialchars($options[$key]); } } } return $ret; break; case "group": //change to retrieve groups and return name of group return $value; break; case "group_multi": //change to retrieve groups and return array of group names return ""; break; case "longdate": //return YYYY/MM/DD format - not optimal as it is not using local date format, but how do we do that //when we cannot convert it to a UNIX timestamp? return str_replace("-", "/", $value); case "date": if ($value > 0) { return formatTimestamp($value, 's'); } return ""; break; case "datetime": if ($value > 0) { return formatTimestamp($value, 'm'); } return ""; break; case "autotext": $value = $user->getVar($this->getVar('field_name'), 'n'); //autotext can have HTML in it $value = str_replace("{X_UID}", $user->getVar("uid"), $value); $value = str_replace("{X_URL}", ICMS_URL, $value); $value = str_replace("{X_UNAME}", $user->getVar("uname"), $value); return $value; break; case "rank": $userrank = $user->rank(); return '<img src="' . $userrank['image'] . '" alt="' . $userrank['title'] . '" /> ' . $userrank['title']; break; case "yesno": return $value ? _YES : _NO; break; case "timezone": $timezones = icms_form_elements_select_Timezone::getTimeZoneList(); return $timezones[str_replace('.0', '', $value)]; break; case "image": if ($value == "") { return ''; } return "<img src='" . ICMS_UPLOAD_URL . "/" . basename(dirname(dirname(__FILE__))) . "/" . $value . "' alt='image' />"; break; case "url": if ($value == "") { return ''; } return icms_core_DataFilter::makeClickable(formatURL($value)); case "location": if ($value == "") { return ''; } return $value . ' <a href="http://maps.google.com/?q=' . $value . '" target="_blank" ><img src="' . ICMS_URL . '/modules/' . basename(dirname(dirname(__FILE__))) . '/images/mapsgoogle.gif" alt="" /></a>'; case "email": if ($value == "") { return ''; } if ($user->getVar('user_viewemail') || is_object(icms::$user) && (icms::$user->isAdmin() || icms::$user->getVar('uid') == $user->getVar('uid'))) { return '<a href="mailto:' . $value . '">' . $value . '</a>'; } return ''; case "openid": if ($value == "") { return ''; } if ($icmsConfigAuth['auth_openid'] == 1 && ($user->getVar('user_viewoid') || is_object(icms::$user) && (icms::$user->isAdmin() || icms::$user->getVar('uid') == $user->getVar('uid')))) { return $value; } return ''; case "textbox": case "theme": case "language": default: return $value; break; } }
/** * Subscribe for notification for an event(s) * * @param string $category category of notification * @param int $item_id ID of the item * @param mixed $events event string or array of events * @param int $mode force a particular notification mode * (e.g. once_only) (default to current user preference) * @param int $module_id ID of the module (default to current module) * @param int $user_id ID of the user (default to current user) **/ public function subscribe($category, $item_id, $events, $mode = null, $module_id = null, $user_id = null) { if (!isset($user_id)) { if (empty(icms::$user)) { return false; // anonymous cannot subscribe } else { $user_id = icms::$user->getVar('uid'); } } if (!isset($module_id)) { global $icmsModule; $module_id = $icmsModule->getVar('mid'); } if (!isset($mode)) { $user = new icms_member_user_Object($user_id); $mode = $user->getVar('notify_mode'); } if (!is_array($events)) { $events = array($events); } foreach ($events as $event) { if ($notification =& $this->getNotification($module_id, $category, $item_id, $event, $user_id)) { if ($notification->getVar('not_mode') != $mode) { $this->updateByField($notification, 'not_mode', $mode); } } else { $notification =& $this->create(); $notification->setVar('not_modid', $module_id); $notification->setVar('not_category', $category); $notification->setVar('not_itemid', $item_id); $notification->setVar('not_uid', $user_id); $notification->setVar('not_event', $event); $notification->setVar('not_mode', $mode); $this->insert($notification); } } }