예제 #1
0
function verify_eventmembers($uids, $status)
{
    global $_SGLOBAL, $event;
    if ($_SGLOBAL['supe_userevent']['status'] < 3) {
        showmessage('no_privilege_manage_event_members');
    }
    $eventid = $_SGLOBAL['supe_userevent']['eventid'];
    if ($eventid != $event['eventid']) {
        $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname("event") . " WHERE eventid='{$eventid}'");
        $event = $_SGLOBAL['db']->fetch_array($query);
    }
    $status = intval($status);
    if ($status < -1 || $status > 3) {
        showmessage("bad_userevent_status");
        // Please select the correct status of the event Members
    }
    if ($event['verify'] == 0 && $status == 0) {
        showmessage("event_not_set_verify");
    }
    if ($status == 3 && $_SGLOBAL['supe_uid'] != $event['uid']) {
        showmessage("only_creator_can_set_admin");
        // Only Founder can set the administrator
    }
    $newids = $actions = $userevents = array();
    $num = 0;
    // changing Event Member Number
    $query = $_SGLOBAL['db']->query("SELECT ue.*, sf.* FROM " . tname("userevent") . " ue LEFT JOIN " . tname("spacefield") . " sf ON ue.uid=sf.uid WHERE ue.uid IN (" . simplode($uids) . ") AND ue.eventid='{$eventid}'");
    while ($value = $_SGLOBAL['db']->fetch_array($query)) {
        if ($value['status'] == $status || $event['uid'] == $value['uid'] || $value['status'] == 1) {
            // The same status, creator, who does not deal with concerned about
            continue;
        }
        if ($status == 2) {
            //Set to ordinary member
            $newids[] = $value['uid'];
            $userevents[$value['uid']] = $value;
            if ($value['status'] == 0) {
                // Join
                $actions[$value['uid']] = "set_verify";
                $num += $value['fellow'] + 1;
            } elseif ($value['status'] == 3) {
                // cancel the Organizer status
                $actions[$value['uid']] = "unset_admin";
            }
        } elseif ($status == 3) {
            //Set to Organizer
            $newids[] = $value['uid'];
            $userevents[$value['uid']] = $value;
            $actions[$value['uid']] = "set_admin";
            if ($value['status'] == 0) {
                $num += $value['fellow'] + 1;
            }
        } elseif ($status == 0) {
            //Set to Pending
            $newids[] = $value['uid'];
            $userevents[$value['uid']] = $value;
            $actions[$value['uid']] = "unset_verify";
            if ($value['status'] >= 2) {
                $num -= $value['fellow'] + 1;
            }
        } elseif ($status == -1) {
            //Delete Members
            $newids[] = $value['uid'];
            $userevents[$value['uid']] = $value;
            $actions[$value['uid']] = "set_delete";
            if ($value['status'] >= 2) {
                $num -= $value['fellow'] + 1;
            }
        }
    }
    if (empty($newids)) {
        return array();
    }
    if ($event['limitnum'] > 0 && $event['membernum'] + $num > $event['limitnum']) {
        // Event Number of members is over
        showmessage("event_will_full");
    }
    $note_inserts = $note_ids = $feed_inserts = array();
    $feedarr = array('appid' => UC_APPID, 'icon' => 'event', 'uid' => '', 'username' => '', 'dateline' => $_SGLOBAL['timestamp'], 'title_template' => cplang('event_join'), 'title_data' => array('title' => $event['title'], "eventid" => $event['eventid'], "uid" => $event['uid'], "username" => $event['username']), 'body_template' => '', 'body_data' => array(), 'body_general' => '', 'image_1' => '', 'image_1_link' => '', 'image_2' => '', 'image_2_link' => '', 'image_3' => '', 'image_3_link' => '', 'image_4' => '', 'image_4_link' => '', 'target_ids' => '', 'friend' => '');
    $feedarr = sstripslashes($feedarr);
    //Remove escape chars
    $feedarr['title_data'] = serialize(sstripslashes($feedarr['title_data']));
    //Serialize
    $feedarr['body_data'] = serialize(sstripslashes($feedarr['body_data']));
    //Serialize
    $feedarr['hash_template'] = md5($feedarr['title_template'] . "\t" . $feedarr['body_template']);
    //Like hash
    $feedarr['hash_data'] = md5($feedarr['title_template'] . "\t" . $feedarr['title_data'] . "\t" . $feedarr['body_template'] . "\t" . $feedarr['body_data']);
    //Merged hash
    $feedarr = saddslashes($feedarr);
    //Add slashes
    foreach ($newids as $id) {
        if ($status > 1 && $userevents[$id]['status'] == 0) {
            // Approved to participate in the Event, participate in activities publish to feed
            $feedarr['uid'] = $userevents[$id]['uid'];
            $feedarr['username'] = $userevents[$id]['username'];
            $feed_inserts[] = "('{$feedarr['appid']}', 'event', '{$feedarr['uid']}', '{$feedarr['username']}', '{$feedarr['dateline']}', '0', '{$feedarr['hash_template']}', '{$feedarr['hash_data']}', '{$feedarr['title_template']}', '{$feedarr['title_data']}', '{$feedarr['body_template']}', '{$feedarr['body_data']}', '{$feedarr['body_general']}', '{$feedarr['image_1']}', '{$feedarr['image_1_link']}', '{$feedarr['image_2']}', '{$feedarr['image_2_link']}', '{$feedarr['image_3']}', '{$feedarr['image_3_link']}', '{$feedarr['image_4']}', '{$feedarr['image_4_link']}')";
        }
        $userevents[$id]['privacy'] = empty($userevents[$id]['privacy']) ? array() : unserialize($userevents[$id]['privacy']);
        $filter = empty($userevents[$id]['privacy']['filter_note']) ? array() : array_keys($userevents[$id]['privacy']['filter_note']);
        if (cknote_uid(array("type" => "eventmemberstatus", "authorid" => $_SGLOBAL['supe_uid']), $filter)) {
            $note_ids[] = $id;
            $note_msg = cplang('eventmember_' . $actions[$id], array("space.php?do=event&id=" . $event['eventid'], $event['title']));
            $note_inserts[] = "('{$id}', 'eventmemberstatus', '1', '{$_SGLOBAL['supe_uid']}', '{$_SGLOBAL['supe_username']}', '" . addslashes($note_msg) . "', '{$_SGLOBAL['timestamp']}')";
        }
    }
    if ($note_ids) {
        $_SGLOBAL['db']->query("INSERT INTO " . tname('notification') . " (`uid`, `type`, `new`, `authorid`, `author`, `note`, `dateline`) VALUES " . implode(',', $note_inserts));
        $_SGLOBAL['db']->query("UPDATE " . tname('space') . " SET notenum=notenum+1 WHERE uid IN (" . simplode($note_ids) . ")");
    }
    if ($feed_inserts) {
        $_SGLOBAL['db']->query("INSERT INTO " . tname('feed') . " (`appid` ,`icon` ,`uid` ,`username` ,`dateline` ,`friend` ,`hash_template` ,`hash_data` ,`title_template` ,`title_data` ,`body_template` ,`body_data` ,`body_general` ,`image_1` ,`image_1_link` ,`image_2` ,`image_2_link` ,`image_3` ,`image_3_link` ,`image_4` ,`image_4_link`) VALUES " . implode(',', $feed_inserts));
    }
    if ($status == -1) {
        // Delete
        $_SGLOBAL['db']->query("DELETE FROM " . tname("userevent") . " WHERE uid IN (" . simplode($newids) . ") AND eventid='{$eventid}'");
    } else {
        // Set status
        $_SGLOBAL['db']->query("UPDATE " . tname("userevent") . " SET status='{$status}' WHERE uid IN (" . simplode($newids) . ") AND eventid='{$eventid}'");
    }
    // Modify Event Number of members
    if ($num != 0) {
        $_SGLOBAL['db']->query("UPDATE " . tname("event") . " SET membernum = membernum + ({$num}) WHERE eventid='{$eventid}'");
    }
    return $newids;
}
예제 #2
0
function notification_add($uid, $type, $note, $returnid=0) {
	global $_SGLOBAL;

	//获取对方的筛选条件
	$tospace = getspace($uid);
	
	//更新我的好友关系热度
	if($_SGLOBAL['supe_uid']) {
		addfriendnum($tospace['uid'], $tospace['username']);
	}
	
	$setarr = array(
		'uid' => $uid,
		'type' => $type,
		'new' => 1,
		'authorid' => $_SGLOBAL['supe_uid'],
		'author' => $_SGLOBAL['supe_username'],
		'note' => addslashes(sstripslashes($note)),
		'dateline' => $_SGLOBAL['timestamp']
	);

	$filter = empty($tospace['privacy']['filter_note'])?array():array_keys($tospace['privacy']['filter_note']);
	if(cknote_uid($setarr, $filter)) {
		//更新用户通知
		$_SGLOBAL['db']->query("UPDATE ".tname('space')." SET notenum=notenum+1 WHERE uid='$uid'");
	
		if($returnid) {
			return inserttable('notification', $setarr, $returnid);
		} else {
			inserttable('notification', $setarr);
		}
	}
}
예제 #3
0
function verify_eventmembers($uids, $status)
{
    global $_SGLOBAL, $event;
    if ($_SGLOBAL['supe_userevent']['status'] < 3) {
        showmessage('no_privilege_manage_event_members');
    }
    $eventid = $_SGLOBAL['supe_userevent']['eventid'];
    if ($eventid != $event['eventid']) {
        $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname("event") . " WHERE eventid='{$eventid}'");
        $event = $_SGLOBAL['db']->fetch_array($query);
    }
    $status = intval($status);
    if ($status < -1 || $status > 3) {
        showmessage("bad_userevent_status");
        // 请选择正确的活动成员状态
    }
    if ($event['verify'] == 0 && $status == 0) {
        showmessage("event_not_set_verify");
    }
    if ($status == 3 && $_SGLOBAL['supe_uid'] != $event['uid']) {
        showmessage("only_creator_can_set_admin");
        // 只有创建者可以设管理员
    }
    $newids = $actions = $userevents = array();
    $num = 0;
    // 活动人数变化
    $query = $_SGLOBAL['db']->query("SELECT ue.*, sf.* FROM " . tname("userevent") . " ue LEFT JOIN " . tname("spacefield") . " sf ON ue.uid=sf.uid WHERE ue.uid IN (" . simplode($uids) . ") AND ue.eventid='{$eventid}'");
    while ($value = $_SGLOBAL['db']->fetch_array($query)) {
        if ($value['status'] == $status || $event['uid'] == $value['uid'] || $value['status'] == 1) {
            // 相同 status 者,创建者,关注者 不处理
            continue;
        }
        if ($status == 2) {
            //设为普通成员
            $newids[] = $value['uid'];
            $userevents[$value['uid']] = $value;
            if ($value['status'] == 0) {
                // 加入
                $actions[$value['uid']] = "set_verify";
                $num += $value['fellow'] + 1;
            } elseif ($value['status'] == 3) {
                // 取消组织者身份
                $actions[$value['uid']] = "unset_admin";
            }
        } elseif ($status == 3) {
            //设为组织者
            $newids[] = $value['uid'];
            $userevents[$value['uid']] = $value;
            $actions[$value['uid']] = "set_admin";
            if ($value['status'] == 0) {
                $num += $value['fellow'] + 1;
            }
        } elseif ($status == 0) {
            //设为待审核
            $newids[] = $value['uid'];
            $userevents[$value['uid']] = $value;
            $actions[$value['uid']] = "unset_verify";
            if ($value['status'] >= 2) {
                $num -= $value['fellow'] + 1;
            }
        } elseif ($status == -1) {
            //删除成员
            $newids[] = $value['uid'];
            $userevents[$value['uid']] = $value;
            $actions[$value['uid']] = "set_delete";
            if ($value['status'] >= 2) {
                $num -= $value['fellow'] + 1;
            }
        }
    }
    if (empty($newids)) {
        return array();
    }
    if ($event['limitnum'] > 0 && $event['membernum'] + $num > $event['limitnum']) {
        // 活动人数超了
        showmessage("event_will_full");
    }
    $note_inserts = $note_ids = $feed_inserts = array();
    $feedarr = array('appid' => UC_APPID, 'icon' => 'event', 'uid' => '', 'username' => '', 'dateline' => $_SGLOBAL['timestamp'], 'title_template' => cplang('event_join'), 'title_data' => array('title' => $event['title'], "eventid" => $event['eventid'], "uid" => $event['uid'], "username" => $event['username']), 'body_template' => '', 'body_data' => array(), 'body_general' => '', 'image_1' => '', 'image_1_link' => '', 'image_2' => '', 'image_2_link' => '', 'image_3' => '', 'image_3_link' => '', 'image_4' => '', 'image_4_link' => '', 'target_ids' => '', 'friend' => '');
    $feedarr = sstripslashes($feedarr);
    //去掉转义
    $feedarr['title_data'] = serialize(sstripslashes($feedarr['title_data']));
    //数组转化
    $feedarr['body_data'] = serialize(sstripslashes($feedarr['body_data']));
    //数组转化
    $feedarr['hash_template'] = md5($feedarr['title_template'] . "\t" . $feedarr['body_template']);
    //喜好hash
    $feedarr['hash_data'] = md5($feedarr['title_template'] . "\t" . $feedarr['title_data'] . "\t" . $feedarr['body_template'] . "\t" . $feedarr['body_data']);
    //合并hash
    $feedarr = saddslashes($feedarr);
    //增加转义
    foreach ($newids as $id) {
        if ($status > 1 && $userevents[$id]['status'] == 0) {
            // 通过审核参加了活动,发布参加活动feed
            $feedarr['uid'] = $userevents[$id]['uid'];
            $feedarr['username'] = $userevents[$id]['username'];
            $feed_inserts[] = "('{$feedarr['appid']}', 'event', '{$feedarr['uid']}', '{$feedarr['username']}', '{$feedarr['dateline']}', '0', '{$feedarr['hash_template']}', '{$feedarr['hash_data']}', '{$feedarr['title_template']}', '{$feedarr['title_data']}', '{$feedarr['body_template']}', '{$feedarr['body_data']}', '{$feedarr['body_general']}', '{$feedarr['image_1']}', '{$feedarr['image_1_link']}', '{$feedarr['image_2']}', '{$feedarr['image_2_link']}', '{$feedarr['image_3']}', '{$feedarr['image_3_link']}', '{$feedarr['image_4']}', '{$feedarr['image_4_link']}')";
        }
        $userevents[$id]['privacy'] = empty($userevents[$id]['privacy']) ? array() : unserialize($userevents[$id]['privacy']);
        $filter = empty($userevents[$id]['privacy']['filter_note']) ? array() : array_keys($userevents[$id]['privacy']['filter_note']);
        if (cknote_uid(array("type" => "eventmemberstatus", "authorid" => $_SGLOBAL['supe_uid']), $filter)) {
            $note_ids[] = $id;
            $note_msg = cplang('eventmember_' . $actions[$id], array("space.php?do=event&id=" . $event['eventid'], $event['title']));
            $note_inserts[] = "('{$id}', 'eventmemberstatus', '1', '{$_SGLOBAL['supe_uid']}', '{$_SGLOBAL['supe_username']}', '" . addslashes($note_msg) . "', '{$_SGLOBAL['timestamp']}')";
        }
    }
    if ($note_ids) {
        $_SGLOBAL['db']->query("INSERT INTO " . tname('notification') . " (`uid`, `type`, `new`, `authorid`, `author`, `note`, `dateline`) VALUES " . implode(',', $note_inserts));
        $_SGLOBAL['db']->query("UPDATE " . tname('space') . " SET notenum=notenum+1 WHERE uid IN (" . simplode($note_ids) . ")");
    }
    if ($feed_inserts) {
        $_SGLOBAL['db']->query("INSERT INTO " . tname('feed') . " (`appid` ,`icon` ,`uid` ,`username` ,`dateline` ,`friend` ,`hash_template` ,`hash_data` ,`title_template` ,`title_data` ,`body_template` ,`body_data` ,`body_general` ,`image_1` ,`image_1_link` ,`image_2` ,`image_2_link` ,`image_3` ,`image_3_link` ,`image_4` ,`image_4_link`) VALUES " . implode(',', $feed_inserts));
    }
    if ($status == -1) {
        // 删除
        $_SGLOBAL['db']->query("DELETE FROM " . tname("userevent") . " WHERE uid IN (" . simplode($newids) . ") AND eventid='{$eventid}'");
    } else {
        // 设置状态
        $_SGLOBAL['db']->query("UPDATE " . tname("userevent") . " SET status='{$status}' WHERE uid IN (" . simplode($newids) . ") AND eventid='{$eventid}'");
    }
    // 修改活动人数
    if ($num != 0) {
        $_SGLOBAL['db']->query("UPDATE " . tname("event") . " SET membernum = membernum + ({$num}) WHERE eventid='{$eventid}'");
    }
    return $newids;
}