function b_profile_friends_show($options) { global $xoTheme; if (!empty(icms::$user)) { $profile_friendship_handler = icms_getModuleHandler('friendship', basename(dirname(dirname(__FILE__))), 'profile'); $friends = $profile_friendship_handler->getFriendships(0, 0, icms::$user->getVar('uid'), 0, PROFILE_FRIENDSHIP_STATUS_ACCEPTED); if (count($friends) == 0) { return; } $block = array(); $i = 0; foreach ($friends as $friend) { $friend_uid = icms::$user->getVar('uid') == $friend['friend1_uid'] ? $friend['friend2_uid'] : $friend['friend1_uid']; $block['friends'][$i]['uname'] = icms_member_user_Handler::getUserLink($friend_uid); $block['friends'][$i]['friend_uid'] = $friend_uid; $block['friends'][$i]['sort'] = icms_member_user_Object::getUnameFromId($friend_uid); $i++; } if (isset($block['friends']) && count($block['friends']) > 0) { usort($block['friends'], 'sortFriendsArray'); } // adding PM javascript, $xoTheme cannot be used in this place because jQuery is not yet loaded if (count($block['friends']) > 0) { $block['jQuery'] = 'jQuery(document).ready(function(){jQuery("a.block-profile-pm").colorbox({width:600, height:395, iframe:true});});'; } } return $block; }
/** * 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; }
} else { $com_mode = $icmsConfig['com_mode']; } } if (!isset($_GET['com_order'])) { if (is_object(icms::$user)) { $com_order = icms::$user->getVar('uorder'); } else { $com_order = $icmsConfig['com_order']; } } else { $com_order = (int) $_GET['com_order']; } $comment_handler = icms::handler('icms_data_comment'); $comment =& $comment_handler->get($com_id); $r_name = icms_member_user_Object::getUnameFromId($comment->getVar('com_uid')); $r_text = _CM_POSTER . ': <strong>' . $r_name . '</strong> ' . _CM_POSTED . ': <strong>' . formatTimestamp($comment->getVar('com_created')) . '</strong><br /><br />' . $comment->getVar('com_text'); $com_title = $comment->getVar('com_title', 'E'); if (!preg_match("/^(Re|" . _CM_RE . "):/i", $com_title)) { $com_title = _CM_RE . ": " . icms_core_DataFilter::icms_substr($com_title, 0, 56); } $com_pid = $com_id; $com_text = ''; $com_id = 0; $dosmiley = 1; $groups = is_object(icms::$user) ? icms::$user->getGroups() : ICMS_GROUP_ANONYMOUS; $gperm_handler = icms::handler('icms_member_groupperm'); if ($icmsConfig['editor_default'] != 'dhtmltextarea' && $gperm_handler->checkRight('use_wysiwygeditor', 1, $groups, 1, false)) { $dohtml = 1; $dobr = 0; } else {
} break; case 'masquerade': /* * Allows an admin user to masquerade as a different user. * This allows the admin to see and do what the other user sees/can-do. * A confirm box will also be created at the footer to allow the admin * 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'])) {
/** * 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; } }
/** * Returns the current username from (@link icms_member_user_Object) * * @return string **/ function uname() { return icms_member_user_Object::getUnameFromId($this->uid); }
$subject = $pm->getVar('subject', 'E'); if (!preg_match("/^Re:/i", $subject)) { $subject = 'Re: ' . $subject; } echo "<td class='even'><input type='text' name='subject' value='" . $subject . "' size='30' maxlength='100' /></td>"; } else { echo "<td class='even'><input type='text' name='subject' size='30' maxlength='100' /></td>"; } echo "</tr>"; echo "<tr valign='top'><td class='head' width='25%'>" . _PM_MESSAGEC . "</td>"; echo "<td class='even'>"; if ($reply == 1) { $pm_handler = icms::handler('icms_data_privmessage'); $pm =& $pm_handler->get($msg_id); if ($pm->getVar("to_userid") == (int) icms::$user->getVar('uid')) { $pm_uname = icms_member_user_Object::getUnameFromId($pm->getVar("from_userid")); $message = "[quote]\n"; $message .= sprintf(_PM_USERWROTE, $pm_uname); $message .= "\n" . $pm->getVar("msg_text", "E") . "\n[/quote]"; } else { unset($pm); $reply = $send2 = 0; } $textarea = new icms_form_elements_Dhtmltextarea(_PM_MESSAGEC, 'message', $message); } else { $textarea = new icms_form_elements_Dhtmltextarea(_PM_MESSAGEC, 'message', ''); } echo $textarea->render(); echo "</td>"; echo "</tr>"; echo "<tr><td class='head'> </td><td class='even'>\r\n <input type='hidden' name='op' value='submit' />" . icms::$security->getTokenHTML() . "\r\n <input type='submit' class='formButton' name='submit' value='" . _PM_SUBMIT . "' /> \r\n <input type='reset' class='formButton' value='" . _PM_CLEAR . "' />\r\n <input type='button' class='formButton' name='cancel' value='" . _PM_CANCELSEND . "' onclick='javascript:window.close();' />\r\n </td></tr></table>\n";
public function __construct(&$id) { parent::__construct($id); $this->_deprecated = icms_core_Debug::setDeprecated('icms_member_user_Object', sprintf(_CORE_REMOVE_IN_VERSION, '1.4')); }
/** * retrieve users from the database * * @param object $criteria {@link icms_db_criteria_Element} conditions to be met * @param bool $id_as_key use the UID as key for the array? * @return array array of {@link icms_member_user_Object} objects */ public function getObjects($criteria = NULL, $id_as_key = FALSE) { $ret = array(); $limit = $start = 0; $sql = "SELECT * FROM " . $this->db->prefix('users'); if (isset($criteria) && is_subclass_of($criteria, 'icms_db_criteria_Element')) { $sql .= " " . $criteria->renderWhere(); if ($criteria->getSort() != '') { $sql .= " ORDER BY " . $criteria->getSort() . " " . $criteria->getOrder(); } $limit = $criteria->getLimit(); $start = $criteria->getStart(); } $result = $this->db->query($sql, $limit, $start); if (!$result) { return $ret; } while ($myrow = $this->db->fetchArray($result)) { $user = new icms_member_user_Object(); $user->assignVars($myrow); if (!$id_as_key) { $ret[] =& $user; } else { $ret[$myrow['uid']] =& $user; } unset($user); } return $ret; }
/** * get user name of the friend * * @return str user name */ public function getFriendUname() { return icms_member_user_Object::getUnameFromId($this->getFriendUid()); }
} for ($i = 0; $i < $total_messages; $i++) { $class = ($i % 2 == 0) ? 'even' : 'odd'; echo "<tr align='" . _GLOBAL_LEFT . "' class='$class'>" . "<td style='vertical-align: middle; width: 2%; text-align: center;'><input type='checkbox' id='message_" . $pm_arr[$i]->getVar('msg_id') . "' name='msg_id[]' value='" . $pm_arr[$i]->getVar('msg_id') . "' /></td>\n"; if ($pm_arr[$i]->getVar('read_msg') == 1) { echo "<td style='vertical-align: middle; width: 5%; text-align: center;'> </td>\n"; } else { echo "<td style='vertical-align: middle; width: 5%; text-align: center;'>" . "<img src='images/read.gif' alt='" . _PM_NOTREAD . "' /></td>\n"; } echo "<td style='vertical-align: middle; width: 5%; text-align: center;'>" . "<img src='images/subject/" . $pm_arr[$i]->getVar('msg_image', 'E') . "' alt='' /></td>\n"; $postername = icms_member_user_Object::getUnameFromId($pm_arr[$i]->getVar('from_userid')); echo "<td style='vertical-align: middle; width: 10%; text-align: center;'>"; // no need to show deleted users if ($postername) { echo "<a href='userinfo.php?uid=". (int) ($pm_arr[$i]->getVar('from_userid')) . "'>" . $postername . "</a>"; } else { echo $icmsConfig['anonymous']; } echo "</td>\n"; echo "<td valign='middle' style='vertical-align: middle;'><a href='readpmsg.php?start=" . (int) (($total_messages-$i-1)) . "&total_messages=" . (int) $total_messages . "'>" . $pm_arr[$i]->getVar('subject') . "</a></td>"; echo "<td style='vertical-align: middle; width: 30%; text-align: center;'>" . formatTimestamp($pm_arr[$i]->getVar('msg_time')) . "</td></tr>"; }
/** * Get a list of users belonging to certain groups and matching criteria * Temporary solution * * @param int $groups IDs of groups * @param object $criteria {@link icms_db_criteria_Element} object * @param bool $asobject return the users as objects? * @param bool $id_as_key use the UID as key for the array if $asobject is TRUE * @return array Array of {@link icms_member_user_Object} objects (if $asobject is TRUE) * or of associative arrays matching the record structure in the database. */ public function getUsersByGroupLink($groups, $criteria = null, $asobject = false, $id_as_key = false) { $ret = array(); $select = $asobject ? "u.*" : "u.uid"; $sql[] = "\tSELECT DISTINCT {$select} " . "\tFROM " . icms::$xoopsDB->prefix("users") . " AS u" . " LEFT JOIN " . icms::$xoopsDB->prefix("groups_users_link") . " AS m ON m.uid = u.uid" . "\tWHERE 1 = '1'"; if (!empty($groups)) { $sql[] = "m.groupid IN (" . implode(", ", $groups) . ")"; } $limit = $start = 0; if (isset($criteria) && is_subclass_of($criteria, 'icms_db_criteria_Element')) { $sql_criteria = $criteria->render(); if ($criteria->getSort() != '') { $sql_criteria .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); } $limit = $criteria->getLimit(); $start = $criteria->getStart(); if ($sql_criteria) { $sql[] = $sql_criteria; } } $sql_string = implode(" AND ", array_filter($sql)); if (!($result = icms::$xoopsDB->query($sql_string, $limit, $start))) { return $ret; } while ($myrow = icms::$xoopsDB->fetchArray($result)) { if ($asobject) { $user = new icms_member_user_Object(); $user->assignVars($myrow); if (!$id_as_key) { $ret[] =& $user; } else { $ret[$myrow['uid']] =& $user; } unset($user); } else { $ret[] = $myrow['uid']; } } return $ret; }
echo "<div><h4>". _PM_PRIVATEMESSAGE."</h4></div><br /><a href='userinfo.php?uid=" . (int) (icms::$user->getVar("uid")) ."'>". _PM_PROFILE ."</a> <span style='font-weight:bold;'>»»</span> <a href='viewpmsg.php'>". _PM_INBOX ."</a> <span style='font-weight:bold;'>»»</span> \n"; if (empty($pm_arr)) { echo '<br /><br />'._PM_YOUDONTHAVE; } else { if (!$pm_handler->setRead($pm_arr[0])) { //echo "failed"; } echo $pm_arr[0]->getVar("subject")."<br /> <form action='readpmsg.php' method='post' name='delete".$pm_arr[0]->getVar("msg_id")."'> <table border='0' cellpadding='4' cellspacing='1' class='outer' width='100%'> <tr><th colspan='2'>". _PM_FROM ."</th></tr><tr class='even'>\n"; $poster = new icms_member_user_Object((int) $pm_arr[0]->getVar("from_userid")); if (!$poster->isActive()) { $poster = false; } echo "<td valign='top'>"; if ($poster != false) { // we need to do this for deleted users echo "<a href='userinfo.php?uid=". (int) ($poster->getVar("uid"))."'>".$poster->getVar("uname")."</a><br />\n"; if ($poster->getVar("user_avatar") != "") { echo "<img src='uploads/".$poster->getVar("user_avatar")."' alt='' /><br />\n"; } if ($poster->getVar("user_from") != "") { echo _PM_FROMC."".$poster->getVar("user_from")."<br /><br />\n"; } if ($poster->isOnline()) { echo "<span style='color:#ee0000;font-weight:bold;'>"._PM_ONLINE."</span><br /><br />\n"; }
$count - $start > $max_results_per_page ? $num_show_this_page = $max_results_per_page : ($num_show_this_page = $count - $start); for ($i = $start; $i < $start + $num_show_this_page; $i++) { $results[$i]['processed_image_alt_text'] = icms_core_DataFilter::checkVar($modname, 'text', 'output') . ": "; if (isset($results[$i]['image']) && $results[$i]['image'] != "") { $results[$i]['processed_image_url'] = "modules/" . $moddir . "/" . $results[$i]['image']; } else { $results[$i]['processed_image_url'] = "images/icons/posticon2.gif"; } if (!preg_match("/^http[s]*:\\/\\//i", $results[$i]['link'])) { $results[$i]['link'] = "modules/" . $moddir . "/" . $results[$i]['link']; } $results[$i]['processed_title'] = icms_core_DataFilter::checkVar($results[$i]['title'], 'text', 'output'); if ($icmsConfigSearch['search_user_date']) { $results[$i]['uid'] = @(int) $results[$i]['uid']; if (!empty($results[$i]['uid'])) { $uname = icms_member_user_Object::getUnameFromId($results[$i]['uid']); $results[$i]['processed_user_name'] = $uname; $results[$i]['processed_user_url'] = ICMS_URL . "/userinfo.php?uid=" . $results[$i]['uid']; } $results[$i]['processed_time'] = !empty($results[$i]['time']) ? " (" . formatTimestamp((int) $results[$i]['time']) . ")" : ""; } } $search_url_prev = ""; $search_url_next = ""; $search_url_base = ICMS_URL . '/search.php?'; $search_url_get_params = 'query=' . urlencode(stripslashes(implode(' ', $queries))); $search_url_get_params .= "&mid={$mid}&action={$action}&andor={$andor}"; if ($action == 'showallbyuser') { $search_url_get_params .= "&uid={$uid}"; } $search_url_get_params = htmlspecialchars($search_url_get_params, ENT_COMPAT, _CHARSET);
/** * 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); } } }