コード例 #1
0
ファイル: item.php プロジェクト: rasuldev/torino
 function Fetch()
 {
     static $arSite = array();
     $r = parent::Fetch();
     if ($r) {
         $site_id = $r["SITE_ID"];
         if (!isset($arSite[$site_id])) {
             $rsSite = CSite::GetList($b, $o, array("ID" => $site_id));
             $arSite[$site_id] = $rsSite->Fetch();
         }
         $r["DIR"] = $arSite[$site_id]["DIR"];
         $r["SERVER_NAME"] = $arSite[$site_id]["SERVER_NAME"];
         if (strlen($r["SITE_URL"]) > 0) {
             $r["URL"] = $r["SITE_URL"];
         }
         if (substr($r["URL"], 0, 1) == "=") {
             foreach (GetModuleEvents("search", "OnSearchGetURL", true) as $arEvent) {
                 $r["URL"] = ExecuteModuleEventEx($arEvent, array($r));
             }
         }
         $r["URL"] = str_replace(array("#LANG#", "#SITE_DIR#", "#SERVER_NAME#"), array($r["DIR"], $r["DIR"], $r["SERVER_NAME"]), $r["URL"]);
         $r["URL"] = preg_replace("'(?<!:)/+'s", "/", $r["URL"]);
         unset($r["SITE_URL"]);
     }
     return $r;
 }
コード例 #2
0
 function Delete($ID)
 {
     global $DB;
     if (!CSocNetGroup::__ValidateID($ID)) {
         return false;
     }
     $ID = IntVal($ID);
     $bSuccess = True;
     $rsUser2UserOld = $DB->Query("SELECT * FROM b_sonet_user_relations WHERE ID = " . $ID . "");
     if ($arUser2UserOld = $rsUser2UserOld->Fetch()) {
         CSocNetSearch::OnUserRelationsChange($arUser2UserOld["FIRST_USER_ID"]);
         CSocNetSearch::OnUserRelationsChange($arUser2UserOld["SECOND_USER_ID"]);
     }
     $db_events = GetModuleEvents("socialnetwork", "OnBeforeSocNetUserRelationsDelete");
     while ($arEvent = $db_events->Fetch()) {
         if (ExecuteModuleEventEx($arEvent, array($ID)) === false) {
             return false;
         }
     }
     $events = GetModuleEvents("socialnetwork", "OnSocNetUserRelationsDelete");
     while ($arEvent = $events->Fetch()) {
         ExecuteModuleEventEx($arEvent, array($ID));
     }
     if ($bSuccess) {
         $arRelation = CSocNetUserRelations::GetByID($ID);
         $bSuccess = $DB->Query("DELETE FROM b_sonet_user_relations WHERE ID = " . $ID . "", true);
     }
     if ($bSuccess) {
         if ($arRelation && $arRelation["RELATION"] == SONET_RELATIONS_FRIEND) {
             $GLOBALS["DB"]->Query("DELETE FROM b_sonet_event_user_view WHERE\n\t\t\t\t\tENTITY_TYPE = '" . SONET_ENTITY_USER . "'\n\t\t\t\t\tAND (\n\t\t\t\t\t\t(USER_ID = " . $arRelation["FIRST_USER_ID"] . " AND ENTITY_ID = " . $arRelation["SECOND_USER_ID"] . ")\n\t\t\t\t\t\tOR (USER_ID = " . $arRelation["SECOND_USER_ID"] . " AND ENTITY_ID = " . $arRelation["FIRST_USER_ID"] . ")\n\t\t\t\t\t\tOR (ENTITY_ID = " . $arRelation["FIRST_USER_ID"] . " AND USER_IM_ID = " . $arRelation["SECOND_USER_ID"] . ")\n\t\t\t\t\t\tOR (ENTITY_ID = " . $arRelation["SECOND_USER_ID"] . " AND USER_IM_ID = " . $arRelation["FIRST_USER_ID"] . ")\n\t\t\t\t\t\tOR (USER_ID = " . $arRelation["FIRST_USER_ID"] . " AND USER_IM_ID = " . $arRelation["SECOND_USER_ID"] . ")\n\t\t\t\t\t\tOR (USER_ID = " . $arRelation["SECOND_USER_ID"] . " AND USER_IM_ID = " . $arRelation["FIRST_USER_ID"] . ")\n\t\t\t\t\t\t)", true);
         }
     }
     return $bSuccess;
 }
コード例 #3
0
 public static function Update($id, $arFields)
 {
     global $DB;
     $id = intval($id);
     if ($id <= 0) {
         throw new Exception("id");
     }
     self::ParseFields($arFields, $id);
     $strUpdate = $DB->PrepareUpdate("b_bp_task", $arFields);
     $strSql = "UPDATE b_bp_task SET " . "\t" . $strUpdate . ", " . "\tMODIFIED = " . $DB->CurrentTimeFunction() . " " . "WHERE ID = " . intval($id) . " ";
     $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     if (is_set($arFields, "USERS")) {
         $DB->Query("DELETE FROM b_bp_task_user WHERE TASK_ID = " . intval($id) . " ");
         CUserCounter::ClearByTag($id, 'bp_tasks', '**');
         $ar = array();
         foreach ($arFields["USERS"] as $userId) {
             $userId = intval($userId);
             if (in_array($userId, $ar)) {
                 continue;
             }
             $DB->Query("INSERT INTO b_bp_task_user (USER_ID, TASK_ID) " . "VALUES (" . intval($userId) . ", " . intval($id) . ") ");
             CUserCounter::Increment($userId, 'bp_tasks', '**');
             $ar[] = $userId;
         }
     }
     $events = GetModuleEvents("bizproc", "OnTaskUpdate");
     while ($arEvent = $events->Fetch()) {
         ExecuteModuleEventEx($arEvent, array($id, $arFields));
     }
     return $id;
 }
