Пример #1
0
 /** Set the node special permissions
  *
  * 	@param	mixed	array with 'viewperms' and/or 'commentperms'
  *
  * 	@return	either 1 or an error message.
  **/
 public function setNodePerms($nodeid, $perms = array())
 {
     if (empty($nodeid) or !intval($nodeid) or !isset($perms['viewperms']) and !isset($perms['commentperms'])) {
         throw new vB_Exception_Api('invalid_request');
     }
     //If this is a gallery and the owner is setting to private, it's O.K.
     if (isset($perms['viewperms']) and !isset($perms['commentperms'])) {
         $node = $this->library->getNodeBare($nodeid);
         if ($node['contenttypeid'] == vB_Types::instance()->getContentTypeID('vBForum_Gallery') and $node['parentid'] == self::fetchAlbumChannel() and $node['userid'] == vB::getCurrentSession()->get('userid')) {
             $canChange = true;
         }
     }
     if (empty($canChange) and !vB::getUserContext()->getChannelPermission('moderatorpermissions', 'canaddowners', $nodeid)) {
         throw new vB_Exception_Api('no_permission');
     }
     $updates = array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED, 'nodeid' => $nodeid);
     $node = $this->getNode($nodeid);
     if (isset($perms['viewperms']) and is_numeric($perms['viewperms']) and in_array($perms['viewperms'], array(0, 1, 2))) {
         $updates['viewperms'] = $perms['viewperms'];
     } else {
         $updates['viewperms'] = $node['viewperms'];
     }
     if (isset($perms['commentperms']) and is_numeric($perms['commentperms']) and in_array($perms['commentperms'], array(0, 1, 2))) {
         $updates['commentperms'] = $perms['commentperms'];
     } else {
         $updates['commentperms'] = $node['commentperms'];
     }
     $result = vB::getDbAssertor()->assertQuery('vBForum:updateNodePerms', $updates);
     $this->clearCacheEvents($nodeid);
     $this->library->clearChildCache($nodeid);
     return $result;
 }