Esempio n. 1
0
 public function setState()
 {
     $http = eZHTTPTool::instance();
     if ($http->hasGetVariable('state')) {
         $this->connection->setState(base64_encode($http->getVariable('state')));
     }
 }
 /**
  * Handles redirection to the mobile optimized interface
  *
  */
 public function redirect()
 {
     $http = eZHTTPTool::instance();
     $currentSiteAccess = eZSiteAccess::current();
     if ($http->hasGetVariable('notmobile')) {
         setcookie('eZMobileDeviceDetect', 1, time() + (int) eZINI::instance()->variable('SiteAccessSettings', 'MobileDeviceDetectCookieTimeout'), '/');
         $http->redirect(eZSys::indexDir());
         eZExecution::cleanExit();
     }
     if (!isset($_COOKIE['eZMobileDeviceDetect']) && !in_array($currentSiteAccess['name'], eZINI::instance()->variable('SiteAccessSettings', 'MobileSiteAccessList'))) {
         $currentUrl = eZSys::serverURL() . eZSys::requestURI();
         $redirectUrl = eZINI::instance()->variable('SiteAccessSettings', 'MobileSiteAccessURL');
         // Do not redirect if already on the redirect url
         if (strpos($currentUrl, $redirectUrl) !== 0) {
             // Default siteaccess name needs to be removed from the uri when redirecting
             $uri = explode('/', ltrim(eZSys::requestURI(), '/'));
             if (array_shift($uri) == $currentSiteAccess['name']) {
                 $http->redirect($redirectUrl . '/' . implode('/', $uri));
             } else {
                 $http->redirect($redirectUrl . eZSys::requestURI());
             }
         }
         eZExecution::cleanExit();
     }
 }
 static function fetchIDListByUserID($userID)
 {
     if ($userID == eZUser::anonymousId()) {
         $userCache = eZUSer::getUserCacheByAnonymousId();
         $ruleArray = $userCache['discount_rules'];
     } else {
         $http = eZHTTPTool::instance();
         $handler = eZExpiryHandler::instance();
         $expiredTimeStamp = 0;
         if ($handler->hasTimestamp('user-discountrules-cache')) {
             $expiredTimeStamp = $handler->timestamp('user-discountrules-cache');
         }
         $ruleTimestamp =& $http->sessionVariable('eZUserDiscountRulesTimestamp');
         $ruleArray = false;
         // check for cached version in session
         if ($ruleTimestamp > $expiredTimeStamp) {
             if ($http->hasSessionVariable('eZUserDiscountRules' . $userID)) {
                 $ruleArray =& $http->sessionVariable('eZUserDiscountRules' . $userID);
             }
         }
         if (!is_array($ruleArray)) {
             $ruleArray = self::generateIDListByUserID((int) $userID);
             $http->setSessionVariable('eZUserDiscountRules' . $userID, $ruleArray);
             $http->setSessionVariable('eZUserDiscountRulesTimestamp', time());
         }
     }
     $rules = array();
     foreach ($ruleArray as $ruleRow) {
         $rules[] = $ruleRow['id'];
     }
     return $rules;
 }
 function execute($process, $event)
 {
     $parameters = $process->attribute('parameter_list');
     $http = eZHTTPTool::instance();
     eZDebug::writeNotice($parameters, "parameters");
     $orderID = $parameters['order_id'];
     $order = eZOrder::fetch($orderID);
     if (empty($orderID) || get_class($order) != 'ezorder') {
         eZDebug::writeWarning("Can't proceed without a Order ID.", "SimpleStockCheck");
         return eZWorkflowEventType::STATUS_FETCH_TEMPLATE_REPEAT;
     }
     // Decrement the quantitity field
     $order = eZOrder::fetch($orderID);
     $productCollection = $order->productCollection();
     $ordereditems = $productCollection->itemList();
     foreach ($ordereditems as $item) {
         $contentObject = $item->contentObject();
         $contentObjectVersion = $contentObject->version($contentObject->attribute('current_version'));
         $contentObjectAttributes = $contentObjectVersion->contentObjectAttributes();
         foreach (array_keys($contentObjectAttributes) as $key) {
             $contentObjectAttribute = $contentObjectAttributes[$key];
             $contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
             // Each attribute has an attribute identifier called 'quantity' that identifies it.
             if ($contentClassAttribute->attribute("identifier") == "quantity") {
                 $contentObjectAttribute->setAttribute("data_int", $contentObjectAttribute->attribute("value") - $item->ItemCount);
                 $contentObjectAttribute->store();
             }
         }
     }
     return eZWorkflowEventType::STATUS_ACCEPTED;
 }
 function answer()
 {
     if ($this->Answer !== false) {
         return $this->Answer;
     }
     $http = eZHTTPTool::instance();
     $prefix = eZSurveyType::PREFIX_ATTRIBUTE;
     $postSurveyAnswer = $prefix . '_ezsurvey_answer_' . $this->ID . '_' . $this->contentObjectAttributeID();
     if ($http->hasPostVariable($postSurveyAnswer)) {
         $surveyAnswer = $http->postVariable($postSurveyAnswer);
         return $surveyAnswer;
     }
     $user = eZUser::instance();
     $value = $this->Default;
     if ($user->isLoggedIn() === true) {
         switch ($this->Text3) {
             case "user_email":
                 $value = $this->userEmail();
                 break;
             case "user_name":
                 $value = $this->userName();
                 break;
             default:
                 $value = $this->defaultUserValue();
         }
     }
     return $value;
 }
    static function createClass( $tpl,
                                 $module,
                                 $stepArray,
                                 $basePath,
                                 $storageName = false,
                                 $metaData = false )
    {
        if ( !$storageName )
        {
            $storageName = 'eZWizard';
        }

        if ( !$metaData )
        {
            $http = eZHTTPTool::instance();
            $metaData = $http->sessionVariable( $storageName . '_meta' );
        }

        if ( !isset( $metaData['current_step'] ) ||
             $metaData['current_step'] < 0 )
        {
            $metaData['current_step'] = 0;
            eZDebug::writeNotice( 'Setting wizard step to : ' . $metaData['current_step'], __METHOD__ );
        }
        $currentStep = $metaData['current_step'];

        if ( count( $stepArray ) <= $currentStep )
        {
            eZDebug::writeError( 'Invalid wizard step count: ' . $currentStep, __METHOD__ );
            return false;
        }

        $filePath = $basePath . $stepArray[$currentStep]['file'];
        if ( !file_exists( $filePath ) )
        {
            eZDebug::writeError( 'Wizard file not found : ' . $filePath, __METHOD__ );
            return false;
        }

        include_once( $filePath );

        $className = $stepArray[$currentStep]['class'];
        eZDebug::writeNotice( 'Creating class : ' . $className, __METHOD__ );
        $returnClass =  new $className( $tpl, $module, $storageName );

        if ( isset( $stepArray[$currentStep]['operation'] ) )
        {
            $operation = $stepArray[$currentStep]['operation'];
            return $returnClass->$operation();
            eZDebug::writeNotice( 'Running : "' . $className . '->' . $operation . '()". Specified in StepArray', __METHOD__ );
        }

        if ( isset( $metaData['current_stage'] ) )
        {
            $returnClass->setMetaData( 'current_stage', $metaData['current_stage'] );
            eZDebug::writeNotice( 'Setting wizard stage to : ' . $metaData['current_stage'], __METHOD__ );
        }

        return $returnClass;
    }
 /**
  * Returns block item XHTML
  *
  * @param mixed $args
  * @return array
  */
 public static function getNextItems($args)
 {
     $http = eZHTTPTool::instance();
     $tpl = eZTemplate::factory();
     $result = array();
     $galleryID = $http->postVariable('gallery_id');
     $offset = $http->postVariable('offset');
     $limit = $http->postVariable('limit');
     $galleryNode = eZContentObjectTreeNode::fetch($galleryID);
     if ($galleryNode instanceof eZContentObjectTreeNode) {
         $params = array('Depth' => 1, 'Offset' => $offset, 'Limit' => $limit);
         $pictureNodes = $galleryNode->subtree($params);
         foreach ($pictureNodes as $validNode) {
             $tpl->setVariable('node', $validNode);
             $tpl->setVariable('view', 'block_item');
             $tpl->setVariable('image_class', 'blockgallery1');
             $content = $tpl->fetch('design:node/view/view.tpl');
             $result[] = $content;
             if ($counter === $limit) {
                 break;
             }
         }
     }
     return $result;
 }
 function fetchAccountInformation(&$module)
 {
     $http = eZHTTPTool::instance();
     $http->setSessionVariable('RedirectAfterLogin', '/shop/basket/');
     $http->setSessionVariable('DoCheckoutAutomatically', true);
     $module->redirectTo('/user/login/');
 }
