Example #1
0
 function getUserappsCacheByUids($uids)
 {
     is_numeric($uids) && ($uids = array(intval($uids)));
     if (!S::isArray($uids)) {
         return false;
     }
     $uids = array_unique($uids);
     $result = $_tmpResult = $keys = $_tmpUids = array();
     foreach ($uids as $uid) {
         $keys[$this->_getUserappsCacheDataKey($uid)] = $uid;
     }
     if ($userApps = $this->_cacheService->get(array_keys($keys))) {
         $_unique = $this->getUnique();
         foreach ($keys as $key => $uid) {
             $_key = $_unique . $key;
             if (isset($userApps[$_key]) && is_array($userApps[$_key])) {
                 $_tmpUids[] = $uid;
                 $result[$uid] = $userApps[$_key];
             }
         }
     }
     $uids = array_diff($uids, $_tmpUids);
     if ($uids) {
         $_tmpResult = $this->_getUserappsCacheDataByUidsNoCache($uids);
         foreach ($uids as $uid) {
             $this->_cacheService->set($this->_getUserappsCacheDataKey($uid), isset($_tmpResult[$uid]) ? $_tmpResult[$uid] : array());
         }
     }
     return (array) $result + (array) $_tmpResult;
 }
Example #2
0
 /**
  * »ñÈ¡¿ªÆôͼ¿áµÄ°æ¿é
  * @return array
  */
 function getTucoolForums()
 {
     $tucoolForums = array();
     $fids = $this->getAllForumIds();
     $forumsDao = $this->getForumsDao();
     $forumSets = $forumsDao->getForumSetsByFids($fids);
     if ($forumSets) {
         foreach ($forumSets as $k => $v) {
             $forumset = array();
             $v = @unserialize($v['forumset']);
             if (!$v['iftucool']) {
                 continue;
             }
             $forumset['tucoolpic'] = intval($v['tucoolpic']);
             S::isArray($forumset) && ($tucoolForums[$k] = $forumset);
         }
     }
     if ($tucoolForums) {
         $forums = $forumsDao->getFormusByFids(array_keys($tucoolForums), 'fid,name');
         foreach ($forums as $k => $v) {
             $tucoolForums[$k] = array_merge($tucoolForums[$k], $v);
         }
     }
     return $tucoolForums;
 }
 /**
  * 添加
  * 
  * @param array $fieldsData 数据数组,以数据库字段为key
  * @return int 新增id
  */
 function insert($fieldsData)
 {
     if (S::isArray($fieldsData)) {
         pwQuery::insert($this->_tableName, $fieldsData);
         return $this->_db->insert_id();
     }
 }
 /**
  * ÅжϸÃÌû×ÓÊÇ·ñÒѱ»É¾³ý
  * @param unknown_type $thread
  */
 function _checkIfDelete($thread)
 {
     if (!S::isArray($thread)) {
         return true;
     }
     return $thread['fid'] == 0 && $thread['ifcheck'] == 1;
 }
 function saveModesData($uid, $data, $conf)
 {
     $array = array();
     foreach ($data as $key => $value) {
         $this->_cacheService->set($this->_getKeyForUserMode($uid, $key), array('num' => S::isArray($conf[$key]) ? S::int($conf[$key]['num']) : $conf[$key], 'value' => $value), S::isArray($conf[$key]) && isset($conf[$key]['expire']) ? S::int($conf[$key]['expire']) : 608400);
     }
 }
 function deleteByTids($tids)
 {
     if (!S::isArray($tids)) {
         return false;
     }
     return pwQuery::delete($this->_tableName, "{$this->_primaryKey} IN (:{$this->_primaryKey})", array($tids));
 }
