public function setUp()
    {
        parent::setUp();

        $this->userLogin = uniqid( '', true );
        $this->userEmail = "{$this->userLogin}@ez.no";

        $ini = eZINI::instance();
        $params = array(
            'creator_id' => 14,
            'class_identifier' => 'user',
            'parent_node_id' => $ini->variable( 'UserSettings', 'DefaultUserPlacement' ),
            'attributes' => array(
                'first_name' => 'foo',
                'last_name' => 'bar' ),
        );

        $contentObject = eZContentFunctions::createAndPublishObject( $params );

        if( !$contentObject instanceof eZContentObject )
        {
            die( 'Impossible to create user object' );
        }

        $this->userObject = $contentObject;
    }
 function createSubscriptionUser($attributes)
 {
     $param = array('parent_node_id' => JAJSubscriptionUser::subscriptionUsersNodeID(), 'class_identifier' => 'subscription_user', 'creator_id' => ezUser::currentUserID(), 'attributes' => array('status' => 'Pending'));
     $param['attributes'] = array_merge($param['attributes'], $attributes);
     $object = eZContentFunctions::createAndPublishObject($param);
     $object->expireAllViewCache();
     return $object;
 }
Beispiel #3
0
 /**
  * Save article draft for later approval
  */
 public function save()
 {
     $user = eZUser::fetchByName('admin');
     $params = array('class_identifier' => 'article', 'creator_id' => $user->attribute('contentobject_id'), 'parent_node_id' => $this->location, 'name' => $this->header, 'attributes' => array('title' => $this->header, 'intro' => $this->xmlConvert($this->ingress), 'body' => $this->xmlConvert($this->text)));
     // Manipulate version (setting state to draft)
     $contentObject = eZContentFunctions::createAndPublishObject($params);
     $version = $contentObject->version(1);
     $version->setAttribute('modified', eZDateTime::currentTimeStamp());
     $version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
     $version->store();
 }
Beispiel #4
0
    function createContentObject( $params )
    {
        $objectID = false;

        $classIdentifier = $params['class_identifier'];
        $location = $params['location'];
        $attributesData = $params['attributes'];

        $parentNode = $this->nodeByUrl( $params );
        if( is_object( $parentNode ) )
        {
            $parentNodeID = $parentNode->attribute( 'node_id' );
            $object = eZContentFunctions::createAndPublishObject( array( 'parent_node_id' => $parentNodeID,
                                                                         'class_identifier' => $classIdentifier,
                                                                         'attributes' => $attributesData ) );

            if( is_object( $object ) )
            {
                $objectID = $object->attribute( 'id' );
            }
        }

        return $objectID;
    }
/**
 * Creates and returns pages folder for given country
 * @param eZContentObject $countryNode
 * @param string $clusterIdentifier
 * @return eZContentObject
 */
function createPagesFolder( $countryNode, $clusterIdentifier )
{
    $parentNodeId = $countryNode->MainNodeID();
    $options = array(
        'parent_node_id' => $parentNodeId,
        'remote_id' => 'application_folder-' . $clusterIdentifier . '-page',
        'class_identifier' => 'folder',
        'attributes' => array(
            'name' => 'Pages'
        ),
    );
    $pagesFolder = eZContentFunctions::createAndPublishObject( $options );
    return $pagesFolder;
}
 /**
  * @param int $remoteNodeID
  * @param int $localParentNodeID
  *
  * @return eZContentObject
  * @throws Exception
  */
 public function import($remoteNodeID, $localParentNodeID)
 {
     if (!class_exists('OCOpenDataApiNode')) {
         throw new Exception("Libreria OCOpenDataApiNode non trovata");
     }
     $apiNodeUrl = rtrim($this->attributes['definition']['Url'], '/') . '/api/opendata/v1/content/node/' . $remoteNodeID;
     $remoteApiNode = OCOpenDataApiNode::fromLink($apiNodeUrl);
     if (!$remoteApiNode instanceof OCOpenDataApiNode) {
         throw new Exception("Url remoto \"{$apiNodeUrl}\" non raggiungibile");
     }
     $attributeList = array();
     foreach ($this->remoteClassAttributes as $identifier) {
         if (isset($remoteApiNode->fields[$identifier])) {
             $fieldArray = $remoteApiNode->fields[$identifier];
             $localeIdentifier = isset($this->mapAttributes[$identifier]) ? $this->mapAttributes[$identifier] : false;
             if ($localeIdentifier) {
                 if (strpos($localeIdentifier, '::') === 0) {
                     $localeIdentifier = str_replace('::', '', $localeIdentifier);
                     $attributeList[$localeIdentifier] = $this->importAttribute($identifier, $localeIdentifier, $fieldArray);
                 } else {
                     switch ($fieldArray['type']) {
                         case 'ezxmltext':
                             $attributeList[$localeIdentifier] = SQLIContentUtils::getRichContent($fieldArray['value']);
                             break;
                         case 'ezbinaryfile':
                         case 'ezimage':
                             $attributeList[$localeIdentifier] = !empty($fieldArray['value']) ? SQLIContentUtils::getRemoteFile($fieldArray['value']) : '';
                             break;
                         default:
                             $attributeList[$localeIdentifier] = $fieldArray['string_value'];
                             break;
                     }
                 }
             }
         }
     }
     $params = array();
     $params['class_identifier'] = $this->mapClassIdentifier;
     $params['remote_id'] = static::REMOTE_PREFIX . $remoteApiNode->metadata['objectRemoteId'];
     $params['parent_node_id'] = $localParentNodeID;
     $params['attributes'] = $attributeList;
     $newObject = eZContentFunctions::createAndPublishObject($params);
     if (!$newObject instanceof eZContentObject) {
         throw new Exception("Fallita la creazione dell'oggetto da nodo remoto");
     }
     return $newObject;
 }