Esempio n. 9
0
 public static function push($args)
 {
     if (!self::userHasAccessToModule()) {
         return self::$noAccessResponse;
     }
     $http = eZHTTPTool::instance();
     if ($http->hasPostVariable('nodeID') && $http->hasPostVariable('accountID')) {
         $NGPushIni = eZINI::instance('ngpush.ini');
         $NGPushAccount = $http->postVariable('accountID');
         $NGPushNodeID = $http->postVariable('nodeID');
         switch ($NGPushIni->variable($NGPushAccount, 'Type')) {
             case 'twitter':
                 $TwitterStatus = $http->postVariable('tw_status');
                 return ngPushTwitterStatus::push($NGPushAccount, $TwitterStatus);
                 break;
             case 'facebook_feed':
                 $Arguments = array('name' => $http->postVariable('fb_name'), 'description' => $http->postVariable('fb_description'), 'message' => $http->postVariable('fb_message'), 'link' => $http->postVariable('fb_link'), 'picture' => $http->postVariable('fb_picture'));
                 return ngPushFacebookFeed::push($NGPushAccount, $Arguments);
                 break;
             default:
                 break;
         }
     }
     return array('status' => 'error', 'message' => 'Account not found!');
 }
Esempio n. 10
0
 public function requestToken($Account)
 {
     $NGPushIni = eZINI::instance('ngpush.ini');
     $SiteIni = eZINI::instance('site.ini');
     $AccessToken = $NGPushIni->variable($Account, 'AccessToken');
     // If access tokens are given
     if ($AccessToken) {
         //Save request signing tokens to cache
         ngPushBase::save_token($Account, $AccessToken, 'main_token');
     } else {
         $AdministrationUrl = '/';
         eZURI::transformURI($AdministrationUrl, false, 'full');
         $AdministrationUrl = base64_encode($AdministrationUrl);
         $SettingsBlock = base64_encode($Account);
         $redirectUrl = 'http://' . $NGPushIni->variable('PushNodeSettings', 'ConnectURL') . '/redirect.php/' . $AdministrationUrl . '/' . $SettingsBlock . '?case=facebook';
         $Facebook = new Facebook(array('appId' => $NGPushIni->variable($Account, 'AppAPIKey'), 'secret' => $NGPushIni->variable($Account, 'AppSecret')));
         $Permissions = array('publish_actions', 'user_posts');
         if ($NGPushIni->variable($Account, 'EntityType') == 'page') {
             $Permissions[] = 'manage_pages';
         }
         $state = md5(uniqid(rand(), true));
         $http = eZHTTPTool::instance();
         $http->setSessionVariable('ngpush_state', $state);
         $LoginUrl = $Facebook->getLoginUrl(array('redirect_uri' => $redirectUrl, 'scope' => implode($Permissions, ','), 'state' => $state));
         self::$response['RequestPermissionsUrl'] = $LoginUrl;
     }
 }
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 ) );
            }
        }
    }
}
Esempio n. 12
0
 /**
  * Provides suggestion results when adding tags to object
  *
  * @static
  * @param mixed $args
  * @return array
  */
 public static function suggest($args)
 {
     $tags = array();
     $siteINI = eZINI::instance('site.ini');
     if ($siteINI->variable('SearchSettings', 'SearchEngine') == 'ezsolr' && class_exists('eZSolr')) {
         $tagsCount = 1;
         $filteredTagsArray = array();
         $http = eZHTTPTool::instance();
         $tagsString = $http->postVariable('tags_string');
         $tagsArray = explode('|#', $tagsString);
         $subTreeLimit = $http->postVariable('subtree_limit');
         $hideRootTag = $http->postVariable('hide_root_tag') == '1' ? true : false;
         if (!empty($tagsArray) && strlen(trim($tagsArray[0])) > 0) {
             $solrFilter = '"' . trim($tagsArray[0]) . '"';
             $filteredTagsArray[] = strtolower(trim($tagsArray[0]));
             for ($i = 1; $i < count($tagsArray); $i++) {
                 if (strlen(trim($tagsArray[$i])) > 0) {
                     $solrFilter = $solrFilter . ' OR "' . trim($tagsArray[$i]) . '"';
                     $filteredTagsArray[] = strtolower(trim($tagsArray[$i]));
                     $tagsCount++;
                 }
             }
             $solrFilter = 'ezf_df_tags:(' . $solrFilter . ')';
             $solrSearch = new eZSolr();
             $params = array('SearchOffset' => 0, 'SearchLimit' => 0, 'Facet' => array(array('field' => 'ezf_df_tags', 'limit' => 5 + $tagsCount, 'mincount', 1)), 'SortBy' => null, 'Filter' => $solrFilter, 'QueryHandler' => 'ezpublish', 'FieldsToReturn' => null);
             $searchResult = $solrSearch->search('', $params);
             $facetResult = $searchResult['SearchExtras']->attribute('facet_fields');
             $facetResult = $facetResult[0]['nameList'];
             $tags = array();
             foreach ($facetResult as $facetValue) {
                 if (!in_array(strtolower($facetValue), $filteredTagsArray)) {
                     $tags[] = trim($facetValue);
                 }
             }
             if (!empty($tags)) {
                 $tags = eZTagsObject::fetchByKeyword(array($tags));
             }
         }
     }
     $returnArray = array();
     $returnArray['status'] = 'success';
     $returnArray['message'] = '';
     $returnArray['tags'] = array();
     foreach ($tags as $tag) {
         if (!$subTreeLimit > 0 || $subTreeLimit > 0 && strpos($tag->attribute('path_string'), '/' . $subTreeLimit . '/') !== false) {
             if (!$hideRootTag || $hideRootTag && $tag->attribute('id') != $subTreeLimit) {
                 $returnArrayChild = array();
                 $returnArrayChild['tag_parent_id'] = (int) $tag->attribute('parent_id');
                 $returnArrayChild['tag_parent_name'] = $tag->hasParent() ? $tag->getParent()->attribute('keyword') : '';
                 $returnArrayChild['tag_name'] = $tag->attribute('keyword');
                 $returnArrayChild['tag_id'] = (int) $tag->attribute('id');
                 $returnArray['tags'][] = $returnArrayChild;
             }
         }
     }
     return $returnArray;
 }
