/**
  * Returns the main node id for the current object.
  *
  * @return int|null
  */
 function mainNode()
 {
     return eZContentObjectTreeNode::findMainNode( $this->attribute( 'id' ), true );
 }
Beispiel #2
0
 /**
  * Update current empty paex fields with values get from paex object of
  * parent of current main node.
  *
  * @param bool $forceUpdate
  * @return true
  */
 function updateFromParent($forceUpdate = false)
 {
     $mainNode = eZContentObjectTreeNode::findMainNode($this->attribute('contentobject_id'), true);
     if (!is_object($mainNode)) {
         eZDebug::writeDebug('mainNode not found', 'eZPaEx::updateFromParent');
     } elseif ($mainNode->attribute('depth') > 1) {
         $parentMainNodeID = $mainNode->attribute('parent_node_id');
         $parentContentObject = eZContentObject::fetchByNodeID($parentMainNodeID);
         $parentPaex = eZPaEx::getPaEx($parentContentObject->attribute('id'));
         if ($parentPaex instanceof eZPaEx) {
             $paexUpdated = false;
             if (!$this->hasRegexp() || $forceUpdate) {
                 $this->setAttribute('passwordvalidationregexp', $parentPaex->attribute('passwordvalidationregexp'));
                 $paexUpdated = true;
             }
             if (!$this->hasLifeTime() || $forceUpdate) {
                 $this->setAttribute('passwordlifetime', $parentPaex->attribute('passwordlifetime'));
                 $paexUpdated = true;
             }
             if (!$this->hasNotification() || $forceUpdate) {
                 $this->setAttribute('expirationnotification', $parentPaex->attribute('expirationnotification'));
                 $paexUpdated = true;
             }
             if ($paexUpdated) {
                 eZDebug::writeDebug('Paex updated from parent', 'eZPaEx::updateFromParent');
                 $this->store();
             }
         }
     }
     return true;
 }