/**
 * create HTML eZ Publish object
 * @param eZContentObjectTreeNode $parentNode
 * @param SimpleXMLElement $_item
 */
function createHTMLObject($parentNode, $_item)
{
    try
    {
        //get actual user
        $user = eZUser::currentUser();

        //object parameters
        $params                      = array();
        $params ['class_identifier'] = 'html';
        $params['creator_id']        = $user->attribute('contentobject_id');
        $params['parent_node_id']    = $parentNode->attribute('node_id');
        $params['section_id']        = $parentNode->object()->attribute('section_id');

        //set template attributes
        include_once('kernel/common/template.php');
        $htmlTpl = eZTemplate::factory();
        $htmlTpl->setVariable('title', $_item->title);
        $htmlTpl->setVariable('link', '/congressos-e-eventos?deeplink=' . urlencode($_item->link));
        $htmlTpl->setVariable('description', $_item->description);
        $htmlTpl->setVariable('category', $_item->category);
        $text = $htmlTpl->fetch('design:html/cronview.tpl');

        //attributes to insert
        $attributesData          = array();
        $attributesData['title'] = $_item->title;
        $attributesData['text']  = $text;

        $params['attributes'] = $attributesData;

        //object creation
        eZContentFunctions::createAndPublishObject($params);
    }
    catch (Exception $e)
    {
        $cli = eZCLI::instance();
        $cli->output($e->getMessage());
    }
}
        if ($user instanceof eZUser) {
            $object = $user->attribute('contentobject');
        }
    }
} else {
    $object = eZContentObject::fetchByRemoteID($remoteID);
}
if ($object instanceof eZContentObject === false) {
    // There is no eZ publish user, so we are creating one
    $userClassID = $ini->variable('UserSettings', 'UserClassID');
    $userClass = eZContentClass::fetch($userClassID);
    if ($userClass instanceof eZContentClass === false) {
        eZDebug::writeError('User calss does not exist', 'NXC Social Networks Login');
        return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
    }
    $object = eZContentFunctions::createAndPublishObject(array('parent_node_id' => $ini->variable('UserSettings', 'DefaultUserPlacement'), 'class_identifier' => $userClass->attribute('identifier'), 'creator_id' => $ini->variable('UserSettings', 'UserCreatorID'), 'section_id' => $ini->variable('UserSettings', 'DefaultSectionID'), 'remote_id' => $uniqueIdentifier == 'remote_id' ? $remoteID : null, 'attributes' => $attributes));
    if ($object instanceof eZContentObject === false) {
        eZDebug::writeError('User`s object isn`t created.', 'NXC Social Networks Login');
        return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
    }
} else {
    // There is also eZ Publish user, so we are updating it, if it is needed
    $isUpdateNeeded = false;
    $dataMap = $object->attribute('data_map');
    // We are not updating user_account attribute
    unset($attributes['user_account']);
    foreach ($attributes as $identifier => $value) {
        if (isset($dataMap[$identifier])) {
            $storedContent = $dataMap[$identifier]->toString();
            if ($identifier == 'image') {
                // We are comparing image sizes (stored in the eZ Publish vs social media avatar)
                }
                if ($userStatus != 'Approved') {
                    $userDataMap['status']->fromString('Approved');
                    $userDataMap['status']->store();
                    $modified = true;
                }
                if ($modified) {
                    $warnings[] = "Row " . ($index + 1) . " subscriber found and updated." . " Email: '" . htmlspecialchars($row[1]) . "'";
                    eZContentObjectTreeNode::clearViewCacheForSubtree($user);
                } else {
                    $warnings[] = "Row " . ($index + 1) . " skipped, subscriber exists." . " Email: '" . htmlspecialchars($row[1]) . "'";
                }
                continue;
            }
            $param_creation['attributes'] = array('name' => $row[0], 'email' => $row[1], 'subscriptions' => $subscriptions, 'status' => 'Approved');
            $object = eZContentFunctions::createAndPublishObject($param_creation);
            if ($object == false) {
                $warnings[] = "Row " . ($index + 1) . " skipped, failed to create subscriber with email: '" . htmlspecialchars($row[1]) . "'";
            } else {
                $warnings[] = "Row " . ($index + 1) . " added subscriber with" . " email: '" . htmlspecialchars($row[1]) . "'";
            }
        }
        if ($http->hasSessionVariable('CSVData')) {
            $http->removeSessionVariable('CSVData');
        }
        $data = array();
    }
} while (false);
$tpl =& templateInit();
//$tpl->setVariable( 'subscriptionListNode', $subscriptionListNode );
$tpl->setVariable('subscription_lists_node', $subscriptionListsNode);