當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserUtil::isRegistration方法代碼示例

本文整理匯總了PHP中UserUtil::isRegistration方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserUtil::isRegistration方法的具體用法?PHP UserUtil::isRegistration怎麽用?PHP UserUtil::isRegistration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserUtil的用法示例。


在下文中一共展示了UserUtil::isRegistration方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getAcceptedPolicies

    /**
     * Retrieves flags indicating which policies the user with the given uid has already accepted.
     *
     * @param numeric $uid A valid uid.
     *
     * @return array An array containing flags indicating whether each policy has been accepted by the user or not.
     */
    public function getAcceptedPolicies($uid = null)
    {
        if (!is_null($uid)) {
            $isRegistration = UserUtil::isRegistration($uid);
        } else {
            $isRegistration = false;
        }

        $termsOfUseAcceptedDateStr              = $this->determineAcceptanceState($uid, $isRegistration, Legal_Constant::ATTRIBUTE_TERMSOFUSE_ACCEPTED);
        $privacyPolicyAcceptedDateStr           = $this->determineAcceptanceState($uid, $isRegistration, Legal_Constant::ATTRIBUTE_PRIVACYPOLICY_ACCEPTED);
        $agePolicyConfirmedDateStr              = $this->determineAcceptanceState($uid, $isRegistration, Legal_Constant::ATTRIBUTE_AGEPOLICY_CONFIRMED);
        $cancellationRightPolicyAcceptedDateStr = $this->determineAcceptanceState($uid, $isRegistration, Legal_Constant::ATTRIBUTE_CANCELLATIONRIGHTPOLICY_ACCEPTED);
        $tradeConditionsAcceptedDateStr         = $this->determineAcceptanceState($uid, $isRegistration, Legal_Constant::ATTRIBUTE_TRADECONDITIONS_ACCEPTED);

        $termsOfUseAcceptedDate                 = $termsOfUseAcceptedDateStr                ? new DateTime($termsOfUseAcceptedDateStr)              : false;
        $privacyPolicyAcceptedDate              = $privacyPolicyAcceptedDateStr             ? new DateTime($privacyPolicyAcceptedDateStr)           : false;
        $agePolicyConfirmedDate                 = $agePolicyConfirmedDateStr                ? new DateTime($agePolicyConfirmedDateStr)              : false;
        $cancellationRightPolicyAcceptedDate    = $cancellationRightPolicyAcceptedDateStr   ? new DateTime($cancellationRightPolicyAcceptedDateStr) : false;
        $tradeConditionsAcceptedDate            = $tradeConditionsAcceptedDateStr           ? new DateTime($tradeConditionsAcceptedDateStr)         : false;

        $now = new DateTime();

        $termsOfUseAccepted                 = $termsOfUseAcceptedDate               ? ($termsOfUseAcceptedDate <= $now)                 : false;
        $privacyPolicyAccepted              = $privacyPolicyAcceptedDate            ? ($privacyPolicyAcceptedDate <= $now)              : false;
        $agePolicyConfirmed                 = $agePolicyConfirmedDate               ? ($agePolicyConfirmedDate <= $now)                 : false;
        $cancellationRightPolicyAccepted    = $cancellationRightPolicyAcceptedDate  ? ($cancellationRightPolicyAcceptedDate <= $now)    : false;
        $tradeConditionsAccepted            = $tradeConditionsAcceptedDate          ? ($tradeConditionsAcceptedDate <= $now)            : false;

        return array(
            'termsOfUse'                => $termsOfUseAccepted,
            'privacyPolicy'             => $privacyPolicyAccepted,
            'agePolicy'                 => $agePolicyConfirmed,
            'cancellationRightPolicy'   => $cancellationRightPolicyAccepted,
            'tradeConditions'           => $tradeConditionsAccepted
        );
    }
開發者ID:projectesIF,項目名稱:Sirius,代碼行數:43,代碼來源:AcceptPolicies.php

