function onPublish($attribute, $contentObject, $publishedNodes)
 {
     $user = eZUser::currentUser();
     $address = $user->attribute('email');
     $userID = $user->attribute('contentobject_id');
     $nodeIDList = eZSubtreeNotificationRule::fetchNodesForUserID($user->attribute('contentobject_id'), false);
     if ($attribute->attribute('data_int') == '1') {
         $newSubscriptions = array();
         foreach ($publishedNodes as $node) {
             if (!in_array($node->attribute('node_id'), $nodeIDList)) {
                 $newSubscriptions[] = $node->attribute('node_id');
             }
         }
         foreach ($newSubscriptions as $nodeID) {
             $rule = eZSubtreeNotificationRule::create($nodeID, $userID);
             $rule->store();
         }
     } else {
         foreach ($publishedNodes as $node) {
             if (in_array($node->attribute('node_id'), $nodeIDList)) {
                 eZSubtreeNotificationRule::removeByNodeAndUserID($user->attribute('contentobject_id'), $node->attribute('node_id'));
             }
         }
     }
     return true;
 }
Exemplo n.º 2
0
    /**
     * Writes $auditName with $auditAttributes as content
     * to file name that will be fetched from ini settings by auditNameSettings() for logging.
     *
     * @param string $auditName
     * @param array $auditAttributes
     * @return bool
     */
    static function writeAudit( $auditName, $auditAttributes = array() )
    {
        $enabled = eZAudit::isAuditEnabled();
        if ( !$enabled )
            return false;

        $auditNameSettings = eZAudit::auditNameSettings();

        if ( !isset( $auditNameSettings[$auditName] ) )
            return false;

        $ip = eZSys::clientIP();
        if ( !$ip )
            $ip = eZSys::serverVariable( 'HOSTNAME', true );

        $user = eZUser::currentUser();
        $userID = $user->attribute( 'contentobject_id' );
        $userLogin = $user->attribute( 'login' );

        $message = "[$ip] [$userLogin:$userID]\n";

        foreach ( array_keys( $auditAttributes ) as $attributeKey )
        {
            $attributeValue = $auditAttributes[$attributeKey];
            $message .= "$attributeKey: $attributeValue\n";
        }

        $logName = $auditNameSettings[$auditName]['file_name'];
        $dir = $auditNameSettings[$auditName]['dir'];
        eZLog::write( $message, $logName, $dir );

        return true;
    }
 function modify(&$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
 {
     switch ($operatorName) {
         case 'recaptcha_get_html':
             include_once 'extension/recaptcha/classes/recaptchalib.php';
             // Retrieve the reCAPTCHA public key from the ini file
             $ini = eZINI::instance('recaptcha.ini');
             $key = $ini->variable('Keys', 'PublicKey');
             if (is_array($key)) {
                 $hostname = eZSys::hostname();
                 if (isset($key[$hostname])) {
                     $key = $key[$hostname];
                 } else {
                     // try our luck with the first entry
                     $key = array_shift($key);
                 }
             }
             // check if the current user is able to bypass filling in the captcha and
             // return nothing so that no captcha is displayed
             $currentUser = eZUser::currentUser();
             $accessAllowed = $currentUser->hasAccessTo('recaptcha', 'bypass_captcha');
             if ($accessAllowed["accessWord"] == 'yes') {
                 $operatorValue = 'User bypasses CAPTCHA';
             } else {
                 // Run the HTML generation code from the reCAPTCHA PHP library
                 $operatorValue = recaptcha_get_html($key);
             }
             break;
     }
 }
Exemplo n.º 4
0
 protected static function checkIfLoggedIn()
 {
     $ini = eZINI::instance('cookielaw.ini');
     if (eZUser::currentUser()->isLoggedIn() && ($ini->hasVariable('UriExcludeList', 'ExcludeUserLoggedIn') && $ini->variable('UriExcludeList', 'ExcludeUserLoggedIn') == 'enabled')) {
         self::$isActive = false;
     }
 }
function akismet_ContentActionHandler($module, $http, $objectID)
{
    $object = eZContentObject::fetch($objectID);
    $version = $object->attribute('current');
    if ($http->hasPostVariable('AkismetSubmitSpam')) {
        $user = eZUser::currentUser();
        $accessResult = $user->hasAccessTo('akismet', 'submit');
        if ($accessResult['accessWord'] === 'yes') {
            $mainNode = $object->attribute('main_node');
            $module->redirectTo($mainNode->attribute('url_alias'));
            $akismetObject = new eZContentObjectAkismet();
            $comment = $akismetObject->akismetInformationExtractor($version);
            if ($comment) {
                $akismet = new eZAkismet($comment);
                if ($akismet) {
                    $feedback = $akismet->submitSpam();
                    $response[] = $feedback[1];
                } else {
                    $response[] = ezi18n('extension/contactivity/akismet/submit', "An error has occured, unable to submit spam to Akismet.");
                }
            } else {
                $response[] = ezi18n('extension/contactivity/akismet/submit', "An error has occured, unable to submit spam to Akismet.");
            }
        }
        $mainNode = $object->attribute('main_node');
        $module->redirectTo($mainNode->attribute('url_alias'));
        return true;
    }
}
Exemplo n.º 6
0
 static function reCAPTCHAValidate($http)
 {
     // check if the current user is able to bypass filling in the captcha and
     // return true without checking if so
     $currentUser = eZUser::currentUser();
     $accessAllowed = $currentUser->hasAccessTo('recaptcha', 'bypass_captcha');
     if ($accessAllowed["accessWord"] == 'yes') {
         return true;
     }
     $ini = eZINI::instance('recaptcha.ini');
     // If PrivateKey is an array try and find a match for the current host
     $privatekey = $ini->variable('Keys', 'PrivateKey');
     if (is_array($privatekey)) {
         $hostname = eZSys::hostname();
         if (isset($privatekey[$hostname])) {
             $privatekey = $privatekey[$hostname];
         } else {
             // try our luck with the first entry
             $privatekey = array_shift($privatekey);
         }
     }
     $recaptcha_challenge_field = $http->postVariable('recaptcha_challenge_field');
     $recaptcha_response_field = $http->postVariable('recaptcha_response_field');
     $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $recaptcha_challenge_field, $recaptcha_response_field);
     return $resp->is_valid;
 }