コード例 #4
0
 public static function Update($ID, $arFields)
 {
     global $DB;
     $e = GetModuleEvents('timeman', 'OnBeforeTMReportUpdate');
     while ($a = $e->Fetch()) {
         if (false === ExecuteModuleEventEx($a, array($arFields))) {
             return false;
         }
     }
     if (!self::CheckFields('UPDATE', $arFields)) {
         return false;
     }
     $strUpdate = $DB->PrepareUpdate('b_timeman_reports', $arFields);
     $query = 'UPDATE b_timeman_reports SET ' . $strUpdate . ' WHERE ID=\'' . intval($ID) . '\'';
     if (($dbRes = $DB->Query($query)) && $dbRes->AffectedRowsCount() > 0) {
         if (isset($arFields['REPORT'])) {
             $DB->QueryBind($query, array('REPORT' => $arFields['REPORT']));
         }
         $e = GetModuleEvents('timeman', 'OnAfterTMReportUpdate');
         while ($a = $e->Fetch()) {
             ExecuteModuleEventEx($a, array($ID, $arFields));
         }
         return $ID;
     }
     return false;
 }
コード例 #5
0
ファイル: short_uri.php プロジェクト: andy-profi/bxApiDocs
 public static function Delete($id)
 {
     global $DB, $APPLICATION;
     self::ClearErrors();
     $id = intval($id);
     if ($id <= 0) {
         self::AddError(GetMessage("MN_SU_NO_ID"));
         return false;
     }
     foreach (GetModuleEvents("main", "OnBeforeShortUriDelete", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array($id)) === false) {
             if ($ex = $APPLICATION->GetException()) {
                 $err = $ex->GetString();
             } else {
                 $err = GetMessage("MN_SU_DELETE_ERROR");
             }
             self::AddError($err);
             return false;
         }
     }
     $fl = $DB->Query("DELETE FROM b_short_uri WHERE ID = " . $id, true);
     if (!$fl) {
         self::AddError(GetMessage("MN_SU_DELETE_ERROR"));
         return false;
     }
     return true;
 }
コード例 #6
0
ファイル: invite_dialog.php プロジェクト: mrdeadmouse/u136006
 function AddNewUser($SITE_ID, $arFields, &$strError)
 {
     $ID_ADDED = 0;
     $iDepartmentId = intval($arFields["DEPARTMENT_ID"]);
     $bExtranet = $iDepartmentId <= 0;
     $strEmail = trim($arFields["ADD_EMAIL"]);
     $strName = trim($arFields["ADD_NAME"]);
     $strLastName = trim($arFields["ADD_LAST_NAME"]);
     $strPosition = trim($arFields["ADD_POSITION"]);
     $strPassword = self::GeneratePassword($SITE_ID, $bExtranetUser);
     self::setSendPassword($arFields["ADD_SEND_PASSWORD"] == "Y");
     if (strlen($strEmail) <= 0) {
         if (!isset($arFields["ADD_MAILBOX_ACTION"]) || !in_array($arFields["ADD_MAILBOX_ACTION"], array("create", "connect")) || strlen($arFields['ADD_MAILBOX_USER']) <= 0 || strlen($arFields['ADD_MAILBOX_DOMAIN']) <= 0) {
             $strError = GetMessage("BX24_INVITE_DIALOG_ERROR_EMPTY_EMAIL");
         } else {
             // email from mailbox
             $strEmail = $arFields['ADD_MAILBOX_USER'] . "@" . $arFields['ADD_MAILBOX_DOMAIN'];
         }
     }
     if (!$strError) {
         $arUser = array("LOGIN" => $strEmail, "NAME" => $strName, "LAST_NAME" => $strLastName, "EMAIL" => $strEmail, "PASSWORD" => $strPassword, "GROUP_ID" => CIntranetInviteDialog::getUserGroups($SITE_ID, $bExtranet), "WORK_POSITION" => $strPosition, "UF_DEPARTMENT" => $iDepartmentId > 0 ? array($iDepartmentId) : array(0));
         if (!self::getSendPassword()) {
             $arUser["CONFIRM_CODE"] = randString(8);
         }
         $obUser = new CUser();
         $ID_ADDED = $obUser->Add($arUser);
         if (!$ID_ADDED) {
             if ($e = $GLOBALS["APPLICATION"]->GetException()) {
                 $strError = $e->GetString();
             } else {
                 $strError = $obUser->LAST_ERROR;
             }
         } else {
             if (self::getSendPassword()) {
                 $db_events = GetModuleEvents("main", "OnUserInitialize", true);
                 foreach ($db_events as $arEvent) {
                     ExecuteModuleEventEx($arEvent, array($ID_ADDED, $arUser));
                 }
             }
             $SiteIdToSend = $bExtranet && CModule::IncludeModule("extranet") ? CExtranet::GetExtranetSiteID() : CSite::GetDefSite();
             $rsSites = CSite::GetByID($SiteIdToSend);
             $arSite = $rsSites->Fetch();
             $serverName = strlen($arSite["SERVER_NAME"]) > 0 ? $arSite["SERVER_NAME"] : (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0 ? SITE_SERVER_NAME : COption::GetOptionString("main", "server_name", ""));
             $event = new CEvent();
             if (self::getSendPassword()) {
                 $url = (CMain::IsHTTPS() ? "https" : "http") . "://" . $serverName . $arSite["DIR"];
                 $event->SendImmediate("INTRANET_USER_ADD", $SITE_ID, array("EMAIL_TO" => $arUser["EMAIL"], "LINK" => $url, "PASSWORD" => $strPassword, "USER_TEXT" => GetMessage("BX24_INVITE_DIALOG_INVITE_MESSAGE_TEXT")));
             } else {
                 $dbUser = CUser::GetByID($ID_ADDED);
                 $arUser = $dbUser->Fetch();
                 if (IsModuleInstalled("bitrix24")) {
                     $event->SendImmediate("BITRIX24_USER_INVITATION", $SITE_ID, array("EMAIL_FROM" => $GLOBALS["USER"]->GetEmail(), "EMAIL_TO" => $arUser["EMAIL"], "LINK" => CHTTP::URN2URI("/bitrix/tools/intranet_invite_dialog.php?user_id=" . $ID_ADDED . "&checkword=" . urlencode($arUser["CONFIRM_CODE"]), $serverName), "USER_TEXT" => GetMessage("BX24_INVITE_DIALOG_INVITE_MESSAGE_TEXT")));
                 } else {
                     $event->SendImmediate("INTRANET_USER_INVITATION", $SITE_ID, array("EMAIL_TO" => $arUser["EMAIL"], "LINK" => CHTTP::URN2URI("/bitrix/tools/intranet_invite_dialog.php?user_id=" . $ID_ADDED . "&checkword=" . urlencode($arUser["CONFIRM_CODE"]), $serverName), "USER_TEXT" => GetMessage("BX24_INVITE_DIALOG_INVITE_MESSAGE_TEXT")));
                 }
             }
         }
     }
     return $ID_ADDED;
 }
