@param string $localeID
@param string $notes
@param bool $approve

@return LocaleEntity
975492
private function createLocale($localeID, $notes, $approve)
    {
        $locale = LocaleEntity::create($localeID)
            ->setRequestedBy($this->getAccess()->getUserEntity('current'))
            ->setRequestedOn(new DateTime())
            ->setIsApproved($approve)
        ;
        $em = $this->app->make(EntityManager::class);
        $em->persist($locale);
        $em->flush($locale);
        if (!$approve) {
            $this->app->make(NotificationRepository::class)->newLocaleRequested($locale, $notes);
        }

        return $locale;
    }
977930
public function choose($number, array $variants, $locale = null) {
		if ($locale === null) {
			$locale = $this->getLocale();
		} else {
			$locale = $this->normalizeLocale($locale);
		}
		
		if (! isset(self::$rulesMap[$locale])) {
			$position = 0;
		} else {
			$rule     = self::$rulesMap[$locale];
			$position = $this->$rule((int) $number);
		}
		
		if (! isset($variants[$position])) {
			throw new InvalidOptions('There is no variant by position: "' . $position . '"');
		}
		
		return $variants[$position];
	}
1150564
public function addLog ( $keys, $received, $sent, $base_string, $notes, $user_id = null )
	{
		$args = array();
		$ps   = array();
		foreach ($keys as $key => $value)
		{
			$args[] = $value;
			$ps[]   = "olg_$key = '%s'";
		}

		if (!empty($_SERVER['REMOTE_ADDR']))
		{
			$remote_ip = $_SERVER['REMOTE_ADDR'];
		}	
		else if (!empty($_SERVER['REMOTE_IP']))
		{
			$remote_ip = $_SERVER['REMOTE_IP'];
		}
		else
		{
			$remote_ip = '0.0.0.0';
		}

		// Build the SQL
		$olg_received = $this->makeUTF8($received);
		$olg_sent = $this->makeUTF8($sent);
		$olg_base_string = $base_string;
		$olg_notes = $this->makeUTF8($notes);
		$olg_usa_id_ref = $user_id;
		$olg_remote_ip = $remote_ip;

		 

		$sql = "BEGIN SP_ADD_LOG(:P_RECEIVED, :P_SENT, :P_BASE_STRING, :P_NOTES, :P_USA_ID_REF, :P_REMOTE_IP, :P_RESULT); END;";

			// parse sql
		$stmt = oci_parse($this->conn, $sql) or die ('Can not parse query');

		// Bind In and Out Variables
		oci_bind_by_name($stmt, ':P_RECEIVED', $olg_received, 255);
		oci_bind_by_name($stmt, ':P_SENT', $olg_sent, 255);
		oci_bind_by_name($stmt, ':P_BASE_STRING', $olg_base_string, 255);
		oci_bind_by_name($stmt, ':P_NOTES', $olg_notes, 255);
		oci_bind_by_name($stmt, ':P_USA_ID_REF', $olg_usa_id_ref, 255);
		oci_bind_by_name($stmt, ':P_REMOTE_IP', $olg_remote_ip, 255);
		oci_bind_by_name($stmt, ':P_RESULT', $result, 20);


		//Execute the statement
		oci_execute($stmt);
	}