Exemplo n.º 7
0
    static function enabled()
    {
        if ( isset( $GLOBALS['eZHTTPHeaderCustom'] ) )
        {
            return $GLOBALS['eZHTTPHeaderCustom'];
        }

        $ini = eZINI::instance();
        if ( !$ini->hasVariable( 'HTTPHeaderSettings', 'CustomHeader' ) )
        {
            $GLOBALS['eZHTTPHeaderCustom'] = false;
        }
        else
        {
            if ( $ini->variable( 'HTTPHeaderSettings', 'CustomHeader' ) === 'enabled'
                 && $ini->hasVariable( 'HTTPHeaderSettings', 'OnlyForAnonymous' )
                 && $ini->variable( 'HTTPHeaderSettings', 'OnlyForAnonymous' ) === 'enabled' )
            {
                $user = eZUser::currentUser();
                $GLOBALS['eZHTTPHeaderCustom'] = !$user->isLoggedIn();
            }
            else
            {
                $GLOBALS['eZHTTPHeaderCustom'] = $ini->variable( 'HTTPHeaderSettings', 'CustomHeader' ) == 'enabled';
            }
        }

        return $GLOBALS['eZHTTPHeaderCustom'];
    }
	function checkAccess( $functionName, $contentObject )
	{
		if( $contentObject instanceof feZMetaData and $functionName)
		{
			$result = $contentObject->checkAccess( $functionName );
			return array( 'result' => $result );
		}
		else
		{
			$user = eZUser::currentUser();
        	$userID = $user->attribute( 'contentobject_id' );

		    $accessResult = $user->hasAccessTo( 'fezmetadata', $functionName );
		    $accessWord = $accessResult['accessWord'];

    		if( $accessWord == 'yes' )
	    	{
		    	return 1;
    		}
	    	else
		    {
    			return 0;
	    	}
		}
	}
