コード例 #1
0
 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;
 }
コード例 #2
0
 /**
  * Checks if a file can be uploaded.
  *
  * @return boolean
  */
 public function canUpload()
 {
     $access = eZUser::instance()->hasAccessTo('content', 'create');
     if ($access['accessWord'] === 'no') {
         return false;
     }
     return true;
 }
コード例 #3
0
 /**
  * Checks if a file can be uploaded
  *
  * @return boolean
  */
 public function canUpload()
 {
     $access = eZUser::instance()->hasAccessTo('content', 'create');
     if ($access['accessWord'] === 'no') {
         return false;
     }
     $ini = eZINI::instance('upload.ini');
     $uploadableClassList = $ini->variable('CreateSettings', 'MimeClassMap');
     $uploadableClassList[] = $ini->variable('CreateSettings', 'DefaultClass');
     $classContent = $this->attribute->attribute('class_content');
     $intersect = array_intersect($classContent['class_constraint_list'], $uploadableClassList);
     if (!empty($classContent['class_constraint_list']) && empty($intersect)) {
         return false;
     }
     return true;
 }
コード例 #4
0
 /**
  * add subscription after adding comment
  * 1) If 'notification' is true
  *     add the user as a subscriber if subscriber with same email doesn't exist
  *     otherwise get the subscriber
  * 2) If 'notification' is true
  *    if the subscription with user's email and contentid doesn't exist, add a new subscription,
  * 3) If there is subscription, add the comment into notifiction queue
  *
  * @see extension/ezcomments/classes/ezcomCommentManager#afterAddingComment($comment)
  */
 public function afterAddingComment($comment, $notification)
 {
     $contentID = $comment->attribute('contentobject_id');
     $languageID = $comment->attribute('language_id');
     $subscriptionType = 'ezcomcomment';
     //add subscription
     $subscription = ezcomSubscriptionManager::instance();
     $user = eZUser::instance();
     if ($notification === true) {
         $subscription->addSubscription($comment->attribute('email'), $user, $contentID, $languageID, $subscriptionType, $comment->attribute('created'));
     }
     // insert data into notification queue
     // if there is no subscription,not adding to notification queue
     if (ezcomSubscription::exists($contentID, $languageID, $subscriptionType, null, 1)) {
         $notification = ezcomNotification::create();
         $notification->setAttribute('contentobject_id', $comment->attribute('contentobject_id'));
         $notification->setAttribute('language_id', $comment->attribute('language_id'));
         $notification->setAttribute('comment_id', $comment->attribute('id'));
         $notification->store();
         eZDebugSetting::writeNotice('extension-ezcomments', 'Notification added to queue', __METHOD__);
     }
 }
コード例 #5
0
    public static function logoutUser()
    {
        session_destroy();
        if( UserLog::canStore() )
        {
            $user = MMUsers::getCurrentUserObject();
            UserLog::instance()->action('logout');

            if( $user )
                UserLog::instance()->uuid( $user->attribute( 'uuid' ) );
            else
                UserLog::instance()->uuid('Unknown')->msg('Logout called for not logged in user');

            UserLog::instance()->store();
        }

        AppBarControl::instance()->store();

        $user = eZUser::instance();
        // Remove all temporary drafts
        eZContentObject::cleanupAllInternalDrafts( $user->attribute( 'contentobject_id' ) );

        // destroy t3 cookies
        // temporary fix - we are reaching the header size limit
        // self::destroyApplicationCookie( 't3process' );

        MMSelections::destroyCookie();
        MMUsers::destroyCookieUserPreferences();
        CookieTool::destroyCookie( 'catchUpSpe' );
        CookieTool::destroyCookie( 'displayToUPPPopin' );
        CookieTool::destroyCookie( 'displayToUPPPopin', '/', null );
        CookieTool::destroyCookie( 'displayToUPPPage' );
        CookieTool::destroyCookie( 'displayToUPPPage', '/', null );
        CookieTool::destroyCookie( MMUsers::COOKIE_KEY );
        CookieTool::destroyCookie(session_name());
    }
