コード例 #1
1
ファイル: culture.php プロジェクト: Satariall/izurit
 public static function delete($id)
 {
     //We know for sure that languages and sites can refer to the culture.
     //Other entities should place CultureOnBeforeDelete event handler.
     $result = new Entity\DeleteResult();
     $res = LanguageTable::getList(array('filter' => array('=CULTURE_ID' => $id)));
     while ($language = $res->fetch()) {
         $result->addError(new Entity\EntityError(Loc::getMessage("culture_err_del_lang", array("#LID#" => $language["LID"]))));
     }
     $res = \Bitrix\Main\SiteTable::getList(array('filter' => array('=CULTURE_ID' => $id)));
     while ($site = $res->fetch()) {
         $result->addError(new Entity\EntityError(Loc::getMessage("culture_err_del_site", array("#LID#" => $site["LID"]))));
     }
     if (!$result->isSuccess()) {
         return $result;
     }
     return parent::delete($id);
 }
コード例 #2
1
ファイル: phone.php プロジェクト: DarneoStudio/bitrix
 public static function deleteByUser($userId)
 {
     $result = new DeleteResult();
     $entity = static::getEntity();
     $userId = intval($userId);
     if ($userId <= 0) {
         $result->addError(new Entity\FieldError($entity->getField('USER_ID'), 'UserID must be greater than zero'));
         return $result;
     }
     $event = new Event($entity, "OnBeforeDeleteByUser", array("USER_ID" => $userId));
     $event->send();
     if ($event->getErrors($result)) {
         return $result;
     }
     $event = new Event($entity, "OnDeleteByUser", array("USER_ID" => $userId));
     $event->send();
     $tableName = $entity->getDBTableName();
     $connection = Application::getConnection();
     $sql = "DELETE FROM " . $tableName . " WHERE USER_ID = " . $userId;
     $connection->queryExecute($sql);
     $event = new Event($entity, "OnAfterDeleteByUser", array("USER_ID" => $userId));
     $event->send();
     return $result;
 }
コード例 #3
0
ファイル: discount.php プロジェクト: DarneoStudio/bitrix
 /**
  * Deletes discount by primary key.
  *
  * @param mixed $primary		Discount primary key.
  * @return Main\Entity\DeleteResult
  */
 public static function delete($primary)
 {
     $result = new Main\Entity\DeleteResult();
     $result->addError(new Main\Entity\EntityError(Loc::getMessage('CATALOG_DISCOUNT_ENTITY_MESS_DELETE_BLOCKED')));
     return $result;
 }
コード例 #4
0
ファイル: mailservices.php プロジェクト: webgksupport/alpina
 public static function delete($primary)
 {
     $serviceForDelete = static::getByPrimary($primary)->fetch();
     if (!$serviceForDelete) {
         $deleteResult = new Entity\DeleteResult();
         $deleteResult->addError(new Entity\EntityError(Localization\Loc::getMessage('mail_mailservice_not_found')));
         return $deleteResult;
     }
     $deleteResult = parent::delete($primary);
     if ($deleteResult->isSuccess()) {
         $serviceId = is_array($primary) ? $primary['ID'] : $primary;
         if (in_array($serviceForDelete['SERVICE_TYPE'], array('controller', 'domain'))) {
             $mbData = array('ACTIVE' => 'N', 'SERVICE_ID' => 0);
         } else {
             $emptyService = static::getList(array('filter' => array('=SITE_ID' => $serviceForDelete['SITE_ID'], 'ACTIVE' => 'Y', '=SERVER' => '', '=PORT' => '', '=ENCRYPTION' => '', '=LINK' => ''), 'limit' => 1))->fetch();
             $mbData = $emptyService ? array('SERVICE_ID' => $emptyService['ID'], 'NAME' => $emptyService['NAME']) : array('ACTIVE' => 'N', 'SERVICE_ID' => 0);
         }
         $selectResult = \CMailbox::getList(array(), array('SERVICE_ID' => $serviceId));
         while ($mailbox = $selectResult->fetch()) {
             \CMailbox::update($mailbox['ID'], $mbData);
         }
     }
     return $deleteResult;
 }