当前位置: 首页>>代码示例>>PHP>>正文


PHP eZSession::userHasSessionCookie方法代码示例

本文整理汇总了PHP中eZSession::userHasSessionCookie方法的典型用法代码示例。如果您正苦于以下问题:PHP eZSession::userHasSessionCookie方法的具体用法?PHP eZSession::userHasSessionCookie怎么用?PHP eZSession::userHasSessionCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZSession的用法示例。


在下文中一共展示了eZSession::userHasSessionCookie方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: rate

 /**
  * Rate content object attribute id
  *
  * @param array $args ( 0 => contentobjectattribute_id,  1 => contentobject_version, 2 => rating )
  * @return array
  */
 public static function rate($args)
 {
     $ret = array('id' => 0, 'rated' => false, 'already_rated' => false, 'stats' => false);
     if (isset($args[0])) {
         $ret['id'] = $args[0];
     }
     if (!isset($args[2]) || !is_numeric($args[0]) || !is_numeric($args[1]) || !is_numeric($args[2]) || $args[2] > 5 || $args[2] < 1) {
         return $ret;
     }
     // Provide extra session protection on 4.1 (not possible on 4.0) by expecting user
     // to have an existing session (new session = mostlikely a spammer / hacker trying to manipulate rating)
     if (class_exists('eZSession') && eZSession::userHasSessionCookie() !== true) {
         return $ret;
     }
     // Return if parameters are not valid attribute id + version numbers
     $contentobjectAttribute = eZContentObjectAttribute::fetch($ret['id'], $args[1]);
     if (!$contentobjectAttribute instanceof eZContentObjectAttribute) {
         return $ret;
     }
     // Return if attribute is not a rating attribute
     if ($contentobjectAttribute->attribute('data_type_string') !== ezsrRatingType::DATA_TYPE_STRING) {
         return $ret;
     }
     // Return if rating has been disabled on current attribute
     if ($contentobjectAttribute->attribute('data_int')) {
         return $ret;
     }
     // Return if user does not have access to object
     $contentobject = $contentobjectAttribute->attribute('object');
     if (!$contentobject instanceof eZContentObject || !$contentobject->attribute('can_read')) {
         return $ret;
     }
     $rateDataObj = ezsrRatingDataObject::create(array('contentobject_id' => $contentobjectAttribute->attribute('contentobject_id'), 'contentobject_attribute_id' => $ret['id'], 'rating' => $args[2]));
     $proiorRating = $rateDataObj->userHasRated(true);
     if ($proiorRating === true) {
         $ret['already_rated'] = true;
     } else {
         if ($proiorRating instanceof ezsrRatingDataObject) {
             $rateDataObj = $proiorRating;
             $rateDataObj->setAttribute('rating', $args[2]);
             $ret['already_rated'] = true;
             $proiorRating = false;
             // just to reuse code bellow
         }
     }
     if (!$proiorRating) {
         $rateDataObj->store();
         $avgRateObj = $rateDataObj->getAverageRating();
         $avgRateObj->updateFromRatingData();
         $avgRateObj->store();
         eZContentCacheManager::clearContentCacheIfNeeded($rateDataObj->attribute('contentobject_id'));
         $ret['rated'] = true;
         $ret['stats'] = array('rating_count' => $avgRateObj->attribute('rating_count'), 'rating_average' => $avgRateObj->attribute('rating_average'), 'rounded_average' => $avgRateObj->attribute('rounded_average'));
     }
     return $ret;
 }
开发者ID:BGCX067,项目名称:ezpublish-thetechtalent-svn-to-git,代码行数:62,代码来源:ezsrserverfunctions.php

