本文整理汇总了PHP中mysqlquery::runsql2方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqlquery::runsql2方法的具体用法?PHP mysqlquery::runsql2怎么用?PHP mysqlquery::runsql2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysqlquery
的用法示例。
在下文中一共展示了mysqlquery::runsql2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkSharedRights
function checkSharedRights($shareId)
{
if (!strlen($this->parentData['item_id'])) {
echo '<script type="text/javascript">alert("Error: No parent found.")</script>';
exit;
} else {
// Check shareid and itemid match
$query = "SELECT {$_SESSION['RealS_prefix']}share.*, {$_SESSION['RealS_prefix']}subjects.*, {$_SESSION['RealS_prefix']}share_type.*, {$_SESSION['RealS_prefix']}cohorts.cohort_name, {$_SESSION['RealS_prefix']}members.mb_type\r\n\t\t\t FROM {$_SESSION['RealS_prefix']}share\r\n\t \t\t \tLEFT JOIN {$_SESSION['RealS_prefix']}members ON {$_SESSION['RealS_prefix']}members.mb_id = {$_SESSION['RealS_prefix']}share.share_member\r\n\t\t\t \tLEFT JOIN {$_SESSION['RealS_prefix']}share_cohort ON {$_SESSION['RealS_prefix']}share_cohort.share_cohort_share = {$_SESSION['RealS_prefix']}share.share_id\r\n\t\t\t \tLEFT JOIN {$_SESSION['RealS_prefix']}cohorts ON {$_SESSION['RealS_prefix']}cohorts.cohort_id = {$_SESSION['RealS_prefix']}share_cohort.share_cohort_cohort\r\n\t\t\t \tLEFT JOIN {$_SESSION['RealS_prefix']}subjects ON {$_SESSION['RealS_prefix']}share.share_subject = {$_SESSION['RealS_prefix']}subjects.subject_id\r\n\t\t\t \tLEFT JOIN {$_SESSION['RealS_prefix']}share_type ON {$_SESSION['RealS_prefix']}share_type.invite_type_id = {$_SESSION['RealS_prefix']}share.share_type\r\n\t\t\t WHERE share_item = " . $this->parentData['item_id'] . "\r\n\t\t\t \tAND share_id = " . $shareId;
$mysql = new mysqlquery();
$share_data = $mysql->runsql($query);
$this->shareData = $share_data[0];
$this->sharePublic = $share_data[0]['share_public'];
$this->shareType = $share_data[0]['invite_type_name'];
$this->cohortName = $share_data[0]['cohort_name'];
// Debugging
//die($query);
$_SESSION['RealS_usertype'] = 'learner';
// Check share rights
if (!strlen($_SESSION['USER']->id) && $this->sharePublic == 0) {
// Not logged in and not public
require_once "main/failed.php";
exit(0);
} elseif (count($this->shareData) == 0) {
// Wrong share id
echo '<script type="text/javascript">alert(\'Wrong share id.\')</script>';
exit;
} elseif ($this->shareData['share_active'] == "PENDING" || $this->shareData['share_active'] == "DECLINED") {
// Not accepted
echo '<script type="text/javascript">alert(\'You can not view a ' . $this->shareData['share_active'] . ' share. Please check your sharing request status for this item.\')</script>';
exit;
} elseif (strlen($_SESSION['USER']->id)) {
if ($this->shareData['share_member'] == $_SESSION['USER']->id) {
// You are the sharer
$this->shareComment = 1;
$this->sharer = 1;
if ($this->shareData['mb_type'] == 'mentor') {
$this->shareMentor = 1;
$_SESSION['RealS_usertype'] = 'mentor';
}
} else {
if ($this->shareData['share_permission'] == $_SESSION['USER']->id) {
// You are the request mentor
$this->shareComment = 1;
$this->shareMentor = 1;
$_SESSION['RealS_usertype'] = 'mentor';
} else {
if (isset($_SESSION['USER']->id)) {
// Check if you are an additional share mentor
$query = "SELECT {$_SESSION['RealS_prefix']}share_mentor.share_mentor_mentor, {$_SESSION['RealS_prefix']}share_mentor.share_mentor_status\r\n\t\t\t\t\t FROM {$_SESSION['RealS_prefix']}share\r\n\t\t\t\t\t INNER JOIN {$_SESSION['RealS_prefix']}share_mentor ON {$_SESSION['RealS_prefix']}share.share_id = {$_SESSION['RealS_prefix']}share_mentor.share_mentor_share\r\n\t\t\t\t\t WHERE {$_SESSION['RealS_prefix']}share_mentor.share_mentor_mentor = " . $_SESSION['USER']->id . "\r\n\t\t\t\t\t AND {$_SESSION['RealS_prefix']}share_mentor.share_mentor_share=" . $shareId;
// Debugging
//die($query . '-' . $_SESSION['USER']->id);
$mysql = new mysqlquery();
$result = $mysql->runsql($query);
if (count($result) > 0) {
// You are an additional mentor of this item
$this->shareComment = 1;
$this->shareMentor = 1;
$_SESSION['RealS_usertype'] = 'mentor';
if ($result[0]['share_mentor_mentor'] == $_SESSION['USER']->id && $result[0]['share_mentor_status'] == 'NEW') {
// Update status
$query = "UPDATE {$_SESSION['RealS_prefix']}share_mentor\r\n\t\t\t\t\t\t\t SET share_mentor_status = 'OLD'\r\n\t\t\t\t\t\t\t WHERE share_mentor_share = " . $this->shareData['share_id'] . "\r\n\t\t\t\t\t\t\t AND share_mentor_mentor = " . $_SESSION['USER']->id;
$mysql = new mysqlquery();
$result = $mysql->runsql2($query);
}
}
}
}
}
}
// Allow public shares
if (strlen($_SESSION['USER']->id)) {
// Update sharer status
if ($this->shareData['share_member'] == $_SESSION['USER']->id && $this->shareData['share_status'] == 'NEW') {
//update status
$query = "UPDATE {$_SESSION['RealS_prefix']}share\r\n\t\t\t\t\t SET share_status = 'OLD'\r\n\t\t\t\t\t WHERE share_id = " . $this->shareData['share_id'];
$mysql = new mysqlquery();
$result = $mysql->runsql2($query);
}
// Check if you are part of cohort
$query = "SELECT {$_SESSION['RealS_prefix']}share_cohort_members.s_c_m_member, {$_SESSION['RealS_prefix']}share_cohort_members.s_c_m_status\r\n\t\t\t\t FROM {$_SESSION['RealS_prefix']}share\r\n\t\t\t\t \tINNER JOIN {$_SESSION['RealS_prefix']}share_cohort_members ON {$_SESSION['RealS_prefix']}share.share_id = {$_SESSION['RealS_prefix']}share_cohort_members.s_c_m_share\r\n\t\t\t\t WHERE {$_SESSION['RealS_prefix']}share_cohort_members.s_c_m_member = " . $_SESSION['USER']->id . "\r\n\t\t\t\t \tAND {$_SESSION['RealS_prefix']}share.share_id = " . $shareId;
$mysql = new mysqlquery();
$result = $mysql->runsql($query);
if (count($result) > 0) {
// This is shared with you
$this->shareComment = 1;
$this->shareMember = 1;
if ($result[0]['s_c_m_member'] == $_SESSION['USER']->id && $result[0]['s_c_m_status'] == 'NEW') {
// Update cohort member status
$query = "UPDATE {$_SESSION['RealS_prefix']}share_cohort_members\r\n\t\t\t\t\t\t SET s_c_m_status = 'OLD'\r\n\t\t\t\t\t\t WHERE s_c_m_share = " . $this->shareData['share_id'] . "\r\n\t\t\t\t\t\t AND s_c_m_member = " . $_SESSION['USER']->id;
$mysql = new mysqlquery();
$result = $mysql->runsql2($query);
}
} else {
if ($this->sharer == 0 && $this->shareMentor == 0 && $this->sharePublic == 0) {
// Nothing to do with you and not public
echo '<script type="text/javascript">alert(\'You may need to login to view this page.\')</script>';
exit;
}
}
}
//.........这里部分代码省略.........