// Class ttSysConfig is used for storing and retrieving named values associated with users.
class ttSysConfig {
- var $u_id = null;
+ var $user_id = null;
+ var $group_id = null;
+ var $org_id = null;
var $mdb2 = null;
// Constructor.
- function __construct($u_id) {
- $this->u_id = $u_id;
+ function __construct($user_id) {
+ global $user;
+ $this->user_id = $user_id; // TODO: review "on behalf" situation and refactor if necessary.
+ $this->group_id = $user->getActiveGroup();
+ $this->org_id = $user->org_id;
$this->mdb2 = getConnection();
}
// The getValue retrieves a value identified by name.
function getValue($name) {
- $res = $this->mdb2->query("select param_value from tt_config where user_id = ".$this->u_id." and param_name=".$this->mdb2->quote($name));
+ $res = $this->mdb2->query("select param_value from tt_config where user_id = ".$this->user_id." and param_name=".$this->mdb2->quote($name));
if (!is_a($res, 'PEAR_Error')) {
$val = $res->fetchRow();
return $val['param_value'];
// The setValue sets a value identified by name.
function setValue($name, $value) {
$rcnt = 0;
- $res = $this->mdb2->query("select count(*) as rcnt from tt_config where user_id = ".$this->u_id." and param_name = ".$this->mdb2->quote($name));
+ $res = $this->mdb2->query("select count(*) as rcnt from tt_config where user_id = ".$this->user_id." and param_name = ".$this->mdb2->quote($name));
if ($val = $res->fetchRow()) $rcnt = $val['rcnt'];
if ($rcnt > 0) {
- $affected = $this->mdb2->exec("update tt_config set param_value = ".$this->mdb2->quote($value)." where user_id = ".$this->u_id." and param_name=".$this->mdb2->quote($name));
+ $affected = $this->mdb2->exec("update tt_config set param_value = ".$this->mdb2->quote($value)." where user_id = ".$this->user_id." and param_name=".$this->mdb2->quote($name));
} else {
- $affected = $this->mdb2->exec("insert into tt_config set param_value = ".$this->mdb2->quote($value).", param_name = ".$this->mdb2->quote($name).", user_id = ".$this->u_id);
+ $sql = "insert into tt_config set param_value = ".$this->mdb2->quote($value).
+ ", param_name = ".$this->mdb2->quote($name).", user_id = ".$this->user_id.", group_id = ".$this->group_id.", org_id = ".$this->org_id;
+ $affected = $this->mdb2->exec($sql);
}
return (!is_a($affected, 'PEAR_Error'));
}
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.18.22.4464 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.18.22.4465 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
setChange("ALTER TABLE `tt_config` ADD `group_id` int(11) default NULL AFTER `user_id`");
setChange("ALTER TABLE `tt_config` ADD `org_id` int(11) default NULL AFTER `group_id`");
setChange("UPDATE `tt_site_config` SET param_value = '1.18.22', modified = now() where param_name = 'version_db' and param_value = '1.18.21'");
+ setChange("update `tt_config` c inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.18.22') inner join `tt_users` u on u.id = c.user_id set c.group_id = u.group_id, c.org_id = u.org_id where c.org_id is null");
}
if ($_POST["cleanup"]) {