Exemplo n.º 9
0
 /**
  * Gets current users bookmarks by offset and limit
  *
  * @param array $args  0 => offset:0, 1 => limit:10
  * @return hash
  */
 public static function bookmarks($args)
 {
     $offset = isset($args[0]) ? (int) $args[0] : 0;
     $limit = isset($args[1]) ? (int) $args[1] : 10;
     $http = eZHTTPTool::instance();
     $user = eZUser::currentUser();
     $sort = 'desc';
     if (!$user instanceof eZUser) {
         throw new ezcBaseFunctionalityNotSupportedException('Bookmarks retrival', 'current user object is not of type eZUser');
     }
     $userID = $user->attribute('contentobject_id');
     if ($http->hasPostVariable('SortBy') && $http->postVariable('SortBy') !== 'asc') {
         $sort = 'asc';
     }
     // fetch bookmarks
     $count = eZPersistentObject::count(eZContentBrowseBookmark::definition(), array('user_id' => $userID));
     if ($count) {
         $objectList = eZPersistentObject::fetchObjectList(eZContentBrowseBookmark::definition(), null, array('user_id' => $userID), array('id' => $sort), array('offset' => $offset, 'length' => $limit), true);
     } else {
         $objectList = false;
     }
     // Simplify node list so it can be encoded
     if ($objectList) {
         $list = ezjscAjaxContent::nodeEncode($objectList, array('loadImages' => true, 'fetchNodeFunction' => 'fetchNode', 'fetchChildrenCount' => true), 'raw');
     } else {
         $list = array();
     }
     return array('list' => $list, 'count' => $count ? count($objectList) : 0, 'total_count' => (int) $count, 'offset' => $offset, 'limit' => $limit);
 }
Exemplo n.º 10
0
 function store($fieldFilters = null)
 {
     $dateTime = time();
     $user = eZUser::currentUser();
     $this->setAttribute('modifier_id', $user->attribute('contentobject_id'));
     $this->setAttribute('modified', $dateTime);
     parent::store($fieldFilters);
 }
Exemplo n.º 11
0
function sectionEditActionCheck( $module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage )
{
    if ( $module->isCurrentAction( 'SectionEdit' ) )
    {
        $http = eZHTTPTool::instance();
        if ( $http->hasPostVariable( 'SelectedSectionId' ) )
        {
            $selectedSectionID = (int) $http->postVariable( 'SelectedSectionId' );
            $selectedSection = eZSection::fetch( $selectedSectionID );
            if ( is_object( $selectedSection ) )
            {
                $currentUser = eZUser::currentUser();
                if ( $currentUser->canAssignSectionToObject( $selectedSectionID, $object ) )
                {
                    $db = eZDB::instance();
                    $db->begin();
                    $assignedNodes = $object->attribute( 'assigned_nodes' );
                    if ( count( $assignedNodes ) > 0 )
                    {
                        foreach ( $assignedNodes as $node )
                        {
                            if ( eZOperationHandler::operationIsAvailable( 'content_updatesection' ) )
                            {
                                $operationResult = eZOperationHandler::execute( 'content',
                                                                                'updatesection',
                                                                                array( 'node_id'             => $node->attribute( 'node_id' ),
                                                                                       'selected_section_id' => $selectedSectionID ),
                                                                                null,
                                                                                true );

                            }
                            else
                            {
                                eZContentOperationCollection::updateSection( $node->attribute( 'node_id' ), $selectedSectionID );
                            }
                        }
                    }
                    else
                    {
                        // If there are no assigned nodes we should update db for the current object.
                        $objectID = $object->attribute( 'id' );
                        $db->query( "UPDATE ezcontentobject SET section_id='$selectedSectionID' WHERE id = '$objectID'" );
                        $db->query( "UPDATE ezsearch_object_word_link SET section_id='$selectedSectionID' WHERE  contentobject_id = '$objectID'" );
                    }
                    $object->expireAllViewCache();
                    $db->commit();
                }
                else
                {
                    eZDebug::writeError( "You do not have permissions to assign the section <" . $selectedSection->attribute( 'name' ) .
                                         "> to the object <" . $object->attribute( 'name' ) . ">." );
                }
                $module->redirectToView( 'edit', array( $object->attribute( 'id' ), $editVersion, $editLanguage, $fromLanguage ) );
            }
        }
    }
}
 static function create($type, $text = false, $creatorID = false)
 {
     $date_time = time();
     if ($creatorID === false) {
         $user = eZUser::currentUser();
         $creatorID = $user->attribute('contentobject_id');
     }
     return new eZCollaborationSimpleMessage(array('message_type' => $type, 'data_text1' => $text, 'creator_id' => $creatorID, 'created' => $date_time, 'modified' => $date_time));
 }
