add methods to userAdapter to get/set "order_master"

This commit is contained in:
jygaulier
2013-05-07 17:59:56 +02:00
parent a281f878fc
commit f7e203089a

View File

@@ -1023,6 +1023,37 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return $this->ftp_dir_prefix; return $this->ftp_dir_prefix;
} }
/**
* get array of base_id's on which the user is 'order master'
*
* @return array
*/
public function get_order_master_bids()
{
$sql = 'SELECT base_id FROM basusr WHERE order_master=\'1\' AND usr_id= :id ';
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':id' => $this->id));
$row = $stmt->fetchAll(PDO::FETCH_COLUMN);
$stmt->closeCursor();
foreach($row as $k=>$v)
$row[$k] = (int)$v;
return $row;
}
/**
* set the user as "order_master" on a collection
*
* @param int $bid
*/
public function set_order_master($bid)
{
$sql = 'UPDATE basusr SET order_master=\'1\' WHERE usr_id= :id AND base_id= :bid';
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':id' => $this->id, 'bid' => $bid));
$stmt->closeCursor();
}
/** /**
* *
* @param <type> $id * @param <type> $id