示例#1
0
 public static function delete($primary)
 {
     $primary = Assert::expectIntegerPositive($primary, '$primary');
     $delResult = parent::delete($primary);
     // delete connected data
     if ($delResult->isSuccess()) {
         Name\TypeTable::deleteMultipleForOwner($primary);
     }
     return $delResult;
 }
示例#2
0
 public static function deleteMultipleForOwner($primaryOwner)
 {
     $primaryOwner = Assert::expectIntegerPositive($primaryOwner, '$primaryOwner');
     $listRes = self::getList(array('filter' => array('LOCATION_ID' => $primaryOwner), 'select' => array('ID')));
     while ($item = $listRes->fetch()) {
         $res = self::delete($item['ID']);
         if (!$res->isSuccess()) {
             throw new Main\SystemException(Loc::getMessage('SALE_LOCATION_EXTERNAL_ENTITY_CANNOT_DELETE_DATA_EXCEPTION'));
         }
     }
 }
示例#3
0
 public static function delete($primary)
 {
     $primary = Assert::expectIntegerPositive($primary, '$primary');
     $delResult = parent::delete($primary);
     // delete connected data
     if ($delResult->isSuccess()) {
         Name\GroupTable::deleteMultipleForOwner($primary);
         // set flag that indicates whether project still uses groups or not
         self::checkGroupUsage();
     }
     return $delResult;
 }
示例#4
0
 /**
  *
  *
  *
  */
 public static function getExternalData($primary, $parameters = array())
 {
     $primary = Assert::expectIntegerPositive($primary, '$primary');
     if (!is_array($parameters) || empty($parameters)) {
         $parameters = array();
     }
     $parameters['filter']['LOCATION_ID'] = $primary;
     return ExternalTable::getList($parameters);
 }
示例#5
0
 protected static function getNodeInfo($primary)
 {
     $primary = Assert::expectIntegerPositive($primary, '$primary');
     $node = self::getById($primary)->fetch();
     if (!isset($node['ID'])) {
         throw new Main\SystemException(Loc::getMessage('SALE_LOCATION_TREE_ENTITY_NODE_NOT_FOUND_EXCEPTION'));
     }
     return $node;
 }
示例#6
0
 /**
  * Get existed translations for $primaryOwner and add only non-existed ones from $names
  * @param mixed $primaryOwner Primary key of the item
  * @param string[] $names A set of translations for the item
  * 
  * @return void
  */
 public static function addAbsentForOwner($primaryOwner, $names, $behaviour = array('TREAT_EMPTY_AS_ABSENT' => true))
 {
     $primaryOwner = Assert::expectIntegerPositive($primaryOwner, '$primaryOwner');
     if (!is_array($names)) {
         $names = array();
     }
     if (!is_array($behaviour)) {
         $behaviour = array();
     }
     if (!isset($behaviour['TREAT_EMPTY_AS_ABSENT'])) {
         $behaviour['TREAT_EMPTY_AS_ABSENT'] = true;
     }
     if (empty($names)) {
         return;
     }
     $namesLC = array();
     foreach ($names as $lid => $data) {
         $namesLC[Assert::castTrimLC($lid)] = $data;
     }
     $names = $namesLC;
     $langField = static::getLanguageFieldName();
     $refField = static::getReferenceFieldName();
     $names2Update = array();
     $res = static::getList(array('filter' => array('=' . $refField => $primaryOwner)));
     while ($item = $res->fetch()) {
         $isEmpty = static::checkEmpty($item);
         if ($isEmpty && $behaviour['TREAT_EMPTY_AS_ABSENT']) {
             $names2Update[$item['ID']] = $names[$item[$langField]];
         }
         unset($names[$item[$langField]]);
     }
     foreach ($names as $lid => $data) {
         $data[$langField] = $lid;
         $data[$refField] = $primaryOwner;
         static::add($data);
     }
     foreach ($names2Update as $id => $data) {
         static::update($id, $data);
     }
 }
示例#7
0
 /**
  * Functions for massive check for link type
  * 
  * 
  */
 public static function getLinkStatusForMultipleNodes($nodeInfo = array(), $entityPrimary, $connectors = false)
 {
     $nodeInfo = Assert::expectArray($nodeInfo, '$nodeInfo');
     $entityPrimary = Assert::expectStringNotNull($entityPrimary, '$entityPrimary');
     $result = array();
     if (!static::checkLinkUsageAny($entityPrimary)) {
         foreach ($nodeInfo as $node) {
             $result[$node['ID']] = self::LSTAT_BELOW_CONNECTOR;
         }
         return $result;
     }
     if (!is_array($connectors)) {
         $connectors = static::getConnectedLocationsInfo($entityPrimary);
     }
     foreach ($nodeInfo as $node) {
         $node = Assert::expectNotEmptyArray($node, '$nodeInfo[]');
         $node['ID'] = Assert::expectIntegerPositive($node['ID'], '$nodeInfo[][ID]');
         $node['LEFT_MARGIN'] = Assert::expectIntegerNonNegative($node['LEFT_MARGIN'], '$nodeInfo[][LEFT_MARGIN]');
         $node['RIGHT_MARGIN'] = Assert::expectIntegerPositive($node['RIGHT_MARGIN'], '$nodeInfo[][RIGHT_MARGIN]');
         $result[$node['ID']] = false;
         foreach ($connectors as $connector) {
             if ($connector['ID'] == $node['ID']) {
                 $result[$node['ID']] = self::LSTAT_IS_CONNECTOR;
                 break;
             } elseif ($node['LEFT_MARGIN'] >= $connector['LEFT_MARGIN'] && $node['RIGHT_MARGIN'] <= $connector['RIGHT_MARGIN']) {
                 $result[$node['ID']] = self::LSTAT_BELOW_CONNECTOR;
                 break;
             } elseif ($node['LEFT_MARGIN'] <= $connector['LEFT_MARGIN'] && $node['RIGHT_MARGIN'] >= $connector['RIGHT_MARGIN']) {
                 $result[$node['ID']] = self::LSTAT_ABOVE_CONNECTOR;
                 break;
             }
         }
         if (!$result[$node['ID']]) {
             $result[$node['ID']] = self::LSTAT_IN_NOT_CONNECTED_BRANCH;
         }
     }
     return $result;
 }
示例#8
0
 public static function checkConnectionExists($entityPrimary, $locationPrimary)
 {
     $entityPrimary = Assert::expectStringNotNull($entityPrimary, '$entityPrimary');
     $locationPrimary = Assert::expectIntegerPositive($locationPrimary, '$locationPrimary');
     if (!static::checkLinkUsageAny($entityPrimary)) {
         // if there are no links at all, connection virtually exists
         return true;
     }
     // todo: here we can rewrite this to make it to do just one query
     $node = LocationTable::getById($locationPrimary)->fetch();
     $result = static::getLinkStatusForMultipleNodes(array($node), $entityPrimary);
     return $result[$locationPrimary] == self::LSTAT_IS_CONNECTOR || $result[$locationPrimary] == self::LSTAT_BELOW_CONNECTOR;
 }