Пример #1
0
 /**
  * Closes a node for posting. Closed nodes can still be viewed but nobody can reply to one.
  *
  * 	@param	mixed	integer or array of integers
  *
  *	@return	mixed	Either array 'errors' => error string or array of id's.
  */
 public function closeNode($nodeid)
 {
     $userContext = vB::getUserContext();
     if ($userContext->isModerator()) {
         $this->inlinemodAuthCheck();
     }
     //we need to handle a single nodeid or an array of nodeids
     if (!is_array($nodeid)) {
         $nodeids = array($nodeid);
     } else {
         $nodeids = $nodeid;
     }
     //First check permissions of course.
     foreach ($nodeids as $nodeid) {
         //this can be approved through moderator permissions, or because the node is the current user's and they have forumpermission canopenclose
         if (!vB::getUserContext()->getChannelPermission('moderatorpermissions', 'canopenclose', $nodeid)) {
             $node = $this->library->getNode($nodeid);
             if ($node['userid'] != vB::getCurrentSession()->get('userid') or !vB::getUserContext()->getChannelPermission('forumpermissions', 'canopenclose', $nodeid)) {
                 throw new vB_Exception_Api('no_permission');
             }
         }
     }
     return $this->library->closeNode($nodeids);
 }