Esempio n. 13
0
 /**
  * This method is used to process the second part of authentication workflow, after redirect
  *
  * @return array Array with status and user details
  */
 public function processAuth()
 {
     $ngConnectINI = eZINI::instance('ngconnect.ini');
     $http = eZHTTPTool::instance();
     $consumerKey = trim($ngConnectINI->variable('LoginMethod_twitter', 'AppConsumerKey'));
     $consumerSecret = trim($ngConnectINI->variable('LoginMethod_twitter', 'AppConsumerSecret'));
     if (empty($consumerKey) || empty($consumerSecret)) {
         return array('status' => 'error', 'message' => 'Consumer key or consumer secret undefined.');
     }
     $oAuthToken = trim($http->getVariable('oauth_token', ''));
     $oAuthVerifier = trim($http->getVariable('oauth_verifier', ''));
     $state = trim($http->getVariable('state', ''));
     if (empty($oAuthToken) || empty($oAuthVerifier) || empty($state)) {
         return array('status' => 'error', 'message' => 'oauth_token, oauth_verifier or state GET parameters undefined.');
     }
     if (!$http->hasSessionVariable('NGConnectOAuthState') || $state != $http->sessionVariable('NGConnectOAuthState')) {
         $http->removeSessionVariable('NGConnectOAuthState');
         return array('status' => 'error', 'message' => 'State parameter does not match stored value.');
     } else {
         $http->removeSessionVariable('NGConnectOAuthState');
     }
     if (!$http->hasSessionVariable('NGConnectOAuthToken') || !$http->hasSessionVariable('NGConnectOAuthTokenSecret') || $oAuthToken != $http->sessionVariable('NGConnectOAuthToken')) {
         $http->removeSessionVariable('NGConnectOAuthToken');
         $http->removeSessionVariable('NGConnectOAuthTokenSecret');
         return array('status' => 'error', 'message' => 'Token does not match stored value.');
     } else {
         $oAuthTokenSecret = $http->sessionVariable('NGConnectOAuthTokenSecret');
         $http->removeSessionVariable('NGConnectOAuthToken');
         $http->removeSessionVariable('NGConnectOAuthTokenSecret');
     }
     $connection = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthTokenSecret);
     $connection->host = self::TWITTER_API_URI;
     $accessToken = $connection->getAccessToken($oAuthVerifier);
     if (!(isset($accessToken['oauth_token']) && isset($accessToken['oauth_token_secret']))) {
         return array('status' => 'error', 'message' => 'Error while retrieving access token.');
     }
     $connection = new TwitterOAuth($consumerKey, $consumerSecret, $accessToken['oauth_token'], $accessToken['oauth_token_secret']);
     $connection->host = self::TWITTER_API_URI;
     $user = $connection->get(self::TWITTER_USER_API_URI);
     if (!isset($user->id) || empty($user->id)) {
         return array('status' => 'error', 'message' => 'Invalid Twitter user.');
     }
     if (isset($user->profile_image_url) && !empty($user->profile_image_url)) {
         $pictureUri = $user->profile_image_url;
         $imageSize = trim($ngConnectINI->variable('LoginMethod_twitter', 'ImageSize'));
         if ($imageSize == 'original') {
             //Hm... it seems there's no way to get the full size image through API
             //Even https://api.twitter.com/1/users/profile_image/username never returns full version
             //Replacing is not safe, but at least we're replacing last occurrence
             $pictureUri = substr_replace($user->profile_image_url, '', strrpos($user->profile_image_url, '_normal'), 7);
         }
     } else {
         $pictureUri = '';
     }
     $result = array('status' => 'success', 'login_method' => 'twitter', 'id' => $user->id, 'first_name' => isset($user->name) ? $user->name : '', 'last_name' => '', 'email' => '', 'picture' => $pictureUri);
     return $result;
 }
 /**
  * @return array
  */
 public function run()
 {
     $result = array();
     $http = eZHTTPTool::instance();
     $action = $http->getVariable('action', false);
     $parameters = $http->getVariable('parameters', false);
     $result['request'] = array('action' => $action, 'parameters' => $parameters);
     $result['response'] = call_user_func(array($this, $action), $parameters);
     return $result;
 }