Exemplo n.º 13
0
 function eZOOImport()
 {
     $this->ERROR['number'] = 0;
     $this->ERROR['value'] = '';
     $this->ERROR['description'] = '';
     $currentUser = eZUser::currentUser();
     $this->currentUserID = $currentUser->id();
     $this->ImportDir .= md5(time()) . "/";
 }
 public function setUp()
 {
     parent::setUp();
     $currentUser = eZUser::currentUser();
     $anonymousID = eZUser::anonymousId();
     if ($currentUser->isRegistered()) {
         self::$previousUserID = $currentUser->attribute('contentobject_id');
         eZUser::setCurrentlyLoggedInUser(eZUser::fetch($anonymousID), $anonymousID);
     }
 }
Exemplo n.º 15
0
 function eZOOImport()
 {
     $this->ERROR['number'] = 0;
     $this->ERROR['value'] = '';
     $this->ERROR['description'] = '';
     $currentUser = eZUser::currentUser();
     $this->currentUserID = $currentUser->id();
     $this->ImportDir .= md5(time()) . "/";
     $this->ooINI = eZINI::instance('odf.ini');
 }
Exemplo n.º 16
0
 private static function userHasAccessToModule()
 {
     $user = eZUser::currentUser();
     if ($user instanceof eZUser) {
         $result = $user->hasAccessTo('push');
         if ($result['accessWord'] == 'no') {
             return false;
         }
     }
     return true;
 }
 function execute($process, $event)
 {
     $user = eZUser::currentUser();
     if ($user->isLoggedIn()) {
         return eZWorkflowType::STATUS_ACCEPTED;
     }
     $http = eZHTTPTool::instance();
     // Get current content object ID.
     $parameters = $process->attribute('parameter_list');
     $nodeID = $parameters['node_id'];
     $node = eZContentObjectTreeNode::fetch($nodeID);
     if (!$node) {
         return eZWorkflowType::STATUS_REJECTED;
     }
     $objectID = $node->attribute('contentobject_id');
     // Get newsletter hash
     $uri = $GLOBALS['eZRequestedURI'];
     $userParameters = $uri->userParameters();
     $hash = isset($userParameters['hash']) ? $userParameters['hash'] : false;
     $sendItem = eZSendNewsletterItem::fetchByHash($hash);
     if ($http->hasSessionVariable('NewsletterNodeIDArray')) {
         $globalNodeIDList = $http->sessionVariable('NewsletterNodeIDArray');
         if (in_array($nodeID, $http->sessionVariable('NewsletterNodeIDArray'))) {
             $sendID = $http->sessionVariable('NewletterNodeMap_' . $nodeID);
             $sendItem = eZSendNewsletterItem::fetch($sendID);
             $sendItem->addObjectRead($objectID);
             return eZWorkflowType::STATUS_ACCEPTED;
         }
     }
     // Get send item, and check that is contains the object id.
     if (!$sendItem) {
         return eZWorkflowType::STATUS_REJECTED;
     }
     $sendItemIDList = $sendItem->attribute('newsletter_related_object_list');
     if (!$sendItemIDList || !in_array($objectID, $sendItemIDList)) {
         return eZWorkflowType::STATUS_REJECTED;
     }
     $sendNodeIDArray = array();
     // Set session variables
     foreach ($sendItemIDList as $sendObjectID) {
         $sendObject = eZContentObject::fetch($sendObjectID);
         if ($sendObject) {
             foreach ($sendObject->assignedNodes(false) as $nodeArray) {
                 $http->setSessionVariable('NewletterNodeMap_' . $nodeArray['node_id'], $sendItem->attribute('id'));
                 $sendNodeIDArray[] = $nodeArray['node_id'];
             }
         }
     }
     $globalNodeIDList = array_unique(array_merge($globalNodeIDList, $sendNodeIDArray));
     $http->setSessionVariable('NewsletterNodeIDArray', $globalNodeIDList);
     // Add object read
     $sendItem->addObjectRead($objectID);
     return eZWorkflowType::STATUS_ACCEPTED;
 }
 public function setUp()
 {
     parent::setUp();
     $adminObjectID = eZUser::fetchByName('admin')->attribute('contentobject_id');
     // Create approval workflow and set up pre publish trigger
     $this->workflow = $this->createApprovalWorkFlow($adminObjectID);
     $this->trigger = $this->createTrigger($this->workflow->attribute('id'));
     // Log in as a user who needs approval.
     $this->currentUser = eZUser::currentUser();
     $anonymous = eZUser::fetchByName('anonymous');
     eZUser::setCurrentlyLoggedInUser($anonymous, $anonymous->attribute('contentobject_id'));
 }