コード例 #6
0
 function initializePackage($siteType, &$accessMap, $charset, &$extraLanguageCodes, &$allLanguages, &$primaryLanguage, &$admin, &$resultArray)
 {
     // Time limit #3:
     // We set the time limit to 5 minutes to ensure we have enough time
     // to initialize the site. However we only set if the current limit
     // is too small
     $maxTime = ini_get('max_execution_time');
     if ($maxTime != 0 and $maxTime < 5 * 60) {
         @set_time_limit(5 * 60);
     }
     switch ($siteType['access_type']) {
         case 'port':
             $userSiteaccessName = $siteType['identifier'] . '_' . 'user';
             $adminSiteaccessName = $siteType['identifier'] . '_' . 'admin';
             $accessMap['port'][$siteType['access_type_value']] = $userSiteaccessName;
             $accessMap['port'][$siteType['admin_access_type_value']] = $adminSiteaccessName;
             break;
         case 'hostname':
             $userSiteaccessName = $siteType['identifier'] . '_' . 'user';
             $adminSiteaccessName = $siteType['identifier'] . '_' . 'admin';
             $accessMap['hostname'][$siteType['access_type_value']] = $userSiteaccessName;
             $accessMap['hostname'][$siteType['admin_access_type_value']] = $adminSiteaccessName;
             break;
         case 'url':
         default:
             $userSiteaccessName = $siteType['access_type_value'];
             $adminSiteaccessName = $siteType['admin_access_type_value'];
             $accessMap['url'][$siteType['access_type_value']] = $userSiteaccessName;
             $accessMap['url'][$siteType['admin_access_type_value']] = $adminSiteaccessName;
             break;
     }
     $accessMap['accesses'][] = $userSiteaccessName;
     $accessMap['accesses'][] = $adminSiteaccessName;
     $accessMap['sites'][] = $userSiteaccessName;
     $userDesignName = $siteType['identifier'];
     $languageObjects = $allLanguages;
     $databaseMap = eZSetupDatabaseMap();
     $databaseInfo = $this->PersistenceList['database_info'];
     $databaseInfo['info'] = $databaseMap[$databaseInfo['type']];
     $dbServer = $databaseInfo['server'];
     $dbPort = $databaseInfo['port'];
     //        $dbName = $databaseInfo['dbname'];
     $dbSocket = $databaseInfo['socket'];
     $dbUser = $databaseInfo['user'];
     $dbPwd = $databaseInfo['password'];
     $dbCharset = $charset;
     $dbDriver = $databaseInfo['info']['driver'];
     $dbName = $siteType['database'];
     $dbParameters = array('server' => $dbServer, 'port' => $dbPort, 'user' => $dbUser, 'password' => $dbPwd, 'socket' => $dbSocket, 'database' => $dbName, 'charset' => $dbCharset);
     $db = eZDB::instance($dbDriver, $dbParameters, true);
     if (!$db->isConnected()) {
         $resultArray['errors'][] = array('code' => 'EZSW-005', 'text' => "Failed connecting to database {$dbName}\n" . $db->errorMessage());
         return false;
     }
     eZDB::setInstance($db);
     $result = true;
     // Initialize the database by inserting schema and data
     if (!isset($siteType['existing_database'])) {
         $siteType['existing_database'] = false;
     }
     if ($siteType['existing_database'] == eZStepInstaller::DB_DATA_REMOVE) {
         eZDBTool::cleanup($db);
     }
     if ($siteType['existing_database'] != eZStepInstaller::DB_DATA_KEEP) {
         $result = true;
         $schemaArray = eZDbSchema::read('share/db_schema.dba', true);
         if (!$schemaArray) {
             $resultArray['errors'][] = array('code' => 'EZSW-001', 'message' => "Failed loading database schema file share/db_schema.dba");
             $result = false;
         }
         if ($result) {
             $result = true;
             $dataArray = eZDbSchema::read('share/db_data.dba', true);
             if (!$dataArray) {
                 $resultArray['errors'][] = array('code' => 'EZSW-002', 'text' => "Failed loading database data file share/db_data.dba");
                 $result = false;
             }
             if ($result) {
                 $schemaArray = array_merge($schemaArray, $dataArray);
                 $schemaArray['type'] = strtolower($db->databaseName());
                 $schemaArray['instance'] = $db;
                 $result = true;
                 $dbSchema = eZDbSchema::instance($schemaArray);
                 if (!$dbSchema) {
                     $resultArray['errors'][] = array('code' => 'EZSW-003', 'text' => "Failed loading " . $db->databaseName() . " schema handler");
                     $result = false;
                 }
                 if ($result) {
                     $result = true;
                     // This will insert the schema, then the data and
                     // run any sequence value correction SQL if required
                     $params = array('schema' => true, 'data' => true);
                     if ($db->databaseName() == 'mysql') {
                         $engines = $db->arrayQuery('SHOW ENGINES');
                         foreach ($engines as $engine) {
                             if ($engine['Engine'] == 'InnoDB' && in_array($engine['Support'], array('YES', 'DEFAULT'))) {
                                 $params['table_type'] = 'innodb';
                                 break;
                             }
                         }
                     }
                     if (!$dbSchema->insertSchema($params)) {
                         $resultArray['errors'][] = array('code' => 'EZSW-004', 'text' => "Failed inserting data to " . $db->databaseName() . "\n" . $db->errorMessage());
                         $result = false;
                     }
                 }
             }
         }
         if ($result) {
             // Inserting data from the dba-data files of the datatypes
             eZDataType::loadAndRegisterAllTypes();
             $registeredDataTypes = eZDataType::registeredDataTypes();
             foreach ($registeredDataTypes as $dataType) {
                 if (!$dataType->importDBDataFromDBAFile()) {
                     $resultArray['errors'][] = array('code' => 'EZSW-002', 'text' => "Failed importing datatype related data into database: \n" . 'datatype - ' . $dataType->DataTypeString . ", \n" . 'dba-data file - ' . $dataType->getDBAFilePath());
                 }
             }
         }
     }
     if (!$result) {
         return false;
     }
     // Database initialization done
     // Prepare languages
     $primaryLanguageLocaleCode = $primaryLanguage->localeCode();
     $primaryLanguageName = $primaryLanguage->languageName();
     $prioritizedLanguages = array_merge(array($primaryLanguageLocaleCode), $extraLanguageCodes);
     $installParameters = array('path' => '.');
     $installParameters['ini'] = array();
     $siteINIChanges = array();
     $url = $siteType['url'];
     if (preg_match("#^[a-zA-Z0-9]+://(.*)\$#", $url, $matches)) {
         $url = $matches[1];
     }
     $siteINIChanges['SiteAccessSettings'] = array('RelatedSiteAccessList' => $accessMap['accesses']);
     $siteINIChanges['ContentSettings'] = array('TranslationList' => implode(';', $extraLanguageCodes));
     $siteINIChanges['SiteSettings'] = array('SiteName' => $siteType['title'], 'SiteURL' => $url);
     $siteINIChanges['DatabaseSettings'] = array('DatabaseImplementation' => $dbDriver, 'Server' => $dbServer, 'Port' => $dbPort, 'Database' => $dbName, 'User' => $dbUser, 'Password' => $dbPwd, 'Charset' => false);
     $siteINIChanges['FileSettings'] = array('VarDir' => 'var/' . $siteType['identifier']);
     if (trim($dbSocket) != '') {
         $siteINIChanges['DatabaseSettings']['Socket'] = $dbSocket;
     } else {
         $siteINIChanges['DatabaseSettings']['Socket'] = 'disabled';
     }
     if ($admin['email']) {
         $siteINIChanges['InformationCollectionSettings'] = array('EmailReceiver' => false);
         $siteINIChanges['UserSettings'] = array('RegistrationEmail' => false);
         $siteINIChanges['MailSettings'] = array('AdminEmail' => $admin['email'], 'EmailSender' => false);
     }
     $siteINIChanges['RegionalSettings'] = array('Locale' => $primaryLanguage->localeFullCode(), 'ContentObjectLocale' => $primaryLanguage->localeCode(), 'SiteLanguageList' => $prioritizedLanguages);
     if ($primaryLanguage->localeCode() == 'eng-GB') {
         $siteINIChanges['RegionalSettings']['TextTranslation'] = 'disabled';
     } else {
         $siteINIChanges['RegionalSettings']['TextTranslation'] = 'enabled';
     }
     $installParameters['ini']['siteaccess'][$adminSiteaccessName]['site.ini.append'] = $siteINIChanges;
     $installParameters['ini']['siteaccess'][$userSiteaccessName]['site.ini.append'] = $siteINIChanges;
     $installParameters['ini']['siteaccess'][$userSiteaccessName]['site.ini']['DesignSettings'] = array('SiteDesign' => $userDesignName);
     $installParameters['variables']['user_siteaccess'] = $userSiteaccessName;
     $installParameters['variables']['admin_siteaccess'] = $adminSiteaccessName;
     $installParameters['variables']['design'] = $userDesignName;
     $tmpSiteINI = eZINI::create('site.ini');
     // Set ReadOnlySettingsCheck to false: towards
     // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
     $tmpSiteINI->setReadOnlySettingsCheck(false);
     $tmpSiteINI->setVariable('FileSettings', 'VarDir', $siteINIChanges['FileSettings']['VarDir']);
     // Change the current translation variables, before other parts start using them
     $tmpSiteINI->setVariable('RegionalSettings', 'Locale', $siteINIChanges['RegionalSettings']['Locale']);
     $tmpSiteINI->setVariable('RegionalSettings', 'ContentObjectLocale', $siteINIChanges['RegionalSettings']['ContentObjectLocale']);
     $tmpSiteINI->setVariable('RegionalSettings', 'TextTranslation', $siteINIChanges['RegionalSettings']['TextTranslation']);
     $tmpSiteINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}");
     /*
     $typeFunctionality = eZSetupFunctionality( $siteType['identifier'] );
     $extraFunctionality = array_merge( isset( $this->PersistenceList['additional_packages'] ) ?
                                        $this->PersistenceList['additional_packages'] :
                                        array(),
                                        $typeFunctionality['required'] );
     $extraFunctionality = array_unique( $extraFunctionality );
     */
     // Add a policy to permit editors using OE
     eZPolicy::createNew(3, array('ModuleName' => 'ezoe', 'FunctionName' => '*'));
     // Install site package and it's required packages
     $sitePackageName = $this->chosenSitePackage();
     $sitePackage = eZPackage::fetch($sitePackageName);
     if (!is_object($sitePackage)) {
         $resultArray['errors'][] = array('code' => 'EZSW-041', 'text' => " Could not fetch site package: '{$sitePackageName}'");
         return false;
     }
     $dependecies = $sitePackage->attribute('dependencies');
     $requires = $dependecies['requires'];
     $requiredPackages = array();
     // Include setting files
     $settingsFiles = $sitePackage->attribute('settings-files');
     foreach ($settingsFiles as $settingsFileName) {
         if (file_exists($sitePackage->path() . '/settings/' . $settingsFileName)) {
             include_once $sitePackage->path() . '/settings/' . $settingsFileName;
         }
     }
     // Call user function for additional setup tasks.
     if (function_exists('eZSitePreInstall')) {
         eZSitePreInstall($siteType);
     }
     // Make sure objects use the selected main language instead of eng-GB
     if ($primaryLanguageLocaleCode != 'eng-GB') {
         $engLanguageObj = eZContentLanguage::fetchByLocale('eng-GB');
         $engLanguageID = (int) $engLanguageObj->attribute('id');
         $updateSql = "UPDATE ezcontent_language\nSET\nlocale='{$primaryLanguageLocaleCode}',\nname='{$primaryLanguageName}'\nWHERE\nid={$engLanguageID}";
         $db->query($updateSql);
         eZContentLanguage::expireCache();
         $primaryLanguageObj = eZContentLanguage::fetchByLocale($primaryLanguageLocaleCode);
         // Add it if it is missing (most likely)
         if (!$primaryLanguageObj) {
             $primaryLanguageObj = eZContentLanguage::addLanguage($primaryLanguageLocaleCode, $primaryLanguageName);
         }
         $primaryLanguageID = (int) $primaryLanguageObj->attribute('id');
         // Find objects which are always available
         if ($db->databaseName() == 'oracle') {
             $sql = "SELECT id\nFROM\nezcontentobject\nWHERE\nbitand( language_mask, 1 ) = 1";
         } else {
             $sql = "SELECT id\nFROM\nezcontentobject\nWHERE\nlanguage_mask & 1 = 1";
         }
         $objectList = array();
         $list = $db->arrayQuery($sql);
         foreach ($list as $row) {
             $objectList[] = (int) $row['id'];
         }
         $inSql = 'IN ( ' . implode(', ', $objectList) . ')';
         // Updates databases that have eng-GB data to the new locale.
         $updateSql = "UPDATE ezcontentobject_name\nSET\ncontent_translation='{$primaryLanguageLocaleCode}',\nreal_translation='{$primaryLanguageLocaleCode}',\nlanguage_id={$primaryLanguageID}\nWHERE\ncontent_translation='eng-GB' OR\nreal_translation='eng-GB'";
         $db->query($updateSql);
         // Fix always available
         $updateSql = "UPDATE ezcontentobject_name\nSET\nlanguage_id=language_id+1\nWHERE\ncontentobject_id {$inSql}";
         $db->query($updateSql);
         // attributes
         $updateSql = "UPDATE ezcontentobject_attribute\nSET\nlanguage_code='{$primaryLanguageLocaleCode}',\nlanguage_id={$primaryLanguageID}\nWHERE\nlanguage_code='eng-GB'";
         $db->query($updateSql);
         // Fix always available
         $updateSql = "UPDATE ezcontentobject_attribute\nSET\nlanguage_id=language_id+1\nWHERE\ncontentobject_id {$inSql}";
         $db->query($updateSql);
         // version
         $updateSql = "UPDATE ezcontentobject_version\nSET\ninitial_language_id={$primaryLanguageID},\nlanguage_mask={$primaryLanguageID}\nWHERE\ninitial_language_id={$engLanguageID}";
         $db->query($updateSql);
         // Fix always available
         $updateSql = "UPDATE ezcontentobject_version\nSET\nlanguage_mask=language_mask+1\nWHERE\ncontentobject_id {$inSql}";
         $db->query($updateSql);
         // object
         $updateSql = "UPDATE ezcontentobject\nSET\ninitial_language_id={$primaryLanguageID},\nlanguage_mask={$primaryLanguageID}\nWHERE\ninitial_language_id={$engLanguageID}";
         $db->query($updateSql);
         // Fix always available
         $updateSql = "UPDATE ezcontentobject\nSET\nlanguage_mask=language_mask+1\nWHERE\nid {$inSql}";
         $db->query($updateSql);
         // content object state groups & states
         $mask = $primaryLanguageID | 1;
         $db->query("UPDATE ezcobj_state_group\n                         SET language_mask = {$mask}, default_language_id = {$primaryLanguageID}\n                         WHERE default_language_id = {$engLanguageID}");
         $db->query("UPDATE ezcobj_state\n                         SET language_mask = {$mask}, default_language_id = {$primaryLanguageID}\n                         WHERE default_language_id = {$engLanguageID}");
         $db->query("UPDATE ezcobj_state_group_language\n                         SET language_id = {$primaryLanguageID}\n                         WHERE language_id = {$engLanguageID}");
         $db->query("UPDATE ezcobj_state_language\n                         SET language_id = {$primaryLanguageID}\n                         WHERE language_id = {$engLanguageID}");
         // ezcontentclass_name
         $updateSql = "UPDATE ezcontentclass_name\nSET\nlanguage_locale='{$primaryLanguageLocaleCode}'\nWHERE\nlanguage_locale='eng-GB'";
         $db->query($updateSql);
         // use high-level api, because it's impossible to update serialized names with direct sqls.
         // use direct access to 'NameList' to avoid unnecessary sql-requests and because
         // we do 'replacement' of existing language(with some 'id') with another language code.
         $contentClassList = eZContentClass::fetchList();
         foreach ($contentClassList as $contentClass) {
             $classAttributes = $contentClass->fetchAttributes();
             foreach ($classAttributes as $classAttribute) {
                 $classAttribute->NameList->setName($classAttribute->NameList->name('eng-GB'), $primaryLanguageLocaleCode);
                 $classAttribute->NameList->setAlwaysAvailableLanguage($primaryLanguageLocaleCode);
                 $classAttribute->NameList->removeName('eng-GB');
                 $classAttribute->store();
             }
             $contentClass->NameList->setName($contentClass->NameList->name('eng-GB'), $primaryLanguageLocaleCode);
             $contentClass->NameList->setAlwaysAvailableLanguage($primaryLanguageLocaleCode);
             $contentClass->NameList->removeName('eng-GB');
             $contentClass->NameList->setHasDirtyData(false);
             // to not update 'ezcontentclass_name', because we've already updated it.
             $contentClass->store();
         }
     }
     // Setup all languages
     foreach ($allLanguages as $languageObject) {
         $primaryLanguageObj = eZContentLanguage::fetchByLocale($languageObject->localeCode());
         // Add it if it is missing (most likely)
         if (!$primaryLanguageObj) {
             $primaryLanguageObj = eZContentLanguage::addLanguage($languageObject->localeCode(), $languageObject->internationalLanguageName());
         }
     }
     eZContentLanguage::expireCache();
     // Make sure priority list is changed to the new chosen languages
     eZContentLanguage::setPrioritizedLanguages($prioritizedLanguages);
     if ($siteType['existing_database'] != eZStepInstaller::DB_DATA_KEEP) {
         $user = eZUser::instance(14);
         // Must be initialized to make node assignments work correctly
         if (!is_object($user)) {
             $resultArray['errors'][] = array('code' => 'EZSW-020', 'text' => "Could not fetch administrator user object");
             return false;
         }
         // Make sure Admin is the currently logged in user
         // This makes sure all new/changed objects get this as creator
         $user->loginCurrent();
         // by default(if 'language_map' is not set) create all necessary languages
         $languageMap = isset($this->PersistenceList['package_info']) && isset($this->PersistenceList['package_info']['language_map']) ? $this->PersistenceList['package_info']['language_map'] : true;
         if (is_array($languageMap) && count($languageMap) > 0) {
             //
             // Create necessary languages and set them as "prioritized languages" to avoid
             // drawbacks in fetch functions, like eZContentObjectTreeNode::fetch().
             //
             $prioritizedLanguageObjects = eZContentLanguage::prioritizedLanguages();
             // returned objects
             foreach ($languageMap as $fromLanguage => $toLanguage) {
                 if ($toLanguage != 'skip') {
                     $prioritizedLanguageObjects[] = eZContentLanguage::fetchByLocale($toLanguage, true);
                 }
             }
             $prioritizedLanguageLocales = array();
             foreach ($prioritizedLanguageObjects as $language) {
                 $locale = $language->attribute('locale');
                 if (!in_array($locale, $prioritizedLanguageLocales)) {
                     $prioritizedLanguageLocales[] = $locale;
                 }
             }
             eZContentLanguage::setPrioritizedLanguages($prioritizedLanguageLocales);
         }
         foreach ($requires as $require) {
             if ($require['type'] != 'ezpackage') {
                 continue;
             }
             $packageName = $require['name'];
             $package = eZPackage::fetch($packageName, false, false, false);
             if (is_object($package)) {
                 $requiredPackages[] = $package;
                 if ($package->attribute('install_type') == 'install') {
                     $installParameters = array('use_dates_from_package' => true, 'site_access_map' => array('*' => $userSiteaccessName), 'top_nodes_map' => array('*' => 2), 'design_map' => array('*' => $userDesignName), 'language_map' => $languageMap, 'restore_dates' => true, 'user_id' => $user->attribute('contentobject_id'), 'non-interactive' => true);
                     $status = $package->install($installParameters);
                     if (!$status) {
                         $errorText = "Unable to install package '{$packageName}'";
                         if (isset($installParameters['error']['description'])) {
                             $errorText .= ": " . $installParameters['error']['description'];
                         }
                         $resultArray['errors'][] = array('code' => 'EZSW-051', 'text' => $errorText);
                         return false;
                     }
                 }
             } else {
                 $resultArray['errors'][] = array('code' => 'EZSW-050', 'text' => "Could not fetch required package: '{$packageName}'");
                 return false;
             }
             unset($package);
         }
     }
     $GLOBALS['eZContentObjectDefaultLanguage'] = $primaryLanguageLocaleCode;
     $nodeRemoteMap = array();
     $rows = $db->arrayQuery("SELECT node_id, remote_id FROM ezcontentobject_tree");
     foreach ($rows as $row) {
         $remoteID = $row['remote_id'];
         if (strlen(trim($remoteID)) > 0) {
             $nodeRemoteMap[$remoteID] = $row['node_id'];
         }
     }
     $objectRemoteMap = array();
     $rows = $db->arrayQuery("SELECT id, remote_id FROM ezcontentobject");
     foreach ($rows as $row) {
         $remoteID = $row['remote_id'];
         if (strlen(trim($remoteID)) > 0) {
             $objectRemoteMap[$remoteID] = $row['id'];
         }
     }
     $classRemoteMap = array();
     $rows = $db->arrayQuery("SELECT id, identifier, remote_id FROM ezcontentclass");
     foreach ($rows as $row) {
         $remoteID = $row['remote_id'];
         if (strlen(trim($remoteID)) > 0) {
             $classRemoteMap[$remoteID] = array('id' => $row['id'], 'identifier' => $row['identifier']);
         }
     }
     $siteCSS = false;
     $classesCSS = false;
     foreach ($requiredPackages as $package) {
         if ($package->attribute('type') == 'sitestyle') {
             $fileList = $package->fileList('default');
             foreach ($fileList as $file) {
                 $fileIdentifier = $file["variable-name"];
                 if ($fileIdentifier == 'sitecssfile') {
                     $siteCSS = $package->fileItemPath($file, 'default');
                 } else {
                     if ($fileIdentifier == 'classescssfile') {
                         $classesCSS = $package->fileItemPath($file, 'default');
                     }
                 }
             }
         }
     }
     $parameters = array('node_remote_map' => $nodeRemoteMap, 'object_remote_map' => $objectRemoteMap, 'class_remote_map' => $classRemoteMap, 'preview_design' => $userDesignName, 'design_list' => array($userDesignName, 'admin2', 'admin'), 'user_siteaccess' => $userSiteaccessName, 'admin_siteaccess' => $adminSiteaccessName, 'package_object' => $sitePackage, 'siteaccess_urls' => $this->siteaccessURLs(), 'access_map' => $accessMap, 'site_type' => $siteType, 'all_language_codes' => $prioritizedLanguages);
     $siteINIStored = false;
     $siteINIAdminStored = false;
     $designINIStored = false;
     if (function_exists('eZSiteINISettings')) {
         $extraSettings = eZSiteINISettings($parameters);
     } else {
         $extraSettings = array();
     }
     if (function_exists('eZSiteAdminINISettings')) {
         $extraAdminSettings = eZSiteAdminINISettings($parameters);
     } else {
         $extraAdminSettings = array();
     }
     if (function_exists('eZSiteCommonINISettings')) {
         $extraCommonSettings = eZSiteCommonINISettings($parameters);
     } else {
         $extraCommonSettings = array();
     }
     $isUntranslatedSettingAdded = false;
     foreach ($extraAdminSettings as $key => $extraAdminSetting) {
         if ($extraAdminSetting['name'] == 'site.ini') {
             $extraAdminSettings[$key]['settings']['RegionalSettings']['ShowUntranslatedObjects'] = 'enabled';
             $isUntranslatedSettingAdded = true;
             break;
         }
     }
     if (!$isUntranslatedSettingAdded) {
         $extraAdminSettings[] = array('name' => 'site.ini', 'settings' => array('RegionalSettings' => array('ShowUntranslatedObjects' => 'enabled')));
     }
     // Enable OE and ODF extensions by default
     $extensionsToEnable = array();
     // Included in "fat" install, needs to override $extraCommonSettings extensions
     $extensionsPrepended = array('ezjscore', 'ezoe', 'ezformtoken');
     foreach (array('ezie', 'ezodf', 'ezprestapiprovider', 'ezmultiupload', 'eztags', 'ezautosave', 'ez_network', 'ez_network_demo') as $extension) {
         if (file_exists("extension/{$extension}")) {
             $extensionsToEnable[] = $extension;
         }
     }
     $settingAdded = false;
     foreach ($extraCommonSettings as $key => $extraCommonSetting) {
         if ($extraCommonSetting['name'] == 'site.ini' && isset($extraCommonSettings[$key]['settings']['ExtensionSettings']['ActiveExtensions'])) {
             $settingAdded = true;
             $extraCommonSettings[$key]['settings']['ExtensionSettings']['ActiveExtensions'] = array_merge($extensionsPrepended, $extraCommonSettings[$key]['settings']['ExtensionSettings']['ActiveExtensions'], $extensionsToEnable);
             break;
         }
     }
     if (!$settingAdded) {
         $extraCommonSettings[] = array('name' => 'site.ini', 'settings' => array('ExtensionSettings' => array('ActiveExtensions' => array_merge($extensionsPrepended, $extensionsToEnable))));
     }
     // Enable dynamic tree menu for the admin interface by default
     $enableDynamicTreeMenuAdded = false;
     foreach ($extraAdminSettings as $key => $extraSetting) {
         if ($extraSetting['name'] == 'contentstructuremenu.ini') {
             if (isset($extraSetting['settings']['TreeMenu'])) {
                 $extraAdminSettings[$key]['settings']['TreeMenu']['Dynamic'] = 'enabled';
             } else {
                 $extraAdminSettings[$key]['settings'] = array('TreeMenu' => array('Dynamic' => 'enabled'));
             }
             $enableDynamicTreeMenuAdded = true;
             break;
         }
     }
     if (!$enableDynamicTreeMenuAdded) {
         $extraAdminSettings[] = array('name' => 'contentstructuremenu.ini', 'settings' => array('TreeMenu' => array('Dynamic' => 'enabled')));
     }
     $resultArray['common_settings'] = $extraCommonSettings;
     foreach ($extraSettings as $extraSetting) {
         if ($extraSetting === false) {
             continue;
         }
         $iniName = $extraSetting['name'];
         $settings = $extraSetting['settings'];
         $resetArray = false;
         if (isset($extraSetting['reset_arrays'])) {
             $resetArray = $extraSetting['reset_arrays'];
         }
         $tmpINI = eZINI::create($iniName);
         // Set ReadOnlySettingsCheck to false: towards
         // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
         $tmpINI->setReadOnlySettingsCheck(false);
         $tmpINI->setVariables($settings);
         if ($iniName == 'site.ini') {
             $siteINIStored = true;
             $tmpINI->setVariables($siteINIChanges);
             $tmpINI->setVariable('DesignSettings', 'SiteDesign', $userDesignName);
             $tmpINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('base'));
         } else {
             if ($iniName == 'design.ini') {
                 if ($siteCSS) {
                     $tmpINI->setVariable('StylesheetSettings', 'SiteCSS', $siteCSS);
                 }
                 if ($classesCSS) {
                     $tmpINI->setVariable('StylesheetSettings', 'ClassesCSS', $classesCSS);
                 }
                 $designINIStored = true;
             }
         }
         $tmpINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}", $resetArray);
         if ($siteType['existing_database'] != eZStepInstaller::DB_DATA_KEEP) {
             // setting up appropriate data in look&feel object
             $templateLookClass = eZContentClass::fetchByIdentifier('template_look', true);
             if ($templateLookClass) {
                 $objectList = $templateLookClass->objectList();
                 if ($objectList and count($objectList) > 0) {
                     $templateLookObject = current($objectList);
                     $dataMap = $templateLookObject->fetchDataMap();
                     if (isset($dataMap['title'])) {
                         $dataMap['title']->setAttribute('data_text', $siteINIChanges['SiteSettings']['SiteName']);
                         $dataMap['title']->store();
                     }
                     if (isset($dataMap['siteurl'])) {
                         $dataMap['siteurl']->setAttribute('data_text', $siteINIChanges['SiteSettings']['SiteURL']);
                         $dataMap['siteurl']->store();
                     }
                     if (isset($dataMap['email'])) {
                         $dataMap['email']->setAttribute('data_text', $siteINIChanges['MailSettings']['AdminEmail']);
                         $dataMap['email']->store();
                     }
                     $objectName = $templateLookClass->contentObjectName($templateLookObject);
                     $templateLookObject->setName($objectName);
                     $templateLookObject->store();
                 }
             }
         }
     }
     foreach ($extraAdminSettings as $extraSetting) {
         if ($extraSetting === false) {
             continue;
         }
         $iniName = $extraSetting['name'];
         $settings = $extraSetting['settings'];
         $resetArray = false;
         if (isset($extraSetting['reset_arrays'])) {
             $resetArray = $extraSetting['reset_arrays'];
         }
         $tmpINI = eZINI::create($iniName);
         $tmpINI->setVariables($settings);
         if ($iniName == 'site.ini') {
             $siteINIAdminStored = true;
             $tmpINI->setVariables($siteINIChanges);
             $tmpINI->setVariable('SiteAccessSettings', 'RequireUserLogin', 'true');
             $tmpINI->setVariable('DesignSettings', 'SiteDesign', 'admin2');
             $tmpINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('admin'));
             $tmpINI->setVariable('SiteSettings', 'LoginPage', 'custom');
             $tmpINI->setVariable('SiteSettings', 'DefaultPage', 'content/dashboard');
         }
         $tmpINI->save(false, '.append.php', false, true, "settings/siteaccess/{$adminSiteaccessName}", $resetArray);
     }
     if (!$siteINIAdminStored) {
         $siteINI = eZINI::create('site.ini');
         // Set ReadOnlySettingsCheck to false: towards
         // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
         $siteINI->setReadOnlySettingsCheck(false);
         $siteINI->setVariables($siteINIChanges);
         $siteINI->setVariable('SiteAccessSettings', 'RequireUserLogin', 'true');
         $siteINI->setVariable('DesignSettings', 'SiteDesign', 'admin2');
         $tmpINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('admin'));
         $siteINI->setVariable('SiteSettings', 'LoginPage', 'custom');
         $siteINI->setVariable('SiteSettings', 'DefaultPage', 'content/dashboard');
         $siteINI->save(false, '.append.php', false, false, "settings/siteaccess/{$adminSiteaccessName}", true);
     }
     if (!$siteINIStored) {
         $siteINI = eZINI::create('site.ini');
         // Set ReadOnlySettingsCheck to false: towards
         // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
         $siteINI->setReadOnlySettingsCheck(false);
         $siteINI->setVariables($siteINIChanges);
         $siteINI->setVariable('DesignSettings', 'SiteDesign', $userDesignName);
         $siteINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('base'));
         $siteINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}", true);
     }
     if (!$designINIStored) {
         $designINI = eZINI::create('design.ini');
         // Set ReadOnlySettingsCheck to false: towards
         // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
         $designINI->setReadOnlySettingsCheck(false);
         if ($siteCSS) {
             $designINI->setVariable('StylesheetSettings', 'SiteCSS', $siteCSS);
         }
         if ($classesCSS) {
             $designINI->setVariable('StylesheetSettings', 'ClassesCSS', $classesCSS);
         }
         $designINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}");
     }
     eZDir::mkdir("design/" . $userDesignName);
     eZDir::mkdir("design/" . $userDesignName . "/templates");
     eZDir::mkdir("design/" . $userDesignName . "/stylesheets");
     eZDir::mkdir("design/" . $userDesignName . "/images");
     eZDir::mkdir("design/" . $userDesignName . "/override");
     eZDir::mkdir("design/" . $userDesignName . "/override/templates");
     if ($siteType['existing_database'] == eZStepInstaller::DB_DATA_KEEP) {
         return true;
     }
     // Try and remove user/login without limitation from the anonymous user
     $anonRole = eZRole::fetchByName('Anonymous');
     if (is_object($anonRole)) {
         $anonPolicies = $anonRole->policyList();
         foreach ($anonPolicies as $anonPolicy) {
             if ($anonPolicy->attribute('module_name') == 'user' and $anonPolicy->attribute('function_name') == 'login') {
                 $anonPolicy->removeThis();
                 break;
             }
         }
     }
     // Setup all roles according to site chosen and addons
     if (function_exists('eZSiteRoles')) {
         $extraRoles = eZSiteRoles($parameters);
         foreach ($extraRoles as $extraRole) {
             if (!$extraRole) {
                 continue;
             }
             $extraRoleName = $extraRole['name'];
             $role = eZRole::fetchByName($extraRoleName);
             if (!is_object($role)) {
                 $role = eZRole::create($extraRoleName);
                 $role->store();
             }
             $roleID = $role->attribute('id');
             if (isset($extraRole['policies'])) {
                 $extraPolicies = $extraRole['policies'];
                 foreach ($extraPolicies as $extraPolicy) {
                     if (isset($extraPolicy['limitation'])) {
                         $role->appendPolicy($extraPolicy['module'], $extraPolicy['function'], $extraPolicy['limitation']);
                     } else {
                         $role->appendPolicy($extraPolicy['module'], $extraPolicy['function']);
                     }
                 }
             }
             if (isset($extraRole['assignments'])) {
                 $roleAssignments = $extraRole['assignments'];
                 foreach ($roleAssignments as $roleAssignment) {
                     $assignmentIdentifier = false;
                     $assignmentValue = false;
                     if (isset($roleAssignment['limitation'])) {
                         $assignmentIdentifier = $roleAssignment['limitation']['identifier'];
                         $assignmentValue = $roleAssignment['limitation']['value'];
                     }
                     $role->assignToUser($roleAssignment['user_id'], $assignmentIdentifier, $assignmentValue);
                 }
             }
         }
     }
     // Setup user preferences based on the site chosen and addons
     if (function_exists('eZSitePreferences')) {
         $prefs = eZSitePreferences($parameters);
         foreach ($prefs as $prefEntry) {
             if (!$prefEntry) {
                 continue;
             }
             $prefUserID = $prefEntry['user_id'];
             foreach ($prefEntry['preferences'] as $pref) {
                 $prefName = $pref['name'];
                 $prefValue = $pref['value'];
                 if (!eZPreferences::setValue($prefName, $prefValue, $prefUserID)) {
                     $resultArray['errors'][] = array('code' => 'EZSW-070', 'text' => "Could not create ezpreference '{$prefValue}' for {$prefUserID}");
                     return false;
                 }
             }
         }
     }
     $publishAdmin = false;
     $userAccount = eZUser::fetch(14);
     if (!is_object($userAccount)) {
         $resultArray['errors'][] = array('code' => 'EZSW-020', 'text' => "Could not fetch administrator user object");
         return false;
     }
     $userObject = $userAccount->attribute('contentobject');
     if (!is_object($userObject)) {
         $resultArray['errors'][] = array('code' => 'EZSW-021', 'text' => "Could not fetch administrator content object");
         return false;
     }
     $newUserObject = $userObject->createNewVersion(false, false);
     if (!is_object($newUserObject)) {
         $resultArray['errors'][] = array('code' => 'EZSW-022', 'text' => "Could not create new version of administrator content object");
         return false;
     }
     $dataMap = $newUserObject->attribute('data_map');
     $error = false;
     if (trim($admin['email'])) {
         if (!isset($dataMap['user_account'])) {
             $resultArray['errors'][] = array('code' => 'EZSW-023', 'text' => "Administrator content object does not have a 'user_account' attribute");
             return false;
         }
         $userAccount->setInformation(14, 'admin', $admin['email'], $admin['password'], $admin['password']);
         $dataMap['user_account']->setContent($userAccount);
         $dataMap['user_account']->store();
         $publishAdmin = true;
         $userAccount->store();
     }
     if (trim($admin['first_name']) or trim($admin['last_name'])) {
         if (!isset($dataMap['first_name'])) {
             $resultArray['errors'][] = array('code' => 'EZSW-023', 'text' => "Administrator content object does not have a 'first_name' field");
             $error = true;
         }
         if (!isset($dataMap['last_name'])) {
             $resultArray['errors'][] = array('code' => 'EZSW-024', 'text' => "Administrator content object does not have a 'last_name' field");
             $error = true;
         }
         if ($error) {
             return false;
         }
         $dataMap['first_name']->setAttribute('data_text', $admin['first_name']);
         $dataMap['first_name']->store();
         $dataMap['last_name']->setAttribute('data_text', $admin['last_name']);
         $dataMap['last_name']->store();
         $newUserObject->store();
         $publishAdmin = true;
     }
     if ($publishAdmin) {
         $operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $newUserObject->attribute('contentobject_id'), 'version' => $newUserObject->attribute('version')));
         if ($operationResult['status'] != eZModuleOperationInfo::STATUS_CONTINUE) {
             $resultArray['errors'][] = array('code' => 'EZSW-025', 'text' => "Failed to properly publish the administrator object");
             return false;
         }
     }
     // Call user function for additional setup tasks.
     if (function_exists('eZSitePostInstall')) {
         eZSitePostInstall($parameters);
     }
     // get all siteaccesses. do it via 'RelatedSiteAccessesList' settings.
     $adminSiteINI = eZINI::instance('site.ini' . '.append.php', "settings/siteaccess/{$adminSiteaccessName}");
     $relatedSiteAccessList = $adminSiteINI->variable('SiteAccessSettings', 'RelatedSiteAccessList');
     // Adding override for 'tiny_image' view for 'multi-option2' datatype
     foreach ($relatedSiteAccessList as $siteAccess) {
         $tmpOverrideINI = new eZINI('override.ini' . '.append.php', "settings/siteaccess/{$siteAccess}", null, null, null, true, true);
         $tmpOverrideINI->setVariable('tiny_image', 'Source', 'content/view/tiny.tpl');
         $tmpOverrideINI->setVariable('tiny_image', 'MatchFile', 'tiny_image.tpl');
         $tmpOverrideINI->setVariable('tiny_image', 'Subdir', 'templates');
         $tmpOverrideINI->setVariable('tiny_image', 'Match', array('class_identifier' => 'image'));
         $tmpOverrideINI->save();
     }
     $accessMap = $parameters['access_map'];
     // Call user function for some text which will be displayed at 'Finish' screen
     if (function_exists('eZSiteFinalText')) {
         $text = eZSiteFinalText($parameters);
         if (!isset($this->PersistenceList['final_text'])) {
             $this->PersistenceList['final_text'] = array();
         }
         $this->PersistenceList['final_text'][] = $text;
     }
     // ensure that evaluated policy wildcards in the user info cache
     // will be up to date with the currently activated modules
     eZCache::clearByID('user_info_cache');
     return true;
 }