Esempio n. 15
0
 /**
  * This method is used to process the second part of authentication workflow, after redirect
  *
  * @return array Array with status and user details
  */
 public function processAuth()
 {
     $ngConnectINI = eZINI::instance('ngconnect.ini');
     $http = eZHTTPTool::instance();
     $appID = trim($ngConnectINI->variable('LoginMethod_facebook', 'FacebookAppID'));
     $appSecret = trim($ngConnectINI->variable('LoginMethod_facebook', 'FacebookAppSecret'));
     if (empty($appID) || empty($appSecret)) {
         return array('status' => 'error', 'message' => 'Facebook app ID or Facebook app secret undefined.');
     }
     $code = trim($http->getVariable('code', ''));
     $state = trim($http->getVariable('state', ''));
     if (empty($code) || empty($state)) {
         return array('status' => 'error', 'message' => 'code or state GET parameters undefined.');
     }
     if (!$http->hasSessionVariable('NGConnectOAuthState') || $state != $http->sessionVariable('NGConnectOAuthState')) {
         $http->removeSessionVariable('NGConnectOAuthState');
         return array('status' => 'error', 'message' => 'State parameter does not match stored value.');
     } else {
         $http->removeSessionVariable('NGConnectOAuthState');
     }
     $callbackUri = self::CALLBACK_URI_PART;
     $loginWindowType = trim($ngConnectINI->variable('ngconnect', 'LoginWindowType'));
     if ($loginWindowType == 'popup') {
         $callbackUri = '/layout/set/ngconnect' . self::CALLBACK_URI_PART;
     }
     eZURI::transformURI($callbackUri, false, 'full');
     $tokenUri = str_replace(array('%app_id%', '%site_url%', '%app_secret%', '%code%'), array(urlencode($appID), urlencode($callbackUri), urlencode($appSecret), urlencode($code)), self::TOKEN_URI);
     $accessToken = ngConnectFunctions::fetchDataFromUrl($tokenUri);
     if (!$accessToken) {
         return array('status' => 'error', 'message' => 'Error while retrieving access token.');
     }
     $accessTokenJson = json_decode($accessToken, true);
     if ($accessTokenJson !== null) {
         return array('status' => 'error', 'message' => $accessTokenJson['error']['message']);
     }
     $graphUri = str_replace(array('%access_token%'), array(trim($accessToken)), self::GRAPH_URI);
     $graphResponse = ngConnectFunctions::fetchDataFromUrl($graphUri);
     if (!$graphResponse) {
         return array('status' => 'error', 'message' => 'Error while retrieving graph response.');
     }
     $user = json_decode($graphResponse, true);
     if ($user === null) {
         return array('status' => 'error', 'message' => 'Invalid JSON data returned.');
     }
     if (!isset($user['id'])) {
         return array('status' => 'error', 'message' => 'Invalid Facebook user.');
     }
     $pictureUri = self::PICTURE_URI;
     $imageSize = trim($ngConnectINI->variable('LoginMethod_facebook', 'ImageSize'));
     if ($imageSize == 'original') {
         $pictureUri = $pictureUri . '?type=large';
     }
     $result = array('status' => 'success', 'login_method' => 'facebook', 'id' => $user['id'], 'first_name' => isset($user['first_name']) ? $user['first_name'] : '', 'last_name' => isset($user['last_name']) ? $user['last_name'] : '', 'email' => isset($user['email']) ? $user['email'] : '', 'picture' => str_replace('%user_id%', $user['id'], $pictureUri));
     return $result;
 }
 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;
 }
 function processEditActions(&$validation, $params)
 {
     $http = eZHTTPTool::instance();
     if ($http->hasPostVariable('SurveyQuestion_' . $this->ID . '_Text') && $http->postVariable('SurveyQuestion_' . $this->ID . '_Text') != $this->Text) {
         $inputXML = $http->postVariable('SurveyQuestion_' . $this->ID . '_Text');
         $xmlData = "<section xmlns:image='http://ez.no/namespaces/ezpublish3/image/' xmlns:xhtml='http://ez.no/namespaces/ezpublish3/xhtml/' xmlns:custom='http://ez.no/namespaces/ezpublish3/custom/' >";
         $xmlData .= "<paragraph>";
         $xmlData .= $inputXML;
         $xmlData .= "</paragraph>";
         $xmlData .= "</section>";
         $xmlObject = new eZXMLText($inputXML, null);
         $inputHandler = $xmlObject->attribute('input');
         $data =& $inputHandler->convertInput($xmlData);
         $domString =& eZXMLTextType::domString($data[0]);
         $domString = preg_replace("#<paragraph> </paragraph>#", "<paragraph>&nbsp;</paragraph>", $domString);
         $domString = str_replace("<paragraph />", "", $domString);
         $domString = str_replace("<line />", "", $domString);
         $domString = str_replace("<paragraph></paragraph>", "", $domString);
         $domString = preg_replace("#<paragraph>&nbsp;</paragraph>#", "<paragraph />", $domString);
         $domString = preg_replace("#<paragraph></paragraph>#", "", $domString);
         $domString = preg_replace("#[\n]+#", "", $domString);
         $domString = preg_replace("#&lt;/line&gt;#", "\n", $domString);
         $domString = preg_replace("#&lt;paragraph&gt;#", "\n\n", $domString);
         $xml = new eZXML();
         $tmpDom = $xml->domTree($domString, array('CharsetConversion' => false));
         $domString = eZXMLTextType::domString($tmpDom);
         $this->setAttribute('text', $domString);
     }
     if ($http->hasPostVariable('SurveyQuestion_' . $this->ID . '_Text2') && $http->postVariable('SurveyQuestion_' . $this->ID . '_Text2') != $this->Text2) {
         $this->setAttribute('text2', $http->postVariable('SurveyQuestion_' . $this->ID . '_Text2'));
     }
     if ($http->hasPostVariable('SurveyQuestion_' . $this->ID . '_Text3') && $http->postVariable('SurveyQuestion_' . $this->ID . '_Text3') != $this->Text3) {
         $this->setAttribute('text3', $http->postVariable('SurveyQuestion_' . $this->ID . '_Text3'));
     }
     if ($http->hasPostVariable('SurveyQuestion_' . $this->ID . '_Num') && $http->postVariable('SurveyQuestion_' . $this->ID . '_Num') != $this->Num) {
         $this->setAttribute('num', $http->postVariable('SurveyQuestion_' . $this->ID . '_Num'));
     }
     if ($http->hasPostVariable('SurveyQuestion_' . $this->ID . '_Num2') && $http->postVariable('SurveyQuestion_' . $this->ID . '_Num2') != $this->Num2) {
         $this->setAttribute('num2', $http->postVariable('SurveyQuestion_' . $this->ID . '_Num2'));
     }
     if ($http->hasPostVariable('SurveyQuestion_' . $this->ID . '_Mandatory_Hidden')) {
         if ($http->hasPostVariable('SurveyQuestion_' . $this->ID . '_Mandatory')) {
             $newMandatory = 1;
         } else {
             $newMandatory = 0;
         }
         if ($newMandatory != $this->Mandatory) {
             $this->setAttribute('mandatory', $newMandatory);
         }
     }
     if ($http->hasPostVariable('SurveyQuestion_' . $this->ID . '_Default') && $http->postVariable('SurveyQuestion_' . $this->ID . '_Default') != $this->Default) {
         $this->setAttribute('default_value', $http->postVariable('SurveyQuestion_' . $this->ID . '_Default'));
     }
 }
