/** * validates that the current can do something with a node with these values * * @param mixed Array of field => value pairs which define the record. * @param string Parameters to be checked for permission * @param int (optional) Node ID * @param array (optional) Nodes * * @return bool */ public function validate(&$data, $action = self::ACTION_ADD, $nodeid = false, $nodes = false) { //One extra check. If the node would otherwise be viewable but viewperms is zero for an album, the the current user //is the owner or follows the owner, they can see it. if (parent::validate($data, $action, $nodeid, $nodes)) { return true; } if (empty($data) and !empty($nodeid)) { $data = vB_Library::instance('node')->getNodeBare($nodeid); } if ($action == self::ACTION_VIEW and isset($data['nodeid']) and isset($data['userid']) and isset($data['parentid']) and isset($data['viewperms']) and $data['viewperms'] != 2 and !empty($data['showapproved']) and !empty($data['showpublished'])) { $gallery = vB_Library::instance('node')->getNodeBare($data['parentid']); return vB_Api::instanceInternal('content_gallery')->validate($gallery, $action, $data['parentid']); return true; } return false; }
/** * Validates that the current can create a node with these values * * @param mixed Array of field => value pairs which define the record. * @param string Parameters to be checked for permission * @param int Node ID * @param array Nodes * * @return bool */ public function validate(&$data, $action = self::ACTION_ADD, $nodeid = false, $nodes = false) { if (parent::validate($data, $action, $nodeid, $nodes) == false) { return false; } $userContext = vB::getUserContext(); switch ($action) { case vB_Api_Content::ACTION_ADD: if (empty($data['filedataid'])) { return false; } break; } return true; }