/** * @param eZWorkflowProcess $process * @param eZWorkflowEvent $event * @return int */ function execute( $process, $event ) { $parameters = $process->attribute( 'parameter_list' ); $deleteNodeIds = isset($parameters['node_id_list']) ? $parameters['node_id_list'] : array(); $removeLocationNodeIds = array(); if(isset($parameters['node_list'])) { foreach($parameters['node_list'] as $node) { $removeLocationNodeIds[] = $node->attribute('node_id'); } } $nodeIds = array_merge($deleteNodeIds, $removeLocationNodeIds); /* @type $selections MMSelections[] */ $selections = MMSelections::fetchObjectList( MMSelections::definition(), null, array( 'node_id' => array( array( $nodeIds ) ) ) ); foreach( $selections as $selection ) { $selection->remove(); } return self::STATUS_ACCEPTED; }
/** * @return int */ protected function startCourse() { $nodeId = ( isset( $_POST['nid'] ) && filter_var($_POST['nid'], FILTER_VALIDATE_INT) ) ? $_POST['nid'] : null; if( is_null($nodeId) ) return null; $node = eZContentObjectTreeNode::fetch($nodeId); if( !$node ) return null; /* @type $dataMap eZContentObjectAttribute[] */ $dataMap = $node->dataMap(); $description = ''; if( $dataMap['promo_description']->hasContent() ) { $description = $dataMap['promo_description']->content(); } $application = $this->applicationObject()->attribute( 'identifier' ); $applicationId = $this->applicationObject()->attribute( 'id' ); $url = NodeOperatorHelper::getUrlNode( $application, $node ); return MMSelections::addToMySelection( $node->object()->remoteID(), ClusterTool::clusterIdentifier(), $description, $url, $applicationId ); }
/** * @param string $remote_id * @param string $cluster_identifier * @param string $description * @param string $url * @param string $application * @param string $elearningStatus * @return int */ public static function addToMySelection( $remote_id, $cluster_identifier, $description, $url, $application, $elearningStatus = null ) { $currentMMUser = MMUsers::getCurrentUserObject(); if ( !($currentMMUser instanceof MMUsers) ) return 0; $uuid = $currentMMUser->attribute( 'uuid' ); $country = $currentMMUser->attribute( 'country' ); if( !self::isAlreadyInUserSelection( $remote_id, $cluster_identifier ) ) { if ( !$currentMMUser ) return self::countTotalFromUserSelection(); $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByApplication($application); $application = $applicationLocalized->applicationObject()->attribute('identifier'); $selection = new MMSelections(); $selection->setAttribute( 'uuid', $uuid ); $selection->setAttribute( 'country', $country ); $selection->setAttribute( 'url', $url ); $selection->setAttribute( 'remote_id', $remote_id ); $selection->setAttribute( 'cluster_identifier', $cluster_identifier ); $selection->setAttribute( 'description', $description ); $selection->setAttribute( 'add_date', time() ); $selection->setAttribute( 'application', $application ); $selection->store(); } elseif( $application == 'e-learning' ) { self::updateSelectionDescription( $remote_id, $cluster_identifier, $description, $elearningStatus ); } self::setCookie(); return self::countTotalFromUserSelection($uuid, $country); }
/** * @param int[] $orderedNodesId * @return bool */ protected function updateOrder($orderedNodesId = null) { if(!$orderedNodesId) $orderedNodesId = $_POST['orderedNodesId']; MMSelections::reorderSelection($orderedNodesId); return true; }
/** * @param $remoteID * @internal param int $nodeID * @return bool */ protected function isAlreadyInUserSelection( $remoteID ) { $clusterIdentifier = ClusterTool::clusterIdentifier(); return MMSelections::isAlreadyInUserSelection( $remoteID, $clusterIdentifier ); }
/** * @return bool * @throws Exception */ public static function selectionRemove() { if ( !isset($_POST['remote_id']) ) { throw new Exception('remote_id parameter is missing', 7); } if ( !isset($_POST['cluster_identifier']) ) { throw new Exception('cluster_identifier parameter is missing', 7); } MMSelections::removeFromSelection($_POST['remote_id'], $_POST['cluster_identifier']); return true; }
protected function refreshAndGetFeedback() { $remoteId = ( isset( $_POST['remoteID'] ) && filter_var($_POST['remoteID'], FILTER_VALIDATE_REGEXP, SecurityTool::$REMOTEID_REGEXP) ) ? $_POST['remoteID'] : null; $clusterIdentifier = ( isset( $_POST['cluster_identifier'] ) && filter_var($_POST['cluster_identifier'], FILTER_VALIDATE_REGEXP, SecurityTool::$CLUSTER_IDENTIFIER_REGEXP) ) ? $_POST['cluster_identifier'] : null; if( !$clusterIdentifier || !$remoteId || !self::user() ) { return 'Unknown Error !'; } $user = self::user(); if ( ($user instanceof MMUsers ) ) { $remoteList = $user->getPreference('ratings'); if (!is_array($remoteList)) { $remoteList = array(); } $results['userRatings'] = $this->getUserRating( $remoteId, self::user(), $clusterIdentifier); $results['in_user_selection'] = MMSelections::isAlreadyInUserSelection( $remoteId, $clusterIdentifier ); } else { // This case is supposed not to happen ! We log a trace for further investigations $remoteList = array(); $results['userRatings'] = NULL; $results['in_user_selection'] = false; eZLog::write( var_export($_ENV, true), 'get_preference.log'); eZLog::write( var_export(apache_request_headers(), true), 'get_preference.log'); } if (!in_array($remoteId, $remoteList)) { $this->addView($remoteId, $remoteList, $clusterIdentifier); } $results['nbViews'] = SolrSafeOperatorHelper::getViewCounter( $remoteId, $clusterIdentifier ); $results['ratings'] = SolrSafeOperatorHelper::getRatings($remoteId, $clusterIdentifier); return $results; }
/** * Logs in the user if applied username and password is * valid. The userID is returned if successful, false if not. * * @param array $params * @return bool */ public static function loginUser($params = null) { $uncryptedTicket = array(); if($params) { $uncryptedTicket["uuid"] = $params["Username"]; $uncryptedTicket["customerType"] = $params["Customer_type"]; $uncryptedTicket["userSpeciality"] = $params["User_specialty"]; $uncryptedTicket["state"] = $params["Province"]; $uncryptedTicket["country"] = $params["Country_of_registration"]; $uncryptedTicket['toUValidated'] = isset( $params['toUValidated'] ) ? $params['toUValidated'] : true; $uncryptedTicket['autologin'] = isset( $params['autologin'] ) ? $params['autologin'] : false; } else { $http = eZHTTPTool::instance(); $hashedTicket = $http->getVariable( 't' ); if ( empty( $hashedTicket ) ) { return false; } $uncryptedTicket = self::uncryptTicket ( $hashedTicket ); } if ( !self::validateTicket($uncryptedTicket) ) { return false; } $mmUser = self::createOrUpdateMMUser($uncryptedTicket); if( isset($uncryptedTicket['toUValidated']) ) { $mmUser->toUValidated( $uncryptedTicket['toUValidated'] ); } if( isset($uncryptedTicket['autologin']) ) { $mmUser->isAutologin( $uncryptedTicket['autologin'] ); } MMUsers::setCurrentUserObject($mmUser); AppBarControl::instance()->store(); MMSelections::setCookie(); MMUsers::setCookieUserPreferences(); $catchUpSpe = $mmUser->getPreference( 'catchUpSpe' ); if ( !empty( $catchUpSpe ) ) { setcookie ('catchUpSpe', '1', CookieTool::getDefaultCookieExpiration(), '/', CookieTool::getCookieDomain() ); } return true; }