コード例 #7
0
ファイル: module_admin.php プロジェクト: ASDAFF/open_bx
function OnModuleInstalledEvent($id)
{
	foreach(GetModuleEvents("main", "OnModuleInstalled", true) as $arEvent)
	{
		ExecuteModuleEventEx($arEvent, array($id));
	}
}
コード例 #8
0
ファイル: taskservice.php プロジェクト: ASDAFF/bitrix-5
	public static function DeleteByWorkflow($workflowId)
	{
		global $DB;

		$workflowId = trim($workflowId);
		if (strlen($workflowId) <= 0)
			throw new Exception("workflowId");

		$dbRes = $DB->Query(
			"SELECT ID ".
			"FROM b_bp_task ".
			"WHERE WORKFLOW_ID = '".$DB->ForSql($workflowId)."' "
		);
		while ($arRes = $dbRes->Fetch())
		{
			$taskId = intval($arRes["ID"]);
			$dbResUser = $DB->Query("SELECT USER_ID FROM b_bp_task_user WHERE TASK_ID = ".$taskId." ");
			while ($arResUser = $dbResUser->Fetch())
				CUserCounter::Decrement($arResUser["USER_ID"], 'bp_tasks', '**');

			$DB->Query("DELETE FROM b_bp_task_user WHERE TASK_ID = ".$taskId." ", true);

			foreach (GetModuleEvents("bizproc", "OnTaskDelete", true) as $arEvent)
				ExecuteModuleEventEx($arEvent, array($taskId));
		}

		$DB->Query(
			"DELETE FROM b_bp_task ".
			"WHERE WORKFLOW_ID = '".$DB->ForSql($workflowId)."' ",
			true
		);
	}
コード例 #9
0
ファイル: file.php プロジェクト: andy-profi/bxApiDocs
 /**
  * <p>Метод удаляет файл из таблицы зарегистрированных файлов (b_file) и с диска. Статичный метод.</p>
  *
  *
  * @param int $id  Цифровой идентификатор файла.
  *
  * @return mixed 
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?
  * // удаляем изображение формы
  * $arFilter = array("ID" =&gt; 1, "ID_EXACT_MATCH" =&gt; "Y");
  * $rsForm = CForm::GetList($by, $order, $arFilter, $is_filtered);
  * if ($arForm = $rsForm-&gt;Fetch())
  * {
  *     if (intval($arForm["IMAGE_ID"])&gt;0) <b>CFile::Delete</b>($arForm["IMAGE_ID"]);	
  * }
  * ?&gt;
  * </pre>
  *
  *
  * <h4>See Also</h4> 
  * <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/functions/file/deletedirfiles.php">DeleteDirFiles</a> </li>
  * <li> <a href="http://dev.1c-bitrix.ru/api_help/main/functions/file/deletedirfilesex.php">DeleteDirFilesEx</a> </li>
  * </ul><a name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/main/reference/cfile/delete.php
  * @author Bitrix
  */
 public static function Delete($ID)
 {
     global $DB;
     $io = CBXVirtualIo::GetInstance();
     $ID = intval($ID);
     if ($ID <= 0) {
         return;
     }
     $res = CFile::GetByID($ID);
     if ($res = $res->Fetch()) {
         $delete_size = 0;
         $upload_dir = COption::GetOptionString("main", "upload_dir", "upload");
         $dname = $_SERVER["DOCUMENT_ROOT"] . "/" . $upload_dir . "/" . $res["SUBDIR"];
         $fname = $dname . "/" . $res["FILE_NAME"];
         $file = $io->GetFile($fname);
         if ($file->isExists() && $file->unlink()) {
             $delete_size += $res["FILE_SIZE"];
         }
         $delete_size += CFile::ResizeImageDelete($res);
         $DB->Query("DELETE FROM b_file WHERE ID = " . $ID);
         $directory = $io->GetDirectory($dname);
         if ($directory->isExists() && $directory->isEmpty()) {
             $directory->rmdir();
         }
         CFile::CleanCache($ID);
         foreach (GetModuleEvents("main", "OnFileDelete", true) as $arEvent) {
             ExecuteModuleEventEx($arEvent, array($res));
         }
         /****************************** QUOTA ******************************/
         if ($delete_size > 0 && COption::GetOptionInt("main", "disk_space") > 0) {
             CDiskQuota::updateDiskQuota("file", $delete_size, "delete");
         }
         /****************************** QUOTA ******************************/
     }
 }