Exemplo n.º 19
0
 public function doGetAll()
 {
     $result = new ezpRestMvcResult();
     // Header
     $tpl = eZTemplate::factory();
     $tpl->setVariable('current_user', eZUser::currentUser());
     $result->variables['menu'] = $tpl->fetch('design:page_topmenu.tpl');
     $result->variables['news'] = $tpl->fetch('design:parts/news_header.tpl');
     $result->variables['styles_ie'] = $tpl->fetch('design:page_head_style_ie.tpl');
     $result->variables['footer'] = $tpl->fetch('design:page_footer.tpl');
     return $result;
 }
 /**
  * Returns if email is generated or not
  *
  * @return array
  */
 public static function emailIsGenerated()
 {
     $currentUser = eZUser::currentUser();
     if ($currentUser instanceof eZUser) {
         $pos = strpos($currentUser->Login, "ngconnect_", 0);
         if ($pos !== false && $pos === 0) {
             if (strpos($currentUser->Email, "@localhost.local", 0) === strlen($currentUser->Email) - 16) {
                 return array('result' => true);
             }
         }
     }
     return array('result' => false);
 }
Exemplo n.º 21
0
 /**
  * Regression test for issue #15263
  * Content object name/url of imported content classes aren't generated correctly
  *
  * @url http://issues.ez.no/15263
  *
  * @outline
  * 1) Expire and force generation of class attribute cache
  * 2) Load a test package
  * 3) Install the package
  * 4) Publish an object of the imported class
  * 5) The object name / url alias shouldn't be the expected one
  **/
 public function testIssue15263()
 {
     $adminUser = eZUser::fetchByName('admin');
     $previousUser = eZUser::currentUser();
     eZUser::setCurrentlyLoggedInUser($adminUser, $adminUser->attribute('contentobject_id'));
     // 1) Expire and force generation of class attribute cache
     $handler = eZExpiryHandler::instance();
     $handler->setTimestamp('class-identifier-cache', time() - 1);
     $handler->store();
     eZContentClassAttribute::classAttributeIdentifierByID(1);
     // 1) Load a test package
     $packageName = 'ezpackage_regression_testIssue15223.ezpkg';
     $packageFilename = dirname(__FILE__) . DIRECTORY_SEPARATOR . $packageName;
     $packageImportTried = false;
     while (!$packageImportTried) {
         $package = eZPackage::import($packageFilename, $packageName);
         if (!$package instanceof eZPackage) {
             if ($package === eZPackage::STATUS_ALREADY_EXISTS) {
                 $packageToRemove = eZPackage::fetch($packageName);
                 $packageToRemove->remove();
             } else {
                 self::fail("An error occured loading the package '{$packageFilename}'");
             }
         }
         $packageImportTried = true;
     }
     // 2) Install the package
     $installParameters = array('site_access_map' => array('*' => false), 'top_nodes_map' => array('*' => 2), 'design_map' => array('*' => false), 'restore_dates' => true, 'user_id' => $adminUser->attribute('contentobject_id'), 'non-interactive' => true, 'language_map' => $package->defaultLanguageMap());
     $result = $package->install($installParameters);
     // 3) Publish an object of the imported class
     $object = new ezpObject('test_issue_15523', 2, $adminUser->attribute('contentobject_id'), 1);
     $object->myname = __METHOD__;
     $object->myothername = __METHOD__;
     $publishedObjectID = $object->publish();
     unset($object);
     // 4) Test data from the publish object
     $publishedNodeArray = eZContentObjectTreeNode::fetchByContentObjectID($publishedObjectID);
     if (count($publishedNodeArray) != 1) {
         $this->fail("An error occured fetching node for object #{$publishedObjectID}");
     }
     $publishedNode = $publishedNodeArray[0];
     if (!$publishedNode instanceof eZContentObjectTreeNode) {
         $this->fail("An error occured fetching node for object #{$publishedObjectID}");
     } else {
         $this->assertEquals("eZPackageRegression::testIssue15263", $publishedNode->attribute('name'));
         $this->assertEquals("eZPackageRegression-testIssue15263", $publishedNode->attribute('url_alias'));
     }
     // Remove the installed package & restore the logged in user
     $package->remove();
     eZUser::setCurrentlyLoggedInUser($previousUser, $previousUser->attribute('contentobject_id'));
 }
