Example #1
1
 public static function deleteMultipleForOwner($primaryOwner)
 {
     $primaryOwner = Assert::expectIntegerPositive($primaryOwner, false, Loc::getMessage('SALE_LOCATION_EXTERNAL_ENTITY_OWNER_NOT_SET_EXCEPTION'));
     $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'));
         }
     }
 }
Example #2
0
 public static function delete($primary)
 {
     $primary = Assert::expectIntegerPositive($primary, Loc::getMessage('SALE_LOCATION_TYPE_ENTITY_PRIMARY_FIELD'));
     $delResult = parent::delete($primary);
     // delete connected data
     if ($delResult->isSuccess()) {
         Name\TypeTable::deleteMultipleForOwner($primary);
     }
     return $delResult;
 }
Example #3
0
 public static function delete($primary)
 {
     $primary = Assert::expectIntegerPositive($primary, Loc::getMessage('SALE_LOCATION_GROUP_ENTITY_PRIMARY_FIELD'));
     $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;
 }
 public static function deleteMultipleForOwner($primaryOwner)
 {
     $primaryOwner = Assert::expectIntegerPositive($primaryOwner, false, Loc::getMessage('SALE_LOCATION_NAME_NAME_ENTITY_OWNER_NOT_SET_EXCEPTION'));
     // hunt existed
     $listRes = static::getList(array('filter' => array(static::getReferenceFieldName() => $primaryOwner), 'select' => array('ID')));
     // kill existed
     while ($item = $listRes->fetch()) {
         $res = static::delete($item['ID']);
         if (!$res->isSuccess()) {
             throw new Main\SystemException(Loc::getMessage('SALE_LOCATION_NAME_NAME_ENTITY_CANNOT_DELETE_NAMES_EXCEPTION'));
         }
     }
 }
Example #5
0
 /**
  * Fetches a chain of parents with their subtrees expanded
  *
  * Available keys in $behaviour
  * SHOW_CHILDREN : if set to true, do return direct ancestors of $primary in the result
  * START_FROM
  */
 public static function getParentTree($primary, $parameters = array(), $behaviour = array('SHOW_CHILDREN' => true, 'START_FROM' => false))
 {
     $primary = Assert::expectIntegerPositive($primary, Loc::getMessage('SALE_LOCATION_TREE_ENTITY_BAD_ARGUMENT_PRIMARY_UNSET_EXCEPTION'));
     if (!is_array($behaviour)) {
         $behaviour = array();
     }
     if (!isset($behaviour['SHOW_CHILDREN'])) {
         $behaviour['SHOW_CHILDREN'] = true;
     }
     if (!isset($behaviour['START_FROM'])) {
         $behaviour['START_FROM'] = false;
     }
     if (empty($parameters)) {
         $parameters = array();
     }
     $startFrom = intval($behaviour['START_FROM']);
     $showChildren = $behaviour['SHOW_CHILDREN'];
     if (!$startFrom) {
         $conditions[] = array('DEPTH_LEVEL' => 1);
     }
     // todo: combine (1) and (2) in one query, check perfomance change
     // (1)
     $res = self::getPathToNode($primary, array('select' => array('ID')));
     $started = !$startFrom;
     while ($item = $res->fetch()) {
         if ($item['ID'] == $startFrom) {
             $started = true;
         }
         if (!$started) {
             continue;
         }
         if (!$showChildren && $item['ID'] == $primary) {
             continue;
         }
         $conditions[] = array('PARENT_ID' => $item['ID']);
     }
     $conditions['LOGIC'] = 'OR';
     $parameters['filter'][] = $conditions;
     if (!is_array($parameters['order']) || empty($parameters['order'])) {
         $parameters['order'] = array('LEFT_MARGIN' => 'asc');
     }
     // (2)
     return self::getList($parameters);
 }
Example #6
0
 public static function checkConnectionExists($entityPrimary, $locationPrimary)
 {
     $entityPrimary = Assert::expectStringNotNull($entityPrimary, Loc::getMessage('SALE_LOCATION_CONNECTOR_ENTITY_PRIMARY_FLD_NAME'));
     $locationPrimary = Assert::expectIntegerPositive($locationPrimary, Loc::getMessage('SALE_LOCATION_CONNECTOR_ENTITY_LOCATION_PRIMARY_FLD_NAME'));
     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;
 }
Example #7
0
 /**
  *
  *
  *
  */
 public static function getExternalData($primary, $parameters = array())
 {
     $primary = Assert::expectIntegerPositive($primary, false, Loc::getMessage('SALE_LOCATION_LOCATION_ENTITY_BAD_ARGUMENT_PRIMARY_UNSET_EXCEPTION'));
     if (!is_array($parameters) || empty($parameters)) {
         $parameters = array();
     }
     $parameters['filter']['LOCATION_ID'] = $primary;
     return ExternalTable::getList($parameters);
 }