コード例 #10
0
ファイル: tags.php プロジェクト: k-kalashnikov/geekcon_new
function tags_prepare($sText, $site_id = false)
{
    static $arEvents = false;
    if ($arEvents === false) {
        $arEvents = array();
        $rsEvents = GetModuleEvents("search", "OnSearchGetTag");
        while ($arEvent = $rsEvents->Fetch()) {
            $arEvents[] = $arEvent;
        }
    }
    $arResult = array();
    $arTags = explode(",", $sText);
    foreach ($arTags as $tag) {
        $tag = trim($tag);
        if (strlen($tag)) {
            foreach ($arEvents as $arEvent) {
                $tag = ExecuteModuleEventEx($arEvent, array($tag));
            }
            if (strlen($tag)) {
                $arResult[$tag] = $tag;
            }
        }
    }
    return $arResult;
}
コード例 #11
0
ファイル: log_rights.php プロジェクト: ASDAFF/bitrix-5
	function Update($RIGHT_ID, $GROUP_CODE)
	{
		global $DB;
		$RIGHT_ID = intval($RIGHT_ID);

		if (is_array($GROUP_CODE))
		{
			foreach($GROUP_CODE as $GROUP_CODE_TMP)
				CSocNetLogRights::Update($RIGHT_ID, $GROUP_CODE_TMP);
			return false;
		}
		else
		{
			$db_events = GetModuleEvents("socialnetwork", "OnBeforeSocNetLogRightsUpdate");
			while ($arEvent = $db_events->Fetch())
				if (ExecuteModuleEventEx($arEvent, array($RIGHT_ID, &$GROUP_CODE))===false)
					return false;

			$strUpdate = $DB->PrepareUpdate("b_sonet_log_right", array(
				"GROUP_CODE" => $GROUP_CODE
			));
			$DB->Query("UPDATE b_sonet_log_right SET ".$strUpdate." WHERE ID = ".$RIGHT_ID);
			return $RIGHT_ID;
		}
	}
コード例 #12
0
ファイル: dbtools.php プロジェクト: DarneoStudio/bitrix
 static function GetDBUpdaters()
 {
     $rsHandlers = GetModuleEvents("forum", "CollectDBUpdater");
     while ($arHandler = $rsHandlers->Fetch()) {
         ExecuteModuleEventEx($arHandler, array());
     }
 }
コード例 #13
0
function OnModuleInstalledEvent($id)
{
    $db_events = GetModuleEvents("main", "OnModuleInstalled");
    while ($arEvent = $db_events->Fetch()) {
        ExecuteModuleEventEx($arEvent, array($id));
    }
}
コード例 #14
0
 /**
  * @return void
  */
 public static function FireEvent($eventName, $eventParams)
 {
     $events = GetModuleEvents('learning', $eventName);
     while ($arEvent = $events->Fetch()) {
         ExecuteModuleEventEx($arEvent, array($eventParams));
     }
 }
コード例 #15
0
ファイル: store_product.php プロジェクト: ASDAFF/bxApiDocs
	/**
	 * <p>Метод добавляет остаток товара, в соответствии с данными из массива arFields.</p>
	 *
	 *
	 *
	 *
	 * @param array $arFields  Ассоциативный массив параметров, ключами в котором являются
	 * названия параметров, а значениями - соответствующие значения.
	 * Допустимые ключи: <br><ul> <li>PRODUCT_ID - ID товара;</li> <li>STORE_ID - ID склада;</li>
	 * <li>AMOUNT - количество товара;</li> </ul>
	 *
	 *
	 *
	 * @return mixed <p>Возвращает <i>ID</i> записи, если добавление совершено, в противном
	 * случае - <i>false</i>.</p><a name="examples"></a>
	 *
	 *
	 * <h4>Example</h4> 
	 * <pre>
	 * $arFields = Array(
	 * 		"PRODUCT_ID" =&gt; 71,
	 * 		"STORE_ID" =&gt; 1,
	 * 		"AMOUNT" =&gt; 50,
	 * 	);
	 * 	
	 * 	$ID = CCatalogStoreProduct::Add($arFields);
	 * </pre>
	 *
	 *
	 * @static
	 * @link http://dev.1c-bitrix.ru/api_help/catalog/classes/ccatalogstoreproduct/add.php
	 * @author Bitrix
	 */
	public static function Add($arFields)
	{
		global $DB;

		foreach(GetModuleEvents("catalog", "OnBeforeStoreProductAdd", true) as $arEvent)
			if(ExecuteModuleEventEx($arEvent, array(&$arFields)) === false)
				return false;

		if (!self::CheckFields('ADD',$arFields))
			return false;

		$arInsert = $DB->PrepareInsert("b_catalog_store_product", $arFields);
		$strSql = "INSERT INTO b_catalog_store_product (".$arInsert[0].") VALUES(".$arInsert[1].")";

		$res = $DB->Query($strSql, true, "File: ".__FILE__."<br>Line: ".__LINE__);
		if(!$res)
			return false;

		$lastId = intval($DB->LastID());

		foreach(GetModuleEvents("catalog", "OnStoreProductAdd", true) as $arEvent)
			ExecuteModuleEventEx($arEvent, array($lastId, $arFields));

		return $lastId;
	}