Exemplo n.º 22
0
 /**
  * Called by PHPUnit before each test.
  */
 public function setUp()
 {
     // Call the setUp() in ezpDatabaseTestCase
     parent::setUp();
     // get server url
     $this->ezp_server = eZINI::instance()->variable('SiteSettings', 'SiteURL');
     // login admin
     $this->currentUser = eZUser::currentUser();
     $admin = eZUser::fetchByName('admin');
     eZUser::setCurrentlyLoggedInUser($admin, $admin->attribute('contentobject_id'));
     $this->ezp_admin_id = $admin->attribute('contentobject_id');
     $this->ezp_admin_email = $admin->attribute('email');
     $this->test_data_folder = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ezrss' . DIRECTORY_SEPARATOR;
 }
 function fetchParticipant($itemID, $participantID)
 {
     if ($participantID === false) {
         $user = eZUser::currentUser();
         $participantID = $user->attribute('contentobject_id');
     }
     $participant = eZCollaborationItemParticipantLink::fetch($itemID, $participantID);
     if ($participant === null) {
         $resultArray = array('error' => array('error_type' => 'kernel', 'error_code' => eZError::KERNEL_NOT_FOUND));
     } else {
         $resultArray = array('result' => $participant);
     }
     return $resultArray;
 }
 function accountName($order = false)
 {
     if ($order === false) {
         $user = eZUser::currentUser();
     } else {
         $user = $order->attribute('user');
     }
     if (is_object($user)) {
         $userObject = $user->attribute('contentobject');
         $accountName = $userObject->attribute('name');
     } else {
         $accountName = null;
     }
     return $accountName;
 }
 /**
  * Called by PHPUnit before each test.
  */
 public function setUp()
 {
     // Call the setUp() in ezpDatabaseTestCase
     parent::setUp();
     // get server url
     $this->ezp_server = eZINI::instance()->variable('SiteSettings', 'SiteURL');
     // login admin
     $this->currentUser = eZUser::currentUser();
     $admin = eZUser::fetchByName('admin');
     eZUser::setCurrentlyLoggedInUser($admin, $admin->attribute('contentobject_id'));
     $this->ezp_admin_id = $admin->attribute('contentobject_id');
     $this->ezp_admin_email = $admin->attribute('email');
     $this->test_data_folder = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ezrss' . DIRECTORY_SEPARATOR;
     $this->remote_id_map = array('894c0959925a6ac47c915b7c8fb6376c', '935f192b93cbadbbf93d7b031bdceb70');
 }
