Пример #1
0
 /**
  * Fetch whovoted a node
  * @param $nodeid
  * @param $private_message false => return only who voted on that node,
  * 		  true  => return node voters plus the current loged user link to the voters (subscribed/notsubscribed)
  *
  * @return array Array of users. An user is also an array contains userid, username, isadmin, ismoderator
  */
 public function fetchWhovoted($nodeid, $private_message = false)
 {
     $node = vB_Api::instanceInternal('node')->getNodeFullContent($nodeid);
     $node = $node[$nodeid];
     $this->checkCanUseRep($node);
     if (!vB::getUserContext()->hasPermission('genericpermissions', 'canseewholiked')) {
         throw new vB_Exception_Api('no_permission');
     }
     if ($private_message) {
         $currentUser = vB::getCurrentSession()->get('userid');
         $users = $this->assertor->getRows('vBForum:reputation_privatemsg_fetchwhovoted', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED, 'nodeid' => $node['nodeid'], 'currentuser' => $currentUser));
     } else {
         $users = $this->assertor->getRows('vBForum:reputation_fetchwhovoted', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED, 'nodeid' => $node['nodeid']));
     }
     foreach ($users as &$user) {
         $user['ismoderator'] = false;
         $user['isadmin'] = false;
         $userinfo = vB_User::fetchUserinfo($user['userid']);
         $user['usertitle'] = $userinfo['usertitle'];
         $usercontext =& vB::getUserContext($user['userid']);
         if ($usercontext->hasPermission('adminpermissions', 'ismoderator')) {
             $user['ismoderator'] = true;
         }
         if ($usercontext->hasAdminPermission('cancontrolpanel')) {
             $user['isadmin'] = true;
         }
         $user['avatarurl'] = vB_Api::instanceInternal('user')->fetchAvatar($user['userid']);
         $user['avatarurl'] = $user['avatarurl']['avatarpath'];
         $user['profileurl'] = vB5_Route::buildUrl('profile', array('userid' => $user['userid']));
         $user['musername'] = vB_Api::instanceInternal("user")->fetchMusername($user);
     }
     return $users;
 }
Пример #2
0
 /**
  * Fetches the IDs of the dismissed notices so we do not display them for the user.
  *
  * @return array
  */
 protected function fetchDismissedNotices()
 {
     static $dismissed_notices = null;
     if ($dismissed_notices === null) {
         $userinfo = vB::getCurrentSession()->fetch_userinfo();
         $dismissed_notices = array();
         if (!$userinfo['userid']) {
             return $dismissed_notices;
         }
         $noticeids = $this->assertor->getRows('vBForum:fetchdismissednotices', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED, 'userid' => $userinfo['userid']));
         foreach ($noticeids as $noticeid) {
             $dismissed_notices[] = $noticeid['noticeid'];
         }
     }
     return $dismissed_notices;
 }
Пример #3
0
 /**
  * Fetches the existing data for the selected user
  *
  * @return	array	Array of [selector][property] = value
  */
 function fetch_existing()
 {
     $usercss_result = $this->assertor->getRows('usercss', array('userid' => $this->userid), 'selector');
     $existing = array();
     foreach ($usercss_result as $usercss) {
         $existing["{$usercss['selector']}"]["{$usercss['property']}"] = $usercss['value'];
     }
     //$this->dbobject->free_result($usercss_result);
     return $existing;
 }
 /**
  * Select query builder / executer
  *
  * @param	mixed	condition value
  * @param	integer	condition type (reference: in this file define('USERCHANGELOG_COND_TYPE_*'))
  * @param	integer minimum time (UNIX_TIMESTAMP)
  * @param	integer maximum time (UNIX_TIMESTAMP)
  * @param	integer which page we want to select
  * @param	integer how many row on the page
  *
  * @return	mixed	sql query (no execute) / select resultset (execute + no just_count) / selected count (execute + just_count)
  */
 function sql_select_core($cond_value, $cond_type, $time_start, $time_end, $page, $limit)
 {
     $page = intval($page);
     $limit = intval($limit);
     $just_count = $this->just_count;
     $where = array();
     $where[vB_dB_Query::TYPE_KEY] = vB_dB_Query::QUERY_METHOD;
     // dbbject need for the escape string
     //		if (!is_object($this->registry) OR !is_object($this->registry->db))
     //		{
     //			trigger_error('Database object is not an object', E_USER_ERROR);
     //		}
     // let's create the where condition depend on the condition type
     switch ($cond_type) {
         // condition by userid
         case USERCHANGELOG_COND_TYPE_USERID:
             //$where = array();
             $where['userchangelog.userid'] = intval($cond_value);
             break;
             // condition by adminid
         // condition by adminid
         case USERCHANGELOG_COND_TYPE_ADMINID:
             //$where = array();
             $where['userchangelog.adminid'] = intval($cond_value);
             break;
             // condition by fieldname
         // condition by fieldname
         case USERCHANGELOG_COND_TYPE_FIELDNAME:
             //$where = array();
             $where['userchangelog.fieldname'] = strval($cond_value);
             break;
             // condition by username
         // condition by username
         case USERCHANGELOG_COND_TYPE_USERNAME:
             //$where = array();
             $where['userchangelog.fieldname'] = 'username';
             $where['userchangelog.oldvalue'] = strval($cond_value);
             $where['userchangelog.newvalue'] = strval($cond_value);
             break;
             // condition by time (do nothing just avoid the default case)
         // condition by time (do nothing just avoid the default case)
         case USERCHANGELOG_COND_TYPE_TIME:
             break;
             // unknown condition type, return an empty string
         // unknown condition type, return an empty string
         default:
             return '';
     }
     // when we have timeframe for the select then we add that to the condition
     if ($time_start) {
         $where['time_start'] = intval($time_start);
         // Send time_start for >= comparison
     }
     if ($time_end) {
         $where['time_end'] = intval($time_end);
         // Send time_end for <= comparison
     }
     $where[vB_dB_Query::PARAM_LIMITPAGE] = $page;
     $where[vB_dB_Query::PARAM_LIMIT] = $limit;
     // let's build the query if we got $where condition
     if ($where) {
         if ($just_count) {
             $where['just_count'] = $just_count;
             $result = $this->assertor->getRow('getChangelogData', $where);
             $result = $result['change_count'];
         } else {
             $result = $this->assertor->getRows('getChangelogData', $where);
         }
     }
     // execute: return with the select result
     /*if ($this->just_count)
     		{
     			$result = $this->registry->db->query_first($query);
     			return $result['change_count'];
     		}
     		else
     		{*/
     return $result;
     //}
 }