Beispiel #1
0
	function getComments($forPostKey, $getLimit = 3)
	{
		$countDS = DB_GetDatasetWQuery('SELECT COUNT(*) as count FROM '.getTableName('messages').'
        WHERE m_parent = ? AND m_deleted = "N" AND m_type="post" AND m_votehash = ""
        ', array($forPostKey));
		return(array(
		  'count' => $countDS['count'],
			'votes' => DB_GetList('SELECT COUNT(*) as votecount,m_data,m_id as count FROM '.getTableName('messages').'
        WHERE m_parent = ? AND m_deleted = "N" AND m_type="post" AND m_votehash != ""
        GROUP BY m_votehash
				ORDER BY votecount DESC, m_created ASC
				LIMIT 10
        ', array($forPostKey)),
		  'list' => array_reverse(DB_GetList('SELECT * FROM '.getTableName('messages').'
	      WHERE m_parent = ? AND m_deleted = "N" AND m_type="post" AND m_votehash = ""
	      ORDER BY m_created DESC
				LIMIT '.$getLimit, array($forPostKey))),
			));
	}
Beispiel #2
0
function DB_GetDatasetMatch($table, $matchOptions, $fillIfEmpty = true, $noMatchOptions = array())
{
    DB_Connect();
    $where = array('1');
    if (!is_array($matchOptions)) {
        $matchOptions = stringParamsToArray($matchOptions);
    }
    foreach ($matchOptions as $k => $v) {
        $where[] = '(' . $k . '="' . DB_Safe($v) . '")';
    }
    foreach ($noMatchOptions as $k => $v) {
        $where[] = '(' . $k . '!="' . DB_Safe($v) . '")';
    }
    $iwhere = implode(' AND ', $where);
    $query = 'SELECT * FROM ' . getTableName($table) . ' WHERE ' . $iwhere;
    $resultDS = DB_GetDatasetWQuery($query);
    if ($fillIfEmpty && sizeof($resultDS) == 0) {
        foreach ($matchOptions as $k => $v) {
            $resultDS[$k] = $v;
        }
    }
    profile_point('DB_GetDatasetMatch(' . $table . ', ' . $iwhere . ')');
    return $resultDS;
}
Beispiel #3
0
<?

    $myOldUsername = $this->user->getUsername();
    
    $ctr = 1;
	  // let's get the attributes exported to us from other services
	  $infoDS = DB_Getdataset('idaccounts', $this->user->key(), 'ia_user');
    $twitterInfo = json_decode($infoDS['ia_properties'], true);
  	$fbInfo = $twitterInfo;
  	$openInfo = $twitterInfo;
		
		// let's try to determine sensible user data from the login services
		$idAccountWithEmail = DB_GetDatasetWQuery('SELECT * FROM '.getTableName('idaccounts').'
		  WHERE ia_user=? AND ia_type = "email"', array($this->user->key()));
		$defaultEmail = getDefault($openInfo['contact/email'], $fbInfo['email'], $idAccountWithEmail['ia_url']);
		// determining a default username idea
		$emlName = trim(substr($defaultEmail, 0, strpos($defaultEmail, '@')));
    $defaultUsername = safename(getDefault($twitterInfo['screen_name'], $fbInfo['first_name'], $emlName, $openInfo['namePerson/friendly']));   
    if($defaultUsername != '' && !HubbubEntity::isNameAvailable($defaultUsername)) 
		{
      do {
        $defaultUsername2 = $defaultUsername.$ctr++;
      } while (!HubbubEntity::isNameAvailable($defaultUsername2));
			$defaultUsername = $defaultUsername2;
		}
		
		// making a reasonable default name of of the email address
		$nameParts = array();
		foreach(explode('.', $defaultUsername) as $namePart)
		  $nameParts[] = strtoupper(substr($namePart, 0, 1)).strtolower(substr($namePart, 1));
		$emailNameReconstruction = implode(' ', $nameParts);
Beispiel #4
0
 function findEntityGlobal($record)
 {
     $rec = array();
     $record['server'] = strtolower(trim($record['server']));
     $ds = DB_GetDatasetWQuery('SELECT * FROM ' . getTableName('entities') . ' WHERE user=? AND server=?', array($record['user'], getDefault($record['server'], cfg('service/server'))));
     if ($ds['_local'] == 'Y') {
         $ds['server'] = cfg('service/server');
     }
     return $ds;
 }