function _post_save_vote(&$data, &$msg) { $msg->voteHash = md5(strtolower(substr($data['text'], 1))); // but if this person already voted, we need to unregister these previous votes DB_Update('UPDATE ' . getTableName('messages') . ' SET m_votehash = "", m_deleted = "Y" WHERE m_parent = ? AND m_author = ?', array($msg->parentKey, $msg->authorEntity->key())); DB_Update('DELETE FROM ' . getTableName('votes') . ' WHERE v_msg = ?', array($msg->parentKey)); // update the vote summary foreach (DB_GetList('SELECT COUNT(*) as votecount,m_data,m_id,m_votehash as count FROM ' . getTableName('messages') . ' WHERE m_parent = ? AND m_deleted = "N" AND m_type="post" AND m_votehash != "" GROUP BY m_votehash') as $vds) { $msgData = HubbubMessage::unpackData($vds); // get the some exemplary votes for this $voterList = array(); foreach (DB_GetList('SELECT m_author FROM ' . getTableName('messages') . ' WHERE m_parent = ? AND m_votehash = ? ORDER BY m_created DESC LIMIT 3', array($msg->parentKey, $vds['m_votehash'])) as $vex) { $voterList[] = $vex; } // if this is also what this message votes for, add it to the list if ($this->{$msg}->voteHash == $vds['m_votehash']) { $voterList[] = getDefault($msg->authorKey, $msg->ownerKey); } // make the vote summary dataset $voteDS = array('v_msg' => $msg->parentKey, 'v_choice' => $vds['m_votehash'], 'v_text' => $msgData['text'], 'v_voters' => implode(',', $voterList), 'v_count' => $vds['votecount']); DB_UpdateDataset('votes', $voteDS); } }
function updateDataset() { if ($this->tableName != '') { $this->getData(); DB_UpdateDataset($this->tableName, $this->ds); } else { logError('form', 'CQForm::updateDataset() unspecified database table'); } }
function ChangeMyUrl($newUrl) { $result = $this->CheckNewUrl($newUrl); if($result['result'] == 'OK') { $ds = $GLOBALS['obj']['user']->selfEntity(); $ds['url'] = $newUrl; DB_UpdateDataset('entities', $ds); return(true); } }
function onOpenIDLogin(&$openid) { $ids = DB_GetDataset('idaccounts', $openid->identity, 'ia_url'); if (sizeof($ids) > 0) { } else { // new account $uds = array('u_name' => ''); $ukey = DB_UpdateDataset('users', $uds); $ids = array('ia_type' => 'openid', 'ia_url' => $openid->identity, 'ia_user' => $this->user->id); DB_UpdateDataset('idaccounts', $ids); } $this->redirect('auth'); }
function setUsername($username) { $userObj = object('user'); $userObj->isNewUser = $this->ds['u_entity'] == 0; $userObj->server = new HubbubServer(cfg('service/server'), true); $userObj->loadEntity(); $userObj->entityDS['user'] = safename($username); $userObj->entityDS['url'] = getDefault($userObj->entityDS['url'], cfg('service/server').'/'.(cfg('service/url_rewrite') ? '' : '?').$username); $userObj->entityDS['_local'] = 'Y'; $userObj->entityDS['_serverkey'] = $userObj->server->ds['s_key']; $userObj->entityDS['server'] = cfg('service/server'); if(trim($userObj->entityDS['user']) != '') $ekey = DB_UpdateDataset('entities', $userObj->entityDS); $userObj->ds['u_entity'] = $ekey; if(trim($userObj->ds['u_name']) != '') DB_UpdateDataset('users', $userObj->ds); if($userObj->isNewUser) h2_execute_event('user_new', $userObj->entityDS, $userObj->ds); }
function getMyGroups() { l10n_load('mvc/friends/l10n'); $result = array(); $grpList = DB_GetList('SELECT * FROM '.getTableName('localgroups').' WHERE lg_entity = ?', array(object('user')->ds['u_entity'])); if(sizeof($grpList) == 0) { foreach(explode(',', '_friends,_colleagues,_acquaintances,_family') as $gname) { $nds = array('lg_entity' => object('user')->ds['u_entity'], 'lg_name' => $gname); $nds['lg_key'] = DB_UpdateDataset('localgroups', $nds); $grpList[] = $nds; } } foreach($grpList as $grp) { if(substr($grp['lg_name'], 0, 1) == '_') $grp['lg_name'] = l10n($grp['lg_name']); $result[] = $grp; } return($result); }
$erec1 = array('server' => $_SERVER['HTTP_HOST'], 'user' => $u1name, 'url' => $_SERVER['HTTP_HOST'].'/'.$u1name); $ne1 = new HubbubEntity(); $ne1->create($erec1, true); $erec2 = array('server' => $_SERVER['HTTP_HOST'], 'user' => $u2name, 'url' => $_SERVER['HTTP_HOST'].'/'.$u2name); $ne2 = new HubbubEntity(); $ne2->create($erec2, true); $ne1key = $ne1->ds['_key']; $ne2key = $ne2->ds['_key']; tlog($ne1->ds['_key'] > 0, 'HubbubEntity::create('.$u1name.')', 'OK', 'failed, no key assigned'); tlog($ne2->ds['_key'] > 0, 'HubbubEntity::create('.$u2name.')', 'OK', 'failed, no key assigned'); $u1 = array('u_name' => $u1name, 'u_entity' => $ne1->ds['_key']); DB_UpdateDataset('users', $u1); $u2 = array('u_name' => $u2name, 'u_entity' => $ne2->ds['_key']); DB_UpdateDataset('users', $u2); tlog($u1['u_key'] > 0, 'HubbubUser::create('.$u1['u_key'].')', 'OK', 'failed, no key assigned'); tlog($u2['u_key'] > 0, 'HubbubUser::create('.$u2['u_key'].')', 'OK', 'failed, no key assigned'); tsection('Message Basic'); $p = new HubbubMessage('friend_request'); tlog($p->data['msgid'] != '', 'HubbubMessage::create(friend_request '.$p->data['msgid'].')', 'OK', 'msgid failure'); $p->author($ne1->ds); $p->owner($ne2->ds); $p->sanitizeDataset(); // to se if sanitizeDataset() corrupts entries $p->sanitizeDataset(); tlog($p->authorEntity->ds['_key'] > 0, 'HubbubMessage->authorEntity key', 'OK ('.$p->authorEntity->ds['_key'].')', 'no key assigned'); tlog($p->authorEntity->ds['user'] == $p->data['author']['user'], 'HubbubMessage->authorEntity username', 'OK', 'not assigned'); tlog($p->ownerEntity->ds['_key'] > 0, 'HubbubMessage->ownerEntity', 'OK ('.$p->ownerEntity->ds['_key'].')', 'no key assigned');
<br/> <? $form = new CQForm('pwrecovery', array('auto-focus' => true)); $form ->add('password', 'new_pwd', array('onvalidate' => function($value, $e, $form) { $form->pwd = trim($value); if(strlen($form->pwd) < 5) return(l10n('email.password.tooshort')); else return(true); })) ->add('param', 'i', $_REQUEST['i']) ->add('submit', 'reset_pwd') ->ds($_REQUEST) ->receive(function($data, $form) { $uds = DB_GetDataset('idaccounts', $_REQUEST['i'], 'ia_recovery'); $uds['ia_password'] = md5($uds['ia_url'].$form->pwd); $uds['ia_recovery'] = ''; DB_UpdateDataset('idaccounts', $uds); object('user')->loginWithId($uds['ia_user']); print(l10n('email.password.reset').'<br/><br/><a href="'.actionUrl('index', 'home').'" class="btn">> OK</a>'); $form->hidden = true; }) ->display(); ?> </td> </tr> </table> </div>
<? $params['ia_recovery'] = randomHashId(); DB_UpdateDataset('idaccounts', $params); $subject = 'Recover Your Hubbub Password'; ?>Dear Hubbub user, you (or someone using your email address) requested that your Hubbub password on server <?php echo cfg('service/server'); ?> be reset. Please click on the following link to change it: <?php echo actionUrl('reset', 'signin', array('i' => $params['ia_recovery']), true); ?> If you did not request a reset, simply ignore this message. The request was made from the following IP address: <?php echo $_SERVER['REMOTE_HOST']; ?>
function save() { if ($this->ds['c_from'] == 0 && $this->ds['c_to'] == 0) { return; } if ($this->ds['c_toserverkey'] == 0) { $toEntity = new HubbubEntity(array('_key' => $this->ds['c_to'])); $this->ds['c_toserverkey'] = $toEntity->ds['_serverkey']; } DB_UpdateDataset('connections', $this->ds); }