Kopiuje plik z jednego obiektu na inny
@param string $srcObject obiekt źródłowy
@param int $srcId id źródła
@param string $destObject obiekt docelowy
@param int $destId docelowy id
@return int ilość skopiowanych
483931
public static function copy($srcObject, $srcId, $destObject, $destId)
    {
        $i = 0;
        //kopiowanie plików
        foreach (CmsFileQuery::byObject($srcObject, $srcId)->find() as $file) {
            try {
                //tworzenie kopii
                $copy = new \Mmi\Http\RequestFile([
                    'name' => $file->original,
                    'tmp_name' => $file->getRealPath(),
                    'size' => $file->size
                ]);
            } catch (\Mmi\App\KernelException $e) {
                \Mmi\App\FrontController::getInstance()->getLogger()->warning('Unable to copy file, file not found: ' . $file->getRealPath());
                continue;
            }
            $newFile = clone $file;
            $newFile->id = null;
            //dołączanie pliku
            self::_copyFile($copy, $destObject, $destId, $newFile);
            $i++;
        }
        return $i;
    }
497808
protected function getPageTitles($SHDObject)
    {
        $titles = array();
        foreach($SHDObject->find('.compTitle h3.title') as $object) {
            // extract and clean anchors innertext
            $titleText = $object->innertext;
            $titles[]  = $this->cleanText($titleText);
        }
        // fetch only organic results
        return $this->normalizeResult($titles);
    }
85880
public static function getRows($object, $objectId, $year = null, $month = null, $day = null, $hour = null)
    {
        //nowa quera filtrująca po obiekcie i ID
        $q = (new Orm\CmsStatDateQuery)
                ->whereObject()->equals($object)
                ->andFieldObjectId()->equals($objectId);
        //wiązanie roku
        self::_bindParam($q, 'year', $year);
        //wiązanie miesiąca
        self::_bindParam($q, 'month', $month);
        //wiązanie dnia
        self::_bindParam($q, 'day', $day);
        //wiązanie godziny
        self::_bindParam($q, 'hour', $hour);

        //sortowanie i zwrot
        return $q->orderAsc('day')
                ->orderAsc('month')
                ->orderAsc('year')
                ->orderAsc('hour')
                ->find();
    }
428873
public function delete_object_from_relationships( $id, $object, $name = null ) {

		/**
		 * @var $pods_init \PodsInit
		 */
		global $pods_init;

		$pod = false;

		// Run any bidirectional delete operations
		if ( is_array( $object ) ) {
			$pod = $object;
		} elseif ( is_object( $pods_init ) ) {
			$pod = PodsInit::$meta->get_object( $object, $name );
		}

		if ( ! empty( $pod ) ) {
			$object = $pod['type'];
			$name   = $pod['name'];

			foreach ( $pod['fields'] as $field ) {
				PodsForm::delete( $field['type'], $id, $field['name'], array_merge( $field, $field['options'] ), $pod );
			}
		}

		// Lookup related fields (non-bidirectional)
		$params = array(
			'where' => array(
				array(
					'key'   => 'type',
					'value' => 'pick'
				),
				array(
					'key'   => 'pick_object',
					'value' => $object
				)
			)
		);

		if ( ! empty( $name ) && $name !== $object ) {
			$params['where'][] = array(
				'key'   => 'pick_val',
				'value' => $name
			);
		}

		$fields = $this->load_fields( $params, false );

		if ( ! empty( $pod ) && 'media' === $pod['type'] ) {
			$params['where'] = array(
				array(
					'key'   => 'type',
					'value' => 'file'
				)
			);

			$fields = array_merge( $fields, $this->load_fields( $params, false ) );
		}

		if ( is_array( $fields ) && ! empty( $fields ) ) {
			foreach ( $fields as $related_field ) {
				$related_pod = $this->load_pod( array( 'id' => $related_field['pod_id'], 'fields' => false ), false );

				if ( empty( $related_pod ) ) {
					continue;
				}

				$related_from = $this->lookup_related_items_from( $related_field['id'], $related_pod['id'], $id, $related_field, $related_pod );

				$this->delete_relationships( $related_from, $id, $related_pod, $related_field );
			}
		}

		if ( ! empty( $pod ) && ! pods_tableless() ) {
			pods_query( "
				DELETE FROM `@wp_podsrel`
				WHERE
				(
					`pod_id` = %d
					AND `item_id` = %d
				)
				OR (
					`related_pod_id` = %d
					AND `related_item_id` = %d
				)
			", array(
				$pod['id'],
				$id,

				$pod['id'],
				$id
			) );
		}

		return true;
	}
