本文整理汇总了PHP中XoopsTree::getAllParentId方法的典型用法代码示例。如果您正苦于以下问题:PHP XoopsTree::getAllParentId方法的具体用法?PHP XoopsTree::getAllParentId怎么用?PHP XoopsTree::getAllParentId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XoopsTree
的用法示例。
在下文中一共展示了XoopsTree::getAllParentId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
function store()
{
$myts =& MyTextSanitizer::getInstance();
$title = "";
$imgurl = "";
$topic_description=$myts->censorString($this->topic_description);
$topic_description= $myts->addSlashes($topic_description);
$topic_rssurl=$myts->addSlashes($this->topic_rssurl);
$topic_color=$myts->addSlashes($this->topic_color);
if ( isset($this->topic_title) && $this->topic_title != "" ) {
$title = $myts->addSlashes($this->topic_title);
}
if ( isset($this->topic_imgurl) && $this->topic_imgurl != "" ) {
$imgurl = $myts->addSlashes($this->topic_imgurl);
}
if ( !isset($this->topic_pid) || !is_numeric($this->topic_pid) ) {
$this->topic_pid = 0;
}
$topic_frontpage=intval($this->topic_frontpage);
$insert=false;
if ( empty($this->topic_id) ) {
$insert=true;
$this->topic_id = $this->db->genId($this->table."_topic_id_seq");
$sql = sprintf("INSERT INTO %s (topic_id, topic_pid, topic_imgurl, topic_title, menu, topic_description, topic_frontpage, topic_rssurl, topic_color) VALUES (%u, %u, '%s', '%s', %u, '%s', %d, '%s', '%s')", $this->table, intval($this->topic_id), intval($this->topic_pid), $imgurl, $title, intval($this->menu), $topic_description, $topic_frontpage, $topic_rssurl, $topic_color);
} else {
$sql = sprintf("UPDATE %s SET topic_pid = %u, topic_imgurl = '%s', topic_title = '%s', menu=%d, topic_description='%s', topic_frontpage=%d, topic_rssurl='%s', topic_color='%s' WHERE topic_id = %u", $this->table, intval($this->topic_pid), $imgurl, $title, intval($this->menu), $topic_description, $topic_frontpage, $topic_rssurl,$topic_color, intval($this->topic_id));
}
if ( !$result = $this->db->query($sql) ) {
// TODO: Replace with something else
ErrorHandler::show('0022');
} else {
if($insert) {
$this->topic_id = $this->db->getInsertId();
}
}
if ( $this->use_permission == true ) {
$xt = new XoopsTree($this->table, "topic_id", "topic_pid");
$parent_topics = $xt->getAllParentId($this->topic_id);
if ( !empty($this->m_groups) && is_array($this->m_groups) ){
foreach ( $this->m_groups as $m_g ) {
$moderate_topics = XoopsPerms::getPermitted($this->mid, "ModInTopic", $m_g);
$add = true;
// only grant this permission when the group has this permission in all parent topics of the created topic
foreach($parent_topics as $p_topic){
if ( !in_array($p_topic, $moderate_topics) ) {
$add = false;
continue;
}
}
if ( $add == true ) {
$xp = new XoopsPerms();
$xp->setModuleId($this->mid);
$xp->setName("ModInTopic");
$xp->setItemId($this->topic_id);
$xp->store();
$xp->addGroup($m_g);
}
}
}
if ( !empty($this->s_groups) && is_array($this->s_groups) ){
foreach ($this->s_groups as $s_g ) {
$submit_topics = XoopsPerms::getPermitted($this->mid, "SubmitInTopic", $s_g);
$add = true;
foreach($parent_topics as $p_topic){
if ( !in_array($p_topic, $submit_topics) ) {
$add = false;
continue;
}
}
if ( $add == true ) {
$xp = new XoopsPerms();
$xp->setModuleId($this->mid);
$xp->setName("SubmitInTopic");
$xp->setItemId($this->topic_id);
$xp->store();
$xp->addGroup($s_g);
}
}
}
if ( !empty($this->r_groups) && is_array($this->r_groups) ){
foreach ( $this->s_groups as $r_g ) {
$read_topics = XoopsPerms::getPermitted($this->mid, "ReadInTopic", $r_g);
$add = true;
foreach($parent_topics as $p_topic){
if ( !in_array($p_topic, $read_topics) ) {
$add = false;
continue;
}
}
if ( $add == true ) {
$xp = new XoopsPerms();
$xp->setModuleId($this->mid);
$xp->setName("ReadInTopic");
$xp->setItemId($this->topic_id);
$xp->store();
$xp->addGroup($r_g);
}
}
//.........这里部分代码省略.........
示例2: store
function store()
{
$myts =& MyTextSanitizer::getInstance();
$title = "";
$imgurl = "";
if (isset($this->topic_title) && $this->topic_title != "") {
$title = $myts->makeTboxData4Save($this->topic_title);
}
if (isset($this->topic_imgurl) && $this->topic_imgurl != "") {
$imgurl = $myts->makeTboxData4Save($this->topic_imgurl);
}
if (!isset($this->topic_pid) || !is_numeric($this->topic_pid)) {
$this->topic_pid = 0;
}
if (empty($this->topic_id)) {
$this->topic_id = $this->db->genId($this->table . "_topic_id_seq");
$sql = sprintf("INSERT INTO %s (topic_id, topic_pid, topic_imgurl, topic_title) VALUES (%u, %u, '%s', '%s')", $this->table, $this->topic_id, $this->topic_pid, $imgurl, $title);
} else {
$sql = sprintf("UPDATE %s SET topic_pid = %u, topic_imgurl = '%s', topic_title = '%s' WHERE topic_id = %u", $this->table, $this->topic_pid, $imgurl, $title, $this->topic_id);
}
if (!($result = $this->db->query($sql))) {
ErrorHandler::show('0022');
}
if ($this->use_permission == true) {
if (empty($this->topic_id)) {
$this->topic_id = $this->db->getInsertId();
}
$xt = new XoopsTree($this->table, "topic_id", "topic_pid");
$parent_topics = $xt->getAllParentId($this->topic_id);
if (!empty($this->m_groups) && is_array($this->m_groups)) {
foreach ($this->m_groups as $m_g) {
$moderate_topics = XoopsPerms::getPermitted($this->mid, "ModInTopic", $m_g);
$add = true;
// only grant this permission when the group has this permission in all parent topics of the created topic
foreach ($parent_topics as $p_topic) {
if (!in_array($p_topic, $moderate_topics)) {
$add = false;
continue;
}
}
if ($add == true) {
$xp = new XoopsPerms();
$xp->setModuleId($this->mid);
$xp->setName("ModInTopic");
$xp->setItemId($this->topic_id);
$xp->store();
$xp->addGroup($m_g);
}
}
}
if (!empty($this->s_groups) && is_array($this->s_groups)) {
foreach ($s_groups as $s_g) {
$submit_topics = XoopsPerms::getPermitted($this->mid, "SubmitInTopic", $s_g);
$add = true;
foreach ($parent_topics as $p_topic) {
if (!in_array($p_topic, $submit_topics)) {
$add = false;
continue;
}
}
if ($add == true) {
$xp = new XoopsPerms();
$xp->setModuleId($this->mid);
$xp->setName("SubmitInTopic");
$xp->setItemId($this->topic_id);
$xp->store();
$xp->addGroup($s_g);
}
}
}
if (!empty($this->r_groups) && is_array($this->r_groups)) {
foreach ($r_groups as $r_g) {
$read_topics = XoopsPerms::getPermitted($this->mid, "ReadInTopic", $r_g);
$add = true;
foreach ($parent_topics as $p_topic) {
if (!in_array($p_topic, $read_topics)) {
$add = false;
continue;
}
}
if ($add == true) {
$xp = new XoopsPerms();
$xp->setModuleId($this->mid);
$xp->setName("ReadInTopic");
$xp->setItemId($this->topic_id);
$xp->store();
$xp->addGroup($r_g);
}
}
}
}
return true;
}
示例3: getLocationHelper
/**
* Add locations to $this->locations
*
* @param int $topic_id
* @param int $offset integer to add to location
*
* @return void
*/
function getLocationHelper($topic_id)
{
include_once XOOPS_ROOT_PATH . "/class/xoopstree.php";
$tree = new XoopsTree($GLOBALS['xoopsDB']->prefix("topics"), "topic_id", "topic_pid");
$this->locations = $tree->getAllParentId($topic_id);
$this->locations[] = $topic_id;
}