示例2: processEdit

    /**
     * Responds to process_edit hook-like event notifications.
     *
     * @param Zikula_Event $event The event that triggered this function call.
     *
     * @return void
     *
     * @throws Zikula_Exception_Fatal Thrown if a user account does not exist for the uid specified by the event.
     */
    public function processEdit(Zikula_Event $event)
    {
        $activePolicies = $this->helper->getActivePolicies();
        $eventName = $event->getName();

        if (isset($this->validation) && !$this->validation->hasErrors()) {
            $user = $event->getSubject();
            $uid = $user['uid'];

            if (!UserUtil::isLoggedIn()) {
                if (($eventName == 'module.users.ui.process_edit.login_screen') || ($eventName == 'module.users.ui.process_edit.login_block')) {
                    $policiesAcceptedAtLogin = $this->validation->getObject();

                    $nowUTC = new DateTime('now', new DateTimeZone('UTC'));
                    $nowUTCStr = $nowUTC->format(DateTime::ISO8601);

                    if ($activePolicies['termsOfUse'] && $policiesAcceptedAtLogin['termsOfUse']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_TERMSOFUSE_ACCEPTED, $nowUTCStr, $uid);
                    }

                    if ($activePolicies['privacyPolicy'] && $policiesAcceptedAtLogin['privacyPolicy']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_PRIVACYPOLICY_ACCEPTED, $nowUTCStr, $uid);
                    }

                    if ($activePolicies['agePolicy'] && $policiesAcceptedAtLogin['agePolicy']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_AGEPOLICY_CONFIRMED, $nowUTCStr, $uid);
                    }

                    if ($activePolicies['cancellationRightPolicy'] && $policiesAcceptedAtLogin['cancellationRightPolicy']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_CANCELLATIONRIGHTPOLICY_ACCEPTED, $nowUTCStr, $uid);
                    }

                    if ($activePolicies['tradeConditions'] && $policiesAcceptedAtLogin['tradeConditions']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_TRADECONDITIONS_ACCEPTED, $nowUTCStr, $uid);
                    }

                    // Force the reload of the user record
                    $user = UserUtil::getVars($uid, true);
                } else {
                    $isRegistration = UserUtil::isRegistration($uid);

                    $user = UserUtil::getVars($uid, false, 'uid', $isRegistration);
                    if (!$user) {
                        throw new Zikula_Exception_Fatal(__('A user account or registration does not exist for the specified uid.', $this->domain));
                    }

                    $policiesAcceptedAtRegistration = $this->validation->getObject();

                    $nowUTC = new DateTime('now', new DateTimeZone('UTC'));
                    $nowUTCStr = $nowUTC->format(DateTime::ISO8601);

                    if ($activePolicies['termsOfUse'] && $policiesAcceptedAtRegistration['termsOfUse']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_TERMSOFUSE_ACCEPTED, $nowUTCStr, $uid);
                    }

                    if ($activePolicies['privacyPolicy'] && $policiesAcceptedAtRegistration['privacyPolicy']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_PRIVACYPOLICY_ACCEPTED, $nowUTCStr, $uid);
                    }

                    if ($activePolicies['agePolicy'] && $policiesAcceptedAtRegistration['agePolicy']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_AGEPOLICY_CONFIRMED, $nowUTCStr, $uid);
                    }

                    if ($activePolicies['cancellationRightPolicy'] && $policiesAcceptedAtRegistration['cancellationRightPolicy']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_CANCELLATIONRIGHTPOLICY_ACCEPTED, $nowUTCStr, $uid);
                    }

                    if ($activePolicies['tradeConditions'] && $policiesAcceptedAtRegistration['tradeConditions']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_TRADECONDITIONS_ACCEPTED, $nowUTCStr, $uid);
                    }

                    // Force the reload of the user record
                    $user = UserUtil::getVars($uid, true, 'uid', $isRegistration);
                }
            } else {
                $isRegistration = UserUtil::isRegistration($uid);

                $user = UserUtil::getVars($uid, false, 'uid', $isRegistration);
                if (!$user) {
                    throw new Zikula_Exception_Fatal(__('A user account or registration does not exist for the specified uid.', $this->domain));
                }

                $policiesAcceptedAtRegistration = $this->validation->getObject();
                $editablePolicies = $this->helper->getEditablePolicies();

                $nowUTC = new DateTime('now', new DateTimeZone('UTC'));
                $nowUTCStr = $nowUTC->format(DateTime::ISO8601);

                if ($activePolicies['termsOfUse'] && $editablePolicies['termsOfUse']) {
                    if ($policiesAcceptedAtRegistration['termsOfUse']) {
                        UserUtil::setVar(Legal_Constant::ATTRIBUTE_TERMSOFUSE_ACCEPTED, $nowUTCStr, $uid);
//.........這裏部分代碼省略.........
開發者ID:projectesIF,項目名稱:Sirius,代碼行數:101,代碼來源:UsersUiHandler.php

示例3: smarty_function_duditemmodify

/**
 * Smarty function to display an editable dynamic user data field.
 *
 * Example
 * {duditemmodify propattribute='avatar'}
 *
 * Example
 * {duditemmodify propattribute='realname' uid=$uid}
 *
 * Example
 * {duditemmodify item=$item}
 *
 * Parameters passed in via the $params array:
 * -------------------------------------------
 * string item          The Profile DUD item.
 * string uid           User ID to display the field value for (-1 = do not load).
 * string class         CSS class to assign to the table row/form row div (optional).
 * string proplabel     Property label to display (optional overrides the preformated dud item $item).
 * string propattribute Property attribute to display.
 * string error         Property error message.
 * 
 * @param array  $params  All attributes passed to this function from the template.
 * @param object &$smarty Reference to the Zikula_View/Smarty object.
 * 
 * @return string|boolean The results of the module function; empty string if the Profile module is not available; false if error.
 */
function smarty_function_duditemmodify($params, &$smarty)
{
    extract($params);
    unset($params);

    if (!ModUtil::available('Profile')) {
        return '';
    }

    if (!isset($item)) {
        if (isset($proplabel)) {
            $item = ModUtil::apiFunc('Profile', 'user', 'get', array('proplabel' => $proplabel));
        } else if (isset($propattribute)) {
            $item = ModUtil::apiFunc('Profile', 'user', 'get', array('propattribute' => $propattribute));
        } else {
            return false;
        }
    }
    if (!isset($item) || empty ($item)) {
        return false;
    }

    // detect if we are in the registration form
    $onregistrationform = false;
    
    // TODO - will these globals always be available? Is there a utility method out there somewhere to get these?
    global $module, $func;
    
    if (strtolower($module) == 'users' && strtolower($func) == 'register') {
        $onregistrationform = true;
    }

    // skip the field if not configured to be on the registration form 
    if ($onregistrationform && !$item['prop_required']) {
        $dudregshow = ModUtil::getVar('Profile', 'dudregshow', array());
        if (!in_array($item['prop_id'], $dudregshow)) {
            return '';
        }
    }

    $dom = ZLanguage::getModuleDomain('Profile');

    if (!isset($uid)) {
        $uid = UserUtil::getVar('uid');
    }
    if (!isset($class) || !is_string($class)) {
        $class = '';
    }

    if (isset($item['temp_propdata'])) {
        $uservalue = $item['temp_propdata'];
    } elseif ($uid >= 0) {
        // TODO - This is a bit of a hack for admin editing. Need to know if it is a reg.
        $user = UserUtil::getVars($uid);
        $isRegistration = UserUtil::isRegistration($uid);
        $uservalue = UserUtil::getVar($item['prop_attribute_name'], $uid, false, $isRegistration); // ($alias, $uid);
    }

    // try to get the DUD output if it's Third Party
    if ($item['prop_dtype'] != 1) {
        $output = ModUtil::apiFunc($item['prop_modname'], 'dud', 'edit',
                               array('item'      => $item,
                                     'uservalue' => $uservalue,
                                     'class'     => $class));
        if ($output) {
            return $output;
        }
    }

    $render = $smarty;//Zikula_View::getInstance('Profile', false, null, true);

    // assign the default values for the control
    $render->assign('class',         $class);
    $render->assign('value',         DataUtil::formatForDisplay($uservalue));
//.........這裏部分代碼省略.........
開發者ID:projectesIF,項目名稱:Sirius,代碼行數:101,代碼來源:function.duditemmodify.php


注:本文中的UserUtil::isRegistration方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。