430827
public static function stickyByObject($object = null, $objectId = null, $class = null)
    {
        //zapytanie po obiekcie
        $q = self::byObject($object, $objectId)
                ->whereSticky()->equals(1);
        //dodawanie klasy jeśli wyspecyfikowana
        if (null !== $class) {
            $q->andFieldClass()->equals($class);
        }
        return $q;
    }
1063670
protected function GetExportRowFromDataObject(&$oDataObjct)
    {
        $aRow = parent::GetExportRowFromDataObject($oDataObjct);

        $oOrder = &$oDataObjct->GetFieldShopOrder();

        $aRow['ordernumber'] = $oOrder->fieldOrdernumber;
        $aRow['customer_number'] = $oOrder->fieldCustomerNumber;
        $aRow['orderdate'] = $oOrder->fieldDatecreated;
        $aRow['affiliate_code'] = $oOrder->fieldAffiliateCode;

        $oLocale = &TCMSLocal::GetActive();
        $aRow['price'] = $oLocale->FormatNumber($aRow['price'], 2);
        $aRow['price_reference'] = $oLocale->FormatNumber($aRow['price_reference'], 2);
        $aRow['vat_percent'] = $oLocale->FormatNumber($aRow['vat_percent'], 2);

        $aRow['order_price_total'] = $oLocale->FormatNumber($aRow['order_price_total'], 2);
        $aRow['order_price_after_discounts'] = $oLocale->FormatNumber($aRow['order_price_after_discounts'], 2);
        $aRow['order_total_weight'] = $oLocale->FormatNumber($aRow['order_total_weight'], 2);
        $aRow['order_total_volume'] = $oLocale->FormatNumber($aRow['order_total_volume'], 2);
        $aRow['order_price'] = $oLocale->FormatNumber($aRow['order_price'], 2);
        $aRow['order_amount'] = $oLocale->FormatNumber($aRow['order_amount'], 2);

        return $aRow;
    }
27379
public function updateFromObject(stdClass $object)
    {
        $this->customHeaders = property_exists($object, 'customHeaders') ? $object->customHeaders : null;

        $this->sender = null;

        if (property_exists($object, 'sender')) {
            $sender = new Contact();
            $sender->updateFromObject($object->sender);

            $this->sender = $sender;
        }

        $this->from    = ContactCollection::createFromObjects(property_exists($object, 'from') ? $object->from : null);
        $this->replyTo = ContactCollection::createFromObjects(property_exists($object, 'replyTo') ? $object->from : null);
        $this->to      = ContactCollection::createFromObjects(property_exists($object, 'to') ? $object->to : null);
        $this->cc      = ContactCollection::createFromObjects(property_exists($object, 'cc') ? $object->cc : null);
        $this->bcc     = ContactCollection::createFromObjects(property_exists($object, 'bcc') ? $object->bcc : null);

        $this->date      = property_exists($object, 'date') ? new DateTime($object->date) : null;
        $this->subject   = property_exists($object, 'subject') ? $object->subject : null;
        $this->inReplyTo = property_exists($object, 'inReplyTo') ? $object->inReplyTo : null;

        $this->bodyParts = EmailBodyPartCollection::createFromObjects(property_exists($object, 'bodyParts') ? $object->bodyParts : null);
    }
