Пример #1
0
 /**
  * Adds a forum with parameters from $this->post
  *
  * @author Mark Elliot <*****@*****.**>
  * @since Beta 2.1
  * @return string Completion message
  **/
 function AddForum()
 {
     if (trim($this->post['name']) == '') {
         return "The forum name is empty. (Please press back and enter a name)";
     }
     $forums = $this->forum_grab();
     $forums_arr = $this->forum_array($forums, $this->post['parent']);
     $position = $forums_arr ? count($forums_arr) : 0;
     $this->db->query("INSERT INTO {$this->pre}forums\r\n\t\t(forum_tree, forum_parent, forum_name, forum_description, forum_position) VALUES\r\n\t\t('" . $this->CreateTree($forums, $this->post['parent']) . "', '{$this->post['parent']}', '{$this->post['name']}', '{$this->post['description']}', '{$position}')");
     $id = $this->db->insert_id();
     $perms = new permissions();
     $perms->db =& $this->db;
     $perms->pre =& $this->pre;
     while ($perms->get_group()) {
         // Full permissions (note: the banned group is still false)
         if ($this->post['sync'] == -2) {
             $perms->add_z($id, $perms->group != USER_BANNED);
             // Default permissions (only works if there are no forums already created)
         } elseif ($this->post['sync'] == -3) {
             $perms->add_z($id);
             // No permissions
         } elseif ($this->post['sync'] == -1) {
             $perms->add_z($id, false);
             // Copy another forum
         } else {
             $perms->add_z($id, false);
             foreach ($perms->standard as $perm => $false) {
                 if (!isset($perms->globals[$perm])) {
                     $perms->set_xyz($perm, $id, $perms->auth($perm, $this->post['sync']));
                 }
             }
         }
         $perms->update();
     }
     return "Forum added!<br/><br/><a href='{$this->self}'>Continue</a>";
 }
Пример #2
0
 /**
  * Creates a category or forum
  *
  * @param string $name Name of the forum
  * @param string $desc Description of the forum
  * @param int $parent Parent id of the forum (0 if a category)
  * @author Geoffrey Dunn <*****@*****.**>
  * @since 1.1.9
  * @return int id of the forum created
  **/
 function create_forum($name, $desc, $parent)
 {
     $parent ? $tree = $parent : ($tree = '');
     $this->db->query("INSERT INTO {$this->pre}forums\n\t\t\t(forum_tree, forum_parent, forum_name, forum_description, forum_position, forum_subcat) VALUES\n\t\t\t('{$tree}', '{$parent}', '{$name}', '{$desc}', '0', '0')");
     $forumId = $this->db->insert_id();
     $perms = new permissions();
     $perms->db =& $this->db;
     $perms->pre =& $this->pre;
     while ($perms->get_group()) {
         if (!$parent) {
             // Default permissions
             $perms->add_z($forumId);
         } else {
             // Copy permissions
             $perms->add_z($forumId, false);
             foreach ($perms->standard as $perm => $false) {
                 if (!isset($perms->globals[$perm])) {
                     $perms->set_xyz($perm, $forumId, $perms->auth($perm, $parent));
                 }
             }
         }
         $perms->update();
     }
     return $forumId;
 }