PHP Code:
function searchAllPriveleges__ByRoleId($id = 0) { # privelege id 'null' by default
$sql = "SELECT
rolepriveleges.roleid,
rolepriveleges.privid,
priveleges.privid AS ID,
priveleges.privdescrip AS DESCRIP
FROM
rolepriveleges, priveleges
WHERE
rolepriveleges.roleid = '". $id ."'
AND
rolepriveleges.privid = priveleges.privid ORDER BY priveleges.privid";
return $this -> retrieve($sql);
}
function & totalRows() {
$sql = "SELECT COUNT(*) FROM roles";
return $this -> retrieve($sql);
}
function searchAll() {
$sql = "SELECT * FROM roles ORDER BY roleid";
return $this -> retrieve($sql);
}
function searchAllRoles__ByAuthorId($id = 0) { # role id 'null' by default
$sql = "SELECT
authorroles.authid,
authorroles.roleid,
roles.roleid AS ID,
roles.rolelimit AS CAP,
roles.roledescrip AS DESCRIP
FROM
authorroles, roles
WHERE
authorroles.authid = '". $id ."'
AND
authorroles.roleid = roles.roleid ORDER BY roles.roleid";
return $this -> retrieve($sql);
}
function searchAll__LogsByCommentId($id) { #
$sql = "SELECT
logs.logid AS LOGID,
logs.logdate AS LOGDATE,
logs.logtitle AS LOGTITLE,
authors.authid AS AUTHID,
authors.authfname AS AUTHFNAME,
authors.authlname AS AUTHLNAME,
authorlogs.logid, authorlogs.authid,
usercomments.commentid, usercomments.logid
FROM
logs, authors, authorlogs, usercomments
WHERE
usercomments.commentid = '". $id ."'
AND
usercomments.logid = logs.logid
AND
authorlogs.logid = logs.logid
AND
authorlogs.authid = authors.authid";
return $this -> retrieve($sql);
}
function searchAll__ByLogDate($param = '') { #
$sql = "SELECT
logs.logid AS LOGID,
logs.logdate AS LOGDATE,
logs.logtitle AS LOGTITLE,
logs.logmessage AS LOGMESSAGE,
logs.logstatus AS LOGSTATUS,
logs.logacceptance AS LOGACCEPT,
authors.authid AS AUTHID,
authors.authfname AS AUTHFNAME,
authors.authlname AS AUTHLNAME,
authorlogs.logid, authorlogs.authid
FROM
logs, authors, authorlogs
WHERE
authorlogs.authid = authors.authid
AND
authorlogs.logid = logs.logid
ORDER BY logs.logdate DESC" . $param;
return $this -> retrieve($sql);
}
function searchAll__ByLogId($id = 0) { # get all log and author by logid
$sql = "SELECT
logs.logid AS LOGID,
logs.logdate AS LOGDATE,
logs.logtitle AS LOGTITLE,
logs.logmessage AS LOGMESSAGE,
logs.logstatus AS LOGSTATUS,
logs.logacceptance AS LOGACCEPT,
authors.authid AS AUTHID,
authors.authfname AS AUTHFNAME,
authors.authlname AS AUTHLNAME,
authorlogs.logid, authorlogs.authid
FROM
logs, authors, authorlogs
WHERE
authorlogs.logid = '". $id ."'
AND
authorlogs.authid = authors.authid
AND
authorlogs.logid = logs.logid
ORDER BY logs.logdate DESC";
return $this -> retrieve($sql);
}
function searchAll__ByAllResults($id = 0, $param = '') { # $id (ie all comments based on one logid - not required here)
$sql = "SELECT
logs.logid AS LOGID,
logs.logdate AS LOGDATE,
logs.logtitle AS LOGTITLE,
logs.logmessage AS LOGMESSAGE,
logs.logstatus AS LOGSTATUS,
logs.logacceptance AS LOGACCEPT,
authors.authid AS AUTHID,
authors.authfname AS AUTHFNAME,
authors.authlname AS AUTHLNAME,
authorlogs.logid, authorlogs.authid
FROM
logs, authors, authorlogs
WHERE
authorlogs.authid = authors.authid
AND
authorlogs.logid = logs.logid
ORDER BY logs.logdate DESC". $param;
return $this -> retrieve($sql);
}
function insert__AddNewLog($title, $message, $notes, $status, $comments, $authid) { #
$sql = "INSERT INTO logs SET
logdate = now(),
logtitle = '". $title ."',
logmessage = '". $message ."',
logstatus = '". $status ."',
logacceptance = '". $comments ."'";
$this -> update($sql);
$insert = (int) mysql_insert_id(); // logid
$sql = "INSERT INTO authorlogs SET
logid = '". $insert ."',
authid = '". $authid ."'";
$this -> update($sql);
$sql = "INSERT INTO authornotes SET
logid = '". $insert ."',
authid = '". $authid ."',
authnotes = '". $notes ."'";
$this -> update($sql);
}
}
...
Bookmarks