コード例 #7
0
<?php

/**
 * File containing logic of setting view
 *
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 *
 */
$tpl = eZTemplate::factory();
$http = eZHTTPTool::instance();
$user = eZUser::instance();
$ini = eZINI::instance('ezcomments.ini');
$hashStringLength = $ini->variable('NotificationSettings', 'SubscriberHashStringLength');
$hashString = null;
$page = 1;
if ($user->isAnonymous()) {
    $hashString = trim($Params['HashString']);
    if (!is_null($Params['Page'])) {
        $page = $Params['Page'];
    }
    if (is_null($hashString) || strlen($hashString) != $hashStringLength) {
        $Result = array();
        $Result['content'] = $tpl->fetch('design:comment/setting.tpl');
        $Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('ezcomments/comment/setting', 'Comment settings')));
        return $Result;
    }
} else {
    if (!is_null($Params['HashString']) && $Params['HashString'] != '') {
        $page = $Params['HashString'];
    }
コード例 #8
0
ファイル: ezflowoperations.php プロジェクト: netbliss/ezflow
 /**
  * Do all time based operations on block pool such as rotation, updating
  * the queue, overflow as well as executes fetch interfaces.
  *
  * @static
  */
 public static function update($nodeArray = array())
 {
     // log in user as anonymous if another user is logged in
     $currentUser = eZUser::currentUser();
     if ($currentUser->isLoggedIn()) {
         $loggedInUser = $currentUser;
         $anonymousUserId = eZUser::anonymousId();
         $anonymousUser = eZUser::instance($anonymousUserId);
         eZUser::setCurrentlyLoggedInUser($anonymousUser, $anonymousUserId);
         unset($currentUser, $anonymousUser, $anonymousUserId);
     }
     include_once 'kernel/classes/ezcontentcache.php';
     $ini = eZINI::instance('block.ini');
     $db = eZDB::instance();
     // Remove the blocks and items for the block if marked for removal
     $res = $db->arrayQuery("SELECT id\n                         FROM ezm_block\n                         WHERE is_removed=1");
     foreach ($res as $row) {
         $blockID = $row['id'];
         $db->begin();
         $db->query("DELETE FROM ezm_pool\n                 WHERE block_id='{$blockID}'");
         $db->query("DELETE FROM ezm_block\n                 WHERE id='{$blockID}'");
         $db->commit();
     }
     if (!$nodeArray) {
         // Update pool and pages for all nodes
         $res = $db->arrayQuery("SELECT DISTINCT node_id FROM ezm_block");
         foreach ($res as $row) {
             $nodeArray[] = $row['node_id'];
         }
     }
     foreach ($nodeArray as $nodeID) {
         $time = time() - 5;
         // a safety margin
         $nodeChanged = false;
         $blocks = $db->arrayQuery("SELECT *\n                                FROM ezm_block\n                                WHERE node_id={$nodeID}");
         $blockByID = array();
         // Determine the order of updating
         $correctOrder = array();
         $next = array();
         foreach ($blocks as $block) {
             $next[$block['id']] = trim($block['overflow_id']);
             // Make sure that block ID does not any have spaces
             $blockByID[$block['id']] = $block;
         }
         $nextIDs = array_keys($next);
         foreach ($nextIDs as $id) {
             if (in_array($id, $correctOrder, true)) {
                 continue;
             }
             if (!$next[$id]) {
                 $correctOrder[] = $id;
                 continue;
             }
             $subCorrectOrder = array($id);
             $currentID = $id;
             while ($nextID = $next[$currentID]) {
                 if (!in_array($nextID, $nextIDs, true)) {
                     eZDebug::writeWarning("Overflow for {$currentID} is {$nextID}, but no such block was found for the given node", __METHOD__);
                     break;
                 }
                 if (in_array($nextID, $subCorrectOrder, true)) {
                     eZDebug::writeWarning("Loop detected, ignoring ({$nextID} should be after {$currentID} and vice versa)", __METHOD__);
                     break;
                 }
                 if (in_array($nextID, $correctOrder, true)) {
                     break;
                 }
                 $subCorrectOrder[] = $nextID;
                 $currentID = $nextID;
             }
             if (!$nextID || !in_array($nextID, $correctOrder, true)) {
                 foreach ($subCorrectOrder as $element) {
                     $correctOrder[] = $element;
                 }
             } else {
                 $newCorrectOrder = array();
                 foreach ($correctOrder as $element) {
                     if ($element === $nextID) {
                         foreach ($subCorrectOrder as $element2) {
                             $newCorrectOrder[] = $element2;
                         }
                     }
                     $newCorrectOrder[] = $element;
                 }
                 $correctOrder = $newCorrectOrder;
             }
         }
         // Loop through all block in determined order
         foreach ($correctOrder as $blockID) {
             if ($blockByID[$blockID]) {
                 $block = $blockByID[$blockID];
             } else {
                 continue;
             }
             // Do we need to update block? No, continue to process next block
             $ttl = 0;
             if ($ini->hasVariable($block['block_type'], 'TTL')) {
                 $ttl = $ini->variable($block['block_type'], 'TTL');
             }
             if ($ttl + $block['last_update'] >= $time) {
                 continue;
             }
             // For "rotating blocks", does the rotation_interval has passed from the last update?
             if ($block['rotation_type'] != self::ROTATION_NONE && $block['last_update'] + $block['rotation_interval'] >= $time) {
                 continue;
             }
             $blockChanged = false;
             // Fetch new objects and add them to the queue of the current block
             eZFlowOperations::updateBlockPoolByBlockID($block, $time);
             $db->begin();
             // We need to find out if there are any items to move from the queue
             $movingFromQueue = $db->arrayQuery("SELECT object_id\n                                             FROM ezm_pool\n                                             WHERE block_id='{$blockID}'\n                                               AND ts_visible=0\n                                               AND ts_hidden=0\n                                               AND ts_publication<={$time}\n                                             ORDER BY ts_publication ASC, priority ASC");
             if ($movingFromQueue) {
                 $blockChanged = true;
                 // Find out a number of items in "valid" state and the max. priority used
                 $countMaxPriorityValid = $db->arrayQuery("SELECT count(*) AS count, max(priority) AS priority\n                                                       FROM ezm_pool\n                                                       WHERE block_id='{$blockID}'\n                                                         AND ts_visible>0\n                                                         AND ts_hidden=0");
                 $countValid = $countMaxPriorityValid[0]['count'];
                 $maxPriorityValid = $countMaxPriorityValid[0]['priority'];
                 if ($countValid == 0) {
                     $maxPriorityValid = 0;
                 }
                 $priority = $maxPriorityValid + 1;
                 // Move objects waiting in queue to the "valid ones"
                 foreach ($movingFromQueue as $itemToMove) {
                     $objectID = $itemToMove['object_id'];
                     $db->query("UPDATE ezm_pool\n                             SET ts_visible={$time}, priority={$priority}\n                             WHERE block_id='{$blockID}'\n                               AND object_id={$objectID}");
                     $priority++;
                 }
                 $countValid += count($movingFromQueue);
                 // Compare this number to the given and archive the oldest (order by ts_visible)
                 $numberOfValidItems = $ini->variable($block['block_type'], 'NumberOfValidItems');
                 if (!$numberOfValidItems) {
                     $numberOfValidItems = 20;
                     eZDebug::writeWarning('Number of valid items for ' . $block['block_type'] . ' is not set; using the default value (' . $numberOfValidItems . ')', __METHOD__);
                 }
                 $countToRemove = $countValid - $numberOfValidItems;
                 if ($countToRemove > 0) {
                     $overflowID = $block['overflow_id'];
                     $items = $db->arrayQuery("SELECT node_id, object_id, rotation_until\n                                           FROM ezm_pool\n                                           WHERE block_id='{$blockID}'\n                                             AND ts_visible>0\n                                             AND ts_hidden=0\n                                           ORDER BY priority ASC", array('limit' => $countToRemove));
                     if ($items) {
                         $itemArray = array();
                         $priority = 0;
                         foreach ($items as $item) {
                             $objectID = $item['object_id'];
                             if ($block['rotation_type'] != self::ROTATION_NONE && ($item['rotation_until'] > $time || $item['rotation_until'] == 0)) {
                                 if ($block['rotation_type'] == self::ROTATION_SIMPLE) {
                                     // Simple rotation
                                     $newPublicationTS = -$time;
                                     $priority++;
                                 } else {
                                     // Random rotation/Shuffle
                                     $newPublicationTS = 0;
                                     $priority = mt_rand();
                                 }
                                 // Move item back to queue
                                 $db->query("UPDATE ezm_pool\n                                         SET ts_visible=0,\n                                             ts_publication=-{$time},\n                                             priority={$priority}\n                                         WHERE block_id='{$blockID}'\n                                           AND object_id={$objectID}");
                             } else {
                                 $itemArray[] = $objectID;
                             }
                         }
                         if ($itemArray) {
                             if ($overflowID) {
                                 // Put $itemArray items into pool of different block
                                 $priority = 0;
                                 foreach ($items as $item) {
                                     $itemObjectID = $item['object_id'];
                                     $itemNodeID = $item['node_id'];
                                     // Check if the object_id is not already in the new block
                                     $duplicityCheck = $db->arrayQuery("SELECT object_id\n                                                                    FROM ezm_pool\n                                                                    WHERE block_id='{$overflowID}'\n                                                                      AND object_id={$itemObjectID}", array('limit' => 1));
                                     if ($duplicityCheck) {
                                         eZDebug::writeNotice("Object {$itemObjectID} is already available in the block {$overflowID}.", __METHOD__);
                                     } else {
                                         $db->query("INSERT INTO ezm_pool(block_id,object_id,node_id,ts_publication,priority)\n                                                 VALUES ('{$overflowID}',{$itemObjectID},{$itemNodeID},{$time},{$priority})");
                                         $priority++;
                                     }
                                 }
                                 $db->query("UPDATE ezm_pool\n                                         SET ts_hidden={$time},\n                                             moved_to='{$overflowID}',\n                                             priority=0\n                                         WHERE block_id='{$blockID}'\n                                           AND " . $db->generateSQLINStatement($itemArray, 'object_id'));
                             } else {
                                 $db->query("UPDATE ezm_pool\n                                         SET ts_hidden={$time},\n                                             priority=0\n                                         WHERE block_id='{$blockID}'\n                                           AND " . $db->generateSQLINStatement($itemArray, 'object_id'));
                             }
                         }
                     }
                 }
                 // Cleanup in archived items
                 $countArchived = $db->arrayQuery("SELECT count(*) AS count\n                                               FROM ezm_pool\n                                               WHERE block_id='{$blockID}'\n                                                 AND ts_hidden>0");
                 $countArchived = $countArchived[0]['count'];
                 // Compare this number to the given and remove the oldest ones
                 $numberOfArchivedItems = $ini->variable($block['block_type'], 'NumberOfArchivedItems');
                 if ($numberOfArchivedItems < 0) {
                     $numberOfArchivedItems = 50;
                     eZDebug::writeWarning('Number of archived items for ' . $block['block_type'] . ' is not set; using the default value (' . $numberOfArchivedItems . ')', __METHOD__);
                 }
                 $countToRemove = $countArchived - $numberOfArchivedItems;
                 if ($countToRemove > 0) {
                     $items = $db->arrayQuery("SELECT object_id\n                                           FROM ezm_pool\n                                           WHERE block_id='{$blockID}'\n                                             AND ts_hidden>0\n                                           ORDER BY ts_hidden ASC", array('limit' => $countToRemove));
                     if ($items) {
                         $itemArray = array();
                         foreach ($items as $item) {
                             $itemArray[] = $item['object_id'];
                         }
                         $db->query("DELETE FROM ezm_pool\n                                 WHERE block_id='{$blockID}'\n                                   AND " . $db->generateSQLINStatement($itemArray, 'object_id'));
                     }
                 }
             }
             // If the block changed, we need to update whole node
             if ($blockChanged) {
                 $nodeChanged = true;
             }
             $db->commit();
         }
         if ($nodeChanged) {
             $contentObject = eZContentObject::fetchByNodeID($nodeID);
             if ($contentObject) {
                 eZContentCacheManager::clearContentCache($contentObject->attribute('id'));
             }
         }
     }
     // log the previously logged in user if it was changed to anonymous earlier
     if (isset($loggedInUser)) {
         eZUser::setCurrentlyLoggedInUser($loggedInUser, $loggedInUser->attribute('contentobject_id'));
     }
 }
コード例 #9
0
 function registerSubscription($firstname, $name, $mobile, $email, $password = false)
 {
     if ($this->emailSubscriptionExists($email)) {
         return false;
     }
     $subscription = eZSubscription::create($this->attribute('id'), $firstname, $name, $mobile, $email);
     $user = eZUser::instance();
     if ($this->attribute('auto_confirm_registered') && $user->isLoggedIn()) {
         $subscription->setAttribute('status', eZSubscription::StatusConfirmed);
         if ($this->attribute('auto_approve_registered')) {
             $subscription->setAttribute('status', eZSubscription::StatusApproved);
         }
     }
     if ($password !== false) {
         $subscription->setAttribute('password', $password);
     }
     if (!is_object($subscription)) {
         eZDebug::writeError('Newsletter Anmeldefehler', __METHOD__);
         eZDebug::writeError($this->attribute('id'), 'subscription id');
         eZDebug::writeError($name, 'name');
         eZDebug::writeError($firstname, 'firstname');
         eZDebug::writeError($email, 'email');
     }
     $subscription->publish();
     return $subscription;
 }
コード例 #10
0
    /**
     * Adds object $contentObject to the search database.
     *
     * @param eZContentObject $contentObject Object to add to search engine
     * @param bool $commit Whether to commit after adding the object.
              If set, run optimize() as well every 1000nd time this function is run.
     * @return bool True if the operation succeed.
     */
    function addObject( $contentObject, $commit = true )
    {
        // Add all translations to the document list
        $docList = array();

        // Check if we need to index this object after all
        // Exclude if class identifier is in the exclude list for classes
        $excludeClasses = $this->FindINI->variable( 'IndexExclude', 'ClassIdentifierList' );
        if ( $excludeClasses && in_array( $contentObject->attribute( 'class_identifier' ), $excludeClasses ) )
        {
            return true;
        }
        // Get global object values
        $mainNode = $contentObject->attribute( 'main_node' );
        if ( !$mainNode )
        {
            eZDebug::writeError( 'Unable to fetch main node for object: ' . $contentObject->attribute( 'id' ), __METHOD__ );
            return false;
        }

        $mainNodePathArray = $mainNode->attribute( 'path_array' );
        $mainNodeID = $mainNode->attribute( 'node_id' );
        // initialize array of parent node path ids, needed for multivalued path field and subtree filters
        $nodePathArray = array();

        //included in $nodePathArray
        //$pathArray = $mainNode->attribute( 'path_array' );
        $currentVersion = $contentObject->currentVersion();

        // Get object meta attributes.
        $metaAttributeValues = self::getMetaAttributesForObject( $contentObject );

        // Get node attributes.
        $nodeAttributeValues = array();
        foreach ( $contentObject->attribute( 'assigned_nodes' ) as $contentNode )
        {
            $nodeID = $contentNode->attribute( 'node_id' );
            foreach ( eZSolr::nodeAttributes() as $attributeName => $fieldType )
            {
                $nodeAttributeValues[$nodeID][] = array( 'name' => $attributeName,
                                                'value' => $contentNode->attribute( $attributeName ),
                                                'fieldType' => $fieldType );
            }
            $nodePathArray[] = $contentNode->attribute( 'path_array' );

        }

        // Check anonymous user access.
        if ( $this->FindINI->variable( 'SiteSettings', 'IndexPubliclyAvailable' ) == 'enabled' )
        {
            $anonymousUserID = $this->SiteINI->variable( 'UserSettings', 'AnonymousUserID' );
            $currentUserID = eZUser::currentUserID();
            $user = eZUser::instance( $anonymousUserID );
            eZUser::setCurrentlyLoggedInUser( $user, $anonymousUserID );
            $anonymousAccess = $contentObject->attribute( 'can_read' );
            $user = eZUser::instance( $currentUserID );
            eZUser::setCurrentlyLoggedInUser( $user, $currentUserID );
            $anonymousAccess = $anonymousAccess ? 'true' : 'false';
        }
        else
        {
            $anonymousAccess = 'false';
        }

        // Load index time boost factors if any
        //$boostMetaFields = $this->FindINI->variable( "IndexBoost", "MetaField" );
        $boostClasses = $this->FindINI->variable( 'IndexBoost', 'Class' );
        $boostAttributes = $this->FindINI->variable( 'IndexBoost', 'Attribute' );
        $boostDatatypes = $this->FindINI->variable( 'IndexBoost', 'Datatype' );
        $reverseRelatedScale = $this->FindINI->variable( 'IndexBoost', 'ReverseRelatedScale' );

        // Initialise default doc boost
        $docBoost = 1.0;
        $contentClassIdentifier = $contentObject->attribute( 'class_identifier' );
        // Just test if the boost factor is defined by checking if it has a numeric value
        if ( isset( $boostClasses[$contentClassIdentifier] ) && is_numeric( $boostClasses[$contentClassIdentifier] ) )
        {
            $docBoost += $boostClasses[$contentClassIdentifier];
        }
        // Google like boosting, using eZ Publish reverseRelatedObjectCount
        $reverseRelatedObjectCount = $contentObject->reverseRelatedObjectCount();
        $docBoost += $reverseRelatedScale * $reverseRelatedObjectCount;

        //  Create the list of available languages for this version :
        $availableLanguages = $currentVersion->translationList( false, false );

        // Loop over each language version and create an eZSolrDoc for it
        foreach ( $availableLanguages as $languageCode )
        {
            $doc = new eZSolrDoc( $docBoost );
            // Set global unique object ID
            $doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'guid' ), $this->guid( $contentObject, $languageCode ) );

            // Set installation identifier
            $doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'installation_id' ), self::installationID() );
            $doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'installation_url' ),
                            $this->FindINI->variable( 'SiteSettings', 'URLProtocol' ) . $this->SiteINI->variable( 'SiteSettings', 'SiteURL' ) . '/' );

            // Set Object attributes
            $doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'name' ), $contentObject->name( false, $languageCode ) );
            // Also add value to the "sort_name" field as "name" is unsortable, due to Solr limitation (tokenized field)
            $doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'sort_name' ), $contentObject->name( false, $languageCode ) );
            $doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'anon_access' ), $anonymousAccess );
            $doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'language_code' ), $languageCode );
            $doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'available_language_codes' ), $availableLanguages );

            if ( $owner = $contentObject->attribute( 'owner' ) )
            {
                // Set owner name
                $doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'owner_name' ),
                                $owner->name( false, $languageCode ) );

                // Set owner group ID
                foreach ( $owner->attribute( 'parent_nodes' ) as $groupID )
                {
                    $doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'owner_group_id' ), $groupID );
                }
            }

            // from eZ Publish 4.1 only: object states
            // so let's check if the content object has it
            if ( method_exists( $contentObject, 'stateIDArray' ) )
            {
                $doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'object_states' ),
                                $contentObject->stateIDArray() );
            }

            // Set content object meta attribute values.
            foreach ( $metaAttributeValues as $metaInfo )
            {
                $doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( $metaInfo['name'] ),
                                ezfSolrDocumentFieldBase::preProcessValue( $metaInfo['value'], $metaInfo['fieldType'] ) );
            }

            // Set content node meta attribute values.
            foreach ( $nodeAttributeValues as $nodeID => $metaInfoArray )
            {
                foreach( $metaInfoArray as $metaInfo)
                {
                    $doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( $metaInfo['name'] ),
                                ezfSolrDocumentFieldBase::preProcessValue( $metaInfo['value'], $metaInfo['fieldType'] ) );
                }
            }

            // Main node gets single valued fields for sorting, using a dedicated prefix
            foreach ( $nodeAttributeValues[$mainNodeID] as $metaInfo )
            {
                $fieldName = 'main_node_' . ezfSolrDocumentFieldBase::generateMetaFieldName( $metaInfo['name'] );
                $doc->addField( $fieldName,
                                    ezfSolrDocumentFieldBase::preProcessValue( $metaInfo['value'],
                                    $metaInfo['fieldType'] ) );
            }


            // Add main url_alias
            $doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'main_url_alias' ), $mainNode->attribute( 'url_alias' ) );

            // Add main path_string
            $doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'main_path_string' ), $mainNode->attribute( 'path_string' ) );

            // add nodeid of all parent nodes path elements
            foreach ( $nodePathArray as $pathArray )
            {
                foreach ( $pathArray as $pathNodeID)
                {
                    $doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'path' ), $pathNodeID );
                }
            }

            // Since eZ Fnd 2.3
            // cannot call metafield field bame constructor as we are creating multiple fields
            foreach ( $mainNodePathArray as $key => $pathNodeID )
            {
                $doc->addField( 'meta_main_path_element_' . $key . '_si', $pathNodeID );

            }

            eZContentObject::recursionProtectionStart();

            // Loop through all eZContentObjectAttributes and add them to the Solr document.
            // @since eZ Find 2.3: look for the attribute storage setting

            $doAttributeStorage = ( ( $this->FindINI->variable( 'IndexOptions', 'EnableSolrAttributeStorage' ) ) === 'true' ) ? true : false;

            if ( $doAttributeStorage )
            {
                $allAttributeData = array();
            }

            foreach ( $currentVersion->contentObjectAttributes( $languageCode ) as $attribute )
            {
                $metaDataText = '';
                $classAttribute = $attribute->contentClassAttribute();
                $attributeIdentifier = $classAttribute->attribute( 'identifier' );
                $combinedIdentifier = $contentClassIdentifier . '/' . $attributeIdentifier;
                $boostAttribute = false;
                if ( isset( $boostAttributes[$attributeIdentifier]) && is_numeric( $boostAttributes[$attributeIdentifier]))
                {
                    $boostAttribute = $boostAttributes[$attributeIdentifier];
                }
                if ( isset( $boostAttributes[$combinedIdentifier]) && is_numeric( $boostAttributes[$combinedIdentifier]))
                {
                    $boostAttribute += $boostAttributes[$combinedIdentifier];
                }
                if ( $classAttribute->attribute( 'is_searchable' ) == 1 )
                {
                    $documentFieldBase = ezfSolrDocumentFieldBase::getInstance( $attribute );
                    $this->addFieldBaseToDoc( $documentFieldBase, $doc, $boostAttribute );
                }

                if ( $doAttributeStorage )
                {
                    $storageFieldName = ezfSolrStorage::getSolrStorageFieldName( $attributeIdentifier );
                    $attributeData = ezfSolrStorage::getAttributeData( $attribute );
                    $allAttributeData['data_map'][$attributeIdentifier] = $attributeData;
                    $doc->addField( $storageFieldName, ezfSolrStorage::serializeData( $attributeData ) );
                }
            }
            eZContentObject::recursionProtectionEnd();

            if ( $doAttributeStorage )
            {
                $doc->addField( 'as_all_bst', ezfSolrStorage::serializeData( $allAttributeData ) );
            }

            $docList[$languageCode] = $doc;
        }

        // Since eZFind 2.7: indexhooks
        $generalPlugins = $this->FindINI->variable( 'IndexPlugins', 'General' );
        $classPlugins   = $this->FindINI->variable( 'IndexPlugins', 'Class' );
        if ( !empty( $generalPlugins ) )
        {
            foreach ( $generalPlugins as $pluginClassString )
            {
                if( !class_exists( $pluginClassString ) )
                {
                    eZDebug::writeError( "Unable to find the PHP class '$classname' defined for index time plugins for eZ Find", __METHOD__ );
                    continue;
                }
                $plugin = new $pluginClassString;
                if ( $plugin instanceof ezfIndexPlugin )
                {
                    $plugin->modify( $contentObject, $docList );
                }
            }
        }

        if (array_key_exists($contentObject->attribute( 'class_identifier' ), $classPlugins ) )
        {
            $pluginClassString = $classPlugins[$contentObject->attribute( 'class_identifier' )];
            if ( class_exists( $pluginClassString ) )
            {
                $plugin = new $pluginClassString;
                if ($plugin instanceof ezfIndexPlugin)
                {
                        $plugin->modify( $contentObject, $docList );
                }
            }
        }

        $optimize = false;
        if ( $this->FindINI->variable( 'IndexOptions', 'DisableDirectCommits' ) === 'true' )
        {
            $commit = false;
        }
        $commitWithin = 0;
        if ( $this->FindINI->variable( 'IndexOptions', 'CommitWithin' ) > 0 )
        {
            $commitWithin = $this->FindINI->variable( 'IndexOptions', 'CommitWithin' );
        }
        if ( $commit && ( $this->FindINI->variable( 'IndexOptions', 'OptimizeOnCommit' ) === 'enabled' ) )
        {
            $optimize = true;
        }

        if ( $this->UseMultiLanguageCores === true)
        {
            $result = true;
            foreach ( $availableLanguages as $languageCode )
            {
                $languageResult = $this->SolrLanguageShards[$languageCode]->addDocs( array( $docList[$languageCode] ), $commit, $optimize, $commitWithin );
                if ( !$languageResult )
                {
                    $result = false;
                }
            }
            return $result;
        }
        else
        {
            return $this->Solr->addDocs( $docList, $commit, $optimize, $commitWithin );
        }


    }