Esempio n. 18
0
function eZSetupSetPersistencePostVariable($var, $value)
{
    $http = eZHTTPTool::instance();
    if (is_array($value)) {
        foreach ($value as $valueKey => $valueItem) {
            $http->setPostVariable('P_' . $var . '-' . $valueKey, $valueItem);
        }
    } else {
        $http->setPostVariable('P_' . $var . '-0', $value);
    }
}
    static function redirectURI( $module, $default, $view = true, $disallowed = false, $preferredURI = false )
    {
        $uri = false;
        $http = eZHTTPTool::instance();

        if ( $preferredURI ) // check if $preferredURI is a valid URI
            return $preferredURI;

        if ( $view )
        {
            if ( $http->hasSessionVariable( "LastAccessesURI", false ) )
            {
                $uri = $http->sessionVariable( "LastAccessesURI" );
            }
        }
        else
        {
            if ( $http->hasSessionVariable( "LastAccessedModifyingURI", false ) )
            {
                $uri = $http->sessionVariable( "LastAccessedModifyingURI" );
            }
        }

        if ( $uri !== false )
        {
            $moduleURI = $module->functionURI( $module->currentView() );
            // Check for correct module/view
            if ( substr( $uri, 0, strlen( $moduleURI ) ) == $moduleURI )
            {
                // Check parameters
                $moduleURI = $module->currentRedirectionURI();
                if ( $moduleURI == $uri )
                    $uri = false;
            }
        }

        // Check for disallowed urls
        if ( $uri !== false and
             is_array( $disallowed ) )
        {
            if ( in_array( $uri, $disallowed ) )
                $uri = false;
        }

        if ( $uri === false )
        {
            // If no default is set we should return false.
            if ( $default === false )
                return false;
            $uri = $default;
        }

        return $uri;
    }
