コード例 #1
0
 /**
  * Loads and parses an XML file into the $this->xml property.
  *
  * @param string The name of the item (page, route, pagetemplate) to load
  */
 protected function loadXmlFile($itemname)
 {
     $filename = "vbulletin-{$itemname}s.xml";
     $xml = vB_Xml_Import::parseFile("{$this->xmldir}/{$filename}");
     $items = array();
     foreach ($xml[$itemname] as $item) {
         $items[$item['guid']] = $item;
     }
     $this->fileVersions[$filename] = $xml['vbversion'];
     return $items;
 }
コード例 #2
0
ファイル: import.php プロジェクト: cedwards-reisys/nexus-web
 /**
  * Imports objects from the specified filepath
  * @param string $filepath
  * @param string $guid Only import the record associated with this guid
  */
 public function importFromFile($filepath, $guid = false)
 {
     $this->parsedXML = vB_Xml_Import::parseFile($filepath);
     $this->import($guid);
 }
コード例 #3
0
ファイル: channel.php プロジェクト: cedwards-reisys/nexus-web
 protected function import()
 {
     if (empty($this->parsedXML['channel'])) {
         $this->parsedXML['channel'] = array();
     }
     $this->checkRoutes();
     $this->checkParents();
     $channels = is_array($this->parsedXML['channel'][0]) ? $this->parsedXML['channel'] : array($this->parsedXML['channel']);
     //On an upgrade from Pre-vB5 the datastore won't exist yet. So we can't get the bitfields from there.
     $parsedRaw = vB_Xml_Import::parseFile(DIR . '/includes/xml/bitfield_vbulletin.xml');
     $forumpermissions = $forumpermissions2 = $moderatorpermissions = $createpermissions = $adminpermissions = $albumpermissions = $socialgrouppermissions = array();
     foreach ($parsedRaw['bitfielddefs']['group'] as $group) {
         if ($group['name'] == 'ugp') {
             foreach ($group['group'] as $bfgroup) {
                 switch ($bfgroup['name']) {
                     case 'forumpermissions':
                         foreach ($bfgroup['bitfield'] as $bitfield) {
                             $forumpermissions[$bitfield['name']] = intval($bitfield['value']);
                         }
                         break;
                     case 'forumpermissions2':
                         foreach ($bfgroup['bitfield'] as $bitfield) {
                             $forumpermissions2[$bitfield['name']] = intval($bitfield['value']);
                         }
                         break;
                     case 'adminpermissions':
                         foreach ($bfgroup['bitfield'] as $bitfield) {
                             $adminpermissions[$bitfield['name']] = intval($bitfield['value']);
                         }
                         break;
                     case 'albumpermissions':
                         foreach ($bfgroup['bitfield'] as $bitfield) {
                             $albumpermissions[$bitfield['name']] = intval($bitfield['value']);
                         }
                         break;
                     case 'createpermissions':
                         foreach ($bfgroup['bitfield'] as $bitfield) {
                             $createpermissions[$bitfield['name']] = intval($bitfield['value']);
                         }
                         break;
                     case 'socialgrouppermissions':
                         foreach ($bfgroup['bitfield'] as $bitfield) {
                             $socialgrouppermissions[$bitfield['name']] = intval($bitfield['value']);
                         }
                 }
             }
         } else {
             if ($group['name'] == 'misc') {
                 foreach ($group['group'] as $bfgroup) {
                     if ($bfgroup['name'] == 'moderatorpermissions') {
                         foreach ($bfgroup['bitfield'] as $bitfield) {
                             $moderatorpermissions[$bitfield['name']] = intval($bitfield['value']);
                         }
                     }
                 }
             }
         }
     }
     $this->bf_administratorpermissions = $adminpermissions;
     $this->bf_moderatorpermissions = $moderatorpermissions;
     $this->bf_forumpermissions = $forumpermissions;
     $this->bf_forumpermissions2 = $forumpermissions2;
     $this->bf_albumpermissions = $albumpermissions;
     $this->bf_socialgrouppermissions = $socialgrouppermissions;
     $this->contenttypes = $createpermissions;
     $usergroups = vB::getDbAssertor()->assertQuery('usergroup', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT));
     foreach ($usergroups as $usergroup) {
         if ($usergroup['systemgroupid'] == vB_Api_UserGroup::CHANNEL_MEMBER_SYSGROUPID) {
             $blogMemberGroupId = $usergroup['usergroupid'];
         } else {
             if ($usergroup['systemgroupid'] == vB_Api_UserGroup::CHANNEL_MEMBER_SYSGROUPID) {
                 $sgMemberGroupId = $usergroup['usergroupid'];
             } else {
                 if ($usergroup['systemgroupid'] == vB_Api_UserGroup::CHANNEL_OWNER_SYSGROUPID) {
                     $channelOwnerGroupId = $usergroup['usergroupid'];
                 }
             }
         }
     }
     $registeredGroupId = 2;
     $unRegisteredGroupId = 1;
     $rootPerms = $this->buildRootPerms();
     $sgperms = array();
     foreach ($rootPerms as $ug => $value) {
         foreach ($value as $perms => $bitvalue) {
             if ($perms === 'socialgrouppermissions') {
                 $sgperms[$ug]['socialgrouppermissions'] = $bitvalue;
                 unset($rootPerms[$ug]['socialgrouppermissions']);
                 break;
             }
         }
     }
     $channelLib = vB_Library::instance('content_channel');
     $channelPerm = vB_ChannelPermission::instance();
     foreach ($channels as $channel) {
         if (isset($channel['installonly'])) {
             if (defined('VB_AREA') and VB_AREA != 'Install' and $channel['installonly']) {
                 // this channel is only added during install, so skip it
                 continue;
             }
             unset($channel['installonly']);
         }
         $data = array_merge($channel, $channel['node']);
         unset($data['node']);
         if (isset($channel['node']['routeguid']) and isset($this->referencedRoutes[$channel['node']['routeguid']])) {
             $data['routeid'] = $this->referencedRoutes[$channel['node']['routeguid']];
         }
         if (isset($channel['node']['parentguid']) and !empty($channel['node']['parentguid']) and ($parentId = $this->referencedParents[$channel['node']['parentguid']] or $parentId = vB_Xml_Import::getImportedId(vB_Xml_Import::TYPE_CHANNEL, $channel['node']['parentguid']))) {
             $data['parentid'] = $parentId;
         }
         $channelId = 0;
         $condition = array('guid' => $channel['guid']);
         // TODO: after talking with Ed, we decided it might be best not to allow node removal at all. Need to confirm with Kevin
         if ($oldChannel = $this->db->getRow('vBForum:channel', $condition)) {
             $channelId = $oldChannel['nodeid'];
         }
         if (empty($channelId)) {
             // We cannot use the API method for adding the root channel, since it requires a parentid.
             if (!isset($data['parentid'])) {
                 $channelContentTypeId = vB_Api::instanceInternal('contenttype')->fetchContentTypeIdFromClass('Channel');
                 $userId = vB::getCurrentSession()->get('userid');
                 // get all columns but the key
                 $channelTable = $this->db->fetchTableStructure('vbforum:channel');
                 $channelTableColumns = array_diff($channelTable['structure'], array($channelTable['key']));
                 $nodeTable = $this->db->fetchTableStructure('vbforum:node');
                 $nodeTableColumns = array_diff($nodeTable['structure'], array($nodeTable['key'], $channelTable['key']));
                 // insert root node
                 $nodeValues = array('userid' => $userId, 'contenttypeid' => $channelContentTypeId);
                 foreach ($nodeTableColumns as $col) {
                     if (isset($channel['node'][$col])) {
                         $nodeValues[$col] = $channel['node'][$col];
                     }
                 }
                 if (isset($data['routeid'])) {
                     $nodeValues['routeid'] = $data['routeid'];
                 }
                 $channelId = $this->db->insertIgnore('vBForum:node', $nodeValues);
                 if (is_array($channelId)) {
                     $channelId = array_pop($channelId);
                 }
                 // continue only if the node could be inserted
                 if ($channelId) {
                     $values = array();
                     foreach ($channelTableColumns as $col) {
                         if (isset($channel[$col])) {
                             $values[$col] = $channel[$col];
                         }
                     }
                     $values['nodeid'] = $channelId;
                     $this->db->insert('vBForum:channel', $values);
                 }
                 // insert in closure
                 $this->db->insert('vBForum:closure', array('parent' => $channelId, 'child' => $channelId, 'depth' => 0));
                 foreach ($rootPerms as $groupPerm) {
                     $channelPerm->setPermissions($channelId, $groupPerm['groupid'], $groupPerm, true);
                 }
             } else {
                 $response = $channelLib->add($data, array('nodeonly' => true, 'skipFloodCheck' => true, 'skipNotification' => true, 'skipDupCheck' => true));
                 $channelId = $response['nodeid'];
             }
         } else {
             /* Apparently routeid gets changed every update .... */
             if (isset($channel['node']['routeguid']) and isset($this->referencedRoutes[$channel['node']['routeguid']])) {
                 $data['routeid'] = $this->referencedRoutes[$channel['node']['routeguid']];
             }
         }
         if (is_array($channelId)) {
             $channelId = array_pop($channelId);
         }
         /* VBV-2536, $oldChannel check. This is to stop the
         			import blindly resetting permissions on every update */
         if (!$oldChannel and !empty($channelId)) {
             /* We don't know what usergroups exist currently. There may be the groups 1-8 we create on a new install,
             			 or there may not. If a group exists it may have a different meaning from what we create on a new install.
             			So here's what we have decided:
             			1) At root if there is at least one forum permission record:
             				a) you get any permissions you have in any existing root forum.
             				b) If you have "albumpermissions -> canalbum" you can create albums and photos.
             				c) If you have adminpermissions->canadminforums you can create channels.
             				d) If you can forumpermissions->canpostnew you can create all the other types
             			2) If the forumpermissions doesn't exist or is empty, treat this as a new install. Take the permissions
             				from the xml file, taking the id as systemgroupid.
             			3) At root everybody can create private messages.
             			4) 	For the blog and social groups channels, we have newly created usergroups with systemgroupid. Those two channels
             			are specified in the xml file.
             			5) For all other usergroups in those two channels-
             				a) if you have moderator permission canmoderateposts, no record. Just inherit.
             				b) otherwise, get your root permissions plus channel
             			6) For the report channel- if you have moderator permission canmoderateposts anywhere on the site
             				you inherit permissions. Otherwise you have none.
             			*/
             vB_Xml_Import::setImportedId(vB_Xml_Import::TYPE_CHANNEL, $channel['guid'], $channelId);
             switch ($data['guid']) {
                 case vB_Channel::DEFAULT_BLOG_PARENT:
                     foreach ($rootPerms as $groupPerm) {
                         $thisPerm = $groupPerm;
                         if ($groupPerm['createpermissions'] > 0) {
                             $thisPerm['createpermissions'] = $groupPerm['createpermissions'] | $this->contenttypes['vbforum_channel'];
                         }
                         //These four groups should not be able to start threads in the blog and social group channels.
                         if ($groupPerm['groupid'] == $blogMemberGroupId or $groupPerm['groupid'] == $sgMemberGroupId or $groupPerm['groupid'] == $registeredGroupId or $groupPerm['groupid'] == $unRegisteredGroupId) {
                             $thisPerm['forumpermissions'] = $thisPerm['forumpermissions'] & ~$forumpermissions['canpostnew'];
                             // but they should be able to reply to others' threads
                             $thisPerm['forumpermissions'] |= $forumpermissions['canreply'];
                             $thisPerm['createpermissions'] |= $this->contenttypes['vbforum_text'];
                             $thisPerm['forumpermissions2'] |= $forumpermissions2['cancomment'];
                         }
                         //Let the channel owner configure his/her channel
                         if ($groupPerm['groupid'] == $channelOwnerGroupId) {
                             $thisPerm['forumpermissions2'] |= $forumpermissions2['canconfigchannel'] | $forumpermissions2['candeletechannel'];
                             $thisPerm['forumpermissions'] |= $forumpermissions2['canuploadchannelicon'] | $forumpermissions2['candeletechannel'];
                         }
                         $channelPerm->setPermissions($channelId, $groupPerm['groupid'], $thisPerm, true);
                     }
                     break;
                 case vB_Channel::DEFAULT_SOCIALGROUP_PARENT:
                     foreach ($rootPerms as $groupPerm) {
                         $thisPerm = $groupPerm;
                         if ($groupPerm['createpermissions'] > 0) {
                             $thisPerm['createpermissions'] = $groupPerm['createpermissions'] | $this->contenttypes['vbforum_channel'];
                             if ($groupPerm['systemgroupid'] == vB_Api_UserGroup::CHANNEL_OWNER_SYSGROUPID or $groupPerm['systemgroupid'] == vB_Api_UserGroup::CHANNEL_MODERATOR_SYSGROUPID or $groupPerm['systemgroupid'] == vB_Api_UserGroup::CHANNEL_MEMBER_SYSGROUPID or $groupPerm['systemgroupid'] == vB_Api_UserGroup::ADMINISTRATOR or $groupPerm['systemgroupid'] == vB_Api_UserGroup::SUPER_MODERATOR) {
                                 $thisPerm['createpermissions'] |= $this->contenttypes['vbforum_text'];
                                 $thisPerm['createpermissions'] |= $this->contenttypes['vbforum_report'];
                                 //$thisPerm['createpermissions'] |= $this->contenttypes['vbforum_calendar'];
                                 $thisPerm['createpermissions'] |= $this->contenttypes['vbforum_gallery'];
                                 $thisPerm['createpermissions'] |= $this->contenttypes['vbforum_poll'];
                                 $thisPerm['createpermissions'] |= $this->contenttypes['vbforum_attach'];
                                 $thisPerm['createpermissions'] |= $this->contenttypes['vbforum_photo'];
                                 $thisPerm['createpermissions'] |= $this->contenttypes['vbforum_privatemessage'];
                                 $thisPerm['createpermissions'] |= $this->contenttypes['vbforum_video'];
                                 $thisPerm['createpermissions'] |= $this->contenttypes['vbforum_link'];
                             } else {
                                 $thisPerm['createpermissions'] &= ~$this->contenttypes['vbforum_text'];
                                 $thisPerm['createpermissions'] &= ~$this->contenttypes['vbforum_report'];
                                 //$thisPerm['createpermissions'] &= ~$this->contenttypes['vbforum_calendar'];
                                 $thisPerm['createpermissions'] &= ~$this->contenttypes['vbforum_gallery'];
                                 $thisPerm['createpermissions'] &= ~$this->contenttypes['vbforum_poll'];
                                 $thisPerm['createpermissions'] &= ~$this->contenttypes['vbforum_attach'];
                                 $thisPerm['createpermissions'] &= ~$this->contenttypes['vbforum_photo'];
                                 $thisPerm['createpermissions'] &= ~$this->contenttypes['vbforum_privatemessage'];
                                 $thisPerm['createpermissions'] &= ~$this->contenttypes['vbforum_video'];
                                 $thisPerm['createpermissions'] &= ~$this->contenttypes['vbforum_link'];
                             }
                             $rootPerms[$groupPerm['groupid']] = $thisPerm;
                         }
                         //These four groups should not be able to start threads in the blog and social group channels.
                         if ($groupPerm['groupid'] == $blogMemberGroupId or $groupPerm['groupid'] == $sgMemberGroupId or $groupPerm['groupid'] == $registeredGroupId or $groupPerm['groupid'] == $unRegisteredGroupId) {
                             $thisPerm['forumpermissions'] = $thisPerm['forumpermissions'] & ~$forumpermissions['canpostnew'];
                             $thisPerm['forumpermissions2'] |= $forumpermissions2['cancomment'];
                         }
                         //Let the channel owner configure his/her channel
                         if ($groupPerm['groupid'] == $channelOwnerGroupId) {
                             $thisPerm['forumpermissions2'] |= $forumpermissions2['canconfigchannel'] | $forumpermissions2['candeletechannel'];
                         }
                         $channelPerm->setPermissions($channelId, $groupPerm['groupid'], $thisPerm, true);
                     }
                     foreach ($sgperms as $index => $sgperm) {
                         $thisPerm = $rootPerms[$index];
                         if ($sgperm['socialgrouppermissions'] & $this->bf_socialgrouppermissions['cancreategroups']) {
                             $thisPerm['createpermissions'] |= $this->contenttypes['vbforum_channel'];
                         } else {
                             $thisPerm['createpermissions'] &= ~$this->contenttypes['vbforum_channel'];
                         }
                         foreach ($this->bf_forumpermissions as $name => $bitfield) {
                             switch ($name) {
                                 case 'canreply':
                                     if ($sgperm['socialgrouppermissions'] & $this->bf_socialgrouppermissions['canpostmessage']) {
                                         $thisPerm['forumpermissions'] |= $bitfield;
                                         $thisPerm['createpermissions'] |= $this->contenttypes['vbforum_text'];
                                     } else {
                                         $rootPerms[$index]['forumpermissions'] &= ~$bitfield;
                                         $thisPerm['forumpermissions'] &= ~$bitfield;
                                     }
                                     break;
                                 case 'canview':
                                 case 'canviewthreads':
                                 case 'canviewothers':
                                     if ($sgperm['socialgrouppermissions'] & $this->bf_socialgrouppermissions['canviewgroups']) {
                                         $thisPerm['forumpermissions'] |= $bitfield;
                                     } else {
                                         $rootPerms[$index]['forumpermissions'] &= ~$bitfield;
                                         $thisPerm['forumpermissions'] &= ~$bitfield;
                                     }
                                     break;
                                 case 'caneditpost':
                                 case 'candeletepost':
                                     if ($sgperm['socialgrouppermissions'] & $this->bf_socialgrouppermissions['canmanagemessages']) {
                                         $thisPerm['forumpermissions'] |= $bitfield;
                                     } else {
                                         $rootPerms[$index]['forumpermissions'] &= ~$bitfield;
                                         $thisPerm['forumpermissions'] &= ~$bitfield;
                                     }
                                     break;
                                 case 'canpostnew':
                                     if ($sgperm['socialgrouppermissions'] & $this->bf_socialgrouppermissions['cancreatediscussion']) {
                                         $thisPerm['forumpermissions'] |= $bitfield;
                                         $thisPerm['createpermissions'] |= $this->contenttypes['vbforum_text'];
                                     } else {
                                         $rootPerms[$index]['forumpermissions'] &= ~$bitfield;
                                         $thisPerm['forumpermissions'] &= ~$bitfield;
                                     }
                                     break;
                                 case 'canpostattachment':
                                     if ($sgperm['socialgrouppermissions'] & $this->bf_socialgrouppermissions['canupload']) {
                                         $thisPerm['forumpermissions'] |= $bitfield;
                                         $thisPerm['createpermissions'] |= $this->contenttypes['vbforum_photo'];
                                     } else {
                                         $rootPerms[$index]['forumpermissions'] &= ~$bitfield;
                                         $thisPerm['forumpermissions'] &= ~$bitfield;
                                     }
                                     break;
                                 case 'canjoin':
                                     if ($sgperm['socialgrouppermissions'] & $this->bf_socialgrouppermissions['canjoingroups']) {
                                         $thisPerm['forumpermissions'] |= $bitfield;
                                     } else {
                                         $rootPerms[$index]['forumpermissions'] &= ~$bitfield;
                                         $thisPerm['forumpermissions'] &= ~$bitfield;
                                     }
                                     break;
                                 case 'candeletethread':
                                     if ($sgperm['socialgrouppermissions'] & $this->bf_socialgrouppermissions['canmanagediscussions']) {
                                         $thisPerm['forumpermissions'] |= $bitfield;
                                     } else {
                                         $rootPerms[$index]['forumpermissions'] &= ~$bitfield;
                                         $thisPerm['forumpermissions'] &= ~$bitfield;
                                     }
                                     break;
                                 case 'canuploadchannelicon':
                                     if ($sgperm['socialgrouppermissions'] & $this->bf_socialgrouppermissions['canuploadgroupicon']) {
                                         $thisPerm['forumpermissions'] |= $bitfield;
                                     } else {
                                         $rootPerms[$index]['forumpermissions'] &= ~$bitfield;
                                         $thisPerm['forumpermissions'] &= ~$bitfield;
                                     }
                                     break;
                                 case 'cananimatedchannelicon':
                                     if ($sgperm['socialgrouppermissions'] & $this->bf_socialgrouppermissions['cananimategroupicon']) {
                                         $thisPerm['forumpermissions'] |= $bitfield;
                                     } else {
                                         $rootPerms[$index]['forumpermissions'] &= ~$bitfield;
                                         $thisPerm['forumpermissions'] &= ~$bitfield;
                                     }
                                     break;
                                 default:
                             }
                         }
                         foreach ($this->bf_forumpermissions2 as $name => $bitfield) {
                             switch ($name) {
                                 case 'canconfigchannel':
                                     if ($index == vB_Api_UserGroup::CHANNEL_OWNER_SYSGROUPID or $index == vB_Api_UserGroup::ADMINISTRATOR or $index == vB_Api_UserGroup::SUPER_MODERATOR) {
                                         if ($sgperm['socialgrouppermissions'] & $this->bf_socialgrouppermissions['caneditowngroups']) {
                                             $thisPerm['forumpermissions2'] |= $bitfield;
                                         } else {
                                             $rootPerms[$index]['forumpermissions2'] &= ~$bitfield;
                                             $thisPerm['forumpermissions2'] &= ~$bitfield;
                                         }
                                     }
                                     break;
                                 case 'candeletechannel':
                                 case 'canmanageownchannels':
                                     if ($index == vB_Api_UserGroup::CHANNEL_OWNER_SYSGROUPID or $index == vB_Api_UserGroup::ADMINISTRATOR or $index == vB_Api_UserGroup::SUPER_MODERATOR) {
                                         if ($sgperm['socialgrouppermissions'] & $this->bf_socialgrouppermissions['canmanageowngroups']) {
                                             $thisPerm['forumpermissions2'] |= $bitfield;
                                         } else {
                                             $rootPerms[$index]['forumpermissions2'] &= ~$bitfield;
                                             $thisPerm['forumpermissions2'] &= ~$bitfield;
                                         }
                                     }
                                     break;
                                 default:
                             }
                         }
                         $channelPerm->setPermissions($channelId, $index, $thisPerm, true);
                     }
                     break;
                 case vB_Channel::REPORT_CHANNEL:
                     foreach ($rootPerms as $groupPerm) {
                         if ($groupPerm['adminpermissions'] > 0) {
                             $channelPerm->setPermissions($channelId, $groupPerm['groupid'], $groupPerm, true);
                         } elseif ($groupPerm['systemgroupid'] == vB_Api_UserGroup::MODERATOR) {
                             // Moderators group do not have any admin permissions by default, but they should at least
                             // be able to view reports - VBV-7955
                             $modPerms = $this->fetchEmptyPermissions();
                             $modPerms['forumpermissions'] |= $forumpermissions['canview'] | $forumpermissions['canviewthreads'] | $forumpermissions['canviewothers'];
                             $channelPerm->setPermissions($channelId, $groupPerm['groupid'], $modPerms, true);
                         } else {
                             $channelPerm->setPermissions($channelId, $groupPerm['groupid'], $this->fetchEmptyPermissions(), true);
                         }
                     }
                     break;
                 case vB_Channel::INFRACTION_CHANNEL:
                     foreach ($rootPerms as $groupPerm) {
                         if ($groupPerm['adminpermissions'] > 0) {
                             $channelPerm->setPermissions($channelId, $groupPerm['groupid'], $groupPerm, true);
                         } elseif ($groupPerm['systemgroupid'] == vB_Api_UserGroup::MODERATOR) {
                             // Moderators group do not have any admin permissions by default, but they should at least
                             // be able to view reports - VBV-7955
                             $modPerms = $this->fetchEmptyPermissions();
                             $modPerms['forumpermissions'] |= $forumpermissions['canview'] | $forumpermissions['canviewthreads'] | $forumpermissions['canviewothers'];
                             $channelPerm->setPermissions($channelId, $groupPerm['groupid'], $modPerms, true);
                         } else {
                             $channelPerm->setPermissions($channelId, $groupPerm['groupid'], $this->fetchEmptyPermissions(), true);
                         }
                     }
                     break;
                 case vB_Channel::DEFAULT_ARTICLE_PARENT:
                     foreach ($rootPerms as $groupPerm) {
                         unset($groupPerm['permissionid']);
                         if ($groupPerm['systemgroupid'] == vB_Api_UserGroup::ADMINISTRATOR) {
                             $groupPerm['createpermissions'] |= $this->contenttypes['vbforum_text'] | $this->contenttypes['vbforum_gallery'] | $this->contenttypes['vbforum_poll'] | $this->contenttypes['vbforum_attach'] | $this->contenttypes['vbforum_photo'] | $this->contenttypes['vbforum_video'] | $this->contenttypes['vbforum_link'];
                             $groupPerm['forumpermissions2'] |= $this->bf_forumpermissions2['canalwaysview'];
                             $groupPerm['forumpermissions'] |= $this->bf_forumpermissions['canpostnew'];
                             $groupPerm['edit_time'] = 24 * 365;
                             $groupPerm['bf_forumpermissions2'] |= $this->bf_forumpermissions2['canpublish'];
                             $channelPerm->setPermissions($channelId, $groupPerm['groupid'], $groupPerm, true);
                         } else {
                             if ($groupPerm['systemgroupid'] != vB_Api_UserGroup::BANNED and $groupPerm['systemgroupid'] != vB_Api_UserGroup::UNREGISTERED_SYSGROUPID) {
                                 $groupPerm['createpermissions'] = $this->contenttypes['vbforum_text'] | $this->contenttypes['vbforum_gallery'] | $this->contenttypes['vbforum_poll'] | $this->contenttypes['vbforum_attach'] | $this->contenttypes['vbforum_photo'] | $this->contenttypes['vbforum_video'];
                                 $groupPerm['forumpermissions'] &= ~$this->bf_forumpermissions['canpostnew'];
                                 $groupPerm['forumpermissions'] |= $this->bf_forumpermissions['canview'] | $this->bf_forumpermissions['canviewthreads'] | $this->bf_forumpermissions['canviewothers'];
                                 $channelPerm->setPermissions($channelId, $groupPerm['groupid'], $groupPerm, true);
                             } else {
                                 if ($groupPerm['systemgroupid'] == vB_Api_UserGroup::REGISTERED_SYSGROUPID) {
                                     $defaultPerms = $groupPerm;
                                 }
                             }
                         }
                     }
                     //insert record for cms authors
                     $defaultPerms['createpermissions'] |= $this->contenttypes['vbforum_text'] | $this->contenttypes['vbforum_report'] | $this->contenttypes['vbforum_gallery'] | $this->contenttypes['vbforum_poll'] | $this->contenttypes['vbforum_attach'] | $this->contenttypes['vbforum_photo'] | $this->contenttypes['vbforum_privatemessage'] | $this->contenttypes['vbforum_video'] | $this->contenttypes['vbforum_link'];
                     $defaultPerms['forumpermissions2'] |= $this->bf_forumpermissions2['canalwaysview'] | $this->bf_forumpermissions2['cangetimgattachment'];
                     $defaultPerms['forumpermissions'] |= $this->bf_forumpermissions['canpostnew'] | $this->bf_forumpermissions['canseedelnotice'] | $this->bf_forumpermissions['cangetattachment'] | $this->bf_forumpermissions['canview'] | $this->bf_forumpermissions['canviewthreads'] | $this->bf_forumpermissions['canviewothers'] | $this->bf_forumpermissions['canpostattachment'] | $this->bf_forumpermissions['cantagown'];
                     $defaultPerms['forumpermissions2'] &= ~$this->bf_forumpermissions2['canpublish'];
                     $defaultPerms['edit_time'] = 24 * 365;
                     $channelPerm->setPermissions($channelId, $this->authorGroupid, $defaultPerms, true);
                     //and for cms editors.
                     $defaultPerms['forumpermissions'] |= $this->bf_forumpermissions['followforummoderation'] | $this->bf_forumpermissions['cantagothers'];
                     $defaultPerms['forumpermissions2'] |= $this->bf_forumpermissions2['canpublish'] | $this->bf_forumpermissions2['caneditothers'];
                     $channelPerm->setPermissions($channelId, $this->editorGroupId, $defaultPerms, true);
                     break;
                     //If it's anything else we don't set permissions.
             }
         }
     }
     $channelPerm->buildDefaultChannelPermsDatastore();
 }