コード例 #16
0
ファイル: store_barcode.php プロジェクト: DarneoStudio/bitrix
 /** Add new store in table b_catalog_store_barcode,
  * @static
  * @param $arFields
  * @return bool|int
  */
 static function add($arFields)
 {
     global $DB;
     foreach (GetModuleEvents("catalog", "OnBeforeCatalogStoreBarCodeAdd", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array(&$arFields)) === false) {
             return false;
         }
     }
     if (array_key_exists('DATE_CREATE', $arFields)) {
         unset($arFields['DATE_CREATE']);
     }
     if (array_key_exists('DATE_MODIFY', $arFields)) {
         unset($arFields['DATE_MODIFY']);
     }
     $arFields['~DATE_MODIFY'] = $DB->GetNowFunction();
     $arFields['~DATE_CREATE'] = $DB->GetNowFunction();
     if (!self::CheckFields('ADD', $arFields)) {
         return false;
     }
     $arInsert = $DB->PrepareInsert("b_catalog_store_barcode", $arFields);
     $strSql = "INSERT INTO b_catalog_store_barcode (" . $arInsert[0] . ") VALUES(" . $arInsert[1] . ")";
     $res = $DB->Query($strSql, true, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     if (!$res) {
         return false;
     }
     $lastId = intval($DB->LastID());
     foreach (GetModuleEvents("catalog", "OnCatalogStoreBarCodeAdd", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($lastId, $arFields));
     }
     return $lastId;
 }
コード例 #17
0
ファイル: typemanager.php プロジェクト: Satariall/izurit
 /** @internal */
 public static function getTypesInternal()
 {
     if (!($types =& static::$types)) {
         $event = static::$event;
         $checkModule = static::$checkModule;
         foreach (EventManager::getInstance()->findEventHandlers('conversion', $event) as $handler) {
             $result = ExecuteModuleEventEx($handler);
             if (!is_array($result)) {
                 throw new SystemException('Not array returned from: ' . print_r($handler, true));
             }
             foreach ($result as $name => $type) {
                 if (!is_array($type)) {
                     throw new SystemException('Not array in: ' . $event . '()[' . $name . '] => ' . print_r($handler, true));
                 }
                 if ($checkModule) {
                     if (!$type['MODULE']) {
                         throw new SystemException('No [MODULE] in: ' . $event . '()[' . $name . '] => ' . print_r($handler, true));
                     }
                 }
                 if ($types[$name]) {
                     throw new SystemException('Duplicate in: ' . $event . '()[' . $name . '] => ' . print_r($handler, true));
                 }
                 $types[$name] = $type;
             }
         }
     }
     return $types;
 }
コード例 #18
0
ファイル: price.php プロジェクト: DarneoStudio/bitrix
 function Add($arFields, $boolRecalc = false)
 {
     global $DB;
     $boolBase = false;
     $arFields['RECALC'] = $boolRecalc === true;
     foreach (GetModuleEvents("catalog", "OnBeforePriceAdd", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array(&$arFields));
     }
     if (!CPrice::CheckFields("ADD", $arFields, 0)) {
         return false;
     }
     if (isset($arFields['RECALC']) && $arFields['RECALC'] === true) {
         CPrice::ReCountFromBase($arFields, $boolBase);
         if (!$boolBase && $arFields['EXTRA_ID'] <= 0) {
             return false;
         }
     }
     $arInsert = $DB->PrepareInsert("b_catalog_price", $arFields);
     $strSql = "INSERT INTO b_catalog_price(" . $arInsert[0] . ") VALUES(" . $arInsert[1] . ")";
     $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     $ID = (int) $DB->LastID();
     if ($ID > 0 && $boolBase) {
         CPrice::ReCountForBase($arFields);
     }
     foreach (GetModuleEvents("catalog", "OnPriceAdd", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID, $arFields));
     }
     // strange copy-paste bug
     foreach (GetModuleEvents("sale", "OnPriceAdd", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID, $arFields));
     }
     return $ID;
 }
コード例 #19
0
 public static function GetNotifySchema()
 {
     if (is_null(self::$arNotifySchema)) {
         self::$arNotifySchema = array();
         foreach (GetModuleEvents("im", "OnGetNotifySchema", true) as $arEvent) {
             $ar = ExecuteModuleEventEx($arEvent);
             if (is_array($ar)) {
                 foreach ($ar as $moduleId => $arNotifyType) {
                     self::$arNotifySchema[$moduleId]['NAME'] = isset($arNotifyType['NOTIFY']) && isset($arNotifyType['NAME']) ? $arNotifyType['NAME'] : '';
                     $arNotify = $arNotifyType;
                     if (isset($arNotifyType['NOTIFY'])) {
                         $arNotify = $arNotifyType['NOTIFY'];
                     }
                     foreach ($arNotify as $notifyEvent => $arConfig) {
                         $arConfig['SITE'] = true;
                         $arConfig['MAIL'] = true;
                         $arConfig['XMPP'] = true;
                         self::$arNotifySchema[$moduleId]['NOTIFY'][$notifyEvent] = $arConfig;
                     }
                 }
             }
         }
     }
     return self::$arNotifySchema;
 }