Esempio n. 20
0
 function eZWizardBase($tpl, &$module, $storageName = false)
 {
     if ($storageName) {
         $this->StorageName = $storageName;
     }
     $this->TPL = $tpl;
     $this->Module = $module;
     $this->HTTP = eZHTTPTool::instance();
     $this->VariableList = $this->HTTP->sessionVariable($this->StorageName . $this->VariableListName);
     $this->MetaData = $this->HTTP->sessionVariable($this->StorageName . $this->MetaDataName);
     $this->initialize();
 }
 public static function write_invalid_checkcreditcard_log($order_id, $response = array("errorcode" => "unknown", "errormessage" => "unknown"))
 {
     $http = eZHTTPTool::instance();
     //set fallbacks for direct ajax request
     if (!isset($order_id) or is_array($order_id) and count($order_id) == 0) {
         $order_id = $http->postVariable('order_id');
     }
     if (!isset($response) or is_array($response) and count($response) == 0) {
         $response = $http->postVariable('response');
     }
     eZLog::write("FAILED in step 1 ('checkcreditcard') for order ID " . $order_id . " with ERRORCODE " . $response["errorcode"] . " Message: " . $response["errormessage"], $logName = 'xrowpayone.log', $dir = 'var/log');
 }
 /**
  * Get HTTP get filter parameters.
  * The filter parameters are specified by "filter[]=<base_name>:<value>".
  * Example:
  * <code>
  * http://my_url/some/path?filter[]=owner_id:12&filter[]=language_code:eng-GB
  *
  * @return array HTTP GET filter parameters
  */
 public function getFilterParameters()
 {
     $http = eZHTTPTool::instance();
     $filterList = array();
     if ($http->hasGetVariable('filter')) {
         foreach ($http->getVariable('filter') as $filterCond) {
             list($name, $value) = explode(':', $filterCond, 2);
             $filterList[$name] = $value;
         }
     }
     return array('result' => $filterList);
 }
Esempio n. 23
0
 function freeRequest()
 {
     $http = eZHTTPTool::instance();
     if ($http->hasPostVariable('FreeTextRequest') && trim($http->postVariable('FreeTextRequest')) != "") {
         $request = $http->postVariable('FreeTextRequest') . "\r\n";
     } else {
         $request = "help\r\n";
     }
     $erg = $this->execute($request, $this->hostname, $this->port, $this->timeout);
     $erg["terminal"] = substr($request, 0, strpos($request, "\r\n"));
     return $erg;
 }
