function &getList($cid, $uid, $limit, $start) { $ret = array(); $cid_sql = ($cid > 0)? " AND a.c_commu_id='".intval($cid)."'" : ""; $uid_sql = ($uid > 0)? " AND a.uid='".intval($uid)."'" : ""; $sql = "SELECT a.* FROM ". $this->prefix($this->table_name). " a,". $this->prefix('c_commu'). " c". " WHERE a.c_commu_id=c.c_commu_id". $cid_sql. $uid_sql. " ORDER BY a.r_datetime DESC"; if($rs = $this->db->query($sql, $limit, $start)){ while($row = $this->db->fetchArray($rs)){ $community =& $this->handler['community']->get(intval($row['c_commu_id'])); $user =& $this->handler['user']->get(intval($row['uid'])); if(is_object($community)){ $ret[] = array( 'member_id' => intval($row['uid']), 'member_name' => is_object($user) ? $user->getVar('uname') : '-', 'commu_id' => intval($row['c_commu_id']), 'commu_name' => $community->getVar('name'), 'time' => XsnsUtils::getUserTimestamp($row['r_datetime']), ); } unset($community, $user); } } return $ret; }
function b_xsns_information_show($options) { global $xoopsUser, $xoopsUserIsAdmin; if(!is_object($xoopsUser)){ return array(); } require_once dirname(dirname(__FILE__)).'/include/common_functions.php'; $db =& Database::getInstance(); $myts =& MyTextSanitizer::getInstance(); $mydirname = empty($options[0]) ? 'xsns' : $options[0]; if( preg_match( '/[^0-9a-zA-Z_-]/' , $mydirname ) ) die( 'Invalid dirname' ) ; $constpref = '_MB_'.strtoupper($mydirname); $block = array(); $sql = "SELECT mode,COUNT(*),MAX(r_datetime) AS max_r_datetime". " FROM ".$db->prefix($mydirname.'_c_commu_confirm'). " WHERE uid_to='".$xoopsUser->getVar('uid')."'". " GROUP BY mode". " ORDER BY max_r_datetime DESC"; $rs = $db->query($sql); if(!$rs || $db->getRowsNum($rs) < 1){ return array(); } require_once dirname(dirname(__FILE__)).'/userlib/utils.php'; while($row = $db->fetchArray($rs)){ $mode = intval($row['mode']); if(defined($constpref.'_INDEX_INFO_MSG_'.$mode)){ $block['info_list'][] = array( 'link' => XOOPS_URL.'/modules/'.$mydirname.'/?p=mypage&act=confirm#mode'.$mode, 'title' => sprintf(constant($constpref.'_INDEX_INFO_MSG_'.$mode), $row['COUNT(*)']), 'time' => XsnsUtils::getUserTimestamp($row['max_r_datetime']), ); } } $tpl = new XoopsTpl(); $tpl->assign('block', $block); $ret = array(); $ret['content'] = $tpl->fetch('db:'.$mydirname.'_block_information.html'); return $ret; }
function getUserDatetime($datetime, $timeoffset="") { return date('Y-m-d H:i:s', XsnsUtils::getUserTimestamp($datetime, $timeoffset)); }
function dispatch() { global $xoopsUser, $xoopsConfig; if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } $user_handler =& XsnsUserHandler::getInstance(); $user =& $user_handler->get($xoopsUser->getVar('uid')); if(!is_object($user)){ redirect_header(XOOPS_URL, 2, _NOPERM); } require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; require_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/user.php'; require_once XOOPS_ROOT_PATH.'/include/comment_constants.php'; $config_handler =& xoops_gethandler('config'); if(defined('XOOPS_CUBE_LEGACY')){ $xoopsConfigUser =& $config_handler->getConfigsByDirname('user'); $user_config =& $xoopsConfigUser; } else{ $xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER); $user_config =& $xoopsConfig; } require_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/notification.php'; require_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; $elements = array(); $token_handler = new XoopsMultiTokenHandler(); $token = new XoopsFormToken($token_handler->create('edituser')); // Hidden $elements['hiddens'] = array( array('html' => '<input type="hidden" name="'.XSNS_PAGE_ARG.'" value="mypage">'), array('html' => '<input type="hidden" name="'.XSNS_ACTION_ARG.'" value="profile_edit_exec">'), array('html' => '<input type="hidden" name="uid" value="'.$xoopsUser->getVar('uid').'">'), array('html' => '<input type="hidden" name="'.$token->_name.'" value="'.$token->_value.'">'), ); // Avatar $elements['avatar'] = array( 'name' => 'user_avatar', 'value' => $xoopsUser->getVar('user_avatar'), 'html' => '<img src="'.XOOPS_UPLOAD_URL.'/'.$xoopsUser->getVar('user_avatar').'" alt="'.$xoopsUser->getVar('uname').'" /><br>[<a href="'.XSNS_URL_MYPAGE.'&'.XSNS_ACTION_ARG.'=profile_avatar_up'.'">'._MD_XSNS_PROFILE_AVATAR_EDIT.'</a>]', ); // E-mail if(@$xoopsConfigUser['allow_chgmail']){ $email_text = '<input type="text" name="email" size="30" value="'.$xoopsUser->getVar('email', 'e').'">'; } else{ $email_text = $xoopsUser->getVar('email'); } $elements['email'] = array( 'name' => 'email', 'value' => $xoopsUser->getVar('email'), 'html' => $email_text.'<br><input type="checkbox" name="user_viewemail" value="1"'.($xoopsUser->getVar('user_viewemail') ? ' checked' : '') .'>'._US_ALLOWVIEWEMAIL, ); // Real name $elements['realname'] = array( 'name' => 'name', 'value' => $xoopsUser->getVar('name', 'e'), ); // Web site URL $elements['url'] = array( 'name' => 'url', 'value' => $xoopsUser->getVar('url', 'e'), ); // ICQ $elements['icq'] = array( 'name' => 'user_icq', 'value' => $xoopsUser->getVar('user_icq', 'e'), ); // AIM $elements['aim'] = array( 'name' => 'user_aim', 'value' => $xoopsUser->getVar('user_aim', 'e'), ); // YIM $elements['yim'] = array( 'name' => 'user_yim', 'value' => $xoopsUser->getVar('user_yim', 'e'), ); // MSNM $elements['msnm'] = array( 'name' => 'user_msnm', 'value' => $xoopsUser->getVar('user_msnm', 'e'), ); // Location $elements['location'] = array( 'name' => 'user_from', 'value' => $xoopsUser->getVar('user_from', 'e'), ); // Occupation $elements['occupation'] = array( 'name' => 'user_occ', 'value' => $xoopsUser->getVar('user_occ', 'e'), ); // Interest $elements['interest'] = array( 'name' => 'user_intrest', 'value' => $xoopsUser->getVar('user_intrest', 'e'), ); // Extra info $elements['extra'] = array( 'name' => 'bio', 'value' => $xoopsUser->getVar('bio', 'e'), ); // Signature $sig = $xoopsUser->getVar('user_sig', 'e'); $this->setXoopsCodeTarea('sig_xoops_codes', $sig, 'user_sig', 50, 5, null, 'sig_xoops_smilies'); $elements['sig'] = array( 'name' => 'user_sig', 'value' => $sig, ); $elements['attachsig'] = array( 'name' => 'attachsig', 'value' => $xoopsUser->getVar('attachsig') ? 'checked' : '', ); // Time zone $timezone_offset = $xoopsUser->getVar('timezone_offset'); $timezone_select = new XoopsFormSelectTimezone(_US_TIMEZONE, 'timezone_offset', $timezone_offset); $elements['timezone'] = array( 'name' => 'timezone_offset', 'value' => $timezone_offset, 'html' => XsnsUtils::getSelectBoxHtml('timezone_offset', $timezone_select->_options, $timezone_offset), ); // Event notify method $not_method = $xoopsUser->getVar('notify_method'); $not_method_arr = array( XOOPS_NOTIFICATION_METHOD_DISABLE => _NOT_METHOD_DISABLE, XOOPS_NOTIFICATION_METHOD_PM => _NOT_METHOD_PM, XOOPS_NOTIFICATION_METHOD_EMAIL => _NOT_METHOD_EMAIL, ); $elements['notify_method'] = array( 'name' => 'notify_method', 'value' => $not_method, 'html' => XsnsUtils::getSelectBoxHtml('notify_method', $not_method_arr, $not_method), ); // Event notify mode $not_mode = $xoopsUser->getVar('notify_mode'); $not_mode_arr = array( XOOPS_NOTIFICATION_MODE_SENDALWAYS => _NOT_MODE_SENDALWAYS, XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE => _NOT_MODE_SENDONCE, XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT => _NOT_MODE_SENDONCEPERLOGIN, ); $elements['notify_mode'] = array( 'name' => 'notify_mode', 'value' => $not_mode, 'html' => XsnsUtils::getSelectBoxHtml('notify_mode', $not_mode_arr, $not_mode), ); // Password $elements['password'] = array( 'name' => 'password', 'html' => '<input type="password" name="password" size="15" maxlength="32"> <input type="password" name="vpass" size="15" maxlength="32">', ); // Comment mode $umode = $xoopsUser->getVar('umode'); $umode_arr = array( 'nest' => _NESTED, 'flat' => _FLAT, 'thread' => _THREADED, ); $elements['umode'] = array( 'name' => 'umode', 'value' => $umode, 'html' => XsnsUtils::getSelectBoxHtml('umode', $umode_arr, $umode), ); // Comment order $uorder = $xoopsUser->getVar('uorder'); $uorder_arr = array( XOOPS_COMMENT_OLD1ST => _OLDESTFIRST, XOOPS_COMMENT_NEW1ST => _NEWESTFIRST, ); $elements['uorder'] = array( 'name' => 'uorder', 'value' => $uorder, 'html' => XsnsUtils::getSelectBoxHtml('uorder', $uorder_arr, $uorder), ); // user cookie $usercookie = empty($_COOKIE[@$user_config['usercookie']]) ? 0 : 1; $usercookie_arr = array(1 => _YES, 0 => _NO); $elements['usercookie'] = array( 'name' => 'usercookie', 'value' => $usercookie, 'html' => XsnsUtils::getRadioHtml('usercookie', $usercookie_arr, $usercookie), ); // user mail ok $mailok = $xoopsUser->getVar('user_mailok'); $mailok_arr = array(1 => _YES, 0 => _NO); $elements['mailok'] = array( 'name' => 'user_mailok', 'value' => $mailok, 'html' => XsnsUtils::getRadioHtml('user_mailok', $mailok_arr, $mailok), ); $this->context->setAttribute('user_menu', $user->getMypageMenu()); $this->context->setAttribute('elements', $elements); $this->context->setAttribute('allow_self_delete', @$xoopsConfigUser['self_delete']); }
function &getListForUser($uid_to, $limit=0, $start=0) { $ret = array(); $sql = "SELECT uid_from,MAX(r_datetime) as max_r_datetime". " FROM ".$this->prefix('c_mypage_footprint'). " WHERE uid_to='".intval($uid_to)."'". " GROUP BY uid_from,r_date". " ORDER BY max_r_datetime DESC"; if($limit > 0){ if($start > 0){ $sql.= " LIMIT ".$start.",".$limit; } else{ $sql.= " LIMIT ".$limit; } } if($rs = $this->db->query($sql)){ while($row = $this->db->fetchArray($rs)){ $ret[] = array( 'uid_from' => $row['uid_from'], 'time' => XsnsUtils::getUserTimestamp($row['max_r_datetime']), ); } } return $ret; }
function &getListForCommunity($cid, $limit=0, $start=0, $get_body=false) { $ts =& XsnsTextSanitizer::getInstance(); $image_handler =& XsnsImageHandler::getInstance(); $file_handler =& XsnsFileHandler::getInstance(); $ret = array(); $base_url = XSNS_URL_TOPIC.'&tid='; $sql = "SELECT ". "ct.c_commu_topic_id AS tid,". "ct.name AS tname,". "MAX(ctc.r_datetime) AS max_r_datetime,". "ctc.c_commu_topic_comment_id AS tcid,". "COUNT(*) AS comment_count". " FROM ". $this->prefix('c_commu_topic_comment'). " ctc". " INNER JOIN ". $this->prefix('c_commu_topic'). " ct". " USING(c_commu_topic_id)". " WHERE ct.c_commu_id='".intval($cid)."'". " GROUP BY ctc.c_commu_topic_id". " ORDER BY max_r_datetime DESC"; $rs = $this->db->query($sql, $limit, $start); if(!$rs){ return $ret; } if($get_body){ $comment_handler =& XsnsTopicCommentHandler::getInstance(); while($row = $this->db->fetchArray($rs)){ $comment =& $comment_handler->getByNumber($row['tid'], 0); $ret[] = array( 'name' => $ts->makeTboxData4Show($row['tname']), 'time' => XsnsUtils::getUserTimestamp($row['max_r_datetime']), 'page_url' => $base_url. intval($row['tid']), 'comment_count' => intval($row['comment_count'])-1, // except comment No.0 'body' => $comment->getVar('body'), 'images' => $image_handler->getList(2, intval($row['tcid'])), 'files' => $file_handler->getList(2, intval($row['tcid'])), ); unset($comment); } } else{ while($row = $this->db->fetchArray($rs)){ $ret[] = array( 'name' => $ts->makeTboxData4Show($row['tname']), 'time' => XsnsUtils::getUserTimestamp($row['max_r_datetime']), 'page_url' => $base_url. intval($row['tid']), 'comment_count' => intval($row['comment_count'])-1, // except comment No.0 'body' => '', ); unset($comment); } } return $ret; }
function &getInformationList() { $ret = array(); $sql = "SELECT mode,COUNT(*),MAX(r_datetime) AS max_r_datetime". " FROM ".$this->handler['confirm']->prefix('c_commu_confirm'). " WHERE uid_to='".$this->getVar('uid')."'". " GROUP BY mode". " ORDER BY max_r_datetime DESC"; $rs = $this->handler['confirm']->db->query($sql); if(!$rs || $this->handler['confirm']->db->getRowsNum($rs) < 1){ return $ret; } while($row = $this->handler['confirm']->db->fetchArray($rs)){ $mode = intval($row['mode']); if(defined('_MD_XSNS_INDEX_INFO_MSG_'.$mode)){ $ret[] = array( 'message' => sprintf(constant('_MD_XSNS_INDEX_INFO_MSG_'.$mode), $row['COUNT(*)']), 'url' => XSNS_URL_MYPAGE.'&'.XSNS_ACTION_ARG.'=confirm#mode'.$mode, 'time' => XsnsUtils::getUserTimestamp($row['max_r_datetime']), ); } } return $ret; }
/** * returns a specific variable for the object in a proper format * * @access public * @param string $key key of the object's variable to be returned * @param string $format format to use for the output * @return mixed formatted value of the variable */ function &getVar($key, $format = 's') { // for XsnsTextSanitizer // $ts =& XsnsTextSanitizer::getInstance(); if(!isset($this->vars[$key]['value'])){ $ret = NULL; return $ret; } $ret = $this->vars[$key]['value']; switch ($this->vars[$key]['data_type']) { case XOBJ_DTYPE_TXTBOX: switch (strtolower($format)) { case 's': case 'show': case 'e': case 'edit': $ts =& XsnsTextSanitizer::getInstance(); $ret = $ts->htmlSpecialChars($ret); break 1; case 'p': case 'preview': case 'f': case 'formpreview': $ts =& XsnsTextSanitizer::getInstance(); $ret = $ts->htmlSpecialChars($ts->stripSlashesGPC($ret)); break 1; case 'n': case 'none': default: break 1; } break; case XOBJ_DTYPE_TXTAREA: switch (strtolower($format)) { case 's': case 'show': $ts =& XsnsTextSanitizer::getInstance(); $ret = $ts->displayTarea($ret, $this->doHtml, $this->doSmiley, $this->doXcode, $this->doImage, $this->doBr); break 1; case 'e': case 'edit': $ret = htmlspecialchars($ret, ENT_QUOTES); break 1; case 'p': case 'preview': $ts =& XsnsTextSanitizer::getInstance(); $ret = $ts->previewTarea($ret, $this->doHtml, $this->doSmiley, $this->doXcode, $this->doImage, $this->doBr); break 1; case 'f': case 'formpreview': $ts =& XsnsTextSanitizer::getInstance(); $ret = htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES); break 1; // strip XOOPS Code ************************ case 'x': $ts =& XsnsTextSanitizer::getInstance(); $ret = $ts->stripXoopsCode($ret); break 1; // ***************************************** case 'n': case 'none': default: break 1; } break; case XOBJ_DTYPE_ARRAY: $ret = unserialize($ret); break; case XOBJ_DTYPE_SOURCE: switch (strtolower($format)) { case 's': case 'show': break 1; case 'e': case 'edit': $ret = htmlspecialchars($ret, ENT_QUOTES); break 1; case 'p': case 'preview': $ts =& XsnsTextSanitizer::getInstance(); $ret = $ts->stripSlashesGPC($ret); break 1; case 'f': case 'formpreview': $ts =& XsnsTextSanitizer::getInstance(); $ret = htmlspecialchars($ts->stripSlashesGPC($ret), ENT_QUOTES); break 1; case 'n': case 'none': default: break 1; } break; case XOBJ_DTYPE_DATE: case XOBJ_DTYPE_DATETIME: $ret = XsnsUtils::getUserTimestamp($ret); break; default: if ($this->vars[$key]['options'] != '' && $ret != '') { switch (strtolower($format)) { case 's': case 'show': $selected = explode('|', $ret); $options = explode('|', $this->vars[$key]['options']); $i = 1; $ret = array(); foreach ($options as $op) { if (in_array($i, $selected)) { $ret[] = $op; } $i++; } $ret = implode(', ', $ret); case 'e': case 'edit': $ret = explode('|', $ret); break 1; default: break 1; } } break; } return $ret; }
function dispatch() { global $xoopsUser, $xoopsUserIsAdmin; if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } $limit = 10; $start = $this->getIntRequest('s', XSNS_REQUEST_GET); if(!isset($start) || $start<0){ $start = 0; } $cid = $this->getIntRequest('cid', XSNS_REQUEST_GET); if(!$cid){ redirect_header(XOOPS_URL, 2, _NOPERM); } // コミュニティの取得 $perm = XSNS_AUTH_XOOPS_ADMIN | XSNS_AUTH_ADMIN; $commu_handler =& XsnsCommunityHandler::getInstance(); $community =& $commu_handler->get($cid); if(!is_object($community) || !$community->checkAuthority($perm)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $commu_vars = array('id' => $cid, 'name' => $community->getVar('name')); // コミュニティメンバー一覧の取得 $c_member_obj_list =& $community->getMemberObjects($limit, $start); $pager = $this->getPageSelector(XSNS_URL_MEMBER."&".XSNS_ACTION_ARG."=edit&cid=".$cid, $start, $limit, count($c_member_obj_list), $community->getMemberCount()); // 管理項目 $menu_list = array( 0 => array( // メンバー 0 => _MD_XSNS_MEMBER_LEAVE, 1 => _MD_XSNS_MEMBER_SET_ADMIN, 2 => _MD_XSNS_MEMBER_SET_SUB_ADMIN, ), 1 => array( // 副管理者 0 => _MD_XSNS_MEMBER_LEAVE, 1 => _MD_XSNS_MEMBER_SET_ADMIN, ), 2 => array( // 承認待ちのメンバー 0 => _MD_XSNS_MEMBER_LEAVE, ), ); $own_uid = $xoopsUser->getVar('uid'); $uid_admin = $community->getVar('uid_admin'); $uid_sub_admin = $community->getVar('uid_sub_admin'); $is_commu_admin = ($own_uid == $uid_admin)? true : false; $c_member_list = array(); foreach($c_member_obj_list as $c_member_obj){ $mid = $c_member_obj->getVar('uid'); $c_member_list[$mid] =& $c_member_obj->getInfo(); $c_member_list[$mid]['form_edit'] = $this->getFormHeader('post', 'member', 'request', false, array('cid'=>$cid, 'uid'=>$mid)); // 対象メンバーが自分自身(管理者)の場合 → 何も表示しない if($mid==$own_uid){ $c_member_list[$mid]['is_editable'] = false; } else{ // XOOPS管理者で、コミュニティの管理者でない場合 → [退会させる]だけを表示 if($xoopsUserIsAdmin && !$is_commu_admin){ $menu = $menu_list[2]; } // 対象メンバーが副管理者の場合 → [副管理者に指名]以外の項目を表示 elseif($mid == $uid_sub_admin){ $menu = $menu_list[1]; } // 対象メンバーが通常のメンバーの場合 → すべての項目を表示 else{ $menu = $menu_list[0]; } $c_member_list[$mid]['is_editable'] = true; $c_member_list[$mid]['sel_edit'] = XsnsUtils::getSelectBoxHtml('mode', $menu); } } $this->context->setAttribute('commu', $commu_vars); $this->context->setAttribute('member_list', $c_member_list); $this->context->setAttribute('pager', $pager); }