示例2: array

 $userClientValidates = true;
 $doValidationRedirect = false;
 if (!eZSession::userHasSessionCookie()) {
     if ($redirectNumber == '2') {
         $userClientValidates = false;
     } else {
         $doValidationRedirect = true;
     }
 }
 if ($doValidationRedirect) {
     $db->rollback();
     return $Module->redirectTo('/user/register/2');
 } else {
     if (!$userClientValidates) {
         $db->rollback();
         $tpl->setVariable('user_has_cookie', eZSession::userHasSessionCookie(), 'User');
         $tpl->setVariable('user_session_validates', true, 'User');
         $Result = array();
         $Result['content'] = $tpl->fetch('design:user/register_user_not_valid.tpl');
         $Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('kernel/user', 'User')), array('url' => false, 'text' => ezpI18n::tr('kernel/user', 'Register')));
         return $Result;
     }
 }
 // else create user object
 if ($http->hasSessionVariable('StartedRegistration')) {
     eZDebug::writeWarning('Cancel module run to protect against multiple form submits', 'user/register');
     $http->removeSessionVariable("RegisterUserID");
     $http->removeSessionVariable('StartedRegistration');
     $db->commit();
     return eZModule::HOOK_STATUS_CANCEL_RUN;
 } else {
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:31,代码来源:register.php

示例3: rate

    /**
     * Rate content object attribute id
     *
     * @param array $args ( 0 => contentobjectattribute_id,  1 => contentobject_version, 2 => rating )
     * @return array
     */
    public static function rate( $args )
    {
        $ret = array( 'id' => 0, 'rated' => false, 'already_rated' => false, 'stats' => false );
        if ( !isset( $args[2] ) )
            throw new LengthException( 'Rating expects 3 arguments: attr_id, version, rating' );
        else if ( !is_numeric( $args[0] ) )
            throw new InvalidArgumentException( 'Rating argument[0] attr_id must be a number' );
        else if ( !is_numeric( $args[1] ) )
            throw new InvalidArgumentException( 'Rating argument[1] version must be a number' );
        else if ( !is_numeric( $args[2] ) )
            throw new InvalidArgumentException( 'Rating argument[2] rating must be a number' );
        else if ( $args[2] > 5 || $args[2] < 1 )
            throw new UnexpectedValueException( 'Rating argument[2] rating must be between 1 and 5' );

        $ret['id'] = (int) $args[0];

        // Provide extra session protection on 4.1 (not possible on 4.0) by expecting user
        // to have an existing session (new session = mostlikely a spammer / hacker trying to manipulate rating)
        if (
            eZSession::userHasSessionCookie() !== true
            && eZINI::instance()->variable( 'eZStarRating', 'AllowAnonymousRating' ) === 'disabled'
        )
            return $ret;

        // Return if parameters are not valid attribute id + version numbers
        $contentobjectAttribute = eZContentObjectAttribute::fetch( $ret['id'], $args[1] );
        if ( !$contentobjectAttribute instanceof eZContentObjectAttribute )
            return $ret;

        // Return if attribute is not a rating attribute
        if ( $contentobjectAttribute->attribute('data_type_string') !== ezsrRatingType::DATA_TYPE_STRING )
            return $ret;

        // Return if rating has been disabled on current attribute
        if ( $contentobjectAttribute->attribute('data_int') )
            return $ret;

        // Return if user does not have access to object
        $contentobject = $contentobjectAttribute->attribute('object');
        if ( !$contentobject instanceof eZContentObject || !$contentobject->attribute('can_read') )
            return $ret;

        $rateDataObj = ezsrRatingDataObject::create( array( 'contentobject_id' => $contentobjectAttribute->attribute('contentobject_id'),
                                                    'contentobject_attribute_id' =>  $ret['id'],
                                                    'rating' => $args[2]
        ));

        $proiorRating = $rateDataObj->userHasRated( true );

        if ( $proiorRating === true )
        {
            $ret['already_rated'] = true;
        }
        else if ( $proiorRating instanceof ezsrRatingDataObject )
        {
            $rateDataObj = $proiorRating;
            $rateDataObj->setAttribute( 'rating', $args[2] );
            $ret['already_rated'] = true;
            $proiorRating = false;// just to reuse code bellow
        }

        if ( !$proiorRating )
        {
            $rateDataObj->store();
            $avgRateObj = $rateDataObj->getAverageRating();
            $avgRateObj->updateFromRatingData();
            $avgRateObj->store();
            eZContentCacheManager::clearContentCacheIfNeeded( $rateDataObj->attribute('contentobject_id') );
            $ret['rated'] = true;
            $ret['stats'] = array(
               'rating_count' => $avgRateObj->attribute('rating_count'),
               'rating_average' => $avgRateObj->attribute('rating_average'),
               'rounded_average' => $avgRateObj->attribute('rounded_average'),
            );
        }
        return $ret;
    }
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:83,代码来源:ezsrserverfunctions.php


注:本文中的eZSession::userHasSessionCookie方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。