Example #7
0
 /**
  * 添加工作经历
  * @param array $data
  * @return bool
  */
 function addCareers($data)
 {
     if (!S::isArray($data)) {
         return false;
     }
     return $this->_db->update("INSERT INTO {$this->_tableName} (uid,companyid,starttime) VALUES " . S::sqlMulti($data) . "");
 }
 /**
  * 添加
  * 
  * @param array $fieldsData 数据数组,以数据库字段为key
  * @return int 新增id
  */
 function insert($fieldsData)
 {
     if (S::isArray($fieldsData)) {
         $typeDb = $this->_getTypeDB();
         return $typeDb->insert($fieldsData);
     }
 }
 /**
  * 获取一组帖子的基本信息
  *
  * @param array $threadIds 帖子id数组
  * @return array
  */
 function getThreadsByThreadIds($threadIds)
 {
     if (!S::isArray($threadIds)) {
         return array();
     }
     if (!$this->checkMemcache()) {
         return $this->_getThreadsNoCache($threadIds);
     }
     $result = $resultInCache = $resultInDb = $keys = $_cachedThreadIds = array();
     foreach ($threadIds as $threadId) {
         $keys[] = $this->_getKeyForThread($threadId);
     }
     if ($threads = $this->_cacheService->get($keys)) {
         foreach ($threads as $value) {
             $_cachedThreadIds[] = $value['tid'];
             $resultInCache[$value['tid']] = $value;
         }
     }
     $_noCachedThreadIds = array_diff($threadIds, $_cachedThreadIds);
     if ($_noCachedThreadIds && ($resultInDb = $this->_getThreadsNoCache($_noCachedThreadIds))) {
         foreach ($resultInDb as $value) {
             $this->_cacheService->set($this->_getKeyForThread($value['tid']), $value);
         }
     }
     $tmpResult = (array) $resultInCache + (array) $resultInDb;
     foreach ($threadIds as $threadId) {
         $result[$threadId] = isset($tmpResult[$threadId]) ? $tmpResult[$threadId] : false;
     }
     return $result;
 }
Example #10
0
 /**
  * 根据tids批量删除数据
  * 
  * @param int $tid
  * @return array 
  */
 function deleteByTids($tids)
 {
     if (!S::isArray($tids)) {
         return false;
     }
     return $this->_db->update("DELETE FROM " . $this->_tableName . " WHERE tid IN (" . S::sqlImplode($tids) . ")");
 }
Example #11
0
 function getAtFeedByUserNames($usernames)
 {
     $data = array();
     if (!S::isArray($usernames)) {
         return $data;
     }
     $userService = L::loadClass('userservice', 'user');
     $users = $userService->getByUserNames($usernames);
     if (S::isArray($users)) {
         $userIds = array();
         foreach ($users as $k => $v) {
             $userIds[$v['uid']] = $v['username'];
         }
         $ouserdataDb = $this->_getOuserdataDB();
         $atFeeds = (array) $ouserdataDb->findUserAtPrivacy(array_keys($userIds));
         if (S::isArray($atFeeds)) {
             foreach ($atFeeds as $v) {
                 $data[$v['uid']] = array('at_isfeed' => $v['at_isfeed'], 'username' => $userIds[$v['uid']]);
             }
         }
         foreach ($userIds as $uid => $username) {
             $data[$uid] or $data[$uid] = array('at_isfeed' => 0, 'username' => $username);
         }
     }
     return $data;
 }
Example #12
0
/**
 * 组装小名片数据
 *
 * @param int $uid 用户ID
 * @param int $winduid 当前用户id
 * @param bool $username 用户名
 * @return array
 */