336242
public function renderCell(\Mmi\Orm\RecordRo $record)
    {
        //dekodowanie json
        if (null === $jsonData = json_decode($this->getValueFromRecord($record), true)) {
            return;
        }
        //zwrot html pola
        return '<pre>' . $this->_renderRecursive($jsonData) . '</pre>';
    }
31878
public function odpocetZalohy($invoice, $odpocet = [])
    {
        if (!isset($odpocet['castkaMen'])) {
            $odpocet['castkaMen'] = $invoice->getDataValue('sumCelkem');
        }
        $odpocet['doklad'] = $invoice;

        $this->setDataValue('odpocty-zaloh', ['odpocet' => $odpocet]);
        $this->insertToFlexiBee();
        return $this->lastResponseCode == 201;
    }
599788
public function bindToObject(ITypedObject $object, array $processedInput)
    {
        $applicableInput = array_intersect_key($processedInput, $this->form->getFields());
        $this->form->getBinding()->bindProcessedTo($object, $applicableInput);
    }
1020120
static function fetchDependentProductsCount( $vatID )
    {
        $vatID = (int) $vatID; // prevent SQL injection

        // We need DISTINCT here since there might be several object translations.
        $query = "SELECT COUNT(DISTINCT coa.contentobject_id) AS count " .
                 "FROM ezcontentobject_attribute coa, ezcontentobject co " .
                 "WHERE " .
                 "coa.contentobject_id=co.id AND " .
                 "coa.version=co.current_version AND " .
                 "data_type_string IN ('ezprice', 'ezmultiprice') " .
                 "AND data_text LIKE '$vatID,%'";

        $db = eZDB::instance();
        $rslt = $db->arrayQuery( $query );
        $nProducts = $rslt[0]['count'];
        return $nProducts;
    }
119486
public static function monthly($object, $objectId, $year)
    {
        $statArray = [];
        //pobieranie rekordów
        foreach (self::getRows($object, $objectId, $year, true, null, null) as $stat) {
            $stat->month = str_pad($stat->month, 2, '0', STR_PAD_LEFT);
            $statArray[$stat->year . '-' . $stat->month] = $stat->count;
        }
        $stats = [];
        //dodawanie do kubełków miesięcy
        for ($i = 1; $i <= 12; $i++) {
            $month = str_pad($i, 2, '0', STR_PAD_LEFT);
            $count = 0;
            if (isset($statArray[$year . '-' . $month])) {
                $count = $statArray[$year . '-' . $month];
            }
            $stats[$year . '-' . $month] = $count;
        }
        return $stats;
    }
283082
public static function appendFile(\Mmi\Http\RequestFile $file, $object, $id = null, $allowedTypes = [])
    {
        //sprawdzenie i skopiowanie pliku do odpowiedniego katalogu na dysku
        if (null === $name = self::_checkAndCopyFile($file, $allowedTypes)) {
            return null;
        }
        //przypisywanie pól w rekordzie
        $record = self::_updateRecordFromRequestFile($file, new \Cms\Orm\CmsFileRecord());
        //zapis nazwy pliku
        $record->name = $name;
        //obiekt i id
        $record->object = $object;
        $record->objectId = $id;
        //zapis rekordu
        return ($record->save()) ? $record : null;
    }
