public function checkAddressExistence($_sAddress) { $count = 0; if ($_sAddress) { $find = '%' . $_sAddress . '%'; $oTypes = umiObjectTypesCollection::getInstance(); $iTypeId = $oTypes->getBaseType('webforms', 'address'); $oSelection = new umiSelection(); $oSelection->addObjectType($iTypeId); $oSelection->addPropertyFilterLike($oTypes->getType($iTypeId)->getFieldId('address_list'), $find); $count = umiSelectionsParser::runSelectionCounts($oSelection); } if (!$count) { $this->errorNewMessage("%unknown_address%"); $this->errorPanic(); } }
public function rename() { $s_path = $this->getCurrentPath(); if (defined("CURRENT_VERSION_LINE") && CURRENT_VERSION_LINE == "demo") { $this->chooseRedirect('/admin/filemanager/directory_list/?dir=' . base64_encode($s_path)); return false; } $s_old_name = getRequest('old_name'); $s_new_name = getRequest('new_name'); if (!$this->checkIsAllowedPath($s_path . "/" . $s_old_name)) { throw new publicAdminException(getLabel('error-fs-not-allowed')); } $s_new_name_arr = explode(".", $s_new_name); foreach ($s_new_name_arr as &$sn) { $sn = translit::convert($sn); } $s_new_name = implode(".", $s_new_name_arr); if (strlen($s_path) && strlen($s_old_name) && strlen($s_new_name)) { if (file_exists($s_path . "/" . $s_old_name) && !file_exists($s_path . "/" . $s_new_name)) { // try rename if (@rename($s_path . "/" . $s_old_name, $s_path . "/" . $s_new_name) === false) { throw new publicAdminException(getLabel('error-cant-rename-dir')); } else { $typesCollection = umiObjectTypesCollection::getInstance(); $objectsCollection = umiObjectsCollection::getInstance(); $selection = new umiSelection(); $typeId = $typesCollection->getBaseType("filemanager", "shared_file"); $type = $typesCollection->getType($typeId); $selection->addObjectType($typeId); $selection->addPropertyFilterLike($type->getFieldId('fs_file'), './' . $s_path . "/" . $s_old_name); $sfiles = umiSelectionsParser::runSelection($selection); foreach ($sfiles as $sfileId) { if ($file = $objectsCollection->getObject($sfileId)) { $file->setValue('fs_file', new umiFile('./' . $s_path . "/" . $s_new_name)); } } } } } $this->chooseRedirect('/admin/filemanager/directory_list/?dir=' . base64_encode($s_path)); }
/** * Применение кастомной логики к объекту umiSelection * * @param umiSelection $selection Объект umiSelection */ public function applyCustomCountFilters(&$selection) { $arCustomFilters = $this->customLogic->filters(); $oType = umiObjectTypesCollection::getInstance()->getType($this->objectsTypeId); if (!$oType) { return; } foreach ($arCustomFilters as $arCustomFilter) { $iFieldId = $oType->getFieldId($arCustomFilter[0]); $sOperator = $arCustomFilter[1]; $value = $arCustomFilter[2]; switch ($sOperator) { case "eq": $selection->addPropertyFilterEqual($iFieldId, $value); break; case "noteq": $selection->addPropertyFilterNotEqual($iFieldId, $value); break; case "null": $selection->addPropertyFilterIsNull($iFieldId); break; case "notnull": $selection->addPropertyFilterIsNotNull($iFieldId); break; case "gt": $selection->addPropertyFilterMore($iFieldId, $value); break; case "lt": $selection->addPropertyFilterLess($iFieldId, $value); break; case "like": $selection->addPropertyFilterLike($iFieldId, $value); break; } } }