public function push() { global $auth, $log, $db; //$log = new Logger('Ec2'); $log->write('info', 'Starting project update'); $db = new dbConnection(); if ($this->checkPermission($auth->getEcUserId()) >= 2) { $log->write('info', 'User has permission'); $res = $db->beginTransaction(); if ($res !== true) { return $res; } $log->write('info', 'transaction started'); $res = $db->do_query("UPDATE Project SET description = " . $db->stringVal($this->description) . ", image = " . $db->stringVal($this->image) . ",\n\t\t\t\t\t\t\t\t\t isPublic = " . $db->boolVal($this->isPublic) . ", isListed = " . $db->boolVal($this->isListed) . ",\n\t\t\t\t\t\t\t\t\tpublicSubmission = " . $db->boolVal($this->publicSubmission) . "\tWHERE id = {$this->id} AND name = '{$this->name}'"); if ($res !== true) { return $res; } $log->write('info', 'Project details updated'); foreach ($this->tables as $tbl) { $log->write('info', "Updating form {$tbl->name}"); $res = $tbl->update(); if ($res !== true) { $log->write('error', "Updating form {$tbl->name} failed {$res}"); $db->rollbackTransaction(); return $res; } $log->write('info', "Updated form {$tbl->name}"); } $db->commitTransaction(); $log->write('info', "Update done"); return true; } else { return "You do not have permission to update this project"; } }