Пример #1
0
 public static function migrateData()
 {
     $res = \CUserOptions::getList(array(), array("CATEGORY" => "socialnetwork", "NAME" => "log_destination"));
     while ($option = $res->fetch()) {
         if (!empty($option["VALUE"])) {
             $optionValue = unserialize($option["VALUE"]);
             if (is_array($optionValue)) {
                 foreach ($optionValue as $key => $val) {
                     if (in_array($key, array("users", "sonetgroups", "department", "companies", "contacts", "leads", "deals"))) {
                         $codes = \CUtil::jsObjectToPhp($val);
                         if (is_array($codes)) {
                             \Bitrix\Main\FinderDestTable::merge(array("USER_ID" => $option["USER_ID"], "CONTEXT" => "blog_post", "CODE" => array_keys($codes)));
                         }
                     }
                 }
             }
         }
     }
     $res = \CUserOptions::getList(array(), array("CATEGORY" => "crm", "NAME" => "log_destination"));
     while ($option = $res->fetch()) {
         if (!empty($option["VALUE"])) {
             $optionValue = unserialize($option["VALUE"]);
             if (is_array($optionValue)) {
                 foreach ($optionValue as $key => $val) {
                     $codes = explode(',', $val);
                     if (is_array($codes)) {
                         \Bitrix\Main\FinderDestTable::merge(array("USER_ID" => $option["USER_ID"], "CONTEXT" => "crm_post", "CODE" => $codes));
                     }
                 }
             }
         }
     }
 }