Esempio n. 24
0
 /**
  * Returns the JSON encoded string of children tags for supplied GET params
  * Used in YUI version of children tags list in admin interface
  *
  * @static
  *
  * @param array $args
  *
  * @return string
  */
 public static function tagsChildren($args)
 {
     $http = eZHTTPTool::instance();
     $filter = urldecode(trim($http->getVariable('filter', '')));
     if (!isset($args[0]) || !is_numeric($args[0])) {
         return array('count' => 0, 'offset' => false, 'filter' => $filter, 'data' => array());
     }
     $offset = false;
     $limits = null;
     if ($http->hasGetVariable('offset')) {
         $offset = (int) $http->getVariable('offset');
         if ($http->hasGetVariable('limit')) {
             $limit = (int) $http->getVariable('limit');
         } else {
             $limit = 10;
         }
         $limits = array('offset' => $offset, 'limit' => $limit);
     }
     $sorts = null;
     if ($http->hasGetVariable('sortby')) {
         $sortBy = trim($http->getVariable('sortby'));
         $sortDirection = 'asc';
         if ($http->hasGetVariable('sortdirection') && trim($http->getVariable('sortdirection')) == 'desc') {
             $sortDirection = 'desc';
         }
         $sorts = array($sortBy => $sortDirection);
     }
     $fetchParams = array('parent_id' => (int) $args[0], 'main_tag_id' => 0);
     if (!empty($filter)) {
         $fetchParams['keyword'] = array('like', '%' . $filter . '%');
     }
     /** @var eZTagsObject[] $children */
     $children = eZTagsObject::fetchList($fetchParams, $limits, $sorts);
     $childrenCount = eZTagsObject::fetchListCount($fetchParams);
     if (!is_array($children) || empty($children)) {
         return array('count' => 0, 'offset' => false, 'filter' => $filter, 'data' => array());
     }
     $dataArray = array();
     foreach ($children as $child) {
         $tagArray = array();
         $tagArray['id'] = $child->attribute('id');
         $tagArray['keyword'] = htmlspecialchars($child->attribute('keyword'), ENT_QUOTES);
         $tagArray['modified'] = $child->attribute('modified');
         $tagArray['translations'] = array();
         foreach ($child->getTranslations() as $translation) {
             $tagArray['translations'][] = htmlspecialchars($translation->attribute('locale'), ENT_QUOTES);
         }
         $dataArray[] = $tagArray;
     }
     return array('count' => $childrenCount, 'offset' => $offset, 'filter' => $filter, 'data' => $dataArray);
 }
Esempio n. 25
0
 /**
  * This method is used to process the second part of authentication workflow, after redirect
  *
  * @return array Array with status and user details
  */
 public function processAuth()
 {
     $ngConnectINI = eZINI::instance('ngconnect.ini');
     $http = eZHTTPTool::instance();
     $clientID = trim($ngConnectINI->variable('LoginMethod_google', 'GoogleClientID'));
     $clientSecret = trim($ngConnectINI->variable('LoginMethod_google', 'GoogleClientSecret'));
     if (empty($clientID) || empty($clientSecret)) {
         return array('status' => 'error', 'message' => 'Google client ID or Google client secret undefined.');
     }
     $code = trim($http->getVariable('code', ''));
     $state = trim($http->getVariable('state', ''));
     if (empty($code) || empty($state)) {
         return array('status' => 'error', 'message' => 'code or state GET parameters undefined.');
     }
     if (!$http->hasSessionVariable('NGConnectOAuthState') || $state != $http->sessionVariable('NGConnectOAuthState')) {
         $http->removeSessionVariable('NGConnectOAuthState');
         return array('status' => 'error', 'message' => 'State parameter does not match stored value.');
     } else {
         $http->removeSessionVariable('NGConnectOAuthState');
     }
     $callbackUri = self::CALLBACK_URI_PART;
     $loginWindowType = trim($ngConnectINI->variable('ngconnect', 'LoginWindowType'));
     if ($loginWindowType == 'popup') {
         $callbackUri = '/layout/set/ngconnect' . self::CALLBACK_URI_PART;
     }
     eZURI::transformURI($callbackUri, false, 'full');
     $scope = self::SCOPE;
     $userScope = trim($ngConnectINI->variable('LoginMethod_google', 'Scope'));
     if (!empty($userScope)) {
         $scope = $userScope . ' ' . $scope;
     }
     $client = new Google_Client();
     $client->setApplicationName(trim($ngConnectINI->variable('LoginMethod_google', 'MethodName')));
     $client->setScopes($scope);
     $client->setClientId($clientID);
     $client->setClientSecret($clientSecret);
     $client->setRedirectUri($callbackUri);
     $client->setUseObjects(true);
     $plus = new Google_PlusService($client);
     $authString = $client->authenticate();
     $accessToken = $client->getAccessToken();
     if (empty($authString) || empty($accessToken)) {
         return array('status' => 'error', 'message' => 'Unable to authenticate to Google.');
     }
     $me = $plus->people->get('me');
     if (!$me instanceof Google_Person) {
         return array('status' => 'error', 'message' => 'Invalid Google user.');
     }
     $result = array('status' => 'success', 'login_method' => 'google', 'id' => $me->id, 'first_name' => !empty($me->name->givenName) ? $me->name->givenName : '', 'last_name' => !empty($me->name->familyName) ? $me->name->familyName : '', 'email' => !empty($me->emails[0]['value']) ? $me->emails[0]['value'] : '', 'picture' => !empty($me->image->url) ? $me->image->url : '');
     return $result;
 }
