コード例 #1
0
ファイル: node.php プロジェクト: cedwards-reisys/nexus-web
 /**
  * undeletes a set of nodes
  * @param	array	The nodeids of the records to be deleted
  *
  * @return	array nodeids that were deleted
  */
 public function undeleteNodes($nodeids)
 {
     if (empty($nodeids)) {
         return false;
     }
     $assertor = vB::getDbAssertor();
     //If it's a protected channel, don't allow removal.
     $existing = vB_Library::instance('node')->getNodes($nodeids);
     // need to see if we require authentication
     $currentUserid = vB::getCurrentSession()->get('userid');
     $userContext = vB::getUserContext();
     //If any of the nodes are channels we need to rebuild
     $needRebuild = false;
     foreach ($existing as $node) {
         if ($node['userid'] != $currentUserid) {
             $this->inlinemodAuthCheck();
         }
         if ($node['contenttypeid'] == vB_Types::instance()->getContentTypeID('vBForum_Channel')) {
             $needRebuild = true;
         }
         if (!$userContext->getChannelPermission('moderatorpermissions', 'candeleteposts', $node['nodeid'])) {
             //one check for channels
             if ($node['starter'] == 0 and $userContext->getChannelPermission('forumpermissions2', 'canmanageownchannels', $node['nodeid'])) {
                 $starter = vB_Api::instanceInternal('node')->getNode($node['starter']);
                 $channel = vB_Api::instanceInternal('node')->getNode($starter['parentid']);
                 if ($channel['userid'] != $currentUserid) {
                     throw new vB_Exception_Api('no_delete_permissions');
                 }
             } else {
                 throw new vB_Exception_Api('no_delete_permissions');
             }
         }
     }
     if (!is_array($nodeids)) {
         $nodeids = array($nodeids);
     }
     return $this->library->undeleteNodes($nodeids, $needRebuild);
 }