コード例 #20
0
ファイル: schema.php プロジェクト: rasuldev/torino
 public function Init()
 {
     if (!isset($this->data_relations)) {
         $this->data_relations = array();
         foreach (GetModuleEvents("perfmon", "OnGetTableSchema", true) as $arEvent) {
             $arModuleSchema = ExecuteModuleEventEx($arEvent);
             if (is_array($arModuleSchema)) {
                 foreach ($arModuleSchema as $module_id => $arModuleTables) {
                     if (!array_key_exists($module_id, $this->data_relations)) {
                         $this->data_relations[$module_id] = array();
                     }
                     foreach ($arModuleTables as $parent_table_name => $arParentColumns) {
                         if (!array_key_exists($parent_table_name, $this->data_relations[$module_id])) {
                             $this->data_relations[$module_id][$parent_table_name] = array();
                         }
                         foreach ($arParentColumns as $parent_column => $arChildren) {
                             if (!array_key_exists($parent_column, $this->data_relations[$module_id][$parent_table_name])) {
                                 $this->data_relations[$module_id][$parent_table_name][$parent_column] = array();
                             }
                             foreach ($arChildren as $child_table_name => $child_column) {
                                 $this->data_relations[$module_id][$parent_table_name][$parent_column][$child_table_name] = $child_column;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #21
0
ファイル: price.php プロジェクト: k-kalashnikov/geekcon_new
 function Add($arFields, $boolRecalc = false)
 {
     global $DB;
     if (!CPrice::CheckFields("ADD", $arFields, 0)) {
         return false;
     }
     $boolBase = false;
     $arFields['RECALC'] = $boolRecalc === true ? true : false;
     $events = GetModuleEvents("catalog", "OnBeforePriceAdd");
     while ($arEvent = $events->Fetch()) {
         ExecuteModuleEventEx($arEvent, array(&$arFields));
     }
     if (!empty($arFields['RECALC']) && $arFields['RECALC'] === true) {
         CPrice::ReCountFromBase($arFields, $boolBase);
     }
     $arInsert = $DB->PrepareInsert("b_catalog_price", $arFields);
     $strSql = "INSERT INTO b_catalog_price(" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")";
     $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     $ID = IntVal($DB->LastID());
     if ($ID > 0 && $boolBase == true) {
         CPrice::ReCountForBase($arFields);
     }
     $events = GetModuleEvents("catalog", "OnPriceAdd");
     while ($arEvent = $events->Fetch()) {
         ExecuteModuleEventEx($arEvent, array($ID, $arFields));
     }
     // strange copy-paste bug
     $events = GetModuleEvents("sale", "OnPriceAdd");
     while ($arEvent = $events->Fetch()) {
         ExecuteModuleEventEx($arEvent, array($ID, $arFields));
     }
     return $ID;
 }
コード例 #22
0
 public static function GetNotifySchema()
 {
     if (is_null(self::$arNotifySchema)) {
         self::$arNotifySchema = array();
         foreach (GetModuleEvents("im", "OnGetNotifySchema", true) as $arEvent) {
             $ar = ExecuteModuleEventEx($arEvent);
             if (is_array($ar)) {
                 foreach ($ar as $moduleId => $arNotifyType) {
                     self::$arNotifySchema[$moduleId]['NAME'] = isset($arNotifyType['NOTIFY']) && isset($arNotifyType['NAME']) ? $arNotifyType['NAME'] : '';
                     $arNotify = $arNotifyType;
                     if (isset($arNotifyType['NOTIFY'])) {
                         $arNotify = $arNotifyType['NOTIFY'];
                     }
                     foreach ($arNotify as $notifyEvent => $arConfig) {
                         if (!isset($arConfig['PUSH']) || $arConfig['PUSH'] == 'NONE') {
                             $arConfig['DISABLED'][] = IM_NOTIFY_FEATURE_PUSH;
                         }
                         $arConfig['SITE'] = !isset($arConfig['SITE']) || $arConfig['SITE'] == 'Y' ? true : false;
                         $arConfig['MAIL'] = !isset($arConfig['MAIL']) || $arConfig['MAIL'] == 'Y' ? true : false;
                         $arConfig['XMPP'] = !isset($arConfig['XMPP']) || $arConfig['XMPP'] == 'Y' ? true : false;
                         $arConfig['PUSH'] = isset($arConfig['PUSH']) && $arConfig['PUSH'] == 'Y' ? true : false;
                         $arDisabled['SITE'] = isset($arConfig['DISABLED']) && in_array(IM_NOTIFY_FEATURE_SITE, $arConfig['DISABLED']) ? true : false;
                         $arDisabled['MAIL'] = isset($arConfig['DISABLED']) && in_array(IM_NOTIFY_FEATURE_MAIL, $arConfig['DISABLED']) ? true : false;
                         $arDisabled['XMPP'] = isset($arConfig['DISABLED']) && in_array(IM_NOTIFY_FEATURE_XMPP, $arConfig['DISABLED']) ? true : false;
                         $arDisabled['PUSH'] = isset($arConfig['DISABLED']) && in_array(IM_NOTIFY_FEATURE_PUSH, $arConfig['DISABLED']) ? true : false;
                         $arConfig['DISABLED'] = $arDisabled;
                         $arConfig['LIFETIME'] = intval($arConfig['LIFETIME']);
                         self::$arNotifySchema[$moduleId]['NOTIFY'][$notifyEvent] = $arConfig;
                     }
                 }
             }
         }
     }
     return self::$arNotifySchema;
 }
コード例 #23
0
ファイル: manager.php プロジェクト: Satariall/izurit
 public static function initClassesList()
 {
     if (static::$classes !== null) {
         return true;
     }
     $classes = array('\\Bitrix\\Sale\\Delivery\\ExtraServices\\Enum' => 'lib/delivery/extra_services/enum.php', '\\Bitrix\\Sale\\Delivery\\ExtraServices\\Store' => 'lib/delivery/extra_services/store.php', '\\Bitrix\\Sale\\Delivery\\ExtraServices\\String' => 'lib/delivery/extra_services/string.php', '\\Bitrix\\Sale\\Delivery\\ExtraServices\\Checkbox' => 'lib/delivery/extra_services/checkbox.php');
     \Bitrix\Main\Loader::registerAutoLoadClasses('sale', $classes);
     unset($classes['\\Bitrix\\Sale\\Delivery\\ExtraServices\\Store']);
     static::$classes = array_keys($classes);
     foreach (GetModuleEvents("sale", "onSaleDeliveryExtraServicesClassesCustom", true) as $arHandler) {
         $classes = ExecuteModuleEventEx($arHandler);
         if (!is_array($classes)) {
             throw new SystemException('Handler of onSaleDeliveryExtraServicesClassesCustom must return Bitrix\\Sale\\Delivery\\ExtraServices\\Base[]');
         }
         foreach ($classes as $class) {
             if (!class_exists($class)) {
                 throw new SystemException('onSaleDeliveryExtraServicesClassesCustom class doesn\'t exist: "' . $class . '"');
             }
             if (in_array($class, static::$classes)) {
                 throw new SystemException('onSaleDeliveryExtraServicesClassesCustom class with such name alredy exists: "' . $class . '"');
             }
             static::$classes[] = $class;
         }
     }
     return true;
 }
コード例 #24
0
ファイル: short_uri.php プロジェクト: ASDAFF/open_bx
	public static function Add($arFields)
	{
		global $DB;

		self::ClearErrors();

		if (!self::ParseFields($arFields))
			return false;

		$arInsert = $DB->PrepareInsert("b_short_uri", $arFields);

		$strSql =
			"INSERT INTO b_short_uri (".$arInsert[0].", MODIFIED) ".
			"VALUES(".$arInsert[1].", ".$DB->CurrentTimeFunction().")";
		$DB->Query($strSql, False, "File: ".__FILE__."<br>Line: ".__LINE__);

		$taskId = intval($DB->LastID());

		$arFields["ID"] = $taskId;

		foreach (GetModuleEvents("main", "OnAfterShortUriAdd", true) as $arEvent)
			ExecuteModuleEventEx($arEvent, array($arFields));

		return $taskId;
	}
コード例 #25
0
ファイル: partner_modules.php プロジェクト: ASDAFF/open_bx
function OnModuleInstalledEvent($id, $installed, $Module)
{
	foreach(GetModuleEvents("main", "OnModuleInstalled", true) as $arEvent)
	{
		ExecuteModuleEventEx($arEvent, array($id, $installed));
	}

	$cModules = COption::GetOptionString("main", "mp_modules_date", "");
	$arModules = array();
	if(strlen($cModules) > 0)
		$arModules = unserialize($cModules);

	if($installed == "Y")
	{
		$arModules[] = array("ID" => $id, "NAME" => htmlspecialcharsbx($Module->MODULE_NAME), "TMS" => time());
		if(count($arModules) > 3)
			$arModules = array_slice($arModules, -3);

		COption::SetOptionString("main", "mp_modules_date", serialize($arModules));
	}
	else
	{
		foreach($arModules as $arid => $val)
		{
			if($val["ID"] == $id)
				unset($arModules[$arid]);
		}
		if(count($arModules) > 0)
			COption::SetOptionString("main", "mp_modules_date", serialize($arModules));
		else
			COption::RemoveOption("main", "mp_modules_date");

		$_SESSION["MP_MOD_DELETED"] = array("ID" => $id, "NAME" => $Module->MODULE_NAME);
	}
}
コード例 #26
0
ファイル: interface.php プロジェクト: ASDAFF/bxApiDocs
	static public function buildMenu($arParams)
	{
		if (!empty(self::$arItems))
			return self::$arItems;

		if (isset($arParams["MENU_FILE"]))
		{
			$arMobileMenuItems = array();

			require($_SERVER["DOCUMENT_ROOT"] . $arParams["MENU_FILE"]);

			if (!empty($arMobileMenuItems))
				foreach ($arMobileMenuItems as $arItem)
					self::addItem($arItem);
		}

		if (isset($arParams["EVENT_NAME"]))
		{
			foreach (GetModuleEvents("mobileapp", $arParams["EVENT_NAME"], true) as $arHandler)
				ExecuteModuleEventEx($arHandler);
		}

		CAdminMobilePush::OnAdminMobileGetPushSettings();

		sortByColumn(self::$arItems, "sort");

		return self::$arItems;
	}
コード例 #27
0
ファイル: user.php プロジェクト: ASDAFF/bxApiDocs
	public static function CheckCurrentUserGroups()
	{
		global $USER;
		$user_id = is_object($USER)? intval($USER->GetID()): 0;

		if($user_id > 0)
		{
			$arGroupCodes = array('AU', 'U'.$user_id); // Authorized
			foreach($USER->GetUserGroupArray() as $group_id)
			{
				$arGroupCodes[] = 'G'.$group_id;
			}

			foreach (GetModuleEvents("search", "OnSearchCheckPermissions", true) as $arEvent)
			{
				$arCodes = ExecuteModuleEventEx($arEvent, array(null));
				if(is_array($arCodes))
				{
					$arGroupCodes = array_merge($arGroupCodes, $arCodes);
				}
			}

			$ob = new CSearchUser($user_id);
			$ob->SetGroups($arGroupCodes);
		}
	}
コード例 #28
0
ファイル: taskservice.php プロジェクト: DarneoStudio/bitrix
 public static function Update($id, $arFields)
 {
     global $DB;
     $id = intval($id);
     if ($id <= 0) {
         throw new Exception("id");
     }
     self::ParseFields($arFields, $id);
     $strUpdate = $DB->PrepareUpdate("b_bp_task", $arFields);
     $strSql = "UPDATE b_bp_task SET " . "\t" . $strUpdate . ", " . "\tMODIFIED = " . $DB->CurrentTimeFunction() . " " . "WHERE ID = " . intval($id) . " ";
     $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     $removedUsers = array();
     if (is_set($arFields, "USERS")) {
         $dbResUser = $DB->Query("SELECT USER_ID FROM b_bp_task_user WHERE TASK_ID = " . intval($id) . " ");
         while ($arResUser = $dbResUser->Fetch()) {
             CUserCounter::Decrement($arResUser["USER_ID"], 'bp_tasks', '**');
             $removedUsers[] = $arResUser["USER_ID"];
         }
         $DB->Query("DELETE FROM b_bp_task_user WHERE TASK_ID = " . intval($id) . " ");
         $ar = array();
         foreach ($arFields["USERS"] as $userId) {
             $userId = intval($userId);
             if (in_array($userId, $ar)) {
                 continue;
             }
             $DB->Query("INSERT INTO b_bp_task_user (USER_ID, TASK_ID, ORIGINAL_USER_ID) " . "VALUES (" . intval($userId) . ", " . intval($id) . ", " . intval($userId) . ") ");
             CUserCounter::Increment($userId, 'bp_tasks', '**');
             $ar[] = $userId;
         }
     }
     $userStatuses = array();
     if (isset($arFields['STATUS']) && $arFields['STATUS'] > CBPTaskStatus::Running) {
         $dbResUser = $DB->Query("SELECT USER_ID FROM b_bp_task_user WHERE TASK_ID = " . $id . " AND STATUS = " . CBPTaskUserStatus::Waiting);
         while ($arResUser = $dbResUser->Fetch()) {
             CUserCounter::Decrement($arResUser["USER_ID"], 'bp_tasks', '**');
             if ($arFields['STATUS'] == CBPTaskStatus::Timeout) {
                 $userStatuses[$arResUser["USER_ID"]] = CBPTaskUserStatus::No;
             } else {
                 $removedUsers[] = $arResUser["USER_ID"];
             }
         }
         if ($arFields['STATUS'] == CBPTaskStatus::Timeout) {
             $DB->Query("UPDATE b_bp_task_user SET STATUS = " . CBPTaskUserStatus::No . ", DATE_UPDATE = " . $DB->CurrentTimeFunction() . " WHERE TASK_ID = " . $id . " AND STATUS = " . CBPTaskUserStatus::Waiting);
         } else {
             $DB->Query("DELETE FROM b_bp_task_user WHERE TASK_ID = " . $id . " AND STATUS = " . CBPTaskUserStatus::Waiting);
         }
     }
     foreach (GetModuleEvents("bizproc", "OnTaskUpdate", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($id, $arFields));
     }
     if ($removedUsers) {
         $arFields['USERS_REMOVED'] = $removedUsers;
     }
     if ($userStatuses) {
         $arFields['USERS_STATUSES'] = $userStatuses;
     }
     self::onTaskChange($id, $arFields, CBPTaskChangedStatus::Update);
     return $id;
 }
コード例 #29
0
ファイル: event_log.php プロジェクト: DarneoStudio/bitrix
 function GetAuditTypes()
 {
     AddEventHandler("main", "GetAuditTypesForum", array("CForumEventLog", "GetAuditTypes"));
     foreach (GetModuleEvents("main", "GetAuditTypesForum", true) as $arEvent) {
         $AuditTypes = ExecuteModuleEventEx($arEvent);
     }
     return $AuditTypes;
 }
コード例 #30
0
ファイル: taskcomments.php プロジェクト: DarneoStudio/bitrix
 public static function fireOnAfterCommentAddEvent($commentId, $taskId, $commentText, $arFilesIds, $urlPreviewId)
 {
     $arFields = array('TASK_ID' => $taskId, 'COMMENT_TEXT' => $commentText, 'FILES' => $arFilesIds, 'URL_PREVIEW' => $urlPreviewId);
     self::addFilesRights($taskId, $arFilesIds);
     foreach (GetModuleEvents('tasks', 'OnAfterCommentAdd', true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($commentId, &$arFields));
     }
 }