Esempio n. 26
0
 public function getAccessToken($redirectURL = null)
 {
     $http = eZHTTPTool::instance();
     $request = $http->hasSessionVariable('linkedin_request_token') ? $http->sessionVariable('linkedin_request_token') : array('oauth_token' => null);
     if ($http->hasGetVariable('oauth_token') && $http->getVariable('oauth_token') !== $request['oauth_token']) {
         throw new Exception('Wrong request token. Refresh the page or try again later.');
     }
     $response = $this->connection->retrieveTokenAccess($request['oauth_token'], $request['oauth_token_secret'], $http->getVariable('oauth_verifier'));
     if ($response['success'] === true) {
         $http->removeSessionVariable('linkedin_request_token');
         return array('token' => $response['linkedin']['oauth_token'], 'secret' => $response['linkedin']['oauth_token_secret']);
     }
     throw new Exception('Could not get access token. Refresh the page or try again later.');
 }
Esempio n. 27
0
 /**
  * Handles redirection to the mobile optimized interface
  *
  */
 public function redirect()
 {
     $http = eZHTTPTool::instance();
     $currentSiteAccess = eZSiteAccess::current();
     if ($http->hasGetVariable('notmobile')) {
         setcookie('eZMobileDeviceDetect', 1, time() + (int) eZINI::instance()->variable('SiteAccessSettings', 'MobileDeviceDetectCookieTimeout'), '/');
         $http->redirect(eZSys::indexDir());
         eZExecution::cleanExit();
     }
     if (!isset($_COOKIE['eZMobileDeviceDetect']) && !in_array($currentSiteAccess['name'], eZINI::instance()->variable('SiteAccessSettings', 'MobileSiteAccessList'))) {
         $http->redirect(eZINI::instance()->variable('SiteAccessSettings', 'MobileSiteAccessURL'));
         eZExecution::cleanExit();
     }
 }
Esempio n. 28
0
 function processViewActions(&$validation, $params)
 {
     $http = eZHTTPTool::instance();
     $variableArray = array();
     $prefix = eZSurveyType::PREFIX_ATTRIBUTE;
     $attributeID = $params['contentobjectattribute_id'];
     $postSurveyAnswer = $prefix . '_ezsurvey_answer_' . $this->ID . '_' . $attributeID;
     if ($this->attribute('mandatory') == 1 and strlen(trim($http->postVariable($postSurveyAnswer))) == 0) {
         $validation['error'] = true;
         $validation['errors'][] = array('message' => ezpI18n::tr('survey', 'Please answer the question %number as well!', null, array('%number' => $this->questionNumber())), 'question_number' => $this->questionNumber(), 'code' => 'general_answer_number_as_well', 'question' => $this);
     }
     $this->setAnswer(trim($http->postVariable($postSurveyAnswer)));
     $variableArray['answer'] = trim($http->postVariable($postSurveyAnswer));
     return $variableArray;
 }
Esempio n. 29
0
 public function getAccessToken($redirectURL = null)
 {
     $http = eZHTTPTool::instance();
     if ($http->hasGetVariable('twitter_request_token') && $http->getVariable('twitter_request_token') !== $http->sessionVariable('twitter_request_token')) {
         throw new Exception('Wrong request token. Refresh the page or try again later.');
     }
     $connection = new TwitterOAuth($this->appSettings['key'], $this->appSettings['secret'], $http->sessionVariable('twitter_request_token'), $http->sessionVariable('twitter_request_token_secret'));
     $accessToken = $connection->getAccessToken($http->getVariable('oauth_verifier'));
     $http->removeSessionVariable('twitter_request_token');
     $http->removeSessionVariable('twitter_request_token_secret');
     if ((int) $connection->http_code === 200) {
         return array('token' => $accessToken['oauth_token'], 'secret' => $accessToken['oauth_token_secret'], 'user_id' => $accessToken['user_id']);
     }
     throw new Exception('Could not get access token. Refresh the page or try again later.');
 }
Esempio n. 30
0
function stateEditActionCheck($module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage)
{
    if ($module->isCurrentAction('StateEdit')) {
        $http = eZHTTPTool::instance();
        if ($http->hasPostVariable('SelectedStateIDList')) {
            $selectedStateIDList = $http->postVariable('SelectedStateIDList');
            $objectID = $object->attribute('id');
            if (eZOperationHandler::operationIsAvailable('content_updateobjectstate')) {
                $operationResult = eZOperationHandler::execute('content', 'updateobjectstate', array('object_id' => $objectID, 'state_id_list' => $selectedStateIDList));
            } else {
                eZContentOperationCollection::updateObjectState($objectID, $selectedStateIDList);
            }
        }
    }
}