Exemplo n.º 26
0
 public function getDraftVersions($objects)
 {
     $return = array();
     $user = eZUser::currentUser();
     foreach ($objects as $object) {
         // If this user already has a draft in this language
         $filters = array('contentobject_id' => $object->attribute('id'), 'status' => array(array(eZContentObjectVersion::STATUS_DRAFT, eZContentObjectVersion::STATUS_INTERNAL_DRAFT)), 'creator_id' => $user->attribute('contentobject_id'));
         $existingDrafts = eZContentObjectVersion::fetchFiltered($filters, 0, 1);
         if (!empty($existingDrafts)) {
             $return[] = $existingDrafts[0];
         } else {
             $return[] = $object->createNewVersion(false, true);
         }
     }
     return $return;
 }
 /**
  * Returns a shared instance of the eZCollaborationProfile class
  * pr user id.
  * note: Transaction unsafe. If you call several transaction unsafe methods you must enclose
  * the calls within a db transaction; thus within db->begin and db->commit.
  *
  * @param int|false $userID Uses current user id if false.
  * @return eZCollaborationProfile
  */
 static function instance($userID = false)
 {
     if ($userID === false) {
         $user = eZUser::currentUser();
         $userID = $user->attribute('contentobject_id');
     }
     $instance =& $GLOBALS["eZCollaborationProfile-{$userID}"];
     if (!isset($instance)) {
         $instance = eZCollaborationProfile::fetchByUser($userID);
         if ($instance === null) {
             $group = eZCollaborationGroup::instantiate($userID, ezpI18n::tr('kernel/classes', 'Inbox'));
             $instance = eZCollaborationProfile::create($userID, $group->attribute('id'));
             $instance->store();
         }
     }
     return $instance;
 }
 /**
  * Returns an array of mime types.
  *
  * @param eZContentObjectTreeNode $parent_node
  * @return array
  */
 static function canUploadMimeTypes($parent_node)
 {
     $return = false;
     $user = eZUser::currentUser();
     $accessResult = $user->hasAccessTo('admin_edit', 'upload_files');
     switch ($accessResult['accessWord']) {
         case 'yes':
             $return = MugoBootStrapAdminFunctions::getMimeTypes();
             break;
         case 'no':
             // still false
             break;
         case 'limited':
             $return = self::matches_limitation($accessResult['policies'], $parent_node);
             break;
         default:
     }
     return array('result' => $return);
 }
Exemplo n.º 29
0
 function store($publish = false)
 {
     if ($publish) {
         $originalVersion = $this->attribute('version');
         $this->setAttribute('version', eZPDFExport::VERSION_VALID);
     }
     $user = eZUser::currentUser();
     $this->setAttribute('modified', time());
     $this->setAttribute('modifier_id', $user->attribute('contentobject_id'));
     $db = eZDB::instance();
     $db->begin();
     parent::store();
     if ($publish) {
         $this->setAttribute('version', eZPDFExport::VERSION_DRAFT);
         $this->remove();
         $this->setAttribute('version', $originalVersion);
     }
     $db->commit();
 }
 /**
  * Create new CjwNewsletterEditionSend object
  *
  * @param CjwNewsletterEdition $editionObject
  * @return object
  */
 static function create(CjwNewsletterEdition $editionObject)
 {
     $editionContentObjectId = $editionObject->attribute('contentobject_id');
     $editionContentObjectVersion = $editionObject->attribute('contentobject_attribute_version');
     $user = eZUser::currentUser();
     $creatorId = $user->attribute('contentobject_id');
     // $outputXml = '<xml>hali hallo</xml>';
     $outputXml = $editionObject->createOutputXml();
     $listAttributeContent = $editionObject->attribute('list_attribute_content');
     $listContentObjectId = $listAttributeContent->attribute('contentobject_id');
     $outputFormatArrayString = $listAttributeContent->attribute('output_format_array_string');
     $mainSiteAccess = $listAttributeContent->attribute('main_siteaccess');
     $emailSender = $listAttributeContent->attribute('email_sender');
     $emailSenderName = $listAttributeContent->attribute('email_sender_name');
     $personalizeContent = $listAttributeContent->attribute('personalize_content');
     $rows = array('list_contentobject_id' => $listContentObjectId, 'edition_contentobject_id' => $editionContentObjectId, 'edition_contentobject_version' => $editionContentObjectVersion, 'siteaccess' => $mainSiteAccess, 'output_format_array_string' => $outputFormatArrayString, 'created' => time(), 'creator_id' => $creatorId, 'status' => CjwNewsletterEditionSend::STATUS_WAIT_FOR_PROCESS, 'output_xml' => $outputXml, 'hash' => CjwNewsletterUtils::generateUniqueMd5Hash($listContentObjectId . $editionContentObjectId . $editionContentObjectVersion), 'email_sender' => $emailSender, 'email_sender_name' => $emailSenderName, 'personalize_content' => $personalizeContent);
     $object = new CjwNewsletterEditionSend($rows);
     return $object;
 }