function getCardData($uid, $winduid, $username)
{
    extract(pwCache::getData(R_P . "data/bbscache/level.php", false));
    if ($uid < 1 && !trim($username) || $username == '游客' || $username == '匿名') {
        return array('username' => '游客', 'memtitle' => $ltitle[2]);
    }
    $userService = L::loadClass('UserService', 'user');
    if ($uid) {
        $userInfo = $userService->get($uid, true, true);
    } elseif ($username) {
        $userInfo = $userService->getByUserName($username, true, true);
    }
    if (!S::isArray($userInfo)) {
        return array();
    }
    require_once R_P . 'require/showimg.php';
    list($faceimage) = showfacedesign($userInfo['icon'], 1, 's');
    $userInfo['groupid'] == '-1' && ($userInfo['groupid'] = $userInfo['memberid']);
    !array_key_exists($userInfo['groupid'], (array) $lpic) && ($userInfo['groupid'] = 8);
    $online = checkOnline($userInfo['thisvisit']);
    $onlineRead = $online ? getOnlineViewing($userInfo['uid'], $userInfo['username']) : array();
    $user = array('mine' => $userInfo['uid'] == $winduid || !$winduid ? 0 : 1, 'uid' => $userInfo['uid'], 'username' => $userInfo['username'], 'icon' => $faceimage, 'memtitle' => $ltitle[$userInfo['groupid']], 'genderClass' => $userInfo['gender'], 'viewTid' => isset($onlineRead['tid']) && $onlineRead['tid'] ? $onlineRead['tid'] : '', 'viewFid' => isset($onlineRead['fid']) && $onlineRead['fid'] ? $onlineRead['fid'] : '', 'online' => $online ? 1 : 0);
    $user['medals'] = getMedalsByUid($userInfo['uid']);
    // 勋章
    $memberTagsService = L::loadClass('memberTagsService', 'user');
    $user['memberTags'] = $memberTagsService->makeClassTags($memberTagsService->getMemberTagsByUid($userInfo['uid']));
    //标签
    $attentionSerivce = L::loadClass('Attention', 'friend');
    /* @var $attentionSerivce PW_Attention */
    $user['attention'] = $attentionSerivce->isFollow($winduid, $userInfo['uid']) ? 1 : 0;
    //关注
    return $user;
}
Example #13
0
 /**
  * 
  * 数据处理
  * @param int $fid
  * @return 
  */
 function _cookData($data)
 {
     if (!S::isArray($data)) {
         return array();
     }
     require_once R_P . 'require/showimg.php';
     foreach ($data as $k => $v) {
         $tem = array();
         $tem['url'] = USER_URL . $v['uid'];
         $tem['title'] = $v['username'];
         $tem['value'] = $v['uid'];
         if (array_key_exists('icon', $v)) {
             $pic = showfacedesign($v['icon'], true, 's');
             if (is_array($pic)) {
                 $tem['image'] = $pic[0];
             } else {
                 $tem['image'] = '';
             }
         } else {
             $tem['image'] = '';
         }
         $tem['addition'] = $v;
         $userInfo[] = $tem;
     }
     return $userInfo;
 }
 /**
  * 添加
  * 
  * @param array $fieldsData
  * @return int
  */
 function insert($fieldsData)
 {
     if (!S::isArray($fieldsData)) {
         return false;
     }
     return $this->_insert($fieldsData);
 }
Example #15
0
 function insert($fieldsData)
 {
     if (!S::isArray($fieldsData)) {
         return false;
     }
     $this->_db->update("INSERT INTO " . $this->_tableName . " (uid,name,type,size,attachurl,uploadtime,descrip,ifthumb) VALUES  " . S::sqlMulti($fieldsData));
     return true;
 }
 /**
  * 不通过缓存直接从数据库获取weibo content信息
  *
  * @param array $mids
  * @return array
  */
 function _getWeiboContentsDataByMidsNoCache($mids)
 {
     if (!S::isArray($mids)) {
         return false;
     }
     $contentDao = L::loadDB('weibo_content', 'sns');
     return $contentDao->getWeibosByMid($mids);
 }
 /**
  * 
  * 检查是否已经关注某些话题
  * @param int $topicIds
  * @param int $userid
  * @return array
  */
 function getAttentionedTopicByTopicIds($topicIds, $userid)
 {
     if (!$userid && !S::isArray($topicIds)) {
         return array();
     }
     $query = $this->_db->query('SELECT userid,topicid FROM ' . $this->_tableName . ' WHERE userid = ' . $this->_addSlashes($userid) . ' AND topicid IN (' . S::sqlImplode($topicIds) . ')');
     return $this->_getAllResultFromQuery($query, 'topicid');
 }
Example #18
0
 /**
  * 批量获取用户信息
  * @param array $uids
  * @return array
  */
 function getKmdUsersByUids($uids)
 {
     if (!S::isArray($uids)) {
         return array();
     }
     $query = $this->_db->query(pwQuery::selectClause($this->_tableName, "{$this->_primaryKey} IN (:{$this->_primaryKey})", array($uids)));
     return $this->_getAllResultFromQuery($query, 'uid');
 }
 function deleteByUids($tid, $pid, $uids)
 {
     $tid = intval($tid);
     $pid = intval($pid);
     if (!$tid || !S::isArray($uids)) {
         return false;
     }
     return $this->_db->update("DELETE FROM {$this->_tableName} WHERE tid={$tid} AND pid={$pid} AND uid IN( " . S::sqlImplode($uids) . ')');
 }
Example #20
0
 function checkTableField($table, $field)
 {
     list($table, $field) = array(trim($table), trim($field));
     if (!$table || !$field) {
         return $this->buildResponse(SITE_INVALID_PARAMS);
     }
     $result = $GLOBALS['db']->get_one(sprintf('SHOW COLUMNS FROM %s LIKE %s', S::sqlMetadata($table), S::sqlEscape($field)));
     return $this->buildResponse(S::isArray($result) ? 0 : 1);
 }