コード例 #11
0
 function user()
 {
     if (isset($this->UserID) and $this->UserID) {
         return eZUser::instance($this->UserID);
     }
     return null;
 }
コード例 #12
0
 /**
  * eZUser: do not generate cache content for invalid user
  *
  * @link http://issues.ez.no/22181
  */
 public function testNullUserCache()
 {
     eZUser::instance($this->userId);
     $cacheFilePath = eZUser::getCacheDir($this->userId) . "/user-data-{$this->userId}.cache.php";
     $this->assertFalse(file_exists($cacheFilePath));
 }
コード例 #13
0
ファイル: ezapprove2type.php プロジェクト: brucem/ezapprove2
 function execute($process, $event)
 {
     eZDebugSetting::writeDebug('kernel-workflow-approve', $process, 'eZApprove2Type::execute');
     eZDebugSetting::writeDebug('kernel-workflow-approve', $event, 'eZApprove2Type::execute');
     $parameters = $process->attribute('parameter_list');
     $versionID = $parameters['version'];
     $object = eZContentObject::fetch($parameters['object_id']);
     if (!$object) {
         eZDebugSetting::writeError('kernel-workflow-approve', $parameters['object_id'], 'eZApprove2Type::execute');
         return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
     }
     /*
       If we run event first time ( when we click publish in admin ) we do not have user_id set in workflow process,
       so we take current user and store it in workflow process, so next time when we run event from cronjob we fetch
       user_id from there.
     */
     if ($process->attribute('user_id') == 0) {
         $user = eZUser::currentUser();
         $process->setAttribute('user_id', $user->id());
     } else {
         $user = eZUser::instance($process->attribute('user_id'));
     }
     $eventData = eZApprove2Event::fetch($event->attribute('id'), $event->attribute('version'));
     $userGroups = array_merge((array) $user->attribute('groups'), (array) $user->attribute('contentobject_id'));
     $workflowSections = explode(',', $eventData->attribute('selected_sections'));
     $workflowGroups = explode(',', $eventData->attribute('selected_usergroups'));
     $editors = explode(',', $eventData->attribute('approve_users'));
     $approveGroups = explode(',', $eventData->attribute('approve_groups'));
     eZDebugSetting::writeDebug('kernel-workflow-approve', $user, 'eZApprove2Type::execute::user');
     eZDebugSetting::writeDebug('kernel-workflow-approve', $userGroups, 'eZApprove2Type::execute::userGroups');
     eZDebugSetting::writeDebug('kernel-workflow-approve', $editors, 'eZApprove2Type::execute::editor');
     eZDebugSetting::writeDebug('kernel-workflow-approve', $workflowSections, 'eZApprove2Type::execute::workflowSections');
     eZDebugSetting::writeDebug('kernel-workflow-approve', $workflowGroups, 'eZApprove2Type::execute::workflowGroups');
     eZDebugSetting::writeDebug('kernel-workflow-approve', $object->attribute('section_id'), 'eZApprove2Type::execute::section_id');
     $section = $object->attribute('section_id');
     $correctSection = false;
     if (!in_array($section, $workflowSections) && !in_array(-1, $workflowSections)) {
         $assignedNodes = $object->attribute('assigned_nodes');
         if ($assignedNodes) {
             foreach ($assignedNodes as $assignedNode) {
                 $parent = $assignedNode->attribute('parent');
                 $parentObject = $parent->object();
                 $section = $parentObject->attribute('section_id');
                 if (in_array($section, $workflowSections)) {
                     $correctSection = true;
                     break;
                 }
             }
         }
     } else {
         $correctSection = true;
     }
     switch ($eventData->attribute('approve_type')) {
         case eZApprove2Event::ApproveTypeUser:
             $inExcludeGroups = false;
             $userIsEditor = false;
             break;
         default:
         case eZApprove2Event::ApproveTypePredefined:
             $inExcludeGroups = count(array_intersect($userGroups, $workflowGroups)) != 0;
             $userIsEditor = in_array($user->id(), $editors) || count(array_intersect($userGroups, $approveGroups)) != 0;
             break;
     }
     if (!$inExcludeGroups && !$userIsEditor && $correctSection) {
         switch ($eventData->attribute('approve_type')) {
             case eZApprove2Event::ApproveTypeUser:
                 $contentObjectVersionID = $parameters['version'];
                 $contentObjectID = $parameters['object_id'];
                 $approveStatus = eZXApproveStatus::fetchByContentObjectID($contentObjectID, $contentObjectVersionID);
                 if (!$approveStatus || $approveStatus->attribute('approve_status') == eZXApproveStatus::StatusSelectApprover) {
                     if (!$approveStatus) {
                         $approveStatus = eZXApproveStatus::create($contentObjectID, $contentObjectVersionID, $process->attribute('id'), $process->attribute('event_position'));
                         $approveStatus->store();
                         $approveStatus->setCreator($user->attribute('contentobject_id'));
                     }
                     $approveStatus->setAttribute('active_version', $contentObjectVersionID);
                     $approveStatus->sync();
                     $process->Template = array();
                     $process->Template['templateName'] = 'design:workflow/eventtype/ezapprove2/select_approver.tpl';
                     $process->Template['templateVars'] = array('event' => $event, 'approval_status' => $approveStatus, 'object' => $object);
                     // Set object version to draft untill approvers are selected successfully in case user exists in the wrong way.
                     #include_once( 'kernel/classes/ezcontentobjectversion.php' );
                     $contentObjectVersion = eZContentObjectVersion::fetchVersion($contentObjectVersionID, $contentObjectID);
                     $contentObjectVersion->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
                     $contentObjectVersion->sync();
                     return eZWorkflowType::STATUS_FETCH_TEMPLATE_REPEAT;
                 } else {
                     switch ($approveStatus->attribute('approve_status')) {
                         case eZXApproveStatus::StatusSelectApprover:
                             // Do nothing, continue processing in next cronjob run.
                             return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
                             break;
                         case eZXApproveStatus::StatusInApproval:
                             // Check if enough users have approves the workflow, or any has discarded it.
                             $discardCount = $approveStatus->discardedUserCount();
                             $collaborationItem = $approveStatus->attribute('collaboration_item');
                             #include_once( eZExtension::baseDirectory() . '/ezapprove2/collaboration/ezapprove2/ezapprove2collaborationhandler.php' );
                             if ($discardCount > 0) {
                                 $approveStatus->cancel();
                                 $approveINI = eZINI::instance('ezapprove2.ini');
                                 if ($approveINI->variable('ApproveSettings', 'NodeCreationOnDraft') == 'true') {
                                     $db = eZDB::instance();
                                     $db->query('UPDATE ezcontentobject_version
                                                  SET status = ' . eZContentObjectVersion::STATUS_REJECTED . '
                                                  WHERE contentobject_id = ' . $approveStatus->attribute('contentobject_id') . '
                                                  AND version = ' . $approveStatus->attribute('active_version'));
                                     $db->query('DELETE FROM ezcontentobject_tree where contentobject_id = ' . $approveStatus->attribute('contentobject_id') . ' AND contentobject_version = ' . $approveStatus->attribute('active_version'));
                                     $db->query('DELETE FROM ezurlalias
                                                  WHERE destination_url=\'content/versionview/' . $approveStatus->attribute('contentobject_id') . '/' . $approveStatus->attribute('active_version') . '\'');
                                 }
                                 return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
                             }
                             $numRequired = $approveStatus->attribute('num_approve_required');
                             $numApproved = $approveStatus->attribute('num_approved');
                             if ($numApproved >= $numRequired) {
                                 $collaborationItem->setAttribute('data_int3', eZApprove2CollaborationHandler::STATUS_ACCEPTED);
                                 $collaborationItem->setAttribute('status', eZCollaborationItem::STATUS_INACTIVE);
                                 $timestamp = time();
                                 $collaborationItem->setAttribute('modified', $timestamp);
                                 $collaborationItem->setIsActive(false);
                                 $collaborationItem->sync();
                                 $approveStatus->setAttribute('approve_status', eZXApproveStatus::StatusApproved);
                                 $approveStatus->store();
                                 $approveINI = eZINI::instance('ezapprove2.ini');
                                 if ($approveINI->variable('ApproveSettings', 'ObjectLockOnEdit') == 'true') {
                                     // Unlock related objects
                                     $object = $approveStatus->attribute('contentobject');
                                     // #HACK#
                                     if ($object->attribute('contentclass_id') == 17) {
                                         foreach ($object->relatedContentObjectList($approveStatus->attribute('active_version'), false, false) as $relatedObject) {
                                             $relatedObject->setAttribute('flags', $relatedObject->attribute('flags') ^ EZ_CONTENT_OBJECT_FLAG_LOCK_EDIT ^ EZ_CONTENT_OBJECT_FLAG_LOCK_REMOVE);
                                             $relatedObject->sync();
                                         }
                                     }
                                 }
                                 return eZWorkflowType::STATUS_ACCEPTED;
                             } else {
                                 // Still need more approvers.
                                 return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
                             }
                             break;
                         case eZXApproveStatus::StatusDiscarded:
                             $approveINI = eZINI::instance('ezapprove2.ini');
                             if ($approveINI->variable('ApproveSettings', 'NodeCreationOnDraft') == 'true') {
                                 $db = eZDB::instance();
                                 $db->arrayQuery('DELETE FROM ezcontentobject_tree where contentobject_id = ' . $approveStatus->attribute('contentobject_id') . ' AND contentobject_version = ' . $approveStatus->attribute('active_version'));
                             }
                             return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
                             break;
                         case eZXApproveStatus::StatusApproved:
                         case eZXApproveStatus::StatusFinnished:
                             // Nothing special to do.
                             break;
                     }
                 }
                 break;
             case eZApprove2Event::ApproveTypePredefined:
                 $approveStatus = eZXApproveStatus::fetchByWorkflowProcessID($process->attribute('id'), $process->attribute('event_position'));
                 if (!$approveStatus) {
                     $contentObjectVersionID = $parameters['version'];
                     $contentObjectID = $parameters['object_id'];
                     $db = eZDB::instance();
                     $db->begin();
                     // CREATE APPROVE STATUS
                     $approveStatus = eZXApproveStatus::create($contentObjectID, $contentObjectVersionID, $process->attribute('id'), $process->attribute('event_position'));
                     $approveStatus->store();
                     $approveStatus->setCreator($user->attribute('contentobject_id'));
                     // ADD APPROVERS
                     foreach ($approveGroups as $userGroupID) {
                         $userGroupObject = eZContentObject::fetch($userGroupID);
                         if ($userGroupObject) {
                             $userGroupNode = $userGroupObject->attribute('main_node');
                             if ($userGroupNode) {
                                 foreach ($userGroupNode->subTree(array('Depth' => 1, 'DepthOperator' => 'eq', 'Limitation' => array())) as $userNode) {
                                     $approveStatus->addApproveUser($userNode->attribute('contentobject_id'));
                                 }
                             }
                         }
                     }
                     foreach ($editors as $userID) {
                         $approveStatus->addApproveUser($userID);
                     }
                     $approveStatus->setAttribute('approve_status', eZXApproveStatus::StatusInApproval);
                     $approveStatus->store();
                     $approveStatus->createCollaboration(false, $user->attribute('contentobject_id'));
                     $approveStatus->store();
                     $db->commit();
                 }
                 $discardCount = $approveStatus->discardedUserCount();
                 $collaborationItem = $approveStatus->attribute('collaboration_item');
                 #include_once( eZExtension::baseDirectory() . '/ezapprove2/collaboration/ezapprove2/ezapprove2collaborationhandler.php' );
                 if ($discardCount > 0) {
                     $approveStatus->cancel();
                     return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
                 }
                 $numApproved = $approveStatus->attribute('num_approved');
                 if ($numApproved >= 1) {
                     $collaborationItem->setAttribute('data_int3', eZApprove2CollaborationHandler::STATUS_ACCEPTED);
                     $collaborationItem->setAttribute('status', eZCollaborationItem::STATUS_INACTIVE);
                     $timestamp = time();
                     $collaborationItem->setAttribute('modified', $timestamp);
                     $collaborationItem->setIsActive(false);
                     $collaborationItem->sync();
                     $approveStatus->setAttribute('approve_status', eZXApproveStatus::StatusApproved);
                     $approveStatus->store();
                     return eZWorkflowType::STATUS_ACCEPTED;
                 } else {
                     // Still need more approvers.
                     return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
                 }
                 break;
         }
     } else {
         eZDebugSetting::writeDebug('kernel-workflow-approve', $workflowSections, "we are not going to create approval " . $object->attribute('section_id'));
         eZDebugSetting::writeDebug('kernel-workflow-approve', $userGroups, "we are not going to create approval");
         eZDebugSetting::writeDebug('kernel-workflow-approve', $workflowGroups, "we are not going to create approval");
         eZDebugSetting::writeDebug('kernel-workflow-approve', $user->id(), "we are not going to create approval ");
         return eZWorkflowType::STATUS_ACCEPTED;
     }
 }
コード例 #14
0
 protected function currentUserObject()
 {
     if (!isset(self::$currentUserObject)) {
         self::$currentUserObject = false;
         $user = eZUser::instance();
         if ($user instanceof eZUser) {
             $object = $user->attribute('contentobject');
             if ($object instanceof eZContentObject) {
                 self::$currentUserObject = $object;
             }
         }
     }
     return self::$currentUserObject;
 }
コード例 #15
0
ファイル: ezuser.php プロジェクト: netbliss/ezpublish
 static function currentUserID()
 {
     $user = eZUser::instance();
     if (!$user) {
         return 0;
     }
     return $user->attribute('contentobject_id');
 }
コード例 #16
0
ファイル: ezsurvey.php プロジェクト: heliopsis/ezsurvey
 function &fetchQuestionResultList($user = false)
 {
     if (!$this->attribute('persistent')) {
         $value = 0;
         return $value;
     }
     if (!$user) {
         $user = eZUser::instance();
     }
     if (!$user->attribute('is_logged_in')) {
         $value = 0;
         return $value;
     }
     $userID = $user->attribute('contentobject_id');
     $surveyResultDefinition = eZSurveyResult::definition();
     $result = eZPersistentObject::fetchObject($surveyResultDefinition, null, array('survey_id' => $this->ID, 'user_id' => $userID));
     if (!$result) {
         $value = 0;
         return $value;
     }
     $isPersistent = $this->Persistent == 1 ? true : false;
     return $result->fetchQuestionResultList(false, $isPersistent);
 }
コード例 #17
0
    function execute( $process, $event )
    {
        eZDebugSetting::writeDebug( 'kernel-workflow-approve', $process, 'eZApproveType::execute' );
        eZDebugSetting::writeDebug( 'kernel-workflow-approve', $event, 'eZApproveType::execute' );
        $parameters = $process->attribute( 'parameter_list' );
        $versionID = $parameters['version'];
        $objectID = $parameters['object_id'];
        $object = eZContentObject::fetch( $objectID );

        if ( !$object )
        {
            eZDebugSetting::writeError( 'kernel-workflow-approve', "No object with ID $objectID", 'eZApproveType::execute' );
            return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
        }

        $version = $object->version( $versionID );

        if ( !$version )
        {
            eZDebugSetting::writeError( 'kernel-workflow-approve', "No version $versionID for object with ID $objectID", 'eZApproveType::execute' );
            return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
        }

        // only check this in cronjob
        if( $process->attribute( 'status' ) == eZWorkflow::STATUS_DEFERRED_TO_CRON )
        {
            $nodeAssignmentList = $version->attribute( 'node_assignments' );
            if( !empty( $nodeAssignmentList ) )
            {
                foreach ( $nodeAssignmentList as $nodeAssignment )
                {
                    $parentNode = $nodeAssignment->getParentNode();
                    if( $parentNode === null )
                    {
                        eZDebugSetting::writeError( 'kernel-workflow-approve', "No parent node for object with ID $objectID version $versionID", 'eZApproveType::execute' );
                        return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
                    }
                }
            }
        }

        // version option checking
        $version_option = $event->attribute( 'version_option' );
        if ( ( $version_option == eZApproveType::VERSION_OPTION_FIRST_ONLY and $parameters['version'] > 1 ) or
             ( $version_option == eZApproveType::VERSION_OPTION_EXCEPT_FIRST and $parameters['version'] == 1 ) )
        {
            return eZWorkflowType::STATUS_ACCEPTED;
        }

        /*
          If we run event first time ( when we click publish in admin ) we do not have user_id set in workflow process,
          so we take current user and store it in workflow process, so next time when we run event from cronjob we fetch
          user_id from there.
         */
        if ( $process->attribute( 'user_id' ) == 0 )
        {
            $user = eZUser::currentUser();
            $process->setAttribute( 'user_id', $user->id() );
        }
        else
        {
            $user = eZUser::instance( $process->attribute( 'user_id' ) );
        }

        $userGroups = array_merge( $user->attribute( 'groups' ), array( $user->attribute( 'contentobject_id' ) ) );
        $workflowSections = explode( ',', $event->attribute( 'data_text1' ) );
        $workflowGroups =   $event->attribute( 'data_text2' ) == '' ? array() : explode( ',', $event->attribute( 'data_text2' ) );
        $editors =          $event->attribute( 'data_text3' ) == '' ? array() : explode( ',', $event->attribute( 'data_text3' ) );
        $approveGroups =    $event->attribute( 'data_text4' ) == '' ? array() : explode( ',', $event->attribute( 'data_text4' ) );
        $languageMask = $event->attribute( 'data_int2' );

        eZDebugSetting::writeDebug( 'kernel-workflow-approve', $user, 'eZApproveType::execute::user' );
        eZDebugSetting::writeDebug( 'kernel-workflow-approve', $userGroups, 'eZApproveType::execute::userGroups' );
        eZDebugSetting::writeDebug( 'kernel-workflow-approve', $editors, 'eZApproveType::execute::editor' );
        eZDebugSetting::writeDebug( 'kernel-workflow-approve', $approveGroups, 'eZApproveType::execute::approveGroups' );
        eZDebugSetting::writeDebug( 'kernel-workflow-approve', $workflowSections, 'eZApproveType::execute::workflowSections' );
        eZDebugSetting::writeDebug( 'kernel-workflow-approve', $workflowGroups, 'eZApproveType::execute::workflowGroups' );
        eZDebugSetting::writeDebug( 'kernel-workflow-approve', $languageMask, 'eZApproveType::execute::languageMask' );
        eZDebugSetting::writeDebug( 'kernel-workflow-approve', $object->attribute( 'section_id'), 'eZApproveType::execute::section_id' );

        $section = $object->attribute( 'section_id' );
        $correctSection = false;

        if ( !in_array( $section, $workflowSections ) && !in_array( -1, $workflowSections ) )
        {
            $assignedNodes = $object->attribute( 'assigned_nodes' );
            if ( $assignedNodes )
            {
                foreach( $assignedNodes as $assignedNode )
                {
                    $parent = $assignedNode->attribute( 'parent' );
                    $parentObject = $parent->object();
                    $section = $parentObject->attribute( 'section_id');

                    if ( in_array( $section, $workflowSections ) )
                    {
                        $correctSection = true;
                        break;
                    }
                }
            }
        }
        else
            $correctSection = true;

        $inExcludeGroups = count( array_intersect( $userGroups, $workflowGroups ) ) != 0;

        $userIsEditor = ( in_array( $user->id(), $editors ) ||
                          count( array_intersect( $userGroups, $approveGroups ) ) != 0 );

        // All languages match by default
        $hasLanguageMatch = true;
        if ( $languageMask != 0 )
        {
            // Examine if the published version contains one of the languages we
            // match for.
            // If the language ID is part of the mask the result is non-zero.
            $languageID = (int)$version->attribute( 'initial_language_id' );
            $hasLanguageMatch = (bool)( $languageMask & $languageID );
        }

        if ( $hasLanguageMatch and
             !$userIsEditor and
             !$inExcludeGroups and
             $correctSection )
        {

            /* Get user IDs from approve user groups */
            $userClassIDArray = eZUser::contentClassIDs();
            $approveUserIDArray = array();
            foreach ( $approveGroups as $approveUserGroupID )
            {
                if (  $approveUserGroupID != false )
                {
                    $approveUserGroup = eZContentObject::fetch( $approveUserGroupID );
                    if ( isset( $approveUserGroup ) )
                    {
                        foreach ( $approveUserGroup->attribute( 'assigned_nodes' ) as $assignedNode )
                        {
                            $userNodeArray = $assignedNode->subTree( array( 'ClassFilterType' => 'include',
                                                                            'ClassFilterArray' => $userClassIDArray,
                                                                            'Limitation' => array() ) );
                            foreach ( $userNodeArray as $userNode )
                            {
                                $approveUserIDArray[] = $userNode->attribute( 'contentobject_id' );
                            }
                        }
                    }
                }
            }
            $approveUserIDArray = array_merge( $approveUserIDArray, $editors );
            $approveUserIDArray = array_unique( $approveUserIDArray );

            $collaborationID = false;
            $db = eZDb::instance();
            $taskResult = $db->arrayQuery( 'select workflow_process_id, collaboration_id from ezapprove_items where workflow_process_id = ' . $process->attribute( 'id' )  );
            if ( count( $taskResult ) > 0 )
                $collaborationID = $taskResult[0]['collaboration_id'];

            eZDebugSetting::writeDebug( 'kernel-workflow-approve', $collaborationID, 'approve collaborationID' );
            eZDebugSetting::writeDebug( 'kernel-workflow-approve', $process->attribute( 'event_state'), 'approve $process->attribute( \'event_state\')' );
            if ( $collaborationID === false )
            {
                $this->createApproveCollaboration( $process, $event, $user->id(), $object->attribute( 'id' ), $versionID, $approveUserIDArray );
                $this->setInformation( "We are going to create approval" );
                $process->setAttribute( 'event_state', eZApproveType::COLLABORATION_CREATED );
                $process->store();
                eZDebugSetting::writeDebug( 'kernel-workflow-approve', $this, 'approve execute' );
                return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
            }
            else if ( $process->attribute( 'event_state') == eZApproveType::COLLABORATION_NOT_CREATED )
            {
                eZApproveCollaborationHandler::activateApproval( $collaborationID );
                $process->setAttribute( 'event_state', eZApproveType::COLLABORATION_CREATED );
                $process->store();
                eZDebugSetting::writeDebug( 'kernel-workflow-approve', $this, 'approve re-execute' );
                return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
            }
            else //eZApproveType::COLLABORATION_CREATED
            {
                $this->setInformation( "we are checking approval now" );
                eZDebugSetting::writeDebug( 'kernel-workflow-approve', $event, 'check approval' );
                return $this->checkApproveCollaboration(  $process, $event );
            }
        }
        else
        {
            eZDebugSetting::writeDebug( 'kernel-workflow-approve', $workflowSections , "we are not going to create approval " . $object->attribute( 'section_id') );
            eZDebugSetting::writeDebug( 'kernel-workflow-approve', $userGroups, "we are not going to create approval" );
            eZDebugSetting::writeDebug( 'kernel-workflow-approve', $workflowGroups,  "we are not going to create approval" );
            eZDebugSetting::writeDebug( 'kernel-workflow-approve', $user->id(), "we are not going to create approval "  );
            return eZWorkflowType::STATUS_ACCEPTED;
        }
    }
コード例 #18
0
 function execute($process, $event)
 {
     eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $process, 'approveLocationType::execute');
     eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $event, 'approveLocationType::execute');
     $parameters = $process->attribute('parameter_list');
     $userID = $parameters['user_id'];
     $objectID = $parameters['object_id'];
     $object = eZContentObject::fetch($objectID);
     if (!$object) {
         eZDebugSetting::writeError('ezworkflowcollection-workflow-approve-location', "No object with ID {$objectID}", 'approveLocationType::execute');
         return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
     }
     $version = $object->currentversion();
     if (!$version) {
         eZDebugSetting::writeError('ezworkflowcollection-workflow-approve-location', "No version for object with ID {$objectID}", 'approveLocationType::execute');
         return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
     } else {
         $versionID = $version->attribute('version');
     }
     // version option checking
     $version_option = $event->attribute('version_option');
     if ($version_option == self::VERSION_OPTION_FIRST_ONLY and $versionID > 1 or $version_option == self::VERSION_OPTION_EXCEPT_FIRST and $versionID == 1) {
         return eZWorkflowType::STATUS_ACCEPTED;
     }
     // Target nodes
     $targetNodeIDs = $parameters['select_node_id_array'];
     if (!is_array($targetNodeIDs) || count($targetNodeIDs) == 0) {
         return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
     }
     /*
      Check userID or get user_id from process object
     */
     if ($userID == 0) {
         $user = eZUser::currentUser();
         $process->setAttribute('user_id', $user->id());
     } else {
         $user = eZUser::instance($userID);
     }
     $userGroups = array_merge($user->attribute('groups'), array($user->attribute('contentobject_id')));
     $workflowSections = explode(',', $event->attribute('data_text1'));
     $workflowGroups = $event->attribute('data_text2') == '' ? array() : explode(',', $event->attribute('data_text2'));
     $editors = $event->attribute('data_text3') == '' ? array() : explode(',', $event->attribute('data_text3'));
     $approveGroups = $event->attribute('data_text4') == '' ? array() : explode(',', $event->attribute('data_text4'));
     $languageMask = $event->attribute('data_int2');
     eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $user, 'approveLocationType::execute::user');
     eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $userGroups, 'approveLocationType::execute::userGroups');
     eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $editors, 'approveLocationType::execute::editor');
     eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $approveGroups, 'approveLocationType::execute::approveGroups');
     eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $workflowSections, 'approveLocationType::execute::workflowSections');
     eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $workflowGroups, 'approveLocationType::execute::workflowGroups');
     eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $languageMask, 'approveLocationType::execute::languageMask');
     eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $object->attribute('section_id'), 'approveLocationType::execute::section_id');
     $section = $object->attribute('section_id');
     $correctSection = false;
     if (!in_array($section, $workflowSections) && !in_array(-1, $workflowSections)) {
         $assignedNodes = $object->attribute('assigned_nodes');
         if ($assignedNodes) {
             foreach ($assignedNodes as $assignedNode) {
                 $parent = $assignedNode->attribute('parent');
                 $parentObject = $parent->object();
                 $section = $parentObject->attribute('section_id');
                 if (in_array($section, $workflowSections)) {
                     $correctSection = true;
                     break;
                 }
             }
         }
     } else {
         $correctSection = true;
     }
     $inExcludeGroups = count(array_intersect($userGroups, $workflowGroups)) != 0;
     $userIsEditor = in_array($user->id(), $editors) || count(array_intersect($userGroups, $approveGroups)) != 0;
     // All languages match by default
     $hasLanguageMatch = true;
     if ($languageMask != 0) {
         // Examine if the published version contains one of the languages we
         // match for.
         // If the language ID is part of the mask the result is non-zero.
         $languageID = (int) $version->attribute('initial_language_id');
         $hasLanguageMatch = (bool) ($languageMask & $languageID);
     }
     if ($hasLanguageMatch and !$userIsEditor and !$inExcludeGroups and $correctSection) {
         /* Get user IDs from approve user groups */
         $userClassIDArray = eZUser::contentClassIDs();
         $approveUserIDArray = array();
         foreach ($approveGroups as $approveUserGroupID) {
             if ($approveUserGroupID != false) {
                 $approveUserGroup = eZContentObject::fetch($approveUserGroupID);
                 if (isset($approveUserGroup)) {
                     foreach ($approveUserGroup->attribute('assigned_nodes') as $assignedNode) {
                         $userNodeArray = $assignedNode->subTree(array('ClassFilterType' => 'include', 'ClassFilterArray' => $userClassIDArray, 'Limitation' => array()));
                         foreach ($userNodeArray as $userNode) {
                             $approveUserIDArray[] = $userNode->attribute('contentobject_id');
                         }
                     }
                 }
             }
         }
         $approveUserIDArray = array_merge($approveUserIDArray, $editors);
         $approveUserIDArray = array_unique($approveUserIDArray);
         $db = eZDb::instance();
         $taskResult = $db->arrayQuery('select workflow_process_id, collaboration_id from ezxapprovelocation_items where workflow_process_id = ' . $process->attribute('id'));
         eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $process->attribute('event_state'), 'approve $process->attribute( \'event_state\')');
         if (count($taskResult) > 0 && $taskResult[0]['collaboration_id'] !== false) {
             $collaborationID = $taskResult[0]['collaboration_id'];
             $status = eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
             if ($process->attribute('event_state') == self::COLLABORATION_NOT_CREATED) {
                 approveLocationCollaborationHandler::activateApproval($collaborationID);
                 $this->setInformation("We are going to create again approval");
                 $process->setAttribute('event_state', self::COLLABORATION_CREATED);
                 $process->store();
                 eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $this, 'approve re-execute');
                 $status = eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
             } else {
                 $this->setInformation("we are checking approval now");
                 eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $event, 'check approval');
                 $status = $this->checkApproveCollaboration($process, $event, $collaborationID);
             }
             return $status;
         } else {
             eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $targetNodeIDs, 'NodeIDs to approve');
             $this->createApproveCollaboration($process, $event, $userID, $object->attribute('id'), $versionID, $approveUserIDArray);
             $this->setInformation("We are going to create approval");
             $process->setAttribute('event_state', self::COLLABORATION_CREATED);
             $process->store();
             eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $this, 'approve execute');
             return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
         }
     } else {
         eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $workflowSections, "we are not going to create approval " . $object->attribute('section_id'));
         eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $userGroups, "we are not going to create approval");
         eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $workflowGroups, "we are not going to create approval");
         eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $user->id(), "we are not going to create approval ");
         eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $targetNodeIDs, 'NodeIDs approved');
         return eZWorkflowType::STATUS_ACCEPTED;
     }
 }