コード例 #4
0
ファイル: theme.php プロジェクト: cedwards-reisys/nexus-web
 public function importThemes($perpage = 1, $overwrite = false)
 {
     $themesdir = DIR . '/install/themes/';
     if (is_dir($themesdir)) {
         /*
          *	There's a bug in the upgrader where only the 'startat' parameter can be returned & used in
          *	the upgrade steps. Since the same upgrade step will be run for a single file, and we have
          *	multiple files to process, we need to keep track of 1) which file we were on and 2) which
          *	iteration of that file we are on. Since we only have 1 variable to keep track of at least
          *	multiple values, we need another way to keep track of data between sessions.
          */
         $datastore = vB::getDatastore();
         $dataTitle = "themeImportProgress";
         $importProgress = $datastore->getValue($dataTitle);
         if (is_null($importProgress)) {
             $importProgress = '';
         }
         $importProgress = json_decode($importProgress, true);
         /*
          * json_encode-d array of
          *	'finished' => 	{array of fully imported filenames},
          *	'current'  => 	{array
          *						'filename' => {current filename},
          *						'startat' => {current progress index} ,
          *						'styleid' => {styleid of added style record if we're not at startat==0}
          *					},
          *	'remaining'	=> 	{array of remaining filenames}
          *
          *	I'm not storing the parsed XML in here, because I'm not certain if the json_encoded data with the parsed
          *	XML can be guaranteed to be less than mediumtext's (type of datastore.data) limit of	2^24 + 3 bytes.
          */
         if (empty($importProgress)) {
             $importProgress = array('finished' => array(), 'remaining' => array_filter(scandir($themesdir), function ($filename) use($themesdir) {
                 return !is_dir($themesdir . '/' . $filename) and strtolower(pathinfo($filename, PATHINFO_EXTENSION)) === 'xml';
                 // skip directories and make sure it has xml extension
             }));
             // TODO: need better check to grab REAL files only. One approach is to use a filename prefix and check for that, like how customlanguages does it
         }
         // Let's grab the file to work on next if we don't have one
         if (empty($importProgress['current'])) {
             // we have no files remaining to import
             if (empty($importProgress['remaining'])) {
                 $datastore->build($dataTitle, '', 0);
                 return array('done' => true, 'continue' => false, 'output' => '');
             } else {
                 $importProgress['current']['filename'] = $themesdir . '/' . array_shift($importProgress['remaining']);
                 $importProgress['current']['startat'] = 0;
                 $importProgress['current']['styleid'] = -1;
             }
         }
         // make sure we have the theme parent, as any imported themes will be its children
         if (empty(self::$themeParent['guid'])) {
             $this->getDefaultParentTheme();
         }
         // fetch the XML file and parse it into something we can understand
         $this->parsedXML['theme'] = vB_Xml_Import::parseFile($importProgress['current']['filename']);
         // ensure that imported theme is a child of the blank parent theme. Any other kind of
         // default data setting global to all "auto-import @ install" themes should happen here.
         $this->parsedXML['theme']['parentid'] = self::$themeParent['styleid'];
         // overwrite check happens inside import()
         $info = $this->import($importProgress['current']['startat'], $perpage, $overwrite, $importProgress['current']['styleid'], true);
         if ($info['done']) {
             $importProgress['finished'][] = $importProgress['current']['filename'];
             unset($importProgress['current']);
         } else {
             $importProgress['current']['styleid'] = $info['overwritestyleid'];
             $importProgress['current']['startat'] += $perpage;
         }
         $importProgress = json_encode($importProgress);
         $datastore->build($dataTitle, $importProgress, 0);
         // move onto the next iteration of this file (or the next file, whichever is appropriate).
         return array('done' => false, 'continue' => true, 'output' => $info['output']);
     } else {
         // themes folder does not exist. nothing to import
         return array('done' => true, 'continue' => false, 'output' => '');
     }
 }