예제 #1
0
    /**
     * @return MMUserData
     */
    public static function instance()
    {
        $instance = eZSession::get(self::SESSION_IDENTIFIER);

        if (empty($instance))
        {
            return new self();
        }
        else
        {
            $instance = unserialize($instance);
        }
        return $instance;
    }
예제 #2
0
 /**
  * Gets the user token from session if it exists or create+store
  * it in session.
  *
  * @return string|null
  */
 public static function getToken()
 {
     if (eZSession::issetkey(self::SESSION_KEY)) {
         return eZSession::get(self::SESSION_KEY);
     }
     $token = md5(uniqid(self::SESSION_KEY, true));
     eZSession::set(self::SESSION_KEY, $token);
     return $token;
 }
예제 #3
0
 /**
  * Get session variable $name
  *
  * @param string $name
  * @param mixed $fallbackValue Return this if session has not started OR name is undefined
  *              if null(default), then force start session and return null if undefined.
  * @return mixed ByRef
  */
 function &sessionVariable($name, $fallbackValue = null)
 {
     return eZSession::get($name, $fallbackValue);
 }
예제 #4
0
 function groups($asObject = false)
 {
     if ($asObject == true) {
         if (!isset($this->GroupsAsObjects)) {
             $db = eZDB::instance();
             $contentobjectID = $this->attribute('contentobject_id');
             $userGroups = $db->arrayQuery("SELECT d.*, c.path_string\n                                                FROM ezcontentobject_tree  b,\n                                                     ezcontentobject_tree  c,\n                                                     ezcontentobject d\n                                                WHERE b.contentobject_id='{$contentobjectID}' AND\n                                                      b.parent_node_id = c.node_id AND\n                                                      d.id = c.contentobject_id\n                                                ORDER BY c.contentobject_id  ");
             $userGroupArray = array();
             $pathArray = array();
             foreach ($userGroups as $group) {
                 $pathItems = explode('/', $group["path_string"]);
                 array_pop($pathItems);
                 array_pop($pathItems);
                 foreach ($pathItems as $pathItem) {
                     if ($pathItem != '' && $pathItem > 1) {
                         $pathArray[] = $pathItem;
                     }
                 }
                 $userGroupArray[] = new eZContentObject($group);
             }
             $pathArray = array_unique($pathArray);
             if (!empty($pathArray)) {
                 $extraGroups = $db->arrayQuery("SELECT d.*\n                                                FROM ezcontentobject_tree  c,\n                                                     ezcontentobject d\n                                                WHERE c.node_id in ( " . implode(', ', $pathArray) . " ) AND\n                                                      d.id = c.contentobject_id\n                                                ORDER BY c.contentobject_id  ");
                 foreach ($extraGroups as $group) {
                     $userGroupArray[] = new eZContentObject($group);
                 }
             }
             $this->GroupsAsObjects = $userGroupArray;
         }
         return $this->GroupsAsObjects;
     } else {
         if (!isset($this->Groups)) {
             // If the user object is not the currently logged in user we cannot use the session cache
             $useCache = $this->ContentObjectID == eZSession::get('eZUserLoggedInID', self::anonymousId());
             if ($useCache) {
                 $userCache = $this->getUserCache();
                 $this->Groups = $userCache['groups'];
             } else {
                 $this->Groups = $this->generateGroupIdList();
             }
         }
         return $this->Groups;
     }
 }
예제 #5
0
/**
 * Pass module view default template parameters
 *
 * @param array $parameters Array of parameters. Optional 
 * @param object $module Object of eZModule. Required  
 * @return string String of url to content/browse
 */
function redirectToContentBrowseModuleView($parameters = false, $module)
{
    if ($parameters == false) {
        // Fetch and use parameters from session directly
        $parameters = eZSession::get('bcimagealias_create_parameters', $parameters);
    }
    /**
     * Fetch array of container classes
     */
    $classes = eZPersistentObject::fetchObjectList(eZContentClass::definition(), array('identifier'), array('is_container' => 1), null, null, false);
    // as object
    /**
     * Prepare array of allowed class identifiers based on above fetch results
     */
    $allowedClasses = array();
    foreach ($classes as $class) {
        $allowedClasses[] = $class['identifier'];
    }
    /**
     * Return browse for node selection view limited to allowed classes
     */
    return eZContentBrowse::browse(array('action_name' => 'BCImageAliasCreateAliasesAddNode', 'from_page' => '/bcimagealias/create', 'class_array' => $allowedClasses, 'persistent_data' => array('ParametersSerialized' => serialize($parameters))), $module);
}
예제 #6
0
파일: Router.php 프로젝트: keyteqlabs/ezote
 /**
  *
  * Handles casese where the token is reset during a request.
  *
  * @param bool $restore
  *
  * @return bool
  *
  */
 public static function handleEZXFormToken($restore = false)
 {
     $activeExtensions = \eZExtension::activeExtensions();
     if (in_array('ezformtoken', $activeExtensions)) {
         if ($restore) {
             if (isset(self::$ezxFormToken) && !empty(self::$ezxFormToken)) {
                 \eZSession::set(\ezxFormToken::SESSION_KEY, self::$ezxFormToken);
             }
         } else {
             self::$ezxFormToken = \eZSession::get(\ezxFormToken::SESSION_KEY);
         }
         return self::$ezxFormToken;
     }
     return false;
 }