1028052
function _doVoid($oID, $note = '') {
    global $db, $messageStack;

    $new_order_status = (int)MODULE_PAYMENT_AUTHORIZENET_ECHECK_REFUNDED_ORDER_STATUS_ID;
    if ($new_order_status == 0) $new_order_status = 1;
    $voidNote = strip_tags(zen_db_input($_POST['voidnote'] . $note));
    $voidAuthID = trim(strip_tags(zen_db_input($_POST['voidauthid'])));
    $proceedToVoid = true;
    if (isset($_POST['ordervoid']) && $_POST['ordervoid'] == MODULE_PAYMENT_AUTHORIZENET_ECHECK_ENTRY_VOID_BUTTON_TEXT) {
      if (isset($_POST['voidconfirm']) && $_POST['voidconfirm'] != 'on') {
        $messageStack->add_session(MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_VOID_CONFIRM_ERROR, 'error');
        $proceedToVoid = false;
      }
    }
    if ($voidAuthID == '') {
      $messageStack->add_session(MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_TRANS_ID_REQUIRED_ERROR, 'error');
      $proceedToVoid = false;
    }
    // Populate an array that contains all of the data to be sent to gateway
    $submit_data = array('x_type' => 'VOID',
                         'x_trans_id' => trim($voidAuthID) );
    /**
     * Submit void request to Gateway
     */
    if ($proceedToVoid) {
      $response = $this->_sendRequest($submit_data);
      $response_code = $response[0];
      $response_text = $response[3];
      $response_alert = $response_text . ($this->commError == '' ? '' : ' Communications Error - Please notify webmaster.');
      $this->reportable_submit_data['Note'] = $voidNote;
      $this->_debugActions($response);

      if ($response_code != '1' || ($response[0]==1 && $response[2] == 310) ) {
        $messageStack->add_session($response_alert, 'error');
      } else {
        // Success, so save the results
        $sql_data_array = array('orders_id' => (int)$oID,
                                'orders_status_id' => (int)$new_order_status,
                                'date_added' => 'now()',
                                'comments' => 'VOIDED. Trans ID: ' . $response[6] . ' ' . $response[4] . "\n" . $voidNote,
                                'customer_notified' => 0
                             );
        zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
        $db->Execute("update " . TABLE_ORDERS  . "
                      set orders_status = '" . (int)$new_order_status . "'
                      where orders_id = '" . (int)$oID . "'");
        $messageStack->add_session(sprintf(MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_VOID_INITIATED, $response[6], $response[4]), 'success');
        return true;
      }
    }
    return false;
  }
937764
private function installTranslations($localeID, Package $package = null)
    {
        if ($package === null) {
            $localStats = $this->localFactory->getCoreStats($localeID);
            $shownDirectoryName = '/' . DIRNAME_APPLICATION . '/' . DIRNAME_LANGUAGES;
        } else {
            $localStats = $this->localFactory->getPackageStats($package, $localeID);
            $shownDirectoryName = '/' . DIRNAME_PACKAGES . '/' . $package->getPackageHandle() . '/' . DIRNAME_LANGUAGES;
        }
        $directory = dirname($localStats->getFilename());
        if (!$this->fs->isDirectory($directory)) {
            if ($this->fs->makeDirectory($directory, DIRECTORY_PERMISSIONS_MODE_COMPUTED, true, true) !== true) {
                throw new Exception(t('Failed to create the directory for the language file. Please be sure that the %s directory is writable', $shownDirectoryName));
            }
        }
        if (!$this->fs->isWritable($directory)) {
            throw new Exception(t('Please be sure that the %s directory is writable', $shownDirectoryName));
        }
        if ($package === null) {
            $coreVersion = $this->config->get('concrete.version_installed');
            $translations = $this->remoteProvider->fetchCoreTranslations($coreVersion, $localeID);
        } else {
            $translations = $this->remoteProvider->fetchPackageTranslations($package->getPackageHandle(), $package->getPackageVersion(), $localeID);
        }
        $saved = @$this->fs->put($localStats->getFilename(), $translations, true) !== false;
        unset($translations);
        if ($saved === false) {
            throw new Exception(t('Failed to save the language file: please be sure that PHP can write files in the directory %s', $shownDirectoryName));
        }
    }
1105602
protected function getTargetDocumentDestination(
        $uuid,
        $localeSource,
        $localeDestination
    ) {
        /** @var BasePageDocument $targetDocumentSource */
        $targetDocumentSource = $this->documentManager->find($uuid, $localeSource);

        if ($this->webspaceKeySource !== $targetDocumentSource->getWebspaceName()) {
            return null;
        }

        $newPathTarget = str_replace(
            $this->sessionManager->getContentPath($this->webspaceKeySource),
            $this->sessionManager->getContentPath($this->webspaceKeyDestination),
            $targetDocumentSource->getPath()
        );

        $targetDocument = null;

        try {
            $targetDocument = $this->documentManager->find($newPathTarget, $localeDestination);
        } catch (DocumentNotFoundException $e) {
            return null;
        }

        return $targetDocument;
    }
657572
protected function getLabels($dictionaryName, $localeId)
    {
        if (!isset($this->dictionaries[$dictionaryName])) {
            return [];
        }
        $dictionary = $this->dictionaries[$dictionaryName];

        try {
            $dictionary = $this->configToArray($dictionary);
        } catch (\InvalidArgumentException $e) {
            $this->log(
                ILogger::LOG_WARNING,
                'Configuration for dictionary "{dictionary}" is incorrect.',
                ['dictionary' => $dictionaryName]
            );

            return [];
        }

        if (!isset($dictionary[$localeId])) {
            $this->log(
                ILogger::LOG_WARNING,
                'Configuration for locale "{locale}" in dictionary "{dictionary}" was not found.',
                ['locale' => $localeId, 'dictionary' => $dictionaryName]
            );

            return [];
        }

        $localeDictionary = $dictionary[$localeId];

        try {
            $localeDictionary = $this->configToArray($localeDictionary);
        } catch (\InvalidArgumentException $e) {
            $this->log(
                ILogger::LOG_WARNING,
                'Configuration for locale "{locale}" in dictionary "{dictionary}" is incorrect.',
                ['locale' => $localeId, 'dictionary' => $dictionaryName]
            );

            return [];
        }

        return $localeDictionary;
    }
512118
static function checkApproval( $approvalID )
    {
        $collaborationItem = eZCollaborationItem::fetch( $approvalID );
        if ( $collaborationItem !== null )
        {
            return $collaborationItem->attribute( 'data_int3' );
        }
        return false;
    }
156417
public function getPageSuggestions($pageID, $limit = 0, $approved = true) {

		// Make sure the current user has appropriate permission.

		$pageID = (int)$pageID;
		if(($page = ExtensibleSearchPage::get_by_id(ExtensibleSearchPage::class, $pageID)) && $page->canView()) {

			// Retrieve the search suggestions.

			$suggestions = ExtensibleSearchSuggestion::get()->filter(array(
				'Approved' => (int)$approved,
				'ExtensibleSearchPageID' => $pageID
			))->sort('Frequency', 'DESC');
			if($limit) {
				$suggestions = $suggestions->limit($limit);
			}

			// Make sure the search suggestions are unique.

			return $suggestions->column('Term');
		}
		return array();
	}
12592
public function saveAnnotation($idNote, $note = '', $starred = '', array $optional = [])
    {
        return $this->_request('Annotations.save', [
            'idNote' => $idNote,
            'note' => $note,
            'starred' => $starred,
        ], $optional);
    }
516287
public function getPackageStats(Package $package, $localeID)
    {
        return $this->getMoFileStats($package->getPackagePath() . '/' . DIRNAME_LANGUAGES . '/' . $localeID . '/LC_MESSAGES/messages.mo');
    }
26140
@View(name = "by_when_action_was_performed", map = "function(doc) { if(doc.whenActionWasPerformed) { emit(doc.whenActionWasPerformed, doc) } }")
    public List<CouchDbAuditActionContext> findAuditRecordsSince(final LocalDate localDate) {
        return db.queryView(createQuery("by_when_action_was_performed").startKey(localDate).includeDocs(true), CouchDbAuditActionContext.class);
    }
995233
function _doVoid($oID, $note = '') {
    global $db, $messageStack;

    $new_order_status = (int)MODULE_PAYMENT_AUTHORIZENET_AIM_REFUNDED_ORDER_STATUS_ID;
    if ($new_order_status == 0) $new_order_status = 1;
    $voidNote = strip_tags(zen_db_input($_POST['voidnote'] . $note));
    $voidAuthID = trim(strip_tags(zen_db_input($_POST['voidauthid'])));
    $proceedToVoid = true;
    if (isset($_POST['ordervoid']) && $_POST['ordervoid'] == MODULE_PAYMENT_AUTHORIZENET_AIM_ENTRY_VOID_BUTTON_TEXT) {
      if (isset($_POST['voidconfirm']) && $_POST['voidconfirm'] != 'on') {
        $messageStack->add_session(MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_VOID_CONFIRM_ERROR, 'error');
        $proceedToVoid = false;
      }
    }
    if ($voidAuthID == '') {
      $messageStack->add_session(MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_TRANS_ID_REQUIRED_ERROR, 'error');
      $proceedToVoid = false;
    }
    // Populate an array that contains all of the data to be sent to gateway
    $submit_data = array('x_type' => 'VOID',
                         'x_trans_id' => trim($voidAuthID) );
    /**
     * Submit void request to Gateway
     */
    if ($proceedToVoid) {
      $response = $this->_sendRequest($submit_data);
      $response_code = $response[0];
      $response_text = $response[3];
      $response_alert = $response_text . ($this->commError == '' ? '' : ' Communications Error - Please notify webmaster.');
      $this->reportable_submit_data['Note'] = $voidNote;
      $this->_debugActions($response);

      if ($response_code != '1' || ($response[0]==1 && $response[2] == 310) ) {
        $messageStack->add_session($response_alert, 'error');
      } else {
        // Success, so save the results
        $sql_data_array = array('orders_id' => (int)$oID,
                                'orders_status_id' => (int)$new_order_status,
                                'date_added' => 'now()',
                                'comments' => 'VOIDED. Trans ID: ' . $response[6] . ' ' . $response[4] . "\n" . $voidNote,
                                'customer_notified' => 0
                             );
        zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
        $db->Execute("update " . TABLE_ORDERS  . "
                      set orders_status = '" . (int)$new_order_status . "'
                      where orders_id = '" . (int)$oID . "'");
        $messageStack->add_session(sprintf(MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_VOID_INITIATED, $response[6], $response[4]), 'success');
        return true;
      }
    }
    return false;
  }
422388
public function setNote($note)
    {
        global $CFG;
        $PDOX = $this->launch->pdox;

        $stmt = $PDOX->queryDie(
            "UPDATE {$CFG->dbprefix}lti_result SET note = :note, updated_at = NOW()
                WHERE result_id = :RID",
            array(
                ':note' => $note,
                ':RID' => $this->id)
        );
    }
312218
public function findByIdAndLocale($id, $locale, $updateApiEntity = true)
    {
        $order = $this->orderRepository->findByIdAndLocale($id, $locale);

        if (!$order) {
            return null;
        }

        $order = $this->orderFactory->createApiEntity($order, $locale);

        if ($updateApiEntity) {
            $this->updateApiEntity($order, $locale);
        }

        return $order;
    }
1033885
static function activateApproval( $approvalID )
    {
        $collaborationItem = eZCollaborationItem::fetch( $approvalID );
        if ( $collaborationItem !== null )
        {
            $collaborationItem->setAttribute( 'data_int3', self::STATUS_WAITING );
            $collaborationItem->setAttribute( 'status', eZCollaborationItem::STATUS_ACTIVE );
            $timestamp = time();
            $collaborationItem->setAttribute( 'modified', $timestamp );
            $collaborationItem->store();
            $participantList = eZCollaborationItemParticipantLink::fetchParticipantList( array( 'item_id' => $approvalID ) );
            foreach( $participantList as $participantLink )
            {
                $collaborationItem->setIsActive( true, $participantLink->attribute( 'participant_id' ) );
            }
            return true;
        }
        return false;
    }
341533
public function getUnreviewedSelectQuery(LocaleEntity $locale)
    {
        $cn = $this->app->make(EntityManager::class)->getConnection();
        $queryLocaleID = $cn->quote($locale->getID());

        return $cn->executeQuery(
            $this->getBaseSelectString($locale, false, false) .
            " inner join
                (
                    select distinct
                        translatable
                    from
                        CommunityTranslationTranslations
                    where
                        locale = $queryLocaleID
                        and
                        (
                            (approved is null)
                            or
                            (current = 1 and approved = 0)
                        )
                ) as tNR on CommunityTranslationTranslatables.id = tNR.translatable
            order by
                CommunityTranslationTranslatables.text
            "
        );
    }