1074170
private function appendForeignKeyNode(ForeignKey $foreignKey, \DOMNode $parentNode)
    {
        $foreignKeyNode = $parentNode->appendChild($this->document->createElement('foreign-key'));
        $foreignKeyNode->setAttribute('foreignTable', $foreignKey->getForeignTableCommonName());

        if ($schema = $foreignKey->getForeignSchemaName()) {
            $foreignKeyNode->setAttribute('foreignSchema', $schema);
        }

        $foreignKeyNode->setAttribute('name', $foreignKey->getName());

        if ($phpName = $foreignKey->getPhpName()) {
            $foreignKeyNode->setAttribute('phpName', $phpName);
        }

        if ($refPhpName = $foreignKey->getRefPhpName()) {
            $foreignKeyNode->setAttribute('refPhpName', $refPhpName);
        }

        if ($defaultJoin = $foreignKey->getDefaultJoin()) {
            $foreignKeyNode->setAttribute('defaultJoin', $defaultJoin);
        }

        if ($onDeleteBehavior = $foreignKey->getOnDelete()) {
            $foreignKeyNode->setAttribute('onDelete', $onDeleteBehavior);
        }

        if ($onUpdateBehavior = $foreignKey->getOnUpdate()) {
            $foreignKeyNode->setAttribute('onUpdate', $onUpdateBehavior);
        }

        for ($i = 0, $size = count($foreignKey->getLocalColumns()); $i < $size; $i++) {
            $refNode = $foreignKeyNode->appendChild($this->document->createElement('reference'));
            $refNode->setAttribute('local', $foreignKey->getLocalColumnName($i));
            $refNode->setAttribute('foreign', $foreignKey->getForeignColumnName($i));
        }

        foreach ($foreignKey->getVendorInformation() as $vendorInformation) {
            $this->appendVendorInformationNode($vendorInformation, $foreignKeyNode);
        }
    }
1004441
public static function copyArray($srcArray,&$destArray,$fieldMap=[])
    {
        if(empty($fieldMap)){
            $destArray=$srcArray;
            return true;
        }else{
            $dim=count($fieldMap)==count($fieldMap,1);
            foreach ($fieldMap as $srcKey=>$destKey){
                if($dim){
                    $srcKey=$destKey;
                }
                $destArray[$destKey]=$srcArray[$srcKey];
            }
            return true;
        }
    }
597785
public function sendClientIfo($lastInsertID = false, $roistat = false)
	{
		// Подготовка шаблона сообщения с информациией о клиенте
		$time 		= date("d.m.y_G:i");
		$message 	= "Время $time \n\n Заявка была заполнена на сайте \n" . $this->url . "\n\n";
		$message .= "Имя: $this->name\n";
		$message .= "Телефон: $this->tel\n";

		if (isset($lastInsertID) && !empty($lastInsertID || $lastInsertID != false)){
			$message .= "\n\nCcылка в админку:\n";
			$message .= $this->config->contactsUrl . $lastInsertID;
		}
		if($roistat !== false ){
			$message .= "\n\nRoistat: " . $roistat . "\n";
		}
		$message .= "\n\nВсе варианты ip:\n";
		foreach ($this->ips as $key => $value) {
			$message .= $value."\n";
		}
		$message .= "\nhttp://sypexgeo.net/ru/demo/";

		$this->sendMail($time, $message);
		return true;
	}
1355473
protected function _buildSelectString($oListObject = null)
    {
        $sQ = parent::_buildSelectString($oListObject);
        if ($sQ) {
            $sTable = getViewName("oxarticles");
            $sQ .= " and $sTable.oxparentid = '' ";

            $sType = false;
            $sArtCat = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("art_category");
            if ($sArtCat && strstr($sArtCat, "@@") !== false) {
                list($sType, $sValue) = explode("@@", $sArtCat);
            }

            switch ($sType) {
                // add category
                case 'cat':
                    $oStr = getStr();
                    $sViewName = getViewName("oxobject2category");
                    $sInsert = "from $sTable left join {$sViewName} on {$sTable}.oxid = {$sViewName}.oxobjectid " .
                               "where {$sViewName}.oxcatnid = " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote($sValue) . " and ";
                    $sQ = $oStr->preg_replace("/from\s+$sTable\s+where/i", $sInsert, $sQ);
                    break;
                // add category
                case 'mnf':
                    $sQ .= " and $sTable.oxmanufacturerid = " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote($sValue);
                    break;
                // add vendor
                case 'vnd':
                    $sQ .= " and $sTable.oxvendorid = " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote($sValue);
                    break;
            }
        }

        return $sQ;
    }