Example #21
0
 /**
  * 编辑
  * 
  * @param array $fieldsData 数据数组,以数据库字段为key
  * @param int $ctid 分类ID
  * @return int 最新编辑的分类ID
  */
 function update($fieldsData, $ctid)
 {
     $ctid = intval($ctid);
     if ($ctid < 1) {
         return null;
     }
     if (S::isArray($fieldsData)) {
         return $this->_update($fieldsData, $ctid);
     }
 }
 /**
  * 编辑
  * 
  * @param array $typeName 数据数组,以数据库字段为key
  * @param int $typeId 分类ID
  * @return int 最新编辑的分类ID
  */
 function update($fieldsData, $typeId)
 {
     if (!intval($typeId)) {
         return null;
     }
     if (S::isArray($fieldsData)) {
         $typeDb = $this->_getTypeDB();
         return $typeDb->update($fieldsData, $typeId);
     }
 }
Example #23
0
 function _doSync($indexes, $attrs, $ids, $state)
 {
     if (!S::isArray($ids)) {
         return false;
     }
     $_tmp = array();
     foreach ($ids as $id) {
         $_tmp[$id] = array($state);
     }
     return $this->_syncData($indexes, $attrs, $_tmp);
 }
 /**
  * 编辑
  * 
  * @param array $fieldsData 数据数组,以数据库字段为key
  * @param int $ctid 分类ID
  * @return int 最新编辑的分类ID
  */
 function update($fieldsData, $ctid)
 {
     $ctid = intval($ctid);
     if ($ctid < 1) {
         return NULL;
     }
     if (S::isArray($fieldsData)) {
         $typeDb = $this->_getCollectionTypeDB();
         return $typeDb->update($fieldsData, $ctid);
     }
 }
Example #25
0
 function filterMemberFields($members)
 {
     if (!S::isArray($members)) {
         return array();
     }
     $result = array();
     foreach ($members as $value) {
         unset($value['password'], $value['safecv']);
         $result[] = $value;
     }
     return $result;
 }
Example #26
0
 function _cookSql($condition)
 {
     if (!S::isArray($condition)) {
         return '';
     }
     if (isset($condition['uid'])) {
         return ' WHERE uid=' . S::sqlEscape($condition['uid']) . ' ';
     }
     if ($condition['medal_id']) {
         return ' WHERE medal_id=' . S::sqlEscape($condition['medal_id']) . ' ';
     }
 }
Example #27
0
 function formatDeleteIds($ids)
 {
     if (!S::isArray($ids)) {
         return array();
     }
     list($tableName, $primaryKey) = $this->getPrimaryKeyAndTable();
     $result = array();
     foreach ($ids as $id) {
         $result[] = array($primaryKey => intval($id));
     }
     return $result;
 }
 function _buildHotwordsSort($data)
 {
     if (!$data || !S::isArray($data)) {
         return array();
     }
     foreach ($data as $value) {
         $sortByViewOrder[] = $value['vieworder'];
         $sortById[] = $value['id'];
     }
     array_multisort($sortByViewOrder, SORT_ASC, $sortById, SORT_DESC, $data);
     return $data;
 }
Example #29
0
 function _insertLog($tableName, $sids, $operate)
 {
     if (!$tableName || !S::isArray($sids) || !$operate) {
         return false;
     }
     global $db, $timestamp;
     $operates = array('update' => 1, 'delete' => 2, 'insert' => 3);
     foreach ($sids as $sid) {
         pwQuery::replace($tableName, array('id' => $sid, 'sid' => $sid, 'operate' => $operates[$operate], 'modified_time' => $timestamp));
     }
     return true;
 }
Example #30
0
function getPhotoList($sv, $aid)
{
    $array = array();
    $sv->setPerpage($sv->getAlbumNumByUid());
    $result = $sv->getPhotoListByAid($aid, false, false);
    list(, $photos) = $result;
    if (S::isArray($photos)) {
        foreach ($photos as $photo) {
            $array[] = array('pid' => $photo['pid'], 'thumbpath' => getphotourl($photo['defaultPath'], $photo['ifthumb']), 'path' => $photo['path']);
        }
    }
    return $array;
}